aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-03-26 18:23:24 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-26 18:23:24 -0400
commit08abe18af1f78ee80c3c3a5ac47c3e0ae0beadf6 (patch)
tree2be39bf8942edca1bcec735145e144a682ca9cd3 /drivers
parentf0de70f8bb56952f6e016a65a8a8d006918f5bf6 (diff)
parent0384e2959127a56d0640505d004d8dd92f9c29f5 (diff)
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Conflicts: drivers/net/wimax/i2400m/usb-notif.c
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/bus.c9
-rw-r--r--drivers/acpi/dock.c2
-rw-r--r--drivers/acpi/numa.c2
-rw-r--r--drivers/acpi/osl.c50
-rw-r--r--drivers/acpi/sleep.c16
-rw-r--r--drivers/amba/bus.c4
-rw-r--r--drivers/ata/ahci.c55
-rw-r--r--drivers/ata/ata_generic.c4
-rw-r--r--drivers/ata/ata_piix.c97
-rw-r--r--drivers/ata/libata-core.c28
-rw-r--r--drivers/ata/libata-eh.c26
-rw-r--r--drivers/ata/libata-sff.c97
-rw-r--r--drivers/ata/libata.h2
-rw-r--r--drivers/ata/pata_acpi.c6
-rw-r--r--drivers/ata/pata_ali.c28
-rw-r--r--drivers/ata/pata_amd.c70
-rw-r--r--drivers/ata/pata_artop.c49
-rw-r--r--drivers/ata/pata_at32.c4
-rw-r--r--drivers/ata/pata_atiixp.c6
-rw-r--r--drivers/ata/pata_bf54x.c2
-rw-r--r--drivers/ata/pata_cmd640.c2
-rw-r--r--drivers/ata/pata_cmd64x.c24
-rw-r--r--drivers/ata/pata_cs5520.c2
-rw-r--r--drivers/ata/pata_cs5530.c8
-rw-r--r--drivers/ata/pata_cs5535.c4
-rw-r--r--drivers/ata/pata_cs5536.c4
-rw-r--r--drivers/ata/pata_cypress.c4
-rw-r--r--drivers/ata/pata_efar.c6
-rw-r--r--drivers/ata/pata_hpt366.c4
-rw-r--r--drivers/ata/pata_hpt37x.c28
-rw-r--r--drivers/ata/pata_hpt3x2n.c4
-rw-r--r--drivers/ata/pata_hpt3x3.c6
-rw-r--r--drivers/ata/pata_icside.c4
-rw-r--r--drivers/ata/pata_isapnp.c14
-rw-r--r--drivers/ata/pata_it8213.c4
-rw-r--r--drivers/ata/pata_it821x.c16
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c2
-rw-r--r--drivers/ata/pata_jmicron.c4
-rw-r--r--drivers/ata/pata_legacy.c2
-rw-r--r--drivers/ata/pata_marvell.c8
-rw-r--r--drivers/ata/pata_mpc52xx.c4
-rw-r--r--drivers/ata/pata_mpiix.c2
-rw-r--r--drivers/ata/pata_netcell.c4
-rw-r--r--drivers/ata/pata_ninja32.c2
-rw-r--r--drivers/ata/pata_ns87410.c2
-rw-r--r--drivers/ata/pata_ns87415.c8
-rw-r--r--drivers/ata/pata_octeon_cf.c4
-rw-r--r--drivers/ata/pata_oldpiix.c4
-rw-r--r--drivers/ata/pata_opti.c2
-rw-r--r--drivers/ata/pata_optidma.c10
-rw-r--r--drivers/ata/pata_pcmcia.c36
-rw-r--r--drivers/ata/pata_pdc2027x.c12
-rw-r--r--drivers/ata/pata_pdc202xx_old.c12
-rw-r--r--drivers/ata/pata_qdi.c4
-rw-r--r--drivers/ata/pata_radisys.c6
-rw-r--r--drivers/ata/pata_rb532_cf.c64
-rw-r--r--drivers/ata/pata_rz1000.c2
-rw-r--r--drivers/ata/pata_sc1200.c35
-rw-r--r--drivers/ata/pata_scc.c4
-rw-r--r--drivers/ata/pata_sch.c6
-rw-r--r--drivers/ata/pata_serverworks.c20
-rw-r--r--drivers/ata/pata_sil680.c8
-rw-r--r--drivers/ata/pata_sis.c32
-rw-r--r--drivers/ata/pata_sl82c105.c6
-rw-r--r--drivers/ata/pata_triflex.c4
-rw-r--r--drivers/ata/pata_via.c24
-rw-r--r--drivers/ata/pata_winbond.c2
-rw-r--r--drivers/ata/pdc_adma.c4
-rw-r--r--drivers/ata/sata_fsl.c4
-rw-r--r--drivers/ata/sata_inic162x.c4
-rw-r--r--drivers/ata/sata_mv.c871
-rw-r--r--drivers/ata/sata_nv.c9
-rw-r--r--drivers/ata/sata_promise.c30
-rw-r--r--drivers/ata/sata_qstor.c3
-rw-r--r--drivers/ata/sata_sil.c16
-rw-r--r--drivers/ata/sata_sil24.c18
-rw-r--r--drivers/ata/sata_sis.c4
-rw-r--r--drivers/ata/sata_svw.c16
-rw-r--r--drivers/ata/sata_sx4.c4
-rw-r--r--drivers/ata/sata_uli.c2
-rw-r--r--drivers/ata/sata_via.c16
-rw-r--r--drivers/ata/sata_vsc.c7
-rw-r--r--drivers/base/base.h31
-rw-r--r--drivers/base/bus.c44
-rw-r--r--drivers/base/core.c108
-rw-r--r--drivers/base/dd.c40
-rw-r--r--drivers/base/driver.c15
-rw-r--r--drivers/base/firmware_class.c4
-rw-r--r--drivers/base/node.c2
-rw-r--r--drivers/base/platform.c60
-rw-r--r--drivers/base/power/main.c44
-rw-r--r--drivers/base/power/power.h8
-rw-r--r--drivers/base/sys.c54
-rw-r--r--drivers/block/Makefile1
-rw-r--r--drivers/block/cciss.c8
-rw-r--r--drivers/block/floppy.c3
-rw-r--r--drivers/block/loop.c3
-rw-r--r--drivers/block/ps3vram.c865
-rw-r--r--drivers/block/ub.c11
-rw-r--r--drivers/block/xen-blkfront.c2
-rw-r--r--drivers/block/xsysace.c22
-rw-r--r--drivers/char/agp/amd64-agp.c13
-rw-r--r--drivers/char/agp/intel-agp.c8
-rw-r--r--drivers/char/agp/parisc-agp.c23
-rw-r--r--drivers/char/hvcs.c9
-rw-r--r--drivers/char/hvsi.c1
-rw-r--r--drivers/char/hw_random/Kconfig14
-rw-r--r--drivers/char/hw_random/Makefile1
-rw-r--r--drivers/char/hw_random/timeriomem-rng.c151
-rw-r--r--drivers/char/tpm/tpm.c530
-rw-r--r--drivers/char/tpm/tpm.h142
-rw-r--r--drivers/char/tpm/tpm_atmel.c28
-rw-r--r--drivers/char/tpm/tpm_tis.c28
-rw-r--r--drivers/char/vc_screen.c16
-rw-r--r--drivers/char/vt.c5
-rw-r--r--drivers/clocksource/Makefile1
-rw-r--r--drivers/clocksource/sh_cmt.c615
-rw-r--r--drivers/cpufreq/cpufreq.c106
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c404
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c74
-rw-r--r--drivers/cpufreq/cpufreq_stats.c74
-rw-r--r--drivers/cpufreq/cpufreq_userspace.c27
-rw-r--r--drivers/cpufreq/freq_table.c18
-rw-r--r--drivers/crypto/Kconfig15
-rw-r--r--drivers/crypto/Makefile1
-rw-r--r--drivers/crypto/amcc/Makefile2
-rw-r--r--drivers/crypto/amcc/crypto4xx_alg.c293
-rw-r--r--drivers/crypto/amcc/crypto4xx_core.c1310
-rw-r--r--drivers/crypto/amcc/crypto4xx_core.h177
-rw-r--r--drivers/crypto/amcc/crypto4xx_reg_def.h284
-rw-r--r--drivers/crypto/amcc/crypto4xx_sa.c108
-rw-r--r--drivers/crypto/amcc/crypto4xx_sa.h243
-rw-r--r--drivers/dca/dca-core.c2
-rw-r--r--drivers/dio/dio.c4
-rw-r--r--drivers/dma/dmatest.c6
-rw-r--r--drivers/dma/dw_dmac.c2
-rw-r--r--drivers/dma/fsldma.c8
-rw-r--r--drivers/dma/ioat.c2
-rw-r--r--drivers/dma/ioat_dca.c26
-rw-r--r--drivers/dma/ioat_dma.c39
-rw-r--r--drivers/dma/ioatdma.h8
-rw-r--r--drivers/dma/ioatdma_hw.h2
-rw-r--r--drivers/dma/ioatdma_registers.h2
-rw-r--r--drivers/dma/iop-adma.c16
-rw-r--r--drivers/dma/ipu/ipu_idmac.c2
-rw-r--r--drivers/dma/mv_xor.c16
-rw-r--r--drivers/edac/cell_edac.c2
-rw-r--r--drivers/edac/mpc85xx_edac.c2
-rw-r--r--drivers/edac/mv64x60_edac.c8
-rw-r--r--drivers/eisa/eisa-bus.c4
-rw-r--r--drivers/gpio/bt8xxgpio.c2
-rw-r--r--drivers/gpu/drm/drm_sysfs.c4
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c2
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h7
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c115
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/i915_suspend.c11
-rw-r--r--drivers/hid/usbhid/hiddev.c4
-rw-r--r--drivers/hwmon/Kconfig4
-rw-r--r--drivers/hwmon/abituguru3.c7
-rw-r--r--drivers/hwmon/f75375s.c2
-rw-r--r--drivers/hwmon/it87.c8
-rw-r--r--drivers/hwmon/lm85.c8
-rw-r--r--drivers/hwmon/lm90.c8
-rw-r--r--drivers/i2c/i2c-core.c2
-rw-r--r--drivers/ide/Kconfig13
-rw-r--r--drivers/ide/Makefile5
-rw-r--r--drivers/ide/aec62xx.c4
-rw-r--r--drivers/ide/alim15x3.c2
-rw-r--r--drivers/ide/amd74xx.c14
-rw-r--r--drivers/ide/at91_ide.c467
-rw-r--r--drivers/ide/atiixp.c3
-rw-r--r--drivers/ide/au1xxx-ide.c36
-rw-r--r--drivers/ide/cmd64x.c2
-rw-r--r--drivers/ide/cs5520.c3
-rw-r--r--drivers/ide/cs5530.c2
-rw-r--r--drivers/ide/delkin_cb.c2
-rw-r--r--drivers/ide/hpt366.c4
-rw-r--r--drivers/ide/ide-acpi.c214
-rw-r--r--drivers/ide/ide-atapi.c53
-rw-r--r--drivers/ide/ide-cd.c4
-rw-r--r--drivers/ide/ide-devsets.c190
-rw-r--r--drivers/ide/ide-disk_proc.c2
-rw-r--r--drivers/ide/ide-dma.c69
-rw-r--r--drivers/ide/ide-eh.c428
-rw-r--r--drivers/ide/ide-floppy.c6
-rw-r--r--drivers/ide/ide-floppy_proc.c2
-rw-r--r--drivers/ide/ide-io-std.c316
-rw-r--r--drivers/ide/ide-io.c323
-rw-r--r--drivers/ide/ide-iops.c740
-rw-r--r--drivers/ide/ide-lib.c240
-rw-r--r--drivers/ide/ide-park.c25
-rw-r--r--drivers/ide/ide-pci-generic.c4
-rw-r--r--drivers/ide/ide-probe.c262
-rw-r--r--drivers/ide/ide-proc.c4
-rw-r--r--drivers/ide/ide-tape.c2
-rw-r--r--drivers/ide/ide-xfer-mode.c246
-rw-r--r--drivers/ide/ide.c156
-rw-r--r--drivers/ide/it821x.c2
-rw-r--r--drivers/ide/ns87415.c4
-rw-r--r--drivers/ide/pdc202xx_new.c4
-rw-r--r--drivers/ide/pdc202xx_old.c4
-rw-r--r--drivers/ide/piix.c13
-rw-r--r--drivers/ide/serverworks.c13
-rw-r--r--drivers/ide/setup-pci.c27
-rw-r--r--drivers/ide/siimage.c2
-rw-r--r--drivers/ide/sis5513.c4
-rw-r--r--drivers/ide/sl82c105.c4
-rw-r--r--drivers/ide/slc90e66.c1
-rw-r--r--drivers/ide/trm290.c3
-rw-r--r--drivers/ide/via82cxxx.c12
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c39
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c2
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.h1
-rw-r--r--drivers/input/joystick/maplecontrol.c4
-rw-r--r--drivers/input/keyboard/maple_keyb.c37
-rw-r--r--drivers/input/keyboard/sh_keysc.c26
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c3
-rw-r--r--drivers/lguest/lguest_device.c6
-rw-r--r--drivers/mca/mca-bus.c4
-rw-r--r--drivers/md/dm-crypt.c43
-rw-r--r--drivers/md/dm-io.c2
-rw-r--r--drivers/md/dm-ioctl.c7
-rw-r--r--drivers/md/dm.c32
-rw-r--r--drivers/md/md.c30
-rw-r--r--drivers/media/dvb/bt8xx/dst.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c7
-rw-r--r--drivers/media/dvb/frontends/stb0899_algo.c14
-rw-r--r--drivers/media/dvb/frontends/stb0899_drv.c2
-rw-r--r--drivers/media/dvb/frontends/stb0899_priv.h12
-rw-r--r--drivers/media/dvb/frontends/stb6100.c4
-rw-r--r--drivers/media/dvb/frontends/zl10353.c2
-rw-r--r--drivers/media/dvb/frontends/zl10353.h3
-rw-r--r--drivers/media/radio/radio-tea5764.c3
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c7
-rw-r--r--drivers/media/video/em28xx/em28xx-audio.c7
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k4aa.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c8
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c1
-rw-r--r--drivers/media/video/tvaudio.c2
-rw-r--r--drivers/media/video/v4l2-device.c2
-rw-r--r--drivers/media/video/zoran/Kconfig1
-rw-r--r--drivers/mfd/mcp-core.c2
-rw-r--r--drivers/mfd/ucb1x00-core.c2
-rw-r--r--drivers/mfd/wm8350-core.c5
-rw-r--r--drivers/mmc/core/mmc_ops.c15
-rw-r--r--drivers/mmc/host/atmel-mci.c2
-rw-r--r--drivers/mmc/host/of_mmc_spi.c2
-rw-r--r--drivers/mmc/host/s3cmci.c3
-rw-r--r--drivers/mtd/devices/Kconfig7
-rw-r--r--drivers/mtd/devices/Makefile1
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c3
-rw-r--r--drivers/mtd/devices/ps3vram.c768
-rw-r--r--drivers/mtd/maps/Kconfig12
-rw-r--r--drivers/mtd/maps/Makefile1
-rw-r--r--drivers/mtd/maps/physmap.c19
-rw-r--r--drivers/mtd/maps/pxa2xx-flash.c37
-rw-r--r--drivers/mtd/maps/vmu-flash.c832
-rw-r--r--drivers/mtd/nand/excite_nandflash.c25
-rw-r--r--drivers/mtd/nand/ndfc.c2
-rw-r--r--drivers/mtd/onenand/generic.c26
-rw-r--r--drivers/net/mipsnet.c26
-rw-r--r--drivers/net/sunhme.c2
-rw-r--r--drivers/parisc/dino.c13
-rw-r--r--drivers/parisc/gsc.c39
-rw-r--r--drivers/parisc/iosapic.c16
-rw-r--r--drivers/parisc/lba_pci.c4
-rw-r--r--drivers/parisc/sba_iommu.c63
-rw-r--r--drivers/pci/hotplug/Kconfig2
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c3
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c3
-rw-r--r--drivers/pci/pcie/portdrv_pci.c1
-rw-r--r--drivers/pci/quirks.c31
-rw-r--r--drivers/pcmcia/au1000_generic.c37
-rw-r--r--drivers/pcmcia/i82365.c28
-rw-r--r--drivers/pcmcia/m32r_cfc.c30
-rw-r--r--drivers/pcmcia/m32r_pcc.c30
-rw-r--r--drivers/pcmcia/rsrc_mgr.c2
-rw-r--r--drivers/pcmcia/sa1100_generic.c38
-rw-r--r--drivers/pcmcia/tcic.c30
-rw-r--r--drivers/pcmcia/vrc4171_card.c34
-rw-r--r--drivers/platform/x86/Kconfig14
-rw-r--r--drivers/platform/x86/acer-wmi.c4
-rw-r--r--drivers/platform/x86/asus-laptop.c5
-rw-r--r--drivers/platform/x86/eeepc-laptop.c6
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c8
-rw-r--r--drivers/platform/x86/wmi.c2
-rw-r--r--drivers/power/ds2760_battery.c11
-rw-r--r--drivers/rapidio/rio-driver.c2
-rw-r--r--drivers/rtc/rtc-at91sam9.c4
-rw-r--r--drivers/rtc/rtc-omap.c4
-rw-r--r--drivers/rtc/rtc-sh.c246
-rw-r--r--drivers/rtc/rtc-twl4030.c2
-rw-r--r--drivers/s390/cio/ccwgroup.c5
-rw-r--r--drivers/s390/cio/chsc_sch.c4
-rw-r--r--drivers/s390/cio/css.c4
-rw-r--r--drivers/s390/cio/device.c13
-rw-r--r--drivers/sbus/char/bbc_i2c.c2
-rw-r--r--drivers/sbus/char/jsflash.c3
-rw-r--r--drivers/sbus/char/openprom.c1
-rw-r--r--drivers/scsi/a4000t.c29
-rw-r--r--drivers/scsi/bvme6000_scsi.c29
-rw-r--r--drivers/scsi/fcoe/fc_transport_fcoe.c91
-rw-r--r--drivers/scsi/fcoe/fcoe_sw.c56
-rw-r--r--drivers/scsi/fcoe/libfcoe.c318
-rw-r--r--drivers/scsi/lasi700.c2
-rw-r--r--drivers/scsi/libfc/fc_disc.c63
-rw-r--r--drivers/scsi/libfc/fc_exch.c32
-rw-r--r--drivers/scsi/libfc/fc_fcp.c56
-rw-r--r--drivers/scsi/libfc/fc_lport.c173
-rw-r--r--drivers/scsi/libfc/fc_rport.c197
-rw-r--r--drivers/scsi/mvme16x_scsi.c29
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c9
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c19
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c10
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c6
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/sd.c26
-rw-r--r--drivers/scsi/zalon.c2
-rw-r--r--drivers/serial/sh-sci.c12
-rw-r--r--drivers/serial/sh-sci.h15
-rw-r--r--drivers/serial/sunzilog.c4
-rw-r--r--drivers/sh/intc.c47
-rw-r--r--drivers/sh/maple/maple.c471
-rw-r--r--drivers/sh/superhyway/superhyway.c4
-rw-r--r--drivers/spi/atmel_spi.c8
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c2
-rw-r--r--drivers/spi/omap2_mcspi.c2
-rw-r--r--drivers/spi/omap_uwire.c12
-rw-r--r--drivers/spi/orion_spi.c2
-rw-r--r--drivers/spi/pxa2xx_spi.c4
-rw-r--r--drivers/spi/spi_bfin5xx.c4
-rw-r--r--drivers/spi/spi_gpio.c2
-rw-r--r--drivers/spi/spi_imx.c5
-rw-r--r--drivers/spi/spi_mpc83xx.c4
-rw-r--r--drivers/spi/spi_txx9.c3
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/benet/Kconfig7
-rw-r--r--drivers/staging/benet/MAINTAINERS6
-rw-r--r--drivers/staging/benet/Makefile14
-rw-r--r--drivers/staging/benet/TODO6
-rw-r--r--drivers/staging/benet/asyncmesg.h82
-rw-r--r--drivers/staging/benet/be_cm.h134
-rw-r--r--drivers/staging/benet/be_common.h53
-rw-r--r--drivers/staging/benet/be_ethtool.c348
-rw-r--r--drivers/staging/benet/be_init.c1382
-rw-r--r--drivers/staging/benet/be_int.c863
-rw-r--r--drivers/staging/benet/be_netif.c705
-rw-r--r--drivers/staging/benet/benet.h429
-rw-r--r--drivers/staging/benet/bestatus.h103
-rw-r--r--drivers/staging/benet/cev.h243
-rw-r--r--drivers/staging/benet/cq.c211
-rw-r--r--drivers/staging/benet/descriptors.h71
-rw-r--r--drivers/staging/benet/doorbells.h179
-rw-r--r--drivers/staging/benet/ep.h66
-rw-r--r--drivers/staging/benet/eq.c299
-rw-r--r--drivers/staging/benet/eth.c1273
-rw-r--r--drivers/staging/benet/etx_context.h55
-rw-r--r--drivers/staging/benet/funcobj.c565
-rw-r--r--drivers/staging/benet/fwcmd_common.h222
-rw-r--r--drivers/staging/benet/fwcmd_common_bmap.h717
-rw-r--r--drivers/staging/benet/fwcmd_eth_bmap.h280
-rw-r--r--drivers/staging/benet/fwcmd_hdr_bmap.h54
-rw-r--r--drivers/staging/benet/fwcmd_mcc.h94
-rw-r--r--drivers/staging/benet/fwcmd_opcodes.h244
-rw-r--r--drivers/staging/benet/fwcmd_types_bmap.h29
-rw-r--r--drivers/staging/benet/host_struct.h182
-rw-r--r--drivers/staging/benet/hwlib.h830
-rw-r--r--drivers/staging/benet/mpu.c1364
-rw-r--r--drivers/staging/benet/mpu.h74
-rw-r--r--drivers/staging/benet/mpu_context.h46
-rw-r--r--drivers/staging/benet/pcicfg.h825
-rw-r--r--drivers/staging/benet/post_codes.h111
-rw-r--r--drivers/staging/benet/regmap.h68
-rw-r--r--drivers/staging/go7007/snd-go7007.c7
-rw-r--r--drivers/tc/tc.c8
-rw-r--r--drivers/uio/Kconfig18
-rw-r--r--drivers/uio/Makefile1
-rw-r--r--drivers/uio/uio.c25
-rw-r--r--drivers/uio/uio_aec.c175
-rw-r--r--drivers/usb/Kconfig1
-rw-r--r--drivers/usb/Makefile1
-rw-r--r--drivers/usb/atm/cxacru.c3
-rw-r--r--drivers/usb/class/usblp.c11
-rw-r--r--drivers/usb/class/usbtmc.c4
-rw-r--r--drivers/usb/core/devices.c2
-rw-r--r--drivers/usb/core/devio.c33
-rw-r--r--drivers/usb/core/endpoint.c9
-rw-r--r--drivers/usb/core/hcd.c33
-rw-r--r--drivers/usb/core/hub.c34
-rw-r--r--drivers/usb/core/message.c11
-rw-r--r--drivers/usb/core/quirks.c4
-rw-r--r--drivers/usb/core/sysfs.c4
-rw-r--r--drivers/usb/core/urb.c4
-rw-r--r--drivers/usb/gadget/Kconfig1
-rw-r--r--drivers/usb/gadget/amd5536udc.c2
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c20
-rw-r--r--drivers/usb/gadget/cdc2.c8
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c3
-rw-r--r--drivers/usb/gadget/composite.c13
-rw-r--r--drivers/usb/gadget/dummy_hcd.c4
-rw-r--r--drivers/usb/gadget/epautoconf.c2
-rw-r--r--drivers/usb/gadget/ether.c8
-rw-r--r--drivers/usb/gadget/f_acm.c10
-rw-r--r--drivers/usb/gadget/f_ecm.c16
-rw-r--r--drivers/usb/gadget/f_loopback.c10
-rw-r--r--drivers/usb/gadget/f_obex.c8
-rw-r--r--drivers/usb/gadget/f_phonet.c8
-rw-r--r--drivers/usb/gadget/f_rndis.c12
-rw-r--r--drivers/usb/gadget/f_serial.c4
-rw-r--r--drivers/usb/gadget/f_sourcesink.c56
-rw-r--r--drivers/usb/gadget/f_subset.c14
-rw-r--r--drivers/usb/gadget/file_storage.c22
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.c8
-rw-r--r--drivers/usb/gadget/g_zero.h4
-rw-r--r--drivers/usb/gadget/gmidi.c23
-rw-r--r--drivers/usb/gadget/goku_udc.c8
-rw-r--r--drivers/usb/gadget/imx_udc.c248
-rw-r--r--drivers/usb/gadget/imx_udc.h49
-rw-r--r--drivers/usb/gadget/inode.c4
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c16
-rw-r--r--drivers/usb/gadget/net2280.c16
-rw-r--r--drivers/usb/gadget/printer.c18
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c272
-rw-r--r--drivers/usb/gadget/pxa27x_udc.h10
-rw-r--r--drivers/usb/gadget/serial.c12
-rw-r--r--drivers/usb/gadget/u_serial.c2
-rw-r--r--drivers/usb/gadget/zero.c78
-rw-r--r--drivers/usb/host/Kconfig7
-rw-r--r--drivers/usb/host/ehci-hcd.c36
-rw-r--r--drivers/usb/host/ehci-q.c35
-rw-r--r--drivers/usb/host/ehci-sched.c12
-rw-r--r--drivers/usb/host/ehci.h39
-rw-r--r--drivers/usb/host/fhci-dbg.c2
-rw-r--r--drivers/usb/host/fhci-hcd.c4
-rw-r--r--drivers/usb/host/hwa-hc.c3
-rw-r--r--drivers/usb/host/isp116x-hcd.c2
-rw-r--r--drivers/usb/host/isp116x.h8
-rw-r--r--drivers/usb/host/isp1760-hcd.c25
-rw-r--r--drivers/usb/host/isp1760-hcd.h7
-rw-r--r--drivers/usb/host/isp1760-if.c95
-rw-r--r--drivers/usb/host/ohci-hcd.c5
-rw-r--r--drivers/usb/host/ohci-s3c2410.c6
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c24
-rw-r--r--drivers/usb/host/oxu210hp.h8
-rw-r--r--drivers/usb/host/pci-quirks.c2
-rw-r--r--drivers/usb/host/r8a66597-hcd.c118
-rw-r--r--drivers/usb/host/r8a66597.h2
-rw-r--r--drivers/usb/host/sl811-hcd.c4
-rw-r--r--drivers/usb/host/uhci-debug.c4
-rw-r--r--drivers/usb/host/uhci-hcd.h10
-rw-r--r--drivers/usb/host/uhci-q.c21
-rw-r--r--drivers/usb/image/mdc800.c9
-rw-r--r--drivers/usb/misc/Kconfig39
-rw-r--r--drivers/usb/misc/Makefile4
-rw-r--r--drivers/usb/misc/adutux.c6
-rw-r--r--drivers/usb/misc/ftdi-elan.c6
-rw-r--r--drivers/usb/misc/phidget.c43
-rw-r--r--drivers/usb/misc/phidget.h12
-rw-r--r--drivers/usb/misc/phidgetkit.c740
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c465
-rw-r--r--drivers/usb/misc/phidgetservo.c375
-rw-r--r--drivers/usb/misc/vstusb.c1
-rw-r--r--drivers/usb/mon/mon_bin.c142
-rw-r--r--drivers/usb/musb/Kconfig6
-rw-r--r--drivers/usb/musb/davinci.c63
-rw-r--r--drivers/usb/musb/davinci.h23
-rw-r--r--drivers/usb/musb/musb_core.c2
-rw-r--r--drivers/usb/musb/musb_core.h5
-rw-r--r--drivers/usb/musb/musb_host.c140
-rw-r--r--drivers/usb/musb/musb_virthub.c2
-rw-r--r--drivers/usb/otg/Kconfig10
-rw-r--r--drivers/usb/otg/Makefile1
-rw-r--r--drivers/usb/otg/gpio_vbus.c42
-rw-r--r--drivers/usb/otg/nop-usb-xceiv.c180
-rw-r--r--drivers/usb/otg/twl4030-usb.c73
-rw-r--r--drivers/usb/serial/Kconfig28
-rw-r--r--drivers/usb/serial/Makefile4
-rw-r--r--drivers/usb/serial/ch341.c396
-rw-r--r--drivers/usb/serial/cp210x.c (renamed from drivers/usb/serial/cp2101.c)162
-rw-r--r--drivers/usb/serial/ftdi_sio.c34
-rw-r--r--drivers/usb/serial/ftdi_sio.h20
-rw-r--r--drivers/usb/serial/generic.c9
-rw-r--r--drivers/usb/serial/ipaq.c43
-rw-r--r--drivers/usb/serial/keyspan.c2
-rw-r--r--drivers/usb/serial/opticon.c215
-rw-r--r--drivers/usb/serial/option.c100
-rw-r--r--drivers/usb/serial/qcserial.c147
-rw-r--r--drivers/usb/serial/symbolserial.c399
-rw-r--r--drivers/usb/serial/usb-serial.c20
-rw-r--r--drivers/usb/storage/Kconfig48
-rw-r--r--drivers/usb/storage/Makefile41
-rw-r--r--drivers/usb/storage/alauda.c192
-rw-r--r--drivers/usb/storage/alauda.h100
-rw-r--r--drivers/usb/storage/cypress_atacb.c106
-rw-r--r--drivers/usb/storage/datafab.c104
-rw-r--r--drivers/usb/storage/datafab.h40
-rw-r--r--drivers/usb/storage/freecom.c99
-rw-r--r--drivers/usb/storage/isd200.c97
-rw-r--r--drivers/usb/storage/jumpshot.c103
-rw-r--r--drivers/usb/storage/jumpshot.h39
-rw-r--r--drivers/usb/storage/karma.c100
-rw-r--r--drivers/usb/storage/karma.h7
-rw-r--r--drivers/usb/storage/libusual.c33
-rw-r--r--drivers/usb/storage/onetouch.c94
-rw-r--r--drivers/usb/storage/onetouch.h9
-rw-r--r--drivers/usb/storage/protocol.c3
-rw-r--r--drivers/usb/storage/scsiglue.c8
-rw-r--r--drivers/usb/storage/sddr09.c147
-rw-r--r--drivers/usb/storage/sddr09.h38
-rw-r--r--drivers/usb/storage/sddr55.c99
-rw-r--r--drivers/usb/storage/shuttle_usbat.c202
-rw-r--r--drivers/usb/storage/shuttle_usbat.h123
-rw-r--r--drivers/usb/storage/transport.c10
-rw-r--r--drivers/usb/storage/unusual_alauda.h (renamed from drivers/usb/storage/freecom.h)29
-rw-r--r--drivers/usb/storage/unusual_cypress.h34
-rw-r--r--drivers/usb/storage/unusual_datafab.h98
-rw-r--r--drivers/usb/storage/unusual_devs.h323
-rw-r--r--drivers/usb/storage/unusual_freecom.h (renamed from drivers/usb/storage/cypress_atacb.h)19
-rw-r--r--drivers/usb/storage/unusual_isd200.h57
-rw-r--r--drivers/usb/storage/unusual_jumpshot.h (renamed from drivers/usb/storage/sddr55.h)23
-rw-r--r--drivers/usb/storage/unusual_karma.h (renamed from drivers/usb/storage/isd200.h)21
-rw-r--r--drivers/usb/storage/unusual_onetouch.h36
-rw-r--r--drivers/usb/storage/unusual_sddr09.h56
-rw-r--r--drivers/usb/storage/unusual_sddr55.h44
-rw-r--r--drivers/usb/storage/unusual_usbat.h43
-rw-r--r--drivers/usb/storage/usb.c344
-rw-r--r--drivers/usb/storage/usb.h21
-rw-r--r--drivers/usb/storage/usual-tables.c116
-rw-r--r--drivers/usb/usb-skeleton.c6
-rw-r--r--drivers/usb/wusbcore/cbaf.c3
-rw-r--r--drivers/usb/wusbcore/devconnect.c2
-rw-r--r--drivers/usb/wusbcore/security.c2
-rw-r--r--drivers/usb/wusbcore/wa-xfer.c4
-rw-r--r--drivers/video/aty/aty128fb.c10
-rw-r--r--drivers/video/aty/radeon_pm.c34
-rw-r--r--drivers/video/au1100fb.c31
-rw-r--r--drivers/video/au1200fb.c25
-rw-r--r--drivers/video/i810/i810_main.c5
-rw-r--r--drivers/video/logo/logo_linux_clut224.ppm4428
-rw-r--r--drivers/video/logo/logo_linux_vga16.ppm4339
-rw-r--r--drivers/video/pmag-ba-fb.c17
-rw-r--r--drivers/video/pmagb-b-fb.c17
-rw-r--r--drivers/video/ps3fb.c2
-rw-r--r--drivers/video/pvr2fb.c16
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c72
-rw-r--r--drivers/video/tmiofb.c2
-rw-r--r--drivers/w1/masters/w1-gpio.c2
-rw-r--r--drivers/watchdog/gef_wdt.c2
-rw-r--r--drivers/watchdog/ks8695_wdt.c1
-rw-r--r--drivers/watchdog/orion5x_wdt.c1
-rw-r--r--drivers/watchdog/rc32434_wdt.c168
-rw-r--r--drivers/watchdog/rm9k_wdt.c27
-rw-r--r--drivers/zorro/zorro.c4
556 files changed, 22574 insertions, 24773 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 765fd1c56cd6..bee64b73c919 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -758,8 +758,7 @@ static int __init acpi_bus_init(void)
758 acpi_status status = AE_OK; 758 acpi_status status = AE_OK;
759 extern acpi_status acpi_os_initialize1(void); 759 extern acpi_status acpi_os_initialize1(void);
760 760
761 761 acpi_os_initialize1();
762 status = acpi_os_initialize1();
763 762
764 status = 763 status =
765 acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE); 764 acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE);
@@ -769,12 +768,6 @@ static int __init acpi_bus_init(void)
769 goto error1; 768 goto error1;
770 } 769 }
771 770
772 if (ACPI_FAILURE(status)) {
773 printk(KERN_ERR PREFIX
774 "Unable to initialize ACPI OS objects\n");
775 goto error1;
776 }
777
778 /* 771 /*
779 * ACPI 2.0 requires the EC driver to be loaded and work before 772 * ACPI 2.0 requires the EC driver to be loaded and work before
780 * the EC device is found in the namespace (i.e. before acpi_initialize_objects() 773 * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 35094f230b1e..7af7db1ba8c4 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -977,7 +977,7 @@ static int dock_add(acpi_handle handle)
977 sizeof(struct dock_station *)); 977 sizeof(struct dock_station *));
978 978
979 /* we want the dock device to send uevents */ 979 /* we want the dock device to send uevents */
980 dock_device->dev.uevent_suppress = 0; 980 dev_set_uevent_suppress(&dock_device->dev, 0);
981 981
982 if (is_dock(handle)) 982 if (is_dock(handle))
983 dock_station->flags |= DOCK_IS_DOCK; 983 dock_station->flags |= DOCK_IS_DOCK;
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index c5e292aab0e3..3a0d8ef25c75 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -277,7 +277,7 @@ int acpi_get_node(acpi_handle *handle)
277 int pxm, node = -1; 277 int pxm, node = -1;
278 278
279 pxm = acpi_get_pxm(handle); 279 pxm = acpi_get_pxm(handle);
280 if (pxm >= 0) 280 if (pxm >= 0 && pxm < MAX_PXM_DOMAINS)
281 node = acpi_map_pxm_to_node(pxm); 281 node = acpi_map_pxm_to_node(pxm);
282 282
283 return node; 283 return node;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index b3193ec0a2ef..1e35f342957c 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1317,54 +1317,6 @@ acpi_os_validate_interface (char *interface)
1317 return AE_SUPPORT; 1317 return AE_SUPPORT;
1318} 1318}
1319 1319
1320#ifdef CONFIG_X86
1321
1322struct aml_port_desc {
1323 uint start;
1324 uint end;
1325 char* name;
1326 char warned;
1327};
1328
1329static struct aml_port_desc aml_invalid_port_list[] = {
1330 {0x20, 0x21, "PIC0", 0},
1331 {0xA0, 0xA1, "PIC1", 0},
1332 {0x4D0, 0x4D1, "ELCR", 0}
1333};
1334
1335/*
1336 * valid_aml_io_address()
1337 *
1338 * if valid, return true
1339 * else invalid, warn once, return false
1340 */
1341static bool valid_aml_io_address(uint address, uint length)
1342{
1343 int i;
1344 int entries = sizeof(aml_invalid_port_list) / sizeof(struct aml_port_desc);
1345
1346 for (i = 0; i < entries; ++i) {
1347 if ((address >= aml_invalid_port_list[i].start &&
1348 address <= aml_invalid_port_list[i].end) ||
1349 (address + length >= aml_invalid_port_list[i].start &&
1350 address + length <= aml_invalid_port_list[i].end))
1351 {
1352 if (!aml_invalid_port_list[i].warned)
1353 {
1354 printk(KERN_ERR "ACPI: Denied BIOS AML access"
1355 " to invalid port 0x%x+0x%x (%s)\n",
1356 address, length,
1357 aml_invalid_port_list[i].name);
1358 aml_invalid_port_list[i].warned = 1;
1359 }
1360 return false; /* invalid */
1361 }
1362 }
1363 return true; /* valid */
1364}
1365#else
1366static inline bool valid_aml_io_address(uint address, uint length) { return true; }
1367#endif
1368/****************************************************************************** 1320/******************************************************************************
1369 * 1321 *
1370 * FUNCTION: acpi_os_validate_address 1322 * FUNCTION: acpi_os_validate_address
@@ -1394,8 +1346,6 @@ acpi_os_validate_address (
1394 1346
1395 switch (space_id) { 1347 switch (space_id) {
1396 case ACPI_ADR_SPACE_SYSTEM_IO: 1348 case ACPI_ADR_SPACE_SYSTEM_IO:
1397 if (!valid_aml_io_address(address, length))
1398 return AE_AML_ILLEGAL_ADDRESS;
1399 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 1349 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
1400 /* Only interference checks against SystemIO and SytemMemory 1350 /* Only interference checks against SystemIO and SytemMemory
1401 are needed */ 1351 are needed */
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 519266654f06..00456fccfa38 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -378,6 +378,22 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
378 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"), 378 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"),
379 }, 379 },
380 }, 380 },
381 {
382 .callback = init_old_suspend_ordering,
383 .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)",
384 .matches = {
385 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."),
386 DMI_MATCH(DMI_BOARD_NAME, "M2N8L"),
387 },
388 },
389 {
390 .callback = init_set_sci_en_on_resume,
391 .ident = "Toshiba Satellite L300",
392 .matches = {
393 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
394 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite L300"),
395 },
396 },
381 {}, 397 {},
382}; 398};
383#endif /* CONFIG_SUSPEND */ 399#endif /* CONFIG_SUSPEND */
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 00c46e0b40e4..3d763fdf99b7 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -210,7 +210,7 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
210 dev->dev.release = amba_device_release; 210 dev->dev.release = amba_device_release;
211 dev->dev.bus = &amba_bustype; 211 dev->dev.bus = &amba_bustype;
212 dev->dev.dma_mask = &dev->dma_mask; 212 dev->dev.dma_mask = &dev->dma_mask;
213 dev->res.name = dev->dev.bus_id; 213 dev->res.name = dev_name(&dev->dev);
214 214
215 if (!dev->dev.coherent_dma_mask && dev->dma_mask) 215 if (!dev->dev.coherent_dma_mask && dev->dma_mask)
216 dev_warn(&dev->dev, "coherent dma mask is unset\n"); 216 dev_warn(&dev->dev, "coherent dma mask is unset\n");
@@ -294,7 +294,7 @@ static int amba_find_match(struct device *dev, void *data)
294 if (d->parent) 294 if (d->parent)
295 r &= d->parent == dev->parent; 295 r &= d->parent == dev->parent;
296 if (d->busid) 296 if (d->busid)
297 r &= strcmp(dev->bus_id, d->busid) == 0; 297 r &= strcmp(dev_name(dev), d->busid) == 0;
298 298
299 if (r) { 299 if (r) {
300 get_device(dev); 300 get_device(dev);
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index a603bbf9b1b7..788bba2b1e17 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -404,7 +404,7 @@ static const struct ata_port_info ahci_port_info[] = {
404 /* board_ahci */ 404 /* board_ahci */
405 { 405 {
406 .flags = AHCI_FLAG_COMMON, 406 .flags = AHCI_FLAG_COMMON,
407 .pio_mask = 0x1f, /* pio0-4 */ 407 .pio_mask = ATA_PIO4,
408 .udma_mask = ATA_UDMA6, 408 .udma_mask = ATA_UDMA6,
409 .port_ops = &ahci_ops, 409 .port_ops = &ahci_ops,
410 }, 410 },
@@ -412,7 +412,7 @@ static const struct ata_port_info ahci_port_info[] = {
412 { 412 {
413 AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_PMP), 413 AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_PMP),
414 .flags = AHCI_FLAG_COMMON, 414 .flags = AHCI_FLAG_COMMON,
415 .pio_mask = 0x1f, /* pio0-4 */ 415 .pio_mask = ATA_PIO4,
416 .udma_mask = ATA_UDMA6, 416 .udma_mask = ATA_UDMA6,
417 .port_ops = &ahci_vt8251_ops, 417 .port_ops = &ahci_vt8251_ops,
418 }, 418 },
@@ -420,7 +420,7 @@ static const struct ata_port_info ahci_port_info[] = {
420 { 420 {
421 AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR), 421 AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR),
422 .flags = AHCI_FLAG_COMMON, 422 .flags = AHCI_FLAG_COMMON,
423 .pio_mask = 0x1f, /* pio0-4 */ 423 .pio_mask = ATA_PIO4,
424 .udma_mask = ATA_UDMA6, 424 .udma_mask = ATA_UDMA6,
425 .port_ops = &ahci_ops, 425 .port_ops = &ahci_ops,
426 }, 426 },
@@ -430,7 +430,7 @@ static const struct ata_port_info ahci_port_info[] = {
430 AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI | 430 AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI |
431 AHCI_HFLAG_SECT255), 431 AHCI_HFLAG_SECT255),
432 .flags = AHCI_FLAG_COMMON, 432 .flags = AHCI_FLAG_COMMON,
433 .pio_mask = 0x1f, /* pio0-4 */ 433 .pio_mask = ATA_PIO4,
434 .udma_mask = ATA_UDMA6, 434 .udma_mask = ATA_UDMA6,
435 .port_ops = &ahci_sb600_ops, 435 .port_ops = &ahci_sb600_ops,
436 }, 436 },
@@ -440,7 +440,7 @@ static const struct ata_port_info ahci_port_info[] = {
440 AHCI_HFLAG_MV_PATA | AHCI_HFLAG_NO_PMP), 440 AHCI_HFLAG_MV_PATA | AHCI_HFLAG_NO_PMP),
441 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 441 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
442 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA, 442 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA,
443 .pio_mask = 0x1f, /* pio0-4 */ 443 .pio_mask = ATA_PIO4,
444 .udma_mask = ATA_UDMA6, 444 .udma_mask = ATA_UDMA6,
445 .port_ops = &ahci_ops, 445 .port_ops = &ahci_ops,
446 }, 446 },
@@ -448,7 +448,7 @@ static const struct ata_port_info ahci_port_info[] = {
448 { 448 {
449 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL), 449 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL),
450 .flags = AHCI_FLAG_COMMON, 450 .flags = AHCI_FLAG_COMMON,
451 .pio_mask = 0x1f, /* pio0-4 */ 451 .pio_mask = ATA_PIO4,
452 .udma_mask = ATA_UDMA6, 452 .udma_mask = ATA_UDMA6,
453 .port_ops = &ahci_sb600_ops, 453 .port_ops = &ahci_sb600_ops,
454 }, 454 },
@@ -456,7 +456,7 @@ static const struct ata_port_info ahci_port_info[] = {
456 { 456 {
457 AHCI_HFLAGS (AHCI_HFLAG_YES_NCQ), 457 AHCI_HFLAGS (AHCI_HFLAG_YES_NCQ),
458 .flags = AHCI_FLAG_COMMON, 458 .flags = AHCI_FLAG_COMMON,
459 .pio_mask = 0x1f, /* pio0-4 */ 459 .pio_mask = ATA_PIO4,
460 .udma_mask = ATA_UDMA6, 460 .udma_mask = ATA_UDMA6,
461 .port_ops = &ahci_ops, 461 .port_ops = &ahci_ops,
462 }, 462 },
@@ -464,7 +464,7 @@ static const struct ata_port_info ahci_port_info[] = {
464 { 464 {
465 AHCI_HFLAGS (AHCI_HFLAG_NO_PMP), 465 AHCI_HFLAGS (AHCI_HFLAG_NO_PMP),
466 .flags = AHCI_FLAG_COMMON, 466 .flags = AHCI_FLAG_COMMON,
467 .pio_mask = 0x1f, /* pio0-4 */ 467 .pio_mask = ATA_PIO4,
468 .udma_mask = ATA_UDMA6, 468 .udma_mask = ATA_UDMA6,
469 .port_ops = &ahci_ops, 469 .port_ops = &ahci_ops,
470 }, 470 },
@@ -582,18 +582,18 @@ static const struct pci_device_id ahci_pci_tbl[] = {
582 { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ 582 { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */
583 { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ 583 { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */
584 { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ 584 { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */
585 { PCI_VDEVICE(NVIDIA, 0x0bc8), board_ahci }, /* MCP7B */ 585 { PCI_VDEVICE(NVIDIA, 0x0d84), board_ahci }, /* MCP89 */
586 { PCI_VDEVICE(NVIDIA, 0x0bc9), board_ahci }, /* MCP7B */ 586 { PCI_VDEVICE(NVIDIA, 0x0d85), board_ahci }, /* MCP89 */
587 { PCI_VDEVICE(NVIDIA, 0x0bca), board_ahci }, /* MCP7B */ 587 { PCI_VDEVICE(NVIDIA, 0x0d86), board_ahci }, /* MCP89 */
588 { PCI_VDEVICE(NVIDIA, 0x0bcb), board_ahci }, /* MCP7B */ 588 { PCI_VDEVICE(NVIDIA, 0x0d87), board_ahci }, /* MCP89 */
589 { PCI_VDEVICE(NVIDIA, 0x0bcc), board_ahci }, /* MCP7B */ 589 { PCI_VDEVICE(NVIDIA, 0x0d88), board_ahci }, /* MCP89 */
590 { PCI_VDEVICE(NVIDIA, 0x0bcd), board_ahci }, /* MCP7B */ 590 { PCI_VDEVICE(NVIDIA, 0x0d89), board_ahci }, /* MCP89 */
591 { PCI_VDEVICE(NVIDIA, 0x0bce), board_ahci }, /* MCP7B */ 591 { PCI_VDEVICE(NVIDIA, 0x0d8a), board_ahci }, /* MCP89 */
592 { PCI_VDEVICE(NVIDIA, 0x0bcf), board_ahci }, /* MCP7B */ 592 { PCI_VDEVICE(NVIDIA, 0x0d8b), board_ahci }, /* MCP89 */
593 { PCI_VDEVICE(NVIDIA, 0x0bc4), board_ahci }, /* MCP7B */ 593 { PCI_VDEVICE(NVIDIA, 0x0d8c), board_ahci }, /* MCP89 */
594 { PCI_VDEVICE(NVIDIA, 0x0bc5), board_ahci }, /* MCP7B */ 594 { PCI_VDEVICE(NVIDIA, 0x0d8d), board_ahci }, /* MCP89 */
595 { PCI_VDEVICE(NVIDIA, 0x0bc6), board_ahci }, /* MCP7B */ 595 { PCI_VDEVICE(NVIDIA, 0x0d8e), board_ahci }, /* MCP89 */
596 { PCI_VDEVICE(NVIDIA, 0x0bc7), board_ahci }, /* MCP7B */ 596 { PCI_VDEVICE(NVIDIA, 0x0d8f), board_ahci }, /* MCP89 */
597 597
598 /* SiS */ 598 /* SiS */
599 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ 599 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
@@ -1348,7 +1348,7 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
1348 writel(message[1], mmio + hpriv->em_loc+4); 1348 writel(message[1], mmio + hpriv->em_loc+4);
1349 1349
1350 /* save off new led state for port/slot */ 1350 /* save off new led state for port/slot */
1351 emp->led_state = message[1]; 1351 emp->led_state = state;
1352 1352
1353 /* 1353 /*
1354 * tell hardware to transmit the message 1354 * tell hardware to transmit the message
@@ -2565,6 +2565,15 @@ static bool ahci_broken_system_poweroff(struct pci_dev *pdev)
2565 /* PCI slot number of the controller */ 2565 /* PCI slot number of the controller */
2566 .driver_data = (void *)0x1FUL, 2566 .driver_data = (void *)0x1FUL,
2567 }, 2567 },
2568 {
2569 .ident = "HP Compaq 6720s",
2570 .matches = {
2571 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
2572 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6720s"),
2573 },
2574 /* PCI slot number of the controller */
2575 .driver_data = (void *)0x1FUL,
2576 },
2568 2577
2569 { } /* terminate list */ 2578 { } /* terminate list */
2570 }; 2579 };
@@ -2647,8 +2656,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2647 if (board_id == board_ahci_sb700 && pdev->revision >= 0x40) 2656 if (board_id == board_ahci_sb700 && pdev->revision >= 0x40)
2648 hpriv->flags &= ~AHCI_HFLAG_IGN_SERR_INTERNAL; 2657 hpriv->flags &= ~AHCI_HFLAG_IGN_SERR_INTERNAL;
2649 2658
2650 if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev)) 2659 if (!(hpriv->flags & AHCI_HFLAG_NO_MSI))
2651 pci_intx(pdev, 1); 2660 pci_enable_msi(pdev);
2652 2661
2653 /* save initial config */ 2662 /* save initial config */
2654 ahci_save_initial_config(pdev, hpriv); 2663 ahci_save_initial_config(pdev, hpriv);
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index dc48a6398abe..ecfd22b4f1ce 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -118,8 +118,8 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
118 u16 command; 118 u16 command;
119 static const struct ata_port_info info = { 119 static const struct ata_port_info info = {
120 .flags = ATA_FLAG_SLAVE_POSS, 120 .flags = ATA_FLAG_SLAVE_POSS,
121 .pio_mask = 0x1f, 121 .pio_mask = ATA_PIO4,
122 .mwdma_mask = 0x07, 122 .mwdma_mask = ATA_MWDMA2,
123 .udma_mask = ATA_UDMA5, 123 .udma_mask = ATA_UDMA5,
124 .port_ops = &generic_port_ops 124 .port_ops = &generic_port_ops
125 }; 125 };
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 54961c0b2c73..e5cbe80ce172 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -446,34 +446,34 @@ static struct ata_port_info piix_port_info[] = {
446 [piix_pata_mwdma] = /* PIIX3 MWDMA only */ 446 [piix_pata_mwdma] = /* PIIX3 MWDMA only */
447 { 447 {
448 .flags = PIIX_PATA_FLAGS, 448 .flags = PIIX_PATA_FLAGS,
449 .pio_mask = 0x1f, /* pio0-4 */ 449 .pio_mask = ATA_PIO4,
450 .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ 450 .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
451 .port_ops = &piix_pata_ops, 451 .port_ops = &piix_pata_ops,
452 }, 452 },
453 453
454 [piix_pata_33] = /* PIIX4 at 33MHz */ 454 [piix_pata_33] = /* PIIX4 at 33MHz */
455 { 455 {
456 .flags = PIIX_PATA_FLAGS, 456 .flags = PIIX_PATA_FLAGS,
457 .pio_mask = 0x1f, /* pio0-4 */ 457 .pio_mask = ATA_PIO4,
458 .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ 458 .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
459 .udma_mask = ATA_UDMA_MASK_40C, 459 .udma_mask = ATA_UDMA2,
460 .port_ops = &piix_pata_ops, 460 .port_ops = &piix_pata_ops,
461 }, 461 },
462 462
463 [ich_pata_33] = /* ICH0 - ICH at 33Mhz*/ 463 [ich_pata_33] = /* ICH0 - ICH at 33Mhz*/
464 { 464 {
465 .flags = PIIX_PATA_FLAGS, 465 .flags = PIIX_PATA_FLAGS,
466 .pio_mask = 0x1f, /* pio 0-4 */ 466 .pio_mask = ATA_PIO4,
467 .mwdma_mask = 0x06, /* Check: maybe 0x07 */ 467 .mwdma_mask = ATA_MWDMA12_ONLY, /* Check: maybe MWDMA0 is ok */
468 .udma_mask = ATA_UDMA2, /* UDMA33 */ 468 .udma_mask = ATA_UDMA2,
469 .port_ops = &ich_pata_ops, 469 .port_ops = &ich_pata_ops,
470 }, 470 },
471 471
472 [ich_pata_66] = /* ICH controllers up to 66MHz */ 472 [ich_pata_66] = /* ICH controllers up to 66MHz */
473 { 473 {
474 .flags = PIIX_PATA_FLAGS, 474 .flags = PIIX_PATA_FLAGS,
475 .pio_mask = 0x1f, /* pio 0-4 */ 475 .pio_mask = ATA_PIO4,
476 .mwdma_mask = 0x06, /* MWDMA0 is broken on chip */ 476 .mwdma_mask = ATA_MWDMA12_ONLY, /* MWDMA0 is broken on chip */
477 .udma_mask = ATA_UDMA4, 477 .udma_mask = ATA_UDMA4,
478 .port_ops = &ich_pata_ops, 478 .port_ops = &ich_pata_ops,
479 }, 479 },
@@ -481,17 +481,17 @@ static struct ata_port_info piix_port_info[] = {
481 [ich_pata_100] = 481 [ich_pata_100] =
482 { 482 {
483 .flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR, 483 .flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,
484 .pio_mask = 0x1f, /* pio0-4 */ 484 .pio_mask = ATA_PIO4,
485 .mwdma_mask = 0x06, /* mwdma1-2 */ 485 .mwdma_mask = ATA_MWDMA12_ONLY,
486 .udma_mask = ATA_UDMA5, /* udma0-5 */ 486 .udma_mask = ATA_UDMA5,
487 .port_ops = &ich_pata_ops, 487 .port_ops = &ich_pata_ops,
488 }, 488 },
489 489
490 [ich5_sata] = 490 [ich5_sata] =
491 { 491 {
492 .flags = PIIX_SATA_FLAGS, 492 .flags = PIIX_SATA_FLAGS,
493 .pio_mask = 0x1f, /* pio0-4 */ 493 .pio_mask = ATA_PIO4,
494 .mwdma_mask = 0x07, /* mwdma0-2 */ 494 .mwdma_mask = ATA_MWDMA2,
495 .udma_mask = ATA_UDMA6, 495 .udma_mask = ATA_UDMA6,
496 .port_ops = &piix_sata_ops, 496 .port_ops = &piix_sata_ops,
497 }, 497 },
@@ -499,8 +499,8 @@ static struct ata_port_info piix_port_info[] = {
499 [ich6_sata] = 499 [ich6_sata] =
500 { 500 {
501 .flags = PIIX_SATA_FLAGS, 501 .flags = PIIX_SATA_FLAGS,
502 .pio_mask = 0x1f, /* pio0-4 */ 502 .pio_mask = ATA_PIO4,
503 .mwdma_mask = 0x07, /* mwdma0-2 */ 503 .mwdma_mask = ATA_MWDMA2,
504 .udma_mask = ATA_UDMA6, 504 .udma_mask = ATA_UDMA6,
505 .port_ops = &piix_sata_ops, 505 .port_ops = &piix_sata_ops,
506 }, 506 },
@@ -508,8 +508,8 @@ static struct ata_port_info piix_port_info[] = {
508 [ich6m_sata] = 508 [ich6m_sata] =
509 { 509 {
510 .flags = PIIX_SATA_FLAGS, 510 .flags = PIIX_SATA_FLAGS,
511 .pio_mask = 0x1f, /* pio0-4 */ 511 .pio_mask = ATA_PIO4,
512 .mwdma_mask = 0x07, /* mwdma0-2 */ 512 .mwdma_mask = ATA_MWDMA2,
513 .udma_mask = ATA_UDMA6, 513 .udma_mask = ATA_UDMA6,
514 .port_ops = &piix_sata_ops, 514 .port_ops = &piix_sata_ops,
515 }, 515 },
@@ -517,8 +517,8 @@ static struct ata_port_info piix_port_info[] = {
517 [ich8_sata] = 517 [ich8_sata] =
518 { 518 {
519 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR, 519 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR,
520 .pio_mask = 0x1f, /* pio0-4 */ 520 .pio_mask = ATA_PIO4,
521 .mwdma_mask = 0x07, /* mwdma0-2 */ 521 .mwdma_mask = ATA_MWDMA2,
522 .udma_mask = ATA_UDMA6, 522 .udma_mask = ATA_UDMA6,
523 .port_ops = &piix_sata_ops, 523 .port_ops = &piix_sata_ops,
524 }, 524 },
@@ -526,8 +526,8 @@ static struct ata_port_info piix_port_info[] = {
526 [ich8_2port_sata] = 526 [ich8_2port_sata] =
527 { 527 {
528 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR, 528 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR,
529 .pio_mask = 0x1f, /* pio0-4 */ 529 .pio_mask = ATA_PIO4,
530 .mwdma_mask = 0x07, /* mwdma0-2 */ 530 .mwdma_mask = ATA_MWDMA2,
531 .udma_mask = ATA_UDMA6, 531 .udma_mask = ATA_UDMA6,
532 .port_ops = &piix_sata_ops, 532 .port_ops = &piix_sata_ops,
533 }, 533 },
@@ -535,8 +535,8 @@ static struct ata_port_info piix_port_info[] = {
535 [tolapai_sata] = 535 [tolapai_sata] =
536 { 536 {
537 .flags = PIIX_SATA_FLAGS, 537 .flags = PIIX_SATA_FLAGS,
538 .pio_mask = 0x1f, /* pio0-4 */ 538 .pio_mask = ATA_PIO4,
539 .mwdma_mask = 0x07, /* mwdma0-2 */ 539 .mwdma_mask = ATA_MWDMA2,
540 .udma_mask = ATA_UDMA6, 540 .udma_mask = ATA_UDMA6,
541 .port_ops = &piix_sata_ops, 541 .port_ops = &piix_sata_ops,
542 }, 542 },
@@ -544,8 +544,8 @@ static struct ata_port_info piix_port_info[] = {
544 [ich8m_apple_sata] = 544 [ich8m_apple_sata] =
545 { 545 {
546 .flags = PIIX_SATA_FLAGS, 546 .flags = PIIX_SATA_FLAGS,
547 .pio_mask = 0x1f, /* pio0-4 */ 547 .pio_mask = ATA_PIO4,
548 .mwdma_mask = 0x07, /* mwdma0-2 */ 548 .mwdma_mask = ATA_MWDMA2,
549 .udma_mask = ATA_UDMA6, 549 .udma_mask = ATA_UDMA6,
550 .port_ops = &piix_sata_ops, 550 .port_ops = &piix_sata_ops,
551 }, 551 },
@@ -553,9 +553,9 @@ static struct ata_port_info piix_port_info[] = {
553 [piix_pata_vmw] = 553 [piix_pata_vmw] =
554 { 554 {
555 .flags = PIIX_PATA_FLAGS, 555 .flags = PIIX_PATA_FLAGS,
556 .pio_mask = 0x1f, /* pio0-4 */ 556 .pio_mask = ATA_PIO4,
557 .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ 557 .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
558 .udma_mask = ATA_UDMA_MASK_40C, 558 .udma_mask = ATA_UDMA2,
559 .port_ops = &piix_vmw_ops, 559 .port_ops = &piix_vmw_ops,
560 }, 560 },
561 561
@@ -1289,6 +1289,39 @@ static const int *__devinit piix_init_sata_map(struct pci_dev *pdev,
1289 return map; 1289 return map;
1290} 1290}
1291 1291
1292static bool piix_no_sidpr(struct ata_host *host)
1293{
1294 struct pci_dev *pdev = to_pci_dev(host->dev);
1295
1296 /*
1297 * Samsung DB-P70 only has three ATA ports exposed and
1298 * curiously the unconnected first port reports link online
1299 * while not responding to SRST protocol causing excessive
1300 * detection delay.
1301 *
1302 * Unfortunately, the system doesn't carry enough DMI
1303 * information to identify the machine but does have subsystem
1304 * vendor and device set. As it's unclear whether the
1305 * subsystem vendor/device is used only for this specific
1306 * board, the port can't be disabled solely with the
1307 * information; however, turning off SIDPR access works around
1308 * the problem. Turn it off.
1309 *
1310 * This problem is reported in bnc#441240.
1311 *
1312 * https://bugzilla.novell.com/show_bug.cgi?id=441420
1313 */
1314 if (pdev->vendor == PCI_VENDOR_ID_INTEL && pdev->device == 0x2920 &&
1315 pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG &&
1316 pdev->subsystem_device == 0xb049) {
1317 dev_printk(KERN_WARNING, host->dev,
1318 "Samsung DB-P70 detected, disabling SIDPR\n");
1319 return true;
1320 }
1321
1322 return false;
1323}
1324
1292static int __devinit piix_init_sidpr(struct ata_host *host) 1325static int __devinit piix_init_sidpr(struct ata_host *host)
1293{ 1326{
1294 struct pci_dev *pdev = to_pci_dev(host->dev); 1327 struct pci_dev *pdev = to_pci_dev(host->dev);
@@ -1302,6 +1335,10 @@ static int __devinit piix_init_sidpr(struct ata_host *host)
1302 if (hpriv->map[i] == IDE) 1335 if (hpriv->map[i] == IDE)
1303 return 0; 1336 return 0;
1304 1337
1338 /* is it blacklisted? */
1339 if (piix_no_sidpr(host))
1340 return 0;
1341
1305 if (!(host->ports[0]->flags & PIIX_FLAG_SIDPR)) 1342 if (!(host->ports[0]->flags & PIIX_FLAG_SIDPR))
1306 return 0; 1343 return 0;
1307 1344
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 9fbf0595f3d4..e7ea77cf6069 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -57,6 +57,7 @@
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 <linux/async.h>
60#include <linux/log2.h>
60#include <scsi/scsi.h> 61#include <scsi/scsi.h>
61#include <scsi/scsi_cmnd.h> 62#include <scsi/scsi_cmnd.h>
62#include <scsi/scsi_host.h> 63#include <scsi/scsi_host.h>
@@ -1322,14 +1323,16 @@ static u64 ata_id_n_sectors(const u16 *id)
1322{ 1323{
1323 if (ata_id_has_lba(id)) { 1324 if (ata_id_has_lba(id)) {
1324 if (ata_id_has_lba48(id)) 1325 if (ata_id_has_lba48(id))
1325 return ata_id_u64(id, 100); 1326 return ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
1326 else 1327 else
1327 return ata_id_u32(id, 60); 1328 return ata_id_u32(id, ATA_ID_LBA_CAPACITY);
1328 } else { 1329 } else {
1329 if (ata_id_current_chs_valid(id)) 1330 if (ata_id_current_chs_valid(id))
1330 return ata_id_u32(id, 57); 1331 return id[ATA_ID_CUR_CYLS] * id[ATA_ID_CUR_HEADS] *
1332 id[ATA_ID_CUR_SECTORS];
1331 else 1333 else
1332 return id[1] * id[3] * id[6]; 1334 return id[ATA_ID_CYLS] * id[ATA_ID_HEADS] *
1335 id[ATA_ID_SECTORS];
1333 } 1336 }
1334} 1337}
1335 1338
@@ -2387,6 +2390,7 @@ int ata_dev_configure(struct ata_device *dev)
2387 dev->cylinders = 0; 2390 dev->cylinders = 0;
2388 dev->heads = 0; 2391 dev->heads = 0;
2389 dev->sectors = 0; 2392 dev->sectors = 0;
2393 dev->multi_count = 0;
2390 2394
2391 /* 2395 /*
2392 * common ATA, ATAPI feature tests 2396 * common ATA, ATAPI feature tests
@@ -2424,8 +2428,15 @@ int ata_dev_configure(struct ata_device *dev)
2424 2428
2425 dev->n_sectors = ata_id_n_sectors(id); 2429 dev->n_sectors = ata_id_n_sectors(id);
2426 2430
2427 if (dev->id[59] & 0x100) 2431 /* get current R/W Multiple count setting */
2428 dev->multi_count = dev->id[59] & 0xff; 2432 if ((dev->id[47] >> 8) == 0x80 && (dev->id[59] & 0x100)) {
2433 unsigned int max = dev->id[47] & 0xff;
2434 unsigned int cnt = dev->id[59] & 0xff;
2435 /* only recognize/allow powers of two here */
2436 if (is_power_of_2(max) && is_power_of_2(cnt))
2437 if (cnt <= max)
2438 dev->multi_count = cnt;
2439 }
2429 2440
2430 if (ata_id_has_lba(id)) { 2441 if (ata_id_has_lba(id)) {
2431 const char *lba_desc; 2442 const char *lba_desc;
@@ -4612,7 +4623,7 @@ void ata_sg_clean(struct ata_queued_cmd *qc)
4612 VPRINTK("unmapping %u sg elements\n", qc->n_elem); 4623 VPRINTK("unmapping %u sg elements\n", qc->n_elem);
4613 4624
4614 if (qc->n_elem) 4625 if (qc->n_elem)
4615 dma_unmap_sg(ap->dev, sg, qc->n_elem, dir); 4626 dma_unmap_sg(ap->dev, sg, qc->orig_n_elem, dir);
4616 4627
4617 qc->flags &= ~ATA_QCFLAG_DMAMAP; 4628 qc->flags &= ~ATA_QCFLAG_DMAMAP;
4618 qc->sg = NULL; 4629 qc->sg = NULL;
@@ -4727,7 +4738,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
4727 return -1; 4738 return -1;
4728 4739
4729 DPRINTK("%d sg elements mapped\n", n_elem); 4740 DPRINTK("%d sg elements mapped\n", n_elem);
4730 4741 qc->orig_n_elem = qc->n_elem;
4731 qc->n_elem = n_elem; 4742 qc->n_elem = n_elem;
4732 qc->flags |= ATA_QCFLAG_DMAMAP; 4743 qc->flags |= ATA_QCFLAG_DMAMAP;
4733 4744
@@ -6707,6 +6718,7 @@ EXPORT_SYMBOL_GPL(ata_id_c_string);
6707EXPORT_SYMBOL_GPL(ata_do_dev_read_id); 6718EXPORT_SYMBOL_GPL(ata_do_dev_read_id);
6708EXPORT_SYMBOL_GPL(ata_scsi_simulate); 6719EXPORT_SYMBOL_GPL(ata_scsi_simulate);
6709 6720
6721EXPORT_SYMBOL_GPL(ata_pio_queue_task);
6710EXPORT_SYMBOL_GPL(ata_pio_need_iordy); 6722EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
6711EXPORT_SYMBOL_GPL(ata_timing_find_mode); 6723EXPORT_SYMBOL_GPL(ata_timing_find_mode);
6712EXPORT_SYMBOL_GPL(ata_timing_compute); 6724EXPORT_SYMBOL_GPL(ata_timing_compute);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index ce2ef0475339..01831312c360 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -547,7 +547,7 @@ void ata_scsi_error(struct Scsi_Host *host)
547 547
548 /* For new EH, all qcs are finished in one of three ways - 548 /* For new EH, all qcs are finished in one of three ways -
549 * normal completion, error completion, and SCSI timeout. 549 * normal completion, error completion, and SCSI timeout.
550 * Both cmpletions can race against SCSI timeout. When normal 550 * Both completions can race against SCSI timeout. When normal
551 * completion wins, the qc never reaches EH. When error 551 * completion wins, the qc never reaches EH. When error
552 * completion wins, the qc has ATA_QCFLAG_FAILED set. 552 * completion wins, the qc has ATA_QCFLAG_FAILED set.
553 * 553 *
@@ -562,7 +562,19 @@ void ata_scsi_error(struct Scsi_Host *host)
562 int nr_timedout = 0; 562 int nr_timedout = 0;
563 563
564 spin_lock_irqsave(ap->lock, flags); 564 spin_lock_irqsave(ap->lock, flags);
565 565
566 /* This must occur under the ap->lock as we don't want
567 a polled recovery to race the real interrupt handler
568
569 The lost_interrupt handler checks for any completed but
570 non-notified command and completes much like an IRQ handler.
571
572 We then fall into the error recovery code which will treat
573 this as if normal completion won the race */
574
575 if (ap->ops->lost_interrupt)
576 ap->ops->lost_interrupt(ap);
577
566 list_for_each_entry_safe(scmd, tmp, &host->eh_cmd_q, eh_entry) { 578 list_for_each_entry_safe(scmd, tmp, &host->eh_cmd_q, eh_entry) {
567 struct ata_queued_cmd *qc; 579 struct ata_queued_cmd *qc;
568 580
@@ -606,6 +618,9 @@ void ata_scsi_error(struct Scsi_Host *host)
606 ap->eh_tries = ATA_EH_MAX_TRIES; 618 ap->eh_tries = ATA_EH_MAX_TRIES;
607 } else 619 } else
608 spin_unlock_wait(ap->lock); 620 spin_unlock_wait(ap->lock);
621
622 /* If we timed raced normal completion and there is nothing to
623 recover nr_timedout == 0 why exactly are we doing error recovery ? */
609 624
610 repeat: 625 repeat:
611 /* invoke error handler */ 626 /* invoke error handler */
@@ -2423,11 +2438,14 @@ int ata_eh_reset(struct ata_link *link, int classify,
2423 } 2438 }
2424 2439
2425 /* prereset() might have cleared ATA_EH_RESET. If so, 2440 /* prereset() might have cleared ATA_EH_RESET. If so,
2426 * bang classes and return. 2441 * bang classes, thaw and return.
2427 */ 2442 */
2428 if (reset && !(ehc->i.action & ATA_EH_RESET)) { 2443 if (reset && !(ehc->i.action & ATA_EH_RESET)) {
2429 ata_for_each_dev(dev, link, ALL) 2444 ata_for_each_dev(dev, link, ALL)
2430 classes[dev->devno] = ATA_DEV_NONE; 2445 classes[dev->devno] = ATA_DEV_NONE;
2446 if ((ap->pflags & ATA_PFLAG_FROZEN) &&
2447 ata_is_host_link(link))
2448 ata_eh_thaw_port(ap);
2431 rc = 0; 2449 rc = 0;
2432 goto out; 2450 goto out;
2433 } 2451 }
@@ -2901,7 +2919,7 @@ static int atapi_eh_clear_ua(struct ata_device *dev)
2901 int i; 2919 int i;
2902 2920
2903 for (i = 0; i < ATA_EH_UA_TRIES; i++) { 2921 for (i = 0; i < ATA_EH_UA_TRIES; i++) {
2904 u8 sense_buffer[SCSI_SENSE_BUFFERSIZE]; 2922 u8 *sense_buffer = dev->link->ap->sector_buf;
2905 u8 sense_key = 0; 2923 u8 sense_key = 0;
2906 unsigned int err_mask; 2924 unsigned int err_mask;
2907 2925
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 714cb046b594..8332e97a9de3 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -52,6 +52,7 @@ const struct ata_port_operations ata_sff_port_ops = {
52 .softreset = ata_sff_softreset, 52 .softreset = ata_sff_softreset,
53 .hardreset = sata_sff_hardreset, 53 .hardreset = sata_sff_hardreset,
54 .postreset = ata_sff_postreset, 54 .postreset = ata_sff_postreset,
55 .drain_fifo = ata_sff_drain_fifo,
55 .error_handler = ata_sff_error_handler, 56 .error_handler = ata_sff_error_handler,
56 .post_internal_cmd = ata_sff_post_internal_cmd, 57 .post_internal_cmd = ata_sff_post_internal_cmd,
57 58
@@ -64,6 +65,8 @@ const struct ata_port_operations ata_sff_port_ops = {
64 .sff_irq_on = ata_sff_irq_on, 65 .sff_irq_on = ata_sff_irq_on,
65 .sff_irq_clear = ata_sff_irq_clear, 66 .sff_irq_clear = ata_sff_irq_clear,
66 67
68 .lost_interrupt = ata_sff_lost_interrupt,
69
67 .port_start = ata_sff_port_start, 70 .port_start = ata_sff_port_start,
68}; 71};
69EXPORT_SYMBOL_GPL(ata_sff_port_ops); 72EXPORT_SYMBOL_GPL(ata_sff_port_ops);
@@ -1646,7 +1649,7 @@ EXPORT_SYMBOL_GPL(ata_sff_qc_fill_rtf);
1646 * RETURNS: 1649 * RETURNS:
1647 * One if interrupt was handled, zero if not (shared irq). 1650 * One if interrupt was handled, zero if not (shared irq).
1648 */ 1651 */
1649inline unsigned int ata_sff_host_intr(struct ata_port *ap, 1652unsigned int ata_sff_host_intr(struct ata_port *ap,
1650 struct ata_queued_cmd *qc) 1653 struct ata_queued_cmd *qc)
1651{ 1654{
1652 struct ata_eh_info *ehi = &ap->link.eh_info; 1655 struct ata_eh_info *ehi = &ap->link.eh_info;
@@ -1775,6 +1778,48 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
1775EXPORT_SYMBOL_GPL(ata_sff_interrupt); 1778EXPORT_SYMBOL_GPL(ata_sff_interrupt);
1776 1779
1777/** 1780/**
1781 * ata_sff_lost_interrupt - Check for an apparent lost interrupt
1782 * @ap: port that appears to have timed out
1783 *
1784 * Called from the libata error handlers when the core code suspects
1785 * an interrupt has been lost. If it has complete anything we can and
1786 * then return. Interface must support altstatus for this faster
1787 * recovery to occur.
1788 *
1789 * Locking:
1790 * Caller holds host lock
1791 */
1792
1793void ata_sff_lost_interrupt(struct ata_port *ap)
1794{
1795 u8 status;
1796 struct ata_queued_cmd *qc;
1797
1798 /* Only one outstanding command per SFF channel */
1799 qc = ata_qc_from_tag(ap, ap->link.active_tag);
1800 /* Check we have a live one.. */
1801 if (qc == NULL || !(qc->flags & ATA_QCFLAG_ACTIVE))
1802 return;
1803 /* We cannot lose an interrupt on a polled command */
1804 if (qc->tf.flags & ATA_TFLAG_POLLING)
1805 return;
1806 /* See if the controller thinks it is still busy - if so the command
1807 isn't a lost IRQ but is still in progress */
1808 status = ata_sff_altstatus(ap);
1809 if (status & ATA_BUSY)
1810 return;
1811
1812 /* There was a command running, we are no longer busy and we have
1813 no interrupt. */
1814 ata_port_printk(ap, KERN_WARNING, "lost interrupt (Status 0x%x)\n",
1815 status);
1816 /* Run the host interrupt logic as if the interrupt had not been
1817 lost */
1818 ata_sff_host_intr(ap, qc);
1819}
1820EXPORT_SYMBOL_GPL(ata_sff_lost_interrupt);
1821
1822/**
1778 * ata_sff_freeze - Freeze SFF controller port 1823 * ata_sff_freeze - Freeze SFF controller port
1779 * @ap: port to freeze 1824 * @ap: port to freeze
1780 * 1825 *
@@ -2066,6 +2111,7 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask,
2066 iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr); 2111 iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr);
2067 udelay(20); /* FIXME: flush */ 2112 udelay(20); /* FIXME: flush */
2068 iowrite8(ap->ctl, ioaddr->ctl_addr); 2113 iowrite8(ap->ctl, ioaddr->ctl_addr);
2114 ap->last_ctl = ap->ctl;
2069 2115
2070 /* wait the port to become ready */ 2116 /* wait the port to become ready */
2071 return ata_sff_wait_after_reset(&ap->link, devmask, deadline); 2117 return ata_sff_wait_after_reset(&ap->link, devmask, deadline);
@@ -2190,12 +2236,47 @@ void ata_sff_postreset(struct ata_link *link, unsigned int *classes)
2190 } 2236 }
2191 2237
2192 /* set up device control */ 2238 /* set up device control */
2193 if (ap->ioaddr.ctl_addr) 2239 if (ap->ioaddr.ctl_addr) {
2194 iowrite8(ap->ctl, ap->ioaddr.ctl_addr); 2240 iowrite8(ap->ctl, ap->ioaddr.ctl_addr);
2241 ap->last_ctl = ap->ctl;
2242 }
2195} 2243}
2196EXPORT_SYMBOL_GPL(ata_sff_postreset); 2244EXPORT_SYMBOL_GPL(ata_sff_postreset);
2197 2245
2198/** 2246/**
2247 * ata_sff_drain_fifo - Stock FIFO drain logic for SFF controllers
2248 * @qc: command
2249 *
2250 * Drain the FIFO and device of any stuck data following a command
2251 * failing to complete. In some cases this is neccessary before a
2252 * reset will recover the device.
2253 *
2254 */
2255
2256void ata_sff_drain_fifo(struct ata_queued_cmd *qc)
2257{
2258 int count;
2259 struct ata_port *ap;
2260
2261 /* We only need to flush incoming data when a command was running */
2262 if (qc == NULL || qc->dma_dir == DMA_TO_DEVICE)
2263 return;
2264
2265 ap = qc->ap;
2266 /* Drain up to 64K of data before we give up this recovery method */
2267 for (count = 0; (ap->ops->sff_check_status(ap) & ATA_DRQ)
2268 && count < 32768; count++)
2269 ioread16(ap->ioaddr.data_addr);
2270
2271 /* Can become DEBUG later */
2272 if (count)
2273 ata_port_printk(ap, KERN_DEBUG,
2274 "drained %d bytes to clear DRQ.\n", count);
2275
2276}
2277EXPORT_SYMBOL_GPL(ata_sff_drain_fifo);
2278
2279/**
2199 * ata_sff_error_handler - Stock error handler for BMDMA controller 2280 * ata_sff_error_handler - Stock error handler for BMDMA controller
2200 * @ap: port to handle error for 2281 * @ap: port to handle error for
2201 * 2282 *
@@ -2236,7 +2317,8 @@ void ata_sff_error_handler(struct ata_port *ap)
2236 * really a timeout event, adjust error mask and 2317 * really a timeout event, adjust error mask and
2237 * cancel frozen state. 2318 * cancel frozen state.
2238 */ 2319 */
2239 if (qc->err_mask == AC_ERR_TIMEOUT && (host_stat & ATA_DMA_ERR)) { 2320 if (qc->err_mask == AC_ERR_TIMEOUT
2321 && (host_stat & ATA_DMA_ERR)) {
2240 qc->err_mask = AC_ERR_HOST_BUS; 2322 qc->err_mask = AC_ERR_HOST_BUS;
2241 thaw = 1; 2323 thaw = 1;
2242 } 2324 }
@@ -2247,6 +2329,13 @@ void ata_sff_error_handler(struct ata_port *ap)
2247 ata_sff_sync(ap); /* FIXME: We don't need this */ 2329 ata_sff_sync(ap); /* FIXME: We don't need this */
2248 ap->ops->sff_check_status(ap); 2330 ap->ops->sff_check_status(ap);
2249 ap->ops->sff_irq_clear(ap); 2331 ap->ops->sff_irq_clear(ap);
2332 /* We *MUST* do FIFO draining before we issue a reset as several
2333 * devices helpfully clear their internal state and will lock solid
2334 * if we touch the data port post reset. Pass qc in case anyone wants
2335 * to do different PIO/DMA recovery or has per command fixups
2336 */
2337 if (ap->ops->drain_fifo)
2338 ap->ops->drain_fifo(qc);
2250 2339
2251 spin_unlock_irqrestore(ap->lock, flags); 2340 spin_unlock_irqrestore(ap->lock, flags);
2252 2341
@@ -2534,6 +2623,7 @@ void ata_bus_reset(struct ata_port *ap)
2534 if (ap->flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST)) { 2623 if (ap->flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST)) {
2535 /* set up device control for ATA_FLAG_SATA_RESET */ 2624 /* set up device control for ATA_FLAG_SATA_RESET */
2536 iowrite8(ap->ctl, ioaddr->ctl_addr); 2625 iowrite8(ap->ctl, ioaddr->ctl_addr);
2626 ap->last_ctl = ap->ctl;
2537 } 2627 }
2538 2628
2539 DPRINTK("EXIT\n"); 2629 DPRINTK("EXIT\n");
@@ -2955,4 +3045,3 @@ out:
2955EXPORT_SYMBOL_GPL(ata_pci_sff_init_one); 3045EXPORT_SYMBOL_GPL(ata_pci_sff_init_one);
2956 3046
2957#endif /* CONFIG_PCI */ 3047#endif /* CONFIG_PCI */
2958
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index cea8014cd87e..89a1e0018e71 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -79,8 +79,6 @@ extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
79 u64 block, u32 n_block, unsigned int tf_flags, 79 u64 block, u32 n_block, unsigned int tf_flags,
80 unsigned int tag); 80 unsigned int tag);
81extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev); 81extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev);
82extern void ata_pio_queue_task(struct ata_port *ap, void *data,
83 unsigned long delay);
84extern void ata_port_flush_task(struct ata_port *ap); 82extern void ata_port_flush_task(struct ata_port *ap);
85extern unsigned ata_exec_internal(struct ata_device *dev, 83extern unsigned ata_exec_internal(struct ata_device *dev,
86 struct ata_taskfile *tf, const u8 *cdb, 84 struct ata_taskfile *tf, const u8 *cdb,
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index 8b77a9802df1..d8f35fe44421 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -246,9 +246,9 @@ static int pacpi_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
246 static const struct ata_port_info info = { 246 static const struct ata_port_info info = {
247 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 247 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
248 248
249 .pio_mask = 0x1f, 249 .pio_mask = ATA_PIO4,
250 .mwdma_mask = 0x07, 250 .mwdma_mask = ATA_MWDMA2,
251 .udma_mask = 0x7f, 251 .udma_mask = ATA_UDMA6,
252 252
253 .port_ops = &pacpi_ops, 253 .port_ops = &pacpi_ops,
254 }; 254 };
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index eb99dbe78081..751b7ea4816c 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -492,53 +492,53 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
492{ 492{
493 static const struct ata_port_info info_early = { 493 static const struct ata_port_info info_early = {
494 .flags = ATA_FLAG_SLAVE_POSS, 494 .flags = ATA_FLAG_SLAVE_POSS,
495 .pio_mask = 0x1f, 495 .pio_mask = ATA_PIO4,
496 .port_ops = &ali_early_port_ops 496 .port_ops = &ali_early_port_ops
497 }; 497 };
498 /* Revision 0x20 added DMA */ 498 /* Revision 0x20 added DMA */
499 static const struct ata_port_info info_20 = { 499 static const struct ata_port_info info_20 = {
500 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 500 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
501 .pio_mask = 0x1f, 501 .pio_mask = ATA_PIO4,
502 .mwdma_mask = 0x07, 502 .mwdma_mask = ATA_MWDMA2,
503 .port_ops = &ali_20_port_ops 503 .port_ops = &ali_20_port_ops
504 }; 504 };
505 /* Revision 0x20 with support logic added UDMA */ 505 /* Revision 0x20 with support logic added UDMA */
506 static const struct ata_port_info info_20_udma = { 506 static const struct ata_port_info info_20_udma = {
507 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 507 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
508 .pio_mask = 0x1f, 508 .pio_mask = ATA_PIO4,
509 .mwdma_mask = 0x07, 509 .mwdma_mask = ATA_MWDMA2,
510 .udma_mask = 0x07, /* UDMA33 */ 510 .udma_mask = ATA_UDMA2,
511 .port_ops = &ali_20_port_ops 511 .port_ops = &ali_20_port_ops
512 }; 512 };
513 /* Revision 0xC2 adds UDMA66 */ 513 /* Revision 0xC2 adds UDMA66 */
514 static const struct ata_port_info info_c2 = { 514 static const struct ata_port_info info_c2 = {
515 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 515 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
516 .pio_mask = 0x1f, 516 .pio_mask = ATA_PIO4,
517 .mwdma_mask = 0x07, 517 .mwdma_mask = ATA_MWDMA2,
518 .udma_mask = ATA_UDMA4, 518 .udma_mask = ATA_UDMA4,
519 .port_ops = &ali_c2_port_ops 519 .port_ops = &ali_c2_port_ops
520 }; 520 };
521 /* Revision 0xC3 is UDMA66 for now */ 521 /* Revision 0xC3 is UDMA66 for now */
522 static const struct ata_port_info info_c3 = { 522 static const struct ata_port_info info_c3 = {
523 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 523 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
524 .pio_mask = 0x1f, 524 .pio_mask = ATA_PIO4,
525 .mwdma_mask = 0x07, 525 .mwdma_mask = ATA_MWDMA2,
526 .udma_mask = ATA_UDMA4, 526 .udma_mask = ATA_UDMA4,
527 .port_ops = &ali_c2_port_ops 527 .port_ops = &ali_c2_port_ops
528 }; 528 };
529 /* Revision 0xC4 is UDMA100 */ 529 /* Revision 0xC4 is UDMA100 */
530 static const struct ata_port_info info_c4 = { 530 static const struct ata_port_info info_c4 = {
531 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 531 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
532 .pio_mask = 0x1f, 532 .pio_mask = ATA_PIO4,
533 .mwdma_mask = 0x07, 533 .mwdma_mask = ATA_MWDMA2,
534 .udma_mask = ATA_UDMA5, 534 .udma_mask = ATA_UDMA5,
535 .port_ops = &ali_c4_port_ops 535 .port_ops = &ali_c4_port_ops
536 }; 536 };
537 /* Revision 0xC5 is UDMA133 with LBA48 DMA */ 537 /* Revision 0xC5 is UDMA133 with LBA48 DMA */
538 static const struct ata_port_info info_c5 = { 538 static const struct ata_port_info info_c5 = {
539 .flags = ATA_FLAG_SLAVE_POSS, 539 .flags = ATA_FLAG_SLAVE_POSS,
540 .pio_mask = 0x1f, 540 .pio_mask = ATA_PIO4,
541 .mwdma_mask = 0x07, 541 .mwdma_mask = ATA_MWDMA2,
542 .udma_mask = ATA_UDMA6, 542 .udma_mask = ATA_UDMA6,
543 .port_ops = &ali_c5_port_ops 543 .port_ops = &ali_c5_port_ops
544 }; 544 };
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 115b1cd6dcf5..33a74f11171c 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -455,74 +455,74 @@ static void amd_clear_fifo(struct pci_dev *pdev)
455static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 455static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
456{ 456{
457 static const struct ata_port_info info[10] = { 457 static const struct ata_port_info info[10] = {
458 { /* 0: AMD 7401 */ 458 { /* 0: AMD 7401 - no swdma */
459 .flags = ATA_FLAG_SLAVE_POSS, 459 .flags = ATA_FLAG_SLAVE_POSS,
460 .pio_mask = 0x1f, 460 .pio_mask = ATA_PIO4,
461 .mwdma_mask = 0x07, /* No SWDMA */ 461 .mwdma_mask = ATA_MWDMA2,
462 .udma_mask = 0x07, /* UDMA 33 */ 462 .udma_mask = ATA_UDMA2,
463 .port_ops = &amd33_port_ops 463 .port_ops = &amd33_port_ops
464 }, 464 },
465 { /* 1: Early AMD7409 - no swdma */ 465 { /* 1: Early AMD7409 - no swdma */
466 .flags = ATA_FLAG_SLAVE_POSS, 466 .flags = ATA_FLAG_SLAVE_POSS,
467 .pio_mask = 0x1f, 467 .pio_mask = ATA_PIO4,
468 .mwdma_mask = 0x07, 468 .mwdma_mask = ATA_MWDMA2,
469 .udma_mask = ATA_UDMA4, /* UDMA 66 */ 469 .udma_mask = ATA_UDMA4,
470 .port_ops = &amd66_port_ops 470 .port_ops = &amd66_port_ops
471 }, 471 },
472 { /* 2: AMD 7409, no swdma errata */ 472 { /* 2: AMD 7409 */
473 .flags = ATA_FLAG_SLAVE_POSS, 473 .flags = ATA_FLAG_SLAVE_POSS,
474 .pio_mask = 0x1f, 474 .pio_mask = ATA_PIO4,
475 .mwdma_mask = 0x07, 475 .mwdma_mask = ATA_MWDMA2,
476 .udma_mask = ATA_UDMA4, /* UDMA 66 */ 476 .udma_mask = ATA_UDMA4,
477 .port_ops = &amd66_port_ops 477 .port_ops = &amd66_port_ops
478 }, 478 },
479 { /* 3: AMD 7411 */ 479 { /* 3: AMD 7411 */
480 .flags = ATA_FLAG_SLAVE_POSS, 480 .flags = ATA_FLAG_SLAVE_POSS,
481 .pio_mask = 0x1f, 481 .pio_mask = ATA_PIO4,
482 .mwdma_mask = 0x07, 482 .mwdma_mask = ATA_MWDMA2,
483 .udma_mask = ATA_UDMA5, /* UDMA 100 */ 483 .udma_mask = ATA_UDMA5,
484 .port_ops = &amd100_port_ops 484 .port_ops = &amd100_port_ops
485 }, 485 },
486 { /* 4: AMD 7441 */ 486 { /* 4: AMD 7441 */
487 .flags = ATA_FLAG_SLAVE_POSS, 487 .flags = ATA_FLAG_SLAVE_POSS,
488 .pio_mask = 0x1f, 488 .pio_mask = ATA_PIO4,
489 .mwdma_mask = 0x07, 489 .mwdma_mask = ATA_MWDMA2,
490 .udma_mask = ATA_UDMA5, /* UDMA 100 */ 490 .udma_mask = ATA_UDMA5,
491 .port_ops = &amd100_port_ops 491 .port_ops = &amd100_port_ops
492 }, 492 },
493 { /* 5: AMD 8111*/ 493 { /* 5: AMD 8111 - no swdma */
494 .flags = ATA_FLAG_SLAVE_POSS, 494 .flags = ATA_FLAG_SLAVE_POSS,
495 .pio_mask = 0x1f, 495 .pio_mask = ATA_PIO4,
496 .mwdma_mask = 0x07, 496 .mwdma_mask = ATA_MWDMA2,
497 .udma_mask = ATA_UDMA6, /* UDMA 133, no swdma */ 497 .udma_mask = ATA_UDMA6,
498 .port_ops = &amd133_port_ops 498 .port_ops = &amd133_port_ops
499 }, 499 },
500 { /* 6: AMD 8111 UDMA 100 (Serenade) */ 500 { /* 6: AMD 8111 UDMA 100 (Serenade) - no swdma */
501 .flags = ATA_FLAG_SLAVE_POSS, 501 .flags = ATA_FLAG_SLAVE_POSS,
502 .pio_mask = 0x1f, 502 .pio_mask = ATA_PIO4,
503 .mwdma_mask = 0x07, 503 .mwdma_mask = ATA_MWDMA2,
504 .udma_mask = ATA_UDMA5, /* UDMA 100, no swdma */ 504 .udma_mask = ATA_UDMA5,
505 .port_ops = &amd133_port_ops 505 .port_ops = &amd133_port_ops
506 }, 506 },
507 { /* 7: Nvidia Nforce */ 507 { /* 7: Nvidia Nforce */
508 .flags = ATA_FLAG_SLAVE_POSS, 508 .flags = ATA_FLAG_SLAVE_POSS,
509 .pio_mask = 0x1f, 509 .pio_mask = ATA_PIO4,
510 .mwdma_mask = 0x07, 510 .mwdma_mask = ATA_MWDMA2,
511 .udma_mask = ATA_UDMA5, /* UDMA 100 */ 511 .udma_mask = ATA_UDMA5,
512 .port_ops = &nv100_port_ops 512 .port_ops = &nv100_port_ops
513 }, 513 },
514 { /* 8: Nvidia Nforce2 and later */ 514 { /* 8: Nvidia Nforce2 and later - no swdma */
515 .flags = ATA_FLAG_SLAVE_POSS, 515 .flags = ATA_FLAG_SLAVE_POSS,
516 .pio_mask = 0x1f, 516 .pio_mask = ATA_PIO4,
517 .mwdma_mask = 0x07, 517 .mwdma_mask = ATA_MWDMA2,
518 .udma_mask = ATA_UDMA6, /* UDMA 133, no swdma */ 518 .udma_mask = ATA_UDMA6,
519 .port_ops = &nv133_port_ops 519 .port_ops = &nv133_port_ops
520 }, 520 },
521 { /* 9: AMD CS5536 (Geode companion) */ 521 { /* 9: AMD CS5536 (Geode companion) */
522 .flags = ATA_FLAG_SLAVE_POSS, 522 .flags = ATA_FLAG_SLAVE_POSS,
523 .pio_mask = 0x1f, 523 .pio_mask = ATA_PIO4,
524 .mwdma_mask = 0x07, 524 .mwdma_mask = ATA_MWDMA2,
525 .udma_mask = ATA_UDMA5, /* UDMA 100 */ 525 .udma_mask = ATA_UDMA5,
526 .port_ops = &amd100_port_ops 526 .port_ops = &amd100_port_ops
527 } 527 }
528 }; 528 };
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index 6b3092c75ffe..d332cfdb0f30 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -12,7 +12,6 @@
12 * performance Alessandro Zummo <alessandro.zummo@towertech.it> 12 * performance Alessandro Zummo <alessandro.zummo@towertech.it>
13 * 13 *
14 * TODO 14 * TODO
15 * 850 serialization once the core supports it
16 * Investigate no_dsc on 850R 15 * Investigate no_dsc on 850R
17 * Clock detect 16 * Clock detect
18 */ 17 */
@@ -29,7 +28,7 @@
29#include <linux/ata.h> 28#include <linux/ata.h>
30 29
31#define DRV_NAME "pata_artop" 30#define DRV_NAME "pata_artop"
32#define DRV_VERSION "0.4.4" 31#define DRV_VERSION "0.4.5"
33 32
34/* 33/*
35 * The ARTOP has 33 Mhz and "over clocked" timing tables. Until we 34 * The ARTOP has 33 Mhz and "over clocked" timing tables. Until we
@@ -283,6 +282,31 @@ static void artop6260_set_dmamode (struct ata_port *ap, struct ata_device *adev)
283 pci_write_config_byte(pdev, 0x44 + ap->port_no, ultra); 282 pci_write_config_byte(pdev, 0x44 + ap->port_no, ultra);
284} 283}
285 284
285/**
286 * artop_6210_qc_defer - implement serialization
287 * @qc: command
288 *
289 * Issue commands per host on this chip.
290 */
291
292static int artop6210_qc_defer(struct ata_queued_cmd *qc)
293{
294 struct ata_host *host = qc->ap->host;
295 struct ata_port *alt = host->ports[1 ^ qc->ap->port_no];
296 int rc;
297
298 /* First apply the usual rules */
299 rc = ata_std_qc_defer(qc);
300 if (rc != 0)
301 return rc;
302
303 /* Now apply serialization rules. Only allow a command if the
304 other channel state machine is idle */
305 if (alt && alt->qc_active)
306 return ATA_DEFER_PORT;
307 return 0;
308}
309
286static struct scsi_host_template artop_sht = { 310static struct scsi_host_template artop_sht = {
287 ATA_BMDMA_SHT(DRV_NAME), 311 ATA_BMDMA_SHT(DRV_NAME),
288}; 312};
@@ -293,6 +317,7 @@ static struct ata_port_operations artop6210_ops = {
293 .set_piomode = artop6210_set_piomode, 317 .set_piomode = artop6210_set_piomode,
294 .set_dmamode = artop6210_set_dmamode, 318 .set_dmamode = artop6210_set_dmamode,
295 .prereset = artop6210_pre_reset, 319 .prereset = artop6210_pre_reset,
320 .qc_defer = artop6210_qc_defer,
296}; 321};
297 322
298static struct ata_port_operations artop6260_ops = { 323static struct ata_port_operations artop6260_ops = {
@@ -323,29 +348,29 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
323 static int printed_version; 348 static int printed_version;
324 static const struct ata_port_info info_6210 = { 349 static const struct ata_port_info info_6210 = {
325 .flags = ATA_FLAG_SLAVE_POSS, 350 .flags = ATA_FLAG_SLAVE_POSS,
326 .pio_mask = 0x1f, /* pio0-4 */ 351 .pio_mask = ATA_PIO4,
327 .mwdma_mask = 0x07, /* mwdma0-2 */ 352 .mwdma_mask = ATA_MWDMA2,
328 .udma_mask = ATA_UDMA2, 353 .udma_mask = ATA_UDMA2,
329 .port_ops = &artop6210_ops, 354 .port_ops = &artop6210_ops,
330 }; 355 };
331 static const struct ata_port_info info_626x = { 356 static const struct ata_port_info info_626x = {
332 .flags = ATA_FLAG_SLAVE_POSS, 357 .flags = ATA_FLAG_SLAVE_POSS,
333 .pio_mask = 0x1f, /* pio0-4 */ 358 .pio_mask = ATA_PIO4,
334 .mwdma_mask = 0x07, /* mwdma0-2 */ 359 .mwdma_mask = ATA_MWDMA2,
335 .udma_mask = ATA_UDMA4, 360 .udma_mask = ATA_UDMA4,
336 .port_ops = &artop6260_ops, 361 .port_ops = &artop6260_ops,
337 }; 362 };
338 static const struct ata_port_info info_628x = { 363 static const struct ata_port_info info_628x = {
339 .flags = ATA_FLAG_SLAVE_POSS, 364 .flags = ATA_FLAG_SLAVE_POSS,
340 .pio_mask = 0x1f, /* pio0-4 */ 365 .pio_mask = ATA_PIO4,
341 .mwdma_mask = 0x07, /* mwdma0-2 */ 366 .mwdma_mask = ATA_MWDMA2,
342 .udma_mask = ATA_UDMA5, 367 .udma_mask = ATA_UDMA5,
343 .port_ops = &artop6260_ops, 368 .port_ops = &artop6260_ops,
344 }; 369 };
345 static const struct ata_port_info info_628x_fast = { 370 static const struct ata_port_info info_628x_fast = {
346 .flags = ATA_FLAG_SLAVE_POSS, 371 .flags = ATA_FLAG_SLAVE_POSS,
347 .pio_mask = 0x1f, /* pio0-4 */ 372 .pio_mask = ATA_PIO4,
348 .mwdma_mask = 0x07, /* mwdma0-2 */ 373 .mwdma_mask = ATA_MWDMA2,
349 .udma_mask = ATA_UDMA6, 374 .udma_mask = ATA_UDMA6,
350 .port_ops = &artop6260_ops, 375 .port_ops = &artop6260_ops,
351 }; 376 };
@@ -362,12 +387,8 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
362 387
363 if (id->driver_data == 0) { /* 6210 variant */ 388 if (id->driver_data == 0) { /* 6210 variant */
364 ppi[0] = &info_6210; 389 ppi[0] = &info_6210;
365 ppi[1] = &ata_dummy_port_info;
366 /* BIOS may have left us in UDMA, clear it before libata probe */ 390 /* BIOS may have left us in UDMA, clear it before libata probe */
367 pci_write_config_byte(pdev, 0x54, 0); 391 pci_write_config_byte(pdev, 0x54, 0);
368 /* For the moment (also lacks dsc) */
369 printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n");
370 printk(KERN_WARNING "Secondary ATA ports will not be activated.\n");
371 } 392 }
372 else if (id->driver_data == 1) /* 6260 */ 393 else if (id->driver_data == 1) /* 6260 */
373 ppi[0] = &info_626x; 394 ppi[0] = &info_626x;
diff --git a/drivers/ata/pata_at32.c b/drivers/ata/pata_at32.c
index ab61095093b9..5c129f99a7e3 100644
--- a/drivers/ata/pata_at32.c
+++ b/drivers/ata/pata_at32.c
@@ -67,7 +67,9 @@
67 * 67 *
68 * Alter PIO_MASK below according to table to set maximal PIO mode. 68 * Alter PIO_MASK below according to table to set maximal PIO mode.
69 */ 69 */
70#define PIO_MASK (0x1f) 70enum {
71 PIO_MASK = ATA_PIO4,
72};
71 73
72/* 74/*
73 * Struct containing private information about device. 75 * Struct containing private information about device.
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 506adde8ebb3..bec0b8ade66d 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -220,9 +220,9 @@ static int atiixp_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
220{ 220{
221 static const struct ata_port_info info = { 221 static const struct ata_port_info info = {
222 .flags = ATA_FLAG_SLAVE_POSS, 222 .flags = ATA_FLAG_SLAVE_POSS,
223 .pio_mask = 0x1f, 223 .pio_mask = ATA_PIO4,
224 .mwdma_mask = 0x06, /* No MWDMA0 support */ 224 .mwdma_mask = ATA_MWDMA12_ONLY,
225 .udma_mask = 0x3F, 225 .udma_mask = ATA_UDMA5,
226 .port_ops = &atiixp_port_ops 226 .port_ops = &atiixp_port_ops
227 }; 227 };
228 static const struct pci_bits atiixp_enable_bits[] = { 228 static const struct pci_bits atiixp_enable_bits[] = {
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index 1050fed96b2b..c4b47a3e5446 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -1502,7 +1502,7 @@ static struct ata_port_info bfin_port_info[] = {
1502 .flags = ATA_FLAG_SLAVE_POSS 1502 .flags = ATA_FLAG_SLAVE_POSS
1503 | ATA_FLAG_MMIO 1503 | ATA_FLAG_MMIO
1504 | ATA_FLAG_NO_LEGACY, 1504 | ATA_FLAG_NO_LEGACY,
1505 .pio_mask = 0x1f, /* pio0-4 */ 1505 .pio_mask = ATA_PIO4,
1506 .mwdma_mask = 0, 1506 .mwdma_mask = 0,
1507 .udma_mask = 0, 1507 .udma_mask = 0,
1508 .port_ops = &bfin_pata_ops, 1508 .port_ops = &bfin_pata_ops,
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c
index 34a394264c3d..5acf9fa9b39f 100644
--- a/drivers/ata/pata_cmd640.c
+++ b/drivers/ata/pata_cmd640.c
@@ -211,7 +211,7 @@ static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
211{ 211{
212 static const struct ata_port_info info = { 212 static const struct ata_port_info info = {
213 .flags = ATA_FLAG_SLAVE_POSS, 213 .flags = ATA_FLAG_SLAVE_POSS,
214 .pio_mask = 0x1f, 214 .pio_mask = ATA_PIO4,
215 .port_ops = &cmd640_port_ops 215 .port_ops = &cmd640_port_ops
216 }; 216 };
217 const struct ata_port_info *ppi[] = { &info, NULL }; 217 const struct ata_port_info *ppi[] = { &info, NULL };
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index 3167d8fed2f2..f98dffedf4bc 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -299,40 +299,40 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
299 static const struct ata_port_info cmd_info[6] = { 299 static const struct ata_port_info cmd_info[6] = {
300 { /* CMD 643 - no UDMA */ 300 { /* CMD 643 - no UDMA */
301 .flags = ATA_FLAG_SLAVE_POSS, 301 .flags = ATA_FLAG_SLAVE_POSS,
302 .pio_mask = 0x1f, 302 .pio_mask = ATA_PIO4,
303 .mwdma_mask = 0x07, 303 .mwdma_mask = ATA_MWDMA2,
304 .port_ops = &cmd64x_port_ops 304 .port_ops = &cmd64x_port_ops
305 }, 305 },
306 { /* CMD 646 with broken UDMA */ 306 { /* CMD 646 with broken UDMA */
307 .flags = ATA_FLAG_SLAVE_POSS, 307 .flags = ATA_FLAG_SLAVE_POSS,
308 .pio_mask = 0x1f, 308 .pio_mask = ATA_PIO4,
309 .mwdma_mask = 0x07, 309 .mwdma_mask = ATA_MWDMA2,
310 .port_ops = &cmd64x_port_ops 310 .port_ops = &cmd64x_port_ops
311 }, 311 },
312 { /* CMD 646 with working UDMA */ 312 { /* CMD 646 with working UDMA */
313 .flags = ATA_FLAG_SLAVE_POSS, 313 .flags = ATA_FLAG_SLAVE_POSS,
314 .pio_mask = 0x1f, 314 .pio_mask = ATA_PIO4,
315 .mwdma_mask = 0x07, 315 .mwdma_mask = ATA_MWDMA2,
316 .udma_mask = ATA_UDMA2, 316 .udma_mask = ATA_UDMA2,
317 .port_ops = &cmd64x_port_ops 317 .port_ops = &cmd64x_port_ops
318 }, 318 },
319 { /* CMD 646 rev 1 */ 319 { /* CMD 646 rev 1 */
320 .flags = ATA_FLAG_SLAVE_POSS, 320 .flags = ATA_FLAG_SLAVE_POSS,
321 .pio_mask = 0x1f, 321 .pio_mask = ATA_PIO4,
322 .mwdma_mask = 0x07, 322 .mwdma_mask = ATA_MWDMA2,
323 .port_ops = &cmd646r1_port_ops 323 .port_ops = &cmd646r1_port_ops
324 }, 324 },
325 { /* CMD 648 */ 325 { /* CMD 648 */
326 .flags = ATA_FLAG_SLAVE_POSS, 326 .flags = ATA_FLAG_SLAVE_POSS,
327 .pio_mask = 0x1f, 327 .pio_mask = ATA_PIO4,
328 .mwdma_mask = 0x07, 328 .mwdma_mask = ATA_MWDMA2,
329 .udma_mask = ATA_UDMA4, 329 .udma_mask = ATA_UDMA4,
330 .port_ops = &cmd648_port_ops 330 .port_ops = &cmd648_port_ops
331 }, 331 },
332 { /* CMD 649 */ 332 { /* CMD 649 */
333 .flags = ATA_FLAG_SLAVE_POSS, 333 .flags = ATA_FLAG_SLAVE_POSS,
334 .pio_mask = 0x1f, 334 .pio_mask = ATA_PIO4,
335 .mwdma_mask = 0x07, 335 .mwdma_mask = ATA_MWDMA2,
336 .udma_mask = ATA_UDMA5, 336 .udma_mask = ATA_UDMA5,
337 .port_ops = &cmd648_port_ops 337 .port_ops = &cmd648_port_ops
338 } 338 }
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index 1186bcd2781c..db6a96984f3f 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -158,7 +158,7 @@ static int __devinit cs5520_init_one(struct pci_dev *pdev, const struct pci_devi
158 static const unsigned int ctl_port[] = { 0x3F6, 0x376 }; 158 static const unsigned int ctl_port[] = { 0x3F6, 0x376 };
159 struct ata_port_info pi = { 159 struct ata_port_info pi = {
160 .flags = ATA_FLAG_SLAVE_POSS, 160 .flags = ATA_FLAG_SLAVE_POSS,
161 .pio_mask = 0x1f, 161 .pio_mask = ATA_PIO4,
162 .port_ops = &cs5520_port_ops, 162 .port_ops = &cs5520_port_ops,
163 }; 163 };
164 const struct ata_port_info *ppi[2]; 164 const struct ata_port_info *ppi[2];
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index bba453381f44..c974b05e4129 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -298,15 +298,15 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
298{ 298{
299 static const struct ata_port_info info = { 299 static const struct ata_port_info info = {
300 .flags = ATA_FLAG_SLAVE_POSS, 300 .flags = ATA_FLAG_SLAVE_POSS,
301 .pio_mask = 0x1f, 301 .pio_mask = ATA_PIO4,
302 .mwdma_mask = 0x07, 302 .mwdma_mask = ATA_MWDMA2,
303 .udma_mask = 0x07, 303 .udma_mask = ATA_UDMA2,
304 .port_ops = &cs5530_port_ops 304 .port_ops = &cs5530_port_ops
305 }; 305 };
306 /* The docking connector doesn't do UDMA, and it seems not MWDMA */ 306 /* The docking connector doesn't do UDMA, and it seems not MWDMA */
307 static const struct ata_port_info info_palmax_secondary = { 307 static const struct ata_port_info info_palmax_secondary = {
308 .flags = ATA_FLAG_SLAVE_POSS, 308 .flags = ATA_FLAG_SLAVE_POSS,
309 .pio_mask = 0x1f, 309 .pio_mask = ATA_PIO4,
310 .port_ops = &cs5530_port_ops 310 .port_ops = &cs5530_port_ops
311 }; 311 };
312 const struct ata_port_info *ppi[] = { &info, NULL }; 312 const struct ata_port_info *ppi[] = { &info, NULL };
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index 8b236af84c2e..d33aa28239a9 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -181,8 +181,8 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
181{ 181{
182 static const struct ata_port_info info = { 182 static const struct ata_port_info info = {
183 .flags = ATA_FLAG_SLAVE_POSS, 183 .flags = ATA_FLAG_SLAVE_POSS,
184 .pio_mask = 0x1f, 184 .pio_mask = ATA_PIO4,
185 .mwdma_mask = 0x07, 185 .mwdma_mask = ATA_MWDMA2,
186 .udma_mask = ATA_UDMA4, 186 .udma_mask = ATA_UDMA4,
187 .port_ops = &cs5535_port_ops 187 .port_ops = &cs5535_port_ops
188 }; 188 };
diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c
index afed92976198..6da4cb486c8d 100644
--- a/drivers/ata/pata_cs5536.c
+++ b/drivers/ata/pata_cs5536.c
@@ -241,8 +241,8 @@ static int cs5536_init_one(struct pci_dev *dev, const struct pci_device_id *id)
241{ 241{
242 static const struct ata_port_info info = { 242 static const struct ata_port_info info = {
243 .flags = ATA_FLAG_SLAVE_POSS, 243 .flags = ATA_FLAG_SLAVE_POSS,
244 .pio_mask = 0x1f, 244 .pio_mask = ATA_PIO4,
245 .mwdma_mask = 0x07, 245 .mwdma_mask = ATA_MWDMA2,
246 .udma_mask = ATA_UDMA5, 246 .udma_mask = ATA_UDMA5,
247 .port_ops = &cs5536_port_ops, 247 .port_ops = &cs5536_port_ops,
248 }; 248 };
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c
index d546425cd380..8fb040bf7361 100644
--- a/drivers/ata/pata_cypress.c
+++ b/drivers/ata/pata_cypress.c
@@ -124,8 +124,8 @@ static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *i
124{ 124{
125 static const struct ata_port_info info = { 125 static const struct ata_port_info info = {
126 .flags = ATA_FLAG_SLAVE_POSS, 126 .flags = ATA_FLAG_SLAVE_POSS,
127 .pio_mask = 0x1f, 127 .pio_mask = ATA_PIO4,
128 .mwdma_mask = 0x07, 128 .mwdma_mask = ATA_MWDMA2,
129 .port_ops = &cy82c693_port_ops 129 .port_ops = &cy82c693_port_ops
130 }; 130 };
131 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; 131 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
index ac6392ea35b0..2085e0a3a05a 100644
--- a/drivers/ata/pata_efar.c
+++ b/drivers/ata/pata_efar.c
@@ -251,9 +251,9 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
251 static int printed_version; 251 static int printed_version;
252 static const struct ata_port_info info = { 252 static const struct ata_port_info info = {
253 .flags = ATA_FLAG_SLAVE_POSS, 253 .flags = ATA_FLAG_SLAVE_POSS,
254 .pio_mask = 0x1f, /* pio0-4 */ 254 .pio_mask = ATA_PIO4,
255 .mwdma_mask = 0x07, /* mwdma1-2 */ 255 .mwdma_mask = ATA_MWDMA2,
256 .udma_mask = 0x0f, /* UDMA 66 */ 256 .udma_mask = ATA_UDMA4,
257 .port_ops = &efar_ops, 257 .port_ops = &efar_ops,
258 }; 258 };
259 const struct ata_port_info *ppi[] = { &info, NULL }; 259 const struct ata_port_info *ppi[] = { &info, NULL };
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index 65c28e5a6cd7..d7f2da127d13 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -336,8 +336,8 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
336{ 336{
337 static const struct ata_port_info info_hpt366 = { 337 static const struct ata_port_info info_hpt366 = {
338 .flags = ATA_FLAG_SLAVE_POSS, 338 .flags = ATA_FLAG_SLAVE_POSS,
339 .pio_mask = 0x1f, 339 .pio_mask = ATA_PIO4,
340 .mwdma_mask = 0x07, 340 .mwdma_mask = ATA_MWDMA2,
341 .udma_mask = ATA_UDMA4, 341 .udma_mask = ATA_UDMA4,
342 .port_ops = &hpt366_port_ops 342 .port_ops = &hpt366_port_ops
343 }; 343 };
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 42163998de9a..81ab57003aba 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -753,55 +753,55 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
753 /* HPT370 - UDMA100 */ 753 /* HPT370 - UDMA100 */
754 static const struct ata_port_info info_hpt370 = { 754 static const struct ata_port_info info_hpt370 = {
755 .flags = ATA_FLAG_SLAVE_POSS, 755 .flags = ATA_FLAG_SLAVE_POSS,
756 .pio_mask = 0x1f, 756 .pio_mask = ATA_PIO4,
757 .mwdma_mask = 0x07, 757 .mwdma_mask = ATA_MWDMA2,
758 .udma_mask = ATA_UDMA5, 758 .udma_mask = ATA_UDMA5,
759 .port_ops = &hpt370_port_ops 759 .port_ops = &hpt370_port_ops
760 }; 760 };
761 /* HPT370A - UDMA100 */ 761 /* HPT370A - UDMA100 */
762 static const struct ata_port_info info_hpt370a = { 762 static const struct ata_port_info info_hpt370a = {
763 .flags = ATA_FLAG_SLAVE_POSS, 763 .flags = ATA_FLAG_SLAVE_POSS,
764 .pio_mask = 0x1f, 764 .pio_mask = ATA_PIO4,
765 .mwdma_mask = 0x07, 765 .mwdma_mask = ATA_MWDMA2,
766 .udma_mask = ATA_UDMA5, 766 .udma_mask = ATA_UDMA5,
767 .port_ops = &hpt370a_port_ops 767 .port_ops = &hpt370a_port_ops
768 }; 768 };
769 /* HPT370 - UDMA100 */ 769 /* HPT370 - UDMA100 */
770 static const struct ata_port_info info_hpt370_33 = { 770 static const struct ata_port_info info_hpt370_33 = {
771 .flags = ATA_FLAG_SLAVE_POSS, 771 .flags = ATA_FLAG_SLAVE_POSS,
772 .pio_mask = 0x1f, 772 .pio_mask = ATA_PIO4,
773 .mwdma_mask = 0x07, 773 .mwdma_mask = ATA_MWDMA2,
774 .udma_mask = ATA_UDMA5, 774 .udma_mask = ATA_UDMA5,
775 .port_ops = &hpt370_port_ops 775 .port_ops = &hpt370_port_ops
776 }; 776 };
777 /* HPT370A - UDMA100 */ 777 /* HPT370A - UDMA100 */
778 static const struct ata_port_info info_hpt370a_33 = { 778 static const struct ata_port_info info_hpt370a_33 = {
779 .flags = ATA_FLAG_SLAVE_POSS, 779 .flags = ATA_FLAG_SLAVE_POSS,
780 .pio_mask = 0x1f, 780 .pio_mask = ATA_PIO4,
781 .mwdma_mask = 0x07, 781 .mwdma_mask = ATA_MWDMA2,
782 .udma_mask = ATA_UDMA5, 782 .udma_mask = ATA_UDMA5,
783 .port_ops = &hpt370a_port_ops 783 .port_ops = &hpt370a_port_ops
784 }; 784 };
785 /* HPT371, 372 and friends - UDMA133 */ 785 /* HPT371, 372 and friends - UDMA133 */
786 static const struct ata_port_info info_hpt372 = { 786 static const struct ata_port_info info_hpt372 = {
787 .flags = ATA_FLAG_SLAVE_POSS, 787 .flags = ATA_FLAG_SLAVE_POSS,
788 .pio_mask = 0x1f, 788 .pio_mask = ATA_PIO4,
789 .mwdma_mask = 0x07, 789 .mwdma_mask = ATA_MWDMA2,
790 .udma_mask = ATA_UDMA6, 790 .udma_mask = ATA_UDMA6,
791 .port_ops = &hpt372_port_ops 791 .port_ops = &hpt372_port_ops
792 }; 792 };
793 /* HPT374 - UDMA100, function 1 uses different prereset method */ 793 /* HPT374 - UDMA100, function 1 uses different prereset method */
794 static const struct ata_port_info info_hpt374_fn0 = { 794 static const struct ata_port_info info_hpt374_fn0 = {
795 .flags = ATA_FLAG_SLAVE_POSS, 795 .flags = ATA_FLAG_SLAVE_POSS,
796 .pio_mask = 0x1f, 796 .pio_mask = ATA_PIO4,
797 .mwdma_mask = 0x07, 797 .mwdma_mask = ATA_MWDMA2,
798 .udma_mask = ATA_UDMA5, 798 .udma_mask = ATA_UDMA5,
799 .port_ops = &hpt372_port_ops 799 .port_ops = &hpt372_port_ops
800 }; 800 };
801 static const struct ata_port_info info_hpt374_fn1 = { 801 static const struct ata_port_info info_hpt374_fn1 = {
802 .flags = ATA_FLAG_SLAVE_POSS, 802 .flags = ATA_FLAG_SLAVE_POSS,
803 .pio_mask = 0x1f, 803 .pio_mask = ATA_PIO4,
804 .mwdma_mask = 0x07, 804 .mwdma_mask = ATA_MWDMA2,
805 .udma_mask = ATA_UDMA5, 805 .udma_mask = ATA_UDMA5,
806 .port_ops = &hpt374_fn1_port_ops 806 .port_ops = &hpt374_fn1_port_ops
807 }; 807 };
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index d5c9fd7b82bb..3d59fe0a408d 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -441,8 +441,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
441 /* HPT372N and friends - UDMA133 */ 441 /* HPT372N and friends - UDMA133 */
442 static const struct ata_port_info info = { 442 static const struct ata_port_info info = {
443 .flags = ATA_FLAG_SLAVE_POSS, 443 .flags = ATA_FLAG_SLAVE_POSS,
444 .pio_mask = 0x1f, 444 .pio_mask = ATA_PIO4,
445 .mwdma_mask = 0x07, 445 .mwdma_mask = ATA_MWDMA2,
446 .udma_mask = ATA_UDMA6, 446 .udma_mask = ATA_UDMA6,
447 .port_ops = &hpt3x2n_port_ops 447 .port_ops = &hpt3x2n_port_ops
448 }; 448 };
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index f19cc645881a..7e310253b36b 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -188,11 +188,11 @@ static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
188 static int printed_version; 188 static int printed_version;
189 static const struct ata_port_info info = { 189 static const struct ata_port_info info = {
190 .flags = ATA_FLAG_SLAVE_POSS, 190 .flags = ATA_FLAG_SLAVE_POSS,
191 .pio_mask = 0x1f, 191 .pio_mask = ATA_PIO4,
192#if defined(CONFIG_PATA_HPT3X3_DMA) 192#if defined(CONFIG_PATA_HPT3X3_DMA)
193 /* Further debug needed */ 193 /* Further debug needed */
194 .mwdma_mask = 0x07, 194 .mwdma_mask = ATA_MWDMA2,
195 .udma_mask = 0x07, 195 .udma_mask = ATA_UDMA2,
196#endif 196#endif
197 .port_ops = &hpt3x3_port_ops 197 .port_ops = &hpt3x3_port_ops
198 }; 198 };
diff --git a/drivers/ata/pata_icside.c b/drivers/ata/pata_icside.c
index cf9e9848f8b5..e7347db5b6c4 100644
--- a/drivers/ata/pata_icside.c
+++ b/drivers/ata/pata_icside.c
@@ -297,7 +297,7 @@ static int icside_dma_init(struct pata_icside_info *info)
297 297
298 if (ec->dma != NO_DMA && !request_dma(ec->dma, DRV_NAME)) { 298 if (ec->dma != NO_DMA && !request_dma(ec->dma, DRV_NAME)) {
299 state->dma = ec->dma; 299 state->dma = ec->dma;
300 info->mwdma_mask = 0x07; /* MW0..2 */ 300 info->mwdma_mask = ATA_MWDMA2;
301 } 301 }
302 302
303 return 0; 303 return 0;
@@ -473,7 +473,7 @@ static int __devinit pata_icside_add_ports(struct pata_icside_info *info)
473 for (i = 0; i < info->nr_ports; i++) { 473 for (i = 0; i < info->nr_ports; i++) {
474 struct ata_port *ap = host->ports[i]; 474 struct ata_port *ap = host->ports[i];
475 475
476 ap->pio_mask = 0x1f; 476 ap->pio_mask = ATA_PIO4;
477 ap->mwdma_mask = info->mwdma_mask; 477 ap->mwdma_mask = info->mwdma_mask;
478 ap->flags |= ATA_FLAG_SLAVE_POSS; 478 ap->flags |= ATA_FLAG_SLAVE_POSS;
479 ap->ops = &pata_icside_port_ops; 479 ap->ops = &pata_icside_port_ops;
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index 15cdb9148aab..4bceb8803a10 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -17,7 +17,7 @@
17#include <linux/libata.h> 17#include <linux/libata.h>
18 18
19#define DRV_NAME "pata_isapnp" 19#define DRV_NAME "pata_isapnp"
20#define DRV_VERSION "0.2.2" 20#define DRV_VERSION "0.2.5"
21 21
22static struct scsi_host_template isapnp_sht = { 22static struct scsi_host_template isapnp_sht = {
23 ATA_PIO_SHT(DRV_NAME), 23 ATA_PIO_SHT(DRV_NAME),
@@ -28,6 +28,13 @@ static struct ata_port_operations isapnp_port_ops = {
28 .cable_detect = ata_cable_40wire, 28 .cable_detect = ata_cable_40wire,
29}; 29};
30 30
31static struct ata_port_operations isapnp_noalt_port_ops = {
32 .inherits = &ata_sff_port_ops,
33 .cable_detect = ata_cable_40wire,
34 /* No altstatus so we don't want to use the lost interrupt poll */
35 .lost_interrupt = ATA_OP_NULL,
36};
37
31/** 38/**
32 * isapnp_init_one - attach an isapnp interface 39 * isapnp_init_one - attach an isapnp interface
33 * @idev: PnP device 40 * @idev: PnP device
@@ -65,8 +72,8 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
65 72
66 ap = host->ports[0]; 73 ap = host->ports[0];
67 74
68 ap->ops = &isapnp_port_ops; 75 ap->ops = &isapnp_noalt_port_ops;
69 ap->pio_mask = 1; 76 ap->pio_mask = ATA_PIO0;
70 ap->flags |= ATA_FLAG_SLAVE_POSS; 77 ap->flags |= ATA_FLAG_SLAVE_POSS;
71 78
72 ap->ioaddr.cmd_addr = cmd_addr; 79 ap->ioaddr.cmd_addr = cmd_addr;
@@ -76,6 +83,7 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
76 pnp_port_start(idev, 1), 1); 83 pnp_port_start(idev, 1), 1);
77 ap->ioaddr.altstatus_addr = ctl_addr; 84 ap->ioaddr.altstatus_addr = ctl_addr;
78 ap->ioaddr.ctl_addr = ctl_addr; 85 ap->ioaddr.ctl_addr = ctl_addr;
86 ap->ops = &isapnp_port_ops;
79 } 87 }
80 88
81 ata_sff_std_ports(&ap->ioaddr); 89 ata_sff_std_ports(&ap->ioaddr);
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c
index c113d7c079c8..f156da8076f7 100644
--- a/drivers/ata/pata_it8213.c
+++ b/drivers/ata/pata_it8213.c
@@ -262,8 +262,8 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en
262 static int printed_version; 262 static int printed_version;
263 static const struct ata_port_info info = { 263 static const struct ata_port_info info = {
264 .flags = ATA_FLAG_SLAVE_POSS, 264 .flags = ATA_FLAG_SLAVE_POSS,
265 .pio_mask = 0x1f, /* pio0-4 */ 265 .pio_mask = ATA_PIO4,
266 .mwdma_mask = 0x07, /* mwdma0-2 */ 266 .mwdma_mask = ATA_MWDMA2,
267 .udma_mask = ATA_UDMA4, /* FIXME: want UDMA 100? */ 267 .udma_mask = ATA_UDMA4, /* FIXME: want UDMA 100? */
268 .port_ops = &it8213_ops, 268 .port_ops = &it8213_ops,
269 }; 269 };
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index b05b86a912c5..188bc2fcd22c 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -875,29 +875,29 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
875 875
876 static const struct ata_port_info info_smart = { 876 static const struct ata_port_info info_smart = {
877 .flags = ATA_FLAG_SLAVE_POSS, 877 .flags = ATA_FLAG_SLAVE_POSS,
878 .pio_mask = 0x1f, 878 .pio_mask = ATA_PIO4,
879 .mwdma_mask = 0x07, 879 .mwdma_mask = ATA_MWDMA2,
880 .udma_mask = ATA_UDMA6, 880 .udma_mask = ATA_UDMA6,
881 .port_ops = &it821x_smart_port_ops 881 .port_ops = &it821x_smart_port_ops
882 }; 882 };
883 static const struct ata_port_info info_passthru = { 883 static const struct ata_port_info info_passthru = {
884 .flags = ATA_FLAG_SLAVE_POSS, 884 .flags = ATA_FLAG_SLAVE_POSS,
885 .pio_mask = 0x1f, 885 .pio_mask = ATA_PIO4,
886 .mwdma_mask = 0x07, 886 .mwdma_mask = ATA_MWDMA2,
887 .udma_mask = ATA_UDMA6, 887 .udma_mask = ATA_UDMA6,
888 .port_ops = &it821x_passthru_port_ops 888 .port_ops = &it821x_passthru_port_ops
889 }; 889 };
890 static const struct ata_port_info info_rdc = { 890 static const struct ata_port_info info_rdc = {
891 .flags = ATA_FLAG_SLAVE_POSS, 891 .flags = ATA_FLAG_SLAVE_POSS,
892 .pio_mask = 0x1f, 892 .pio_mask = ATA_PIO4,
893 .mwdma_mask = 0x07, 893 .mwdma_mask = ATA_MWDMA2,
894 .udma_mask = ATA_UDMA6, 894 .udma_mask = ATA_UDMA6,
895 .port_ops = &it821x_rdc_port_ops 895 .port_ops = &it821x_rdc_port_ops
896 }; 896 };
897 static const struct ata_port_info info_rdc_11 = { 897 static const struct ata_port_info info_rdc_11 = {
898 .flags = ATA_FLAG_SLAVE_POSS, 898 .flags = ATA_FLAG_SLAVE_POSS,
899 .pio_mask = 0x1f, 899 .pio_mask = ATA_PIO4,
900 .mwdma_mask = 0x07, 900 .mwdma_mask = ATA_MWDMA2,
901 /* No UDMA */ 901 /* No UDMA */
902 .port_ops = &it821x_rdc_port_ops 902 .port_ops = &it821x_rdc_port_ops
903 }; 903 };
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index b173c157ab00..19fdecf319a6 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -176,7 +176,7 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
176 ap = host->ports[0]; 176 ap = host->ports[0];
177 177
178 ap->ops = &ixp4xx_port_ops; 178 ap->ops = &ixp4xx_port_ops;
179 ap->pio_mask = 0x1f; /* PIO4 */ 179 ap->pio_mask = ATA_PIO4;
180 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY | ATA_FLAG_NO_ATAPI; 180 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY | ATA_FLAG_NO_ATAPI;
181 181
182 ixp4xx_setup_port(ap, data, cs0->start, cs1->start); 182 ixp4xx_setup_port(ap, data, cs0->start, cs1->start);
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 38cf1ab2d289..3a1474ac8838 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -136,8 +136,8 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i
136 static const struct ata_port_info info = { 136 static const struct ata_port_info info = {
137 .flags = ATA_FLAG_SLAVE_POSS, 137 .flags = ATA_FLAG_SLAVE_POSS,
138 138
139 .pio_mask = 0x1f, 139 .pio_mask = ATA_PIO4,
140 .mwdma_mask = 0x07, 140 .mwdma_mask = ATA_MWDMA2,
141 .udma_mask = ATA_UDMA5, 141 .udma_mask = ATA_UDMA5,
142 142
143 .port_ops = &jmicron_ops, 143 .port_ops = &jmicron_ops,
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index e3bc1b436284..3f830f0fe2cc 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -129,7 +129,7 @@ static int qdi; /* Set to probe QDI controllers */
129static int winbond; /* Set to probe Winbond controllers, 129static int winbond; /* Set to probe Winbond controllers,
130 give I/O port if non standard */ 130 give I/O port if non standard */
131static int autospeed; /* Chip present which snoops speed changes */ 131static int autospeed; /* Chip present which snoops speed changes */
132static int pio_mask = 0x1F; /* PIO range for autospeed devices */ 132static int pio_mask = ATA_PIO4; /* PIO range for autospeed devices */
133static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */ 133static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */
134 134
135/** 135/**
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index 76e399bf8c1b..2096fb737f82 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -126,8 +126,8 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
126 static const struct ata_port_info info = { 126 static const struct ata_port_info info = {
127 .flags = ATA_FLAG_SLAVE_POSS, 127 .flags = ATA_FLAG_SLAVE_POSS,
128 128
129 .pio_mask = 0x1f, 129 .pio_mask = ATA_PIO4,
130 .mwdma_mask = 0x07, 130 .mwdma_mask = ATA_MWDMA2,
131 .udma_mask = ATA_UDMA5, 131 .udma_mask = ATA_UDMA5,
132 132
133 .port_ops = &marvell_ops, 133 .port_ops = &marvell_ops,
@@ -136,8 +136,8 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
136 /* Slave possible as its magically mapped not real */ 136 /* Slave possible as its magically mapped not real */
137 .flags = ATA_FLAG_SLAVE_POSS, 137 .flags = ATA_FLAG_SLAVE_POSS,
138 138
139 .pio_mask = 0x1f, 139 .pio_mask = ATA_PIO4,
140 .mwdma_mask = 0x07, 140 .mwdma_mask = ATA_MWDMA2,
141 .udma_mask = ATA_UDMA6, 141 .udma_mask = ATA_UDMA6,
142 142
143 .port_ops = &marvell_ops, 143 .port_ops = &marvell_ops,
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 50ae6d13078a..68d27bc70d06 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -737,10 +737,10 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
737 */ 737 */
738 prop = of_get_property(op->node, "mwdma-mode", &proplen); 738 prop = of_get_property(op->node, "mwdma-mode", &proplen);
739 if ((prop) && (proplen >= 4)) 739 if ((prop) && (proplen >= 4))
740 mwdma_mask = 0x7 & ((1 << (*prop + 1)) - 1); 740 mwdma_mask = ATA_MWDMA2 & ((1 << (*prop + 1)) - 1);
741 prop = of_get_property(op->node, "udma-mode", &proplen); 741 prop = of_get_property(op->node, "udma-mode", &proplen);
742 if ((prop) && (proplen >= 4)) 742 if ((prop) && (proplen >= 4))
743 udma_mask = 0x7 & ((1 << (*prop + 1)) - 1); 743 udma_mask = ATA_UDMA2 & ((1 << (*prop + 1)) - 1);
744 744
745 ata_irq = irq_of_parse_and_map(op->node, 0); 745 ata_irq = irq_of_parse_and_map(op->node, 0);
746 if (ata_irq == NO_IRQ) { 746 if (ata_irq == NO_IRQ) {
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index aa576cac4d17..b21f0021f54a 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -200,7 +200,7 @@ static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
200 the MPIIX your box goes castors up */ 200 the MPIIX your box goes castors up */
201 201
202 ap->ops = &mpiix_port_ops; 202 ap->ops = &mpiix_port_ops;
203 ap->pio_mask = 0x1F; 203 ap->pio_mask = ATA_PIO4;
204 ap->flags |= ATA_FLAG_SLAVE_POSS; 204 ap->flags |= ATA_FLAG_SLAVE_POSS;
205 205
206 ap->ioaddr.cmd_addr = cmd_addr; 206 ap->ioaddr.cmd_addr = cmd_addr;
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c
index 9dc05e1656a8..bdb236957cb9 100644
--- a/drivers/ata/pata_netcell.c
+++ b/drivers/ata/pata_netcell.c
@@ -51,8 +51,8 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e
51 .flags = ATA_FLAG_SLAVE_POSS, 51 .flags = ATA_FLAG_SLAVE_POSS,
52 /* Actually we don't really care about these as the 52 /* Actually we don't really care about these as the
53 firmware deals with it */ 53 firmware deals with it */
54 .pio_mask = 0x1f, /* pio0-4 */ 54 .pio_mask = ATA_PIO4,
55 .mwdma_mask = 0x07, /* mwdma0-2 */ 55 .mwdma_mask = ATA_MWDMA2,
56 .udma_mask = ATA_UDMA5, /* UDMA 133 */ 56 .udma_mask = ATA_UDMA5, /* UDMA 133 */
57 .port_ops = &netcell_ops, 57 .port_ops = &netcell_ops,
58 }; 58 };
diff --git a/drivers/ata/pata_ninja32.c b/drivers/ata/pata_ninja32.c
index 4dd9a3b031e4..0fb6b1b1e634 100644
--- a/drivers/ata/pata_ninja32.c
+++ b/drivers/ata/pata_ninja32.c
@@ -136,7 +136,7 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id)
136 if (!base) 136 if (!base)
137 return -ENOMEM; 137 return -ENOMEM;
138 ap->ops = &ninja32_port_ops; 138 ap->ops = &ninja32_port_ops;
139 ap->pio_mask = 0x1F; 139 ap->pio_mask = ATA_PIO4;
140 ap->flags |= ATA_FLAG_SLAVE_POSS; 140 ap->flags |= ATA_FLAG_SLAVE_POSS;
141 141
142 ap->ioaddr.cmd_addr = base + 0x10; 142 ap->ioaddr.cmd_addr = base + 0x10;
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
index 40d411c460de..ca53fac06717 100644
--- a/drivers/ata/pata_ns87410.c
+++ b/drivers/ata/pata_ns87410.c
@@ -144,7 +144,7 @@ static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id)
144{ 144{
145 static const struct ata_port_info info = { 145 static const struct ata_port_info info = {
146 .flags = ATA_FLAG_SLAVE_POSS, 146 .flags = ATA_FLAG_SLAVE_POSS,
147 .pio_mask = 0x0F, 147 .pio_mask = ATA_PIO3,
148 .port_ops = &ns87410_port_ops 148 .port_ops = &ns87410_port_ops
149 }; 149 };
150 const struct ata_port_info *ppi[] = { &info, NULL }; 150 const struct ata_port_info *ppi[] = { &info, NULL };
diff --git a/drivers/ata/pata_ns87415.c b/drivers/ata/pata_ns87415.c
index 89bf5f865d6a..773b1590b492 100644
--- a/drivers/ata/pata_ns87415.c
+++ b/drivers/ata/pata_ns87415.c
@@ -346,8 +346,8 @@ static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *e
346 static int printed_version; 346 static int printed_version;
347 static const struct ata_port_info info = { 347 static const struct ata_port_info info = {
348 .flags = ATA_FLAG_SLAVE_POSS, 348 .flags = ATA_FLAG_SLAVE_POSS,
349 .pio_mask = 0x1f, /* pio0-4 */ 349 .pio_mask = ATA_PIO4,
350 .mwdma_mask = 0x07, /* mwdma0-2 */ 350 .mwdma_mask = ATA_MWDMA2,
351 .port_ops = &ns87415_pata_ops, 351 .port_ops = &ns87415_pata_ops,
352 }; 352 };
353 const struct ata_port_info *ppi[] = { &info, NULL }; 353 const struct ata_port_info *ppi[] = { &info, NULL };
@@ -355,8 +355,8 @@ static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *e
355#if defined(CONFIG_SUPERIO) 355#if defined(CONFIG_SUPERIO)
356 static const struct ata_port_info info87560 = { 356 static const struct ata_port_info info87560 = {
357 .flags = ATA_FLAG_SLAVE_POSS, 357 .flags = ATA_FLAG_SLAVE_POSS,
358 .pio_mask = 0x1f, /* pio0-4 */ 358 .pio_mask = ATA_PIO4,
359 .mwdma_mask = 0x07, /* mwdma0-2 */ 359 .mwdma_mask = ATA_MWDMA2,
360 .port_ops = &ns87560_pata_ops, 360 .port_ops = &ns87560_pata_ops,
361 }; 361 };
362 362
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index 0fe4ef309c62..efe2c1985af3 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -871,7 +871,7 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
871 ap->private_data = cf_port; 871 ap->private_data = cf_port;
872 cf_port->ap = ap; 872 cf_port->ap = ap;
873 ap->ops = &octeon_cf_ops; 873 ap->ops = &octeon_cf_ops;
874 ap->pio_mask = 0x7f; /* Support PIO 0-6 */ 874 ap->pio_mask = ATA_PIO6;
875 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY 875 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY
876 | ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING; 876 | ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING;
877 877
@@ -900,7 +900,7 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
900 ap->ioaddr.ctl_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; 901 octeon_cf_ops.sff_data_xfer = octeon_cf_data_xfer16;
902 902
903 ap->mwdma_mask = 0x1f; /* Support MWDMA 0-4 */ 903 ap->mwdma_mask = ATA_MWDMA4;
904 irq = platform_get_irq(pdev, 0); 904 irq = platform_get_irq(pdev, 0);
905 irq_handler = octeon_cf_interrupt; 905 irq_handler = octeon_cf_interrupt;
906 906
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
index 2c1a91c40c1a..84ac5033ac89 100644
--- a/drivers/ata/pata_oldpiix.c
+++ b/drivers/ata/pata_oldpiix.c
@@ -238,8 +238,8 @@ static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *e
238 static int printed_version; 238 static int printed_version;
239 static const struct ata_port_info info = { 239 static const struct ata_port_info info = {
240 .flags = ATA_FLAG_SLAVE_POSS, 240 .flags = ATA_FLAG_SLAVE_POSS,
241 .pio_mask = 0x1f, /* pio0-4 */ 241 .pio_mask = ATA_PIO4,
242 .mwdma_mask = 0x07, /* mwdma1-2 */ 242 .mwdma_mask = ATA_MWDMA2,
243 .port_ops = &oldpiix_pata_ops, 243 .port_ops = &oldpiix_pata_ops,
244 }; 244 };
245 const struct ata_port_info *ppi[] = { &info, NULL }; 245 const struct ata_port_info *ppi[] = { &info, NULL };
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
index e4fa4d565e96..99eddda2d2e5 100644
--- a/drivers/ata/pata_opti.c
+++ b/drivers/ata/pata_opti.c
@@ -163,7 +163,7 @@ static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id)
163{ 163{
164 static const struct ata_port_info info = { 164 static const struct ata_port_info info = {
165 .flags = ATA_FLAG_SLAVE_POSS, 165 .flags = ATA_FLAG_SLAVE_POSS,
166 .pio_mask = 0x1f, 166 .pio_mask = ATA_PIO4,
167 .port_ops = &opti_port_ops 167 .port_ops = &opti_port_ops
168 }; 168 };
169 const struct ata_port_info *ppi[] = { &info, NULL }; 169 const struct ata_port_info *ppi[] = { &info, NULL };
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index 93bb6e91973f..86885a445f97 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -399,15 +399,15 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
399{ 399{
400 static const struct ata_port_info info_82c700 = { 400 static const struct ata_port_info info_82c700 = {
401 .flags = ATA_FLAG_SLAVE_POSS, 401 .flags = ATA_FLAG_SLAVE_POSS,
402 .pio_mask = 0x1f, 402 .pio_mask = ATA_PIO4,
403 .mwdma_mask = 0x07, 403 .mwdma_mask = ATA_MWDMA2,
404 .port_ops = &optidma_port_ops 404 .port_ops = &optidma_port_ops
405 }; 405 };
406 static const struct ata_port_info info_82c700_udma = { 406 static const struct ata_port_info info_82c700_udma = {
407 .flags = ATA_FLAG_SLAVE_POSS, 407 .flags = ATA_FLAG_SLAVE_POSS,
408 .pio_mask = 0x1f, 408 .pio_mask = ATA_PIO4,
409 .mwdma_mask = 0x07, 409 .mwdma_mask = ATA_MWDMA2,
410 .udma_mask = 0x07, 410 .udma_mask = ATA_UDMA2,
411 .port_ops = &optiplus_port_ops 411 .port_ops = &optiplus_port_ops
412 }; 412 };
413 const struct ata_port_info *ppi[] = { &info_82c700, NULL }; 413 const struct ata_port_info *ppi[] = { &info_82c700, NULL };
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 64b2e2281ee7..f4d009ed50ac 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -42,7 +42,7 @@
42 42
43 43
44#define DRV_NAME "pata_pcmcia" 44#define DRV_NAME "pata_pcmcia"
45#define DRV_VERSION "0.3.3" 45#define DRV_VERSION "0.3.5"
46 46
47/* 47/*
48 * Private data structure to glue stuff together 48 * Private data structure to glue stuff together
@@ -126,6 +126,37 @@ static unsigned int ata_data_xfer_8bit(struct ata_device *dev,
126 return buflen; 126 return buflen;
127} 127}
128 128
129/**
130 * pcmcia_8bit_drain_fifo - Stock FIFO drain logic for SFF controllers
131 * @qc: command
132 *
133 * Drain the FIFO and device of any stuck data following a command
134 * failing to complete. In some cases this is neccessary before a
135 * reset will recover the device.
136 *
137 */
138
139void pcmcia_8bit_drain_fifo(struct ata_queued_cmd *qc)
140{
141 int count;
142 struct ata_port *ap;
143
144 /* We only need to flush incoming data when a command was running */
145 if (qc == NULL || qc->dma_dir == DMA_TO_DEVICE)
146 return;
147
148 ap = qc->ap;
149
150 /* Drain up to 64K of data before we give up this recovery method */
151 for (count = 0; (ap->ops->sff_check_status(ap) & ATA_DRQ)
152 && count++ < 65536;)
153 ioread8(ap->ioaddr.data_addr);
154
155 if (count)
156 ata_port_printk(ap, KERN_WARNING, "drained %d bytes to clear DRQ.\n",
157 count);
158
159}
129 160
130static struct scsi_host_template pcmcia_sht = { 161static struct scsi_host_template pcmcia_sht = {
131 ATA_PIO_SHT(DRV_NAME), 162 ATA_PIO_SHT(DRV_NAME),
@@ -143,6 +174,7 @@ static struct ata_port_operations pcmcia_8bit_port_ops = {
143 .sff_data_xfer = ata_data_xfer_8bit, 174 .sff_data_xfer = ata_data_xfer_8bit,
144 .cable_detect = ata_cable_40wire, 175 .cable_detect = ata_cable_40wire,
145 .set_mode = pcmcia_set_mode_8bit, 176 .set_mode = pcmcia_set_mode_8bit,
177 .drain_fifo = pcmcia_8bit_drain_fifo,
146}; 178};
147 179
148#define CS_CHECK(fn, ret) \ 180#define CS_CHECK(fn, ret) \
@@ -299,7 +331,7 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
299 ap = host->ports[p]; 331 ap = host->ports[p];
300 332
301 ap->ops = ops; 333 ap->ops = ops;
302 ap->pio_mask = 1; /* ISA so PIO 0 cycles */ 334 ap->pio_mask = ATA_PIO0; /* ISA so PIO 0 cycles */
303 ap->flags |= ATA_FLAG_SLAVE_POSS; 335 ap->flags |= ATA_FLAG_SLAVE_POSS;
304 ap->ioaddr.cmd_addr = io_addr + 0x10 * p; 336 ap->ioaddr.cmd_addr = io_addr + 0x10 * p;
305 ap->ioaddr.altstatus_addr = ctl_addr + 0x10 * p; 337 ap->ioaddr.altstatus_addr = ctl_addr + 0x10 * p;
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index e94efccaa482..ca5cad0fd80b 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -152,18 +152,18 @@ static struct ata_port_info pdc2027x_port_info[] = {
152 { 152 {
153 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS | 153 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS |
154 ATA_FLAG_MMIO, 154 ATA_FLAG_MMIO,
155 .pio_mask = 0x1f, /* pio0-4 */ 155 .pio_mask = ATA_PIO4,
156 .mwdma_mask = 0x07, /* mwdma0-2 */ 156 .mwdma_mask = ATA_MWDMA2,
157 .udma_mask = ATA_UDMA5, /* udma0-5 */ 157 .udma_mask = ATA_UDMA5,
158 .port_ops = &pdc2027x_pata100_ops, 158 .port_ops = &pdc2027x_pata100_ops,
159 }, 159 },
160 /* PDC_UDMA_133 */ 160 /* PDC_UDMA_133 */
161 { 161 {
162 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS | 162 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS |
163 ATA_FLAG_MMIO, 163 ATA_FLAG_MMIO,
164 .pio_mask = 0x1f, /* pio0-4 */ 164 .pio_mask = ATA_PIO4,
165 .mwdma_mask = 0x07, /* mwdma0-2 */ 165 .mwdma_mask = ATA_MWDMA2,
166 .udma_mask = ATA_UDMA6, /* udma0-6 */ 166 .udma_mask = ATA_UDMA6,
167 .port_ops = &pdc2027x_pata133_ops, 167 .port_ops = &pdc2027x_pata133_ops,
168 }, 168 },
169}; 169};
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
index 799a6a098712..5fedb3d4032b 100644
--- a/drivers/ata/pata_pdc202xx_old.c
+++ b/drivers/ata/pata_pdc202xx_old.c
@@ -291,22 +291,22 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id
291 static const struct ata_port_info info[3] = { 291 static const struct ata_port_info info[3] = {
292 { 292 {
293 .flags = ATA_FLAG_SLAVE_POSS, 293 .flags = ATA_FLAG_SLAVE_POSS,
294 .pio_mask = 0x1f, 294 .pio_mask = ATA_PIO4,
295 .mwdma_mask = 0x07, 295 .mwdma_mask = ATA_MWDMA2,
296 .udma_mask = ATA_UDMA2, 296 .udma_mask = ATA_UDMA2,
297 .port_ops = &pdc2024x_port_ops 297 .port_ops = &pdc2024x_port_ops
298 }, 298 },
299 { 299 {
300 .flags = ATA_FLAG_SLAVE_POSS, 300 .flags = ATA_FLAG_SLAVE_POSS,
301 .pio_mask = 0x1f, 301 .pio_mask = ATA_PIO4,
302 .mwdma_mask = 0x07, 302 .mwdma_mask = ATA_MWDMA2,
303 .udma_mask = ATA_UDMA4, 303 .udma_mask = ATA_UDMA4,
304 .port_ops = &pdc2026x_port_ops 304 .port_ops = &pdc2026x_port_ops
305 }, 305 },
306 { 306 {
307 .flags = ATA_FLAG_SLAVE_POSS, 307 .flags = ATA_FLAG_SLAVE_POSS,
308 .pio_mask = 0x1f, 308 .pio_mask = ATA_PIO4,
309 .mwdma_mask = 0x07, 309 .mwdma_mask = ATA_MWDMA2,
310 .udma_mask = ATA_UDMA5, 310 .udma_mask = ATA_UDMA5,
311 .port_ops = &pdc2026x_port_ops 311 .port_ops = &pdc2026x_port_ops
312 } 312 }
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index f1b26f7c8e4d..45879dc6fa41 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -212,11 +212,11 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
212 212
213 if (type == 6580) { 213 if (type == 6580) {
214 ap->ops = &qdi6580_port_ops; 214 ap->ops = &qdi6580_port_ops;
215 ap->pio_mask = 0x1F; 215 ap->pio_mask = ATA_PIO4;
216 ap->flags |= ATA_FLAG_SLAVE_POSS; 216 ap->flags |= ATA_FLAG_SLAVE_POSS;
217 } else { 217 } else {
218 ap->ops = &qdi6500_port_ops; 218 ap->ops = &qdi6500_port_ops;
219 ap->pio_mask = 0x07; /* Actually PIO3 !IORDY is possible */ 219 ap->pio_mask = ATA_PIO2; /* Actually PIO3 !IORDY is possible */
220 ap->flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_IORDY; 220 ap->flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_IORDY;
221 } 221 }
222 222
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c
index 695d44ae52c6..4401b332eaab 100644
--- a/drivers/ata/pata_radisys.c
+++ b/drivers/ata/pata_radisys.c
@@ -216,9 +216,9 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e
216 static int printed_version; 216 static int printed_version;
217 static const struct ata_port_info info = { 217 static const struct ata_port_info info = {
218 .flags = ATA_FLAG_SLAVE_POSS, 218 .flags = ATA_FLAG_SLAVE_POSS,
219 .pio_mask = 0x1f, /* pio0-4 */ 219 .pio_mask = ATA_PIO4,
220 .mwdma_mask = 0x07, /* mwdma1-2 */ 220 .mwdma_mask = ATA_MWDMA12_ONLY,
221 .udma_mask = 0x14, /* UDMA33/66 only */ 221 .udma_mask = ATA_UDMA24_ONLY,
222 .port_ops = &radisys_pata_ops, 222 .port_ops = &radisys_pata_ops,
223 }; 223 };
224 const struct ata_port_info *ppi[] = { &info, NULL }; 224 const struct ata_port_info *ppi[] = { &info, NULL };
diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index ebfcda26d639..8e3cdef8a25f 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -48,63 +48,11 @@
48struct rb532_cf_info { 48struct rb532_cf_info {
49 void __iomem *iobase; 49 void __iomem *iobase;
50 unsigned int gpio_line; 50 unsigned int gpio_line;
51 int frozen;
52 unsigned int irq; 51 unsigned int irq;
53}; 52};
54 53
55/* ------------------------------------------------------------------------ */ 54/* ------------------------------------------------------------------------ */
56 55
57static inline void rb532_pata_finish_io(struct ata_port *ap)
58{
59 struct ata_host *ah = ap->host;
60 struct rb532_cf_info *info = ah->private_data;
61
62 /* FIXME: Keep previous delay. If this is merely a fence then
63 ata_sff_sync might be sufficient. */
64 ata_sff_dma_pause(ap);
65 ndelay(RB500_CF_IO_DELAY);
66}
67
68static void rb532_pata_exec_command(struct ata_port *ap,
69 const struct ata_taskfile *tf)
70{
71 writeb(tf->command, ap->ioaddr.command_addr);
72 rb532_pata_finish_io(ap);
73}
74
75static unsigned int rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf,
76 unsigned int buflen, int write_data)
77{
78 struct ata_port *ap = adev->link->ap;
79 void __iomem *ioaddr = ap->ioaddr.data_addr;
80 int retlen = buflen;
81
82 if (write_data) {
83 for (; buflen > 0; buflen--, buf++)
84 writeb(*buf, ioaddr);
85 } else {
86 for (; buflen > 0; buflen--, buf++)
87 *buf = readb(ioaddr);
88 }
89
90 rb532_pata_finish_io(adev->link->ap);
91 return retlen;
92}
93
94static void rb532_pata_freeze(struct ata_port *ap)
95{
96 struct rb532_cf_info *info = ap->host->private_data;
97
98 info->frozen = 1;
99}
100
101static void rb532_pata_thaw(struct ata_port *ap)
102{
103 struct rb532_cf_info *info = ap->host->private_data;
104
105 info->frozen = 0;
106}
107
108static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance) 56static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance)
109{ 57{
110 struct ata_host *ah = dev_instance; 58 struct ata_host *ah = dev_instance;
@@ -112,8 +60,7 @@ static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance)
112 60
113 if (gpio_get_value(info->gpio_line)) { 61 if (gpio_get_value(info->gpio_line)) {
114 set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW); 62 set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW);
115 if (!info->frozen) 63 ata_sff_interrupt(info->irq, dev_instance);
116 ata_sff_interrupt(info->irq, dev_instance);
117 } else { 64 } else {
118 set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH); 65 set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH);
119 } 66 }
@@ -123,10 +70,7 @@ static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance)
123 70
124static struct ata_port_operations rb532_pata_port_ops = { 71static struct ata_port_operations rb532_pata_port_ops = {
125 .inherits = &ata_sff_port_ops, 72 .inherits = &ata_sff_port_ops,
126 .sff_exec_command = rb532_pata_exec_command, 73 .sff_data_xfer = ata_sff_data_xfer32,
127 .sff_data_xfer = rb532_pata_data_xfer,
128 .freeze = rb532_pata_freeze,
129 .thaw = rb532_pata_thaw,
130}; 74};
131 75
132/* ------------------------------------------------------------------------ */ 76/* ------------------------------------------------------------------------ */
@@ -145,7 +89,7 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
145 ap = ah->ports[0]; 89 ap = ah->ports[0];
146 90
147 ap->ops = &rb532_pata_port_ops; 91 ap->ops = &rb532_pata_port_ops;
148 ap->pio_mask = 0x1f; /* PIO4 */ 92 ap->pio_mask = ATA_PIO4;
149 ap->flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO; 93 ap->flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO;
150 94
151 ap->ioaddr.cmd_addr = info->iobase + RB500_CF_REG_BASE; 95 ap->ioaddr.cmd_addr = info->iobase + RB500_CF_REG_BASE;
@@ -160,7 +104,7 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
160 104
161static __devinit int rb532_pata_driver_probe(struct platform_device *pdev) 105static __devinit int rb532_pata_driver_probe(struct platform_device *pdev)
162{ 106{
163 unsigned int irq; 107 int irq;
164 int gpio; 108 int gpio;
165 struct resource *res; 109 struct resource *res;
166 struct ata_host *ah; 110 struct ata_host *ah;
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 46d6bc1bf1e9..0c574c065c62 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -88,7 +88,7 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
88 static int printed_version; 88 static int printed_version;
89 static const struct ata_port_info info = { 89 static const struct ata_port_info info = {
90 .flags = ATA_FLAG_SLAVE_POSS, 90 .flags = ATA_FLAG_SLAVE_POSS,
91 .pio_mask = 0x1f, 91 .pio_mask = ATA_PIO4,
92 .port_ops = &rz1000_port_ops 92 .port_ops = &rz1000_port_ops
93 }; 93 };
94 const struct ata_port_info *ppi[] = { &info, NULL }; 94 const struct ata_port_info *ppi[] = { &info, NULL };
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c
index 9a4bdca54616..f49814d6fd2e 100644
--- a/drivers/ata/pata_sc1200.c
+++ b/drivers/ata/pata_sc1200.c
@@ -2,7 +2,6 @@
2 * New ATA layer SC1200 driver Alan Cox <alan@lxorguk.ukuu.org.uk> 2 * New ATA layer SC1200 driver Alan Cox <alan@lxorguk.ukuu.org.uk>
3 * 3 *
4 * TODO: Mode selection filtering 4 * TODO: Mode selection filtering
5 * TODO: Can't enable second channel until ATA core has serialize
6 * TODO: Needs custom DMA cleanup code 5 * TODO: Needs custom DMA cleanup code
7 * 6 *
8 * Based very heavily on 7 * Based very heavily on
@@ -178,6 +177,31 @@ static unsigned int sc1200_qc_issue(struct ata_queued_cmd *qc)
178 return ata_sff_qc_issue(qc); 177 return ata_sff_qc_issue(qc);
179} 178}
180 179
180/**
181 * sc1200_qc_defer - implement serialization
182 * @qc: command
183 *
184 * Serialize command issue on this controller.
185 */
186
187static int sc1200_qc_defer(struct ata_queued_cmd *qc)
188{
189 struct ata_host *host = qc->ap->host;
190 struct ata_port *alt = host->ports[1 ^ qc->ap->port_no];
191 int rc;
192
193 /* First apply the usual rules */
194 rc = ata_std_qc_defer(qc);
195 if (rc != 0)
196 return rc;
197
198 /* Now apply serialization rules. Only allow a command if the
199 other channel state machine is idle */
200 if (alt && alt->qc_active)
201 return ATA_DEFER_PORT;
202 return 0;
203}
204
181static struct scsi_host_template sc1200_sht = { 205static struct scsi_host_template sc1200_sht = {
182 ATA_BMDMA_SHT(DRV_NAME), 206 ATA_BMDMA_SHT(DRV_NAME),
183 .sg_tablesize = LIBATA_DUMB_MAX_PRD, 207 .sg_tablesize = LIBATA_DUMB_MAX_PRD,
@@ -187,6 +211,7 @@ static struct ata_port_operations sc1200_port_ops = {
187 .inherits = &ata_bmdma_port_ops, 211 .inherits = &ata_bmdma_port_ops,
188 .qc_prep = ata_sff_dumb_qc_prep, 212 .qc_prep = ata_sff_dumb_qc_prep,
189 .qc_issue = sc1200_qc_issue, 213 .qc_issue = sc1200_qc_issue,
214 .qc_defer = sc1200_qc_defer,
190 .cable_detect = ata_cable_40wire, 215 .cable_detect = ata_cable_40wire,
191 .set_piomode = sc1200_set_piomode, 216 .set_piomode = sc1200_set_piomode,
192 .set_dmamode = sc1200_set_dmamode, 217 .set_dmamode = sc1200_set_dmamode,
@@ -205,13 +230,13 @@ static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
205{ 230{
206 static const struct ata_port_info info = { 231 static const struct ata_port_info info = {
207 .flags = ATA_FLAG_SLAVE_POSS, 232 .flags = ATA_FLAG_SLAVE_POSS,
208 .pio_mask = 0x1f, 233 .pio_mask = ATA_PIO4,
209 .mwdma_mask = 0x07, 234 .mwdma_mask = ATA_MWDMA2,
210 .udma_mask = 0x07, 235 .udma_mask = ATA_UDMA2,
211 .port_ops = &sc1200_port_ops 236 .port_ops = &sc1200_port_ops
212 }; 237 };
213 /* Can't enable port 2 yet, see top comments */ 238 /* Can't enable port 2 yet, see top comments */
214 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; 239 const struct ata_port_info *ppi[] = { &info, };
215 240
216 return ata_pci_sff_init_one(dev, ppi, &sc1200_sht, NULL); 241 return ata_pci_sff_init_one(dev, ppi, &sc1200_sht, NULL);
217} 242}
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index d447f1cb46ec..4257d6b40af4 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -1001,8 +1001,8 @@ static struct ata_port_operations scc_pata_ops = {
1001static struct ata_port_info scc_port_info[] = { 1001static struct ata_port_info scc_port_info[] = {
1002 { 1002 {
1003 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY, 1003 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY,
1004 .pio_mask = 0x1f, /* pio0-4 */ 1004 .pio_mask = ATA_PIO4,
1005 .mwdma_mask = 0x00, 1005 /* No MWDMA */
1006 .udma_mask = ATA_UDMA6, 1006 .udma_mask = ATA_UDMA6,
1007 .port_ops = &scc_pata_ops, 1007 .port_ops = &scc_pata_ops,
1008 }, 1008 },
diff --git a/drivers/ata/pata_sch.c b/drivers/ata/pata_sch.c
index 6aeeeeb34124..99cceb458e2a 100644
--- a/drivers/ata/pata_sch.c
+++ b/drivers/ata/pata_sch.c
@@ -84,9 +84,9 @@ static struct ata_port_operations sch_pata_ops = {
84 84
85static struct ata_port_info sch_port_info = { 85static struct ata_port_info sch_port_info = {
86 .flags = ATA_FLAG_SLAVE_POSS, 86 .flags = ATA_FLAG_SLAVE_POSS,
87 .pio_mask = ATA_PIO4, /* pio0-4 */ 87 .pio_mask = ATA_PIO4,
88 .mwdma_mask = ATA_MWDMA2, /* mwdma0-2 */ 88 .mwdma_mask = ATA_MWDMA2,
89 .udma_mask = ATA_UDMA5, /* udma0-5 */ 89 .udma_mask = ATA_UDMA5,
90 .port_ops = &sch_pata_ops, 90 .port_ops = &sch_pata_ops,
91}; 91};
92 92
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index 8d2fd9dd40c7..beaed12d50e4 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -398,26 +398,26 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
398 static const struct ata_port_info info[4] = { 398 static const struct ata_port_info info[4] = {
399 { /* OSB4 */ 399 { /* OSB4 */
400 .flags = ATA_FLAG_SLAVE_POSS, 400 .flags = ATA_FLAG_SLAVE_POSS,
401 .pio_mask = 0x1f, 401 .pio_mask = ATA_PIO4,
402 .mwdma_mask = 0x07, 402 .mwdma_mask = ATA_MWDMA2,
403 .udma_mask = 0x07, 403 .udma_mask = ATA_UDMA2,
404 .port_ops = &serverworks_osb4_port_ops 404 .port_ops = &serverworks_osb4_port_ops
405 }, { /* OSB4 no UDMA */ 405 }, { /* OSB4 no UDMA */
406 .flags = ATA_FLAG_SLAVE_POSS, 406 .flags = ATA_FLAG_SLAVE_POSS,
407 .pio_mask = 0x1f, 407 .pio_mask = ATA_PIO4,
408 .mwdma_mask = 0x07, 408 .mwdma_mask = ATA_MWDMA2,
409 .udma_mask = 0x00, 409 /* No UDMA */
410 .port_ops = &serverworks_osb4_port_ops 410 .port_ops = &serverworks_osb4_port_ops
411 }, { /* CSB5 */ 411 }, { /* CSB5 */
412 .flags = ATA_FLAG_SLAVE_POSS, 412 .flags = ATA_FLAG_SLAVE_POSS,
413 .pio_mask = 0x1f, 413 .pio_mask = ATA_PIO4,
414 .mwdma_mask = 0x07, 414 .mwdma_mask = ATA_MWDMA2,
415 .udma_mask = ATA_UDMA4, 415 .udma_mask = ATA_UDMA4,
416 .port_ops = &serverworks_csb_port_ops 416 .port_ops = &serverworks_csb_port_ops
417 }, { /* CSB5 - later revisions*/ 417 }, { /* CSB5 - later revisions*/
418 .flags = ATA_FLAG_SLAVE_POSS, 418 .flags = ATA_FLAG_SLAVE_POSS,
419 .pio_mask = 0x1f, 419 .pio_mask = ATA_PIO4,
420 .mwdma_mask = 0x07, 420 .mwdma_mask = ATA_MWDMA2,
421 .udma_mask = ATA_UDMA5, 421 .udma_mask = ATA_UDMA5,
422 .port_ops = &serverworks_csb_port_ops 422 .port_ops = &serverworks_csb_port_ops
423 } 423 }
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 9e764e5747e6..4cb649d8d38c 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -282,15 +282,15 @@ static int __devinit sil680_init_one(struct pci_dev *pdev,
282{ 282{
283 static const struct ata_port_info info = { 283 static const struct ata_port_info info = {
284 .flags = ATA_FLAG_SLAVE_POSS, 284 .flags = ATA_FLAG_SLAVE_POSS,
285 .pio_mask = 0x1f, 285 .pio_mask = ATA_PIO4,
286 .mwdma_mask = 0x07, 286 .mwdma_mask = ATA_MWDMA2,
287 .udma_mask = ATA_UDMA6, 287 .udma_mask = ATA_UDMA6,
288 .port_ops = &sil680_port_ops 288 .port_ops = &sil680_port_ops
289 }; 289 };
290 static const struct ata_port_info info_slow = { 290 static const struct ata_port_info info_slow = {
291 .flags = ATA_FLAG_SLAVE_POSS, 291 .flags = ATA_FLAG_SLAVE_POSS,
292 .pio_mask = 0x1f, 292 .pio_mask = ATA_PIO4,
293 .mwdma_mask = 0x07, 293 .mwdma_mask = ATA_MWDMA2,
294 .udma_mask = ATA_UDMA5, 294 .udma_mask = ATA_UDMA5,
295 .port_ops = &sil680_port_ops 295 .port_ops = &sil680_port_ops
296 }; 296 };
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index 27ceb42a774b..488e77bcd22b 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -552,51 +552,57 @@ static struct ata_port_operations sis_old_ops = {
552 552
553static const struct ata_port_info sis_info = { 553static const struct ata_port_info sis_info = {
554 .flags = ATA_FLAG_SLAVE_POSS, 554 .flags = ATA_FLAG_SLAVE_POSS,
555 .pio_mask = 0x1f, /* pio0-4 */ 555 .pio_mask = ATA_PIO4,
556 .mwdma_mask = 0x07, 556 .mwdma_mask = ATA_MWDMA2,
557 .udma_mask = 0, 557 /* No UDMA */
558 .port_ops = &sis_old_ops, 558 .port_ops = &sis_old_ops,
559}; 559};
560static const struct ata_port_info sis_info33 = { 560static const struct ata_port_info sis_info33 = {
561 .flags = ATA_FLAG_SLAVE_POSS, 561 .flags = ATA_FLAG_SLAVE_POSS,
562 .pio_mask = 0x1f, /* pio0-4 */ 562 .pio_mask = ATA_PIO4,
563 .mwdma_mask = 0x07, 563 .mwdma_mask = ATA_MWDMA2,
564 .udma_mask = ATA_UDMA2, /* UDMA 33 */ 564 .udma_mask = ATA_UDMA2,
565 .port_ops = &sis_old_ops, 565 .port_ops = &sis_old_ops,
566}; 566};
567static const struct ata_port_info sis_info66 = { 567static const struct ata_port_info sis_info66 = {
568 .flags = ATA_FLAG_SLAVE_POSS, 568 .flags = ATA_FLAG_SLAVE_POSS,
569 .pio_mask = 0x1f, /* pio0-4 */ 569 .pio_mask = ATA_PIO4,
570 .udma_mask = ATA_UDMA4, /* UDMA 66 */ 570 /* No MWDMA */
571 .udma_mask = ATA_UDMA4,
571 .port_ops = &sis_66_ops, 572 .port_ops = &sis_66_ops,
572}; 573};
573static const struct ata_port_info sis_info100 = { 574static const struct ata_port_info sis_info100 = {
574 .flags = ATA_FLAG_SLAVE_POSS, 575 .flags = ATA_FLAG_SLAVE_POSS,
575 .pio_mask = 0x1f, /* pio0-4 */ 576 .pio_mask = ATA_PIO4,
577 /* No MWDMA */
576 .udma_mask = ATA_UDMA5, 578 .udma_mask = ATA_UDMA5,
577 .port_ops = &sis_100_ops, 579 .port_ops = &sis_100_ops,
578}; 580};
579static const struct ata_port_info sis_info100_early = { 581static const struct ata_port_info sis_info100_early = {
580 .flags = ATA_FLAG_SLAVE_POSS, 582 .flags = ATA_FLAG_SLAVE_POSS,
583 .pio_mask = ATA_PIO4,
584 /* No MWDMA */
581 .udma_mask = ATA_UDMA5, 585 .udma_mask = ATA_UDMA5,
582 .pio_mask = 0x1f, /* pio0-4 */
583 .port_ops = &sis_66_ops, 586 .port_ops = &sis_66_ops,
584}; 587};
585static const struct ata_port_info sis_info133 = { 588static const struct ata_port_info sis_info133 = {
586 .flags = ATA_FLAG_SLAVE_POSS, 589 .flags = ATA_FLAG_SLAVE_POSS,
587 .pio_mask = 0x1f, /* pio0-4 */ 590 .pio_mask = ATA_PIO4,
591 /* No MWDMA */
588 .udma_mask = ATA_UDMA6, 592 .udma_mask = ATA_UDMA6,
589 .port_ops = &sis_133_ops, 593 .port_ops = &sis_133_ops,
590}; 594};
591const struct ata_port_info sis_info133_for_sata = { 595const struct ata_port_info sis_info133_for_sata = {
592 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 596 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
593 .pio_mask = 0x1f, /* pio0-4 */ 597 .pio_mask = ATA_PIO4,
598 /* No MWDMA */
594 .udma_mask = ATA_UDMA6, 599 .udma_mask = ATA_UDMA6,
595 .port_ops = &sis_133_for_sata_ops, 600 .port_ops = &sis_133_for_sata_ops,
596}; 601};
597static const struct ata_port_info sis_info133_early = { 602static const struct ata_port_info sis_info133_early = {
598 .flags = ATA_FLAG_SLAVE_POSS, 603 .flags = ATA_FLAG_SLAVE_POSS,
599 .pio_mask = 0x1f, /* pio0-4 */ 604 .pio_mask = ATA_PIO4,
605 /* No MWDMA */
600 .udma_mask = ATA_UDMA6, 606 .udma_mask = ATA_UDMA6,
601 .port_ops = &sis_133_early_ops, 607 .port_ops = &sis_133_early_ops,
602}; 608};
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index 1b0e7b6d8ef5..29f733c32066 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -283,13 +283,13 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id
283{ 283{
284 static const struct ata_port_info info_dma = { 284 static const struct ata_port_info info_dma = {
285 .flags = ATA_FLAG_SLAVE_POSS, 285 .flags = ATA_FLAG_SLAVE_POSS,
286 .pio_mask = 0x1f, 286 .pio_mask = ATA_PIO4,
287 .mwdma_mask = 0x07, 287 .mwdma_mask = ATA_MWDMA2,
288 .port_ops = &sl82c105_port_ops 288 .port_ops = &sl82c105_port_ops
289 }; 289 };
290 static const struct ata_port_info info_early = { 290 static const struct ata_port_info info_early = {
291 .flags = ATA_FLAG_SLAVE_POSS, 291 .flags = ATA_FLAG_SLAVE_POSS,
292 .pio_mask = 0x1f, 292 .pio_mask = ATA_PIO4,
293 .port_ops = &sl82c105_port_ops 293 .port_ops = &sl82c105_port_ops
294 }; 294 };
295 /* for now use only the first port */ 295 /* for now use only the first port */
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index ef9597517cdd..f1f13ff222fd 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -191,8 +191,8 @@ static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id)
191{ 191{
192 static const struct ata_port_info info = { 192 static const struct ata_port_info info = {
193 .flags = ATA_FLAG_SLAVE_POSS, 193 .flags = ATA_FLAG_SLAVE_POSS,
194 .pio_mask = 0x1f, 194 .pio_mask = ATA_PIO4,
195 .mwdma_mask = 0x07, 195 .mwdma_mask = ATA_MWDMA2,
196 .port_ops = &triflex_port_ops 196 .port_ops = &triflex_port_ops
197 }; 197 };
198 const struct ata_port_info *ppi[] = { &info, NULL }; 198 const struct ata_port_info *ppi[] = { &info, NULL };
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index ba556d3e6963..b08e6e0f82b6 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -422,46 +422,46 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
422 /* Early VIA without UDMA support */ 422 /* Early VIA without UDMA support */
423 static const struct ata_port_info via_mwdma_info = { 423 static const struct ata_port_info via_mwdma_info = {
424 .flags = ATA_FLAG_SLAVE_POSS, 424 .flags = ATA_FLAG_SLAVE_POSS,
425 .pio_mask = 0x1f, 425 .pio_mask = ATA_PIO4,
426 .mwdma_mask = 0x07, 426 .mwdma_mask = ATA_MWDMA2,
427 .port_ops = &via_port_ops 427 .port_ops = &via_port_ops
428 }; 428 };
429 /* Ditto with IRQ masking required */ 429 /* Ditto with IRQ masking required */
430 static const struct ata_port_info via_mwdma_info_borked = { 430 static const struct ata_port_info via_mwdma_info_borked = {
431 .flags = ATA_FLAG_SLAVE_POSS, 431 .flags = ATA_FLAG_SLAVE_POSS,
432 .pio_mask = 0x1f, 432 .pio_mask = ATA_PIO4,
433 .mwdma_mask = 0x07, 433 .mwdma_mask = ATA_MWDMA2,
434 .port_ops = &via_port_ops_noirq, 434 .port_ops = &via_port_ops_noirq,
435 }; 435 };
436 /* VIA UDMA 33 devices (and borked 66) */ 436 /* VIA UDMA 33 devices (and borked 66) */
437 static const struct ata_port_info via_udma33_info = { 437 static const struct ata_port_info via_udma33_info = {
438 .flags = ATA_FLAG_SLAVE_POSS, 438 .flags = ATA_FLAG_SLAVE_POSS,
439 .pio_mask = 0x1f, 439 .pio_mask = ATA_PIO4,
440 .mwdma_mask = 0x07, 440 .mwdma_mask = ATA_MWDMA2,
441 .udma_mask = ATA_UDMA2, 441 .udma_mask = ATA_UDMA2,
442 .port_ops = &via_port_ops 442 .port_ops = &via_port_ops
443 }; 443 };
444 /* VIA UDMA 66 devices */ 444 /* VIA UDMA 66 devices */
445 static const struct ata_port_info via_udma66_info = { 445 static const struct ata_port_info via_udma66_info = {
446 .flags = ATA_FLAG_SLAVE_POSS, 446 .flags = ATA_FLAG_SLAVE_POSS,
447 .pio_mask = 0x1f, 447 .pio_mask = ATA_PIO4,
448 .mwdma_mask = 0x07, 448 .mwdma_mask = ATA_MWDMA2,
449 .udma_mask = ATA_UDMA4, 449 .udma_mask = ATA_UDMA4,
450 .port_ops = &via_port_ops 450 .port_ops = &via_port_ops
451 }; 451 };
452 /* VIA UDMA 100 devices */ 452 /* VIA UDMA 100 devices */
453 static const struct ata_port_info via_udma100_info = { 453 static const struct ata_port_info via_udma100_info = {
454 .flags = ATA_FLAG_SLAVE_POSS, 454 .flags = ATA_FLAG_SLAVE_POSS,
455 .pio_mask = 0x1f, 455 .pio_mask = ATA_PIO4,
456 .mwdma_mask = 0x07, 456 .mwdma_mask = ATA_MWDMA2,
457 .udma_mask = ATA_UDMA5, 457 .udma_mask = ATA_UDMA5,
458 .port_ops = &via_port_ops 458 .port_ops = &via_port_ops
459 }; 459 };
460 /* UDMA133 with bad AST (All current 133) */ 460 /* UDMA133 with bad AST (All current 133) */
461 static const struct ata_port_info via_udma133_info = { 461 static const struct ata_port_info via_udma133_info = {
462 .flags = ATA_FLAG_SLAVE_POSS, 462 .flags = ATA_FLAG_SLAVE_POSS,
463 .pio_mask = 0x1f, 463 .pio_mask = ATA_PIO4,
464 .mwdma_mask = 0x07, 464 .mwdma_mask = ATA_MWDMA2,
465 .udma_mask = ATA_UDMA6, /* FIXME: should check north bridge */ 465 .udma_mask = ATA_UDMA6, /* FIXME: should check north bridge */
466 .port_ops = &via_port_ops 466 .port_ops = &via_port_ops
467 }; 467 };
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c
index 319e164a3d74..6d8619b6f670 100644
--- a/drivers/ata/pata_winbond.c
+++ b/drivers/ata/pata_winbond.c
@@ -193,7 +193,7 @@ static __init int winbond_init_one(unsigned long port)
193 ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", cmd_port, ctl_port); 193 ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", cmd_port, ctl_port);
194 194
195 ap->ops = &winbond_port_ops; 195 ap->ops = &winbond_port_ops;
196 ap->pio_mask = 0x1F; 196 ap->pio_mask = ATA_PIO4;
197 ap->flags |= ATA_FLAG_SLAVE_POSS; 197 ap->flags |= ATA_FLAG_SLAVE_POSS;
198 ap->ioaddr.cmd_addr = cmd_addr; 198 ap->ioaddr.cmd_addr = cmd_addr;
199 ap->ioaddr.altstatus_addr = ctl_addr; 199 ap->ioaddr.altstatus_addr = ctl_addr;
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c
index be53545c9f64..39588178d028 100644
--- a/drivers/ata/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -148,6 +148,8 @@ static struct scsi_host_template adma_ata_sht = {
148static struct ata_port_operations adma_ata_ops = { 148static struct ata_port_operations adma_ata_ops = {
149 .inherits = &ata_sff_port_ops, 149 .inherits = &ata_sff_port_ops,
150 150
151 .lost_interrupt = ATA_OP_NULL,
152
151 .check_atapi_dma = adma_check_atapi_dma, 153 .check_atapi_dma = adma_check_atapi_dma,
152 .qc_prep = adma_qc_prep, 154 .qc_prep = adma_qc_prep,
153 .qc_issue = adma_qc_issue, 155 .qc_issue = adma_qc_issue,
@@ -166,7 +168,7 @@ static struct ata_port_info adma_port_info[] = {
166 .flags = ATA_FLAG_SLAVE_POSS | 168 .flags = ATA_FLAG_SLAVE_POSS |
167 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO | 169 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO |
168 ATA_FLAG_PIO_POLLING, 170 ATA_FLAG_PIO_POLLING,
169 .pio_mask = 0x10, /* pio4 */ 171 .pio_mask = ATA_PIO4_ONLY,
170 .udma_mask = ATA_UDMA4, 172 .udma_mask = ATA_UDMA4,
171 .port_ops = &adma_ata_ops, 173 .port_ops = &adma_ata_ops,
172 }, 174 },
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 55bc88c1707b..c2e90e1fece0 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -1279,8 +1279,8 @@ static struct ata_port_operations sata_fsl_ops = {
1279static const struct ata_port_info sata_fsl_port_info[] = { 1279static const struct ata_port_info sata_fsl_port_info[] = {
1280 { 1280 {
1281 .flags = SATA_FSL_HOST_FLAGS, 1281 .flags = SATA_FSL_HOST_FLAGS,
1282 .pio_mask = 0x1f, /* pio 0-4 */ 1282 .pio_mask = ATA_PIO4,
1283 .udma_mask = 0x7f, /* udma 0-6 */ 1283 .udma_mask = ATA_UDMA6,
1284 .port_ops = &sata_fsl_ops, 1284 .port_ops = &sata_fsl_ops,
1285 }, 1285 },
1286}; 1286};
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index fbbd87c96f10..305a4f825f53 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -744,8 +744,8 @@ static struct ata_port_operations inic_port_ops = {
744 744
745static struct ata_port_info inic_port_info = { 745static struct ata_port_info inic_port_info = {
746 .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA, 746 .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA,
747 .pio_mask = 0x1f, /* pio0-4 */ 747 .pio_mask = ATA_PIO4,
748 .mwdma_mask = 0x07, /* mwdma0-2 */ 748 .mwdma_mask = ATA_MWDMA2,
749 .udma_mask = ATA_UDMA6, 749 .udma_mask = ATA_UDMA6,
750 .port_ops = &inic_port_ops 750 .port_ops = &inic_port_ops
751}; 751};
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 7007edd2d451..a377226b81c8 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -1,10 +1,13 @@
1/* 1/*
2 * sata_mv.c - Marvell SATA support 2 * sata_mv.c - Marvell SATA support
3 * 3 *
4 * Copyright 2008: Marvell Corporation, all rights reserved. 4 * Copyright 2008-2009: Marvell Corporation, all rights reserved.
5 * Copyright 2005: EMC Corporation, all rights reserved. 5 * Copyright 2005: EMC Corporation, all rights reserved.
6 * Copyright 2005 Red Hat, Inc. All rights reserved. 6 * Copyright 2005 Red Hat, Inc. All rights reserved.
7 * 7 *
8 * Originally written by Brett Russ.
9 * Extensive overhaul and enhancement by Mark Lord <mlord@pobox.com>.
10 *
8 * Please ALWAYS copy linux-ide@vger.kernel.org on emails. 11 * Please ALWAYS copy linux-ide@vger.kernel.org on emails.
9 * 12 *
10 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
@@ -25,20 +28,13 @@
25/* 28/*
26 * sata_mv TODO list: 29 * sata_mv TODO list:
27 * 30 *
28 * --> Errata workaround for NCQ device errors.
29 *
30 * --> More errata workarounds for PCI-X. 31 * --> More errata workarounds for PCI-X.
31 * 32 *
32 * --> Complete a full errata audit for all chipsets to identify others. 33 * --> Complete a full errata audit for all chipsets to identify others.
33 * 34 *
34 * --> ATAPI support (Marvell claims the 60xx/70xx chips can do it).
35 *
36 * --> Develop a low-power-consumption strategy, and implement it. 35 * --> Develop a low-power-consumption strategy, and implement it.
37 * 36 *
38 * --> [Experiment, low priority] Investigate interrupt coalescing. 37 * --> Add sysfs attributes for per-chip / per-HC IRQ coalescing thresholds.
39 * Quite often, especially with PCI Message Signalled Interrupts (MSI),
40 * the overhead reduced by interrupt mitigation is quite often not
41 * worth the latency cost.
42 * 38 *
43 * --> [Experiment, Marvell value added] Is it possible to use target 39 * --> [Experiment, Marvell value added] Is it possible to use target
44 * mode to cross-connect two Linux boxes with Marvell cards? If so, 40 * mode to cross-connect two Linux boxes with Marvell cards? If so,
@@ -68,7 +64,27 @@
68#include <linux/libata.h> 64#include <linux/libata.h>
69 65
70#define DRV_NAME "sata_mv" 66#define DRV_NAME "sata_mv"
71#define DRV_VERSION "1.25" 67#define DRV_VERSION "1.27"
68
69/*
70 * module options
71 */
72
73static int msi;
74#ifdef CONFIG_PCI
75module_param(msi, int, S_IRUGO);
76MODULE_PARM_DESC(msi, "Enable use of PCI MSI (0=off, 1=on)");
77#endif
78
79static int irq_coalescing_io_count;
80module_param(irq_coalescing_io_count, int, S_IRUGO);
81MODULE_PARM_DESC(irq_coalescing_io_count,
82 "IRQ coalescing I/O count threshold (0..255)");
83
84static int irq_coalescing_usecs;
85module_param(irq_coalescing_usecs, int, S_IRUGO);
86MODULE_PARM_DESC(irq_coalescing_usecs,
87 "IRQ coalescing time threshold in usecs");
72 88
73enum { 89enum {
74 /* BAR's are enumerated in terms of pci_resource_start() terms */ 90 /* BAR's are enumerated in terms of pci_resource_start() terms */
@@ -79,13 +95,32 @@ enum {
79 MV_MAJOR_REG_AREA_SZ = 0x10000, /* 64KB */ 95 MV_MAJOR_REG_AREA_SZ = 0x10000, /* 64KB */
80 MV_MINOR_REG_AREA_SZ = 0x2000, /* 8KB */ 96 MV_MINOR_REG_AREA_SZ = 0x2000, /* 8KB */
81 97
98 /* For use with both IRQ coalescing methods ("all ports" or "per-HC" */
99 COAL_CLOCKS_PER_USEC = 150, /* for calculating COAL_TIMEs */
100 MAX_COAL_TIME_THRESHOLD = ((1 << 24) - 1), /* internal clocks count */
101 MAX_COAL_IO_COUNT = 255, /* completed I/O count */
102
82 MV_PCI_REG_BASE = 0, 103 MV_PCI_REG_BASE = 0,
83 MV_IRQ_COAL_REG_BASE = 0x18000, /* 6xxx part only */ 104
84 MV_IRQ_COAL_CAUSE = (MV_IRQ_COAL_REG_BASE + 0x08), 105 /*
85 MV_IRQ_COAL_CAUSE_LO = (MV_IRQ_COAL_REG_BASE + 0x88), 106 * Per-chip ("all ports") interrupt coalescing feature.
86 MV_IRQ_COAL_CAUSE_HI = (MV_IRQ_COAL_REG_BASE + 0x8c), 107 * This is only for GEN_II / GEN_IIE hardware.
87 MV_IRQ_COAL_THRESHOLD = (MV_IRQ_COAL_REG_BASE + 0xcc), 108 *
88 MV_IRQ_COAL_TIME_THRESHOLD = (MV_IRQ_COAL_REG_BASE + 0xd0), 109 * Coalescing defers the interrupt until either the IO_THRESHOLD
110 * (count of completed I/Os) is met, or the TIME_THRESHOLD is met.
111 */
112 MV_COAL_REG_BASE = 0x18000,
113 MV_IRQ_COAL_CAUSE = (MV_COAL_REG_BASE + 0x08),
114 ALL_PORTS_COAL_IRQ = (1 << 4), /* all ports irq event */
115
116 MV_IRQ_COAL_IO_THRESHOLD = (MV_COAL_REG_BASE + 0xcc),
117 MV_IRQ_COAL_TIME_THRESHOLD = (MV_COAL_REG_BASE + 0xd0),
118
119 /*
120 * Registers for the (unused here) transaction coalescing feature:
121 */
122 MV_TRAN_COAL_CAUSE_LO = (MV_COAL_REG_BASE + 0x88),
123 MV_TRAN_COAL_CAUSE_HI = (MV_COAL_REG_BASE + 0x8c),
89 124
90 MV_SATAHC0_REG_BASE = 0x20000, 125 MV_SATAHC0_REG_BASE = 0x20000,
91 MV_FLASH_CTL_OFS = 0x1046c, 126 MV_FLASH_CTL_OFS = 0x1046c,
@@ -117,17 +152,16 @@ enum {
117 152
118 /* Host Flags */ 153 /* Host Flags */
119 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ 154 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */
120 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */
121 155
122 MV_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 156 MV_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
123 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI | 157 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING,
124 ATA_FLAG_PIO_POLLING, 158
159 MV_GEN_I_FLAGS = MV_COMMON_FLAGS | ATA_FLAG_NO_ATAPI,
125 160
126 MV_6XXX_FLAGS = MV_FLAG_IRQ_COALESCE, 161 MV_GEN_II_FLAGS = MV_COMMON_FLAGS | ATA_FLAG_NCQ |
162 ATA_FLAG_PMP | ATA_FLAG_ACPI_SATA,
127 163
128 MV_GENIIE_FLAGS = MV_COMMON_FLAGS | MV_6XXX_FLAGS | 164 MV_GEN_IIE_FLAGS = MV_GEN_II_FLAGS | ATA_FLAG_AN,
129 ATA_FLAG_PMP | ATA_FLAG_ACPI_SATA |
130 ATA_FLAG_NCQ | ATA_FLAG_AN,
131 165
132 CRQB_FLAG_READ = (1 << 0), 166 CRQB_FLAG_READ = (1 << 0),
133 CRQB_TAG_SHIFT = 1, 167 CRQB_TAG_SHIFT = 1,
@@ -180,16 +214,18 @@ enum {
180 PCI_HC_MAIN_IRQ_MASK_OFS = 0x1d64, 214 PCI_HC_MAIN_IRQ_MASK_OFS = 0x1d64,
181 SOC_HC_MAIN_IRQ_CAUSE_OFS = 0x20020, 215 SOC_HC_MAIN_IRQ_CAUSE_OFS = 0x20020,
182 SOC_HC_MAIN_IRQ_MASK_OFS = 0x20024, 216 SOC_HC_MAIN_IRQ_MASK_OFS = 0x20024,
183 ERR_IRQ = (1 << 0), /* shift by port # */ 217 ERR_IRQ = (1 << 0), /* shift by (2 * port #) */
184 DONE_IRQ = (1 << 1), /* shift by port # */ 218 DONE_IRQ = (1 << 1), /* shift by (2 * port #) */
185 HC0_IRQ_PEND = 0x1ff, /* bits 0-8 = HC0's ports */ 219 HC0_IRQ_PEND = 0x1ff, /* bits 0-8 = HC0's ports */
186 HC_SHIFT = 9, /* bits 9-17 = HC1's ports */ 220 HC_SHIFT = 9, /* bits 9-17 = HC1's ports */
221 DONE_IRQ_0_3 = 0x000000aa, /* DONE_IRQ ports 0,1,2,3 */
222 DONE_IRQ_4_7 = (DONE_IRQ_0_3 << HC_SHIFT), /* 4,5,6,7 */
187 PCI_ERR = (1 << 18), 223 PCI_ERR = (1 << 18),
188 TRAN_LO_DONE = (1 << 19), /* 6xxx: IRQ coalescing */ 224 TRAN_COAL_LO_DONE = (1 << 19), /* transaction coalescing */
189 TRAN_HI_DONE = (1 << 20), /* 6xxx: IRQ coalescing */ 225 TRAN_COAL_HI_DONE = (1 << 20), /* transaction coalescing */
190 PORTS_0_3_COAL_DONE = (1 << 8), 226 PORTS_0_3_COAL_DONE = (1 << 8), /* HC0 IRQ coalescing */
191 PORTS_4_7_COAL_DONE = (1 << 17), 227 PORTS_4_7_COAL_DONE = (1 << 17), /* HC1 IRQ coalescing */
192 PORTS_0_7_COAL_DONE = (1 << 21), /* 6xxx: IRQ coalescing */ 228 ALL_PORTS_COAL_DONE = (1 << 21), /* GEN_II(E) IRQ coalescing */
193 GPIO_INT = (1 << 22), 229 GPIO_INT = (1 << 22),
194 SELF_INT = (1 << 23), 230 SELF_INT = (1 << 23),
195 TWSI_INT = (1 << 24), 231 TWSI_INT = (1 << 24),
@@ -205,6 +241,21 @@ enum {
205 HC_COAL_IRQ = (1 << 4), /* IRQ coalescing */ 241 HC_COAL_IRQ = (1 << 4), /* IRQ coalescing */
206 DEV_IRQ = (1 << 8), /* shift by port # */ 242 DEV_IRQ = (1 << 8), /* shift by port # */
207 243
244 /*
245 * Per-HC (Host-Controller) interrupt coalescing feature.
246 * This is present on all chip generations.
247 *
248 * Coalescing defers the interrupt until either the IO_THRESHOLD
249 * (count of completed I/Os) is met, or the TIME_THRESHOLD is met.
250 */
251 HC_IRQ_COAL_IO_THRESHOLD_OFS = 0x000c,
252 HC_IRQ_COAL_TIME_THRESHOLD_OFS = 0x0010,
253
254 SOC_LED_CTRL_OFS = 0x2c,
255 SOC_LED_CTRL_BLINK = (1 << 0), /* Active LED blink */
256 SOC_LED_CTRL_ACT_PRESENCE = (1 << 2), /* Multiplex dev presence */
257 /* with dev activity LED */
258
208 /* Shadow block registers */ 259 /* Shadow block registers */
209 SHD_BLK_OFS = 0x100, 260 SHD_BLK_OFS = 0x100,
210 SHD_CTL_AST_OFS = 0x20, /* ofs from SHD_BLK_OFS */ 261 SHD_CTL_AST_OFS = 0x20, /* ofs from SHD_BLK_OFS */
@@ -346,6 +397,12 @@ enum {
346 EDMA_ARB_CFG_OFS = 0x38, 397 EDMA_ARB_CFG_OFS = 0x38,
347 398
348 EDMA_HALTCOND_OFS = 0x60, /* GenIIe halt conditions */ 399 EDMA_HALTCOND_OFS = 0x60, /* GenIIe halt conditions */
400 EDMA_UNKNOWN_RSVD_OFS = 0x6C, /* GenIIe unknown/reserved */
401
402 BMDMA_CMD_OFS = 0x224, /* bmdma command register */
403 BMDMA_STATUS_OFS = 0x228, /* bmdma status register */
404 BMDMA_PRD_LOW_OFS = 0x22c, /* bmdma PRD addr 31:0 */
405 BMDMA_PRD_HIGH_OFS = 0x230, /* bmdma PRD addr 63:32 */
349 406
350 /* Host private flags (hp_flags) */ 407 /* Host private flags (hp_flags) */
351 MV_HP_FLAG_MSI = (1 << 0), 408 MV_HP_FLAG_MSI = (1 << 0),
@@ -359,12 +416,14 @@ enum {
359 MV_HP_PCIE = (1 << 9), /* PCIe bus/regs: 7042 */ 416 MV_HP_PCIE = (1 << 9), /* PCIe bus/regs: 7042 */
360 MV_HP_CUT_THROUGH = (1 << 10), /* can use EDMA cut-through */ 417 MV_HP_CUT_THROUGH = (1 << 10), /* can use EDMA cut-through */
361 MV_HP_FLAG_SOC = (1 << 11), /* SystemOnChip, no PCI */ 418 MV_HP_FLAG_SOC = (1 << 11), /* SystemOnChip, no PCI */
419 MV_HP_QUIRK_LED_BLINK_EN = (1 << 12), /* is led blinking enabled? */
362 420
363 /* Port private flags (pp_flags) */ 421 /* Port private flags (pp_flags) */
364 MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */ 422 MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */
365 MV_PP_FLAG_NCQ_EN = (1 << 1), /* is EDMA set up for NCQ? */ 423 MV_PP_FLAG_NCQ_EN = (1 << 1), /* is EDMA set up for NCQ? */
366 MV_PP_FLAG_FBS_EN = (1 << 2), /* is EDMA set up for FBS? */ 424 MV_PP_FLAG_FBS_EN = (1 << 2), /* is EDMA set up for FBS? */
367 MV_PP_FLAG_DELAYED_EH = (1 << 3), /* delayed dev err handling */ 425 MV_PP_FLAG_DELAYED_EH = (1 << 3), /* delayed dev err handling */
426 MV_PP_FLAG_FAKE_ATA_BUSY = (1 << 4), /* ignore initial ATA_DRDY */
368}; 427};
369 428
370#define IS_GEN_I(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_I) 429#define IS_GEN_I(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_I)
@@ -433,6 +492,18 @@ struct mv_sg {
433 __le32 reserved; 492 __le32 reserved;
434}; 493};
435 494
495/*
496 * We keep a local cache of a few frequently accessed port
497 * registers here, to avoid having to read them (very slow)
498 * when switching between EDMA and non-EDMA modes.
499 */
500struct mv_cached_regs {
501 u32 fiscfg;
502 u32 ltmode;
503 u32 haltcond;
504 u32 unknown_rsvd;
505};
506
436struct mv_port_priv { 507struct mv_port_priv {
437 struct mv_crqb *crqb; 508 struct mv_crqb *crqb;
438 dma_addr_t crqb_dma; 509 dma_addr_t crqb_dma;
@@ -445,6 +516,7 @@ struct mv_port_priv {
445 unsigned int resp_idx; 516 unsigned int resp_idx;
446 517
447 u32 pp_flags; 518 u32 pp_flags;
519 struct mv_cached_regs cached;
448 unsigned int delayed_eh_pmp_map; 520 unsigned int delayed_eh_pmp_map;
449}; 521};
450 522
@@ -535,7 +607,7 @@ static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio,
535 unsigned int port_no); 607 unsigned int port_no);
536static int mv_stop_edma(struct ata_port *ap); 608static int mv_stop_edma(struct ata_port *ap);
537static int mv_stop_edma_engine(void __iomem *port_mmio); 609static int mv_stop_edma_engine(void __iomem *port_mmio);
538static void mv_edma_cfg(struct ata_port *ap, int want_ncq); 610static void mv_edma_cfg(struct ata_port *ap, int want_ncq, int want_edma);
539 611
540static void mv_pmp_select(struct ata_port *ap, int pmp); 612static void mv_pmp_select(struct ata_port *ap, int pmp);
541static int mv_pmp_hardreset(struct ata_link *link, unsigned int *class, 613static int mv_pmp_hardreset(struct ata_link *link, unsigned int *class,
@@ -546,6 +618,14 @@ static void mv_pmp_error_handler(struct ata_port *ap);
546static void mv_process_crpb_entries(struct ata_port *ap, 618static void mv_process_crpb_entries(struct ata_port *ap,
547 struct mv_port_priv *pp); 619 struct mv_port_priv *pp);
548 620
621static void mv_sff_irq_clear(struct ata_port *ap);
622static int mv_check_atapi_dma(struct ata_queued_cmd *qc);
623static void mv_bmdma_setup(struct ata_queued_cmd *qc);
624static void mv_bmdma_start(struct ata_queued_cmd *qc);
625static void mv_bmdma_stop(struct ata_queued_cmd *qc);
626static u8 mv_bmdma_status(struct ata_port *ap);
627static u8 mv_sff_check_status(struct ata_port *ap);
628
549/* .sg_tablesize is (MV_MAX_SG_CT / 2) in the structures below 629/* .sg_tablesize is (MV_MAX_SG_CT / 2) in the structures below
550 * because we have to allow room for worst case splitting of 630 * because we have to allow room for worst case splitting of
551 * PRDs for 64K boundaries in mv_fill_sg(). 631 * PRDs for 64K boundaries in mv_fill_sg().
@@ -566,6 +646,8 @@ static struct scsi_host_template mv6_sht = {
566static struct ata_port_operations mv5_ops = { 646static struct ata_port_operations mv5_ops = {
567 .inherits = &ata_sff_port_ops, 647 .inherits = &ata_sff_port_ops,
568 648
649 .lost_interrupt = ATA_OP_NULL,
650
569 .qc_defer = mv_qc_defer, 651 .qc_defer = mv_qc_defer,
570 .qc_prep = mv_qc_prep, 652 .qc_prep = mv_qc_prep,
571 .qc_issue = mv_qc_issue, 653 .qc_issue = mv_qc_issue,
@@ -593,6 +675,14 @@ static struct ata_port_operations mv6_ops = {
593 .pmp_softreset = mv_softreset, 675 .pmp_softreset = mv_softreset,
594 .softreset = mv_softreset, 676 .softreset = mv_softreset,
595 .error_handler = mv_pmp_error_handler, 677 .error_handler = mv_pmp_error_handler,
678
679 .sff_check_status = mv_sff_check_status,
680 .sff_irq_clear = mv_sff_irq_clear,
681 .check_atapi_dma = mv_check_atapi_dma,
682 .bmdma_setup = mv_bmdma_setup,
683 .bmdma_start = mv_bmdma_start,
684 .bmdma_stop = mv_bmdma_stop,
685 .bmdma_status = mv_bmdma_status,
596}; 686};
597 687
598static struct ata_port_operations mv_iie_ops = { 688static struct ata_port_operations mv_iie_ops = {
@@ -603,53 +693,49 @@ static struct ata_port_operations mv_iie_ops = {
603 693
604static const struct ata_port_info mv_port_info[] = { 694static const struct ata_port_info mv_port_info[] = {
605 { /* chip_504x */ 695 { /* chip_504x */
606 .flags = MV_COMMON_FLAGS, 696 .flags = MV_GEN_I_FLAGS,
607 .pio_mask = 0x1f, /* pio0-4 */ 697 .pio_mask = 0x1f, /* pio0-4 */
608 .udma_mask = ATA_UDMA6, 698 .udma_mask = ATA_UDMA6,
609 .port_ops = &mv5_ops, 699 .port_ops = &mv5_ops,
610 }, 700 },
611 { /* chip_508x */ 701 { /* chip_508x */
612 .flags = MV_COMMON_FLAGS | MV_FLAG_DUAL_HC, 702 .flags = MV_GEN_I_FLAGS | MV_FLAG_DUAL_HC,
613 .pio_mask = 0x1f, /* pio0-4 */ 703 .pio_mask = 0x1f, /* pio0-4 */
614 .udma_mask = ATA_UDMA6, 704 .udma_mask = ATA_UDMA6,
615 .port_ops = &mv5_ops, 705 .port_ops = &mv5_ops,
616 }, 706 },
617 { /* chip_5080 */ 707 { /* chip_5080 */
618 .flags = MV_COMMON_FLAGS | MV_FLAG_DUAL_HC, 708 .flags = MV_GEN_I_FLAGS | MV_FLAG_DUAL_HC,
619 .pio_mask = 0x1f, /* pio0-4 */ 709 .pio_mask = 0x1f, /* pio0-4 */
620 .udma_mask = ATA_UDMA6, 710 .udma_mask = ATA_UDMA6,
621 .port_ops = &mv5_ops, 711 .port_ops = &mv5_ops,
622 }, 712 },
623 { /* chip_604x */ 713 { /* chip_604x */
624 .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS | 714 .flags = MV_GEN_II_FLAGS,
625 ATA_FLAG_PMP | ATA_FLAG_ACPI_SATA |
626 ATA_FLAG_NCQ,
627 .pio_mask = 0x1f, /* pio0-4 */ 715 .pio_mask = 0x1f, /* pio0-4 */
628 .udma_mask = ATA_UDMA6, 716 .udma_mask = ATA_UDMA6,
629 .port_ops = &mv6_ops, 717 .port_ops = &mv6_ops,
630 }, 718 },
631 { /* chip_608x */ 719 { /* chip_608x */
632 .flags = MV_COMMON_FLAGS | MV_6XXX_FLAGS | 720 .flags = MV_GEN_II_FLAGS | MV_FLAG_DUAL_HC,
633 ATA_FLAG_PMP | ATA_FLAG_ACPI_SATA |
634 ATA_FLAG_NCQ | MV_FLAG_DUAL_HC,
635 .pio_mask = 0x1f, /* pio0-4 */ 721 .pio_mask = 0x1f, /* pio0-4 */
636 .udma_mask = ATA_UDMA6, 722 .udma_mask = ATA_UDMA6,
637 .port_ops = &mv6_ops, 723 .port_ops = &mv6_ops,
638 }, 724 },
639 { /* chip_6042 */ 725 { /* chip_6042 */
640 .flags = MV_GENIIE_FLAGS, 726 .flags = MV_GEN_IIE_FLAGS,
641 .pio_mask = 0x1f, /* pio0-4 */ 727 .pio_mask = 0x1f, /* pio0-4 */
642 .udma_mask = ATA_UDMA6, 728 .udma_mask = ATA_UDMA6,
643 .port_ops = &mv_iie_ops, 729 .port_ops = &mv_iie_ops,
644 }, 730 },
645 { /* chip_7042 */ 731 { /* chip_7042 */
646 .flags = MV_GENIIE_FLAGS, 732 .flags = MV_GEN_IIE_FLAGS,
647 .pio_mask = 0x1f, /* pio0-4 */ 733 .pio_mask = 0x1f, /* pio0-4 */
648 .udma_mask = ATA_UDMA6, 734 .udma_mask = ATA_UDMA6,
649 .port_ops = &mv_iie_ops, 735 .port_ops = &mv_iie_ops,
650 }, 736 },
651 { /* chip_soc */ 737 { /* chip_soc */
652 .flags = MV_GENIIE_FLAGS, 738 .flags = MV_GEN_IIE_FLAGS,
653 .pio_mask = 0x1f, /* pio0-4 */ 739 .pio_mask = 0x1f, /* pio0-4 */
654 .udma_mask = ATA_UDMA6, 740 .udma_mask = ATA_UDMA6,
655 .port_ops = &mv_iie_ops, 741 .port_ops = &mv_iie_ops,
@@ -794,6 +880,44 @@ static inline int mv_get_hc_count(unsigned long port_flags)
794 return ((port_flags & MV_FLAG_DUAL_HC) ? 2 : 1); 880 return ((port_flags & MV_FLAG_DUAL_HC) ? 2 : 1);
795} 881}
796 882
883/**
884 * mv_save_cached_regs - (re-)initialize cached port registers
885 * @ap: the port whose registers we are caching
886 *
887 * Initialize the local cache of port registers,
888 * so that reading them over and over again can
889 * be avoided on the hotter paths of this driver.
890 * This saves a few microseconds each time we switch
891 * to/from EDMA mode to perform (eg.) a drive cache flush.
892 */
893static void mv_save_cached_regs(struct ata_port *ap)
894{
895 void __iomem *port_mmio = mv_ap_base(ap);
896 struct mv_port_priv *pp = ap->private_data;
897
898 pp->cached.fiscfg = readl(port_mmio + FISCFG_OFS);
899 pp->cached.ltmode = readl(port_mmio + LTMODE_OFS);
900 pp->cached.haltcond = readl(port_mmio + EDMA_HALTCOND_OFS);
901 pp->cached.unknown_rsvd = readl(port_mmio + EDMA_UNKNOWN_RSVD_OFS);
902}
903
904/**
905 * mv_write_cached_reg - write to a cached port register
906 * @addr: hardware address of the register
907 * @old: pointer to cached value of the register
908 * @new: new value for the register
909 *
910 * Write a new value to a cached register,
911 * but only if the value is different from before.
912 */
913static inline void mv_write_cached_reg(void __iomem *addr, u32 *old, u32 new)
914{
915 if (new != *old) {
916 *old = new;
917 writel(new, addr);
918 }
919}
920
797static void mv_set_edma_ptrs(void __iomem *port_mmio, 921static void mv_set_edma_ptrs(void __iomem *port_mmio,
798 struct mv_host_priv *hpriv, 922 struct mv_host_priv *hpriv,
799 struct mv_port_priv *pp) 923 struct mv_port_priv *pp)
@@ -825,6 +949,23 @@ static void mv_set_edma_ptrs(void __iomem *port_mmio,
825 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 949 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
826} 950}
827 951
952static void mv_write_main_irq_mask(u32 mask, struct mv_host_priv *hpriv)
953{
954 /*
955 * When writing to the main_irq_mask in hardware,
956 * we must ensure exclusivity between the interrupt coalescing bits
957 * and the corresponding individual port DONE_IRQ bits.
958 *
959 * Note that this register is really an "IRQ enable" register,
960 * not an "IRQ mask" register as Marvell's naming might suggest.
961 */
962 if (mask & (ALL_PORTS_COAL_DONE | PORTS_0_3_COAL_DONE))
963 mask &= ~DONE_IRQ_0_3;
964 if (mask & (ALL_PORTS_COAL_DONE | PORTS_4_7_COAL_DONE))
965 mask &= ~DONE_IRQ_4_7;
966 writelfl(mask, hpriv->main_irq_mask_addr);
967}
968
828static void mv_set_main_irq_mask(struct ata_host *host, 969static void mv_set_main_irq_mask(struct ata_host *host,
829 u32 disable_bits, u32 enable_bits) 970 u32 disable_bits, u32 enable_bits)
830{ 971{
@@ -835,7 +976,7 @@ static void mv_set_main_irq_mask(struct ata_host *host,
835 new_mask = (old_mask & ~disable_bits) | enable_bits; 976 new_mask = (old_mask & ~disable_bits) | enable_bits;
836 if (new_mask != old_mask) { 977 if (new_mask != old_mask) {
837 hpriv->main_irq_mask = new_mask; 978 hpriv->main_irq_mask = new_mask;
838 writelfl(new_mask, hpriv->main_irq_mask_addr); 979 mv_write_main_irq_mask(new_mask, hpriv);
839 } 980 }
840} 981}
841 982
@@ -852,8 +993,94 @@ static void mv_enable_port_irqs(struct ata_port *ap,
852 mv_set_main_irq_mask(ap->host, disable_bits, enable_bits); 993 mv_set_main_irq_mask(ap->host, disable_bits, enable_bits);
853} 994}
854 995
996static void mv_clear_and_enable_port_irqs(struct ata_port *ap,
997 void __iomem *port_mmio,
998 unsigned int port_irqs)
999{
1000 struct mv_host_priv *hpriv = ap->host->private_data;
1001 int hardport = mv_hardport_from_port(ap->port_no);
1002 void __iomem *hc_mmio = mv_hc_base_from_port(
1003 mv_host_base(ap->host), ap->port_no);
1004 u32 hc_irq_cause;
1005
1006 /* clear EDMA event indicators, if any */
1007 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
1008
1009 /* clear pending irq events */
1010 hc_irq_cause = ~((DEV_IRQ | DMA_IRQ) << hardport);
1011 writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS);
1012
1013 /* clear FIS IRQ Cause */
1014 if (IS_GEN_IIE(hpriv))
1015 writelfl(0, port_mmio + SATA_FIS_IRQ_CAUSE_OFS);
1016
1017 mv_enable_port_irqs(ap, port_irqs);
1018}
1019
1020static void mv_set_irq_coalescing(struct ata_host *host,
1021 unsigned int count, unsigned int usecs)
1022{
1023 struct mv_host_priv *hpriv = host->private_data;
1024 void __iomem *mmio = hpriv->base, *hc_mmio;
1025 u32 coal_enable = 0;
1026 unsigned long flags;
1027 unsigned int clks, is_dual_hc = hpriv->n_ports > MV_PORTS_PER_HC;
1028 const u32 coal_disable = PORTS_0_3_COAL_DONE | PORTS_4_7_COAL_DONE |
1029 ALL_PORTS_COAL_DONE;
1030
1031 /* Disable IRQ coalescing if either threshold is zero */
1032 if (!usecs || !count) {
1033 clks = count = 0;
1034 } else {
1035 /* Respect maximum limits of the hardware */
1036 clks = usecs * COAL_CLOCKS_PER_USEC;
1037 if (clks > MAX_COAL_TIME_THRESHOLD)
1038 clks = MAX_COAL_TIME_THRESHOLD;
1039 if (count > MAX_COAL_IO_COUNT)
1040 count = MAX_COAL_IO_COUNT;
1041 }
1042
1043 spin_lock_irqsave(&host->lock, flags);
1044 mv_set_main_irq_mask(host, coal_disable, 0);
1045
1046 if (is_dual_hc && !IS_GEN_I(hpriv)) {
1047 /*
1048 * GEN_II/GEN_IIE with dual host controllers:
1049 * one set of global thresholds for the entire chip.
1050 */
1051 writel(clks, mmio + MV_IRQ_COAL_TIME_THRESHOLD);
1052 writel(count, mmio + MV_IRQ_COAL_IO_THRESHOLD);
1053 /* clear leftover coal IRQ bit */
1054 writel(~ALL_PORTS_COAL_IRQ, mmio + MV_IRQ_COAL_CAUSE);
1055 if (count)
1056 coal_enable = ALL_PORTS_COAL_DONE;
1057 clks = count = 0; /* force clearing of regular regs below */
1058 }
1059
1060 /*
1061 * All chips: independent thresholds for each HC on the chip.
1062 */
1063 hc_mmio = mv_hc_base_from_port(mmio, 0);
1064 writel(clks, hc_mmio + HC_IRQ_COAL_TIME_THRESHOLD_OFS);
1065 writel(count, hc_mmio + HC_IRQ_COAL_IO_THRESHOLD_OFS);
1066 writel(~HC_COAL_IRQ, hc_mmio + HC_IRQ_CAUSE_OFS);
1067 if (count)
1068 coal_enable |= PORTS_0_3_COAL_DONE;
1069 if (is_dual_hc) {
1070 hc_mmio = mv_hc_base_from_port(mmio, MV_PORTS_PER_HC);
1071 writel(clks, hc_mmio + HC_IRQ_COAL_TIME_THRESHOLD_OFS);
1072 writel(count, hc_mmio + HC_IRQ_COAL_IO_THRESHOLD_OFS);
1073 writel(~HC_COAL_IRQ, hc_mmio + HC_IRQ_CAUSE_OFS);
1074 if (count)
1075 coal_enable |= PORTS_4_7_COAL_DONE;
1076 }
1077
1078 mv_set_main_irq_mask(host, 0, coal_enable);
1079 spin_unlock_irqrestore(&host->lock, flags);
1080}
1081
855/** 1082/**
856 * mv_start_dma - Enable eDMA engine 1083 * mv_start_edma - Enable eDMA engine
857 * @base: port base address 1084 * @base: port base address
858 * @pp: port private data 1085 * @pp: port private data
859 * 1086 *
@@ -863,7 +1090,7 @@ static void mv_enable_port_irqs(struct ata_port *ap,
863 * LOCKING: 1090 * LOCKING:
864 * Inherited from caller. 1091 * Inherited from caller.
865 */ 1092 */
866static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio, 1093static void mv_start_edma(struct ata_port *ap, void __iomem *port_mmio,
867 struct mv_port_priv *pp, u8 protocol) 1094 struct mv_port_priv *pp, u8 protocol)
868{ 1095{
869 int want_ncq = (protocol == ATA_PROT_NCQ); 1096 int want_ncq = (protocol == ATA_PROT_NCQ);
@@ -875,26 +1102,11 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio,
875 } 1102 }
876 if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) { 1103 if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) {
877 struct mv_host_priv *hpriv = ap->host->private_data; 1104 struct mv_host_priv *hpriv = ap->host->private_data;
878 int hardport = mv_hardport_from_port(ap->port_no);
879 void __iomem *hc_mmio = mv_hc_base_from_port(
880 mv_host_base(ap->host), ap->port_no);
881 u32 hc_irq_cause;
882
883 /* clear EDMA event indicators, if any */
884 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
885 1105
886 /* clear pending irq events */ 1106 mv_edma_cfg(ap, want_ncq, 1);
887 hc_irq_cause = ~((DEV_IRQ | DMA_IRQ) << hardport);
888 writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS);
889
890 mv_edma_cfg(ap, want_ncq);
891
892 /* clear FIS IRQ Cause */
893 if (IS_GEN_IIE(hpriv))
894 writelfl(0, port_mmio + SATA_FIS_IRQ_CAUSE_OFS);
895 1107
896 mv_set_edma_ptrs(port_mmio, hpriv, pp); 1108 mv_set_edma_ptrs(port_mmio, hpriv, pp);
897 mv_enable_port_irqs(ap, DONE_IRQ|ERR_IRQ); 1109 mv_clear_and_enable_port_irqs(ap, port_mmio, DONE_IRQ|ERR_IRQ);
898 1110
899 writelfl(EDMA_EN, port_mmio + EDMA_CMD_OFS); 1111 writelfl(EDMA_EN, port_mmio + EDMA_CMD_OFS);
900 pp->pp_flags |= MV_PP_FLAG_EDMA_EN; 1112 pp->pp_flags |= MV_PP_FLAG_EDMA_EN;
@@ -952,6 +1164,7 @@ static int mv_stop_edma(struct ata_port *ap)
952{ 1164{
953 void __iomem *port_mmio = mv_ap_base(ap); 1165 void __iomem *port_mmio = mv_ap_base(ap);
954 struct mv_port_priv *pp = ap->private_data; 1166 struct mv_port_priv *pp = ap->private_data;
1167 int err = 0;
955 1168
956 if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) 1169 if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN))
957 return 0; 1170 return 0;
@@ -959,9 +1172,10 @@ static int mv_stop_edma(struct ata_port *ap)
959 mv_wait_for_edma_empty_idle(ap); 1172 mv_wait_for_edma_empty_idle(ap);
960 if (mv_stop_edma_engine(port_mmio)) { 1173 if (mv_stop_edma_engine(port_mmio)) {
961 ata_port_printk(ap, KERN_ERR, "Unable to stop eDMA\n"); 1174 ata_port_printk(ap, KERN_ERR, "Unable to stop eDMA\n");
962 return -EIO; 1175 err = -EIO;
963 } 1176 }
964 return 0; 1177 mv_edma_cfg(ap, 0, 0);
1178 return err;
965} 1179}
966 1180
967#ifdef ATA_DEBUG 1181#ifdef ATA_DEBUG
@@ -1130,35 +1344,33 @@ static int mv_qc_defer(struct ata_queued_cmd *qc)
1130 return ATA_DEFER_PORT; 1344 return ATA_DEFER_PORT;
1131} 1345}
1132 1346
1133static void mv_config_fbs(void __iomem *port_mmio, int want_ncq, int want_fbs) 1347static void mv_config_fbs(struct ata_port *ap, int want_ncq, int want_fbs)
1134{ 1348{
1135 u32 new_fiscfg, old_fiscfg; 1349 struct mv_port_priv *pp = ap->private_data;
1136 u32 new_ltmode, old_ltmode; 1350 void __iomem *port_mmio;
1137 u32 new_haltcond, old_haltcond;
1138 1351
1139 old_fiscfg = readl(port_mmio + FISCFG_OFS); 1352 u32 fiscfg, *old_fiscfg = &pp->cached.fiscfg;
1140 old_ltmode = readl(port_mmio + LTMODE_OFS); 1353 u32 ltmode, *old_ltmode = &pp->cached.ltmode;
1141 old_haltcond = readl(port_mmio + EDMA_HALTCOND_OFS); 1354 u32 haltcond, *old_haltcond = &pp->cached.haltcond;
1142 1355
1143 new_fiscfg = old_fiscfg & ~(FISCFG_SINGLE_SYNC | FISCFG_WAIT_DEV_ERR); 1356 ltmode = *old_ltmode & ~LTMODE_BIT8;
1144 new_ltmode = old_ltmode & ~LTMODE_BIT8; 1357 haltcond = *old_haltcond | EDMA_ERR_DEV;
1145 new_haltcond = old_haltcond | EDMA_ERR_DEV;
1146 1358
1147 if (want_fbs) { 1359 if (want_fbs) {
1148 new_fiscfg = old_fiscfg | FISCFG_SINGLE_SYNC; 1360 fiscfg = *old_fiscfg | FISCFG_SINGLE_SYNC;
1149 new_ltmode = old_ltmode | LTMODE_BIT8; 1361 ltmode = *old_ltmode | LTMODE_BIT8;
1150 if (want_ncq) 1362 if (want_ncq)
1151 new_haltcond &= ~EDMA_ERR_DEV; 1363 haltcond &= ~EDMA_ERR_DEV;
1152 else 1364 else
1153 new_fiscfg |= FISCFG_WAIT_DEV_ERR; 1365 fiscfg |= FISCFG_WAIT_DEV_ERR;
1366 } else {
1367 fiscfg = *old_fiscfg & ~(FISCFG_SINGLE_SYNC | FISCFG_WAIT_DEV_ERR);
1154 } 1368 }
1155 1369
1156 if (new_fiscfg != old_fiscfg) 1370 port_mmio = mv_ap_base(ap);
1157 writelfl(new_fiscfg, port_mmio + FISCFG_OFS); 1371 mv_write_cached_reg(port_mmio + FISCFG_OFS, old_fiscfg, fiscfg);
1158 if (new_ltmode != old_ltmode) 1372 mv_write_cached_reg(port_mmio + LTMODE_OFS, old_ltmode, ltmode);
1159 writelfl(new_ltmode, port_mmio + LTMODE_OFS); 1373 mv_write_cached_reg(port_mmio + EDMA_HALTCOND_OFS, old_haltcond, haltcond);
1160 if (new_haltcond != old_haltcond)
1161 writelfl(new_haltcond, port_mmio + EDMA_HALTCOND_OFS);
1162} 1374}
1163 1375
1164static void mv_60x1_errata_sata25(struct ata_port *ap, int want_ncq) 1376static void mv_60x1_errata_sata25(struct ata_port *ap, int want_ncq)
@@ -1176,7 +1388,86 @@ static void mv_60x1_errata_sata25(struct ata_port *ap, int want_ncq)
1176 writel(new, hpriv->base + MV_GPIO_PORT_CTL_OFS); 1388 writel(new, hpriv->base + MV_GPIO_PORT_CTL_OFS);
1177} 1389}
1178 1390
1179static void mv_edma_cfg(struct ata_port *ap, int want_ncq) 1391/**
1392 * mv_bmdma_enable - set a magic bit on GEN_IIE to allow bmdma
1393 * @ap: Port being initialized
1394 *
1395 * There are two DMA modes on these chips: basic DMA, and EDMA.
1396 *
1397 * Bit-0 of the "EDMA RESERVED" register enables/disables use
1398 * of basic DMA on the GEN_IIE versions of the chips.
1399 *
1400 * This bit survives EDMA resets, and must be set for basic DMA
1401 * to function, and should be cleared when EDMA is active.
1402 */
1403static void mv_bmdma_enable_iie(struct ata_port *ap, int enable_bmdma)
1404{
1405 struct mv_port_priv *pp = ap->private_data;
1406 u32 new, *old = &pp->cached.unknown_rsvd;
1407
1408 if (enable_bmdma)
1409 new = *old | 1;
1410 else
1411 new = *old & ~1;
1412 mv_write_cached_reg(mv_ap_base(ap) + EDMA_UNKNOWN_RSVD_OFS, old, new);
1413}
1414
1415/*
1416 * SOC chips have an issue whereby the HDD LEDs don't always blink
1417 * during I/O when NCQ is enabled. Enabling a special "LED blink" mode
1418 * of the SOC takes care of it, generating a steady blink rate when
1419 * any drive on the chip is active.
1420 *
1421 * Unfortunately, the blink mode is a global hardware setting for the SOC,
1422 * so we must use it whenever at least one port on the SOC has NCQ enabled.
1423 *
1424 * We turn "LED blink" off when NCQ is not in use anywhere, because the normal
1425 * LED operation works then, and provides better (more accurate) feedback.
1426 *
1427 * Note that this code assumes that an SOC never has more than one HC onboard.
1428 */
1429static void mv_soc_led_blink_enable(struct ata_port *ap)
1430{
1431 struct ata_host *host = ap->host;
1432 struct mv_host_priv *hpriv = host->private_data;
1433 void __iomem *hc_mmio;
1434 u32 led_ctrl;
1435
1436 if (hpriv->hp_flags & MV_HP_QUIRK_LED_BLINK_EN)
1437 return;
1438 hpriv->hp_flags |= MV_HP_QUIRK_LED_BLINK_EN;
1439 hc_mmio = mv_hc_base_from_port(mv_host_base(host), ap->port_no);
1440 led_ctrl = readl(hc_mmio + SOC_LED_CTRL_OFS);
1441 writel(led_ctrl | SOC_LED_CTRL_BLINK, hc_mmio + SOC_LED_CTRL_OFS);
1442}
1443
1444static void mv_soc_led_blink_disable(struct ata_port *ap)
1445{
1446 struct ata_host *host = ap->host;
1447 struct mv_host_priv *hpriv = host->private_data;
1448 void __iomem *hc_mmio;
1449 u32 led_ctrl;
1450 unsigned int port;
1451
1452 if (!(hpriv->hp_flags & MV_HP_QUIRK_LED_BLINK_EN))
1453 return;
1454
1455 /* disable led-blink only if no ports are using NCQ */
1456 for (port = 0; port < hpriv->n_ports; port++) {
1457 struct ata_port *this_ap = host->ports[port];
1458 struct mv_port_priv *pp = this_ap->private_data;
1459
1460 if (pp->pp_flags & MV_PP_FLAG_NCQ_EN)
1461 return;
1462 }
1463
1464 hpriv->hp_flags &= ~MV_HP_QUIRK_LED_BLINK_EN;
1465 hc_mmio = mv_hc_base_from_port(mv_host_base(host), ap->port_no);
1466 led_ctrl = readl(hc_mmio + SOC_LED_CTRL_OFS);
1467 writel(led_ctrl & ~SOC_LED_CTRL_BLINK, hc_mmio + SOC_LED_CTRL_OFS);
1468}
1469
1470static void mv_edma_cfg(struct ata_port *ap, int want_ncq, int want_edma)
1180{ 1471{
1181 u32 cfg; 1472 u32 cfg;
1182 struct mv_port_priv *pp = ap->private_data; 1473 struct mv_port_priv *pp = ap->private_data;
@@ -1185,7 +1476,8 @@ static void mv_edma_cfg(struct ata_port *ap, int want_ncq)
1185 1476
1186 /* set up non-NCQ EDMA configuration */ 1477 /* set up non-NCQ EDMA configuration */
1187 cfg = EDMA_CFG_Q_DEPTH; /* always 0x1f for *all* chips */ 1478 cfg = EDMA_CFG_Q_DEPTH; /* always 0x1f for *all* chips */
1188 pp->pp_flags &= ~MV_PP_FLAG_FBS_EN; 1479 pp->pp_flags &=
1480 ~(MV_PP_FLAG_FBS_EN | MV_PP_FLAG_NCQ_EN | MV_PP_FLAG_FAKE_ATA_BUSY);
1189 1481
1190 if (IS_GEN_I(hpriv)) 1482 if (IS_GEN_I(hpriv))
1191 cfg |= (1 << 8); /* enab config burst size mask */ 1483 cfg |= (1 << 8); /* enab config burst size mask */
@@ -1206,7 +1498,7 @@ static void mv_edma_cfg(struct ata_port *ap, int want_ncq)
1206 */ 1498 */
1207 want_fbs &= want_ncq; 1499 want_fbs &= want_ncq;
1208 1500
1209 mv_config_fbs(port_mmio, want_ncq, want_fbs); 1501 mv_config_fbs(ap, want_ncq, want_fbs);
1210 1502
1211 if (want_fbs) { 1503 if (want_fbs) {
1212 pp->pp_flags |= MV_PP_FLAG_FBS_EN; 1504 pp->pp_flags |= MV_PP_FLAG_FBS_EN;
@@ -1214,18 +1506,27 @@ static void mv_edma_cfg(struct ata_port *ap, int want_ncq)
1214 } 1506 }
1215 1507
1216 cfg |= (1 << 23); /* do not mask PM field in rx'd FIS */ 1508 cfg |= (1 << 23); /* do not mask PM field in rx'd FIS */
1217 cfg |= (1 << 22); /* enab 4-entry host queue cache */ 1509 if (want_edma) {
1218 if (!IS_SOC(hpriv)) 1510 cfg |= (1 << 22); /* enab 4-entry host queue cache */
1219 cfg |= (1 << 18); /* enab early completion */ 1511 if (!IS_SOC(hpriv))
1512 cfg |= (1 << 18); /* enab early completion */
1513 }
1220 if (hpriv->hp_flags & MV_HP_CUT_THROUGH) 1514 if (hpriv->hp_flags & MV_HP_CUT_THROUGH)
1221 cfg |= (1 << 17); /* enab cut-thru (dis stor&forwrd) */ 1515 cfg |= (1 << 17); /* enab cut-thru (dis stor&forwrd) */
1516 mv_bmdma_enable_iie(ap, !want_edma);
1517
1518 if (IS_SOC(hpriv)) {
1519 if (want_ncq)
1520 mv_soc_led_blink_enable(ap);
1521 else
1522 mv_soc_led_blink_disable(ap);
1523 }
1222 } 1524 }
1223 1525
1224 if (want_ncq) { 1526 if (want_ncq) {
1225 cfg |= EDMA_CFG_NCQ; 1527 cfg |= EDMA_CFG_NCQ;
1226 pp->pp_flags |= MV_PP_FLAG_NCQ_EN; 1528 pp->pp_flags |= MV_PP_FLAG_NCQ_EN;
1227 } else 1529 }
1228 pp->pp_flags &= ~MV_PP_FLAG_NCQ_EN;
1229 1530
1230 writelfl(cfg, port_mmio + EDMA_CFG_OFS); 1531 writelfl(cfg, port_mmio + EDMA_CFG_OFS);
1231} 1532}
@@ -1309,6 +1610,8 @@ static int mv_port_start(struct ata_port *ap)
1309 pp->sg_tbl_dma[tag] = pp->sg_tbl_dma[0]; 1610 pp->sg_tbl_dma[tag] = pp->sg_tbl_dma[0];
1310 } 1611 }
1311 } 1612 }
1613 mv_save_cached_regs(ap);
1614 mv_edma_cfg(ap, 0, 0);
1312 return 0; 1615 return 0;
1313 1616
1314out_port_free_dma_mem: 1617out_port_free_dma_mem:
@@ -1357,12 +1660,13 @@ static void mv_fill_sg(struct ata_queued_cmd *qc)
1357 u32 offset = addr & 0xffff; 1660 u32 offset = addr & 0xffff;
1358 u32 len = sg_len; 1661 u32 len = sg_len;
1359 1662
1360 if ((offset + sg_len > 0x10000)) 1663 if (offset + len > 0x10000)
1361 len = 0x10000 - offset; 1664 len = 0x10000 - offset;
1362 1665
1363 mv_sg->addr = cpu_to_le32(addr & 0xffffffff); 1666 mv_sg->addr = cpu_to_le32(addr & 0xffffffff);
1364 mv_sg->addr_hi = cpu_to_le32((addr >> 16) >> 16); 1667 mv_sg->addr_hi = cpu_to_le32((addr >> 16) >> 16);
1365 mv_sg->flags_size = cpu_to_le32(len & 0xffff); 1668 mv_sg->flags_size = cpu_to_le32(len & 0xffff);
1669 mv_sg->reserved = 0;
1366 1670
1367 sg_len -= len; 1671 sg_len -= len;
1368 addr += len; 1672 addr += len;
@@ -1374,6 +1678,7 @@ static void mv_fill_sg(struct ata_queued_cmd *qc)
1374 1678
1375 if (likely(last_sg)) 1679 if (likely(last_sg))
1376 last_sg->flags_size |= cpu_to_le32(EPRD_FLAG_END_OF_TBL); 1680 last_sg->flags_size |= cpu_to_le32(EPRD_FLAG_END_OF_TBL);
1681 mb(); /* ensure data structure is visible to the chipset */
1377} 1682}
1378 1683
1379static void mv_crqb_pack_cmd(__le16 *cmdw, u8 data, u8 addr, unsigned last) 1684static void mv_crqb_pack_cmd(__le16 *cmdw, u8 data, u8 addr, unsigned last)
@@ -1384,6 +1689,147 @@ static void mv_crqb_pack_cmd(__le16 *cmdw, u8 data, u8 addr, unsigned last)
1384} 1689}
1385 1690
1386/** 1691/**
1692 * mv_sff_irq_clear - Clear hardware interrupt after DMA.
1693 * @ap: Port associated with this ATA transaction.
1694 *
1695 * We need this only for ATAPI bmdma transactions,
1696 * as otherwise we experience spurious interrupts
1697 * after libata-sff handles the bmdma interrupts.
1698 */
1699static void mv_sff_irq_clear(struct ata_port *ap)
1700{
1701 mv_clear_and_enable_port_irqs(ap, mv_ap_base(ap), ERR_IRQ);
1702}
1703
1704/**
1705 * mv_check_atapi_dma - Filter ATAPI cmds which are unsuitable for DMA.
1706 * @qc: queued command to check for chipset/DMA compatibility.
1707 *
1708 * The bmdma engines cannot handle speculative data sizes
1709 * (bytecount under/over flow). So only allow DMA for
1710 * data transfer commands with known data sizes.
1711 *
1712 * LOCKING:
1713 * Inherited from caller.
1714 */
1715static int mv_check_atapi_dma(struct ata_queued_cmd *qc)
1716{
1717 struct scsi_cmnd *scmd = qc->scsicmd;
1718
1719 if (scmd) {
1720 switch (scmd->cmnd[0]) {
1721 case READ_6:
1722 case READ_10:
1723 case READ_12:
1724 case WRITE_6:
1725 case WRITE_10:
1726 case WRITE_12:
1727 case GPCMD_READ_CD:
1728 case GPCMD_SEND_DVD_STRUCTURE:
1729 case GPCMD_SEND_CUE_SHEET:
1730 return 0; /* DMA is safe */
1731 }
1732 }
1733 return -EOPNOTSUPP; /* use PIO instead */
1734}
1735
1736/**
1737 * mv_bmdma_setup - Set up BMDMA transaction
1738 * @qc: queued command to prepare DMA for.
1739 *
1740 * LOCKING:
1741 * Inherited from caller.
1742 */
1743static void mv_bmdma_setup(struct ata_queued_cmd *qc)
1744{
1745 struct ata_port *ap = qc->ap;
1746 void __iomem *port_mmio = mv_ap_base(ap);
1747 struct mv_port_priv *pp = ap->private_data;
1748
1749 mv_fill_sg(qc);
1750
1751 /* clear all DMA cmd bits */
1752 writel(0, port_mmio + BMDMA_CMD_OFS);
1753
1754 /* load PRD table addr. */
1755 writel((pp->sg_tbl_dma[qc->tag] >> 16) >> 16,
1756 port_mmio + BMDMA_PRD_HIGH_OFS);
1757 writelfl(pp->sg_tbl_dma[qc->tag],
1758 port_mmio + BMDMA_PRD_LOW_OFS);
1759
1760 /* issue r/w command */
1761 ap->ops->sff_exec_command(ap, &qc->tf);
1762}
1763
1764/**
1765 * mv_bmdma_start - Start a BMDMA transaction
1766 * @qc: queued command to start DMA on.
1767 *
1768 * LOCKING:
1769 * Inherited from caller.
1770 */
1771static void mv_bmdma_start(struct ata_queued_cmd *qc)
1772{
1773 struct ata_port *ap = qc->ap;
1774 void __iomem *port_mmio = mv_ap_base(ap);
1775 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
1776 u32 cmd = (rw ? 0 : ATA_DMA_WR) | ATA_DMA_START;
1777
1778 /* start host DMA transaction */
1779 writelfl(cmd, port_mmio + BMDMA_CMD_OFS);
1780}
1781
1782/**
1783 * mv_bmdma_stop - Stop BMDMA transfer
1784 * @qc: queued command to stop DMA on.
1785 *
1786 * Clears the ATA_DMA_START flag in the bmdma control register
1787 *
1788 * LOCKING:
1789 * Inherited from caller.
1790 */
1791static void mv_bmdma_stop(struct ata_queued_cmd *qc)
1792{
1793 struct ata_port *ap = qc->ap;
1794 void __iomem *port_mmio = mv_ap_base(ap);
1795 u32 cmd;
1796
1797 /* clear start/stop bit */
1798 cmd = readl(port_mmio + BMDMA_CMD_OFS);
1799 cmd &= ~ATA_DMA_START;
1800 writelfl(cmd, port_mmio + BMDMA_CMD_OFS);
1801
1802 /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
1803 ata_sff_dma_pause(ap);
1804}
1805
1806/**
1807 * mv_bmdma_status - Read BMDMA status
1808 * @ap: port for which to retrieve DMA status.
1809 *
1810 * Read and return equivalent of the sff BMDMA status register.
1811 *
1812 * LOCKING:
1813 * Inherited from caller.
1814 */
1815static u8 mv_bmdma_status(struct ata_port *ap)
1816{
1817 void __iomem *port_mmio = mv_ap_base(ap);
1818 u32 reg, status;
1819
1820 /*
1821 * Other bits are valid only if ATA_DMA_ACTIVE==0,
1822 * and the ATA_DMA_INTR bit doesn't exist.
1823 */
1824 reg = readl(port_mmio + BMDMA_STATUS_OFS);
1825 if (reg & ATA_DMA_ACTIVE)
1826 status = ATA_DMA_ACTIVE;
1827 else
1828 status = (reg & ATA_DMA_ERR) | ATA_DMA_INTR;
1829 return status;
1830}
1831
1832/**
1387 * mv_qc_prep - Host specific command preparation. 1833 * mv_qc_prep - Host specific command preparation.
1388 * @qc: queued command to prepare 1834 * @qc: queued command to prepare
1389 * 1835 *
@@ -1545,6 +1991,132 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
1545} 1991}
1546 1992
1547/** 1993/**
1994 * mv_sff_check_status - fetch device status, if valid
1995 * @ap: ATA port to fetch status from
1996 *
1997 * When using command issue via mv_qc_issue_fis(),
1998 * the initial ATA_BUSY state does not show up in the
1999 * ATA status (shadow) register. This can confuse libata!
2000 *
2001 * So we have a hook here to fake ATA_BUSY for that situation,
2002 * until the first time a BUSY, DRQ, or ERR bit is seen.
2003 *
2004 * The rest of the time, it simply returns the ATA status register.
2005 */
2006static u8 mv_sff_check_status(struct ata_port *ap)
2007{
2008 u8 stat = ioread8(ap->ioaddr.status_addr);
2009 struct mv_port_priv *pp = ap->private_data;
2010
2011 if (pp->pp_flags & MV_PP_FLAG_FAKE_ATA_BUSY) {
2012 if (stat & (ATA_BUSY | ATA_DRQ | ATA_ERR))
2013 pp->pp_flags &= ~MV_PP_FLAG_FAKE_ATA_BUSY;
2014 else
2015 stat = ATA_BUSY;
2016 }
2017 return stat;
2018}
2019
2020/**
2021 * mv_send_fis - Send a FIS, using the "Vendor-Unique FIS" register
2022 * @fis: fis to be sent
2023 * @nwords: number of 32-bit words in the fis
2024 */
2025static unsigned int mv_send_fis(struct ata_port *ap, u32 *fis, int nwords)
2026{
2027 void __iomem *port_mmio = mv_ap_base(ap);
2028 u32 ifctl, old_ifctl, ifstat;
2029 int i, timeout = 200, final_word = nwords - 1;
2030
2031 /* Initiate FIS transmission mode */
2032 old_ifctl = readl(port_mmio + SATA_IFCTL_OFS);
2033 ifctl = 0x100 | (old_ifctl & 0xf);
2034 writelfl(ifctl, port_mmio + SATA_IFCTL_OFS);
2035
2036 /* Send all words of the FIS except for the final word */
2037 for (i = 0; i < final_word; ++i)
2038 writel(fis[i], port_mmio + VENDOR_UNIQUE_FIS_OFS);
2039
2040 /* Flag end-of-transmission, and then send the final word */
2041 writelfl(ifctl | 0x200, port_mmio + SATA_IFCTL_OFS);
2042 writelfl(fis[final_word], port_mmio + VENDOR_UNIQUE_FIS_OFS);
2043
2044 /*
2045 * Wait for FIS transmission to complete.
2046 * This typically takes just a single iteration.
2047 */
2048 do {
2049 ifstat = readl(port_mmio + SATA_IFSTAT_OFS);
2050 } while (!(ifstat & 0x1000) && --timeout);
2051
2052 /* Restore original port configuration */
2053 writelfl(old_ifctl, port_mmio + SATA_IFCTL_OFS);
2054
2055 /* See if it worked */
2056 if ((ifstat & 0x3000) != 0x1000) {
2057 ata_port_printk(ap, KERN_WARNING,
2058 "%s transmission error, ifstat=%08x\n",
2059 __func__, ifstat);
2060 return AC_ERR_OTHER;
2061 }
2062 return 0;
2063}
2064
2065/**
2066 * mv_qc_issue_fis - Issue a command directly as a FIS
2067 * @qc: queued command to start
2068 *
2069 * Note that the ATA shadow registers are not updated
2070 * after command issue, so the device will appear "READY"
2071 * if polled, even while it is BUSY processing the command.
2072 *
2073 * So we use a status hook to fake ATA_BUSY until the drive changes state.
2074 *
2075 * Note: we don't get updated shadow regs on *completion*
2076 * of non-data commands. So avoid sending them via this function,
2077 * as they will appear to have completed immediately.
2078 *
2079 * GEN_IIE has special registers that we could get the result tf from,
2080 * but earlier chipsets do not. For now, we ignore those registers.
2081 */
2082static unsigned int mv_qc_issue_fis(struct ata_queued_cmd *qc)
2083{
2084 struct ata_port *ap = qc->ap;
2085 struct mv_port_priv *pp = ap->private_data;
2086 struct ata_link *link = qc->dev->link;
2087 u32 fis[5];
2088 int err = 0;
2089
2090 ata_tf_to_fis(&qc->tf, link->pmp, 1, (void *)fis);
2091 err = mv_send_fis(ap, fis, sizeof(fis) / sizeof(fis[0]));
2092 if (err)
2093 return err;
2094
2095 switch (qc->tf.protocol) {
2096 case ATAPI_PROT_PIO:
2097 pp->pp_flags |= MV_PP_FLAG_FAKE_ATA_BUSY;
2098 /* fall through */
2099 case ATAPI_PROT_NODATA:
2100 ap->hsm_task_state = HSM_ST_FIRST;
2101 break;
2102 case ATA_PROT_PIO:
2103 pp->pp_flags |= MV_PP_FLAG_FAKE_ATA_BUSY;
2104 if (qc->tf.flags & ATA_TFLAG_WRITE)
2105 ap->hsm_task_state = HSM_ST_FIRST;
2106 else
2107 ap->hsm_task_state = HSM_ST;
2108 break;
2109 default:
2110 ap->hsm_task_state = HSM_ST_LAST;
2111 break;
2112 }
2113
2114 if (qc->tf.flags & ATA_TFLAG_POLLING)
2115 ata_pio_queue_task(ap, qc, 0);
2116 return 0;
2117}
2118
2119/**
1548 * mv_qc_issue - Initiate a command to the host 2120 * mv_qc_issue - Initiate a command to the host
1549 * @qc: queued command to start 2121 * @qc: queued command to start
1550 * 2122 *
@@ -1558,14 +2130,28 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
1558 */ 2130 */
1559static unsigned int mv_qc_issue(struct ata_queued_cmd *qc) 2131static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
1560{ 2132{
2133 static int limit_warnings = 10;
1561 struct ata_port *ap = qc->ap; 2134 struct ata_port *ap = qc->ap;
1562 void __iomem *port_mmio = mv_ap_base(ap); 2135 void __iomem *port_mmio = mv_ap_base(ap);
1563 struct mv_port_priv *pp = ap->private_data; 2136 struct mv_port_priv *pp = ap->private_data;
1564 u32 in_index; 2137 u32 in_index;
2138 unsigned int port_irqs;
1565 2139
1566 if ((qc->tf.protocol != ATA_PROT_DMA) && 2140 pp->pp_flags &= ~MV_PP_FLAG_FAKE_ATA_BUSY; /* paranoia */
1567 (qc->tf.protocol != ATA_PROT_NCQ)) { 2141
1568 static int limit_warnings = 10; 2142 switch (qc->tf.protocol) {
2143 case ATA_PROT_DMA:
2144 case ATA_PROT_NCQ:
2145 mv_start_edma(ap, port_mmio, pp, qc->tf.protocol);
2146 pp->req_idx = (pp->req_idx + 1) & MV_MAX_Q_DEPTH_MASK;
2147 in_index = pp->req_idx << EDMA_REQ_Q_PTR_SHIFT;
2148
2149 /* Write the request in pointer to kick the EDMA to life */
2150 writelfl((pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK) | in_index,
2151 port_mmio + EDMA_REQ_Q_IN_PTR_OFS);
2152 return 0;
2153
2154 case ATA_PROT_PIO:
1569 /* 2155 /*
1570 * Errata SATA#16, SATA#24: warn if multiple DRQs expected. 2156 * Errata SATA#16, SATA#24: warn if multiple DRQs expected.
1571 * 2157 *
@@ -1583,27 +2169,46 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
1583 ": attempting PIO w/multiple DRQ: " 2169 ": attempting PIO w/multiple DRQ: "
1584 "this may fail due to h/w errata\n"); 2170 "this may fail due to h/w errata\n");
1585 } 2171 }
1586 /* 2172 /* drop through */
1587 * We're about to send a non-EDMA capable command to the 2173 case ATA_PROT_NODATA:
1588 * port. Turn off EDMA so there won't be problems accessing 2174 case ATAPI_PROT_PIO:
1589 * shadow block, etc registers. 2175 case ATAPI_PROT_NODATA:
1590 */ 2176 if (ap->flags & ATA_FLAG_PIO_POLLING)
1591 mv_stop_edma(ap); 2177 qc->tf.flags |= ATA_TFLAG_POLLING;
1592 mv_enable_port_irqs(ap, ERR_IRQ); 2178 break;
1593 mv_pmp_select(ap, qc->dev->link->pmp);
1594 return ata_sff_qc_issue(qc);
1595 } 2179 }
1596 2180
1597 mv_start_dma(ap, port_mmio, pp, qc->tf.protocol); 2181 if (qc->tf.flags & ATA_TFLAG_POLLING)
1598 2182 port_irqs = ERR_IRQ; /* mask device interrupt when polling */
1599 pp->req_idx = (pp->req_idx + 1) & MV_MAX_Q_DEPTH_MASK; 2183 else
1600 in_index = pp->req_idx << EDMA_REQ_Q_PTR_SHIFT; 2184 port_irqs = ERR_IRQ | DONE_IRQ; /* unmask all interrupts */
1601 2185
1602 /* and write the request in pointer to kick the EDMA to life */ 2186 /*
1603 writelfl((pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK) | in_index, 2187 * We're about to send a non-EDMA capable command to the
1604 port_mmio + EDMA_REQ_Q_IN_PTR_OFS); 2188 * port. Turn off EDMA so there won't be problems accessing
2189 * shadow block, etc registers.
2190 */
2191 mv_stop_edma(ap);
2192 mv_clear_and_enable_port_irqs(ap, mv_ap_base(ap), port_irqs);
2193 mv_pmp_select(ap, qc->dev->link->pmp);
1605 2194
1606 return 0; 2195 if (qc->tf.command == ATA_CMD_READ_LOG_EXT) {
2196 struct mv_host_priv *hpriv = ap->host->private_data;
2197 /*
2198 * Workaround for 88SX60x1 FEr SATA#25 (part 2).
2199 *
2200 * After any NCQ error, the READ_LOG_EXT command
2201 * from libata-eh *must* use mv_qc_issue_fis().
2202 * Otherwise it might fail, due to chip errata.
2203 *
2204 * Rather than special-case it, we'll just *always*
2205 * use this method here for READ_LOG_EXT, making for
2206 * easier testing.
2207 */
2208 if (IS_GEN_II(hpriv))
2209 return mv_qc_issue_fis(qc);
2210 }
2211 return ata_sff_qc_issue(qc);
1607} 2212}
1608 2213
1609static struct ata_queued_cmd *mv_get_active_qc(struct ata_port *ap) 2214static struct ata_queued_cmd *mv_get_active_qc(struct ata_port *ap)
@@ -1614,8 +2219,12 @@ static struct ata_queued_cmd *mv_get_active_qc(struct ata_port *ap)
1614 if (pp->pp_flags & MV_PP_FLAG_NCQ_EN) 2219 if (pp->pp_flags & MV_PP_FLAG_NCQ_EN)
1615 return NULL; 2220 return NULL;
1616 qc = ata_qc_from_tag(ap, ap->link.active_tag); 2221 qc = ata_qc_from_tag(ap, ap->link.active_tag);
1617 if (qc && (qc->tf.flags & ATA_TFLAG_POLLING)) 2222 if (qc) {
1618 qc = NULL; 2223 if (qc->tf.flags & ATA_TFLAG_POLLING)
2224 qc = NULL;
2225 else if (!(qc->flags & ATA_QCFLAG_ACTIVE))
2226 qc = NULL;
2227 }
1619 return qc; 2228 return qc;
1620} 2229}
1621 2230
@@ -2084,6 +2693,10 @@ static int mv_host_intr(struct ata_host *host, u32 main_irq_cause)
2084 void __iomem *mmio = hpriv->base, *hc_mmio; 2693 void __iomem *mmio = hpriv->base, *hc_mmio;
2085 unsigned int handled = 0, port; 2694 unsigned int handled = 0, port;
2086 2695
2696 /* If asserted, clear the "all ports" IRQ coalescing bit */
2697 if (main_irq_cause & ALL_PORTS_COAL_DONE)
2698 writel(~ALL_PORTS_COAL_IRQ, mmio + MV_IRQ_COAL_CAUSE);
2699
2087 for (port = 0; port < hpriv->n_ports; port++) { 2700 for (port = 0; port < hpriv->n_ports; port++) {
2088 struct ata_port *ap = host->ports[port]; 2701 struct ata_port *ap = host->ports[port];
2089 unsigned int p, shift, hardport, port_cause; 2702 unsigned int p, shift, hardport, port_cause;
@@ -2116,6 +2729,8 @@ static int mv_host_intr(struct ata_host *host, u32 main_irq_cause)
2116 * to ack (only) those ports via hc_irq_cause. 2729 * to ack (only) those ports via hc_irq_cause.
2117 */ 2730 */
2118 ack_irqs = 0; 2731 ack_irqs = 0;
2732 if (hc_cause & PORTS_0_3_COAL_DONE)
2733 ack_irqs = HC_COAL_IRQ;
2119 for (p = 0; p < MV_PORTS_PER_HC; ++p) { 2734 for (p = 0; p < MV_PORTS_PER_HC; ++p) {
2120 if ((port + p) >= hpriv->n_ports) 2735 if ((port + p) >= hpriv->n_ports)
2121 break; 2736 break;
@@ -2204,7 +2819,7 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance)
2204 2819
2205 /* for MSI: block new interrupts while in here */ 2820 /* for MSI: block new interrupts while in here */
2206 if (using_msi) 2821 if (using_msi)
2207 writel(0, hpriv->main_irq_mask_addr); 2822 mv_write_main_irq_mask(0, hpriv);
2208 2823
2209 main_irq_cause = readl(hpriv->main_irq_cause_addr); 2824 main_irq_cause = readl(hpriv->main_irq_cause_addr);
2210 pending_irqs = main_irq_cause & hpriv->main_irq_mask; 2825 pending_irqs = main_irq_cause & hpriv->main_irq_mask;
@@ -2218,11 +2833,12 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance)
2218 else 2833 else
2219 handled = mv_host_intr(host, pending_irqs); 2834 handled = mv_host_intr(host, pending_irqs);
2220 } 2835 }
2221 spin_unlock(&host->lock);
2222 2836
2223 /* for MSI: unmask; interrupt cause bits will retrigger now */ 2837 /* for MSI: unmask; interrupt cause bits will retrigger now */
2224 if (using_msi) 2838 if (using_msi)
2225 writel(hpriv->main_irq_mask, hpriv->main_irq_mask_addr); 2839 mv_write_main_irq_mask(hpriv->main_irq_mask, hpriv);
2840
2841 spin_unlock(&host->lock);
2226 2842
2227 return IRQ_RETVAL(handled); 2843 return IRQ_RETVAL(handled);
2228} 2844}
@@ -2773,6 +3389,8 @@ static int mv_hardreset(struct ata_link *link, unsigned int *class,
2773 3389
2774 mv_reset_channel(hpriv, mmio, ap->port_no); 3390 mv_reset_channel(hpriv, mmio, ap->port_no);
2775 pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; 3391 pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN;
3392 pp->pp_flags &=
3393 ~(MV_PP_FLAG_FBS_EN | MV_PP_FLAG_NCQ_EN | MV_PP_FLAG_FAKE_ATA_BUSY);
2776 3394
2777 /* Workaround for errata FEr SATA#10 (part 2) */ 3395 /* Workaround for errata FEr SATA#10 (part 2) */
2778 do { 3396 do {
@@ -2792,6 +3410,8 @@ static int mv_hardreset(struct ata_link *link, unsigned int *class,
2792 extra = HZ; /* only extend it once, max */ 3410 extra = HZ; /* only extend it once, max */
2793 } 3411 }
2794 } while (sstatus != 0x0 && sstatus != 0x113 && sstatus != 0x123); 3412 } while (sstatus != 0x0 && sstatus != 0x113 && sstatus != 0x123);
3413 mv_save_cached_regs(ap);
3414 mv_edma_cfg(ap, 0, 0);
2795 3415
2796 return rc; 3416 return rc;
2797} 3417}
@@ -3125,6 +3745,8 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx)
3125 * The per-port interrupts get done later as ports are set up. 3745 * The per-port interrupts get done later as ports are set up.
3126 */ 3746 */
3127 mv_set_main_irq_mask(host, 0, PCI_ERR); 3747 mv_set_main_irq_mask(host, 0, PCI_ERR);
3748 mv_set_irq_coalescing(host, irq_coalescing_io_count,
3749 irq_coalescing_usecs);
3128done: 3750done:
3129 return rc; 3751 return rc;
3130} 3752}
@@ -3286,12 +3908,6 @@ static struct pci_driver mv_pci_driver = {
3286 .remove = ata_pci_remove_one, 3908 .remove = ata_pci_remove_one,
3287}; 3909};
3288 3910
3289/*
3290 * module options
3291 */
3292static int msi; /* Use PCI msi; either zero (off, default) or non-zero */
3293
3294
3295/* move to PCI layer or libata core? */ 3911/* move to PCI layer or libata core? */
3296static int pci_go_64(struct pci_dev *pdev) 3912static int pci_go_64(struct pci_dev *pdev)
3297{ 3913{
@@ -3473,10 +4089,5 @@ MODULE_DEVICE_TABLE(pci, mv_pci_tbl);
3473MODULE_VERSION(DRV_VERSION); 4089MODULE_VERSION(DRV_VERSION);
3474MODULE_ALIAS("platform:" DRV_NAME); 4090MODULE_ALIAS("platform:" DRV_NAME);
3475 4091
3476#ifdef CONFIG_PCI
3477module_param(msi, int, 0444);
3478MODULE_PARM_DESC(msi, "Enable use of PCI MSI (0=off, 1=on)");
3479#endif
3480
3481module_init(mv_init); 4092module_init(mv_init);
3482module_exit(mv_exit); 4093module_exit(mv_exit);
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 55a8eed3f3a3..6cda12ba8122 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -57,9 +57,9 @@ enum {
57 NV_MMIO_BAR = 5, 57 NV_MMIO_BAR = 5,
58 58
59 NV_PORTS = 2, 59 NV_PORTS = 2,
60 NV_PIO_MASK = 0x1f, 60 NV_PIO_MASK = ATA_PIO4,
61 NV_MWDMA_MASK = 0x07, 61 NV_MWDMA_MASK = ATA_MWDMA2,
62 NV_UDMA_MASK = 0x7f, 62 NV_UDMA_MASK = ATA_UDMA6,
63 NV_PORT0_SCR_REG_OFFSET = 0x00, 63 NV_PORT0_SCR_REG_OFFSET = 0x00,
64 NV_PORT1_SCR_REG_OFFSET = 0x40, 64 NV_PORT1_SCR_REG_OFFSET = 0x40,
65 65
@@ -408,6 +408,7 @@ static struct scsi_host_template nv_swncq_sht = {
408 408
409static struct ata_port_operations nv_common_ops = { 409static struct ata_port_operations nv_common_ops = {
410 .inherits = &ata_bmdma_port_ops, 410 .inherits = &ata_bmdma_port_ops,
411 .lost_interrupt = ATA_OP_NULL,
411 .scr_read = nv_scr_read, 412 .scr_read = nv_scr_read,
412 .scr_write = nv_scr_write, 413 .scr_write = nv_scr_write,
413}; 414};
@@ -2523,7 +2524,7 @@ static void __exit nv_exit(void)
2523module_init(nv_init); 2524module_init(nv_init);
2524module_exit(nv_exit); 2525module_exit(nv_exit);
2525module_param_named(adma, adma_enabled, bool, 0444); 2526module_param_named(adma, adma_enabled, bool, 0444);
2526MODULE_PARM_DESC(adma, "Enable use of ADMA (Default: true)"); 2527MODULE_PARM_DESC(adma, "Enable use of ADMA (Default: false)");
2527module_param_named(swncq, swncq_enabled, bool, 0444); 2528module_param_named(swncq, swncq_enabled, bool, 0444);
2528MODULE_PARM_DESC(swncq, "Enable use of SWNCQ (Default: true)"); 2529MODULE_PARM_DESC(swncq, "Enable use of SWNCQ (Default: true)");
2529 2530
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index ba9a2570a742..b1fd7d62071a 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -176,7 +176,9 @@ static const struct ata_port_operations pdc_common_ops = {
176 .check_atapi_dma = pdc_check_atapi_dma, 176 .check_atapi_dma = pdc_check_atapi_dma,
177 .qc_prep = pdc_qc_prep, 177 .qc_prep = pdc_qc_prep,
178 .qc_issue = pdc_qc_issue, 178 .qc_issue = pdc_qc_issue,
179
179 .sff_irq_clear = pdc_irq_clear, 180 .sff_irq_clear = pdc_irq_clear,
181 .lost_interrupt = ATA_OP_NULL,
180 182
181 .post_internal_cmd = pdc_post_internal_cmd, 183 .post_internal_cmd = pdc_post_internal_cmd,
182 .error_handler = pdc_error_handler, 184 .error_handler = pdc_error_handler,
@@ -213,8 +215,8 @@ static const struct ata_port_info pdc_port_info[] = {
213 { 215 {
214 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | 216 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA |
215 PDC_FLAG_SATA_PATA, 217 PDC_FLAG_SATA_PATA,
216 .pio_mask = 0x1f, /* pio0-4 */ 218 .pio_mask = ATA_PIO4,
217 .mwdma_mask = 0x07, /* mwdma0-2 */ 219 .mwdma_mask = ATA_MWDMA2,
218 .udma_mask = ATA_UDMA6, 220 .udma_mask = ATA_UDMA6,
219 .port_ops = &pdc_old_sata_ops, 221 .port_ops = &pdc_old_sata_ops,
220 }, 222 },
@@ -222,8 +224,8 @@ static const struct ata_port_info pdc_port_info[] = {
222 [board_2037x_pata] = 224 [board_2037x_pata] =
223 { 225 {
224 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, 226 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS,
225 .pio_mask = 0x1f, /* pio0-4 */ 227 .pio_mask = ATA_PIO4,
226 .mwdma_mask = 0x07, /* mwdma0-2 */ 228 .mwdma_mask = ATA_MWDMA2,
227 .udma_mask = ATA_UDMA6, 229 .udma_mask = ATA_UDMA6,
228 .port_ops = &pdc_pata_ops, 230 .port_ops = &pdc_pata_ops,
229 }, 231 },
@@ -232,8 +234,8 @@ static const struct ata_port_info pdc_port_info[] = {
232 { 234 {
233 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | 235 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA |
234 PDC_FLAG_4_PORTS, 236 PDC_FLAG_4_PORTS,
235 .pio_mask = 0x1f, /* pio0-4 */ 237 .pio_mask = ATA_PIO4,
236 .mwdma_mask = 0x07, /* mwdma0-2 */ 238 .mwdma_mask = ATA_MWDMA2,
237 .udma_mask = ATA_UDMA6, 239 .udma_mask = ATA_UDMA6,
238 .port_ops = &pdc_old_sata_ops, 240 .port_ops = &pdc_old_sata_ops,
239 }, 241 },
@@ -242,8 +244,8 @@ static const struct ata_port_info pdc_port_info[] = {
242 { 244 {
243 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS | 245 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS |
244 PDC_FLAG_4_PORTS, 246 PDC_FLAG_4_PORTS,
245 .pio_mask = 0x1f, /* pio0-4 */ 247 .pio_mask = ATA_PIO4,
246 .mwdma_mask = 0x07, /* mwdma0-2 */ 248 .mwdma_mask = ATA_MWDMA2,
247 .udma_mask = ATA_UDMA6, 249 .udma_mask = ATA_UDMA6,
248 .port_ops = &pdc_pata_ops, 250 .port_ops = &pdc_pata_ops,
249 }, 251 },
@@ -252,8 +254,8 @@ static const struct ata_port_info pdc_port_info[] = {
252 { 254 {
253 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | 255 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA |
254 PDC_FLAG_GEN_II | PDC_FLAG_SATA_PATA, 256 PDC_FLAG_GEN_II | PDC_FLAG_SATA_PATA,
255 .pio_mask = 0x1f, /* pio0-4 */ 257 .pio_mask = ATA_PIO4,
256 .mwdma_mask = 0x07, /* mwdma0-2 */ 258 .mwdma_mask = ATA_MWDMA2,
257 .udma_mask = ATA_UDMA6, 259 .udma_mask = ATA_UDMA6,
258 .port_ops = &pdc_sata_ops, 260 .port_ops = &pdc_sata_ops,
259 }, 261 },
@@ -262,8 +264,8 @@ static const struct ata_port_info pdc_port_info[] = {
262 { 264 {
263 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS | 265 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS |
264 PDC_FLAG_GEN_II, 266 PDC_FLAG_GEN_II,
265 .pio_mask = 0x1f, /* pio0-4 */ 267 .pio_mask = ATA_PIO4,
266 .mwdma_mask = 0x07, /* mwdma0-2 */ 268 .mwdma_mask = ATA_MWDMA2,
267 .udma_mask = ATA_UDMA6, 269 .udma_mask = ATA_UDMA6,
268 .port_ops = &pdc_pata_ops, 270 .port_ops = &pdc_pata_ops,
269 }, 271 },
@@ -272,8 +274,8 @@ static const struct ata_port_info pdc_port_info[] = {
272 { 274 {
273 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | 275 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA |
274 PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS, 276 PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS,
275 .pio_mask = 0x1f, /* pio0-4 */ 277 .pio_mask = ATA_PIO4,
276 .mwdma_mask = 0x07, /* mwdma0-2 */ 278 .mwdma_mask = ATA_MWDMA2,
277 .udma_mask = ATA_UDMA6, 279 .udma_mask = ATA_UDMA6,
278 .port_ops = &pdc_sata_ops, 280 .port_ops = &pdc_sata_ops,
279 }, 281 },
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c
index a000c86ac859..c3936d35cdac 100644
--- a/drivers/ata/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -147,6 +147,7 @@ static struct ata_port_operations qs_ata_ops = {
147 .softreset = ATA_OP_NULL, 147 .softreset = ATA_OP_NULL,
148 .error_handler = qs_error_handler, 148 .error_handler = qs_error_handler,
149 .post_internal_cmd = ATA_OP_NULL, 149 .post_internal_cmd = ATA_OP_NULL,
150 .lost_interrupt = ATA_OP_NULL,
150 151
151 .scr_read = qs_scr_read, 152 .scr_read = qs_scr_read,
152 .scr_write = qs_scr_write, 153 .scr_write = qs_scr_write,
@@ -160,7 +161,7 @@ static const struct ata_port_info qs_port_info[] = {
160 { 161 {
161 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 162 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
162 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING, 163 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING,
163 .pio_mask = 0x10, /* pio4 */ 164 .pio_mask = ATA_PIO4_ONLY,
164 .udma_mask = ATA_UDMA6, 165 .udma_mask = ATA_UDMA6,
165 .port_ops = &qs_ata_ops, 166 .port_ops = &qs_ata_ops,
166 }, 167 },
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index d0091609e210..e67ce8e5caa5 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -200,8 +200,8 @@ static const struct ata_port_info sil_port_info[] = {
200 /* sil_3112 */ 200 /* sil_3112 */
201 { 201 {
202 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_MOD15WRITE, 202 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_MOD15WRITE,
203 .pio_mask = 0x1f, /* pio0-4 */ 203 .pio_mask = ATA_PIO4,
204 .mwdma_mask = 0x07, /* mwdma0-2 */ 204 .mwdma_mask = ATA_MWDMA2,
205 .udma_mask = ATA_UDMA5, 205 .udma_mask = ATA_UDMA5,
206 .port_ops = &sil_ops, 206 .port_ops = &sil_ops,
207 }, 207 },
@@ -209,24 +209,24 @@ static const struct ata_port_info sil_port_info[] = {
209 { 209 {
210 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_MOD15WRITE | 210 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_MOD15WRITE |
211 SIL_FLAG_NO_SATA_IRQ, 211 SIL_FLAG_NO_SATA_IRQ,
212 .pio_mask = 0x1f, /* pio0-4 */ 212 .pio_mask = ATA_PIO4,
213 .mwdma_mask = 0x07, /* mwdma0-2 */ 213 .mwdma_mask = ATA_MWDMA2,
214 .udma_mask = ATA_UDMA5, 214 .udma_mask = ATA_UDMA5,
215 .port_ops = &sil_ops, 215 .port_ops = &sil_ops,
216 }, 216 },
217 /* sil_3512 */ 217 /* sil_3512 */
218 { 218 {
219 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT, 219 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
220 .pio_mask = 0x1f, /* pio0-4 */ 220 .pio_mask = ATA_PIO4,
221 .mwdma_mask = 0x07, /* mwdma0-2 */ 221 .mwdma_mask = ATA_MWDMA2,
222 .udma_mask = ATA_UDMA5, 222 .udma_mask = ATA_UDMA5,
223 .port_ops = &sil_ops, 223 .port_ops = &sil_ops,
224 }, 224 },
225 /* sil_3114 */ 225 /* sil_3114 */
226 { 226 {
227 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT, 227 .flags = SIL_DFL_PORT_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
228 .pio_mask = 0x1f, /* pio0-4 */ 228 .pio_mask = ATA_PIO4,
229 .mwdma_mask = 0x07, /* mwdma0-2 */ 229 .mwdma_mask = ATA_MWDMA2,
230 .udma_mask = ATA_UDMA5, 230 .udma_mask = ATA_UDMA5,
231 .port_ops = &sil_ops, 231 .port_ops = &sil_ops,
232 }, 232 },
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 2590c2279fa7..0d8990dcdfcd 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -429,25 +429,25 @@ static const struct ata_port_info sil24_port_info[] = {
429 { 429 {
430 .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(4) | 430 .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(4) |
431 SIL24_FLAG_PCIX_IRQ_WOC, 431 SIL24_FLAG_PCIX_IRQ_WOC,
432 .pio_mask = 0x1f, /* pio0-4 */ 432 .pio_mask = ATA_PIO4,
433 .mwdma_mask = 0x07, /* mwdma0-2 */ 433 .mwdma_mask = ATA_MWDMA2,
434 .udma_mask = ATA_UDMA5, /* udma0-5 */ 434 .udma_mask = ATA_UDMA5,
435 .port_ops = &sil24_ops, 435 .port_ops = &sil24_ops,
436 }, 436 },
437 /* sil_3132 */ 437 /* sil_3132 */
438 { 438 {
439 .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(2), 439 .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(2),
440 .pio_mask = 0x1f, /* pio0-4 */ 440 .pio_mask = ATA_PIO4,
441 .mwdma_mask = 0x07, /* mwdma0-2 */ 441 .mwdma_mask = ATA_MWDMA2,
442 .udma_mask = ATA_UDMA5, /* udma0-5 */ 442 .udma_mask = ATA_UDMA5,
443 .port_ops = &sil24_ops, 443 .port_ops = &sil24_ops,
444 }, 444 },
445 /* sil_3131/sil_3531 */ 445 /* sil_3131/sil_3531 */
446 { 446 {
447 .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(1), 447 .flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(1),
448 .pio_mask = 0x1f, /* pio0-4 */ 448 .pio_mask = ATA_PIO4,
449 .mwdma_mask = 0x07, /* mwdma0-2 */ 449 .mwdma_mask = ATA_MWDMA2,
450 .udma_mask = ATA_UDMA5, /* udma0-5 */ 450 .udma_mask = ATA_UDMA5,
451 .port_ops = &sil24_ops, 451 .port_ops = &sil24_ops,
452 }, 452 },
453}; 453};
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index 9c43b4e7c4a6..8f9833228619 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -97,8 +97,8 @@ static struct ata_port_operations sis_ops = {
97 97
98static const struct ata_port_info sis_port_info = { 98static const struct ata_port_info sis_port_info = {
99 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 99 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
100 .pio_mask = 0x1f, 100 .pio_mask = ATA_PIO4,
101 .mwdma_mask = 0x7, 101 .mwdma_mask = ATA_MWDMA2,
102 .udma_mask = ATA_UDMA6, 102 .udma_mask = ATA_UDMA6,
103 .port_ops = &sis_ops, 103 .port_ops = &sis_ops,
104}; 104};
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 609d147813ae..7257f2d5c52c 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -361,8 +361,8 @@ static const struct ata_port_info k2_port_info[] = {
361 { 361 {
362 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 362 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
363 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA, 363 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA,
364 .pio_mask = 0x1f, 364 .pio_mask = ATA_PIO4,
365 .mwdma_mask = 0x07, 365 .mwdma_mask = ATA_MWDMA2,
366 .udma_mask = ATA_UDMA6, 366 .udma_mask = ATA_UDMA6,
367 .port_ops = &k2_sata_ops, 367 .port_ops = &k2_sata_ops,
368 }, 368 },
@@ -371,8 +371,8 @@ static const struct ata_port_info k2_port_info[] = {
371 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 371 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
372 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA | 372 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA |
373 K2_FLAG_SATA_8_PORTS, 373 K2_FLAG_SATA_8_PORTS,
374 .pio_mask = 0x1f, 374 .pio_mask = ATA_PIO4,
375 .mwdma_mask = 0x07, 375 .mwdma_mask = ATA_MWDMA2,
376 .udma_mask = ATA_UDMA6, 376 .udma_mask = ATA_UDMA6,
377 .port_ops = &k2_sata_ops, 377 .port_ops = &k2_sata_ops,
378 }, 378 },
@@ -380,8 +380,8 @@ static const struct ata_port_info k2_port_info[] = {
380 { 380 {
381 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 381 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
382 ATA_FLAG_MMIO | K2_FLAG_BAR_POS_3, 382 ATA_FLAG_MMIO | K2_FLAG_BAR_POS_3,
383 .pio_mask = 0x1f, 383 .pio_mask = ATA_PIO4,
384 .mwdma_mask = 0x07, 384 .mwdma_mask = ATA_MWDMA2,
385 .udma_mask = ATA_UDMA6, 385 .udma_mask = ATA_UDMA6,
386 .port_ops = &k2_sata_ops, 386 .port_ops = &k2_sata_ops,
387 }, 387 },
@@ -389,8 +389,8 @@ static const struct ata_port_info k2_port_info[] = {
389 { 389 {
390 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 390 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
391 ATA_FLAG_MMIO, 391 ATA_FLAG_MMIO,
392 .pio_mask = 0x1f, 392 .pio_mask = ATA_PIO4,
393 .mwdma_mask = 0x07, 393 .mwdma_mask = ATA_MWDMA2,
394 .udma_mask = ATA_UDMA6, 394 .udma_mask = ATA_UDMA6,
395 .port_ops = &k2_sata_ops, 395 .port_ops = &k2_sata_ops,
396 }, 396 },
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index ec04b8d3c791..dce3dccced3f 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -265,8 +265,8 @@ static const struct ata_port_info pdc_port_info[] = {
265 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 265 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
266 ATA_FLAG_SRST | ATA_FLAG_MMIO | 266 ATA_FLAG_SRST | ATA_FLAG_MMIO |
267 ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING, 267 ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING,
268 .pio_mask = 0x1f, /* pio0-4 */ 268 .pio_mask = ATA_PIO4,
269 .mwdma_mask = 0x07, /* mwdma0-2 */ 269 .mwdma_mask = ATA_MWDMA2,
270 .udma_mask = ATA_UDMA6, 270 .udma_mask = ATA_UDMA6,
271 .port_ops = &pdc_20621_ops, 271 .port_ops = &pdc_20621_ops,
272 }, 272 },
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index 019575bb3e08..e5bff47e8aa1 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -89,7 +89,7 @@ static struct ata_port_operations uli_ops = {
89static const struct ata_port_info uli_port_info = { 89static const struct ata_port_info uli_port_info = {
90 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 90 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
91 ATA_FLAG_IGN_SIMPLEX, 91 ATA_FLAG_IGN_SIMPLEX,
92 .pio_mask = 0x1f, /* pio0-4 */ 92 .pio_mask = ATA_PIO4,
93 .udma_mask = ATA_UDMA6, 93 .udma_mask = ATA_UDMA6,
94 .port_ops = &uli_ops, 94 .port_ops = &uli_ops,
95}; 95};
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 5c62da9cd491..98e8c50703b3 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -146,24 +146,24 @@ static struct ata_port_operations vt8251_ops = {
146 146
147static const struct ata_port_info vt6420_port_info = { 147static const struct ata_port_info vt6420_port_info = {
148 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 148 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
149 .pio_mask = 0x1f, 149 .pio_mask = ATA_PIO4,
150 .mwdma_mask = 0x07, 150 .mwdma_mask = ATA_MWDMA2,
151 .udma_mask = ATA_UDMA6, 151 .udma_mask = ATA_UDMA6,
152 .port_ops = &vt6420_sata_ops, 152 .port_ops = &vt6420_sata_ops,
153}; 153};
154 154
155static struct ata_port_info vt6421_sport_info = { 155static struct ata_port_info vt6421_sport_info = {
156 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 156 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
157 .pio_mask = 0x1f, 157 .pio_mask = ATA_PIO4,
158 .mwdma_mask = 0x07, 158 .mwdma_mask = ATA_MWDMA2,
159 .udma_mask = ATA_UDMA6, 159 .udma_mask = ATA_UDMA6,
160 .port_ops = &vt6421_sata_ops, 160 .port_ops = &vt6421_sata_ops,
161}; 161};
162 162
163static struct ata_port_info vt6421_pport_info = { 163static struct ata_port_info vt6421_pport_info = {
164 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_LEGACY, 164 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_LEGACY,
165 .pio_mask = 0x1f, 165 .pio_mask = ATA_PIO4,
166 .mwdma_mask = 0, 166 /* No MWDMA */
167 .udma_mask = ATA_UDMA6, 167 .udma_mask = ATA_UDMA6,
168 .port_ops = &vt6421_pata_ops, 168 .port_ops = &vt6421_pata_ops,
169}; 169};
@@ -171,8 +171,8 @@ static struct ata_port_info vt6421_pport_info = {
171static struct ata_port_info vt8251_port_info = { 171static struct ata_port_info vt8251_port_info = {
172 .flags = ATA_FLAG_SATA | ATA_FLAG_SLAVE_POSS | 172 .flags = ATA_FLAG_SATA | ATA_FLAG_SLAVE_POSS |
173 ATA_FLAG_NO_LEGACY, 173 ATA_FLAG_NO_LEGACY,
174 .pio_mask = 0x1f, 174 .pio_mask = ATA_PIO4,
175 .mwdma_mask = 0x07, 175 .mwdma_mask = ATA_MWDMA2,
176 .udma_mask = ATA_UDMA6, 176 .udma_mask = ATA_UDMA6,
177 .port_ops = &vt8251_ops, 177 .port_ops = &vt8251_ops,
178}; 178};
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c
index c57cdff9e6bd..ed70bd28fa2c 100644
--- a/drivers/ata/sata_vsc.c
+++ b/drivers/ata/sata_vsc.c
@@ -308,6 +308,9 @@ static struct scsi_host_template vsc_sata_sht = {
308 308
309static struct ata_port_operations vsc_sata_ops = { 309static struct ata_port_operations vsc_sata_ops = {
310 .inherits = &ata_bmdma_port_ops, 310 .inherits = &ata_bmdma_port_ops,
311 /* The IRQ handling is not quite standard SFF behaviour so we
312 cannot use the default lost interrupt handler */
313 .lost_interrupt = ATA_OP_NULL,
311 .sff_tf_load = vsc_sata_tf_load, 314 .sff_tf_load = vsc_sata_tf_load,
312 .sff_tf_read = vsc_sata_tf_read, 315 .sff_tf_read = vsc_sata_tf_read,
313 .freeze = vsc_freeze, 316 .freeze = vsc_freeze,
@@ -345,8 +348,8 @@ static int __devinit vsc_sata_init_one(struct pci_dev *pdev,
345 static const struct ata_port_info pi = { 348 static const struct ata_port_info pi = {
346 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 349 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
347 ATA_FLAG_MMIO, 350 ATA_FLAG_MMIO,
348 .pio_mask = 0x1f, 351 .pio_mask = ATA_PIO4,
349 .mwdma_mask = 0x07, 352 .mwdma_mask = ATA_MWDMA2,
350 .udma_mask = ATA_UDMA6, 353 .udma_mask = ATA_UDMA6,
351 .port_ops = &vsc_sata_ops, 354 .port_ops = &vsc_sata_ops,
352 }; 355 };
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 9f50f1b545dc..ddc97496db4a 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -63,6 +63,32 @@ 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
66/* initialisation functions */ 92/* initialisation functions */
67extern int devices_init(void); 93extern int devices_init(void);
68extern int buses_init(void); 94extern int buses_init(void);
@@ -86,6 +112,11 @@ extern void bus_remove_driver(struct device_driver *drv);
86 112
87extern void driver_detach(struct device_driver *drv); 113extern void driver_detach(struct device_driver *drv);
88extern int driver_probe_device(struct device_driver *drv, struct device *dev); 114extern int driver_probe_device(struct device_driver *drv, struct device *dev);
115static inline int driver_match_device(struct device_driver *drv,
116 struct device *dev)
117{
118 return drv->bus->match && drv->bus->match(dev, drv);
119}
89 120
90extern void sysdev_shutdown(void); 121extern void sysdev_shutdown(void);
91 122
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 83f32b891fa9..dc030f1f00f1 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -198,7 +198,7 @@ static ssize_t driver_bind(struct device_driver *drv,
198 int err = -ENODEV; 198 int err = -ENODEV;
199 199
200 dev = bus_find_device_by_name(bus, NULL, buf); 200 dev = bus_find_device_by_name(bus, NULL, buf);
201 if (dev && dev->driver == NULL) { 201 if (dev && dev->driver == NULL && driver_match_device(drv, dev)) {
202 if (dev->parent) /* Needed for USB */ 202 if (dev->parent) /* Needed for USB */
203 down(&dev->parent->sem); 203 down(&dev->parent->sem);
204 down(&dev->sem); 204 down(&dev->sem);
@@ -253,7 +253,14 @@ 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 return n ? container_of(n, struct device, knode_bus) : NULL; 256 struct device *dev = 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;
257} 264}
258 265
259/** 266/**
@@ -286,7 +293,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start,
286 return -EINVAL; 293 return -EINVAL;
287 294
288 klist_iter_init_node(&bus->p->klist_devices, &i, 295 klist_iter_init_node(&bus->p->klist_devices, &i,
289 (start ? &start->knode_bus : NULL)); 296 (start ? &start->p->knode_bus : NULL));
290 while ((dev = next_device(&i)) && !error) 297 while ((dev = next_device(&i)) && !error)
291 error = fn(dev, data); 298 error = fn(dev, data);
292 klist_iter_exit(&i); 299 klist_iter_exit(&i);
@@ -320,7 +327,7 @@ struct device *bus_find_device(struct bus_type *bus,
320 return NULL; 327 return NULL;
321 328
322 klist_iter_init_node(&bus->p->klist_devices, &i, 329 klist_iter_init_node(&bus->p->klist_devices, &i,
323 (start ? &start->knode_bus : NULL)); 330 (start ? &start->p->knode_bus : NULL));
324 while ((dev = next_device(&i))) 331 while ((dev = next_device(&i)))
325 if (match(dev, data) && get_device(dev)) 332 if (match(dev, data) && get_device(dev))
326 break; 333 break;
@@ -507,7 +514,8 @@ void bus_attach_device(struct device *dev)
507 ret = device_attach(dev); 514 ret = device_attach(dev);
508 WARN_ON(ret < 0); 515 WARN_ON(ret < 0);
509 if (ret >= 0) 516 if (ret >= 0)
510 klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); 517 klist_add_tail(&dev->p->knode_bus,
518 &bus->p->klist_devices);
511 } 519 }
512} 520}
513 521
@@ -528,8 +536,8 @@ void bus_remove_device(struct device *dev)
528 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 536 sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
529 dev_name(dev)); 537 dev_name(dev));
530 device_remove_attrs(dev->bus, dev); 538 device_remove_attrs(dev->bus, dev);
531 if (klist_node_attached(&dev->knode_bus)) 539 if (klist_node_attached(&dev->p->knode_bus))
532 klist_del(&dev->knode_bus); 540 klist_del(&dev->p->knode_bus);
533 541
534 pr_debug("bus: '%s': remove device %s\n", 542 pr_debug("bus: '%s': remove device %s\n",
535 dev->bus->name, dev_name(dev)); 543 dev->bus->name, dev_name(dev));
@@ -831,14 +839,16 @@ static void bus_remove_attrs(struct bus_type *bus)
831 839
832static void klist_devices_get(struct klist_node *n) 840static void klist_devices_get(struct klist_node *n)
833{ 841{
834 struct device *dev = container_of(n, struct device, knode_bus); 842 struct device_private *dev_prv = to_device_private_bus(n);
843 struct device *dev = dev_prv->device;
835 844
836 get_device(dev); 845 get_device(dev);
837} 846}
838 847
839static void klist_devices_put(struct klist_node *n) 848static void klist_devices_put(struct klist_node *n)
840{ 849{
841 struct device *dev = container_of(n, struct device, knode_bus); 850 struct device_private *dev_prv = to_device_private_bus(n);
851 struct device *dev = dev_prv->device;
842 852
843 put_device(dev); 853 put_device(dev);
844} 854}
@@ -932,6 +942,7 @@ bus_uevent_fail:
932 kset_unregister(&bus->p->subsys); 942 kset_unregister(&bus->p->subsys);
933 kfree(bus->p); 943 kfree(bus->p);
934out: 944out:
945 bus->p = NULL;
935 return retval; 946 return retval;
936} 947}
937EXPORT_SYMBOL_GPL(bus_register); 948EXPORT_SYMBOL_GPL(bus_register);
@@ -953,6 +964,7 @@ void bus_unregister(struct bus_type *bus)
953 bus_remove_file(bus, &bus_attr_uevent); 964 bus_remove_file(bus, &bus_attr_uevent);
954 kset_unregister(&bus->p->subsys); 965 kset_unregister(&bus->p->subsys);
955 kfree(bus->p); 966 kfree(bus->p);
967 bus->p = NULL;
956} 968}
957EXPORT_SYMBOL_GPL(bus_unregister); 969EXPORT_SYMBOL_GPL(bus_unregister);
958 970
@@ -993,18 +1005,20 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list
993{ 1005{
994 struct list_head *pos; 1006 struct list_head *pos;
995 struct klist_node *n; 1007 struct klist_node *n;
1008 struct device_private *dev_prv;
996 struct device *b; 1009 struct device *b;
997 1010
998 list_for_each(pos, list) { 1011 list_for_each(pos, list) {
999 n = container_of(pos, struct klist_node, n_node); 1012 n = container_of(pos, struct klist_node, n_node);
1000 b = container_of(n, struct device, knode_bus); 1013 dev_prv = to_device_private_bus(n);
1014 b = dev_prv->device;
1001 if (compare(a, b) <= 0) { 1015 if (compare(a, b) <= 0) {
1002 list_move_tail(&a->knode_bus.n_node, 1016 list_move_tail(&a->p->knode_bus.n_node,
1003 &b->knode_bus.n_node); 1017 &b->p->knode_bus.n_node);
1004 return; 1018 return;
1005 } 1019 }
1006 } 1020 }
1007 list_move_tail(&a->knode_bus.n_node, list); 1021 list_move_tail(&a->p->knode_bus.n_node, list);
1008} 1022}
1009 1023
1010void bus_sort_breadthfirst(struct bus_type *bus, 1024void bus_sort_breadthfirst(struct bus_type *bus,
@@ -1014,6 +1028,7 @@ void bus_sort_breadthfirst(struct bus_type *bus,
1014 LIST_HEAD(sorted_devices); 1028 LIST_HEAD(sorted_devices);
1015 struct list_head *pos, *tmp; 1029 struct list_head *pos, *tmp;
1016 struct klist_node *n; 1030 struct klist_node *n;
1031 struct device_private *dev_prv;
1017 struct device *dev; 1032 struct device *dev;
1018 struct klist *device_klist; 1033 struct klist *device_klist;
1019 1034
@@ -1022,7 +1037,8 @@ void bus_sort_breadthfirst(struct bus_type *bus,
1022 spin_lock(&device_klist->k_lock); 1037 spin_lock(&device_klist->k_lock);
1023 list_for_each_safe(pos, tmp, &device_klist->k_list) { 1038 list_for_each_safe(pos, tmp, &device_klist->k_list) {
1024 n = container_of(pos, struct klist_node, n_node); 1039 n = container_of(pos, struct klist_node, n_node);
1025 dev = container_of(n, struct device, knode_bus); 1040 dev_prv = to_device_private_bus(n);
1041 dev = dev_prv->device;
1026 device_insertion_sort_klist(dev, &sorted_devices, compare); 1042 device_insertion_sort_klist(dev, &sorted_devices, compare);
1027 } 1043 }
1028 list_splice(&sorted_devices, &device_klist->k_list); 1044 list_splice(&sorted_devices, &device_klist->k_list);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index f3eae630e589..e73c92d13a23 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -109,6 +109,7 @@ 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;
112 113
113 if (dev->release) 114 if (dev->release)
114 dev->release(dev); 115 dev->release(dev);
@@ -120,6 +121,7 @@ static void device_release(struct kobject *kobj)
120 WARN(1, KERN_ERR "Device '%s' does not have a release() " 121 WARN(1, KERN_ERR "Device '%s' does not have a release() "
121 "function, it is broken and must be fixed.\n", 122 "function, it is broken and must be fixed.\n",
122 dev_name(dev)); 123 dev_name(dev));
124 kfree(p);
123} 125}
124 126
125static struct kobj_type device_ktype = { 127static struct kobj_type device_ktype = {
@@ -134,8 +136,6 @@ static int dev_uevent_filter(struct kset *kset, struct kobject *kobj)
134 136
135 if (ktype == &device_ktype) { 137 if (ktype == &device_ktype) {
136 struct device *dev = to_dev(kobj); 138 struct device *dev = to_dev(kobj);
137 if (dev->uevent_suppress)
138 return 0;
139 if (dev->bus) 139 if (dev->bus)
140 return 1; 140 return 1;
141 if (dev->class) 141 if (dev->class)
@@ -507,14 +507,16 @@ EXPORT_SYMBOL_GPL(device_schedule_callback_owner);
507 507
508static void klist_children_get(struct klist_node *n) 508static void klist_children_get(struct klist_node *n)
509{ 509{
510 struct device *dev = container_of(n, struct device, knode_parent); 510 struct device_private *p = to_device_private_parent(n);
511 struct device *dev = p->device;
511 512
512 get_device(dev); 513 get_device(dev);
513} 514}
514 515
515static void klist_children_put(struct klist_node *n) 516static void klist_children_put(struct klist_node *n)
516{ 517{
517 struct device *dev = container_of(n, struct device, knode_parent); 518 struct device_private *p = to_device_private_parent(n);
519 struct device *dev = p->device;
518 520
519 put_device(dev); 521 put_device(dev);
520} 522}
@@ -538,8 +540,6 @@ void device_initialize(struct device *dev)
538{ 540{
539 dev->kobj.kset = devices_kset; 541 dev->kobj.kset = devices_kset;
540 kobject_init(&dev->kobj, &device_ktype); 542 kobject_init(&dev->kobj, &device_ktype);
541 klist_init(&dev->klist_children, klist_children_get,
542 klist_children_put);
543 INIT_LIST_HEAD(&dev->dma_pools); 543 INIT_LIST_HEAD(&dev->dma_pools);
544 init_MUTEX(&dev->sem); 544 init_MUTEX(&dev->sem);
545 spin_lock_init(&dev->devres_lock); 545 spin_lock_init(&dev->devres_lock);
@@ -777,17 +777,12 @@ static void device_remove_class_symlinks(struct device *dev)
777int dev_set_name(struct device *dev, const char *fmt, ...) 777int dev_set_name(struct device *dev, const char *fmt, ...)
778{ 778{
779 va_list vargs; 779 va_list vargs;
780 char *s; 780 int err;
781 781
782 va_start(vargs, fmt); 782 va_start(vargs, fmt);
783 vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs); 783 err = kobject_set_name_vargs(&dev->kobj, fmt, vargs);
784 va_end(vargs); 784 va_end(vargs);
785 785 return err;
786 /* ewww... some of these buggers have / in the name... */
787 while ((s = strchr(dev->bus_id, '/')))
788 *s = '!';
789
790 return 0;
791} 786}
792EXPORT_SYMBOL_GPL(dev_set_name); 787EXPORT_SYMBOL_GPL(dev_set_name);
793 788
@@ -864,12 +859,26 @@ int device_add(struct device *dev)
864 if (!dev) 859 if (!dev)
865 goto done; 860 goto done;
866 861
867 /* Temporarily support init_name if it is set. 862 dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL);
868 * It will override bus_id for now */ 863 if (!dev->p) {
869 if (dev->init_name) 864 error = -ENOMEM;
870 dev_set_name(dev, "%s", dev->init_name); 865 goto done;
866 }
867 dev->p->device = dev;
868 klist_init(&dev->p->klist_children, klist_children_get,
869 klist_children_put);
870
871 /*
872 * for statically allocated devices, which should all be converted
873 * some day, we need to initialize the name. We prevent reading back
874 * the name, and force the use of dev_name()
875 */
876 if (dev->init_name) {
877 dev_set_name(dev, dev->init_name);
878 dev->init_name = NULL;
879 }
871 880
872 if (!strlen(dev->bus_id)) 881 if (!dev_name(dev))
873 goto done; 882 goto done;
874 883
875 pr_debug("device: '%s': %s\n", dev_name(dev), __func__); 884 pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
@@ -928,7 +937,8 @@ int device_add(struct device *dev)
928 kobject_uevent(&dev->kobj, KOBJ_ADD); 937 kobject_uevent(&dev->kobj, KOBJ_ADD);
929 bus_attach_device(dev); 938 bus_attach_device(dev);
930 if (parent) 939 if (parent)
931 klist_add_tail(&dev->knode_parent, &parent->klist_children); 940 klist_add_tail(&dev->p->knode_parent,
941 &parent->p->klist_children);
932 942
933 if (dev->class) { 943 if (dev->class) {
934 mutex_lock(&dev->class->p->class_mutex); 944 mutex_lock(&dev->class->p->class_mutex);
@@ -1042,7 +1052,7 @@ void device_del(struct device *dev)
1042 device_pm_remove(dev); 1052 device_pm_remove(dev);
1043 dpm_sysfs_remove(dev); 1053 dpm_sysfs_remove(dev);
1044 if (parent) 1054 if (parent)
1045 klist_del(&dev->knode_parent); 1055 klist_del(&dev->p->knode_parent);
1046 if (MAJOR(dev->devt)) { 1056 if (MAJOR(dev->devt)) {
1047 device_remove_sys_dev_entry(dev); 1057 device_remove_sys_dev_entry(dev);
1048 device_remove_file(dev, &devt_attr); 1058 device_remove_file(dev, &devt_attr);
@@ -1103,7 +1113,14 @@ void device_unregister(struct device *dev)
1103static struct device *next_device(struct klist_iter *i) 1113static struct device *next_device(struct klist_iter *i)
1104{ 1114{
1105 struct klist_node *n = klist_next(i); 1115 struct klist_node *n = klist_next(i);
1106 return n ? container_of(n, struct device, knode_parent) : NULL; 1116 struct device *dev = NULL;
1117 struct device_private *p;
1118
1119 if (n) {
1120 p = to_device_private_parent(n);
1121 dev = p->device;
1122 }
1123 return dev;
1107} 1124}
1108 1125
1109/** 1126/**
@@ -1125,7 +1142,7 @@ int device_for_each_child(struct device *parent, void *data,
1125 struct device *child; 1142 struct device *child;
1126 int error = 0; 1143 int error = 0;
1127 1144
1128 klist_iter_init(&parent->klist_children, &i); 1145 klist_iter_init(&parent->p->klist_children, &i);
1129 while ((child = next_device(&i)) && !error) 1146 while ((child = next_device(&i)) && !error)
1130 error = fn(child, data); 1147 error = fn(child, data);
1131 klist_iter_exit(&i); 1148 klist_iter_exit(&i);
@@ -1156,7 +1173,7 @@ struct device *device_find_child(struct device *parent, void *data,
1156 if (!parent) 1173 if (!parent)
1157 return NULL; 1174 return NULL;
1158 1175
1159 klist_iter_init(&parent->klist_children, &i); 1176 klist_iter_init(&parent->p->klist_children, &i);
1160 while ((child = next_device(&i))) 1177 while ((child = next_device(&i)))
1161 if (match(child, data) && get_device(child)) 1178 if (match(child, data) && get_device(child))
1162 break; 1179 break;
@@ -1348,7 +1365,10 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
1348 dev->release = device_create_release; 1365 dev->release = device_create_release;
1349 dev_set_drvdata(dev, drvdata); 1366 dev_set_drvdata(dev, drvdata);
1350 1367
1351 vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args); 1368 retval = kobject_set_name_vargs(&dev->kobj, fmt, args);
1369 if (retval)
1370 goto error;
1371
1352 retval = device_register(dev); 1372 retval = device_register(dev);
1353 if (retval) 1373 if (retval)
1354 goto error; 1374 goto error;
@@ -1452,19 +1472,15 @@ int device_rename(struct device *dev, char *new_name)
1452 old_class_name = make_class_name(dev->class->name, &dev->kobj); 1472 old_class_name = make_class_name(dev->class->name, &dev->kobj);
1453#endif 1473#endif
1454 1474
1455 old_device_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); 1475 old_device_name = kstrdup(dev_name(dev), GFP_KERNEL);
1456 if (!old_device_name) { 1476 if (!old_device_name) {
1457 error = -ENOMEM; 1477 error = -ENOMEM;
1458 goto out; 1478 goto out;
1459 } 1479 }
1460 strlcpy(old_device_name, dev->bus_id, BUS_ID_SIZE);
1461 strlcpy(dev->bus_id, new_name, BUS_ID_SIZE);
1462 1480
1463 error = kobject_rename(&dev->kobj, new_name); 1481 error = kobject_rename(&dev->kobj, new_name);
1464 if (error) { 1482 if (error)
1465 strlcpy(dev->bus_id, old_device_name, BUS_ID_SIZE);
1466 goto out; 1483 goto out;
1467 }
1468 1484
1469#ifdef CONFIG_SYSFS_DEPRECATED 1485#ifdef CONFIG_SYSFS_DEPRECATED
1470 if (old_class_name) { 1486 if (old_class_name) {
@@ -1545,8 +1561,10 @@ out:
1545 * device_move - moves a device to a new parent 1561 * device_move - moves a device to a new parent
1546 * @dev: the pointer to the struct device to be moved 1562 * @dev: the pointer to the struct device to be moved
1547 * @new_parent: the new parent of the device (can by NULL) 1563 * @new_parent: the new parent of the device (can by NULL)
1564 * @dpm_order: how to reorder the dpm_list
1548 */ 1565 */
1549int device_move(struct device *dev, struct device *new_parent) 1566int device_move(struct device *dev, struct device *new_parent,
1567 enum dpm_order dpm_order)
1550{ 1568{
1551 int error; 1569 int error;
1552 struct device *old_parent; 1570 struct device *old_parent;
@@ -1556,6 +1574,7 @@ int device_move(struct device *dev, struct device *new_parent)
1556 if (!dev) 1574 if (!dev)
1557 return -EINVAL; 1575 return -EINVAL;
1558 1576
1577 device_pm_lock();
1559 new_parent = get_device(new_parent); 1578 new_parent = get_device(new_parent);
1560 new_parent_kobj = get_device_parent(dev, new_parent); 1579 new_parent_kobj = get_device_parent(dev, new_parent);
1561 1580
@@ -1570,9 +1589,10 @@ int device_move(struct device *dev, struct device *new_parent)
1570 old_parent = dev->parent; 1589 old_parent = dev->parent;
1571 dev->parent = new_parent; 1590 dev->parent = new_parent;
1572 if (old_parent) 1591 if (old_parent)
1573 klist_remove(&dev->knode_parent); 1592 klist_remove(&dev->p->knode_parent);
1574 if (new_parent) { 1593 if (new_parent) {
1575 klist_add_tail(&dev->knode_parent, &new_parent->klist_children); 1594 klist_add_tail(&dev->p->knode_parent,
1595 &new_parent->p->klist_children);
1576 set_dev_node(dev, dev_to_node(new_parent)); 1596 set_dev_node(dev, dev_to_node(new_parent));
1577 } 1597 }
1578 1598
@@ -1584,11 +1604,11 @@ int device_move(struct device *dev, struct device *new_parent)
1584 device_move_class_links(dev, new_parent, old_parent); 1604 device_move_class_links(dev, new_parent, old_parent);
1585 if (!kobject_move(&dev->kobj, &old_parent->kobj)) { 1605 if (!kobject_move(&dev->kobj, &old_parent->kobj)) {
1586 if (new_parent) 1606 if (new_parent)
1587 klist_remove(&dev->knode_parent); 1607 klist_remove(&dev->p->knode_parent);
1588 dev->parent = old_parent; 1608 dev->parent = old_parent;
1589 if (old_parent) { 1609 if (old_parent) {
1590 klist_add_tail(&dev->knode_parent, 1610 klist_add_tail(&dev->p->knode_parent,
1591 &old_parent->klist_children); 1611 &old_parent->p->klist_children);
1592 set_dev_node(dev, dev_to_node(old_parent)); 1612 set_dev_node(dev, dev_to_node(old_parent));
1593 } 1613 }
1594 } 1614 }
@@ -1596,9 +1616,23 @@ int device_move(struct device *dev, struct device *new_parent)
1596 put_device(new_parent); 1616 put_device(new_parent);
1597 goto out; 1617 goto out;
1598 } 1618 }
1619 switch (dpm_order) {
1620 case DPM_ORDER_NONE:
1621 break;
1622 case DPM_ORDER_DEV_AFTER_PARENT:
1623 device_pm_move_after(dev, new_parent);
1624 break;
1625 case DPM_ORDER_PARENT_BEFORE_DEV:
1626 device_pm_move_before(new_parent, dev);
1627 break;
1628 case DPM_ORDER_DEV_LAST:
1629 device_pm_move_last(dev);
1630 break;
1631 }
1599out_put: 1632out_put:
1600 put_device(old_parent); 1633 put_device(old_parent);
1601out: 1634out:
1635 device_pm_unlock();
1602 put_device(dev); 1636 put_device(dev);
1603 return error; 1637 return error;
1604} 1638}
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 135231239103..f17c3266a0e0 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -30,7 +30,7 @@
30 30
31static void driver_bound(struct device *dev) 31static void driver_bound(struct device *dev)
32{ 32{
33 if (klist_node_attached(&dev->knode_driver)) { 33 if (klist_node_attached(&dev->p->knode_driver)) {
34 printk(KERN_WARNING "%s: device %s already bound\n", 34 printk(KERN_WARNING "%s: device %s already bound\n",
35 __func__, kobject_name(&dev->kobj)); 35 __func__, kobject_name(&dev->kobj));
36 return; 36 return;
@@ -43,7 +43,7 @@ static void driver_bound(struct device *dev)
43 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 43 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
44 BUS_NOTIFY_BOUND_DRIVER, dev); 44 BUS_NOTIFY_BOUND_DRIVER, dev);
45 45
46 klist_add_tail(&dev->knode_driver, &dev->driver->p->klist_devices); 46 klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices);
47} 47}
48 48
49static int driver_sysfs_add(struct device *dev) 49static int driver_sysfs_add(struct device *dev)
@@ -172,16 +172,12 @@ int driver_probe_done(void)
172/** 172/**
173 * wait_for_device_probe 173 * wait_for_device_probe
174 * Wait for device probing to be completed. 174 * Wait for device probing to be completed.
175 *
176 * Note: this function polls at 100 msec intervals.
177 */ 175 */
178int wait_for_device_probe(void) 176void wait_for_device_probe(void)
179{ 177{
180 /* wait for the known devices to complete their probing */ 178 /* wait for the known devices to complete their probing */
181 while (driver_probe_done() != 0) 179 wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);
182 msleep(100);
183 async_synchronize_full(); 180 async_synchronize_full();
184 return 0;
185} 181}
186 182
187/** 183/**
@@ -189,14 +185,8 @@ int wait_for_device_probe(void)
189 * @drv: driver to bind a device to 185 * @drv: driver to bind a device to
190 * @dev: device to try to bind to the driver 186 * @dev: device to try to bind to the driver
191 * 187 *
192 * First, we call the bus's match function, if one present, which should 188 * This function returns -ENODEV if the device is not registered,
193 * compare the device IDs the driver supports with the device IDs of the 189 * 1 if the device is bound sucessfully and 0 otherwise.
194 * device. Note we don't do this ourselves because we don't know the
195 * format of the ID structures, nor what is to be considered a match and
196 * what is not.
197 *
198 * This function returns 1 if a match is found, -ENODEV if the device is
199 * not registered, and 0 otherwise.
200 * 190 *
201 * This function must be called with @dev->sem held. When called for a 191 * This function must be called with @dev->sem held. When called for a
202 * USB interface, @dev->parent->sem must be held as well. 192 * USB interface, @dev->parent->sem must be held as well.
@@ -207,21 +197,22 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
207 197
208 if (!device_is_registered(dev)) 198 if (!device_is_registered(dev))
209 return -ENODEV; 199 return -ENODEV;
210 if (drv->bus->match && !drv->bus->match(dev, drv))
211 goto done;
212 200
213 pr_debug("bus: '%s': %s: matched device %s with driver %s\n", 201 pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
214 drv->bus->name, __func__, dev_name(dev), drv->name); 202 drv->bus->name, __func__, dev_name(dev), drv->name);
215 203
216 ret = really_probe(dev, drv); 204 ret = really_probe(dev, drv);
217 205
218done:
219 return ret; 206 return ret;
220} 207}
221 208
222static int __device_attach(struct device_driver *drv, void *data) 209static int __device_attach(struct device_driver *drv, void *data)
223{ 210{
224 struct device *dev = data; 211 struct device *dev = data;
212
213 if (!driver_match_device(drv, dev))
214 return 0;
215
225 return driver_probe_device(drv, dev); 216 return driver_probe_device(drv, dev);
226} 217}
227 218
@@ -274,7 +265,7 @@ static int __driver_attach(struct device *dev, void *data)
274 * is an error. 265 * is an error.
275 */ 266 */
276 267
277 if (drv->bus->match && !drv->bus->match(dev, drv)) 268 if (!driver_match_device(drv, dev))
278 return 0; 269 return 0;
279 270
280 if (dev->parent) /* Needed for USB */ 271 if (dev->parent) /* Needed for USB */
@@ -327,7 +318,7 @@ static void __device_release_driver(struct device *dev)
327 drv->remove(dev); 318 drv->remove(dev);
328 devres_release_all(dev); 319 devres_release_all(dev);
329 dev->driver = NULL; 320 dev->driver = NULL;
330 klist_remove(&dev->knode_driver); 321 klist_remove(&dev->p->knode_driver);
331 } 322 }
332} 323}
333 324
@@ -357,6 +348,7 @@ EXPORT_SYMBOL_GPL(device_release_driver);
357 */ 348 */
358void driver_detach(struct device_driver *drv) 349void driver_detach(struct device_driver *drv)
359{ 350{
351 struct device_private *dev_prv;
360 struct device *dev; 352 struct device *dev;
361 353
362 for (;;) { 354 for (;;) {
@@ -365,8 +357,10 @@ void driver_detach(struct device_driver *drv)
365 spin_unlock(&drv->p->klist_devices.k_lock); 357 spin_unlock(&drv->p->klist_devices.k_lock);
366 break; 358 break;
367 } 359 }
368 dev = list_entry(drv->p->klist_devices.k_list.prev, 360 dev_prv = list_entry(drv->p->klist_devices.k_list.prev,
369 struct device, knode_driver.n_node); 361 struct device_private,
362 knode_driver.n_node);
363 dev = dev_prv->device;
370 get_device(dev); 364 get_device(dev);
371 spin_unlock(&drv->p->klist_devices.k_lock); 365 spin_unlock(&drv->p->klist_devices.k_lock);
372 366
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 1e2bda780e48..c51f11bb29ae 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -19,7 +19,14 @@
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 return n ? container_of(n, struct device, knode_driver) : NULL; 22 struct device *dev = 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;
23} 30}
24 31
25/** 32/**
@@ -42,7 +49,7 @@ int driver_for_each_device(struct device_driver *drv, struct device *start,
42 return -EINVAL; 49 return -EINVAL;
43 50
44 klist_iter_init_node(&drv->p->klist_devices, &i, 51 klist_iter_init_node(&drv->p->klist_devices, &i,
45 start ? &start->knode_driver : NULL); 52 start ? &start->p->knode_driver : NULL);
46 while ((dev = next_device(&i)) && !error) 53 while ((dev = next_device(&i)) && !error)
47 error = fn(dev, data); 54 error = fn(dev, data);
48 klist_iter_exit(&i); 55 klist_iter_exit(&i);
@@ -76,7 +83,7 @@ struct device *driver_find_device(struct device_driver *drv,
76 return NULL; 83 return NULL;
77 84
78 klist_iter_init_node(&drv->p->klist_devices, &i, 85 klist_iter_init_node(&drv->p->klist_devices, &i,
79 (start ? &start->knode_driver : NULL)); 86 (start ? &start->p->knode_driver : NULL));
80 while ((dev = next_device(&i))) 87 while ((dev = next_device(&i)))
81 if (match(dev, data) && get_device(dev)) 88 if (match(dev, data) && get_device(dev))
82 break; 89 break;
@@ -216,6 +223,8 @@ int driver_register(struct device_driver *drv)
216 int ret; 223 int ret;
217 struct device_driver *other; 224 struct device_driver *other;
218 225
226 BUG_ON(!drv->bus->p);
227
219 if ((drv->bus->probe && drv->probe) || 228 if ((drv->bus->probe && drv->probe) ||
220 (drv->bus->remove && drv->remove) || 229 (drv->bus->remove && drv->remove) ||
221 (drv->bus->shutdown && drv->shutdown)) 230 (drv->bus->shutdown && drv->shutdown))
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 44699d9dd85c..d3a59c688fe4 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -319,7 +319,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
319 f_dev->parent = device; 319 f_dev->parent = device;
320 f_dev->class = &firmware_class; 320 f_dev->class = &firmware_class;
321 dev_set_drvdata(f_dev, fw_priv); 321 dev_set_drvdata(f_dev, fw_priv);
322 f_dev->uevent_suppress = 1; 322 dev_set_uevent_suppress(f_dev, 1);
323 retval = device_register(f_dev); 323 retval = device_register(f_dev);
324 if (retval) { 324 if (retval) {
325 dev_err(device, "%s: device_register failed\n", __func__); 325 dev_err(device, "%s: device_register failed\n", __func__);
@@ -366,7 +366,7 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p,
366 } 366 }
367 367
368 if (uevent) 368 if (uevent)
369 f_dev->uevent_suppress = 0; 369 dev_set_uevent_suppress(f_dev, 0);
370 *dev_p = f_dev; 370 *dev_p = f_dev;
371 goto out; 371 goto out;
372 372
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 43fa90b837ee..f8f578a71b25 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -303,7 +303,7 @@ int unregister_mem_sect_under_nodes(struct memory_block *mem_blk)
303 sect_start_pfn = section_nr_to_pfn(mem_blk->phys_index); 303 sect_start_pfn = section_nr_to_pfn(mem_blk->phys_index);
304 sect_end_pfn = sect_start_pfn + PAGES_PER_SECTION - 1; 304 sect_end_pfn = sect_start_pfn + PAGES_PER_SECTION - 1;
305 for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) { 305 for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) {
306 unsigned int nid; 306 int nid;
307 307
308 nid = get_nid_for_pfn(pfn); 308 nid = get_nid_for_pfn(pfn);
309 if (nid < 0) 309 if (nid < 0)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 349a1013603f..d2198f64ad4e 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -217,6 +217,7 @@ int platform_device_add_data(struct platform_device *pdev, const void *data,
217 if (d) { 217 if (d) {
218 memcpy(d, data, size); 218 memcpy(d, data, size);
219 pdev->dev.platform_data = d; 219 pdev->dev.platform_data = d;
220 pdev->platform_data = d;
220 } 221 }
221 return d ? 0 : -ENOMEM; 222 return d ? 0 : -ENOMEM;
222} 223}
@@ -246,6 +247,21 @@ int platform_device_add(struct platform_device *pdev)
246 else 247 else
247 dev_set_name(&pdev->dev, pdev->name); 248 dev_set_name(&pdev->dev, pdev->name);
248 249
250 /* We will remove platform_data field from struct device
251 * if all platform devices pass its platform specific data
252 * from platform_device. The conversion is going to be a
253 * long time, so we allow the two cases coexist to make
254 * this kind of fix more easily*/
255 if (pdev->platform_data && pdev->dev.platform_data) {
256 printk(KERN_ERR
257 "%s: use which platform_data?\n",
258 dev_name(&pdev->dev));
259 } else if (pdev->platform_data) {
260 pdev->dev.platform_data = pdev->platform_data;
261 } else if (pdev->dev.platform_data) {
262 pdev->platform_data = pdev->dev.platform_data;
263 }
264
249 for (i = 0; i < pdev->num_resources; i++) { 265 for (i = 0; i < pdev->num_resources; i++) {
250 struct resource *p, *r = &pdev->resource[i]; 266 struct resource *p, *r = &pdev->resource[i];
251 267
@@ -584,10 +600,25 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
584{ 600{
585 struct platform_device *pdev = to_platform_device(dev); 601 struct platform_device *pdev = to_platform_device(dev);
586 602
587 add_uevent_var(env, "MODALIAS=platform:%s", pdev->name); 603 add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX,
604 (pdev->id_entry) ? pdev->id_entry->name : pdev->name);
588 return 0; 605 return 0;
589} 606}
590 607
608static const struct platform_device_id *platform_match_id(
609 struct platform_device_id *id,
610 struct platform_device *pdev)
611{
612 while (id->name[0]) {
613 if (strcmp(pdev->name, id->name) == 0) {
614 pdev->id_entry = id;
615 return id;
616 }
617 id++;
618 }
619 return NULL;
620}
621
591/** 622/**
592 * platform_match - bind platform device to platform driver. 623 * platform_match - bind platform device to platform driver.
593 * @dev: device. 624 * @dev: device.
@@ -603,9 +634,14 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
603 */ 634 */
604static int platform_match(struct device *dev, struct device_driver *drv) 635static int platform_match(struct device *dev, struct device_driver *drv)
605{ 636{
606 struct platform_device *pdev; 637 struct platform_device *pdev = to_platform_device(dev);
638 struct platform_driver *pdrv = to_platform_driver(drv);
607 639
608 pdev = container_of(dev, struct platform_device, dev); 640 /* match against the id table first */
641 if (pdrv->id_table)
642 return platform_match_id(pdrv->id_table, pdev) != NULL;
643
644 /* fall-back to driver name match */
609 return (strcmp(pdev->name, drv->name) == 0); 645 return (strcmp(pdev->name, drv->name) == 0);
610} 646}
611 647
@@ -623,26 +659,24 @@ static int platform_legacy_suspend(struct device *dev, pm_message_t mesg)
623 659
624static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg) 660static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg)
625{ 661{
626 struct platform_driver *drv = to_platform_driver(dev->driver); 662 struct platform_driver *pdrv = to_platform_driver(dev->driver);
627 struct platform_device *pdev; 663 struct platform_device *pdev = to_platform_device(dev);
628 int ret = 0; 664 int ret = 0;
629 665
630 pdev = container_of(dev, struct platform_device, dev); 666 if (dev->driver && pdrv->suspend_late)
631 if (dev->driver && drv->suspend_late) 667 ret = pdrv->suspend_late(pdev, mesg);
632 ret = drv->suspend_late(pdev, mesg);
633 668
634 return ret; 669 return ret;
635} 670}
636 671
637static int platform_legacy_resume_early(struct device *dev) 672static int platform_legacy_resume_early(struct device *dev)
638{ 673{
639 struct platform_driver *drv = to_platform_driver(dev->driver); 674 struct platform_driver *pdrv = to_platform_driver(dev->driver);
640 struct platform_device *pdev; 675 struct platform_device *pdev = to_platform_device(dev);
641 int ret = 0; 676 int ret = 0;
642 677
643 pdev = container_of(dev, struct platform_device, dev); 678 if (dev->driver && pdrv->resume_early)
644 if (dev->driver && drv->resume_early) 679 ret = pdrv->resume_early(pdev);
645 ret = drv->resume_early(pdev);
646 680
647 return ret; 681 return ret;
648} 682}
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 2d14f4ae6c01..e255341682c8 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -107,6 +107,50 @@ void device_pm_remove(struct device *dev)
107} 107}
108 108
109/** 109/**
110 * device_pm_move_before - move device in dpm_list
111 * @deva: Device to move in dpm_list
112 * @devb: Device @deva should come before
113 */
114void device_pm_move_before(struct device *deva, struct device *devb)
115{
116 pr_debug("PM: Moving %s:%s before %s:%s\n",
117 deva->bus ? deva->bus->name : "No Bus",
118 kobject_name(&deva->kobj),
119 devb->bus ? devb->bus->name : "No Bus",
120 kobject_name(&devb->kobj));
121 /* Delete deva from dpm_list and reinsert before devb. */
122 list_move_tail(&deva->power.entry, &devb->power.entry);
123}
124
125/**
126 * device_pm_move_after - move device in dpm_list
127 * @deva: Device to move in dpm_list
128 * @devb: Device @deva should come after
129 */
130void device_pm_move_after(struct device *deva, struct device *devb)
131{
132 pr_debug("PM: Moving %s:%s after %s:%s\n",
133 deva->bus ? deva->bus->name : "No Bus",
134 kobject_name(&deva->kobj),
135 devb->bus ? devb->bus->name : "No Bus",
136 kobject_name(&devb->kobj));
137 /* Delete deva from dpm_list and reinsert after devb. */
138 list_move(&deva->power.entry, &devb->power.entry);
139}
140
141/**
142 * device_pm_move_last - move device to end of dpm_list
143 * @dev: Device to move in dpm_list
144 */
145void device_pm_move_last(struct device *dev)
146{
147 pr_debug("PM: Moving %s:%s to end of list\n",
148 dev->bus ? dev->bus->name : "No Bus",
149 kobject_name(&dev->kobj));
150 list_move_tail(&dev->power.entry, &dpm_list);
151}
152
153/**
110 * pm_op - execute the PM operation appropiate for given PM event 154 * pm_op - execute the PM operation appropiate for given PM event
111 * @dev: Device. 155 * @dev: Device.
112 * @ops: PM operations to choose from. 156 * @ops: PM operations to choose from.
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 41f51fae042f..c7cb4fc3735c 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -18,11 +18,19 @@ static inline struct device *to_device(struct list_head *entry)
18 18
19extern void device_pm_add(struct device *); 19extern void device_pm_add(struct device *);
20extern void device_pm_remove(struct device *); 20extern void device_pm_remove(struct device *);
21extern void device_pm_move_before(struct device *, struct device *);
22extern void device_pm_move_after(struct device *, struct device *);
23extern void device_pm_move_last(struct device *);
21 24
22#else /* CONFIG_PM_SLEEP */ 25#else /* CONFIG_PM_SLEEP */
23 26
24static inline void device_pm_add(struct device *dev) {} 27static inline void device_pm_add(struct device *dev) {}
25static inline void device_pm_remove(struct device *dev) {} 28static inline void device_pm_remove(struct device *dev) {}
29static inline void device_pm_move_before(struct device *deva,
30 struct device *devb) {}
31static inline void device_pm_move_after(struct device *deva,
32 struct device *devb) {}
33static inline void device_pm_move_last(struct device *dev) {}
26 34
27#endif 35#endif
28 36
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index b428c8c4bc64..cbd36cf59a0f 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -30,10 +30,10 @@
30 30
31 31
32static ssize_t 32static ssize_t
33sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer) 33sysdev_show(struct kobject *kobj, struct attribute *attr, char *buffer)
34{ 34{
35 struct sys_device * sysdev = to_sysdev(kobj); 35 struct sys_device *sysdev = to_sysdev(kobj);
36 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 36 struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr);
37 37
38 if (sysdev_attr->show) 38 if (sysdev_attr->show)
39 return sysdev_attr->show(sysdev, sysdev_attr, buffer); 39 return sysdev_attr->show(sysdev, sysdev_attr, buffer);
@@ -42,11 +42,11 @@ sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer)
42 42
43 43
44static ssize_t 44static ssize_t
45sysdev_store(struct kobject * kobj, struct attribute * attr, 45sysdev_store(struct kobject *kobj, struct attribute *attr,
46 const char * buffer, size_t count) 46 const char *buffer, size_t count)
47{ 47{
48 struct sys_device * sysdev = to_sysdev(kobj); 48 struct sys_device *sysdev = to_sysdev(kobj);
49 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 49 struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr);
50 50
51 if (sysdev_attr->store) 51 if (sysdev_attr->store)
52 return sysdev_attr->store(sysdev, sysdev_attr, buffer, count); 52 return sysdev_attr->store(sysdev, sysdev_attr, buffer, count);
@@ -63,13 +63,13 @@ static struct kobj_type ktype_sysdev = {
63}; 63};
64 64
65 65
66int sysdev_create_file(struct sys_device * s, struct sysdev_attribute * a) 66int sysdev_create_file(struct sys_device *s, struct sysdev_attribute *a)
67{ 67{
68 return sysfs_create_file(&s->kobj, &a->attr); 68 return sysfs_create_file(&s->kobj, &a->attr);
69} 69}
70 70
71 71
72void sysdev_remove_file(struct sys_device * s, struct sysdev_attribute * a) 72void sysdev_remove_file(struct sys_device *s, struct sysdev_attribute *a)
73{ 73{
74 sysfs_remove_file(&s->kobj, &a->attr); 74 sysfs_remove_file(&s->kobj, &a->attr);
75} 75}
@@ -84,7 +84,7 @@ EXPORT_SYMBOL_GPL(sysdev_remove_file);
84static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr, 84static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr,
85 char *buffer) 85 char *buffer)
86{ 86{
87 struct sysdev_class * class = to_sysdev_class(kobj); 87 struct sysdev_class *class = to_sysdev_class(kobj);
88 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); 88 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
89 89
90 if (class_attr->show) 90 if (class_attr->show)
@@ -95,8 +95,8 @@ static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr,
95static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr, 95static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
96 const char *buffer, size_t count) 96 const char *buffer, size_t count)
97{ 97{
98 struct sysdev_class * class = to_sysdev_class(kobj); 98 struct sysdev_class *class = to_sysdev_class(kobj);
99 struct sysdev_class_attribute * class_attr = to_sysdev_class_attr(attr); 99 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
100 100
101 if (class_attr->store) 101 if (class_attr->store)
102 return class_attr->store(class, buffer, count); 102 return class_attr->store(class, buffer, count);
@@ -128,7 +128,7 @@ EXPORT_SYMBOL_GPL(sysdev_class_remove_file);
128 128
129static struct kset *system_kset; 129static struct kset *system_kset;
130 130
131int sysdev_class_register(struct sysdev_class * cls) 131int sysdev_class_register(struct sysdev_class *cls)
132{ 132{
133 pr_debug("Registering sysdev class '%s'\n", cls->name); 133 pr_debug("Registering sysdev class '%s'\n", cls->name);
134 134
@@ -141,7 +141,7 @@ int sysdev_class_register(struct sysdev_class * cls)
141 return kset_register(&cls->kset); 141 return kset_register(&cls->kset);
142} 142}
143 143
144void sysdev_class_unregister(struct sysdev_class * cls) 144void sysdev_class_unregister(struct sysdev_class *cls)
145{ 145{
146 pr_debug("Unregistering sysdev class '%s'\n", 146 pr_debug("Unregistering sysdev class '%s'\n",
147 kobject_name(&cls->kset.kobj)); 147 kobject_name(&cls->kset.kobj));
@@ -203,8 +203,8 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
203 * @cls: Class driver belongs to. 203 * @cls: Class driver belongs to.
204 * @drv: Driver. 204 * @drv: Driver.
205 */ 205 */
206void sysdev_driver_unregister(struct sysdev_class * cls, 206void sysdev_driver_unregister(struct sysdev_class *cls,
207 struct sysdev_driver * drv) 207 struct sysdev_driver *drv)
208{ 208{
209 mutex_lock(&sysdev_drivers_lock); 209 mutex_lock(&sysdev_drivers_lock);
210 list_del_init(&drv->entry); 210 list_del_init(&drv->entry);
@@ -229,10 +229,10 @@ EXPORT_SYMBOL_GPL(sysdev_driver_unregister);
229 * @sysdev: device in question 229 * @sysdev: device in question
230 * 230 *
231 */ 231 */
232int sysdev_register(struct sys_device * sysdev) 232int sysdev_register(struct sys_device *sysdev)
233{ 233{
234 int error; 234 int error;
235 struct sysdev_class * cls = sysdev->cls; 235 struct sysdev_class *cls = sysdev->cls;
236 236
237 if (!cls) 237 if (!cls)
238 return -EINVAL; 238 return -EINVAL;
@@ -252,7 +252,7 @@ int sysdev_register(struct sys_device * sysdev)
252 sysdev->id); 252 sysdev->id);
253 253
254 if (!error) { 254 if (!error) {
255 struct sysdev_driver * drv; 255 struct sysdev_driver *drv;
256 256
257 pr_debug("Registering sys device '%s'\n", 257 pr_debug("Registering sys device '%s'\n",
258 kobject_name(&sysdev->kobj)); 258 kobject_name(&sysdev->kobj));
@@ -274,9 +274,9 @@ int sysdev_register(struct sys_device * sysdev)
274 return error; 274 return error;
275} 275}
276 276
277void sysdev_unregister(struct sys_device * sysdev) 277void sysdev_unregister(struct sys_device *sysdev)
278{ 278{
279 struct sysdev_driver * drv; 279 struct sysdev_driver *drv;
280 280
281 mutex_lock(&sysdev_drivers_lock); 281 mutex_lock(&sysdev_drivers_lock);
282 list_for_each_entry(drv, &sysdev->cls->drivers, entry) { 282 list_for_each_entry(drv, &sysdev->cls->drivers, entry) {
@@ -305,19 +305,19 @@ void sysdev_unregister(struct sys_device * sysdev)
305 */ 305 */
306void sysdev_shutdown(void) 306void sysdev_shutdown(void)
307{ 307{
308 struct sysdev_class * cls; 308 struct sysdev_class *cls;
309 309
310 pr_debug("Shutting Down System Devices\n"); 310 pr_debug("Shutting Down System Devices\n");
311 311
312 mutex_lock(&sysdev_drivers_lock); 312 mutex_lock(&sysdev_drivers_lock);
313 list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) { 313 list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
314 struct sys_device * sysdev; 314 struct sys_device *sysdev;
315 315
316 pr_debug("Shutting down type '%s':\n", 316 pr_debug("Shutting down type '%s':\n",
317 kobject_name(&cls->kset.kobj)); 317 kobject_name(&cls->kset.kobj));
318 318
319 list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) { 319 list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
320 struct sysdev_driver * drv; 320 struct sysdev_driver *drv;
321 pr_debug(" %s\n", kobject_name(&sysdev->kobj)); 321 pr_debug(" %s\n", kobject_name(&sysdev->kobj));
322 322
323 /* Call auxillary drivers first */ 323 /* Call auxillary drivers first */
@@ -364,7 +364,7 @@ static void __sysdev_resume(struct sys_device *dev)
364 */ 364 */
365int sysdev_suspend(pm_message_t state) 365int sysdev_suspend(pm_message_t state)
366{ 366{
367 struct sysdev_class * cls; 367 struct sysdev_class *cls;
368 struct sys_device *sysdev, *err_dev; 368 struct sys_device *sysdev, *err_dev;
369 struct sysdev_driver *drv, *err_drv; 369 struct sysdev_driver *drv, *err_drv;
370 int ret; 370 int ret;
@@ -442,12 +442,12 @@ EXPORT_SYMBOL_GPL(sysdev_suspend);
442 */ 442 */
443int sysdev_resume(void) 443int sysdev_resume(void)
444{ 444{
445 struct sysdev_class * cls; 445 struct sysdev_class *cls;
446 446
447 pr_debug("Resuming System Devices\n"); 447 pr_debug("Resuming System Devices\n");
448 448
449 list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) { 449 list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) {
450 struct sys_device * sysdev; 450 struct sys_device *sysdev;
451 451
452 pr_debug("Resuming type '%s':\n", 452 pr_debug("Resuming type '%s':\n",
453 kobject_name(&cls->kset.kobj)); 453 kobject_name(&cls->kset.kobj));
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 204332b29578..87e120e0a79c 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MAC_FLOPPY) += swim3.o
9obj-$(CONFIG_BLK_DEV_FD) += floppy.o 9obj-$(CONFIG_BLK_DEV_FD) += floppy.o
10obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o 10obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o
11obj-$(CONFIG_PS3_DISK) += ps3disk.o 11obj-$(CONFIG_PS3_DISK) += ps3disk.o
12obj-$(CONFIG_PS3_VRAM) += ps3vram.o
12obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o 13obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
13obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o 14obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
14obj-$(CONFIG_BLK_DEV_RAM) += brd.o 15obj-$(CONFIG_BLK_DEV_RAM) += brd.o
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index b5a061114630..4f9b6d792017 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3606,11 +3606,9 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3606 if (cciss_hard_reset_controller(pdev) || cciss_reset_msi(pdev)) 3606 if (cciss_hard_reset_controller(pdev) || cciss_reset_msi(pdev))
3607 return -ENODEV; 3607 return -ENODEV;
3608 3608
3609 /* Some devices (notably the HP Smart Array 5i Controller) 3609 /* Now try to get the controller to respond to a no-op. Some
3610 need a little pause here */ 3610 devices (notably the HP Smart Array 5i Controller) need
3611 schedule_timeout_uninterruptible(30*HZ); 3611 up to 30 seconds to respond. */
3612
3613 /* Now try to get the controller to respond to a no-op */
3614 for (i=0; i<30; i++) { 3612 for (i=0; i<30; i++) {
3615 if (cciss_noop(pdev) == 0) 3613 if (cciss_noop(pdev) == 0)
3616 break; 3614 break;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 83d8ed39433d..c2c95e614506 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4135,10 +4135,9 @@ static int have_no_fdc = -ENODEV;
4135static ssize_t floppy_cmos_show(struct device *dev, 4135static ssize_t floppy_cmos_show(struct device *dev,
4136 struct device_attribute *attr, char *buf) 4136 struct device_attribute *attr, char *buf)
4137{ 4137{
4138 struct platform_device *p; 4138 struct platform_device *p = to_platform_device(dev);
4139 int drive; 4139 int drive;
4140 4140
4141 p = container_of(dev, struct platform_device,dev);
4142 drive = p->id; 4141 drive = p->id;
4143 return sprintf(buf, "%X\n", UDP->cmos); 4142 return sprintf(buf, "%X\n", UDP->cmos);
4144} 4143}
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index edbaac6c0573..bf0345577672 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -392,8 +392,7 @@ lo_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
392 struct loop_device *lo = p->lo; 392 struct loop_device *lo = p->lo;
393 struct page *page = buf->page; 393 struct page *page = buf->page;
394 sector_t IV; 394 sector_t IV;
395 size_t size; 395 int size, ret;
396 int ret;
397 396
398 ret = buf->ops->confirm(pipe, buf); 397 ret = buf->ops->confirm(pipe, buf);
399 if (unlikely(ret)) 398 if (unlikely(ret))
diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
new file mode 100644
index 000000000000..393ed6760d78
--- /dev/null
+++ b/drivers/block/ps3vram.c
@@ -0,0 +1,865 @@
1/*
2 * ps3vram - Use extra PS3 video ram as MTD block device.
3 *
4 * Copyright 2009 Sony Corporation
5 *
6 * Based on the MTD ps3vram driver, which is
7 * Copyright (c) 2007-2008 Jim Paris <jim@jtan.com>
8 * Added support RSX DMA Vivien Chappelier <vivien.chappelier@free.fr>
9 */
10
11#include <linux/blkdev.h>
12#include <linux/delay.h>
13#include <linux/proc_fs.h>
14#include <linux/seq_file.h>
15
16#include <asm/firmware.h>
17#include <asm/lv1call.h>
18#include <asm/ps3.h>
19
20
21#define DEVICE_NAME "ps3vram"
22
23
24#define XDR_BUF_SIZE (2 * 1024 * 1024) /* XDR buffer (must be 1MiB aligned) */
25#define XDR_IOIF 0x0c000000
26
27#define FIFO_BASE XDR_IOIF
28#define FIFO_SIZE (64 * 1024)
29
30#define DMA_PAGE_SIZE (4 * 1024)
31
32#define CACHE_PAGE_SIZE (256 * 1024)
33#define CACHE_PAGE_COUNT ((XDR_BUF_SIZE - FIFO_SIZE) / CACHE_PAGE_SIZE)
34
35#define CACHE_OFFSET CACHE_PAGE_SIZE
36#define FIFO_OFFSET 0
37
38#define CTRL_PUT 0x10
39#define CTRL_GET 0x11
40#define CTRL_TOP 0x15
41
42#define UPLOAD_SUBCH 1
43#define DOWNLOAD_SUBCH 2
44
45#define NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN 0x0000030c
46#define NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY 0x00000104
47
48#define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT 0x601
49
50#define CACHE_PAGE_PRESENT 1
51#define CACHE_PAGE_DIRTY 2
52
53struct ps3vram_tag {
54 unsigned int address;
55 unsigned int flags;
56};
57
58struct ps3vram_cache {
59 unsigned int page_count;
60 unsigned int page_size;
61 struct ps3vram_tag *tags;
62 unsigned int hit;
63 unsigned int miss;
64};
65
66struct ps3vram_priv {
67 struct request_queue *queue;
68 struct gendisk *gendisk;
69
70 u64 size;
71
72 u64 memory_handle;
73 u64 context_handle;
74 u32 *ctrl;
75 u32 *reports;
76 u8 __iomem *ddr_base;
77 u8 *xdr_buf;
78
79 u32 *fifo_base;
80 u32 *fifo_ptr;
81
82 struct ps3vram_cache cache;
83
84 /* Used to serialize cache/DMA operations */
85 struct mutex lock;
86};
87
88
89static int ps3vram_major;
90
91
92static struct block_device_operations ps3vram_fops = {
93 .owner = THIS_MODULE,
94};
95
96
97#define DMA_NOTIFIER_HANDLE_BASE 0x66604200 /* first DMA notifier handle */
98#define DMA_NOTIFIER_OFFSET_BASE 0x1000 /* first DMA notifier offset */
99#define DMA_NOTIFIER_SIZE 0x40
100#define NOTIFIER 7 /* notifier used for completion report */
101
102static char *size = "256M";
103module_param(size, charp, 0);
104MODULE_PARM_DESC(size, "memory size");
105
106static u32 *ps3vram_get_notifier(u32 *reports, int notifier)
107{
108 return (void *)reports + DMA_NOTIFIER_OFFSET_BASE +
109 DMA_NOTIFIER_SIZE * notifier;
110}
111
112static void ps3vram_notifier_reset(struct ps3_system_bus_device *dev)
113{
114 struct ps3vram_priv *priv = dev->core.driver_data;
115 u32 *notify = ps3vram_get_notifier(priv->reports, NOTIFIER);
116 int i;
117
118 for (i = 0; i < 4; i++)
119 notify[i] = 0xffffffff;
120}
121
122static int ps3vram_notifier_wait(struct ps3_system_bus_device *dev,
123 unsigned int timeout_ms)
124{
125 struct ps3vram_priv *priv = dev->core.driver_data;
126 u32 *notify = ps3vram_get_notifier(priv->reports, NOTIFIER);
127 unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
128
129 do {
130 if (!notify[3])
131 return 0;
132 msleep(1);
133 } while (time_before(jiffies, timeout));
134
135 return -ETIMEDOUT;
136}
137
138static void ps3vram_init_ring(struct ps3_system_bus_device *dev)
139{
140 struct ps3vram_priv *priv = dev->core.driver_data;
141
142 priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET;
143 priv->ctrl[CTRL_GET] = FIFO_BASE + FIFO_OFFSET;
144}
145
146static int ps3vram_wait_ring(struct ps3_system_bus_device *dev,
147 unsigned int timeout_ms)
148{
149 struct ps3vram_priv *priv = dev->core.driver_data;
150 unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
151
152 do {
153 if (priv->ctrl[CTRL_PUT] == priv->ctrl[CTRL_GET])
154 return 0;
155 msleep(1);
156 } while (time_before(jiffies, timeout));
157
158 dev_warn(&dev->core, "FIFO timeout (%08x/%08x/%08x)\n",
159 priv->ctrl[CTRL_PUT], priv->ctrl[CTRL_GET],
160 priv->ctrl[CTRL_TOP]);
161
162 return -ETIMEDOUT;
163}
164
165static void ps3vram_out_ring(struct ps3vram_priv *priv, u32 data)
166{
167 *(priv->fifo_ptr)++ = data;
168}
169
170static void ps3vram_begin_ring(struct ps3vram_priv *priv, u32 chan, u32 tag,
171 u32 size)
172{
173 ps3vram_out_ring(priv, (size << 18) | (chan << 13) | tag);
174}
175
176static void ps3vram_rewind_ring(struct ps3_system_bus_device *dev)
177{
178 struct ps3vram_priv *priv = dev->core.driver_data;
179 int status;
180
181 ps3vram_out_ring(priv, 0x20000000 | (FIFO_BASE + FIFO_OFFSET));
182
183 priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET;
184
185 /* asking the HV for a blit will kick the FIFO */
186 status = lv1_gpu_context_attribute(priv->context_handle,
187 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 0,
188 0, 0, 0);
189 if (status)
190 dev_err(&dev->core,
191 "%s: lv1_gpu_context_attribute failed %d\n", __func__,
192 status);
193
194 priv->fifo_ptr = priv->fifo_base;
195}
196
197static void ps3vram_fire_ring(struct ps3_system_bus_device *dev)
198{
199 struct ps3vram_priv *priv = dev->core.driver_data;
200 int status;
201
202 mutex_lock(&ps3_gpu_mutex);
203
204 priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET +
205 (priv->fifo_ptr - priv->fifo_base) * sizeof(u32);
206
207 /* asking the HV for a blit will kick the FIFO */
208 status = lv1_gpu_context_attribute(priv->context_handle,
209 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 0,
210 0, 0, 0);
211 if (status)
212 dev_err(&dev->core,
213 "%s: lv1_gpu_context_attribute failed %d\n", __func__,
214 status);
215
216 if ((priv->fifo_ptr - priv->fifo_base) * sizeof(u32) >
217 FIFO_SIZE - 1024) {
218 dev_dbg(&dev->core, "FIFO full, rewinding\n");
219 ps3vram_wait_ring(dev, 200);
220 ps3vram_rewind_ring(dev);
221 }
222
223 mutex_unlock(&ps3_gpu_mutex);
224}
225
226static void ps3vram_bind(struct ps3_system_bus_device *dev)
227{
228 struct ps3vram_priv *priv = dev->core.driver_data;
229
230 ps3vram_begin_ring(priv, UPLOAD_SUBCH, 0, 1);
231 ps3vram_out_ring(priv, 0x31337303);
232 ps3vram_begin_ring(priv, UPLOAD_SUBCH, 0x180, 3);
233 ps3vram_out_ring(priv, DMA_NOTIFIER_HANDLE_BASE + NOTIFIER);
234 ps3vram_out_ring(priv, 0xfeed0001); /* DMA system RAM instance */
235 ps3vram_out_ring(priv, 0xfeed0000); /* DMA video RAM instance */
236
237 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH, 0, 1);
238 ps3vram_out_ring(priv, 0x3137c0de);
239 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH, 0x180, 3);
240 ps3vram_out_ring(priv, DMA_NOTIFIER_HANDLE_BASE + NOTIFIER);
241 ps3vram_out_ring(priv, 0xfeed0000); /* DMA video RAM instance */
242 ps3vram_out_ring(priv, 0xfeed0001); /* DMA system RAM instance */
243
244 ps3vram_fire_ring(dev);
245}
246
247static int ps3vram_upload(struct ps3_system_bus_device *dev,
248 unsigned int src_offset, unsigned int dst_offset,
249 int len, int count)
250{
251 struct ps3vram_priv *priv = dev->core.driver_data;
252
253 ps3vram_begin_ring(priv, UPLOAD_SUBCH,
254 NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
255 ps3vram_out_ring(priv, XDR_IOIF + src_offset);
256 ps3vram_out_ring(priv, dst_offset);
257 ps3vram_out_ring(priv, len);
258 ps3vram_out_ring(priv, len);
259 ps3vram_out_ring(priv, len);
260 ps3vram_out_ring(priv, count);
261 ps3vram_out_ring(priv, (1 << 8) | 1);
262 ps3vram_out_ring(priv, 0);
263
264 ps3vram_notifier_reset(dev);
265 ps3vram_begin_ring(priv, UPLOAD_SUBCH,
266 NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY, 1);
267 ps3vram_out_ring(priv, 0);
268 ps3vram_begin_ring(priv, UPLOAD_SUBCH, 0x100, 1);
269 ps3vram_out_ring(priv, 0);
270 ps3vram_fire_ring(dev);
271 if (ps3vram_notifier_wait(dev, 200) < 0) {
272 dev_warn(&dev->core, "%s: Notifier timeout\n", __func__);
273 return -1;
274 }
275
276 return 0;
277}
278
279static int ps3vram_download(struct ps3_system_bus_device *dev,
280 unsigned int src_offset, unsigned int dst_offset,
281 int len, int count)
282{
283 struct ps3vram_priv *priv = dev->core.driver_data;
284
285 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH,
286 NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
287 ps3vram_out_ring(priv, src_offset);
288 ps3vram_out_ring(priv, XDR_IOIF + dst_offset);
289 ps3vram_out_ring(priv, len);
290 ps3vram_out_ring(priv, len);
291 ps3vram_out_ring(priv, len);
292 ps3vram_out_ring(priv, count);
293 ps3vram_out_ring(priv, (1 << 8) | 1);
294 ps3vram_out_ring(priv, 0);
295
296 ps3vram_notifier_reset(dev);
297 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH,
298 NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY, 1);
299 ps3vram_out_ring(priv, 0);
300 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH, 0x100, 1);
301 ps3vram_out_ring(priv, 0);
302 ps3vram_fire_ring(dev);
303 if (ps3vram_notifier_wait(dev, 200) < 0) {
304 dev_warn(&dev->core, "%s: Notifier timeout\n", __func__);
305 return -1;
306 }
307
308 return 0;
309}
310
311static void ps3vram_cache_evict(struct ps3_system_bus_device *dev, int entry)
312{
313 struct ps3vram_priv *priv = dev->core.driver_data;
314 struct ps3vram_cache *cache = &priv->cache;
315
316 if (!(cache->tags[entry].flags & CACHE_PAGE_DIRTY))
317 return;
318
319 dev_dbg(&dev->core, "Flushing %d: 0x%08x\n", entry,
320 cache->tags[entry].address);
321 if (ps3vram_upload(dev, CACHE_OFFSET + entry * cache->page_size,
322 cache->tags[entry].address, DMA_PAGE_SIZE,
323 cache->page_size / DMA_PAGE_SIZE) < 0) {
324 dev_err(&dev->core,
325 "Failed to upload from 0x%x to " "0x%x size 0x%x\n",
326 entry * cache->page_size, cache->tags[entry].address,
327 cache->page_size);
328 }
329 cache->tags[entry].flags &= ~CACHE_PAGE_DIRTY;
330}
331
332static void ps3vram_cache_load(struct ps3_system_bus_device *dev, int entry,
333 unsigned int address)
334{
335 struct ps3vram_priv *priv = dev->core.driver_data;
336 struct ps3vram_cache *cache = &priv->cache;
337
338 dev_dbg(&dev->core, "Fetching %d: 0x%08x\n", entry, address);
339 if (ps3vram_download(dev, address,
340 CACHE_OFFSET + entry * cache->page_size,
341 DMA_PAGE_SIZE,
342 cache->page_size / DMA_PAGE_SIZE) < 0) {
343 dev_err(&dev->core,
344 "Failed to download from 0x%x to 0x%x size 0x%x\n",
345 address, entry * cache->page_size, cache->page_size);
346 }
347
348 cache->tags[entry].address = address;
349 cache->tags[entry].flags |= CACHE_PAGE_PRESENT;
350}
351
352
353static void ps3vram_cache_flush(struct ps3_system_bus_device *dev)
354{
355 struct ps3vram_priv *priv = dev->core.driver_data;
356 struct ps3vram_cache *cache = &priv->cache;
357 int i;
358
359 dev_dbg(&dev->core, "FLUSH\n");
360 for (i = 0; i < cache->page_count; i++) {
361 ps3vram_cache_evict(dev, i);
362 cache->tags[i].flags = 0;
363 }
364}
365
366static unsigned int ps3vram_cache_match(struct ps3_system_bus_device *dev,
367 loff_t address)
368{
369 struct ps3vram_priv *priv = dev->core.driver_data;
370 struct ps3vram_cache *cache = &priv->cache;
371 unsigned int base;
372 unsigned int offset;
373 int i;
374 static int counter;
375
376 offset = (unsigned int) (address & (cache->page_size - 1));
377 base = (unsigned int) (address - offset);
378
379 /* fully associative check */
380 for (i = 0; i < cache->page_count; i++) {
381 if ((cache->tags[i].flags & CACHE_PAGE_PRESENT) &&
382 cache->tags[i].address == base) {
383 cache->hit++;
384 dev_dbg(&dev->core, "Found entry %d: 0x%08x\n", i,
385 cache->tags[i].address);
386 return i;
387 }
388 }
389
390 /* choose a random entry */
391 i = (jiffies + (counter++)) % cache->page_count;
392 dev_dbg(&dev->core, "Using entry %d\n", i);
393
394 ps3vram_cache_evict(dev, i);
395 ps3vram_cache_load(dev, i, base);
396
397 cache->miss++;
398 return i;
399}
400
401static int ps3vram_cache_init(struct ps3_system_bus_device *dev)
402{
403 struct ps3vram_priv *priv = dev->core.driver_data;
404
405 priv->cache.page_count = CACHE_PAGE_COUNT;
406 priv->cache.page_size = CACHE_PAGE_SIZE;
407 priv->cache.tags = kzalloc(sizeof(struct ps3vram_tag) *
408 CACHE_PAGE_COUNT, GFP_KERNEL);
409 if (priv->cache.tags == NULL) {
410 dev_err(&dev->core, "Could not allocate cache tags\n");
411 return -ENOMEM;
412 }
413
414 dev_info(&dev->core, "Created ram cache: %d entries, %d KiB each\n",
415 CACHE_PAGE_COUNT, CACHE_PAGE_SIZE / 1024);
416
417 return 0;
418}
419
420static void ps3vram_cache_cleanup(struct ps3_system_bus_device *dev)
421{
422 struct ps3vram_priv *priv = dev->core.driver_data;
423
424 ps3vram_cache_flush(dev);
425 kfree(priv->cache.tags);
426}
427
428static int ps3vram_read(struct ps3_system_bus_device *dev, loff_t from,
429 size_t len, size_t *retlen, u_char *buf)
430{
431 struct ps3vram_priv *priv = dev->core.driver_data;
432 unsigned int cached, count;
433
434 dev_dbg(&dev->core, "%s: from=0x%08x len=0x%zx\n", __func__,
435 (unsigned int)from, len);
436
437 if (from >= priv->size)
438 return -EIO;
439
440 if (len > priv->size - from)
441 len = priv->size - from;
442
443 /* Copy from vram to buf */
444 count = len;
445 while (count) {
446 unsigned int offset, avail;
447 unsigned int entry;
448
449 offset = (unsigned int) (from & (priv->cache.page_size - 1));
450 avail = priv->cache.page_size - offset;
451
452 mutex_lock(&priv->lock);
453
454 entry = ps3vram_cache_match(dev, from);
455 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset;
456
457 dev_dbg(&dev->core, "%s: from=%08x cached=%08x offset=%08x "
458 "avail=%08x count=%08x\n", __func__,
459 (unsigned int)from, cached, offset, avail, count);
460
461 if (avail > count)
462 avail = count;
463 memcpy(buf, priv->xdr_buf + cached, avail);
464
465 mutex_unlock(&priv->lock);
466
467 buf += avail;
468 count -= avail;
469 from += avail;
470 }
471
472 *retlen = len;
473 return 0;
474}
475
476static int ps3vram_write(struct ps3_system_bus_device *dev, loff_t to,
477 size_t len, size_t *retlen, const u_char *buf)
478{
479 struct ps3vram_priv *priv = dev->core.driver_data;
480 unsigned int cached, count;
481
482 if (to >= priv->size)
483 return -EIO;
484
485 if (len > priv->size - to)
486 len = priv->size - to;
487
488 /* Copy from buf to vram */
489 count = len;
490 while (count) {
491 unsigned int offset, avail;
492 unsigned int entry;
493
494 offset = (unsigned int) (to & (priv->cache.page_size - 1));
495 avail = priv->cache.page_size - offset;
496
497 mutex_lock(&priv->lock);
498
499 entry = ps3vram_cache_match(dev, to);
500 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset;
501
502 dev_dbg(&dev->core, "%s: to=%08x cached=%08x offset=%08x "
503 "avail=%08x count=%08x\n", __func__, (unsigned int)to,
504 cached, offset, avail, count);
505
506 if (avail > count)
507 avail = count;
508 memcpy(priv->xdr_buf + cached, buf, avail);
509
510 priv->cache.tags[entry].flags |= CACHE_PAGE_DIRTY;
511
512 mutex_unlock(&priv->lock);
513
514 buf += avail;
515 count -= avail;
516 to += avail;
517 }
518
519 *retlen = len;
520 return 0;
521}
522
523static int ps3vram_proc_show(struct seq_file *m, void *v)
524{
525 struct ps3vram_priv *priv = m->private;
526
527 seq_printf(m, "hit:%u\nmiss:%u\n", priv->cache.hit, priv->cache.miss);
528 return 0;
529}
530
531static int ps3vram_proc_open(struct inode *inode, struct file *file)
532{
533 return single_open(file, ps3vram_proc_show, PDE(inode)->data);
534}
535
536static const struct file_operations ps3vram_proc_fops = {
537 .owner = THIS_MODULE,
538 .open = ps3vram_proc_open,
539 .read = seq_read,
540 .llseek = seq_lseek,
541 .release = single_release,
542};
543
544static void __devinit ps3vram_proc_init(struct ps3_system_bus_device *dev)
545{
546 struct ps3vram_priv *priv = dev->core.driver_data;
547 struct proc_dir_entry *pde;
548
549 pde = proc_create(DEVICE_NAME, 0444, NULL, &ps3vram_proc_fops);
550 if (!pde) {
551 dev_warn(&dev->core, "failed to create /proc entry\n");
552 return;
553 }
554
555 pde->owner = THIS_MODULE;
556 pde->data = priv;
557}
558
559static int ps3vram_make_request(struct request_queue *q, struct bio *bio)
560{
561 struct ps3_system_bus_device *dev = q->queuedata;
562 int write = bio_data_dir(bio) == WRITE;
563 const char *op = write ? "write" : "read";
564 loff_t offset = bio->bi_sector << 9;
565 int error = 0;
566 struct bio_vec *bvec;
567 unsigned int i;
568
569 dev_dbg(&dev->core, "%s\n", __func__);
570
571 bio_for_each_segment(bvec, bio, i) {
572 /* PS3 is ppc64, so we don't handle highmem */
573 char *ptr = page_address(bvec->bv_page) + bvec->bv_offset;
574 size_t len = bvec->bv_len, retlen;
575
576 dev_dbg(&dev->core, " %s %zu bytes at offset %llu\n", op,
577 len, offset);
578 if (write)
579 error = ps3vram_write(dev, offset, len, &retlen, ptr);
580 else
581 error = ps3vram_read(dev, offset, len, &retlen, ptr);
582
583 if (error) {
584 dev_err(&dev->core, "%s failed\n", op);
585 goto out;
586 }
587
588 if (retlen != len) {
589 dev_err(&dev->core, "Short %s\n", op);
590 goto out;
591 }
592
593 offset += len;
594 }
595
596 dev_dbg(&dev->core, "%s completed\n", op);
597
598out:
599 bio_endio(bio, error);
600 return 0;
601}
602
603static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
604{
605 struct ps3vram_priv *priv;
606 int error, status;
607 struct request_queue *queue;
608 struct gendisk *gendisk;
609 u64 ddr_lpar, ctrl_lpar, info_lpar, reports_lpar, ddr_size,
610 reports_size;
611 char *rest;
612
613 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
614 if (!priv) {
615 error = -ENOMEM;
616 goto fail;
617 }
618
619 mutex_init(&priv->lock);
620 dev->core.driver_data = priv;
621
622 priv = dev->core.driver_data;
623
624 /* Allocate XDR buffer (1MiB aligned) */
625 priv->xdr_buf = (void *)__get_free_pages(GFP_KERNEL,
626 get_order(XDR_BUF_SIZE));
627 if (priv->xdr_buf == NULL) {
628 dev_err(&dev->core, "Could not allocate XDR buffer\n");
629 error = -ENOMEM;
630 goto fail_free_priv;
631 }
632
633 /* Put FIFO at begginning of XDR buffer */
634 priv->fifo_base = (u32 *) (priv->xdr_buf + FIFO_OFFSET);
635 priv->fifo_ptr = priv->fifo_base;
636
637 /* XXX: Need to open GPU, in case ps3fb or snd_ps3 aren't loaded */
638 if (ps3_open_hv_device(dev)) {
639 dev_err(&dev->core, "ps3_open_hv_device failed\n");
640 error = -EAGAIN;
641 goto out_close_gpu;
642 }
643
644 /* Request memory */
645 status = -1;
646 ddr_size = ALIGN(memparse(size, &rest), 1024*1024);
647 if (!ddr_size) {
648 dev_err(&dev->core, "Specified size is too small\n");
649 error = -EINVAL;
650 goto out_close_gpu;
651 }
652
653 while (ddr_size > 0) {
654 status = lv1_gpu_memory_allocate(ddr_size, 0, 0, 0, 0,
655 &priv->memory_handle,
656 &ddr_lpar);
657 if (!status)
658 break;
659 ddr_size -= 1024*1024;
660 }
661 if (status) {
662 dev_err(&dev->core, "lv1_gpu_memory_allocate failed %d\n",
663 status);
664 error = -ENOMEM;
665 goto out_free_xdr_buf;
666 }
667
668 /* Request context */
669 status = lv1_gpu_context_allocate(priv->memory_handle, 0,
670 &priv->context_handle, &ctrl_lpar,
671 &info_lpar, &reports_lpar,
672 &reports_size);
673 if (status) {
674 dev_err(&dev->core, "lv1_gpu_context_allocate failed %d\n",
675 status);
676 error = -ENOMEM;
677 goto out_free_memory;
678 }
679
680 /* Map XDR buffer to RSX */
681 status = lv1_gpu_context_iomap(priv->context_handle, XDR_IOIF,
682 ps3_mm_phys_to_lpar(__pa(priv->xdr_buf)),
683 XDR_BUF_SIZE, 0);
684 if (status) {
685 dev_err(&dev->core, "lv1_gpu_context_iomap failed %d\n",
686 status);
687 error = -ENOMEM;
688 goto out_free_context;
689 }
690
691 priv->ddr_base = ioremap_flags(ddr_lpar, ddr_size, _PAGE_NO_CACHE);
692
693 if (!priv->ddr_base) {
694 dev_err(&dev->core, "ioremap DDR failed\n");
695 error = -ENOMEM;
696 goto out_free_context;
697 }
698
699 priv->ctrl = ioremap(ctrl_lpar, 64 * 1024);
700 if (!priv->ctrl) {
701 dev_err(&dev->core, "ioremap CTRL failed\n");
702 error = -ENOMEM;
703 goto out_unmap_vram;
704 }
705
706 priv->reports = ioremap(reports_lpar, reports_size);
707 if (!priv->reports) {
708 dev_err(&dev->core, "ioremap REPORTS failed\n");
709 error = -ENOMEM;
710 goto out_unmap_ctrl;
711 }
712
713 mutex_lock(&ps3_gpu_mutex);
714 ps3vram_init_ring(dev);
715 mutex_unlock(&ps3_gpu_mutex);
716
717 priv->size = ddr_size;
718
719 ps3vram_bind(dev);
720
721 mutex_lock(&ps3_gpu_mutex);
722 error = ps3vram_wait_ring(dev, 100);
723 mutex_unlock(&ps3_gpu_mutex);
724 if (error < 0) {
725 dev_err(&dev->core, "Failed to initialize channels\n");
726 error = -ETIMEDOUT;
727 goto out_unmap_reports;
728 }
729
730 ps3vram_cache_init(dev);
731 ps3vram_proc_init(dev);
732
733 queue = blk_alloc_queue(GFP_KERNEL);
734 if (!queue) {
735 dev_err(&dev->core, "blk_alloc_queue failed\n");
736 error = -ENOMEM;
737 goto out_cache_cleanup;
738 }
739
740 priv->queue = queue;
741 queue->queuedata = dev;
742 blk_queue_make_request(queue, ps3vram_make_request);
743 blk_queue_max_phys_segments(queue, MAX_PHYS_SEGMENTS);
744 blk_queue_max_hw_segments(queue, MAX_HW_SEGMENTS);
745 blk_queue_max_segment_size(queue, MAX_SEGMENT_SIZE);
746 blk_queue_max_sectors(queue, SAFE_MAX_SECTORS);
747
748 gendisk = alloc_disk(1);
749 if (!gendisk) {
750 dev_err(&dev->core, "alloc_disk failed\n");
751 error = -ENOMEM;
752 goto fail_cleanup_queue;
753 }
754
755 priv->gendisk = gendisk;
756 gendisk->major = ps3vram_major;
757 gendisk->first_minor = 0;
758 gendisk->fops = &ps3vram_fops;
759 gendisk->queue = queue;
760 gendisk->private_data = dev;
761 gendisk->driverfs_dev = &dev->core;
762 strlcpy(gendisk->disk_name, DEVICE_NAME, sizeof(gendisk->disk_name));
763 set_capacity(gendisk, priv->size >> 9);
764
765 dev_info(&dev->core, "%s: Using %lu MiB of GPU memory\n",
766 gendisk->disk_name, get_capacity(gendisk) >> 11);
767
768 add_disk(gendisk);
769 return 0;
770
771fail_cleanup_queue:
772 blk_cleanup_queue(queue);
773out_cache_cleanup:
774 remove_proc_entry(DEVICE_NAME, NULL);
775 ps3vram_cache_cleanup(dev);
776out_unmap_reports:
777 iounmap(priv->reports);
778out_unmap_ctrl:
779 iounmap(priv->ctrl);
780out_unmap_vram:
781 iounmap(priv->ddr_base);
782out_free_context:
783 lv1_gpu_context_free(priv->context_handle);
784out_free_memory:
785 lv1_gpu_memory_free(priv->memory_handle);
786out_close_gpu:
787 ps3_close_hv_device(dev);
788out_free_xdr_buf:
789 free_pages((unsigned long) priv->xdr_buf, get_order(XDR_BUF_SIZE));
790fail_free_priv:
791 kfree(priv);
792 dev->core.driver_data = NULL;
793fail:
794 return error;
795}
796
797static int ps3vram_remove(struct ps3_system_bus_device *dev)
798{
799 struct ps3vram_priv *priv = dev->core.driver_data;
800
801 del_gendisk(priv->gendisk);
802 put_disk(priv->gendisk);
803 blk_cleanup_queue(priv->queue);
804 remove_proc_entry(DEVICE_NAME, NULL);
805 ps3vram_cache_cleanup(dev);
806 iounmap(priv->reports);
807 iounmap(priv->ctrl);
808 iounmap(priv->ddr_base);
809 lv1_gpu_context_free(priv->context_handle);
810 lv1_gpu_memory_free(priv->memory_handle);
811 ps3_close_hv_device(dev);
812 free_pages((unsigned long) priv->xdr_buf, get_order(XDR_BUF_SIZE));
813 kfree(priv);
814 dev->core.driver_data = NULL;
815 return 0;
816}
817
818static struct ps3_system_bus_driver ps3vram = {
819 .match_id = PS3_MATCH_ID_GPU,
820 .match_sub_id = PS3_MATCH_SUB_ID_GPU_RAMDISK,
821 .core.name = DEVICE_NAME,
822 .core.owner = THIS_MODULE,
823 .probe = ps3vram_probe,
824 .remove = ps3vram_remove,
825 .shutdown = ps3vram_remove,
826};
827
828
829static int __init ps3vram_init(void)
830{
831 int error;
832
833 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
834 return -ENODEV;
835
836 error = register_blkdev(0, DEVICE_NAME);
837 if (error <= 0) {
838 pr_err("%s: register_blkdev failed %d\n", DEVICE_NAME, error);
839 return error;
840 }
841 ps3vram_major = error;
842
843 pr_info("%s: registered block device major %d\n", DEVICE_NAME,
844 ps3vram_major);
845
846 error = ps3_system_bus_driver_register(&ps3vram);
847 if (error)
848 unregister_blkdev(ps3vram_major, DEVICE_NAME);
849
850 return error;
851}
852
853static void __exit ps3vram_exit(void)
854{
855 ps3_system_bus_driver_unregister(&ps3vram);
856 unregister_blkdev(ps3vram_major, DEVICE_NAME);
857}
858
859module_init(ps3vram_init);
860module_exit(ps3vram_exit);
861
862MODULE_LICENSE("GPL");
863MODULE_DESCRIPTION("PS3 Video RAM Storage Driver");
864MODULE_AUTHOR("Sony Corporation");
865MODULE_ALIAS(PS3_MODULE_ALIAS_GPU_RAMDISK);
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 12fb816db7b0..69b7f8e77596 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -391,7 +391,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum);
391 */ 391 */
392#ifdef CONFIG_USB_LIBUSUAL 392#ifdef CONFIG_USB_LIBUSUAL
393 393
394#define ub_usb_ids storage_usb_ids 394#define ub_usb_ids usb_storage_usb_ids
395#else 395#else
396 396
397static struct usb_device_id ub_usb_ids[] = { 397static struct usb_device_id ub_usb_ids[] = {
@@ -2146,10 +2146,9 @@ static int ub_get_pipes(struct ub_dev *sc, struct usb_device *dev,
2146 ep = &altsetting->endpoint[i].desc; 2146 ep = &altsetting->endpoint[i].desc;
2147 2147
2148 /* Is it a BULK endpoint? */ 2148 /* Is it a BULK endpoint? */
2149 if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 2149 if (usb_endpoint_xfer_bulk(ep)) {
2150 == USB_ENDPOINT_XFER_BULK) {
2151 /* BULK in or out? */ 2150 /* BULK in or out? */
2152 if (ep->bEndpointAddress & USB_DIR_IN) { 2151 if (usb_endpoint_dir_in(ep)) {
2153 if (ep_in == NULL) 2152 if (ep_in == NULL)
2154 ep_in = ep; 2153 ep_in = ep;
2155 } else { 2154 } else {
@@ -2168,9 +2167,9 @@ static int ub_get_pipes(struct ub_dev *sc, struct usb_device *dev,
2168 sc->send_ctrl_pipe = usb_sndctrlpipe(dev, 0); 2167 sc->send_ctrl_pipe = usb_sndctrlpipe(dev, 0);
2169 sc->recv_ctrl_pipe = usb_rcvctrlpipe(dev, 0); 2168 sc->recv_ctrl_pipe = usb_rcvctrlpipe(dev, 0);
2170 sc->send_bulk_pipe = usb_sndbulkpipe(dev, 2169 sc->send_bulk_pipe = usb_sndbulkpipe(dev,
2171 ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 2170 usb_endpoint_num(ep_out));
2172 sc->recv_bulk_pipe = usb_rcvbulkpipe(dev, 2171 sc->recv_bulk_pipe = usb_rcvbulkpipe(dev,
2173 ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 2172 usb_endpoint_num(ep_in));
2174 2173
2175 return 0; 2174 return 0;
2176} 2175}
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index b6c8ce254359..8f905089b72b 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -977,6 +977,8 @@ static void backend_changed(struct xenbus_device *dev,
977 break; 977 break;
978 978
979 case XenbusStateClosing: 979 case XenbusStateClosing:
980 if (info->gd == NULL)
981 xenbus_dev_fatal(dev, -ENODEV, "gd is NULL");
980 bd = bdget_disk(info->gd, 0); 982 bd = bdget_disk(info->gd, 0);
981 if (bd == NULL) 983 if (bd == NULL)
982 xenbus_dev_fatal(dev, -ENODEV, "bdget failed"); 984 xenbus_dev_fatal(dev, -ENODEV, "bdget failed");
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 381d686fc1a3..119be3442f28 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -489,6 +489,28 @@ static void ace_fsm_dostate(struct ace_device *ace)
489 ace->fsm_state, ace->id_req_count); 489 ace->fsm_state, ace->id_req_count);
490#endif 490#endif
491 491
492 /* Verify that there is actually a CF in the slot. If not, then
493 * bail out back to the idle state and wake up all the waiters */
494 status = ace_in32(ace, ACE_STATUS);
495 if ((status & ACE_STATUS_CFDETECT) == 0) {
496 ace->fsm_state = ACE_FSM_STATE_IDLE;
497 ace->media_change = 1;
498 set_capacity(ace->gd, 0);
499 dev_info(ace->dev, "No CF in slot\n");
500
501 /* Drop all pending requests */
502 while ((req = elv_next_request(ace->queue)) != NULL)
503 end_request(req, 0);
504
505 /* Drop back to IDLE state and notify waiters */
506 ace->fsm_state = ACE_FSM_STATE_IDLE;
507 ace->id_result = -EIO;
508 while (ace->id_req_count) {
509 complete(&ace->id_completion);
510 ace->id_req_count--;
511 }
512 }
513
492 switch (ace->fsm_state) { 514 switch (ace->fsm_state) {
493 case ACE_FSM_STATE_IDLE: 515 case ACE_FSM_STATE_IDLE:
494 /* See if there is anything to do */ 516 /* See if there is anything to do */
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 52f4361eb6e4..d765afda9c2a 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -271,15 +271,15 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp,
271 nb_order = (nb_order >> 1) & 7; 271 nb_order = (nb_order >> 1) & 7;
272 pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base); 272 pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base);
273 nb_aper = nb_base << 25; 273 nb_aper = nb_base << 25;
274 if (agp_aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) {
275 return 0;
276 }
277 274
278 /* Northbridge seems to contain crap. Try the AGP bridge. */ 275 /* Northbridge seems to contain crap. Try the AGP bridge. */
279 276
280 pci_read_config_word(agp, cap+0x14, &apsize); 277 pci_read_config_word(agp, cap+0x14, &apsize);
281 if (apsize == 0xffff) 278 if (apsize == 0xffff) {
279 if (agp_aperture_valid(nb_aper, (32*1024*1024)<<nb_order))
280 return 0;
282 return -1; 281 return -1;
282 }
283 283
284 apsize &= 0xfff; 284 apsize &= 0xfff;
285 /* Some BIOS use weird encodings not in the AGPv3 table. */ 285 /* Some BIOS use weird encodings not in the AGPv3 table. */
@@ -301,6 +301,11 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp,
301 order = nb_order; 301 order = nb_order;
302 } 302 }
303 303
304 if (nb_order >= order) {
305 if (agp_aperture_valid(nb_aper, (32*1024*1024)<<nb_order))
306 return 0;
307 }
308
304 dev_info(&agp->dev, "aperture from AGP @ %Lx size %u MB\n", 309 dev_info(&agp->dev, "aperture from AGP @ %Lx size %u MB\n",
305 aper, 32 << order); 310 aper, 32 << order);
306 if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order)) 311 if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order))
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index c7714185f831..4373adb2119a 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -633,13 +633,15 @@ static void intel_i830_init_gtt_entries(void)
633 break; 633 break;
634 } 634 }
635 } 635 }
636 if (gtt_entries > 0) 636 if (gtt_entries > 0) {
637 dev_info(&agp_bridge->dev->dev, "detected %dK %s memory\n", 637 dev_info(&agp_bridge->dev->dev, "detected %dK %s memory\n",
638 gtt_entries / KB(1), local ? "local" : "stolen"); 638 gtt_entries / KB(1), local ? "local" : "stolen");
639 else 639 gtt_entries /= KB(4);
640 } else {
640 dev_info(&agp_bridge->dev->dev, 641 dev_info(&agp_bridge->dev->dev,
641 "no pre-allocated video memory detected\n"); 642 "no pre-allocated video memory detected\n");
642 gtt_entries /= KB(4); 643 gtt_entries = 0;
644 }
643 645
644 intel_private.gtt_entries = gtt_entries; 646 intel_private.gtt_entries = gtt_entries;
645} 647}
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index db60539bf67a..699e3422ad93 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -359,9 +359,16 @@ fail:
359 return error; 359 return error;
360} 360}
361 361
362static struct device *next_device(struct klist_iter *i) { 362static int
363 struct klist_node * n = klist_next(i); 363find_quicksilver(struct device *dev, void *data)
364 return n ? container_of(n, struct device, knode_parent) : NULL; 364{
365 struct parisc_device **lba = data;
366 struct parisc_device *padev = to_parisc_device(dev);
367
368 if (IS_QUICKSILVER(padev))
369 *lba = padev;
370
371 return 0;
365} 372}
366 373
367static int 374static int
@@ -372,8 +379,6 @@ parisc_agp_init(void)
372 int err = -1; 379 int err = -1;
373 struct parisc_device *sba = NULL, *lba = NULL; 380 struct parisc_device *sba = NULL, *lba = NULL;
374 struct lba_device *lbadev = NULL; 381 struct lba_device *lbadev = NULL;
375 struct device *dev = NULL;
376 struct klist_iter i;
377 382
378 if (!sba_list) 383 if (!sba_list)
379 goto out; 384 goto out;
@@ -386,13 +391,7 @@ parisc_agp_init(void)
386 } 391 }
387 392
388 /* Now search our Pluto for our precious AGP device... */ 393 /* Now search our Pluto for our precious AGP device... */
389 klist_iter_init(&sba->dev.klist_children, &i); 394 device_for_each_child(&sba->dev, &lba, find_quicksilver);
390 while ((dev = next_device(&i))) {
391 struct parisc_device *padev = to_parisc_device(dev);
392 if (IS_QUICKSILVER(padev))
393 lba = padev;
394 }
395 klist_iter_exit(&i);
396 395
397 if (!lba) { 396 if (!lba) {
398 printk(KERN_INFO DRVPFX "No AGP devices found.\n"); 397 printk(KERN_INFO DRVPFX "No AGP devices found.\n");
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 6e6eb445d374..c76bccf5354d 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -1139,15 +1139,6 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
1139 hvcsd->tty = tty; 1139 hvcsd->tty = tty;
1140 tty->driver_data = hvcsd; 1140 tty->driver_data = hvcsd;
1141 1141
1142 /*
1143 * Set this driver to low latency so that we actually have a chance at
1144 * catching a throttled TTY after we flip_buffer_push. Otherwise the
1145 * flush_to_async may not execute until after the kernel_thread has
1146 * yielded and resumed the next flip_buffer_push resulting in data
1147 * loss.
1148 */
1149 tty->low_latency = 1;
1150
1151 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN); 1142 memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN);
1152 1143
1153 /* 1144 /*
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 406f8742a260..2989056a9e39 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -810,7 +810,6 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp)
810 hp = &hvsi_ports[line]; 810 hp = &hvsi_ports[line];
811 811
812 tty->driver_data = hp; 812 tty->driver_data = hp;
813 tty->low_latency = 1; /* avoid throttle/tty_flip_buffer_push race */
814 813
815 mb(); 814 mb();
816 if (hp->state == HVSI_FSP_DIED) 815 if (hp->state == HVSI_FSP_DIED)
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 8822eca58ffa..5fab6470f4b2 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -20,6 +20,20 @@ config HW_RANDOM
20 20
21 If unsure, say Y. 21 If unsure, say Y.
22 22
23config HW_RANDOM_TIMERIOMEM
24 tristate "Timer IOMEM HW Random Number Generator support"
25 depends on HW_RANDOM && HAS_IOMEM
26 ---help---
27 This driver provides kernel-side support for a generic Random
28 Number Generator used by reading a 'dumb' iomem address that
29 is to be read no faster than, for example, once a second;
30 the default FPGA bitstream on the TS-7800 has such functionality.
31
32 To compile this driver as a module, choose M here: the
33 module will be called timeriomem-rng.
34
35 If unsure, say Y.
36
23config HW_RANDOM_INTEL 37config HW_RANDOM_INTEL
24 tristate "Intel HW Random Number Generator support" 38 tristate "Intel HW Random Number Generator support"
25 depends on HW_RANDOM && (X86 || IA64) && PCI 39 depends on HW_RANDOM && (X86 || IA64) && PCI
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index b6effb7522c2..e81d21a5f28f 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -4,6 +4,7 @@
4 4
5obj-$(CONFIG_HW_RANDOM) += rng-core.o 5obj-$(CONFIG_HW_RANDOM) += rng-core.o
6rng-core-y := core.o 6rng-core-y := core.o
7obj-$(CONFIG_HW_RANDOM_TIMERIOMEM) += timeriomem-rng.o
7obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o 8obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o
8obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o 9obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o
9obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o 10obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o
diff --git a/drivers/char/hw_random/timeriomem-rng.c b/drivers/char/hw_random/timeriomem-rng.c
new file mode 100644
index 000000000000..10ad41be5897
--- /dev/null
+++ b/drivers/char/hw_random/timeriomem-rng.c
@@ -0,0 +1,151 @@
1/*
2 * drivers/char/hw_random/timeriomem-rng.c
3 *
4 * Copyright (C) 2009 Alexander Clouter <alex@digriz.org.uk>
5 *
6 * Derived from drivers/char/hw_random/omap-rng.c
7 * Copyright 2005 (c) MontaVista Software, Inc.
8 * Author: Deepak Saxena <dsaxena@plexity.net>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * Overview:
15 * This driver is useful for platforms that have an IO range that provides
16 * periodic random data from a single IO memory address. All the platform
17 * has to do is provide the address and 'wait time' that new data becomes
18 * available.
19 *
20 * TODO: add support for reading sizes other than 32bits and masking
21 */
22
23#include <linux/module.h>
24#include <linux/kernel.h>
25#include <linux/platform_device.h>
26#include <linux/hw_random.h>
27#include <linux/io.h>
28#include <linux/timeriomem-rng.h>
29#include <linux/jiffies.h>
30#include <linux/sched.h>
31#include <linux/timer.h>
32#include <linux/completion.h>
33
34static struct timeriomem_rng_data *timeriomem_rng_data;
35
36static void timeriomem_rng_trigger(unsigned long);
37static DEFINE_TIMER(timeriomem_rng_timer, timeriomem_rng_trigger, 0, 0);
38
39/*
40 * have data return 1, however return 0 if we have nothing
41 */
42static int timeriomem_rng_data_present(struct hwrng *rng, int wait)
43{
44 if (rng->priv == 0)
45 return 1;
46
47 if (!wait || timeriomem_rng_data->present)
48 return timeriomem_rng_data->present;
49
50 wait_for_completion(&timeriomem_rng_data->completion);
51
52 return 1;
53}
54
55static int timeriomem_rng_data_read(struct hwrng *rng, u32 *data)
56{
57 unsigned long cur;
58 s32 delay;
59
60 *data = readl(timeriomem_rng_data->address);
61
62 if (rng->priv != 0) {
63 cur = jiffies;
64
65 delay = cur - timeriomem_rng_timer.expires;
66 delay = rng->priv - (delay % rng->priv);
67
68 timeriomem_rng_timer.expires = cur + delay;
69 timeriomem_rng_data->present = 0;
70
71 init_completion(&timeriomem_rng_data->completion);
72 add_timer(&timeriomem_rng_timer);
73 }
74
75 return 4;
76}
77
78static void timeriomem_rng_trigger(unsigned long dummy)
79{
80 timeriomem_rng_data->present = 1;
81 complete(&timeriomem_rng_data->completion);
82}
83
84static struct hwrng timeriomem_rng_ops = {
85 .name = "timeriomem",
86 .data_present = timeriomem_rng_data_present,
87 .data_read = timeriomem_rng_data_read,
88 .priv = 0,
89};
90
91static int __init timeriomem_rng_probe(struct platform_device *pdev)
92{
93 int ret;
94
95 timeriomem_rng_data = pdev->dev.platform_data;
96
97 if (timeriomem_rng_data->period != 0
98 && usecs_to_jiffies(timeriomem_rng_data->period) > 0) {
99 timeriomem_rng_timer.expires = jiffies;
100
101 timeriomem_rng_ops.priv = usecs_to_jiffies(
102 timeriomem_rng_data->period);
103 }
104 timeriomem_rng_data->present = 1;
105
106 ret = hwrng_register(&timeriomem_rng_ops);
107 if (ret) {
108 dev_err(&pdev->dev, "problem registering\n");
109 return ret;
110 }
111
112 dev_info(&pdev->dev, "32bits from 0x%p @ %dus\n",
113 timeriomem_rng_data->address,
114 timeriomem_rng_data->period);
115
116 return 0;
117}
118
119static int __devexit timeriomem_rng_remove(struct platform_device *pdev)
120{
121 del_timer_sync(&timeriomem_rng_timer);
122 hwrng_unregister(&timeriomem_rng_ops);
123
124 return 0;
125}
126
127static struct platform_driver timeriomem_rng_driver = {
128 .driver = {
129 .name = "timeriomem_rng",
130 .owner = THIS_MODULE,
131 },
132 .probe = timeriomem_rng_probe,
133 .remove = __devexit_p(timeriomem_rng_remove),
134};
135
136static int __init timeriomem_rng_init(void)
137{
138 return platform_driver_register(&timeriomem_rng_driver);
139}
140
141static void __exit timeriomem_rng_exit(void)
142{
143 platform_driver_unregister(&timeriomem_rng_driver);
144}
145
146module_init(timeriomem_rng_init);
147module_exit(timeriomem_rng_exit);
148
149MODULE_LICENSE("GPL");
150MODULE_AUTHOR("Alexander Clouter <alex@digriz.org.uk>");
151MODULE_DESCRIPTION("Timer IOMEM H/W RNG driver");
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 9c47dc48c9fd..ccdd828adcef 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -429,134 +429,148 @@ out:
429#define TPM_DIGEST_SIZE 20 429#define TPM_DIGEST_SIZE 20
430#define TPM_ERROR_SIZE 10 430#define TPM_ERROR_SIZE 10
431#define TPM_RET_CODE_IDX 6 431#define TPM_RET_CODE_IDX 6
432#define TPM_GET_CAP_RET_SIZE_IDX 10
433#define TPM_GET_CAP_RET_UINT32_1_IDX 14
434#define TPM_GET_CAP_RET_UINT32_2_IDX 18
435#define TPM_GET_CAP_RET_UINT32_3_IDX 22
436#define TPM_GET_CAP_RET_UINT32_4_IDX 26
437#define TPM_GET_CAP_PERM_DISABLE_IDX 16
438#define TPM_GET_CAP_PERM_INACTIVE_IDX 18
439#define TPM_GET_CAP_RET_BOOL_1_IDX 14
440#define TPM_GET_CAP_TEMP_INACTIVE_IDX 16
441
442#define TPM_CAP_IDX 13
443#define TPM_CAP_SUBCAP_IDX 21
444 432
445enum tpm_capabilities { 433enum tpm_capabilities {
446 TPM_CAP_FLAG = 4, 434 TPM_CAP_FLAG = cpu_to_be32(4),
447 TPM_CAP_PROP = 5, 435 TPM_CAP_PROP = cpu_to_be32(5),
436 CAP_VERSION_1_1 = cpu_to_be32(0x06),
437 CAP_VERSION_1_2 = cpu_to_be32(0x1A)
448}; 438};
449 439
450enum tpm_sub_capabilities { 440enum tpm_sub_capabilities {
451 TPM_CAP_PROP_PCR = 0x1, 441 TPM_CAP_PROP_PCR = cpu_to_be32(0x101),
452 TPM_CAP_PROP_MANUFACTURER = 0x3, 442 TPM_CAP_PROP_MANUFACTURER = cpu_to_be32(0x103),
453 TPM_CAP_FLAG_PERM = 0x8, 443 TPM_CAP_FLAG_PERM = cpu_to_be32(0x108),
454 TPM_CAP_FLAG_VOL = 0x9, 444 TPM_CAP_FLAG_VOL = cpu_to_be32(0x109),
455 TPM_CAP_PROP_OWNER = 0x11, 445 TPM_CAP_PROP_OWNER = cpu_to_be32(0x111),
456 TPM_CAP_PROP_TIS_TIMEOUT = 0x15, 446 TPM_CAP_PROP_TIS_TIMEOUT = cpu_to_be32(0x115),
457 TPM_CAP_PROP_TIS_DURATION = 0x20, 447 TPM_CAP_PROP_TIS_DURATION = cpu_to_be32(0x120),
458};
459 448
460/*
461 * This is a semi generic GetCapability command for use
462 * with the capability type TPM_CAP_PROP or TPM_CAP_FLAG
463 * and their associated sub_capabilities.
464 */
465
466static const u8 tpm_cap[] = {
467 0, 193, /* TPM_TAG_RQU_COMMAND */
468 0, 0, 0, 22, /* length */
469 0, 0, 0, 101, /* TPM_ORD_GetCapability */
470 0, 0, 0, 0, /* TPM_CAP_<TYPE> */
471 0, 0, 0, 4, /* TPM_CAP_SUB_<TYPE> size */
472 0, 0, 1, 0 /* TPM_CAP_SUB_<TYPE> */
473}; 449};
474 450
475static ssize_t transmit_cmd(struct tpm_chip *chip, u8 *data, int len, 451static ssize_t transmit_cmd(struct tpm_chip *chip, struct tpm_cmd_t *cmd,
476 char *desc) 452 int len, const char *desc)
477{ 453{
478 int err; 454 int err;
479 455
480 len = tpm_transmit(chip, data, len); 456 len = tpm_transmit(chip,(u8 *) cmd, len);
481 if (len < 0) 457 if (len < 0)
482 return len; 458 return len;
483 if (len == TPM_ERROR_SIZE) { 459 if (len == TPM_ERROR_SIZE) {
484 err = be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX))); 460 err = be32_to_cpu(cmd->header.out.return_code);
485 dev_dbg(chip->dev, "A TPM error (%d) occurred %s\n", err, desc); 461 dev_dbg(chip->dev, "A TPM error (%d) occurred %s\n", err, desc);
486 return err; 462 return err;
487 } 463 }
488 return 0; 464 return 0;
489} 465}
490 466
467#define TPM_INTERNAL_RESULT_SIZE 200
468#define TPM_TAG_RQU_COMMAND cpu_to_be16(193)
469#define TPM_ORD_GET_CAP cpu_to_be32(101)
470
471static const struct tpm_input_header tpm_getcap_header = {
472 .tag = TPM_TAG_RQU_COMMAND,
473 .length = cpu_to_be32(22),
474 .ordinal = TPM_ORD_GET_CAP
475};
476
477ssize_t tpm_getcap(struct device *dev, __be32 subcap_id, cap_t *cap,
478 const char *desc)
479{
480 struct tpm_cmd_t tpm_cmd;
481 int rc;
482 struct tpm_chip *chip = dev_get_drvdata(dev);
483
484 tpm_cmd.header.in = tpm_getcap_header;
485 if (subcap_id == CAP_VERSION_1_1 || subcap_id == CAP_VERSION_1_2) {
486 tpm_cmd.params.getcap_in.cap = subcap_id;
487 /*subcap field not necessary */
488 tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(0);
489 tpm_cmd.header.in.length -= cpu_to_be32(sizeof(__be32));
490 } else {
491 if (subcap_id == TPM_CAP_FLAG_PERM ||
492 subcap_id == TPM_CAP_FLAG_VOL)
493 tpm_cmd.params.getcap_in.cap = TPM_CAP_FLAG;
494 else
495 tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
496 tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
497 tpm_cmd.params.getcap_in.subcap = subcap_id;
498 }
499 rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, desc);
500 if (!rc)
501 *cap = tpm_cmd.params.getcap_out.cap;
502 return rc;
503}
504
491void tpm_gen_interrupt(struct tpm_chip *chip) 505void tpm_gen_interrupt(struct tpm_chip *chip)
492{ 506{
493 u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 30)]; 507 struct tpm_cmd_t tpm_cmd;
494 ssize_t rc; 508 ssize_t rc;
495 509
496 memcpy(data, tpm_cap, sizeof(tpm_cap)); 510 tpm_cmd.header.in = tpm_getcap_header;
497 data[TPM_CAP_IDX] = TPM_CAP_PROP; 511 tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
498 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_TIS_TIMEOUT; 512 tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
513 tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
499 514
500 rc = transmit_cmd(chip, data, sizeof(data), 515 rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
501 "attempting to determine the timeouts"); 516 "attempting to determine the timeouts");
502} 517}
503EXPORT_SYMBOL_GPL(tpm_gen_interrupt); 518EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
504 519
505void tpm_get_timeouts(struct tpm_chip *chip) 520void tpm_get_timeouts(struct tpm_chip *chip)
506{ 521{
507 u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 30)]; 522 struct tpm_cmd_t tpm_cmd;
523 struct timeout_t *timeout_cap;
524 struct duration_t *duration_cap;
508 ssize_t rc; 525 ssize_t rc;
509 u32 timeout; 526 u32 timeout;
510 527
511 memcpy(data, tpm_cap, sizeof(tpm_cap)); 528 tpm_cmd.header.in = tpm_getcap_header;
512 data[TPM_CAP_IDX] = TPM_CAP_PROP; 529 tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
513 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_TIS_TIMEOUT; 530 tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
531 tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
514 532
515 rc = transmit_cmd(chip, data, sizeof(data), 533 rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
516 "attempting to determine the timeouts"); 534 "attempting to determine the timeouts");
517 if (rc) 535 if (rc)
518 goto duration; 536 goto duration;
519 537
520 if (be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_SIZE_IDX))) 538 if (be32_to_cpu(tpm_cmd.header.out.length)
521 != 4 * sizeof(u32)) 539 != 4 * sizeof(u32))
522 goto duration; 540 goto duration;
523 541
542 timeout_cap = &tpm_cmd.params.getcap_out.cap.timeout;
524 /* Don't overwrite default if value is 0 */ 543 /* Don't overwrite default if value is 0 */
525 timeout = 544 timeout = be32_to_cpu(timeout_cap->a);
526 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)));
527 if (timeout) 545 if (timeout)
528 chip->vendor.timeout_a = usecs_to_jiffies(timeout); 546 chip->vendor.timeout_a = usecs_to_jiffies(timeout);
529 timeout = 547 timeout = be32_to_cpu(timeout_cap->b);
530 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX)));
531 if (timeout) 548 if (timeout)
532 chip->vendor.timeout_b = usecs_to_jiffies(timeout); 549 chip->vendor.timeout_b = usecs_to_jiffies(timeout);
533 timeout = 550 timeout = be32_to_cpu(timeout_cap->c);
534 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX)));
535 if (timeout) 551 if (timeout)
536 chip->vendor.timeout_c = usecs_to_jiffies(timeout); 552 chip->vendor.timeout_c = usecs_to_jiffies(timeout);
537 timeout = 553 timeout = be32_to_cpu(timeout_cap->d);
538 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX)));
539 if (timeout) 554 if (timeout)
540 chip->vendor.timeout_d = usecs_to_jiffies(timeout); 555 chip->vendor.timeout_d = usecs_to_jiffies(timeout);
541 556
542duration: 557duration:
543 memcpy(data, tpm_cap, sizeof(tpm_cap)); 558 tpm_cmd.header.in = tpm_getcap_header;
544 data[TPM_CAP_IDX] = TPM_CAP_PROP; 559 tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
545 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_TIS_DURATION; 560 tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
561 tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_DURATION;
546 562
547 rc = transmit_cmd(chip, data, sizeof(data), 563 rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
548 "attempting to determine the durations"); 564 "attempting to determine the durations");
549 if (rc) 565 if (rc)
550 return; 566 return;
551 567
552 if (be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_SIZE_IDX))) 568 if (be32_to_cpu(tpm_cmd.header.out.return_code)
553 != 3 * sizeof(u32)) 569 != 3 * sizeof(u32))
554 return; 570 return;
555 571 duration_cap = &tpm_cmd.params.getcap_out.cap.duration;
556 chip->vendor.duration[TPM_SHORT] = 572 chip->vendor.duration[TPM_SHORT] =
557 usecs_to_jiffies(be32_to_cpu 573 usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_short));
558 (*((__be32 *) (data +
559 TPM_GET_CAP_RET_UINT32_1_IDX))));
560 /* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above 574 /* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above
561 * value wrong and apparently reports msecs rather than usecs. So we 575 * value wrong and apparently reports msecs rather than usecs. So we
562 * fix up the resulting too-small TPM_SHORT value to make things work. 576 * fix up the resulting too-small TPM_SHORT value to make things work.
@@ -565,13 +579,9 @@ duration:
565 chip->vendor.duration[TPM_SHORT] = HZ; 579 chip->vendor.duration[TPM_SHORT] = HZ;
566 580
567 chip->vendor.duration[TPM_MEDIUM] = 581 chip->vendor.duration[TPM_MEDIUM] =
568 usecs_to_jiffies(be32_to_cpu 582 usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_medium));
569 (*((__be32 *) (data +
570 TPM_GET_CAP_RET_UINT32_2_IDX))));
571 chip->vendor.duration[TPM_LONG] = 583 chip->vendor.duration[TPM_LONG] =
572 usecs_to_jiffies(be32_to_cpu 584 usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_long));
573 (*((__be32 *) (data +
574 TPM_GET_CAP_RET_UINT32_3_IDX))));
575} 585}
576EXPORT_SYMBOL_GPL(tpm_get_timeouts); 586EXPORT_SYMBOL_GPL(tpm_get_timeouts);
577 587
@@ -587,36 +597,18 @@ void tpm_continue_selftest(struct tpm_chip *chip)
587} 597}
588EXPORT_SYMBOL_GPL(tpm_continue_selftest); 598EXPORT_SYMBOL_GPL(tpm_continue_selftest);
589 599
590#define TPM_INTERNAL_RESULT_SIZE 200
591
592ssize_t tpm_show_enabled(struct device * dev, struct device_attribute * attr, 600ssize_t tpm_show_enabled(struct device * dev, struct device_attribute * attr,
593 char *buf) 601 char *buf)
594{ 602{
595 u8 *data; 603 cap_t cap;
596 ssize_t rc; 604 ssize_t rc;
597 605
598 struct tpm_chip *chip = dev_get_drvdata(dev); 606 rc = tpm_getcap(dev, TPM_CAP_FLAG_PERM, &cap,
599 if (chip == NULL) 607 "attempting to determine the permanent enabled state");
600 return -ENODEV; 608 if (rc)
601
602 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
603 if (!data)
604 return -ENOMEM;
605
606 memcpy(data, tpm_cap, sizeof(tpm_cap));
607 data[TPM_CAP_IDX] = TPM_CAP_FLAG;
608 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM;
609
610 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
611 "attemtping to determine the permanent enabled state");
612 if (rc) {
613 kfree(data);
614 return 0; 609 return 0;
615 }
616
617 rc = sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_DISABLE_IDX]);
618 610
619 kfree(data); 611 rc = sprintf(buf, "%d\n", !cap.perm_flags.disable);
620 return rc; 612 return rc;
621} 613}
622EXPORT_SYMBOL_GPL(tpm_show_enabled); 614EXPORT_SYMBOL_GPL(tpm_show_enabled);
@@ -624,31 +616,15 @@ EXPORT_SYMBOL_GPL(tpm_show_enabled);
624ssize_t tpm_show_active(struct device * dev, struct device_attribute * attr, 616ssize_t tpm_show_active(struct device * dev, struct device_attribute * attr,
625 char *buf) 617 char *buf)
626{ 618{
627 u8 *data; 619 cap_t cap;
628 ssize_t rc; 620 ssize_t rc;
629 621
630 struct tpm_chip *chip = dev_get_drvdata(dev); 622 rc = tpm_getcap(dev, TPM_CAP_FLAG_PERM, &cap,
631 if (chip == NULL) 623 "attempting to determine the permanent active state");
632 return -ENODEV; 624 if (rc)
633
634 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
635 if (!data)
636 return -ENOMEM;
637
638 memcpy(data, tpm_cap, sizeof(tpm_cap));
639 data[TPM_CAP_IDX] = TPM_CAP_FLAG;
640 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM;
641
642 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
643 "attemtping to determine the permanent active state");
644 if (rc) {
645 kfree(data);
646 return 0; 625 return 0;
647 }
648 626
649 rc = sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_INACTIVE_IDX]); 627 rc = sprintf(buf, "%d\n", !cap.perm_flags.deactivated);
650
651 kfree(data);
652 return rc; 628 return rc;
653} 629}
654EXPORT_SYMBOL_GPL(tpm_show_active); 630EXPORT_SYMBOL_GPL(tpm_show_active);
@@ -656,31 +632,15 @@ EXPORT_SYMBOL_GPL(tpm_show_active);
656ssize_t tpm_show_owned(struct device * dev, struct device_attribute * attr, 632ssize_t tpm_show_owned(struct device * dev, struct device_attribute * attr,
657 char *buf) 633 char *buf)
658{ 634{
659 u8 *data; 635 cap_t cap;
660 ssize_t rc; 636 ssize_t rc;
661 637
662 struct tpm_chip *chip = dev_get_drvdata(dev); 638 rc = tpm_getcap(dev, TPM_CAP_PROP_OWNER, &cap,
663 if (chip == NULL) 639 "attempting to determine the owner state");
664 return -ENODEV; 640 if (rc)
665
666 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
667 if (!data)
668 return -ENOMEM;
669
670 memcpy(data, tpm_cap, sizeof(tpm_cap));
671 data[TPM_CAP_IDX] = TPM_CAP_PROP;
672 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_OWNER;
673
674 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
675 "attempting to determine the owner state");
676 if (rc) {
677 kfree(data);
678 return 0; 641 return 0;
679 }
680
681 rc = sprintf(buf, "%d\n", data[TPM_GET_CAP_RET_BOOL_1_IDX]);
682 642
683 kfree(data); 643 rc = sprintf(buf, "%d\n", cap.owned);
684 return rc; 644 return rc;
685} 645}
686EXPORT_SYMBOL_GPL(tpm_show_owned); 646EXPORT_SYMBOL_GPL(tpm_show_owned);
@@ -688,116 +648,180 @@ EXPORT_SYMBOL_GPL(tpm_show_owned);
688ssize_t tpm_show_temp_deactivated(struct device * dev, 648ssize_t tpm_show_temp_deactivated(struct device * dev,
689 struct device_attribute * attr, char *buf) 649 struct device_attribute * attr, char *buf)
690{ 650{
691 u8 *data; 651 cap_t cap;
692 ssize_t rc; 652 ssize_t rc;
693 653
694 struct tpm_chip *chip = dev_get_drvdata(dev); 654 rc = tpm_getcap(dev, TPM_CAP_FLAG_VOL, &cap,
695 if (chip == NULL) 655 "attempting to determine the temporary state");
696 return -ENODEV; 656 if (rc)
657 return 0;
697 658
698 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL); 659 rc = sprintf(buf, "%d\n", cap.stclear_flags.deactivated);
699 if (!data) 660 return rc;
700 return -ENOMEM; 661}
662EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated);
701 663
702 memcpy(data, tpm_cap, sizeof(tpm_cap)); 664/*
703 data[TPM_CAP_IDX] = TPM_CAP_FLAG; 665 * tpm_chip_find_get - return tpm_chip for given chip number
704 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_VOL; 666 */
667static struct tpm_chip *tpm_chip_find_get(int chip_num)
668{
669 struct tpm_chip *pos, *chip = NULL;
705 670
706 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE, 671 rcu_read_lock();
707 "attempting to determine the temporary state"); 672 list_for_each_entry_rcu(pos, &tpm_chip_list, list) {
708 if (rc) { 673 if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
709 kfree(data); 674 continue;
710 return 0; 675
676 if (try_module_get(pos->dev->driver->owner)) {
677 chip = pos;
678 break;
679 }
711 } 680 }
681 rcu_read_unlock();
682 return chip;
683}
712 684
713 rc = sprintf(buf, "%d\n", data[TPM_GET_CAP_TEMP_INACTIVE_IDX]); 685#define TPM_ORDINAL_PCRREAD cpu_to_be32(21)
686#define READ_PCR_RESULT_SIZE 30
687static struct tpm_input_header pcrread_header = {
688 .tag = TPM_TAG_RQU_COMMAND,
689 .length = cpu_to_be32(14),
690 .ordinal = TPM_ORDINAL_PCRREAD
691};
714 692
715 kfree(data); 693int __tpm_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf)
694{
695 int rc;
696 struct tpm_cmd_t cmd;
697
698 cmd.header.in = pcrread_header;
699 cmd.params.pcrread_in.pcr_idx = cpu_to_be32(pcr_idx);
700 BUILD_BUG_ON(cmd.header.in.length > READ_PCR_RESULT_SIZE);
701 rc = transmit_cmd(chip, &cmd, cmd.header.in.length,
702 "attempting to read a pcr value");
703
704 if (rc == 0)
705 memcpy(res_buf, cmd.params.pcrread_out.pcr_result,
706 TPM_DIGEST_SIZE);
716 return rc; 707 return rc;
717} 708}
718EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated);
719 709
720static const u8 pcrread[] = { 710/**
721 0, 193, /* TPM_TAG_RQU_COMMAND */ 711 * tpm_pcr_read - read a pcr value
722 0, 0, 0, 14, /* length */ 712 * @chip_num: tpm idx # or ANY
723 0, 0, 0, 21, /* TPM_ORD_PcrRead */ 713 * @pcr_idx: pcr idx to retrieve
724 0, 0, 0, 0 /* PCR index */ 714 * @res_buf: TPM_PCR value
715 * size of res_buf is 20 bytes (or NULL if you don't care)
716 *
717 * The TPM driver should be built-in, but for whatever reason it
718 * isn't, protect against the chip disappearing, by incrementing
719 * the module usage count.
720 */
721int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf)
722{
723 struct tpm_chip *chip;
724 int rc;
725
726 chip = tpm_chip_find_get(chip_num);
727 if (chip == NULL)
728 return -ENODEV;
729 rc = __tpm_pcr_read(chip, pcr_idx, res_buf);
730 module_put(chip->dev->driver->owner);
731 return rc;
732}
733EXPORT_SYMBOL_GPL(tpm_pcr_read);
734
735/**
736 * tpm_pcr_extend - extend pcr value with hash
737 * @chip_num: tpm idx # or AN&
738 * @pcr_idx: pcr idx to extend
739 * @hash: hash value used to extend pcr value
740 *
741 * The TPM driver should be built-in, but for whatever reason it
742 * isn't, protect against the chip disappearing, by incrementing
743 * the module usage count.
744 */
745#define TPM_ORD_PCR_EXTEND cpu_to_be32(20)
746#define EXTEND_PCR_SIZE 34
747static struct tpm_input_header pcrextend_header = {
748 .tag = TPM_TAG_RQU_COMMAND,
749 .length = cpu_to_be32(34),
750 .ordinal = TPM_ORD_PCR_EXTEND
725}; 751};
726 752
753int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash)
754{
755 struct tpm_cmd_t cmd;
756 int rc;
757 struct tpm_chip *chip;
758
759 chip = tpm_chip_find_get(chip_num);
760 if (chip == NULL)
761 return -ENODEV;
762
763 cmd.header.in = pcrextend_header;
764 BUILD_BUG_ON(be32_to_cpu(cmd.header.in.length) > EXTEND_PCR_SIZE);
765 cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(pcr_idx);
766 memcpy(cmd.params.pcrextend_in.hash, hash, TPM_DIGEST_SIZE);
767 rc = transmit_cmd(chip, &cmd, cmd.header.in.length,
768 "attempting extend a PCR value");
769
770 module_put(chip->dev->driver->owner);
771 return rc;
772}
773EXPORT_SYMBOL_GPL(tpm_pcr_extend);
774
727ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr, 775ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
728 char *buf) 776 char *buf)
729{ 777{
730 u8 *data; 778 cap_t cap;
779 u8 digest[TPM_DIGEST_SIZE];
731 ssize_t rc; 780 ssize_t rc;
732 int i, j, num_pcrs; 781 int i, j, num_pcrs;
733 __be32 index;
734 char *str = buf; 782 char *str = buf;
735
736 struct tpm_chip *chip = dev_get_drvdata(dev); 783 struct tpm_chip *chip = dev_get_drvdata(dev);
737 if (chip == NULL)
738 return -ENODEV;
739 784
740 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL); 785 rc = tpm_getcap(dev, TPM_CAP_PROP_PCR, &cap,
741 if (!data)
742 return -ENOMEM;
743
744 memcpy(data, tpm_cap, sizeof(tpm_cap));
745 data[TPM_CAP_IDX] = TPM_CAP_PROP;
746 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_PCR;
747
748 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
749 "attempting to determine the number of PCRS"); 786 "attempting to determine the number of PCRS");
750 if (rc) { 787 if (rc)
751 kfree(data);
752 return 0; 788 return 0;
753 }
754 789
755 num_pcrs = be32_to_cpu(*((__be32 *) (data + 14))); 790 num_pcrs = be32_to_cpu(cap.num_pcrs);
756 for (i = 0; i < num_pcrs; i++) { 791 for (i = 0; i < num_pcrs; i++) {
757 memcpy(data, pcrread, sizeof(pcrread)); 792 rc = __tpm_pcr_read(chip, i, digest);
758 index = cpu_to_be32(i);
759 memcpy(data + 10, &index, 4);
760 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
761 "attempting to read a PCR");
762 if (rc) 793 if (rc)
763 goto out; 794 break;
764 str += sprintf(str, "PCR-%02d: ", i); 795 str += sprintf(str, "PCR-%02d: ", i);
765 for (j = 0; j < TPM_DIGEST_SIZE; j++) 796 for (j = 0; j < TPM_DIGEST_SIZE; j++)
766 str += sprintf(str, "%02X ", *(data + 10 + j)); 797 str += sprintf(str, "%02X ", digest[j]);
767 str += sprintf(str, "\n"); 798 str += sprintf(str, "\n");
768 } 799 }
769out:
770 kfree(data);
771 return str - buf; 800 return str - buf;
772} 801}
773EXPORT_SYMBOL_GPL(tpm_show_pcrs); 802EXPORT_SYMBOL_GPL(tpm_show_pcrs);
774 803
775#define READ_PUBEK_RESULT_SIZE 314 804#define READ_PUBEK_RESULT_SIZE 314
776static const u8 readpubek[] = { 805#define TPM_ORD_READPUBEK cpu_to_be32(124)
777 0, 193, /* TPM_TAG_RQU_COMMAND */ 806struct tpm_input_header tpm_readpubek_header = {
778 0, 0, 0, 30, /* length */ 807 .tag = TPM_TAG_RQU_COMMAND,
779 0, 0, 0, 124, /* TPM_ORD_ReadPubek */ 808 .length = cpu_to_be32(30),
809 .ordinal = TPM_ORD_READPUBEK
780}; 810};
781 811
782ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr, 812ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr,
783 char *buf) 813 char *buf)
784{ 814{
785 u8 *data; 815 u8 *data;
816 struct tpm_cmd_t tpm_cmd;
786 ssize_t err; 817 ssize_t err;
787 int i, rc; 818 int i, rc;
788 char *str = buf; 819 char *str = buf;
789 820
790 struct tpm_chip *chip = dev_get_drvdata(dev); 821 struct tpm_chip *chip = dev_get_drvdata(dev);
791 if (chip == NULL)
792 return -ENODEV;
793 822
794 data = kzalloc(READ_PUBEK_RESULT_SIZE, GFP_KERNEL); 823 tpm_cmd.header.in = tpm_readpubek_header;
795 if (!data) 824 err = transmit_cmd(chip, &tpm_cmd, READ_PUBEK_RESULT_SIZE,
796 return -ENOMEM;
797
798 memcpy(data, readpubek, sizeof(readpubek));
799
800 err = transmit_cmd(chip, data, READ_PUBEK_RESULT_SIZE,
801 "attempting to read the PUBEK"); 825 "attempting to read the PUBEK");
802 if (err) 826 if (err)
803 goto out; 827 goto out;
@@ -812,7 +836,7 @@ ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr,
812 256 byte modulus 836 256 byte modulus
813 ignore checksum 20 bytes 837 ignore checksum 20 bytes
814 */ 838 */
815 839 data = tpm_cmd.params.readpubek_out_buffer;
816 str += 840 str +=
817 sprintf(str, 841 sprintf(str,
818 "Algorithm: %02X %02X %02X %02X\nEncscheme: %02X %02X\n" 842 "Algorithm: %02X %02X %02X %02X\nEncscheme: %02X %02X\n"
@@ -832,65 +856,33 @@ ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr,
832 } 856 }
833out: 857out:
834 rc = str - buf; 858 rc = str - buf;
835 kfree(data);
836 return rc; 859 return rc;
837} 860}
838EXPORT_SYMBOL_GPL(tpm_show_pubek); 861EXPORT_SYMBOL_GPL(tpm_show_pubek);
839 862
840#define CAP_VERSION_1_1 6
841#define CAP_VERSION_1_2 0x1A
842#define CAP_VERSION_IDX 13
843static const u8 cap_version[] = {
844 0, 193, /* TPM_TAG_RQU_COMMAND */
845 0, 0, 0, 18, /* length */
846 0, 0, 0, 101, /* TPM_ORD_GetCapability */
847 0, 0, 0, 0,
848 0, 0, 0, 0
849};
850 863
851ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr, 864ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr,
852 char *buf) 865 char *buf)
853{ 866{
854 u8 *data; 867 cap_t cap;
855 ssize_t rc; 868 ssize_t rc;
856 char *str = buf; 869 char *str = buf;
857 870
858 struct tpm_chip *chip = dev_get_drvdata(dev); 871 rc = tpm_getcap(dev, TPM_CAP_PROP_MANUFACTURER, &cap,
859 if (chip == NULL)
860 return -ENODEV;
861
862 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
863 if (!data)
864 return -ENOMEM;
865
866 memcpy(data, tpm_cap, sizeof(tpm_cap));
867 data[TPM_CAP_IDX] = TPM_CAP_PROP;
868 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER;
869
870 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
871 "attempting to determine the manufacturer"); 872 "attempting to determine the manufacturer");
872 if (rc) { 873 if (rc)
873 kfree(data);
874 return 0; 874 return 0;
875 }
876
877 str += sprintf(str, "Manufacturer: 0x%x\n", 875 str += sprintf(str, "Manufacturer: 0x%x\n",
878 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)))); 876 be32_to_cpu(cap.manufacturer_id));
879 877
880 memcpy(data, cap_version, sizeof(cap_version)); 878 rc = tpm_getcap(dev, CAP_VERSION_1_1, &cap,
881 data[CAP_VERSION_IDX] = CAP_VERSION_1_1; 879 "attempting to determine the 1.1 version");
882 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
883 "attempting to determine the 1.1 version");
884 if (rc) 880 if (rc)
885 goto out; 881 return 0;
886
887 str += sprintf(str, 882 str += sprintf(str,
888 "TCG version: %d.%d\nFirmware version: %d.%d\n", 883 "TCG version: %d.%d\nFirmware version: %d.%d\n",
889 (int) data[14], (int) data[15], (int) data[16], 884 cap.tpm_version.Major, cap.tpm_version.Minor,
890 (int) data[17]); 885 cap.tpm_version.revMajor, cap.tpm_version.revMinor);
891
892out:
893 kfree(data);
894 return str - buf; 886 return str - buf;
895} 887}
896EXPORT_SYMBOL_GPL(tpm_show_caps); 888EXPORT_SYMBOL_GPL(tpm_show_caps);
@@ -898,51 +890,25 @@ EXPORT_SYMBOL_GPL(tpm_show_caps);
898ssize_t tpm_show_caps_1_2(struct device * dev, 890ssize_t tpm_show_caps_1_2(struct device * dev,
899 struct device_attribute * attr, char *buf) 891 struct device_attribute * attr, char *buf)
900{ 892{
901 u8 *data; 893 cap_t cap;
902 ssize_t len; 894 ssize_t rc;
903 char *str = buf; 895 char *str = buf;
904 896
905 struct tpm_chip *chip = dev_get_drvdata(dev); 897 rc = tpm_getcap(dev, TPM_CAP_PROP_MANUFACTURER, &cap,
906 if (chip == NULL) 898 "attempting to determine the manufacturer");
907 return -ENODEV; 899 if (rc)
908
909 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
910 if (!data)
911 return -ENOMEM;
912
913 memcpy(data, tpm_cap, sizeof(tpm_cap));
914 data[TPM_CAP_IDX] = TPM_CAP_PROP;
915 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER;
916
917 len = tpm_transmit(chip, data, TPM_INTERNAL_RESULT_SIZE);
918 if (len <= TPM_ERROR_SIZE) {
919 dev_dbg(chip->dev, "A TPM error (%d) occurred "
920 "attempting to determine the manufacturer\n",
921 be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX))));
922 kfree(data);
923 return 0; 900 return 0;
924 }
925
926 str += sprintf(str, "Manufacturer: 0x%x\n", 901 str += sprintf(str, "Manufacturer: 0x%x\n",
927 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)))); 902 be32_to_cpu(cap.manufacturer_id));
928 903 rc = tpm_getcap(dev, CAP_VERSION_1_2, &cap,
929 memcpy(data, cap_version, sizeof(cap_version)); 904 "attempting to determine the 1.2 version");
930 data[CAP_VERSION_IDX] = CAP_VERSION_1_2; 905 if (rc)
931 906 return 0;
932 len = tpm_transmit(chip, data, TPM_INTERNAL_RESULT_SIZE);
933 if (len <= TPM_ERROR_SIZE) {
934 dev_err(chip->dev, "A TPM error (%d) occurred "
935 "attempting to determine the 1.2 version\n",
936 be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX))));
937 goto out;
938 }
939 str += sprintf(str, 907 str += sprintf(str,
940 "TCG version: %d.%d\nFirmware version: %d.%d\n", 908 "TCG version: %d.%d\nFirmware version: %d.%d\n",
941 (int) data[16], (int) data[17], (int) data[18], 909 cap.tpm_version_1_2.Major, cap.tpm_version_1_2.Minor,
942 (int) data[19]); 910 cap.tpm_version_1_2.revMajor,
943 911 cap.tpm_version_1_2.revMinor);
944out:
945 kfree(data);
946 return str - buf; 912 return str - buf;
947} 913}
948EXPORT_SYMBOL_GPL(tpm_show_caps_1_2); 914EXPORT_SYMBOL_GPL(tpm_show_caps_1_2);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 8e30df4a4388..8e00b4ddd083 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -26,6 +26,7 @@
26#include <linux/miscdevice.h> 26#include <linux/miscdevice.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/tpm.h>
29 30
30enum tpm_timeout { 31enum tpm_timeout {
31 TPM_TIMEOUT = 5, /* msecs */ 32 TPM_TIMEOUT = 5, /* msecs */
@@ -123,6 +124,147 @@ static inline void tpm_write_index(int base, int index, int value)
123 outb(index, base); 124 outb(index, base);
124 outb(value & 0xFF, base+1); 125 outb(value & 0xFF, base+1);
125} 126}
127struct tpm_input_header {
128 __be16 tag;
129 __be32 length;
130 __be32 ordinal;
131}__attribute__((packed));
132
133struct tpm_output_header {
134 __be16 tag;
135 __be32 length;
136 __be32 return_code;
137}__attribute__((packed));
138
139struct stclear_flags_t {
140 __be16 tag;
141 u8 deactivated;
142 u8 disableForceClear;
143 u8 physicalPresence;
144 u8 physicalPresenceLock;
145 u8 bGlobalLock;
146}__attribute__((packed));
147
148struct tpm_version_t {
149 u8 Major;
150 u8 Minor;
151 u8 revMajor;
152 u8 revMinor;
153}__attribute__((packed));
154
155struct tpm_version_1_2_t {
156 __be16 tag;
157 u8 Major;
158 u8 Minor;
159 u8 revMajor;
160 u8 revMinor;
161}__attribute__((packed));
162
163struct timeout_t {
164 __be32 a;
165 __be32 b;
166 __be32 c;
167 __be32 d;
168}__attribute__((packed));
169
170struct duration_t {
171 __be32 tpm_short;
172 __be32 tpm_medium;
173 __be32 tpm_long;
174}__attribute__((packed));
175
176struct permanent_flags_t {
177 __be16 tag;
178 u8 disable;
179 u8 ownership;
180 u8 deactivated;
181 u8 readPubek;
182 u8 disableOwnerClear;
183 u8 allowMaintenance;
184 u8 physicalPresenceLifetimeLock;
185 u8 physicalPresenceHWEnable;
186 u8 physicalPresenceCMDEnable;
187 u8 CEKPUsed;
188 u8 TPMpost;
189 u8 TPMpostLock;
190 u8 FIPS;
191 u8 operator;
192 u8 enableRevokeEK;
193 u8 nvLocked;
194 u8 readSRKPub;
195 u8 tpmEstablished;
196 u8 maintenanceDone;
197 u8 disableFullDALogicInfo;
198}__attribute__((packed));
199
200typedef union {
201 struct permanent_flags_t perm_flags;
202 struct stclear_flags_t stclear_flags;
203 bool owned;
204 __be32 num_pcrs;
205 struct tpm_version_t tpm_version;
206 struct tpm_version_1_2_t tpm_version_1_2;
207 __be32 manufacturer_id;
208 struct timeout_t timeout;
209 struct duration_t duration;
210} cap_t;
211
212struct tpm_getcap_params_in {
213 __be32 cap;
214 __be32 subcap_size;
215 __be32 subcap;
216}__attribute__((packed));
217
218struct tpm_getcap_params_out {
219 __be32 cap_size;
220 cap_t cap;
221}__attribute__((packed));
222
223struct tpm_readpubek_params_out {
224 u8 algorithm[4];
225 u8 encscheme[2];
226 u8 sigscheme[2];
227 u8 parameters[12]; /*assuming RSA*/
228 __be32 keysize;
229 u8 modulus[256];
230 u8 checksum[20];
231}__attribute__((packed));
232
233typedef union {
234 struct tpm_input_header in;
235 struct tpm_output_header out;
236} tpm_cmd_header;
237
238#define TPM_DIGEST_SIZE 20
239struct tpm_pcrread_out {
240 u8 pcr_result[TPM_DIGEST_SIZE];
241}__attribute__((packed));
242
243struct tpm_pcrread_in {
244 __be32 pcr_idx;
245}__attribute__((packed));
246
247struct tpm_pcrextend_in {
248 __be32 pcr_idx;
249 u8 hash[TPM_DIGEST_SIZE];
250}__attribute__((packed));
251
252typedef union {
253 struct tpm_getcap_params_out getcap_out;
254 struct tpm_readpubek_params_out readpubek_out;
255 u8 readpubek_out_buffer[sizeof(struct tpm_readpubek_params_out)];
256 struct tpm_getcap_params_in getcap_in;
257 struct tpm_pcrread_in pcrread_in;
258 struct tpm_pcrread_out pcrread_out;
259 struct tpm_pcrextend_in pcrextend_in;
260} tpm_cmd_params;
261
262struct tpm_cmd_t {
263 tpm_cmd_header header;
264 tpm_cmd_params params;
265}__attribute__((packed));
266
267ssize_t tpm_getcap(struct device *, __be32, cap_t *, const char *);
126 268
127extern void tpm_get_timeouts(struct tpm_chip *); 269extern void tpm_get_timeouts(struct tpm_chip *);
128extern void tpm_gen_interrupt(struct tpm_chip *); 270extern void tpm_gen_interrupt(struct tpm_chip *);
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index d0e7926eb486..c64a1bc65349 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -168,12 +168,22 @@ static void atml_plat_remove(void)
168 } 168 }
169} 169}
170 170
171static struct device_driver atml_drv = { 171static int tpm_atml_suspend(struct platform_device *dev, pm_message_t msg)
172 .name = "tpm_atmel", 172{
173 .bus = &platform_bus_type, 173 return tpm_pm_suspend(&dev->dev, msg);
174 .owner = THIS_MODULE, 174}
175 .suspend = tpm_pm_suspend, 175
176 .resume = tpm_pm_resume, 176static int tpm_atml_resume(struct platform_device *dev)
177{
178 return tpm_pm_resume(&dev->dev);
179}
180static struct platform_driver atml_drv = {
181 .driver = {
182 .name = "tpm_atmel",
183 .owner = THIS_MODULE,
184 },
185 .suspend = tpm_atml_suspend,
186 .resume = tpm_atml_resume,
177}; 187};
178 188
179static int __init init_atmel(void) 189static int __init init_atmel(void)
@@ -184,7 +194,7 @@ static int __init init_atmel(void)
184 unsigned long base; 194 unsigned long base;
185 struct tpm_chip *chip; 195 struct tpm_chip *chip;
186 196
187 rc = driver_register(&atml_drv); 197 rc = platform_driver_register(&atml_drv);
188 if (rc) 198 if (rc)
189 return rc; 199 return rc;
190 200
@@ -223,13 +233,13 @@ err_rel_reg:
223 atmel_release_region(base, 233 atmel_release_region(base,
224 region_size); 234 region_size);
225err_unreg_drv: 235err_unreg_drv:
226 driver_unregister(&atml_drv); 236 platform_driver_unregister(&atml_drv);
227 return rc; 237 return rc;
228} 238}
229 239
230static void __exit cleanup_atmel(void) 240static void __exit cleanup_atmel(void)
231{ 241{
232 driver_unregister(&atml_drv); 242 platform_driver_unregister(&atml_drv);
233 atml_plat_remove(); 243 atml_plat_remove();
234} 244}
235 245
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 717af7ad1bdf..aec1931608aa 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -654,12 +654,22 @@ module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id,
654 sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444); 654 sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444);
655MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe"); 655MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe");
656 656
657static struct device_driver tis_drv = { 657static int tpm_tis_suspend(struct platform_device *dev, pm_message_t msg)
658 .name = "tpm_tis", 658{
659 .bus = &platform_bus_type, 659 return tpm_pm_suspend(&dev->dev, msg);
660 .owner = THIS_MODULE, 660}
661 .suspend = tpm_pm_suspend, 661
662 .resume = tpm_pm_resume, 662static int tpm_tis_resume(struct platform_device *dev)
663{
664 return tpm_pm_resume(&dev->dev);
665}
666static struct platform_driver tis_drv = {
667 .driver = {
668 .name = "tpm_tis",
669 .owner = THIS_MODULE,
670 },
671 .suspend = tpm_tis_suspend,
672 .resume = tpm_tis_resume,
663}; 673};
664 674
665static struct platform_device *pdev; 675static struct platform_device *pdev;
@@ -672,14 +682,14 @@ static int __init init_tis(void)
672 int rc; 682 int rc;
673 683
674 if (force) { 684 if (force) {
675 rc = driver_register(&tis_drv); 685 rc = platform_driver_register(&tis_drv);
676 if (rc < 0) 686 if (rc < 0)
677 return rc; 687 return rc;
678 if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0))) 688 if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0)))
679 return PTR_ERR(pdev); 689 return PTR_ERR(pdev);
680 if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) { 690 if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) {
681 platform_device_unregister(pdev); 691 platform_device_unregister(pdev);
682 driver_unregister(&tis_drv); 692 platform_driver_unregister(&tis_drv);
683 } 693 }
684 return rc; 694 return rc;
685 } 695 }
@@ -711,7 +721,7 @@ static void __exit cleanup_tis(void)
711 721
712 if (force) { 722 if (force) {
713 platform_device_unregister(pdev); 723 platform_device_unregister(pdev);
714 driver_unregister(&tis_drv); 724 platform_driver_unregister(&tis_drv);
715 } else 725 } else
716 pnp_unregister_driver(&tis_pnp_driver); 726 pnp_unregister_driver(&tis_pnp_driver);
717} 727}
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index 4f3b3f95fc42..d94d25c12aa8 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -479,18 +479,18 @@ static const struct file_operations vcs_fops = {
479 479
480static struct class *vc_class; 480static struct class *vc_class;
481 481
482void vcs_make_sysfs(struct tty_struct *tty) 482void vcs_make_sysfs(int index)
483{ 483{
484 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), NULL, 484 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 1), NULL,
485 "vcs%u", tty->index + 1); 485 "vcs%u", index + 1);
486 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), NULL, 486 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 129), NULL,
487 "vcsa%u", tty->index + 1); 487 "vcsa%u", index + 1);
488} 488}
489 489
490void vcs_remove_sysfs(struct tty_struct *tty) 490void vcs_remove_sysfs(int index)
491{ 491{
492 device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1)); 492 device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 1));
493 device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129)); 493 device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 129));
494} 494}
495 495
496int __init vcs_init(void) 496int __init vcs_init(void)
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 7900bd63b36d..2c1d133819b5 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -778,6 +778,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
778 } 778 }
779 vc->vc_kmalloced = 1; 779 vc->vc_kmalloced = 1;
780 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); 780 vc_init(vc, vc->vc_rows, vc->vc_cols, 1);
781 vcs_make_sysfs(currcons);
781 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param); 782 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param);
782 } 783 }
783 return 0; 784 return 0;
@@ -987,7 +988,9 @@ void vc_deallocate(unsigned int currcons)
987 if (vc_cons_allocated(currcons)) { 988 if (vc_cons_allocated(currcons)) {
988 struct vc_data *vc = vc_cons[currcons].d; 989 struct vc_data *vc = vc_cons[currcons].d;
989 struct vt_notifier_param param = { .vc = vc }; 990 struct vt_notifier_param param = { .vc = vc };
991
990 atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, &param); 992 atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, &param);
993 vcs_remove_sysfs(currcons);
991 vc->vc_sw->con_deinit(vc); 994 vc->vc_sw->con_deinit(vc);
992 put_pid(vc->vt_pid); 995 put_pid(vc->vt_pid);
993 module_put(vc->vc_sw->owner); 996 module_put(vc->vc_sw->owner);
@@ -2775,7 +2778,6 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2775 tty->termios->c_iflag |= IUTF8; 2778 tty->termios->c_iflag |= IUTF8;
2776 else 2779 else
2777 tty->termios->c_iflag &= ~IUTF8; 2780 tty->termios->c_iflag &= ~IUTF8;
2778 vcs_make_sysfs(tty);
2779 release_console_sem(); 2781 release_console_sem();
2780 return ret; 2782 return ret;
2781 } 2783 }
@@ -2795,7 +2797,6 @@ static void con_shutdown(struct tty_struct *tty)
2795 BUG_ON(vc == NULL); 2797 BUG_ON(vc == NULL);
2796 acquire_console_sem(); 2798 acquire_console_sem();
2797 vc->vc_tty = NULL; 2799 vc->vc_tty = NULL;
2798 vcs_remove_sysfs(tty);
2799 release_console_sem(); 2800 release_console_sem();
2800 tty_shutdown(tty); 2801 tty_shutdown(tty);
2801} 2802}
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 1525882190fd..1efb2879a94f 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
2obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o 2obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o
3obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o 3obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
4obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o 4obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
5obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
new file mode 100644
index 000000000000..7783b42f6914
--- /dev/null
+++ b/drivers/clocksource/sh_cmt.c
@@ -0,0 +1,615 @@
1/*
2 * SuperH Timer Support - CMT
3 *
4 * Copyright (C) 2008 Magnus Damm
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
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/init.h>
21#include <linux/bootmem.h>
22#include <linux/platform_device.h>
23#include <linux/spinlock.h>
24#include <linux/interrupt.h>
25#include <linux/ioport.h>
26#include <linux/io.h>
27#include <linux/clk.h>
28#include <linux/irq.h>
29#include <linux/err.h>
30#include <linux/clocksource.h>
31#include <linux/clockchips.h>
32#include <linux/sh_cmt.h>
33
34struct sh_cmt_priv {
35 void __iomem *mapbase;
36 struct clk *clk;
37 unsigned long width; /* 16 or 32 bit version of hardware block */
38 unsigned long overflow_bit;
39 unsigned long clear_bits;
40 struct irqaction irqaction;
41 struct platform_device *pdev;
42
43 unsigned long flags;
44 unsigned long match_value;
45 unsigned long next_match_value;
46 unsigned long max_match_value;
47 unsigned long rate;
48 spinlock_t lock;
49 struct clock_event_device ced;
50 unsigned long total_cycles;
51};
52
53static DEFINE_SPINLOCK(sh_cmt_lock);
54
55#define CMSTR -1 /* shared register */
56#define CMCSR 0 /* channel register */
57#define CMCNT 1 /* channel register */
58#define CMCOR 2 /* channel register */
59
60static inline unsigned long sh_cmt_read(struct sh_cmt_priv *p, int reg_nr)
61{
62 struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
63 void __iomem *base = p->mapbase;
64 unsigned long offs;
65
66 if (reg_nr == CMSTR) {
67 offs = 0;
68 base -= cfg->channel_offset;
69 } else
70 offs = reg_nr;
71
72 if (p->width == 16)
73 offs <<= 1;
74 else {
75 offs <<= 2;
76 if ((reg_nr == CMCNT) || (reg_nr == CMCOR))
77 return ioread32(base + offs);
78 }
79
80 return ioread16(base + offs);
81}
82
83static inline void sh_cmt_write(struct sh_cmt_priv *p, int reg_nr,
84 unsigned long value)
85{
86 struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
87 void __iomem *base = p->mapbase;
88 unsigned long offs;
89
90 if (reg_nr == CMSTR) {
91 offs = 0;
92 base -= cfg->channel_offset;
93 } else
94 offs = reg_nr;
95
96 if (p->width == 16)
97 offs <<= 1;
98 else {
99 offs <<= 2;
100 if ((reg_nr == CMCNT) || (reg_nr == CMCOR)) {
101 iowrite32(value, base + offs);
102 return;
103 }
104 }
105
106 iowrite16(value, base + offs);
107}
108
109static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p,
110 int *has_wrapped)
111{
112 unsigned long v1, v2, v3;
113
114 /* Make sure the timer value is stable. Stolen from acpi_pm.c */
115 do {
116 v1 = sh_cmt_read(p, CMCNT);
117 v2 = sh_cmt_read(p, CMCNT);
118 v3 = sh_cmt_read(p, CMCNT);
119 } while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1)
120 || (v3 > v1 && v3 < v2)));
121
122 *has_wrapped = sh_cmt_read(p, CMCSR) & p->overflow_bit;
123 return v2;
124}
125
126
127static void sh_cmt_start_stop_ch(struct sh_cmt_priv *p, int start)
128{
129 struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
130 unsigned long flags, value;
131
132 /* start stop register shared by multiple timer channels */
133 spin_lock_irqsave(&sh_cmt_lock, flags);
134 value = sh_cmt_read(p, CMSTR);
135
136 if (start)
137 value |= 1 << cfg->timer_bit;
138 else
139 value &= ~(1 << cfg->timer_bit);
140
141 sh_cmt_write(p, CMSTR, value);
142 spin_unlock_irqrestore(&sh_cmt_lock, flags);
143}
144
145static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate)
146{
147 struct sh_cmt_config *cfg = p->pdev->dev.platform_data;
148 int ret;
149
150 /* enable clock */
151 ret = clk_enable(p->clk);
152 if (ret) {
153 pr_err("sh_cmt: cannot enable clock \"%s\"\n", cfg->clk);
154 return ret;
155 }
156 *rate = clk_get_rate(p->clk) / 8;
157
158 /* make sure channel is disabled */
159 sh_cmt_start_stop_ch(p, 0);
160
161 /* configure channel, periodic mode and maximum timeout */
162 if (p->width == 16)
163 sh_cmt_write(p, CMCSR, 0);
164 else
165 sh_cmt_write(p, CMCSR, 0x01a4);
166
167 sh_cmt_write(p, CMCOR, 0xffffffff);
168 sh_cmt_write(p, CMCNT, 0);
169
170 /* enable channel */
171 sh_cmt_start_stop_ch(p, 1);
172 return 0;
173}
174
175static void sh_cmt_disable(struct sh_cmt_priv *p)
176{
177 /* disable channel */
178 sh_cmt_start_stop_ch(p, 0);
179
180 /* stop clock */
181 clk_disable(p->clk);
182}
183
184/* private flags */
185#define FLAG_CLOCKEVENT (1 << 0)
186#define FLAG_CLOCKSOURCE (1 << 1)
187#define FLAG_REPROGRAM (1 << 2)
188#define FLAG_SKIPEVENT (1 << 3)
189#define FLAG_IRQCONTEXT (1 << 4)
190
191static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p,
192 int absolute)
193{
194 unsigned long new_match;
195 unsigned long value = p->next_match_value;
196 unsigned long delay = 0;
197 unsigned long now = 0;
198 int has_wrapped;
199
200 now = sh_cmt_get_counter(p, &has_wrapped);
201 p->flags |= FLAG_REPROGRAM; /* force reprogram */
202
203 if (has_wrapped) {
204 /* we're competing with the interrupt handler.
205 * -> let the interrupt handler reprogram the timer.
206 * -> interrupt number two handles the event.
207 */
208 p->flags |= FLAG_SKIPEVENT;
209 return;
210 }
211
212 if (absolute)
213 now = 0;
214
215 do {
216 /* reprogram the timer hardware,
217 * but don't save the new match value yet.
218 */
219 new_match = now + value + delay;
220 if (new_match > p->max_match_value)
221 new_match = p->max_match_value;
222
223 sh_cmt_write(p, CMCOR, new_match);
224
225 now = sh_cmt_get_counter(p, &has_wrapped);
226 if (has_wrapped && (new_match > p->match_value)) {
227 /* we are changing to a greater match value,
228 * so this wrap must be caused by the counter
229 * matching the old value.
230 * -> first interrupt reprograms the timer.
231 * -> interrupt number two handles the event.
232 */
233 p->flags |= FLAG_SKIPEVENT;
234 break;
235 }
236
237 if (has_wrapped) {
238 /* we are changing to a smaller match value,
239 * so the wrap must be caused by the counter
240 * matching the new value.
241 * -> save programmed match value.
242 * -> let isr handle the event.
243 */
244 p->match_value = new_match;
245 break;
246 }
247
248 /* be safe: verify hardware settings */
249 if (now < new_match) {
250 /* timer value is below match value, all good.
251 * this makes sure we won't miss any match events.
252 * -> save programmed match value.
253 * -> let isr handle the event.
254 */
255 p->match_value = new_match;
256 break;
257 }
258
259 /* the counter has reached a value greater
260 * than our new match value. and since the
261 * has_wrapped flag isn't set we must have
262 * programmed a too close event.
263 * -> increase delay and retry.
264 */
265 if (delay)
266 delay <<= 1;
267 else
268 delay = 1;
269
270 if (!delay)
271 pr_warning("sh_cmt: too long delay\n");
272
273 } while (delay);
274}
275
276static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta)
277{
278 unsigned long flags;
279
280 if (delta > p->max_match_value)
281 pr_warning("sh_cmt: delta out of range\n");
282
283 spin_lock_irqsave(&p->lock, flags);
284 p->next_match_value = delta;
285 sh_cmt_clock_event_program_verify(p, 0);
286 spin_unlock_irqrestore(&p->lock, flags);
287}
288
289static irqreturn_t sh_cmt_interrupt(int irq, void *dev_id)
290{
291 struct sh_cmt_priv *p = dev_id;
292
293 /* clear flags */
294 sh_cmt_write(p, CMCSR, sh_cmt_read(p, CMCSR) & p->clear_bits);
295
296 /* update clock source counter to begin with if enabled
297 * the wrap flag should be cleared by the timer specific
298 * isr before we end up here.
299 */
300 if (p->flags & FLAG_CLOCKSOURCE)
301 p->total_cycles += p->match_value;
302
303 if (!(p->flags & FLAG_REPROGRAM))
304 p->next_match_value = p->max_match_value;
305
306 p->flags |= FLAG_IRQCONTEXT;
307
308 if (p->flags & FLAG_CLOCKEVENT) {
309 if (!(p->flags & FLAG_SKIPEVENT)) {
310 if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT) {
311 p->next_match_value = p->max_match_value;
312 p->flags |= FLAG_REPROGRAM;
313 }
314
315 p->ced.event_handler(&p->ced);
316 }
317 }
318
319 p->flags &= ~FLAG_SKIPEVENT;
320
321 if (p->flags & FLAG_REPROGRAM) {
322 p->flags &= ~FLAG_REPROGRAM;
323 sh_cmt_clock_event_program_verify(p, 1);
324
325 if (p->flags & FLAG_CLOCKEVENT)
326 if ((p->ced.mode == CLOCK_EVT_MODE_SHUTDOWN)
327 || (p->match_value == p->next_match_value))
328 p->flags &= ~FLAG_REPROGRAM;
329 }
330
331 p->flags &= ~FLAG_IRQCONTEXT;
332
333 return IRQ_HANDLED;
334}
335
336static int sh_cmt_start(struct sh_cmt_priv *p, unsigned long flag)
337{
338 int ret = 0;
339 unsigned long flags;
340
341 spin_lock_irqsave(&p->lock, flags);
342
343 if (!(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
344 ret = sh_cmt_enable(p, &p->rate);
345
346 if (ret)
347 goto out;
348 p->flags |= flag;
349
350 /* setup timeout if no clockevent */
351 if ((flag == FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT)))
352 sh_cmt_set_next(p, p->max_match_value);
353 out:
354 spin_unlock_irqrestore(&p->lock, flags);
355
356 return ret;
357}
358
359static void sh_cmt_stop(struct sh_cmt_priv *p, unsigned long flag)
360{
361 unsigned long flags;
362 unsigned long f;
363
364 spin_lock_irqsave(&p->lock, flags);
365
366 f = p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE);
367 p->flags &= ~flag;
368
369 if (f && !(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
370 sh_cmt_disable(p);
371
372 /* adjust the timeout to maximum if only clocksource left */
373 if ((flag == FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE))
374 sh_cmt_set_next(p, p->max_match_value);
375
376 spin_unlock_irqrestore(&p->lock, flags);
377}
378
379static struct sh_cmt_priv *ced_to_sh_cmt(struct clock_event_device *ced)
380{
381 return container_of(ced, struct sh_cmt_priv, ced);
382}
383
384static void sh_cmt_clock_event_start(struct sh_cmt_priv *p, int periodic)
385{
386 struct clock_event_device *ced = &p->ced;
387
388 sh_cmt_start(p, FLAG_CLOCKEVENT);
389
390 /* TODO: calculate good shift from rate and counter bit width */
391
392 ced->shift = 32;
393 ced->mult = div_sc(p->rate, NSEC_PER_SEC, ced->shift);
394 ced->max_delta_ns = clockevent_delta2ns(p->max_match_value, ced);
395 ced->min_delta_ns = clockevent_delta2ns(0x1f, ced);
396
397 if (periodic)
398 sh_cmt_set_next(p, (p->rate + HZ/2) / HZ);
399 else
400 sh_cmt_set_next(p, p->max_match_value);
401}
402
403static void sh_cmt_clock_event_mode(enum clock_event_mode mode,
404 struct clock_event_device *ced)
405{
406 struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
407
408 /* deal with old setting first */
409 switch (ced->mode) {
410 case CLOCK_EVT_MODE_PERIODIC:
411 case CLOCK_EVT_MODE_ONESHOT:
412 sh_cmt_stop(p, FLAG_CLOCKEVENT);
413 break;
414 default:
415 break;
416 }
417
418 switch (mode) {
419 case CLOCK_EVT_MODE_PERIODIC:
420 pr_info("sh_cmt: %s used for periodic clock events\n",
421 ced->name);
422 sh_cmt_clock_event_start(p, 1);
423 break;
424 case CLOCK_EVT_MODE_ONESHOT:
425 pr_info("sh_cmt: %s used for oneshot clock events\n",
426 ced->name);
427 sh_cmt_clock_event_start(p, 0);
428 break;
429 case CLOCK_EVT_MODE_SHUTDOWN:
430 case CLOCK_EVT_MODE_UNUSED:
431 sh_cmt_stop(p, FLAG_CLOCKEVENT);
432 break;
433 default:
434 break;
435 }
436}
437
438static int sh_cmt_clock_event_next(unsigned long delta,
439 struct clock_event_device *ced)
440{
441 struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
442
443 BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT);
444 if (likely(p->flags & FLAG_IRQCONTEXT))
445 p->next_match_value = delta;
446 else
447 sh_cmt_set_next(p, delta);
448
449 return 0;
450}
451
452static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
453 char *name, unsigned long rating)
454{
455 struct clock_event_device *ced = &p->ced;
456
457 memset(ced, 0, sizeof(*ced));
458
459 ced->name = name;
460 ced->features = CLOCK_EVT_FEAT_PERIODIC;
461 ced->features |= CLOCK_EVT_FEAT_ONESHOT;
462 ced->rating = rating;
463 ced->cpumask = cpumask_of(0);
464 ced->set_next_event = sh_cmt_clock_event_next;
465 ced->set_mode = sh_cmt_clock_event_mode;
466
467 pr_info("sh_cmt: %s used for clock events\n", ced->name);
468 ced->mult = 1; /* work around misplaced WARN_ON() in clockevents.c */
469 clockevents_register_device(ced);
470}
471
472int sh_cmt_register(struct sh_cmt_priv *p, char *name,
473 unsigned long clockevent_rating,
474 unsigned long clocksource_rating)
475{
476 if (p->width == (sizeof(p->max_match_value) * 8))
477 p->max_match_value = ~0;
478 else
479 p->max_match_value = (1 << p->width) - 1;
480
481 p->match_value = p->max_match_value;
482 spin_lock_init(&p->lock);
483
484 if (clockevent_rating)
485 sh_cmt_register_clockevent(p, name, clockevent_rating);
486
487 return 0;
488}
489
490static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
491{
492 struct sh_cmt_config *cfg = pdev->dev.platform_data;
493 struct resource *res;
494 int irq, ret;
495 ret = -ENXIO;
496
497 memset(p, 0, sizeof(*p));
498 p->pdev = pdev;
499
500 if (!cfg) {
501 dev_err(&p->pdev->dev, "missing platform data\n");
502 goto err0;
503 }
504
505 platform_set_drvdata(pdev, p);
506
507 res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0);
508 if (!res) {
509 dev_err(&p->pdev->dev, "failed to get I/O memory\n");
510 goto err0;
511 }
512
513 irq = platform_get_irq(p->pdev, 0);
514 if (irq < 0) {
515 dev_err(&p->pdev->dev, "failed to get irq\n");
516 goto err0;
517 }
518
519 /* map memory, let mapbase point to our channel */
520 p->mapbase = ioremap_nocache(res->start, resource_size(res));
521 if (p->mapbase == NULL) {
522 pr_err("sh_cmt: failed to remap I/O memory\n");
523 goto err0;
524 }
525
526 /* request irq using setup_irq() (too early for request_irq()) */
527 p->irqaction.name = cfg->name;
528 p->irqaction.handler = sh_cmt_interrupt;
529 p->irqaction.dev_id = p;
530 p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL;
531 p->irqaction.mask = CPU_MASK_NONE;
532 ret = setup_irq(irq, &p->irqaction);
533 if (ret) {
534 pr_err("sh_cmt: failed to request irq %d\n", irq);
535 goto err1;
536 }
537
538 /* get hold of clock */
539 p->clk = clk_get(&p->pdev->dev, cfg->clk);
540 if (IS_ERR(p->clk)) {
541 pr_err("sh_cmt: cannot get clock \"%s\"\n", cfg->clk);
542 ret = PTR_ERR(p->clk);
543 goto err2;
544 }
545
546 if (resource_size(res) == 6) {
547 p->width = 16;
548 p->overflow_bit = 0x80;
549 p->clear_bits = ~0xc0;
550 } else {
551 p->width = 32;
552 p->overflow_bit = 0x8000;
553 p->clear_bits = ~0xc000;
554 }
555
556 return sh_cmt_register(p, cfg->name,
557 cfg->clockevent_rating,
558 cfg->clocksource_rating);
559 err2:
560 free_irq(irq, p);
561 err1:
562 iounmap(p->mapbase);
563 err0:
564 return ret;
565}
566
567static int __devinit sh_cmt_probe(struct platform_device *pdev)
568{
569 struct sh_cmt_priv *p = platform_get_drvdata(pdev);
570 int ret;
571
572 p = kmalloc(sizeof(*p), GFP_KERNEL);
573 if (p == NULL) {
574 dev_err(&pdev->dev, "failed to allocate driver data\n");
575 return -ENOMEM;
576 }
577
578 ret = sh_cmt_setup(p, pdev);
579 if (ret) {
580 kfree(p);
581
582 platform_set_drvdata(pdev, NULL);
583 }
584 return ret;
585}
586
587static int __devexit sh_cmt_remove(struct platform_device *pdev)
588{
589 return -EBUSY; /* cannot unregister clockevent and clocksource */
590}
591
592static struct platform_driver sh_cmt_device_driver = {
593 .probe = sh_cmt_probe,
594 .remove = __devexit_p(sh_cmt_remove),
595 .driver = {
596 .name = "sh_cmt",
597 }
598};
599
600static int __init sh_cmt_init(void)
601{
602 return platform_driver_register(&sh_cmt_device_driver);
603}
604
605static void __exit sh_cmt_exit(void)
606{
607 platform_driver_unregister(&sh_cmt_device_driver);
608}
609
610module_init(sh_cmt_init);
611module_exit(sh_cmt_exit);
612
613MODULE_AUTHOR("Magnus Damm");
614MODULE_DESCRIPTION("SuperH CMT Timer Driver");
615MODULE_LICENSE("GPL v2");
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b55cb67435bd..d270e8eb3e67 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -104,7 +104,8 @@ EXPORT_SYMBOL_GPL(unlock_policy_rwsem_write);
104 104
105 105
106/* internal prototypes */ 106/* internal prototypes */
107static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); 107static int __cpufreq_governor(struct cpufreq_policy *policy,
108 unsigned int event);
108static unsigned int __cpufreq_get(unsigned int cpu); 109static unsigned int __cpufreq_get(unsigned int cpu);
109static void handle_update(struct work_struct *work); 110static void handle_update(struct work_struct *work);
110 111
@@ -128,7 +129,7 @@ static int __init init_cpufreq_transition_notifier_list(void)
128pure_initcall(init_cpufreq_transition_notifier_list); 129pure_initcall(init_cpufreq_transition_notifier_list);
129 130
130static LIST_HEAD(cpufreq_governor_list); 131static LIST_HEAD(cpufreq_governor_list);
131static DEFINE_MUTEX (cpufreq_governor_mutex); 132static DEFINE_MUTEX(cpufreq_governor_mutex);
132 133
133struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) 134struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
134{ 135{
@@ -371,7 +372,7 @@ static struct cpufreq_governor *__find_governor(const char *str_governor)
371 struct cpufreq_governor *t; 372 struct cpufreq_governor *t;
372 373
373 list_for_each_entry(t, &cpufreq_governor_list, governor_list) 374 list_for_each_entry(t, &cpufreq_governor_list, governor_list)
374 if (!strnicmp(str_governor,t->name,CPUFREQ_NAME_LEN)) 375 if (!strnicmp(str_governor, t->name, CPUFREQ_NAME_LEN))
375 return t; 376 return t;
376 377
377 return NULL; 378 return NULL;
@@ -429,15 +430,11 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
429 430
430 mutex_unlock(&cpufreq_governor_mutex); 431 mutex_unlock(&cpufreq_governor_mutex);
431 } 432 }
432 out: 433out:
433 return err; 434 return err;
434} 435}
435 436
436 437
437/* drivers/base/cpu.c */
438extern struct sysdev_class cpu_sysdev_class;
439
440
441/** 438/**
442 * cpufreq_per_cpu_attr_read() / show_##file_name() - 439 * cpufreq_per_cpu_attr_read() / show_##file_name() -
443 * print out cpufreq information 440 * print out cpufreq information
@@ -450,11 +447,12 @@ extern struct sysdev_class cpu_sysdev_class;
450static ssize_t show_##file_name \ 447static ssize_t show_##file_name \
451(struct cpufreq_policy *policy, char *buf) \ 448(struct cpufreq_policy *policy, char *buf) \
452{ \ 449{ \
453 return sprintf (buf, "%u\n", policy->object); \ 450 return sprintf(buf, "%u\n", policy->object); \
454} 451}
455 452
456show_one(cpuinfo_min_freq, cpuinfo.min_freq); 453show_one(cpuinfo_min_freq, cpuinfo.min_freq);
457show_one(cpuinfo_max_freq, cpuinfo.max_freq); 454show_one(cpuinfo_max_freq, cpuinfo.max_freq);
455show_one(cpuinfo_transition_latency, cpuinfo.transition_latency);
458show_one(scaling_min_freq, min); 456show_one(scaling_min_freq, min);
459show_one(scaling_max_freq, max); 457show_one(scaling_max_freq, max);
460show_one(scaling_cur_freq, cur); 458show_one(scaling_cur_freq, cur);
@@ -476,7 +474,7 @@ static ssize_t store_##file_name \
476 if (ret) \ 474 if (ret) \
477 return -EINVAL; \ 475 return -EINVAL; \
478 \ 476 \
479 ret = sscanf (buf, "%u", &new_policy.object); \ 477 ret = sscanf(buf, "%u", &new_policy.object); \
480 if (ret != 1) \ 478 if (ret != 1) \
481 return -EINVAL; \ 479 return -EINVAL; \
482 \ 480 \
@@ -486,8 +484,8 @@ static ssize_t store_##file_name \
486 return ret ? ret : count; \ 484 return ret ? ret : count; \
487} 485}
488 486
489store_one(scaling_min_freq,min); 487store_one(scaling_min_freq, min);
490store_one(scaling_max_freq,max); 488store_one(scaling_max_freq, max);
491 489
492/** 490/**
493 * show_cpuinfo_cur_freq - current CPU frequency as detected by hardware 491 * show_cpuinfo_cur_freq - current CPU frequency as detected by hardware
@@ -507,12 +505,13 @@ static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy,
507 */ 505 */
508static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf) 506static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf)
509{ 507{
510 if(policy->policy == CPUFREQ_POLICY_POWERSAVE) 508 if (policy->policy == CPUFREQ_POLICY_POWERSAVE)
511 return sprintf(buf, "powersave\n"); 509 return sprintf(buf, "powersave\n");
512 else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) 510 else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE)
513 return sprintf(buf, "performance\n"); 511 return sprintf(buf, "performance\n");
514 else if (policy->governor) 512 else if (policy->governor)
515 return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", policy->governor->name); 513 return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n",
514 policy->governor->name);
516 return -EINVAL; 515 return -EINVAL;
517} 516}
518 517
@@ -531,7 +530,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
531 if (ret) 530 if (ret)
532 return ret; 531 return ret;
533 532
534 ret = sscanf (buf, "%15s", str_governor); 533 ret = sscanf(buf, "%15s", str_governor);
535 if (ret != 1) 534 if (ret != 1)
536 return -EINVAL; 535 return -EINVAL;
537 536
@@ -575,7 +574,8 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy,
575 } 574 }
576 575
577 list_for_each_entry(t, &cpufreq_governor_list, governor_list) { 576 list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
578 if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) - (CPUFREQ_NAME_LEN + 2))) 577 if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char))
578 - (CPUFREQ_NAME_LEN + 2)))
579 goto out; 579 goto out;
580 i += scnprintf(&buf[i], CPUFREQ_NAME_LEN, "%s ", t->name); 580 i += scnprintf(&buf[i], CPUFREQ_NAME_LEN, "%s ", t->name);
581 } 581 }
@@ -594,7 +594,7 @@ static ssize_t show_cpus(const struct cpumask *mask, char *buf)
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);
596 if (i >= (PAGE_SIZE - 5)) 596 if (i >= (PAGE_SIZE - 5))
597 break; 597 break;
598 } 598 }
599 i += sprintf(&buf[i], "\n"); 599 i += sprintf(&buf[i], "\n");
600 return i; 600 return i;
@@ -660,6 +660,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
660define_one_ro0400(cpuinfo_cur_freq); 660define_one_ro0400(cpuinfo_cur_freq);
661define_one_ro(cpuinfo_min_freq); 661define_one_ro(cpuinfo_min_freq);
662define_one_ro(cpuinfo_max_freq); 662define_one_ro(cpuinfo_max_freq);
663define_one_ro(cpuinfo_transition_latency);
663define_one_ro(scaling_available_governors); 664define_one_ro(scaling_available_governors);
664define_one_ro(scaling_driver); 665define_one_ro(scaling_driver);
665define_one_ro(scaling_cur_freq); 666define_one_ro(scaling_cur_freq);
@@ -673,6 +674,7 @@ define_one_rw(scaling_setspeed);
673static struct attribute *default_attrs[] = { 674static struct attribute *default_attrs[] = {
674 &cpuinfo_min_freq.attr, 675 &cpuinfo_min_freq.attr,
675 &cpuinfo_max_freq.attr, 676 &cpuinfo_max_freq.attr,
677 &cpuinfo_transition_latency.attr,
676 &scaling_min_freq.attr, 678 &scaling_min_freq.attr,
677 &scaling_max_freq.attr, 679 &scaling_max_freq.attr,
678 &affected_cpus.attr, 680 &affected_cpus.attr,
@@ -684,10 +686,10 @@ static struct attribute *default_attrs[] = {
684 NULL 686 NULL
685}; 687};
686 688
687#define to_policy(k) container_of(k,struct cpufreq_policy,kobj) 689#define to_policy(k) container_of(k, struct cpufreq_policy, kobj)
688#define to_attr(a) container_of(a,struct freq_attr,attr) 690#define to_attr(a) container_of(a, struct freq_attr, attr)
689 691
690static ssize_t show(struct kobject *kobj, struct attribute *attr ,char *buf) 692static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
691{ 693{
692 struct cpufreq_policy *policy = to_policy(kobj); 694 struct cpufreq_policy *policy = to_policy(kobj);
693 struct freq_attr *fattr = to_attr(attr); 695 struct freq_attr *fattr = to_attr(attr);
@@ -754,11 +756,6 @@ static struct kobj_type ktype_cpufreq = {
754 .release = cpufreq_sysfs_release, 756 .release = cpufreq_sysfs_release,
755}; 757};
756 758
757static struct kobj_type ktype_empty_cpufreq = {
758 .sysfs_ops = &sysfs_ops,
759 .release = cpufreq_sysfs_release,
760};
761
762 759
763/** 760/**
764 * cpufreq_add_dev - add a CPU device 761 * cpufreq_add_dev - add a CPU device
@@ -858,10 +855,10 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
858 if (cpu == j) 855 if (cpu == j)
859 continue; 856 continue;
860 857
861 /* check for existing affected CPUs. They may not be aware 858 /* Check for existing affected CPUs.
862 * of it due to CPU Hotplug. 859 * They may not be aware of it due to CPU Hotplug.
863 */ 860 */
864 managed_policy = cpufreq_cpu_get(j); // FIXME: Where is this released? What about error paths? 861 managed_policy = cpufreq_cpu_get(j); /* FIXME: Where is this released? What about error paths? */
865 if (unlikely(managed_policy)) { 862 if (unlikely(managed_policy)) {
866 863
867 /* Set proper policy_cpu */ 864 /* Set proper policy_cpu */
@@ -892,36 +889,26 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
892 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); 889 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
893 890
894 /* prepare interface data */ 891 /* prepare interface data */
895 if (!cpufreq_driver->hide_interface) { 892 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj,
896 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, 893 "cpufreq");
897 &sys_dev->kobj, "cpufreq"); 894 if (ret)
895 goto err_out_driver_exit;
896
897 /* set up files for this cpu device */
898 drv_attr = cpufreq_driver->attr;
899 while ((drv_attr) && (*drv_attr)) {
900 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
898 if (ret) 901 if (ret)
899 goto err_out_driver_exit; 902 goto err_out_driver_exit;
900 903 drv_attr++;
901 /* set up files for this cpu device */ 904 }
902 drv_attr = cpufreq_driver->attr; 905 if (cpufreq_driver->get) {
903 while ((drv_attr) && (*drv_attr)) { 906 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr);
904 ret = sysfs_create_file(&policy->kobj, 907 if (ret)
905 &((*drv_attr)->attr)); 908 goto err_out_driver_exit;
906 if (ret) 909 }
907 goto err_out_driver_exit; 910 if (cpufreq_driver->target) {
908 drv_attr++; 911 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
909 }
910 if (cpufreq_driver->get) {
911 ret = sysfs_create_file(&policy->kobj,
912 &cpuinfo_cur_freq.attr);
913 if (ret)
914 goto err_out_driver_exit;
915 }
916 if (cpufreq_driver->target) {
917 ret = sysfs_create_file(&policy->kobj,
918 &scaling_cur_freq.attr);
919 if (ret)
920 goto err_out_driver_exit;
921 }
922 } else {
923 ret = kobject_init_and_add(&policy->kobj, &ktype_empty_cpufreq,
924 &sys_dev->kobj, "cpufreq");
925 if (ret) 912 if (ret)
926 goto err_out_driver_exit; 913 goto err_out_driver_exit;
927 } 914 }
@@ -1142,8 +1129,8 @@ static void handle_update(struct work_struct *work)
1142 * @old_freq: CPU frequency the kernel thinks the CPU runs at 1129 * @old_freq: CPU frequency the kernel thinks the CPU runs at
1143 * @new_freq: CPU frequency the CPU actually runs at 1130 * @new_freq: CPU frequency the CPU actually runs at
1144 * 1131 *
1145 * We adjust to current frequency first, and need to clean up later. So either call 1132 * We adjust to current frequency first, and need to clean up later.
1146 * to cpufreq_update_policy() or schedule handle_update()). 1133 * So either call to cpufreq_update_policy() or schedule handle_update()).
1147 */ 1134 */
1148static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, 1135static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq,
1149 unsigned int new_freq) 1136 unsigned int new_freq)
@@ -1625,7 +1612,8 @@ EXPORT_SYMBOL_GPL(cpufreq_unregister_governor);
1625 1612
1626/** 1613/**
1627 * cpufreq_get_policy - get the current cpufreq_policy 1614 * cpufreq_get_policy - get the current cpufreq_policy
1628 * @policy: struct cpufreq_policy into which the current cpufreq_policy is written 1615 * @policy: struct cpufreq_policy into which the current cpufreq_policy
1616 * is written
1629 * 1617 *
1630 * Reads the current cpufreq policy. 1618 * Reads the current cpufreq policy.
1631 */ 1619 */
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 0320962c4ec5..2ecd95e4ab1a 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2001 Russell King 4 * Copyright (C) 2001 Russell King
5 * (C) 2003 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>. 5 * (C) 2003 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>.
6 * Jun Nakajima <jun.nakajima@intel.com> 6 * Jun Nakajima <jun.nakajima@intel.com>
7 * (C) 2004 Alexander Clouter <alex-kernel@digriz.org.uk> 7 * (C) 2009 Alexander Clouter <alex@digriz.org.uk>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
@@ -13,22 +13,17 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/smp.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/interrupt.h>
19#include <linux/ctype.h>
20#include <linux/cpufreq.h> 17#include <linux/cpufreq.h>
21#include <linux/sysctl.h>
22#include <linux/types.h>
23#include <linux/fs.h>
24#include <linux/sysfs.h>
25#include <linux/cpu.h> 18#include <linux/cpu.h>
26#include <linux/kmod.h>
27#include <linux/workqueue.h>
28#include <linux/jiffies.h> 19#include <linux/jiffies.h>
29#include <linux/kernel_stat.h> 20#include <linux/kernel_stat.h>
30#include <linux/percpu.h>
31#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/hrtimer.h>
23#include <linux/tick.h>
24#include <linux/ktime.h>
25#include <linux/sched.h>
26
32/* 27/*
33 * dbs is used in this file as a shortform for demandbased switching 28 * dbs is used in this file as a shortform for demandbased switching
34 * It helps to keep variable names smaller, simpler 29 * It helps to keep variable names smaller, simpler
@@ -43,19 +38,31 @@
43 * latency of the processor. The governor will work on any processor with 38 * latency of the processor. The governor will work on any processor with
44 * transition latency <= 10mS, using appropriate sampling 39 * transition latency <= 10mS, using appropriate sampling
45 * rate. 40 * rate.
46 * For CPUs with transition latency > 10mS (mostly drivers 41 * For CPUs with transition latency > 10mS (mostly drivers with CPUFREQ_ETERNAL)
47 * with CPUFREQ_ETERNAL), this governor will not work. 42 * this governor will not work.
48 * All times here are in uS. 43 * All times here are in uS.
49 */ 44 */
50static unsigned int def_sampling_rate; 45static unsigned int def_sampling_rate;
51#define MIN_SAMPLING_RATE_RATIO (2) 46#define MIN_SAMPLING_RATE_RATIO (2)
52/* for correct statistics, we need at least 10 ticks between each measure */ 47/* for correct statistics, we need at least 10 ticks between each measure */
53#define MIN_STAT_SAMPLING_RATE \ 48#define MIN_STAT_SAMPLING_RATE \
54 (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) 49 (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
55#define MIN_SAMPLING_RATE \ 50#define MIN_SAMPLING_RATE \
56 (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) 51 (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
52/* Above MIN_SAMPLING_RATE will vanish with its sysfs file soon
53 * Define the minimal settable sampling rate to the greater of:
54 * - "HW transition latency" * 100 (same as default sampling / 10)
55 * - MIN_STAT_SAMPLING_RATE
56 * To avoid that userspace shoots itself.
57*/
58static unsigned int minimum_sampling_rate(void)
59{
60 return max(def_sampling_rate / 10, MIN_STAT_SAMPLING_RATE);
61}
62
63/* This will also vanish soon with removing sampling_rate_max */
57#define MAX_SAMPLING_RATE (500 * def_sampling_rate) 64#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
58#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 65#define LATENCY_MULTIPLIER (1000)
59#define DEF_SAMPLING_DOWN_FACTOR (1) 66#define DEF_SAMPLING_DOWN_FACTOR (1)
60#define MAX_SAMPLING_DOWN_FACTOR (10) 67#define MAX_SAMPLING_DOWN_FACTOR (10)
61#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) 68#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
@@ -63,12 +70,15 @@ static unsigned int def_sampling_rate;
63static void do_dbs_timer(struct work_struct *work); 70static void do_dbs_timer(struct work_struct *work);
64 71
65struct cpu_dbs_info_s { 72struct cpu_dbs_info_s {
73 cputime64_t prev_cpu_idle;
74 cputime64_t prev_cpu_wall;
75 cputime64_t prev_cpu_nice;
66 struct cpufreq_policy *cur_policy; 76 struct cpufreq_policy *cur_policy;
67 unsigned int prev_cpu_idle_up; 77 struct delayed_work work;
68 unsigned int prev_cpu_idle_down;
69 unsigned int enable;
70 unsigned int down_skip; 78 unsigned int down_skip;
71 unsigned int requested_freq; 79 unsigned int requested_freq;
80 int cpu;
81 unsigned int enable:1;
72}; 82};
73static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); 83static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
74 84
@@ -82,19 +92,18 @@ static unsigned int dbs_enable; /* number of CPUs using this policy */
82 * cpu_hotplug lock should be taken before that. Note that cpu_hotplug lock 92 * cpu_hotplug lock should be taken before that. Note that cpu_hotplug lock
83 * is recursive for the same process. -Venki 93 * is recursive for the same process. -Venki
84 */ 94 */
85static DEFINE_MUTEX (dbs_mutex); 95static DEFINE_MUTEX(dbs_mutex);
86static DECLARE_DELAYED_WORK(dbs_work, do_dbs_timer);
87 96
88struct dbs_tuners { 97static struct workqueue_struct *kconservative_wq;
98
99static struct dbs_tuners {
89 unsigned int sampling_rate; 100 unsigned int sampling_rate;
90 unsigned int sampling_down_factor; 101 unsigned int sampling_down_factor;
91 unsigned int up_threshold; 102 unsigned int up_threshold;
92 unsigned int down_threshold; 103 unsigned int down_threshold;
93 unsigned int ignore_nice; 104 unsigned int ignore_nice;
94 unsigned int freq_step; 105 unsigned int freq_step;
95}; 106} dbs_tuners_ins = {
96
97static struct dbs_tuners dbs_tuners_ins = {
98 .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, 107 .up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
99 .down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD, 108 .down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD,
100 .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, 109 .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR,
@@ -102,18 +111,37 @@ static struct dbs_tuners dbs_tuners_ins = {
102 .freq_step = 5, 111 .freq_step = 5,
103}; 112};
104 113
105static inline unsigned int get_cpu_idle_time(unsigned int cpu) 114static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
115 cputime64_t *wall)
106{ 116{
107 unsigned int add_nice = 0, ret; 117 cputime64_t idle_time;
118 cputime64_t cur_wall_time;
119 cputime64_t busy_time;
108 120
109 if (dbs_tuners_ins.ignore_nice) 121 cur_wall_time = jiffies64_to_cputime64(get_jiffies_64());
110 add_nice = kstat_cpu(cpu).cpustat.nice; 122 busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user,
123 kstat_cpu(cpu).cpustat.system);
124
125 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq);
126 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq);
127 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal);
128 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice);
129
130 idle_time = cputime64_sub(cur_wall_time, busy_time);
131 if (wall)
132 *wall = cur_wall_time;
133
134 return idle_time;
135}
136
137static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)
138{
139 u64 idle_time = get_cpu_idle_time_us(cpu, wall);
111 140
112 ret = kstat_cpu(cpu).cpustat.idle + 141 if (idle_time == -1ULL)
113 kstat_cpu(cpu).cpustat.iowait + 142 return get_cpu_idle_time_jiffy(cpu, wall);
114 add_nice;
115 143
116 return ret; 144 return idle_time;
117} 145}
118 146
119/* keep track of frequency transitions */ 147/* keep track of frequency transitions */
@@ -125,10 +153,21 @@ dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
125 struct cpu_dbs_info_s *this_dbs_info = &per_cpu(cpu_dbs_info, 153 struct cpu_dbs_info_s *this_dbs_info = &per_cpu(cpu_dbs_info,
126 freq->cpu); 154 freq->cpu);
127 155
156 struct cpufreq_policy *policy;
157
128 if (!this_dbs_info->enable) 158 if (!this_dbs_info->enable)
129 return 0; 159 return 0;
130 160
131 this_dbs_info->requested_freq = freq->new; 161 policy = this_dbs_info->cur_policy;
162
163 /*
164 * we only care if our internally tracked freq moves outside
165 * the 'valid' ranges of freqency available to us otherwise
166 * we do not change it
167 */
168 if (this_dbs_info->requested_freq > policy->max
169 || this_dbs_info->requested_freq < policy->min)
170 this_dbs_info->requested_freq = freq->new;
132 171
133 return 0; 172 return 0;
134} 173}
@@ -140,16 +179,31 @@ static struct notifier_block dbs_cpufreq_notifier_block = {
140/************************** sysfs interface ************************/ 179/************************** sysfs interface ************************/
141static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) 180static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf)
142{ 181{
143 return sprintf (buf, "%u\n", MAX_SAMPLING_RATE); 182 static int print_once;
183
184 if (!print_once) {
185 printk(KERN_INFO "CPUFREQ: conservative sampling_rate_max "
186 "sysfs file is deprecated - used by: %s\n",
187 current->comm);
188 print_once = 1;
189 }
190 return sprintf(buf, "%u\n", MAX_SAMPLING_RATE);
144} 191}
145 192
146static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) 193static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf)
147{ 194{
148 return sprintf (buf, "%u\n", MIN_SAMPLING_RATE); 195 static int print_once;
196
197 if (!print_once) {
198 printk(KERN_INFO "CPUFREQ: conservative sampling_rate_max "
199 "sysfs file is deprecated - used by: %s\n", current->comm);
200 print_once = 1;
201 }
202 return sprintf(buf, "%u\n", MIN_SAMPLING_RATE);
149} 203}
150 204
151#define define_one_ro(_name) \ 205#define define_one_ro(_name) \
152static struct freq_attr _name = \ 206static struct freq_attr _name = \
153__ATTR(_name, 0444, show_##_name, NULL) 207__ATTR(_name, 0444, show_##_name, NULL)
154 208
155define_one_ro(sampling_rate_max); 209define_one_ro(sampling_rate_max);
@@ -174,7 +228,8 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
174{ 228{
175 unsigned int input; 229 unsigned int input;
176 int ret; 230 int ret;
177 ret = sscanf (buf, "%u", &input); 231 ret = sscanf(buf, "%u", &input);
232
178 if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1) 233 if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1)
179 return -EINVAL; 234 return -EINVAL;
180 235
@@ -190,15 +245,13 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
190{ 245{
191 unsigned int input; 246 unsigned int input;
192 int ret; 247 int ret;
193 ret = sscanf (buf, "%u", &input); 248 ret = sscanf(buf, "%u", &input);
194 249
195 mutex_lock(&dbs_mutex); 250 if (ret != 1)
196 if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) {
197 mutex_unlock(&dbs_mutex);
198 return -EINVAL; 251 return -EINVAL;
199 }
200 252
201 dbs_tuners_ins.sampling_rate = input; 253 mutex_lock(&dbs_mutex);
254 dbs_tuners_ins.sampling_rate = max(input, minimum_sampling_rate());
202 mutex_unlock(&dbs_mutex); 255 mutex_unlock(&dbs_mutex);
203 256
204 return count; 257 return count;
@@ -209,10 +262,11 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
209{ 262{
210 unsigned int input; 263 unsigned int input;
211 int ret; 264 int ret;
212 ret = sscanf (buf, "%u", &input); 265 ret = sscanf(buf, "%u", &input);
213 266
214 mutex_lock(&dbs_mutex); 267 mutex_lock(&dbs_mutex);
215 if (ret != 1 || input > 100 || input <= dbs_tuners_ins.down_threshold) { 268 if (ret != 1 || input > 100 ||
269 input <= dbs_tuners_ins.down_threshold) {
216 mutex_unlock(&dbs_mutex); 270 mutex_unlock(&dbs_mutex);
217 return -EINVAL; 271 return -EINVAL;
218 } 272 }
@@ -228,10 +282,12 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused,
228{ 282{
229 unsigned int input; 283 unsigned int input;
230 int ret; 284 int ret;
231 ret = sscanf (buf, "%u", &input); 285 ret = sscanf(buf, "%u", &input);
232 286
233 mutex_lock(&dbs_mutex); 287 mutex_lock(&dbs_mutex);
234 if (ret != 1 || input > 100 || input >= dbs_tuners_ins.up_threshold) { 288 /* cannot be lower than 11 otherwise freq will not fall */
289 if (ret != 1 || input < 11 || input > 100 ||
290 input >= dbs_tuners_ins.up_threshold) {
235 mutex_unlock(&dbs_mutex); 291 mutex_unlock(&dbs_mutex);
236 return -EINVAL; 292 return -EINVAL;
237 } 293 }
@@ -264,12 +320,14 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
264 } 320 }
265 dbs_tuners_ins.ignore_nice = input; 321 dbs_tuners_ins.ignore_nice = input;
266 322
267 /* we need to re-evaluate prev_cpu_idle_up and prev_cpu_idle_down */ 323 /* we need to re-evaluate prev_cpu_idle */
268 for_each_online_cpu(j) { 324 for_each_online_cpu(j) {
269 struct cpu_dbs_info_s *j_dbs_info; 325 struct cpu_dbs_info_s *dbs_info;
270 j_dbs_info = &per_cpu(cpu_dbs_info, j); 326 dbs_info = &per_cpu(cpu_dbs_info, j);
271 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); 327 dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
272 j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; 328 &dbs_info->prev_cpu_wall);
329 if (dbs_tuners_ins.ignore_nice)
330 dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice;
273 } 331 }
274 mutex_unlock(&dbs_mutex); 332 mutex_unlock(&dbs_mutex);
275 333
@@ -281,7 +339,6 @@ static ssize_t store_freq_step(struct cpufreq_policy *policy,
281{ 339{
282 unsigned int input; 340 unsigned int input;
283 int ret; 341 int ret;
284
285 ret = sscanf(buf, "%u", &input); 342 ret = sscanf(buf, "%u", &input);
286 343
287 if (ret != 1) 344 if (ret != 1)
@@ -310,7 +367,7 @@ define_one_rw(down_threshold);
310define_one_rw(ignore_nice_load); 367define_one_rw(ignore_nice_load);
311define_one_rw(freq_step); 368define_one_rw(freq_step);
312 369
313static struct attribute * dbs_attributes[] = { 370static struct attribute *dbs_attributes[] = {
314 &sampling_rate_max.attr, 371 &sampling_rate_max.attr,
315 &sampling_rate_min.attr, 372 &sampling_rate_min.attr,
316 &sampling_rate.attr, 373 &sampling_rate.attr,
@@ -329,55 +386,78 @@ static struct attribute_group dbs_attr_group = {
329 386
330/************************** sysfs end ************************/ 387/************************** sysfs end ************************/
331 388
332static void dbs_check_cpu(int cpu) 389static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
333{ 390{
334 unsigned int idle_ticks, up_idle_ticks, down_idle_ticks; 391 unsigned int load = 0;
335 unsigned int tmp_idle_ticks, total_idle_ticks;
336 unsigned int freq_target; 392 unsigned int freq_target;
337 unsigned int freq_down_sampling_rate;
338 struct cpu_dbs_info_s *this_dbs_info = &per_cpu(cpu_dbs_info, cpu);
339 struct cpufreq_policy *policy;
340 393
341 if (!this_dbs_info->enable) 394 struct cpufreq_policy *policy;
342 return; 395 unsigned int j;
343 396
344 policy = this_dbs_info->cur_policy; 397 policy = this_dbs_info->cur_policy;
345 398
346 /* 399 /*
347 * The default safe range is 20% to 80% 400 * Every sampling_rate, we check, if current idle time is less
348 * Every sampling_rate, we check 401 * than 20% (default), then we try to increase frequency
349 * - If current idle time is less than 20%, then we try to 402 * Every sampling_rate*sampling_down_factor, we check, if current
350 * increase frequency 403 * idle time is more than 80%, then we try to decrease frequency
351 * Every sampling_rate*sampling_down_factor, we check
352 * - If current idle time is more than 80%, then we try to
353 * decrease frequency
354 * 404 *
355 * Any frequency increase takes it to the maximum frequency. 405 * Any frequency increase takes it to the maximum frequency.
356 * Frequency reduction happens at minimum steps of 406 * Frequency reduction happens at minimum steps of
357 * 5% (default) of max_frequency 407 * 5% (default) of maximum frequency
358 */ 408 */
359 409
360 /* Check for frequency increase */ 410 /* Get Absolute Load */
361 idle_ticks = UINT_MAX; 411 for_each_cpu(j, policy->cpus) {
412 struct cpu_dbs_info_s *j_dbs_info;
413 cputime64_t cur_wall_time, cur_idle_time;
414 unsigned int idle_time, wall_time;
362 415
363 /* Check for frequency increase */ 416 j_dbs_info = &per_cpu(cpu_dbs_info, j);
364 total_idle_ticks = get_cpu_idle_time(cpu); 417
365 tmp_idle_ticks = total_idle_ticks - 418 cur_idle_time = get_cpu_idle_time(j, &cur_wall_time);
366 this_dbs_info->prev_cpu_idle_up; 419
367 this_dbs_info->prev_cpu_idle_up = total_idle_ticks; 420 wall_time = (unsigned int) cputime64_sub(cur_wall_time,
421 j_dbs_info->prev_cpu_wall);
422 j_dbs_info->prev_cpu_wall = cur_wall_time;
423
424 idle_time = (unsigned int) cputime64_sub(cur_idle_time,
425 j_dbs_info->prev_cpu_idle);
426 j_dbs_info->prev_cpu_idle = cur_idle_time;
427
428 if (dbs_tuners_ins.ignore_nice) {
429 cputime64_t cur_nice;
430 unsigned long cur_nice_jiffies;
431
432 cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice,
433 j_dbs_info->prev_cpu_nice);
434 /*
435 * Assumption: nice time between sampling periods will
436 * be less than 2^32 jiffies for 32 bit sys
437 */
438 cur_nice_jiffies = (unsigned long)
439 cputime64_to_jiffies64(cur_nice);
368 440
369 if (tmp_idle_ticks < idle_ticks) 441 j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice;
370 idle_ticks = tmp_idle_ticks; 442 idle_time += jiffies_to_usecs(cur_nice_jiffies);
443 }
444
445 if (unlikely(!wall_time || wall_time < idle_time))
446 continue;
447
448 load = 100 * (wall_time - idle_time) / wall_time;
449 }
371 450
372 /* Scale idle ticks by 100 and compare with up and down ticks */ 451 /*
373 idle_ticks *= 100; 452 * break out if we 'cannot' reduce the speed as the user might
374 up_idle_ticks = (100 - dbs_tuners_ins.up_threshold) * 453 * want freq_step to be zero
375 usecs_to_jiffies(dbs_tuners_ins.sampling_rate); 454 */
455 if (dbs_tuners_ins.freq_step == 0)
456 return;
376 457
377 if (idle_ticks < up_idle_ticks) { 458 /* Check for frequency increase */
459 if (load > dbs_tuners_ins.up_threshold) {
378 this_dbs_info->down_skip = 0; 460 this_dbs_info->down_skip = 0;
379 this_dbs_info->prev_cpu_idle_down =
380 this_dbs_info->prev_cpu_idle_up;
381 461
382 /* if we are already at full speed then break out early */ 462 /* if we are already at full speed then break out early */
383 if (this_dbs_info->requested_freq == policy->max) 463 if (this_dbs_info->requested_freq == policy->max)
@@ -398,49 +478,24 @@ static void dbs_check_cpu(int cpu)
398 return; 478 return;
399 } 479 }
400 480
401 /* Check for frequency decrease */ 481 /*
402 this_dbs_info->down_skip++; 482 * The optimal frequency is the frequency that is the lowest that
403 if (this_dbs_info->down_skip < dbs_tuners_ins.sampling_down_factor) 483 * can support the current CPU usage without triggering the up
404 return; 484 * policy. To be safe, we focus 10 points under the threshold.
405 485 */
406 /* Check for frequency decrease */ 486 if (load < (dbs_tuners_ins.down_threshold - 10)) {
407 total_idle_ticks = this_dbs_info->prev_cpu_idle_up;
408 tmp_idle_ticks = total_idle_ticks -
409 this_dbs_info->prev_cpu_idle_down;
410 this_dbs_info->prev_cpu_idle_down = total_idle_ticks;
411
412 if (tmp_idle_ticks < idle_ticks)
413 idle_ticks = tmp_idle_ticks;
414
415 /* Scale idle ticks by 100 and compare with up and down ticks */
416 idle_ticks *= 100;
417 this_dbs_info->down_skip = 0;
418
419 freq_down_sampling_rate = dbs_tuners_ins.sampling_rate *
420 dbs_tuners_ins.sampling_down_factor;
421 down_idle_ticks = (100 - dbs_tuners_ins.down_threshold) *
422 usecs_to_jiffies(freq_down_sampling_rate);
423
424 if (idle_ticks > down_idle_ticks) {
425 /*
426 * if we are already at the lowest speed then break out early
427 * or if we 'cannot' reduce the speed as the user might want
428 * freq_target to be zero
429 */
430 if (this_dbs_info->requested_freq == policy->min
431 || dbs_tuners_ins.freq_step == 0)
432 return;
433
434 freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100; 487 freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100;
435 488
436 /* max freq cannot be less than 100. But who knows.... */
437 if (unlikely(freq_target == 0))
438 freq_target = 5;
439
440 this_dbs_info->requested_freq -= freq_target; 489 this_dbs_info->requested_freq -= freq_target;
441 if (this_dbs_info->requested_freq < policy->min) 490 if (this_dbs_info->requested_freq < policy->min)
442 this_dbs_info->requested_freq = policy->min; 491 this_dbs_info->requested_freq = policy->min;
443 492
493 /*
494 * if we cannot reduce the frequency anymore, break out early
495 */
496 if (policy->cur == policy->min)
497 return;
498
444 __cpufreq_driver_target(policy, this_dbs_info->requested_freq, 499 __cpufreq_driver_target(policy, this_dbs_info->requested_freq,
445 CPUFREQ_RELATION_H); 500 CPUFREQ_RELATION_H);
446 return; 501 return;
@@ -449,27 +504,45 @@ static void dbs_check_cpu(int cpu)
449 504
450static void do_dbs_timer(struct work_struct *work) 505static void do_dbs_timer(struct work_struct *work)
451{ 506{
452 int i; 507 struct cpu_dbs_info_s *dbs_info =
453 mutex_lock(&dbs_mutex); 508 container_of(work, struct cpu_dbs_info_s, work.work);
454 for_each_online_cpu(i) 509 unsigned int cpu = dbs_info->cpu;
455 dbs_check_cpu(i); 510
456 schedule_delayed_work(&dbs_work, 511 /* We want all CPUs to do sampling nearly on same jiffy */
457 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 512 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
458 mutex_unlock(&dbs_mutex); 513
514 delay -= jiffies % delay;
515
516 if (lock_policy_rwsem_write(cpu) < 0)
517 return;
518
519 if (!dbs_info->enable) {
520 unlock_policy_rwsem_write(cpu);
521 return;
522 }
523
524 dbs_check_cpu(dbs_info);
525
526 queue_delayed_work_on(cpu, kconservative_wq, &dbs_info->work, delay);
527 unlock_policy_rwsem_write(cpu);
459} 528}
460 529
461static inline void dbs_timer_init(void) 530static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
462{ 531{
463 init_timer_deferrable(&dbs_work.timer); 532 /* We want all CPUs to do sampling nearly on same jiffy */
464 schedule_delayed_work(&dbs_work, 533 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
465 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 534 delay -= jiffies % delay;
466 return; 535
536 dbs_info->enable = 1;
537 INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);
538 queue_delayed_work_on(dbs_info->cpu, kconservative_wq, &dbs_info->work,
539 delay);
467} 540}
468 541
469static inline void dbs_timer_exit(void) 542static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
470{ 543{
471 cancel_delayed_work(&dbs_work); 544 dbs_info->enable = 0;
472 return; 545 cancel_delayed_work(&dbs_info->work);
473} 546}
474 547
475static int cpufreq_governor_dbs(struct cpufreq_policy *policy, 548static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
@@ -503,11 +576,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
503 j_dbs_info = &per_cpu(cpu_dbs_info, j); 576 j_dbs_info = &per_cpu(cpu_dbs_info, j);
504 j_dbs_info->cur_policy = policy; 577 j_dbs_info->cur_policy = policy;
505 578
506 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(cpu); 579 j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
507 j_dbs_info->prev_cpu_idle_down 580 &j_dbs_info->prev_cpu_wall);
508 = j_dbs_info->prev_cpu_idle_up; 581 if (dbs_tuners_ins.ignore_nice) {
582 j_dbs_info->prev_cpu_nice =
583 kstat_cpu(j).cpustat.nice;
584 }
509 } 585 }
510 this_dbs_info->enable = 1;
511 this_dbs_info->down_skip = 0; 586 this_dbs_info->down_skip = 0;
512 this_dbs_info->requested_freq = policy->cur; 587 this_dbs_info->requested_freq = policy->cur;
513 588
@@ -523,38 +598,36 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
523 if (latency == 0) 598 if (latency == 0)
524 latency = 1; 599 latency = 1;
525 600
526 def_sampling_rate = 10 * latency * 601 def_sampling_rate =
527 DEF_SAMPLING_RATE_LATENCY_MULTIPLIER; 602 max(latency * LATENCY_MULTIPLIER,
528 603 MIN_STAT_SAMPLING_RATE);
529 if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
530 def_sampling_rate = MIN_STAT_SAMPLING_RATE;
531 604
532 dbs_tuners_ins.sampling_rate = def_sampling_rate; 605 dbs_tuners_ins.sampling_rate = def_sampling_rate;
533 606
534 dbs_timer_init();
535 cpufreq_register_notifier( 607 cpufreq_register_notifier(
536 &dbs_cpufreq_notifier_block, 608 &dbs_cpufreq_notifier_block,
537 CPUFREQ_TRANSITION_NOTIFIER); 609 CPUFREQ_TRANSITION_NOTIFIER);
538 } 610 }
611 dbs_timer_init(this_dbs_info);
539 612
540 mutex_unlock(&dbs_mutex); 613 mutex_unlock(&dbs_mutex);
614
541 break; 615 break;
542 616
543 case CPUFREQ_GOV_STOP: 617 case CPUFREQ_GOV_STOP:
544 mutex_lock(&dbs_mutex); 618 mutex_lock(&dbs_mutex);
545 this_dbs_info->enable = 0; 619 dbs_timer_exit(this_dbs_info);
546 sysfs_remove_group(&policy->kobj, &dbs_attr_group); 620 sysfs_remove_group(&policy->kobj, &dbs_attr_group);
547 dbs_enable--; 621 dbs_enable--;
622
548 /* 623 /*
549 * Stop the timerschedule work, when this governor 624 * Stop the timerschedule work, when this governor
550 * is used for first time 625 * is used for first time
551 */ 626 */
552 if (dbs_enable == 0) { 627 if (dbs_enable == 0)
553 dbs_timer_exit();
554 cpufreq_unregister_notifier( 628 cpufreq_unregister_notifier(
555 &dbs_cpufreq_notifier_block, 629 &dbs_cpufreq_notifier_block,
556 CPUFREQ_TRANSITION_NOTIFIER); 630 CPUFREQ_TRANSITION_NOTIFIER);
557 }
558 631
559 mutex_unlock(&dbs_mutex); 632 mutex_unlock(&dbs_mutex);
560 633
@@ -571,6 +644,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
571 this_dbs_info->cur_policy, 644 this_dbs_info->cur_policy,
572 policy->min, CPUFREQ_RELATION_L); 645 policy->min, CPUFREQ_RELATION_L);
573 mutex_unlock(&dbs_mutex); 646 mutex_unlock(&dbs_mutex);
647
574 break; 648 break;
575 } 649 }
576 return 0; 650 return 0;
@@ -588,23 +662,33 @@ struct cpufreq_governor cpufreq_gov_conservative = {
588 662
589static int __init cpufreq_gov_dbs_init(void) 663static int __init cpufreq_gov_dbs_init(void)
590{ 664{
591 return cpufreq_register_governor(&cpufreq_gov_conservative); 665 int err;
666
667 kconservative_wq = create_workqueue("kconservative");
668 if (!kconservative_wq) {
669 printk(KERN_ERR "Creation of kconservative failed\n");
670 return -EFAULT;
671 }
672
673 err = cpufreq_register_governor(&cpufreq_gov_conservative);
674 if (err)
675 destroy_workqueue(kconservative_wq);
676
677 return err;
592} 678}
593 679
594static void __exit cpufreq_gov_dbs_exit(void) 680static void __exit cpufreq_gov_dbs_exit(void)
595{ 681{
596 /* Make sure that the scheduled work is indeed not running */
597 flush_scheduled_work();
598
599 cpufreq_unregister_governor(&cpufreq_gov_conservative); 682 cpufreq_unregister_governor(&cpufreq_gov_conservative);
683 destroy_workqueue(kconservative_wq);
600} 684}
601 685
602 686
603MODULE_AUTHOR ("Alexander Clouter <alex-kernel@digriz.org.uk>"); 687MODULE_AUTHOR("Alexander Clouter <alex@digriz.org.uk>");
604MODULE_DESCRIPTION ("'cpufreq_conservative' - A dynamic cpufreq governor for " 688MODULE_DESCRIPTION("'cpufreq_conservative' - A dynamic cpufreq governor for "
605 "Low Latency Frequency Transition capable processors " 689 "Low Latency Frequency Transition capable processors "
606 "optimised for use in a battery environment"); 690 "optimised for use in a battery environment");
607MODULE_LICENSE ("GPL"); 691MODULE_LICENSE("GPL");
608 692
609#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE 693#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
610fs_initcall(cpufreq_gov_dbs_init); 694fs_initcall(cpufreq_gov_dbs_init);
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 6f45b1658a67..338f428a15b7 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -21,6 +21,7 @@
21#include <linux/hrtimer.h> 21#include <linux/hrtimer.h>
22#include <linux/tick.h> 22#include <linux/tick.h>
23#include <linux/ktime.h> 23#include <linux/ktime.h>
24#include <linux/sched.h>
24 25
25/* 26/*
26 * dbs is used in this file as a shortform for demandbased switching 27 * dbs is used in this file as a shortform for demandbased switching
@@ -51,8 +52,20 @@ static unsigned int def_sampling_rate;
51 (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) 52 (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
52#define MIN_SAMPLING_RATE \ 53#define MIN_SAMPLING_RATE \
53 (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) 54 (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
55/* Above MIN_SAMPLING_RATE will vanish with its sysfs file soon
56 * Define the minimal settable sampling rate to the greater of:
57 * - "HW transition latency" * 100 (same as default sampling / 10)
58 * - MIN_STAT_SAMPLING_RATE
59 * To avoid that userspace shoots itself.
60*/
61static unsigned int minimum_sampling_rate(void)
62{
63 return max(def_sampling_rate / 10, MIN_STAT_SAMPLING_RATE);
64}
65
66/* This will also vanish soon with removing sampling_rate_max */
54#define MAX_SAMPLING_RATE (500 * def_sampling_rate) 67#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
55#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 68#define LATENCY_MULTIPLIER (1000)
56#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) 69#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
57 70
58static void do_dbs_timer(struct work_struct *work); 71static void do_dbs_timer(struct work_struct *work);
@@ -65,14 +78,14 @@ struct cpu_dbs_info_s {
65 cputime64_t prev_cpu_wall; 78 cputime64_t prev_cpu_wall;
66 cputime64_t prev_cpu_nice; 79 cputime64_t prev_cpu_nice;
67 struct cpufreq_policy *cur_policy; 80 struct cpufreq_policy *cur_policy;
68 struct delayed_work work; 81 struct delayed_work work;
69 struct cpufreq_frequency_table *freq_table; 82 struct cpufreq_frequency_table *freq_table;
70 unsigned int freq_lo; 83 unsigned int freq_lo;
71 unsigned int freq_lo_jiffies; 84 unsigned int freq_lo_jiffies;
72 unsigned int freq_hi_jiffies; 85 unsigned int freq_hi_jiffies;
73 int cpu; 86 int cpu;
74 unsigned int enable:1, 87 unsigned int enable:1,
75 sample_type:1; 88 sample_type:1;
76}; 89};
77static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); 90static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
78 91
@@ -203,12 +216,28 @@ static void ondemand_powersave_bias_init(void)
203/************************** sysfs interface ************************/ 216/************************** sysfs interface ************************/
204static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) 217static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf)
205{ 218{
206 return sprintf (buf, "%u\n", MAX_SAMPLING_RATE); 219 static int print_once;
220
221 if (!print_once) {
222 printk(KERN_INFO "CPUFREQ: ondemand sampling_rate_max "
223 "sysfs file is deprecated - used by: %s\n",
224 current->comm);
225 print_once = 1;
226 }
227 return sprintf(buf, "%u\n", MAX_SAMPLING_RATE);
207} 228}
208 229
209static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) 230static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf)
210{ 231{
211 return sprintf (buf, "%u\n", MIN_SAMPLING_RATE); 232 static int print_once;
233
234 if (!print_once) {
235 printk(KERN_INFO "CPUFREQ: ondemand sampling_rate_min "
236 "sysfs file is deprecated - used by: %s\n",
237 current->comm);
238 print_once = 1;
239 }
240 return sprintf(buf, "%u\n", MIN_SAMPLING_RATE);
212} 241}
213 242
214#define define_one_ro(_name) \ 243#define define_one_ro(_name) \
@@ -238,13 +267,11 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
238 ret = sscanf(buf, "%u", &input); 267 ret = sscanf(buf, "%u", &input);
239 268
240 mutex_lock(&dbs_mutex); 269 mutex_lock(&dbs_mutex);
241 if (ret != 1 || input > MAX_SAMPLING_RATE 270 if (ret != 1) {
242 || input < MIN_SAMPLING_RATE) {
243 mutex_unlock(&dbs_mutex); 271 mutex_unlock(&dbs_mutex);
244 return -EINVAL; 272 return -EINVAL;
245 } 273 }
246 274 dbs_tuners_ins.sampling_rate = max(input, minimum_sampling_rate());
247 dbs_tuners_ins.sampling_rate = input;
248 mutex_unlock(&dbs_mutex); 275 mutex_unlock(&dbs_mutex);
249 276
250 return count; 277 return count;
@@ -279,14 +306,14 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
279 unsigned int j; 306 unsigned int j;
280 307
281 ret = sscanf(buf, "%u", &input); 308 ret = sscanf(buf, "%u", &input);
282 if ( ret != 1 ) 309 if (ret != 1)
283 return -EINVAL; 310 return -EINVAL;
284 311
285 if ( input > 1 ) 312 if (input > 1)
286 input = 1; 313 input = 1;
287 314
288 mutex_lock(&dbs_mutex); 315 mutex_lock(&dbs_mutex);
289 if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ 316 if (input == dbs_tuners_ins.ignore_nice) { /* nothing to do */
290 mutex_unlock(&dbs_mutex); 317 mutex_unlock(&dbs_mutex);
291 return count; 318 return count;
292 } 319 }
@@ -337,7 +364,7 @@ define_one_rw(up_threshold);
337define_one_rw(ignore_nice_load); 364define_one_rw(ignore_nice_load);
338define_one_rw(powersave_bias); 365define_one_rw(powersave_bias);
339 366
340static struct attribute * dbs_attributes[] = { 367static struct attribute *dbs_attributes[] = {
341 &sampling_rate_max.attr, 368 &sampling_rate_max.attr,
342 &sampling_rate_min.attr, 369 &sampling_rate_min.attr,
343 &sampling_rate.attr, 370 &sampling_rate.attr,
@@ -512,8 +539,7 @@ static void do_dbs_timer(struct work_struct *work)
512 } 539 }
513 } else { 540 } else {
514 __cpufreq_driver_target(dbs_info->cur_policy, 541 __cpufreq_driver_target(dbs_info->cur_policy,
515 dbs_info->freq_lo, 542 dbs_info->freq_lo, CPUFREQ_RELATION_H);
516 CPUFREQ_RELATION_H);
517 } 543 }
518 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); 544 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay);
519 unlock_policy_rwsem_write(cpu); 545 unlock_policy_rwsem_write(cpu);
@@ -530,7 +556,7 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
530 dbs_info->sample_type = DBS_NORMAL_SAMPLE; 556 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
531 INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer); 557 INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);
532 queue_delayed_work_on(dbs_info->cpu, kondemand_wq, &dbs_info->work, 558 queue_delayed_work_on(dbs_info->cpu, kondemand_wq, &dbs_info->work,
533 delay); 559 delay);
534} 560}
535 561
536static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) 562static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
@@ -591,11 +617,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
591 if (latency == 0) 617 if (latency == 0)
592 latency = 1; 618 latency = 1;
593 619
594 def_sampling_rate = latency * 620 def_sampling_rate =
595 DEF_SAMPLING_RATE_LATENCY_MULTIPLIER; 621 max(latency * LATENCY_MULTIPLIER,
596 622 MIN_STAT_SAMPLING_RATE);
597 if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
598 def_sampling_rate = MIN_STAT_SAMPLING_RATE;
599 623
600 dbs_tuners_ins.sampling_rate = def_sampling_rate; 624 dbs_tuners_ins.sampling_rate = def_sampling_rate;
601 } 625 }
@@ -617,12 +641,10 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
617 mutex_lock(&dbs_mutex); 641 mutex_lock(&dbs_mutex);
618 if (policy->max < this_dbs_info->cur_policy->cur) 642 if (policy->max < this_dbs_info->cur_policy->cur)
619 __cpufreq_driver_target(this_dbs_info->cur_policy, 643 __cpufreq_driver_target(this_dbs_info->cur_policy,
620 policy->max, 644 policy->max, CPUFREQ_RELATION_H);
621 CPUFREQ_RELATION_H);
622 else if (policy->min > this_dbs_info->cur_policy->cur) 645 else if (policy->min > this_dbs_info->cur_policy->cur)
623 __cpufreq_driver_target(this_dbs_info->cur_policy, 646 __cpufreq_driver_target(this_dbs_info->cur_policy,
624 policy->min, 647 policy->min, CPUFREQ_RELATION_L);
625 CPUFREQ_RELATION_L);
626 mutex_unlock(&dbs_mutex); 648 mutex_unlock(&dbs_mutex);
627 break; 649 break;
628 } 650 }
@@ -677,7 +699,7 @@ static void __exit cpufreq_gov_dbs_exit(void)
677MODULE_AUTHOR("Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>"); 699MODULE_AUTHOR("Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>");
678MODULE_AUTHOR("Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>"); 700MODULE_AUTHOR("Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>");
679MODULE_DESCRIPTION("'cpufreq_ondemand' - A dynamic cpufreq governor for " 701MODULE_DESCRIPTION("'cpufreq_ondemand' - A dynamic cpufreq governor for "
680 "Low Latency Frequency Transition capable processors"); 702 "Low Latency Frequency Transition capable processors");
681MODULE_LICENSE("GPL"); 703MODULE_LICENSE("GPL");
682 704
683#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND 705#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index c0ff97d375d7..5a62d678dd19 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -2,7 +2,7 @@
2 * drivers/cpufreq/cpufreq_stats.c 2 * drivers/cpufreq/cpufreq_stats.c
3 * 3 *
4 * Copyright (C) 2003-2004 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>. 4 * Copyright (C) 2003-2004 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>.
5 * (C) 2004 Zou Nan hai <nanhai.zou@intel.com>. 5 * (C) 2004 Zou Nan hai <nanhai.zou@intel.com>.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -23,7 +23,7 @@
23 23
24static spinlock_t cpufreq_stats_lock; 24static spinlock_t cpufreq_stats_lock;
25 25
26#define CPUFREQ_STATDEVICE_ATTR(_name,_mode,_show) \ 26#define CPUFREQ_STATDEVICE_ATTR(_name, _mode, _show) \
27static struct freq_attr _attr_##_name = {\ 27static struct freq_attr _attr_##_name = {\
28 .attr = {.name = __stringify(_name), .mode = _mode, }, \ 28 .attr = {.name = __stringify(_name), .mode = _mode, }, \
29 .show = _show,\ 29 .show = _show,\
@@ -50,8 +50,7 @@ struct cpufreq_stats_attribute {
50 ssize_t(*show) (struct cpufreq_stats *, char *); 50 ssize_t(*show) (struct cpufreq_stats *, char *);
51}; 51};
52 52
53static int 53static int cpufreq_stats_update(unsigned int cpu)
54cpufreq_stats_update (unsigned int cpu)
55{ 54{
56 struct cpufreq_stats *stat; 55 struct cpufreq_stats *stat;
57 unsigned long long cur_time; 56 unsigned long long cur_time;
@@ -68,8 +67,7 @@ cpufreq_stats_update (unsigned int cpu)
68 return 0; 67 return 0;
69} 68}
70 69
71static ssize_t 70static ssize_t show_total_trans(struct cpufreq_policy *policy, char *buf)
72show_total_trans(struct cpufreq_policy *policy, char *buf)
73{ 71{
74 struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); 72 struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu);
75 if (!stat) 73 if (!stat)
@@ -78,8 +76,7 @@ show_total_trans(struct cpufreq_policy *policy, char *buf)
78 per_cpu(cpufreq_stats_table, stat->cpu)->total_trans); 76 per_cpu(cpufreq_stats_table, stat->cpu)->total_trans);
79} 77}
80 78
81static ssize_t 79static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
82show_time_in_state(struct cpufreq_policy *policy, char *buf)
83{ 80{
84 ssize_t len = 0; 81 ssize_t len = 0;
85 int i; 82 int i;
@@ -89,14 +86,14 @@ show_time_in_state(struct cpufreq_policy *policy, char *buf)
89 cpufreq_stats_update(stat->cpu); 86 cpufreq_stats_update(stat->cpu);
90 for (i = 0; i < stat->state_num; i++) { 87 for (i = 0; i < stat->state_num; i++) {
91 len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], 88 len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i],
92 (unsigned long long)cputime64_to_clock_t(stat->time_in_state[i])); 89 (unsigned long long)
90 cputime64_to_clock_t(stat->time_in_state[i]));
93 } 91 }
94 return len; 92 return len;
95} 93}
96 94
97#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 95#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
98static ssize_t 96static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
99show_trans_table(struct cpufreq_policy *policy, char *buf)
100{ 97{
101 ssize_t len = 0; 98 ssize_t len = 0;
102 int i, j; 99 int i, j;
@@ -139,11 +136,11 @@ show_trans_table(struct cpufreq_policy *policy, char *buf)
139 return PAGE_SIZE; 136 return PAGE_SIZE;
140 return len; 137 return len;
141} 138}
142CPUFREQ_STATDEVICE_ATTR(trans_table,0444,show_trans_table); 139CPUFREQ_STATDEVICE_ATTR(trans_table, 0444, show_trans_table);
143#endif 140#endif
144 141
145CPUFREQ_STATDEVICE_ATTR(total_trans,0444,show_total_trans); 142CPUFREQ_STATDEVICE_ATTR(total_trans, 0444, show_total_trans);
146CPUFREQ_STATDEVICE_ATTR(time_in_state,0444,show_time_in_state); 143CPUFREQ_STATDEVICE_ATTR(time_in_state, 0444, show_time_in_state);
147 144
148static struct attribute *default_attrs[] = { 145static struct attribute *default_attrs[] = {
149 &_attr_total_trans.attr, 146 &_attr_total_trans.attr,
@@ -158,8 +155,7 @@ static struct attribute_group stats_attr_group = {
158 .name = "stats" 155 .name = "stats"
159}; 156};
160 157
161static int 158static int freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq)
162freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq)
163{ 159{
164 int index; 160 int index;
165 for (index = 0; index < stat->max_state; index++) 161 for (index = 0; index < stat->max_state; index++)
@@ -183,8 +179,7 @@ static void cpufreq_stats_free_table(unsigned int cpu)
183 cpufreq_cpu_put(policy); 179 cpufreq_cpu_put(policy);
184} 180}
185 181
186static int 182static int cpufreq_stats_create_table(struct cpufreq_policy *policy,
187cpufreq_stats_create_table (struct cpufreq_policy *policy,
188 struct cpufreq_frequency_table *table) 183 struct cpufreq_frequency_table *table)
189{ 184{
190 unsigned int i, j, count = 0, ret = 0; 185 unsigned int i, j, count = 0, ret = 0;
@@ -194,7 +189,8 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
194 unsigned int cpu = policy->cpu; 189 unsigned int cpu = policy->cpu;
195 if (per_cpu(cpufreq_stats_table, cpu)) 190 if (per_cpu(cpufreq_stats_table, cpu))
196 return -EBUSY; 191 return -EBUSY;
197 if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL) 192 stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL);
193 if ((stat) == NULL)
198 return -ENOMEM; 194 return -ENOMEM;
199 195
200 data = cpufreq_cpu_get(cpu); 196 data = cpufreq_cpu_get(cpu);
@@ -203,13 +199,14 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
203 goto error_get_fail; 199 goto error_get_fail;
204 } 200 }
205 201
206 if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group))) 202 ret = sysfs_create_group(&data->kobj, &stats_attr_group);
203 if (ret)
207 goto error_out; 204 goto error_out;
208 205
209 stat->cpu = cpu; 206 stat->cpu = cpu;
210 per_cpu(cpufreq_stats_table, cpu) = stat; 207 per_cpu(cpufreq_stats_table, cpu) = stat;
211 208
212 for (i=0; table[i].frequency != CPUFREQ_TABLE_END; i++) { 209 for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
213 unsigned int freq = table[i].frequency; 210 unsigned int freq = table[i].frequency;
214 if (freq == CPUFREQ_ENTRY_INVALID) 211 if (freq == CPUFREQ_ENTRY_INVALID)
215 continue; 212 continue;
@@ -255,9 +252,8 @@ error_get_fail:
255 return ret; 252 return ret;
256} 253}
257 254
258static int 255static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
259cpufreq_stat_notifier_policy (struct notifier_block *nb, unsigned long val, 256 unsigned long val, void *data)
260 void *data)
261{ 257{
262 int ret; 258 int ret;
263 struct cpufreq_policy *policy = data; 259 struct cpufreq_policy *policy = data;
@@ -268,14 +264,14 @@ cpufreq_stat_notifier_policy (struct notifier_block *nb, unsigned long val,
268 table = cpufreq_frequency_get_table(cpu); 264 table = cpufreq_frequency_get_table(cpu);
269 if (!table) 265 if (!table)
270 return 0; 266 return 0;
271 if ((ret = cpufreq_stats_create_table(policy, table))) 267 ret = cpufreq_stats_create_table(policy, table);
268 if (ret)
272 return ret; 269 return ret;
273 return 0; 270 return 0;
274} 271}
275 272
276static int 273static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
277cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val, 274 unsigned long val, void *data)
278 void *data)
279{ 275{
280 struct cpufreq_freqs *freq = data; 276 struct cpufreq_freqs *freq = data;
281 struct cpufreq_stats *stat; 277 struct cpufreq_stats *stat;
@@ -340,19 +336,20 @@ static struct notifier_block notifier_trans_block = {
340 .notifier_call = cpufreq_stat_notifier_trans 336 .notifier_call = cpufreq_stat_notifier_trans
341}; 337};
342 338
343static int 339static int __init cpufreq_stats_init(void)
344__init cpufreq_stats_init(void)
345{ 340{
346 int ret; 341 int ret;
347 unsigned int cpu; 342 unsigned int cpu;
348 343
349 spin_lock_init(&cpufreq_stats_lock); 344 spin_lock_init(&cpufreq_stats_lock);
350 if ((ret = cpufreq_register_notifier(&notifier_policy_block, 345 ret = cpufreq_register_notifier(&notifier_policy_block,
351 CPUFREQ_POLICY_NOTIFIER))) 346 CPUFREQ_POLICY_NOTIFIER);
347 if (ret)
352 return ret; 348 return ret;
353 349
354 if ((ret = cpufreq_register_notifier(&notifier_trans_block, 350 ret = cpufreq_register_notifier(&notifier_trans_block,
355 CPUFREQ_TRANSITION_NOTIFIER))) { 351 CPUFREQ_TRANSITION_NOTIFIER);
352 if (ret) {
356 cpufreq_unregister_notifier(&notifier_policy_block, 353 cpufreq_unregister_notifier(&notifier_policy_block,
357 CPUFREQ_POLICY_NOTIFIER); 354 CPUFREQ_POLICY_NOTIFIER);
358 return ret; 355 return ret;
@@ -364,8 +361,7 @@ __init cpufreq_stats_init(void)
364 } 361 }
365 return 0; 362 return 0;
366} 363}
367static void 364static void __exit cpufreq_stats_exit(void)
368__exit cpufreq_stats_exit(void)
369{ 365{
370 unsigned int cpu; 366 unsigned int cpu;
371 367
@@ -379,10 +375,10 @@ __exit cpufreq_stats_exit(void)
379 } 375 }
380} 376}
381 377
382MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>"); 378MODULE_AUTHOR("Zou Nan hai <nanhai.zou@intel.com>");
383MODULE_DESCRIPTION ("'cpufreq_stats' - A driver to export cpufreq stats " 379MODULE_DESCRIPTION("'cpufreq_stats' - A driver to export cpufreq stats "
384 "through sysfs filesystem"); 380 "through sysfs filesystem");
385MODULE_LICENSE ("GPL"); 381MODULE_LICENSE("GPL");
386 382
387module_init(cpufreq_stats_init); 383module_init(cpufreq_stats_init);
388module_exit(cpufreq_stats_exit); 384module_exit(cpufreq_stats_exit);
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c
index 1442bbada053..66d2d1d6c80f 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -24,9 +24,6 @@
24#include <linux/sysfs.h> 24#include <linux/sysfs.h>
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26 26
27#include <asm/uaccess.h>
28
29
30/** 27/**
31 * A few values needed by the userspace governor 28 * A few values needed by the userspace governor
32 */ 29 */
@@ -37,7 +34,7 @@ static DEFINE_PER_CPU(unsigned int, cpu_set_freq); /* CPU freq desired by
37 userspace */ 34 userspace */
38static DEFINE_PER_CPU(unsigned int, cpu_is_managed); 35static DEFINE_PER_CPU(unsigned int, cpu_is_managed);
39 36
40static DEFINE_MUTEX (userspace_mutex); 37static DEFINE_MUTEX(userspace_mutex);
41static int cpus_using_userspace_governor; 38static int cpus_using_userspace_governor;
42 39
43#define dprintk(msg...) \ 40#define dprintk(msg...) \
@@ -46,9 +43,9 @@ static int cpus_using_userspace_governor;
46/* keep track of frequency transitions */ 43/* keep track of frequency transitions */
47static int 44static int
48userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val, 45userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
49 void *data) 46 void *data)
50{ 47{
51 struct cpufreq_freqs *freq = data; 48 struct cpufreq_freqs *freq = data;
52 49
53 if (!per_cpu(cpu_is_managed, freq->cpu)) 50 if (!per_cpu(cpu_is_managed, freq->cpu))
54 return 0; 51 return 0;
@@ -57,11 +54,11 @@ userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
57 freq->cpu, freq->new); 54 freq->cpu, freq->new);
58 per_cpu(cpu_cur_freq, freq->cpu) = freq->new; 55 per_cpu(cpu_cur_freq, freq->cpu) = freq->new;
59 56
60 return 0; 57 return 0;
61} 58}
62 59
63static struct notifier_block userspace_cpufreq_notifier_block = { 60static struct notifier_block userspace_cpufreq_notifier_block = {
64 .notifier_call = userspace_cpufreq_notifier 61 .notifier_call = userspace_cpufreq_notifier
65}; 62};
66 63
67 64
@@ -93,8 +90,11 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq)
93 * We're safe from concurrent calls to ->target() here 90 * We're safe from concurrent calls to ->target() here
94 * as we hold the userspace_mutex lock. If we were calling 91 * as we hold the userspace_mutex lock. If we were calling
95 * cpufreq_driver_target, a deadlock situation might occur: 92 * cpufreq_driver_target, a deadlock situation might occur:
96 * A: cpufreq_set (lock userspace_mutex) -> cpufreq_driver_target(lock policy->lock) 93 * A: cpufreq_set (lock userspace_mutex) ->
97 * B: cpufreq_set_policy(lock policy->lock) -> __cpufreq_governor -> cpufreq_governor_userspace (lock userspace_mutex) 94 * cpufreq_driver_target(lock policy->lock)
95 * B: cpufreq_set_policy(lock policy->lock) ->
96 * __cpufreq_governor ->
97 * cpufreq_governor_userspace (lock userspace_mutex)
98 */ 98 */
99 ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L); 99 ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);
100 100
@@ -210,9 +210,10 @@ static void __exit cpufreq_gov_userspace_exit(void)
210} 210}
211 211
212 212
213MODULE_AUTHOR ("Dominik Brodowski <linux@brodo.de>, Russell King <rmk@arm.linux.org.uk>"); 213MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, "
214MODULE_DESCRIPTION ("CPUfreq policy governor 'userspace'"); 214 "Russell King <rmk@arm.linux.org.uk>");
215MODULE_LICENSE ("GPL"); 215MODULE_DESCRIPTION("CPUfreq policy governor 'userspace'");
216MODULE_LICENSE("GPL");
216 217
217#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE 218#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE
218fs_initcall(cpufreq_gov_userspace_init); 219fs_initcall(cpufreq_gov_userspace_init);
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 9071d80fbba2..a9bd3a05a684 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -28,7 +28,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
28 unsigned int max_freq = 0; 28 unsigned int max_freq = 0;
29 unsigned int i; 29 unsigned int i;
30 30
31 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 31 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
32 unsigned int freq = table[i].frequency; 32 unsigned int freq = table[i].frequency;
33 if (freq == CPUFREQ_ENTRY_INVALID) { 33 if (freq == CPUFREQ_ENTRY_INVALID) {
34 dprintk("table entry %u is invalid, skipping\n", i); 34 dprintk("table entry %u is invalid, skipping\n", i);
@@ -70,7 +70,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
70 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, 70 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
71 policy->cpuinfo.max_freq); 71 policy->cpuinfo.max_freq);
72 72
73 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 73 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
74 unsigned int freq = table[i].frequency; 74 unsigned int freq = table[i].frequency;
75 if (freq == CPUFREQ_ENTRY_INVALID) 75 if (freq == CPUFREQ_ENTRY_INVALID)
76 continue; 76 continue;
@@ -125,13 +125,13 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
125 if (!cpu_online(policy->cpu)) 125 if (!cpu_online(policy->cpu))
126 return -EINVAL; 126 return -EINVAL;
127 127
128 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 128 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
129 unsigned int freq = table[i].frequency; 129 unsigned int freq = table[i].frequency;
130 if (freq == CPUFREQ_ENTRY_INVALID) 130 if (freq == CPUFREQ_ENTRY_INVALID)
131 continue; 131 continue;
132 if ((freq < policy->min) || (freq > policy->max)) 132 if ((freq < policy->min) || (freq > policy->max))
133 continue; 133 continue;
134 switch(relation) { 134 switch (relation) {
135 case CPUFREQ_RELATION_H: 135 case CPUFREQ_RELATION_H:
136 if (freq <= target_freq) { 136 if (freq <= target_freq) {
137 if (freq >= optimal.frequency) { 137 if (freq >= optimal.frequency) {
@@ -178,7 +178,7 @@ static DEFINE_PER_CPU(struct cpufreq_frequency_table *, show_table);
178/** 178/**
179 * show_available_freqs - show available frequencies for the specified CPU 179 * show_available_freqs - show available frequencies for the specified CPU
180 */ 180 */
181static ssize_t show_available_freqs (struct cpufreq_policy *policy, char *buf) 181static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf)
182{ 182{
183 unsigned int i = 0; 183 unsigned int i = 0;
184 unsigned int cpu = policy->cpu; 184 unsigned int cpu = policy->cpu;
@@ -190,7 +190,7 @@ static ssize_t show_available_freqs (struct cpufreq_policy *policy, char *buf)
190 190
191 table = per_cpu(show_table, cpu); 191 table = per_cpu(show_table, cpu);
192 192
193 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 193 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
194 if (table[i].frequency == CPUFREQ_ENTRY_INVALID) 194 if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
195 continue; 195 continue;
196 count += sprintf(&buf[count], "%d ", table[i].frequency); 196 count += sprintf(&buf[count], "%d ", table[i].frequency);
@@ -234,6 +234,6 @@ struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu)
234} 234}
235EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); 235EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table);
236 236
237MODULE_AUTHOR ("Dominik Brodowski <linux@brodo.de>"); 237MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>");
238MODULE_DESCRIPTION ("CPUfreq frequency table helpers"); 238MODULE_DESCRIPTION("CPUfreq frequency table helpers");
239MODULE_LICENSE ("GPL"); 239MODULE_LICENSE("GPL");
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index e522144cba3a..01afd758072f 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -86,7 +86,7 @@ config ZCRYPT_MONOLITHIC
86config CRYPTO_SHA1_S390 86config CRYPTO_SHA1_S390
87 tristate "SHA1 digest algorithm" 87 tristate "SHA1 digest algorithm"
88 depends on S390 88 depends on S390
89 select CRYPTO_ALGAPI 89 select CRYPTO_HASH
90 help 90 help
91 This is the s390 hardware accelerated implementation of the 91 This is the s390 hardware accelerated implementation of the
92 SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2). 92 SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2).
@@ -94,7 +94,7 @@ config CRYPTO_SHA1_S390
94config CRYPTO_SHA256_S390 94config CRYPTO_SHA256_S390
95 tristate "SHA256 digest algorithm" 95 tristate "SHA256 digest algorithm"
96 depends on S390 96 depends on S390
97 select CRYPTO_ALGAPI 97 select CRYPTO_HASH
98 help 98 help
99 This is the s390 hardware accelerated implementation of the 99 This is the s390 hardware accelerated implementation of the
100 SHA256 secure hash standard (DFIPS 180-2). 100 SHA256 secure hash standard (DFIPS 180-2).
@@ -105,7 +105,7 @@ config CRYPTO_SHA256_S390
105config CRYPTO_SHA512_S390 105config CRYPTO_SHA512_S390
106 tristate "SHA384 and SHA512 digest algorithm" 106 tristate "SHA384 and SHA512 digest algorithm"
107 depends on S390 107 depends on S390
108 select CRYPTO_ALGAPI 108 select CRYPTO_HASH
109 help 109 help
110 This is the s390 hardware accelerated implementation of the 110 This is the s390 hardware accelerated implementation of the
111 SHA512 secure hash standard. 111 SHA512 secure hash standard.
@@ -200,4 +200,13 @@ config CRYPTO_DEV_IXP4XX
200 help 200 help
201 Driver for the IXP4xx NPE crypto engine. 201 Driver for the IXP4xx NPE crypto engine.
202 202
203config CRYPTO_DEV_PPC4XX
204 tristate "Driver AMCC PPC4xx crypto accelerator"
205 depends on PPC && 4xx
206 select CRYPTO_HASH
207 select CRYPTO_ALGAPI
208 select CRYPTO_BLKCIPHER
209 help
210 This option allows you to have support for AMCC crypto acceleration.
211
203endif # CRYPTO_HW 212endif # CRYPTO_HW
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index 73557b2968d3..9bf4a2bc8846 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_CRYPTO_DEV_GEODE) += geode-aes.o
4obj-$(CONFIG_CRYPTO_DEV_HIFN_795X) += hifn_795x.o 4obj-$(CONFIG_CRYPTO_DEV_HIFN_795X) += hifn_795x.o
5obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o 5obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
6obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o 6obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o
7obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/
diff --git a/drivers/crypto/amcc/Makefile b/drivers/crypto/amcc/Makefile
new file mode 100644
index 000000000000..aa376e8d5ed5
--- /dev/null
+++ b/drivers/crypto/amcc/Makefile
@@ -0,0 +1,2 @@
1obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += crypto4xx.o
2crypto4xx-objs := crypto4xx_core.o crypto4xx_alg.o crypto4xx_sa.o
diff --git a/drivers/crypto/amcc/crypto4xx_alg.c b/drivers/crypto/amcc/crypto4xx_alg.c
new file mode 100644
index 000000000000..61b6e1bec8c6
--- /dev/null
+++ b/drivers/crypto/amcc/crypto4xx_alg.c
@@ -0,0 +1,293 @@
1/**
2 * AMCC SoC PPC4xx Crypto Driver
3 *
4 * Copyright (c) 2008 Applied Micro Circuits Corporation.
5 * All rights reserved. James Hsiao <jhsiao@amcc.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 * This file implements the Linux crypto algorithms.
18 */
19
20#include <linux/kernel.h>
21#include <linux/interrupt.h>
22#include <linux/spinlock_types.h>
23#include <linux/scatterlist.h>
24#include <linux/crypto.h>
25#include <linux/hash.h>
26#include <crypto/internal/hash.h>
27#include <linux/dma-mapping.h>
28#include <crypto/algapi.h>
29#include <crypto/aes.h>
30#include <crypto/sha.h>
31#include "crypto4xx_reg_def.h"
32#include "crypto4xx_sa.h"
33#include "crypto4xx_core.h"
34
35void set_dynamic_sa_command_0(struct dynamic_sa_ctl *sa, u32 save_h,
36 u32 save_iv, u32 ld_h, u32 ld_iv, u32 hdr_proc,
37 u32 h, u32 c, u32 pad_type, u32 op_grp, u32 op,
38 u32 dir)
39{
40 sa->sa_command_0.w = 0;
41 sa->sa_command_0.bf.save_hash_state = save_h;
42 sa->sa_command_0.bf.save_iv = save_iv;
43 sa->sa_command_0.bf.load_hash_state = ld_h;
44 sa->sa_command_0.bf.load_iv = ld_iv;
45 sa->sa_command_0.bf.hdr_proc = hdr_proc;
46 sa->sa_command_0.bf.hash_alg = h;
47 sa->sa_command_0.bf.cipher_alg = c;
48 sa->sa_command_0.bf.pad_type = pad_type & 3;
49 sa->sa_command_0.bf.extend_pad = pad_type >> 2;
50 sa->sa_command_0.bf.op_group = op_grp;
51 sa->sa_command_0.bf.opcode = op;
52 sa->sa_command_0.bf.dir = dir;
53}
54
55void set_dynamic_sa_command_1(struct dynamic_sa_ctl *sa, u32 cm, u32 hmac_mc,
56 u32 cfb, u32 esn, u32 sn_mask, u32 mute,
57 u32 cp_pad, u32 cp_pay, u32 cp_hdr)
58{
59 sa->sa_command_1.w = 0;
60 sa->sa_command_1.bf.crypto_mode31 = (cm & 4) >> 2;
61 sa->sa_command_1.bf.crypto_mode9_8 = cm & 3;
62 sa->sa_command_1.bf.feedback_mode = cfb,
63 sa->sa_command_1.bf.sa_rev = 1;
64 sa->sa_command_1.bf.extended_seq_num = esn;
65 sa->sa_command_1.bf.seq_num_mask = sn_mask;
66 sa->sa_command_1.bf.mutable_bit_proc = mute;
67 sa->sa_command_1.bf.copy_pad = cp_pad;
68 sa->sa_command_1.bf.copy_payload = cp_pay;
69 sa->sa_command_1.bf.copy_hdr = cp_hdr;
70}
71
72int crypto4xx_encrypt(struct ablkcipher_request *req)
73{
74 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
75
76 ctx->direction = DIR_OUTBOUND;
77 ctx->hash_final = 0;
78 ctx->is_hash = 0;
79 ctx->pd_ctl = 0x1;
80
81 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
82 req->nbytes, req->info,
83 get_dynamic_sa_iv_size(ctx));
84}
85
86int crypto4xx_decrypt(struct ablkcipher_request *req)
87{
88 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
89
90 ctx->direction = DIR_INBOUND;
91 ctx->hash_final = 0;
92 ctx->is_hash = 0;
93 ctx->pd_ctl = 1;
94
95 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
96 req->nbytes, req->info,
97 get_dynamic_sa_iv_size(ctx));
98}
99
100/**
101 * AES Functions
102 */
103static int crypto4xx_setkey_aes(struct crypto_ablkcipher *cipher,
104 const u8 *key,
105 unsigned int keylen,
106 unsigned char cm,
107 u8 fb)
108{
109 struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher);
110 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(tfm);
111 struct dynamic_sa_ctl *sa;
112 int rc;
113
114 if (keylen != AES_KEYSIZE_256 &&
115 keylen != AES_KEYSIZE_192 && keylen != AES_KEYSIZE_128) {
116 crypto_ablkcipher_set_flags(cipher,
117 CRYPTO_TFM_RES_BAD_KEY_LEN);
118 return -EINVAL;
119 }
120
121 /* Create SA */
122 if (ctx->sa_in_dma_addr || ctx->sa_out_dma_addr)
123 crypto4xx_free_sa(ctx);
124
125 rc = crypto4xx_alloc_sa(ctx, SA_AES128_LEN + (keylen-16) / 4);
126 if (rc)
127 return rc;
128
129 if (ctx->state_record_dma_addr == 0) {
130 rc = crypto4xx_alloc_state_record(ctx);
131 if (rc) {
132 crypto4xx_free_sa(ctx);
133 return rc;
134 }
135 }
136 /* Setup SA */
137 sa = (struct dynamic_sa_ctl *) ctx->sa_in;
138 ctx->hash_final = 0;
139
140 set_dynamic_sa_command_0(sa, SA_NOT_SAVE_HASH, SA_NOT_SAVE_IV,
141 SA_LOAD_HASH_FROM_SA, SA_LOAD_IV_FROM_STATE,
142 SA_NO_HEADER_PROC, SA_HASH_ALG_NULL,
143 SA_CIPHER_ALG_AES, SA_PAD_TYPE_ZERO,
144 SA_OP_GROUP_BASIC, SA_OPCODE_DECRYPT,
145 DIR_INBOUND);
146
147 set_dynamic_sa_command_1(sa, cm, SA_HASH_MODE_HASH,
148 fb, SA_EXTENDED_SN_OFF,
149 SA_SEQ_MASK_OFF, SA_MC_ENABLE,
150 SA_NOT_COPY_PAD, SA_NOT_COPY_PAYLOAD,
151 SA_NOT_COPY_HDR);
152 crypto4xx_memcpy_le(ctx->sa_in + get_dynamic_sa_offset_key_field(ctx),
153 key, keylen);
154 sa->sa_contents = SA_AES_CONTENTS | (keylen << 2);
155 sa->sa_command_1.bf.key_len = keylen >> 3;
156 ctx->is_hash = 0;
157 ctx->direction = DIR_INBOUND;
158 memcpy(ctx->sa_in + get_dynamic_sa_offset_state_ptr_field(ctx),
159 (void *)&ctx->state_record_dma_addr, 4);
160 ctx->offset_to_sr_ptr = get_dynamic_sa_offset_state_ptr_field(ctx);
161
162 memcpy(ctx->sa_out, ctx->sa_in, ctx->sa_len * 4);
163 sa = (struct dynamic_sa_ctl *) ctx->sa_out;
164 sa->sa_command_0.bf.dir = DIR_OUTBOUND;
165
166 return 0;
167}
168
169int crypto4xx_setkey_aes_cbc(struct crypto_ablkcipher *cipher,
170 const u8 *key, unsigned int keylen)
171{
172 return crypto4xx_setkey_aes(cipher, key, keylen, CRYPTO_MODE_CBC,
173 CRYPTO_FEEDBACK_MODE_NO_FB);
174}
175
176/**
177 * HASH SHA1 Functions
178 */
179static int crypto4xx_hash_alg_init(struct crypto_tfm *tfm,
180 unsigned int sa_len,
181 unsigned char ha,
182 unsigned char hm)
183{
184 struct crypto_alg *alg = tfm->__crt_alg;
185 struct crypto4xx_alg *my_alg = crypto_alg_to_crypto4xx_alg(alg);
186 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(tfm);
187 struct dynamic_sa_ctl *sa;
188 struct dynamic_sa_hash160 *sa_in;
189 int rc;
190
191 ctx->dev = my_alg->dev;
192 ctx->is_hash = 1;
193 ctx->hash_final = 0;
194
195 /* Create SA */
196 if (ctx->sa_in_dma_addr || ctx->sa_out_dma_addr)
197 crypto4xx_free_sa(ctx);
198
199 rc = crypto4xx_alloc_sa(ctx, sa_len);
200 if (rc)
201 return rc;
202
203 if (ctx->state_record_dma_addr == 0) {
204 crypto4xx_alloc_state_record(ctx);
205 if (!ctx->state_record_dma_addr) {
206 crypto4xx_free_sa(ctx);
207 return -ENOMEM;
208 }
209 }
210
211 tfm->crt_ahash.reqsize = sizeof(struct crypto4xx_ctx);
212 sa = (struct dynamic_sa_ctl *) ctx->sa_in;
213 set_dynamic_sa_command_0(sa, SA_SAVE_HASH, SA_NOT_SAVE_IV,
214 SA_NOT_LOAD_HASH, SA_LOAD_IV_FROM_SA,
215 SA_NO_HEADER_PROC, ha, SA_CIPHER_ALG_NULL,
216 SA_PAD_TYPE_ZERO, SA_OP_GROUP_BASIC,
217 SA_OPCODE_HASH, DIR_INBOUND);
218 set_dynamic_sa_command_1(sa, 0, SA_HASH_MODE_HASH,
219 CRYPTO_FEEDBACK_MODE_NO_FB, SA_EXTENDED_SN_OFF,
220 SA_SEQ_MASK_OFF, SA_MC_ENABLE,
221 SA_NOT_COPY_PAD, SA_NOT_COPY_PAYLOAD,
222 SA_NOT_COPY_HDR);
223 ctx->direction = DIR_INBOUND;
224 sa->sa_contents = SA_HASH160_CONTENTS;
225 sa_in = (struct dynamic_sa_hash160 *) ctx->sa_in;
226 /* Need to zero hash digest in SA */
227 memset(sa_in->inner_digest, 0, sizeof(sa_in->inner_digest));
228 memset(sa_in->outer_digest, 0, sizeof(sa_in->outer_digest));
229 sa_in->state_ptr = ctx->state_record_dma_addr;
230 ctx->offset_to_sr_ptr = get_dynamic_sa_offset_state_ptr_field(ctx);
231
232 return 0;
233}
234
235int crypto4xx_hash_init(struct ahash_request *req)
236{
237 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
238 int ds;
239 struct dynamic_sa_ctl *sa;
240
241 sa = (struct dynamic_sa_ctl *) ctx->sa_in;
242 ds = crypto_ahash_digestsize(
243 __crypto_ahash_cast(req->base.tfm));
244 sa->sa_command_0.bf.digest_len = ds >> 2;
245 sa->sa_command_0.bf.load_hash_state = SA_LOAD_HASH_FROM_SA;
246 ctx->is_hash = 1;
247 ctx->direction = DIR_INBOUND;
248
249 return 0;
250}
251
252int crypto4xx_hash_update(struct ahash_request *req)
253{
254 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
255
256 ctx->is_hash = 1;
257 ctx->hash_final = 0;
258 ctx->pd_ctl = 0x11;
259 ctx->direction = DIR_INBOUND;
260
261 return crypto4xx_build_pd(&req->base, ctx, req->src,
262 (struct scatterlist *) req->result,
263 req->nbytes, NULL, 0);
264}
265
266int crypto4xx_hash_final(struct ahash_request *req)
267{
268 return 0;
269}
270
271int crypto4xx_hash_digest(struct ahash_request *req)
272{
273 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
274
275 ctx->hash_final = 1;
276 ctx->pd_ctl = 0x11;
277 ctx->direction = DIR_INBOUND;
278
279 return crypto4xx_build_pd(&req->base, ctx, req->src,
280 (struct scatterlist *) req->result,
281 req->nbytes, NULL, 0);
282}
283
284/**
285 * SHA1 Algorithm
286 */
287int crypto4xx_sha1_alg_init(struct crypto_tfm *tfm)
288{
289 return crypto4xx_hash_alg_init(tfm, SA_HASH160_LEN, SA_HASH_ALG_SHA1,
290 SA_HASH_MODE_HASH);
291}
292
293
diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
new file mode 100644
index 000000000000..4c0dfb2b872e
--- /dev/null
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -0,0 +1,1310 @@
1/**
2 * AMCC SoC PPC4xx Crypto Driver
3 *
4 * Copyright (c) 2008 Applied Micro Circuits Corporation.
5 * All rights reserved. James Hsiao <jhsiao@amcc.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 * This file implements AMCC crypto offload Linux device driver for use with
18 * Linux CryptoAPI.
19 */
20
21#include <linux/kernel.h>
22#include <linux/interrupt.h>
23#include <linux/spinlock_types.h>
24#include <linux/random.h>
25#include <linux/scatterlist.h>
26#include <linux/crypto.h>
27#include <linux/dma-mapping.h>
28#include <linux/platform_device.h>
29#include <linux/init.h>
30#include <linux/of_platform.h>
31#include <asm/dcr.h>
32#include <asm/dcr-regs.h>
33#include <asm/cacheflush.h>
34#include <crypto/internal/hash.h>
35#include <crypto/algapi.h>
36#include <crypto/aes.h>
37#include <crypto/sha.h>
38#include "crypto4xx_reg_def.h"
39#include "crypto4xx_core.h"
40#include "crypto4xx_sa.h"
41
42#define PPC4XX_SEC_VERSION_STR "0.5"
43
44/**
45 * PPC4xx Crypto Engine Initialization Routine
46 */
47static void crypto4xx_hw_init(struct crypto4xx_device *dev)
48{
49 union ce_ring_size ring_size;
50 union ce_ring_contol ring_ctrl;
51 union ce_part_ring_size part_ring_size;
52 union ce_io_threshold io_threshold;
53 u32 rand_num;
54 union ce_pe_dma_cfg pe_dma_cfg;
55
56 writel(PPC4XX_BYTE_ORDER, dev->ce_base + CRYPTO4XX_BYTE_ORDER_CFG);
57 /* setup pe dma, include reset sg, pdr and pe, then release reset */
58 pe_dma_cfg.w = 0;
59 pe_dma_cfg.bf.bo_sgpd_en = 1;
60 pe_dma_cfg.bf.bo_data_en = 0;
61 pe_dma_cfg.bf.bo_sa_en = 1;
62 pe_dma_cfg.bf.bo_pd_en = 1;
63 pe_dma_cfg.bf.dynamic_sa_en = 1;
64 pe_dma_cfg.bf.reset_sg = 1;
65 pe_dma_cfg.bf.reset_pdr = 1;
66 pe_dma_cfg.bf.reset_pe = 1;
67 writel(pe_dma_cfg.w, dev->ce_base + CRYPTO4XX_PE_DMA_CFG);
68 /* un reset pe,sg and pdr */
69 pe_dma_cfg.bf.pe_mode = 0;
70 pe_dma_cfg.bf.reset_sg = 0;
71 pe_dma_cfg.bf.reset_pdr = 0;
72 pe_dma_cfg.bf.reset_pe = 0;
73 pe_dma_cfg.bf.bo_td_en = 0;
74 writel(pe_dma_cfg.w, dev->ce_base + CRYPTO4XX_PE_DMA_CFG);
75 writel(dev->pdr_pa, dev->ce_base + CRYPTO4XX_PDR_BASE);
76 writel(dev->pdr_pa, dev->ce_base + CRYPTO4XX_RDR_BASE);
77 writel(PPC4XX_PRNG_CTRL_AUTO_EN, dev->ce_base + CRYPTO4XX_PRNG_CTRL);
78 get_random_bytes(&rand_num, sizeof(rand_num));
79 writel(rand_num, dev->ce_base + CRYPTO4XX_PRNG_SEED_L);
80 get_random_bytes(&rand_num, sizeof(rand_num));
81 writel(rand_num, dev->ce_base + CRYPTO4XX_PRNG_SEED_H);
82 ring_size.w = 0;
83 ring_size.bf.ring_offset = PPC4XX_PD_SIZE;
84 ring_size.bf.ring_size = PPC4XX_NUM_PD;
85 writel(ring_size.w, dev->ce_base + CRYPTO4XX_RING_SIZE);
86 ring_ctrl.w = 0;
87 writel(ring_ctrl.w, dev->ce_base + CRYPTO4XX_RING_CTRL);
88 writel(PPC4XX_DC_3DES_EN, dev->ce_base + CRYPTO4XX_DEVICE_CTRL);
89 writel(dev->gdr_pa, dev->ce_base + CRYPTO4XX_GATH_RING_BASE);
90 writel(dev->sdr_pa, dev->ce_base + CRYPTO4XX_SCAT_RING_BASE);
91 part_ring_size.w = 0;
92 part_ring_size.bf.sdr_size = PPC4XX_SDR_SIZE;
93 part_ring_size.bf.gdr_size = PPC4XX_GDR_SIZE;
94 writel(part_ring_size.w, dev->ce_base + CRYPTO4XX_PART_RING_SIZE);
95 writel(PPC4XX_SD_BUFFER_SIZE, dev->ce_base + CRYPTO4XX_PART_RING_CFG);
96 io_threshold.w = 0;
97 io_threshold.bf.output_threshold = PPC4XX_OUTPUT_THRESHOLD;
98 io_threshold.bf.input_threshold = PPC4XX_INPUT_THRESHOLD;
99 writel(io_threshold.w, dev->ce_base + CRYPTO4XX_IO_THRESHOLD);
100 writel(0, dev->ce_base + CRYPTO4XX_PDR_BASE_UADDR);
101 writel(0, dev->ce_base + CRYPTO4XX_RDR_BASE_UADDR);
102 writel(0, dev->ce_base + CRYPTO4XX_PKT_SRC_UADDR);
103 writel(0, dev->ce_base + CRYPTO4XX_PKT_DEST_UADDR);
104 writel(0, dev->ce_base + CRYPTO4XX_SA_UADDR);
105 writel(0, dev->ce_base + CRYPTO4XX_GATH_RING_BASE_UADDR);
106 writel(0, dev->ce_base + CRYPTO4XX_SCAT_RING_BASE_UADDR);
107 /* un reset pe,sg and pdr */
108 pe_dma_cfg.bf.pe_mode = 1;
109 pe_dma_cfg.bf.reset_sg = 0;
110 pe_dma_cfg.bf.reset_pdr = 0;
111 pe_dma_cfg.bf.reset_pe = 0;
112 pe_dma_cfg.bf.bo_td_en = 0;
113 writel(pe_dma_cfg.w, dev->ce_base + CRYPTO4XX_PE_DMA_CFG);
114 /*clear all pending interrupt*/
115 writel(PPC4XX_INTERRUPT_CLR, dev->ce_base + CRYPTO4XX_INT_CLR);
116 writel(PPC4XX_INT_DESCR_CNT, dev->ce_base + CRYPTO4XX_INT_DESCR_CNT);
117 writel(PPC4XX_INT_DESCR_CNT, dev->ce_base + CRYPTO4XX_INT_DESCR_CNT);
118 writel(PPC4XX_INT_CFG, dev->ce_base + CRYPTO4XX_INT_CFG);
119 writel(PPC4XX_PD_DONE_INT, dev->ce_base + CRYPTO4XX_INT_EN);
120}
121
122int crypto4xx_alloc_sa(struct crypto4xx_ctx *ctx, u32 size)
123{
124 ctx->sa_in = dma_alloc_coherent(ctx->dev->core_dev->device, size * 4,
125 &ctx->sa_in_dma_addr, GFP_ATOMIC);
126 if (ctx->sa_in == NULL)
127 return -ENOMEM;
128
129 ctx->sa_out = dma_alloc_coherent(ctx->dev->core_dev->device, size * 4,
130 &ctx->sa_out_dma_addr, GFP_ATOMIC);
131 if (ctx->sa_out == NULL) {
132 dma_free_coherent(ctx->dev->core_dev->device,
133 ctx->sa_len * 4,
134 ctx->sa_in, ctx->sa_in_dma_addr);
135 return -ENOMEM;
136 }
137
138 memset(ctx->sa_in, 0, size * 4);
139 memset(ctx->sa_out, 0, size * 4);
140 ctx->sa_len = size;
141
142 return 0;
143}
144
145void crypto4xx_free_sa(struct crypto4xx_ctx *ctx)
146{
147 if (ctx->sa_in != NULL)
148 dma_free_coherent(ctx->dev->core_dev->device, ctx->sa_len * 4,
149 ctx->sa_in, ctx->sa_in_dma_addr);
150 if (ctx->sa_out != NULL)
151 dma_free_coherent(ctx->dev->core_dev->device, ctx->sa_len * 4,
152 ctx->sa_out, ctx->sa_out_dma_addr);
153
154 ctx->sa_in_dma_addr = 0;
155 ctx->sa_out_dma_addr = 0;
156 ctx->sa_len = 0;
157}
158
159u32 crypto4xx_alloc_state_record(struct crypto4xx_ctx *ctx)
160{
161 ctx->state_record = dma_alloc_coherent(ctx->dev->core_dev->device,
162 sizeof(struct sa_state_record),
163 &ctx->state_record_dma_addr, GFP_ATOMIC);
164 if (!ctx->state_record_dma_addr)
165 return -ENOMEM;
166 memset(ctx->state_record, 0, sizeof(struct sa_state_record));
167
168 return 0;
169}
170
171void crypto4xx_free_state_record(struct crypto4xx_ctx *ctx)
172{
173 if (ctx->state_record != NULL)
174 dma_free_coherent(ctx->dev->core_dev->device,
175 sizeof(struct sa_state_record),
176 ctx->state_record,
177 ctx->state_record_dma_addr);
178 ctx->state_record_dma_addr = 0;
179}
180
181/**
182 * alloc memory for the gather ring
183 * no need to alloc buf for the ring
184 * gdr_tail, gdr_head and gdr_count are initialized by this function
185 */
186static u32 crypto4xx_build_pdr(struct crypto4xx_device *dev)
187{
188 int i;
189 struct pd_uinfo *pd_uinfo;
190 dev->pdr = dma_alloc_coherent(dev->core_dev->device,
191 sizeof(struct ce_pd) * PPC4XX_NUM_PD,
192 &dev->pdr_pa, GFP_ATOMIC);
193 if (!dev->pdr)
194 return -ENOMEM;
195
196 dev->pdr_uinfo = kzalloc(sizeof(struct pd_uinfo) * PPC4XX_NUM_PD,
197 GFP_KERNEL);
198 if (!dev->pdr_uinfo) {
199 dma_free_coherent(dev->core_dev->device,
200 sizeof(struct ce_pd) * PPC4XX_NUM_PD,
201 dev->pdr,
202 dev->pdr_pa);
203 return -ENOMEM;
204 }
205 memset(dev->pdr, 0, sizeof(struct ce_pd) * PPC4XX_NUM_PD);
206 dev->shadow_sa_pool = dma_alloc_coherent(dev->core_dev->device,
207 256 * PPC4XX_NUM_PD,
208 &dev->shadow_sa_pool_pa,
209 GFP_ATOMIC);
210 if (!dev->shadow_sa_pool)
211 return -ENOMEM;
212
213 dev->shadow_sr_pool = dma_alloc_coherent(dev->core_dev->device,
214 sizeof(struct sa_state_record) * PPC4XX_NUM_PD,
215 &dev->shadow_sr_pool_pa, GFP_ATOMIC);
216 if (!dev->shadow_sr_pool)
217 return -ENOMEM;
218 for (i = 0; i < PPC4XX_NUM_PD; i++) {
219 pd_uinfo = (struct pd_uinfo *) (dev->pdr_uinfo +
220 sizeof(struct pd_uinfo) * i);
221
222 /* alloc 256 bytes which is enough for any kind of dynamic sa */
223 pd_uinfo->sa_va = dev->shadow_sa_pool + 256 * i;
224 pd_uinfo->sa_pa = dev->shadow_sa_pool_pa + 256 * i;
225
226 /* alloc state record */
227 pd_uinfo->sr_va = dev->shadow_sr_pool +
228 sizeof(struct sa_state_record) * i;
229 pd_uinfo->sr_pa = dev->shadow_sr_pool_pa +
230 sizeof(struct sa_state_record) * i;
231 }
232
233 return 0;
234}
235
236static void crypto4xx_destroy_pdr(struct crypto4xx_device *dev)
237{
238 if (dev->pdr != NULL)
239 dma_free_coherent(dev->core_dev->device,
240 sizeof(struct ce_pd) * PPC4XX_NUM_PD,
241 dev->pdr, dev->pdr_pa);
242 if (dev->shadow_sa_pool)
243 dma_free_coherent(dev->core_dev->device, 256 * PPC4XX_NUM_PD,
244 dev->shadow_sa_pool, dev->shadow_sa_pool_pa);
245 if (dev->shadow_sr_pool)
246 dma_free_coherent(dev->core_dev->device,
247 sizeof(struct sa_state_record) * PPC4XX_NUM_PD,
248 dev->shadow_sr_pool, dev->shadow_sr_pool_pa);
249
250 kfree(dev->pdr_uinfo);
251}
252
253static u32 crypto4xx_get_pd_from_pdr_nolock(struct crypto4xx_device *dev)
254{
255 u32 retval;
256 u32 tmp;
257
258 retval = dev->pdr_head;
259 tmp = (dev->pdr_head + 1) % PPC4XX_NUM_PD;
260
261 if (tmp == dev->pdr_tail)
262 return ERING_WAS_FULL;
263
264 dev->pdr_head = tmp;
265
266 return retval;
267}
268
269static u32 crypto4xx_put_pd_to_pdr(struct crypto4xx_device *dev, u32 idx)
270{
271 struct pd_uinfo *pd_uinfo;
272 unsigned long flags;
273
274 pd_uinfo = (struct pd_uinfo *)(dev->pdr_uinfo +
275 sizeof(struct pd_uinfo) * idx);
276 spin_lock_irqsave(&dev->core_dev->lock, flags);
277 if (dev->pdr_tail != PPC4XX_LAST_PD)
278 dev->pdr_tail++;
279 else
280 dev->pdr_tail = 0;
281 pd_uinfo->state = PD_ENTRY_FREE;
282 spin_unlock_irqrestore(&dev->core_dev->lock, flags);
283
284 return 0;
285}
286
287static struct ce_pd *crypto4xx_get_pdp(struct crypto4xx_device *dev,
288 dma_addr_t *pd_dma, u32 idx)
289{
290 *pd_dma = dev->pdr_pa + sizeof(struct ce_pd) * idx;
291
292 return dev->pdr + sizeof(struct ce_pd) * idx;
293}
294
295/**
296 * alloc memory for the gather ring
297 * no need to alloc buf for the ring
298 * gdr_tail, gdr_head and gdr_count are initialized by this function
299 */
300static u32 crypto4xx_build_gdr(struct crypto4xx_device *dev)
301{
302 dev->gdr = dma_alloc_coherent(dev->core_dev->device,
303 sizeof(struct ce_gd) * PPC4XX_NUM_GD,
304 &dev->gdr_pa, GFP_ATOMIC);
305 if (!dev->gdr)
306 return -ENOMEM;
307
308 memset(dev->gdr, 0, sizeof(struct ce_gd) * PPC4XX_NUM_GD);
309
310 return 0;
311}
312
313static inline void crypto4xx_destroy_gdr(struct crypto4xx_device *dev)
314{
315 dma_free_coherent(dev->core_dev->device,
316 sizeof(struct ce_gd) * PPC4XX_NUM_GD,
317 dev->gdr, dev->gdr_pa);
318}
319
320/*
321 * when this function is called.
322 * preemption or interrupt must be disabled
323 */
324u32 crypto4xx_get_n_gd(struct crypto4xx_device *dev, int n)
325{
326 u32 retval;
327 u32 tmp;
328 if (n >= PPC4XX_NUM_GD)
329 return ERING_WAS_FULL;
330
331 retval = dev->gdr_head;
332 tmp = (dev->gdr_head + n) % PPC4XX_NUM_GD;
333 if (dev->gdr_head > dev->gdr_tail) {
334 if (tmp < dev->gdr_head && tmp >= dev->gdr_tail)
335 return ERING_WAS_FULL;
336 } else if (dev->gdr_head < dev->gdr_tail) {
337 if (tmp < dev->gdr_head || tmp >= dev->gdr_tail)
338 return ERING_WAS_FULL;
339 }
340 dev->gdr_head = tmp;
341
342 return retval;
343}
344
345static u32 crypto4xx_put_gd_to_gdr(struct crypto4xx_device *dev)
346{
347 unsigned long flags;
348
349 spin_lock_irqsave(&dev->core_dev->lock, flags);
350 if (dev->gdr_tail == dev->gdr_head) {
351 spin_unlock_irqrestore(&dev->core_dev->lock, flags);
352 return 0;
353 }
354
355 if (dev->gdr_tail != PPC4XX_LAST_GD)
356 dev->gdr_tail++;
357 else
358 dev->gdr_tail = 0;
359
360 spin_unlock_irqrestore(&dev->core_dev->lock, flags);
361
362 return 0;
363}
364
365static inline struct ce_gd *crypto4xx_get_gdp(struct crypto4xx_device *dev,
366 dma_addr_t *gd_dma, u32 idx)
367{
368 *gd_dma = dev->gdr_pa + sizeof(struct ce_gd) * idx;
369
370 return (struct ce_gd *) (dev->gdr + sizeof(struct ce_gd) * idx);
371}
372
373/**
374 * alloc memory for the scatter ring
375 * need to alloc buf for the ring
376 * sdr_tail, sdr_head and sdr_count are initialized by this function
377 */
378static u32 crypto4xx_build_sdr(struct crypto4xx_device *dev)
379{
380 int i;
381 struct ce_sd *sd_array;
382
383 /* alloc memory for scatter descriptor ring */
384 dev->sdr = dma_alloc_coherent(dev->core_dev->device,
385 sizeof(struct ce_sd) * PPC4XX_NUM_SD,
386 &dev->sdr_pa, GFP_ATOMIC);
387 if (!dev->sdr)
388 return -ENOMEM;
389
390 dev->scatter_buffer_size = PPC4XX_SD_BUFFER_SIZE;
391 dev->scatter_buffer_va =
392 dma_alloc_coherent(dev->core_dev->device,
393 dev->scatter_buffer_size * PPC4XX_NUM_SD,
394 &dev->scatter_buffer_pa, GFP_ATOMIC);
395 if (!dev->scatter_buffer_va) {
396 dma_free_coherent(dev->core_dev->device,
397 sizeof(struct ce_sd) * PPC4XX_NUM_SD,
398 dev->sdr, dev->sdr_pa);
399 return -ENOMEM;
400 }
401
402 sd_array = dev->sdr;
403
404 for (i = 0; i < PPC4XX_NUM_SD; i++) {
405 sd_array[i].ptr = dev->scatter_buffer_pa +
406 dev->scatter_buffer_size * i;
407 }
408
409 return 0;
410}
411
412static void crypto4xx_destroy_sdr(struct crypto4xx_device *dev)
413{
414 if (dev->sdr != NULL)
415 dma_free_coherent(dev->core_dev->device,
416 sizeof(struct ce_sd) * PPC4XX_NUM_SD,
417 dev->sdr, dev->sdr_pa);
418
419 if (dev->scatter_buffer_va != NULL)
420 dma_free_coherent(dev->core_dev->device,
421 dev->scatter_buffer_size * PPC4XX_NUM_SD,
422 dev->scatter_buffer_va,
423 dev->scatter_buffer_pa);
424}
425
426/*
427 * when this function is called.
428 * preemption or interrupt must be disabled
429 */
430static u32 crypto4xx_get_n_sd(struct crypto4xx_device *dev, int n)
431{
432 u32 retval;
433 u32 tmp;
434
435 if (n >= PPC4XX_NUM_SD)
436 return ERING_WAS_FULL;
437
438 retval = dev->sdr_head;
439 tmp = (dev->sdr_head + n) % PPC4XX_NUM_SD;
440 if (dev->sdr_head > dev->gdr_tail) {
441 if (tmp < dev->sdr_head && tmp >= dev->sdr_tail)
442 return ERING_WAS_FULL;
443 } else if (dev->sdr_head < dev->sdr_tail) {
444 if (tmp < dev->sdr_head || tmp >= dev->sdr_tail)
445 return ERING_WAS_FULL;
446 } /* the head = tail, or empty case is already take cared */
447 dev->sdr_head = tmp;
448
449 return retval;
450}
451
452static u32 crypto4xx_put_sd_to_sdr(struct crypto4xx_device *dev)
453{
454 unsigned long flags;
455
456 spin_lock_irqsave(&dev->core_dev->lock, flags);
457 if (dev->sdr_tail == dev->sdr_head) {
458 spin_unlock_irqrestore(&dev->core_dev->lock, flags);
459 return 0;
460 }
461 if (dev->sdr_tail != PPC4XX_LAST_SD)
462 dev->sdr_tail++;
463 else
464 dev->sdr_tail = 0;
465 spin_unlock_irqrestore(&dev->core_dev->lock, flags);
466
467 return 0;
468}
469
470static inline struct ce_sd *crypto4xx_get_sdp(struct crypto4xx_device *dev,
471 dma_addr_t *sd_dma, u32 idx)
472{
473 *sd_dma = dev->sdr_pa + sizeof(struct ce_sd) * idx;
474
475 return (struct ce_sd *)(dev->sdr + sizeof(struct ce_sd) * idx);
476}
477
478static u32 crypto4xx_fill_one_page(struct crypto4xx_device *dev,
479 dma_addr_t *addr, u32 *length,
480 u32 *idx, u32 *offset, u32 *nbytes)
481{
482 u32 len;
483
484 if (*length > dev->scatter_buffer_size) {
485 memcpy(phys_to_virt(*addr),
486 dev->scatter_buffer_va +
487 *idx * dev->scatter_buffer_size + *offset,
488 dev->scatter_buffer_size);
489 *offset = 0;
490 *length -= dev->scatter_buffer_size;
491 *nbytes -= dev->scatter_buffer_size;
492 if (*idx == PPC4XX_LAST_SD)
493 *idx = 0;
494 else
495 (*idx)++;
496 *addr = *addr + dev->scatter_buffer_size;
497 return 1;
498 } else if (*length < dev->scatter_buffer_size) {
499 memcpy(phys_to_virt(*addr),
500 dev->scatter_buffer_va +
501 *idx * dev->scatter_buffer_size + *offset, *length);
502 if ((*offset + *length) == dev->scatter_buffer_size) {
503 if (*idx == PPC4XX_LAST_SD)
504 *idx = 0;
505 else
506 (*idx)++;
507 *nbytes -= *length;
508 *offset = 0;
509 } else {
510 *nbytes -= *length;
511 *offset += *length;
512 }
513
514 return 0;
515 } else {
516 len = (*nbytes <= dev->scatter_buffer_size) ?
517 (*nbytes) : dev->scatter_buffer_size;
518 memcpy(phys_to_virt(*addr),
519 dev->scatter_buffer_va +
520 *idx * dev->scatter_buffer_size + *offset,
521 len);
522 *offset = 0;
523 *nbytes -= len;
524
525 if (*idx == PPC4XX_LAST_SD)
526 *idx = 0;
527 else
528 (*idx)++;
529
530 return 0;
531 }
532}
533
534static void crypto4xx_copy_pkt_to_dst(struct crypto4xx_device *dev,
535 struct ce_pd *pd,
536 struct pd_uinfo *pd_uinfo,
537 u32 nbytes,
538 struct scatterlist *dst)
539{
540 dma_addr_t addr;
541 u32 this_sd;
542 u32 offset;
543 u32 len;
544 u32 i;
545 u32 sg_len;
546 struct scatterlist *sg;
547
548 this_sd = pd_uinfo->first_sd;
549 offset = 0;
550 i = 0;
551
552 while (nbytes) {
553 sg = &dst[i];
554 sg_len = sg->length;
555 addr = dma_map_page(dev->core_dev->device, sg_page(sg),
556 sg->offset, sg->length, DMA_TO_DEVICE);
557
558 if (offset == 0) {
559 len = (nbytes <= sg->length) ? nbytes : sg->length;
560 while (crypto4xx_fill_one_page(dev, &addr, &len,
561 &this_sd, &offset, &nbytes))
562 ;
563 if (!nbytes)
564 return;
565 i++;
566 } else {
567 len = (nbytes <= (dev->scatter_buffer_size - offset)) ?
568 nbytes : (dev->scatter_buffer_size - offset);
569 len = (sg->length < len) ? sg->length : len;
570 while (crypto4xx_fill_one_page(dev, &addr, &len,
571 &this_sd, &offset, &nbytes))
572 ;
573 if (!nbytes)
574 return;
575 sg_len -= len;
576 if (sg_len) {
577 addr += len;
578 while (crypto4xx_fill_one_page(dev, &addr,
579 &sg_len, &this_sd, &offset, &nbytes))
580 ;
581 }
582 i++;
583 }
584 }
585}
586
587static u32 crypto4xx_copy_digest_to_dst(struct pd_uinfo *pd_uinfo,
588 struct crypto4xx_ctx *ctx)
589{
590 struct dynamic_sa_ctl *sa = (struct dynamic_sa_ctl *) ctx->sa_in;
591 struct sa_state_record *state_record =
592 (struct sa_state_record *) pd_uinfo->sr_va;
593
594 if (sa->sa_command_0.bf.hash_alg == SA_HASH_ALG_SHA1) {
595 memcpy((void *) pd_uinfo->dest_va, state_record->save_digest,
596 SA_HASH_ALG_SHA1_DIGEST_SIZE);
597 }
598
599 return 0;
600}
601
602static void crypto4xx_ret_sg_desc(struct crypto4xx_device *dev,
603 struct pd_uinfo *pd_uinfo)
604{
605 int i;
606 if (pd_uinfo->num_gd) {
607 for (i = 0; i < pd_uinfo->num_gd; i++)
608 crypto4xx_put_gd_to_gdr(dev);
609 pd_uinfo->first_gd = 0xffffffff;
610 pd_uinfo->num_gd = 0;
611 }
612 if (pd_uinfo->num_sd) {
613 for (i = 0; i < pd_uinfo->num_sd; i++)
614 crypto4xx_put_sd_to_sdr(dev);
615
616 pd_uinfo->first_sd = 0xffffffff;
617 pd_uinfo->num_sd = 0;
618 }
619}
620
621static u32 crypto4xx_ablkcipher_done(struct crypto4xx_device *dev,
622 struct pd_uinfo *pd_uinfo,
623 struct ce_pd *pd)
624{
625 struct crypto4xx_ctx *ctx;
626 struct ablkcipher_request *ablk_req;
627 struct scatterlist *dst;
628 dma_addr_t addr;
629
630 ablk_req = ablkcipher_request_cast(pd_uinfo->async_req);
631 ctx = crypto_tfm_ctx(ablk_req->base.tfm);
632
633 if (pd_uinfo->using_sd) {
634 crypto4xx_copy_pkt_to_dst(dev, pd, pd_uinfo, ablk_req->nbytes,
635 ablk_req->dst);
636 } else {
637 dst = pd_uinfo->dest_va;
638 addr = dma_map_page(dev->core_dev->device, sg_page(dst),
639 dst->offset, dst->length, DMA_FROM_DEVICE);
640 }
641 crypto4xx_ret_sg_desc(dev, pd_uinfo);
642 if (ablk_req->base.complete != NULL)
643 ablk_req->base.complete(&ablk_req->base, 0);
644
645 return 0;
646}
647
648static u32 crypto4xx_ahash_done(struct crypto4xx_device *dev,
649 struct pd_uinfo *pd_uinfo)
650{
651 struct crypto4xx_ctx *ctx;
652 struct ahash_request *ahash_req;
653
654 ahash_req = ahash_request_cast(pd_uinfo->async_req);
655 ctx = crypto_tfm_ctx(ahash_req->base.tfm);
656
657 crypto4xx_copy_digest_to_dst(pd_uinfo,
658 crypto_tfm_ctx(ahash_req->base.tfm));
659 crypto4xx_ret_sg_desc(dev, pd_uinfo);
660 /* call user provided callback function x */
661 if (ahash_req->base.complete != NULL)
662 ahash_req->base.complete(&ahash_req->base, 0);
663
664 return 0;
665}
666
667static u32 crypto4xx_pd_done(struct crypto4xx_device *dev, u32 idx)
668{
669 struct ce_pd *pd;
670 struct pd_uinfo *pd_uinfo;
671
672 pd = dev->pdr + sizeof(struct ce_pd)*idx;
673 pd_uinfo = dev->pdr_uinfo + sizeof(struct pd_uinfo)*idx;
674 if (crypto_tfm_alg_type(pd_uinfo->async_req->tfm) ==
675 CRYPTO_ALG_TYPE_ABLKCIPHER)
676 return crypto4xx_ablkcipher_done(dev, pd_uinfo, pd);
677 else
678 return crypto4xx_ahash_done(dev, pd_uinfo);
679}
680
681/**
682 * Note: Only use this function to copy items that is word aligned.
683 */
684void crypto4xx_memcpy_le(unsigned int *dst,
685 const unsigned char *buf,
686 int len)
687{
688 u8 *tmp;
689 for (; len >= 4; buf += 4, len -= 4)
690 *dst++ = cpu_to_le32(*(unsigned int *) buf);
691
692 tmp = (u8 *)dst;
693 switch (len) {
694 case 3:
695 *tmp++ = 0;
696 *tmp++ = *(buf+2);
697 *tmp++ = *(buf+1);
698 *tmp++ = *buf;
699 break;
700 case 2:
701 *tmp++ = 0;
702 *tmp++ = 0;
703 *tmp++ = *(buf+1);
704 *tmp++ = *buf;
705 break;
706 case 1:
707 *tmp++ = 0;
708 *tmp++ = 0;
709 *tmp++ = 0;
710 *tmp++ = *buf;
711 break;
712 default:
713 break;
714 }
715}
716
717static void crypto4xx_stop_all(struct crypto4xx_core_device *core_dev)
718{
719 crypto4xx_destroy_pdr(core_dev->dev);
720 crypto4xx_destroy_gdr(core_dev->dev);
721 crypto4xx_destroy_sdr(core_dev->dev);
722 dev_set_drvdata(core_dev->device, NULL);
723 iounmap(core_dev->dev->ce_base);
724 kfree(core_dev->dev);
725 kfree(core_dev);
726}
727
728void crypto4xx_return_pd(struct crypto4xx_device *dev,
729 u32 pd_entry, struct ce_pd *pd,
730 struct pd_uinfo *pd_uinfo)
731{
732 /* irq should be already disabled */
733 dev->pdr_head = pd_entry;
734 pd->pd_ctl.w = 0;
735 pd->pd_ctl_len.w = 0;
736 pd_uinfo->state = PD_ENTRY_FREE;
737}
738
739/*
740 * derive number of elements in scatterlist
741 * Shamlessly copy from talitos.c
742 */
743static int get_sg_count(struct scatterlist *sg_list, int nbytes)
744{
745 struct scatterlist *sg = sg_list;
746 int sg_nents = 0;
747
748 while (nbytes) {
749 sg_nents++;
750 if (sg->length > nbytes)
751 break;
752 nbytes -= sg->length;
753 sg = sg_next(sg);
754 }
755
756 return sg_nents;
757}
758
759static u32 get_next_gd(u32 current)
760{
761 if (current != PPC4XX_LAST_GD)
762 return current + 1;
763 else
764 return 0;
765}
766
767static u32 get_next_sd(u32 current)
768{
769 if (current != PPC4XX_LAST_SD)
770 return current + 1;
771 else
772 return 0;
773}
774
775u32 crypto4xx_build_pd(struct crypto_async_request *req,
776 struct crypto4xx_ctx *ctx,
777 struct scatterlist *src,
778 struct scatterlist *dst,
779 unsigned int datalen,
780 void *iv, u32 iv_len)
781{
782 struct crypto4xx_device *dev = ctx->dev;
783 dma_addr_t addr, pd_dma, sd_dma, gd_dma;
784 struct dynamic_sa_ctl *sa;
785 struct scatterlist *sg;
786 struct ce_gd *gd;
787 struct ce_pd *pd;
788 u32 num_gd, num_sd;
789 u32 fst_gd = 0xffffffff;
790 u32 fst_sd = 0xffffffff;
791 u32 pd_entry;
792 unsigned long flags;
793 struct pd_uinfo *pd_uinfo = NULL;
794 unsigned int nbytes = datalen, idx;
795 unsigned int ivlen = 0;
796 u32 gd_idx = 0;
797
798 /* figure how many gd is needed */
799 num_gd = get_sg_count(src, datalen);
800 if (num_gd == 1)
801 num_gd = 0;
802
803 /* figure how many sd is needed */
804 if (sg_is_last(dst) || ctx->is_hash) {
805 num_sd = 0;
806 } else {
807 if (datalen > PPC4XX_SD_BUFFER_SIZE) {
808 num_sd = datalen / PPC4XX_SD_BUFFER_SIZE;
809 if (datalen % PPC4XX_SD_BUFFER_SIZE)
810 num_sd++;
811 } else {
812 num_sd = 1;
813 }
814 }
815
816 /*
817 * The follow section of code needs to be protected
818 * The gather ring and scatter ring needs to be consecutive
819 * In case of run out of any kind of descriptor, the descriptor
820 * already got must be return the original place.
821 */
822 spin_lock_irqsave(&dev->core_dev->lock, flags);
823 if (num_gd) {
824 fst_gd = crypto4xx_get_n_gd(dev, num_gd);
825 if (fst_gd == ERING_WAS_FULL) {
826 spin_unlock_irqrestore(&dev->core_dev->lock, flags);
827 return -EAGAIN;
828 }
829 }
830 if (num_sd) {
831 fst_sd = crypto4xx_get_n_sd(dev, num_sd);
832 if (fst_sd == ERING_WAS_FULL) {
833 if (num_gd)
834 dev->gdr_head = fst_gd;
835 spin_unlock_irqrestore(&dev->core_dev->lock, flags);
836 return -EAGAIN;
837 }
838 }
839 pd_entry = crypto4xx_get_pd_from_pdr_nolock(dev);
840 if (pd_entry == ERING_WAS_FULL) {
841 if (num_gd)
842 dev->gdr_head = fst_gd;
843 if (num_sd)
844 dev->sdr_head = fst_sd;
845 spin_unlock_irqrestore(&dev->core_dev->lock, flags);
846 return -EAGAIN;
847 }
848 spin_unlock_irqrestore(&dev->core_dev->lock, flags);
849
850 pd_uinfo = (struct pd_uinfo *)(dev->pdr_uinfo +
851 sizeof(struct pd_uinfo) * pd_entry);
852 pd = crypto4xx_get_pdp(dev, &pd_dma, pd_entry);
853 pd_uinfo->async_req = req;
854 pd_uinfo->num_gd = num_gd;
855 pd_uinfo->num_sd = num_sd;
856
857 if (iv_len || ctx->is_hash) {
858 ivlen = iv_len;
859 pd->sa = pd_uinfo->sa_pa;
860 sa = (struct dynamic_sa_ctl *) pd_uinfo->sa_va;
861 if (ctx->direction == DIR_INBOUND)
862 memcpy(sa, ctx->sa_in, ctx->sa_len * 4);
863 else
864 memcpy(sa, ctx->sa_out, ctx->sa_len * 4);
865
866 memcpy((void *) sa + ctx->offset_to_sr_ptr,
867 &pd_uinfo->sr_pa, 4);
868
869 if (iv_len)
870 crypto4xx_memcpy_le(pd_uinfo->sr_va, iv, iv_len);
871 } else {
872 if (ctx->direction == DIR_INBOUND) {
873 pd->sa = ctx->sa_in_dma_addr;
874 sa = (struct dynamic_sa_ctl *) ctx->sa_in;
875 } else {
876 pd->sa = ctx->sa_out_dma_addr;
877 sa = (struct dynamic_sa_ctl *) ctx->sa_out;
878 }
879 }
880 pd->sa_len = ctx->sa_len;
881 if (num_gd) {
882 /* get first gd we are going to use */
883 gd_idx = fst_gd;
884 pd_uinfo->first_gd = fst_gd;
885 pd_uinfo->num_gd = num_gd;
886 gd = crypto4xx_get_gdp(dev, &gd_dma, gd_idx);
887 pd->src = gd_dma;
888 /* enable gather */
889 sa->sa_command_0.bf.gather = 1;
890 idx = 0;
891 src = &src[0];
892 /* walk the sg, and setup gather array */
893 while (nbytes) {
894 sg = &src[idx];
895 addr = dma_map_page(dev->core_dev->device, sg_page(sg),
896 sg->offset, sg->length, DMA_TO_DEVICE);
897 gd->ptr = addr;
898 gd->ctl_len.len = sg->length;
899 gd->ctl_len.done = 0;
900 gd->ctl_len.ready = 1;
901 if (sg->length >= nbytes)
902 break;
903 nbytes -= sg->length;
904 gd_idx = get_next_gd(gd_idx);
905 gd = crypto4xx_get_gdp(dev, &gd_dma, gd_idx);
906 idx++;
907 }
908 } else {
909 pd->src = (u32)dma_map_page(dev->core_dev->device, sg_page(src),
910 src->offset, src->length, DMA_TO_DEVICE);
911 /*
912 * Disable gather in sa command
913 */
914 sa->sa_command_0.bf.gather = 0;
915 /*
916 * Indicate gather array is not used
917 */
918 pd_uinfo->first_gd = 0xffffffff;
919 pd_uinfo->num_gd = 0;
920 }
921 if (ctx->is_hash || sg_is_last(dst)) {
922 /*
923 * we know application give us dst a whole piece of memory
924 * no need to use scatter ring.
925 * In case of is_hash, the icv is always at end of src data.
926 */
927 pd_uinfo->using_sd = 0;
928 pd_uinfo->first_sd = 0xffffffff;
929 pd_uinfo->num_sd = 0;
930 pd_uinfo->dest_va = dst;
931 sa->sa_command_0.bf.scatter = 0;
932 if (ctx->is_hash)
933 pd->dest = virt_to_phys((void *)dst);
934 else
935 pd->dest = (u32)dma_map_page(dev->core_dev->device,
936 sg_page(dst), dst->offset,
937 dst->length, DMA_TO_DEVICE);
938 } else {
939 struct ce_sd *sd = NULL;
940 u32 sd_idx = fst_sd;
941 nbytes = datalen;
942 sa->sa_command_0.bf.scatter = 1;
943 pd_uinfo->using_sd = 1;
944 pd_uinfo->dest_va = dst;
945 pd_uinfo->first_sd = fst_sd;
946 pd_uinfo->num_sd = num_sd;
947 sd = crypto4xx_get_sdp(dev, &sd_dma, sd_idx);
948 pd->dest = sd_dma;
949 /* setup scatter descriptor */
950 sd->ctl.done = 0;
951 sd->ctl.rdy = 1;
952 /* sd->ptr should be setup by sd_init routine*/
953 idx = 0;
954 if (nbytes >= PPC4XX_SD_BUFFER_SIZE)
955 nbytes -= PPC4XX_SD_BUFFER_SIZE;
956 else
957 nbytes = 0;
958 while (nbytes) {
959 sd_idx = get_next_sd(sd_idx);
960 sd = crypto4xx_get_sdp(dev, &sd_dma, sd_idx);
961 /* setup scatter descriptor */
962 sd->ctl.done = 0;
963 sd->ctl.rdy = 1;
964 if (nbytes >= PPC4XX_SD_BUFFER_SIZE)
965 nbytes -= PPC4XX_SD_BUFFER_SIZE;
966 else
967 /*
968 * SD entry can hold PPC4XX_SD_BUFFER_SIZE,
969 * which is more than nbytes, so done.
970 */
971 nbytes = 0;
972 }
973 }
974
975 sa->sa_command_1.bf.hash_crypto_offset = 0;
976 pd->pd_ctl.w = ctx->pd_ctl;
977 pd->pd_ctl_len.w = 0x00400000 | (ctx->bypass << 24) | datalen;
978 pd_uinfo->state = PD_ENTRY_INUSE;
979 wmb();
980 /* write any value to push engine to read a pd */
981 writel(1, dev->ce_base + CRYPTO4XX_INT_DESCR_RD);
982 return -EINPROGRESS;
983}
984
985/**
986 * Algorithm Registration Functions
987 */
988static int crypto4xx_alg_init(struct crypto_tfm *tfm)
989{
990 struct crypto_alg *alg = tfm->__crt_alg;
991 struct crypto4xx_alg *amcc_alg = crypto_alg_to_crypto4xx_alg(alg);
992 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(tfm);
993
994 ctx->dev = amcc_alg->dev;
995 ctx->sa_in = NULL;
996 ctx->sa_out = NULL;
997 ctx->sa_in_dma_addr = 0;
998 ctx->sa_out_dma_addr = 0;
999 ctx->sa_len = 0;
1000
1001 if (alg->cra_type == &crypto_ablkcipher_type)
1002 tfm->crt_ablkcipher.reqsize = sizeof(struct crypto4xx_ctx);
1003 else if (alg->cra_type == &crypto_ahash_type)
1004 tfm->crt_ahash.reqsize = sizeof(struct crypto4xx_ctx);
1005
1006 return 0;
1007}
1008
1009static void crypto4xx_alg_exit(struct crypto_tfm *tfm)
1010{
1011 struct crypto4xx_ctx *ctx = crypto_tfm_ctx(tfm);
1012
1013 crypto4xx_free_sa(ctx);
1014 crypto4xx_free_state_record(ctx);
1015}
1016
1017int crypto4xx_register_alg(struct crypto4xx_device *sec_dev,
1018 struct crypto_alg *crypto_alg, int array_size)
1019{
1020 struct crypto4xx_alg *alg;
1021 int i;
1022 int rc = 0;
1023
1024 for (i = 0; i < array_size; i++) {
1025 alg = kzalloc(sizeof(struct crypto4xx_alg), GFP_KERNEL);
1026 if (!alg)
1027 return -ENOMEM;
1028
1029 alg->alg = crypto_alg[i];
1030 INIT_LIST_HEAD(&alg->alg.cra_list);
1031 if (alg->alg.cra_init == NULL)
1032 alg->alg.cra_init = crypto4xx_alg_init;
1033 if (alg->alg.cra_exit == NULL)
1034 alg->alg.cra_exit = crypto4xx_alg_exit;
1035 alg->dev = sec_dev;
1036 rc = crypto_register_alg(&alg->alg);
1037 if (rc) {
1038 list_del(&alg->entry);
1039 kfree(alg);
1040 } else {
1041 list_add_tail(&alg->entry, &sec_dev->alg_list);
1042 }
1043 }
1044
1045 return 0;
1046}
1047
1048static void crypto4xx_unregister_alg(struct crypto4xx_device *sec_dev)
1049{
1050 struct crypto4xx_alg *alg, *tmp;
1051
1052 list_for_each_entry_safe(alg, tmp, &sec_dev->alg_list, entry) {
1053 list_del(&alg->entry);
1054 crypto_unregister_alg(&alg->alg);
1055 kfree(alg);
1056 }
1057}
1058
1059static void crypto4xx_bh_tasklet_cb(unsigned long data)
1060{
1061 struct device *dev = (struct device *)data;
1062 struct crypto4xx_core_device *core_dev = dev_get_drvdata(dev);
1063 struct pd_uinfo *pd_uinfo;
1064 struct ce_pd *pd;
1065 u32 tail;
1066
1067 while (core_dev->dev->pdr_head != core_dev->dev->pdr_tail) {
1068 tail = core_dev->dev->pdr_tail;
1069 pd_uinfo = core_dev->dev->pdr_uinfo +
1070 sizeof(struct pd_uinfo)*tail;
1071 pd = core_dev->dev->pdr + sizeof(struct ce_pd) * tail;
1072 if ((pd_uinfo->state == PD_ENTRY_INUSE) &&
1073 pd->pd_ctl.bf.pe_done &&
1074 !pd->pd_ctl.bf.host_ready) {
1075 pd->pd_ctl.bf.pe_done = 0;
1076 crypto4xx_pd_done(core_dev->dev, tail);
1077 crypto4xx_put_pd_to_pdr(core_dev->dev, tail);
1078 pd_uinfo->state = PD_ENTRY_FREE;
1079 } else {
1080 /* if tail not done, break */
1081 break;
1082 }
1083 }
1084}
1085
1086/**
1087 * Top Half of isr.
1088 */
1089static irqreturn_t crypto4xx_ce_interrupt_handler(int irq, void *data)
1090{
1091 struct device *dev = (struct device *)data;
1092 struct crypto4xx_core_device *core_dev = dev_get_drvdata(dev);
1093
1094 if (core_dev->dev->ce_base == 0)
1095 return 0;
1096
1097 writel(PPC4XX_INTERRUPT_CLR,
1098 core_dev->dev->ce_base + CRYPTO4XX_INT_CLR);
1099 tasklet_schedule(&core_dev->tasklet);
1100
1101 return IRQ_HANDLED;
1102}
1103
1104/**
1105 * Supported Crypto Algorithms
1106 */
1107struct crypto_alg crypto4xx_alg[] = {
1108 /* Crypto AES modes */
1109 {
1110 .cra_name = "cbc(aes)",
1111 .cra_driver_name = "cbc-aes-ppc4xx",
1112 .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
1113 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
1114 .cra_blocksize = AES_BLOCK_SIZE,
1115 .cra_ctxsize = sizeof(struct crypto4xx_ctx),
1116 .cra_alignmask = 0,
1117 .cra_type = &crypto_ablkcipher_type,
1118 .cra_module = THIS_MODULE,
1119 .cra_u = {
1120 .ablkcipher = {
1121 .min_keysize = AES_MIN_KEY_SIZE,
1122 .max_keysize = AES_MAX_KEY_SIZE,
1123 .ivsize = AES_IV_SIZE,
1124 .setkey = crypto4xx_setkey_aes_cbc,
1125 .encrypt = crypto4xx_encrypt,
1126 .decrypt = crypto4xx_decrypt,
1127 }
1128 }
1129 },
1130 /* Hash SHA1 */
1131 {
1132 .cra_name = "sha1",
1133 .cra_driver_name = "sha1-ppc4xx",
1134 .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
1135 .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC,
1136 .cra_blocksize = SHA1_BLOCK_SIZE,
1137 .cra_ctxsize = sizeof(struct crypto4xx_ctx),
1138 .cra_alignmask = 0,
1139 .cra_type = &crypto_ahash_type,
1140 .cra_init = crypto4xx_sha1_alg_init,
1141 .cra_module = THIS_MODULE,
1142 .cra_u = {
1143 .ahash = {
1144 .digestsize = SHA1_DIGEST_SIZE,
1145 .init = crypto4xx_hash_init,
1146 .update = crypto4xx_hash_update,
1147 .final = crypto4xx_hash_final,
1148 .digest = crypto4xx_hash_digest,
1149 }
1150 }
1151 },
1152};
1153
1154/**
1155 * Module Initialization Routine
1156 */
1157static int __init crypto4xx_probe(struct of_device *ofdev,
1158 const struct of_device_id *match)
1159{
1160 int rc;
1161 struct resource res;
1162 struct device *dev = &ofdev->dev;
1163 struct crypto4xx_core_device *core_dev;
1164
1165 rc = of_address_to_resource(ofdev->node, 0, &res);
1166 if (rc)
1167 return -ENODEV;
1168
1169 if (of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-crypto")) {
1170 mtdcri(SDR0, PPC460EX_SDR0_SRST,
1171 mfdcri(SDR0, PPC460EX_SDR0_SRST) | PPC460EX_CE_RESET);
1172 mtdcri(SDR0, PPC460EX_SDR0_SRST,
1173 mfdcri(SDR0, PPC460EX_SDR0_SRST) & ~PPC460EX_CE_RESET);
1174 } else if (of_find_compatible_node(NULL, NULL,
1175 "amcc,ppc405ex-crypto")) {
1176 mtdcri(SDR0, PPC405EX_SDR0_SRST,
1177 mfdcri(SDR0, PPC405EX_SDR0_SRST) | PPC405EX_CE_RESET);
1178 mtdcri(SDR0, PPC405EX_SDR0_SRST,
1179 mfdcri(SDR0, PPC405EX_SDR0_SRST) & ~PPC405EX_CE_RESET);
1180 } else if (of_find_compatible_node(NULL, NULL,
1181 "amcc,ppc460sx-crypto")) {
1182 mtdcri(SDR0, PPC460SX_SDR0_SRST,
1183 mfdcri(SDR0, PPC460SX_SDR0_SRST) | PPC460SX_CE_RESET);
1184 mtdcri(SDR0, PPC460SX_SDR0_SRST,
1185 mfdcri(SDR0, PPC460SX_SDR0_SRST) & ~PPC460SX_CE_RESET);
1186 } else {
1187 printk(KERN_ERR "Crypto Function Not supported!\n");
1188 return -EINVAL;
1189 }
1190
1191 core_dev = kzalloc(sizeof(struct crypto4xx_core_device), GFP_KERNEL);
1192 if (!core_dev)
1193 return -ENOMEM;
1194
1195 dev_set_drvdata(dev, core_dev);
1196 core_dev->ofdev = ofdev;
1197 core_dev->dev = kzalloc(sizeof(struct crypto4xx_device), GFP_KERNEL);
1198 if (!core_dev->dev)
1199 goto err_alloc_dev;
1200
1201 core_dev->dev->core_dev = core_dev;
1202 core_dev->device = dev;
1203 spin_lock_init(&core_dev->lock);
1204 INIT_LIST_HEAD(&core_dev->dev->alg_list);
1205 rc = crypto4xx_build_pdr(core_dev->dev);
1206 if (rc)
1207 goto err_build_pdr;
1208
1209 rc = crypto4xx_build_gdr(core_dev->dev);
1210 if (rc)
1211 goto err_build_gdr;
1212
1213 rc = crypto4xx_build_sdr(core_dev->dev);
1214 if (rc)
1215 goto err_build_sdr;
1216
1217 /* Init tasklet for bottom half processing */
1218 tasklet_init(&core_dev->tasklet, crypto4xx_bh_tasklet_cb,
1219 (unsigned long) dev);
1220
1221 /* Register for Crypto isr, Crypto Engine IRQ */
1222 core_dev->irq = irq_of_parse_and_map(ofdev->node, 0);
1223 rc = request_irq(core_dev->irq, crypto4xx_ce_interrupt_handler, 0,
1224 core_dev->dev->name, dev);
1225 if (rc)
1226 goto err_request_irq;
1227
1228 core_dev->dev->ce_base = of_iomap(ofdev->node, 0);
1229 if (!core_dev->dev->ce_base) {
1230 dev_err(dev, "failed to of_iomap\n");
1231 goto err_iomap;
1232 }
1233
1234 /* need to setup pdr, rdr, gdr and sdr before this */
1235 crypto4xx_hw_init(core_dev->dev);
1236
1237 /* Register security algorithms with Linux CryptoAPI */
1238 rc = crypto4xx_register_alg(core_dev->dev, crypto4xx_alg,
1239 ARRAY_SIZE(crypto4xx_alg));
1240 if (rc)
1241 goto err_start_dev;
1242
1243 return 0;
1244
1245err_start_dev:
1246 iounmap(core_dev->dev->ce_base);
1247err_iomap:
1248 free_irq(core_dev->irq, dev);
1249 irq_dispose_mapping(core_dev->irq);
1250 tasklet_kill(&core_dev->tasklet);
1251err_request_irq:
1252 crypto4xx_destroy_sdr(core_dev->dev);
1253err_build_sdr:
1254 crypto4xx_destroy_gdr(core_dev->dev);
1255err_build_gdr:
1256 crypto4xx_destroy_pdr(core_dev->dev);
1257err_build_pdr:
1258 kfree(core_dev->dev);
1259err_alloc_dev:
1260 kfree(core_dev);
1261
1262 return rc;
1263}
1264
1265static int __exit crypto4xx_remove(struct of_device *ofdev)
1266{
1267 struct device *dev = &ofdev->dev;
1268 struct crypto4xx_core_device *core_dev = dev_get_drvdata(dev);
1269
1270 free_irq(core_dev->irq, dev);
1271 irq_dispose_mapping(core_dev->irq);
1272
1273 tasklet_kill(&core_dev->tasklet);
1274 /* Un-register with Linux CryptoAPI */
1275 crypto4xx_unregister_alg(core_dev->dev);
1276 /* Free all allocated memory */
1277 crypto4xx_stop_all(core_dev);
1278
1279 return 0;
1280}
1281
1282static struct of_device_id crypto4xx_match[] = {
1283 { .compatible = "amcc,ppc4xx-crypto",},
1284 { },
1285};
1286
1287static struct of_platform_driver crypto4xx_driver = {
1288 .name = "crypto4xx",
1289 .match_table = crypto4xx_match,
1290 .probe = crypto4xx_probe,
1291 .remove = crypto4xx_remove,
1292};
1293
1294static int __init crypto4xx_init(void)
1295{
1296 return of_register_platform_driver(&crypto4xx_driver);
1297}
1298
1299static void __exit crypto4xx_exit(void)
1300{
1301 of_unregister_platform_driver(&crypto4xx_driver);
1302}
1303
1304module_init(crypto4xx_init);
1305module_exit(crypto4xx_exit);
1306
1307MODULE_LICENSE("GPL");
1308MODULE_AUTHOR("James Hsiao <jhsiao@amcc.com>");
1309MODULE_DESCRIPTION("Driver for AMCC PPC4xx crypto accelerator");
1310
diff --git a/drivers/crypto/amcc/crypto4xx_core.h b/drivers/crypto/amcc/crypto4xx_core.h
new file mode 100644
index 000000000000..1ef103449364
--- /dev/null
+++ b/drivers/crypto/amcc/crypto4xx_core.h
@@ -0,0 +1,177 @@
1/**
2 * AMCC SoC PPC4xx Crypto Driver
3 *
4 * Copyright (c) 2008 Applied Micro Circuits Corporation.
5 * All rights reserved. James Hsiao <jhsiao@amcc.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 * This is the header file for AMCC Crypto offload Linux device driver for
18 * use with Linux CryptoAPI.
19
20 */
21
22#ifndef __CRYPTO4XX_CORE_H__
23#define __CRYPTO4XX_CORE_H__
24
25#define PPC460SX_SDR0_SRST 0x201
26#define PPC405EX_SDR0_SRST 0x200
27#define PPC460EX_SDR0_SRST 0x201
28#define PPC460EX_CE_RESET 0x08000000
29#define PPC460SX_CE_RESET 0x20000000
30#define PPC405EX_CE_RESET 0x00000008
31
32#define CRYPTO4XX_CRYPTO_PRIORITY 300
33#define PPC4XX_LAST_PD 63
34#define PPC4XX_NUM_PD 64
35#define PPC4XX_LAST_GD 1023
36#define PPC4XX_NUM_GD 1024
37#define PPC4XX_LAST_SD 63
38#define PPC4XX_NUM_SD 64
39#define PPC4XX_SD_BUFFER_SIZE 2048
40
41#define PD_ENTRY_INUSE 1
42#define PD_ENTRY_FREE 0
43#define ERING_WAS_FULL 0xffffffff
44
45struct crypto4xx_device;
46
47struct pd_uinfo {
48 struct crypto4xx_device *dev;
49 u32 state;
50 u32 using_sd;
51 u32 first_gd; /* first gather discriptor
52 used by this packet */
53 u32 num_gd; /* number of gather discriptor
54 used by this packet */
55 u32 first_sd; /* first scatter discriptor
56 used by this packet */
57 u32 num_sd; /* number of scatter discriptors
58 used by this packet */
59 void *sa_va; /* shadow sa, when using cp from ctx->sa */
60 u32 sa_pa;
61 void *sr_va; /* state record for shadow sa */
62 u32 sr_pa;
63 struct scatterlist *dest_va;
64 struct crypto_async_request *async_req; /* base crypto request
65 for this packet */
66};
67
68struct crypto4xx_device {
69 struct crypto4xx_core_device *core_dev;
70 char *name;
71 u64 ce_phy_address;
72 void __iomem *ce_base;
73
74 void *pdr; /* base address of packet
75 descriptor ring */
76 dma_addr_t pdr_pa; /* physical address used to
77 program ce pdr_base_register */
78 void *gdr; /* gather descriptor ring */
79 dma_addr_t gdr_pa; /* physical address used to
80 program ce gdr_base_register */
81 void *sdr; /* scatter descriptor ring */
82 dma_addr_t sdr_pa; /* physical address used to
83 program ce sdr_base_register */
84 void *scatter_buffer_va;
85 dma_addr_t scatter_buffer_pa;
86 u32 scatter_buffer_size;
87
88 void *shadow_sa_pool; /* pool of memory for sa in pd_uinfo */
89 dma_addr_t shadow_sa_pool_pa;
90 void *shadow_sr_pool; /* pool of memory for sr in pd_uinfo */
91 dma_addr_t shadow_sr_pool_pa;
92 u32 pdr_tail;
93 u32 pdr_head;
94 u32 gdr_tail;
95 u32 gdr_head;
96 u32 sdr_tail;
97 u32 sdr_head;
98 void *pdr_uinfo;
99 struct list_head alg_list; /* List of algorithm supported
100 by this device */
101};
102
103struct crypto4xx_core_device {
104 struct device *device;
105 struct of_device *ofdev;
106 struct crypto4xx_device *dev;
107 u32 int_status;
108 u32 irq;
109 struct tasklet_struct tasklet;
110 spinlock_t lock;
111};
112
113struct crypto4xx_ctx {
114 struct crypto4xx_device *dev;
115 void *sa_in;
116 dma_addr_t sa_in_dma_addr;
117 void *sa_out;
118 dma_addr_t sa_out_dma_addr;
119 void *state_record;
120 dma_addr_t state_record_dma_addr;
121 u32 sa_len;
122 u32 offset_to_sr_ptr; /* offset to state ptr, in dynamic sa */
123 u32 direction;
124 u32 next_hdr;
125 u32 save_iv;
126 u32 pd_ctl_len;
127 u32 pd_ctl;
128 u32 bypass;
129 u32 is_hash;
130 u32 hash_final;
131};
132
133struct crypto4xx_req_ctx {
134 struct crypto4xx_device *dev; /* Device in which
135 operation to send to */
136 void *sa;
137 u32 sa_dma_addr;
138 u16 sa_len;
139};
140
141struct crypto4xx_alg {
142 struct list_head entry;
143 struct crypto_alg alg;
144 struct crypto4xx_device *dev;
145};
146
147#define crypto_alg_to_crypto4xx_alg(x) \
148 container_of(x, struct crypto4xx_alg, alg)
149
150extern int crypto4xx_alloc_sa(struct crypto4xx_ctx *ctx, u32 size);
151extern void crypto4xx_free_sa(struct crypto4xx_ctx *ctx);
152extern u32 crypto4xx_alloc_sa_rctx(struct crypto4xx_ctx *ctx,
153 struct crypto4xx_ctx *rctx);
154extern void crypto4xx_free_sa_rctx(struct crypto4xx_ctx *rctx);
155extern void crypto4xx_free_ctx(struct crypto4xx_ctx *ctx);
156extern u32 crypto4xx_alloc_state_record(struct crypto4xx_ctx *ctx);
157extern u32 get_dynamic_sa_offset_state_ptr_field(struct crypto4xx_ctx *ctx);
158extern u32 get_dynamic_sa_offset_key_field(struct crypto4xx_ctx *ctx);
159extern u32 get_dynamic_sa_iv_size(struct crypto4xx_ctx *ctx);
160extern void crypto4xx_memcpy_le(unsigned int *dst,
161 const unsigned char *buf, int len);
162extern u32 crypto4xx_build_pd(struct crypto_async_request *req,
163 struct crypto4xx_ctx *ctx,
164 struct scatterlist *src,
165 struct scatterlist *dst,
166 unsigned int datalen,
167 void *iv, u32 iv_len);
168extern int crypto4xx_setkey_aes_cbc(struct crypto_ablkcipher *cipher,
169 const u8 *key, unsigned int keylen);
170extern int crypto4xx_encrypt(struct ablkcipher_request *req);
171extern int crypto4xx_decrypt(struct ablkcipher_request *req);
172extern int crypto4xx_sha1_alg_init(struct crypto_tfm *tfm);
173extern int crypto4xx_hash_digest(struct ahash_request *req);
174extern int crypto4xx_hash_final(struct ahash_request *req);
175extern int crypto4xx_hash_update(struct ahash_request *req);
176extern int crypto4xx_hash_init(struct ahash_request *req);
177#endif
diff --git a/drivers/crypto/amcc/crypto4xx_reg_def.h b/drivers/crypto/amcc/crypto4xx_reg_def.h
new file mode 100644
index 000000000000..7d4edb002619
--- /dev/null
+++ b/drivers/crypto/amcc/crypto4xx_reg_def.h
@@ -0,0 +1,284 @@
1/**
2 * AMCC SoC PPC4xx Crypto Driver
3 *
4 * Copyright (c) 2008 Applied Micro Circuits Corporation.
5 * All rights reserved. James Hsiao <jhsiao@amcc.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 * This filr defines the register set for Security Subsystem
18 */
19
20#ifndef __CRYPTO4XX_REG_DEF_H__
21#define __CRYPTO4XX_REG_DEF_H__
22
23/* CRYPTO4XX Register offset */
24#define CRYPTO4XX_DESCRIPTOR 0x00000000
25#define CRYPTO4XX_CTRL_STAT 0x00000000
26#define CRYPTO4XX_SOURCE 0x00000004
27#define CRYPTO4XX_DEST 0x00000008
28#define CRYPTO4XX_SA 0x0000000C
29#define CRYPTO4XX_SA_LENGTH 0x00000010
30#define CRYPTO4XX_LENGTH 0x00000014
31
32#define CRYPTO4XX_PE_DMA_CFG 0x00000040
33#define CRYPTO4XX_PE_DMA_STAT 0x00000044
34#define CRYPTO4XX_PDR_BASE 0x00000048
35#define CRYPTO4XX_RDR_BASE 0x0000004c
36#define CRYPTO4XX_RING_SIZE 0x00000050
37#define CRYPTO4XX_RING_CTRL 0x00000054
38#define CRYPTO4XX_INT_RING_STAT 0x00000058
39#define CRYPTO4XX_EXT_RING_STAT 0x0000005c
40#define CRYPTO4XX_IO_THRESHOLD 0x00000060
41#define CRYPTO4XX_GATH_RING_BASE 0x00000064
42#define CRYPTO4XX_SCAT_RING_BASE 0x00000068
43#define CRYPTO4XX_PART_RING_SIZE 0x0000006c
44#define CRYPTO4XX_PART_RING_CFG 0x00000070
45
46#define CRYPTO4XX_PDR_BASE_UADDR 0x00000080
47#define CRYPTO4XX_RDR_BASE_UADDR 0x00000084
48#define CRYPTO4XX_PKT_SRC_UADDR 0x00000088
49#define CRYPTO4XX_PKT_DEST_UADDR 0x0000008c
50#define CRYPTO4XX_SA_UADDR 0x00000090
51#define CRYPTO4XX_GATH_RING_BASE_UADDR 0x000000A0
52#define CRYPTO4XX_SCAT_RING_BASE_UADDR 0x000000A4
53
54#define CRYPTO4XX_SEQ_RD 0x00000408
55#define CRYPTO4XX_SEQ_MASK_RD 0x0000040C
56
57#define CRYPTO4XX_SA_CMD_0 0x00010600
58#define CRYPTO4XX_SA_CMD_1 0x00010604
59
60#define CRYPTO4XX_STATE_PTR 0x000106dc
61#define CRYPTO4XX_STATE_IV 0x00010700
62#define CRYPTO4XX_STATE_HASH_BYTE_CNT_0 0x00010710
63#define CRYPTO4XX_STATE_HASH_BYTE_CNT_1 0x00010714
64
65#define CRYPTO4XX_STATE_IDIGEST_0 0x00010718
66#define CRYPTO4XX_STATE_IDIGEST_1 0x0001071c
67
68#define CRYPTO4XX_DATA_IN 0x00018000
69#define CRYPTO4XX_DATA_OUT 0x0001c000
70
71#define CRYPTO4XX_INT_UNMASK_STAT 0x000500a0
72#define CRYPTO4XX_INT_MASK_STAT 0x000500a4
73#define CRYPTO4XX_INT_CLR 0x000500a4
74#define CRYPTO4XX_INT_EN 0x000500a8
75
76#define CRYPTO4XX_INT_PKA 0x00000002
77#define CRYPTO4XX_INT_PDR_DONE 0x00008000
78#define CRYPTO4XX_INT_MA_WR_ERR 0x00020000
79#define CRYPTO4XX_INT_MA_RD_ERR 0x00010000
80#define CRYPTO4XX_INT_PE_ERR 0x00000200
81#define CRYPTO4XX_INT_USER_DMA_ERR 0x00000040
82#define CRYPTO4XX_INT_SLAVE_ERR 0x00000010
83#define CRYPTO4XX_INT_MASTER_ERR 0x00000008
84#define CRYPTO4XX_INT_ERROR 0x00030258
85
86#define CRYPTO4XX_INT_CFG 0x000500ac
87#define CRYPTO4XX_INT_DESCR_RD 0x000500b0
88#define CRYPTO4XX_INT_DESCR_CNT 0x000500b4
89#define CRYPTO4XX_INT_TIMEOUT_CNT 0x000500b8
90
91#define CRYPTO4XX_DEVICE_CTRL 0x00060080
92#define CRYPTO4XX_DEVICE_ID 0x00060084
93#define CRYPTO4XX_DEVICE_INFO 0x00060088
94#define CRYPTO4XX_DMA_USER_SRC 0x00060094
95#define CRYPTO4XX_DMA_USER_DEST 0x00060098
96#define CRYPTO4XX_DMA_USER_CMD 0x0006009C
97
98#define CRYPTO4XX_DMA_CFG 0x000600d4
99#define CRYPTO4XX_BYTE_ORDER_CFG 0x000600d8
100#define CRYPTO4XX_ENDIAN_CFG 0x000600d8
101
102#define CRYPTO4XX_PRNG_STAT 0x00070000
103#define CRYPTO4XX_PRNG_CTRL 0x00070004
104#define CRYPTO4XX_PRNG_SEED_L 0x00070008
105#define CRYPTO4XX_PRNG_SEED_H 0x0007000c
106
107#define CRYPTO4XX_PRNG_RES_0 0x00070020
108#define CRYPTO4XX_PRNG_RES_1 0x00070024
109#define CRYPTO4XX_PRNG_RES_2 0x00070028
110#define CRYPTO4XX_PRNG_RES_3 0x0007002C
111
112#define CRYPTO4XX_PRNG_LFSR_L 0x00070030
113#define CRYPTO4XX_PRNG_LFSR_H 0x00070034
114
115/**
116 * Initilize CRYPTO ENGINE registers, and memory bases.
117 */
118#define PPC4XX_PDR_POLL 0x3ff
119#define PPC4XX_OUTPUT_THRESHOLD 2
120#define PPC4XX_INPUT_THRESHOLD 2
121#define PPC4XX_PD_SIZE 6
122#define PPC4XX_CTX_DONE_INT 0x2000
123#define PPC4XX_PD_DONE_INT 0x8000
124#define PPC4XX_BYTE_ORDER 0x22222
125#define PPC4XX_INTERRUPT_CLR 0x3ffff
126#define PPC4XX_PRNG_CTRL_AUTO_EN 0x3
127#define PPC4XX_DC_3DES_EN 1
128#define PPC4XX_INT_DESCR_CNT 4
129#define PPC4XX_INT_TIMEOUT_CNT 0
130#define PPC4XX_INT_CFG 1
131/**
132 * all follow define are ad hoc
133 */
134#define PPC4XX_RING_RETRY 100
135#define PPC4XX_RING_POLL 100
136#define PPC4XX_SDR_SIZE PPC4XX_NUM_SD
137#define PPC4XX_GDR_SIZE PPC4XX_NUM_GD
138
139/**
140 * Generic Security Association (SA) with all possible fields. These will
141 * never likely used except for reference purpose. These structure format
142 * can be not changed as the hardware expects them to be layout as defined.
143 * Field can be removed or reduced but ordering can not be changed.
144 */
145#define CRYPTO4XX_DMA_CFG_OFFSET 0x40
146union ce_pe_dma_cfg {
147 struct {
148 u32 rsv:7;
149 u32 dir_host:1;
150 u32 rsv1:2;
151 u32 bo_td_en:1;
152 u32 dis_pdr_upd:1;
153 u32 bo_sgpd_en:1;
154 u32 bo_data_en:1;
155 u32 bo_sa_en:1;
156 u32 bo_pd_en:1;
157 u32 rsv2:4;
158 u32 dynamic_sa_en:1;
159 u32 pdr_mode:2;
160 u32 pe_mode:1;
161 u32 rsv3:5;
162 u32 reset_sg:1;
163 u32 reset_pdr:1;
164 u32 reset_pe:1;
165 } bf;
166 u32 w;
167} __attribute__((packed));
168
169#define CRYPTO4XX_PDR_BASE_OFFSET 0x48
170#define CRYPTO4XX_RDR_BASE_OFFSET 0x4c
171#define CRYPTO4XX_RING_SIZE_OFFSET 0x50
172union ce_ring_size {
173 struct {
174 u32 ring_offset:16;
175 u32 rsv:6;
176 u32 ring_size:10;
177 } bf;
178 u32 w;
179} __attribute__((packed));
180
181#define CRYPTO4XX_RING_CONTROL_OFFSET 0x54
182union ce_ring_contol {
183 struct {
184 u32 continuous:1;
185 u32 rsv:5;
186 u32 ring_retry_divisor:10;
187 u32 rsv1:4;
188 u32 ring_poll_divisor:10;
189 } bf;
190 u32 w;
191} __attribute__((packed));
192
193#define CRYPTO4XX_IO_THRESHOLD_OFFSET 0x60
194union ce_io_threshold {
195 struct {
196 u32 rsv:6;
197 u32 output_threshold:10;
198 u32 rsv1:6;
199 u32 input_threshold:10;
200 } bf;
201 u32 w;
202} __attribute__((packed));
203
204#define CRYPTO4XX_GATHER_RING_BASE_OFFSET 0x64
205#define CRYPTO4XX_SCATTER_RING_BASE_OFFSET 0x68
206
207union ce_part_ring_size {
208 struct {
209 u32 sdr_size:16;
210 u32 gdr_size:16;
211 } bf;
212 u32 w;
213} __attribute__((packed));
214
215#define MAX_BURST_SIZE_32 0
216#define MAX_BURST_SIZE_64 1
217#define MAX_BURST_SIZE_128 2
218#define MAX_BURST_SIZE_256 3
219
220/* gather descriptor control length */
221struct gd_ctl_len {
222 u32 len:16;
223 u32 rsv:14;
224 u32 done:1;
225 u32 ready:1;
226} __attribute__((packed));
227
228struct ce_gd {
229 u32 ptr;
230 struct gd_ctl_len ctl_len;
231} __attribute__((packed));
232
233struct sd_ctl {
234 u32 ctl:30;
235 u32 done:1;
236 u32 rdy:1;
237} __attribute__((packed));
238
239struct ce_sd {
240 u32 ptr;
241 struct sd_ctl ctl;
242} __attribute__((packed));
243
244#define PD_PAD_CTL_32 0x10
245#define PD_PAD_CTL_64 0x20
246#define PD_PAD_CTL_128 0x40
247#define PD_PAD_CTL_256 0x80
248union ce_pd_ctl {
249 struct {
250 u32 pd_pad_ctl:8;
251 u32 status:8;
252 u32 next_hdr:8;
253 u32 rsv:2;
254 u32 cached_sa:1;
255 u32 hash_final:1;
256 u32 init_arc4:1;
257 u32 rsv1:1;
258 u32 pe_done:1;
259 u32 host_ready:1;
260 } bf;
261 u32 w;
262} __attribute__((packed));
263
264union ce_pd_ctl_len {
265 struct {
266 u32 bypass:8;
267 u32 pe_done:1;
268 u32 host_ready:1;
269 u32 rsv:2;
270 u32 pkt_len:20;
271 } bf;
272 u32 w;
273} __attribute__((packed));
274
275struct ce_pd {
276 union ce_pd_ctl pd_ctl;
277 u32 src;
278 u32 dest;
279 u32 sa; /* get from ctx->sa_dma_addr */
280 u32 sa_len; /* only if dynamic sa is used */
281 union ce_pd_ctl_len pd_ctl_len;
282
283} __attribute__((packed));
284#endif
diff --git a/drivers/crypto/amcc/crypto4xx_sa.c b/drivers/crypto/amcc/crypto4xx_sa.c
new file mode 100644
index 000000000000..466fd94cd4a3
--- /dev/null
+++ b/drivers/crypto/amcc/crypto4xx_sa.c
@@ -0,0 +1,108 @@
1/**
2 * AMCC SoC PPC4xx Crypto Driver
3 *
4 * Copyright (c) 2008 Applied Micro Circuits Corporation.
5 * All rights reserved. James Hsiao <jhsiao@amcc.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 * @file crypto4xx_sa.c
18 *
19 * This file implements the security context
20 * assoicate format.
21 */
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/mod_devicetable.h>
26#include <linux/interrupt.h>
27#include <linux/spinlock_types.h>
28#include <linux/highmem.h>
29#include <linux/scatterlist.h>
30#include <linux/crypto.h>
31#include <crypto/algapi.h>
32#include <crypto/des.h>
33#include "crypto4xx_reg_def.h"
34#include "crypto4xx_sa.h"
35#include "crypto4xx_core.h"
36
37u32 get_dynamic_sa_offset_iv_field(struct crypto4xx_ctx *ctx)
38{
39 u32 offset;
40 union dynamic_sa_contents cts;
41
42 if (ctx->direction == DIR_INBOUND)
43 cts.w = ((struct dynamic_sa_ctl *)(ctx->sa_in))->sa_contents;
44 else
45 cts.w = ((struct dynamic_sa_ctl *)(ctx->sa_out))->sa_contents;
46 offset = cts.bf.key_size
47 + cts.bf.inner_size
48 + cts.bf.outer_size
49 + cts.bf.spi
50 + cts.bf.seq_num0
51 + cts.bf.seq_num1
52 + cts.bf.seq_num_mask0
53 + cts.bf.seq_num_mask1
54 + cts.bf.seq_num_mask2
55 + cts.bf.seq_num_mask3;
56
57 return sizeof(struct dynamic_sa_ctl) + offset * 4;
58}
59
60u32 get_dynamic_sa_offset_state_ptr_field(struct crypto4xx_ctx *ctx)
61{
62 u32 offset;
63 union dynamic_sa_contents cts;
64
65 if (ctx->direction == DIR_INBOUND)
66 cts.w = ((struct dynamic_sa_ctl *) ctx->sa_in)->sa_contents;
67 else
68 cts.w = ((struct dynamic_sa_ctl *) ctx->sa_out)->sa_contents;
69 offset = cts.bf.key_size
70 + cts.bf.inner_size
71 + cts.bf.outer_size
72 + cts.bf.spi
73 + cts.bf.seq_num0
74 + cts.bf.seq_num1
75 + cts.bf.seq_num_mask0
76 + cts.bf.seq_num_mask1
77 + cts.bf.seq_num_mask2
78 + cts.bf.seq_num_mask3
79 + cts.bf.iv0
80 + cts.bf.iv1
81 + cts.bf.iv2
82 + cts.bf.iv3;
83
84 return sizeof(struct dynamic_sa_ctl) + offset * 4;
85}
86
87u32 get_dynamic_sa_iv_size(struct crypto4xx_ctx *ctx)
88{
89 union dynamic_sa_contents cts;
90
91 if (ctx->direction == DIR_INBOUND)
92 cts.w = ((struct dynamic_sa_ctl *) ctx->sa_in)->sa_contents;
93 else
94 cts.w = ((struct dynamic_sa_ctl *) ctx->sa_out)->sa_contents;
95 return (cts.bf.iv0 + cts.bf.iv1 + cts.bf.iv2 + cts.bf.iv3) * 4;
96}
97
98u32 get_dynamic_sa_offset_key_field(struct crypto4xx_ctx *ctx)
99{
100 union dynamic_sa_contents cts;
101
102 if (ctx->direction == DIR_INBOUND)
103 cts.w = ((struct dynamic_sa_ctl *) ctx->sa_in)->sa_contents;
104 else
105 cts.w = ((struct dynamic_sa_ctl *) ctx->sa_out)->sa_contents;
106
107 return sizeof(struct dynamic_sa_ctl);
108}
diff --git a/drivers/crypto/amcc/crypto4xx_sa.h b/drivers/crypto/amcc/crypto4xx_sa.h
new file mode 100644
index 000000000000..4b83ed7e5570
--- /dev/null
+++ b/drivers/crypto/amcc/crypto4xx_sa.h
@@ -0,0 +1,243 @@
1/**
2 * AMCC SoC PPC4xx Crypto Driver
3 *
4 * Copyright (c) 2008 Applied Micro Circuits Corporation.
5 * All rights reserved. James Hsiao <jhsiao@amcc.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 * This file defines the security context
18 * assoicate format.
19 */
20
21#ifndef __CRYPTO4XX_SA_H__
22#define __CRYPTO4XX_SA_H__
23
24#define AES_IV_SIZE 16
25
26/**
27 * Contents of Dynamic Security Association (SA) with all possible fields
28 */
29union dynamic_sa_contents {
30 struct {
31 u32 arc4_state_ptr:1;
32 u32 arc4_ij_ptr:1;
33 u32 state_ptr:1;
34 u32 iv3:1;
35 u32 iv2:1;
36 u32 iv1:1;
37 u32 iv0:1;
38 u32 seq_num_mask3:1;
39 u32 seq_num_mask2:1;
40 u32 seq_num_mask1:1;
41 u32 seq_num_mask0:1;
42 u32 seq_num1:1;
43 u32 seq_num0:1;
44 u32 spi:1;
45 u32 outer_size:5;
46 u32 inner_size:5;
47 u32 key_size:4;
48 u32 cmd_size:4;
49 } bf;
50 u32 w;
51} __attribute__((packed));
52
53#define DIR_OUTBOUND 0
54#define DIR_INBOUND 1
55#define SA_OP_GROUP_BASIC 0
56#define SA_OPCODE_ENCRYPT 0
57#define SA_OPCODE_DECRYPT 0
58#define SA_OPCODE_HASH 3
59#define SA_CIPHER_ALG_DES 0
60#define SA_CIPHER_ALG_3DES 1
61#define SA_CIPHER_ALG_ARC4 2
62#define SA_CIPHER_ALG_AES 3
63#define SA_CIPHER_ALG_KASUMI 4
64#define SA_CIPHER_ALG_NULL 15
65
66#define SA_HASH_ALG_MD5 0
67#define SA_HASH_ALG_SHA1 1
68#define SA_HASH_ALG_NULL 15
69#define SA_HASH_ALG_SHA1_DIGEST_SIZE 20
70
71#define SA_LOAD_HASH_FROM_SA 0
72#define SA_LOAD_HASH_FROM_STATE 2
73#define SA_NOT_LOAD_HASH 3
74#define SA_LOAD_IV_FROM_SA 0
75#define SA_LOAD_IV_FROM_INPUT 1
76#define SA_LOAD_IV_FROM_STATE 2
77#define SA_LOAD_IV_GEN_IV 3
78
79#define SA_PAD_TYPE_CONSTANT 2
80#define SA_PAD_TYPE_ZERO 3
81#define SA_PAD_TYPE_TLS 5
82#define SA_PAD_TYPE_DTLS 5
83#define SA_NOT_SAVE_HASH 0
84#define SA_SAVE_HASH 1
85#define SA_NOT_SAVE_IV 0
86#define SA_SAVE_IV 1
87#define SA_HEADER_PROC 1
88#define SA_NO_HEADER_PROC 0
89
90union sa_command_0 {
91 struct {
92 u32 scatter:1;
93 u32 gather:1;
94 u32 save_hash_state:1;
95 u32 save_iv:1;
96 u32 load_hash_state:2;
97 u32 load_iv:2;
98 u32 digest_len:4;
99 u32 hdr_proc:1;
100 u32 extend_pad:1;
101 u32 stream_cipher_pad:1;
102 u32 rsv:1;
103 u32 hash_alg:4;
104 u32 cipher_alg:4;
105 u32 pad_type:2;
106 u32 op_group:2;
107 u32 dir:1;
108 u32 opcode:3;
109 } bf;
110 u32 w;
111} __attribute__((packed));
112
113#define CRYPTO_MODE_ECB 0
114#define CRYPTO_MODE_CBC 1
115
116#define CRYPTO_FEEDBACK_MODE_NO_FB 0
117#define CRYPTO_FEEDBACK_MODE_64BIT_OFB 0
118#define CRYPTO_FEEDBACK_MODE_8BIT_CFB 1
119#define CRYPTO_FEEDBACK_MODE_1BIT_CFB 2
120#define CRYPTO_FEEDBACK_MODE_128BIT_CFB 3
121
122#define SA_AES_KEY_LEN_128 2
123#define SA_AES_KEY_LEN_192 3
124#define SA_AES_KEY_LEN_256 4
125
126#define SA_REV2 1
127/**
128 * The follow defines bits sa_command_1
129 * In Basic hash mode this bit define simple hash or hmac.
130 * In IPsec mode, this bit define muting control.
131 */
132#define SA_HASH_MODE_HASH 0
133#define SA_HASH_MODE_HMAC 1
134#define SA_MC_ENABLE 0
135#define SA_MC_DISABLE 1
136#define SA_NOT_COPY_HDR 0
137#define SA_COPY_HDR 1
138#define SA_NOT_COPY_PAD 0
139#define SA_COPY_PAD 1
140#define SA_NOT_COPY_PAYLOAD 0
141#define SA_COPY_PAYLOAD 1
142#define SA_EXTENDED_SN_OFF 0
143#define SA_EXTENDED_SN_ON 1
144#define SA_SEQ_MASK_OFF 0
145#define SA_SEQ_MASK_ON 1
146
147union sa_command_1 {
148 struct {
149 u32 crypto_mode31:1;
150 u32 save_arc4_state:1;
151 u32 arc4_stateful:1;
152 u32 key_len:5;
153 u32 hash_crypto_offset:8;
154 u32 sa_rev:2;
155 u32 byte_offset:1;
156 u32 hmac_muting:1;
157 u32 feedback_mode:2;
158 u32 crypto_mode9_8:2;
159 u32 extended_seq_num:1;
160 u32 seq_num_mask:1;
161 u32 mutable_bit_proc:1;
162 u32 ip_version:1;
163 u32 copy_pad:1;
164 u32 copy_payload:1;
165 u32 copy_hdr:1;
166 u32 rsv1:1;
167 } bf;
168 u32 w;
169} __attribute__((packed));
170
171struct dynamic_sa_ctl {
172 u32 sa_contents;
173 union sa_command_0 sa_command_0;
174 union sa_command_1 sa_command_1;
175} __attribute__((packed));
176
177/**
178 * State Record for Security Association (SA)
179 */
180struct sa_state_record {
181 u32 save_iv[4];
182 u32 save_hash_byte_cnt[2];
183 u32 save_digest[16];
184} __attribute__((packed));
185
186/**
187 * Security Association (SA) for AES128
188 *
189 */
190struct dynamic_sa_aes128 {
191 struct dynamic_sa_ctl ctrl;
192 u32 key[4];
193 u32 iv[4]; /* for CBC, OFC, and CFB mode */
194 u32 state_ptr;
195 u32 reserved;
196} __attribute__((packed));
197
198#define SA_AES128_LEN (sizeof(struct dynamic_sa_aes128)/4)
199#define SA_AES128_CONTENTS 0x3e000042
200
201/*
202 * Security Association (SA) for AES192
203 */
204struct dynamic_sa_aes192 {
205 struct dynamic_sa_ctl ctrl;
206 u32 key[6];
207 u32 iv[4]; /* for CBC, OFC, and CFB mode */
208 u32 state_ptr;
209 u32 reserved;
210} __attribute__((packed));
211
212#define SA_AES192_LEN (sizeof(struct dynamic_sa_aes192)/4)
213#define SA_AES192_CONTENTS 0x3e000062
214
215/**
216 * Security Association (SA) for AES256
217 */
218struct dynamic_sa_aes256 {
219 struct dynamic_sa_ctl ctrl;
220 u32 key[8];
221 u32 iv[4]; /* for CBC, OFC, and CFB mode */
222 u32 state_ptr;
223 u32 reserved;
224} __attribute__((packed));
225
226#define SA_AES256_LEN (sizeof(struct dynamic_sa_aes256)/4)
227#define SA_AES256_CONTENTS 0x3e000082
228#define SA_AES_CONTENTS 0x3e000002
229
230/**
231 * Security Association (SA) for HASH160: HMAC-SHA1
232 */
233struct dynamic_sa_hash160 {
234 struct dynamic_sa_ctl ctrl;
235 u32 inner_digest[5];
236 u32 outer_digest[5];
237 u32 state_ptr;
238 u32 reserved;
239} __attribute__((packed));
240#define SA_HASH160_LEN (sizeof(struct dynamic_sa_hash160)/4)
241#define SA_HASH160_CONTENTS 0x2000a502
242
243#endif
diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c
index 33bd75347518..25b743abfb59 100644
--- a/drivers/dca/dca-core.c
+++ b/drivers/dca/dca-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved. 2 * Copyright(c) 2007 - 2009 Intel Corporation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free 5 * under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c
index 10c3c498358c..55dd88d82d6d 100644
--- a/drivers/dio/dio.c
+++ b/drivers/dio/dio.c
@@ -182,7 +182,7 @@ static int __init dio_init(void)
182 182
183 /* Initialize the DIO bus */ 183 /* Initialize the DIO bus */
184 INIT_LIST_HEAD(&dio_bus.devices); 184 INIT_LIST_HEAD(&dio_bus.devices);
185 strcpy(dio_bus.dev.bus_id, "dio"); 185 dev_set_name(&dio_bus.dev, "dio");
186 error = device_register(&dio_bus.dev); 186 error = device_register(&dio_bus.dev);
187 if (error) { 187 if (error) {
188 pr_err("DIO: Error registering dio_bus\n"); 188 pr_err("DIO: Error registering dio_bus\n");
@@ -237,7 +237,7 @@ static int __init dio_init(void)
237 dev->scode = scode; 237 dev->scode = scode;
238 dev->resource.start = pa; 238 dev->resource.start = pa;
239 dev->resource.end = pa + DIO_SIZE(scode, va); 239 dev->resource.end = pa + DIO_SIZE(scode, va);
240 sprintf(dev->dev.bus_id,"%02x", scode); 240 dev_set_name(&dev->dev, "%02x", scode);
241 241
242 /* read the ID byte(s) and encode if necessary. */ 242 /* read the ID byte(s) and encode if necessary. */
243 prid = DIO_ID(va); 243 prid = DIO_ID(va);
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 732fa1ec36ab..e190d8b30700 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -430,13 +430,15 @@ late_initcall(dmatest_init);
430static void __exit dmatest_exit(void) 430static void __exit dmatest_exit(void)
431{ 431{
432 struct dmatest_chan *dtc, *_dtc; 432 struct dmatest_chan *dtc, *_dtc;
433 struct dma_chan *chan;
433 434
434 list_for_each_entry_safe(dtc, _dtc, &dmatest_channels, node) { 435 list_for_each_entry_safe(dtc, _dtc, &dmatest_channels, node) {
435 list_del(&dtc->node); 436 list_del(&dtc->node);
437 chan = dtc->chan;
436 dmatest_cleanup_channel(dtc); 438 dmatest_cleanup_channel(dtc);
437 pr_debug("dmatest: dropped channel %s\n", 439 pr_debug("dmatest: dropped channel %s\n",
438 dma_chan_name(dtc->chan)); 440 dma_chan_name(chan));
439 dma_release_channel(dtc->chan); 441 dma_release_channel(chan);
440 } 442 }
441} 443}
442module_exit(dmatest_exit); 444module_exit(dmatest_exit);
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index a97c07eef7ec..20ad3d26bec2 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1011,7 +1011,7 @@ static int __init dw_probe(struct platform_device *pdev)
1011 dma_writel(dw, CFG, DW_CFG_DMA_EN); 1011 dma_writel(dw, CFG, DW_CFG_DMA_EN);
1012 1012
1013 printk(KERN_INFO "%s: DesignWare DMA Controller, %d channels\n", 1013 printk(KERN_INFO "%s: DesignWare DMA Controller, %d channels\n",
1014 pdev->dev.bus_id, dw->dma.chancnt); 1014 dev_name(&pdev->dev), dw->dma.chancnt);
1015 1015
1016 dma_async_device_register(&dw->dma); 1016 dma_async_device_register(&dw->dma);
1017 1017
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 70126a606239..86d6da47f558 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -158,7 +158,8 @@ static void dma_start(struct fsl_dma_chan *fsl_chan)
158 158
159static void dma_halt(struct fsl_dma_chan *fsl_chan) 159static void dma_halt(struct fsl_dma_chan *fsl_chan)
160{ 160{
161 int i = 0; 161 int i;
162
162 DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, 163 DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
163 DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | FSL_DMA_MR_CA, 164 DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | FSL_DMA_MR_CA,
164 32); 165 32);
@@ -166,8 +167,11 @@ static void dma_halt(struct fsl_dma_chan *fsl_chan)
166 DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) & ~(FSL_DMA_MR_CS 167 DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) & ~(FSL_DMA_MR_CS
167 | FSL_DMA_MR_EMS_EN | FSL_DMA_MR_CA), 32); 168 | FSL_DMA_MR_EMS_EN | FSL_DMA_MR_CA), 32);
168 169
169 while (!dma_is_idle(fsl_chan) && (i++ < 100)) 170 for (i = 0; i < 100; i++) {
171 if (dma_is_idle(fsl_chan))
172 break;
170 udelay(10); 173 udelay(10);
174 }
171 if (i >= 100 && !dma_is_idle(fsl_chan)) 175 if (i >= 100 && !dma_is_idle(fsl_chan))
172 dev_err(fsl_chan->dev, "DMA halt timeout!\n"); 176 dev_err(fsl_chan->dev, "DMA halt timeout!\n");
173} 177}
diff --git a/drivers/dma/ioat.c b/drivers/dma/ioat.c
index 4105d6575b64..ed83dd9df192 100644
--- a/drivers/dma/ioat.c
+++ b/drivers/dma/ioat.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Intel I/OAT DMA Linux driver 2 * Intel I/OAT DMA Linux driver
3 * Copyright(c) 2007 Intel Corporation. 3 * Copyright(c) 2007 - 2009 Intel Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License, 6 * under the terms and conditions of the GNU General Public License,
diff --git a/drivers/dma/ioat_dca.c b/drivers/dma/ioat_dca.c
index 6cf622da0286..c012a1e15043 100644
--- a/drivers/dma/ioat_dca.c
+++ b/drivers/dma/ioat_dca.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Intel I/OAT DMA Linux driver 2 * Intel I/OAT DMA Linux driver
3 * Copyright(c) 2007 Intel Corporation. 3 * Copyright(c) 2007 - 2009 Intel Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License, 6 * under the terms and conditions of the GNU General Public License,
@@ -49,6 +49,23 @@
49 49
50#define DCA_TAG_MAP_MASK 0xDF 50#define DCA_TAG_MAP_MASK 0xDF
51 51
52/* expected tag map bytes for I/OAT ver.2 */
53#define DCA2_TAG_MAP_BYTE0 0x80
54#define DCA2_TAG_MAP_BYTE1 0x0
55#define DCA2_TAG_MAP_BYTE2 0x81
56#define DCA2_TAG_MAP_BYTE3 0x82
57#define DCA2_TAG_MAP_BYTE4 0x82
58
59/* verify if tag map matches expected values */
60static inline int dca2_tag_map_valid(u8 *tag_map)
61{
62 return ((tag_map[0] == DCA2_TAG_MAP_BYTE0) &&
63 (tag_map[1] == DCA2_TAG_MAP_BYTE1) &&
64 (tag_map[2] == DCA2_TAG_MAP_BYTE2) &&
65 (tag_map[3] == DCA2_TAG_MAP_BYTE3) &&
66 (tag_map[4] == DCA2_TAG_MAP_BYTE4));
67}
68
52/* 69/*
53 * "Legacy" DCA systems do not implement the DCA register set in the 70 * "Legacy" DCA systems do not implement the DCA register set in the
54 * I/OAT device. Software needs direct support for their tag mappings. 71 * I/OAT device. Software needs direct support for their tag mappings.
@@ -452,6 +469,13 @@ struct dca_provider *ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase)
452 ioatdca->tag_map[i] = 0; 469 ioatdca->tag_map[i] = 0;
453 } 470 }
454 471
472 if (!dca2_tag_map_valid(ioatdca->tag_map)) {
473 dev_err(&pdev->dev, "APICID_TAG_MAP set incorrectly by BIOS, "
474 "disabling DCA\n");
475 free_dca_provider(dca);
476 return NULL;
477 }
478
455 err = register_dca_provider(dca, &pdev->dev); 479 err = register_dca_provider(dca, &pdev->dev);
456 if (err) { 480 if (err) {
457 free_dca_provider(dca); 481 free_dca_provider(dca);
diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c
index b3759c4b6536..5905cd36bcd2 100644
--- a/drivers/dma/ioat_dma.c
+++ b/drivers/dma/ioat_dma.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Intel I/OAT DMA Linux driver 2 * Intel I/OAT DMA Linux driver
3 * Copyright(c) 2004 - 2007 Intel Corporation. 3 * Copyright(c) 2004 - 2009 Intel Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License, 6 * under the terms and conditions of the GNU General Public License,
@@ -189,11 +189,13 @@ static int ioat_dma_enumerate_channels(struct ioatdma_device *device)
189 ioat_chan->xfercap = xfercap; 189 ioat_chan->xfercap = xfercap;
190 ioat_chan->desccount = 0; 190 ioat_chan->desccount = 0;
191 INIT_DELAYED_WORK(&ioat_chan->work, ioat_dma_chan_reset_part2); 191 INIT_DELAYED_WORK(&ioat_chan->work, ioat_dma_chan_reset_part2);
192 if (ioat_chan->device->version != IOAT_VER_1_2) { 192 if (ioat_chan->device->version == IOAT_VER_2_0)
193 writel(IOAT_DCACTRL_CMPL_WRITE_ENABLE 193 writel(IOAT_DCACTRL_CMPL_WRITE_ENABLE |
194 | IOAT_DMA_DCA_ANY_CPU, 194 IOAT_DMA_DCA_ANY_CPU,
195 ioat_chan->reg_base + IOAT_DCACTRL_OFFSET); 195 ioat_chan->reg_base + IOAT_DCACTRL_OFFSET);
196 } 196 else if (ioat_chan->device->version == IOAT_VER_3_0)
197 writel(IOAT_DMA_DCA_ANY_CPU,
198 ioat_chan->reg_base + IOAT_DCACTRL_OFFSET);
197 spin_lock_init(&ioat_chan->cleanup_lock); 199 spin_lock_init(&ioat_chan->cleanup_lock);
198 spin_lock_init(&ioat_chan->desc_lock); 200 spin_lock_init(&ioat_chan->desc_lock);
199 INIT_LIST_HEAD(&ioat_chan->free_desc); 201 INIT_LIST_HEAD(&ioat_chan->free_desc);
@@ -1169,9 +1171,8 @@ static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan)
1169 * up if the client is done with the descriptor 1171 * up if the client is done with the descriptor
1170 */ 1172 */
1171 if (async_tx_test_ack(&desc->async_tx)) { 1173 if (async_tx_test_ack(&desc->async_tx)) {
1172 list_del(&desc->node); 1174 list_move_tail(&desc->node,
1173 list_add_tail(&desc->node, 1175 &ioat_chan->free_desc);
1174 &ioat_chan->free_desc);
1175 } else 1176 } else
1176 desc->async_tx.cookie = 0; 1177 desc->async_tx.cookie = 0;
1177 } else { 1178 } else {
@@ -1362,6 +1363,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1362 dma_cookie_t cookie; 1363 dma_cookie_t cookie;
1363 int err = 0; 1364 int err = 0;
1364 struct completion cmp; 1365 struct completion cmp;
1366 unsigned long tmo;
1365 1367
1366 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); 1368 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
1367 if (!src) 1369 if (!src)
@@ -1413,9 +1415,10 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1413 } 1415 }
1414 device->common.device_issue_pending(dma_chan); 1416 device->common.device_issue_pending(dma_chan);
1415 1417
1416 wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)); 1418 tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000));
1417 1419
1418 if (device->common.device_is_tx_complete(dma_chan, cookie, NULL, NULL) 1420 if (tmo == 0 ||
1421 device->common.device_is_tx_complete(dma_chan, cookie, NULL, NULL)
1419 != DMA_SUCCESS) { 1422 != DMA_SUCCESS) {
1420 dev_err(&device->pdev->dev, 1423 dev_err(&device->pdev->dev,
1421 "Self-test copy timed out, disabling\n"); 1424 "Self-test copy timed out, disabling\n");
@@ -1657,6 +1660,13 @@ struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev,
1657 " %d channels, device version 0x%02x, driver version %s\n", 1660 " %d channels, device version 0x%02x, driver version %s\n",
1658 device->common.chancnt, device->version, IOAT_DMA_VERSION); 1661 device->common.chancnt, device->version, IOAT_DMA_VERSION);
1659 1662
1663 if (!device->common.chancnt) {
1664 dev_err(&device->pdev->dev,
1665 "Intel(R) I/OAT DMA Engine problem found: "
1666 "zero channels detected\n");
1667 goto err_setup_interrupts;
1668 }
1669
1660 err = ioat_dma_setup_interrupts(device); 1670 err = ioat_dma_setup_interrupts(device);
1661 if (err) 1671 if (err)
1662 goto err_setup_interrupts; 1672 goto err_setup_interrupts;
@@ -1696,6 +1706,9 @@ void ioat_dma_remove(struct ioatdma_device *device)
1696 struct dma_chan *chan, *_chan; 1706 struct dma_chan *chan, *_chan;
1697 struct ioat_dma_chan *ioat_chan; 1707 struct ioat_dma_chan *ioat_chan;
1698 1708
1709 if (device->version != IOAT_VER_3_0)
1710 cancel_delayed_work(&device->work);
1711
1699 ioat_dma_remove_interrupts(device); 1712 ioat_dma_remove_interrupts(device);
1700 1713
1701 dma_async_device_unregister(&device->common); 1714 dma_async_device_unregister(&device->common);
@@ -1707,10 +1720,6 @@ void ioat_dma_remove(struct ioatdma_device *device)
1707 pci_release_regions(device->pdev); 1720 pci_release_regions(device->pdev);
1708 pci_disable_device(device->pdev); 1721 pci_disable_device(device->pdev);
1709 1722
1710 if (device->version != IOAT_VER_3_0) {
1711 cancel_delayed_work(&device->work);
1712 }
1713
1714 list_for_each_entry_safe(chan, _chan, 1723 list_for_each_entry_safe(chan, _chan,
1715 &device->common.channels, device_node) { 1724 &device->common.channels, device_node) {
1716 ioat_chan = to_ioat_chan(chan); 1725 ioat_chan = to_ioat_chan(chan);
diff --git a/drivers/dma/ioatdma.h b/drivers/dma/ioatdma.h
index a3306d0e1372..a52ff4bd4601 100644
--- a/drivers/dma/ioatdma.h
+++ b/drivers/dma/ioatdma.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright(c) 2004 - 2007 Intel Corporation. All rights reserved. 2 * Copyright(c) 2004 - 2009 Intel Corporation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free 5 * under the terms of the GNU General Public License as published by the Free
@@ -29,7 +29,7 @@
29#include <linux/pci_ids.h> 29#include <linux/pci_ids.h>
30#include <net/tcp.h> 30#include <net/tcp.h>
31 31
32#define IOAT_DMA_VERSION "3.30" 32#define IOAT_DMA_VERSION "3.64"
33 33
34enum ioat_interrupt { 34enum ioat_interrupt {
35 none = 0, 35 none = 0,
@@ -135,12 +135,14 @@ static inline void ioat_set_tcp_copy_break(struct ioatdma_device *dev)
135 #ifdef CONFIG_NET_DMA 135 #ifdef CONFIG_NET_DMA
136 switch (dev->version) { 136 switch (dev->version) {
137 case IOAT_VER_1_2: 137 case IOAT_VER_1_2:
138 case IOAT_VER_3_0:
139 sysctl_tcp_dma_copybreak = 4096; 138 sysctl_tcp_dma_copybreak = 4096;
140 break; 139 break;
141 case IOAT_VER_2_0: 140 case IOAT_VER_2_0:
142 sysctl_tcp_dma_copybreak = 2048; 141 sysctl_tcp_dma_copybreak = 2048;
143 break; 142 break;
143 case IOAT_VER_3_0:
144 sysctl_tcp_dma_copybreak = 262144;
145 break;
144 } 146 }
145 #endif 147 #endif
146} 148}
diff --git a/drivers/dma/ioatdma_hw.h b/drivers/dma/ioatdma_hw.h
index f1ae2c776f74..afa57eef86c9 100644
--- a/drivers/dma/ioatdma_hw.h
+++ b/drivers/dma/ioatdma_hw.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright(c) 2004 - 2007 Intel Corporation. All rights reserved. 2 * Copyright(c) 2004 - 2009 Intel Corporation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free 5 * under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/dma/ioatdma_registers.h b/drivers/dma/ioatdma_registers.h
index 827cb503cac6..49bc277424f8 100644
--- a/drivers/dma/ioatdma_registers.h
+++ b/drivers/dma/ioatdma_registers.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright(c) 2004 - 2007 Intel Corporation. All rights reserved. 2 * Copyright(c) 2004 - 2009 Intel Corporation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free 5 * under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c
index 647374acba94..16adbe61cfb2 100644
--- a/drivers/dma/iop-adma.c
+++ b/drivers/dma/iop-adma.c
@@ -928,19 +928,19 @@ iop_adma_xor_zero_sum_self_test(struct iop_adma_device *device)
928 928
929 for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) { 929 for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) {
930 xor_srcs[src_idx] = alloc_page(GFP_KERNEL); 930 xor_srcs[src_idx] = alloc_page(GFP_KERNEL);
931 if (!xor_srcs[src_idx]) 931 if (!xor_srcs[src_idx]) {
932 while (src_idx--) { 932 while (src_idx--)
933 __free_page(xor_srcs[src_idx]); 933 __free_page(xor_srcs[src_idx]);
934 return -ENOMEM; 934 return -ENOMEM;
935 } 935 }
936 } 936 }
937 937
938 dest = alloc_page(GFP_KERNEL); 938 dest = alloc_page(GFP_KERNEL);
939 if (!dest) 939 if (!dest) {
940 while (src_idx--) { 940 while (src_idx--)
941 __free_page(xor_srcs[src_idx]); 941 __free_page(xor_srcs[src_idx]);
942 return -ENOMEM; 942 return -ENOMEM;
943 } 943 }
944 944
945 /* Fill in src buffers */ 945 /* Fill in src buffers */
946 for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) { 946 for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) {
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c
index 1f154d08e98f..ae50a9d1a4e6 100644
--- a/drivers/dma/ipu/ipu_idmac.c
+++ b/drivers/dma/ipu/ipu_idmac.c
@@ -729,7 +729,7 @@ static int ipu_init_channel_buffer(struct idmac_channel *ichan,
729 729
730 ichan->status = IPU_CHANNEL_READY; 730 ichan->status = IPU_CHANNEL_READY;
731 731
732 spin_unlock_irqrestore(ipu->lock, flags); 732 spin_unlock_irqrestore(&ipu->lock, flags);
733 733
734 return 0; 734 return 0;
735} 735}
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 5d5d5b31867f..cb7f26fb9f18 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1019,19 +1019,19 @@ mv_xor_xor_self_test(struct mv_xor_device *device)
1019 1019
1020 for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { 1020 for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) {
1021 xor_srcs[src_idx] = alloc_page(GFP_KERNEL); 1021 xor_srcs[src_idx] = alloc_page(GFP_KERNEL);
1022 if (!xor_srcs[src_idx]) 1022 if (!xor_srcs[src_idx]) {
1023 while (src_idx--) { 1023 while (src_idx--)
1024 __free_page(xor_srcs[src_idx]); 1024 __free_page(xor_srcs[src_idx]);
1025 return -ENOMEM; 1025 return -ENOMEM;
1026 } 1026 }
1027 } 1027 }
1028 1028
1029 dest = alloc_page(GFP_KERNEL); 1029 dest = alloc_page(GFP_KERNEL);
1030 if (!dest) 1030 if (!dest) {
1031 while (src_idx--) { 1031 while (src_idx--)
1032 __free_page(xor_srcs[src_idx]); 1032 __free_page(xor_srcs[src_idx]);
1033 return -ENOMEM; 1033 return -ENOMEM;
1034 } 1034 }
1035 1035
1036 /* Fill in src buffers */ 1036 /* Fill in src buffers */
1037 for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { 1037 for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) {
diff --git a/drivers/edac/cell_edac.c b/drivers/edac/cell_edac.c
index 24f3ca851523..cb0f639f049d 100644
--- a/drivers/edac/cell_edac.c
+++ b/drivers/edac/cell_edac.c
@@ -198,7 +198,7 @@ static int __devinit cell_edac_probe(struct platform_device *pdev)
198 mci->edac_cap = EDAC_FLAG_EC | EDAC_FLAG_SECDED; 198 mci->edac_cap = EDAC_FLAG_EC | EDAC_FLAG_SECDED;
199 mci->mod_name = "cell_edac"; 199 mci->mod_name = "cell_edac";
200 mci->ctl_name = "MIC"; 200 mci->ctl_name = "MIC";
201 mci->dev_name = pdev->dev.bus_id; 201 mci->dev_name = dev_name(&pdev->dev);
202 mci->edac_check = cell_edac_check; 202 mci->edac_check = cell_edac_check;
203 cell_edac_init_csrows(mci); 203 cell_edac_init_csrows(mci);
204 204
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 853ef37ec006..4637a4a757df 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -218,7 +218,7 @@ static int __devinit mpc85xx_pci_err_probe(struct of_device *op,
218 pci->dev = &op->dev; 218 pci->dev = &op->dev;
219 pci->mod_name = EDAC_MOD_STR; 219 pci->mod_name = EDAC_MOD_STR;
220 pci->ctl_name = pdata->name; 220 pci->ctl_name = pdata->name;
221 pci->dev_name = op->dev.bus_id; 221 pci->dev_name = dev_name(&op->dev);
222 222
223 if (edac_op_state == EDAC_OPSTATE_POLL) 223 if (edac_op_state == EDAC_OPSTATE_POLL)
224 pci->edac_check = mpc85xx_pci_check; 224 pci->edac_check = mpc85xx_pci_check;
diff --git a/drivers/edac/mv64x60_edac.c b/drivers/edac/mv64x60_edac.c
index 083ce8d0c63d..5131aaae8e03 100644
--- a/drivers/edac/mv64x60_edac.c
+++ b/drivers/edac/mv64x60_edac.c
@@ -121,7 +121,7 @@ static int __devinit mv64x60_pci_err_probe(struct platform_device *pdev)
121 pdata->irq = NO_IRQ; 121 pdata->irq = NO_IRQ;
122 platform_set_drvdata(pdev, pci); 122 platform_set_drvdata(pdev, pci);
123 pci->dev = &pdev->dev; 123 pci->dev = &pdev->dev;
124 pci->dev_name = pdev->dev.bus_id; 124 pci->dev_name = dev_name(&pdev->dev);
125 pci->mod_name = EDAC_MOD_STR; 125 pci->mod_name = EDAC_MOD_STR;
126 pci->ctl_name = pdata->name; 126 pci->ctl_name = pdata->name;
127 127
@@ -294,7 +294,7 @@ static int __devinit mv64x60_sram_err_probe(struct platform_device *pdev)
294 pdata->irq = NO_IRQ; 294 pdata->irq = NO_IRQ;
295 edac_dev->dev = &pdev->dev; 295 edac_dev->dev = &pdev->dev;
296 platform_set_drvdata(pdev, edac_dev); 296 platform_set_drvdata(pdev, edac_dev);
297 edac_dev->dev_name = pdev->dev.bus_id; 297 edac_dev->dev_name = dev_name(&pdev->dev);
298 298
299 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 299 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
300 if (!r) { 300 if (!r) {
@@ -462,7 +462,7 @@ static int __devinit mv64x60_cpu_err_probe(struct platform_device *pdev)
462 pdata->irq = NO_IRQ; 462 pdata->irq = NO_IRQ;
463 edac_dev->dev = &pdev->dev; 463 edac_dev->dev = &pdev->dev;
464 platform_set_drvdata(pdev, edac_dev); 464 platform_set_drvdata(pdev, edac_dev);
465 edac_dev->dev_name = pdev->dev.bus_id; 465 edac_dev->dev_name = dev_name(&pdev->dev);
466 466
467 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 467 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
468 if (!r) { 468 if (!r) {
@@ -713,7 +713,7 @@ static int __devinit mv64x60_mc_err_probe(struct platform_device *pdev)
713 platform_set_drvdata(pdev, mci); 713 platform_set_drvdata(pdev, mci);
714 pdata->name = "mv64x60_mc_err"; 714 pdata->name = "mv64x60_mc_err";
715 pdata->irq = NO_IRQ; 715 pdata->irq = NO_IRQ;
716 mci->dev_name = pdev->dev.bus_id; 716 mci->dev_name = dev_name(&pdev->dev);
717 pdata->edac_idx = edac_mc_idx++; 717 pdata->edac_idx = edac_mc_idx++;
718 718
719 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 719 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index c950bf8606d9..66958b3f10b4 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -200,7 +200,7 @@ static int __init eisa_init_device (struct eisa_root_device *root,
200 edev->dev.bus = &eisa_bus_type; 200 edev->dev.bus = &eisa_bus_type;
201 edev->dev.dma_mask = &edev->dma_mask; 201 edev->dev.dma_mask = &edev->dma_mask;
202 edev->dev.coherent_dma_mask = edev->dma_mask; 202 edev->dev.coherent_dma_mask = edev->dma_mask;
203 sprintf (edev->dev.bus_id, "%02X:%02X", root->bus_nr, slot); 203 dev_set_name(&edev->dev, "%02X:%02X", root->bus_nr, slot);
204 204
205 for (i = 0; i < EISA_MAX_RESOURCES; i++) { 205 for (i = 0; i < EISA_MAX_RESOURCES; i++) {
206#ifdef CONFIG_EISA_NAMES 206#ifdef CONFIG_EISA_NAMES
@@ -301,7 +301,7 @@ static int __init eisa_probe (struct eisa_root_device *root)
301 struct eisa_device *edev; 301 struct eisa_device *edev;
302 302
303 printk (KERN_INFO "EISA: Probing bus %d at %s\n", 303 printk (KERN_INFO "EISA: Probing bus %d at %s\n",
304 root->bus_nr, root->dev->bus_id); 304 root->bus_nr, dev_name(root->dev));
305 305
306 /* First try to get hold of slot 0. If there is no device 306 /* First try to get hold of slot 0. If there is no device
307 * here, simply fail, unless root->force_probe is set. */ 307 * here, simply fail, unless root->force_probe is set. */
diff --git a/drivers/gpio/bt8xxgpio.c b/drivers/gpio/bt8xxgpio.c
index 7a1168249dd5..984b587f0f96 100644
--- a/drivers/gpio/bt8xxgpio.c
+++ b/drivers/gpio/bt8xxgpio.c
@@ -160,7 +160,7 @@ static void bt8xxgpio_gpio_setup(struct bt8xxgpio *bg)
160{ 160{
161 struct gpio_chip *c = &bg->gpio; 161 struct gpio_chip *c = &bg->gpio;
162 162
163 c->label = bg->pdev->dev.bus_id; 163 c->label = dev_name(&bg->pdev->dev);
164 c->owner = THIS_MODULE; 164 c->owner = THIS_MODULE;
165 c->direction_input = bt8xxgpio_gpio_direction_input; 165 c->direction_input = bt8xxgpio_gpio_direction_input;
166 c->get = bt8xxgpio_gpio_get; 166 c->get = bt8xxgpio_gpio_get;
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 5aa6780652aa..186d08159d48 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -359,8 +359,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
359 DRM_DEBUG("adding \"%s\" to sysfs\n", 359 DRM_DEBUG("adding \"%s\" to sysfs\n",
360 drm_get_connector_name(connector)); 360 drm_get_connector_name(connector));
361 361
362 snprintf(connector->kdev.bus_id, BUS_ID_SIZE, "card%d-%s", 362 dev_set_name(&connector->kdev, "card%d-%s",
363 dev->primary->index, drm_get_connector_name(connector)); 363 dev->primary->index, drm_get_connector_name(connector));
364 ret = device_register(&connector->kdev); 364 ret = device_register(&connector->kdev);
365 365
366 if (ret) { 366 if (ret) {
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 6dab63bdc4c1..6d21b9e48b89 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1105,7 +1105,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1105 1024 * 1024, 1105 1024 * 1024,
1106 MTRR_TYPE_WRCOMB, 1); 1106 MTRR_TYPE_WRCOMB, 1);
1107 if (dev_priv->mm.gtt_mtrr < 0) { 1107 if (dev_priv->mm.gtt_mtrr < 0) {
1108 DRM_INFO("MTRR allocation failed\n. Graphics " 1108 DRM_INFO("MTRR allocation failed. Graphics "
1109 "performance may suffer.\n"); 1109 "performance may suffer.\n");
1110 } 1110 }
1111 1111
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 17fa40858d26..d6cc9861e0a1 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -279,7 +279,6 @@ typedef struct drm_i915_private {
279 u8 saveAR_INDEX; 279 u8 saveAR_INDEX;
280 u8 saveAR[21]; 280 u8 saveAR[21];
281 u8 saveDACMASK; 281 u8 saveDACMASK;
282 u8 saveDACDATA[256*3]; /* 256 3-byte colors */
283 u8 saveCR[37]; 282 u8 saveCR[37];
284 283
285 struct { 284 struct {
@@ -457,6 +456,12 @@ struct drm_i915_gem_object {
457 456
458 /** for phy allocated objects */ 457 /** for phy allocated objects */
459 struct drm_i915_gem_phys_object *phys_obj; 458 struct drm_i915_gem_phys_object *phys_obj;
459
460 /**
461 * Used for checking the object doesn't appear more than once
462 * in an execbuffer object list.
463 */
464 int in_execbuffer;
460}; 465};
461 466
462/** 467/**
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 85685bfd12da..37427e4016cb 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1476,7 +1476,7 @@ static void i915_write_fence_reg(struct drm_i915_fence_reg *reg)
1476 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1476 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1477 int regnum = obj_priv->fence_reg; 1477 int regnum = obj_priv->fence_reg;
1478 int tile_width; 1478 int tile_width;
1479 uint32_t val; 1479 uint32_t fence_reg, val;
1480 uint32_t pitch_val; 1480 uint32_t pitch_val;
1481 1481
1482 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) || 1482 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) ||
@@ -1503,7 +1503,11 @@ static void i915_write_fence_reg(struct drm_i915_fence_reg *reg)
1503 val |= pitch_val << I830_FENCE_PITCH_SHIFT; 1503 val |= pitch_val << I830_FENCE_PITCH_SHIFT;
1504 val |= I830_FENCE_REG_VALID; 1504 val |= I830_FENCE_REG_VALID;
1505 1505
1506 I915_WRITE(FENCE_REG_830_0 + (regnum * 4), val); 1506 if (regnum < 8)
1507 fence_reg = FENCE_REG_830_0 + (regnum * 4);
1508 else
1509 fence_reg = FENCE_REG_945_8 + ((regnum - 8) * 4);
1510 I915_WRITE(fence_reg, val);
1507} 1511}
1508 1512
1509static void i830_write_fence_reg(struct drm_i915_fence_reg *reg) 1513static void i830_write_fence_reg(struct drm_i915_fence_reg *reg)
@@ -1557,7 +1561,8 @@ i915_gem_object_get_fence_reg(struct drm_gem_object *obj, bool write)
1557 struct drm_i915_private *dev_priv = dev->dev_private; 1561 struct drm_i915_private *dev_priv = dev->dev_private;
1558 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1562 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1559 struct drm_i915_fence_reg *reg = NULL; 1563 struct drm_i915_fence_reg *reg = NULL;
1560 int i, ret; 1564 struct drm_i915_gem_object *old_obj_priv = NULL;
1565 int i, ret, avail;
1561 1566
1562 switch (obj_priv->tiling_mode) { 1567 switch (obj_priv->tiling_mode) {
1563 case I915_TILING_NONE: 1568 case I915_TILING_NONE:
@@ -1580,25 +1585,46 @@ i915_gem_object_get_fence_reg(struct drm_gem_object *obj, bool write)
1580 } 1585 }
1581 1586
1582 /* First try to find a free reg */ 1587 /* First try to find a free reg */
1588try_again:
1589 avail = 0;
1583 for (i = dev_priv->fence_reg_start; i < dev_priv->num_fence_regs; i++) { 1590 for (i = dev_priv->fence_reg_start; i < dev_priv->num_fence_regs; i++) {
1584 reg = &dev_priv->fence_regs[i]; 1591 reg = &dev_priv->fence_regs[i];
1585 if (!reg->obj) 1592 if (!reg->obj)
1586 break; 1593 break;
1594
1595 old_obj_priv = reg->obj->driver_private;
1596 if (!old_obj_priv->pin_count)
1597 avail++;
1587 } 1598 }
1588 1599
1589 /* None available, try to steal one or wait for a user to finish */ 1600 /* None available, try to steal one or wait for a user to finish */
1590 if (i == dev_priv->num_fence_regs) { 1601 if (i == dev_priv->num_fence_regs) {
1591 struct drm_i915_gem_object *old_obj_priv = NULL; 1602 uint32_t seqno = dev_priv->mm.next_gem_seqno;
1592 loff_t offset; 1603 loff_t offset;
1593 1604
1594try_again: 1605 if (avail == 0)
1595 /* Could try to use LRU here instead... */ 1606 return -ENOMEM;
1607
1596 for (i = dev_priv->fence_reg_start; 1608 for (i = dev_priv->fence_reg_start;
1597 i < dev_priv->num_fence_regs; i++) { 1609 i < dev_priv->num_fence_regs; i++) {
1610 uint32_t this_seqno;
1611
1598 reg = &dev_priv->fence_regs[i]; 1612 reg = &dev_priv->fence_regs[i];
1599 old_obj_priv = reg->obj->driver_private; 1613 old_obj_priv = reg->obj->driver_private;
1600 if (!old_obj_priv->pin_count) 1614
1615 if (old_obj_priv->pin_count)
1616 continue;
1617
1618 /* i915 uses fences for GPU access to tiled buffers */
1619 if (IS_I965G(dev) || !old_obj_priv->active)
1601 break; 1620 break;
1621
1622 /* find the seqno of the first available fence */
1623 this_seqno = old_obj_priv->last_rendering_seqno;
1624 if (this_seqno != 0 &&
1625 reg->obj->write_domain == 0 &&
1626 i915_seqno_passed(seqno, this_seqno))
1627 seqno = this_seqno;
1602 } 1628 }
1603 1629
1604 /* 1630 /*
@@ -1606,15 +1632,25 @@ try_again:
1606 * objects to finish before trying again. 1632 * objects to finish before trying again.
1607 */ 1633 */
1608 if (i == dev_priv->num_fence_regs) { 1634 if (i == dev_priv->num_fence_regs) {
1609 ret = i915_gem_object_set_to_gtt_domain(reg->obj, 0); 1635 if (seqno == dev_priv->mm.next_gem_seqno) {
1610 if (ret) { 1636 i915_gem_flush(dev,
1611 WARN(ret != -ERESTARTSYS, 1637 I915_GEM_GPU_DOMAINS,
1612 "switch to GTT domain failed: %d\n", ret); 1638 I915_GEM_GPU_DOMAINS);
1613 return ret; 1639 seqno = i915_add_request(dev,
1640 I915_GEM_GPU_DOMAINS);
1641 if (seqno == 0)
1642 return -ENOMEM;
1614 } 1643 }
1644
1645 ret = i915_wait_request(dev, seqno);
1646 if (ret)
1647 return ret;
1615 goto try_again; 1648 goto try_again;
1616 } 1649 }
1617 1650
1651 BUG_ON(old_obj_priv->active ||
1652 (reg->obj->write_domain & I915_GEM_GPU_DOMAINS));
1653
1618 /* 1654 /*
1619 * Zap this virtual mapping so we can set up a fence again 1655 * Zap this virtual mapping so we can set up a fence again
1620 * for this object next time we need it. 1656 * for this object next time we need it.
@@ -1655,8 +1691,17 @@ i915_gem_clear_fence_reg(struct drm_gem_object *obj)
1655 1691
1656 if (IS_I965G(dev)) 1692 if (IS_I965G(dev))
1657 I915_WRITE64(FENCE_REG_965_0 + (obj_priv->fence_reg * 8), 0); 1693 I915_WRITE64(FENCE_REG_965_0 + (obj_priv->fence_reg * 8), 0);
1658 else 1694 else {
1659 I915_WRITE(FENCE_REG_830_0 + (obj_priv->fence_reg * 4), 0); 1695 uint32_t fence_reg;
1696
1697 if (obj_priv->fence_reg < 8)
1698 fence_reg = FENCE_REG_830_0 + obj_priv->fence_reg * 4;
1699 else
1700 fence_reg = FENCE_REG_945_8 + (obj_priv->fence_reg -
1701 8) * 4;
1702
1703 I915_WRITE(fence_reg, 0);
1704 }
1660 1705
1661 dev_priv->fence_regs[obj_priv->fence_reg].obj = NULL; 1706 dev_priv->fence_regs[obj_priv->fence_reg].obj = NULL;
1662 obj_priv->fence_reg = I915_FENCE_REG_NONE; 1707 obj_priv->fence_reg = I915_FENCE_REG_NONE;
@@ -2469,6 +2514,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
2469 struct drm_i915_gem_exec_object *exec_list = NULL; 2514 struct drm_i915_gem_exec_object *exec_list = NULL;
2470 struct drm_gem_object **object_list = NULL; 2515 struct drm_gem_object **object_list = NULL;
2471 struct drm_gem_object *batch_obj; 2516 struct drm_gem_object *batch_obj;
2517 struct drm_i915_gem_object *obj_priv;
2472 int ret, i, pinned = 0; 2518 int ret, i, pinned = 0;
2473 uint64_t exec_offset; 2519 uint64_t exec_offset;
2474 uint32_t seqno, flush_domains; 2520 uint32_t seqno, flush_domains;
@@ -2533,6 +2579,15 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
2533 ret = -EBADF; 2579 ret = -EBADF;
2534 goto err; 2580 goto err;
2535 } 2581 }
2582
2583 obj_priv = object_list[i]->driver_private;
2584 if (obj_priv->in_execbuffer) {
2585 DRM_ERROR("Object %p appears more than once in object list\n",
2586 object_list[i]);
2587 ret = -EBADF;
2588 goto err;
2589 }
2590 obj_priv->in_execbuffer = true;
2536 } 2591 }
2537 2592
2538 /* Pin and relocate */ 2593 /* Pin and relocate */
@@ -2674,8 +2729,13 @@ err:
2674 for (i = 0; i < pinned; i++) 2729 for (i = 0; i < pinned; i++)
2675 i915_gem_object_unpin(object_list[i]); 2730 i915_gem_object_unpin(object_list[i]);
2676 2731
2677 for (i = 0; i < args->buffer_count; i++) 2732 for (i = 0; i < args->buffer_count; i++) {
2733 if (object_list[i]) {
2734 obj_priv = object_list[i]->driver_private;
2735 obj_priv->in_execbuffer = false;
2736 }
2678 drm_gem_object_unreference(object_list[i]); 2737 drm_gem_object_unreference(object_list[i]);
2738 }
2679 2739
2680 mutex_unlock(&dev->struct_mutex); 2740 mutex_unlock(&dev->struct_mutex);
2681 2741
@@ -2712,17 +2772,24 @@ i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment)
2712 ret = i915_gem_object_bind_to_gtt(obj, alignment); 2772 ret = i915_gem_object_bind_to_gtt(obj, alignment);
2713 if (ret != 0) { 2773 if (ret != 0) {
2714 if (ret != -EBUSY && ret != -ERESTARTSYS) 2774 if (ret != -EBUSY && ret != -ERESTARTSYS)
2715 DRM_ERROR("Failure to bind: %d", ret); 2775 DRM_ERROR("Failure to bind: %d\n", ret);
2776 return ret;
2777 }
2778 }
2779 /*
2780 * Pre-965 chips need a fence register set up in order to
2781 * properly handle tiled surfaces.
2782 */
2783 if (!IS_I965G(dev) &&
2784 obj_priv->fence_reg == I915_FENCE_REG_NONE &&
2785 obj_priv->tiling_mode != I915_TILING_NONE) {
2786 ret = i915_gem_object_get_fence_reg(obj, true);
2787 if (ret != 0) {
2788 if (ret != -EBUSY && ret != -ERESTARTSYS)
2789 DRM_ERROR("Failure to install fence: %d\n",
2790 ret);
2716 return ret; 2791 return ret;
2717 } 2792 }
2718 /*
2719 * Pre-965 chips need a fence register set up in order to
2720 * properly handle tiled surfaces.
2721 */
2722 if (!IS_I965G(dev) &&
2723 obj_priv->fence_reg == I915_FENCE_REG_NONE &&
2724 obj_priv->tiling_mode != I915_TILING_NONE)
2725 i915_gem_object_get_fence_reg(obj, true);
2726 } 2793 }
2727 obj_priv->pin_count++; 2794 obj_priv->pin_count++;
2728 2795
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 9d6539a868b3..90600d899413 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -184,6 +184,7 @@
184 * Fence registers 184 * Fence registers
185 */ 185 */
186#define FENCE_REG_830_0 0x2000 186#define FENCE_REG_830_0 0x2000
187#define FENCE_REG_945_8 0x3000
187#define I830_FENCE_START_MASK 0x07f80000 188#define I830_FENCE_START_MASK 0x07f80000
188#define I830_FENCE_TILING_Y_SHIFT 12 189#define I830_FENCE_TILING_Y_SHIFT 12
189#define I830_FENCE_SIZE_BITS(size) ((ffs((size) >> 19) - 1) << 8) 190#define I830_FENCE_SIZE_BITS(size) ((ffs((size) >> 19) - 1) << 8)
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index 5d84027ee8f3..d669cc2b42c0 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -119,11 +119,6 @@ static void i915_save_vga(struct drm_device *dev)
119 119
120 /* VGA color palette registers */ 120 /* VGA color palette registers */
121 dev_priv->saveDACMASK = I915_READ8(VGA_DACMASK); 121 dev_priv->saveDACMASK = I915_READ8(VGA_DACMASK);
122 /* DACCRX automatically increments during read */
123 I915_WRITE8(VGA_DACRX, 0);
124 /* Read 3 bytes of color data from each index */
125 for (i = 0; i < 256 * 3; i++)
126 dev_priv->saveDACDATA[i] = I915_READ8(VGA_DACDATA);
127 122
128 /* MSR bits */ 123 /* MSR bits */
129 dev_priv->saveMSR = I915_READ8(VGA_MSR_READ); 124 dev_priv->saveMSR = I915_READ8(VGA_MSR_READ);
@@ -225,12 +220,6 @@ static void i915_restore_vga(struct drm_device *dev)
225 220
226 /* VGA color palette registers */ 221 /* VGA color palette registers */
227 I915_WRITE8(VGA_DACMASK, dev_priv->saveDACMASK); 222 I915_WRITE8(VGA_DACMASK, dev_priv->saveDACMASK);
228 /* DACCRX automatically increments during read */
229 I915_WRITE8(VGA_DACWX, 0);
230 /* Read 3 bytes of color data from each index */
231 for (i = 0; i < 256 * 3; i++)
232 I915_WRITE8(VGA_DACDATA, dev_priv->saveDACDATA[i]);
233
234} 223}
235 224
236int i915_save_state(struct drm_device *dev) 225int i915_save_state(struct drm_device *dev)
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 4940e4d70c2d..1f5b5d4c3c34 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -306,7 +306,7 @@ static int hiddev_open(struct inode *inode, struct file *file)
306 return 0; 306 return 0;
307bail: 307bail:
308 file->private_data = NULL; 308 file->private_data = NULL;
309 kfree(list->hiddev); 309 kfree(list);
310 return res; 310 return res;
311} 311}
312 312
@@ -323,7 +323,7 @@ static ssize_t hiddev_write(struct file * file, const char __user * buffer, size
323 */ 323 */
324static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) 324static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos)
325{ 325{
326 DECLARE_WAITQUEUE(wait, current); 326 DEFINE_WAIT(wait);
327 struct hiddev_list *list = file->private_data; 327 struct hiddev_list *list = file->private_data;
328 int event_size; 328 int event_size;
329 int retval; 329 int retval;
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index b84bf066879b..b4eea0292c1a 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -543,8 +543,8 @@ config SENSORS_LM90
543 help 543 help
544 If you say yes here you get support for National Semiconductor LM90, 544 If you say yes here you get support for National Semiconductor LM90,
545 LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, and Maxim 545 LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, and Maxim
546 MAX6646, MAX6647, MAX6649, MAX6657, MAX6658, MAX6659, MAX6680 and 546 MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659,
547 MAX6681 sensor chips. 547 MAX6680, MAX6681 and MAX6692 sensor chips.
548 548
549 This driver can also be built as a module. If so, the module 549 This driver can also be built as a module. If so, the module
550 will be called lm90. 550 will be called lm90.
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index e52b38806d03..ad2b3431b725 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -760,8 +760,11 @@ static int abituguru3_read_increment_offset(struct abituguru3_data *data,
760 760
761 for (i = 0; i < offset_count; i++) 761 for (i = 0; i < offset_count; i++)
762 if ((x = abituguru3_read(data, bank, offset + i, count, 762 if ((x = abituguru3_read(data, bank, offset + i, count,
763 buf + i * count)) != count) 763 buf + i * count)) != count) {
764 return i * count + (i && (x < 0)) ? 0 : x; 764 if (x < 0)
765 return x;
766 return i * count + x;
767 }
765 768
766 return i * count; 769 return i * count;
767} 770}
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 1692de369969..18a1ba888165 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -617,7 +617,7 @@ static void f75375_init(struct i2c_client *client, struct f75375_data *data,
617static int f75375_probe(struct i2c_client *client, 617static int f75375_probe(struct i2c_client *client,
618 const struct i2c_device_id *id) 618 const struct i2c_device_id *id)
619{ 619{
620 struct f75375_data *data = i2c_get_clientdata(client); 620 struct f75375_data *data;
621 struct f75375s_platform_data *f75375s_pdata = client->dev.platform_data; 621 struct f75375s_platform_data *f75375s_pdata = client->dev.platform_data;
622 int err; 622 int err;
623 623
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 95a99c590da2..9157247fed8e 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -213,7 +213,7 @@ static inline u16 FAN16_TO_REG(long rpm)
213 213
214#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)<0?(((val)-500)/1000):\ 214#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)<0?(((val)-500)/1000):\
215 ((val)+500)/1000),-128,127)) 215 ((val)+500)/1000),-128,127))
216#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) 216#define TEMP_FROM_REG(val) ((val) * 1000)
217 217
218#define PWM_TO_REG(val) ((val) >> 1) 218#define PWM_TO_REG(val) ((val) >> 1)
219#define PWM_FROM_REG(val) (((val)&0x7f) << 1) 219#define PWM_FROM_REG(val) (((val)&0x7f) << 1)
@@ -267,9 +267,9 @@ struct it87_data {
267 u8 has_fan; /* Bitfield, fans enabled */ 267 u8 has_fan; /* Bitfield, fans enabled */
268 u16 fan[5]; /* Register values, possibly combined */ 268 u16 fan[5]; /* Register values, possibly combined */
269 u16 fan_min[5]; /* Register values, possibly combined */ 269 u16 fan_min[5]; /* Register values, possibly combined */
270 u8 temp[3]; /* Register value */ 270 s8 temp[3]; /* Register value */
271 u8 temp_high[3]; /* Register value */ 271 s8 temp_high[3]; /* Register value */
272 u8 temp_low[3]; /* Register value */ 272 s8 temp_low[3]; /* Register value */
273 u8 sensor; /* Register value */ 273 u8 sensor; /* Register value */
274 u8 fan_div[3]; /* Register encoding, shifted right */ 274 u8 fan_div[3]; /* Register encoding, shifted right */
275 u8 vid; /* Register encoding, combined */ 275 u8 vid; /* Register encoding, combined */
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index cfc1ee90f5a3..b251d8674b41 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -72,6 +72,7 @@ I2C_CLIENT_INSMOD_7(lm85b, lm85c, adm1027, adt7463, adt7468, emc6d100,
72#define LM85_COMPANY_SMSC 0x5c 72#define LM85_COMPANY_SMSC 0x5c
73#define LM85_VERSTEP_VMASK 0xf0 73#define LM85_VERSTEP_VMASK 0xf0
74#define LM85_VERSTEP_GENERIC 0x60 74#define LM85_VERSTEP_GENERIC 0x60
75#define LM85_VERSTEP_GENERIC2 0x70
75#define LM85_VERSTEP_LM85C 0x60 76#define LM85_VERSTEP_LM85C 0x60
76#define LM85_VERSTEP_LM85B 0x62 77#define LM85_VERSTEP_LM85B 0x62
77#define LM85_VERSTEP_ADM1027 0x60 78#define LM85_VERSTEP_ADM1027 0x60
@@ -334,6 +335,7 @@ static struct lm85_data *lm85_update_device(struct device *dev);
334static const struct i2c_device_id lm85_id[] = { 335static const struct i2c_device_id lm85_id[] = {
335 { "adm1027", adm1027 }, 336 { "adm1027", adm1027 },
336 { "adt7463", adt7463 }, 337 { "adt7463", adt7463 },
338 { "adt7468", adt7468 },
337 { "lm85", any_chip }, 339 { "lm85", any_chip },
338 { "lm85b", lm85b }, 340 { "lm85b", lm85b },
339 { "lm85c", lm85c }, 341 { "lm85c", lm85c },
@@ -408,7 +410,8 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr,
408 struct lm85_data *data = lm85_update_device(dev); 410 struct lm85_data *data = lm85_update_device(dev);
409 int vid; 411 int vid;
410 412
411 if (data->type == adt7463 && (data->vid & 0x80)) { 413 if ((data->type == adt7463 || data->type == adt7468) &&
414 (data->vid & 0x80)) {
412 /* 6-pin VID (VRM 10) */ 415 /* 6-pin VID (VRM 10) */
413 vid = vid_from_reg(data->vid & 0x3f, data->vrm); 416 vid = vid_from_reg(data->vid & 0x3f, data->vrm);
414 } else { 417 } else {
@@ -1153,7 +1156,8 @@ static int lm85_detect(struct i2c_client *client, int kind,
1153 address, company, verstep); 1156 address, company, verstep);
1154 1157
1155 /* All supported chips have the version in common */ 1158 /* All supported chips have the version in common */
1156 if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC) { 1159 if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC &&
1160 (verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC2) {
1157 dev_dbg(&adapter->dev, "Autodetection failed: " 1161 dev_dbg(&adapter->dev, "Autodetection failed: "
1158 "unsupported version\n"); 1162 "unsupported version\n");
1159 return -ENODEV; 1163 return -ENODEV;
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 96a701866726..1aff7575799d 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -32,10 +32,10 @@
32 * supported by this driver. These chips lack the remote temperature 32 * supported by this driver. These chips lack the remote temperature
33 * offset feature. 33 * offset feature.
34 * 34 *
35 * This driver also supports the MAX6646, MAX6647 and MAX6649 chips 35 * This driver also supports the MAX6646, MAX6647, MAX6648, MAX6649 and
36 * made by Maxim. These are again similar to the LM86, but they use 36 * MAX6692 chips made by Maxim. These are again similar to the LM86,
37 * unsigned temperature values and can report temperatures from 0 to 37 * but they use unsigned temperature values and can report temperatures
38 * 145 degrees. 38 * from 0 to 145 degrees.
39 * 39 *
40 * This driver also supports the MAX6680 and MAX6681, two other sensor 40 * This driver also supports the MAX6680 and MAX6681, two other sensor
41 * chips made by Maxim. These are quite similar to the other Maxim 41 * chips made by Maxim. These are quite similar to the other Maxim
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e7d984866de0..fbb9030b68a5 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -841,7 +841,7 @@ int i2c_attach_client(struct i2c_client *client)
841 841
842 if (client->driver && !is_newstyle_driver(client->driver)) { 842 if (client->driver && !is_newstyle_driver(client->driver)) {
843 client->dev.release = i2c_client_release; 843 client->dev.release = i2c_client_release;
844 client->dev.uevent_suppress = 1; 844 dev_set_uevent_suppress(&client->dev, 1);
845 } else 845 } else
846 client->dev.release = i2c_client_dev_release; 846 client->dev.release = i2c_client_dev_release;
847 847
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index e072903b12f0..640c99207242 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -56,8 +56,12 @@ if IDE
56 56
57comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" 57comment "Please see Documentation/ide/ide.txt for help/info on IDE drives"
58 58
59config IDE_XFER_MODE
60 bool
61
59config IDE_TIMINGS 62config IDE_TIMINGS
60 bool 63 bool
64 select IDE_XFER_MODE
61 65
62config IDE_ATAPI 66config IDE_ATAPI
63 bool 67 bool
@@ -698,6 +702,7 @@ config BLK_DEV_IDE_PMAC_ATA100FIRST
698config BLK_DEV_IDE_AU1XXX 702config BLK_DEV_IDE_AU1XXX
699 bool "IDE for AMD Alchemy Au1200" 703 bool "IDE for AMD Alchemy Au1200"
700 depends on SOC_AU1200 704 depends on SOC_AU1200
705 select IDE_XFER_MODE
701choice 706choice
702 prompt "IDE Mode for AMD Alchemy Au1200" 707 prompt "IDE Mode for AMD Alchemy Au1200"
703 default CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA 708 default CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
@@ -721,6 +726,11 @@ config BLK_DEV_IDE_TX4939
721 depends on SOC_TX4939 726 depends on SOC_TX4939
722 select BLK_DEV_IDEDMA_SFF 727 select BLK_DEV_IDEDMA_SFF
723 728
729config BLK_DEV_IDE_AT91
730 tristate "Atmel AT91 (SAM9, CAP9, AT572D940HF) IDE support"
731 depends on ARM && ARCH_AT91 && !ARCH_AT91RM9200 && !ARCH_AT91X40
732 select IDE_TIMINGS
733
724config IDE_ARM 734config IDE_ARM
725 tristate "ARM IDE support" 735 tristate "ARM IDE support"
726 depends on ARM && (ARCH_RPC || ARCH_SHARK) 736 depends on ARM && (ARCH_RPC || ARCH_SHARK)
@@ -866,6 +876,7 @@ config BLK_DEV_ALI14XX
866 876
867config BLK_DEV_DTC2278 877config BLK_DEV_DTC2278
868 tristate "DTC-2278 support" 878 tristate "DTC-2278 support"
879 select IDE_XFER_MODE
869 select IDE_LEGACY 880 select IDE_LEGACY
870 help 881 help
871 This driver is enabled at runtime using the "dtc2278.probe" kernel 882 This driver is enabled at runtime using the "dtc2278.probe" kernel
@@ -897,6 +908,7 @@ config BLK_DEV_QD65XX
897 908
898config BLK_DEV_UMC8672 909config BLK_DEV_UMC8672
899 tristate "UMC-8672 support" 910 tristate "UMC-8672 support"
911 select IDE_XFER_MODE
900 select IDE_LEGACY 912 select IDE_LEGACY
901 help 913 help
902 This driver is enabled at runtime using the "umc8672.probe" kernel 914 This driver is enabled at runtime using the "umc8672.probe" kernel
@@ -910,5 +922,6 @@ endif
910config BLK_DEV_IDEDMA 922config BLK_DEV_IDEDMA
911 def_bool BLK_DEV_IDEDMA_SFF || \ 923 def_bool BLK_DEV_IDEDMA_SFF || \
912 BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 924 BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
925 select IDE_XFER_MODE
913 926
914endif # IDE 927endif # IDE
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index d0e3d7d5b467..9b4bbe1cdc1a 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -5,9 +5,11 @@
5EXTRA_CFLAGS += -Idrivers/ide 5EXTRA_CFLAGS += -Idrivers/ide
6 6
7ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ 7ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \
8 ide-taskfile.o ide-pm.o ide-park.o ide-pio-blacklist.o ide-sysfs.o 8 ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o \
9 ide-io-std.o ide-eh.o
9 10
10# core IDE code 11# core IDE code
12ide-core-$(CONFIG_IDE_XFER_MODE) += ide-pio-blacklist.o ide-xfer-mode.o
11ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o 13ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o
12ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o 14ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o
13ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o 15ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o
@@ -116,3 +118,4 @@ obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o
116 118
117obj-$(CONFIG_BLK_DEV_IDE_TX4938) += tx4938ide.o 119obj-$(CONFIG_BLK_DEV_IDE_TX4938) += tx4938ide.o
118obj-$(CONFIG_BLK_DEV_IDE_TX4939) += tx4939ide.o 120obj-$(CONFIG_BLK_DEV_IDE_TX4939) += tx4939ide.o
121obj-$(CONFIG_BLK_DEV_IDE_AT91) += at91_ide.o
diff --git a/drivers/ide/aec62xx.c b/drivers/ide/aec62xx.c
index 4485b9c6f0e6..878f8ec6dbe1 100644
--- a/drivers/ide/aec62xx.c
+++ b/drivers/ide/aec62xx.c
@@ -139,7 +139,7 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio)
139 drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); 139 drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0);
140} 140}
141 141
142static unsigned int init_chipset_aec62xx(struct pci_dev *dev) 142static int init_chipset_aec62xx(struct pci_dev *dev)
143{ 143{
144 /* These are necessary to get AEC6280 Macintosh cards to work */ 144 /* These are necessary to get AEC6280 Macintosh cards to work */
145 if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) || 145 if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) ||
@@ -156,7 +156,7 @@ static unsigned int init_chipset_aec62xx(struct pci_dev *dev)
156 pci_write_config_byte(dev, 0x4a, reg4ah | 0x80); 156 pci_write_config_byte(dev, 0x4a, reg4ah | 0x80);
157 } 157 }
158 158
159 return dev->irq; 159 return 0;
160} 160}
161 161
162static u8 atp86x_cable_detect(ide_hwif_t *hwif) 162static u8 atp86x_cable_detect(ide_hwif_t *hwif)
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c
index 66f43083408b..d3513b6b8530 100644
--- a/drivers/ide/alim15x3.c
+++ b/drivers/ide/alim15x3.c
@@ -212,7 +212,7 @@ static int ali15x3_dma_setup(ide_drive_t *drive)
212 * appropriate also sets up the 1533 southbridge. 212 * appropriate also sets up the 1533 southbridge.
213 */ 213 */
214 214
215static unsigned int init_chipset_ali15x3(struct pci_dev *dev) 215static int init_chipset_ali15x3(struct pci_dev *dev)
216{ 216{
217 unsigned long flags; 217 unsigned long flags;
218 u8 tmpbyte; 218 u8 tmpbyte;
diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c
index 77267c859965..628cd2e5fed8 100644
--- a/drivers/ide/amd74xx.c
+++ b/drivers/ide/amd74xx.c
@@ -140,7 +140,7 @@ static void amd7411_cable_detect(struct pci_dev *dev)
140 * The initialization callback. Initialize drive independent registers. 140 * The initialization callback. Initialize drive independent registers.
141 */ 141 */
142 142
143static unsigned int init_chipset_amd74xx(struct pci_dev *dev) 143static int init_chipset_amd74xx(struct pci_dev *dev)
144{ 144{
145 u8 t = 0, offset = amd_offset(dev); 145 u8 t = 0, offset = amd_offset(dev);
146 146
@@ -172,7 +172,7 @@ static unsigned int init_chipset_amd74xx(struct pci_dev *dev)
172 t |= 0xf0; 172 t |= 0xf0;
173 pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); 173 pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t);
174 174
175 return dev->irq; 175 return 0;
176} 176}
177 177
178static u8 amd_cable_detect(ide_hwif_t *hwif) 178static u8 amd_cable_detect(ide_hwif_t *hwif)
@@ -183,14 +183,6 @@ static u8 amd_cable_detect(ide_hwif_t *hwif)
183 return ATA_CBL_PATA40; 183 return ATA_CBL_PATA40;
184} 184}
185 185
186static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
187{
188 struct pci_dev *dev = to_pci_dev(hwif->dev);
189
190 if (hwif->irq == 0) /* 0 is bogus but will do for now */
191 hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel);
192}
193
194static const struct ide_port_ops amd_port_ops = { 186static const struct ide_port_ops amd_port_ops = {
195 .set_pio_mode = amd_set_pio_mode, 187 .set_pio_mode = amd_set_pio_mode,
196 .set_dma_mode = amd_set_drive, 188 .set_dma_mode = amd_set_drive,
@@ -207,7 +199,6 @@ static const struct ide_port_ops amd_port_ops = {
207 { \ 199 { \
208 .name = DRV_NAME, \ 200 .name = DRV_NAME, \
209 .init_chipset = init_chipset_amd74xx, \ 201 .init_chipset = init_chipset_amd74xx, \
210 .init_hwif = init_hwif_amd74xx, \
211 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ 202 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \
212 .port_ops = &amd_port_ops, \ 203 .port_ops = &amd_port_ops, \
213 .host_flags = IDE_HFLAGS_AMD, \ 204 .host_flags = IDE_HFLAGS_AMD, \
@@ -221,7 +212,6 @@ static const struct ide_port_ops amd_port_ops = {
221 { \ 212 { \
222 .name = DRV_NAME, \ 213 .name = DRV_NAME, \
223 .init_chipset = init_chipset_amd74xx, \ 214 .init_chipset = init_chipset_amd74xx, \
224 .init_hwif = init_hwif_amd74xx, \
225 .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ 215 .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \
226 .port_ops = &amd_port_ops, \ 216 .port_ops = &amd_port_ops, \
227 .host_flags = IDE_HFLAGS_AMD, \ 217 .host_flags = IDE_HFLAGS_AMD, \
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c
new file mode 100644
index 000000000000..1bb50f46388d
--- /dev/null
+++ b/drivers/ide/at91_ide.c
@@ -0,0 +1,467 @@
1/*
2 * IDE host driver for AT91 (SAM9, CAP9, AT572D940HF) Static Memory Controller
3 * with Compact Flash True IDE logic
4 *
5 * Copyright (c) 2008, 2009 Kelvatek Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23#include <linux/version.h>
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/clk.h>
27#include <linux/err.h>
28#include <linux/ide.h>
29#include <linux/platform_device.h>
30
31#include <mach/board.h>
32#include <mach/gpio.h>
33#include <mach/at91sam9263.h>
34#include <mach/at91sam9_smc.h>
35#include <mach/at91sam9263_matrix.h>
36
37#define DRV_NAME "at91_ide"
38
39#define perr(fmt, args...) pr_err(DRV_NAME ": " fmt, ##args)
40#define pdbg(fmt, args...) pr_debug("%s " fmt, __func__, ##args)
41
42/*
43 * Access to IDE device is possible through EBI Static Memory Controller
44 * with Compact Flash logic. For details see EBI and SMC datasheet sections
45 * of any microcontroller from AT91SAM9 family.
46 *
47 * Within SMC chip select address space, lines A[23:21] distinguish Compact
48 * Flash modes (I/O, common memory, attribute memory, True IDE). IDE modes are:
49 * 0x00c0000 - True IDE
50 * 0x00e0000 - Alternate True IDE (Alt Status Register)
51 *
52 * On True IDE mode Task File and Data Register are mapped at the same address.
53 * To distinguish access between these two different bus data width is used:
54 * 8Bit for Task File, 16Bit for Data I/O.
55 *
56 * After initialization we do 8/16 bit flipping (changes in SMC MODE register)
57 * only inside IDE callback routines which are serialized by IDE layer,
58 * so no additional locking needed.
59 */
60
61#define TASK_FILE 0x00c00000
62#define ALT_MODE 0x00e00000
63#define REGS_SIZE 8
64
65#define enter_16bit(cs, mode) do { \
66 mode = at91_sys_read(AT91_SMC_MODE(cs)); \
67 at91_sys_write(AT91_SMC_MODE(cs), mode | AT91_SMC_DBW_16); \
68} while (0)
69
70#define leave_16bit(cs, mode) at91_sys_write(AT91_SMC_MODE(cs), mode);
71
72static void set_smc_timings(const u8 chipselect, const u16 cycle,
73 const u16 setup, const u16 pulse,
74 const u16 data_float, int use_iordy)
75{
76 unsigned long mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
77 AT91_SMC_BAT_SELECT;
78
79 /* disable or enable waiting for IORDY signal */
80 if (use_iordy)
81 mode |= AT91_SMC_EXNWMODE_READY;
82
83 /* add data float cycles if needed */
84 if (data_float)
85 mode |= AT91_SMC_TDF_(data_float);
86
87 at91_sys_write(AT91_SMC_MODE(chipselect), mode);
88
89 /* setup timings in SMC */
90 at91_sys_write(AT91_SMC_SETUP(chipselect), AT91_SMC_NWESETUP_(setup) |
91 AT91_SMC_NCS_WRSETUP_(0) |
92 AT91_SMC_NRDSETUP_(setup) |
93 AT91_SMC_NCS_RDSETUP_(0));
94 at91_sys_write(AT91_SMC_PULSE(chipselect), AT91_SMC_NWEPULSE_(pulse) |
95 AT91_SMC_NCS_WRPULSE_(cycle) |
96 AT91_SMC_NRDPULSE_(pulse) |
97 AT91_SMC_NCS_RDPULSE_(cycle));
98 at91_sys_write(AT91_SMC_CYCLE(chipselect), AT91_SMC_NWECYCLE_(cycle) |
99 AT91_SMC_NRDCYCLE_(cycle));
100}
101
102static unsigned int calc_mck_cycles(unsigned int ns, unsigned int mck_hz)
103{
104 u64 tmp = ns;
105
106 tmp *= mck_hz;
107 tmp += 1000*1000*1000 - 1; /* round up */
108 do_div(tmp, 1000*1000*1000);
109 return (unsigned int) tmp;
110}
111
112static void apply_timings(const u8 chipselect, const u8 pio,
113 const struct ide_timing *timing, int use_iordy)
114{
115 unsigned int t0, t1, t2, t6z;
116 unsigned int cycle, setup, pulse, data_float;
117 unsigned int mck_hz;
118 struct clk *mck;
119
120 /* see table 22 of Compact Flash standard 4.1 for the meaning,
121 * we do not stretch active (t2) time, so setup (t1) + hold time (th)
122 * assure at least minimal recovery (t2i) time */
123 t0 = timing->cyc8b;
124 t1 = timing->setup;
125 t2 = timing->act8b;
126 t6z = (pio < 5) ? 30 : 20;
127
128 pdbg("t0=%u t1=%u t2=%u t6z=%u\n", t0, t1, t2, t6z);
129
130 mck = clk_get(NULL, "mck");
131 BUG_ON(IS_ERR(mck));
132 mck_hz = clk_get_rate(mck);
133 pdbg("mck_hz=%u\n", mck_hz);
134
135 cycle = calc_mck_cycles(t0, mck_hz);
136 setup = calc_mck_cycles(t1, mck_hz);
137 pulse = calc_mck_cycles(t2, mck_hz);
138 data_float = calc_mck_cycles(t6z, mck_hz);
139
140 pdbg("cycle=%u setup=%u pulse=%u data_float=%u\n",
141 cycle, setup, pulse, data_float);
142
143 set_smc_timings(chipselect, cycle, setup, pulse, data_float, use_iordy);
144}
145
146static void at91_ide_input_data(ide_drive_t *drive, struct request *rq,
147 void *buf, unsigned int len)
148{
149 ide_hwif_t *hwif = drive->hwif;
150 struct ide_io_ports *io_ports = &hwif->io_ports;
151 u8 chipselect = hwif->select_data;
152 unsigned long mode;
153
154 pdbg("cs %u buf %p len %d\n", chipselect, buf, len);
155
156 len++;
157
158 enter_16bit(chipselect, mode);
159 __ide_mm_insw((void __iomem *) io_ports->data_addr, buf, len / 2);
160 leave_16bit(chipselect, mode);
161}
162
163static void at91_ide_output_data(ide_drive_t *drive, struct request *rq,
164 void *buf, unsigned int len)
165{
166 ide_hwif_t *hwif = drive->hwif;
167 struct ide_io_ports *io_ports = &hwif->io_ports;
168 u8 chipselect = hwif->select_data;
169 unsigned long mode;
170
171 pdbg("cs %u buf %p len %d\n", chipselect, buf, len);
172
173 enter_16bit(chipselect, mode);
174 __ide_mm_outsw((void __iomem *) io_ports->data_addr, buf, len / 2);
175 leave_16bit(chipselect, mode);
176}
177
178static u8 ide_mm_inb(unsigned long port)
179{
180 return readb((void __iomem *) port);
181}
182
183static void ide_mm_outb(u8 value, unsigned long port)
184{
185 writeb(value, (void __iomem *) port);
186}
187
188static void at91_ide_tf_load(ide_drive_t *drive, ide_task_t *task)
189{
190 ide_hwif_t *hwif = drive->hwif;
191 struct ide_io_ports *io_ports = &hwif->io_ports;
192 struct ide_taskfile *tf = &task->tf;
193 u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF;
194
195 if (task->tf_flags & IDE_TFLAG_FLAGGED)
196 HIHI = 0xFF;
197
198 if (task->tf_flags & IDE_TFLAG_OUT_DATA) {
199 u16 data = (tf->hob_data << 8) | tf->data;
200
201 at91_ide_output_data(drive, NULL, &data, 2);
202 }
203
204 if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
205 ide_mm_outb(tf->hob_feature, io_ports->feature_addr);
206 if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
207 ide_mm_outb(tf->hob_nsect, io_ports->nsect_addr);
208 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
209 ide_mm_outb(tf->hob_lbal, io_ports->lbal_addr);
210 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
211 ide_mm_outb(tf->hob_lbam, io_ports->lbam_addr);
212 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
213 ide_mm_outb(tf->hob_lbah, io_ports->lbah_addr);
214
215 if (task->tf_flags & IDE_TFLAG_OUT_FEATURE)
216 ide_mm_outb(tf->feature, io_ports->feature_addr);
217 if (task->tf_flags & IDE_TFLAG_OUT_NSECT)
218 ide_mm_outb(tf->nsect, io_ports->nsect_addr);
219 if (task->tf_flags & IDE_TFLAG_OUT_LBAL)
220 ide_mm_outb(tf->lbal, io_ports->lbal_addr);
221 if (task->tf_flags & IDE_TFLAG_OUT_LBAM)
222 ide_mm_outb(tf->lbam, io_ports->lbam_addr);
223 if (task->tf_flags & IDE_TFLAG_OUT_LBAH)
224 ide_mm_outb(tf->lbah, io_ports->lbah_addr);
225
226 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE)
227 ide_mm_outb((tf->device & HIHI) | drive->select, io_ports->device_addr);
228}
229
230static void at91_ide_tf_read(ide_drive_t *drive, ide_task_t *task)
231{
232 ide_hwif_t *hwif = drive->hwif;
233 struct ide_io_ports *io_ports = &hwif->io_ports;
234 struct ide_taskfile *tf = &task->tf;
235
236 if (task->tf_flags & IDE_TFLAG_IN_DATA) {
237 u16 data;
238
239 at91_ide_input_data(drive, NULL, &data, 2);
240 tf->data = data & 0xff;
241 tf->hob_data = (data >> 8) & 0xff;
242 }
243
244 /* be sure we're looking at the low order bits */
245 ide_mm_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
246
247 if (task->tf_flags & IDE_TFLAG_IN_FEATURE)
248 tf->feature = ide_mm_inb(io_ports->feature_addr);
249 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
250 tf->nsect = ide_mm_inb(io_ports->nsect_addr);
251 if (task->tf_flags & IDE_TFLAG_IN_LBAL)
252 tf->lbal = ide_mm_inb(io_ports->lbal_addr);
253 if (task->tf_flags & IDE_TFLAG_IN_LBAM)
254 tf->lbam = ide_mm_inb(io_ports->lbam_addr);
255 if (task->tf_flags & IDE_TFLAG_IN_LBAH)
256 tf->lbah = ide_mm_inb(io_ports->lbah_addr);
257 if (task->tf_flags & IDE_TFLAG_IN_DEVICE)
258 tf->device = ide_mm_inb(io_ports->device_addr);
259
260 if (task->tf_flags & IDE_TFLAG_LBA48) {
261 ide_mm_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
262
263 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
264 tf->hob_feature = ide_mm_inb(io_ports->feature_addr);
265 if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
266 tf->hob_nsect = ide_mm_inb(io_ports->nsect_addr);
267 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
268 tf->hob_lbal = ide_mm_inb(io_ports->lbal_addr);
269 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
270 tf->hob_lbam = ide_mm_inb(io_ports->lbam_addr);
271 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
272 tf->hob_lbah = ide_mm_inb(io_ports->lbah_addr);
273 }
274}
275
276static void at91_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
277{
278 struct ide_timing *timing;
279 u8 chipselect = drive->hwif->select_data;
280 int use_iordy = 0;
281
282 pdbg("chipselect %u pio %u\n", chipselect, pio);
283
284 timing = ide_timing_find_mode(XFER_PIO_0 + pio);
285 BUG_ON(!timing);
286
287 if ((pio > 2 || ata_id_has_iordy(drive->id)) &&
288 !(ata_id_is_cfa(drive->id) && pio > 4))
289 use_iordy = 1;
290
291 apply_timings(chipselect, pio, timing, use_iordy);
292}
293
294static const struct ide_tp_ops at91_ide_tp_ops = {
295 .exec_command = ide_exec_command,
296 .read_status = ide_read_status,
297 .read_altstatus = ide_read_altstatus,
298 .set_irq = ide_set_irq,
299
300 .tf_load = at91_ide_tf_load,
301 .tf_read = at91_ide_tf_read,
302
303 .input_data = at91_ide_input_data,
304 .output_data = at91_ide_output_data,
305};
306
307static const struct ide_port_ops at91_ide_port_ops = {
308 .set_pio_mode = at91_ide_set_pio_mode,
309};
310
311static const struct ide_port_info at91_ide_port_info __initdata = {
312 .port_ops = &at91_ide_port_ops,
313 .tp_ops = &at91_ide_tp_ops,
314 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE |
315 IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS,
316 .pio_mask = ATA_PIO5,
317};
318
319/*
320 * If interrupt is delivered through GPIO, IRQ are triggered on falling
321 * and rising edge of signal. Whereas IDE device request interrupt on high
322 * level (rising edge in our case). This mean we have fake interrupts, so
323 * we need to check interrupt pin and exit instantly from ISR when line
324 * is on low level.
325 */
326
327irqreturn_t at91_irq_handler(int irq, void *dev_id)
328{
329 int ntries = 8;
330 int pin_val1, pin_val2;
331
332 /* additional deglitch, line can be noisy in badly designed PCB */
333 do {
334 pin_val1 = at91_get_gpio_value(irq);
335 pin_val2 = at91_get_gpio_value(irq);
336 } while (pin_val1 != pin_val2 && --ntries > 0);
337
338 if (pin_val1 == 0 || ntries <= 0)
339 return IRQ_HANDLED;
340
341 return ide_intr(irq, dev_id);
342}
343
344static int __init at91_ide_probe(struct platform_device *pdev)
345{
346 int ret;
347 hw_regs_t hw;
348 hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
349 struct ide_host *host;
350 struct resource *res;
351 unsigned long tf_base = 0, ctl_base = 0;
352 struct at91_cf_data *board = pdev->dev.platform_data;
353
354 if (!board)
355 return -ENODEV;
356
357 if (board->det_pin && at91_get_gpio_value(board->det_pin) != 0) {
358 perr("no device detected\n");
359 return -ENODEV;
360 }
361
362 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
363 if (!res) {
364 perr("can't get memory resource\n");
365 return -ENODEV;
366 }
367
368 if (!devm_request_mem_region(&pdev->dev, res->start + TASK_FILE,
369 REGS_SIZE, "ide") ||
370 !devm_request_mem_region(&pdev->dev, res->start + ALT_MODE,
371 REGS_SIZE, "alt")) {
372 perr("memory resources in use\n");
373 return -EBUSY;
374 }
375
376 pdbg("chipselect %u irq %u res %08lx\n", board->chipselect,
377 board->irq_pin, (unsigned long) res->start);
378
379 tf_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + TASK_FILE,
380 REGS_SIZE);
381 ctl_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + ALT_MODE,
382 REGS_SIZE);
383 if (!tf_base || !ctl_base) {
384 perr("can't map memory regions\n");
385 return -EBUSY;
386 }
387
388 memset(&hw, 0, sizeof(hw));
389
390 if (board->flags & AT91_IDE_SWAP_A0_A2) {
391 /* workaround for stupid hardware bug */
392 hw.io_ports.data_addr = tf_base + 0;
393 hw.io_ports.error_addr = tf_base + 4;
394 hw.io_ports.nsect_addr = tf_base + 2;
395 hw.io_ports.lbal_addr = tf_base + 6;
396 hw.io_ports.lbam_addr = tf_base + 1;
397 hw.io_ports.lbah_addr = tf_base + 5;
398 hw.io_ports.device_addr = tf_base + 3;
399 hw.io_ports.command_addr = tf_base + 7;
400 hw.io_ports.ctl_addr = ctl_base + 3;
401 } else
402 ide_std_init_ports(&hw, tf_base, ctl_base + 6);
403
404 hw.irq = board->irq_pin;
405 hw.chipset = ide_generic;
406 hw.dev = &pdev->dev;
407
408 host = ide_host_alloc(&at91_ide_port_info, hws);
409 if (!host) {
410 perr("failed to allocate ide host\n");
411 return -ENOMEM;
412 }
413
414 /* setup Static Memory Controller - PIO 0 as default */
415 apply_timings(board->chipselect, 0, ide_timing_find_mode(XFER_PIO_0), 0);
416
417 /* with GPIO interrupt we have to do quirks in handler */
418 if (board->irq_pin >= PIN_BASE)
419 host->irq_handler = at91_irq_handler;
420
421 host->ports[0]->select_data = board->chipselect;
422
423 ret = ide_host_register(host, &at91_ide_port_info, hws);
424 if (ret) {
425 perr("failed to register ide host\n");
426 goto err_free_host;
427 }
428 platform_set_drvdata(pdev, host);
429 return 0;
430
431err_free_host:
432 ide_host_free(host);
433 return ret;
434}
435
436static int __exit at91_ide_remove(struct platform_device *pdev)
437{
438 struct ide_host *host = platform_get_drvdata(pdev);
439
440 ide_host_remove(host);
441 return 0;
442}
443
444static struct platform_driver at91_ide_driver = {
445 .driver = {
446 .name = DRV_NAME,
447 .owner = THIS_MODULE,
448 },
449 .remove = __exit_p(at91_ide_remove),
450};
451
452static int __init at91_ide_init(void)
453{
454 return platform_driver_probe(&at91_ide_driver, at91_ide_probe);
455}
456
457static void __exit at91_ide_exit(void)
458{
459 platform_driver_unregister(&at91_ide_driver);
460}
461
462module_init(at91_ide_init);
463module_exit(at91_ide_exit);
464
465MODULE_LICENSE("GPL");
466MODULE_AUTHOR("Stanislaw Gruszka <stf_xl@wp.pl>");
467
diff --git a/drivers/ide/atiixp.c b/drivers/ide/atiixp.c
index ecd1e62ca91a..923cbfe259d3 100644
--- a/drivers/ide/atiixp.c
+++ b/drivers/ide/atiixp.c
@@ -142,7 +142,6 @@ static const struct ide_port_info atiixp_pci_info[] __devinitdata = {
142 .name = DRV_NAME, 142 .name = DRV_NAME,
143 .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, 143 .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}},
144 .port_ops = &atiixp_port_ops, 144 .port_ops = &atiixp_port_ops,
145 .host_flags = IDE_HFLAG_LEGACY_IRQS,
146 .pio_mask = ATA_PIO4, 145 .pio_mask = ATA_PIO4,
147 .mwdma_mask = ATA_MWDMA2, 146 .mwdma_mask = ATA_MWDMA2,
148 .udma_mask = ATA_UDMA5, 147 .udma_mask = ATA_UDMA5,
@@ -151,7 +150,7 @@ static const struct ide_port_info atiixp_pci_info[] __devinitdata = {
151 .name = DRV_NAME, 150 .name = DRV_NAME,
152 .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, 151 .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}},
153 .port_ops = &atiixp_port_ops, 152 .port_ops = &atiixp_port_ops,
154 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, 153 .host_flags = IDE_HFLAG_SINGLE,
155 .pio_mask = ATA_PIO4, 154 .pio_mask = ATA_PIO4,
156 .mwdma_mask = ATA_MWDMA2, 155 .mwdma_mask = ATA_MWDMA2,
157 .udma_mask = ATA_UDMA5, 156 .udma_mask = ATA_UDMA5,
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c
index 79a2dfed8eb7..154ec2cf734f 100644
--- a/drivers/ide/au1xxx-ide.c
+++ b/drivers/ide/au1xxx-ide.c
@@ -536,9 +536,8 @@ static const struct ide_port_info au1xxx_port_info = {
536#endif 536#endif
537}; 537};
538 538
539static int au_ide_probe(struct device *dev) 539static int au_ide_probe(struct platform_device *dev)
540{ 540{
541 struct platform_device *pdev = to_platform_device(dev);
542 _auide_hwif *ahwif = &auide_hwif; 541 _auide_hwif *ahwif = &auide_hwif;
543 struct resource *res; 542 struct resource *res;
544 struct ide_host *host; 543 struct ide_host *host;
@@ -552,23 +551,23 @@ static int au_ide_probe(struct device *dev)
552#endif 551#endif
553 552
554 memset(&auide_hwif, 0, sizeof(_auide_hwif)); 553 memset(&auide_hwif, 0, sizeof(_auide_hwif));
555 ahwif->irq = platform_get_irq(pdev, 0); 554 ahwif->irq = platform_get_irq(dev, 0);
556 555
557 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 556 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
558 557
559 if (res == NULL) { 558 if (res == NULL) {
560 pr_debug("%s %d: no base address\n", DRV_NAME, pdev->id); 559 pr_debug("%s %d: no base address\n", DRV_NAME, dev->id);
561 ret = -ENODEV; 560 ret = -ENODEV;
562 goto out; 561 goto out;
563 } 562 }
564 if (ahwif->irq < 0) { 563 if (ahwif->irq < 0) {
565 pr_debug("%s %d: no IRQ\n", DRV_NAME, pdev->id); 564 pr_debug("%s %d: no IRQ\n", DRV_NAME, dev->id);
566 ret = -ENODEV; 565 ret = -ENODEV;
567 goto out; 566 goto out;
568 } 567 }
569 568
570 if (!request_mem_region(res->start, res->end - res->start + 1, 569 if (!request_mem_region(res->start, res->end - res->start + 1,
571 pdev->name)) { 570 dev->name)) {
572 pr_debug("%s: request_mem_region failed\n", DRV_NAME); 571 pr_debug("%s: request_mem_region failed\n", DRV_NAME);
573 ret = -EBUSY; 572 ret = -EBUSY;
574 goto out; 573 goto out;
@@ -583,7 +582,7 @@ static int au_ide_probe(struct device *dev)
583 memset(&hw, 0, sizeof(hw)); 582 memset(&hw, 0, sizeof(hw));
584 auide_setup_ports(&hw, ahwif); 583 auide_setup_ports(&hw, ahwif);
585 hw.irq = ahwif->irq; 584 hw.irq = ahwif->irq;
586 hw.dev = dev; 585 hw.dev = &dev->dev;
587 hw.chipset = ide_au1xxx; 586 hw.chipset = ide_au1xxx;
588 587
589 ret = ide_host_add(&au1xxx_port_info, hws, &host); 588 ret = ide_host_add(&au1xxx_port_info, hws, &host);
@@ -592,7 +591,7 @@ static int au_ide_probe(struct device *dev)
592 591
593 auide_hwif.hwif = host->ports[0]; 592 auide_hwif.hwif = host->ports[0];
594 593
595 dev_set_drvdata(dev, host); 594 platform_set_drvdata(dev, host);
596 595
597 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode ); 596 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
598 597
@@ -600,38 +599,39 @@ static int au_ide_probe(struct device *dev)
600 return ret; 599 return ret;
601} 600}
602 601
603static int au_ide_remove(struct device *dev) 602static int au_ide_remove(struct platform_device *dev)
604{ 603{
605 struct platform_device *pdev = to_platform_device(dev);
606 struct resource *res; 604 struct resource *res;
607 struct ide_host *host = dev_get_drvdata(dev); 605 struct ide_host *host = platform_get_drvdata(dev);
608 _auide_hwif *ahwif = &auide_hwif; 606 _auide_hwif *ahwif = &auide_hwif;
609 607
610 ide_host_remove(host); 608 ide_host_remove(host);
611 609
612 iounmap((void *)ahwif->regbase); 610 iounmap((void *)ahwif->regbase);
613 611
614 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 612 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
615 release_mem_region(res->start, res->end - res->start + 1); 613 release_mem_region(res->start, res->end - res->start + 1);
616 614
617 return 0; 615 return 0;
618} 616}
619 617
620static struct device_driver au1200_ide_driver = { 618static struct platform_driver au1200_ide_driver = {
621 .name = "au1200-ide", 619 .driver = {
622 .bus = &platform_bus_type, 620 .name = "au1200-ide",
621 .owner = THIS_MODULE,
622 },
623 .probe = au_ide_probe, 623 .probe = au_ide_probe,
624 .remove = au_ide_remove, 624 .remove = au_ide_remove,
625}; 625};
626 626
627static int __init au_ide_init(void) 627static int __init au_ide_init(void)
628{ 628{
629 return driver_register(&au1200_ide_driver); 629 return platform_driver_register(&au1200_ide_driver);
630} 630}
631 631
632static void __exit au_ide_exit(void) 632static void __exit au_ide_exit(void)
633{ 633{
634 driver_unregister(&au1200_ide_driver); 634 platform_driver_unregister(&au1200_ide_driver);
635} 635}
636 636
637MODULE_LICENSE("GPL"); 637MODULE_LICENSE("GPL");
diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c
index 2f9688d87ecd..aeee036b1503 100644
--- a/drivers/ide/cmd64x.c
+++ b/drivers/ide/cmd64x.c
@@ -333,7 +333,7 @@ static int cmd646_1_dma_end(ide_drive_t *drive)
333 return (dma_stat & 7) != 4; 333 return (dma_stat & 7) != 4;
334} 334}
335 335
336static unsigned int init_chipset_cmd64x(struct pci_dev *dev) 336static int init_chipset_cmd64x(struct pci_dev *dev)
337{ 337{
338 u8 mrdmode = 0; 338 u8 mrdmode = 0;
339 339
diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c
index d003bec56ff9..58fb90e5b763 100644
--- a/drivers/ide/cs5520.c
+++ b/drivers/ide/cs5520.c
@@ -133,7 +133,8 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
133 * do all the device setup for us 133 * do all the device setup for us
134 */ 134 */
135 135
136 ide_pci_setup_ports(dev, d, 14, &hw[0], &hws[0]); 136 ide_pci_setup_ports(dev, d, &hw[0], &hws[0]);
137 hw[0].irq = 14;
137 138
138 return ide_host_add(d, hws, NULL); 139 return ide_host_add(d, hws, NULL);
139} 140}
diff --git a/drivers/ide/cs5530.c b/drivers/ide/cs5530.c
index d8ede85fe17f..8e8b35a89901 100644
--- a/drivers/ide/cs5530.c
+++ b/drivers/ide/cs5530.c
@@ -135,7 +135,7 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode)
135 * Initialize the cs5530 bridge for reliable IDE DMA operation. 135 * Initialize the cs5530 bridge for reliable IDE DMA operation.
136 */ 136 */
137 137
138static unsigned int init_chipset_cs5530(struct pci_dev *dev) 138static int init_chipset_cs5530(struct pci_dev *dev)
139{ 139{
140 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; 140 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL;
141 141
diff --git a/drivers/ide/delkin_cb.c b/drivers/ide/delkin_cb.c
index 8f1b2d9f0513..bacb1194c9c9 100644
--- a/drivers/ide/delkin_cb.c
+++ b/drivers/ide/delkin_cb.c
@@ -46,7 +46,7 @@ static const struct ide_port_ops delkin_cb_port_ops = {
46 .quirkproc = ide_undecoded_slave, 46 .quirkproc = ide_undecoded_slave,
47}; 47};
48 48
49static unsigned int delkin_cb_init_chipset(struct pci_dev *dev) 49static int delkin_cb_init_chipset(struct pci_dev *dev)
50{ 50{
51 unsigned long base = pci_resource_start(dev, 0); 51 unsigned long base = pci_resource_start(dev, 0);
52 int i; 52 int i;
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
index 3eb9b5c63a0f..d3b3e824f445 100644
--- a/drivers/ide/hpt366.c
+++ b/drivers/ide/hpt366.c
@@ -995,7 +995,7 @@ static void hpt3xx_disable_fast_irq(struct pci_dev *dev, u8 mcr_addr)
995 pci_write_config_byte(dev, mcr_addr + 1, new_mcr); 995 pci_write_config_byte(dev, mcr_addr + 1, new_mcr);
996} 996}
997 997
998static unsigned int init_chipset_hpt366(struct pci_dev *dev) 998static int init_chipset_hpt366(struct pci_dev *dev)
999{ 999{
1000 unsigned long io_base = pci_resource_start(dev, 4); 1000 unsigned long io_base = pci_resource_start(dev, 4);
1001 struct hpt_info *info = hpt3xx_get_info(&dev->dev); 1001 struct hpt_info *info = hpt3xx_get_info(&dev->dev);
@@ -1237,7 +1237,7 @@ static unsigned int init_chipset_hpt366(struct pci_dev *dev)
1237 hpt3xx_disable_fast_irq(dev, 0x50); 1237 hpt3xx_disable_fast_irq(dev, 0x50);
1238 hpt3xx_disable_fast_irq(dev, 0x54); 1238 hpt3xx_disable_fast_irq(dev, 0x54);
1239 1239
1240 return dev->irq; 1240 return 0;
1241} 1241}
1242 1242
1243static u8 hpt3xx_cable_detect(ide_hwif_t *hwif) 1243static u8 hpt3xx_cable_detect(ide_hwif_t *hwif)
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index ec7d07fa570a..5b704f1ea90c 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -20,9 +20,6 @@
20#include <acpi/acpi_bus.h> 20#include <acpi/acpi_bus.h>
21 21
22#define REGS_PER_GTF 7 22#define REGS_PER_GTF 7
23struct taskfile_array {
24 u8 tfa[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */
25};
26 23
27struct GTM_buffer { 24struct GTM_buffer {
28 u32 PIO_speed0; 25 u32 PIO_speed0;
@@ -89,12 +86,8 @@ static const struct dmi_system_id ide_acpi_dmi_table[] = {
89 { } /* terminate list */ 86 { } /* terminate list */
90}; 87};
91 88
92static int ide_acpi_blacklist(void) 89int ide_acpi_init(void)
93{ 90{
94 static int done;
95 if (done)
96 return 0;
97 done = 1;
98 dmi_check_system(ide_acpi_dmi_table); 91 dmi_check_system(ide_acpi_dmi_table);
99 return 0; 92 return 0;
100} 93}
@@ -202,40 +195,6 @@ static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif)
202} 195}
203 196
204/** 197/**
205 * ide_acpi_drive_get_handle - Get ACPI object handle for a given drive
206 * @drive: device to locate
207 *
208 * Retrieves the object handle of a given drive. According to the ACPI
209 * spec the drive is a child of the hwif.
210 *
211 * Returns handle on success, 0 on error.
212 */
213static acpi_handle ide_acpi_drive_get_handle(ide_drive_t *drive)
214{
215 ide_hwif_t *hwif = drive->hwif;
216 int port;
217 acpi_handle drive_handle;
218
219 if (!hwif->acpidata)
220 return NULL;
221
222 if (!hwif->acpidata->obj_handle)
223 return NULL;
224
225 port = hwif->channel ? drive->dn - 2: drive->dn;
226
227 DEBPRINT("ENTER: %s at channel#: %d port#: %d\n",
228 drive->name, hwif->channel, port);
229
230
231 /* TBD: could also check ACPI object VALID bits */
232 drive_handle = acpi_get_child(hwif->acpidata->obj_handle, port);
233 DEBPRINT("drive %s handle 0x%p\n", drive->name, drive_handle);
234
235 return drive_handle;
236}
237
238/**
239 * do_drive_get_GTF - get the drive bootup default taskfile settings 198 * do_drive_get_GTF - get the drive bootup default taskfile settings
240 * @drive: the drive for which the taskfile settings should be retrieved 199 * @drive: the drive for which the taskfile settings should be retrieved
241 * @gtf_length: number of bytes of _GTF data returned at @gtf_address 200 * @gtf_length: number of bytes of _GTF data returned at @gtf_address
@@ -257,47 +216,15 @@ static int do_drive_get_GTF(ide_drive_t *drive,
257 acpi_status status; 216 acpi_status status;
258 struct acpi_buffer output; 217 struct acpi_buffer output;
259 union acpi_object *out_obj; 218 union acpi_object *out_obj;
260 ide_hwif_t *hwif = drive->hwif;
261 struct device *dev = hwif->gendev.parent;
262 int err = -ENODEV; 219 int err = -ENODEV;
263 int port;
264 220
265 *gtf_length = 0; 221 *gtf_length = 0;
266 *gtf_address = 0UL; 222 *gtf_address = 0UL;
267 *obj_loc = 0UL; 223 *obj_loc = 0UL;
268 224
269 if (ide_noacpi)
270 return 0;
271
272 if (!dev) {
273 DEBPRINT("no PCI device for %s\n", hwif->name);
274 goto out;
275 }
276
277 if (!hwif->acpidata) {
278 DEBPRINT("no ACPI data for %s\n", hwif->name);
279 goto out;
280 }
281
282 port = hwif->channel ? drive->dn - 2: drive->dn;
283
284 DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n",
285 hwif->name, dev_name(dev), port, hwif->channel);
286
287 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) {
288 DEBPRINT("%s drive %d:%d not present\n",
289 hwif->name, hwif->channel, port);
290 goto out;
291 }
292
293 /* Get this drive's _ADR info. if not already known. */
294 if (!drive->acpidata->obj_handle) { 225 if (!drive->acpidata->obj_handle) {
295 drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive); 226 DEBPRINT("No ACPI object found for %s\n", drive->name);
296 if (!drive->acpidata->obj_handle) { 227 goto out;
297 DEBPRINT("No ACPI object found for %s\n",
298 drive->name);
299 goto out;
300 }
301 } 228 }
302 229
303 /* Setting up output buffer */ 230 /* Setting up output buffer */
@@ -355,43 +282,6 @@ out:
355} 282}
356 283
357/** 284/**
358 * taskfile_load_raw - send taskfile registers to drive
359 * @drive: drive to which output is sent
360 * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7)
361 *
362 * Outputs IDE taskfile to the drive.
363 */
364static int taskfile_load_raw(ide_drive_t *drive,
365 const struct taskfile_array *gtf)
366{
367 ide_task_t args;
368 int err = 0;
369
370 DEBPRINT("(0x1f1-1f7): hex: "
371 "%02x %02x %02x %02x %02x %02x %02x\n",
372 gtf->tfa[0], gtf->tfa[1], gtf->tfa[2],
373 gtf->tfa[3], gtf->tfa[4], gtf->tfa[5], gtf->tfa[6]);
374
375 memset(&args, 0, sizeof(ide_task_t));
376
377 /* convert gtf to IDE Taskfile */
378 memcpy(&args.tf_array[7], &gtf->tfa, 7);
379 args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
380
381 if (!ide_acpigtf) {
382 DEBPRINT("_GTF execution disabled\n");
383 return err;
384 }
385
386 err = ide_no_data_taskfile(drive, &args);
387 if (err)
388 printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n",
389 __func__, err);
390
391 return err;
392}
393
394/**
395 * do_drive_set_taskfiles - write the drive taskfile settings from _GTF 285 * do_drive_set_taskfiles - write the drive taskfile settings from _GTF
396 * @drive: the drive to which the taskfile command should be sent 286 * @drive: the drive to which the taskfile command should be sent
397 * @gtf_length: total number of bytes of _GTF taskfiles 287 * @gtf_length: total number of bytes of _GTF taskfiles
@@ -404,43 +294,41 @@ static int do_drive_set_taskfiles(ide_drive_t *drive,
404 unsigned int gtf_length, 294 unsigned int gtf_length,
405 unsigned long gtf_address) 295 unsigned long gtf_address)
406{ 296{
407 int rc = -ENODEV, err; 297 int rc = 0, err;
408 int gtf_count = gtf_length / REGS_PER_GTF; 298 int gtf_count = gtf_length / REGS_PER_GTF;
409 int ix; 299 int ix;
410 struct taskfile_array *gtf;
411
412 if (ide_noacpi)
413 return 0;
414
415 DEBPRINT("ENTER: %s, hard_port#: %d\n", drive->name, drive->dn);
416
417 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
418 goto out;
419
420 if (!gtf_count) /* shouldn't be here */
421 goto out;
422 300
423 DEBPRINT("total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n", 301 DEBPRINT("total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n",
424 gtf_length, gtf_length, gtf_count, gtf_address); 302 gtf_length, gtf_length, gtf_count, gtf_address);
425 303
426 if (gtf_length % REGS_PER_GTF) { 304 /* send all taskfile registers (0x1f1-0x1f7) *in*that*order* */
427 printk(KERN_ERR "%s: unexpected GTF length (%d)\n",
428 __func__, gtf_length);
429 goto out;
430 }
431
432 rc = 0;
433 for (ix = 0; ix < gtf_count; ix++) { 305 for (ix = 0; ix < gtf_count; ix++) {
434 gtf = (struct taskfile_array *) 306 u8 *gtf = (u8 *)(gtf_address + ix * REGS_PER_GTF);
435 (gtf_address + ix * REGS_PER_GTF); 307 ide_task_t task;
436 308
437 /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ 309 DEBPRINT("(0x1f1-1f7): "
438 err = taskfile_load_raw(drive, gtf); 310 "hex: %02x %02x %02x %02x %02x %02x %02x\n",
439 if (err) 311 gtf[0], gtf[1], gtf[2],
312 gtf[3], gtf[4], gtf[5], gtf[6]);
313
314 if (!ide_acpigtf) {
315 DEBPRINT("_GTF execution disabled\n");
316 continue;
317 }
318
319 /* convert GTF to taskfile */
320 memset(&task, 0, sizeof(ide_task_t));
321 memcpy(&task.tf_array[7], gtf, REGS_PER_GTF);
322 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
323
324 err = ide_no_data_taskfile(drive, &task);
325 if (err) {
326 printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n",
327 __func__, err);
440 rc = err; 328 rc = err;
329 }
441 } 330 }
442 331
443out:
444 return rc; 332 return rc;
445} 333}
446 334
@@ -647,26 +535,23 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
647 DEBPRINT("no ACPI data for %s\n", hwif->name); 535 DEBPRINT("no ACPI data for %s\n", hwif->name);
648 return; 536 return;
649 } 537 }
538
650 /* channel first and then drives for power on and verse versa for power off */ 539 /* channel first and then drives for power on and verse versa for power off */
651 if (on) 540 if (on)
652 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); 541 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
653 542
654 ide_port_for_each_dev(i, drive, hwif) { 543 ide_port_for_each_present_dev(i, drive, hwif) {
655 if (!drive->acpidata->obj_handle) 544 if (drive->acpidata->obj_handle)
656 drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
657
658 if (drive->acpidata->obj_handle &&
659 (drive->dev_flags & IDE_DFLAG_PRESENT)) {
660 acpi_bus_set_power(drive->acpidata->obj_handle, 545 acpi_bus_set_power(drive->acpidata->obj_handle,
661 on? ACPI_STATE_D0: ACPI_STATE_D3); 546 on ? ACPI_STATE_D0 : ACPI_STATE_D3);
662 }
663 } 547 }
548
664 if (!on) 549 if (!on)
665 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3); 550 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3);
666} 551}
667 552
668/** 553/**
669 * ide_acpi_init - initialize the ACPI link for an IDE interface 554 * ide_acpi_init_port - initialize the ACPI link for an IDE interface
670 * @hwif: target IDE interface (channel) 555 * @hwif: target IDE interface (channel)
671 * 556 *
672 * The ACPI spec is not quite clear when the drive identify buffer 557 * The ACPI spec is not quite clear when the drive identify buffer
@@ -676,10 +561,8 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
676 * So we get the information during startup; but this means that 561 * So we get the information during startup; but this means that
677 * any changes during run-time will be lost after resume. 562 * any changes during run-time will be lost after resume.
678 */ 563 */
679void ide_acpi_init(ide_hwif_t *hwif) 564void ide_acpi_init_port(ide_hwif_t *hwif)
680{ 565{
681 ide_acpi_blacklist();
682
683 hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL); 566 hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL);
684 if (!hwif->acpidata) 567 if (!hwif->acpidata)
685 return; 568 return;
@@ -708,15 +591,24 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
708 hwif->devices[0]->acpidata = &hwif->acpidata->master; 591 hwif->devices[0]->acpidata = &hwif->acpidata->master;
709 hwif->devices[1]->acpidata = &hwif->acpidata->slave; 592 hwif->devices[1]->acpidata = &hwif->acpidata->slave;
710 593
711 /* 594 /* get _ADR info for each device */
712 * Send IDENTIFY for each drive 595 ide_port_for_each_present_dev(i, drive, hwif) {
713 */ 596 acpi_handle dev_handle;
714 ide_port_for_each_dev(i, drive, hwif) {
715 memset(drive->acpidata, 0, sizeof(*drive->acpidata));
716 597
717 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 598 DEBPRINT("ENTER: %s at channel#: %d port#: %d\n",
718 continue; 599 drive->name, hwif->channel, drive->dn & 1);
600
601 /* TBD: could also check ACPI object VALID bits */
602 dev_handle = acpi_get_child(hwif->acpidata->obj_handle,
603 drive->dn & 1);
604
605 DEBPRINT("drive %s handle 0x%p\n", drive->name, dev_handle);
606
607 drive->acpidata->obj_handle = dev_handle;
608 }
719 609
610 /* send IDENTIFY for each device */
611 ide_port_for_each_present_dev(i, drive, hwif) {
720 err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff); 612 err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff);
721 if (err) 613 if (err)
722 DEBPRINT("identify device %s failed (%d)\n", 614 DEBPRINT("identify device %s failed (%d)\n",
@@ -736,9 +628,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
736 ide_acpi_get_timing(hwif); 628 ide_acpi_get_timing(hwif);
737 ide_acpi_push_timing(hwif); 629 ide_acpi_push_timing(hwif);
738 630
739 ide_port_for_each_dev(i, drive, hwif) { 631 ide_port_for_each_present_dev(i, drive, hwif) {
740 if (drive->dev_flags & IDE_DFLAG_PRESENT) 632 ide_acpi_exec_tfs(drive);
741 /* Execute ACPI startup code */
742 ide_acpi_exec_tfs(drive);
743 } 633 }
744} 634}
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index e96c01260598..6adc5b4a4406 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -140,10 +140,19 @@ static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
140 rq->cmd_flags |= REQ_PREEMPT; 140 rq->cmd_flags |= REQ_PREEMPT;
141 rq->buffer = (char *)pc; 141 rq->buffer = (char *)pc;
142 rq->rq_disk = disk; 142 rq->rq_disk = disk;
143
144 if (pc->req_xfer) {
145 rq->data = pc->buf;
146 rq->data_len = pc->req_xfer;
147 }
148
143 memcpy(rq->cmd, pc->c, 12); 149 memcpy(rq->cmd, pc->c, 12);
144 if (drive->media == ide_tape) 150 if (drive->media == ide_tape)
145 rq->cmd[13] = REQ_IDETAPE_PC1; 151 rq->cmd[13] = REQ_IDETAPE_PC1;
146 ide_do_drive_cmd(drive, rq); 152
153 drive->hwif->rq = NULL;
154
155 elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0);
147} 156}
148 157
149/* 158/*
@@ -159,6 +168,12 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
159 rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 168 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
160 rq->cmd_type = REQ_TYPE_SPECIAL; 169 rq->cmd_type = REQ_TYPE_SPECIAL;
161 rq->buffer = (char *)pc; 170 rq->buffer = (char *)pc;
171
172 if (pc->req_xfer) {
173 rq->data = pc->buf;
174 rq->data_len = pc->req_xfer;
175 }
176
162 memcpy(rq->cmd, pc->c, 12); 177 memcpy(rq->cmd, pc->c, 12);
163 if (drive->media == ide_tape) 178 if (drive->media == ide_tape)
164 rq->cmd[13] = REQ_IDETAPE_PC1; 179 rq->cmd[13] = REQ_IDETAPE_PC1;
@@ -285,6 +300,21 @@ int ide_cd_get_xferlen(struct request *rq)
285} 300}
286EXPORT_SYMBOL_GPL(ide_cd_get_xferlen); 301EXPORT_SYMBOL_GPL(ide_cd_get_xferlen);
287 302
303void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason)
304{
305 ide_task_t task;
306
307 memset(&task, 0, sizeof(task));
308 task.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM |
309 IDE_TFLAG_IN_NSECT;
310
311 drive->hwif->tp_ops->tf_read(drive, &task);
312
313 *bcount = (task.tf.lbah << 8) | task.tf.lbam;
314 *ireason = task.tf.nsect & 3;
315}
316EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason);
317
288/* 318/*
289 * This is the usual interrupt handler which will be called during a packet 319 * This is the usual interrupt handler which will be called during a packet
290 * command. We will transfer some of the data (as requested by the drive) 320 * command. We will transfer some of the data (as requested by the drive)
@@ -444,6 +474,25 @@ next_irq:
444 return ide_started; 474 return ide_started;
445} 475}
446 476
477static void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount)
478{
479 ide_hwif_t *hwif = drive->hwif;
480 ide_task_t task;
481 u8 dma = drive->dma;
482
483 memset(&task, 0, sizeof(task));
484 task.tf_flags = IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM |
485 IDE_TFLAG_OUT_FEATURE | tf_flags;
486 task.tf.feature = dma; /* Use PIO/DMA */
487 task.tf.lbam = bcount & 0xff;
488 task.tf.lbah = (bcount >> 8) & 0xff;
489
490 ide_tf_dump(drive->name, &task.tf);
491 hwif->tp_ops->set_irq(hwif, 1);
492 SELECT_MASK(drive, 0);
493 hwif->tp_ops->tf_load(drive, &task);
494}
495
447static u8 ide_read_ireason(ide_drive_t *drive) 496static u8 ide_read_ireason(ide_drive_t *drive)
448{ 497{
449 ide_task_t task; 498 ide_task_t task;
@@ -617,7 +666,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
617 : WAIT_TAPE_CMD; 666 : WAIT_TAPE_CMD;
618 } 667 }
619 668
620 ide_pktcmd_tf_load(drive, tf_flags, bcount, drive->dma); 669 ide_pktcmd_tf_load(drive, tf_flags, bcount);
621 670
622 /* Issue the packet command */ 671 /* Issue the packet command */
623 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { 672 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index ddfbea41d296..2177cd11664c 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -242,7 +242,9 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
242 ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x\n", 242 ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x\n",
243 failed_command->cmd[0]); 243 failed_command->cmd[0]);
244 244
245 ide_do_drive_cmd(drive, rq); 245 drive->hwif->rq = NULL;
246
247 elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0);
246} 248}
247 249
248static void cdrom_end_request(ide_drive_t *drive, int uptodate) 250static void cdrom_end_request(ide_drive_t *drive, int uptodate)
diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c
new file mode 100644
index 000000000000..7c3953414d47
--- /dev/null
+++ b/drivers/ide/ide-devsets.c
@@ -0,0 +1,190 @@
1
2#include <linux/kernel.h>
3#include <linux/ide.h>
4
5DEFINE_MUTEX(ide_setting_mtx);
6
7ide_devset_get(io_32bit, io_32bit);
8
9static int set_io_32bit(ide_drive_t *drive, int arg)
10{
11 if (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT)
12 return -EPERM;
13
14 if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1))
15 return -EINVAL;
16
17 drive->io_32bit = arg;
18
19 return 0;
20}
21
22ide_devset_get_flag(ksettings, IDE_DFLAG_KEEP_SETTINGS);
23
24static int set_ksettings(ide_drive_t *drive, int arg)
25{
26 if (arg < 0 || arg > 1)
27 return -EINVAL;
28
29 if (arg)
30 drive->dev_flags |= IDE_DFLAG_KEEP_SETTINGS;
31 else
32 drive->dev_flags &= ~IDE_DFLAG_KEEP_SETTINGS;
33
34 return 0;
35}
36
37ide_devset_get_flag(using_dma, IDE_DFLAG_USING_DMA);
38
39static int set_using_dma(ide_drive_t *drive, int arg)
40{
41#ifdef CONFIG_BLK_DEV_IDEDMA
42 int err = -EPERM;
43
44 if (arg < 0 || arg > 1)
45 return -EINVAL;
46
47 if (ata_id_has_dma(drive->id) == 0)
48 goto out;
49
50 if (drive->hwif->dma_ops == NULL)
51 goto out;
52
53 err = 0;
54
55 if (arg) {
56 if (ide_set_dma(drive))
57 err = -EIO;
58 } else
59 ide_dma_off(drive);
60
61out:
62 return err;
63#else
64 if (arg < 0 || arg > 1)
65 return -EINVAL;
66
67 return -EPERM;
68#endif
69}
70
71/*
72 * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away
73 */
74static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio)
75{
76 switch (req_pio) {
77 case 202:
78 case 201:
79 case 200:
80 case 102:
81 case 101:
82 case 100:
83 return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0;
84 case 9:
85 case 8:
86 return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0;
87 case 7:
88 case 6:
89 return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0;
90 default:
91 return 0;
92 }
93}
94
95static int set_pio_mode(ide_drive_t *drive, int arg)
96{
97 ide_hwif_t *hwif = drive->hwif;
98 const struct ide_port_ops *port_ops = hwif->port_ops;
99
100 if (arg < 0 || arg > 255)
101 return -EINVAL;
102
103 if (port_ops == NULL || port_ops->set_pio_mode == NULL ||
104 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
105 return -ENOSYS;
106
107 if (set_pio_mode_abuse(drive->hwif, arg)) {
108 if (arg == 8 || arg == 9) {
109 unsigned long flags;
110
111 /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */
112 spin_lock_irqsave(&hwif->lock, flags);
113 port_ops->set_pio_mode(drive, arg);
114 spin_unlock_irqrestore(&hwif->lock, flags);
115 } else
116 port_ops->set_pio_mode(drive, arg);
117 } else {
118 int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
119
120 ide_set_pio(drive, arg);
121
122 if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) {
123 if (keep_dma)
124 ide_dma_on(drive);
125 }
126 }
127
128 return 0;
129}
130
131ide_devset_get_flag(unmaskirq, IDE_DFLAG_UNMASK);
132
133static int set_unmaskirq(ide_drive_t *drive, int arg)
134{
135 if (drive->dev_flags & IDE_DFLAG_NO_UNMASK)
136 return -EPERM;
137
138 if (arg < 0 || arg > 1)
139 return -EINVAL;
140
141 if (arg)
142 drive->dev_flags |= IDE_DFLAG_UNMASK;
143 else
144 drive->dev_flags &= ~IDE_DFLAG_UNMASK;
145
146 return 0;
147}
148
149ide_ext_devset_rw_sync(io_32bit, io_32bit);
150ide_ext_devset_rw_sync(keepsettings, ksettings);
151ide_ext_devset_rw_sync(unmaskirq, unmaskirq);
152ide_ext_devset_rw_sync(using_dma, using_dma);
153__IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode);
154
155int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
156 int arg)
157{
158 struct request_queue *q = drive->queue;
159 struct request *rq;
160 int ret = 0;
161
162 if (!(setting->flags & DS_SYNC))
163 return setting->set(drive, arg);
164
165 rq = blk_get_request(q, READ, __GFP_WAIT);
166 rq->cmd_type = REQ_TYPE_SPECIAL;
167 rq->cmd_len = 5;
168 rq->cmd[0] = REQ_DEVSET_EXEC;
169 *(int *)&rq->cmd[1] = arg;
170 rq->special = setting->set;
171
172 if (blk_execute_rq(q, NULL, rq, 0))
173 ret = rq->errors;
174 blk_put_request(rq);
175
176 return ret;
177}
178
179ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq)
180{
181 int err, (*setfunc)(ide_drive_t *, int) = rq->special;
182
183 err = setfunc(drive, *(int *)&rq->cmd[1]);
184 if (err)
185 rq->errors = err;
186 else
187 err = 1;
188 ide_end_request(drive, err, 0);
189 return ide_stopped;
190}
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index 1146f4204c6e..1f86dcbd2b1c 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -125,5 +125,5 @@ const struct ide_proc_devset ide_disk_settings[] = {
125 IDE_PROC_DEVSET(multcount, 0, 16), 125 IDE_PROC_DEVSET(multcount, 0, 16),
126 IDE_PROC_DEVSET(nowerr, 0, 1), 126 IDE_PROC_DEVSET(nowerr, 0, 1),
127 IDE_PROC_DEVSET(wcache, 0, 1), 127 IDE_PROC_DEVSET(wcache, 0, 1),
128 { 0 }, 128 { NULL },
129}; 129};
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 72ebab0bc755..a878f4734f81 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -128,6 +128,7 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
128{ 128{
129 ide_hwif_t *hwif = drive->hwif; 129 ide_hwif_t *hwif = drive->hwif;
130 struct scatterlist *sg = hwif->sg_table; 130 struct scatterlist *sg = hwif->sg_table;
131 int i;
131 132
132 ide_map_sg(drive, rq); 133 ide_map_sg(drive, rq);
133 134
@@ -136,8 +137,13 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
136 else 137 else
137 hwif->sg_dma_direction = DMA_TO_DEVICE; 138 hwif->sg_dma_direction = DMA_TO_DEVICE;
138 139
139 return dma_map_sg(hwif->dev, sg, hwif->sg_nents, 140 i = dma_map_sg(hwif->dev, sg, hwif->sg_nents, hwif->sg_dma_direction);
140 hwif->sg_dma_direction); 141 if (i) {
142 hwif->orig_sg_nents = hwif->sg_nents;
143 hwif->sg_nents = i;
144 }
145
146 return i;
141} 147}
142EXPORT_SYMBOL_GPL(ide_build_sglist); 148EXPORT_SYMBOL_GPL(ide_build_sglist);
143 149
@@ -156,7 +162,7 @@ void ide_destroy_dmatable(ide_drive_t *drive)
156{ 162{
157 ide_hwif_t *hwif = drive->hwif; 163 ide_hwif_t *hwif = drive->hwif;
158 164
159 dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->sg_nents, 165 dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->orig_sg_nents,
160 hwif->sg_dma_direction); 166 hwif->sg_dma_direction);
161} 167}
162EXPORT_SYMBOL_GPL(ide_destroy_dmatable); 168EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
@@ -464,6 +470,63 @@ void ide_dma_timeout(ide_drive_t *drive)
464} 470}
465EXPORT_SYMBOL_GPL(ide_dma_timeout); 471EXPORT_SYMBOL_GPL(ide_dma_timeout);
466 472
473/*
474 * un-busy the port etc, and clear any pending DMA status. we want to
475 * retry the current request in pio mode instead of risking tossing it
476 * all away
477 */
478ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
479{
480 ide_hwif_t *hwif = drive->hwif;
481 struct request *rq;
482 ide_startstop_t ret = ide_stopped;
483
484 /*
485 * end current dma transaction
486 */
487
488 if (error < 0) {
489 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
490 (void)hwif->dma_ops->dma_end(drive);
491 ret = ide_error(drive, "dma timeout error",
492 hwif->tp_ops->read_status(hwif));
493 } else {
494 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name);
495 hwif->dma_ops->dma_timeout(drive);
496 }
497
498 /*
499 * disable dma for now, but remember that we did so because of
500 * a timeout -- we'll reenable after we finish this next request
501 * (or rather the first chunk of it) in pio.
502 */
503 drive->dev_flags |= IDE_DFLAG_DMA_PIO_RETRY;
504 drive->retry_pio++;
505 ide_dma_off_quietly(drive);
506
507 /*
508 * un-busy drive etc and make sure request is sane
509 */
510
511 rq = hwif->rq;
512 if (!rq)
513 goto out;
514
515 hwif->rq = NULL;
516
517 rq->errors = 0;
518
519 if (!rq->bio)
520 goto out;
521
522 rq->sector = rq->bio->bi_sector;
523 rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9;
524 rq->hard_cur_sectors = rq->current_nr_sectors;
525 rq->buffer = bio_data(rq->bio);
526out:
527 return ret;
528}
529
467void ide_release_dma_engine(ide_hwif_t *hwif) 530void ide_release_dma_engine(ide_hwif_t *hwif)
468{ 531{
469 if (hwif->dmatable_cpu) { 532 if (hwif->dmatable_cpu) {
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c
new file mode 100644
index 000000000000..1231b5e486f2
--- /dev/null
+++ b/drivers/ide/ide-eh.c
@@ -0,0 +1,428 @@
1
2#include <linux/kernel.h>
3#include <linux/ide.h>
4#include <linux/delay.h>
5
6static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq,
7 u8 stat, u8 err)
8{
9 ide_hwif_t *hwif = drive->hwif;
10
11 if ((stat & ATA_BUSY) ||
12 ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
13 /* other bits are useless when BUSY */
14 rq->errors |= ERROR_RESET;
15 } else if (stat & ATA_ERR) {
16 /* err has different meaning on cdrom and tape */
17 if (err == ATA_ABORTED) {
18 if ((drive->dev_flags & IDE_DFLAG_LBA) &&
19 /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */
20 hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS)
21 return ide_stopped;
22 } else if ((err & BAD_CRC) == BAD_CRC) {
23 /* UDMA crc error, just retry the operation */
24 drive->crc_count++;
25 } else if (err & (ATA_BBK | ATA_UNC)) {
26 /* retries won't help these */
27 rq->errors = ERROR_MAX;
28 } else if (err & ATA_TRK0NF) {
29 /* help it find track zero */
30 rq->errors |= ERROR_RECAL;
31 }
32 }
33
34 if ((stat & ATA_DRQ) && rq_data_dir(rq) == READ &&
35 (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) {
36 int nsect = drive->mult_count ? drive->mult_count : 1;
37
38 ide_pad_transfer(drive, READ, nsect * SECTOR_SIZE);
39 }
40
41 if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) {
42 ide_kill_rq(drive, rq);
43 return ide_stopped;
44 }
45
46 if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ))
47 rq->errors |= ERROR_RESET;
48
49 if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
50 ++rq->errors;
51 return ide_do_reset(drive);
52 }
53
54 if ((rq->errors & ERROR_RECAL) == ERROR_RECAL)
55 drive->special.b.recalibrate = 1;
56
57 ++rq->errors;
58
59 return ide_stopped;
60}
61
62static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq,
63 u8 stat, u8 err)
64{
65 ide_hwif_t *hwif = drive->hwif;
66
67 if ((stat & ATA_BUSY) ||
68 ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
69 /* other bits are useless when BUSY */
70 rq->errors |= ERROR_RESET;
71 } else {
72 /* add decoding error stuff */
73 }
74
75 if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ))
76 /* force an abort */
77 hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE);
78
79 if (rq->errors >= ERROR_MAX) {
80 ide_kill_rq(drive, rq);
81 } else {
82 if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
83 ++rq->errors;
84 return ide_do_reset(drive);
85 }
86 ++rq->errors;
87 }
88
89 return ide_stopped;
90}
91
92static ide_startstop_t __ide_error(ide_drive_t *drive, struct request *rq,
93 u8 stat, u8 err)
94{
95 if (drive->media == ide_disk)
96 return ide_ata_error(drive, rq, stat, err);
97 return ide_atapi_error(drive, rq, stat, err);
98}
99
100/**
101 * ide_error - handle an error on the IDE
102 * @drive: drive the error occurred on
103 * @msg: message to report
104 * @stat: status bits
105 *
106 * ide_error() takes action based on the error returned by the drive.
107 * For normal I/O that may well include retries. We deal with
108 * both new-style (taskfile) and old style command handling here.
109 * In the case of taskfile command handling there is work left to
110 * do
111 */
112
113ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat)
114{
115 struct request *rq;
116 u8 err;
117
118 err = ide_dump_status(drive, msg, stat);
119
120 rq = drive->hwif->rq;
121 if (rq == NULL)
122 return ide_stopped;
123
124 /* retry only "normal" I/O: */
125 if (!blk_fs_request(rq)) {
126 rq->errors = 1;
127 ide_end_drive_cmd(drive, stat, err);
128 return ide_stopped;
129 }
130
131 return __ide_error(drive, rq, stat, err);
132}
133EXPORT_SYMBOL_GPL(ide_error);
134
135static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
136{
137 struct request *rq = drive->hwif->rq;
138
139 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET)
140 ide_end_request(drive, err ? err : 1, 0);
141}
142
143/* needed below */
144static ide_startstop_t do_reset1(ide_drive_t *, int);
145
146/*
147 * atapi_reset_pollfunc() gets invoked to poll the interface for completion
148 * every 50ms during an atapi drive reset operation. If the drive has not yet
149 * responded, and we have not yet hit our maximum waiting time, then the timer
150 * is restarted for another 50ms.
151 */
152static ide_startstop_t atapi_reset_pollfunc(ide_drive_t *drive)
153{
154 ide_hwif_t *hwif = drive->hwif;
155 u8 stat;
156
157 SELECT_DRIVE(drive);
158 udelay(10);
159 stat = hwif->tp_ops->read_status(hwif);
160
161 if (OK_STAT(stat, 0, ATA_BUSY))
162 printk(KERN_INFO "%s: ATAPI reset complete\n", drive->name);
163 else {
164 if (time_before(jiffies, hwif->poll_timeout)) {
165 ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20,
166 NULL);
167 /* continue polling */
168 return ide_started;
169 }
170 /* end of polling */
171 hwif->polling = 0;
172 printk(KERN_ERR "%s: ATAPI reset timed-out, status=0x%02x\n",
173 drive->name, stat);
174 /* do it the old fashioned way */
175 return do_reset1(drive, 1);
176 }
177 /* done polling */
178 hwif->polling = 0;
179 ide_complete_drive_reset(drive, 0);
180 return ide_stopped;
181}
182
183static void ide_reset_report_error(ide_hwif_t *hwif, u8 err)
184{
185 static const char *err_master_vals[] =
186 { NULL, "passed", "formatter device error",
187 "sector buffer error", "ECC circuitry error",
188 "controlling MPU error" };
189
190 u8 err_master = err & 0x7f;
191
192 printk(KERN_ERR "%s: reset: master: ", hwif->name);
193 if (err_master && err_master < 6)
194 printk(KERN_CONT "%s", err_master_vals[err_master]);
195 else
196 printk(KERN_CONT "error (0x%02x?)", err);
197 if (err & 0x80)
198 printk(KERN_CONT "; slave: failed");
199 printk(KERN_CONT "\n");
200}
201
202/*
203 * reset_pollfunc() gets invoked to poll the interface for completion every 50ms
204 * during an ide reset operation. If the drives have not yet responded,
205 * and we have not yet hit our maximum waiting time, then the timer is restarted
206 * for another 50ms.
207 */
208static ide_startstop_t reset_pollfunc(ide_drive_t *drive)
209{
210 ide_hwif_t *hwif = drive->hwif;
211 const struct ide_port_ops *port_ops = hwif->port_ops;
212 u8 tmp;
213 int err = 0;
214
215 if (port_ops && port_ops->reset_poll) {
216 err = port_ops->reset_poll(drive);
217 if (err) {
218 printk(KERN_ERR "%s: host reset_poll failure for %s.\n",
219 hwif->name, drive->name);
220 goto out;
221 }
222 }
223
224 tmp = hwif->tp_ops->read_status(hwif);
225
226 if (!OK_STAT(tmp, 0, ATA_BUSY)) {
227 if (time_before(jiffies, hwif->poll_timeout)) {
228 ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
229 /* continue polling */
230 return ide_started;
231 }
232 printk(KERN_ERR "%s: reset timed-out, status=0x%02x\n",
233 hwif->name, tmp);
234 drive->failures++;
235 err = -EIO;
236 } else {
237 tmp = ide_read_error(drive);
238
239 if (tmp == 1) {
240 printk(KERN_INFO "%s: reset: success\n", hwif->name);
241 drive->failures = 0;
242 } else {
243 ide_reset_report_error(hwif, tmp);
244 drive->failures++;
245 err = -EIO;
246 }
247 }
248out:
249 hwif->polling = 0; /* done polling */
250 ide_complete_drive_reset(drive, err);
251 return ide_stopped;
252}
253
254static void ide_disk_pre_reset(ide_drive_t *drive)
255{
256 int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1;
257
258 drive->special.all = 0;
259 drive->special.b.set_geometry = legacy;
260 drive->special.b.recalibrate = legacy;
261
262 drive->mult_count = 0;
263 drive->dev_flags &= ~IDE_DFLAG_PARKED;
264
265 if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0 &&
266 (drive->dev_flags & IDE_DFLAG_USING_DMA) == 0)
267 drive->mult_req = 0;
268
269 if (drive->mult_req != drive->mult_count)
270 drive->special.b.set_multmode = 1;
271}
272
273static void pre_reset(ide_drive_t *drive)
274{
275 const struct ide_port_ops *port_ops = drive->hwif->port_ops;
276
277 if (drive->media == ide_disk)
278 ide_disk_pre_reset(drive);
279 else
280 drive->dev_flags |= IDE_DFLAG_POST_RESET;
281
282 if (drive->dev_flags & IDE_DFLAG_USING_DMA) {
283 if (drive->crc_count)
284 ide_check_dma_crc(drive);
285 else
286 ide_dma_off(drive);
287 }
288
289 if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0) {
290 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) {
291 drive->dev_flags &= ~IDE_DFLAG_UNMASK;
292 drive->io_32bit = 0;
293 }
294 return;
295 }
296
297 if (port_ops && port_ops->pre_reset)
298 port_ops->pre_reset(drive);
299
300 if (drive->current_speed != 0xff)
301 drive->desired_speed = drive->current_speed;
302 drive->current_speed = 0xff;
303}
304
305/*
306 * do_reset1() attempts to recover a confused drive by resetting it.
307 * Unfortunately, resetting a disk drive actually resets all devices on
308 * the same interface, so it can really be thought of as resetting the
309 * interface rather than resetting the drive.
310 *
311 * ATAPI devices have their own reset mechanism which allows them to be
312 * individually reset without clobbering other devices on the same interface.
313 *
314 * Unfortunately, the IDE interface does not generate an interrupt to let
315 * us know when the reset operation has finished, so we must poll for this.
316 * Equally poor, though, is the fact that this may a very long time to complete,
317 * (up to 30 seconds worstcase). So, instead of busy-waiting here for it,
318 * we set a timer to poll at 50ms intervals.
319 */
320static ide_startstop_t do_reset1(ide_drive_t *drive, int do_not_try_atapi)
321{
322 ide_hwif_t *hwif = drive->hwif;
323 struct ide_io_ports *io_ports = &hwif->io_ports;
324 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
325 const struct ide_port_ops *port_ops;
326 ide_drive_t *tdrive;
327 unsigned long flags, timeout;
328 int i;
329 DEFINE_WAIT(wait);
330
331 spin_lock_irqsave(&hwif->lock, flags);
332
333 /* We must not reset with running handlers */
334 BUG_ON(hwif->handler != NULL);
335
336 /* For an ATAPI device, first try an ATAPI SRST. */
337 if (drive->media != ide_disk && !do_not_try_atapi) {
338 pre_reset(drive);
339 SELECT_DRIVE(drive);
340 udelay(20);
341 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
342 ndelay(400);
343 hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
344 hwif->polling = 1;
345 __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
346 spin_unlock_irqrestore(&hwif->lock, flags);
347 return ide_started;
348 }
349
350 /* We must not disturb devices in the IDE_DFLAG_PARKED state. */
351 do {
352 unsigned long now;
353
354 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
355 timeout = jiffies;
356 ide_port_for_each_present_dev(i, tdrive, hwif) {
357 if ((tdrive->dev_flags & IDE_DFLAG_PARKED) &&
358 time_after(tdrive->sleep, timeout))
359 timeout = tdrive->sleep;
360 }
361
362 now = jiffies;
363 if (time_before_eq(timeout, now))
364 break;
365
366 spin_unlock_irqrestore(&hwif->lock, flags);
367 timeout = schedule_timeout_uninterruptible(timeout - now);
368 spin_lock_irqsave(&hwif->lock, flags);
369 } while (timeout);
370 finish_wait(&ide_park_wq, &wait);
371
372 /*
373 * First, reset any device state data we were maintaining
374 * for any of the drives on this interface.
375 */
376 ide_port_for_each_dev(i, tdrive, hwif)
377 pre_reset(tdrive);
378
379 if (io_ports->ctl_addr == 0) {
380 spin_unlock_irqrestore(&hwif->lock, flags);
381 ide_complete_drive_reset(drive, -ENXIO);
382 return ide_stopped;
383 }
384
385 /*
386 * Note that we also set nIEN while resetting the device,
387 * to mask unwanted interrupts from the interface during the reset.
388 * However, due to the design of PC hardware, this will cause an
389 * immediate interrupt due to the edge transition it produces.
390 * This single interrupt gives us a "fast poll" for drives that
391 * recover from reset very quickly, saving us the first 50ms wait time.
392 *
393 * TODO: add ->softreset method and stop abusing ->set_irq
394 */
395 /* set SRST and nIEN */
396 tp_ops->set_irq(hwif, 4);
397 /* more than enough time */
398 udelay(10);
399 /* clear SRST, leave nIEN (unless device is on the quirk list) */
400 tp_ops->set_irq(hwif, drive->quirk_list == 2);
401 /* more than enough time */
402 udelay(10);
403 hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
404 hwif->polling = 1;
405 __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
406
407 /*
408 * Some weird controller like resetting themselves to a strange
409 * state when the disks are reset this way. At least, the Winbond
410 * 553 documentation says that
411 */
412 port_ops = hwif->port_ops;
413 if (port_ops && port_ops->resetproc)
414 port_ops->resetproc(drive);
415
416 spin_unlock_irqrestore(&hwif->lock, flags);
417 return ide_started;
418}
419
420/*
421 * ide_do_reset() is the entry point to the drive/interface reset code.
422 */
423
424ide_startstop_t ide_do_reset(ide_drive_t *drive)
425{
426 return do_reset1(drive, 0);
427}
428EXPORT_SYMBOL(ide_do_reset);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 3eab1c6c9b31..317ec62c33d4 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -327,8 +327,10 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
327 return ide_stopped; 327 return ide_stopped;
328 } 328 }
329 329
330 ide_init_sg_cmd(drive, rq); 330 if (blk_fs_request(rq) || pc->req_xfer) {
331 ide_map_sg(drive, rq); 331 ide_init_sg_cmd(drive, rq);
332 ide_map_sg(drive, rq);
333 }
332 334
333 pc->sg = hwif->sg_table; 335 pc->sg = hwif->sg_table;
334 pc->sg_cnt = hwif->sg_nents; 336 pc->sg_cnt = hwif->sg_nents;
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c
index 3ec762cb60ab..fcd4d8153df5 100644
--- a/drivers/ide/ide-floppy_proc.c
+++ b/drivers/ide/ide-floppy_proc.c
@@ -29,5 +29,5 @@ const struct ide_proc_devset ide_floppy_settings[] = {
29 IDE_PROC_DEVSET(bios_head, 0, 255), 29 IDE_PROC_DEVSET(bios_head, 0, 255),
30 IDE_PROC_DEVSET(bios_sect, 0, 63), 30 IDE_PROC_DEVSET(bios_sect, 0, 63),
31 IDE_PROC_DEVSET(ticks, 0, 255), 31 IDE_PROC_DEVSET(ticks, 0, 255),
32 { 0 }, 32 { NULL },
33}; 33};
diff --git a/drivers/ide/ide-io-std.c b/drivers/ide/ide-io-std.c
new file mode 100644
index 000000000000..45b43dd49cda
--- /dev/null
+++ b/drivers/ide/ide-io-std.c
@@ -0,0 +1,316 @@
1
2#include <linux/kernel.h>
3#include <linux/ide.h>
4
5/*
6 * Conventional PIO operations for ATA devices
7 */
8
9static u8 ide_inb(unsigned long port)
10{
11 return (u8) inb(port);
12}
13
14static void ide_outb(u8 val, unsigned long port)
15{
16 outb(val, port);
17}
18
19/*
20 * MMIO operations, typically used for SATA controllers
21 */
22
23static u8 ide_mm_inb(unsigned long port)
24{
25 return (u8) readb((void __iomem *) port);
26}
27
28static void ide_mm_outb(u8 value, unsigned long port)
29{
30 writeb(value, (void __iomem *) port);
31}
32
33void ide_exec_command(ide_hwif_t *hwif, u8 cmd)
34{
35 if (hwif->host_flags & IDE_HFLAG_MMIO)
36 writeb(cmd, (void __iomem *)hwif->io_ports.command_addr);
37 else
38 outb(cmd, hwif->io_ports.command_addr);
39}
40EXPORT_SYMBOL_GPL(ide_exec_command);
41
42u8 ide_read_status(ide_hwif_t *hwif)
43{
44 if (hwif->host_flags & IDE_HFLAG_MMIO)
45 return readb((void __iomem *)hwif->io_ports.status_addr);
46 else
47 return inb(hwif->io_ports.status_addr);
48}
49EXPORT_SYMBOL_GPL(ide_read_status);
50
51u8 ide_read_altstatus(ide_hwif_t *hwif)
52{
53 if (hwif->host_flags & IDE_HFLAG_MMIO)
54 return readb((void __iomem *)hwif->io_ports.ctl_addr);
55 else
56 return inb(hwif->io_ports.ctl_addr);
57}
58EXPORT_SYMBOL_GPL(ide_read_altstatus);
59
60void ide_set_irq(ide_hwif_t *hwif, int on)
61{
62 u8 ctl = ATA_DEVCTL_OBS;
63
64 if (on == 4) { /* hack for SRST */
65 ctl |= 4;
66 on &= ~4;
67 }
68
69 ctl |= on ? 0 : 2;
70
71 if (hwif->host_flags & IDE_HFLAG_MMIO)
72 writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr);
73 else
74 outb(ctl, hwif->io_ports.ctl_addr);
75}
76EXPORT_SYMBOL_GPL(ide_set_irq);
77
78void ide_tf_load(ide_drive_t *drive, ide_task_t *task)
79{
80 ide_hwif_t *hwif = drive->hwif;
81 struct ide_io_ports *io_ports = &hwif->io_ports;
82 struct ide_taskfile *tf = &task->tf;
83 void (*tf_outb)(u8 addr, unsigned long port);
84 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
85 u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF;
86
87 if (mmio)
88 tf_outb = ide_mm_outb;
89 else
90 tf_outb = ide_outb;
91
92 if (task->tf_flags & IDE_TFLAG_FLAGGED)
93 HIHI = 0xFF;
94
95 if (task->tf_flags & IDE_TFLAG_OUT_DATA) {
96 u16 data = (tf->hob_data << 8) | tf->data;
97
98 if (mmio)
99 writew(data, (void __iomem *)io_ports->data_addr);
100 else
101 outw(data, io_ports->data_addr);
102 }
103
104 if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
105 tf_outb(tf->hob_feature, io_ports->feature_addr);
106 if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
107 tf_outb(tf->hob_nsect, io_ports->nsect_addr);
108 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
109 tf_outb(tf->hob_lbal, io_ports->lbal_addr);
110 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
111 tf_outb(tf->hob_lbam, io_ports->lbam_addr);
112 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
113 tf_outb(tf->hob_lbah, io_ports->lbah_addr);
114
115 if (task->tf_flags & IDE_TFLAG_OUT_FEATURE)
116 tf_outb(tf->feature, io_ports->feature_addr);
117 if (task->tf_flags & IDE_TFLAG_OUT_NSECT)
118 tf_outb(tf->nsect, io_ports->nsect_addr);
119 if (task->tf_flags & IDE_TFLAG_OUT_LBAL)
120 tf_outb(tf->lbal, io_ports->lbal_addr);
121 if (task->tf_flags & IDE_TFLAG_OUT_LBAM)
122 tf_outb(tf->lbam, io_ports->lbam_addr);
123 if (task->tf_flags & IDE_TFLAG_OUT_LBAH)
124 tf_outb(tf->lbah, io_ports->lbah_addr);
125
126 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE)
127 tf_outb((tf->device & HIHI) | drive->select,
128 io_ports->device_addr);
129}
130EXPORT_SYMBOL_GPL(ide_tf_load);
131
132void ide_tf_read(ide_drive_t *drive, ide_task_t *task)
133{
134 ide_hwif_t *hwif = drive->hwif;
135 struct ide_io_ports *io_ports = &hwif->io_ports;
136 struct ide_taskfile *tf = &task->tf;
137 void (*tf_outb)(u8 addr, unsigned long port);
138 u8 (*tf_inb)(unsigned long port);
139 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
140
141 if (mmio) {
142 tf_outb = ide_mm_outb;
143 tf_inb = ide_mm_inb;
144 } else {
145 tf_outb = ide_outb;
146 tf_inb = ide_inb;
147 }
148
149 if (task->tf_flags & IDE_TFLAG_IN_DATA) {
150 u16 data;
151
152 if (mmio)
153 data = readw((void __iomem *)io_ports->data_addr);
154 else
155 data = inw(io_ports->data_addr);
156
157 tf->data = data & 0xff;
158 tf->hob_data = (data >> 8) & 0xff;
159 }
160
161 /* be sure we're looking at the low order bits */
162 tf_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
163
164 if (task->tf_flags & IDE_TFLAG_IN_FEATURE)
165 tf->feature = tf_inb(io_ports->feature_addr);
166 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
167 tf->nsect = tf_inb(io_ports->nsect_addr);
168 if (task->tf_flags & IDE_TFLAG_IN_LBAL)
169 tf->lbal = tf_inb(io_ports->lbal_addr);
170 if (task->tf_flags & IDE_TFLAG_IN_LBAM)
171 tf->lbam = tf_inb(io_ports->lbam_addr);
172 if (task->tf_flags & IDE_TFLAG_IN_LBAH)
173 tf->lbah = tf_inb(io_ports->lbah_addr);
174 if (task->tf_flags & IDE_TFLAG_IN_DEVICE)
175 tf->device = tf_inb(io_ports->device_addr);
176
177 if (task->tf_flags & IDE_TFLAG_LBA48) {
178 tf_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
179
180 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
181 tf->hob_feature = tf_inb(io_ports->feature_addr);
182 if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
183 tf->hob_nsect = tf_inb(io_ports->nsect_addr);
184 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
185 tf->hob_lbal = tf_inb(io_ports->lbal_addr);
186 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
187 tf->hob_lbam = tf_inb(io_ports->lbam_addr);
188 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
189 tf->hob_lbah = tf_inb(io_ports->lbah_addr);
190 }
191}
192EXPORT_SYMBOL_GPL(ide_tf_read);
193
194/*
195 * Some localbus EIDE interfaces require a special access sequence
196 * when using 32-bit I/O instructions to transfer data. We call this
197 * the "vlb_sync" sequence, which consists of three successive reads
198 * of the sector count register location, with interrupts disabled
199 * to ensure that the reads all happen together.
200 */
201static void ata_vlb_sync(unsigned long port)
202{
203 (void)inb(port);
204 (void)inb(port);
205 (void)inb(port);
206}
207
208/*
209 * This is used for most PIO data transfers *from* the IDE interface
210 *
211 * These routines will round up any request for an odd number of bytes,
212 * so if an odd len is specified, be sure that there's at least one
213 * extra byte allocated for the buffer.
214 */
215void ide_input_data(ide_drive_t *drive, struct request *rq, void *buf,
216 unsigned int len)
217{
218 ide_hwif_t *hwif = drive->hwif;
219 struct ide_io_ports *io_ports = &hwif->io_ports;
220 unsigned long data_addr = io_ports->data_addr;
221 u8 io_32bit = drive->io_32bit;
222 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
223
224 len++;
225
226 if (io_32bit) {
227 unsigned long uninitialized_var(flags);
228
229 if ((io_32bit & 2) && !mmio) {
230 local_irq_save(flags);
231 ata_vlb_sync(io_ports->nsect_addr);
232 }
233
234 if (mmio)
235 __ide_mm_insl((void __iomem *)data_addr, buf, len / 4);
236 else
237 insl(data_addr, buf, len / 4);
238
239 if ((io_32bit & 2) && !mmio)
240 local_irq_restore(flags);
241
242 if ((len & 3) >= 2) {
243 if (mmio)
244 __ide_mm_insw((void __iomem *)data_addr,
245 (u8 *)buf + (len & ~3), 1);
246 else
247 insw(data_addr, (u8 *)buf + (len & ~3), 1);
248 }
249 } else {
250 if (mmio)
251 __ide_mm_insw((void __iomem *)data_addr, buf, len / 2);
252 else
253 insw(data_addr, buf, len / 2);
254 }
255}
256EXPORT_SYMBOL_GPL(ide_input_data);
257
258/*
259 * This is used for most PIO data transfers *to* the IDE interface
260 */
261void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf,
262 unsigned int len)
263{
264 ide_hwif_t *hwif = drive->hwif;
265 struct ide_io_ports *io_ports = &hwif->io_ports;
266 unsigned long data_addr = io_ports->data_addr;
267 u8 io_32bit = drive->io_32bit;
268 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
269
270 len++;
271
272 if (io_32bit) {
273 unsigned long uninitialized_var(flags);
274
275 if ((io_32bit & 2) && !mmio) {
276 local_irq_save(flags);
277 ata_vlb_sync(io_ports->nsect_addr);
278 }
279
280 if (mmio)
281 __ide_mm_outsl((void __iomem *)data_addr, buf, len / 4);
282 else
283 outsl(data_addr, buf, len / 4);
284
285 if ((io_32bit & 2) && !mmio)
286 local_irq_restore(flags);
287
288 if ((len & 3) >= 2) {
289 if (mmio)
290 __ide_mm_outsw((void __iomem *)data_addr,
291 (u8 *)buf + (len & ~3), 1);
292 else
293 outsw(data_addr, (u8 *)buf + (len & ~3), 1);
294 }
295 } else {
296 if (mmio)
297 __ide_mm_outsw((void __iomem *)data_addr, buf, len / 2);
298 else
299 outsw(data_addr, buf, len / 2);
300 }
301}
302EXPORT_SYMBOL_GPL(ide_output_data);
303
304const struct ide_tp_ops default_tp_ops = {
305 .exec_command = ide_exec_command,
306 .read_status = ide_read_status,
307 .read_altstatus = ide_read_altstatus,
308
309 .set_irq = ide_set_irq,
310
311 .tf_load = ide_tf_load,
312 .tf_read = ide_tf_read,
313
314 .input_data = ide_input_data,
315 .output_data = ide_output_data,
316};
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 9ee51adf567f..2e92497b58aa 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -196,7 +196,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
196} 196}
197EXPORT_SYMBOL(ide_end_drive_cmd); 197EXPORT_SYMBOL(ide_end_drive_cmd);
198 198
199static void ide_kill_rq(ide_drive_t *drive, struct request *rq) 199void ide_kill_rq(ide_drive_t *drive, struct request *rq)
200{ 200{
201 if (rq->rq_disk) { 201 if (rq->rq_disk) {
202 struct ide_driver *drv; 202 struct ide_driver *drv;
@@ -207,133 +207,6 @@ static void ide_kill_rq(ide_drive_t *drive, struct request *rq)
207 ide_end_request(drive, 0, 0); 207 ide_end_request(drive, 0, 0);
208} 208}
209 209
210static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
211{
212 ide_hwif_t *hwif = drive->hwif;
213
214 if ((stat & ATA_BUSY) ||
215 ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
216 /* other bits are useless when BUSY */
217 rq->errors |= ERROR_RESET;
218 } else if (stat & ATA_ERR) {
219 /* err has different meaning on cdrom and tape */
220 if (err == ATA_ABORTED) {
221 if ((drive->dev_flags & IDE_DFLAG_LBA) &&
222 /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */
223 hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS)
224 return ide_stopped;
225 } else if ((err & BAD_CRC) == BAD_CRC) {
226 /* UDMA crc error, just retry the operation */
227 drive->crc_count++;
228 } else if (err & (ATA_BBK | ATA_UNC)) {
229 /* retries won't help these */
230 rq->errors = ERROR_MAX;
231 } else if (err & ATA_TRK0NF) {
232 /* help it find track zero */
233 rq->errors |= ERROR_RECAL;
234 }
235 }
236
237 if ((stat & ATA_DRQ) && rq_data_dir(rq) == READ &&
238 (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) {
239 int nsect = drive->mult_count ? drive->mult_count : 1;
240
241 ide_pad_transfer(drive, READ, nsect * SECTOR_SIZE);
242 }
243
244 if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) {
245 ide_kill_rq(drive, rq);
246 return ide_stopped;
247 }
248
249 if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ))
250 rq->errors |= ERROR_RESET;
251
252 if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
253 ++rq->errors;
254 return ide_do_reset(drive);
255 }
256
257 if ((rq->errors & ERROR_RECAL) == ERROR_RECAL)
258 drive->special.b.recalibrate = 1;
259
260 ++rq->errors;
261
262 return ide_stopped;
263}
264
265static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
266{
267 ide_hwif_t *hwif = drive->hwif;
268
269 if ((stat & ATA_BUSY) ||
270 ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
271 /* other bits are useless when BUSY */
272 rq->errors |= ERROR_RESET;
273 } else {
274 /* add decoding error stuff */
275 }
276
277 if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ))
278 /* force an abort */
279 hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE);
280
281 if (rq->errors >= ERROR_MAX) {
282 ide_kill_rq(drive, rq);
283 } else {
284 if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
285 ++rq->errors;
286 return ide_do_reset(drive);
287 }
288 ++rq->errors;
289 }
290
291 return ide_stopped;
292}
293
294static ide_startstop_t
295__ide_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
296{
297 if (drive->media == ide_disk)
298 return ide_ata_error(drive, rq, stat, err);
299 return ide_atapi_error(drive, rq, stat, err);
300}
301
302/**
303 * ide_error - handle an error on the IDE
304 * @drive: drive the error occurred on
305 * @msg: message to report
306 * @stat: status bits
307 *
308 * ide_error() takes action based on the error returned by the drive.
309 * For normal I/O that may well include retries. We deal with
310 * both new-style (taskfile) and old style command handling here.
311 * In the case of taskfile command handling there is work left to
312 * do
313 */
314
315ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat)
316{
317 struct request *rq;
318 u8 err;
319
320 err = ide_dump_status(drive, msg, stat);
321
322 rq = drive->hwif->rq;
323 if (rq == NULL)
324 return ide_stopped;
325
326 /* retry only "normal" I/O: */
327 if (!blk_fs_request(rq)) {
328 rq->errors = 1;
329 ide_end_drive_cmd(drive, stat, err);
330 return ide_stopped;
331 }
332
333 return __ide_error(drive, rq, stat, err);
334}
335EXPORT_SYMBOL_GPL(ide_error);
336
337static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) 210static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
338{ 211{
339 tf->nsect = drive->sect; 212 tf->nsect = drive->sect;
@@ -490,71 +363,16 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
490 return ide_stopped; 363 return ide_stopped;
491} 364}
492 365
493int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
494 int arg)
495{
496 struct request_queue *q = drive->queue;
497 struct request *rq;
498 int ret = 0;
499
500 if (!(setting->flags & DS_SYNC))
501 return setting->set(drive, arg);
502
503 rq = blk_get_request(q, READ, __GFP_WAIT);
504 rq->cmd_type = REQ_TYPE_SPECIAL;
505 rq->cmd_len = 5;
506 rq->cmd[0] = REQ_DEVSET_EXEC;
507 *(int *)&rq->cmd[1] = arg;
508 rq->special = setting->set;
509
510 if (blk_execute_rq(q, NULL, rq, 0))
511 ret = rq->errors;
512 blk_put_request(rq);
513
514 return ret;
515}
516EXPORT_SYMBOL_GPL(ide_devset_execute);
517
518static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) 366static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq)
519{ 367{
520 u8 cmd = rq->cmd[0]; 368 u8 cmd = rq->cmd[0];
521 369
522 if (cmd == REQ_PARK_HEADS || cmd == REQ_UNPARK_HEADS) {
523 ide_task_t task;
524 struct ide_taskfile *tf = &task.tf;
525
526 memset(&task, 0, sizeof(task));
527 if (cmd == REQ_PARK_HEADS) {
528 drive->sleep = *(unsigned long *)rq->special;
529 drive->dev_flags |= IDE_DFLAG_SLEEPING;
530 tf->command = ATA_CMD_IDLEIMMEDIATE;
531 tf->feature = 0x44;
532 tf->lbal = 0x4c;
533 tf->lbam = 0x4e;
534 tf->lbah = 0x55;
535 task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER;
536 } else /* cmd == REQ_UNPARK_HEADS */
537 tf->command = ATA_CMD_CHK_POWER;
538
539 task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
540 task.rq = rq;
541 drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA;
542 return do_rw_taskfile(drive, &task);
543 }
544
545 switch (cmd) { 370 switch (cmd) {
371 case REQ_PARK_HEADS:
372 case REQ_UNPARK_HEADS:
373 return ide_do_park_unpark(drive, rq);
546 case REQ_DEVSET_EXEC: 374 case REQ_DEVSET_EXEC:
547 { 375 return ide_do_devset(drive, rq);
548 int err, (*setfunc)(ide_drive_t *, int) = rq->special;
549
550 err = setfunc(drive, *(int *)&rq->cmd[1]);
551 if (err)
552 rq->errors = err;
553 else
554 err = 1;
555 ide_end_request(drive, err, 0);
556 return ide_stopped;
557 }
558 case REQ_DRIVE_RESET: 376 case REQ_DRIVE_RESET:
559 return ide_do_reset(drive); 377 return ide_do_reset(drive);
560 default: 378 default:
@@ -820,63 +638,6 @@ plug_device_2:
820 blk_plug_device(q); 638 blk_plug_device(q);
821} 639}
822 640
823/*
824 * un-busy the port etc, and clear any pending DMA status. we want to
825 * retry the current request in pio mode instead of risking tossing it
826 * all away
827 */
828static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
829{
830 ide_hwif_t *hwif = drive->hwif;
831 struct request *rq;
832 ide_startstop_t ret = ide_stopped;
833
834 /*
835 * end current dma transaction
836 */
837
838 if (error < 0) {
839 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
840 (void)hwif->dma_ops->dma_end(drive);
841 ret = ide_error(drive, "dma timeout error",
842 hwif->tp_ops->read_status(hwif));
843 } else {
844 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name);
845 hwif->dma_ops->dma_timeout(drive);
846 }
847
848 /*
849 * disable dma for now, but remember that we did so because of
850 * a timeout -- we'll reenable after we finish this next request
851 * (or rather the first chunk of it) in pio.
852 */
853 drive->dev_flags |= IDE_DFLAG_DMA_PIO_RETRY;
854 drive->retry_pio++;
855 ide_dma_off_quietly(drive);
856
857 /*
858 * un-busy drive etc and make sure request is sane
859 */
860
861 rq = hwif->rq;
862 if (!rq)
863 goto out;
864
865 hwif->rq = NULL;
866
867 rq->errors = 0;
868
869 if (!rq->bio)
870 goto out;
871
872 rq->sector = rq->bio->bi_sector;
873 rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9;
874 rq->hard_cur_sectors = rq->current_nr_sectors;
875 rq->buffer = bio_data(rq->bio);
876out:
877 return ret;
878}
879
880static void ide_plug_device(ide_drive_t *drive) 641static void ide_plug_device(ide_drive_t *drive)
881{ 642{
882 struct request_queue *q = drive->queue; 643 struct request_queue *q = drive->queue;
@@ -888,6 +649,29 @@ static void ide_plug_device(ide_drive_t *drive)
888 spin_unlock_irqrestore(q->queue_lock, flags); 649 spin_unlock_irqrestore(q->queue_lock, flags);
889} 650}
890 651
652static int drive_is_ready(ide_drive_t *drive)
653{
654 ide_hwif_t *hwif = drive->hwif;
655 u8 stat = 0;
656
657 if (drive->waiting_for_dma)
658 return hwif->dma_ops->dma_test_irq(drive);
659
660 if (hwif->io_ports.ctl_addr &&
661 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0)
662 stat = hwif->tp_ops->read_altstatus(hwif);
663 else
664 /* Note: this may clear a pending IRQ!! */
665 stat = hwif->tp_ops->read_status(hwif);
666
667 if (stat & ATA_BUSY)
668 /* drive busy: definitely not interrupting */
669 return 0;
670
671 /* drive ready: *might* be interrupting */
672 return 1;
673}
674
891/** 675/**
892 * ide_timer_expiry - handle lack of an IDE interrupt 676 * ide_timer_expiry - handle lack of an IDE interrupt
893 * @data: timer callback magic (hwif) 677 * @data: timer callback magic (hwif)
@@ -908,7 +692,7 @@ void ide_timer_expiry (unsigned long data)
908 ide_drive_t *uninitialized_var(drive); 692 ide_drive_t *uninitialized_var(drive);
909 ide_handler_t *handler; 693 ide_handler_t *handler;
910 unsigned long flags; 694 unsigned long flags;
911 unsigned long wait = -1; 695 int wait = -1;
912 int plug_device = 0; 696 int plug_device = 0;
913 697
914 spin_lock_irqsave(&hwif->lock, flags); 698 spin_lock_irqsave(&hwif->lock, flags);
@@ -1162,54 +946,7 @@ out_early:
1162 946
1163 return irq_ret; 947 return irq_ret;
1164} 948}
1165 949EXPORT_SYMBOL_GPL(ide_intr);
1166/**
1167 * ide_do_drive_cmd - issue IDE special command
1168 * @drive: device to issue command
1169 * @rq: request to issue
1170 *
1171 * This function issues a special IDE device request
1172 * onto the request queue.
1173 *
1174 * the rq is queued at the head of the request queue, displacing
1175 * the currently-being-processed request and this function
1176 * returns immediately without waiting for the new rq to be
1177 * completed. This is VERY DANGEROUS, and is intended for
1178 * careful use by the ATAPI tape/cdrom driver code.
1179 */
1180
1181void ide_do_drive_cmd(ide_drive_t *drive, struct request *rq)
1182{
1183 struct request_queue *q = drive->queue;
1184 unsigned long flags;
1185
1186 drive->hwif->rq = NULL;
1187
1188 spin_lock_irqsave(q->queue_lock, flags);
1189 __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0);
1190 spin_unlock_irqrestore(q->queue_lock, flags);
1191}
1192EXPORT_SYMBOL(ide_do_drive_cmd);
1193
1194void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma)
1195{
1196 ide_hwif_t *hwif = drive->hwif;
1197 ide_task_t task;
1198
1199 memset(&task, 0, sizeof(task));
1200 task.tf_flags = IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM |
1201 IDE_TFLAG_OUT_FEATURE | tf_flags;
1202 task.tf.feature = dma; /* Use PIO/DMA */
1203 task.tf.lbam = bcount & 0xff;
1204 task.tf.lbah = (bcount >> 8) & 0xff;
1205
1206 ide_tf_dump(drive->name, &task.tf);
1207 hwif->tp_ops->set_irq(hwif, 1);
1208 SELECT_MASK(drive, 0);
1209 hwif->tp_ops->tf_load(drive, &task);
1210}
1211
1212EXPORT_SYMBOL_GPL(ide_pktcmd_tf_load);
1213 950
1214void ide_pad_transfer(ide_drive_t *drive, int write, int len) 951void ide_pad_transfer(ide_drive_t *drive, int write, int len)
1215{ 952{
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 753b92ebe0ae..317c5dadd7c0 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -27,35 +27,7 @@
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <asm/io.h> 28#include <asm/io.h>
29 29
30/* 30void SELECT_DRIVE(ide_drive_t *drive)
31 * Conventional PIO operations for ATA devices
32 */
33
34static u8 ide_inb (unsigned long port)
35{
36 return (u8) inb(port);
37}
38
39static void ide_outb (u8 val, unsigned long port)
40{
41 outb(val, port);
42}
43
44/*
45 * MMIO operations, typically used for SATA controllers
46 */
47
48static u8 ide_mm_inb (unsigned long port)
49{
50 return (u8) readb((void __iomem *) port);
51}
52
53static void ide_mm_outb (u8 value, unsigned long port)
54{
55 writeb(value, (void __iomem *) port);
56}
57
58void SELECT_DRIVE (ide_drive_t *drive)
59{ 31{
60 ide_hwif_t *hwif = drive->hwif; 32 ide_hwif_t *hwif = drive->hwif;
61 const struct ide_port_ops *port_ops = hwif->port_ops; 33 const struct ide_port_ops *port_ops = hwif->port_ops;
@@ -78,275 +50,6 @@ void SELECT_MASK(ide_drive_t *drive, int mask)
78 port_ops->maskproc(drive, mask); 50 port_ops->maskproc(drive, mask);
79} 51}
80 52
81void ide_exec_command(ide_hwif_t *hwif, u8 cmd)
82{
83 if (hwif->host_flags & IDE_HFLAG_MMIO)
84 writeb(cmd, (void __iomem *)hwif->io_ports.command_addr);
85 else
86 outb(cmd, hwif->io_ports.command_addr);
87}
88EXPORT_SYMBOL_GPL(ide_exec_command);
89
90u8 ide_read_status(ide_hwif_t *hwif)
91{
92 if (hwif->host_flags & IDE_HFLAG_MMIO)
93 return readb((void __iomem *)hwif->io_ports.status_addr);
94 else
95 return inb(hwif->io_ports.status_addr);
96}
97EXPORT_SYMBOL_GPL(ide_read_status);
98
99u8 ide_read_altstatus(ide_hwif_t *hwif)
100{
101 if (hwif->host_flags & IDE_HFLAG_MMIO)
102 return readb((void __iomem *)hwif->io_ports.ctl_addr);
103 else
104 return inb(hwif->io_ports.ctl_addr);
105}
106EXPORT_SYMBOL_GPL(ide_read_altstatus);
107
108void ide_set_irq(ide_hwif_t *hwif, int on)
109{
110 u8 ctl = ATA_DEVCTL_OBS;
111
112 if (on == 4) { /* hack for SRST */
113 ctl |= 4;
114 on &= ~4;
115 }
116
117 ctl |= on ? 0 : 2;
118
119 if (hwif->host_flags & IDE_HFLAG_MMIO)
120 writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr);
121 else
122 outb(ctl, hwif->io_ports.ctl_addr);
123}
124EXPORT_SYMBOL_GPL(ide_set_irq);
125
126void ide_tf_load(ide_drive_t *drive, ide_task_t *task)
127{
128 ide_hwif_t *hwif = drive->hwif;
129 struct ide_io_ports *io_ports = &hwif->io_ports;
130 struct ide_taskfile *tf = &task->tf;
131 void (*tf_outb)(u8 addr, unsigned long port);
132 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
133 u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF;
134
135 if (mmio)
136 tf_outb = ide_mm_outb;
137 else
138 tf_outb = ide_outb;
139
140 if (task->tf_flags & IDE_TFLAG_FLAGGED)
141 HIHI = 0xFF;
142
143 if (task->tf_flags & IDE_TFLAG_OUT_DATA) {
144 u16 data = (tf->hob_data << 8) | tf->data;
145
146 if (mmio)
147 writew(data, (void __iomem *)io_ports->data_addr);
148 else
149 outw(data, io_ports->data_addr);
150 }
151
152 if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
153 tf_outb(tf->hob_feature, io_ports->feature_addr);
154 if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
155 tf_outb(tf->hob_nsect, io_ports->nsect_addr);
156 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
157 tf_outb(tf->hob_lbal, io_ports->lbal_addr);
158 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
159 tf_outb(tf->hob_lbam, io_ports->lbam_addr);
160 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
161 tf_outb(tf->hob_lbah, io_ports->lbah_addr);
162
163 if (task->tf_flags & IDE_TFLAG_OUT_FEATURE)
164 tf_outb(tf->feature, io_ports->feature_addr);
165 if (task->tf_flags & IDE_TFLAG_OUT_NSECT)
166 tf_outb(tf->nsect, io_ports->nsect_addr);
167 if (task->tf_flags & IDE_TFLAG_OUT_LBAL)
168 tf_outb(tf->lbal, io_ports->lbal_addr);
169 if (task->tf_flags & IDE_TFLAG_OUT_LBAM)
170 tf_outb(tf->lbam, io_ports->lbam_addr);
171 if (task->tf_flags & IDE_TFLAG_OUT_LBAH)
172 tf_outb(tf->lbah, io_ports->lbah_addr);
173
174 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE)
175 tf_outb((tf->device & HIHI) | drive->select,
176 io_ports->device_addr);
177}
178EXPORT_SYMBOL_GPL(ide_tf_load);
179
180void ide_tf_read(ide_drive_t *drive, ide_task_t *task)
181{
182 ide_hwif_t *hwif = drive->hwif;
183 struct ide_io_ports *io_ports = &hwif->io_ports;
184 struct ide_taskfile *tf = &task->tf;
185 void (*tf_outb)(u8 addr, unsigned long port);
186 u8 (*tf_inb)(unsigned long port);
187 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
188
189 if (mmio) {
190 tf_outb = ide_mm_outb;
191 tf_inb = ide_mm_inb;
192 } else {
193 tf_outb = ide_outb;
194 tf_inb = ide_inb;
195 }
196
197 if (task->tf_flags & IDE_TFLAG_IN_DATA) {
198 u16 data;
199
200 if (mmio)
201 data = readw((void __iomem *)io_ports->data_addr);
202 else
203 data = inw(io_ports->data_addr);
204
205 tf->data = data & 0xff;
206 tf->hob_data = (data >> 8) & 0xff;
207 }
208
209 /* be sure we're looking at the low order bits */
210 tf_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
211
212 if (task->tf_flags & IDE_TFLAG_IN_FEATURE)
213 tf->feature = tf_inb(io_ports->feature_addr);
214 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
215 tf->nsect = tf_inb(io_ports->nsect_addr);
216 if (task->tf_flags & IDE_TFLAG_IN_LBAL)
217 tf->lbal = tf_inb(io_ports->lbal_addr);
218 if (task->tf_flags & IDE_TFLAG_IN_LBAM)
219 tf->lbam = tf_inb(io_ports->lbam_addr);
220 if (task->tf_flags & IDE_TFLAG_IN_LBAH)
221 tf->lbah = tf_inb(io_ports->lbah_addr);
222 if (task->tf_flags & IDE_TFLAG_IN_DEVICE)
223 tf->device = tf_inb(io_ports->device_addr);
224
225 if (task->tf_flags & IDE_TFLAG_LBA48) {
226 tf_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
227
228 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
229 tf->hob_feature = tf_inb(io_ports->feature_addr);
230 if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
231 tf->hob_nsect = tf_inb(io_ports->nsect_addr);
232 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
233 tf->hob_lbal = tf_inb(io_ports->lbal_addr);
234 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
235 tf->hob_lbam = tf_inb(io_ports->lbam_addr);
236 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
237 tf->hob_lbah = tf_inb(io_ports->lbah_addr);
238 }
239}
240EXPORT_SYMBOL_GPL(ide_tf_read);
241
242/*
243 * Some localbus EIDE interfaces require a special access sequence
244 * when using 32-bit I/O instructions to transfer data. We call this
245 * the "vlb_sync" sequence, which consists of three successive reads
246 * of the sector count register location, with interrupts disabled
247 * to ensure that the reads all happen together.
248 */
249static void ata_vlb_sync(unsigned long port)
250{
251 (void)inb(port);
252 (void)inb(port);
253 (void)inb(port);
254}
255
256/*
257 * This is used for most PIO data transfers *from* the IDE interface
258 *
259 * These routines will round up any request for an odd number of bytes,
260 * so if an odd len is specified, be sure that there's at least one
261 * extra byte allocated for the buffer.
262 */
263void ide_input_data(ide_drive_t *drive, struct request *rq, void *buf,
264 unsigned int len)
265{
266 ide_hwif_t *hwif = drive->hwif;
267 struct ide_io_ports *io_ports = &hwif->io_ports;
268 unsigned long data_addr = io_ports->data_addr;
269 u8 io_32bit = drive->io_32bit;
270 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
271
272 len++;
273
274 if (io_32bit) {
275 unsigned long uninitialized_var(flags);
276
277 if ((io_32bit & 2) && !mmio) {
278 local_irq_save(flags);
279 ata_vlb_sync(io_ports->nsect_addr);
280 }
281
282 if (mmio)
283 __ide_mm_insl((void __iomem *)data_addr, buf, len / 4);
284 else
285 insl(data_addr, buf, len / 4);
286
287 if ((io_32bit & 2) && !mmio)
288 local_irq_restore(flags);
289
290 if ((len & 3) >= 2) {
291 if (mmio)
292 __ide_mm_insw((void __iomem *)data_addr,
293 (u8 *)buf + (len & ~3), 1);
294 else
295 insw(data_addr, (u8 *)buf + (len & ~3), 1);
296 }
297 } else {
298 if (mmio)
299 __ide_mm_insw((void __iomem *)data_addr, buf, len / 2);
300 else
301 insw(data_addr, buf, len / 2);
302 }
303}
304EXPORT_SYMBOL_GPL(ide_input_data);
305
306/*
307 * This is used for most PIO data transfers *to* the IDE interface
308 */
309void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf,
310 unsigned int len)
311{
312 ide_hwif_t *hwif = drive->hwif;
313 struct ide_io_ports *io_ports = &hwif->io_ports;
314 unsigned long data_addr = io_ports->data_addr;
315 u8 io_32bit = drive->io_32bit;
316 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
317
318 if (io_32bit) {
319 unsigned long uninitialized_var(flags);
320
321 if ((io_32bit & 2) && !mmio) {
322 local_irq_save(flags);
323 ata_vlb_sync(io_ports->nsect_addr);
324 }
325
326 if (mmio)
327 __ide_mm_outsl((void __iomem *)data_addr, buf, len / 4);
328 else
329 outsl(data_addr, buf, len / 4);
330
331 if ((io_32bit & 2) && !mmio)
332 local_irq_restore(flags);
333
334 if ((len & 3) >= 2) {
335 if (mmio)
336 __ide_mm_outsw((void __iomem *)data_addr,
337 (u8 *)buf + (len & ~3), 1);
338 else
339 outsw(data_addr, (u8 *)buf + (len & ~3), 1);
340 }
341 } else {
342 if (mmio)
343 __ide_mm_outsw((void __iomem *)data_addr, buf, len / 2);
344 else
345 outsw(data_addr, buf, len / 2);
346 }
347}
348EXPORT_SYMBOL_GPL(ide_output_data);
349
350u8 ide_read_error(ide_drive_t *drive) 53u8 ide_read_error(ide_drive_t *drive)
351{ 54{
352 ide_task_t task; 55 ide_task_t task;
@@ -360,35 +63,6 @@ u8 ide_read_error(ide_drive_t *drive)
360} 63}
361EXPORT_SYMBOL_GPL(ide_read_error); 64EXPORT_SYMBOL_GPL(ide_read_error);
362 65
363void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason)
364{
365 ide_task_t task;
366
367 memset(&task, 0, sizeof(task));
368 task.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM |
369 IDE_TFLAG_IN_NSECT;
370
371 drive->hwif->tp_ops->tf_read(drive, &task);
372
373 *bcount = (task.tf.lbah << 8) | task.tf.lbam;
374 *ireason = task.tf.nsect & 3;
375}
376EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason);
377
378const struct ide_tp_ops default_tp_ops = {
379 .exec_command = ide_exec_command,
380 .read_status = ide_read_status,
381 .read_altstatus = ide_read_altstatus,
382
383 .set_irq = ide_set_irq,
384
385 .tf_load = ide_tf_load,
386 .tf_read = ide_tf_read,
387
388 .input_data = ide_input_data,
389 .output_data = ide_output_data,
390};
391
392void ide_fix_driveid(u16 *id) 66void ide_fix_driveid(u16 *id)
393{ 67{
394#ifndef __LITTLE_ENDIAN 68#ifndef __LITTLE_ENDIAN
@@ -410,7 +84,7 @@ void ide_fix_driveid(u16 *id)
410 * returned by the ATA_CMD_ID_ATA[PI] commands. 84 * returned by the ATA_CMD_ID_ATA[PI] commands.
411 */ 85 */
412 86
413void ide_fixstring (u8 *s, const int bytecount, const int byteswap) 87void ide_fixstring(u8 *s, const int bytecount, const int byteswap)
414{ 88{
415 u8 *p, *end = &s[bytecount & ~1]; /* bytecount must be even */ 89 u8 *p, *end = &s[bytecount & ~1]; /* bytecount must be even */
416 90
@@ -433,44 +107,9 @@ void ide_fixstring (u8 *s, const int bytecount, const int byteswap)
433 while (p != end) 107 while (p != end)
434 *p++ = '\0'; 108 *p++ = '\0';
435} 109}
436
437EXPORT_SYMBOL(ide_fixstring); 110EXPORT_SYMBOL(ide_fixstring);
438 111
439/* 112/*
440 * Needed for PCI irq sharing
441 */
442int drive_is_ready (ide_drive_t *drive)
443{
444 ide_hwif_t *hwif = drive->hwif;
445 u8 stat = 0;
446
447 if (drive->waiting_for_dma)
448 return hwif->dma_ops->dma_test_irq(drive);
449
450 /*
451 * We do a passive status test under shared PCI interrupts on
452 * cards that truly share the ATA side interrupt, but may also share
453 * an interrupt with another pci card/device. We make no assumptions
454 * about possible isa-pnp and pci-pnp issues yet.
455 */
456 if (hwif->io_ports.ctl_addr &&
457 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0)
458 stat = hwif->tp_ops->read_altstatus(hwif);
459 else
460 /* Note: this may clear a pending IRQ!! */
461 stat = hwif->tp_ops->read_status(hwif);
462
463 if (stat & ATA_BUSY)
464 /* drive busy: definitely not interrupting */
465 return 0;
466
467 /* drive ready: *might* be interrupting */
468 return 1;
469}
470
471EXPORT_SYMBOL(drive_is_ready);
472
473/*
474 * This routine busy-waits for the drive status to be not "busy". 113 * This routine busy-waits for the drive status to be not "busy".
475 * It then checks the status for all of the "good" bits and none 114 * It then checks the status for all of the "good" bits and none
476 * of the "bad" bits, and if all is okay it returns 0. All other 115 * of the "bad" bits, and if all is okay it returns 0. All other
@@ -481,7 +120,8 @@ EXPORT_SYMBOL(drive_is_ready);
481 * setting a timer to wake up at half second intervals thereafter, 120 * setting a timer to wake up at half second intervals thereafter,
482 * until timeout is achieved, before timing out. 121 * until timeout is achieved, before timing out.
483 */ 122 */
484static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) 123static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad,
124 unsigned long timeout, u8 *rstat)
485{ 125{
486 ide_hwif_t *hwif = drive->hwif; 126 ide_hwif_t *hwif = drive->hwif;
487 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 127 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
@@ -539,7 +179,8 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
539 * The caller should return the updated value of "startstop" in this case, 179 * The caller should return the updated value of "startstop" in this case,
540 * "startstop" is unchanged when the function returns 0. 180 * "startstop" is unchanged when the function returns 0.
541 */ 181 */
542int ide_wait_stat(ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout) 182int ide_wait_stat(ide_startstop_t *startstop, ide_drive_t *drive, u8 good,
183 u8 bad, unsigned long timeout)
543{ 184{
544 int err; 185 int err;
545 u8 stat; 186 u8 stat;
@@ -559,7 +200,6 @@ int ide_wait_stat(ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 ba
559 200
560 return err; 201 return err;
561} 202}
562
563EXPORT_SYMBOL(ide_wait_stat); 203EXPORT_SYMBOL(ide_wait_stat);
564 204
565/** 205/**
@@ -580,7 +220,6 @@ int ide_in_drive_list(u16 *id, const struct drive_list_entry *table)
580 return 1; 220 return 1;
581 return 0; 221 return 0;
582} 222}
583
584EXPORT_SYMBOL_GPL(ide_in_drive_list); 223EXPORT_SYMBOL_GPL(ide_in_drive_list);
585 224
586/* 225/*
@@ -605,7 +244,7 @@ static const struct drive_list_entry ivb_list[] = {
605 * All hosts that use the 80c ribbon must use! 244 * All hosts that use the 80c ribbon must use!
606 * The name is derived from upper byte of word 93 and the 80c ribbon. 245 * The name is derived from upper byte of word 93 and the 80c ribbon.
607 */ 246 */
608u8 eighty_ninty_three (ide_drive_t *drive) 247u8 eighty_ninty_three(ide_drive_t *drive)
609{ 248{
610 ide_hwif_t *hwif = drive->hwif; 249 ide_hwif_t *hwif = drive->hwif;
611 u16 *id = drive->id; 250 u16 *id = drive->id;
@@ -650,47 +289,19 @@ no_80w:
650 289
651int ide_driveid_update(ide_drive_t *drive) 290int ide_driveid_update(ide_drive_t *drive)
652{ 291{
653 ide_hwif_t *hwif = drive->hwif;
654 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
655 u16 *id; 292 u16 *id;
656 unsigned long flags; 293 int rc;
657 u8 stat;
658
659 /*
660 * Re-read drive->id for possible DMA mode
661 * change (copied from ide-probe.c)
662 */
663 294
664 SELECT_MASK(drive, 1); 295 id = kmalloc(SECTOR_SIZE, GFP_ATOMIC);
665 tp_ops->set_irq(hwif, 0); 296 if (id == NULL)
666 msleep(50);
667 tp_ops->exec_command(hwif, ATA_CMD_ID_ATA);
668
669 if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 1)) {
670 SELECT_MASK(drive, 0);
671 return 0; 297 return 0;
672 }
673
674 msleep(50); /* wait for IRQ and ATA_DRQ */
675 stat = tp_ops->read_status(hwif);
676 298
677 if (!OK_STAT(stat, ATA_DRQ, BAD_R_STAT)) { 299 SELECT_MASK(drive, 1);
678 SELECT_MASK(drive, 0); 300 rc = ide_dev_read_id(drive, ATA_CMD_ID_ATA, id);
679 printk("%s: CHECK for good STATUS\n", drive->name);
680 return 0;
681 }
682 local_irq_save(flags);
683 SELECT_MASK(drive, 0); 301 SELECT_MASK(drive, 0);
684 id = kmalloc(SECTOR_SIZE, GFP_ATOMIC); 302
685 if (!id) { 303 if (rc)
686 local_irq_restore(flags); 304 goto out_err;
687 return 0;
688 }
689 tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
690 (void)tp_ops->read_status(hwif); /* clear drive IRQ */
691 local_irq_enable();
692 local_irq_restore(flags);
693 ide_fix_driveid(id);
694 305
695 drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES]; 306 drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES];
696 drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES]; 307 drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES];
@@ -703,6 +314,12 @@ int ide_driveid_update(ide_drive_t *drive)
703 ide_dma_off(drive); 314 ide_dma_off(drive);
704 315
705 return 1; 316 return 1;
317out_err:
318 SELECT_MASK(drive, 0);
319 if (rc == 2)
320 printk(KERN_ERR "%s: %s: bad status\n", drive->name, __func__);
321 kfree(id);
322 return 0;
706} 323}
707 324
708int ide_config_drive_speed(ide_drive_t *drive, u8 speed) 325int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
@@ -729,18 +346,15 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
729 * but for some reason these don't work at 346 * but for some reason these don't work at
730 * this point (lost interrupt). 347 * this point (lost interrupt).
731 */ 348 */
732 /* 349
733 * Select the drive, and issue the SETFEATURES command
734 */
735 disable_irq_nosync(hwif->irq);
736
737 /* 350 /*
738 * FIXME: we race against the running IRQ here if 351 * FIXME: we race against the running IRQ here if
739 * this is called from non IRQ context. If we use 352 * this is called from non IRQ context. If we use
740 * disable_irq() we hang on the error path. Work 353 * disable_irq() we hang on the error path. Work
741 * is needed. 354 * is needed.
742 */ 355 */
743 356 disable_irq_nosync(hwif->irq);
357
744 udelay(1); 358 udelay(1);
745 SELECT_DRIVE(drive); 359 SELECT_DRIVE(drive);
746 SELECT_MASK(drive, 1); 360 SELECT_MASK(drive, 1);
@@ -810,8 +424,8 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
810 * 424 *
811 * See also ide_execute_command 425 * See also ide_execute_command
812 */ 426 */
813static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, 427void __ide_set_handler(ide_drive_t *drive, ide_handler_t *handler,
814 unsigned int timeout, ide_expiry_t *expiry) 428 unsigned int timeout, ide_expiry_t *expiry)
815{ 429{
816 ide_hwif_t *hwif = drive->hwif; 430 ide_hwif_t *hwif = drive->hwif;
817 431
@@ -833,9 +447,8 @@ void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
833 __ide_set_handler(drive, handler, timeout, expiry); 447 __ide_set_handler(drive, handler, timeout, expiry);
834 spin_unlock_irqrestore(&hwif->lock, flags); 448 spin_unlock_irqrestore(&hwif->lock, flags);
835} 449}
836
837EXPORT_SYMBOL(ide_set_handler); 450EXPORT_SYMBOL(ide_set_handler);
838 451
839/** 452/**
840 * ide_execute_command - execute an IDE command 453 * ide_execute_command - execute an IDE command
841 * @drive: IDE drive to issue the command against 454 * @drive: IDE drive to issue the command against
@@ -845,7 +458,7 @@ EXPORT_SYMBOL(ide_set_handler);
845 * @expiry: handler to run on timeout 458 * @expiry: handler to run on timeout
846 * 459 *
847 * Helper function to issue an IDE command. This handles the 460 * Helper function to issue an IDE command. This handles the
848 * atomicity requirements, command timing and ensures that the 461 * atomicity requirements, command timing and ensures that the
849 * handler and IRQ setup do not race. All IDE command kick off 462 * handler and IRQ setup do not race. All IDE command kick off
850 * should go via this function or do equivalent locking. 463 * should go via this function or do equivalent locking.
851 */ 464 */
@@ -882,301 +495,6 @@ void ide_execute_pkt_cmd(ide_drive_t *drive)
882} 495}
883EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); 496EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd);
884 497
885static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
886{
887 struct request *rq = drive->hwif->rq;
888
889 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET)
890 ide_end_request(drive, err ? err : 1, 0);
891}
892
893/* needed below */
894static ide_startstop_t do_reset1 (ide_drive_t *, int);
895
896/*
897 * atapi_reset_pollfunc() gets invoked to poll the interface for completion every 50ms
898 * during an atapi drive reset operation. If the drive has not yet responded,
899 * and we have not yet hit our maximum waiting time, then the timer is restarted
900 * for another 50ms.
901 */
902static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
903{
904 ide_hwif_t *hwif = drive->hwif;
905 u8 stat;
906
907 SELECT_DRIVE(drive);
908 udelay (10);
909 stat = hwif->tp_ops->read_status(hwif);
910
911 if (OK_STAT(stat, 0, ATA_BUSY))
912 printk("%s: ATAPI reset complete\n", drive->name);
913 else {
914 if (time_before(jiffies, hwif->poll_timeout)) {
915 ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
916 /* continue polling */
917 return ide_started;
918 }
919 /* end of polling */
920 hwif->polling = 0;
921 printk("%s: ATAPI reset timed-out, status=0x%02x\n",
922 drive->name, stat);
923 /* do it the old fashioned way */
924 return do_reset1(drive, 1);
925 }
926 /* done polling */
927 hwif->polling = 0;
928 ide_complete_drive_reset(drive, 0);
929 return ide_stopped;
930}
931
932static void ide_reset_report_error(ide_hwif_t *hwif, u8 err)
933{
934 static const char *err_master_vals[] =
935 { NULL, "passed", "formatter device error",
936 "sector buffer error", "ECC circuitry error",
937 "controlling MPU error" };
938
939 u8 err_master = err & 0x7f;
940
941 printk(KERN_ERR "%s: reset: master: ", hwif->name);
942 if (err_master && err_master < 6)
943 printk(KERN_CONT "%s", err_master_vals[err_master]);
944 else
945 printk(KERN_CONT "error (0x%02x?)", err);
946 if (err & 0x80)
947 printk(KERN_CONT "; slave: failed");
948 printk(KERN_CONT "\n");
949}
950
951/*
952 * reset_pollfunc() gets invoked to poll the interface for completion every 50ms
953 * during an ide reset operation. If the drives have not yet responded,
954 * and we have not yet hit our maximum waiting time, then the timer is restarted
955 * for another 50ms.
956 */
957static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
958{
959 ide_hwif_t *hwif = drive->hwif;
960 const struct ide_port_ops *port_ops = hwif->port_ops;
961 u8 tmp;
962 int err = 0;
963
964 if (port_ops && port_ops->reset_poll) {
965 err = port_ops->reset_poll(drive);
966 if (err) {
967 printk(KERN_ERR "%s: host reset_poll failure for %s.\n",
968 hwif->name, drive->name);
969 goto out;
970 }
971 }
972
973 tmp = hwif->tp_ops->read_status(hwif);
974
975 if (!OK_STAT(tmp, 0, ATA_BUSY)) {
976 if (time_before(jiffies, hwif->poll_timeout)) {
977 ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
978 /* continue polling */
979 return ide_started;
980 }
981 printk("%s: reset timed-out, status=0x%02x\n", hwif->name, tmp);
982 drive->failures++;
983 err = -EIO;
984 } else {
985 tmp = ide_read_error(drive);
986
987 if (tmp == 1) {
988 printk(KERN_INFO "%s: reset: success\n", hwif->name);
989 drive->failures = 0;
990 } else {
991 ide_reset_report_error(hwif, tmp);
992 drive->failures++;
993 err = -EIO;
994 }
995 }
996out:
997 hwif->polling = 0; /* done polling */
998 ide_complete_drive_reset(drive, err);
999 return ide_stopped;
1000}
1001
1002static void ide_disk_pre_reset(ide_drive_t *drive)
1003{
1004 int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1;
1005
1006 drive->special.all = 0;
1007 drive->special.b.set_geometry = legacy;
1008 drive->special.b.recalibrate = legacy;
1009
1010 drive->mult_count = 0;
1011 drive->dev_flags &= ~IDE_DFLAG_PARKED;
1012
1013 if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0 &&
1014 (drive->dev_flags & IDE_DFLAG_USING_DMA) == 0)
1015 drive->mult_req = 0;
1016
1017 if (drive->mult_req != drive->mult_count)
1018 drive->special.b.set_multmode = 1;
1019}
1020
1021static void pre_reset(ide_drive_t *drive)
1022{
1023 const struct ide_port_ops *port_ops = drive->hwif->port_ops;
1024
1025 if (drive->media == ide_disk)
1026 ide_disk_pre_reset(drive);
1027 else
1028 drive->dev_flags |= IDE_DFLAG_POST_RESET;
1029
1030 if (drive->dev_flags & IDE_DFLAG_USING_DMA) {
1031 if (drive->crc_count)
1032 ide_check_dma_crc(drive);
1033 else
1034 ide_dma_off(drive);
1035 }
1036
1037 if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0) {
1038 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) {
1039 drive->dev_flags &= ~IDE_DFLAG_UNMASK;
1040 drive->io_32bit = 0;
1041 }
1042 return;
1043 }
1044
1045 if (port_ops && port_ops->pre_reset)
1046 port_ops->pre_reset(drive);
1047
1048 if (drive->current_speed != 0xff)
1049 drive->desired_speed = drive->current_speed;
1050 drive->current_speed = 0xff;
1051}
1052
1053/*
1054 * do_reset1() attempts to recover a confused drive by resetting it.
1055 * Unfortunately, resetting a disk drive actually resets all devices on
1056 * the same interface, so it can really be thought of as resetting the
1057 * interface rather than resetting the drive.
1058 *
1059 * ATAPI devices have their own reset mechanism which allows them to be
1060 * individually reset without clobbering other devices on the same interface.
1061 *
1062 * Unfortunately, the IDE interface does not generate an interrupt to let
1063 * us know when the reset operation has finished, so we must poll for this.
1064 * Equally poor, though, is the fact that this may a very long time to complete,
1065 * (up to 30 seconds worstcase). So, instead of busy-waiting here for it,
1066 * we set a timer to poll at 50ms intervals.
1067 */
1068static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1069{
1070 ide_hwif_t *hwif = drive->hwif;
1071 struct ide_io_ports *io_ports = &hwif->io_ports;
1072 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
1073 const struct ide_port_ops *port_ops;
1074 ide_drive_t *tdrive;
1075 unsigned long flags, timeout;
1076 int i;
1077 DEFINE_WAIT(wait);
1078
1079 spin_lock_irqsave(&hwif->lock, flags);
1080
1081 /* We must not reset with running handlers */
1082 BUG_ON(hwif->handler != NULL);
1083
1084 /* For an ATAPI device, first try an ATAPI SRST. */
1085 if (drive->media != ide_disk && !do_not_try_atapi) {
1086 pre_reset(drive);
1087 SELECT_DRIVE(drive);
1088 udelay (20);
1089 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
1090 ndelay(400);
1091 hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
1092 hwif->polling = 1;
1093 __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
1094 spin_unlock_irqrestore(&hwif->lock, flags);
1095 return ide_started;
1096 }
1097
1098 /* We must not disturb devices in the IDE_DFLAG_PARKED state. */
1099 do {
1100 unsigned long now;
1101
1102 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
1103 timeout = jiffies;
1104 ide_port_for_each_dev(i, tdrive, hwif) {
1105 if (tdrive->dev_flags & IDE_DFLAG_PRESENT &&
1106 tdrive->dev_flags & IDE_DFLAG_PARKED &&
1107 time_after(tdrive->sleep, timeout))
1108 timeout = tdrive->sleep;
1109 }
1110
1111 now = jiffies;
1112 if (time_before_eq(timeout, now))
1113 break;
1114
1115 spin_unlock_irqrestore(&hwif->lock, flags);
1116 timeout = schedule_timeout_uninterruptible(timeout - now);
1117 spin_lock_irqsave(&hwif->lock, flags);
1118 } while (timeout);
1119 finish_wait(&ide_park_wq, &wait);
1120
1121 /*
1122 * First, reset any device state data we were maintaining
1123 * for any of the drives on this interface.
1124 */
1125 ide_port_for_each_dev(i, tdrive, hwif)
1126 pre_reset(tdrive);
1127
1128 if (io_ports->ctl_addr == 0) {
1129 spin_unlock_irqrestore(&hwif->lock, flags);
1130 ide_complete_drive_reset(drive, -ENXIO);
1131 return ide_stopped;
1132 }
1133
1134 /*
1135 * Note that we also set nIEN while resetting the device,
1136 * to mask unwanted interrupts from the interface during the reset.
1137 * However, due to the design of PC hardware, this will cause an
1138 * immediate interrupt due to the edge transition it produces.
1139 * This single interrupt gives us a "fast poll" for drives that
1140 * recover from reset very quickly, saving us the first 50ms wait time.
1141 *
1142 * TODO: add ->softreset method and stop abusing ->set_irq
1143 */
1144 /* set SRST and nIEN */
1145 tp_ops->set_irq(hwif, 4);
1146 /* more than enough time */
1147 udelay(10);
1148 /* clear SRST, leave nIEN (unless device is on the quirk list) */
1149 tp_ops->set_irq(hwif, drive->quirk_list == 2);
1150 /* more than enough time */
1151 udelay(10);
1152 hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
1153 hwif->polling = 1;
1154 __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
1155
1156 /*
1157 * Some weird controller like resetting themselves to a strange
1158 * state when the disks are reset this way. At least, the Winbond
1159 * 553 documentation says that
1160 */
1161 port_ops = hwif->port_ops;
1162 if (port_ops && port_ops->resetproc)
1163 port_ops->resetproc(drive);
1164
1165 spin_unlock_irqrestore(&hwif->lock, flags);
1166 return ide_started;
1167}
1168
1169/*
1170 * ide_do_reset() is the entry point to the drive/interface reset code.
1171 */
1172
1173ide_startstop_t ide_do_reset (ide_drive_t *drive)
1174{
1175 return do_reset1(drive, 0);
1176}
1177
1178EXPORT_SYMBOL(ide_do_reset);
1179
1180/* 498/*
1181 * ide_wait_not_busy() waits for the currently selected device on the hwif 499 * ide_wait_not_busy() waits for the currently selected device on the hwif
1182 * to report a non-busy status, see comments in ide_probe_port(). 500 * to report a non-busy status, see comments in ide_probe_port().
@@ -1185,7 +503,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
1185{ 503{
1186 u8 stat = 0; 504 u8 stat = 0;
1187 505
1188 while(timeout--) { 506 while (timeout--) {
1189 /* 507 /*
1190 * Turn this into a schedule() sleep once I'm sure 508 * Turn this into a schedule() sleep once I'm sure
1191 * about locking issues (2.5 work ?). 509 * about locking issues (2.5 work ?).
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 09526a0de734..f6c683dd2987 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -5,163 +5,6 @@
5#include <linux/ide.h> 5#include <linux/ide.h>
6#include <linux/bitops.h> 6#include <linux/bitops.h>
7 7
8static const char *udma_str[] =
9 { "UDMA/16", "UDMA/25", "UDMA/33", "UDMA/44",
10 "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" };
11static const char *mwdma_str[] =
12 { "MWDMA0", "MWDMA1", "MWDMA2" };
13static const char *swdma_str[] =
14 { "SWDMA0", "SWDMA1", "SWDMA2" };
15static const char *pio_str[] =
16 { "PIO0", "PIO1", "PIO2", "PIO3", "PIO4", "PIO5" };
17
18/**
19 * ide_xfer_verbose - return IDE mode names
20 * @mode: transfer mode
21 *
22 * Returns a constant string giving the name of the mode
23 * requested.
24 */
25
26const char *ide_xfer_verbose(u8 mode)
27{
28 const char *s;
29 u8 i = mode & 0xf;
30
31 if (mode >= XFER_UDMA_0 && mode <= XFER_UDMA_7)
32 s = udma_str[i];
33 else if (mode >= XFER_MW_DMA_0 && mode <= XFER_MW_DMA_2)
34 s = mwdma_str[i];
35 else if (mode >= XFER_SW_DMA_0 && mode <= XFER_SW_DMA_2)
36 s = swdma_str[i];
37 else if (mode >= XFER_PIO_0 && mode <= XFER_PIO_5)
38 s = pio_str[i & 0x7];
39 else if (mode == XFER_PIO_SLOW)
40 s = "PIO SLOW";
41 else
42 s = "XFER ERROR";
43
44 return s;
45}
46EXPORT_SYMBOL(ide_xfer_verbose);
47
48/**
49 * ide_rate_filter - filter transfer mode
50 * @drive: IDE device
51 * @speed: desired speed
52 *
53 * Given the available transfer modes this function returns
54 * the best available speed at or below the speed requested.
55 *
56 * TODO: check device PIO capabilities
57 */
58
59static u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
60{
61 ide_hwif_t *hwif = drive->hwif;
62 u8 mode = ide_find_dma_mode(drive, speed);
63
64 if (mode == 0) {
65 if (hwif->pio_mask)
66 mode = fls(hwif->pio_mask) - 1 + XFER_PIO_0;
67 else
68 mode = XFER_PIO_4;
69 }
70
71/* printk("%s: mode 0x%02x, speed 0x%02x\n", __func__, mode, speed); */
72
73 return min(speed, mode);
74}
75
76/**
77 * ide_get_best_pio_mode - get PIO mode from drive
78 * @drive: drive to consider
79 * @mode_wanted: preferred mode
80 * @max_mode: highest allowed mode
81 *
82 * This routine returns the recommended PIO settings for a given drive,
83 * based on the drive->id information and the ide_pio_blacklist[].
84 *
85 * Drive PIO mode is auto-selected if 255 is passed as mode_wanted.
86 * This is used by most chipset support modules when "auto-tuning".
87 */
88
89u8 ide_get_best_pio_mode(ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
90{
91 u16 *id = drive->id;
92 int pio_mode = -1, overridden = 0;
93
94 if (mode_wanted != 255)
95 return min_t(u8, mode_wanted, max_mode);
96
97 if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0)
98 pio_mode = ide_scan_pio_blacklist((char *)&id[ATA_ID_PROD]);
99
100 if (pio_mode != -1) {
101 printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name);
102 } else {
103 pio_mode = id[ATA_ID_OLD_PIO_MODES] >> 8;
104 if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */
105 pio_mode = 2;
106 overridden = 1;
107 }
108
109 if (id[ATA_ID_FIELD_VALID] & 2) { /* ATA2? */
110 if (ata_id_has_iordy(id)) {
111 if (id[ATA_ID_PIO_MODES] & 7) {
112 overridden = 0;
113 if (id[ATA_ID_PIO_MODES] & 4)
114 pio_mode = 5;
115 else if (id[ATA_ID_PIO_MODES] & 2)
116 pio_mode = 4;
117 else
118 pio_mode = 3;
119 }
120 }
121 }
122
123 if (overridden)
124 printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n",
125 drive->name);
126 }
127
128 if (pio_mode > max_mode)
129 pio_mode = max_mode;
130
131 return pio_mode;
132}
133EXPORT_SYMBOL_GPL(ide_get_best_pio_mode);
134
135/* req_pio == "255" for auto-tune */
136void ide_set_pio(ide_drive_t *drive, u8 req_pio)
137{
138 ide_hwif_t *hwif = drive->hwif;
139 const struct ide_port_ops *port_ops = hwif->port_ops;
140 u8 host_pio, pio;
141
142 if (port_ops == NULL || port_ops->set_pio_mode == NULL ||
143 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
144 return;
145
146 BUG_ON(hwif->pio_mask == 0x00);
147
148 host_pio = fls(hwif->pio_mask) - 1;
149
150 pio = ide_get_best_pio_mode(drive, req_pio, host_pio);
151
152 /*
153 * TODO:
154 * - report device max PIO mode
155 * - check req_pio != 255 against device max PIO mode
156 */
157 printk(KERN_DEBUG "%s: host max PIO%d wanted PIO%d%s selected PIO%d\n",
158 drive->name, host_pio, req_pio,
159 req_pio == 255 ? "(auto-tune)" : "", pio);
160
161 (void)ide_set_pio_mode(drive, XFER_PIO_0 + pio);
162}
163EXPORT_SYMBOL_GPL(ide_set_pio);
164
165/** 8/**
166 * ide_toggle_bounce - handle bounce buffering 9 * ide_toggle_bounce - handle bounce buffering
167 * @drive: drive to update 10 * @drive: drive to update
@@ -188,89 +31,6 @@ void ide_toggle_bounce(ide_drive_t *drive, int on)
188 blk_queue_bounce_limit(drive->queue, addr); 31 blk_queue_bounce_limit(drive->queue, addr);
189} 32}
190 33
191int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
192{
193 ide_hwif_t *hwif = drive->hwif;
194 const struct ide_port_ops *port_ops = hwif->port_ops;
195
196 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
197 return 0;
198
199 if (port_ops == NULL || port_ops->set_pio_mode == NULL)
200 return -1;
201
202 /*
203 * TODO: temporary hack for some legacy host drivers that didn't
204 * set transfer mode on the device in ->set_pio_mode method...
205 */
206 if (port_ops->set_dma_mode == NULL) {
207 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
208 return 0;
209 }
210
211 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
212 if (ide_config_drive_speed(drive, mode))
213 return -1;
214 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
215 return 0;
216 } else {
217 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
218 return ide_config_drive_speed(drive, mode);
219 }
220}
221
222int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
223{
224 ide_hwif_t *hwif = drive->hwif;
225 const struct ide_port_ops *port_ops = hwif->port_ops;
226
227 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
228 return 0;
229
230 if (port_ops == NULL || port_ops->set_dma_mode == NULL)
231 return -1;
232
233 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
234 if (ide_config_drive_speed(drive, mode))
235 return -1;
236 port_ops->set_dma_mode(drive, mode);
237 return 0;
238 } else {
239 port_ops->set_dma_mode(drive, mode);
240 return ide_config_drive_speed(drive, mode);
241 }
242}
243EXPORT_SYMBOL_GPL(ide_set_dma_mode);
244
245/**
246 * ide_set_xfer_rate - set transfer rate
247 * @drive: drive to set
248 * @rate: speed to attempt to set
249 *
250 * General helper for setting the speed of an IDE device. This
251 * function knows about user enforced limits from the configuration
252 * which ->set_pio_mode/->set_dma_mode does not.
253 */
254
255int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
256{
257 ide_hwif_t *hwif = drive->hwif;
258 const struct ide_port_ops *port_ops = hwif->port_ops;
259
260 if (port_ops == NULL || port_ops->set_dma_mode == NULL ||
261 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
262 return -1;
263
264 rate = ide_rate_filter(drive, rate);
265
266 BUG_ON(rate < XFER_PIO_0);
267
268 if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5)
269 return ide_set_pio_mode(drive, rate);
270
271 return ide_set_dma_mode(drive, rate);
272}
273
274static void ide_dump_opcode(ide_drive_t *drive) 34static void ide_dump_opcode(ide_drive_t *drive)
275{ 35{
276 struct request *rq = drive->hwif->rq; 36 struct request *rq = drive->hwif->rq;
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index c875a957596c..f30e52152fcb 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -1,5 +1,6 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/hdreg.h>
3#include <linux/jiffies.h> 4#include <linux/jiffies.h>
4#include <linux/blkdev.h> 5#include <linux/blkdev.h>
5 6
@@ -60,6 +61,30 @@ out:
60 return; 61 return;
61} 62}
62 63
64ide_startstop_t ide_do_park_unpark(ide_drive_t *drive, struct request *rq)
65{
66 ide_task_t task;
67 struct ide_taskfile *tf = &task.tf;
68
69 memset(&task, 0, sizeof(task));
70 if (rq->cmd[0] == REQ_PARK_HEADS) {
71 drive->sleep = *(unsigned long *)rq->special;
72 drive->dev_flags |= IDE_DFLAG_SLEEPING;
73 tf->command = ATA_CMD_IDLEIMMEDIATE;
74 tf->feature = 0x44;
75 tf->lbal = 0x4c;
76 tf->lbam = 0x4e;
77 tf->lbah = 0x55;
78 task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER;
79 } else /* cmd == REQ_UNPARK_HEADS */
80 tf->command = ATA_CMD_CHK_POWER;
81
82 task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
83 task.rq = rq;
84 drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA;
85 return do_rw_taskfile(drive, &task);
86}
87
63ssize_t ide_park_show(struct device *dev, struct device_attribute *attr, 88ssize_t ide_park_show(struct device *dev, struct device_attribute *attr,
64 char *buf) 89 char *buf)
65{ 90{
diff --git a/drivers/ide/ide-pci-generic.c b/drivers/ide/ide-pci-generic.c
index bddae2b329a0..61111fd27130 100644
--- a/drivers/ide/ide-pci-generic.c
+++ b/drivers/ide/ide-pci-generic.c
@@ -33,8 +33,6 @@ static int ide_generic_all; /* Set to claim all devices */
33module_param_named(all_generic_ide, ide_generic_all, bool, 0444); 33module_param_named(all_generic_ide, ide_generic_all, bool, 0444);
34MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); 34MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers.");
35 35
36#define IDE_HFLAGS_UMC (IDE_HFLAG_NO_DMA | IDE_HFLAG_FORCE_LEGACY_IRQS)
37
38#define DECLARE_GENERIC_PCI_DEV(extra_flags) \ 36#define DECLARE_GENERIC_PCI_DEV(extra_flags) \
39 { \ 37 { \
40 .name = DRV_NAME, \ 38 .name = DRV_NAME, \
@@ -61,7 +59,7 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = {
61 /* 2: SAMURAI / HT6565 / HINT_IDE */ 59 /* 2: SAMURAI / HT6565 / HINT_IDE */
62 DECLARE_GENERIC_PCI_DEV(0), 60 DECLARE_GENERIC_PCI_DEV(0),
63 /* 3: UM8673F / UM8886A / UM8886BF */ 61 /* 3: UM8673F / UM8886A / UM8886BF */
64 DECLARE_GENERIC_PCI_DEV(IDE_HFLAGS_UMC), 62 DECLARE_GENERIC_PCI_DEV(IDE_HFLAG_NO_DMA),
65 /* 4: VIA_IDE / OPTI621V / Piccolo010{2,3,5} */ 63 /* 4: VIA_IDE / OPTI621V / Piccolo010{2,3,5} */
66 DECLARE_GENERIC_PCI_DEV(IDE_HFLAG_NO_AUTODMA), 64 DECLARE_GENERIC_PCI_DEV(IDE_HFLAG_NO_AUTODMA),
67 65
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index ce0818a993f6..974067043fba 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -181,16 +181,16 @@ static void ide_classify_atapi_dev(ide_drive_t *drive)
181 * do_identify - identify a drive 181 * do_identify - identify a drive
182 * @drive: drive to identify 182 * @drive: drive to identify
183 * @cmd: command used 183 * @cmd: command used
184 * @id: buffer for IDENTIFY data
184 * 185 *
185 * Called when we have issued a drive identify command to 186 * Called when we have issued a drive identify command to
186 * read and parse the results. This function is run with 187 * read and parse the results. This function is run with
187 * interrupts disabled. 188 * interrupts disabled.
188 */ 189 */
189 190
190static void do_identify(ide_drive_t *drive, u8 cmd) 191static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id)
191{ 192{
192 ide_hwif_t *hwif = drive->hwif; 193 ide_hwif_t *hwif = drive->hwif;
193 u16 *id = drive->id;
194 char *m = (char *)&id[ATA_ID_PROD]; 194 char *m = (char *)&id[ATA_ID_PROD];
195 unsigned long flags; 195 unsigned long flags;
196 int bswap = 1; 196 int bswap = 1;
@@ -233,16 +233,6 @@ static void do_identify(ide_drive_t *drive, u8 cmd)
233 drive->dev_flags |= IDE_DFLAG_PRESENT; 233 drive->dev_flags |= IDE_DFLAG_PRESENT;
234 drive->dev_flags &= ~IDE_DFLAG_DEAD; 234 drive->dev_flags &= ~IDE_DFLAG_DEAD;
235 235
236 /*
237 * Check for an ATAPI device
238 */
239 if (cmd == ATA_CMD_ID_ATAPI)
240 ide_classify_atapi_dev(drive);
241 else
242 /*
243 * Not an ATAPI device: looks like a "regular" hard disk
244 */
245 ide_classify_ata_dev(drive);
246 return; 236 return;
247err_misc: 237err_misc:
248 kfree(id); 238 kfree(id);
@@ -250,21 +240,19 @@ err_misc:
250} 240}
251 241
252/** 242/**
253 * actual_try_to_identify - send ata/atapi identify 243 * ide_dev_read_id - send ATA/ATAPI IDENTIFY command
254 * @drive: drive to identify 244 * @drive: drive to identify
255 * @cmd: command to use 245 * @cmd: command to use
246 * @id: buffer for IDENTIFY data
256 * 247 *
257 * try_to_identify() sends an ATA(PI) IDENTIFY request to a drive 248 * Sends an ATA(PI) IDENTIFY request to a drive and waits for a response.
258 * and waits for a response. It also monitors irqs while this is
259 * happening, in hope of automatically determining which one is
260 * being used by the interface.
261 * 249 *
262 * Returns: 0 device was identified 250 * Returns: 0 device was identified
263 * 1 device timed-out (no response to identify request) 251 * 1 device timed-out (no response to identify request)
264 * 2 device aborted the command (refused to identify itself) 252 * 2 device aborted the command (refused to identify itself)
265 */ 253 */
266 254
267static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) 255int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
268{ 256{
269 ide_hwif_t *hwif = drive->hwif; 257 ide_hwif_t *hwif = drive->hwif;
270 struct ide_io_ports *io_ports = &hwif->io_ports; 258 struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -273,6 +261,13 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
273 unsigned long timeout; 261 unsigned long timeout;
274 u8 s = 0, a = 0; 262 u8 s = 0, a = 0;
275 263
264 /*
265 * Disable device IRQ. Otherwise we'll get spurious interrupts
266 * during the identify phase that the IRQ handler isn't expecting.
267 */
268 if (io_ports->ctl_addr)
269 tp_ops->set_irq(hwif, 0);
270
276 /* take a deep breath */ 271 /* take a deep breath */
277 msleep(50); 272 msleep(50);
278 273
@@ -317,7 +312,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
317 312
318 if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { 313 if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) {
319 /* drive returned ID */ 314 /* drive returned ID */
320 do_identify(drive, cmd); 315 do_identify(drive, cmd, id);
321 /* drive responded with ID */ 316 /* drive responded with ID */
322 rc = 0; 317 rc = 0;
323 /* clear drive IRQ */ 318 /* clear drive IRQ */
@@ -329,63 +324,6 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
329 return rc; 324 return rc;
330} 325}
331 326
332/**
333 * try_to_identify - try to identify a drive
334 * @drive: drive to probe
335 * @cmd: command to use
336 *
337 * Issue the identify command and then do IRQ probing to
338 * complete the identification when needed by finding the
339 * IRQ the drive is attached to
340 */
341
342static int try_to_identify (ide_drive_t *drive, u8 cmd)
343{
344 ide_hwif_t *hwif = drive->hwif;
345 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
346 int retval;
347 int autoprobe = 0;
348 unsigned long cookie = 0;
349
350 /*
351 * Disable device irq unless we need to
352 * probe for it. Otherwise we'll get spurious
353 * interrupts during the identify-phase that
354 * the irq handler isn't expecting.
355 */
356 if (hwif->io_ports.ctl_addr) {
357 if (!hwif->irq) {
358 autoprobe = 1;
359 cookie = probe_irq_on();
360 }
361 tp_ops->set_irq(hwif, autoprobe);
362 }
363
364 retval = actual_try_to_identify(drive, cmd);
365
366 if (autoprobe) {
367 int irq;
368
369 tp_ops->set_irq(hwif, 0);
370 /* clear drive IRQ */
371 (void)tp_ops->read_status(hwif);
372 udelay(5);
373 irq = probe_irq_off(cookie);
374 if (!hwif->irq) {
375 if (irq > 0) {
376 hwif->irq = irq;
377 } else {
378 /* Mmmm.. multiple IRQs..
379 * don't know which was ours
380 */
381 printk(KERN_ERR "%s: IRQ probe failed (0x%lx)\n",
382 drive->name, cookie);
383 }
384 }
385 }
386 return retval;
387}
388
389int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus) 327int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus)
390{ 328{
391 u8 stat; 329 u8 stat;
@@ -440,6 +378,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
440{ 378{
441 ide_hwif_t *hwif = drive->hwif; 379 ide_hwif_t *hwif = drive->hwif;
442 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 380 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
381 u16 *id = drive->id;
443 int rc; 382 int rc;
444 u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; 383 u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat;
445 384
@@ -475,11 +414,10 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
475 414
476 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || 415 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) ||
477 present || cmd == ATA_CMD_ID_ATAPI) { 416 present || cmd == ATA_CMD_ID_ATAPI) {
478 /* send cmd and wait */ 417 rc = ide_dev_read_id(drive, cmd, id);
479 if ((rc = try_to_identify(drive, cmd))) { 418 if (rc)
480 /* failed: try again */ 419 /* failed: try again */
481 rc = try_to_identify(drive,cmd); 420 rc = ide_dev_read_id(drive, cmd, id);
482 }
483 421
484 stat = tp_ops->read_status(hwif); 422 stat = tp_ops->read_status(hwif);
485 423
@@ -494,7 +432,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
494 msleep(50); 432 msleep(50);
495 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); 433 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
496 (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0); 434 (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0);
497 rc = try_to_identify(drive, cmd); 435 rc = ide_dev_read_id(drive, cmd, id);
498 } 436 }
499 437
500 /* ensure drive IRQ is clear */ 438 /* ensure drive IRQ is clear */
@@ -517,37 +455,6 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
517 return rc; 455 return rc;
518} 456}
519 457
520/*
521 *
522 */
523static void enable_nest (ide_drive_t *drive)
524{
525 ide_hwif_t *hwif = drive->hwif;
526 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
527 u8 stat;
528
529 printk(KERN_INFO "%s: enabling %s -- ",
530 hwif->name, (char *)&drive->id[ATA_ID_PROD]);
531
532 SELECT_DRIVE(drive);
533 msleep(50);
534 tp_ops->exec_command(hwif, ATA_EXABYTE_ENABLE_NEST);
535
536 if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 0)) {
537 printk(KERN_CONT "failed (timeout)\n");
538 return;
539 }
540
541 msleep(50);
542
543 stat = tp_ops->read_status(hwif);
544
545 if (!OK_STAT(stat, 0, BAD_STAT))
546 printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
547 else
548 printk(KERN_CONT "success\n");
549}
550
551/** 458/**
552 * probe_for_drives - upper level drive probe 459 * probe_for_drives - upper level drive probe
553 * @drive: drive to probe for 460 * @drive: drive to probe for
@@ -563,6 +470,8 @@ static void enable_nest (ide_drive_t *drive)
563static u8 probe_for_drive(ide_drive_t *drive) 470static u8 probe_for_drive(ide_drive_t *drive)
564{ 471{
565 char *m; 472 char *m;
473 int rc;
474 u8 cmd;
566 475
567 /* 476 /*
568 * In order to keep things simple we have an id 477 * In order to keep things simple we have an id
@@ -586,21 +495,19 @@ static u8 probe_for_drive(ide_drive_t *drive)
586 495
587 /* skip probing? */ 496 /* skip probing? */
588 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) { 497 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) {
589retry:
590 /* if !(success||timed-out) */ 498 /* if !(success||timed-out) */
591 if (do_probe(drive, ATA_CMD_ID_ATA) >= 2) 499 cmd = ATA_CMD_ID_ATA;
500 rc = do_probe(drive, cmd);
501 if (rc >= 2) {
592 /* look for ATAPI device */ 502 /* look for ATAPI device */
593 (void)do_probe(drive, ATA_CMD_ID_ATAPI); 503 cmd = ATA_CMD_ID_ATAPI;
504 rc = do_probe(drive, cmd);
505 }
594 506
595 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 507 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
596 /* drive not found */ 508 /* drive not found */
597 return 0; 509 return 0;
598 510
599 if (strstr(m, "E X A B Y T E N E S T")) {
600 enable_nest(drive);
601 goto retry;
602 }
603
604 /* identification failed? */ 511 /* identification failed? */
605 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { 512 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) {
606 if (drive->media == ide_disk) { 513 if (drive->media == ide_disk) {
@@ -614,8 +521,12 @@ retry:
614 printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); 521 printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name);
615 drive->dev_flags &= ~IDE_DFLAG_PRESENT; 522 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
616 } 523 }
524 } else {
525 if (cmd == ATA_CMD_ID_ATAPI)
526 ide_classify_atapi_dev(drive);
527 else
528 ide_classify_ata_dev(drive);
617 } 529 }
618 /* drive was found */
619 } 530 }
620 531
621 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 532 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
@@ -779,7 +690,6 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
779static int ide_probe_port(ide_hwif_t *hwif) 690static int ide_probe_port(ide_hwif_t *hwif)
780{ 691{
781 ide_drive_t *drive; 692 ide_drive_t *drive;
782 unsigned long flags;
783 unsigned int irqd; 693 unsigned int irqd;
784 int i, rc = -ENODEV; 694 int i, rc = -ENODEV;
785 695
@@ -797,9 +707,6 @@ static int ide_probe_port(ide_hwif_t *hwif)
797 if (irqd) 707 if (irqd)
798 disable_irq(hwif->irq); 708 disable_irq(hwif->irq);
799 709
800 local_save_flags(flags);
801 local_irq_enable_in_hardirq();
802
803 if (ide_port_wait_ready(hwif) == -EBUSY) 710 if (ide_port_wait_ready(hwif) == -EBUSY)
804 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); 711 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name);
805 712
@@ -813,8 +720,6 @@ static int ide_probe_port(ide_hwif_t *hwif)
813 rc = 0; 720 rc = 0;
814 } 721 }
815 722
816 local_irq_restore(flags);
817
818 /* 723 /*
819 * Use cached IRQ number. It might be (and is...) changed by probe 724 * Use cached IRQ number. It might be (and is...) changed by probe
820 * code above 725 * code above
@@ -831,29 +736,18 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
831 ide_drive_t *drive; 736 ide_drive_t *drive;
832 int i; 737 int i;
833 738
834 ide_port_for_each_dev(i, drive, hwif) { 739 ide_port_for_each_present_dev(i, drive, hwif) {
835 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 740 if (port_ops && port_ops->quirkproc)
836 if (port_ops && port_ops->quirkproc) 741 port_ops->quirkproc(drive);
837 port_ops->quirkproc(drive);
838 }
839 } 742 }
840 743
841 ide_port_for_each_dev(i, drive, hwif) { 744 ide_port_for_each_present_dev(i, drive, hwif) {
842 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 745 ide_set_max_pio(drive);
843 ide_set_max_pio(drive);
844 746
845 drive->dev_flags |= IDE_DFLAG_NICE1; 747 drive->dev_flags |= IDE_DFLAG_NICE1;
846 748
847 if (hwif->dma_ops) 749 if (hwif->dma_ops)
848 ide_set_dma(drive); 750 ide_set_dma(drive);
849 }
850 }
851
852 ide_port_for_each_dev(i, drive, hwif) {
853 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT)
854 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
855 else
856 drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT;
857 } 751 }
858} 752}
859 753
@@ -924,10 +818,7 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
924 int i, j = 0; 818 int i, j = 0;
925 819
926 mutex_lock(&ide_cfg_mtx); 820 mutex_lock(&ide_cfg_mtx);
927 ide_port_for_each_dev(i, drive, hwif) { 821 ide_port_for_each_present_dev(i, drive, hwif) {
928 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
929 continue;
930
931 if (ide_init_queue(drive)) { 822 if (ide_init_queue(drive)) {
932 printk(KERN_ERR "ide: failed to init %s\n", 823 printk(KERN_ERR "ide: failed to init %s\n",
933 drive->name); 824 drive->name);
@@ -950,14 +841,12 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
950static int init_irq (ide_hwif_t *hwif) 841static int init_irq (ide_hwif_t *hwif)
951{ 842{
952 struct ide_io_ports *io_ports = &hwif->io_ports; 843 struct ide_io_ports *io_ports = &hwif->io_ports;
844 irq_handler_t irq_handler;
953 int sa = 0; 845 int sa = 0;
954 846
955 mutex_lock(&ide_cfg_mtx); 847 irq_handler = hwif->host->irq_handler;
956 spin_lock_init(&hwif->lock); 848 if (irq_handler == NULL)
957 849 irq_handler = ide_intr;
958 init_timer(&hwif->timer);
959 hwif->timer.function = &ide_timer_expiry;
960 hwif->timer.data = (unsigned long)hwif;
961 850
962#if defined(__mc68000__) 851#if defined(__mc68000__)
963 sa = IRQF_SHARED; 852 sa = IRQF_SHARED;
@@ -969,7 +858,7 @@ static int init_irq (ide_hwif_t *hwif)
969 if (io_ports->ctl_addr) 858 if (io_ports->ctl_addr)
970 hwif->tp_ops->set_irq(hwif, 1); 859 hwif->tp_ops->set_irq(hwif, 1);
971 860
972 if (request_irq(hwif->irq, &ide_intr, sa, hwif->name, hwif)) 861 if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif))
973 goto out_up; 862 goto out_up;
974 863
975 if (!hwif->rqsize) { 864 if (!hwif->rqsize) {
@@ -992,10 +881,8 @@ static int init_irq (ide_hwif_t *hwif)
992 printk(KERN_CONT " (serialized)"); 881 printk(KERN_CONT " (serialized)");
993 printk(KERN_CONT "\n"); 882 printk(KERN_CONT "\n");
994 883
995 mutex_unlock(&ide_cfg_mtx);
996 return 0; 884 return 0;
997out_up: 885out_up:
998 mutex_unlock(&ide_cfg_mtx);
999 return 1; 886 return 1;
1000} 887}
1001 888
@@ -1094,14 +981,9 @@ static void drive_release_dev (struct device *dev)
1094 981
1095static int hwif_init(ide_hwif_t *hwif) 982static int hwif_init(ide_hwif_t *hwif)
1096{ 983{
1097 int old_irq;
1098
1099 if (!hwif->irq) { 984 if (!hwif->irq) {
1100 hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); 985 printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name);
1101 if (!hwif->irq) { 986 return 0;
1102 printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name);
1103 return 0;
1104 }
1105 } 987 }
1106 988
1107 if (register_blkdev(hwif->major, hwif->name)) 989 if (register_blkdev(hwif->major, hwif->name))
@@ -1119,29 +1001,12 @@ static int hwif_init(ide_hwif_t *hwif)
1119 1001
1120 sg_init_table(hwif->sg_table, hwif->sg_max_nents); 1002 sg_init_table(hwif->sg_table, hwif->sg_max_nents);
1121 1003
1122 if (init_irq(hwif) == 0)
1123 goto done;
1124
1125 old_irq = hwif->irq;
1126 /*
1127 * It failed to initialise. Find the default IRQ for
1128 * this port and try that.
1129 */
1130 hwif->irq = __ide_default_irq(hwif->io_ports.data_addr);
1131 if (!hwif->irq) {
1132 printk(KERN_ERR "%s: disabled, unable to get IRQ %d\n",
1133 hwif->name, old_irq);
1134 goto out;
1135 }
1136 if (init_irq(hwif)) { 1004 if (init_irq(hwif)) {
1137 printk(KERN_ERR "%s: probed IRQ %d and default IRQ %d failed\n", 1005 printk(KERN_ERR "%s: disabled, unable to get IRQ %d\n",
1138 hwif->name, old_irq, hwif->irq); 1006 hwif->name, hwif->irq);
1139 goto out; 1007 goto out;
1140 } 1008 }
1141 printk(KERN_WARNING "%s: probed IRQ %d failed, using default\n",
1142 hwif->name, hwif->irq);
1143 1009
1144done:
1145 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, 1010 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS,
1146 THIS_MODULE, ata_probe, ata_lock, hwif); 1011 THIS_MODULE, ata_probe, ata_lock, hwif);
1147 return 1; 1012 return 1;
@@ -1156,13 +1021,10 @@ static void hwif_register_devices(ide_hwif_t *hwif)
1156 ide_drive_t *drive; 1021 ide_drive_t *drive;
1157 unsigned int i; 1022 unsigned int i;
1158 1023
1159 ide_port_for_each_dev(i, drive, hwif) { 1024 ide_port_for_each_present_dev(i, drive, hwif) {
1160 struct device *dev = &drive->gendev; 1025 struct device *dev = &drive->gendev;
1161 int ret; 1026 int ret;
1162 1027
1163 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
1164 continue;
1165
1166 dev_set_name(dev, "%u.%u", hwif->index, i); 1028 dev_set_name(dev, "%u.%u", hwif->index, i);
1167 dev->parent = &hwif->gendev; 1029 dev->parent = &hwif->gendev;
1168 dev->bus = &ide_bus_type; 1030 dev->bus = &ide_bus_type;
@@ -1187,6 +1049,8 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
1187 1049
1188 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) 1050 if (hwif->host_flags & IDE_HFLAG_IO_32BIT)
1189 drive->io_32bit = 1; 1051 drive->io_32bit = 1;
1052 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT)
1053 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
1190 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) 1054 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS)
1191 drive->dev_flags |= IDE_DFLAG_UNMASK; 1055 drive->dev_flags |= IDE_DFLAG_UNMASK;
1192 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) 1056 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS)
@@ -1208,10 +1072,6 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
1208 if (d->init_iops) 1072 if (d->init_iops)
1209 d->init_iops(hwif); 1073 d->init_iops(hwif);
1210 1074
1211 if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) ||
1212 (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
1213 hwif->irq = port ? 15 : 14;
1214
1215 /* ->host_flags may be set by ->init_iops (or even earlier...) */ 1075 /* ->host_flags may be set by ->init_iops (or even earlier...) */
1216 hwif->host_flags |= d->host_flags; 1076 hwif->host_flags |= d->host_flags;
1217 hwif->pio_mask = d->pio_mask; 1077 hwif->pio_mask = d->pio_mask;
@@ -1312,6 +1172,12 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
1312 hwif->name[2] = 'e'; 1172 hwif->name[2] = 'e';
1313 hwif->name[3] = '0' + index; 1173 hwif->name[3] = '0' + index;
1314 1174
1175 spin_lock_init(&hwif->lock);
1176
1177 init_timer(&hwif->timer);
1178 hwif->timer.function = &ide_timer_expiry;
1179 hwif->timer.data = (unsigned long)hwif;
1180
1315 init_completion(&hwif->gendev_rel_comp); 1181 init_completion(&hwif->gendev_rel_comp);
1316 1182
1317 hwif->tp_ops = &default_tp_ops; 1183 hwif->tp_ops = &default_tp_ops;
@@ -1562,7 +1428,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1562 1428
1563 j++; 1429 j++;
1564 1430
1565 ide_acpi_init(hwif); 1431 ide_acpi_init_port(hwif);
1566 1432
1567 if (hwif->present) 1433 if (hwif->present)
1568 ide_acpi_port_init_devices(hwif); 1434 ide_acpi_port_init_devices(hwif);
@@ -1619,11 +1485,9 @@ static void __ide_port_unregister_devices(ide_hwif_t *hwif)
1619 ide_drive_t *drive; 1485 ide_drive_t *drive;
1620 int i; 1486 int i;
1621 1487
1622 ide_port_for_each_dev(i, drive, hwif) { 1488 ide_port_for_each_present_dev(i, drive, hwif) {
1623 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 1489 device_unregister(&drive->gendev);
1624 device_unregister(&drive->gendev); 1490 wait_for_completion(&drive->gendev_rel_comp);
1625 wait_for_completion(&drive->gendev_rel_comp);
1626 }
1627 } 1491 }
1628} 1492}
1629 1493
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 1d8978b3314a..417cde56eafd 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -231,7 +231,7 @@ static const struct ide_proc_devset ide_generic_settings[] = {
231 IDE_PROC_DEVSET(pio_mode, 0, 255), 231 IDE_PROC_DEVSET(pio_mode, 0, 255),
232 IDE_PROC_DEVSET(unmaskirq, 0, 1), 232 IDE_PROC_DEVSET(unmaskirq, 0, 1),
233 IDE_PROC_DEVSET(using_dma, 0, 1), 233 IDE_PROC_DEVSET(using_dma, 0, 1),
234 { 0 }, 234 { NULL },
235}; 235};
236 236
237static void proc_ide_settings_warn(void) 237static void proc_ide_settings_warn(void)
@@ -600,7 +600,7 @@ void ide_proc_port_register_devices(ide_hwif_t *hwif)
600 int i; 600 int i;
601 601
602 ide_port_for_each_dev(i, drive, hwif) { 602 ide_port_for_each_dev(i, drive, hwif) {
603 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc) 603 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
604 continue; 604 continue;
605 605
606 drive->proc = proc_mkdir(drive->name, parent); 606 drive->proc = proc_mkdir(drive->name, parent);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index bb450a7608c2..4e6181c7bbda 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2166,7 +2166,7 @@ static const struct ide_proc_devset idetape_settings[] = {
2166 __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), 2166 __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL),
2167 __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 2167 __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX,
2168 mulf_tdsc, divf_tdsc), 2168 mulf_tdsc, divf_tdsc),
2169 { 0 }, 2169 { NULL },
2170}; 2170};
2171#endif 2171#endif
2172 2172
diff --git a/drivers/ide/ide-xfer-mode.c b/drivers/ide/ide-xfer-mode.c
new file mode 100644
index 000000000000..6910f6a257e8
--- /dev/null
+++ b/drivers/ide/ide-xfer-mode.c
@@ -0,0 +1,246 @@
1#include <linux/types.h>
2#include <linux/string.h>
3#include <linux/kernel.h>
4#include <linux/interrupt.h>
5#include <linux/ide.h>
6#include <linux/bitops.h>
7
8static const char *udma_str[] =
9 { "UDMA/16", "UDMA/25", "UDMA/33", "UDMA/44",
10 "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" };
11static const char *mwdma_str[] =
12 { "MWDMA0", "MWDMA1", "MWDMA2" };
13static const char *swdma_str[] =
14 { "SWDMA0", "SWDMA1", "SWDMA2" };
15static const char *pio_str[] =
16 { "PIO0", "PIO1", "PIO2", "PIO3", "PIO4", "PIO5" };
17
18/**
19 * ide_xfer_verbose - return IDE mode names
20 * @mode: transfer mode
21 *
22 * Returns a constant string giving the name of the mode
23 * requested.
24 */
25
26const char *ide_xfer_verbose(u8 mode)
27{
28 const char *s;
29 u8 i = mode & 0xf;
30
31 if (mode >= XFER_UDMA_0 && mode <= XFER_UDMA_7)
32 s = udma_str[i];
33 else if (mode >= XFER_MW_DMA_0 && mode <= XFER_MW_DMA_2)
34 s = mwdma_str[i];
35 else if (mode >= XFER_SW_DMA_0 && mode <= XFER_SW_DMA_2)
36 s = swdma_str[i];
37 else if (mode >= XFER_PIO_0 && mode <= XFER_PIO_5)
38 s = pio_str[i & 0x7];
39 else if (mode == XFER_PIO_SLOW)
40 s = "PIO SLOW";
41 else
42 s = "XFER ERROR";
43
44 return s;
45}
46EXPORT_SYMBOL(ide_xfer_verbose);
47
48/**
49 * ide_get_best_pio_mode - get PIO mode from drive
50 * @drive: drive to consider
51 * @mode_wanted: preferred mode
52 * @max_mode: highest allowed mode
53 *
54 * This routine returns the recommended PIO settings for a given drive,
55 * based on the drive->id information and the ide_pio_blacklist[].
56 *
57 * Drive PIO mode is auto-selected if 255 is passed as mode_wanted.
58 * This is used by most chipset support modules when "auto-tuning".
59 */
60
61u8 ide_get_best_pio_mode(ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
62{
63 u16 *id = drive->id;
64 int pio_mode = -1, overridden = 0;
65
66 if (mode_wanted != 255)
67 return min_t(u8, mode_wanted, max_mode);
68
69 if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0)
70 pio_mode = ide_scan_pio_blacklist((char *)&id[ATA_ID_PROD]);
71
72 if (pio_mode != -1) {
73 printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name);
74 } else {
75 pio_mode = id[ATA_ID_OLD_PIO_MODES] >> 8;
76 if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */
77 pio_mode = 2;
78 overridden = 1;
79 }
80
81 if (id[ATA_ID_FIELD_VALID] & 2) { /* ATA2? */
82 if (ata_id_has_iordy(id)) {
83 if (id[ATA_ID_PIO_MODES] & 7) {
84 overridden = 0;
85 if (id[ATA_ID_PIO_MODES] & 4)
86 pio_mode = 5;
87 else if (id[ATA_ID_PIO_MODES] & 2)
88 pio_mode = 4;
89 else
90 pio_mode = 3;
91 }
92 }
93 }
94
95 if (overridden)
96 printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n",
97 drive->name);
98 }
99
100 if (pio_mode > max_mode)
101 pio_mode = max_mode;
102
103 return pio_mode;
104}
105EXPORT_SYMBOL_GPL(ide_get_best_pio_mode);
106
107int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
108{
109 ide_hwif_t *hwif = drive->hwif;
110 const struct ide_port_ops *port_ops = hwif->port_ops;
111
112 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
113 return 0;
114
115 if (port_ops == NULL || port_ops->set_pio_mode == NULL)
116 return -1;
117
118 /*
119 * TODO: temporary hack for some legacy host drivers that didn't
120 * set transfer mode on the device in ->set_pio_mode method...
121 */
122 if (port_ops->set_dma_mode == NULL) {
123 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
124 return 0;
125 }
126
127 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
128 if (ide_config_drive_speed(drive, mode))
129 return -1;
130 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
131 return 0;
132 } else {
133 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
134 return ide_config_drive_speed(drive, mode);
135 }
136}
137
138int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
139{
140 ide_hwif_t *hwif = drive->hwif;
141 const struct ide_port_ops *port_ops = hwif->port_ops;
142
143 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
144 return 0;
145
146 if (port_ops == NULL || port_ops->set_dma_mode == NULL)
147 return -1;
148
149 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
150 if (ide_config_drive_speed(drive, mode))
151 return -1;
152 port_ops->set_dma_mode(drive, mode);
153 return 0;
154 } else {
155 port_ops->set_dma_mode(drive, mode);
156 return ide_config_drive_speed(drive, mode);
157 }
158}
159EXPORT_SYMBOL_GPL(ide_set_dma_mode);
160
161/* req_pio == "255" for auto-tune */
162void ide_set_pio(ide_drive_t *drive, u8 req_pio)
163{
164 ide_hwif_t *hwif = drive->hwif;
165 const struct ide_port_ops *port_ops = hwif->port_ops;
166 u8 host_pio, pio;
167
168 if (port_ops == NULL || port_ops->set_pio_mode == NULL ||
169 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
170 return;
171
172 BUG_ON(hwif->pio_mask == 0x00);
173
174 host_pio = fls(hwif->pio_mask) - 1;
175
176 pio = ide_get_best_pio_mode(drive, req_pio, host_pio);
177
178 /*
179 * TODO:
180 * - report device max PIO mode
181 * - check req_pio != 255 against device max PIO mode
182 */
183 printk(KERN_DEBUG "%s: host max PIO%d wanted PIO%d%s selected PIO%d\n",
184 drive->name, host_pio, req_pio,
185 req_pio == 255 ? "(auto-tune)" : "", pio);
186
187 (void)ide_set_pio_mode(drive, XFER_PIO_0 + pio);
188}
189EXPORT_SYMBOL_GPL(ide_set_pio);
190
191/**
192 * ide_rate_filter - filter transfer mode
193 * @drive: IDE device
194 * @speed: desired speed
195 *
196 * Given the available transfer modes this function returns
197 * the best available speed at or below the speed requested.
198 *
199 * TODO: check device PIO capabilities
200 */
201
202static u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
203{
204 ide_hwif_t *hwif = drive->hwif;
205 u8 mode = ide_find_dma_mode(drive, speed);
206
207 if (mode == 0) {
208 if (hwif->pio_mask)
209 mode = fls(hwif->pio_mask) - 1 + XFER_PIO_0;
210 else
211 mode = XFER_PIO_4;
212 }
213
214/* printk("%s: mode 0x%02x, speed 0x%02x\n", __func__, mode, speed); */
215
216 return min(speed, mode);
217}
218
219/**
220 * ide_set_xfer_rate - set transfer rate
221 * @drive: drive to set
222 * @rate: speed to attempt to set
223 *
224 * General helper for setting the speed of an IDE device. This
225 * function knows about user enforced limits from the configuration
226 * which ->set_pio_mode/->set_dma_mode does not.
227 */
228
229int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
230{
231 ide_hwif_t *hwif = drive->hwif;
232 const struct ide_port_ops *port_ops = hwif->port_ops;
233
234 if (port_ops == NULL || port_ops->set_dma_mode == NULL ||
235 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
236 return -1;
237
238 rate = ide_rate_filter(drive, rate);
239
240 BUG_ON(rate < XFER_PIO_0);
241
242 if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5)
243 return ide_set_pio_mode(drive, rate);
244
245 return ide_set_dma_mode(drive, rate);
246}
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 0920e3b0c962..92c9b90931e7 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -62,160 +62,6 @@
62 62
63struct class *ide_port_class; 63struct class *ide_port_class;
64 64
65/*
66 * Locks for IDE setting functionality
67 */
68
69DEFINE_MUTEX(ide_setting_mtx);
70
71ide_devset_get(io_32bit, io_32bit);
72
73static int set_io_32bit(ide_drive_t *drive, int arg)
74{
75 if (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT)
76 return -EPERM;
77
78 if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1))
79 return -EINVAL;
80
81 drive->io_32bit = arg;
82
83 return 0;
84}
85
86ide_devset_get_flag(ksettings, IDE_DFLAG_KEEP_SETTINGS);
87
88static int set_ksettings(ide_drive_t *drive, int arg)
89{
90 if (arg < 0 || arg > 1)
91 return -EINVAL;
92
93 if (arg)
94 drive->dev_flags |= IDE_DFLAG_KEEP_SETTINGS;
95 else
96 drive->dev_flags &= ~IDE_DFLAG_KEEP_SETTINGS;
97
98 return 0;
99}
100
101ide_devset_get_flag(using_dma, IDE_DFLAG_USING_DMA);
102
103static int set_using_dma(ide_drive_t *drive, int arg)
104{
105#ifdef CONFIG_BLK_DEV_IDEDMA
106 int err = -EPERM;
107
108 if (arg < 0 || arg > 1)
109 return -EINVAL;
110
111 if (ata_id_has_dma(drive->id) == 0)
112 goto out;
113
114 if (drive->hwif->dma_ops == NULL)
115 goto out;
116
117 err = 0;
118
119 if (arg) {
120 if (ide_set_dma(drive))
121 err = -EIO;
122 } else
123 ide_dma_off(drive);
124
125out:
126 return err;
127#else
128 if (arg < 0 || arg > 1)
129 return -EINVAL;
130
131 return -EPERM;
132#endif
133}
134
135/*
136 * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away
137 */
138static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio)
139{
140 switch (req_pio) {
141 case 202:
142 case 201:
143 case 200:
144 case 102:
145 case 101:
146 case 100:
147 return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0;
148 case 9:
149 case 8:
150 return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0;
151 case 7:
152 case 6:
153 return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0;
154 default:
155 return 0;
156 }
157}
158
159static int set_pio_mode(ide_drive_t *drive, int arg)
160{
161 ide_hwif_t *hwif = drive->hwif;
162 const struct ide_port_ops *port_ops = hwif->port_ops;
163
164 if (arg < 0 || arg > 255)
165 return -EINVAL;
166
167 if (port_ops == NULL || port_ops->set_pio_mode == NULL ||
168 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
169 return -ENOSYS;
170
171 if (set_pio_mode_abuse(drive->hwif, arg)) {
172 if (arg == 8 || arg == 9) {
173 unsigned long flags;
174
175 /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */
176 spin_lock_irqsave(&hwif->lock, flags);
177 port_ops->set_pio_mode(drive, arg);
178 spin_unlock_irqrestore(&hwif->lock, flags);
179 } else
180 port_ops->set_pio_mode(drive, arg);
181 } else {
182 int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
183
184 ide_set_pio(drive, arg);
185
186 if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) {
187 if (keep_dma)
188 ide_dma_on(drive);
189 }
190 }
191
192 return 0;
193}
194
195ide_devset_get_flag(unmaskirq, IDE_DFLAG_UNMASK);
196
197static int set_unmaskirq(ide_drive_t *drive, int arg)
198{
199 if (drive->dev_flags & IDE_DFLAG_NO_UNMASK)
200 return -EPERM;
201
202 if (arg < 0 || arg > 1)
203 return -EINVAL;
204
205 if (arg)
206 drive->dev_flags |= IDE_DFLAG_UNMASK;
207 else
208 drive->dev_flags &= ~IDE_DFLAG_UNMASK;
209
210 return 0;
211}
212
213ide_ext_devset_rw_sync(io_32bit, io_32bit);
214ide_ext_devset_rw_sync(keepsettings, ksettings);
215ide_ext_devset_rw_sync(unmaskirq, unmaskirq);
216ide_ext_devset_rw_sync(using_dma, using_dma);
217__IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode);
218
219/** 65/**
220 * ide_device_get - get an additional reference to a ide_drive_t 66 * ide_device_get - get an additional reference to a ide_drive_t
221 * @drive: device to get a reference to 67 * @drive: device to get a reference to
@@ -527,6 +373,8 @@ static int __init ide_init(void)
527 goto out_port_class; 373 goto out_port_class;
528 } 374 }
529 375
376 ide_acpi_init();
377
530 proc_ide_create(); 378 proc_ide_create();
531 379
532 return 0; 380 return 0;
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c
index 13b8153112ed..6b9fc950b4af 100644
--- a/drivers/ide/it821x.c
+++ b/drivers/ide/it821x.c
@@ -603,7 +603,7 @@ static void it8212_disable_raid(struct pci_dev *dev)
603 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); 603 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
604} 604}
605 605
606static unsigned int init_chipset_it821x(struct pci_dev *dev) 606static int init_chipset_it821x(struct pci_dev *dev)
607{ 607{
608 u8 conf; 608 u8 conf;
609 static char *mode[2] = { "pass through", "smart" }; 609 static char *mode[2] = { "pass through", "smart" };
diff --git a/drivers/ide/ns87415.c b/drivers/ide/ns87415.c
index 83643ed9a426..ea48a3ee8063 100644
--- a/drivers/ide/ns87415.c
+++ b/drivers/ide/ns87415.c
@@ -286,9 +286,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
286 } 286 }
287 287
288 if (!using_inta) 288 if (!using_inta)
289 hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); 289 hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel);
290 else if (!hwif->irq && hwif->mate && hwif->mate->irq)
291 hwif->irq = hwif->mate->irq; /* share IRQ with mate */
292 290
293 if (!hwif->dma_base) 291 if (!hwif->dma_base)
294 return; 292 return;
diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c
index f21290c4b447..b68906c3c17e 100644
--- a/drivers/ide/pdc202xx_new.c
+++ b/drivers/ide/pdc202xx_new.c
@@ -325,7 +325,7 @@ static void apple_kiwi_init(struct pci_dev *pdev)
325} 325}
326#endif /* CONFIG_PPC_PMAC */ 326#endif /* CONFIG_PPC_PMAC */
327 327
328static unsigned int init_chipset_pdcnew(struct pci_dev *dev) 328static int init_chipset_pdcnew(struct pci_dev *dev)
329{ 329{
330 const char *name = DRV_NAME; 330 const char *name = DRV_NAME;
331 unsigned long dma_base = pci_resource_start(dev, 4); 331 unsigned long dma_base = pci_resource_start(dev, 4);
@@ -444,7 +444,7 @@ static unsigned int init_chipset_pdcnew(struct pci_dev *dev)
444#endif 444#endif
445 445
446 out: 446 out:
447 return dev->irq; 447 return 0;
448} 448}
449 449
450static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) 450static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev)
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index 97193323aebf..cba66ebce4e3 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -264,7 +264,7 @@ static void pdc202xx_dma_timeout(ide_drive_t *drive)
264 ide_dma_timeout(drive); 264 ide_dma_timeout(drive);
265} 265}
266 266
267static unsigned int init_chipset_pdc202xx(struct pci_dev *dev) 267static int init_chipset_pdc202xx(struct pci_dev *dev)
268{ 268{
269 unsigned long dmabase = pci_resource_start(dev, 4); 269 unsigned long dmabase = pci_resource_start(dev, 4);
270 u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; 270 u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0;
@@ -290,7 +290,7 @@ static unsigned int init_chipset_pdc202xx(struct pci_dev *dev)
290 printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN"); 290 printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN");
291 } 291 }
292out: 292out:
293 return dev->irq; 293 return 0;
294} 294}
295 295
296static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, 296static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c
index f1e2e4ef0d71..2aa699933064 100644
--- a/drivers/ide/piix.c
+++ b/drivers/ide/piix.c
@@ -204,7 +204,7 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
204 * out to be nice and simple. 204 * out to be nice and simple.
205 */ 205 */
206 206
207static unsigned int init_chipset_ich(struct pci_dev *dev) 207static int init_chipset_ich(struct pci_dev *dev)
208{ 208{
209 u32 extra = 0; 209 u32 extra = 0;
210 210
@@ -318,19 +318,12 @@ static const struct ide_port_ops ich_port_ops = {
318 .cable_detect = piix_cable_detect, 318 .cable_detect = piix_cable_detect,
319}; 319};
320 320
321#ifndef CONFIG_IA64
322 #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS
323#else
324 #define IDE_HFLAGS_PIIX 0
325#endif
326
327#define DECLARE_PIIX_DEV(udma) \ 321#define DECLARE_PIIX_DEV(udma) \
328 { \ 322 { \
329 .name = DRV_NAME, \ 323 .name = DRV_NAME, \
330 .init_hwif = init_hwif_piix, \ 324 .init_hwif = init_hwif_piix, \
331 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 325 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \
332 .port_ops = &piix_port_ops, \ 326 .port_ops = &piix_port_ops, \
333 .host_flags = IDE_HFLAGS_PIIX, \
334 .pio_mask = ATA_PIO4, \ 327 .pio_mask = ATA_PIO4, \
335 .swdma_mask = ATA_SWDMA2_ONLY, \ 328 .swdma_mask = ATA_SWDMA2_ONLY, \
336 .mwdma_mask = ATA_MWDMA12_ONLY, \ 329 .mwdma_mask = ATA_MWDMA12_ONLY, \
@@ -344,7 +337,6 @@ static const struct ide_port_ops ich_port_ops = {
344 .init_hwif = init_hwif_piix, \ 337 .init_hwif = init_hwif_piix, \
345 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 338 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \
346 .port_ops = &ich_port_ops, \ 339 .port_ops = &ich_port_ops, \
347 .host_flags = IDE_HFLAGS_PIIX, \
348 .pio_mask = ATA_PIO4, \ 340 .pio_mask = ATA_PIO4, \
349 .swdma_mask = ATA_SWDMA2_ONLY, \ 341 .swdma_mask = ATA_SWDMA2_ONLY, \
350 .mwdma_mask = ATA_MWDMA12_ONLY, \ 342 .mwdma_mask = ATA_MWDMA12_ONLY, \
@@ -360,8 +352,7 @@ static const struct ide_port_info piix_pci_info[] __devinitdata = {
360 */ 352 */
361 .name = DRV_NAME, 353 .name = DRV_NAME,
362 .enablebits = {{0x6d,0xc0,0x80}, {0x6d,0xc0,0xc0}}, 354 .enablebits = {{0x6d,0xc0,0x80}, {0x6d,0xc0,0xc0}},
363 .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_NO_DMA | 355 .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_NO_DMA,
364 IDE_HFLAGS_PIIX,
365 .pio_mask = ATA_PIO4, 356 .pio_mask = ATA_PIO4,
366 /* This is a painful system best to let it self tune for now */ 357 /* This is a painful system best to let it self tune for now */
367 }, 358 },
diff --git a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c
index 382102ba467b..b6554ef92716 100644
--- a/drivers/ide/serverworks.c
+++ b/drivers/ide/serverworks.c
@@ -175,7 +175,7 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed)
175 pci_write_config_byte(dev, 0x54, ultra_enable); 175 pci_write_config_byte(dev, 0x54, ultra_enable);
176} 176}
177 177
178static unsigned int init_chipset_svwks(struct pci_dev *dev) 178static int init_chipset_svwks(struct pci_dev *dev)
179{ 179{
180 unsigned int reg; 180 unsigned int reg;
181 u8 btr; 181 u8 btr;
@@ -270,7 +270,7 @@ static unsigned int init_chipset_svwks(struct pci_dev *dev)
270 pci_write_config_byte(dev, 0x5A, btr); 270 pci_write_config_byte(dev, 0x5A, btr);
271 } 271 }
272 272
273 return dev->irq; 273 return 0;
274} 274}
275 275
276static u8 ata66_svwks_svwks(ide_hwif_t *hwif) 276static u8 ata66_svwks_svwks(ide_hwif_t *hwif)
@@ -353,14 +353,11 @@ static const struct ide_port_ops svwks_port_ops = {
353 .cable_detect = svwks_cable_detect, 353 .cable_detect = svwks_cable_detect,
354}; 354};
355 355
356#define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS
357
358static const struct ide_port_info serverworks_chipsets[] __devinitdata = { 356static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
359 { /* 0: OSB4 */ 357 { /* 0: OSB4 */
360 .name = DRV_NAME, 358 .name = DRV_NAME,
361 .init_chipset = init_chipset_svwks, 359 .init_chipset = init_chipset_svwks,
362 .port_ops = &osb4_port_ops, 360 .port_ops = &osb4_port_ops,
363 .host_flags = IDE_HFLAGS_SVWKS,
364 .pio_mask = ATA_PIO4, 361 .pio_mask = ATA_PIO4,
365 .mwdma_mask = ATA_MWDMA2, 362 .mwdma_mask = ATA_MWDMA2,
366 .udma_mask = 0x00, /* UDMA is problematic on OSB4 */ 363 .udma_mask = 0x00, /* UDMA is problematic on OSB4 */
@@ -369,7 +366,6 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
369 .name = DRV_NAME, 366 .name = DRV_NAME,
370 .init_chipset = init_chipset_svwks, 367 .init_chipset = init_chipset_svwks,
371 .port_ops = &svwks_port_ops, 368 .port_ops = &svwks_port_ops,
372 .host_flags = IDE_HFLAGS_SVWKS,
373 .pio_mask = ATA_PIO4, 369 .pio_mask = ATA_PIO4,
374 .mwdma_mask = ATA_MWDMA2, 370 .mwdma_mask = ATA_MWDMA2,
375 .udma_mask = ATA_UDMA5, 371 .udma_mask = ATA_UDMA5,
@@ -378,7 +374,6 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
378 .name = DRV_NAME, 374 .name = DRV_NAME,
379 .init_chipset = init_chipset_svwks, 375 .init_chipset = init_chipset_svwks,
380 .port_ops = &svwks_port_ops, 376 .port_ops = &svwks_port_ops,
381 .host_flags = IDE_HFLAGS_SVWKS,
382 .pio_mask = ATA_PIO4, 377 .pio_mask = ATA_PIO4,
383 .mwdma_mask = ATA_MWDMA2, 378 .mwdma_mask = ATA_MWDMA2,
384 .udma_mask = ATA_UDMA5, 379 .udma_mask = ATA_UDMA5,
@@ -387,7 +382,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
387 .name = DRV_NAME, 382 .name = DRV_NAME,
388 .init_chipset = init_chipset_svwks, 383 .init_chipset = init_chipset_svwks,
389 .port_ops = &svwks_port_ops, 384 .port_ops = &svwks_port_ops,
390 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, 385 .host_flags = IDE_HFLAG_SINGLE,
391 .pio_mask = ATA_PIO4, 386 .pio_mask = ATA_PIO4,
392 .mwdma_mask = ATA_MWDMA2, 387 .mwdma_mask = ATA_MWDMA2,
393 .udma_mask = ATA_UDMA5, 388 .udma_mask = ATA_UDMA5,
@@ -396,7 +391,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
396 .name = DRV_NAME, 391 .name = DRV_NAME,
397 .init_chipset = init_chipset_svwks, 392 .init_chipset = init_chipset_svwks,
398 .port_ops = &svwks_port_ops, 393 .port_ops = &svwks_port_ops,
399 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, 394 .host_flags = IDE_HFLAG_SINGLE,
400 .pio_mask = ATA_PIO4, 395 .pio_mask = ATA_PIO4,
401 .mwdma_mask = ATA_MWDMA2, 396 .mwdma_mask = ATA_MWDMA2,
402 .udma_mask = ATA_UDMA5, 397 .udma_mask = ATA_UDMA5,
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index e85d1ed29c2a..24bc884826fc 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -305,7 +305,6 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
305 * @dev: PCI device holding interface 305 * @dev: PCI device holding interface
306 * @d: IDE port info 306 * @d: IDE port info
307 * @port: port number 307 * @port: port number
308 * @irq: PCI IRQ
309 * @hw: hw_regs_t instance corresponding to this port 308 * @hw: hw_regs_t instance corresponding to this port
310 * 309 *
311 * Perform the initial set up for the hardware interface structure. This 310 * Perform the initial set up for the hardware interface structure. This
@@ -316,7 +315,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
316 */ 315 */
317 316
318static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, 317static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
319 unsigned int port, int irq, hw_regs_t *hw) 318 unsigned int port, hw_regs_t *hw)
320{ 319{
321 unsigned long ctl = 0, base = 0; 320 unsigned long ctl = 0, base = 0;
322 321
@@ -344,7 +343,6 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
344 } 343 }
345 344
346 memset(hw, 0, sizeof(*hw)); 345 memset(hw, 0, sizeof(*hw));
347 hw->irq = irq;
348 hw->dev = &dev->dev; 346 hw->dev = &dev->dev;
349 hw->chipset = d->chipset ? d->chipset : ide_pci; 347 hw->chipset = d->chipset ? d->chipset : ide_pci;
350 ide_std_init_ports(hw, base, ctl | 2); 348 ide_std_init_ports(hw, base, ctl | 2);
@@ -448,7 +446,6 @@ out:
448 * ide_pci_setup_ports - configure ports/devices on PCI IDE 446 * ide_pci_setup_ports - configure ports/devices on PCI IDE
449 * @dev: PCI device 447 * @dev: PCI device
450 * @d: IDE port info 448 * @d: IDE port info
451 * @pciirq: IRQ line
452 * @hw: hw_regs_t instances corresponding to this PCI IDE device 449 * @hw: hw_regs_t instances corresponding to this PCI IDE device
453 * @hws: hw_regs_t pointers table to update 450 * @hws: hw_regs_t pointers table to update
454 * 451 *
@@ -462,7 +459,7 @@ out:
462 */ 459 */
463 460
464void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, 461void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d,
465 int pciirq, hw_regs_t *hw, hw_regs_t **hws) 462 hw_regs_t *hw, hw_regs_t **hws)
466{ 463{
467 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; 464 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
468 u8 tmp; 465 u8 tmp;
@@ -481,7 +478,7 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d,
481 continue; /* port not enabled */ 478 continue; /* port not enabled */
482 } 479 }
483 480
484 if (ide_hw_configure(dev, d, port, pciirq, hw + port)) 481 if (ide_hw_configure(dev, d, port, hw + port))
485 continue; 482 continue;
486 483
487 *(hws + port) = hw + port; 484 *(hws + port) = hw + port;
@@ -524,7 +521,7 @@ static int do_ide_setup_pci_device(struct pci_dev *dev,
524 if (noisy) 521 if (noisy)
525 printk(KERN_INFO "%s %s: not 100%% native mode: will " 522 printk(KERN_INFO "%s %s: not 100%% native mode: will "
526 "probe irqs later\n", d->name, pci_name(dev)); 523 "probe irqs later\n", d->name, pci_name(dev));
527 pciirq = ret; 524 pciirq = 0;
528 } else if (!pciirq && noisy) { 525 } else if (!pciirq && noisy) {
529 printk(KERN_WARNING "%s %s: bad irq (%d): will probe later\n", 526 printk(KERN_WARNING "%s %s: bad irq (%d): will probe later\n",
530 d->name, pci_name(dev), pciirq); 527 d->name, pci_name(dev), pciirq);
@@ -549,7 +546,7 @@ int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
549 if (ret < 0) 546 if (ret < 0)
550 goto out; 547 goto out;
551 548
552 ide_pci_setup_ports(dev, d, 0, &hw[0], &hws[0]); 549 ide_pci_setup_ports(dev, d, &hw[0], &hws[0]);
553 550
554 host = ide_host_alloc(d, hws); 551 host = ide_host_alloc(d, hws);
555 if (host == NULL) { 552 if (host == NULL) {
@@ -568,7 +565,11 @@ int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
568 goto out; 565 goto out;
569 566
570 /* fixup IRQ */ 567 /* fixup IRQ */
571 hw[1].irq = hw[0].irq = ret; 568 if (ide_pci_is_in_compatibility_mode(dev)) {
569 hw[0].irq = pci_get_legacy_ide_irq(dev, 0);
570 hw[1].irq = pci_get_legacy_ide_irq(dev, 1);
571 } else
572 hw[1].irq = hw[0].irq = ret;
572 573
573 ret = ide_host_register(host, d, hws); 574 ret = ide_host_register(host, d, hws);
574 if (ret) 575 if (ret)
@@ -591,7 +592,7 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
591 if (ret < 0) 592 if (ret < 0)
592 goto out; 593 goto out;
593 594
594 ide_pci_setup_ports(pdev[i], d, 0, &hw[i*2], &hws[i*2]); 595 ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]);
595 } 596 }
596 597
597 host = ide_host_alloc(d, hws); 598 host = ide_host_alloc(d, hws);
@@ -619,7 +620,11 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
619 goto out; 620 goto out;
620 621
621 /* fixup IRQ */ 622 /* fixup IRQ */
622 hw[i*2 + 1].irq = hw[i*2].irq = ret; 623 if (ide_pci_is_in_compatibility_mode(pdev[i])) {
624 hw[i*2].irq = pci_get_legacy_ide_irq(pdev[i], 0);
625 hw[i*2 + 1].irq = pci_get_legacy_ide_irq(pdev[i], 1);
626 } else
627 hw[i*2 + 1].irq = hw[i*2].irq = ret;
623 } 628 }
624 629
625 ret = ide_host_register(host, d, hws); 630 ret = ide_host_register(host, d, hws);
diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c
index cb2b352b876b..1811ae9cd843 100644
--- a/drivers/ide/siimage.c
+++ b/drivers/ide/siimage.c
@@ -464,7 +464,7 @@ static void sil_sata_pre_reset(ide_drive_t *drive)
464 * to 133 MHz clocking if the system isn't already set up to do it. 464 * to 133 MHz clocking if the system isn't already set up to do it.
465 */ 465 */
466 466
467static unsigned int init_chipset_siimage(struct pci_dev *dev) 467static int init_chipset_siimage(struct pci_dev *dev)
468{ 468{
469 struct ide_host *host = pci_get_drvdata(dev); 469 struct ide_host *host = pci_get_drvdata(dev);
470 void __iomem *ioaddr = host->host_priv; 470 void __iomem *ioaddr = host->host_priv;
diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c
index 9ec1a4a4432c..afca22beaadf 100644
--- a/drivers/ide/sis5513.c
+++ b/drivers/ide/sis5513.c
@@ -447,7 +447,7 @@ static int __devinit sis_find_family(struct pci_dev *dev)
447 return chipset_family; 447 return chipset_family;
448} 448}
449 449
450static unsigned int init_chipset_sis5513(struct pci_dev *dev) 450static int init_chipset_sis5513(struct pci_dev *dev)
451{ 451{
452 /* Make general config ops here 452 /* Make general config ops here
453 1/ tell IDE channels to operate in Compatibility mode only 453 1/ tell IDE channels to operate in Compatibility mode only
@@ -563,7 +563,7 @@ static const struct ide_port_info sis5513_chipset __devinitdata = {
563 .name = DRV_NAME, 563 .name = DRV_NAME,
564 .init_chipset = init_chipset_sis5513, 564 .init_chipset = init_chipset_sis5513,
565 .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, 565 .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} },
566 .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, 566 .host_flags = IDE_HFLAG_NO_AUTODMA,
567 .pio_mask = ATA_PIO4, 567 .pio_mask = ATA_PIO4,
568 .mwdma_mask = ATA_MWDMA2, 568 .mwdma_mask = ATA_MWDMA2,
569}; 569};
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c
index 6297956507c0..dba213c51baa 100644
--- a/drivers/ide/sl82c105.c
+++ b/drivers/ide/sl82c105.c
@@ -271,7 +271,7 @@ static u8 sl82c105_bridge_revision(struct pci_dev *dev)
271 * channel 0 here at least, but channel 1 has to be enabled by 271 * channel 0 here at least, but channel 1 has to be enabled by
272 * firmware or arch code. We still set both to 16 bits mode. 272 * firmware or arch code. We still set both to 16 bits mode.
273 */ 273 */
274static unsigned int init_chipset_sl82c105(struct pci_dev *dev) 274static int init_chipset_sl82c105(struct pci_dev *dev)
275{ 275{
276 u32 val; 276 u32 val;
277 277
@@ -281,7 +281,7 @@ static unsigned int init_chipset_sl82c105(struct pci_dev *dev)
281 val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; 281 val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16;
282 pci_write_config_dword(dev, 0x40, val); 282 pci_write_config_dword(dev, 0x40, val);
283 283
284 return dev->irq; 284 return 0;
285} 285}
286 286
287static const struct ide_port_ops sl82c105_port_ops = { 287static const struct ide_port_ops sl82c105_port_ops = {
diff --git a/drivers/ide/slc90e66.c b/drivers/ide/slc90e66.c
index 40b4b94a4288..f55d7d6313e8 100644
--- a/drivers/ide/slc90e66.c
+++ b/drivers/ide/slc90e66.c
@@ -136,7 +136,6 @@ static const struct ide_port_info slc90e66_chipset __devinitdata = {
136 .name = DRV_NAME, 136 .name = DRV_NAME,
137 .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, 137 .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} },
138 .port_ops = &slc90e66_port_ops, 138 .port_ops = &slc90e66_port_ops,
139 .host_flags = IDE_HFLAG_LEGACY_IRQS,
140 .pio_mask = ATA_PIO4, 139 .pio_mask = ATA_PIO4,
141 .swdma_mask = ATA_SWDMA2_ONLY, 140 .swdma_mask = ATA_SWDMA2_ONLY,
142 .mwdma_mask = ATA_MWDMA12_ONLY, 141 .mwdma_mask = ATA_MWDMA12_ONLY,
diff --git a/drivers/ide/trm290.c b/drivers/ide/trm290.c
index b6a1285a4021..1c09e549c423 100644
--- a/drivers/ide/trm290.c
+++ b/drivers/ide/trm290.c
@@ -277,9 +277,6 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif)
277 if (reg & 0x10) 277 if (reg & 0x10)
278 /* legacy mode */ 278 /* legacy mode */
279 hwif->irq = hwif->channel ? 15 : 14; 279 hwif->irq = hwif->channel ? 15 : 14;
280 else if (!hwif->irq && hwif->mate && hwif->mate->irq)
281 /* sharing IRQ with mate */
282 hwif->irq = hwif->mate->irq;
283 280
284#if 1 281#if 1
285 { 282 {
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
index 6092fe3f409d..3ff7231e4858 100644
--- a/drivers/ide/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c
@@ -267,7 +267,7 @@ static void via_cable_detect(struct via82cxxx_dev *vdev, u32 u)
267 * and initialize its drive independent registers. 267 * and initialize its drive independent registers.
268 */ 268 */
269 269
270static unsigned int init_chipset_via82cxxx(struct pci_dev *dev) 270static int init_chipset_via82cxxx(struct pci_dev *dev)
271{ 271{
272 struct ide_host *host = pci_get_drvdata(dev); 272 struct ide_host *host = pci_get_drvdata(dev);
273 struct via82cxxx_dev *vdev = host->host_priv; 273 struct via82cxxx_dev *vdev = host->host_priv;
@@ -443,16 +443,6 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i
443 if ((via_config->flags & VIA_NO_UNMASK) == 0) 443 if ((via_config->flags & VIA_NO_UNMASK) == 0)
444 d.host_flags |= IDE_HFLAG_UNMASK_IRQS; 444 d.host_flags |= IDE_HFLAG_UNMASK_IRQS;
445 445
446#ifdef CONFIG_PPC_CHRP
447 if (machine_is(chrp) && _chrp_type == _CHRP_Pegasos)
448 d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS;
449#endif
450
451#ifdef CONFIG_AMIGAONE
452 if (machine_is(amigaone))
453 d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS;
454#endif
455
456 d.udma_mask = via_config->udma_mask; 446 d.udma_mask = via_config->udma_mask;
457 447
458 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); 448 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index a01b4488208b..4a65b96db2c8 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -2490,12 +2490,14 @@ static int nes_disconnect(struct nes_qp *nesqp, int abrupt)
2490 int ret = 0; 2490 int ret = 0;
2491 struct nes_vnic *nesvnic; 2491 struct nes_vnic *nesvnic;
2492 struct nes_device *nesdev; 2492 struct nes_device *nesdev;
2493 struct nes_ib_device *nesibdev;
2493 2494
2494 nesvnic = to_nesvnic(nesqp->ibqp.device); 2495 nesvnic = to_nesvnic(nesqp->ibqp.device);
2495 if (!nesvnic) 2496 if (!nesvnic)
2496 return -EINVAL; 2497 return -EINVAL;
2497 2498
2498 nesdev = nesvnic->nesdev; 2499 nesdev = nesvnic->nesdev;
2500 nesibdev = nesvnic->nesibdev;
2499 2501
2500 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n", 2502 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
2501 atomic_read(&nesvnic->netdev->refcnt)); 2503 atomic_read(&nesvnic->netdev->refcnt));
@@ -2507,6 +2509,8 @@ static int nes_disconnect(struct nes_qp *nesqp, int abrupt)
2507 } else { 2509 } else {
2508 /* Need to free the Last Streaming Mode Message */ 2510 /* Need to free the Last Streaming Mode Message */
2509 if (nesqp->ietf_frame) { 2511 if (nesqp->ietf_frame) {
2512 if (nesqp->lsmm_mr)
2513 nesibdev->ibdev.dereg_mr(nesqp->lsmm_mr);
2510 pci_free_consistent(nesdev->pcidev, 2514 pci_free_consistent(nesdev->pcidev,
2511 nesqp->private_data_len+sizeof(struct ietf_mpa_frame), 2515 nesqp->private_data_len+sizeof(struct ietf_mpa_frame),
2512 nesqp->ietf_frame, nesqp->ietf_frame_pbase); 2516 nesqp->ietf_frame, nesqp->ietf_frame_pbase);
@@ -2543,6 +2547,12 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2543 u32 crc_value; 2547 u32 crc_value;
2544 int ret; 2548 int ret;
2545 int passive_state; 2549 int passive_state;
2550 struct nes_ib_device *nesibdev;
2551 struct ib_mr *ibmr = NULL;
2552 struct ib_phys_buf ibphysbuf;
2553 struct nes_pd *nespd;
2554
2555
2546 2556
2547 ibqp = nes_get_qp(cm_id->device, conn_param->qpn); 2557 ibqp = nes_get_qp(cm_id->device, conn_param->qpn);
2548 if (!ibqp) 2558 if (!ibqp)
@@ -2601,6 +2611,26 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2601 if (cm_id->remote_addr.sin_addr.s_addr != 2611 if (cm_id->remote_addr.sin_addr.s_addr !=
2602 cm_id->local_addr.sin_addr.s_addr) { 2612 cm_id->local_addr.sin_addr.s_addr) {
2603 u64temp = (unsigned long)nesqp; 2613 u64temp = (unsigned long)nesqp;
2614 nesibdev = nesvnic->nesibdev;
2615 nespd = nesqp->nespd;
2616 ibphysbuf.addr = nesqp->ietf_frame_pbase;
2617 ibphysbuf.size = conn_param->private_data_len +
2618 sizeof(struct ietf_mpa_frame);
2619 ibmr = nesibdev->ibdev.reg_phys_mr((struct ib_pd *)nespd,
2620 &ibphysbuf, 1,
2621 IB_ACCESS_LOCAL_WRITE,
2622 (u64 *)&nesqp->ietf_frame);
2623 if (!ibmr) {
2624 nes_debug(NES_DBG_CM, "Unable to register memory region"
2625 "for lSMM for cm_node = %p \n",
2626 cm_node);
2627 return -ENOMEM;
2628 }
2629
2630 ibmr->pd = &nespd->ibpd;
2631 ibmr->device = nespd->ibpd.device;
2632 nesqp->lsmm_mr = ibmr;
2633
2604 u64temp |= NES_SW_CONTEXT_ALIGN>>1; 2634 u64temp |= NES_SW_CONTEXT_ALIGN>>1;
2605 set_wqe_64bit_value(wqe->wqe_words, 2635 set_wqe_64bit_value(wqe->wqe_words,
2606 NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX, 2636 NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX,
@@ -2611,14 +2641,13 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2611 wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = 2641 wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] =
2612 cpu_to_le32(conn_param->private_data_len + 2642 cpu_to_le32(conn_param->private_data_len +
2613 sizeof(struct ietf_mpa_frame)); 2643 sizeof(struct ietf_mpa_frame));
2614 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] = 2644 set_wqe_64bit_value(wqe->wqe_words,
2615 cpu_to_le32((u32)nesqp->ietf_frame_pbase); 2645 NES_IWARP_SQ_WQE_FRAG0_LOW_IDX,
2616 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] = 2646 (u64)nesqp->ietf_frame);
2617 cpu_to_le32((u32)((u64)nesqp->ietf_frame_pbase >> 32));
2618 wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] = 2647 wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] =
2619 cpu_to_le32(conn_param->private_data_len + 2648 cpu_to_le32(conn_param->private_data_len +
2620 sizeof(struct ietf_mpa_frame)); 2649 sizeof(struct ietf_mpa_frame));
2621 wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0; 2650 wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = ibmr->lkey;
2622 2651
2623 nesqp->nesqp_context->ird_ord_sizes |= 2652 nesqp->nesqp_context->ird_ord_sizes |=
2624 cpu_to_le32(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | 2653 cpu_to_le32(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT |
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index 4fdb72454f94..d93a6562817c 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -1360,8 +1360,10 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1360 NES_QPCONTEXT_MISC_RQ_SIZE_SHIFT); 1360 NES_QPCONTEXT_MISC_RQ_SIZE_SHIFT);
1361 nesqp->nesqp_context->misc |= cpu_to_le32((u32)nesqp->hwqp.sq_encoded_size << 1361 nesqp->nesqp_context->misc |= cpu_to_le32((u32)nesqp->hwqp.sq_encoded_size <<
1362 NES_QPCONTEXT_MISC_SQ_SIZE_SHIFT); 1362 NES_QPCONTEXT_MISC_SQ_SIZE_SHIFT);
1363 if (!udata) {
1363 nesqp->nesqp_context->misc |= cpu_to_le32(NES_QPCONTEXT_MISC_PRIV_EN); 1364 nesqp->nesqp_context->misc |= cpu_to_le32(NES_QPCONTEXT_MISC_PRIV_EN);
1364 nesqp->nesqp_context->misc |= cpu_to_le32(NES_QPCONTEXT_MISC_FAST_REGISTER_EN); 1365 nesqp->nesqp_context->misc |= cpu_to_le32(NES_QPCONTEXT_MISC_FAST_REGISTER_EN);
1366 }
1365 nesqp->nesqp_context->cqs = cpu_to_le32(nesqp->nesscq->hw_cq.cq_number + 1367 nesqp->nesqp_context->cqs = cpu_to_le32(nesqp->nesscq->hw_cq.cq_number +
1366 ((u32)nesqp->nesrcq->hw_cq.cq_number << 16)); 1368 ((u32)nesqp->nesrcq->hw_cq.cq_number << 16));
1367 u64temp = (u64)nesqp->hwqp.sq_pbase; 1369 u64temp = (u64)nesqp->hwqp.sq_pbase;
diff --git a/drivers/infiniband/hw/nes/nes_verbs.h b/drivers/infiniband/hw/nes/nes_verbs.h
index 6c6b4da5184f..ae0ca9bc83bd 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.h
+++ b/drivers/infiniband/hw/nes/nes_verbs.h
@@ -134,6 +134,7 @@ struct nes_qp {
134 struct ietf_mpa_frame *ietf_frame; 134 struct ietf_mpa_frame *ietf_frame;
135 dma_addr_t ietf_frame_pbase; 135 dma_addr_t ietf_frame_pbase;
136 wait_queue_head_t state_waitq; 136 wait_queue_head_t state_waitq;
137 struct ib_mr *lsmm_mr;
137 unsigned long socket; 138 unsigned long socket;
138 struct nes_hw_qp hwqp; 139 struct nes_hw_qp hwqp;
139 struct work_struct work; 140 struct work_struct work;
diff --git a/drivers/input/joystick/maplecontrol.c b/drivers/input/joystick/maplecontrol.c
index e50047bfe938..77cfde571bd9 100644
--- a/drivers/input/joystick/maplecontrol.c
+++ b/drivers/input/joystick/maplecontrol.c
@@ -3,7 +3,7 @@
3 * Based on drivers/usb/iforce.c 3 * Based on drivers/usb/iforce.c
4 * 4 *
5 * Copyright Yaegashi Takeshi, 2001 5 * Copyright Yaegashi Takeshi, 2001
6 * Adrian McMenamin, 2008 6 * Adrian McMenamin, 2008 - 2009
7 */ 7 */
8 8
9#include <linux/kernel.h> 9#include <linux/kernel.h>
@@ -29,7 +29,7 @@ static void dc_pad_callback(struct mapleq *mq)
29 struct maple_device *mapledev = mq->dev; 29 struct maple_device *mapledev = mq->dev;
30 struct dc_pad *pad = maple_get_drvdata(mapledev); 30 struct dc_pad *pad = maple_get_drvdata(mapledev);
31 struct input_dev *dev = pad->dev; 31 struct input_dev *dev = pad->dev;
32 unsigned char *res = mq->recvbuf; 32 unsigned char *res = mq->recvbuf->buf;
33 33
34 buttons = ~le16_to_cpup((__le16 *)(res + 8)); 34 buttons = ~le16_to_cpup((__le16 *)(res + 8));
35 35
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c
index 22f17a593be7..5aa2361aef95 100644
--- a/drivers/input/keyboard/maple_keyb.c
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * SEGA Dreamcast keyboard driver 2 * SEGA Dreamcast keyboard driver
3 * Based on drivers/usb/usbkbd.c 3 * Based on drivers/usb/usbkbd.c
4 * Copyright YAEGASHI Takeshi, 2001 4 * Copyright (c) YAEGASHI Takeshi, 2001
5 * Porting to 2.6 Copyright Adrian McMenamin, 2007, 2008 5 * Porting to 2.6 Copyright (c) Adrian McMenamin, 2007 - 2009
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@ static DEFINE_MUTEX(maple_keyb_mutex);
33 33
34#define NR_SCANCODES 256 34#define NR_SCANCODES 256
35 35
36MODULE_AUTHOR("YAEGASHI Takeshi, Adrian McMenamin"); 36MODULE_AUTHOR("Adrian McMenamin <adrian@mcmen.demon.co.uk");
37MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver"); 37MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
38MODULE_LICENSE("GPL"); 38MODULE_LICENSE("GPL");
39 39
@@ -115,7 +115,7 @@ static void dc_scan_kbd(struct dc_kbd *kbd)
115 input_event(dev, EV_MSC, MSC_SCAN, code); 115 input_event(dev, EV_MSC, MSC_SCAN, code);
116 input_report_key(dev, keycode, 0); 116 input_report_key(dev, keycode, 0);
117 } else 117 } else
118 printk(KERN_DEBUG "maple_keyb: " 118 dev_dbg(&dev->dev,
119 "Unknown key (scancode %#x) released.", 119 "Unknown key (scancode %#x) released.",
120 code); 120 code);
121 } 121 }
@@ -127,7 +127,7 @@ static void dc_scan_kbd(struct dc_kbd *kbd)
127 input_event(dev, EV_MSC, MSC_SCAN, code); 127 input_event(dev, EV_MSC, MSC_SCAN, code);
128 input_report_key(dev, keycode, 1); 128 input_report_key(dev, keycode, 1);
129 } else 129 } else
130 printk(KERN_DEBUG "maple_keyb: " 130 dev_dbg(&dev->dev,
131 "Unknown key (scancode %#x) pressed.", 131 "Unknown key (scancode %#x) pressed.",
132 code); 132 code);
133 } 133 }
@@ -140,7 +140,7 @@ static void dc_kbd_callback(struct mapleq *mq)
140{ 140{
141 struct maple_device *mapledev = mq->dev; 141 struct maple_device *mapledev = mq->dev;
142 struct dc_kbd *kbd = maple_get_drvdata(mapledev); 142 struct dc_kbd *kbd = maple_get_drvdata(mapledev);
143 unsigned long *buf = mq->recvbuf; 143 unsigned long *buf = (unsigned long *)(mq->recvbuf->buf);
144 144
145 /* 145 /*
146 * We should always get the lock because the only 146 * We should always get the lock because the only
@@ -159,22 +159,27 @@ static void dc_kbd_callback(struct mapleq *mq)
159 159
160static int probe_maple_kbd(struct device *dev) 160static int probe_maple_kbd(struct device *dev)
161{ 161{
162 struct maple_device *mdev = to_maple_dev(dev); 162 struct maple_device *mdev;
163 struct maple_driver *mdrv = to_maple_driver(dev->driver); 163 struct maple_driver *mdrv;
164 int i, error; 164 int i, error;
165 struct dc_kbd *kbd; 165 struct dc_kbd *kbd;
166 struct input_dev *idev; 166 struct input_dev *idev;
167 167
168 if (!(mdev->function & MAPLE_FUNC_KEYBOARD)) 168 mdev = to_maple_dev(dev);
169 return -EINVAL; 169 mdrv = to_maple_driver(dev->driver);
170 170
171 kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); 171 kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL);
172 idev = input_allocate_device(); 172 if (!kbd) {
173 if (!kbd || !idev) {
174 error = -ENOMEM; 173 error = -ENOMEM;
175 goto fail; 174 goto fail;
176 } 175 }
177 176
177 idev = input_allocate_device();
178 if (!idev) {
179 error = -ENOMEM;
180 goto fail_idev_alloc;
181 }
182
178 kbd->dev = idev; 183 kbd->dev = idev;
179 memcpy(kbd->keycode, dc_kbd_keycode, sizeof(kbd->keycode)); 184 memcpy(kbd->keycode, dc_kbd_keycode, sizeof(kbd->keycode));
180 185
@@ -195,7 +200,7 @@ static int probe_maple_kbd(struct device *dev)
195 200
196 error = input_register_device(idev); 201 error = input_register_device(idev);
197 if (error) 202 if (error)
198 goto fail; 203 goto fail_register;
199 204
200 /* Maple polling is locked to VBLANK - which may be just 50/s */ 205 /* Maple polling is locked to VBLANK - which may be just 50/s */
201 maple_getcond_callback(mdev, dc_kbd_callback, HZ/50, 206 maple_getcond_callback(mdev, dc_kbd_callback, HZ/50,
@@ -207,10 +212,12 @@ static int probe_maple_kbd(struct device *dev)
207 212
208 return error; 213 return error;
209 214
210fail: 215fail_register:
216 maple_set_drvdata(mdev, NULL);
211 input_free_device(idev); 217 input_free_device(idev);
218fail_idev_alloc:
212 kfree(kbd); 219 kfree(kbd);
213 maple_set_drvdata(mdev, NULL); 220fail:
214 return error; 221 return error;
215} 222}
216 223
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
index 5c8a1bcf7ca7..e1480fb11de3 100644
--- a/drivers/input/keyboard/sh_keysc.c
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -219,6 +219,8 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
219 pdata->scan_timing, priv->iomem_base + KYCR1_OFFS); 219 pdata->scan_timing, priv->iomem_base + KYCR1_OFFS);
220 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); 220 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS);
221 iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); 221 iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS);
222
223 device_init_wakeup(&pdev->dev, 1);
222 return 0; 224 return 0;
223 err5: 225 err5:
224 free_irq(irq, pdev); 226 free_irq(irq, pdev);
@@ -253,17 +255,33 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev)
253 return 0; 255 return 0;
254} 256}
255 257
258static int sh_keysc_suspend(struct device *dev)
259{
260 struct platform_device *pdev = to_platform_device(dev);
261 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
262 unsigned short value;
263
264 value = ioread16(priv->iomem_base + KYCR1_OFFS);
265
266 if (device_may_wakeup(dev))
267 value |= 0x80;
268 else
269 value &= ~0x80;
256 270
257#define sh_keysc_suspend NULL 271 iowrite16(value, priv->iomem_base + KYCR1_OFFS);
258#define sh_keysc_resume NULL 272 return 0;
273}
274
275static struct dev_pm_ops sh_keysc_dev_pm_ops = {
276 .suspend = sh_keysc_suspend,
277};
259 278
260struct platform_driver sh_keysc_device_driver = { 279struct platform_driver sh_keysc_device_driver = {
261 .probe = sh_keysc_probe, 280 .probe = sh_keysc_probe,
262 .remove = __devexit_p(sh_keysc_remove), 281 .remove = __devexit_p(sh_keysc_remove),
263 .suspend = sh_keysc_suspend,
264 .resume = sh_keysc_resume,
265 .driver = { 282 .driver = {
266 .name = "sh_keysc", 283 .name = "sh_keysc",
284 .pm = &sh_keysc_dev_pm_ops,
267 } 285 }
268}; 286};
269 287
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index ac245e7e96a5..3071a52467ed 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -389,8 +389,7 @@ static void gigaset_freecshw(struct cardstate *cs)
389 389
390static void gigaset_device_release(struct device *dev) 390static void gigaset_device_release(struct device *dev)
391{ 391{
392 struct platform_device *pdev = 392 struct platform_device *pdev = to_platform_device(dev);
393 container_of(dev, struct platform_device, dev);
394 393
395 /* adapted from platform_device_release() in drivers/base/platform.c */ 394 /* adapted from platform_device_release() in drivers/base/platform.c */
396 //FIXME is this actually necessary? 395 //FIXME is this actually necessary?
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index b4d44e571d76..8132533d71f9 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -212,6 +212,9 @@ static void lg_notify(struct virtqueue *vq)
212 hcall(LHCALL_NOTIFY, lvq->config.pfn << PAGE_SHIFT, 0, 0); 212 hcall(LHCALL_NOTIFY, lvq->config.pfn << PAGE_SHIFT, 0, 0);
213} 213}
214 214
215/* An extern declaration inside a C file is bad form. Don't do it. */
216extern void lguest_setup_irq(unsigned int irq);
217
215/* This routine finds the first virtqueue described in the configuration of 218/* This routine finds the first virtqueue described in the configuration of
216 * this device and sets it up. 219 * this device and sets it up.
217 * 220 *
@@ -266,6 +269,9 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
266 goto unmap; 269 goto unmap;
267 } 270 }
268 271
272 /* Make sure the interrupt is allocated. */
273 lguest_setup_irq(lvq->config.irq);
274
269 /* Tell the interrupt for this virtqueue to go to the virtio_ring 275 /* Tell the interrupt for this virtqueue to go to the virtio_ring
270 * interrupt handler. */ 276 * interrupt handler. */
271 /* FIXME: We used to have a flag for the Host to tell us we could use 277 /* FIXME: We used to have a flag for the Host to tell us we could use
diff --git a/drivers/mca/mca-bus.c b/drivers/mca/mca-bus.c
index ef2dbfe74714..ada5ebbaa255 100644
--- a/drivers/mca/mca-bus.c
+++ b/drivers/mca/mca-bus.c
@@ -110,7 +110,7 @@ int __init mca_register_device(int bus, struct mca_device *mca_dev)
110 110
111 mca_dev->dev.parent = &mca_bus->dev; 111 mca_dev->dev.parent = &mca_bus->dev;
112 mca_dev->dev.bus = &mca_bus_type; 112 mca_dev->dev.bus = &mca_bus_type;
113 sprintf (mca_dev->dev.bus_id, "%02d:%02X", bus, mca_dev->slot); 113 dev_set_name(&mca_dev->dev, "%02d:%02X", bus, mca_dev->slot);
114 mca_dev->dma_mask = mca_bus->default_dma_mask; 114 mca_dev->dma_mask = mca_bus->default_dma_mask;
115 mca_dev->dev.dma_mask = &mca_dev->dma_mask; 115 mca_dev->dev.dma_mask = &mca_dev->dma_mask;
116 mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask; 116 mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask;
@@ -151,7 +151,7 @@ struct mca_bus * __devinit mca_attach_bus(int bus)
151 if (!mca_bus) 151 if (!mca_bus)
152 return NULL; 152 return NULL;
153 153
154 sprintf(mca_bus->dev.bus_id,"mca%d",bus); 154 dev_set_name(&mca_bus->dev, "mca%d", bus);
155 sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary"); 155 sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary");
156 if (device_register(&mca_bus->dev)) { 156 if (device_register(&mca_bus->dev)) {
157 kfree(mca_bus); 157 kfree(mca_bus);
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 35bda49796fb..bfefd079a955 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -60,6 +60,7 @@ struct dm_crypt_io {
60}; 60};
61 61
62struct dm_crypt_request { 62struct dm_crypt_request {
63 struct convert_context *ctx;
63 struct scatterlist sg_in; 64 struct scatterlist sg_in;
64 struct scatterlist sg_out; 65 struct scatterlist sg_out;
65}; 66};
@@ -335,6 +336,18 @@ static void crypt_convert_init(struct crypt_config *cc,
335 init_completion(&ctx->restart); 336 init_completion(&ctx->restart);
336} 337}
337 338
339static struct dm_crypt_request *dmreq_of_req(struct crypt_config *cc,
340 struct ablkcipher_request *req)
341{
342 return (struct dm_crypt_request *)((char *)req + cc->dmreq_start);
343}
344
345static struct ablkcipher_request *req_of_dmreq(struct crypt_config *cc,
346 struct dm_crypt_request *dmreq)
347{
348 return (struct ablkcipher_request *)((char *)dmreq - cc->dmreq_start);
349}
350
338static int crypt_convert_block(struct crypt_config *cc, 351static int crypt_convert_block(struct crypt_config *cc,
339 struct convert_context *ctx, 352 struct convert_context *ctx,
340 struct ablkcipher_request *req) 353 struct ablkcipher_request *req)
@@ -345,10 +358,11 @@ static int crypt_convert_block(struct crypt_config *cc,
345 u8 *iv; 358 u8 *iv;
346 int r = 0; 359 int r = 0;
347 360
348 dmreq = (struct dm_crypt_request *)((char *)req + cc->dmreq_start); 361 dmreq = dmreq_of_req(cc, req);
349 iv = (u8 *)ALIGN((unsigned long)(dmreq + 1), 362 iv = (u8 *)ALIGN((unsigned long)(dmreq + 1),
350 crypto_ablkcipher_alignmask(cc->tfm) + 1); 363 crypto_ablkcipher_alignmask(cc->tfm) + 1);
351 364
365 dmreq->ctx = ctx;
352 sg_init_table(&dmreq->sg_in, 1); 366 sg_init_table(&dmreq->sg_in, 1);
353 sg_set_page(&dmreq->sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT, 367 sg_set_page(&dmreq->sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT,
354 bv_in->bv_offset + ctx->offset_in); 368 bv_in->bv_offset + ctx->offset_in);
@@ -395,8 +409,9 @@ static void crypt_alloc_req(struct crypt_config *cc,
395 cc->req = mempool_alloc(cc->req_pool, GFP_NOIO); 409 cc->req = mempool_alloc(cc->req_pool, GFP_NOIO);
396 ablkcipher_request_set_tfm(cc->req, cc->tfm); 410 ablkcipher_request_set_tfm(cc->req, cc->tfm);
397 ablkcipher_request_set_callback(cc->req, CRYPTO_TFM_REQ_MAY_BACKLOG | 411 ablkcipher_request_set_callback(cc->req, CRYPTO_TFM_REQ_MAY_BACKLOG |
398 CRYPTO_TFM_REQ_MAY_SLEEP, 412 CRYPTO_TFM_REQ_MAY_SLEEP,
399 kcryptd_async_done, ctx); 413 kcryptd_async_done,
414 dmreq_of_req(cc, cc->req));
400} 415}
401 416
402/* 417/*
@@ -553,19 +568,22 @@ static void crypt_inc_pending(struct dm_crypt_io *io)
553static void crypt_dec_pending(struct dm_crypt_io *io) 568static void crypt_dec_pending(struct dm_crypt_io *io)
554{ 569{
555 struct crypt_config *cc = io->target->private; 570 struct crypt_config *cc = io->target->private;
571 struct bio *base_bio = io->base_bio;
572 struct dm_crypt_io *base_io = io->base_io;
573 int error = io->error;
556 574
557 if (!atomic_dec_and_test(&io->pending)) 575 if (!atomic_dec_and_test(&io->pending))
558 return; 576 return;
559 577
560 if (likely(!io->base_io)) 578 mempool_free(io, cc->io_pool);
561 bio_endio(io->base_bio, io->error); 579
580 if (likely(!base_io))
581 bio_endio(base_bio, error);
562 else { 582 else {
563 if (io->error && !io->base_io->error) 583 if (error && !base_io->error)
564 io->base_io->error = io->error; 584 base_io->error = error;
565 crypt_dec_pending(io->base_io); 585 crypt_dec_pending(base_io);
566 } 586 }
567
568 mempool_free(io, cc->io_pool);
569} 587}
570 588
571/* 589/*
@@ -821,7 +839,8 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)
821static void kcryptd_async_done(struct crypto_async_request *async_req, 839static void kcryptd_async_done(struct crypto_async_request *async_req,
822 int error) 840 int error)
823{ 841{
824 struct convert_context *ctx = async_req->data; 842 struct dm_crypt_request *dmreq = async_req->data;
843 struct convert_context *ctx = dmreq->ctx;
825 struct dm_crypt_io *io = container_of(ctx, struct dm_crypt_io, ctx); 844 struct dm_crypt_io *io = container_of(ctx, struct dm_crypt_io, ctx);
826 struct crypt_config *cc = io->target->private; 845 struct crypt_config *cc = io->target->private;
827 846
@@ -830,7 +849,7 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
830 return; 849 return;
831 } 850 }
832 851
833 mempool_free(ablkcipher_request_cast(async_req), cc->req_pool); 852 mempool_free(req_of_dmreq(cc, dmreq), cc->req_pool);
834 853
835 if (!atomic_dec_and_test(&ctx->pending)) 854 if (!atomic_dec_and_test(&ctx->pending))
836 return; 855 return;
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index f14813be4eff..36e2b5e46a6b 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -292,6 +292,8 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
292 (PAGE_SIZE >> SECTOR_SHIFT)); 292 (PAGE_SIZE >> SECTOR_SHIFT));
293 num_bvecs = 1 + min_t(int, bio_get_nr_vecs(where->bdev), 293 num_bvecs = 1 + min_t(int, bio_get_nr_vecs(where->bdev),
294 num_bvecs); 294 num_bvecs);
295 if (unlikely(num_bvecs > BIO_MAX_PAGES))
296 num_bvecs = BIO_MAX_PAGES;
295 bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios); 297 bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios);
296 bio->bi_sector = where->sector + (where->count - remaining); 298 bio->bi_sector = where->sector + (where->count - remaining);
297 bio->bi_bdev = where->bdev; 299 bio->bi_bdev = where->bdev;
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 54d0588fc1f6..f01096549a93 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -704,7 +704,8 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
704 char *new_name = (char *) param + param->data_start; 704 char *new_name = (char *) param + param->data_start;
705 705
706 if (new_name < param->data || 706 if (new_name < param->data ||
707 invalid_str(new_name, (void *) param + param_size)) { 707 invalid_str(new_name, (void *) param + param_size) ||
708 strlen(new_name) > DM_NAME_LEN - 1) {
708 DMWARN("Invalid new logical volume name supplied."); 709 DMWARN("Invalid new logical volume name supplied.");
709 return -EINVAL; 710 return -EINVAL;
710 } 711 }
@@ -1063,7 +1064,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
1063 1064
1064 r = populate_table(t, param, param_size); 1065 r = populate_table(t, param, param_size);
1065 if (r) { 1066 if (r) {
1066 dm_table_put(t); 1067 dm_table_destroy(t);
1067 goto out; 1068 goto out;
1068 } 1069 }
1069 1070
@@ -1071,7 +1072,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
1071 hc = dm_get_mdptr(md); 1072 hc = dm_get_mdptr(md);
1072 if (!hc || hc->md != md) { 1073 if (!hc || hc->md != md) {
1073 DMWARN("device has been removed from the dev hash table."); 1074 DMWARN("device has been removed from the dev hash table.");
1074 dm_table_put(t); 1075 dm_table_destroy(t);
1075 up_write(&_hash_lock); 1076 up_write(&_hash_lock);
1076 r = -ENXIO; 1077 r = -ENXIO;
1077 goto out; 1078 goto out;
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 51ba1db4b3e7..8d40f27cce89 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -525,9 +525,12 @@ static int __noflush_suspending(struct mapped_device *md)
525static void dec_pending(struct dm_io *io, int error) 525static void dec_pending(struct dm_io *io, int error)
526{ 526{
527 unsigned long flags; 527 unsigned long flags;
528 int io_error;
529 struct bio *bio;
530 struct mapped_device *md = io->md;
528 531
529 /* Push-back supersedes any I/O errors */ 532 /* Push-back supersedes any I/O errors */
530 if (error && !(io->error > 0 && __noflush_suspending(io->md))) 533 if (error && !(io->error > 0 && __noflush_suspending(md)))
531 io->error = error; 534 io->error = error;
532 535
533 if (atomic_dec_and_test(&io->io_count)) { 536 if (atomic_dec_and_test(&io->io_count)) {
@@ -537,24 +540,27 @@ static void dec_pending(struct dm_io *io, int error)
537 * This must be handled before the sleeper on 540 * This must be handled before the sleeper on
538 * suspend queue merges the pushback list. 541 * suspend queue merges the pushback list.
539 */ 542 */
540 spin_lock_irqsave(&io->md->pushback_lock, flags); 543 spin_lock_irqsave(&md->pushback_lock, flags);
541 if (__noflush_suspending(io->md)) 544 if (__noflush_suspending(md))
542 bio_list_add(&io->md->pushback, io->bio); 545 bio_list_add(&md->pushback, io->bio);
543 else 546 else
544 /* noflush suspend was interrupted. */ 547 /* noflush suspend was interrupted. */
545 io->error = -EIO; 548 io->error = -EIO;
546 spin_unlock_irqrestore(&io->md->pushback_lock, flags); 549 spin_unlock_irqrestore(&md->pushback_lock, flags);
547 } 550 }
548 551
549 end_io_acct(io); 552 end_io_acct(io);
550 553
551 if (io->error != DM_ENDIO_REQUEUE) { 554 io_error = io->error;
552 trace_block_bio_complete(io->md->queue, io->bio); 555 bio = io->bio;
553 556
554 bio_endio(io->bio, io->error); 557 free_io(md, io);
555 } 558
559 if (io_error != DM_ENDIO_REQUEUE) {
560 trace_block_bio_complete(md->queue, bio);
556 561
557 free_io(io->md, io); 562 bio_endio(bio, io_error);
563 }
558 } 564 }
559} 565}
560 566
@@ -562,6 +568,7 @@ static void clone_endio(struct bio *bio, int error)
562{ 568{
563 int r = 0; 569 int r = 0;
564 struct dm_target_io *tio = bio->bi_private; 570 struct dm_target_io *tio = bio->bi_private;
571 struct dm_io *io = tio->io;
565 struct mapped_device *md = tio->io->md; 572 struct mapped_device *md = tio->io->md;
566 dm_endio_fn endio = tio->ti->type->end_io; 573 dm_endio_fn endio = tio->ti->type->end_io;
567 574
@@ -585,15 +592,14 @@ static void clone_endio(struct bio *bio, int error)
585 } 592 }
586 } 593 }
587 594
588 dec_pending(tio->io, error);
589
590 /* 595 /*
591 * Store md for cleanup instead of tio which is about to get freed. 596 * Store md for cleanup instead of tio which is about to get freed.
592 */ 597 */
593 bio->bi_private = md->bs; 598 bio->bi_private = md->bs;
594 599
595 bio_put(bio);
596 free_tio(md, tio); 600 free_tio(md, tio);
601 bio_put(bio);
602 dec_pending(io, error);
597} 603}
598 604
599static sector_t max_io_len(struct mapped_device *md, 605static sector_t max_io_len(struct mapped_device *md,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 03b4cd0a6344..a307f87eb90e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -214,12 +214,7 @@ 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) 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 218
224static void mddev_put(mddev_t *mddev) 219static void mddev_put(mddev_t *mddev)
225{ 220{
@@ -3542,6 +3537,21 @@ static struct kobj_type md_ktype = {
3542 3537
3543int mdp_major = 0; 3538int mdp_major = 0;
3544 3539
3540static void mddev_delayed_delete(struct work_struct *ws)
3541{
3542 mddev_t *mddev = container_of(ws, mddev_t, del_work);
3543
3544 if (mddev->private == &md_redundancy_group) {
3545 sysfs_remove_group(&mddev->kobj, &md_redundancy_group);
3546 if (mddev->sysfs_action)
3547 sysfs_put(mddev->sysfs_action);
3548 mddev->sysfs_action = NULL;
3549 mddev->private = NULL;
3550 }
3551 kobject_del(&mddev->kobj);
3552 kobject_put(&mddev->kobj);
3553}
3554
3545static int md_alloc(dev_t dev, char *name) 3555static int md_alloc(dev_t dev, char *name)
3546{ 3556{
3547 static DEFINE_MUTEX(disks_mutex); 3557 static DEFINE_MUTEX(disks_mutex);
@@ -4033,13 +4043,9 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4033 mddev->queue->merge_bvec_fn = NULL; 4043 mddev->queue->merge_bvec_fn = NULL;
4034 mddev->queue->unplug_fn = NULL; 4044 mddev->queue->unplug_fn = NULL;
4035 mddev->queue->backing_dev_info.congested_fn = NULL; 4045 mddev->queue->backing_dev_info.congested_fn = NULL;
4036 if (mddev->pers->sync_request) {
4037 sysfs_remove_group(&mddev->kobj, &md_redundancy_group);
4038 if (mddev->sysfs_action)
4039 sysfs_put(mddev->sysfs_action);
4040 mddev->sysfs_action = NULL;
4041 }
4042 module_put(mddev->pers->owner); 4046 module_put(mddev->pers->owner);
4047 if (mddev->pers->sync_request)
4048 mddev->private = &md_redundancy_group;
4043 mddev->pers = NULL; 4049 mddev->pers = NULL;
4044 /* tell userspace to handle 'inactive' */ 4050 /* tell userspace to handle 'inactive' */
4045 sysfs_notify_dirent(mddev->sysfs_state); 4051 sysfs_notify_dirent(mddev->sysfs_state);
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 29e8f1546ab6..fec1d77fa855 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1683,7 +1683,7 @@ static int dst_tune_frontend(struct dvb_frontend* fe,
1683 1683
1684static int dst_get_tuning_algo(struct dvb_frontend *fe) 1684static int dst_get_tuning_algo(struct dvb_frontend *fe)
1685{ 1685{
1686 return dst_algo; 1686 return dst_algo ? DVBFE_ALGO_HW : DVBFE_ALGO_SW;
1687} 1687}
1688 1688
1689static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) 1689static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 843407785083..8dcb3fbf7acd 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -1290,9 +1290,6 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
1290 dprintk("%s() Finalised property cache\n", __func__); 1290 dprintk("%s() Finalised property cache\n", __func__);
1291 dtv_property_cache_submit(fe); 1291 dtv_property_cache_submit(fe);
1292 1292
1293 /* Request the search algorithm to search */
1294 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN;
1295
1296 r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND, 1293 r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND,
1297 &fepriv->parameters); 1294 &fepriv->parameters);
1298 break; 1295 break;
@@ -1717,6 +1714,10 @@ static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file,
1717 fepriv->min_delay = (dvb_override_tune_delay * HZ) / 1000; 1714 fepriv->min_delay = (dvb_override_tune_delay * HZ) / 1000;
1718 1715
1719 fepriv->state = FESTATE_RETUNE; 1716 fepriv->state = FESTATE_RETUNE;
1717
1718 /* Request the search algorithm to search */
1719 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN;
1720
1720 dvb_frontend_wakeup(fe); 1721 dvb_frontend_wakeup(fe);
1721 dvb_frontend_add_event(fe, 0); 1722 dvb_frontend_add_event(fe, 0);
1722 fepriv->status = 0; 1723 fepriv->status = 0;
diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c
index a67d1775a43c..2da55ec20392 100644
--- a/drivers/media/dvb/frontends/stb0899_algo.c
+++ b/drivers/media/dvb/frontends/stb0899_algo.c
@@ -156,7 +156,7 @@ static void stb0899_first_subrange(struct stb0899_state *state)
156 } 156 }
157 157
158 if (range > 0) 158 if (range > 0)
159 internal->sub_range = MIN(internal->srch_range, range); 159 internal->sub_range = min(internal->srch_range, range);
160 else 160 else
161 internal->sub_range = 0; 161 internal->sub_range = 0;
162 162
@@ -185,7 +185,7 @@ static enum stb0899_status stb0899_check_tmg(struct stb0899_state *state)
185 timing = stb0899_read_reg(state, STB0899_RTF); 185 timing = stb0899_read_reg(state, STB0899_RTF);
186 186
187 if (lock >= 42) { 187 if (lock >= 42) {
188 if ((lock > 48) && (ABS(timing) >= 110)) { 188 if ((lock > 48) && (abs(timing) >= 110)) {
189 internal->status = ANALOGCARRIER; 189 internal->status = ANALOGCARRIER;
190 dprintk(state->verbose, FE_DEBUG, 1, "-->ANALOG Carrier !"); 190 dprintk(state->verbose, FE_DEBUG, 1, "-->ANALOG Carrier !");
191 } else { 191 } else {
@@ -222,7 +222,7 @@ static enum stb0899_status stb0899_search_tmg(struct stb0899_state *state)
222 index++; 222 index++;
223 derot_freq += index * internal->direction * derot_step; /* next derot zig zag position */ 223 derot_freq += index * internal->direction * derot_step; /* next derot zig zag position */
224 224
225 if (ABS(derot_freq) > derot_limit) 225 if (abs(derot_freq) > derot_limit)
226 next_loop--; 226 next_loop--;
227 227
228 if (next_loop) { 228 if (next_loop) {
@@ -298,7 +298,7 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state)
298 last_derot_freq = derot_freq; 298 last_derot_freq = derot_freq;
299 derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator position */ 299 derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator position */
300 300
301 if(ABS(derot_freq) > derot_limit) 301 if(abs(derot_freq) > derot_limit)
302 next_loop--; 302 next_loop--;
303 303
304 if (next_loop) { 304 if (next_loop) {
@@ -400,7 +400,7 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state)
400 if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) { 400 if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) {
401 401
402 derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */ 402 derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */
403 if (ABS(derot_freq) > derot_limit) 403 if (abs(derot_freq) > derot_limit)
404 next_loop--; 404 next_loop--;
405 405
406 if (next_loop) { 406 if (next_loop) {
@@ -467,7 +467,7 @@ static void next_sub_range(struct stb0899_state *state)
467 467
468 if (internal->sub_dir > 0) { 468 if (internal->sub_dir > 0) {
469 old_sub_range = internal->sub_range; 469 old_sub_range = internal->sub_range;
470 internal->sub_range = MIN((internal->srch_range / 2) - 470 internal->sub_range = min((internal->srch_range / 2) -
471 (internal->tuner_offst + internal->sub_range / 2), 471 (internal->tuner_offst + internal->sub_range / 2),
472 internal->sub_range); 472 internal->sub_range);
473 473
@@ -771,7 +771,7 @@ static long Log2Int(int number)
771 int i; 771 int i;
772 772
773 i = 0; 773 i = 0;
774 while ((1 << i) <= ABS(number)) 774 while ((1 << i) <= abs(number))
775 i++; 775 i++;
776 776
777 if (number == 0) 777 if (number == 0)
diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c
index 10613acf18f5..a04c782fff8d 100644
--- a/drivers/media/dvb/frontends/stb0899_drv.c
+++ b/drivers/media/dvb/frontends/stb0899_drv.c
@@ -794,7 +794,7 @@ static int stb0899_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t
794 reg = stb0899_read_reg(state, STB0899_DISCNTRL1); 794 reg = stb0899_read_reg(state, STB0899_DISCNTRL1);
795 old_state = reg; 795 old_state = reg;
796 /* set to burst mode */ 796 /* set to burst mode */
797 STB0899_SETFIELD_VAL(DISEQCMODE, reg, 0x02); 797 STB0899_SETFIELD_VAL(DISEQCMODE, reg, 0x03);
798 STB0899_SETFIELD_VAL(DISPRECHARGE, reg, 0x01); 798 STB0899_SETFIELD_VAL(DISPRECHARGE, reg, 0x01);
799 stb0899_write_reg(state, STB0899_DISCNTRL1, reg); 799 stb0899_write_reg(state, STB0899_DISCNTRL1, reg);
800 switch (burst) { 800 switch (burst) {
diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h
index 24619e3689db..82395b912815 100644
--- a/drivers/media/dvb/frontends/stb0899_priv.h
+++ b/drivers/media/dvb/frontends/stb0899_priv.h
@@ -59,10 +59,6 @@
59#define MAKEWORD32(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) 59#define MAKEWORD32(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
60#define MAKEWORD16(a, b) (((a) << 8) | (b)) 60#define MAKEWORD16(a, b) (((a) << 8) | (b))
61 61
62#define MIN(x, y) ((x) <= (y) ? (x) : (y))
63#define MAX(x, y) ((x) >= (y) ? (x) : (y))
64#define ABS(x) ((x) >= 0 ? (x) : -(x))
65
66#define LSB(x) ((x & 0xff)) 62#define LSB(x) ((x & 0xff))
67#define MSB(y) ((y >> 8) & 0xff) 63#define MSB(y) ((y >> 8) & 0xff)
68 64
@@ -168,10 +164,10 @@ struct stb0899_internal {
168 u32 freq; /* Demod internal Frequency */ 164 u32 freq; /* Demod internal Frequency */
169 u32 srate; /* Demod internal Symbol rate */ 165 u32 srate; /* Demod internal Symbol rate */
170 enum stb0899_fec fecrate; /* Demod internal FEC rate */ 166 enum stb0899_fec fecrate; /* Demod internal FEC rate */
171 u32 srch_range; /* Demod internal Search Range */ 167 s32 srch_range; /* Demod internal Search Range */
172 u32 sub_range; /* Demod current sub range (Hz) */ 168 s32 sub_range; /* Demod current sub range (Hz) */
173 u32 tuner_step; /* Tuner step (Hz) */ 169 s32 tuner_step; /* Tuner step (Hz) */
174 u32 tuner_offst; /* Relative offset to carrier (Hz) */ 170 s32 tuner_offst; /* Relative offset to carrier (Hz) */
175 u32 tuner_bw; /* Current bandwidth of the tuner (Hz) */ 171 u32 tuner_bw; /* Current bandwidth of the tuner (Hz) */
176 172
177 s32 mclk; /* Masterclock Divider factor (binary) */ 173 s32 mclk; /* Masterclock Divider factor (binary) */
diff --git a/drivers/media/dvb/frontends/stb6100.c b/drivers/media/dvb/frontends/stb6100.c
index ff39275ab49c..1ed5a7db4c5e 100644
--- a/drivers/media/dvb/frontends/stb6100.c
+++ b/drivers/media/dvb/frontends/stb6100.c
@@ -427,11 +427,11 @@ static int stb6100_init(struct dvb_frontend *fe)
427 status->refclock = 27000000; /* Hz */ 427 status->refclock = 27000000; /* Hz */
428 status->iqsense = 1; 428 status->iqsense = 1;
429 status->bandwidth = 36000; /* kHz */ 429 status->bandwidth = 36000; /* kHz */
430 state->bandwidth = status->bandwidth * 1000; /* MHz */ 430 state->bandwidth = status->bandwidth * 1000; /* Hz */
431 state->reference = status->refclock / 1000; /* kHz */ 431 state->reference = status->refclock / 1000; /* kHz */
432 432
433 /* Set default bandwidth. */ 433 /* Set default bandwidth. */
434 return stb6100_set_bandwidth(fe, status->bandwidth); 434 return stb6100_set_bandwidth(fe, state->bandwidth);
435} 435}
436 436
437static int stb6100_get_state(struct dvb_frontend *fe, 437static int stb6100_get_state(struct dvb_frontend *fe,
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c
index 170720b02815..b150ed306696 100644
--- a/drivers/media/dvb/frontends/zl10353.c
+++ b/drivers/media/dvb/frontends/zl10353.c
@@ -590,7 +590,7 @@ static int zl10353_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
590 struct zl10353_state *state = fe->demodulator_priv; 590 struct zl10353_state *state = fe->demodulator_priv;
591 u8 val = 0x0a; 591 u8 val = 0x0a;
592 592
593 if (state->config.no_tuner) { 593 if (state->config.disable_i2c_gate_ctrl) {
594 /* No tuner attached to the internal I2C bus */ 594 /* No tuner attached to the internal I2C bus */
595 /* If set enable I2C bridge, the main I2C bus stopped hardly */ 595 /* If set enable I2C bridge, the main I2C bus stopped hardly */
596 return 0; 596 return 0;
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h
index fdbb88ff75fe..2287bac46243 100644
--- a/drivers/media/dvb/frontends/zl10353.h
+++ b/drivers/media/dvb/frontends/zl10353.h
@@ -38,6 +38,9 @@ struct zl10353_config
38 38
39 /* set if parallel ts output is required */ 39 /* set if parallel ts output is required */
40 int parallel_ts; 40 int parallel_ts;
41
42 /* set if i2c_gate_ctrl disable is required */
43 u8 disable_i2c_gate_ctrl:1;
41}; 44};
42 45
43#if defined(CONFIG_DVB_ZL10353) || (defined(CONFIG_DVB_ZL10353_MODULE) && defined(MODULE)) 46#if defined(CONFIG_DVB_ZL10353) || (defined(CONFIG_DVB_ZL10353_MODULE) && defined(MODULE))
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 4d35308fc1ff..393623818ade 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -298,7 +298,8 @@ static int vidioc_querycap(struct file *file, void *priv,
298 298
299 strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver)); 299 strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver));
300 strlcpy(v->card, dev->name, sizeof(v->card)); 300 strlcpy(v->card, dev->name, sizeof(v->card));
301 snprintf(v->bus_info, sizeof(v->bus_info), "I2C:%s", dev->dev.bus_id); 301 snprintf(v->bus_info, sizeof(v->bus_info),
302 "I2C:%s", dev_name(&dev->dev));
302 v->version = RADIO_VERSION; 303 v->version = RADIO_VERSION;
303 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; 304 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
304 return 0; 305 return 0;
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 66c755c116dc..ce98d955231a 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -803,9 +803,10 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
803 return (-ENOENT); 803 return (-ENOENT);
804 } 804 }
805 805
806 card = snd_card_new(index[devno], id[devno], THIS_MODULE, sizeof(snd_cx88_card_t)); 806 err = snd_card_create(index[devno], id[devno], THIS_MODULE,
807 if (!card) 807 sizeof(snd_cx88_card_t), &card);
808 return (-ENOMEM); 808 if (err < 0)
809 return err;
809 810
810 card->private_free = snd_cx88_dev_free; 811 card->private_free = snd_cx88_dev_free;
811 812
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c
index 2ac738fa6a07..f132e31f6edd 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -448,9 +448,10 @@ static int em28xx_audio_init(struct em28xx *dev)
448 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " 448 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus "
449 "Rechberger\n"); 449 "Rechberger\n");
450 450
451 card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE, 0); 451 err = snd_card_create(index[devnr], "Em28xx Audio", THIS_MODULE, 0,
452 if (card == NULL) 452 &card);
453 return -ENOMEM; 453 if (err < 0)
454 return err;
454 455
455 spin_lock_init(&adev->slock); 456 spin_lock_init(&adev->slock);
456 err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); 457 err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm);
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
index e564a61a72d7..48892b5715d5 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
@@ -102,7 +102,11 @@ int s5k4aa_probe(struct sd *sd)
102 } 102 }
103 103
104 /* Test some registers, but we don't know their exact meaning yet */ 104 /* Test some registers, but we don't know their exact meaning yet */
105 if (m5602_read_sensor(sd, 0x00, prod_id, sizeof(prod_id))) 105 if (m5602_read_sensor(sd, 0x00, prod_id, 2))
106 return -ENODEV;
107 if (m5602_read_sensor(sd, 0x02, prod_id+2, 2))
108 return -ENODEV;
109 if (m5602_read_sensor(sd, 0x04, prod_id+4, 2))
106 return -ENODEV; 110 return -ENODEV;
107 111
108 if (memcmp(prod_id, expected_prod_id, sizeof(prod_id))) 112 if (memcmp(prod_id, expected_prod_id, sizeof(prod_id)))
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index c750d3dd57d2..8b0b64a89874 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -990,10 +990,10 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
990 if (!enable[devnum]) 990 if (!enable[devnum])
991 return -ENODEV; 991 return -ENODEV;
992 992
993 card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, sizeof(snd_card_saa7134_t)); 993 err = snd_card_create(index[devnum], id[devnum], THIS_MODULE,
994 994 sizeof(snd_card_saa7134_t), &card);
995 if (card == NULL) 995 if (err < 0)
996 return -ENOMEM; 996 return err;
997 997
998 strcpy(card->driver, "SAA7134"); 998 strcpy(card->driver, "SAA7134");
999 999
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 0776ecf56d27..b5370b3e1a3d 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -860,6 +860,7 @@ static struct zl10353_config behold_h6_config = {
860 .demod_address = 0x1e>>1, 860 .demod_address = 0x1e>>1,
861 .no_tuner = 1, 861 .no_tuner = 1,
862 .parallel_ts = 1, 862 .parallel_ts = 1,
863 .disable_i2c_gate_ctrl = 1,
863}; 864};
864 865
865/* ================================================================== 866/* ==================================================================
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 5aeccb301cea..076ed5bf48b1 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL");
54/* ---------------------------------------------------------------------- */ 54/* ---------------------------------------------------------------------- */
55/* our structs */ 55/* our structs */
56 56
57#define MAXREGS 64 57#define MAXREGS 256
58 58
59struct CHIPSTATE; 59struct CHIPSTATE;
60typedef int (*getvalue)(int); 60typedef int (*getvalue)(int);
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index cf9d4c7f571a..8a4b74f3129f 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -34,7 +34,7 @@ int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
34 spin_lock_init(&v4l2_dev->lock); 34 spin_lock_init(&v4l2_dev->lock);
35 v4l2_dev->dev = dev; 35 v4l2_dev->dev = dev;
36 snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s %s", 36 snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s %s",
37 dev->driver->name, dev->bus_id); 37 dev->driver->name, dev_name(dev));
38 dev_set_drvdata(dev, v4l2_dev); 38 dev_set_drvdata(dev, v4l2_dev);
39 return 0; 39 return 0;
40} 40}
diff --git a/drivers/media/video/zoran/Kconfig b/drivers/media/video/zoran/Kconfig
index 4ea5fa71de89..8666e19f31a7 100644
--- a/drivers/media/video/zoran/Kconfig
+++ b/drivers/media/video/zoran/Kconfig
@@ -68,6 +68,7 @@ config VIDEO_ZORAN_AVS6EYES
68 tristate "AverMedia 6 Eyes support (EXPERIMENTAL)" 68 tristate "AverMedia 6 Eyes support (EXPERIMENTAL)"
69 depends on VIDEO_ZORAN_ZR36060 && EXPERIMENTAL && VIDEO_V4L1 69 depends on VIDEO_ZORAN_ZR36060 && EXPERIMENTAL && VIDEO_V4L1
70 select VIDEO_BT856 if VIDEO_HELPER_CHIPS_AUTO 70 select VIDEO_BT856 if VIDEO_HELPER_CHIPS_AUTO
71 select VIDEO_BT866 if VIDEO_HELPER_CHIPS_AUTO
71 select VIDEO_KS0127 if VIDEO_HELPER_CHIPS_AUTO 72 select VIDEO_KS0127 if VIDEO_HELPER_CHIPS_AUTO
72 help 73 help
73 Support for the AverMedia 6 Eyes video surveillance card. 74 Support for the AverMedia 6 Eyes video surveillance card.
diff --git a/drivers/mfd/mcp-core.c b/drivers/mfd/mcp-core.c
index 6063dc2b52e8..57271cb3b316 100644
--- a/drivers/mfd/mcp-core.c
+++ b/drivers/mfd/mcp-core.c
@@ -214,7 +214,7 @@ EXPORT_SYMBOL(mcp_host_alloc);
214 214
215int mcp_host_register(struct mcp *mcp) 215int mcp_host_register(struct mcp *mcp)
216{ 216{
217 strcpy(mcp->attached_device.bus_id, "mcp0"); 217 dev_set_name(&mcp->attached_device, "mcp0");
218 return device_register(&mcp->attached_device); 218 return device_register(&mcp->attached_device);
219} 219}
220EXPORT_SYMBOL(mcp_host_register); 220EXPORT_SYMBOL(mcp_host_register);
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c
index 6860c924f364..fea9085fe52c 100644
--- a/drivers/mfd/ucb1x00-core.c
+++ b/drivers/mfd/ucb1x00-core.c
@@ -492,7 +492,7 @@ static int ucb1x00_probe(struct mcp *mcp)
492 492
493 ucb->dev.class = &ucb1x00_class; 493 ucb->dev.class = &ucb1x00_class;
494 ucb->dev.parent = &mcp->attached_device; 494 ucb->dev.parent = &mcp->attached_device;
495 strlcpy(ucb->dev.bus_id, "ucb1x00", sizeof(ucb->dev.bus_id)); 495 dev_set_name(&ucb->dev, "ucb1x00");
496 496
497 spin_lock_init(&ucb->lock); 497 spin_lock_init(&ucb->lock);
498 spin_lock_init(&ucb->io_lock); 498 spin_lock_init(&ucb->io_lock);
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 84d5ea1ec171..b457a05b28d9 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -1383,6 +1383,11 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
1383 wm8350->power.rev_g_coeff = 1; 1383 wm8350->power.rev_g_coeff = 1;
1384 break; 1384 break;
1385 1385
1386 case 1:
1387 dev_info(wm8350->dev, "WM8351 Rev B\n");
1388 wm8350->power.rev_g_coeff = 1;
1389 break;
1390
1386 default: 1391 default:
1387 dev_err(wm8350->dev, "Unknown WM8351 CHIP_REV\n"); 1392 dev_err(wm8350->dev, "Unknown WM8351 CHIP_REV\n");
1388 ret = -ENODEV; 1393 ret = -ENODEV;
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 9c50e6f1c236..34ce2703d29a 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -248,12 +248,15 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
248 248
249 sg_init_one(&sg, data_buf, len); 249 sg_init_one(&sg, data_buf, len);
250 250
251 /* 251 if (opcode == MMC_SEND_CSD || opcode == MMC_SEND_CID) {
252 * The spec states that CSR and CID accesses have a timeout 252 /*
253 * of 64 clock cycles. 253 * The spec states that CSR and CID accesses have a timeout
254 */ 254 * of 64 clock cycles.
255 data.timeout_ns = 0; 255 */
256 data.timeout_clks = 64; 256 data.timeout_ns = 0;
257 data.timeout_clks = 64;
258 } else
259 mmc_set_data_timeout(&data, card);
257 260
258 mmc_wait_for_req(host, &mrq); 261 mmc_wait_for_req(host, &mrq);
259 262
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 2b1196e6142c..e94e92001e7c 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -1603,7 +1603,7 @@ static int __init atmci_probe(struct platform_device *pdev)
1603 1603
1604 tasklet_init(&host->tasklet, atmci_tasklet_func, (unsigned long)host); 1604 tasklet_init(&host->tasklet, atmci_tasklet_func, (unsigned long)host);
1605 1605
1606 ret = request_irq(irq, atmci_interrupt, 0, pdev->dev.bus_id, host); 1606 ret = request_irq(irq, atmci_interrupt, 0, dev_name(&pdev->dev), host);
1607 if (ret) 1607 if (ret)
1608 goto err_request_irq; 1608 goto err_request_irq;
1609 1609
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c
index fb2921f8099d..0c44d560bf1a 100644
--- a/drivers/mmc/host/of_mmc_spi.c
+++ b/drivers/mmc/host/of_mmc_spi.c
@@ -103,7 +103,7 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
103 if (!gpio_is_valid(oms->gpios[i])) 103 if (!gpio_is_valid(oms->gpios[i]))
104 continue; 104 continue;
105 105
106 ret = gpio_request(oms->gpios[i], dev->bus_id); 106 ret = gpio_request(oms->gpios[i], dev_name(dev));
107 if (ret < 0) { 107 if (ret < 0) {
108 oms->gpios[i] = -EINVAL; 108 oms->gpios[i] = -EINVAL;
109 continue; 109 continue;
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c
index f4a67c65d301..2db166b7096f 100644
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -793,8 +793,7 @@ static void s3cmci_dma_setup(struct s3cmci_host *host,
793 host->mem->start + host->sdidata); 793 host->mem->start + host->sdidata);
794 794
795 if (!setup_ok) { 795 if (!setup_ok) {
796 s3c2410_dma_config(host->dma, 4, 796 s3c2410_dma_config(host->dma, 4, 0);
797 (S3C2410_DCON_HWTRIG | S3C2410_DCON_CH0_SDI));
798 s3c2410_dma_set_buffdone_fn(host->dma, 797 s3c2410_dma_set_buffdone_fn(host->dma,
799 s3cmci_dma_done_callback); 798 s3cmci_dma_done_callback);
800 s3c2410_dma_setflags(host->dma, S3C2410_DMAF_AUTOSTART); 799 s3c2410_dma_setflags(host->dma, S3C2410_DMAF_AUTOSTART);
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index bc33200535fc..6fde0a2e3567 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -120,13 +120,6 @@ 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
130config MTD_LART 123config MTD_LART
131 tristate "28F160xx flash driver for LART" 124 tristate "28F160xx flash driver for LART"
132 depends on SA1100_LART 125 depends on SA1100_LART
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index e51521df4e40..0993d5cf3923 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -16,4 +16,3 @@ 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/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index d44f741ae229..6d9f810565c8 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -821,7 +821,8 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
821 if (!(info->flags & IS_POW2PS)) 821 if (!(info->flags & IS_POW2PS))
822 return info; 822 return info;
823 } 823 }
824 } 824 } else
825 return info;
825 } 826 }
826 } 827 }
827 828
diff --git a/drivers/mtd/devices/ps3vram.c b/drivers/mtd/devices/ps3vram.c
deleted file mode 100644
index d21e9beb7ed2..000000000000
--- a/drivers/mtd/devices/ps3vram.c
+++ /dev/null
@@ -1,768 +0,0 @@
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/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 043d50fb6ef6..729f899a5cd5 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -551,5 +551,15 @@ config MTD_PLATRAM
551 551
552 This selection automatically selects the map_ram driver. 552 This selection automatically selects the map_ram driver.
553 553
554endmenu 554config MTD_VMU
555 tristate "Map driver for Dreamcast VMU"
556 depends on MAPLE
557 help
558 This driver enables access to the Dreamcast Visual Memory Unit (VMU).
559
560 Most Dreamcast users will want to say Y here.
555 561
562 To build this as a module select M here, the module will be called
563 vmu-flash.
564
565endmenu
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 6d9ba35caf11..26b28a7a90b5 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -61,3 +61,4 @@ obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o
61obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o 61obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
62obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o 62obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o
63obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o 63obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o
64obj-$(CONFIG_MTD_VMU) += vmu-flash.o
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 4b122e7ab4b3..229718222db7 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -46,16 +46,19 @@ static int physmap_flash_remove(struct platform_device *dev)
46 46
47 physmap_data = dev->dev.platform_data; 47 physmap_data = dev->dev.platform_data;
48 48
49 if (info->cmtd) {
49#ifdef CONFIG_MTD_PARTITIONS 50#ifdef CONFIG_MTD_PARTITIONS
50 if (info->nr_parts) { 51 if (info->nr_parts || physmap_data->nr_parts)
51 del_mtd_partitions(info->cmtd); 52 del_mtd_partitions(info->cmtd);
52 kfree(info->parts); 53 else
53 } else if (physmap_data->nr_parts) 54 del_mtd_device(info->cmtd);
54 del_mtd_partitions(info->cmtd);
55 else
56 del_mtd_device(info->cmtd);
57#else 55#else
58 del_mtd_device(info->cmtd); 56 del_mtd_device(info->cmtd);
57#endif
58 }
59#ifdef CONFIG_MTD_PARTITIONS
60 if (info->nr_parts)
61 kfree(info->parts);
59#endif 62#endif
60 63
61#ifdef CONFIG_MTD_CONCAT 64#ifdef CONFIG_MTD_CONCAT
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
index 771139c5bf87..e9026cb1c5b2 100644
--- a/drivers/mtd/maps/pxa2xx-flash.c
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -41,9 +41,8 @@ struct pxa2xx_flash_info {
41static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 41static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
42 42
43 43
44static int __init pxa2xx_flash_probe(struct device *dev) 44static int __init pxa2xx_flash_probe(struct platform_device *pdev)
45{ 45{
46 struct platform_device *pdev = to_platform_device(dev);
47 struct flash_platform_data *flash = pdev->dev.platform_data; 46 struct flash_platform_data *flash = pdev->dev.platform_data;
48 struct pxa2xx_flash_info *info; 47 struct pxa2xx_flash_info *info;
49 struct mtd_partition *parts; 48 struct mtd_partition *parts;
@@ -114,15 +113,15 @@ static int __init pxa2xx_flash_probe(struct device *dev)
114 add_mtd_device(info->mtd); 113 add_mtd_device(info->mtd);
115 } 114 }
116 115
117 dev_set_drvdata(dev, info); 116 platform_set_drvdata(pdev, info);
118 return 0; 117 return 0;
119} 118}
120 119
121static int __exit pxa2xx_flash_remove(struct device *dev) 120static int __exit pxa2xx_flash_remove(struct platform_device *dev)
122{ 121{
123 struct pxa2xx_flash_info *info = dev_get_drvdata(dev); 122 struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
124 123
125 dev_set_drvdata(dev, NULL); 124 platform_set_drvdata(dev, NULL);
126 125
127#ifdef CONFIG_MTD_PARTITIONS 126#ifdef CONFIG_MTD_PARTITIONS
128 if (info->nr_parts) 127 if (info->nr_parts)
@@ -141,9 +140,9 @@ static int __exit pxa2xx_flash_remove(struct device *dev)
141} 140}
142 141
143#ifdef CONFIG_PM 142#ifdef CONFIG_PM
144static int pxa2xx_flash_suspend(struct device *dev, pm_message_t state) 143static int pxa2xx_flash_suspend(struct platform_device *dev, pm_message_t state)
145{ 144{
146 struct pxa2xx_flash_info *info = dev_get_drvdata(dev); 145 struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
147 int ret = 0; 146 int ret = 0;
148 147
149 if (info->mtd && info->mtd->suspend) 148 if (info->mtd && info->mtd->suspend)
@@ -151,17 +150,17 @@ static int pxa2xx_flash_suspend(struct device *dev, pm_message_t state)
151 return ret; 150 return ret;
152} 151}
153 152
154static int pxa2xx_flash_resume(struct device *dev) 153static int pxa2xx_flash_resume(struct platform_device *dev)
155{ 154{
156 struct pxa2xx_flash_info *info = dev_get_drvdata(dev); 155 struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
157 156
158 if (info->mtd && info->mtd->resume) 157 if (info->mtd && info->mtd->resume)
159 info->mtd->resume(info->mtd); 158 info->mtd->resume(info->mtd);
160 return 0; 159 return 0;
161} 160}
162static void pxa2xx_flash_shutdown(struct device *dev) 161static void pxa2xx_flash_shutdown(struct platform_device *dev)
163{ 162{
164 struct pxa2xx_flash_info *info = dev_get_drvdata(dev); 163 struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
165 164
166 if (info && info->mtd->suspend(info->mtd) == 0) 165 if (info && info->mtd->suspend(info->mtd) == 0)
167 info->mtd->resume(info->mtd); 166 info->mtd->resume(info->mtd);
@@ -172,11 +171,13 @@ static void pxa2xx_flash_shutdown(struct device *dev)
172#define pxa2xx_flash_shutdown NULL 171#define pxa2xx_flash_shutdown NULL
173#endif 172#endif
174 173
175static struct device_driver pxa2xx_flash_driver = { 174static struct platform_driver pxa2xx_flash_driver = {
176 .name = "pxa2xx-flash", 175 .driver = {
177 .bus = &platform_bus_type, 176 .name = "pxa2xx-flash",
177 .owner = THIS_MODULE,
178 },
178 .probe = pxa2xx_flash_probe, 179 .probe = pxa2xx_flash_probe,
179 .remove = __exit_p(pxa2xx_flash_remove), 180 .remove = __devexit_p(pxa2xx_flash_remove),
180 .suspend = pxa2xx_flash_suspend, 181 .suspend = pxa2xx_flash_suspend,
181 .resume = pxa2xx_flash_resume, 182 .resume = pxa2xx_flash_resume,
182 .shutdown = pxa2xx_flash_shutdown, 183 .shutdown = pxa2xx_flash_shutdown,
@@ -184,12 +185,12 @@ static struct device_driver pxa2xx_flash_driver = {
184 185
185static int __init init_pxa2xx_flash(void) 186static int __init init_pxa2xx_flash(void)
186{ 187{
187 return driver_register(&pxa2xx_flash_driver); 188 return platform_driver_register(&pxa2xx_flash_driver);
188} 189}
189 190
190static void __exit cleanup_pxa2xx_flash(void) 191static void __exit cleanup_pxa2xx_flash(void)
191{ 192{
192 driver_unregister(&pxa2xx_flash_driver); 193 platform_driver_unregister(&pxa2xx_flash_driver);
193} 194}
194 195
195module_init(init_pxa2xx_flash); 196module_init(init_pxa2xx_flash);
diff --git a/drivers/mtd/maps/vmu-flash.c b/drivers/mtd/maps/vmu-flash.c
new file mode 100644
index 000000000000..1f73297e7776
--- /dev/null
+++ b/drivers/mtd/maps/vmu-flash.c
@@ -0,0 +1,832 @@
1/* vmu-flash.c
2 * Driver for SEGA Dreamcast Visual Memory Unit
3 *
4 * Copyright (c) Adrian McMenamin 2002 - 2009
5 * Copyright (c) Paul Mundt 2001
6 *
7 * Licensed under version 2 of the
8 * GNU General Public Licence
9 */
10#include <linux/init.h>
11#include <linux/sched.h>
12#include <linux/delay.h>
13#include <linux/maple.h>
14#include <linux/mtd/mtd.h>
15#include <linux/mtd/map.h>
16
17struct vmu_cache {
18 unsigned char *buffer; /* Cache */
19 unsigned int block; /* Which block was cached */
20 unsigned long jiffies_atc; /* When was it cached? */
21 int valid;
22};
23
24struct mdev_part {
25 struct maple_device *mdev;
26 int partition;
27};
28
29struct vmupart {
30 u16 user_blocks;
31 u16 root_block;
32 u16 numblocks;
33 char *name;
34 struct vmu_cache *pcache;
35};
36
37struct memcard {
38 u16 tempA;
39 u16 tempB;
40 u32 partitions;
41 u32 blocklen;
42 u32 writecnt;
43 u32 readcnt;
44 u32 removeable;
45 int partition;
46 int read;
47 unsigned char *blockread;
48 struct vmupart *parts;
49 struct mtd_info *mtd;
50};
51
52struct vmu_block {
53 unsigned int num; /* block number */
54 unsigned int ofs; /* block offset */
55};
56
57static struct vmu_block *ofs_to_block(unsigned long src_ofs,
58 struct mtd_info *mtd, int partition)
59{
60 struct vmu_block *vblock;
61 struct maple_device *mdev;
62 struct memcard *card;
63 struct mdev_part *mpart;
64 int num;
65
66 mpart = mtd->priv;
67 mdev = mpart->mdev;
68 card = maple_get_drvdata(mdev);
69
70 if (src_ofs >= card->parts[partition].numblocks * card->blocklen)
71 goto failed;
72
73 num = src_ofs / card->blocklen;
74 if (num > card->parts[partition].numblocks)
75 goto failed;
76
77 vblock = kmalloc(sizeof(struct vmu_block), GFP_KERNEL);
78 if (!vblock)
79 goto failed;
80
81 vblock->num = num;
82 vblock->ofs = src_ofs % card->blocklen;
83 return vblock;
84
85failed:
86 return NULL;
87}
88
89/* Maple bus callback function for reads */
90static void vmu_blockread(struct mapleq *mq)
91{
92 struct maple_device *mdev;
93 struct memcard *card;
94
95 mdev = mq->dev;
96 card = maple_get_drvdata(mdev);
97 /* copy the read in data */
98
99 if (unlikely(!card->blockread))
100 return;
101
102 memcpy(card->blockread, mq->recvbuf->buf + 12,
103 card->blocklen/card->readcnt);
104
105}
106
107/* Interface with maple bus to read blocks
108 * caching the results so that other parts
109 * of the driver can access block reads */
110static int maple_vmu_read_block(unsigned int num, unsigned char *buf,
111 struct mtd_info *mtd)
112{
113 struct memcard *card;
114 struct mdev_part *mpart;
115 struct maple_device *mdev;
116 int partition, error = 0, x, wait;
117 unsigned char *blockread = NULL;
118 struct vmu_cache *pcache;
119 __be32 sendbuf;
120
121 mpart = mtd->priv;
122 mdev = mpart->mdev;
123 partition = mpart->partition;
124 card = maple_get_drvdata(mdev);
125 pcache = card->parts[partition].pcache;
126 pcache->valid = 0;
127
128 /* prepare the cache for this block */
129 if (!pcache->buffer) {
130 pcache->buffer = kmalloc(card->blocklen, GFP_KERNEL);
131 if (!pcache->buffer) {
132 dev_err(&mdev->dev, "VMU at (%d, %d) - read fails due"
133 " to lack of memory\n", mdev->port,
134 mdev->unit);
135 error = -ENOMEM;
136 goto outB;
137 }
138 }
139
140 /*
141 * Reads may be phased - again the hardware spec
142 * supports this - though may not be any devices in
143 * the wild that implement it, but we will here
144 */
145 for (x = 0; x < card->readcnt; x++) {
146 sendbuf = cpu_to_be32(partition << 24 | x << 16 | num);
147
148 if (atomic_read(&mdev->busy) == 1) {
149 wait_event_interruptible_timeout(mdev->maple_wait,
150 atomic_read(&mdev->busy) == 0, HZ);
151 if (atomic_read(&mdev->busy) == 1) {
152 dev_notice(&mdev->dev, "VMU at (%d, %d)"
153 " is busy\n", mdev->port, mdev->unit);
154 error = -EAGAIN;
155 goto outB;
156 }
157 }
158
159 atomic_set(&mdev->busy, 1);
160 blockread = kmalloc(card->blocklen/card->readcnt, GFP_KERNEL);
161 if (!blockread) {
162 error = -ENOMEM;
163 atomic_set(&mdev->busy, 0);
164 goto outB;
165 }
166 card->blockread = blockread;
167
168 maple_getcond_callback(mdev, vmu_blockread, 0,
169 MAPLE_FUNC_MEMCARD);
170 error = maple_add_packet(mdev, MAPLE_FUNC_MEMCARD,
171 MAPLE_COMMAND_BREAD, 2, &sendbuf);
172 /* Very long timeouts seem to be needed when box is stressed */
173 wait = wait_event_interruptible_timeout(mdev->maple_wait,
174 (atomic_read(&mdev->busy) == 0 ||
175 atomic_read(&mdev->busy) == 2), HZ * 3);
176 /*
177 * MTD layer does not handle hotplugging well
178 * so have to return errors when VMU is unplugged
179 * in the middle of a read (busy == 2)
180 */
181 if (error || atomic_read(&mdev->busy) == 2) {
182 if (atomic_read(&mdev->busy) == 2)
183 error = -ENXIO;
184 atomic_set(&mdev->busy, 0);
185 card->blockread = NULL;
186 goto outA;
187 }
188 if (wait == 0 || wait == -ERESTARTSYS) {
189 card->blockread = NULL;
190 atomic_set(&mdev->busy, 0);
191 error = -EIO;
192 list_del_init(&(mdev->mq->list));
193 kfree(mdev->mq->sendbuf);
194 mdev->mq->sendbuf = NULL;
195 if (wait == -ERESTARTSYS) {
196 dev_warn(&mdev->dev, "VMU read on (%d, %d)"
197 " interrupted on block 0x%X\n",
198 mdev->port, mdev->unit, num);
199 } else
200 dev_notice(&mdev->dev, "VMU read on (%d, %d)"
201 " timed out on block 0x%X\n",
202 mdev->port, mdev->unit, num);
203 goto outA;
204 }
205
206 memcpy(buf + (card->blocklen/card->readcnt) * x, blockread,
207 card->blocklen/card->readcnt);
208
209 memcpy(pcache->buffer + (card->blocklen/card->readcnt) * x,
210 card->blockread, card->blocklen/card->readcnt);
211 card->blockread = NULL;
212 pcache->block = num;
213 pcache->jiffies_atc = jiffies;
214 pcache->valid = 1;
215 kfree(blockread);
216 }
217
218 return error;
219
220outA:
221 kfree(blockread);
222outB:
223 return error;
224}
225
226/* communicate with maple bus for phased writing */
227static int maple_vmu_write_block(unsigned int num, const unsigned char *buf,
228 struct mtd_info *mtd)
229{
230 struct memcard *card;
231 struct mdev_part *mpart;
232 struct maple_device *mdev;
233 int partition, error, locking, x, phaselen, wait;
234 __be32 *sendbuf;
235
236 mpart = mtd->priv;
237 mdev = mpart->mdev;
238 partition = mpart->partition;
239 card = maple_get_drvdata(mdev);
240
241 phaselen = card->blocklen/card->writecnt;
242
243 sendbuf = kmalloc(phaselen + 4, GFP_KERNEL);
244 if (!sendbuf) {
245 error = -ENOMEM;
246 goto fail_nosendbuf;
247 }
248 for (x = 0; x < card->writecnt; x++) {
249 sendbuf[0] = cpu_to_be32(partition << 24 | x << 16 | num);
250 memcpy(&sendbuf[1], buf + phaselen * x, phaselen);
251 /* wait until the device is not busy doing something else
252 * or 1 second - which ever is longer */
253 if (atomic_read(&mdev->busy) == 1) {
254 wait_event_interruptible_timeout(mdev->maple_wait,
255 atomic_read(&mdev->busy) == 0, HZ);
256 if (atomic_read(&mdev->busy) == 1) {
257 error = -EBUSY;
258 dev_notice(&mdev->dev, "VMU write at (%d, %d)"
259 "failed - device is busy\n",
260 mdev->port, mdev->unit);
261 goto fail_nolock;
262 }
263 }
264 atomic_set(&mdev->busy, 1);
265
266 locking = maple_add_packet(mdev, MAPLE_FUNC_MEMCARD,
267 MAPLE_COMMAND_BWRITE, phaselen / 4 + 2, sendbuf);
268 wait = wait_event_interruptible_timeout(mdev->maple_wait,
269 atomic_read(&mdev->busy) == 0, HZ/10);
270 if (locking) {
271 error = -EIO;
272 atomic_set(&mdev->busy, 0);
273 goto fail_nolock;
274 }
275 if (atomic_read(&mdev->busy) == 2) {
276 atomic_set(&mdev->busy, 0);
277 } else if (wait == 0 || wait == -ERESTARTSYS) {
278 error = -EIO;
279 dev_warn(&mdev->dev, "Write at (%d, %d) of block"
280 " 0x%X at phase %d failed: could not"
281 " communicate with VMU", mdev->port,
282 mdev->unit, num, x);
283 atomic_set(&mdev->busy, 0);
284 kfree(mdev->mq->sendbuf);
285 mdev->mq->sendbuf = NULL;
286 list_del_init(&(mdev->mq->list));
287 goto fail_nolock;
288 }
289 }
290 kfree(sendbuf);
291
292 return card->blocklen;
293
294fail_nolock:
295 kfree(sendbuf);
296fail_nosendbuf:
297 dev_err(&mdev->dev, "VMU (%d, %d): write failed\n", mdev->port,
298 mdev->unit);
299 return error;
300}
301
302/* mtd function to simulate reading byte by byte */
303static unsigned char vmu_flash_read_char(unsigned long ofs, int *retval,
304 struct mtd_info *mtd)
305{
306 struct vmu_block *vblock;
307 struct memcard *card;
308 struct mdev_part *mpart;
309 struct maple_device *mdev;
310 unsigned char *buf, ret;
311 int partition, error;
312
313 mpart = mtd->priv;
314 mdev = mpart->mdev;
315 partition = mpart->partition;
316 card = maple_get_drvdata(mdev);
317 *retval = 0;
318
319 buf = kmalloc(card->blocklen, GFP_KERNEL);
320 if (!buf) {
321 *retval = 1;
322 ret = -ENOMEM;
323 goto finish;
324 }
325
326 vblock = ofs_to_block(ofs, mtd, partition);
327 if (!vblock) {
328 *retval = 3;
329 ret = -ENOMEM;
330 goto out_buf;
331 }
332
333 error = maple_vmu_read_block(vblock->num, buf, mtd);
334 if (error) {
335 ret = error;
336 *retval = 2;
337 goto out_vblock;
338 }
339
340 ret = buf[vblock->ofs];
341
342out_vblock:
343 kfree(vblock);
344out_buf:
345 kfree(buf);
346finish:
347 return ret;
348}
349
350/* mtd higher order function to read flash */
351static int vmu_flash_read(struct mtd_info *mtd, loff_t from, size_t len,
352 size_t *retlen, u_char *buf)
353{
354 struct maple_device *mdev;
355 struct memcard *card;
356 struct mdev_part *mpart;
357 struct vmu_cache *pcache;
358 struct vmu_block *vblock;
359 int index = 0, retval, partition, leftover, numblocks;
360 unsigned char cx;
361
362 if (len < 1)
363 return -EIO;
364
365 mpart = mtd->priv;
366 mdev = mpart->mdev;
367 partition = mpart->partition;
368 card = maple_get_drvdata(mdev);
369
370 numblocks = card->parts[partition].numblocks;
371 if (from + len > numblocks * card->blocklen)
372 len = numblocks * card->blocklen - from;
373 if (len == 0)
374 return -EIO;
375 /* Have we cached this bit already? */
376 pcache = card->parts[partition].pcache;
377 do {
378 vblock = ofs_to_block(from + index, mtd, partition);
379 if (!vblock)
380 return -ENOMEM;
381 /* Have we cached this and is the cache valid and timely? */
382 if (pcache->valid &&
383 time_before(jiffies, pcache->jiffies_atc + HZ) &&
384 (pcache->block == vblock->num)) {
385 /* we have cached it, so do necessary copying */
386 leftover = card->blocklen - vblock->ofs;
387 if (vblock->ofs + len - index < card->blocklen) {
388 /* only a bit of this block to copy */
389 memcpy(buf + index,
390 pcache->buffer + vblock->ofs,
391 len - index);
392 index = len;
393 } else {
394 /* otherwise copy remainder of whole block */
395 memcpy(buf + index, pcache->buffer +
396 vblock->ofs, leftover);
397 index += leftover;
398 }
399 } else {
400 /*
401 * Not cached so read one byte -
402 * but cache the rest of the block
403 */
404 cx = vmu_flash_read_char(from + index, &retval, mtd);
405 if (retval) {
406 *retlen = index;
407 kfree(vblock);
408 return cx;
409 }
410 memset(buf + index, cx, 1);
411 index++;
412 }
413 kfree(vblock);
414 } while (len > index);
415 *retlen = index;
416
417 return 0;
418}
419
420static int vmu_flash_write(struct mtd_info *mtd, loff_t to, size_t len,
421 size_t *retlen, const u_char *buf)
422{
423 struct maple_device *mdev;
424 struct memcard *card;
425 struct mdev_part *mpart;
426 int index = 0, partition, error = 0, numblocks;
427 struct vmu_cache *pcache;
428 struct vmu_block *vblock;
429 unsigned char *buffer;
430
431 mpart = mtd->priv;
432 mdev = mpart->mdev;
433 partition = mpart->partition;
434 card = maple_get_drvdata(mdev);
435
436 /* simple sanity checks */
437 if (len < 1) {
438 error = -EIO;
439 goto failed;
440 }
441 numblocks = card->parts[partition].numblocks;
442 if (to + len > numblocks * card->blocklen)
443 len = numblocks * card->blocklen - to;
444 if (len == 0) {
445 error = -EIO;
446 goto failed;
447 }
448
449 vblock = ofs_to_block(to, mtd, partition);
450 if (!vblock) {
451 error = -ENOMEM;
452 goto failed;
453 }
454
455 buffer = kmalloc(card->blocklen, GFP_KERNEL);
456 if (!buffer) {
457 error = -ENOMEM;
458 goto fail_buffer;
459 }
460
461 do {
462 /* Read in the block we are to write to */
463 error = maple_vmu_read_block(vblock->num, buffer, mtd);
464 if (error)
465 goto fail_io;
466
467 do {
468 buffer[vblock->ofs] = buf[index];
469 vblock->ofs++;
470 index++;
471 if (index >= len)
472 break;
473 } while (vblock->ofs < card->blocklen);
474
475 /* write out new buffer */
476 error = maple_vmu_write_block(vblock->num, buffer, mtd);
477 /* invalidate the cache */
478 pcache = card->parts[partition].pcache;
479 pcache->valid = 0;
480
481 if (error != card->blocklen)
482 goto fail_io;
483
484 vblock->num++;
485 vblock->ofs = 0;
486 } while (len > index);
487
488 kfree(buffer);
489 *retlen = index;
490 kfree(vblock);
491 return 0;
492
493fail_io:
494 kfree(buffer);
495fail_buffer:
496 kfree(vblock);
497failed:
498 dev_err(&mdev->dev, "VMU write failing with error %d\n", error);
499 return error;
500}
501
502static void vmu_flash_sync(struct mtd_info *mtd)
503{
504 /* Do nothing here */
505}
506
507/* Maple bus callback function to recursively query hardware details */
508static void vmu_queryblocks(struct mapleq *mq)
509{
510 struct maple_device *mdev;
511 unsigned short *res;
512 struct memcard *card;
513 __be32 partnum;
514 struct vmu_cache *pcache;
515 struct mdev_part *mpart;
516 struct mtd_info *mtd_cur;
517 struct vmupart *part_cur;
518 int error;
519
520 mdev = mq->dev;
521 card = maple_get_drvdata(mdev);
522 res = (unsigned short *) (mq->recvbuf->buf);
523 card->tempA = res[12];
524 card->tempB = res[6];
525
526 dev_info(&mdev->dev, "VMU device at partition %d has %d user "
527 "blocks with a root block at %d\n", card->partition,
528 card->tempA, card->tempB);
529
530 part_cur = &card->parts[card->partition];
531 part_cur->user_blocks = card->tempA;
532 part_cur->root_block = card->tempB;
533 part_cur->numblocks = card->tempB + 1;
534 part_cur->name = kmalloc(12, GFP_KERNEL);
535 if (!part_cur->name)
536 goto fail_name;
537
538 sprintf(part_cur->name, "vmu%d.%d.%d",
539 mdev->port, mdev->unit, card->partition);
540 mtd_cur = &card->mtd[card->partition];
541 mtd_cur->name = part_cur->name;
542 mtd_cur->type = 8;
543 mtd_cur->flags = MTD_WRITEABLE|MTD_NO_ERASE;
544 mtd_cur->size = part_cur->numblocks * card->blocklen;
545 mtd_cur->erasesize = card->blocklen;
546 mtd_cur->write = vmu_flash_write;
547 mtd_cur->read = vmu_flash_read;
548 mtd_cur->sync = vmu_flash_sync;
549 mtd_cur->writesize = card->blocklen;
550
551 mpart = kmalloc(sizeof(struct mdev_part), GFP_KERNEL);
552 if (!mpart)
553 goto fail_mpart;
554
555 mpart->mdev = mdev;
556 mpart->partition = card->partition;
557 mtd_cur->priv = mpart;
558 mtd_cur->owner = THIS_MODULE;
559
560 pcache = kzalloc(sizeof(struct vmu_cache), GFP_KERNEL);
561 if (!pcache)
562 goto fail_cache_create;
563 part_cur->pcache = pcache;
564
565 error = add_mtd_device(mtd_cur);
566 if (error)
567 goto fail_mtd_register;
568
569 maple_getcond_callback(mdev, NULL, 0,
570 MAPLE_FUNC_MEMCARD);
571
572 /*
573 * Set up a recursive call to the (probably theoretical)
574 * second or more partition
575 */
576 if (++card->partition < card->partitions) {
577 partnum = cpu_to_be32(card->partition << 24);
578 maple_getcond_callback(mdev, vmu_queryblocks, 0,
579 MAPLE_FUNC_MEMCARD);
580 maple_add_packet(mdev, MAPLE_FUNC_MEMCARD,
581 MAPLE_COMMAND_GETMINFO, 2, &partnum);
582 }
583 return;
584
585fail_mtd_register:
586 dev_err(&mdev->dev, "Could not register maple device at (%d, %d)"
587 "error is 0x%X\n", mdev->port, mdev->unit, error);
588 for (error = 0; error <= card->partition; error++) {
589 kfree(((card->parts)[error]).pcache);
590 ((card->parts)[error]).pcache = NULL;
591 }
592fail_cache_create:
593fail_mpart:
594 for (error = 0; error <= card->partition; error++) {
595 kfree(((card->mtd)[error]).priv);
596 ((card->mtd)[error]).priv = NULL;
597 }
598 maple_getcond_callback(mdev, NULL, 0,
599 MAPLE_FUNC_MEMCARD);
600 kfree(part_cur->name);
601fail_name:
602 return;
603}
604
605/* Handles very basic info about the flash, queries for details */
606static int __devinit vmu_connect(struct maple_device *mdev)
607{
608 unsigned long test_flash_data, basic_flash_data;
609 int c, error;
610 struct memcard *card;
611 u32 partnum = 0;
612
613 test_flash_data = be32_to_cpu(mdev->devinfo.function);
614 /* Need to count how many bits are set - to find out which
615 * function_data element has details of the memory card:
616 * using Brian Kernighan's/Peter Wegner's method */
617 for (c = 0; test_flash_data; c++)
618 test_flash_data &= test_flash_data - 1;
619
620 basic_flash_data = be32_to_cpu(mdev->devinfo.function_data[c - 1]);
621
622 card = kmalloc(sizeof(struct memcard), GFP_KERNEL);
623 if (!card) {
624 error = ENOMEM;
625 goto fail_nomem;
626 }
627
628 card->partitions = (basic_flash_data >> 24 & 0xFF) + 1;
629 card->blocklen = ((basic_flash_data >> 16 & 0xFF) + 1) << 5;
630 card->writecnt = basic_flash_data >> 12 & 0xF;
631 card->readcnt = basic_flash_data >> 8 & 0xF;
632 card->removeable = basic_flash_data >> 7 & 1;
633
634 card->partition = 0;
635
636 /*
637 * Not sure there are actually any multi-partition devices in the
638 * real world, but the hardware supports them, so, so will we
639 */
640 card->parts = kmalloc(sizeof(struct vmupart) * card->partitions,
641 GFP_KERNEL);
642 if (!card->parts) {
643 error = -ENOMEM;
644 goto fail_partitions;
645 }
646
647 card->mtd = kmalloc(sizeof(struct mtd_info) * card->partitions,
648 GFP_KERNEL);
649 if (!card->mtd) {
650 error = -ENOMEM;
651 goto fail_mtd_info;
652 }
653
654 maple_set_drvdata(mdev, card);
655
656 /*
657 * We want to trap meminfo not get cond
658 * so set interval to zero, but rely on maple bus
659 * driver to pass back the results of the meminfo
660 */
661 maple_getcond_callback(mdev, vmu_queryblocks, 0,
662 MAPLE_FUNC_MEMCARD);
663
664 /* Make sure we are clear to go */
665 if (atomic_read(&mdev->busy) == 1) {
666 wait_event_interruptible_timeout(mdev->maple_wait,
667 atomic_read(&mdev->busy) == 0, HZ);
668 if (atomic_read(&mdev->busy) == 1) {
669 dev_notice(&mdev->dev, "VMU at (%d, %d) is busy\n",
670 mdev->port, mdev->unit);
671 error = -EAGAIN;
672 goto fail_device_busy;
673 }
674 }
675
676 atomic_set(&mdev->busy, 1);
677
678 /*
679 * Set up the minfo call: vmu_queryblocks will handle
680 * the information passed back
681 */
682 error = maple_add_packet(mdev, MAPLE_FUNC_MEMCARD,
683 MAPLE_COMMAND_GETMINFO, 2, &partnum);
684 if (error) {
685 dev_err(&mdev->dev, "Could not lock VMU at (%d, %d)"
686 " error is 0x%X\n", mdev->port, mdev->unit, error);
687 goto fail_mtd_info;
688 }
689 return 0;
690
691fail_device_busy:
692 kfree(card->mtd);
693fail_mtd_info:
694 kfree(card->parts);
695fail_partitions:
696 kfree(card);
697fail_nomem:
698 return error;
699}
700
701static void __devexit vmu_disconnect(struct maple_device *mdev)
702{
703 struct memcard *card;
704 struct mdev_part *mpart;
705 int x;
706
707 mdev->callback = NULL;
708 card = maple_get_drvdata(mdev);
709 for (x = 0; x < card->partitions; x++) {
710 mpart = ((card->mtd)[x]).priv;
711 mpart->mdev = NULL;
712 del_mtd_device(&((card->mtd)[x]));
713 kfree(((card->parts)[x]).name);
714 }
715 kfree(card->parts);
716 kfree(card->mtd);
717 kfree(card);
718}
719
720/* Callback to handle eccentricities of both mtd subsystem
721 * and general flakyness of Dreamcast VMUs
722 */
723static int vmu_can_unload(struct maple_device *mdev)
724{
725 struct memcard *card;
726 int x;
727 struct mtd_info *mtd;
728
729 card = maple_get_drvdata(mdev);
730 for (x = 0; x < card->partitions; x++) {
731 mtd = &((card->mtd)[x]);
732 if (mtd->usecount > 0)
733 return 0;
734 }
735 return 1;
736}
737
738#define ERRSTR "VMU at (%d, %d) file error -"
739
740static void vmu_file_error(struct maple_device *mdev, void *recvbuf)
741{
742 enum maple_file_errors error = ((int *)recvbuf)[1];
743
744 switch (error) {
745
746 case MAPLE_FILEERR_INVALID_PARTITION:
747 dev_notice(&mdev->dev, ERRSTR " invalid partition number\n",
748 mdev->port, mdev->unit);
749 break;
750
751 case MAPLE_FILEERR_PHASE_ERROR:
752 dev_notice(&mdev->dev, ERRSTR " phase error\n",
753 mdev->port, mdev->unit);
754 break;
755
756 case MAPLE_FILEERR_INVALID_BLOCK:
757 dev_notice(&mdev->dev, ERRSTR " invalid block number\n",
758 mdev->port, mdev->unit);
759 break;
760
761 case MAPLE_FILEERR_WRITE_ERROR:
762 dev_notice(&mdev->dev, ERRSTR " write error\n",
763 mdev->port, mdev->unit);
764 break;
765
766 case MAPLE_FILEERR_INVALID_WRITE_LENGTH:
767 dev_notice(&mdev->dev, ERRSTR " invalid write length\n",
768 mdev->port, mdev->unit);
769 break;
770
771 case MAPLE_FILEERR_BAD_CRC:
772 dev_notice(&mdev->dev, ERRSTR " bad CRC\n",
773 mdev->port, mdev->unit);
774 break;
775
776 default:
777 dev_notice(&mdev->dev, ERRSTR " 0x%X\n",
778 mdev->port, mdev->unit, error);
779 }
780}
781
782
783static int __devinit probe_maple_vmu(struct device *dev)
784{
785 int error;
786 struct maple_device *mdev = to_maple_dev(dev);
787 struct maple_driver *mdrv = to_maple_driver(dev->driver);
788
789 mdev->can_unload = vmu_can_unload;
790 mdev->fileerr_handler = vmu_file_error;
791 mdev->driver = mdrv;
792
793 error = vmu_connect(mdev);
794 if (error)
795 return error;
796
797 return 0;
798}
799
800static int __devexit remove_maple_vmu(struct device *dev)
801{
802 struct maple_device *mdev = to_maple_dev(dev);
803
804 vmu_disconnect(mdev);
805 return 0;
806}
807
808static struct maple_driver vmu_flash_driver = {
809 .function = MAPLE_FUNC_MEMCARD,
810 .drv = {
811 .name = "Dreamcast_visual_memory",
812 .probe = probe_maple_vmu,
813 .remove = __devexit_p(remove_maple_vmu),
814 },
815};
816
817static int __init vmu_flash_map_init(void)
818{
819 return maple_driver_register(&vmu_flash_driver);
820}
821
822static void __exit vmu_flash_map_exit(void)
823{
824 maple_driver_unregister(&vmu_flash_driver);
825}
826
827module_init(vmu_flash_map_init);
828module_exit(vmu_flash_map_exit);
829
830MODULE_LICENSE("GPL");
831MODULE_AUTHOR("Adrian McMenamin");
832MODULE_DESCRIPTION("Flash mapping for Sega Dreamcast visual memory");
diff --git a/drivers/mtd/nand/excite_nandflash.c b/drivers/mtd/nand/excite_nandflash.c
index ced14b5294d5..72446fb48d4b 100644
--- a/drivers/mtd/nand/excite_nandflash.c
+++ b/drivers/mtd/nand/excite_nandflash.c
@@ -128,11 +128,11 @@ static int excite_nand_devready(struct mtd_info *mtd)
128 * The binding to the mtd and all allocated 128 * The binding to the mtd and all allocated
129 * resources are released. 129 * resources are released.
130 */ 130 */
131static int __exit excite_nand_remove(struct device *dev) 131static int __exit excite_nand_remove(struct platform_device *dev)
132{ 132{
133 struct excite_nand_drvdata * const this = dev_get_drvdata(dev); 133 struct excite_nand_drvdata * const this = platform_get_drvdata(dev);
134 134
135 dev_set_drvdata(dev, NULL); 135 platform_set_drvdata(dev, NULL);
136 136
137 if (unlikely(!this)) { 137 if (unlikely(!this)) {
138 printk(KERN_ERR "%s: called %s without private data!!", 138 printk(KERN_ERR "%s: called %s without private data!!",
@@ -159,9 +159,8 @@ static int __exit excite_nand_remove(struct device *dev)
159 * it can allocate all necessary resources then calls the 159 * it can allocate all necessary resources then calls the
160 * nand layer to look for devices. 160 * nand layer to look for devices.
161*/ 161*/
162static int __init excite_nand_probe(struct device *dev) 162static int __init excite_nand_probe(struct platform_device *pdev)
163{ 163{
164 struct platform_device * const pdev = to_platform_device(dev);
165 struct excite_nand_drvdata *drvdata; /* private driver data */ 164 struct excite_nand_drvdata *drvdata; /* private driver data */
166 struct nand_chip *board_chip; /* private flash chip data */ 165 struct nand_chip *board_chip; /* private flash chip data */
167 struct mtd_info *board_mtd; /* mtd info for this board */ 166 struct mtd_info *board_mtd; /* mtd info for this board */
@@ -175,7 +174,7 @@ static int __init excite_nand_probe(struct device *dev)
175 } 174 }
176 175
177 /* bind private data into driver */ 176 /* bind private data into driver */
178 dev_set_drvdata(dev, drvdata); 177 platform_set_drvdata(pdev, drvdata);
179 178
180 /* allocate and map the resource */ 179 /* allocate and map the resource */
181 drvdata->regs = 180 drvdata->regs =
@@ -219,23 +218,25 @@ static int __init excite_nand_probe(struct device *dev)
219 return 0; 218 return 0;
220} 219}
221 220
222static struct device_driver excite_nand_driver = { 221static struct platform_driver excite_nand_driver = {
223 .name = "excite_nand", 222 .driver = {
224 .bus = &platform_bus_type, 223 .name = "excite_nand",
224 .owner = THIS_MODULE,
225 },
225 .probe = excite_nand_probe, 226 .probe = excite_nand_probe,
226 .remove = __exit_p(excite_nand_remove) 227 .remove = __devexit_p(excite_nand_remove)
227}; 228};
228 229
229static int __init excite_nand_init(void) 230static int __init excite_nand_init(void)
230{ 231{
231 pr_info("Basler eXcite nand flash driver Version " 232 pr_info("Basler eXcite nand flash driver Version "
232 EXCITE_NANDFLASH_VERSION "\n"); 233 EXCITE_NANDFLASH_VERSION "\n");
233 return driver_register(&excite_nand_driver); 234 return platform_driver_register(&excite_nand_driver);
234} 235}
235 236
236static void __exit excite_nand_exit(void) 237static void __exit excite_nand_exit(void)
237{ 238{
238 driver_unregister(&excite_nand_driver); 239 platform_driver_unregister(&excite_nand_driver);
239} 240}
240 241
241module_init(excite_nand_init); 242module_init(excite_nand_init);
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 582cf80f555a..89bf85af642c 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -187,7 +187,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
187 return -ENODEV; 187 return -ENODEV;
188 188
189 ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s", 189 ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s",
190 ndfc->ofdev->dev.bus_id, flash_np->name); 190 dev_name(&ndfc->ofdev->dev), flash_np->name);
191 if (!ndfc->mtd.name) { 191 if (!ndfc->mtd.name) {
192 ret = -ENOMEM; 192 ret = -ENOMEM;
193 goto err; 193 goto err;
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c
index 5b69e7773c6c..3a496c33fb52 100644
--- a/drivers/mtd/onenand/generic.c
+++ b/drivers/mtd/onenand/generic.c
@@ -36,10 +36,9 @@ struct onenand_info {
36 struct onenand_chip onenand; 36 struct onenand_chip onenand;
37}; 37};
38 38
39static int __devinit generic_onenand_probe(struct device *dev) 39static int __devinit generic_onenand_probe(struct platform_device *pdev)
40{ 40{
41 struct onenand_info *info; 41 struct onenand_info *info;
42 struct platform_device *pdev = to_platform_device(dev);
43 struct flash_platform_data *pdata = pdev->dev.platform_data; 42 struct flash_platform_data *pdata = pdev->dev.platform_data;
44 struct resource *res = pdev->resource; 43 struct resource *res = pdev->resource;
45 unsigned long size = res->end - res->start + 1; 44 unsigned long size = res->end - res->start + 1;
@@ -49,7 +48,7 @@ static int __devinit generic_onenand_probe(struct device *dev)
49 if (!info) 48 if (!info)
50 return -ENOMEM; 49 return -ENOMEM;
51 50
52 if (!request_mem_region(res->start, size, dev->driver->name)) { 51 if (!request_mem_region(res->start, size, pdev->dev.driver->name)) {
53 err = -EBUSY; 52 err = -EBUSY;
54 goto out_free_info; 53 goto out_free_info;
55 } 54 }
@@ -82,7 +81,7 @@ static int __devinit generic_onenand_probe(struct device *dev)
82#endif 81#endif
83 err = add_mtd_device(&info->mtd); 82 err = add_mtd_device(&info->mtd);
84 83
85 dev_set_drvdata(&pdev->dev, info); 84 platform_set_drvdata(pdev, info);
86 85
87 return 0; 86 return 0;
88 87
@@ -96,14 +95,13 @@ out_free_info:
96 return err; 95 return err;
97} 96}
98 97
99static int __devexit generic_onenand_remove(struct device *dev) 98static int __devexit generic_onenand_remove(struct platform_device *pdev)
100{ 99{
101 struct platform_device *pdev = to_platform_device(dev); 100 struct onenand_info *info = platform_get_drvdata(pdev);
102 struct onenand_info *info = dev_get_drvdata(&pdev->dev);
103 struct resource *res = pdev->resource; 101 struct resource *res = pdev->resource;
104 unsigned long size = res->end - res->start + 1; 102 unsigned long size = res->end - res->start + 1;
105 103
106 dev_set_drvdata(&pdev->dev, NULL); 104 platform_set_drvdata(pdev, NULL);
107 105
108 if (info) { 106 if (info) {
109 if (info->parts) 107 if (info->parts)
@@ -120,9 +118,11 @@ static int __devexit generic_onenand_remove(struct device *dev)
120 return 0; 118 return 0;
121} 119}
122 120
123static struct device_driver generic_onenand_driver = { 121static struct platform_driver generic_onenand_driver = {
124 .name = DRIVER_NAME, 122 .driver = {
125 .bus = &platform_bus_type, 123 .name = DRIVER_NAME,
124 .owner = THIS_MODULE,
125 },
126 .probe = generic_onenand_probe, 126 .probe = generic_onenand_probe,
127 .remove = __devexit_p(generic_onenand_remove), 127 .remove = __devexit_p(generic_onenand_remove),
128}; 128};
@@ -131,12 +131,12 @@ MODULE_ALIAS(DRIVER_NAME);
131 131
132static int __init generic_onenand_init(void) 132static int __init generic_onenand_init(void)
133{ 133{
134 return driver_register(&generic_onenand_driver); 134 return platform_driver_register(&generic_onenand_driver);
135} 135}
136 136
137static void __exit generic_onenand_exit(void) 137static void __exit generic_onenand_exit(void)
138{ 138{
139 driver_unregister(&generic_onenand_driver); 139 platform_driver_unregister(&generic_onenand_driver);
140} 140}
141 141
142module_init(generic_onenand_init); 142module_init(generic_onenand_init);
diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c
index 4e7a5faf0351..664835b822fb 100644
--- a/drivers/net/mipsnet.c
+++ b/drivers/net/mipsnet.c
@@ -237,7 +237,7 @@ static void mipsnet_set_mclist(struct net_device *dev)
237{ 237{
238} 238}
239 239
240static int __init mipsnet_probe(struct device *dev) 240static int __init mipsnet_probe(struct platform_device *dev)
241{ 241{
242 struct net_device *netdev; 242 struct net_device *netdev;
243 int err; 243 int err;
@@ -248,7 +248,7 @@ static int __init mipsnet_probe(struct device *dev)
248 goto out; 248 goto out;
249 } 249 }
250 250
251 dev_set_drvdata(dev, netdev); 251 platform_set_drvdata(dev, netdev);
252 252
253 netdev->open = mipsnet_open; 253 netdev->open = mipsnet_open;
254 netdev->stop = mipsnet_close; 254 netdev->stop = mipsnet_close;
@@ -293,23 +293,25 @@ out:
293 return err; 293 return err;
294} 294}
295 295
296static int __devexit mipsnet_device_remove(struct device *device) 296static int __devexit mipsnet_device_remove(struct platform_device *device)
297{ 297{
298 struct net_device *dev = dev_get_drvdata(device); 298 struct net_device *dev = platform_get_drvdata(device);
299 299
300 unregister_netdev(dev); 300 unregister_netdev(dev);
301 release_region(dev->base_addr, sizeof(struct mipsnet_regs)); 301 release_region(dev->base_addr, sizeof(struct mipsnet_regs));
302 free_netdev(dev); 302 free_netdev(dev);
303 dev_set_drvdata(device, NULL); 303 platform_set_drvdata(device, NULL);
304 304
305 return 0; 305 return 0;
306} 306}
307 307
308static struct device_driver mipsnet_driver = { 308static struct platform_driver mipsnet_driver = {
309 .name = mipsnet_string, 309 .driver = {
310 .bus = &platform_bus_type, 310 .name = mipsnet_string,
311 .probe = mipsnet_probe, 311 .owner = THIS_MODULE,
312 .remove = __devexit_p(mipsnet_device_remove), 312 },
313 .probe = mipsnet_probe,
314 .remove = __devexit_p(mipsnet_device_remove),
313}; 315};
314 316
315static int __init mipsnet_init_module(void) 317static int __init mipsnet_init_module(void)
@@ -319,7 +321,7 @@ static int __init mipsnet_init_module(void)
319 printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. " 321 printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. "
320 "(c)2005 MIPS Technologies, Inc.\n", MIPSNET_VERSION); 322 "(c)2005 MIPS Technologies, Inc.\n", MIPSNET_VERSION);
321 323
322 err = driver_register(&mipsnet_driver); 324 err = platform_driver_register(&mipsnet_driver);
323 if (err) 325 if (err)
324 printk(KERN_ERR "Driver registration failed\n"); 326 printk(KERN_ERR "Driver registration failed\n");
325 327
@@ -328,7 +330,7 @@ static int __init mipsnet_init_module(void)
328 330
329static void __exit mipsnet_exit_module(void) 331static void __exit mipsnet_exit_module(void)
330{ 332{
331 driver_unregister(&mipsnet_driver); 333 platform_driver_unregister(&mipsnet_driver);
332} 334}
333 335
334module_init(mipsnet_init_module); 336module_init(mipsnet_init_module);
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index d4fb4acdbebd..4e9bd380a5c2 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -2649,8 +2649,6 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
2649 int err = -ENODEV; 2649 int err = -ENODEV;
2650 2650
2651 sbus_dp = to_of_device(op->dev.parent)->node; 2651 sbus_dp = to_of_device(op->dev.parent)->node;
2652 if (is_qfe)
2653 sbus_dp = to_of_device(op->dev.parent->parent)->node;
2654 2652
2655 /* We can match PCI devices too, do not accept those here. */ 2653 /* We can match PCI devices too, do not accept those here. */
2656 if (strcmp(sbus_dp->name, "sbus")) 2654 if (strcmp(sbus_dp->name, "sbus"))
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index d539d9df88e7..bb5a1c9597cb 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -479,7 +479,7 @@ dino_card_setup(struct pci_bus *bus, void __iomem *base_addr)
479 res = &dino_dev->hba.lmmio_space; 479 res = &dino_dev->hba.lmmio_space;
480 res->flags = IORESOURCE_MEM; 480 res->flags = IORESOURCE_MEM;
481 size = scnprintf(name, sizeof(name), "Dino LMMIO (%s)", 481 size = scnprintf(name, sizeof(name), "Dino LMMIO (%s)",
482 bus->bridge->bus_id); 482 dev_name(bus->bridge));
483 res->name = kmalloc(size+1, GFP_KERNEL); 483 res->name = kmalloc(size+1, GFP_KERNEL);
484 if(res->name) 484 if(res->name)
485 strcpy((char *)res->name, name); 485 strcpy((char *)res->name, name);
@@ -493,7 +493,7 @@ dino_card_setup(struct pci_bus *bus, void __iomem *base_addr)
493 struct list_head *ln, *tmp_ln; 493 struct list_head *ln, *tmp_ln;
494 494
495 printk(KERN_ERR "Dino: cannot attach bus %s\n", 495 printk(KERN_ERR "Dino: cannot attach bus %s\n",
496 bus->bridge->bus_id); 496 dev_name(bus->bridge));
497 /* kill the bus, we can't do anything with it */ 497 /* kill the bus, we can't do anything with it */
498 list_for_each_safe(ln, tmp_ln, &bus->devices) { 498 list_for_each_safe(ln, tmp_ln, &bus->devices) {
499 struct pci_dev *dev = pci_dev_b(ln); 499 struct pci_dev *dev = pci_dev_b(ln);
@@ -587,7 +587,7 @@ dino_fixup_bus(struct pci_bus *bus)
587 bus->resource[i+1] = &res[i]; 587 bus->resource[i+1] = &res[i];
588 } 588 }
589 589
590 } else if(bus->self) { 590 } else if (bus->parent) {
591 int i; 591 int i;
592 592
593 pci_read_bridge_bases(bus); 593 pci_read_bridge_bases(bus);
@@ -611,12 +611,12 @@ dino_fixup_bus(struct pci_bus *bus)
611 } 611 }
612 612
613 DBG("DEBUG %s assigning %d [0x%lx,0x%lx]\n", 613 DBG("DEBUG %s assigning %d [0x%lx,0x%lx]\n",
614 bus->self->dev.bus_id, i, 614 dev_name(&bus->self->dev), i,
615 bus->self->resource[i].start, 615 bus->self->resource[i].start,
616 bus->self->resource[i].end); 616 bus->self->resource[i].end);
617 pci_assign_resource(bus->self, i); 617 pci_assign_resource(bus->self, i);
618 DBG("DEBUG %s after assign %d [0x%lx,0x%lx]\n", 618 DBG("DEBUG %s after assign %d [0x%lx,0x%lx]\n",
619 bus->self->dev.bus_id, i, 619 dev_name(&bus->self->dev), i,
620 bus->self->resource[i].start, 620 bus->self->resource[i].start,
621 bus->self->resource[i].end); 621 bus->self->resource[i].end);
622 } 622 }
@@ -1026,7 +1026,8 @@ static int __init dino_probe(struct parisc_device *dev)
1026 dino_current_bus = bus->subordinate + 1; 1026 dino_current_bus = bus->subordinate + 1;
1027 pci_bus_assign_resources(bus); 1027 pci_bus_assign_resources(bus);
1028 } else { 1028 } else {
1029 printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (probably duplicate bus number %d)\n", dev->dev.bus_id, dino_current_bus); 1029 printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (probably duplicate bus number %d)\n",
1030 dev_name(&dev->dev), dino_current_bus);
1030 /* increment the bus number in case of duplicates */ 1031 /* increment the bus number in case of duplicates */
1031 dino_current_bus++; 1032 dino_current_bus++;
1032 } 1033 }
diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c
index e76db9e4d504..d33632917696 100644
--- a/drivers/parisc/gsc.c
+++ b/drivers/parisc/gsc.c
@@ -186,29 +186,34 @@ void gsc_asic_assign_irq(struct gsc_asic *asic, int local_irq, int *irqp)
186 *irqp = irq; 186 *irqp = irq;
187} 187}
188 188
189static struct device *next_device(struct klist_iter *i) 189struct gsc_fixup_struct {
190 void (*choose_irq)(struct parisc_device *, void *);
191 void *ctrl;
192};
193
194static int gsc_fixup_irqs_callback(struct device *dev, void *data)
190{ 195{
191 struct klist_node * n = klist_next(i); 196 struct parisc_device *padev = to_parisc_device(dev);
192 return n ? container_of(n, struct device, knode_parent) : NULL; 197 struct gsc_fixup_struct *gf = data;
198
199 /* work-around for 715/64 and others which have parent
200 at path [5] and children at path [5/0/x] */
201 if (padev->id.hw_type == HPHW_FAULTY)
202 gsc_fixup_irqs(padev, gf->ctrl, gf->choose_irq);
203 gf->choose_irq(padev, gf->ctrl);
204
205 return 0;
193} 206}
194 207
195void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl, 208void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl,
196 void (*choose_irq)(struct parisc_device *, void *)) 209 void (*choose_irq)(struct parisc_device *, void *))
197{ 210{
198 struct device *dev; 211 struct gsc_fixup_struct data = {
199 struct klist_iter i; 212 .choose_irq = choose_irq,
200 213 .ctrl = ctrl,
201 klist_iter_init(&parent->dev.klist_children, &i); 214 };
202 while ((dev = next_device(&i))) { 215
203 struct parisc_device *padev = to_parisc_device(dev); 216 device_for_each_child(&parent->dev, &data, gsc_fixup_irqs_callback);
204
205 /* work-around for 715/64 and others which have parent
206 at path [5] and children at path [5/0/x] */
207 if (padev->id.hw_type == HPHW_FAULTY)
208 return gsc_fixup_irqs(padev, ctrl, choose_irq);
209 choose_irq(padev, ctrl);
210 }
211 klist_iter_exit(&i);
212} 217}
213 218
214int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic) 219int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic)
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 0797659ee016..501aaf1f253f 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -487,7 +487,7 @@ iosapic_xlate_pin(struct iosapic_info *isi, struct pci_dev *pcidev)
487 } 487 }
488 488
489 /* Check if pcidev behind a PPB */ 489 /* Check if pcidev behind a PPB */
490 if (NULL != pcidev->bus->self) { 490 if (pcidev->bus->parent) {
491 /* Convert pcidev INTR_PIN into something we 491 /* Convert pcidev INTR_PIN into something we
492 ** can lookup in the IRT. 492 ** can lookup in the IRT.
493 */ 493 */
@@ -523,10 +523,9 @@ iosapic_xlate_pin(struct iosapic_info *isi, struct pci_dev *pcidev)
523#endif /* PCI_BRIDGE_FUNCS */ 523#endif /* PCI_BRIDGE_FUNCS */
524 524
525 /* 525 /*
526 ** Locate the host slot the PPB nearest the Host bus 526 * Locate the host slot of the PPB.
527 ** adapter. 527 */
528 */ 528 while (p->parent->parent)
529 while (NULL != p->parent->self)
530 p = p->parent; 529 p = p->parent;
531 530
532 intr_slot = PCI_SLOT(p->self->devfn); 531 intr_slot = PCI_SLOT(p->self->devfn);
@@ -709,11 +708,14 @@ static void iosapic_set_affinity_irq(unsigned int irq,
709 struct vector_info *vi = iosapic_get_vector(irq); 708 struct vector_info *vi = iosapic_get_vector(irq);
710 u32 d0, d1, dummy_d0; 709 u32 d0, d1, dummy_d0;
711 unsigned long flags; 710 unsigned long flags;
711 int dest_cpu;
712 712
713 if (cpu_check_affinity(irq, dest)) 713 dest_cpu = cpu_check_affinity(irq, dest);
714 if (dest_cpu < 0)
714 return; 715 return;
715 716
716 vi->txn_addr = txn_affinity_addr(irq, cpumask_first(dest)); 717 irq_desc[irq].affinity = cpumask_of_cpu(dest_cpu);
718 vi->txn_addr = txn_affinity_addr(irq, dest_cpu);
717 719
718 spin_lock_irqsave(&iosapic_lock, flags); 720 spin_lock_irqsave(&iosapic_lock, flags);
719 /* d1 contains the destination CPU, so only want to set that 721 /* d1 contains the destination CPU, so only want to set that
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index d8233de8c75d..59fbbf128365 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -644,7 +644,7 @@ lba_fixup_bus(struct pci_bus *bus)
644 ** Properly Setup MMIO resources for this bus. 644 ** Properly Setup MMIO resources for this bus.
645 ** pci_alloc_primary_bus() mangles this. 645 ** pci_alloc_primary_bus() mangles this.
646 */ 646 */
647 if (bus->self) { 647 if (bus->parent) {
648 int i; 648 int i;
649 /* PCI-PCI Bridge */ 649 /* PCI-PCI Bridge */
650 pci_read_bridge_bases(bus); 650 pci_read_bridge_bases(bus);
@@ -802,7 +802,7 @@ lba_fixup_bus(struct pci_bus *bus)
802** Can't fixup here anyway....garr... 802** Can't fixup here anyway....garr...
803*/ 803*/
804 if (fbb_enable) { 804 if (fbb_enable) {
805 if (bus->self) { 805 if (bus->parent) {
806 u8 control; 806 u8 control;
807 /* enable on PPB */ 807 /* enable on PPB */
808 (void) pci_read_config_byte(bus->self, PCI_BRIDGE_CONTROL, &control); 808 (void) pci_read_config_byte(bus->self, PCI_BRIDGE_CONTROL, &control);
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index a70cf16ee1ad..e5999c4cedc8 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -1206,30 +1206,48 @@ sba_alloc_pdir(unsigned int pdir_size)
1206 return (void *) pdir_base; 1206 return (void *) pdir_base;
1207} 1207}
1208 1208
1209static struct device *next_device(struct klist_iter *i) 1209struct ibase_data_struct {
1210 struct ioc *ioc;
1211 int ioc_num;
1212};
1213
1214static int setup_ibase_imask_callback(struct device *dev, void *data)
1210{ 1215{
1211 struct klist_node * n = klist_next(i); 1216 /* lba_set_iregs() is in drivers/parisc/lba_pci.c */
1212 return n ? container_of(n, struct device, knode_parent) : NULL; 1217 extern void lba_set_iregs(struct parisc_device *, u32, u32);
1218 struct parisc_device *lba = to_parisc_device(dev);
1219 struct ibase_data_struct *ibd = data;
1220 int rope_num = (lba->hpa.start >> 13) & 0xf;
1221 if (rope_num >> 3 == ibd->ioc_num)
1222 lba_set_iregs(lba, ibd->ioc->ibase, ibd->ioc->imask);
1223 return 0;
1213} 1224}
1214 1225
1215/* setup Mercury or Elroy IBASE/IMASK registers. */ 1226/* setup Mercury or Elroy IBASE/IMASK registers. */
1216static void 1227static void
1217setup_ibase_imask(struct parisc_device *sba, struct ioc *ioc, int ioc_num) 1228setup_ibase_imask(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1218{ 1229{
1219 /* lba_set_iregs() is in drivers/parisc/lba_pci.c */ 1230 struct ibase_data_struct ibase_data = {
1220 extern void lba_set_iregs(struct parisc_device *, u32, u32); 1231 .ioc = ioc,
1221 struct device *dev; 1232 .ioc_num = ioc_num,
1222 struct klist_iter i; 1233 };
1223 1234
1224 klist_iter_init(&sba->dev.klist_children, &i); 1235 device_for_each_child(&sba->dev, &ibase_data,
1225 while ((dev = next_device(&i))) { 1236 setup_ibase_imask_callback);
1226 struct parisc_device *lba = to_parisc_device(dev); 1237}
1227 int rope_num = (lba->hpa.start >> 13) & 0xf; 1238
1228 if (rope_num >> 3 == ioc_num) 1239#ifdef SBA_AGP_SUPPORT
1229 lba_set_iregs(lba, ioc->ibase, ioc->imask); 1240static int
1230 } 1241sba_ioc_find_quicksilver(struct device *dev, void *data)
1231 klist_iter_exit(&i); 1242{
1243 int *agp_found = data;
1244 struct parisc_device *lba = to_parisc_device(dev);
1245
1246 if (IS_QUICKSILVER(lba))
1247 *agp_found = 1;
1248 return 0;
1232} 1249}
1250#endif
1233 1251
1234static void 1252static void
1235sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num) 1253sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
@@ -1332,9 +1350,6 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1332 WRITE_REG(ioc->ibase | 31, ioc->ioc_hpa + IOC_PCOM); 1350 WRITE_REG(ioc->ibase | 31, ioc->ioc_hpa + IOC_PCOM);
1333 1351
1334#ifdef SBA_AGP_SUPPORT 1352#ifdef SBA_AGP_SUPPORT
1335{
1336 struct klist_iter i;
1337 struct device *dev = NULL;
1338 1353
1339 /* 1354 /*
1340 ** If an AGP device is present, only use half of the IOV space 1355 ** If an AGP device is present, only use half of the IOV space
@@ -1344,13 +1359,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1344 ** We program the next pdir index after we stop w/ a key for 1359 ** We program the next pdir index after we stop w/ a key for
1345 ** the GART code to handshake on. 1360 ** the GART code to handshake on.
1346 */ 1361 */
1347 klist_iter_init(&sba->dev.klist_children, &i); 1362 device_for_each_child(&sba->dev, &agp_found, sba_ioc_find_quicksilver);
1348 while ((dev = next_device(&i))) {
1349 struct parisc_device *lba = to_parisc_device(dev);
1350 if (IS_QUICKSILVER(lba))
1351 agp_found = 1;
1352 }
1353 klist_iter_exit(&i);
1354 1363
1355 if (agp_found && sba_reserve_agpgart) { 1364 if (agp_found && sba_reserve_agpgart) {
1356 printk(KERN_INFO "%s: reserving %dMb of IOVA space for agpgart\n", 1365 printk(KERN_INFO "%s: reserving %dMb of IOVA space for agpgart\n",
@@ -1358,9 +1367,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1358 ioc->pdir_size /= 2; 1367 ioc->pdir_size /= 2;
1359 ioc->pdir_base[PDIR_INDEX(iova_space_size/2)] = SBA_AGPGART_COOKIE; 1368 ioc->pdir_base[PDIR_INDEX(iova_space_size/2)] = SBA_AGPGART_COOKIE;
1360 } 1369 }
1361}
1362#endif /*SBA_AGP_SUPPORT*/ 1370#endif /*SBA_AGP_SUPPORT*/
1363
1364} 1371}
1365 1372
1366static void 1373static void
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig
index eacfb13998bb..9aa4fe100a0d 100644
--- a/drivers/pci/hotplug/Kconfig
+++ b/drivers/pci/hotplug/Kconfig
@@ -143,7 +143,7 @@ config HOTPLUG_PCI_SHPC
143 143
144config HOTPLUG_PCI_RPA 144config HOTPLUG_PCI_RPA
145 tristate "RPA PCI Hotplug driver" 145 tristate "RPA PCI Hotplug driver"
146 depends on PPC_PSERIES && PPC64 && !HOTPLUG_PCI_FAKE 146 depends on PPC_PSERIES && EEH && !HOTPLUG_PCI_FAKE
147 help 147 help
148 Say Y here if you have a RPA system that supports PCI Hotplug. 148 Say Y here if you have a RPA system that supports PCI Hotplug.
149 149
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index a13abf55d784..8450f4a6568a 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -225,7 +225,8 @@ void cpqhp_shutdown_debugfs(void)
225 225
226void cpqhp_create_debugfs_files(struct controller *ctrl) 226void cpqhp_create_debugfs_files(struct controller *ctrl)
227{ 227{
228 ctrl->dentry = debugfs_create_file(ctrl->pci_dev->dev.bus_id, S_IRUGO, root, ctrl, &debug_ops); 228 ctrl->dentry = debugfs_create_file(dev_name(&ctrl->pci_dev->dev),
229 S_IRUGO, root, ctrl, &debug_ops);
229} 230}
230 231
231void cpqhp_remove_debugfs_files(struct controller *ctrl) 232void cpqhp_remove_debugfs_files(struct controller *ctrl)
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index d0c973685868..382575007382 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -133,6 +133,9 @@ static void set_downstream_devices_error_reporting(struct pci_dev *dev,
133 bool enable) 133 bool enable)
134{ 134{
135 set_device_error_reporting(dev, &enable); 135 set_device_error_reporting(dev, &enable);
136
137 if (!dev->subordinate)
138 return;
136 pci_walk_bus(dev->subordinate, set_device_error_reporting, &enable); 139 pci_walk_bus(dev->subordinate, set_device_error_reporting, &enable);
137} 140}
138 141
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 248b4db91552..5ea566e20b37 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -103,6 +103,7 @@ static int __devinit pcie_portdrv_probe (struct pci_dev *dev,
103static void pcie_portdrv_remove (struct pci_dev *dev) 103static void pcie_portdrv_remove (struct pci_dev *dev)
104{ 104{
105 pcie_port_device_remove(dev); 105 pcie_port_device_remove(dev);
106 pci_disable_device(dev);
106 kfree(pci_get_drvdata(dev)); 107 kfree(pci_get_drvdata(dev));
107} 108}
108 109
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index f20d55368edb..92b9efe9bcaf 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -23,6 +23,7 @@
23#include <linux/acpi.h> 23#include <linux/acpi.h>
24#include <linux/kallsyms.h> 24#include <linux/kallsyms.h>
25#include <linux/dmi.h> 25#include <linux/dmi.h>
26#include <linux/pci-aspm.h>
26#include "pci.h" 27#include "pci.h"
27 28
28int isa_dma_bridge_buggy; 29int isa_dma_bridge_buggy;
@@ -1749,6 +1750,30 @@ static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
1749} 1750}
1750DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt); 1751DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt);
1751 1752
1753/*
1754 * The 82575 and 82598 may experience data corruption issues when transitioning
1755 * out of L0S. To prevent this we need to disable L0S on the pci-e link
1756 */
1757static void __devinit quirk_disable_aspm_l0s(struct pci_dev *dev)
1758{
1759 dev_info(&dev->dev, "Disabling L0s\n");
1760 pci_disable_link_state(dev, PCIE_LINK_STATE_L0S);
1761}
1762DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a7, quirk_disable_aspm_l0s);
1763DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a9, quirk_disable_aspm_l0s);
1764DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10b6, quirk_disable_aspm_l0s);
1765DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c6, quirk_disable_aspm_l0s);
1766DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c7, quirk_disable_aspm_l0s);
1767DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c8, quirk_disable_aspm_l0s);
1768DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10d6, quirk_disable_aspm_l0s);
1769DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10db, quirk_disable_aspm_l0s);
1770DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10dd, quirk_disable_aspm_l0s);
1771DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10e1, quirk_disable_aspm_l0s);
1772DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10ec, quirk_disable_aspm_l0s);
1773DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f1, quirk_disable_aspm_l0s);
1774DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s);
1775DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s);
1776
1752static void __devinit fixup_rev1_53c810(struct pci_dev* dev) 1777static void __devinit fixup_rev1_53c810(struct pci_dev* dev)
1753{ 1778{
1754 /* rev 1 ncr53c810 chips don't set the class at all which means 1779 /* rev 1 ncr53c810 chips don't set the class at all which means
@@ -2097,7 +2122,7 @@ static void __devinit ht_disable_msi_mapping(struct pci_dev *dev)
2097 2122
2098 if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, 2123 if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,
2099 &flags) == 0) { 2124 &flags) == 0) {
2100 dev_info(&dev->dev, "Enabling HT MSI Mapping\n"); 2125 dev_info(&dev->dev, "Disabling HT MSI Mapping\n");
2101 2126
2102 pci_write_config_byte(dev, pos + HT_MSI_FLAGS, 2127 pci_write_config_byte(dev, pos + HT_MSI_FLAGS,
2103 flags & ~HT_MSI_FLAGS_ENABLE); 2128 flags & ~HT_MSI_FLAGS_ENABLE);
@@ -2141,6 +2166,10 @@ static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev)
2141 int pos; 2166 int pos;
2142 int found; 2167 int found;
2143 2168
2169 /* Enabling HT MSI mapping on this device breaks MCP51 */
2170 if (dev->device == 0x270)
2171 return;
2172
2144 /* check if there is HT MSI cap or enabled on this device */ 2173 /* check if there is HT MSI cap or enabled on this device */
2145 found = ht_check_msi_mapping(dev); 2174 found = ht_check_msi_mapping(dev);
2146 2175
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index fc1de46fd20a..90013341cd5f 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -468,13 +468,13 @@ out:
468 return ret; 468 return ret;
469} 469}
470 470
471int au1x00_drv_pcmcia_remove(struct device *dev) 471int au1x00_drv_pcmcia_remove(struct platform_device *dev)
472{ 472{
473 struct skt_dev_info *sinfo = dev_get_drvdata(dev); 473 struct skt_dev_info *sinfo = platform_get_drvdata(dev);
474 int i; 474 int i;
475 475
476 mutex_lock(&pcmcia_sockets_lock); 476 mutex_lock(&pcmcia_sockets_lock);
477 dev_set_drvdata(dev, NULL); 477 platform_set_drvdata(dev, NULL);
478 478
479 for (i = 0; i < sinfo->nskt; i++) { 479 for (i = 0; i < sinfo->nskt; i++) {
480 struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); 480 struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i);
@@ -498,13 +498,13 @@ int au1x00_drv_pcmcia_remove(struct device *dev)
498 * PCMCIA "Driver" API 498 * PCMCIA "Driver" API
499 */ 499 */
500 500
501static int au1x00_drv_pcmcia_probe(struct device *dev) 501static int au1x00_drv_pcmcia_probe(struct platform_device *dev)
502{ 502{
503 int i, ret = -ENODEV; 503 int i, ret = -ENODEV;
504 504
505 mutex_lock(&pcmcia_sockets_lock); 505 mutex_lock(&pcmcia_sockets_lock);
506 for (i=0; i < ARRAY_SIZE(au1x00_pcmcia_hw_init); i++) { 506 for (i=0; i < ARRAY_SIZE(au1x00_pcmcia_hw_init); i++) {
507 ret = au1x00_pcmcia_hw_init[i](dev); 507 ret = au1x00_pcmcia_hw_init[i](&dev->dev);
508 if (ret == 0) 508 if (ret == 0)
509 break; 509 break;
510 } 510 }
@@ -512,14 +512,26 @@ static int au1x00_drv_pcmcia_probe(struct device *dev)
512 return ret; 512 return ret;
513} 513}
514 514
515static int au1x00_drv_pcmcia_suspend(struct platform_device *dev,
516 pm_message_t state)
517{
518 return pcmcia_socket_dev_suspend(&dev->dev, state);
519}
520
521static int au1x00_drv_pcmcia_resume(struct platform_device *dev)
522{
523 return pcmcia_socket_dev_resume(&dev->dev);
524}
515 525
516static struct device_driver au1x00_pcmcia_driver = { 526static struct platform_driver au1x00_pcmcia_driver = {
527 .driver = {
528 .name = "au1x00-pcmcia",
529 .owner = THIS_MODULE,
530 },
517 .probe = au1x00_drv_pcmcia_probe, 531 .probe = au1x00_drv_pcmcia_probe,
518 .remove = au1x00_drv_pcmcia_remove, 532 .remove = au1x00_drv_pcmcia_remove,
519 .name = "au1x00-pcmcia", 533 .suspend = au1x00_drv_pcmcia_suspend,
520 .bus = &platform_bus_type, 534 .resume = au1x00_drv_pcmcia_resume,
521 .suspend = pcmcia_socket_dev_suspend,
522 .resume = pcmcia_socket_dev_resume,
523}; 535};
524 536
525 537
@@ -533,8 +545,7 @@ static struct device_driver au1x00_pcmcia_driver = {
533static int __init au1x00_pcmcia_init(void) 545static int __init au1x00_pcmcia_init(void)
534{ 546{
535 int error = 0; 547 int error = 0;
536 if ((error = driver_register(&au1x00_pcmcia_driver))) 548 error = platform_driver_register(&au1x00_pcmcia_driver);
537 return error;
538 return error; 549 return error;
539} 550}
540 551
@@ -544,7 +555,7 @@ static int __init au1x00_pcmcia_init(void)
544 */ 555 */
545static void __exit au1x00_pcmcia_exit(void) 556static void __exit au1x00_pcmcia_exit(void)
546{ 557{
547 driver_unregister(&au1x00_pcmcia_driver); 558 platform_driver_unregister(&au1x00_pcmcia_driver);
548} 559}
549 560
550module_init(au1x00_pcmcia_init); 561module_init(au1x00_pcmcia_init);
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index 71653ab84890..40d4953e4b12 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -1238,6 +1238,16 @@ static int pcic_init(struct pcmcia_socket *s)
1238 return 0; 1238 return 0;
1239} 1239}
1240 1240
1241static int i82365_drv_pcmcia_suspend(struct platform_device *dev,
1242 pm_message_t state)
1243{
1244 return pcmcia_socket_dev_suspend(&dev->dev, state);
1245}
1246
1247static int i82365_drv_pcmcia_resume(struct platform_device *dev)
1248{
1249 return pcmcia_socket_dev_resume(&dev->dev);
1250}
1241static struct pccard_operations pcic_operations = { 1251static struct pccard_operations pcic_operations = {
1242 .init = pcic_init, 1252 .init = pcic_init,
1243 .get_status = pcic_get_status, 1253 .get_status = pcic_get_status,
@@ -1248,11 +1258,13 @@ static struct pccard_operations pcic_operations = {
1248 1258
1249/*====================================================================*/ 1259/*====================================================================*/
1250 1260
1251static struct device_driver i82365_driver = { 1261static struct platform_driver i82365_driver = {
1252 .name = "i82365", 1262 .driver = {
1253 .bus = &platform_bus_type, 1263 .name = "i82365",
1254 .suspend = pcmcia_socket_dev_suspend, 1264 .owner = THIS_MODULE,
1255 .resume = pcmcia_socket_dev_resume, 1265 },
1266 .suspend = i82365_drv_pcmcia_suspend,
1267 .resume = i82365_drv_pcmcia_resume,
1256}; 1268};
1257 1269
1258static struct platform_device *i82365_device; 1270static struct platform_device *i82365_device;
@@ -1261,7 +1273,7 @@ static int __init init_i82365(void)
1261{ 1273{
1262 int i, ret; 1274 int i, ret;
1263 1275
1264 ret = driver_register(&i82365_driver); 1276 ret = platform_driver_register(&i82365_driver);
1265 if (ret) 1277 if (ret)
1266 goto err_out; 1278 goto err_out;
1267 1279
@@ -1337,7 +1349,7 @@ err_dev_unregister:
1337 pnp_disable_dev(i82365_pnpdev); 1349 pnp_disable_dev(i82365_pnpdev);
1338#endif 1350#endif
1339err_driver_unregister: 1351err_driver_unregister:
1340 driver_unregister(&i82365_driver); 1352 platform_driver_unregister(&i82365_driver);
1341err_out: 1353err_out:
1342 return ret; 1354 return ret;
1343} /* init_i82365 */ 1355} /* init_i82365 */
@@ -1365,7 +1377,7 @@ static void __exit exit_i82365(void)
1365 if (i82365_pnpdev) 1377 if (i82365_pnpdev)
1366 pnp_disable_dev(i82365_pnpdev); 1378 pnp_disable_dev(i82365_pnpdev);
1367#endif 1379#endif
1368 driver_unregister(&i82365_driver); 1380 platform_driver_unregister(&i82365_driver);
1369} /* exit_i82365 */ 1381} /* exit_i82365 */
1370 1382
1371module_init(init_i82365); 1383module_init(init_i82365);
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 2ab4f22c21de..62b4ecc97c46 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -696,13 +696,25 @@ static struct pccard_operations pcc_operations = {
696 .set_mem_map = pcc_set_mem_map, 696 .set_mem_map = pcc_set_mem_map,
697}; 697};
698 698
699static int cfc_drv_pcmcia_suspend(struct platform_device *dev,
700 pm_message_t state)
701{
702 return pcmcia_socket_dev_suspend(&dev->dev, state);
703}
704
705static int cfc_drv_pcmcia_resume(struct platform_device *dev)
706{
707 return pcmcia_socket_dev_resume(&dev->dev);
708}
699/*====================================================================*/ 709/*====================================================================*/
700 710
701static struct device_driver pcc_driver = { 711static struct platform_driver pcc_driver = {
702 .name = "cfc", 712 .driver = {
703 .bus = &platform_bus_type, 713 .name = "cfc",
704 .suspend = pcmcia_socket_dev_suspend, 714 .owner = THIS_MODULE,
705 .resume = pcmcia_socket_dev_resume, 715 },
716 .suspend = cfc_drv_pcmcia_suspend,
717 .resume = cfc_drv_pcmcia_resume,
706}; 718};
707 719
708static struct platform_device pcc_device = { 720static struct platform_device pcc_device = {
@@ -716,13 +728,13 @@ static int __init init_m32r_pcc(void)
716{ 728{
717 int i, ret; 729 int i, ret;
718 730
719 ret = driver_register(&pcc_driver); 731 ret = platform_driver_register(&pcc_driver);
720 if (ret) 732 if (ret)
721 return ret; 733 return ret;
722 734
723 ret = platform_device_register(&pcc_device); 735 ret = platform_device_register(&pcc_device);
724 if (ret){ 736 if (ret){
725 driver_unregister(&pcc_driver); 737 platform_driver_unregister(&pcc_driver);
726 return ret; 738 return ret;
727 } 739 }
728 740
@@ -754,7 +766,7 @@ static int __init init_m32r_pcc(void)
754 if (pcc_sockets == 0) { 766 if (pcc_sockets == 0) {
755 printk("socket is not found.\n"); 767 printk("socket is not found.\n");
756 platform_device_unregister(&pcc_device); 768 platform_device_unregister(&pcc_device);
757 driver_unregister(&pcc_driver); 769 platform_driver_unregister(&pcc_driver);
758 return -ENODEV; 770 return -ENODEV;
759 } 771 }
760 772
@@ -802,7 +814,7 @@ static void __exit exit_m32r_pcc(void)
802 if (poll_interval != 0) 814 if (poll_interval != 0)
803 del_timer_sync(&poll_timer); 815 del_timer_sync(&poll_timer);
804 816
805 driver_unregister(&pcc_driver); 817 platform_driver_unregister(&pcc_driver);
806} /* exit_m32r_pcc */ 818} /* exit_m32r_pcc */
807 819
808module_init(init_m32r_pcc); 820module_init(init_m32r_pcc);
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index 2f108c23dbd9..12034b41d196 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -672,13 +672,25 @@ static struct pccard_operations pcc_operations = {
672 .set_mem_map = pcc_set_mem_map, 672 .set_mem_map = pcc_set_mem_map,
673}; 673};
674 674
675static int pcc_drv_pcmcia_suspend(struct platform_device *dev,
676 pm_message_t state)
677{
678 return pcmcia_socket_dev_suspend(&dev->dev, state);
679}
680
681static int pcc_drv_pcmcia_resume(struct platform_device *dev)
682{
683 return pcmcia_socket_dev_resume(&dev->dev);
684}
675/*====================================================================*/ 685/*====================================================================*/
676 686
677static struct device_driver pcc_driver = { 687static struct platform_driver pcc_driver = {
678 .name = "pcc", 688 .driver = {
679 .bus = &platform_bus_type, 689 .name = "pcc",
680 .suspend = pcmcia_socket_dev_suspend, 690 .owner = THIS_MODULE,
681 .resume = pcmcia_socket_dev_resume, 691 },
692 .suspend = pcc_drv_pcmcia_suspend,
693 .resume = pcc_drv_pcmcia_resume,
682}; 694};
683 695
684static struct platform_device pcc_device = { 696static struct platform_device pcc_device = {
@@ -692,13 +704,13 @@ static int __init init_m32r_pcc(void)
692{ 704{
693 int i, ret; 705 int i, ret;
694 706
695 ret = driver_register(&pcc_driver); 707 ret = platform_driver_register(&pcc_driver);
696 if (ret) 708 if (ret)
697 return ret; 709 return ret;
698 710
699 ret = platform_device_register(&pcc_device); 711 ret = platform_device_register(&pcc_device);
700 if (ret){ 712 if (ret){
701 driver_unregister(&pcc_driver); 713 platform_driver_unregister(&pcc_driver);
702 return ret; 714 return ret;
703 } 715 }
704 716
@@ -715,7 +727,7 @@ static int __init init_m32r_pcc(void)
715 if (pcc_sockets == 0) { 727 if (pcc_sockets == 0) {
716 printk("socket is not found.\n"); 728 printk("socket is not found.\n");
717 platform_device_unregister(&pcc_device); 729 platform_device_unregister(&pcc_device);
718 driver_unregister(&pcc_driver); 730 platform_driver_unregister(&pcc_driver);
719 return -ENODEV; 731 return -ENODEV;
720 } 732 }
721 733
@@ -763,7 +775,7 @@ static void __exit exit_m32r_pcc(void)
763 if (poll_interval != 0) 775 if (poll_interval != 0)
764 del_timer_sync(&poll_timer); 776 del_timer_sync(&poll_timer);
765 777
766 driver_unregister(&pcc_driver); 778 platform_driver_unregister(&pcc_driver);
767} /* exit_m32r_pcc */ 779} /* exit_m32r_pcc */
768 780
769module_init(init_m32r_pcc); 781module_init(init_m32r_pcc);
diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c
index c0e2afc79e3e..e592e0e0d7ed 100644
--- a/drivers/pcmcia/rsrc_mgr.c
+++ b/drivers/pcmcia/rsrc_mgr.c
@@ -153,7 +153,7 @@ static struct resource *iodyn_find_io_region(unsigned long base, int num,
153 unsigned long align, struct pcmcia_socket *s) 153 unsigned long align, struct pcmcia_socket *s)
154{ 154{
155 struct resource *res = make_resource(0, num, IORESOURCE_IO, 155 struct resource *res = make_resource(0, num, IORESOURCE_IO,
156 s->dev.bus_id); 156 dev_name(&s->dev));
157 struct pcmcia_align_data data; 157 struct pcmcia_align_data data;
158 unsigned long min = base; 158 unsigned long min = base;
159 int ret; 159 int ret;
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
index c5b2a44b4c37..d8da5ac844e9 100644
--- a/drivers/pcmcia/sa1100_generic.c
+++ b/drivers/pcmcia/sa1100_generic.c
@@ -65,7 +65,7 @@ static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = {
65#endif 65#endif
66}; 66};
67 67
68static int sa11x0_drv_pcmcia_probe(struct device *dev) 68static int sa11x0_drv_pcmcia_probe(struct platform_device *dev)
69{ 69{
70 int i, ret = -ENODEV; 70 int i, ret = -ENODEV;
71 71
@@ -73,7 +73,7 @@ static int sa11x0_drv_pcmcia_probe(struct device *dev)
73 * Initialise any "on-board" PCMCIA sockets. 73 * Initialise any "on-board" PCMCIA sockets.
74 */ 74 */
75 for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) { 75 for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) {
76 ret = sa11x0_pcmcia_hw_init[i](dev); 76 ret = sa11x0_pcmcia_hw_init[i](&dev->dev);
77 if (ret == 0) 77 if (ret == 0)
78 break; 78 break;
79 } 79 }
@@ -81,13 +81,31 @@ static int sa11x0_drv_pcmcia_probe(struct device *dev)
81 return ret; 81 return ret;
82} 82}
83 83
84static struct device_driver sa11x0_pcmcia_driver = { 84static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
85{
86 return soc_common_drv_pcmcia_remove(&dev->dev);
87}
88
89static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev,
90 pm_message_t state)
91{
92 return pcmcia_socket_dev_suspend(&dev->dev, state);
93}
94
95static int sa11x0_drv_pcmcia_resume(struct platform_device *dev)
96{
97 return pcmcia_socket_dev_resume(&dev->dev);
98}
99
100static struct platform_driver sa11x0_pcmcia_driver = {
101 .driver = {
102 .name = "sa11x0-pcmcia",
103 .owner = THIS_MODULE,
104 },
85 .probe = sa11x0_drv_pcmcia_probe, 105 .probe = sa11x0_drv_pcmcia_probe,
86 .remove = soc_common_drv_pcmcia_remove, 106 .remove = sa11x0_drv_pcmcia_remove,
87 .name = "sa11x0-pcmcia", 107 .suspend = sa11x0_drv_pcmcia_suspend,
88 .bus = &platform_bus_type, 108 .resume = sa11x0_drv_pcmcia_resume,
89 .suspend = pcmcia_socket_dev_suspend,
90 .resume = pcmcia_socket_dev_resume,
91}; 109};
92 110
93/* sa11x0_pcmcia_init() 111/* sa11x0_pcmcia_init()
@@ -100,7 +118,7 @@ static struct device_driver sa11x0_pcmcia_driver = {
100 */ 118 */
101static int __init sa11x0_pcmcia_init(void) 119static int __init sa11x0_pcmcia_init(void)
102{ 120{
103 return driver_register(&sa11x0_pcmcia_driver); 121 return platform_driver_register(&sa11x0_pcmcia_driver);
104} 122}
105 123
106/* sa11x0_pcmcia_exit() 124/* sa11x0_pcmcia_exit()
@@ -110,7 +128,7 @@ static int __init sa11x0_pcmcia_init(void)
110 */ 128 */
111static void __exit sa11x0_pcmcia_exit(void) 129static void __exit sa11x0_pcmcia_exit(void)
112{ 130{
113 driver_unregister(&sa11x0_pcmcia_driver); 131 platform_driver_unregister(&sa11x0_pcmcia_driver);
114} 132}
115 133
116MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>"); 134MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index 2a613e920fd4..9ad97ea836e8 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -363,13 +363,25 @@ static int __init get_tcic_id(void)
363 return id; 363 return id;
364} 364}
365 365
366static int tcic_drv_pcmcia_suspend(struct platform_device *dev,
367 pm_message_t state)
368{
369 return pcmcia_socket_dev_suspend(&dev->dev, state);
370}
371
372static int tcic_drv_pcmcia_resume(struct platform_device *dev)
373{
374 return pcmcia_socket_dev_resume(&dev->dev);
375}
366/*====================================================================*/ 376/*====================================================================*/
367 377
368static struct device_driver tcic_driver = { 378static struct platform_driver tcic_driver = {
369 .name = "tcic-pcmcia", 379 .driver = {
370 .bus = &platform_bus_type, 380 .name = "tcic-pcmcia",
371 .suspend = pcmcia_socket_dev_suspend, 381 .owner = THIS_MODULE,
372 .resume = pcmcia_socket_dev_resume, 382 },
383 .suspend = tcic_drv_pcmcia_suspend,
384 .resume = tcic_drv_pcmcia_resume,
373}; 385};
374 386
375static struct platform_device tcic_device = { 387static struct platform_device tcic_device = {
@@ -383,7 +395,7 @@ static int __init init_tcic(void)
383 int i, sock, ret = 0; 395 int i, sock, ret = 0;
384 u_int mask, scan; 396 u_int mask, scan;
385 397
386 if (driver_register(&tcic_driver)) 398 if (platform_driver_register(&tcic_driver))
387 return -1; 399 return -1;
388 400
389 printk(KERN_INFO "Databook TCIC-2 PCMCIA probe: "); 401 printk(KERN_INFO "Databook TCIC-2 PCMCIA probe: ");
@@ -391,7 +403,7 @@ static int __init init_tcic(void)
391 403
392 if (!request_region(tcic_base, 16, "tcic-2")) { 404 if (!request_region(tcic_base, 16, "tcic-2")) {
393 printk("could not allocate ports,\n "); 405 printk("could not allocate ports,\n ");
394 driver_unregister(&tcic_driver); 406 platform_driver_unregister(&tcic_driver);
395 return -ENODEV; 407 return -ENODEV;
396 } 408 }
397 else { 409 else {
@@ -414,7 +426,7 @@ static int __init init_tcic(void)
414 if (sock == 0) { 426 if (sock == 0) {
415 printk("not found.\n"); 427 printk("not found.\n");
416 release_region(tcic_base, 16); 428 release_region(tcic_base, 16);
417 driver_unregister(&tcic_driver); 429 platform_driver_unregister(&tcic_driver);
418 return -ENODEV; 430 return -ENODEV;
419 } 431 }
420 432
@@ -542,7 +554,7 @@ static void __exit exit_tcic(void)
542 } 554 }
543 555
544 platform_device_unregister(&tcic_device); 556 platform_device_unregister(&tcic_device);
545 driver_unregister(&tcic_driver); 557 platform_driver_unregister(&tcic_driver);
546} /* exit_tcic */ 558} /* exit_tcic */
547 559
548/*====================================================================*/ 560/*====================================================================*/
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c
index b2c412419059..659421d0ca46 100644
--- a/drivers/pcmcia/vrc4171_card.c
+++ b/drivers/pcmcia/vrc4171_card.c
@@ -704,24 +704,37 @@ static int __devinit vrc4171_card_setup(char *options)
704 704
705__setup("vrc4171_card=", vrc4171_card_setup); 705__setup("vrc4171_card=", vrc4171_card_setup);
706 706
707static struct device_driver vrc4171_card_driver = { 707static int vrc4171_card_suspend(struct platform_device *dev,
708 .name = vrc4171_card_name, 708 pm_message_t state)
709 .bus = &platform_bus_type, 709{
710 .suspend = pcmcia_socket_dev_suspend, 710 return pcmcia_socket_dev_suspend(&dev->dev, state);
711 .resume = pcmcia_socket_dev_resume, 711}
712
713static int vrc4171_card_resume(struct platform_device *dev)
714{
715 return pcmcia_socket_dev_resume(&dev->dev);
716}
717
718static struct platform_driver vrc4171_card_driver = {
719 .driver = {
720 .name = vrc4171_card_name,
721 .owner = THIS_MODULE,
722 },
723 .suspend = vrc4171_card_suspend,
724 .resume = vrc4171_card_resume,
712}; 725};
713 726
714static int __devinit vrc4171_card_init(void) 727static int __devinit vrc4171_card_init(void)
715{ 728{
716 int retval; 729 int retval;
717 730
718 retval = driver_register(&vrc4171_card_driver); 731 retval = platform_driver_register(&vrc4171_card_driver);
719 if (retval < 0) 732 if (retval < 0)
720 return retval; 733 return retval;
721 734
722 retval = platform_device_register(&vrc4171_card_device); 735 retval = platform_device_register(&vrc4171_card_device);
723 if (retval < 0) { 736 if (retval < 0) {
724 driver_unregister(&vrc4171_card_driver); 737 platform_driver_unregister(&vrc4171_card_driver);
725 return retval; 738 return retval;
726 } 739 }
727 740
@@ -735,11 +748,12 @@ static int __devinit vrc4171_card_init(void)
735 if (retval < 0) { 748 if (retval < 0) {
736 vrc4171_remove_sockets(); 749 vrc4171_remove_sockets();
737 platform_device_unregister(&vrc4171_card_device); 750 platform_device_unregister(&vrc4171_card_device);
738 driver_unregister(&vrc4171_card_driver); 751 platform_driver_unregister(&vrc4171_card_driver);
739 return retval; 752 return retval;
740 } 753 }
741 754
742 printk(KERN_INFO "%s, connected to IRQ %d\n", vrc4171_card_driver.name, vrc4171_irq); 755 printk(KERN_INFO "%s, connected to IRQ %d\n",
756 vrc4171_card_driver.driver.name, vrc4171_irq);
743 757
744 return 0; 758 return 0;
745} 759}
@@ -749,7 +763,7 @@ static void __devexit vrc4171_card_exit(void)
749 free_irq(vrc4171_irq, vrc4171_sockets); 763 free_irq(vrc4171_irq, vrc4171_sockets);
750 vrc4171_remove_sockets(); 764 vrc4171_remove_sockets();
751 platform_device_unregister(&vrc4171_card_device); 765 platform_device_unregister(&vrc4171_card_device);
752 driver_unregister(&vrc4171_card_driver); 766 platform_driver_unregister(&vrc4171_card_driver);
753} 767}
754 768
755module_init(vrc4171_card_init); 769module_init(vrc4171_card_init);
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index b3866ad50227..3608081bc3e0 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -15,8 +15,7 @@ menuconfig X86_PLATFORM_DEVICES
15if X86_PLATFORM_DEVICES 15if X86_PLATFORM_DEVICES
16 16
17config ACER_WMI 17config ACER_WMI
18 tristate "Acer WMI Laptop Extras (EXPERIMENTAL)" 18 tristate "Acer WMI Laptop Extras"
19 depends on EXPERIMENTAL
20 depends on ACPI 19 depends on ACPI
21 depends on LEDS_CLASS 20 depends on LEDS_CLASS
22 depends on NEW_LEDS 21 depends on NEW_LEDS
@@ -39,9 +38,9 @@ config ASUS_LAPTOP
39 tristate "Asus Laptop Extras (EXPERIMENTAL)" 38 tristate "Asus Laptop Extras (EXPERIMENTAL)"
40 depends on ACPI 39 depends on ACPI
41 depends on EXPERIMENTAL && !ACPI_ASUS 40 depends on EXPERIMENTAL && !ACPI_ASUS
42 depends on LEDS_CLASS 41 select LEDS_CLASS
43 depends on NEW_LEDS 42 select NEW_LEDS
44 depends on BACKLIGHT_CLASS_DEVICE 43 select BACKLIGHT_CLASS_DEVICE
45 depends on INPUT 44 depends on INPUT
46 ---help--- 45 ---help---
47 This is the new Linux driver for Asus laptops. It may also support some 46 This is the new Linux driver for Asus laptops. It may also support some
@@ -185,11 +184,11 @@ config SONYPI_COMPAT
185config THINKPAD_ACPI 184config THINKPAD_ACPI
186 tristate "ThinkPad ACPI Laptop Extras" 185 tristate "ThinkPad ACPI Laptop Extras"
187 depends on ACPI 186 depends on ACPI
187 depends on INPUT
188 select BACKLIGHT_LCD_SUPPORT 188 select BACKLIGHT_LCD_SUPPORT
189 select BACKLIGHT_CLASS_DEVICE 189 select BACKLIGHT_CLASS_DEVICE
190 select HWMON 190 select HWMON
191 select NVRAM 191 select NVRAM
192 select INPUT
193 select NEW_LEDS 192 select NEW_LEDS
194 select LEDS_CLASS 193 select LEDS_CLASS
195 select NET 194 select NET
@@ -315,9 +314,8 @@ config EEEPC_LAPTOP
315 314
316 315
317config ACPI_WMI 316config ACPI_WMI
318 tristate "WMI (EXPERIMENTAL)" 317 tristate "WMI"
319 depends on ACPI 318 depends on ACPI
320 depends on EXPERIMENTAL
321 help 319 help
322 This driver adds support for the ACPI-WMI (Windows Management 320 This driver adds support for the ACPI-WMI (Windows Management
323 Instrumentation) mapper device (PNP0C14) found on some systems. 321 Instrumentation) mapper device (PNP0C14) found on some systems.
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 94c9f911824e..a6a42e8c060b 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -1026,7 +1026,7 @@ static void acer_rfkill_exit(void)
1026 kfree(wireless_rfkill->data); 1026 kfree(wireless_rfkill->data);
1027 rfkill_unregister(wireless_rfkill); 1027 rfkill_unregister(wireless_rfkill);
1028 if (has_cap(ACER_CAP_BLUETOOTH)) { 1028 if (has_cap(ACER_CAP_BLUETOOTH)) {
1029 kfree(wireless_rfkill->data); 1029 kfree(bluetooth_rfkill->data);
1030 rfkill_unregister(bluetooth_rfkill); 1030 rfkill_unregister(bluetooth_rfkill);
1031 } 1031 }
1032 return; 1032 return;
@@ -1297,7 +1297,7 @@ static int __init acer_wmi_init(void)
1297 1297
1298 set_quirks(); 1298 set_quirks();
1299 1299
1300 if (!acpi_video_backlight_support() && has_cap(ACER_CAP_BRIGHTNESS)) { 1300 if (acpi_video_backlight_support() && has_cap(ACER_CAP_BRIGHTNESS)) {
1301 interface->capability &= ~ACER_CAP_BRIGHTNESS; 1301 interface->capability &= ~ACER_CAP_BRIGHTNESS;
1302 printk(ACER_INFO "Brightness must be controlled by " 1302 printk(ACER_INFO "Brightness must be controlled by "
1303 "generic video driver\n"); 1303 "generic video driver\n");
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 56af6cf385b0..eeafc6c0160d 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -815,6 +815,7 @@ static int asus_setkeycode(struct input_dev *dev, int scancode, int keycode)
815static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) 815static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
816{ 816{
817 static struct key_entry *key; 817 static struct key_entry *key;
818 u16 count;
818 819
819 /* TODO Find a better way to handle events count. */ 820 /* TODO Find a better way to handle events count. */
820 if (!hotk) 821 if (!hotk)
@@ -832,9 +833,11 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
832 lcd_blank(FB_BLANK_POWERDOWN); 833 lcd_blank(FB_BLANK_POWERDOWN);
833 } 834 }
834 835
836 count = hotk->event_count[event % 128]++;
837 acpi_bus_generate_proc_event(hotk->device, event, count);
835 acpi_bus_generate_netlink_event(hotk->device->pnp.device_class, 838 acpi_bus_generate_netlink_event(hotk->device->pnp.device_class,
836 dev_name(&hotk->device->dev), event, 839 dev_name(&hotk->device->dev), event,
837 hotk->event_count[event % 128]++); 840 count);
838 841
839 if (hotk->inputdev) { 842 if (hotk->inputdev) {
840 key = asus_get_entry_by_scancode(event); 843 key = asus_get_entry_by_scancode(event);
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 786ed8661cb0..6f54fd1757cd 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -557,13 +557,17 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
557static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) 557static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
558{ 558{
559 static struct key_entry *key; 559 static struct key_entry *key;
560 u16 count;
561
560 if (!ehotk) 562 if (!ehotk)
561 return; 563 return;
562 if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) 564 if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
563 notify_brn(); 565 notify_brn();
566 count = ehotk->event_count[event % 128]++;
567 acpi_bus_generate_proc_event(ehotk->device, event, count);
564 acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class, 568 acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class,
565 dev_name(&ehotk->device->dev), event, 569 dev_name(&ehotk->device->dev), event,
566 ehotk->event_count[event % 128]++); 570 count);
567 if (ehotk->inputdev) { 571 if (ehotk->inputdev) {
568 key = eepc_get_entry_by_scancode(event); 572 key = eepc_get_entry_by_scancode(event);
569 if (key) { 573 if (key) {
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index bcbc05107ba8..d2433204a40c 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -7532,7 +7532,7 @@ MODULE_ALIAS(TPACPI_DRVR_SHORTNAME);
7532 * if it is not there yet. 7532 * if it is not there yet.
7533 */ 7533 */
7534#define IBM_BIOS_MODULE_ALIAS(__type) \ 7534#define IBM_BIOS_MODULE_ALIAS(__type) \
7535 MODULE_ALIAS("dmi:bvnIBM:bvr" __type "ET??WW") 7535 MODULE_ALIAS("dmi:bvnIBM:bvr" __type "ET??WW*")
7536 7536
7537/* Non-ancient thinkpads */ 7537/* Non-ancient thinkpads */
7538MODULE_ALIAS("dmi:bvnIBM:*:svnIBM:*:pvrThinkPad*:rvnIBM:*"); 7538MODULE_ALIAS("dmi:bvnIBM:*:svnIBM:*:pvrThinkPad*:rvnIBM:*");
@@ -7541,9 +7541,9 @@ MODULE_ALIAS("dmi:bvnLENOVO:*:svnLENOVO:*:pvrThinkPad*:rvnLENOVO:*");
7541/* Ancient thinkpad BIOSes have to be identified by 7541/* Ancient thinkpad BIOSes have to be identified by
7542 * BIOS type or model number, and there are far less 7542 * BIOS type or model number, and there are far less
7543 * BIOS types than model numbers... */ 7543 * BIOS types than model numbers... */
7544IBM_BIOS_MODULE_ALIAS("I[B,D,H,I,M,N,O,T,W,V,Y,Z]"); 7544IBM_BIOS_MODULE_ALIAS("I[BDHIMNOTWVYZ]");
7545IBM_BIOS_MODULE_ALIAS("1[0,3,6,8,A-G,I,K,M-P,S,T]"); 7545IBM_BIOS_MODULE_ALIAS("1[0368A-GIKM-PST]");
7546IBM_BIOS_MODULE_ALIAS("K[U,X-Z]"); 7546IBM_BIOS_MODULE_ALIAS("K[UX-Z]");
7547 7547
7548MODULE_AUTHOR("Borislav Deianov, Henrique de Moraes Holschuh"); 7548MODULE_AUTHOR("Borislav Deianov, Henrique de Moraes Holschuh");
7549MODULE_DESCRIPTION(TPACPI_DESC); 7549MODULE_DESCRIPTION(TPACPI_DESC);
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 8a8b377712c9..2f269e117b8f 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -708,7 +708,7 @@ static int __init acpi_wmi_add(struct acpi_device *device)
708 708
709static int __init acpi_wmi_init(void) 709static int __init acpi_wmi_init(void)
710{ 710{
711 acpi_status result; 711 int result;
712 712
713 INIT_LIST_HEAD(&wmi_blocks.list); 713 INIT_LIST_HEAD(&wmi_blocks.list);
714 714
diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c
index 1d768928e0bb..a52d4a11652d 100644
--- a/drivers/power/ds2760_battery.c
+++ b/drivers/power/ds2760_battery.c
@@ -180,10 +180,13 @@ static int ds2760_battery_read_status(struct ds2760_device_info *di)
180 di->empty_uAh = battery_interpolate(scale, di->temp_C / 10); 180 di->empty_uAh = battery_interpolate(scale, di->temp_C / 10);
181 di->empty_uAh *= 1000; /* convert to µAh */ 181 di->empty_uAh *= 1000; /* convert to µAh */
182 182
183 /* From Maxim Application Note 131: remaining capacity = 183 if (di->full_active_uAh == di->empty_uAh)
184 * ((ICA - Empty Value) / (Full Value - Empty Value)) x 100% */ 184 di->rem_capacity = 0;
185 di->rem_capacity = ((di->accum_current_uAh - di->empty_uAh) * 100L) / 185 else
186 (di->full_active_uAh - di->empty_uAh); 186 /* From Maxim Application Note 131: remaining capacity =
187 * ((ICA - Empty Value) / (Full Value - Empty Value)) x 100% */
188 di->rem_capacity = ((di->accum_current_uAh - di->empty_uAh) * 100L) /
189 (di->full_active_uAh - di->empty_uAh);
187 190
188 if (di->rem_capacity < 0) 191 if (di->rem_capacity < 0)
189 di->rem_capacity = 0; 192 di->rem_capacity = 0;
diff --git a/drivers/rapidio/rio-driver.c b/drivers/rapidio/rio-driver.c
index addb87cf44d9..3222fa3c808c 100644
--- a/drivers/rapidio/rio-driver.c
+++ b/drivers/rapidio/rio-driver.c
@@ -193,7 +193,7 @@ static int rio_match_bus(struct device *dev, struct device_driver *drv)
193} 193}
194 194
195static struct device rio_bus = { 195static struct device rio_bus = {
196 .bus_id = "rapidio", 196 .init_name = "rapidio",
197}; 197};
198 198
199struct bus_type rio_bus_type = { 199struct bus_type rio_bus_type = {
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index d5e4e637ddec..86c61f143515 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -351,7 +351,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
351 /* register irq handler after we know what name we'll use */ 351 /* register irq handler after we know what name we'll use */
352 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, 352 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt,
353 IRQF_DISABLED | IRQF_SHARED, 353 IRQF_DISABLED | IRQF_SHARED,
354 rtc->rtcdev->dev.bus_id, rtc); 354 dev_name(&rtc->rtcdev->dev), rtc);
355 if (ret) { 355 if (ret) {
356 dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS); 356 dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS);
357 rtc_device_unregister(rtc->rtcdev); 357 rtc_device_unregister(rtc->rtcdev);
@@ -366,7 +366,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
366 366
367 if (gpbr_readl(rtc) == 0) 367 if (gpbr_readl(rtc) == 0)
368 dev_warn(&pdev->dev, "%s: SET TIME!\n", 368 dev_warn(&pdev->dev, "%s: SET TIME!\n",
369 rtc->rtcdev->dev.bus_id); 369 dev_name(&rtc->rtcdev->dev));
370 370
371 return 0; 371 return 0;
372 372
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 2cbeb0794f14..bd1ce8e2bc18 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -377,13 +377,13 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
377 377
378 /* handle periodic and alarm irqs */ 378 /* handle periodic and alarm irqs */
379 if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED, 379 if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED,
380 rtc->dev.bus_id, rtc)) { 380 dev_name(&rtc->dev), rtc)) {
381 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", 381 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
382 pdev->name, omap_rtc_timer); 382 pdev->name, omap_rtc_timer);
383 goto fail0; 383 goto fail0;
384 } 384 }
385 if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED, 385 if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED,
386 rtc->dev.bus_id, rtc)) { 386 dev_name(&rtc->dev), rtc)) {
387 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", 387 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
388 pdev->name, omap_rtc_alarm); 388 pdev->name, omap_rtc_alarm);
389 goto fail1; 389 goto fail1;
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 1c3fc6b428e9..4898f7fe8518 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -28,7 +28,7 @@
28#include <asm/rtc.h> 28#include <asm/rtc.h>
29 29
30#define DRV_NAME "sh-rtc" 30#define DRV_NAME "sh-rtc"
31#define DRV_VERSION "0.2.0" 31#define DRV_VERSION "0.2.1"
32 32
33#define RTC_REG(r) ((r) * rtc_reg_size) 33#define RTC_REG(r) ((r) * rtc_reg_size)
34 34
@@ -99,56 +99,51 @@ struct sh_rtc {
99 unsigned short periodic_freq; 99 unsigned short periodic_freq;
100}; 100};
101 101
102static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id) 102static int __sh_rtc_interrupt(struct sh_rtc *rtc)
103{ 103{
104 struct sh_rtc *rtc = dev_id; 104 unsigned int tmp, pending;
105 unsigned int tmp;
106
107 spin_lock(&rtc->lock);
108 105
109 tmp = readb(rtc->regbase + RCR1); 106 tmp = readb(rtc->regbase + RCR1);
107 pending = tmp & RCR1_CF;
110 tmp &= ~RCR1_CF; 108 tmp &= ~RCR1_CF;
111 writeb(tmp, rtc->regbase + RCR1); 109 writeb(tmp, rtc->regbase + RCR1);
112 110
113 /* Users have requested One x Second IRQ */ 111 /* Users have requested One x Second IRQ */
114 if (rtc->periodic_freq & PF_OXS) 112 if (pending && rtc->periodic_freq & PF_OXS)
115 rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF); 113 rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
116 114
117 spin_unlock(&rtc->lock); 115 return pending;
118
119 return IRQ_HANDLED;
120} 116}
121 117
122static irqreturn_t sh_rtc_alarm(int irq, void *dev_id) 118static int __sh_rtc_alarm(struct sh_rtc *rtc)
123{ 119{
124 struct sh_rtc *rtc = dev_id; 120 unsigned int tmp, pending;
125 unsigned int tmp;
126
127 spin_lock(&rtc->lock);
128 121
129 tmp = readb(rtc->regbase + RCR1); 122 tmp = readb(rtc->regbase + RCR1);
123 pending = tmp & RCR1_AF;
130 tmp &= ~(RCR1_AF | RCR1_AIE); 124 tmp &= ~(RCR1_AF | RCR1_AIE);
131 writeb(tmp, rtc->regbase + RCR1); 125 writeb(tmp, rtc->regbase + RCR1);
132
133 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
134 126
135 spin_unlock(&rtc->lock); 127 if (pending)
128 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
136 129
137 return IRQ_HANDLED; 130 return pending;
138} 131}
139 132
140static irqreturn_t sh_rtc_periodic(int irq, void *dev_id) 133static int __sh_rtc_periodic(struct sh_rtc *rtc)
141{ 134{
142 struct sh_rtc *rtc = dev_id;
143 struct rtc_device *rtc_dev = rtc->rtc_dev; 135 struct rtc_device *rtc_dev = rtc->rtc_dev;
144 unsigned int tmp; 136 struct rtc_task *irq_task;
145 137 unsigned int tmp, pending;
146 spin_lock(&rtc->lock);
147 138
148 tmp = readb(rtc->regbase + RCR2); 139 tmp = readb(rtc->regbase + RCR2);
140 pending = tmp & RCR2_PEF;
149 tmp &= ~RCR2_PEF; 141 tmp &= ~RCR2_PEF;
150 writeb(tmp, rtc->regbase + RCR2); 142 writeb(tmp, rtc->regbase + RCR2);
151 143
144 if (!pending)
145 return 0;
146
152 /* Half period enabled than one skipped and the next notified */ 147 /* Half period enabled than one skipped and the next notified */
153 if ((rtc->periodic_freq & PF_HP) && (rtc->periodic_freq & PF_COUNT)) 148 if ((rtc->periodic_freq & PF_HP) && (rtc->periodic_freq & PF_COUNT))
154 rtc->periodic_freq &= ~PF_COUNT; 149 rtc->periodic_freq &= ~PF_COUNT;
@@ -157,16 +152,65 @@ static irqreturn_t sh_rtc_periodic(int irq, void *dev_id)
157 rtc->periodic_freq |= PF_COUNT; 152 rtc->periodic_freq |= PF_COUNT;
158 if (rtc->periodic_freq & PF_KOU) { 153 if (rtc->periodic_freq & PF_KOU) {
159 spin_lock(&rtc_dev->irq_task_lock); 154 spin_lock(&rtc_dev->irq_task_lock);
160 if (rtc_dev->irq_task) 155 irq_task = rtc_dev->irq_task;
161 rtc_dev->irq_task->func(rtc_dev->irq_task->private_data); 156 if (irq_task)
157 irq_task->func(irq_task->private_data);
162 spin_unlock(&rtc_dev->irq_task_lock); 158 spin_unlock(&rtc_dev->irq_task_lock);
163 } else 159 } else
164 rtc_update_irq(rtc->rtc_dev, 1, RTC_PF | RTC_IRQF); 160 rtc_update_irq(rtc->rtc_dev, 1, RTC_PF | RTC_IRQF);
165 } 161 }
166 162
163 return pending;
164}
165
166static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id)
167{
168 struct sh_rtc *rtc = dev_id;
169 int ret;
170
171 spin_lock(&rtc->lock);
172 ret = __sh_rtc_interrupt(rtc);
173 spin_unlock(&rtc->lock);
174
175 return IRQ_RETVAL(ret);
176}
177
178static irqreturn_t sh_rtc_alarm(int irq, void *dev_id)
179{
180 struct sh_rtc *rtc = dev_id;
181 int ret;
182
183 spin_lock(&rtc->lock);
184 ret = __sh_rtc_alarm(rtc);
185 spin_unlock(&rtc->lock);
186
187 return IRQ_RETVAL(ret);
188}
189
190static irqreturn_t sh_rtc_periodic(int irq, void *dev_id)
191{
192 struct sh_rtc *rtc = dev_id;
193 int ret;
194
195 spin_lock(&rtc->lock);
196 ret = __sh_rtc_periodic(rtc);
167 spin_unlock(&rtc->lock); 197 spin_unlock(&rtc->lock);
168 198
169 return IRQ_HANDLED; 199 return IRQ_RETVAL(ret);
200}
201
202static irqreturn_t sh_rtc_shared(int irq, void *dev_id)
203{
204 struct sh_rtc *rtc = dev_id;
205 int ret;
206
207 spin_lock(&rtc->lock);
208 ret = __sh_rtc_interrupt(rtc);
209 ret |= __sh_rtc_alarm(rtc);
210 ret |= __sh_rtc_periodic(rtc);
211 spin_unlock(&rtc->lock);
212
213 return IRQ_RETVAL(ret);
170} 214}
171 215
172static inline void sh_rtc_setpie(struct device *dev, unsigned int enable) 216static inline void sh_rtc_setpie(struct device *dev, unsigned int enable)
@@ -275,6 +319,25 @@ static int sh_rtc_proc(struct device *dev, struct seq_file *seq)
275 return 0; 319 return 0;
276} 320}
277 321
322static inline void sh_rtc_setcie(struct device *dev, unsigned int enable)
323{
324 struct sh_rtc *rtc = dev_get_drvdata(dev);
325 unsigned int tmp;
326
327 spin_lock_irq(&rtc->lock);
328
329 tmp = readb(rtc->regbase + RCR1);
330
331 if (!enable)
332 tmp &= ~RCR1_CIE;
333 else
334 tmp |= RCR1_CIE;
335
336 writeb(tmp, rtc->regbase + RCR1);
337
338 spin_unlock_irq(&rtc->lock);
339}
340
278static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 341static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
279{ 342{
280 struct sh_rtc *rtc = dev_get_drvdata(dev); 343 struct sh_rtc *rtc = dev_get_drvdata(dev);
@@ -291,9 +354,11 @@ static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
291 break; 354 break;
292 case RTC_UIE_OFF: 355 case RTC_UIE_OFF:
293 rtc->periodic_freq &= ~PF_OXS; 356 rtc->periodic_freq &= ~PF_OXS;
357 sh_rtc_setcie(dev, 0);
294 break; 358 break;
295 case RTC_UIE_ON: 359 case RTC_UIE_ON:
296 rtc->periodic_freq |= PF_OXS; 360 rtc->periodic_freq |= PF_OXS;
361 sh_rtc_setcie(dev, 1);
297 break; 362 break;
298 case RTC_IRQP_READ: 363 case RTC_IRQP_READ:
299 ret = put_user(rtc->rtc_dev->irq_freq, 364 ret = put_user(rtc->rtc_dev->irq_freq,
@@ -356,18 +421,17 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm)
356 tm->tm_sec--; 421 tm->tm_sec--;
357#endif 422#endif
358 423
424 /* only keep the carry interrupt enabled if UIE is on */
425 if (!(rtc->periodic_freq & PF_OXS))
426 sh_rtc_setcie(dev, 0);
427
359 dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " 428 dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
360 "mday=%d, mon=%d, year=%d, wday=%d\n", 429 "mday=%d, mon=%d, year=%d, wday=%d\n",
361 __func__, 430 __func__,
362 tm->tm_sec, tm->tm_min, tm->tm_hour, 431 tm->tm_sec, tm->tm_min, tm->tm_hour,
363 tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday); 432 tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday);
364 433
365 if (rtc_valid_tm(tm) < 0) { 434 return rtc_valid_tm(tm);
366 dev_err(dev, "invalid date\n");
367 rtc_time_to_tm(0, tm);
368 }
369
370 return 0;
371} 435}
372 436
373static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm) 437static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm)
@@ -572,7 +636,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
572{ 636{
573 struct sh_rtc *rtc; 637 struct sh_rtc *rtc;
574 struct resource *res; 638 struct resource *res;
575 unsigned int tmp; 639 struct rtc_time r;
576 int ret; 640 int ret;
577 641
578 rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL); 642 rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL);
@@ -585,26 +649,12 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
585 ret = platform_get_irq(pdev, 0); 649 ret = platform_get_irq(pdev, 0);
586 if (unlikely(ret <= 0)) { 650 if (unlikely(ret <= 0)) {
587 ret = -ENOENT; 651 ret = -ENOENT;
588 dev_err(&pdev->dev, "No IRQ for period\n"); 652 dev_err(&pdev->dev, "No IRQ resource\n");
589 goto err_badres; 653 goto err_badres;
590 } 654 }
591 rtc->periodic_irq = ret; 655 rtc->periodic_irq = ret;
592 656 rtc->carry_irq = platform_get_irq(pdev, 1);
593 ret = platform_get_irq(pdev, 1); 657 rtc->alarm_irq = platform_get_irq(pdev, 2);
594 if (unlikely(ret <= 0)) {
595 ret = -ENOENT;
596 dev_err(&pdev->dev, "No IRQ for carry\n");
597 goto err_badres;
598 }
599 rtc->carry_irq = ret;
600
601 ret = platform_get_irq(pdev, 2);
602 if (unlikely(ret <= 0)) {
603 ret = -ENOENT;
604 dev_err(&pdev->dev, "No IRQ for alarm\n");
605 goto err_badres;
606 }
607 rtc->alarm_irq = ret;
608 658
609 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 659 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
610 if (unlikely(res == NULL)) { 660 if (unlikely(res == NULL)) {
@@ -646,47 +696,66 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
646 } 696 }
647 697
648 rtc->rtc_dev->max_user_freq = 256; 698 rtc->rtc_dev->max_user_freq = 256;
649 rtc->rtc_dev->irq_freq = 1;
650 rtc->periodic_freq = 0x60;
651 699
652 platform_set_drvdata(pdev, rtc); 700 platform_set_drvdata(pdev, rtc);
653 701
654 /* register periodic/carry/alarm irqs */ 702 if (rtc->carry_irq <= 0) {
655 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, IRQF_DISABLED, 703 /* register shared periodic/carry/alarm irq */
656 "sh-rtc period", rtc); 704 ret = request_irq(rtc->periodic_irq, sh_rtc_shared,
657 if (unlikely(ret)) { 705 IRQF_DISABLED, "sh-rtc", rtc);
658 dev_err(&pdev->dev, 706 if (unlikely(ret)) {
659 "request period IRQ failed with %d, IRQ %d\n", ret, 707 dev_err(&pdev->dev,
660 rtc->periodic_irq); 708 "request IRQ failed with %d, IRQ %d\n", ret,
661 goto err_unmap; 709 rtc->periodic_irq);
662 } 710 goto err_unmap;
711 }
712 } else {
713 /* register periodic/carry/alarm irqs */
714 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic,
715 IRQF_DISABLED, "sh-rtc period", rtc);
716 if (unlikely(ret)) {
717 dev_err(&pdev->dev,
718 "request period IRQ failed with %d, IRQ %d\n",
719 ret, rtc->periodic_irq);
720 goto err_unmap;
721 }
663 722
664 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, IRQF_DISABLED, 723 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt,
665 "sh-rtc carry", rtc); 724 IRQF_DISABLED, "sh-rtc carry", rtc);
666 if (unlikely(ret)) { 725 if (unlikely(ret)) {
667 dev_err(&pdev->dev, 726 dev_err(&pdev->dev,
668 "request carry IRQ failed with %d, IRQ %d\n", ret, 727 "request carry IRQ failed with %d, IRQ %d\n",
669 rtc->carry_irq); 728 ret, rtc->carry_irq);
670 free_irq(rtc->periodic_irq, rtc); 729 free_irq(rtc->periodic_irq, rtc);
671 goto err_unmap; 730 goto err_unmap;
672 } 731 }
673 732
674 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, IRQF_DISABLED, 733 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm,
675 "sh-rtc alarm", rtc); 734 IRQF_DISABLED, "sh-rtc alarm", rtc);
676 if (unlikely(ret)) { 735 if (unlikely(ret)) {
677 dev_err(&pdev->dev, 736 dev_err(&pdev->dev,
678 "request alarm IRQ failed with %d, IRQ %d\n", ret, 737 "request alarm IRQ failed with %d, IRQ %d\n",
679 rtc->alarm_irq); 738 ret, rtc->alarm_irq);
680 free_irq(rtc->carry_irq, rtc); 739 free_irq(rtc->carry_irq, rtc);
681 free_irq(rtc->periodic_irq, rtc); 740 free_irq(rtc->periodic_irq, rtc);
682 goto err_unmap; 741 goto err_unmap;
742 }
683 } 743 }
684 744
685 tmp = readb(rtc->regbase + RCR1); 745 /* everything disabled by default */
686 tmp &= ~RCR1_CF; 746 rtc->periodic_freq = 0;
687 tmp |= RCR1_CIE; 747 rtc->rtc_dev->irq_freq = 0;
688 writeb(tmp, rtc->regbase + RCR1); 748 sh_rtc_setpie(&pdev->dev, 0);
749 sh_rtc_setaie(&pdev->dev, 0);
750 sh_rtc_setcie(&pdev->dev, 0);
751
752 /* reset rtc to epoch 0 if time is invalid */
753 if (rtc_read_time(rtc->rtc_dev, &r) < 0) {
754 rtc_time_to_tm(0, &r);
755 rtc_set_time(rtc->rtc_dev, &r);
756 }
689 757
758 device_init_wakeup(&pdev->dev, 1);
690 return 0; 759 return 0;
691 760
692err_unmap: 761err_unmap:
@@ -708,10 +777,13 @@ static int __devexit sh_rtc_remove(struct platform_device *pdev)
708 777
709 sh_rtc_setpie(&pdev->dev, 0); 778 sh_rtc_setpie(&pdev->dev, 0);
710 sh_rtc_setaie(&pdev->dev, 0); 779 sh_rtc_setaie(&pdev->dev, 0);
780 sh_rtc_setcie(&pdev->dev, 0);
711 781
712 free_irq(rtc->carry_irq, rtc);
713 free_irq(rtc->periodic_irq, rtc); 782 free_irq(rtc->periodic_irq, rtc);
714 free_irq(rtc->alarm_irq, rtc); 783 if (rtc->carry_irq > 0) {
784 free_irq(rtc->carry_irq, rtc);
785 free_irq(rtc->alarm_irq, rtc);
786 }
715 787
716 release_resource(rtc->res); 788 release_resource(rtc->res);
717 789
diff --git a/drivers/rtc/rtc-twl4030.c b/drivers/rtc/rtc-twl4030.c
index ad35f76c46b7..a6341e4f9a0f 100644
--- a/drivers/rtc/rtc-twl4030.c
+++ b/drivers/rtc/rtc-twl4030.c
@@ -426,7 +426,7 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
426 426
427 ret = request_irq(irq, twl4030_rtc_interrupt, 427 ret = request_irq(irq, twl4030_rtc_interrupt,
428 IRQF_TRIGGER_RISING, 428 IRQF_TRIGGER_RISING,
429 rtc->dev.bus_id, rtc); 429 dev_name(&rtc->dev), rtc);
430 if (ret < 0) { 430 if (ret < 0) {
431 dev_err(&pdev->dev, "IRQ is not free.\n"); 431 dev_err(&pdev->dev, "IRQ is not free.\n");
432 goto out1; 432 goto out1;
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 918e6fce2573..b91c1719b075 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -104,8 +104,9 @@ ccwgroup_ungroup_store(struct device *dev, struct device_attribute *attr, const
104 rc = device_schedule_callback(dev, ccwgroup_ungroup_callback); 104 rc = device_schedule_callback(dev, ccwgroup_ungroup_callback);
105out: 105out:
106 if (rc) { 106 if (rc) {
107 /* Release onoff "lock" when ungrouping failed. */ 107 if (rc != -EAGAIN)
108 atomic_set(&gdev->onoff, 0); 108 /* Release onoff "lock" when ungrouping failed. */
109 atomic_set(&gdev->onoff, 0);
109 return rc; 110 return rc;
110 } 111 }
111 return count; 112 return count;
diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c
index 0a2f2edafc03..93eca1731b81 100644
--- a/drivers/s390/cio/chsc_sch.c
+++ b/drivers/s390/cio/chsc_sch.c
@@ -84,8 +84,8 @@ static int chsc_subchannel_probe(struct subchannel *sch)
84 kfree(private); 84 kfree(private);
85 } else { 85 } else {
86 sch->private = private; 86 sch->private = private;
87 if (sch->dev.uevent_suppress) { 87 if (dev_get_uevent_suppress(&sch->dev)) {
88 sch->dev.uevent_suppress = 0; 88 dev_set_uevent_suppress(&sch->dev, 0);
89 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 89 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
90 } 90 }
91 } 91 }
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 8019288bc6de..427d11d88069 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -272,7 +272,7 @@ static int css_register_subchannel(struct subchannel *sch)
272 * the subchannel driver can decide itself when it wants to inform 272 * the subchannel driver can decide itself when it wants to inform
273 * userspace of its existence. 273 * userspace of its existence.
274 */ 274 */
275 sch->dev.uevent_suppress = 1; 275 dev_set_uevent_suppress(&sch->dev, 1);
276 css_update_ssd_info(sch); 276 css_update_ssd_info(sch);
277 /* make it known to the system */ 277 /* make it known to the system */
278 ret = css_sch_device_register(sch); 278 ret = css_sch_device_register(sch);
@@ -287,7 +287,7 @@ static int css_register_subchannel(struct subchannel *sch)
287 * a fitting driver module may be loaded based on the 287 * a fitting driver module may be loaded based on the
288 * modalias. 288 * modalias.
289 */ 289 */
290 sch->dev.uevent_suppress = 0; 290 dev_set_uevent_suppress(&sch->dev, 0);
291 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 291 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
292 } 292 }
293 return ret; 293 return ret;
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 23d5752349b5..e28f8ae53453 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -799,7 +799,7 @@ static void sch_attach_disconnected_device(struct subchannel *sch,
799 return; 799 return;
800 other_sch = to_subchannel(cdev->dev.parent); 800 other_sch = to_subchannel(cdev->dev.parent);
801 /* Note: device_move() changes cdev->dev.parent */ 801 /* Note: device_move() changes cdev->dev.parent */
802 ret = device_move(&cdev->dev, &sch->dev); 802 ret = device_move(&cdev->dev, &sch->dev, DPM_ORDER_PARENT_BEFORE_DEV);
803 if (ret) { 803 if (ret) {
804 CIO_MSG_EVENT(0, "Moving disconnected device 0.%x.%04x failed " 804 CIO_MSG_EVENT(0, "Moving disconnected device 0.%x.%04x failed "
805 "(ret=%d)!\n", cdev->private->dev_id.ssid, 805 "(ret=%d)!\n", cdev->private->dev_id.ssid,
@@ -830,7 +830,7 @@ static void sch_attach_orphaned_device(struct subchannel *sch,
830 * Try to move the ccw device to its new subchannel. 830 * Try to move the ccw device to its new subchannel.
831 * Note: device_move() changes cdev->dev.parent 831 * Note: device_move() changes cdev->dev.parent
832 */ 832 */
833 ret = device_move(&cdev->dev, &sch->dev); 833 ret = device_move(&cdev->dev, &sch->dev, DPM_ORDER_PARENT_BEFORE_DEV);
834 if (ret) { 834 if (ret) {
835 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x from orphanage " 835 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x from orphanage "
836 "failed (ret=%d)!\n", 836 "failed (ret=%d)!\n",
@@ -897,7 +897,8 @@ void ccw_device_move_to_orphanage(struct work_struct *work)
897 * ccw device can take its place on the subchannel. 897 * ccw device can take its place on the subchannel.
898 * Note: device_move() changes cdev->dev.parent 898 * Note: device_move() changes cdev->dev.parent
899 */ 899 */
900 ret = device_move(&cdev->dev, &css->pseudo_subchannel->dev); 900 ret = device_move(&cdev->dev, &css->pseudo_subchannel->dev,
901 DPM_ORDER_NONE);
901 if (ret) { 902 if (ret) {
902 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x to orphanage failed " 903 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x to orphanage failed "
903 "(ret=%d)!\n", cdev->private->dev_id.ssid, 904 "(ret=%d)!\n", cdev->private->dev_id.ssid,
@@ -981,7 +982,7 @@ io_subchannel_register(struct work_struct *work)
981 * Now we know this subchannel will stay, we can throw 982 * Now we know this subchannel will stay, we can throw
982 * our delayed uevent. 983 * our delayed uevent.
983 */ 984 */
984 sch->dev.uevent_suppress = 0; 985 dev_set_uevent_suppress(&sch->dev, 0);
985 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 986 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
986 /* make it known to the system */ 987 /* make it known to the system */
987 ret = ccw_device_register(cdev); 988 ret = ccw_device_register(cdev);
@@ -1129,7 +1130,7 @@ static void ccw_device_move_to_sch(struct work_struct *work)
1129 * Try to move the ccw device to its new subchannel. 1130 * Try to move the ccw device to its new subchannel.
1130 * Note: device_move() changes cdev->dev.parent 1131 * Note: device_move() changes cdev->dev.parent
1131 */ 1132 */
1132 rc = device_move(&cdev->dev, &sch->dev); 1133 rc = device_move(&cdev->dev, &sch->dev, DPM_ORDER_PARENT_BEFORE_DEV);
1133 mutex_unlock(&sch->reg_mutex); 1134 mutex_unlock(&sch->reg_mutex);
1134 if (rc) { 1135 if (rc) {
1135 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x to subchannel " 1136 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x to subchannel "
@@ -1243,7 +1244,7 @@ static int io_subchannel_probe(struct subchannel *sch)
1243 * the ccw_device and exit. This happens for all early 1244 * the ccw_device and exit. This happens for all early
1244 * devices, e.g. the console. 1245 * devices, e.g. the console.
1245 */ 1246 */
1246 sch->dev.uevent_suppress = 0; 1247 dev_set_uevent_suppress(&sch->dev, 0);
1247 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 1248 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
1248 cdev->dev.groups = ccwdev_attr_groups; 1249 cdev->dev.groups = ccwdev_attr_groups;
1249 device_initialize(&cdev->dev); 1250 device_initialize(&cdev->dev);
diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c
index f08e169ba1b5..7e30e5f6e032 100644
--- a/drivers/sbus/char/bbc_i2c.c
+++ b/drivers/sbus/char/bbc_i2c.c
@@ -129,7 +129,7 @@ static int wait_for_pin(struct bbc_i2c_bus *bp, u8 *status)
129 bp->waiting = 1; 129 bp->waiting = 1;
130 add_wait_queue(&bp->wq, &wait); 130 add_wait_queue(&bp->wq, &wait);
131 while (limit-- > 0) { 131 while (limit-- > 0) {
132 unsigned long val; 132 long val;
133 133
134 val = wait_event_interruptible_timeout( 134 val = wait_event_interruptible_timeout(
135 bp->wq, 135 bp->wq,
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
index a9a9893a5f95..e6d1fc8c54f1 100644
--- a/drivers/sbus/char/jsflash.c
+++ b/drivers/sbus/char/jsflash.c
@@ -38,9 +38,6 @@
38#include <linux/string.h> 38#include <linux/string.h>
39#include <linux/genhd.h> 39#include <linux/genhd.h>
40#include <linux/blkdev.h> 40#include <linux/blkdev.h>
41
42#define MAJOR_NR JSFD_MAJOR
43
44#include <asm/uaccess.h> 41#include <asm/uaccess.h>
45#include <asm/pgtable.h> 42#include <asm/pgtable.h>
46#include <asm/io.h> 43#include <asm/io.h>
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index 29dc735e1a20..124f660a0383 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -51,6 +51,7 @@ MODULE_AUTHOR("Thomas K. Dyas (tdyas@noc.rutgers.edu) and Eddie C. Dost (ecd@sk
51MODULE_DESCRIPTION("OPENPROM Configuration Driver"); 51MODULE_DESCRIPTION("OPENPROM Configuration Driver");
52MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
53MODULE_VERSION("1.0"); 53MODULE_VERSION("1.0");
54MODULE_ALIAS_MISCDEV(SUN_OPENPROM_MINOR);
54 55
55/* Private data kept by the driver for each descriptor. */ 56/* Private data kept by the driver for each descriptor. */
56typedef struct openprom_private_data 57typedef struct openprom_private_data
diff --git a/drivers/scsi/a4000t.c b/drivers/scsi/a4000t.c
index d4bda2017746..61af3d91ac8a 100644
--- a/drivers/scsi/a4000t.c
+++ b/drivers/scsi/a4000t.c
@@ -35,7 +35,7 @@ static struct platform_device *a4000t_scsi_device;
35 35
36#define A4000T_SCSI_ADDR 0xdd0040 36#define A4000T_SCSI_ADDR 0xdd0040
37 37
38static int __devinit a4000t_probe(struct device *dev) 38static int __devinit a4000t_probe(struct platform_device *dev)
39{ 39{
40 struct Scsi_Host *host; 40 struct Scsi_Host *host;
41 struct NCR_700_Host_Parameters *hostdata; 41 struct NCR_700_Host_Parameters *hostdata;
@@ -61,7 +61,8 @@ static int __devinit a4000t_probe(struct device *dev)
61 hostdata->dcntl_extra = EA_710; 61 hostdata->dcntl_extra = EA_710;
62 62
63 /* and register the chip */ 63 /* and register the chip */
64 host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata, dev); 64 host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata,
65 &dev->dev);
65 if (!host) { 66 if (!host) {
66 printk(KERN_ERR "a4000t-scsi: No host detected; " 67 printk(KERN_ERR "a4000t-scsi: No host detected; "
67 "board configuration problem?\n"); 68 "board configuration problem?\n");
@@ -78,7 +79,7 @@ static int __devinit a4000t_probe(struct device *dev)
78 goto out_put_host; 79 goto out_put_host;
79 } 80 }
80 81
81 dev_set_drvdata(dev, host); 82 platform_set_drvdata(dev, host);
82 scsi_scan_host(host); 83 scsi_scan_host(host);
83 84
84 return 0; 85 return 0;
@@ -93,9 +94,9 @@ static int __devinit a4000t_probe(struct device *dev)
93 return -ENODEV; 94 return -ENODEV;
94} 95}
95 96
96static __devexit int a4000t_device_remove(struct device *dev) 97static __devexit int a4000t_device_remove(struct platform_device *dev)
97{ 98{
98 struct Scsi_Host *host = dev_get_drvdata(dev); 99 struct Scsi_Host *host = platform_get_drvdata(dev);
99 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 100 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
100 101
101 scsi_remove_host(host); 102 scsi_remove_host(host);
@@ -108,25 +109,27 @@ static __devexit int a4000t_device_remove(struct device *dev)
108 return 0; 109 return 0;
109} 110}
110 111
111static struct device_driver a4000t_scsi_driver = { 112static struct platform_driver a4000t_scsi_driver = {
112 .name = "a4000t-scsi", 113 .driver = {
113 .bus = &platform_bus_type, 114 .name = "a4000t-scsi",
114 .probe = a4000t_probe, 115 .owner = THIS_MODULE,
115 .remove = __devexit_p(a4000t_device_remove), 116 },
117 .probe = a4000t_probe,
118 .remove = __devexit_p(a4000t_device_remove),
116}; 119};
117 120
118static int __init a4000t_scsi_init(void) 121static int __init a4000t_scsi_init(void)
119{ 122{
120 int err; 123 int err;
121 124
122 err = driver_register(&a4000t_scsi_driver); 125 err = platform_driver_register(&a4000t_scsi_driver);
123 if (err) 126 if (err)
124 return err; 127 return err;
125 128
126 a4000t_scsi_device = platform_device_register_simple("a4000t-scsi", 129 a4000t_scsi_device = platform_device_register_simple("a4000t-scsi",
127 -1, NULL, 0); 130 -1, NULL, 0);
128 if (IS_ERR(a4000t_scsi_device)) { 131 if (IS_ERR(a4000t_scsi_device)) {
129 driver_unregister(&a4000t_scsi_driver); 132 platform_driver_register(&a4000t_scsi_driver);
130 return PTR_ERR(a4000t_scsi_device); 133 return PTR_ERR(a4000t_scsi_device);
131 } 134 }
132 135
@@ -136,7 +139,7 @@ static int __init a4000t_scsi_init(void)
136static void __exit a4000t_scsi_exit(void) 139static void __exit a4000t_scsi_exit(void)
137{ 140{
138 platform_device_unregister(a4000t_scsi_device); 141 platform_device_unregister(a4000t_scsi_device);
139 driver_unregister(&a4000t_scsi_driver); 142 platform_driver_unregister(&a4000t_scsi_driver);
140} 143}
141 144
142module_init(a4000t_scsi_init); 145module_init(a4000t_scsi_init);
diff --git a/drivers/scsi/bvme6000_scsi.c b/drivers/scsi/bvme6000_scsi.c
index d858f3d41274..5799cb5cba6b 100644
--- a/drivers/scsi/bvme6000_scsi.c
+++ b/drivers/scsi/bvme6000_scsi.c
@@ -34,7 +34,7 @@ static struct scsi_host_template bvme6000_scsi_driver_template = {
34static struct platform_device *bvme6000_scsi_device; 34static struct platform_device *bvme6000_scsi_device;
35 35
36static __devinit int 36static __devinit int
37bvme6000_probe(struct device *dev) 37bvme6000_probe(struct platform_device *dev)
38{ 38{
39 struct Scsi_Host *host; 39 struct Scsi_Host *host;
40 struct NCR_700_Host_Parameters *hostdata; 40 struct NCR_700_Host_Parameters *hostdata;
@@ -58,7 +58,8 @@ bvme6000_probe(struct device *dev)
58 hostdata->ctest7_extra = CTEST7_TT1; 58 hostdata->ctest7_extra = CTEST7_TT1;
59 59
60 /* and register the chip */ 60 /* and register the chip */
61 host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata, dev); 61 host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata,
62 &dev->dev);
62 if (!host) { 63 if (!host) {
63 printk(KERN_ERR "bvme6000-scsi: No host detected; " 64 printk(KERN_ERR "bvme6000-scsi: No host detected; "
64 "board configuration problem?\n"); 65 "board configuration problem?\n");
@@ -73,7 +74,7 @@ bvme6000_probe(struct device *dev)
73 goto out_put_host; 74 goto out_put_host;
74 } 75 }
75 76
76 dev_set_drvdata(dev, host); 77 platform_set_drvdata(dev, host);
77 scsi_scan_host(host); 78 scsi_scan_host(host);
78 79
79 return 0; 80 return 0;
@@ -87,9 +88,9 @@ bvme6000_probe(struct device *dev)
87} 88}
88 89
89static __devexit int 90static __devexit int
90bvme6000_device_remove(struct device *dev) 91bvme6000_device_remove(struct platform_device *dev)
91{ 92{
92 struct Scsi_Host *host = dev_get_drvdata(dev); 93 struct Scsi_Host *host = platform_get_drvdata(dev);
93 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 94 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
94 95
95 scsi_remove_host(host); 96 scsi_remove_host(host);
@@ -100,25 +101,27 @@ bvme6000_device_remove(struct device *dev)
100 return 0; 101 return 0;
101} 102}
102 103
103static struct device_driver bvme6000_scsi_driver = { 104static struct platform_driver bvme6000_scsi_driver = {
104 .name = "bvme6000-scsi", 105 .driver = {
105 .bus = &platform_bus_type, 106 .name = "bvme6000-scsi",
106 .probe = bvme6000_probe, 107 .owner = THIS_MODULE,
107 .remove = __devexit_p(bvme6000_device_remove), 108 },
109 .probe = bvme6000_probe,
110 .remove = __devexit_p(bvme6000_device_remove),
108}; 111};
109 112
110static int __init bvme6000_scsi_init(void) 113static int __init bvme6000_scsi_init(void)
111{ 114{
112 int err; 115 int err;
113 116
114 err = driver_register(&bvme6000_scsi_driver); 117 err = platform_driver_register(&bvme6000_scsi_driver);
115 if (err) 118 if (err)
116 return err; 119 return err;
117 120
118 bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi", 121 bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi",
119 -1, NULL, 0); 122 -1, NULL, 0);
120 if (IS_ERR(bvme6000_scsi_device)) { 123 if (IS_ERR(bvme6000_scsi_device)) {
121 driver_unregister(&bvme6000_scsi_driver); 124 platform_driver_unregister(&bvme6000_scsi_driver);
122 return PTR_ERR(bvme6000_scsi_device); 125 return PTR_ERR(bvme6000_scsi_device);
123 } 126 }
124 127
@@ -128,7 +131,7 @@ static int __init bvme6000_scsi_init(void)
128static void __exit bvme6000_scsi_exit(void) 131static void __exit bvme6000_scsi_exit(void)
129{ 132{
130 platform_device_unregister(bvme6000_scsi_device); 133 platform_device_unregister(bvme6000_scsi_device);
131 driver_unregister(&bvme6000_scsi_driver); 134 platform_driver_unregister(&bvme6000_scsi_driver);
132} 135}
133 136
134module_init(bvme6000_scsi_init); 137module_init(bvme6000_scsi_init);
diff --git a/drivers/scsi/fcoe/fc_transport_fcoe.c b/drivers/scsi/fcoe/fc_transport_fcoe.c
index bf7fe6fc0820..8862758006c0 100644
--- a/drivers/scsi/fcoe/fc_transport_fcoe.c
+++ b/drivers/scsi/fcoe/fc_transport_fcoe.c
@@ -33,19 +33,19 @@ static LIST_HEAD(fcoe_transports);
33static DEFINE_MUTEX(fcoe_transports_lock); 33static DEFINE_MUTEX(fcoe_transports_lock);
34 34
35/** 35/**
36 * fcoe_transport_default - returns ptr to the default transport fcoe_sw 36 * fcoe_transport_default() - Returns ptr to the default transport fcoe_sw
37 **/ 37 */
38struct fcoe_transport *fcoe_transport_default(void) 38struct fcoe_transport *fcoe_transport_default(void)
39{ 39{
40 return &fcoe_sw_transport; 40 return &fcoe_sw_transport;
41} 41}
42 42
43/** 43/**
44 * fcoe_transport_to_pcidev - get the pci dev from a netdev 44 * fcoe_transport_to_pcidev() - get the pci dev from a netdev
45 * @netdev: the netdev that pci dev will be retrived from 45 * @netdev: the netdev that pci dev will be retrived from
46 * 46 *
47 * Returns: NULL or the corrsponding pci_dev 47 * Returns: NULL or the corrsponding pci_dev
48 **/ 48 */
49struct pci_dev *fcoe_transport_pcidev(const struct net_device *netdev) 49struct pci_dev *fcoe_transport_pcidev(const struct net_device *netdev)
50{ 50{
51 if (!netdev->dev.parent) 51 if (!netdev->dev.parent)
@@ -54,18 +54,17 @@ struct pci_dev *fcoe_transport_pcidev(const struct net_device *netdev)
54} 54}
55 55
56/** 56/**
57 * fcoe_transport_device_lookup - find out netdev is managed by the 57 * fcoe_transport_device_lookup() - Lookup a transport
58 * transport
59 * assign a transport to a device
60 * @netdev: the netdev the transport to be attached to 58 * @netdev: the netdev the transport to be attached to
61 * 59 *
62 * This will look for existing offload driver, if not found, it falls back to 60 * This will look for existing offload driver, if not found, it falls back to
63 * the default sw hba (fcoe_sw) as its fcoe transport. 61 * the default sw hba (fcoe_sw) as its fcoe transport.
64 * 62 *
65 * Returns: 0 for success 63 * Returns: 0 for success
66 **/ 64 */
67static struct fcoe_transport_internal *fcoe_transport_device_lookup( 65static struct fcoe_transport_internal *
68 struct fcoe_transport *t, struct net_device *netdev) 66fcoe_transport_device_lookup(struct fcoe_transport *t,
67 struct net_device *netdev)
69{ 68{
70 struct fcoe_transport_internal *ti; 69 struct fcoe_transport_internal *ti;
71 70
@@ -81,14 +80,14 @@ static struct fcoe_transport_internal *fcoe_transport_device_lookup(
81 return NULL; 80 return NULL;
82} 81}
83/** 82/**
84 * fcoe_transport_device_add - assign a transport to a device 83 * fcoe_transport_device_add() - Assign a transport to a device
85 * @netdev: the netdev the transport to be attached to 84 * @netdev: the netdev the transport to be attached to
86 * 85 *
87 * This will look for existing offload driver, if not found, it falls back to 86 * This will look for existing offload driver, if not found, it falls back to
88 * the default sw hba (fcoe_sw) as its fcoe transport. 87 * the default sw hba (fcoe_sw) as its fcoe transport.
89 * 88 *
90 * Returns: 0 for success 89 * Returns: 0 for success
91 **/ 90 */
92static int fcoe_transport_device_add(struct fcoe_transport *t, 91static int fcoe_transport_device_add(struct fcoe_transport *t,
93 struct net_device *netdev) 92 struct net_device *netdev)
94{ 93{
@@ -123,14 +122,14 @@ static int fcoe_transport_device_add(struct fcoe_transport *t,
123} 122}
124 123
125/** 124/**
126 * fcoe_transport_device_remove - remove a device from its transport 125 * fcoe_transport_device_remove() - Remove a device from its transport
127 * @netdev: the netdev the transport to be attached to 126 * @netdev: the netdev the transport to be attached to
128 * 127 *
129 * this removes the device from the transport so the given transport will 128 * This removes the device from the transport so the given transport will
130 * not manage this device any more 129 * not manage this device any more
131 * 130 *
132 * Returns: 0 for success 131 * Returns: 0 for success
133 **/ 132 */
134static int fcoe_transport_device_remove(struct fcoe_transport *t, 133static int fcoe_transport_device_remove(struct fcoe_transport *t,
135 struct net_device *netdev) 134 struct net_device *netdev)
136{ 135{
@@ -155,13 +154,13 @@ static int fcoe_transport_device_remove(struct fcoe_transport *t,
155} 154}
156 155
157/** 156/**
158 * fcoe_transport_device_remove_all - remove all from transport devlist 157 * fcoe_transport_device_remove_all() - Remove all from transport devlist
159 * 158 *
160 * this removes the device from the transport so the given transport will 159 * This removes the device from the transport so the given transport will
161 * not manage this device any more 160 * not manage this device any more
162 * 161 *
163 * Returns: 0 for success 162 * Returns: 0 for success
164 **/ 163 */
165static void fcoe_transport_device_remove_all(struct fcoe_transport *t) 164static void fcoe_transport_device_remove_all(struct fcoe_transport *t)
166{ 165{
167 struct fcoe_transport_internal *ti, *tmp; 166 struct fcoe_transport_internal *ti, *tmp;
@@ -175,18 +174,18 @@ static void fcoe_transport_device_remove_all(struct fcoe_transport *t)
175} 174}
176 175
177/** 176/**
178 * fcoe_transport_match - use the bus device match function to match the hw 177 * fcoe_transport_match() - Use the bus device match function to match the hw
179 * @t: the fcoe transport 178 * @t: The fcoe transport to check
180 * @netdev: 179 * @netdev: The netdev to match against
181 * 180 *
182 * This function is used to check if the givne transport wants to manage the 181 * This function is used to check if the given transport wants to manage the
183 * input netdev. if the transports implements the match function, it will be 182 * input netdev. if the transports implements the match function, it will be
184 * called, o.w. we just compare the pci vendor and device id. 183 * called, o.w. we just compare the pci vendor and device id.
185 * 184 *
186 * Returns: true for match up 185 * Returns: true for match up
187 **/ 186 */
188static bool fcoe_transport_match(struct fcoe_transport *t, 187static bool fcoe_transport_match(struct fcoe_transport *t,
189 struct net_device *netdev) 188 struct net_device *netdev)
190{ 189{
191 /* match transport by vendor and device id */ 190 /* match transport by vendor and device id */
192 struct pci_dev *pci; 191 struct pci_dev *pci;
@@ -210,17 +209,17 @@ static bool fcoe_transport_match(struct fcoe_transport *t,
210} 209}
211 210
212/** 211/**
213 * fcoe_transport_lookup - check if the transport is already registered 212 * fcoe_transport_lookup() - Check if the transport is already registered
214 * @t: the transport to be looked up 213 * @t: the transport to be looked up
215 * 214 *
216 * This compares the parent device (pci) vendor and device id 215 * This compares the parent device (pci) vendor and device id
217 * 216 *
218 * Returns: NULL if not found 217 * Returns: NULL if not found
219 * 218 *
220 * TODO - return default sw transport if no other transport is found 219 * TODO: return default sw transport if no other transport is found
221 **/ 220 */
222static struct fcoe_transport *fcoe_transport_lookup( 221static struct fcoe_transport *
223 struct net_device *netdev) 222fcoe_transport_lookup(struct net_device *netdev)
224{ 223{
225 struct fcoe_transport *t; 224 struct fcoe_transport *t;
226 225
@@ -239,11 +238,11 @@ static struct fcoe_transport *fcoe_transport_lookup(
239} 238}
240 239
241/** 240/**
242 * fcoe_transport_register - adds a fcoe transport to the fcoe transports list 241 * fcoe_transport_register() - Adds a fcoe transport to the fcoe transports list
243 * @t: ptr to the fcoe transport to be added 242 * @t: ptr to the fcoe transport to be added
244 * 243 *
245 * Returns: 0 for success 244 * Returns: 0 for success
246 **/ 245 */
247int fcoe_transport_register(struct fcoe_transport *t) 246int fcoe_transport_register(struct fcoe_transport *t)
248{ 247{
249 struct fcoe_transport *tt; 248 struct fcoe_transport *tt;
@@ -259,9 +258,6 @@ int fcoe_transport_register(struct fcoe_transport *t)
259 list_add_tail(&t->list, &fcoe_transports); 258 list_add_tail(&t->list, &fcoe_transports);
260 mutex_unlock(&fcoe_transports_lock); 259 mutex_unlock(&fcoe_transports_lock);
261 260
262 mutex_init(&t->devlock);
263 INIT_LIST_HEAD(&t->devlist);
264
265 printk(KERN_DEBUG "fcoe_transport_register:%s\n", t->name); 261 printk(KERN_DEBUG "fcoe_transport_register:%s\n", t->name);
266 262
267 return 0; 263 return 0;
@@ -269,11 +265,11 @@ int fcoe_transport_register(struct fcoe_transport *t)
269EXPORT_SYMBOL_GPL(fcoe_transport_register); 265EXPORT_SYMBOL_GPL(fcoe_transport_register);
270 266
271/** 267/**
272 * fcoe_transport_unregister - remove the tranport fro the fcoe transports list 268 * fcoe_transport_unregister() - Remove the tranport fro the fcoe transports list
273 * @t: ptr to the fcoe transport to be removed 269 * @t: ptr to the fcoe transport to be removed
274 * 270 *
275 * Returns: 0 for success 271 * Returns: 0 for success
276 **/ 272 */
277int fcoe_transport_unregister(struct fcoe_transport *t) 273int fcoe_transport_unregister(struct fcoe_transport *t)
278{ 274{
279 struct fcoe_transport *tt, *tmp; 275 struct fcoe_transport *tt, *tmp;
@@ -294,8 +290,8 @@ int fcoe_transport_unregister(struct fcoe_transport *t)
294} 290}
295EXPORT_SYMBOL_GPL(fcoe_transport_unregister); 291EXPORT_SYMBOL_GPL(fcoe_transport_unregister);
296 292
297/* 293/**
298 * fcoe_load_transport_driver - load an offload driver by alias name 294 * fcoe_load_transport_driver() - Load an offload driver by alias name
299 * @netdev: the target net device 295 * @netdev: the target net device
300 * 296 *
301 * Requests for an offload driver module as the fcoe transport, if fails, it 297 * Requests for an offload driver module as the fcoe transport, if fails, it
@@ -307,7 +303,7 @@ EXPORT_SYMBOL_GPL(fcoe_transport_unregister);
307 * 3. pure hw fcoe hba may not have netdev 303 * 3. pure hw fcoe hba may not have netdev
308 * 304 *
309 * Returns: 0 for success 305 * Returns: 0 for success
310 **/ 306 */
311int fcoe_load_transport_driver(struct net_device *netdev) 307int fcoe_load_transport_driver(struct net_device *netdev)
312{ 308{
313 struct pci_dev *pci; 309 struct pci_dev *pci;
@@ -335,14 +331,14 @@ int fcoe_load_transport_driver(struct net_device *netdev)
335EXPORT_SYMBOL_GPL(fcoe_load_transport_driver); 331EXPORT_SYMBOL_GPL(fcoe_load_transport_driver);
336 332
337/** 333/**
338 * fcoe_transport_attach - load transport to fcoe 334 * fcoe_transport_attach() - Load transport to fcoe
339 * @netdev: the netdev the transport to be attached to 335 * @netdev: the netdev the transport to be attached to
340 * 336 *
341 * This will look for existing offload driver, if not found, it falls back to 337 * This will look for existing offload driver, if not found, it falls back to
342 * the default sw hba (fcoe_sw) as its fcoe transport. 338 * the default sw hba (fcoe_sw) as its fcoe transport.
343 * 339 *
344 * Returns: 0 for success 340 * Returns: 0 for success
345 **/ 341 */
346int fcoe_transport_attach(struct net_device *netdev) 342int fcoe_transport_attach(struct net_device *netdev)
347{ 343{
348 struct fcoe_transport *t; 344 struct fcoe_transport *t;
@@ -373,11 +369,11 @@ int fcoe_transport_attach(struct net_device *netdev)
373EXPORT_SYMBOL_GPL(fcoe_transport_attach); 369EXPORT_SYMBOL_GPL(fcoe_transport_attach);
374 370
375/** 371/**
376 * fcoe_transport_release - unload transport from fcoe 372 * fcoe_transport_release() - Unload transport from fcoe
377 * @netdev: the net device on which fcoe is to be released 373 * @netdev: the net device on which fcoe is to be released
378 * 374 *
379 * Returns: 0 for success 375 * Returns: 0 for success
380 **/ 376 */
381int fcoe_transport_release(struct net_device *netdev) 377int fcoe_transport_release(struct net_device *netdev)
382{ 378{
383 struct fcoe_transport *t; 379 struct fcoe_transport *t;
@@ -410,12 +406,12 @@ int fcoe_transport_release(struct net_device *netdev)
410EXPORT_SYMBOL_GPL(fcoe_transport_release); 406EXPORT_SYMBOL_GPL(fcoe_transport_release);
411 407
412/** 408/**
413 * fcoe_transport_init - initializes fcoe transport layer 409 * fcoe_transport_init() - Initializes fcoe transport layer
414 * 410 *
415 * This prepares for the fcoe transport layer 411 * This prepares for the fcoe transport layer
416 * 412 *
417 * Returns: none 413 * Returns: none
418 **/ 414 */
419int __init fcoe_transport_init(void) 415int __init fcoe_transport_init(void)
420{ 416{
421 INIT_LIST_HEAD(&fcoe_transports); 417 INIT_LIST_HEAD(&fcoe_transports);
@@ -424,12 +420,13 @@ int __init fcoe_transport_init(void)
424} 420}
425 421
426/** 422/**
427 * fcoe_transport_exit - cleans up the fcoe transport layer 423 * fcoe_transport_exit() - Cleans up the fcoe transport layer
424 *
428 * This cleans up the fcoe transport layer. removing any transport on the list, 425 * This cleans up the fcoe transport layer. removing any transport on the list,
429 * note that the transport destroy func is not called here. 426 * note that the transport destroy func is not called here.
430 * 427 *
431 * Returns: none 428 * Returns: none
432 **/ 429 */
433int __exit fcoe_transport_exit(void) 430int __exit fcoe_transport_exit(void)
434{ 431{
435 struct fcoe_transport *t, *tmp; 432 struct fcoe_transport *t, *tmp;
diff --git a/drivers/scsi/fcoe/fcoe_sw.c b/drivers/scsi/fcoe/fcoe_sw.c
index dc4cd5e25760..da210eba1941 100644
--- a/drivers/scsi/fcoe/fcoe_sw.c
+++ b/drivers/scsi/fcoe/fcoe_sw.c
@@ -104,19 +104,19 @@ static struct scsi_host_template fcoe_sw_shost_template = {
104 .max_sectors = 0xffff, 104 .max_sectors = 0xffff,
105}; 105};
106 106
107/* 107/**
108 * fcoe_sw_lport_config - sets up the fc_lport 108 * fcoe_sw_lport_config() - sets up the fc_lport
109 * @lp: ptr to the fc_lport 109 * @lp: ptr to the fc_lport
110 * @shost: ptr to the parent scsi host 110 * @shost: ptr to the parent scsi host
111 * 111 *
112 * Returns: 0 for success 112 * Returns: 0 for success
113 *
114 */ 113 */
115static int fcoe_sw_lport_config(struct fc_lport *lp) 114static int fcoe_sw_lport_config(struct fc_lport *lp)
116{ 115{
117 int i = 0; 116 int i = 0;
118 117
119 lp->link_status = 0; 118 lp->link_up = 0;
119 lp->qfull = 0;
120 lp->max_retry_count = 3; 120 lp->max_retry_count = 3;
121 lp->e_d_tov = 2 * 1000; /* FC-FS default */ 121 lp->e_d_tov = 2 * 1000; /* FC-FS default */
122 lp->r_a_tov = 2 * 2 * 1000; 122 lp->r_a_tov = 2 * 2 * 1000;
@@ -136,16 +136,14 @@ static int fcoe_sw_lport_config(struct fc_lport *lp)
136 return 0; 136 return 0;
137} 137}
138 138
139/* 139/**
140 * fcoe_sw_netdev_config - sets up fcoe_softc for lport and network 140 * fcoe_sw_netdev_config() - Set up netdev for SW FCoE
141 * related properties
142 * @lp : ptr to the fc_lport 141 * @lp : ptr to the fc_lport
143 * @netdev : ptr to the associated netdevice struct 142 * @netdev : ptr to the associated netdevice struct
144 * 143 *
145 * Must be called after fcoe_sw_lport_config() as it will use lport mutex 144 * Must be called after fcoe_sw_lport_config() as it will use lport mutex
146 * 145 *
147 * Returns : 0 for success 146 * Returns : 0 for success
148 *
149 */ 147 */
150static int fcoe_sw_netdev_config(struct fc_lport *lp, struct net_device *netdev) 148static int fcoe_sw_netdev_config(struct fc_lport *lp, struct net_device *netdev)
151{ 149{
@@ -181,9 +179,8 @@ static int fcoe_sw_netdev_config(struct fc_lport *lp, struct net_device *netdev)
181 if (fc_set_mfs(lp, mfs)) 179 if (fc_set_mfs(lp, mfs))
182 return -EINVAL; 180 return -EINVAL;
183 181
184 lp->link_status = ~FC_PAUSE & ~FC_LINK_UP;
185 if (!fcoe_link_ok(lp)) 182 if (!fcoe_link_ok(lp))
186 lp->link_status |= FC_LINK_UP; 183 lp->link_up = 1;
187 184
188 /* offload features support */ 185 /* offload features support */
189 if (fc->real_dev->features & NETIF_F_SG) 186 if (fc->real_dev->features & NETIF_F_SG)
@@ -191,6 +188,7 @@ static int fcoe_sw_netdev_config(struct fc_lport *lp, struct net_device *netdev)
191 188
192 189
193 skb_queue_head_init(&fc->fcoe_pending_queue); 190 skb_queue_head_init(&fc->fcoe_pending_queue);
191 fc->fcoe_pending_queue_active = 0;
194 192
195 /* setup Source Mac Address */ 193 /* setup Source Mac Address */
196 memcpy(fc->ctl_src_addr, fc->real_dev->dev_addr, 194 memcpy(fc->ctl_src_addr, fc->real_dev->dev_addr,
@@ -224,16 +222,15 @@ static int fcoe_sw_netdev_config(struct fc_lport *lp, struct net_device *netdev)
224 return 0; 222 return 0;
225} 223}
226 224
227/* 225/**
228 * fcoe_sw_shost_config - sets up fc_lport->host 226 * fcoe_sw_shost_config() - Sets up fc_lport->host
229 * @lp : ptr to the fc_lport 227 * @lp : ptr to the fc_lport
230 * @shost : ptr to the associated scsi host 228 * @shost : ptr to the associated scsi host
231 * @dev : device associated to scsi host 229 * @dev : device associated to scsi host
232 * 230 *
233 * Must be called after fcoe_sw_lport_config) and fcoe_sw_netdev_config() 231 * Must be called after fcoe_sw_lport_config() and fcoe_sw_netdev_config()
234 * 232 *
235 * Returns : 0 for success 233 * Returns : 0 for success
236 *
237 */ 234 */
238static int fcoe_sw_shost_config(struct fc_lport *lp, struct Scsi_Host *shost, 235static int fcoe_sw_shost_config(struct fc_lport *lp, struct Scsi_Host *shost,
239 struct device *dev) 236 struct device *dev)
@@ -261,8 +258,8 @@ static int fcoe_sw_shost_config(struct fc_lport *lp, struct Scsi_Host *shost,
261 return 0; 258 return 0;
262} 259}
263 260
264/* 261/**
265 * fcoe_sw_em_config - allocates em for this lport 262 * fcoe_sw_em_config() - allocates em for this lport
266 * @lp: the port that em is to allocated for 263 * @lp: the port that em is to allocated for
267 * 264 *
268 * Returns : 0 on success 265 * Returns : 0 on success
@@ -279,8 +276,8 @@ static inline int fcoe_sw_em_config(struct fc_lport *lp)
279 return 0; 276 return 0;
280} 277}
281 278
282/* 279/**
283 * fcoe_sw_destroy - FCoE software HBA tear-down function 280 * fcoe_sw_destroy() - FCoE software HBA tear-down function
284 * @netdev: ptr to the associated net_device 281 * @netdev: ptr to the associated net_device
285 * 282 *
286 * Returns: 0 if link is OK for use by FCoE. 283 * Returns: 0 if link is OK for use by FCoE.
@@ -301,7 +298,7 @@ static int fcoe_sw_destroy(struct net_device *netdev)
301 if (!lp) 298 if (!lp)
302 return -ENODEV; 299 return -ENODEV;
303 300
304 fc = fcoe_softc(lp); 301 fc = lport_priv(lp);
305 302
306 /* Logout of the fabric */ 303 /* Logout of the fabric */
307 fc_fabric_logoff(lp); 304 fc_fabric_logoff(lp);
@@ -353,8 +350,8 @@ static struct libfc_function_template fcoe_sw_libfc_fcn_templ = {
353 .frame_send = fcoe_xmit, 350 .frame_send = fcoe_xmit,
354}; 351};
355 352
356/* 353/**
357 * fcoe_sw_create - this function creates the fcoe interface 354 * fcoe_sw_create() - this function creates the fcoe interface
358 * @netdev: pointer the associated netdevice 355 * @netdev: pointer the associated netdevice
359 * 356 *
360 * Creates fc_lport struct and scsi_host for lport, configures lport 357 * Creates fc_lport struct and scsi_host for lport, configures lport
@@ -440,8 +437,8 @@ out_host_put:
440 return rc; 437 return rc;
441} 438}
442 439
443/* 440/**
444 * fcoe_sw_match - the fcoe sw transport match function 441 * fcoe_sw_match() - The FCoE SW transport match function
445 * 442 *
446 * Returns : false always 443 * Returns : false always
447 */ 444 */
@@ -461,8 +458,8 @@ struct fcoe_transport fcoe_sw_transport = {
461 .device = 0xffff, 458 .device = 0xffff,
462}; 459};
463 460
464/* 461/**
465 * fcoe_sw_init - registers fcoe_sw_transport 462 * fcoe_sw_init() - Registers fcoe_sw_transport
466 * 463 *
467 * Returns : 0 on success 464 * Returns : 0 on success
468 */ 465 */
@@ -471,17 +468,22 @@ int __init fcoe_sw_init(void)
471 /* attach to scsi transport */ 468 /* attach to scsi transport */
472 scsi_transport_fcoe_sw = 469 scsi_transport_fcoe_sw =
473 fc_attach_transport(&fcoe_sw_transport_function); 470 fc_attach_transport(&fcoe_sw_transport_function);
471
474 if (!scsi_transport_fcoe_sw) { 472 if (!scsi_transport_fcoe_sw) {
475 printk(KERN_ERR "fcoe_sw_init:fc_attach_transport() failed\n"); 473 printk(KERN_ERR "fcoe_sw_init:fc_attach_transport() failed\n");
476 return -ENODEV; 474 return -ENODEV;
477 } 475 }
476
477 mutex_init(&fcoe_sw_transport.devlock);
478 INIT_LIST_HEAD(&fcoe_sw_transport.devlist);
479
478 /* register sw transport */ 480 /* register sw transport */
479 fcoe_transport_register(&fcoe_sw_transport); 481 fcoe_transport_register(&fcoe_sw_transport);
480 return 0; 482 return 0;
481} 483}
482 484
483/* 485/**
484 * fcoe_sw_exit - unregisters fcoe_sw_transport 486 * fcoe_sw_exit() - Unregisters fcoe_sw_transport
485 * 487 *
486 * Returns : 0 on success 488 * Returns : 0 on success
487 */ 489 */
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c
index e419f486cdb3..5548bf3bb58b 100644
--- a/drivers/scsi/fcoe/libfcoe.c
+++ b/drivers/scsi/fcoe/libfcoe.c
@@ -49,6 +49,7 @@
49static int debug_fcoe; 49static int debug_fcoe;
50 50
51#define FCOE_MAX_QUEUE_DEPTH 256 51#define FCOE_MAX_QUEUE_DEPTH 256
52#define FCOE_LOW_QUEUE_DEPTH 32
52 53
53/* destination address mode */ 54/* destination address mode */
54#define FCOE_GW_ADDR_MODE 0x00 55#define FCOE_GW_ADDR_MODE 0x00
@@ -69,8 +70,6 @@ struct fcoe_percpu_s *fcoe_percpu[NR_CPUS];
69 70
70/* Function Prototyes */ 71/* Function Prototyes */
71static int fcoe_check_wait_queue(struct fc_lport *); 72static int fcoe_check_wait_queue(struct fc_lport *);
72static void fcoe_insert_wait_queue_head(struct fc_lport *, struct sk_buff *);
73static void fcoe_insert_wait_queue(struct fc_lport *, struct sk_buff *);
74static void fcoe_recv_flogi(struct fcoe_softc *, struct fc_frame *, u8 *); 73static void fcoe_recv_flogi(struct fcoe_softc *, struct fc_frame *, u8 *);
75#ifdef CONFIG_HOTPLUG_CPU 74#ifdef CONFIG_HOTPLUG_CPU
76static int fcoe_cpu_callback(struct notifier_block *, ulong, void *); 75static int fcoe_cpu_callback(struct notifier_block *, ulong, void *);
@@ -91,13 +90,13 @@ static struct notifier_block fcoe_cpu_notifier = {
91}; 90};
92 91
93/** 92/**
94 * fcoe_create_percpu_data - creates the associated cpu data 93 * fcoe_create_percpu_data() - creates the associated cpu data
95 * @cpu: index for the cpu where fcoe cpu data will be created 94 * @cpu: index for the cpu where fcoe cpu data will be created
96 * 95 *
97 * create percpu stats block, from cpu add notifier 96 * create percpu stats block, from cpu add notifier
98 * 97 *
99 * Returns: none 98 * Returns: none
100 **/ 99 */
101static void fcoe_create_percpu_data(int cpu) 100static void fcoe_create_percpu_data(int cpu)
102{ 101{
103 struct fc_lport *lp; 102 struct fc_lport *lp;
@@ -115,13 +114,13 @@ static void fcoe_create_percpu_data(int cpu)
115} 114}
116 115
117/** 116/**
118 * fcoe_destroy_percpu_data - destroys the associated cpu data 117 * fcoe_destroy_percpu_data() - destroys the associated cpu data
119 * @cpu: index for the cpu where fcoe cpu data will destroyed 118 * @cpu: index for the cpu where fcoe cpu data will destroyed
120 * 119 *
121 * destroy percpu stats block called by cpu add/remove notifier 120 * destroy percpu stats block called by cpu add/remove notifier
122 * 121 *
123 * Retuns: none 122 * Retuns: none
124 **/ 123 */
125static void fcoe_destroy_percpu_data(int cpu) 124static void fcoe_destroy_percpu_data(int cpu)
126{ 125{
127 struct fc_lport *lp; 126 struct fc_lport *lp;
@@ -137,7 +136,7 @@ static void fcoe_destroy_percpu_data(int cpu)
137} 136}
138 137
139/** 138/**
140 * fcoe_cpu_callback - fcoe cpu hotplug event callback 139 * fcoe_cpu_callback() - fcoe cpu hotplug event callback
141 * @nfb: callback data block 140 * @nfb: callback data block
142 * @action: event triggering the callback 141 * @action: event triggering the callback
143 * @hcpu: index for the cpu of this event 142 * @hcpu: index for the cpu of this event
@@ -145,7 +144,7 @@ static void fcoe_destroy_percpu_data(int cpu)
145 * this creates or destroys per cpu data for fcoe 144 * this creates or destroys per cpu data for fcoe
146 * 145 *
147 * Returns NOTIFY_OK always. 146 * Returns NOTIFY_OK always.
148 **/ 147 */
149static int fcoe_cpu_callback(struct notifier_block *nfb, unsigned long action, 148static int fcoe_cpu_callback(struct notifier_block *nfb, unsigned long action,
150 void *hcpu) 149 void *hcpu)
151{ 150{
@@ -166,7 +165,7 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, unsigned long action,
166#endif /* CONFIG_HOTPLUG_CPU */ 165#endif /* CONFIG_HOTPLUG_CPU */
167 166
168/** 167/**
169 * fcoe_rcv - this is the fcoe receive function called by NET_RX_SOFTIRQ 168 * fcoe_rcv() - this is the fcoe receive function called by NET_RX_SOFTIRQ
170 * @skb: the receive skb 169 * @skb: the receive skb
171 * @dev: associated net device 170 * @dev: associated net device
172 * @ptype: context 171 * @ptype: context
@@ -175,7 +174,7 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, unsigned long action,
175 * this function will receive the packet and build fc frame and pass it up 174 * this function will receive the packet and build fc frame and pass it up
176 * 175 *
177 * Returns: 0 for success 176 * Returns: 0 for success
178 **/ 177 */
179int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, 178int fcoe_rcv(struct sk_buff *skb, struct net_device *dev,
180 struct packet_type *ptype, struct net_device *olddev) 179 struct packet_type *ptype, struct net_device *olddev)
181{ 180{
@@ -265,11 +264,11 @@ err2:
265EXPORT_SYMBOL_GPL(fcoe_rcv); 264EXPORT_SYMBOL_GPL(fcoe_rcv);
266 265
267/** 266/**
268 * fcoe_start_io - pass to netdev to start xmit for fcoe 267 * fcoe_start_io() - pass to netdev to start xmit for fcoe
269 * @skb: the skb to be xmitted 268 * @skb: the skb to be xmitted
270 * 269 *
271 * Returns: 0 for success 270 * Returns: 0 for success
272 **/ 271 */
273static inline int fcoe_start_io(struct sk_buff *skb) 272static inline int fcoe_start_io(struct sk_buff *skb)
274{ 273{
275 int rc; 274 int rc;
@@ -283,12 +282,12 @@ static inline int fcoe_start_io(struct sk_buff *skb)
283} 282}
284 283
285/** 284/**
286 * fcoe_get_paged_crc_eof - in case we need alloc a page for crc_eof 285 * fcoe_get_paged_crc_eof() - in case we need alloc a page for crc_eof
287 * @skb: the skb to be xmitted 286 * @skb: the skb to be xmitted
288 * @tlen: total len 287 * @tlen: total len
289 * 288 *
290 * Returns: 0 for success 289 * Returns: 0 for success
291 **/ 290 */
292static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen) 291static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen)
293{ 292{
294 struct fcoe_percpu_s *fps; 293 struct fcoe_percpu_s *fps;
@@ -326,13 +325,12 @@ static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen)
326} 325}
327 326
328/** 327/**
329 * fcoe_fc_crc - calculates FC CRC in this fcoe skb 328 * fcoe_fc_crc() - calculates FC CRC in this fcoe skb
330 * @fp: the fc_frame containg data to be checksummed 329 * @fp: the fc_frame containg data to be checksummed
331 * 330 *
332 * This uses crc32() to calculate the crc for fc frame 331 * This uses crc32() to calculate the crc for fc frame
333 * Return : 32 bit crc 332 * Return : 32 bit crc
334 * 333 */
335 **/
336u32 fcoe_fc_crc(struct fc_frame *fp) 334u32 fcoe_fc_crc(struct fc_frame *fp)
337{ 335{
338 struct sk_buff *skb = fp_skb(fp); 336 struct sk_buff *skb = fp_skb(fp);
@@ -363,13 +361,12 @@ u32 fcoe_fc_crc(struct fc_frame *fp)
363EXPORT_SYMBOL_GPL(fcoe_fc_crc); 361EXPORT_SYMBOL_GPL(fcoe_fc_crc);
364 362
365/** 363/**
366 * fcoe_xmit - FCoE frame transmit function 364 * fcoe_xmit() - FCoE frame transmit function
367 * @lp: the associated local port 365 * @lp: the associated local port
368 * @fp: the fc_frame to be transmitted 366 * @fp: the fc_frame to be transmitted
369 * 367 *
370 * Return : 0 for success 368 * Return : 0 for success
371 * 369 */
372 **/
373int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) 370int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
374{ 371{
375 int wlen, rc = 0; 372 int wlen, rc = 0;
@@ -389,7 +386,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
389 386
390 WARN_ON((fr_len(fp) % sizeof(u32)) != 0); 387 WARN_ON((fr_len(fp) % sizeof(u32)) != 0);
391 388
392 fc = fcoe_softc(lp); 389 fc = lport_priv(lp);
393 /* 390 /*
394 * if it is a flogi then we need to learn gw-addr 391 * if it is a flogi then we need to learn gw-addr
395 * and my own fcid 392 * and my own fcid
@@ -439,7 +436,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
439 if (skb_is_nonlinear(skb)) { 436 if (skb_is_nonlinear(skb)) {
440 skb_frag_t *frag; 437 skb_frag_t *frag;
441 if (fcoe_get_paged_crc_eof(skb, tlen)) { 438 if (fcoe_get_paged_crc_eof(skb, tlen)) {
442 kfree(skb); 439 kfree_skb(skb);
443 return -ENOMEM; 440 return -ENOMEM;
444 } 441 }
445 frag = &skb_shinfo(skb)->frags[skb_shinfo(skb)->nr_frags - 1]; 442 frag = &skb_shinfo(skb)->frags[skb_shinfo(skb)->nr_frags - 1];
@@ -502,21 +499,22 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
502 rc = fcoe_start_io(skb); 499 rc = fcoe_start_io(skb);
503 500
504 if (rc) { 501 if (rc) {
505 fcoe_insert_wait_queue(lp, skb); 502 spin_lock_bh(&fc->fcoe_pending_queue.lock);
503 __skb_queue_tail(&fc->fcoe_pending_queue, skb);
504 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
506 if (fc->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH) 505 if (fc->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH)
507 fc_pause(lp); 506 lp->qfull = 1;
508 } 507 }
509 508
510 return 0; 509 return 0;
511} 510}
512EXPORT_SYMBOL_GPL(fcoe_xmit); 511EXPORT_SYMBOL_GPL(fcoe_xmit);
513 512
514/* 513/**
515 * fcoe_percpu_receive_thread - recv thread per cpu 514 * fcoe_percpu_receive_thread() - recv thread per cpu
516 * @arg: ptr to the fcoe per cpu struct 515 * @arg: ptr to the fcoe per cpu struct
517 * 516 *
518 * Return: 0 for success 517 * Return: 0 for success
519 *
520 */ 518 */
521int fcoe_percpu_receive_thread(void *arg) 519int fcoe_percpu_receive_thread(void *arg)
522{ 520{
@@ -533,7 +531,7 @@ int fcoe_percpu_receive_thread(void *arg)
533 struct fcoe_softc *fc; 531 struct fcoe_softc *fc;
534 struct fcoe_hdr *hp; 532 struct fcoe_hdr *hp;
535 533
536 set_user_nice(current, 19); 534 set_user_nice(current, -20);
537 535
538 while (!kthread_should_stop()) { 536 while (!kthread_should_stop()) {
539 537
@@ -658,7 +656,7 @@ int fcoe_percpu_receive_thread(void *arg)
658} 656}
659 657
660/** 658/**
661 * fcoe_recv_flogi - flogi receive function 659 * fcoe_recv_flogi() - flogi receive function
662 * @fc: associated fcoe_softc 660 * @fc: associated fcoe_softc
663 * @fp: the recieved frame 661 * @fp: the recieved frame
664 * @sa: the source address of this flogi 662 * @sa: the source address of this flogi
@@ -667,7 +665,7 @@ int fcoe_percpu_receive_thread(void *arg)
667 * mac address for the initiator, eitehr OUI based or GW based. 665 * mac address for the initiator, eitehr OUI based or GW based.
668 * 666 *
669 * Returns: none 667 * Returns: none
670 **/ 668 */
671static void fcoe_recv_flogi(struct fcoe_softc *fc, struct fc_frame *fp, u8 *sa) 669static void fcoe_recv_flogi(struct fcoe_softc *fc, struct fc_frame *fp, u8 *sa)
672{ 670{
673 struct fc_frame_header *fh; 671 struct fc_frame_header *fh;
@@ -715,32 +713,23 @@ static void fcoe_recv_flogi(struct fcoe_softc *fc, struct fc_frame *fp, u8 *sa)
715} 713}
716 714
717/** 715/**
718 * fcoe_watchdog - fcoe timer callback 716 * fcoe_watchdog() - fcoe timer callback
719 * @vp: 717 * @vp:
720 * 718 *
721 * This checks the pending queue length for fcoe and put fcoe to be paused state 719 * This checks the pending queue length for fcoe and set lport qfull
722 * if the FCOE_MAX_QUEUE_DEPTH is reached. This is done for all fc_lport on the 720 * if the FCOE_MAX_QUEUE_DEPTH is reached. This is done for all fc_lport on the
723 * fcoe_hostlist. 721 * fcoe_hostlist.
724 * 722 *
725 * Returns: 0 for success 723 * Returns: 0 for success
726 **/ 724 */
727void fcoe_watchdog(ulong vp) 725void fcoe_watchdog(ulong vp)
728{ 726{
729 struct fc_lport *lp;
730 struct fcoe_softc *fc; 727 struct fcoe_softc *fc;
731 int paused = 0;
732 728
733 read_lock(&fcoe_hostlist_lock); 729 read_lock(&fcoe_hostlist_lock);
734 list_for_each_entry(fc, &fcoe_hostlist, list) { 730 list_for_each_entry(fc, &fcoe_hostlist, list) {
735 lp = fc->lp; 731 if (fc->lp)
736 if (lp) { 732 fcoe_check_wait_queue(fc->lp);
737 if (fc->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH)
738 paused = 1;
739 if (fcoe_check_wait_queue(lp) < FCOE_MAX_QUEUE_DEPTH) {
740 if (paused)
741 fc_unpause(lp);
742 }
743 }
744 } 733 }
745 read_unlock(&fcoe_hostlist_lock); 734 read_unlock(&fcoe_hostlist_lock);
746 735
@@ -750,96 +739,64 @@ void fcoe_watchdog(ulong vp)
750 739
751 740
752/** 741/**
753 * fcoe_check_wait_queue - put the skb into fcoe pending xmit queue 742 * fcoe_check_wait_queue() - put the skb into fcoe pending xmit queue
754 * @lp: the fc_port for this skb 743 * @lp: the fc_port for this skb
755 * @skb: the associated skb to be xmitted 744 * @skb: the associated skb to be xmitted
756 * 745 *
757 * This empties the wait_queue, dequeue the head of the wait_queue queue 746 * This empties the wait_queue, dequeue the head of the wait_queue queue
758 * and calls fcoe_start_io() for each packet, if all skb have been 747 * and calls fcoe_start_io() for each packet, if all skb have been
759 * transmitted, return 0 if a error occurs, then restore wait_queue and 748 * transmitted, return qlen or -1 if a error occurs, then restore
760 * try again later. 749 * wait_queue and try again later.
761 * 750 *
762 * The wait_queue is used when the skb transmit fails. skb will go 751 * The wait_queue is used when the skb transmit fails. skb will go
763 * in the wait_queue which will be emptied by the time function OR 752 * in the wait_queue which will be emptied by the time function OR
764 * by the next skb transmit. 753 * by the next skb transmit.
765 * 754 *
766 * Returns: 0 for success 755 * Returns: 0 for success
767 **/ 756 */
768static int fcoe_check_wait_queue(struct fc_lport *lp) 757static int fcoe_check_wait_queue(struct fc_lport *lp)
769{ 758{
770 int rc, unpause = 0; 759 struct fcoe_softc *fc = lport_priv(lp);
771 int paused = 0;
772 struct sk_buff *skb; 760 struct sk_buff *skb;
773 struct fcoe_softc *fc; 761 int rc = -1;
774 762
775 fc = fcoe_softc(lp);
776 spin_lock_bh(&fc->fcoe_pending_queue.lock); 763 spin_lock_bh(&fc->fcoe_pending_queue.lock);
764 if (fc->fcoe_pending_queue_active)
765 goto out;
766 fc->fcoe_pending_queue_active = 1;
777 767
778 /* 768 while (fc->fcoe_pending_queue.qlen) {
779 * is this interface paused? 769 /* keep qlen > 0 until fcoe_start_io succeeds */
780 */ 770 fc->fcoe_pending_queue.qlen++;
781 if (fc->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH) 771 skb = __skb_dequeue(&fc->fcoe_pending_queue);
782 paused = 1;
783 if (fc->fcoe_pending_queue.qlen) {
784 while ((skb = __skb_dequeue(&fc->fcoe_pending_queue)) != NULL) {
785 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
786 rc = fcoe_start_io(skb);
787 if (rc) {
788 fcoe_insert_wait_queue_head(lp, skb);
789 return rc;
790 }
791 spin_lock_bh(&fc->fcoe_pending_queue.lock);
792 }
793 if (fc->fcoe_pending_queue.qlen < FCOE_MAX_QUEUE_DEPTH)
794 unpause = 1;
795 }
796 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
797 if ((unpause) && (paused))
798 fc_unpause(lp);
799 return fc->fcoe_pending_queue.qlen;
800}
801
802/**
803 * fcoe_insert_wait_queue_head - puts skb to fcoe pending queue head
804 * @lp: the fc_port for this skb
805 * @skb: the associated skb to be xmitted
806 *
807 * Returns: none
808 **/
809static void fcoe_insert_wait_queue_head(struct fc_lport *lp,
810 struct sk_buff *skb)
811{
812 struct fcoe_softc *fc;
813 772
814 fc = fcoe_softc(lp); 773 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
815 spin_lock_bh(&fc->fcoe_pending_queue.lock); 774 rc = fcoe_start_io(skb);
816 __skb_queue_head(&fc->fcoe_pending_queue, skb); 775 spin_lock_bh(&fc->fcoe_pending_queue.lock);
817 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
818}
819 776
820/** 777 if (rc) {
821 * fcoe_insert_wait_queue - put the skb into fcoe pending queue tail 778 __skb_queue_head(&fc->fcoe_pending_queue, skb);
822 * @lp: the fc_port for this skb 779 /* undo temporary increment above */
823 * @skb: the associated skb to be xmitted 780 fc->fcoe_pending_queue.qlen--;
824 * 781 break;
825 * Returns: none 782 }
826 **/ 783 /* undo temporary increment above */
827static void fcoe_insert_wait_queue(struct fc_lport *lp, 784 fc->fcoe_pending_queue.qlen--;
828 struct sk_buff *skb) 785 }
829{
830 struct fcoe_softc *fc;
831 786
832 fc = fcoe_softc(lp); 787 if (fc->fcoe_pending_queue.qlen < FCOE_LOW_QUEUE_DEPTH)
833 spin_lock_bh(&fc->fcoe_pending_queue.lock); 788 lp->qfull = 0;
834 __skb_queue_tail(&fc->fcoe_pending_queue, skb); 789 fc->fcoe_pending_queue_active = 0;
790 rc = fc->fcoe_pending_queue.qlen;
791out:
835 spin_unlock_bh(&fc->fcoe_pending_queue.lock); 792 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
793 return rc;
836} 794}
837 795
838/** 796/**
839 * fcoe_dev_setup - setup link change notification interface 797 * fcoe_dev_setup() - setup link change notification interface
840 * 798 */
841 **/ 799static void fcoe_dev_setup()
842static void fcoe_dev_setup(void)
843{ 800{
844 /* 801 /*
845 * here setup a interface specific wd time to 802 * here setup a interface specific wd time to
@@ -849,15 +806,15 @@ static void fcoe_dev_setup(void)
849} 806}
850 807
851/** 808/**
852 * fcoe_dev_setup - cleanup link change notification interface 809 * fcoe_dev_setup() - cleanup link change notification interface
853 **/ 810 */
854static void fcoe_dev_cleanup(void) 811static void fcoe_dev_cleanup(void)
855{ 812{
856 unregister_netdevice_notifier(&fcoe_notifier); 813 unregister_netdevice_notifier(&fcoe_notifier);
857} 814}
858 815
859/** 816/**
860 * fcoe_device_notification - netdev event notification callback 817 * fcoe_device_notification() - netdev event notification callback
861 * @notifier: context of the notification 818 * @notifier: context of the notification
862 * @event: type of event 819 * @event: type of event
863 * @ptr: fixed array for output parsed ifname 820 * @ptr: fixed array for output parsed ifname
@@ -865,7 +822,7 @@ static void fcoe_dev_cleanup(void)
865 * This function is called by the ethernet driver in case of link change event 822 * This function is called by the ethernet driver in case of link change event
866 * 823 *
867 * Returns: 0 for success 824 * Returns: 0 for success
868 **/ 825 */
869static int fcoe_device_notification(struct notifier_block *notifier, 826static int fcoe_device_notification(struct notifier_block *notifier,
870 ulong event, void *ptr) 827 ulong event, void *ptr)
871{ 828{
@@ -873,7 +830,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
873 struct net_device *real_dev = ptr; 830 struct net_device *real_dev = ptr;
874 struct fcoe_softc *fc; 831 struct fcoe_softc *fc;
875 struct fcoe_dev_stats *stats; 832 struct fcoe_dev_stats *stats;
876 u16 new_status; 833 u32 new_link_up;
877 u32 mfs; 834 u32 mfs;
878 int rc = NOTIFY_OK; 835 int rc = NOTIFY_OK;
879 836
@@ -890,17 +847,15 @@ static int fcoe_device_notification(struct notifier_block *notifier,
890 goto out; 847 goto out;
891 } 848 }
892 849
893 new_status = lp->link_status; 850 new_link_up = lp->link_up;
894 switch (event) { 851 switch (event) {
895 case NETDEV_DOWN: 852 case NETDEV_DOWN:
896 case NETDEV_GOING_DOWN: 853 case NETDEV_GOING_DOWN:
897 new_status &= ~FC_LINK_UP; 854 new_link_up = 0;
898 break; 855 break;
899 case NETDEV_UP: 856 case NETDEV_UP:
900 case NETDEV_CHANGE: 857 case NETDEV_CHANGE:
901 new_status &= ~FC_LINK_UP; 858 new_link_up = !fcoe_link_ok(lp);
902 if (!fcoe_link_ok(lp))
903 new_status |= FC_LINK_UP;
904 break; 859 break;
905 case NETDEV_CHANGEMTU: 860 case NETDEV_CHANGEMTU:
906 mfs = fc->real_dev->mtu - 861 mfs = fc->real_dev->mtu -
@@ -908,17 +863,15 @@ static int fcoe_device_notification(struct notifier_block *notifier,
908 sizeof(struct fcoe_crc_eof)); 863 sizeof(struct fcoe_crc_eof));
909 if (mfs >= FC_MIN_MAX_FRAME) 864 if (mfs >= FC_MIN_MAX_FRAME)
910 fc_set_mfs(lp, mfs); 865 fc_set_mfs(lp, mfs);
911 new_status &= ~FC_LINK_UP; 866 new_link_up = !fcoe_link_ok(lp);
912 if (!fcoe_link_ok(lp))
913 new_status |= FC_LINK_UP;
914 break; 867 break;
915 case NETDEV_REGISTER: 868 case NETDEV_REGISTER:
916 break; 869 break;
917 default: 870 default:
918 FC_DBG("unknown event %ld call", event); 871 FC_DBG("unknown event %ld call", event);
919 } 872 }
920 if (lp->link_status != new_status) { 873 if (lp->link_up != new_link_up) {
921 if ((new_status & FC_LINK_UP) == FC_LINK_UP) 874 if (new_link_up)
922 fc_linkup(lp); 875 fc_linkup(lp);
923 else { 876 else {
924 stats = lp->dev_stats[smp_processor_id()]; 877 stats = lp->dev_stats[smp_processor_id()];
@@ -933,12 +886,12 @@ out:
933} 886}
934 887
935/** 888/**
936 * fcoe_if_to_netdev - parse a name buffer to get netdev 889 * fcoe_if_to_netdev() - parse a name buffer to get netdev
937 * @ifname: fixed array for output parsed ifname 890 * @ifname: fixed array for output parsed ifname
938 * @buffer: incoming buffer to be copied 891 * @buffer: incoming buffer to be copied
939 * 892 *
940 * Returns: NULL or ptr to netdeive 893 * Returns: NULL or ptr to netdeive
941 **/ 894 */
942static struct net_device *fcoe_if_to_netdev(const char *buffer) 895static struct net_device *fcoe_if_to_netdev(const char *buffer)
943{ 896{
944 char *cp; 897 char *cp;
@@ -955,13 +908,13 @@ static struct net_device *fcoe_if_to_netdev(const char *buffer)
955} 908}
956 909
957/** 910/**
958 * fcoe_netdev_to_module_owner - finds out the nic drive moddule of the netdev 911 * fcoe_netdev_to_module_owner() - finds out the nic drive moddule of the netdev
959 * @netdev: the target netdev 912 * @netdev: the target netdev
960 * 913 *
961 * Returns: ptr to the struct module, NULL for failure 914 * Returns: ptr to the struct module, NULL for failure
962 **/ 915 */
963static struct module *fcoe_netdev_to_module_owner( 916static struct module *
964 const struct net_device *netdev) 917fcoe_netdev_to_module_owner(const struct net_device *netdev)
965{ 918{
966 struct device *dev; 919 struct device *dev;
967 920
@@ -979,12 +932,14 @@ static struct module *fcoe_netdev_to_module_owner(
979} 932}
980 933
981/** 934/**
982 * fcoe_ethdrv_get - holds the nic driver module by try_module_get() for 935 * fcoe_ethdrv_get() - Hold the Ethernet driver
983 * the corresponding netdev.
984 * @netdev: the target netdev 936 * @netdev: the target netdev
985 * 937 *
938 * Holds the Ethernet driver module by try_module_get() for
939 * the corresponding netdev.
940 *
986 * Returns: 0 for succsss 941 * Returns: 0 for succsss
987 **/ 942 */
988static int fcoe_ethdrv_get(const struct net_device *netdev) 943static int fcoe_ethdrv_get(const struct net_device *netdev)
989{ 944{
990 struct module *owner; 945 struct module *owner;
@@ -999,12 +954,14 @@ static int fcoe_ethdrv_get(const struct net_device *netdev)
999} 954}
1000 955
1001/** 956/**
1002 * fcoe_ethdrv_get - releases the nic driver module by module_put for 957 * fcoe_ethdrv_put() - Release the Ethernet driver
1003 * the corresponding netdev.
1004 * @netdev: the target netdev 958 * @netdev: the target netdev
1005 * 959 *
960 * Releases the Ethernet driver module by module_put for
961 * the corresponding netdev.
962 *
1006 * Returns: 0 for succsss 963 * Returns: 0 for succsss
1007 **/ 964 */
1008static int fcoe_ethdrv_put(const struct net_device *netdev) 965static int fcoe_ethdrv_put(const struct net_device *netdev)
1009{ 966{
1010 struct module *owner; 967 struct module *owner;
@@ -1020,12 +977,12 @@ static int fcoe_ethdrv_put(const struct net_device *netdev)
1020} 977}
1021 978
1022/** 979/**
1023 * fcoe_destroy- handles the destroy from sysfs 980 * fcoe_destroy() - handles the destroy from sysfs
1024 * @buffer: expcted to be a eth if name 981 * @buffer: expcted to be a eth if name
1025 * @kp: associated kernel param 982 * @kp: associated kernel param
1026 * 983 *
1027 * Returns: 0 for success 984 * Returns: 0 for success
1028 **/ 985 */
1029static int fcoe_destroy(const char *buffer, struct kernel_param *kp) 986static int fcoe_destroy(const char *buffer, struct kernel_param *kp)
1030{ 987{
1031 int rc; 988 int rc;
@@ -1058,12 +1015,12 @@ out_nodev:
1058} 1015}
1059 1016
1060/** 1017/**
1061 * fcoe_create - handles the create call from sysfs 1018 * fcoe_create() - Handles the create call from sysfs
1062 * @buffer: expcted to be a eth if name 1019 * @buffer: expcted to be a eth if name
1063 * @kp: associated kernel param 1020 * @kp: associated kernel param
1064 * 1021 *
1065 * Returns: 0 for success 1022 * Returns: 0 for success
1066 **/ 1023 */
1067static int fcoe_create(const char *buffer, struct kernel_param *kp) 1024static int fcoe_create(const char *buffer, struct kernel_param *kp)
1068{ 1025{
1069 int rc; 1026 int rc;
@@ -1104,8 +1061,8 @@ module_param_call(destroy, fcoe_destroy, NULL, NULL, S_IWUSR);
1104__MODULE_PARM_TYPE(destroy, "string"); 1061__MODULE_PARM_TYPE(destroy, "string");
1105MODULE_PARM_DESC(destroy, "Destroy fcoe port"); 1062MODULE_PARM_DESC(destroy, "Destroy fcoe port");
1106 1063
1107/* 1064/**
1108 * fcoe_link_ok - check if link is ok for the fc_lport 1065 * fcoe_link_ok() - Check if link is ok for the fc_lport
1109 * @lp: ptr to the fc_lport 1066 * @lp: ptr to the fc_lport
1110 * 1067 *
1111 * Any permanently-disqualifying conditions have been previously checked. 1068 * Any permanently-disqualifying conditions have been previously checked.
@@ -1120,7 +1077,7 @@ MODULE_PARM_DESC(destroy, "Destroy fcoe port");
1120 */ 1077 */
1121int fcoe_link_ok(struct fc_lport *lp) 1078int fcoe_link_ok(struct fc_lport *lp)
1122{ 1079{
1123 struct fcoe_softc *fc = fcoe_softc(lp); 1080 struct fcoe_softc *fc = lport_priv(lp);
1124 struct net_device *dev = fc->real_dev; 1081 struct net_device *dev = fc->real_dev;
1125 struct ethtool_cmd ecmd = { ETHTOOL_GSET }; 1082 struct ethtool_cmd ecmd = { ETHTOOL_GSET };
1126 int rc = 0; 1083 int rc = 0;
@@ -1149,9 +1106,8 @@ int fcoe_link_ok(struct fc_lport *lp)
1149} 1106}
1150EXPORT_SYMBOL_GPL(fcoe_link_ok); 1107EXPORT_SYMBOL_GPL(fcoe_link_ok);
1151 1108
1152/* 1109/**
1153 * fcoe_percpu_clean - frees skb of the corresponding lport from the per 1110 * fcoe_percpu_clean() - Clear the pending skbs for an lport
1154 * cpu queue.
1155 * @lp: the fc_lport 1111 * @lp: the fc_lport
1156 */ 1112 */
1157void fcoe_percpu_clean(struct fc_lport *lp) 1113void fcoe_percpu_clean(struct fc_lport *lp)
@@ -1185,11 +1141,11 @@ void fcoe_percpu_clean(struct fc_lport *lp)
1185EXPORT_SYMBOL_GPL(fcoe_percpu_clean); 1141EXPORT_SYMBOL_GPL(fcoe_percpu_clean);
1186 1142
1187/** 1143/**
1188 * fcoe_clean_pending_queue - dequeue skb and free it 1144 * fcoe_clean_pending_queue() - Dequeue a skb and free it
1189 * @lp: the corresponding fc_lport 1145 * @lp: the corresponding fc_lport
1190 * 1146 *
1191 * Returns: none 1147 * Returns: none
1192 **/ 1148 */
1193void fcoe_clean_pending_queue(struct fc_lport *lp) 1149void fcoe_clean_pending_queue(struct fc_lport *lp)
1194{ 1150{
1195 struct fcoe_softc *fc = lport_priv(lp); 1151 struct fcoe_softc *fc = lport_priv(lp);
@@ -1206,21 +1162,21 @@ void fcoe_clean_pending_queue(struct fc_lport *lp)
1206EXPORT_SYMBOL_GPL(fcoe_clean_pending_queue); 1162EXPORT_SYMBOL_GPL(fcoe_clean_pending_queue);
1207 1163
1208/** 1164/**
1209 * libfc_host_alloc - allocate a Scsi_Host with room for the fc_lport 1165 * libfc_host_alloc() - Allocate a Scsi_Host with room for the fc_lport
1210 * @sht: ptr to the scsi host templ 1166 * @sht: ptr to the scsi host templ
1211 * @priv_size: size of private data after fc_lport 1167 * @priv_size: size of private data after fc_lport
1212 * 1168 *
1213 * Returns: ptr to Scsi_Host 1169 * Returns: ptr to Scsi_Host
1214 * TODO - to libfc? 1170 * TODO: to libfc?
1215 */ 1171 */
1216static inline struct Scsi_Host *libfc_host_alloc( 1172static inline struct Scsi_Host *
1217 struct scsi_host_template *sht, int priv_size) 1173libfc_host_alloc(struct scsi_host_template *sht, int priv_size)
1218{ 1174{
1219 return scsi_host_alloc(sht, sizeof(struct fc_lport) + priv_size); 1175 return scsi_host_alloc(sht, sizeof(struct fc_lport) + priv_size);
1220} 1176}
1221 1177
1222/** 1178/**
1223 * fcoe_host_alloc - allocate a Scsi_Host with room for the fcoe_softc 1179 * fcoe_host_alloc() - Allocate a Scsi_Host with room for the fcoe_softc
1224 * @sht: ptr to the scsi host templ 1180 * @sht: ptr to the scsi host templ
1225 * @priv_size: size of private data after fc_lport 1181 * @priv_size: size of private data after fc_lport
1226 * 1182 *
@@ -1232,8 +1188,8 @@ struct Scsi_Host *fcoe_host_alloc(struct scsi_host_template *sht, int priv_size)
1232} 1188}
1233EXPORT_SYMBOL_GPL(fcoe_host_alloc); 1189EXPORT_SYMBOL_GPL(fcoe_host_alloc);
1234 1190
1235/* 1191/**
1236 * fcoe_reset - resets the fcoe 1192 * fcoe_reset() - Resets the fcoe
1237 * @shost: shost the reset is from 1193 * @shost: shost the reset is from
1238 * 1194 *
1239 * Returns: always 0 1195 * Returns: always 0
@@ -1246,8 +1202,8 @@ int fcoe_reset(struct Scsi_Host *shost)
1246} 1202}
1247EXPORT_SYMBOL_GPL(fcoe_reset); 1203EXPORT_SYMBOL_GPL(fcoe_reset);
1248 1204
1249/* 1205/**
1250 * fcoe_wwn_from_mac - converts 48-bit IEEE MAC address to 64-bit FC WWN. 1206 * fcoe_wwn_from_mac() - Converts 48-bit IEEE MAC address to 64-bit FC WWN.
1251 * @mac: mac address 1207 * @mac: mac address
1252 * @scheme: check port 1208 * @scheme: check port
1253 * @port: port indicator for converting 1209 * @port: port indicator for converting
@@ -1286,14 +1242,15 @@ u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN],
1286 return wwn; 1242 return wwn;
1287} 1243}
1288EXPORT_SYMBOL_GPL(fcoe_wwn_from_mac); 1244EXPORT_SYMBOL_GPL(fcoe_wwn_from_mac);
1289/* 1245
1290 * fcoe_hostlist_lookup_softc - find the corresponding lport by a given device 1246/**
1247 * fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device
1291 * @device: this is currently ptr to net_device 1248 * @device: this is currently ptr to net_device
1292 * 1249 *
1293 * Returns: NULL or the located fcoe_softc 1250 * Returns: NULL or the located fcoe_softc
1294 */ 1251 */
1295static struct fcoe_softc *fcoe_hostlist_lookup_softc( 1252static struct fcoe_softc *
1296 const struct net_device *dev) 1253fcoe_hostlist_lookup_softc(const struct net_device *dev)
1297{ 1254{
1298 struct fcoe_softc *fc; 1255 struct fcoe_softc *fc;
1299 1256
@@ -1308,8 +1265,8 @@ static struct fcoe_softc *fcoe_hostlist_lookup_softc(
1308 return NULL; 1265 return NULL;
1309} 1266}
1310 1267
1311/* 1268/**
1312 * fcoe_hostlist_lookup - find the corresponding lport by netdev 1269 * fcoe_hostlist_lookup() - Find the corresponding lport by netdev
1313 * @netdev: ptr to net_device 1270 * @netdev: ptr to net_device
1314 * 1271 *
1315 * Returns: 0 for success 1272 * Returns: 0 for success
@@ -1324,8 +1281,8 @@ struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
1324} 1281}
1325EXPORT_SYMBOL_GPL(fcoe_hostlist_lookup); 1282EXPORT_SYMBOL_GPL(fcoe_hostlist_lookup);
1326 1283
1327/* 1284/**
1328 * fcoe_hostlist_add - add a lport to lports list 1285 * fcoe_hostlist_add() - Add a lport to lports list
1329 * @lp: ptr to the fc_lport to badded 1286 * @lp: ptr to the fc_lport to badded
1330 * 1287 *
1331 * Returns: 0 for success 1288 * Returns: 0 for success
@@ -1336,7 +1293,7 @@ int fcoe_hostlist_add(const struct fc_lport *lp)
1336 1293
1337 fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp)); 1294 fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp));
1338 if (!fc) { 1295 if (!fc) {
1339 fc = fcoe_softc(lp); 1296 fc = lport_priv(lp);
1340 write_lock_bh(&fcoe_hostlist_lock); 1297 write_lock_bh(&fcoe_hostlist_lock);
1341 list_add_tail(&fc->list, &fcoe_hostlist); 1298 list_add_tail(&fc->list, &fcoe_hostlist);
1342 write_unlock_bh(&fcoe_hostlist_lock); 1299 write_unlock_bh(&fcoe_hostlist_lock);
@@ -1345,8 +1302,8 @@ int fcoe_hostlist_add(const struct fc_lport *lp)
1345} 1302}
1346EXPORT_SYMBOL_GPL(fcoe_hostlist_add); 1303EXPORT_SYMBOL_GPL(fcoe_hostlist_add);
1347 1304
1348/* 1305/**
1349 * fcoe_hostlist_remove - remove a lport from lports list 1306 * fcoe_hostlist_remove() - remove a lport from lports list
1350 * @lp: ptr to the fc_lport to badded 1307 * @lp: ptr to the fc_lport to badded
1351 * 1308 *
1352 * Returns: 0 for success 1309 * Returns: 0 for success
@@ -1366,12 +1323,12 @@ int fcoe_hostlist_remove(const struct fc_lport *lp)
1366EXPORT_SYMBOL_GPL(fcoe_hostlist_remove); 1323EXPORT_SYMBOL_GPL(fcoe_hostlist_remove);
1367 1324
1368/** 1325/**
1369 * fcoe_libfc_config - sets up libfc related properties for lport 1326 * fcoe_libfc_config() - sets up libfc related properties for lport
1370 * @lp: ptr to the fc_lport 1327 * @lp: ptr to the fc_lport
1371 * @tt: libfc function template 1328 * @tt: libfc function template
1372 * 1329 *
1373 * Returns : 0 for success 1330 * Returns : 0 for success
1374 **/ 1331 */
1375int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt) 1332int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt)
1376{ 1333{
1377 /* Set the function pointers set by the LLDD */ 1334 /* Set the function pointers set by the LLDD */
@@ -1389,14 +1346,14 @@ int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt)
1389EXPORT_SYMBOL_GPL(fcoe_libfc_config); 1346EXPORT_SYMBOL_GPL(fcoe_libfc_config);
1390 1347
1391/** 1348/**
1392 * fcoe_init - fcoe module loading initialization 1349 * fcoe_init() - fcoe module loading initialization
1393 * 1350 *
1394 * Initialization routine 1351 * Initialization routine
1395 * 1. Will create fc transport software structure 1352 * 1. Will create fc transport software structure
1396 * 2. initialize the link list of port information structure 1353 * 2. initialize the link list of port information structure
1397 * 1354 *
1398 * Returns 0 on success, negative on failure 1355 * Returns 0 on success, negative on failure
1399 **/ 1356 */
1400static int __init fcoe_init(void) 1357static int __init fcoe_init(void)
1401{ 1358{
1402 int cpu; 1359 int cpu;
@@ -1433,7 +1390,6 @@ static int __init fcoe_init(void)
1433 } else { 1390 } else {
1434 fcoe_percpu[cpu] = NULL; 1391 fcoe_percpu[cpu] = NULL;
1435 kfree(p); 1392 kfree(p);
1436
1437 } 1393 }
1438 } 1394 }
1439 } 1395 }
@@ -1443,11 +1399,9 @@ static int __init fcoe_init(void)
1443 */ 1399 */
1444 fcoe_dev_setup(); 1400 fcoe_dev_setup();
1445 1401
1446 init_timer(&fcoe_timer); 1402 setup_timer(&fcoe_timer, fcoe_watchdog, 0);
1447 fcoe_timer.data = 0; 1403
1448 fcoe_timer.function = fcoe_watchdog; 1404 mod_timer(&fcoe_timer, jiffies + (10 * HZ));
1449 fcoe_timer.expires = (jiffies + (10 * HZ));
1450 add_timer(&fcoe_timer);
1451 1405
1452 /* initiatlize the fcoe transport */ 1406 /* initiatlize the fcoe transport */
1453 fcoe_transport_init(); 1407 fcoe_transport_init();
@@ -1459,10 +1413,10 @@ static int __init fcoe_init(void)
1459module_init(fcoe_init); 1413module_init(fcoe_init);
1460 1414
1461/** 1415/**
1462 * fcoe_exit - fcoe module unloading cleanup 1416 * fcoe_exit() - fcoe module unloading cleanup
1463 * 1417 *
1464 * Returns 0 on success, negative on failure 1418 * Returns 0 on success, negative on failure
1465 **/ 1419 */
1466static void __exit fcoe_exit(void) 1420static void __exit fcoe_exit(void)
1467{ 1421{
1468 u32 idx; 1422 u32 idx;
@@ -1483,7 +1437,7 @@ static void __exit fcoe_exit(void)
1483 */ 1437 */
1484 del_timer_sync(&fcoe_timer); 1438 del_timer_sync(&fcoe_timer);
1485 1439
1486 /* releases the assocaited fcoe transport for each lport */ 1440 /* releases the associated fcoe transport for each lport */
1487 list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list) 1441 list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list)
1488 fcoe_transport_release(fc->real_dev); 1442 fcoe_transport_release(fc->real_dev);
1489 1443
diff --git a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c
index 4a4e6954ec79..f23c4ca9a2ee 100644
--- a/drivers/scsi/lasi700.c
+++ b/drivers/scsi/lasi700.c
@@ -103,7 +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 dev_printk(KERN_ERR, dev, "Failed to allocate host data\n"); 106 dev_printk(KERN_ERR, &dev->dev, "Failed to allocate host data\n");
107 return -ENOMEM; 107 return -ENOMEM;
108 } 108 }
109 109
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index dd1564c9e04a..e57556ea5b48 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -64,7 +64,7 @@ static void fc_disc_single(struct fc_disc *, struct fc_disc_port *);
64static void fc_disc_restart(struct fc_disc *); 64static void fc_disc_restart(struct fc_disc *);
65 65
66/** 66/**
67 * fc_disc_lookup_rport - lookup a remote port by port_id 67 * fc_disc_lookup_rport() - lookup a remote port by port_id
68 * @lport: Fibre Channel host port instance 68 * @lport: Fibre Channel host port instance
69 * @port_id: remote port port_id to match 69 * @port_id: remote port port_id to match
70 */ 70 */
@@ -92,7 +92,7 @@ struct fc_rport *fc_disc_lookup_rport(const struct fc_lport *lport,
92} 92}
93 93
94/** 94/**
95 * fc_disc_stop_rports - delete all the remote ports associated with the lport 95 * fc_disc_stop_rports() - delete all the remote ports associated with the lport
96 * @disc: The discovery job to stop rports on 96 * @disc: The discovery job to stop rports on
97 * 97 *
98 * Locking Note: This function expects that the lport mutex is locked before 98 * Locking Note: This function expects that the lport mutex is locked before
@@ -117,7 +117,7 @@ void fc_disc_stop_rports(struct fc_disc *disc)
117} 117}
118 118
119/** 119/**
120 * fc_disc_rport_callback - Event handler for rport events 120 * fc_disc_rport_callback() - Event handler for rport events
121 * @lport: The lport which is receiving the event 121 * @lport: The lport which is receiving the event
122 * @rport: The rport which the event has occured on 122 * @rport: The rport which the event has occured on
123 * @event: The event that occured 123 * @event: The event that occured
@@ -151,7 +151,7 @@ static void fc_disc_rport_callback(struct fc_lport *lport,
151} 151}
152 152
153/** 153/**
154 * fc_disc_recv_rscn_req - Handle Registered State Change Notification (RSCN) 154 * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN)
155 * @sp: Current sequence of the RSCN exchange 155 * @sp: Current sequence of the RSCN exchange
156 * @fp: RSCN Frame 156 * @fp: RSCN Frame
157 * @lport: Fibre Channel host port instance 157 * @lport: Fibre Channel host port instance
@@ -246,7 +246,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
246 list_del(&dp->peers); 246 list_del(&dp->peers);
247 rport = lport->tt.rport_lookup(lport, dp->ids.port_id); 247 rport = lport->tt.rport_lookup(lport, dp->ids.port_id);
248 if (rport) { 248 if (rport) {
249 rdata = RPORT_TO_PRIV(rport); 249 rdata = rport->dd_data;
250 list_del(&rdata->peers); 250 list_del(&rdata->peers);
251 lport->tt.rport_logoff(rport); 251 lport->tt.rport_logoff(rport);
252 } 252 }
@@ -265,7 +265,7 @@ reject:
265} 265}
266 266
267/** 267/**
268 * fc_disc_recv_req - Handle incoming requests 268 * fc_disc_recv_req() - Handle incoming requests
269 * @sp: Current sequence of the request exchange 269 * @sp: Current sequence of the request exchange
270 * @fp: The frame 270 * @fp: The frame
271 * @lport: The FC local port 271 * @lport: The FC local port
@@ -294,7 +294,7 @@ static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp,
294} 294}
295 295
296/** 296/**
297 * fc_disc_restart - Restart discovery 297 * fc_disc_restart() - Restart discovery
298 * @lport: FC discovery context 298 * @lport: FC discovery context
299 * 299 *
300 * Locking Note: This function expects that the disc mutex 300 * Locking Note: This function expects that the disc mutex
@@ -322,7 +322,7 @@ static void fc_disc_restart(struct fc_disc *disc)
322} 322}
323 323
324/** 324/**
325 * fc_disc_start - Fibre Channel Target discovery 325 * fc_disc_start() - Fibre Channel Target discovery
326 * @lport: FC local port 326 * @lport: FC local port
327 * 327 *
328 * Returns non-zero if discovery cannot be started. 328 * Returns non-zero if discovery cannot be started.
@@ -383,7 +383,7 @@ static struct fc_rport_operations fc_disc_rport_ops = {
383}; 383};
384 384
385/** 385/**
386 * fc_disc_new_target - Handle new target found by discovery 386 * fc_disc_new_target() - Handle new target found by discovery
387 * @lport: FC local port 387 * @lport: FC local port
388 * @rport: The previous FC remote port (NULL if new remote port) 388 * @rport: The previous FC remote port (NULL if new remote port)
389 * @ids: Identifiers for the new FC remote port 389 * @ids: Identifiers for the new FC remote port
@@ -396,7 +396,7 @@ static int fc_disc_new_target(struct fc_disc *disc,
396 struct fc_rport_identifiers *ids) 396 struct fc_rport_identifiers *ids)
397{ 397{
398 struct fc_lport *lport = disc->lport; 398 struct fc_lport *lport = disc->lport;
399 struct fc_rport_libfc_priv *rp; 399 struct fc_rport_libfc_priv *rdata;
400 int error = 0; 400 int error = 0;
401 401
402 if (rport && ids->port_name) { 402 if (rport && ids->port_name) {
@@ -430,15 +430,15 @@ static int fc_disc_new_target(struct fc_disc *disc,
430 dp.ids.port_name = ids->port_name; 430 dp.ids.port_name = ids->port_name;
431 dp.ids.node_name = ids->node_name; 431 dp.ids.node_name = ids->node_name;
432 dp.ids.roles = ids->roles; 432 dp.ids.roles = ids->roles;
433 rport = fc_rport_rogue_create(&dp); 433 rport = lport->tt.rport_create(&dp);
434 } 434 }
435 if (!rport) 435 if (!rport)
436 error = -ENOMEM; 436 error = -ENOMEM;
437 } 437 }
438 if (rport) { 438 if (rport) {
439 rp = rport->dd_data; 439 rdata = rport->dd_data;
440 rp->ops = &fc_disc_rport_ops; 440 rdata->ops = &fc_disc_rport_ops;
441 rp->rp_state = RPORT_ST_INIT; 441 rdata->rp_state = RPORT_ST_INIT;
442 lport->tt.rport_login(rport); 442 lport->tt.rport_login(rport);
443 } 443 }
444 } 444 }
@@ -446,20 +446,20 @@ static int fc_disc_new_target(struct fc_disc *disc,
446} 446}
447 447
448/** 448/**
449 * fc_disc_del_target - Delete a target 449 * fc_disc_del_target() - Delete a target
450 * @disc: FC discovery context 450 * @disc: FC discovery context
451 * @rport: The remote port to be removed 451 * @rport: The remote port to be removed
452 */ 452 */
453static void fc_disc_del_target(struct fc_disc *disc, struct fc_rport *rport) 453static void fc_disc_del_target(struct fc_disc *disc, struct fc_rport *rport)
454{ 454{
455 struct fc_lport *lport = disc->lport; 455 struct fc_lport *lport = disc->lport;
456 struct fc_rport_libfc_priv *rdata = RPORT_TO_PRIV(rport); 456 struct fc_rport_libfc_priv *rdata = rport->dd_data;
457 list_del(&rdata->peers); 457 list_del(&rdata->peers);
458 lport->tt.rport_logoff(rport); 458 lport->tt.rport_logoff(rport);
459} 459}
460 460
461/** 461/**
462 * fc_disc_done - Discovery has been completed 462 * fc_disc_done() - Discovery has been completed
463 * @disc: FC discovery context 463 * @disc: FC discovery context
464 */ 464 */
465static void fc_disc_done(struct fc_disc *disc) 465static void fc_disc_done(struct fc_disc *disc)
@@ -479,7 +479,7 @@ static void fc_disc_done(struct fc_disc *disc)
479} 479}
480 480
481/** 481/**
482 * fc_disc_error - Handle error on dNS request 482 * fc_disc_error() - Handle error on dNS request
483 * @disc: FC discovery context 483 * @disc: FC discovery context
484 * @fp: The frame pointer 484 * @fp: The frame pointer
485 */ 485 */
@@ -519,7 +519,7 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
519} 519}
520 520
521/** 521/**
522 * fc_disc_gpn_ft_req - Send Get Port Names by FC-4 type (GPN_FT) request 522 * fc_disc_gpn_ft_req() - Send Get Port Names by FC-4 type (GPN_FT) request
523 * @lport: FC discovery context 523 * @lport: FC discovery context
524 * 524 *
525 * Locking Note: This function expects that the disc_mutex is locked 525 * Locking Note: This function expects that the disc_mutex is locked
@@ -553,7 +553,7 @@ err:
553} 553}
554 554
555/** 555/**
556 * fc_disc_gpn_ft_parse - Parse the list of IDs and names resulting from a request 556 * fc_disc_gpn_ft_parse() - Parse the list of IDs and names resulting from a request
557 * @lport: Fibre Channel host port instance 557 * @lport: Fibre Channel host port instance
558 * @buf: GPN_FT response buffer 558 * @buf: GPN_FT response buffer
559 * @len: size of response buffer 559 * @len: size of response buffer
@@ -617,7 +617,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
617 617
618 if ((dp.ids.port_id != fc_host_port_id(lport->host)) && 618 if ((dp.ids.port_id != fc_host_port_id(lport->host)) &&
619 (dp.ids.port_name != lport->wwpn)) { 619 (dp.ids.port_name != lport->wwpn)) {
620 rport = fc_rport_rogue_create(&dp); 620 rport = lport->tt.rport_create(&dp);
621 if (rport) { 621 if (rport) {
622 rdata = rport->dd_data; 622 rdata = rport->dd_data;
623 rdata->ops = &fc_disc_rport_ops; 623 rdata->ops = &fc_disc_rport_ops;
@@ -658,7 +658,10 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
658 return error; 658 return error;
659} 659}
660 660
661/* 661/**
662 * fc_disc_timeout() - Retry handler for the disc component
663 * @work: Structure holding disc obj that needs retry discovery
664 *
662 * Handle retry of memory allocation for remote ports. 665 * Handle retry of memory allocation for remote ports.
663 */ 666 */
664static void fc_disc_timeout(struct work_struct *work) 667static void fc_disc_timeout(struct work_struct *work)
@@ -673,7 +676,7 @@ static void fc_disc_timeout(struct work_struct *work)
673} 676}
674 677
675/** 678/**
676 * fc_disc_gpn_ft_resp - Handle a response frame from Get Port Names (GPN_FT) 679 * fc_disc_gpn_ft_resp() - Handle a response frame from Get Port Names (GPN_FT)
677 * @sp: Current sequence of GPN_FT exchange 680 * @sp: Current sequence of GPN_FT exchange
678 * @fp: response frame 681 * @fp: response frame
679 * @lp_arg: Fibre Channel host port instance 682 * @lp_arg: Fibre Channel host port instance
@@ -712,9 +715,7 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
712 fr_len(fp)); 715 fr_len(fp));
713 } else if (ntohs(cp->ct_cmd) == FC_FS_ACC) { 716 } else if (ntohs(cp->ct_cmd) == FC_FS_ACC) {
714 717
715 /* 718 /* Accepted, parse the response. */
716 * Accepted. Parse response.
717 */
718 buf = cp + 1; 719 buf = cp + 1;
719 len -= sizeof(*cp); 720 len -= sizeof(*cp);
720 } else if (ntohs(cp->ct_cmd) == FC_FS_RJT) { 721 } else if (ntohs(cp->ct_cmd) == FC_FS_RJT) {
@@ -746,7 +747,7 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
746} 747}
747 748
748/** 749/**
749 * fc_disc_single - Discover the directory information for a single target 750 * fc_disc_single() - Discover the directory information for a single target
750 * @lport: FC local port 751 * @lport: FC local port
751 * @dp: The port to rediscover 752 * @dp: The port to rediscover
752 * 753 *
@@ -769,7 +770,7 @@ static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp)
769 if (rport) 770 if (rport)
770 fc_disc_del_target(disc, rport); 771 fc_disc_del_target(disc, rport);
771 772
772 new_rport = fc_rport_rogue_create(dp); 773 new_rport = lport->tt.rport_create(dp);
773 if (new_rport) { 774 if (new_rport) {
774 rdata = new_rport->dd_data; 775 rdata = new_rport->dd_data;
775 rdata->ops = &fc_disc_rport_ops; 776 rdata->ops = &fc_disc_rport_ops;
@@ -782,7 +783,7 @@ out:
782} 783}
783 784
784/** 785/**
785 * fc_disc_stop - Stop discovery for a given lport 786 * fc_disc_stop() - Stop discovery for a given lport
786 * @lport: The lport that discovery should stop for 787 * @lport: The lport that discovery should stop for
787 */ 788 */
788void fc_disc_stop(struct fc_lport *lport) 789void fc_disc_stop(struct fc_lport *lport)
@@ -796,7 +797,7 @@ void fc_disc_stop(struct fc_lport *lport)
796} 797}
797 798
798/** 799/**
799 * fc_disc_stop_final - Stop discovery for a given lport 800 * fc_disc_stop_final() - Stop discovery for a given lport
800 * @lport: The lport that discovery should stop for 801 * @lport: The lport that discovery should stop for
801 * 802 *
802 * This function will block until discovery has been 803 * This function will block until discovery has been
@@ -809,7 +810,7 @@ void fc_disc_stop_final(struct fc_lport *lport)
809} 810}
810 811
811/** 812/**
812 * fc_disc_init - Initialize the discovery block 813 * fc_disc_init() - Initialize the discovery block
813 * @lport: FC local port 814 * @lport: FC local port
814 */ 815 */
815int fc_disc_init(struct fc_lport *lport) 816int fc_disc_init(struct fc_lport *lport)
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 66db08a5f27f..505825b6124d 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -32,8 +32,6 @@
32#include <scsi/libfc.h> 32#include <scsi/libfc.h>
33#include <scsi/fc_encode.h> 33#include <scsi/fc_encode.h>
34 34
35#define FC_DEF_R_A_TOV (10 * 1000) /* resource allocation timeout */
36
37/* 35/*
38 * fc_exch_debug can be set in debugger or at compile time to get more logs. 36 * fc_exch_debug can be set in debugger or at compile time to get more logs.
39 */ 37 */
@@ -627,7 +625,6 @@ static struct fc_exch *fc_exch_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
627{ 625{
628 struct fc_exch *ep; 626 struct fc_exch *ep;
629 struct fc_frame_header *fh; 627 struct fc_frame_header *fh;
630 u16 rxid;
631 628
632 ep = mp->lp->tt.exch_get(mp->lp, fp); 629 ep = mp->lp->tt.exch_get(mp->lp, fp);
633 if (ep) { 630 if (ep) {
@@ -654,18 +651,6 @@ static struct fc_exch *fc_exch_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
654 if ((ntoh24(fh->fh_f_ctl) & FC_FC_SEQ_INIT) == 0) 651 if ((ntoh24(fh->fh_f_ctl) & FC_FC_SEQ_INIT) == 0)
655 ep->esb_stat &= ~ESB_ST_SEQ_INIT; 652 ep->esb_stat &= ~ESB_ST_SEQ_INIT;
656 653
657 /*
658 * Set the responder ID in the frame header.
659 * The old one should've been 0xffff.
660 * If it isn't, don't assign one.
661 * Incoming basic link service frames may specify
662 * a referenced RX_ID.
663 */
664 if (fh->fh_type != FC_TYPE_BLS) {
665 rxid = ntohs(fh->fh_rx_id);
666 WARN_ON(rxid != FC_XID_UNKNOWN);
667 fh->fh_rx_id = htons(ep->rxid);
668 }
669 fc_exch_hold(ep); /* hold for caller */ 654 fc_exch_hold(ep); /* hold for caller */
670 spin_unlock_bh(&ep->ex_lock); /* lock from exch_get */ 655 spin_unlock_bh(&ep->ex_lock); /* lock from exch_get */
671 } 656 }
@@ -677,8 +662,8 @@ static struct fc_exch *fc_exch_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
677 * If fc_pf_rjt_reason is FC_RJT_NONE then this function will have a hold 662 * If fc_pf_rjt_reason is FC_RJT_NONE then this function will have a hold
678 * on the ep that should be released by the caller. 663 * on the ep that should be released by the caller.
679 */ 664 */
680static enum fc_pf_rjt_reason 665static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_exch_mgr *mp,
681fc_seq_lookup_recip(struct fc_exch_mgr *mp, struct fc_frame *fp) 666 struct fc_frame *fp)
682{ 667{
683 struct fc_frame_header *fh = fc_frame_header_get(fp); 668 struct fc_frame_header *fh = fc_frame_header_get(fp);
684 struct fc_exch *ep = NULL; 669 struct fc_exch *ep = NULL;
@@ -996,9 +981,9 @@ static void fc_seq_send_ack(struct fc_seq *sp, const struct fc_frame *rx_fp)
996 * Send BLS Reject. 981 * Send BLS Reject.
997 * This is for rejecting BA_ABTS only. 982 * This is for rejecting BA_ABTS only.
998 */ 983 */
999static void 984static void fc_exch_send_ba_rjt(struct fc_frame *rx_fp,
1000fc_exch_send_ba_rjt(struct fc_frame *rx_fp, enum fc_ba_rjt_reason reason, 985 enum fc_ba_rjt_reason reason,
1001 enum fc_ba_rjt_explan explan) 986 enum fc_ba_rjt_explan explan)
1002{ 987{
1003 struct fc_frame *fp; 988 struct fc_frame *fp;
1004 struct fc_frame_header *rx_fh; 989 struct fc_frame_header *rx_fh;
@@ -1096,7 +1081,7 @@ static void fc_exch_recv_abts(struct fc_exch *ep, struct fc_frame *rx_fp)
1096 ap->ba_high_seq_cnt = fh->fh_seq_cnt; 1081 ap->ba_high_seq_cnt = fh->fh_seq_cnt;
1097 ap->ba_low_seq_cnt = htons(sp->cnt); 1082 ap->ba_low_seq_cnt = htons(sp->cnt);
1098 } 1083 }
1099 sp = fc_seq_start_next(sp); 1084 sp = fc_seq_start_next_locked(sp);
1100 spin_unlock_bh(&ep->ex_lock); 1085 spin_unlock_bh(&ep->ex_lock);
1101 fc_seq_send_last(sp, fp, FC_RCTL_BA_ACC, FC_TYPE_BLS); 1086 fc_seq_send_last(sp, fp, FC_RCTL_BA_ACC, FC_TYPE_BLS);
1102 fc_frame_free(rx_fp); 1087 fc_frame_free(rx_fp);
@@ -1480,10 +1465,11 @@ static void fc_exch_reset(struct fc_exch *ep)
1480 * If sid is non-zero, reset only exchanges we source from that FID. 1465 * If sid is non-zero, reset only exchanges we source from that FID.
1481 * If did is non-zero, reset only exchanges destined to that FID. 1466 * If did is non-zero, reset only exchanges destined to that FID.
1482 */ 1467 */
1483void fc_exch_mgr_reset(struct fc_exch_mgr *mp, u32 sid, u32 did) 1468void fc_exch_mgr_reset(struct fc_lport *lp, u32 sid, u32 did)
1484{ 1469{
1485 struct fc_exch *ep; 1470 struct fc_exch *ep;
1486 struct fc_exch *next; 1471 struct fc_exch *next;
1472 struct fc_exch_mgr *mp = lp->emp;
1487 1473
1488 spin_lock_bh(&mp->em_lock); 1474 spin_lock_bh(&mp->em_lock);
1489restart: 1475restart:
@@ -1607,7 +1593,7 @@ static void fc_exch_rrq_resp(struct fc_seq *sp, struct fc_frame *fp, void *arg)
1607 if (IS_ERR(fp)) { 1593 if (IS_ERR(fp)) {
1608 int err = PTR_ERR(fp); 1594 int err = PTR_ERR(fp);
1609 1595
1610 if (err == -FC_EX_CLOSED) 1596 if (err == -FC_EX_CLOSED || err == -FC_EX_TIMEOUT)
1611 goto cleanup; 1597 goto cleanup;
1612 FC_DBG("Cannot process RRQ, because of frame error %d\n", err); 1598 FC_DBG("Cannot process RRQ, because of frame error %d\n", err);
1613 return; 1599 return;
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index 404e63ff46b8..2a631d7dbcec 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -161,7 +161,7 @@ static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lp, gfp_t gfp)
161} 161}
162 162
163/** 163/**
164 * fc_fcp_pkt_release - release hold on scsi_pkt packet 164 * fc_fcp_pkt_release() - release hold on scsi_pkt packet
165 * @fsp: fcp packet struct 165 * @fsp: fcp packet struct
166 * 166 *
167 * This is used by upper layer scsi driver. 167 * This is used by upper layer scsi driver.
@@ -183,8 +183,7 @@ static void fc_fcp_pkt_hold(struct fc_fcp_pkt *fsp)
183} 183}
184 184
185/** 185/**
186 * fc_fcp_pkt_destory - release hold on scsi_pkt packet 186 * fc_fcp_pkt_destory() - release hold on scsi_pkt packet
187 *
188 * @seq: exchange sequence 187 * @seq: exchange sequence
189 * @fsp: fcp packet struct 188 * @fsp: fcp packet struct
190 * 189 *
@@ -199,7 +198,7 @@ static void fc_fcp_pkt_destroy(struct fc_seq *seq, void *fsp)
199} 198}
200 199
201/** 200/**
202 * fc_fcp_lock_pkt - lock a packet and get a ref to it. 201 * fc_fcp_lock_pkt() - lock a packet and get a ref to it.
203 * @fsp: fcp packet 202 * @fsp: fcp packet
204 * 203 *
205 * We should only return error if we return a command to scsi-ml before 204 * We should only return error if we return a command to scsi-ml before
@@ -291,9 +290,7 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
291 buf = fc_frame_payload_get(fp, 0); 290 buf = fc_frame_payload_get(fp, 0);
292 291
293 if (offset + len > fsp->data_len) { 292 if (offset + len > fsp->data_len) {
294 /* 293 /* this should never happen */
295 * this should never happen
296 */
297 if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) && 294 if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) &&
298 fc_frame_crc_check(fp)) 295 fc_frame_crc_check(fp))
299 goto crc_err; 296 goto crc_err;
@@ -387,8 +384,8 @@ crc_err:
387 fc_fcp_complete_locked(fsp); 384 fc_fcp_complete_locked(fsp);
388} 385}
389 386
390/* 387/**
391 * fc_fcp_send_data - Send SCSI data to target. 388 * fc_fcp_send_data() - Send SCSI data to target.
392 * @fsp: ptr to fc_fcp_pkt 389 * @fsp: ptr to fc_fcp_pkt
393 * @sp: ptr to this sequence 390 * @sp: ptr to this sequence
394 * @offset: starting offset for this data request 391 * @offset: starting offset for this data request
@@ -610,8 +607,8 @@ static void fc_fcp_abts_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
610 } 607 }
611} 608}
612 609
613/* 610/**
614 * fc_fcp_reduce_can_queue - drop can_queue 611 * fc_fcp_reduce_can_queue() - drop can_queue
615 * @lp: lport to drop queueing for 612 * @lp: lport to drop queueing for
616 * 613 *
617 * If we are getting memory allocation failures, then we may 614 * If we are getting memory allocation failures, then we may
@@ -642,9 +639,11 @@ done:
642 spin_unlock_irqrestore(lp->host->host_lock, flags); 639 spin_unlock_irqrestore(lp->host->host_lock, flags);
643} 640}
644 641
645/* 642/**
646 * exch mgr calls this routine to process scsi 643 * fc_fcp_recv() - Reveive FCP frames
647 * exchanges. 644 * @seq: The sequence the frame is on
645 * @fp: The FC frame
646 * @arg: The related FCP packet
648 * 647 *
649 * Return : None 648 * Return : None
650 * Context : called from Soft IRQ context 649 * Context : called from Soft IRQ context
@@ -832,7 +831,7 @@ err:
832} 831}
833 832
834/** 833/**
835 * fc_fcp_complete_locked - complete processing of a fcp packet 834 * fc_fcp_complete_locked() - complete processing of a fcp packet
836 * @fsp: fcp packet 835 * @fsp: fcp packet
837 * 836 *
838 * This function may sleep if a timer is pending. The packet lock must be 837 * This function may sleep if a timer is pending. The packet lock must be
@@ -900,7 +899,7 @@ static void fc_fcp_cleanup_cmd(struct fc_fcp_pkt *fsp, int error)
900} 899}
901 900
902/** 901/**
903 * fc_fcp_cleanup_each_cmd - run fn on each active command 902 * fc_fcp_cleanup_each_cmd() - Cleanup active commads
904 * @lp: logical port 903 * @lp: logical port
905 * @id: target id 904 * @id: target id
906 * @lun: lun 905 * @lun: lun
@@ -952,7 +951,7 @@ static void fc_fcp_abort_io(struct fc_lport *lp)
952} 951}
953 952
954/** 953/**
955 * fc_fcp_pkt_send - send a fcp packet to the lower level. 954 * fc_fcp_pkt_send() - send a fcp packet to the lower level.
956 * @lp: fc lport 955 * @lp: fc lport
957 * @fsp: fc packet. 956 * @fsp: fc packet.
958 * 957 *
@@ -1621,7 +1620,7 @@ out:
1621static inline int fc_fcp_lport_queue_ready(struct fc_lport *lp) 1620static inline int fc_fcp_lport_queue_ready(struct fc_lport *lp)
1622{ 1621{
1623 /* lock ? */ 1622 /* lock ? */
1624 return (lp->state == LPORT_ST_READY) && (lp->link_status & FC_LINK_UP); 1623 return (lp->state == LPORT_ST_READY) && lp->link_up && !lp->qfull;
1625} 1624}
1626 1625
1627/** 1626/**
@@ -1727,7 +1726,7 @@ out:
1727EXPORT_SYMBOL(fc_queuecommand); 1726EXPORT_SYMBOL(fc_queuecommand);
1728 1727
1729/** 1728/**
1730 * fc_io_compl - Handle responses for completed commands 1729 * fc_io_compl() - Handle responses for completed commands
1731 * @fsp: scsi packet 1730 * @fsp: scsi packet
1732 * 1731 *
1733 * Translates a error to a Linux SCSI error. 1732 * Translates a error to a Linux SCSI error.
@@ -1810,12 +1809,12 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
1810 sc_cmd->result = DID_ERROR << 16; 1809 sc_cmd->result = DID_ERROR << 16;
1811 break; 1810 break;
1812 case FC_DATA_UNDRUN: 1811 case FC_DATA_UNDRUN:
1813 if (fsp->cdb_status == 0) { 1812 if ((fsp->cdb_status == 0) && !(fsp->req_flags & FC_SRB_READ)) {
1814 /* 1813 /*
1815 * scsi status is good but transport level 1814 * scsi status is good but transport level
1816 * underrun. for read it should be an error?? 1815 * underrun.
1817 */ 1816 */
1818 sc_cmd->result = (DID_OK << 16) | fsp->cdb_status; 1817 sc_cmd->result = DID_OK << 16;
1819 } else { 1818 } else {
1820 /* 1819 /*
1821 * scsi got underrun, this is an error 1820 * scsi got underrun, this is an error
@@ -1857,7 +1856,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
1857} 1856}
1858 1857
1859/** 1858/**
1860 * fc_fcp_complete - complete processing of a fcp packet 1859 * fc_fcp_complete() - complete processing of a fcp packet
1861 * @fsp: fcp packet 1860 * @fsp: fcp packet
1862 * 1861 *
1863 * This function may sleep if a fsp timer is pending. 1862 * This function may sleep if a fsp timer is pending.
@@ -1874,9 +1873,10 @@ void fc_fcp_complete(struct fc_fcp_pkt *fsp)
1874EXPORT_SYMBOL(fc_fcp_complete); 1873EXPORT_SYMBOL(fc_fcp_complete);
1875 1874
1876/** 1875/**
1877 * fc_eh_abort - Abort a command...from scsi host template 1876 * fc_eh_abort() - Abort a command
1878 * @sc_cmd: scsi command to abort 1877 * @sc_cmd: scsi command to abort
1879 * 1878 *
1879 * From scsi host template.
1880 * send ABTS to the target device and wait for the response 1880 * send ABTS to the target device and wait for the response
1881 * sc_cmd is the pointer to the command to be aborted. 1881 * sc_cmd is the pointer to the command to be aborted.
1882 */ 1882 */
@@ -1890,7 +1890,7 @@ int fc_eh_abort(struct scsi_cmnd *sc_cmd)
1890 lp = shost_priv(sc_cmd->device->host); 1890 lp = shost_priv(sc_cmd->device->host);
1891 if (lp->state != LPORT_ST_READY) 1891 if (lp->state != LPORT_ST_READY)
1892 return rc; 1892 return rc;
1893 else if (!(lp->link_status & FC_LINK_UP)) 1893 else if (!lp->link_up)
1894 return rc; 1894 return rc;
1895 1895
1896 spin_lock_irqsave(lp->host->host_lock, flags); 1896 spin_lock_irqsave(lp->host->host_lock, flags);
@@ -1920,7 +1920,7 @@ release_pkt:
1920EXPORT_SYMBOL(fc_eh_abort); 1920EXPORT_SYMBOL(fc_eh_abort);
1921 1921
1922/** 1922/**
1923 * fc_eh_device_reset: Reset a single LUN 1923 * fc_eh_device_reset() Reset a single LUN
1924 * @sc_cmd: scsi command 1924 * @sc_cmd: scsi command
1925 * 1925 *
1926 * Set from scsi host template to send tm cmd to the target and wait for the 1926 * Set from scsi host template to send tm cmd to the target and wait for the
@@ -1973,7 +1973,7 @@ out:
1973EXPORT_SYMBOL(fc_eh_device_reset); 1973EXPORT_SYMBOL(fc_eh_device_reset);
1974 1974
1975/** 1975/**
1976 * fc_eh_host_reset - The reset function will reset the ports on the host. 1976 * fc_eh_host_reset() - The reset function will reset the ports on the host.
1977 * @sc_cmd: scsi command 1977 * @sc_cmd: scsi command
1978 */ 1978 */
1979int fc_eh_host_reset(struct scsi_cmnd *sc_cmd) 1979int fc_eh_host_reset(struct scsi_cmnd *sc_cmd)
@@ -1999,7 +1999,7 @@ int fc_eh_host_reset(struct scsi_cmnd *sc_cmd)
1999EXPORT_SYMBOL(fc_eh_host_reset); 1999EXPORT_SYMBOL(fc_eh_host_reset);
2000 2000
2001/** 2001/**
2002 * fc_slave_alloc - configure queue depth 2002 * fc_slave_alloc() - configure queue depth
2003 * @sdev: scsi device 2003 * @sdev: scsi device
2004 * 2004 *
2005 * Configures queue depth based on host's cmd_per_len. If not set 2005 * Configures queue depth based on host's cmd_per_len. If not set
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 0b9bdb1fb807..2ae50a1188e6 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -139,7 +139,7 @@ static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp)
139} 139}
140 140
141/** 141/**
142 * fc_lport_rport_callback - Event handler for rport events 142 * fc_lport_rport_callback() - Event handler for rport events
143 * @lport: The lport which is receiving the event 143 * @lport: The lport which is receiving the event
144 * @rport: The rport which the event has occured on 144 * @rport: The rport which the event has occured on
145 * @event: The event that occured 145 * @event: The event that occured
@@ -195,7 +195,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
195} 195}
196 196
197/** 197/**
198 * fc_lport_state - Return a string which represents the lport's state 198 * fc_lport_state() - Return a string which represents the lport's state
199 * @lport: The lport whose state is to converted to a string 199 * @lport: The lport whose state is to converted to a string
200 */ 200 */
201static const char *fc_lport_state(struct fc_lport *lport) 201static const char *fc_lport_state(struct fc_lport *lport)
@@ -209,7 +209,7 @@ static const char *fc_lport_state(struct fc_lport *lport)
209} 209}
210 210
211/** 211/**
212 * fc_lport_ptp_setup - Create an rport for point-to-point mode 212 * fc_lport_ptp_setup() - Create an rport for point-to-point mode
213 * @lport: The lport to attach the ptp rport to 213 * @lport: The lport to attach the ptp rport to
214 * @fid: The FID of the ptp rport 214 * @fid: The FID of the ptp rport
215 * @remote_wwpn: The WWPN of the ptp rport 215 * @remote_wwpn: The WWPN of the ptp rport
@@ -232,7 +232,7 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
232 lport->ptp_rp = NULL; 232 lport->ptp_rp = NULL;
233 } 233 }
234 234
235 lport->ptp_rp = fc_rport_rogue_create(&dp); 235 lport->ptp_rp = lport->tt.rport_create(&dp);
236 236
237 lport->tt.rport_login(lport->ptp_rp); 237 lport->tt.rport_login(lport->ptp_rp);
238 238
@@ -250,7 +250,7 @@ void fc_get_host_port_state(struct Scsi_Host *shost)
250{ 250{
251 struct fc_lport *lp = shost_priv(shost); 251 struct fc_lport *lp = shost_priv(shost);
252 252
253 if ((lp->link_status & FC_LINK_UP) == FC_LINK_UP) 253 if (lp->link_up)
254 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; 254 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
255 else 255 else
256 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; 256 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
@@ -351,7 +351,7 @@ static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type)
351} 351}
352 352
353/** 353/**
354 * fc_lport_recv_rlir_req - Handle received Registered Link Incident Report. 354 * fc_lport_recv_rlir_req() - Handle received Registered Link Incident Report.
355 * @lport: Fibre Channel local port recieving the RLIR 355 * @lport: Fibre Channel local port recieving the RLIR
356 * @sp: current sequence in the RLIR exchange 356 * @sp: current sequence in the RLIR exchange
357 * @fp: RLIR request frame 357 * @fp: RLIR request frame
@@ -370,7 +370,7 @@ static void fc_lport_recv_rlir_req(struct fc_seq *sp, struct fc_frame *fp,
370} 370}
371 371
372/** 372/**
373 * fc_lport_recv_echo_req - Handle received ECHO request 373 * fc_lport_recv_echo_req() - Handle received ECHO request
374 * @lport: Fibre Channel local port recieving the ECHO 374 * @lport: Fibre Channel local port recieving the ECHO
375 * @sp: current sequence in the ECHO exchange 375 * @sp: current sequence in the ECHO exchange
376 * @fp: ECHO request frame 376 * @fp: ECHO request frame
@@ -412,7 +412,7 @@ static void fc_lport_recv_echo_req(struct fc_seq *sp, struct fc_frame *in_fp,
412} 412}
413 413
414/** 414/**
415 * fc_lport_recv_echo_req - Handle received Request Node ID data request 415 * fc_lport_recv_echo_req() - Handle received Request Node ID data request
416 * @lport: Fibre Channel local port recieving the RNID 416 * @lport: Fibre Channel local port recieving the RNID
417 * @sp: current sequence in the RNID exchange 417 * @sp: current sequence in the RNID exchange
418 * @fp: RNID request frame 418 * @fp: RNID request frame
@@ -479,7 +479,7 @@ static void fc_lport_recv_rnid_req(struct fc_seq *sp, struct fc_frame *in_fp,
479} 479}
480 480
481/** 481/**
482 * fc_lport_recv_adisc_req - Handle received Address Discovery Request 482 * fc_lport_recv_adisc_req() - Handle received Address Discovery Request
483 * @lport: Fibre Channel local port recieving the ADISC 483 * @lport: Fibre Channel local port recieving the ADISC
484 * @sp: current sequence in the ADISC exchange 484 * @sp: current sequence in the ADISC exchange
485 * @fp: ADISC request frame 485 * @fp: ADISC request frame
@@ -529,7 +529,7 @@ static void fc_lport_recv_adisc_req(struct fc_seq *sp, struct fc_frame *in_fp,
529} 529}
530 530
531/** 531/**
532 * fc_lport_recv_logo_req - Handle received fabric LOGO request 532 * fc_lport_recv_logo_req() - Handle received fabric LOGO request
533 * @lport: Fibre Channel local port recieving the LOGO 533 * @lport: Fibre Channel local port recieving the LOGO
534 * @sp: current sequence in the LOGO exchange 534 * @sp: current sequence in the LOGO exchange
535 * @fp: LOGO request frame 535 * @fp: LOGO request frame
@@ -546,7 +546,7 @@ static void fc_lport_recv_logo_req(struct fc_seq *sp, struct fc_frame *fp,
546} 546}
547 547
548/** 548/**
549 * fc_fabric_login - Start the lport state machine 549 * fc_fabric_login() - Start the lport state machine
550 * @lport: The lport that should log into the fabric 550 * @lport: The lport that should log into the fabric
551 * 551 *
552 * Locking Note: This function should not be called 552 * Locking Note: This function should not be called
@@ -568,7 +568,7 @@ int fc_fabric_login(struct fc_lport *lport)
568EXPORT_SYMBOL(fc_fabric_login); 568EXPORT_SYMBOL(fc_fabric_login);
569 569
570/** 570/**
571 * fc_linkup - Handler for transport linkup events 571 * fc_linkup() - Handler for transport linkup events
572 * @lport: The lport whose link is up 572 * @lport: The lport whose link is up
573 */ 573 */
574void fc_linkup(struct fc_lport *lport) 574void fc_linkup(struct fc_lport *lport)
@@ -577,8 +577,8 @@ void fc_linkup(struct fc_lport *lport)
577 fc_host_port_id(lport->host)); 577 fc_host_port_id(lport->host));
578 578
579 mutex_lock(&lport->lp_mutex); 579 mutex_lock(&lport->lp_mutex);
580 if ((lport->link_status & FC_LINK_UP) != FC_LINK_UP) { 580 if (!lport->link_up) {
581 lport->link_status |= FC_LINK_UP; 581 lport->link_up = 1;
582 582
583 if (lport->state == LPORT_ST_RESET) 583 if (lport->state == LPORT_ST_RESET)
584 fc_lport_enter_flogi(lport); 584 fc_lport_enter_flogi(lport);
@@ -588,7 +588,7 @@ void fc_linkup(struct fc_lport *lport)
588EXPORT_SYMBOL(fc_linkup); 588EXPORT_SYMBOL(fc_linkup);
589 589
590/** 590/**
591 * fc_linkdown - Handler for transport linkdown events 591 * fc_linkdown() - Handler for transport linkdown events
592 * @lport: The lport whose link is down 592 * @lport: The lport whose link is down
593 */ 593 */
594void fc_linkdown(struct fc_lport *lport) 594void fc_linkdown(struct fc_lport *lport)
@@ -597,8 +597,8 @@ void fc_linkdown(struct fc_lport *lport)
597 FC_DEBUG_LPORT("Link is down for port (%6x)\n", 597 FC_DEBUG_LPORT("Link is down for port (%6x)\n",
598 fc_host_port_id(lport->host)); 598 fc_host_port_id(lport->host));
599 599
600 if ((lport->link_status & FC_LINK_UP) == FC_LINK_UP) { 600 if (lport->link_up) {
601 lport->link_status &= ~(FC_LINK_UP); 601 lport->link_up = 0;
602 fc_lport_enter_reset(lport); 602 fc_lport_enter_reset(lport);
603 lport->tt.fcp_cleanup(lport); 603 lport->tt.fcp_cleanup(lport);
604 } 604 }
@@ -607,48 +607,25 @@ void fc_linkdown(struct fc_lport *lport)
607EXPORT_SYMBOL(fc_linkdown); 607EXPORT_SYMBOL(fc_linkdown);
608 608
609/** 609/**
610 * fc_pause - Pause the flow of frames 610 * fc_fabric_logoff() - Logout of the fabric
611 * @lport: The lport to be paused
612 */
613void fc_pause(struct fc_lport *lport)
614{
615 mutex_lock(&lport->lp_mutex);
616 lport->link_status |= FC_PAUSE;
617 mutex_unlock(&lport->lp_mutex);
618}
619EXPORT_SYMBOL(fc_pause);
620
621/**
622 * fc_unpause - Unpause the flow of frames
623 * @lport: The lport to be unpaused
624 */
625void fc_unpause(struct fc_lport *lport)
626{
627 mutex_lock(&lport->lp_mutex);
628 lport->link_status &= ~(FC_PAUSE);
629 mutex_unlock(&lport->lp_mutex);
630}
631EXPORT_SYMBOL(fc_unpause);
632
633/**
634 * fc_fabric_logoff - Logout of the fabric
635 * @lport: fc_lport pointer to logoff the fabric 611 * @lport: fc_lport pointer to logoff the fabric
636 * 612 *
637 * Return value: 613 * Return value:
638 * 0 for success, -1 for failure 614 * 0 for success, -1 for failure
639 **/ 615 */
640int fc_fabric_logoff(struct fc_lport *lport) 616int fc_fabric_logoff(struct fc_lport *lport)
641{ 617{
642 lport->tt.disc_stop_final(lport); 618 lport->tt.disc_stop_final(lport);
643 mutex_lock(&lport->lp_mutex); 619 mutex_lock(&lport->lp_mutex);
644 fc_lport_enter_logo(lport); 620 fc_lport_enter_logo(lport);
645 mutex_unlock(&lport->lp_mutex); 621 mutex_unlock(&lport->lp_mutex);
622 cancel_delayed_work_sync(&lport->retry_work);
646 return 0; 623 return 0;
647} 624}
648EXPORT_SYMBOL(fc_fabric_logoff); 625EXPORT_SYMBOL(fc_fabric_logoff);
649 626
650/** 627/**
651 * fc_lport_destroy - unregister a fc_lport 628 * fc_lport_destroy() - unregister a fc_lport
652 * @lport: fc_lport pointer to unregister 629 * @lport: fc_lport pointer to unregister
653 * 630 *
654 * Return value: 631 * Return value:
@@ -658,26 +635,25 @@ EXPORT_SYMBOL(fc_fabric_logoff);
658 * clean-up all the allocated memory 635 * clean-up all the allocated memory
659 * and free up other system resources. 636 * and free up other system resources.
660 * 637 *
661 **/ 638 */
662int fc_lport_destroy(struct fc_lport *lport) 639int fc_lport_destroy(struct fc_lport *lport)
663{ 640{
664 lport->tt.frame_send = fc_frame_drop; 641 lport->tt.frame_send = fc_frame_drop;
665 lport->tt.fcp_abort_io(lport); 642 lport->tt.fcp_abort_io(lport);
666 lport->tt.exch_mgr_reset(lport->emp, 0, 0); 643 lport->tt.exch_mgr_reset(lport, 0, 0);
667 return 0; 644 return 0;
668} 645}
669EXPORT_SYMBOL(fc_lport_destroy); 646EXPORT_SYMBOL(fc_lport_destroy);
670 647
671/** 648/**
672 * fc_set_mfs - sets up the mfs for the corresponding fc_lport 649 * fc_set_mfs() - sets up the mfs for the corresponding fc_lport
673 * @lport: fc_lport pointer to unregister 650 * @lport: fc_lport pointer to unregister
674 * @mfs: the new mfs for fc_lport 651 * @mfs: the new mfs for fc_lport
675 * 652 *
676 * Set mfs for the given fc_lport to the new mfs. 653 * Set mfs for the given fc_lport to the new mfs.
677 * 654 *
678 * Return: 0 for success 655 * Return: 0 for success
679 * 656 */
680 **/
681int fc_set_mfs(struct fc_lport *lport, u32 mfs) 657int fc_set_mfs(struct fc_lport *lport, u32 mfs)
682{ 658{
683 unsigned int old_mfs; 659 unsigned int old_mfs;
@@ -706,7 +682,7 @@ int fc_set_mfs(struct fc_lport *lport, u32 mfs)
706EXPORT_SYMBOL(fc_set_mfs); 682EXPORT_SYMBOL(fc_set_mfs);
707 683
708/** 684/**
709 * fc_lport_disc_callback - Callback for discovery events 685 * fc_lport_disc_callback() - Callback for discovery events
710 * @lport: FC local port 686 * @lport: FC local port
711 * @event: The discovery event 687 * @event: The discovery event
712 */ 688 */
@@ -731,7 +707,7 @@ void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event)
731} 707}
732 708
733/** 709/**
734 * fc_rport_enter_ready - Enter the ready state and start discovery 710 * fc_rport_enter_ready() - Enter the ready state and start discovery
735 * @lport: Fibre Channel local port that is ready 711 * @lport: Fibre Channel local port that is ready
736 * 712 *
737 * Locking Note: The lport lock is expected to be held before calling 713 * Locking Note: The lport lock is expected to be held before calling
@@ -748,7 +724,7 @@ static void fc_lport_enter_ready(struct fc_lport *lport)
748} 724}
749 725
750/** 726/**
751 * fc_lport_recv_flogi_req - Receive a FLOGI request 727 * fc_lport_recv_flogi_req() - Receive a FLOGI request
752 * @sp_in: The sequence the FLOGI is on 728 * @sp_in: The sequence the FLOGI is on
753 * @rx_fp: The frame the FLOGI is in 729 * @rx_fp: The frame the FLOGI is in
754 * @lport: The lport that recieved the request 730 * @lport: The lport that recieved the request
@@ -838,7 +814,7 @@ out:
838} 814}
839 815
840/** 816/**
841 * fc_lport_recv_req - The generic lport request handler 817 * fc_lport_recv_req() - The generic lport request handler
842 * @lport: The lport that received the request 818 * @lport: The lport that received the request
843 * @sp: The sequence the request is on 819 * @sp: The sequence the request is on
844 * @fp: The frame the request is in 820 * @fp: The frame the request is in
@@ -934,7 +910,7 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp,
934} 910}
935 911
936/** 912/**
937 * fc_lport_reset - Reset an lport 913 * fc_lport_reset() - Reset an lport
938 * @lport: The lport which should be reset 914 * @lport: The lport which should be reset
939 * 915 *
940 * Locking Note: This functions should not be called with the 916 * Locking Note: This functions should not be called with the
@@ -942,6 +918,7 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp,
942 */ 918 */
943int fc_lport_reset(struct fc_lport *lport) 919int fc_lport_reset(struct fc_lport *lport)
944{ 920{
921 cancel_delayed_work_sync(&lport->retry_work);
945 mutex_lock(&lport->lp_mutex); 922 mutex_lock(&lport->lp_mutex);
946 fc_lport_enter_reset(lport); 923 fc_lport_enter_reset(lport);
947 mutex_unlock(&lport->lp_mutex); 924 mutex_unlock(&lport->lp_mutex);
@@ -950,7 +927,7 @@ int fc_lport_reset(struct fc_lport *lport)
950EXPORT_SYMBOL(fc_lport_reset); 927EXPORT_SYMBOL(fc_lport_reset);
951 928
952/** 929/**
953 * fc_rport_enter_reset - Reset the local port 930 * fc_rport_enter_reset() - Reset the local port
954 * @lport: Fibre Channel local port to be reset 931 * @lport: Fibre Channel local port to be reset
955 * 932 *
956 * Locking Note: The lport lock is expected to be held before calling 933 * Locking Note: The lport lock is expected to be held before calling
@@ -973,16 +950,16 @@ static void fc_lport_enter_reset(struct fc_lport *lport)
973 950
974 lport->tt.disc_stop(lport); 951 lport->tt.disc_stop(lport);
975 952
976 lport->tt.exch_mgr_reset(lport->emp, 0, 0); 953 lport->tt.exch_mgr_reset(lport, 0, 0);
977 fc_host_fabric_name(lport->host) = 0; 954 fc_host_fabric_name(lport->host) = 0;
978 fc_host_port_id(lport->host) = 0; 955 fc_host_port_id(lport->host) = 0;
979 956
980 if ((lport->link_status & FC_LINK_UP) == FC_LINK_UP) 957 if (lport->link_up)
981 fc_lport_enter_flogi(lport); 958 fc_lport_enter_flogi(lport);
982} 959}
983 960
984/** 961/**
985 * fc_lport_error - Handler for any errors 962 * fc_lport_error() - Handler for any errors
986 * @lport: The fc_lport object 963 * @lport: The fc_lport object
987 * @fp: The frame pointer 964 * @fp: The frame pointer
988 * 965 *
@@ -1029,8 +1006,8 @@ static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp)
1029} 1006}
1030 1007
1031/** 1008/**
1032 * fc_lport_rft_id_resp - Handle response to Register Fibre 1009 * fc_lport_rft_id_resp() - Handle response to Register Fibre
1033 * Channel Types by ID (RPN_ID) request 1010 * Channel Types by ID (RPN_ID) request
1034 * @sp: current sequence in RPN_ID exchange 1011 * @sp: current sequence in RPN_ID exchange
1035 * @fp: response frame 1012 * @fp: response frame
1036 * @lp_arg: Fibre Channel host port instance 1013 * @lp_arg: Fibre Channel host port instance
@@ -1053,17 +1030,17 @@ static void fc_lport_rft_id_resp(struct fc_seq *sp, struct fc_frame *fp,
1053 1030
1054 FC_DEBUG_LPORT("Received a RFT_ID response\n"); 1031 FC_DEBUG_LPORT("Received a RFT_ID response\n");
1055 1032
1033 if (IS_ERR(fp)) {
1034 fc_lport_error(lport, fp);
1035 goto err;
1036 }
1037
1056 if (lport->state != LPORT_ST_RFT_ID) { 1038 if (lport->state != LPORT_ST_RFT_ID) {
1057 FC_DBG("Received a RFT_ID response, but in state %s\n", 1039 FC_DBG("Received a RFT_ID response, but in state %s\n",
1058 fc_lport_state(lport)); 1040 fc_lport_state(lport));
1059 goto out; 1041 goto out;
1060 } 1042 }
1061 1043
1062 if (IS_ERR(fp)) {
1063 fc_lport_error(lport, fp);
1064 goto err;
1065 }
1066
1067 fh = fc_frame_header_get(fp); 1044 fh = fc_frame_header_get(fp);
1068 ct = fc_frame_payload_get(fp, sizeof(*ct)); 1045 ct = fc_frame_payload_get(fp, sizeof(*ct));
1069 1046
@@ -1081,8 +1058,8 @@ err:
1081} 1058}
1082 1059
1083/** 1060/**
1084 * fc_lport_rpn_id_resp - Handle response to Register Port 1061 * fc_lport_rpn_id_resp() - Handle response to Register Port
1085 * Name by ID (RPN_ID) request 1062 * Name by ID (RPN_ID) request
1086 * @sp: current sequence in RPN_ID exchange 1063 * @sp: current sequence in RPN_ID exchange
1087 * @fp: response frame 1064 * @fp: response frame
1088 * @lp_arg: Fibre Channel host port instance 1065 * @lp_arg: Fibre Channel host port instance
@@ -1105,17 +1082,17 @@ static void fc_lport_rpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
1105 1082
1106 FC_DEBUG_LPORT("Received a RPN_ID response\n"); 1083 FC_DEBUG_LPORT("Received a RPN_ID response\n");
1107 1084
1085 if (IS_ERR(fp)) {
1086 fc_lport_error(lport, fp);
1087 goto err;
1088 }
1089
1108 if (lport->state != LPORT_ST_RPN_ID) { 1090 if (lport->state != LPORT_ST_RPN_ID) {
1109 FC_DBG("Received a RPN_ID response, but in state %s\n", 1091 FC_DBG("Received a RPN_ID response, but in state %s\n",
1110 fc_lport_state(lport)); 1092 fc_lport_state(lport));
1111 goto out; 1093 goto out;
1112 } 1094 }
1113 1095
1114 if (IS_ERR(fp)) {
1115 fc_lport_error(lport, fp);
1116 goto err;
1117 }
1118
1119 fh = fc_frame_header_get(fp); 1096 fh = fc_frame_header_get(fp);
1120 ct = fc_frame_payload_get(fp, sizeof(*ct)); 1097 ct = fc_frame_payload_get(fp, sizeof(*ct));
1121 if (fh && ct && fh->fh_type == FC_TYPE_CT && 1098 if (fh && ct && fh->fh_type == FC_TYPE_CT &&
@@ -1133,7 +1110,7 @@ err:
1133} 1110}
1134 1111
1135/** 1112/**
1136 * fc_lport_scr_resp - Handle response to State Change Register (SCR) request 1113 * fc_lport_scr_resp() - Handle response to State Change Register (SCR) request
1137 * @sp: current sequence in SCR exchange 1114 * @sp: current sequence in SCR exchange
1138 * @fp: response frame 1115 * @fp: response frame
1139 * @lp_arg: Fibre Channel lport port instance that sent the registration request 1116 * @lp_arg: Fibre Channel lport port instance that sent the registration request
@@ -1155,17 +1132,17 @@ static void fc_lport_scr_resp(struct fc_seq *sp, struct fc_frame *fp,
1155 1132
1156 FC_DEBUG_LPORT("Received a SCR response\n"); 1133 FC_DEBUG_LPORT("Received a SCR response\n");
1157 1134
1135 if (IS_ERR(fp)) {
1136 fc_lport_error(lport, fp);
1137 goto err;
1138 }
1139
1158 if (lport->state != LPORT_ST_SCR) { 1140 if (lport->state != LPORT_ST_SCR) {
1159 FC_DBG("Received a SCR response, but in state %s\n", 1141 FC_DBG("Received a SCR response, but in state %s\n",
1160 fc_lport_state(lport)); 1142 fc_lport_state(lport));
1161 goto out; 1143 goto out;
1162 } 1144 }
1163 1145
1164 if (IS_ERR(fp)) {
1165 fc_lport_error(lport, fp);
1166 goto err;
1167 }
1168
1169 op = fc_frame_payload_op(fp); 1146 op = fc_frame_payload_op(fp);
1170 if (op == ELS_LS_ACC) 1147 if (op == ELS_LS_ACC)
1171 fc_lport_enter_ready(lport); 1148 fc_lport_enter_ready(lport);
@@ -1179,7 +1156,7 @@ err:
1179} 1156}
1180 1157
1181/** 1158/**
1182 * fc_lport_enter_scr - Send a State Change Register (SCR) request 1159 * fc_lport_enter_scr() - Send a State Change Register (SCR) request
1183 * @lport: Fibre Channel local port to register for state changes 1160 * @lport: Fibre Channel local port to register for state changes
1184 * 1161 *
1185 * Locking Note: The lport lock is expected to be held before calling 1162 * Locking Note: The lport lock is expected to be held before calling
@@ -1206,7 +1183,7 @@ static void fc_lport_enter_scr(struct fc_lport *lport)
1206} 1183}
1207 1184
1208/** 1185/**
1209 * fc_lport_enter_rft_id - Register FC4-types with the name server 1186 * fc_lport_enter_rft_id() - Register FC4-types with the name server
1210 * @lport: Fibre Channel local port to register 1187 * @lport: Fibre Channel local port to register
1211 * 1188 *
1212 * Locking Note: The lport lock is expected to be held before calling 1189 * Locking Note: The lport lock is expected to be held before calling
@@ -1248,7 +1225,7 @@ static void fc_lport_enter_rft_id(struct fc_lport *lport)
1248} 1225}
1249 1226
1250/** 1227/**
1251 * fc_rport_enter_rft_id - Register port name with the name server 1228 * fc_rport_enter_rft_id() - Register port name with the name server
1252 * @lport: Fibre Channel local port to register 1229 * @lport: Fibre Channel local port to register
1253 * 1230 *
1254 * Locking Note: The lport lock is expected to be held before calling 1231 * Locking Note: The lport lock is expected to be held before calling
@@ -1281,7 +1258,7 @@ static struct fc_rport_operations fc_lport_rport_ops = {
1281}; 1258};
1282 1259
1283/** 1260/**
1284 * fc_rport_enter_dns - Create a rport to the name server 1261 * fc_rport_enter_dns() - Create a rport to the name server
1285 * @lport: Fibre Channel local port requesting a rport for the name server 1262 * @lport: Fibre Channel local port requesting a rport for the name server
1286 * 1263 *
1287 * Locking Note: The lport lock is expected to be held before calling 1264 * Locking Note: The lport lock is expected to be held before calling
@@ -1304,7 +1281,7 @@ static void fc_lport_enter_dns(struct fc_lport *lport)
1304 1281
1305 fc_lport_state_enter(lport, LPORT_ST_DNS); 1282 fc_lport_state_enter(lport, LPORT_ST_DNS);
1306 1283
1307 rport = fc_rport_rogue_create(&dp); 1284 rport = lport->tt.rport_create(&dp);
1308 if (!rport) 1285 if (!rport)
1309 goto err; 1286 goto err;
1310 1287
@@ -1318,7 +1295,7 @@ err:
1318} 1295}
1319 1296
1320/** 1297/**
1321 * fc_lport_timeout - Handler for the retry_work timer. 1298 * fc_lport_timeout() - Handler for the retry_work timer.
1322 * @work: The work struct of the fc_lport 1299 * @work: The work struct of the fc_lport
1323 */ 1300 */
1324static void fc_lport_timeout(struct work_struct *work) 1301static void fc_lport_timeout(struct work_struct *work)
@@ -1359,7 +1336,7 @@ static void fc_lport_timeout(struct work_struct *work)
1359} 1336}
1360 1337
1361/** 1338/**
1362 * fc_lport_logo_resp - Handle response to LOGO request 1339 * fc_lport_logo_resp() - Handle response to LOGO request
1363 * @sp: current sequence in LOGO exchange 1340 * @sp: current sequence in LOGO exchange
1364 * @fp: response frame 1341 * @fp: response frame
1365 * @lp_arg: Fibre Channel lport port instance that sent the LOGO request 1342 * @lp_arg: Fibre Channel lport port instance that sent the LOGO request
@@ -1381,17 +1358,17 @@ static void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
1381 1358
1382 FC_DEBUG_LPORT("Received a LOGO response\n"); 1359 FC_DEBUG_LPORT("Received a LOGO response\n");
1383 1360
1361 if (IS_ERR(fp)) {
1362 fc_lport_error(lport, fp);
1363 goto err;
1364 }
1365
1384 if (lport->state != LPORT_ST_LOGO) { 1366 if (lport->state != LPORT_ST_LOGO) {
1385 FC_DBG("Received a LOGO response, but in state %s\n", 1367 FC_DBG("Received a LOGO response, but in state %s\n",
1386 fc_lport_state(lport)); 1368 fc_lport_state(lport));
1387 goto out; 1369 goto out;
1388 } 1370 }
1389 1371
1390 if (IS_ERR(fp)) {
1391 fc_lport_error(lport, fp);
1392 goto err;
1393 }
1394
1395 op = fc_frame_payload_op(fp); 1372 op = fc_frame_payload_op(fp);
1396 if (op == ELS_LS_ACC) 1373 if (op == ELS_LS_ACC)
1397 fc_lport_enter_reset(lport); 1374 fc_lport_enter_reset(lport);
@@ -1405,7 +1382,7 @@ err:
1405} 1382}
1406 1383
1407/** 1384/**
1408 * fc_rport_enter_logo - Logout of the fabric 1385 * fc_rport_enter_logo() - Logout of the fabric
1409 * @lport: Fibre Channel local port to be logged out 1386 * @lport: Fibre Channel local port to be logged out
1410 * 1387 *
1411 * Locking Note: The lport lock is expected to be held before calling 1388 * Locking Note: The lport lock is expected to be held before calling
@@ -1437,7 +1414,7 @@ static void fc_lport_enter_logo(struct fc_lport *lport)
1437} 1414}
1438 1415
1439/** 1416/**
1440 * fc_lport_flogi_resp - Handle response to FLOGI request 1417 * fc_lport_flogi_resp() - Handle response to FLOGI request
1441 * @sp: current sequence in FLOGI exchange 1418 * @sp: current sequence in FLOGI exchange
1442 * @fp: response frame 1419 * @fp: response frame
1443 * @lp_arg: Fibre Channel lport port instance that sent the FLOGI request 1420 * @lp_arg: Fibre Channel lport port instance that sent the FLOGI request
@@ -1465,17 +1442,17 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
1465 1442
1466 FC_DEBUG_LPORT("Received a FLOGI response\n"); 1443 FC_DEBUG_LPORT("Received a FLOGI response\n");
1467 1444
1445 if (IS_ERR(fp)) {
1446 fc_lport_error(lport, fp);
1447 goto err;
1448 }
1449
1468 if (lport->state != LPORT_ST_FLOGI) { 1450 if (lport->state != LPORT_ST_FLOGI) {
1469 FC_DBG("Received a FLOGI response, but in state %s\n", 1451 FC_DBG("Received a FLOGI response, but in state %s\n",
1470 fc_lport_state(lport)); 1452 fc_lport_state(lport));
1471 goto out; 1453 goto out;
1472 } 1454 }
1473 1455
1474 if (IS_ERR(fp)) {
1475 fc_lport_error(lport, fp);
1476 goto err;
1477 }
1478
1479 fh = fc_frame_header_get(fp); 1456 fh = fc_frame_header_get(fp);
1480 did = ntoh24(fh->fh_d_id); 1457 did = ntoh24(fh->fh_d_id);
1481 if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { 1458 if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) {
@@ -1532,7 +1509,7 @@ err:
1532} 1509}
1533 1510
1534/** 1511/**
1535 * fc_rport_enter_flogi - Send a FLOGI request to the fabric manager 1512 * fc_rport_enter_flogi() - Send a FLOGI request to the fabric manager
1536 * @lport: Fibre Channel local port to be logged in to the fabric 1513 * @lport: Fibre Channel local port to be logged in to the fabric
1537 * 1514 *
1538 * Locking Note: The lport lock is expected to be held before calling 1515 * Locking Note: The lport lock is expected to be held before calling
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index e780d8caf70e..dae65133a833 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -81,6 +81,7 @@ static void fc_rport_recv_logo_req(struct fc_rport *,
81 struct fc_seq *, struct fc_frame *); 81 struct fc_seq *, struct fc_frame *);
82static void fc_rport_timeout(struct work_struct *); 82static void fc_rport_timeout(struct work_struct *);
83static void fc_rport_error(struct fc_rport *, struct fc_frame *); 83static void fc_rport_error(struct fc_rport *, struct fc_frame *);
84static void fc_rport_error_retry(struct fc_rport *, struct fc_frame *);
84static void fc_rport_work(struct work_struct *); 85static void fc_rport_work(struct work_struct *);
85 86
86static const char *fc_rport_state_names[] = { 87static const char *fc_rport_state_names[] = {
@@ -145,7 +146,7 @@ struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
145} 146}
146 147
147/** 148/**
148 * fc_rport_state - return a string for the state the rport is in 149 * fc_rport_state() - return a string for the state the rport is in
149 * @rport: The rport whose state we want to get a string for 150 * @rport: The rport whose state we want to get a string for
150 */ 151 */
151static const char *fc_rport_state(struct fc_rport *rport) 152static const char *fc_rport_state(struct fc_rport *rport)
@@ -160,7 +161,7 @@ static const char *fc_rport_state(struct fc_rport *rport)
160} 161}
161 162
162/** 163/**
163 * fc_set_rport_loss_tmo - Set the remote port loss timeout in seconds. 164 * fc_set_rport_loss_tmo() - Set the remote port loss timeout in seconds.
164 * @rport: Pointer to Fibre Channel remote port structure 165 * @rport: Pointer to Fibre Channel remote port structure
165 * @timeout: timeout in seconds 166 * @timeout: timeout in seconds
166 */ 167 */
@@ -174,12 +175,12 @@ void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout)
174EXPORT_SYMBOL(fc_set_rport_loss_tmo); 175EXPORT_SYMBOL(fc_set_rport_loss_tmo);
175 176
176/** 177/**
177 * fc_plogi_get_maxframe - Get max payload from the common service parameters 178 * fc_plogi_get_maxframe() - Get max payload from the common service parameters
178 * @flp: FLOGI payload structure 179 * @flp: FLOGI payload structure
179 * @maxval: upper limit, may be less than what is in the service parameters 180 * @maxval: upper limit, may be less than what is in the service parameters
180 */ 181 */
181static unsigned int 182static unsigned int fc_plogi_get_maxframe(struct fc_els_flogi *flp,
182fc_plogi_get_maxframe(struct fc_els_flogi *flp, unsigned int maxval) 183 unsigned int maxval)
183{ 184{
184 unsigned int mfs; 185 unsigned int mfs;
185 186
@@ -197,7 +198,7 @@ fc_plogi_get_maxframe(struct fc_els_flogi *flp, unsigned int maxval)
197} 198}
198 199
199/** 200/**
200 * fc_rport_state_enter - Change the rport's state 201 * fc_rport_state_enter() - Change the rport's state
201 * @rport: The rport whose state should change 202 * @rport: The rport whose state should change
202 * @new: The new state of the rport 203 * @new: The new state of the rport
203 * 204 *
@@ -214,6 +215,7 @@ static void fc_rport_state_enter(struct fc_rport *rport,
214 215
215static void fc_rport_work(struct work_struct *work) 216static void fc_rport_work(struct work_struct *work)
216{ 217{
218 u32 port_id;
217 struct fc_rport_libfc_priv *rdata = 219 struct fc_rport_libfc_priv *rdata =
218 container_of(work, struct fc_rport_libfc_priv, event_work); 220 container_of(work, struct fc_rport_libfc_priv, event_work);
219 enum fc_rport_event event; 221 enum fc_rport_event event;
@@ -279,14 +281,18 @@ static void fc_rport_work(struct work_struct *work)
279 rport_ops->event_callback(lport, rport, event); 281 rport_ops->event_callback(lport, rport, event);
280 if (trans_state == FC_PORTSTATE_ROGUE) 282 if (trans_state == FC_PORTSTATE_ROGUE)
281 put_device(&rport->dev); 283 put_device(&rport->dev);
282 else 284 else {
285 port_id = rport->port_id;
283 fc_remote_port_delete(rport); 286 fc_remote_port_delete(rport);
287 lport->tt.exch_mgr_reset(lport, 0, port_id);
288 lport->tt.exch_mgr_reset(lport, port_id, 0);
289 }
284 } else 290 } else
285 mutex_unlock(&rdata->rp_mutex); 291 mutex_unlock(&rdata->rp_mutex);
286} 292}
287 293
288/** 294/**
289 * fc_rport_login - Start the remote port login state machine 295 * fc_rport_login() - Start the remote port login state machine
290 * @rport: Fibre Channel remote port 296 * @rport: Fibre Channel remote port
291 * 297 *
292 * Locking Note: Called without the rport lock held. This 298 * Locking Note: Called without the rport lock held. This
@@ -309,7 +315,7 @@ int fc_rport_login(struct fc_rport *rport)
309} 315}
310 316
311/** 317/**
312 * fc_rport_logoff - Logoff and remove an rport 318 * fc_rport_logoff() - Logoff and remove an rport
313 * @rport: Fibre Channel remote port to be removed 319 * @rport: Fibre Channel remote port to be removed
314 * 320 *
315 * Locking Note: Called without the rport lock held. This 321 * Locking Note: Called without the rport lock held. This
@@ -347,7 +353,7 @@ int fc_rport_logoff(struct fc_rport *rport)
347} 353}
348 354
349/** 355/**
350 * fc_rport_enter_ready - The rport is ready 356 * fc_rport_enter_ready() - The rport is ready
351 * @rport: Fibre Channel remote port that is ready 357 * @rport: Fibre Channel remote port that is ready
352 * 358 *
353 * Locking Note: The rport lock is expected to be held before calling 359 * Locking Note: The rport lock is expected to be held before calling
@@ -366,7 +372,7 @@ static void fc_rport_enter_ready(struct fc_rport *rport)
366} 372}
367 373
368/** 374/**
369 * fc_rport_timeout - Handler for the retry_work timer. 375 * fc_rport_timeout() - Handler for the retry_work timer.
370 * @work: The work struct of the fc_rport_libfc_priv 376 * @work: The work struct of the fc_rport_libfc_priv
371 * 377 *
372 * Locking Note: Called without the rport lock held. This 378 * Locking Note: Called without the rport lock held. This
@@ -405,59 +411,75 @@ static void fc_rport_timeout(struct work_struct *work)
405} 411}
406 412
407/** 413/**
408 * fc_rport_error - Handler for any errors 414 * fc_rport_error() - Error handler, called once retries have been exhausted
409 * @rport: The fc_rport object 415 * @rport: The fc_rport object
410 * @fp: The frame pointer 416 * @fp: The frame pointer
411 * 417 *
412 * If the error was caused by a resource allocation failure
413 * then wait for half a second and retry, otherwise retry
414 * immediately.
415 *
416 * Locking Note: The rport lock is expected to be held before 418 * Locking Note: The rport lock is expected to be held before
417 * calling this routine 419 * calling this routine
418 */ 420 */
419static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp) 421static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp)
420{ 422{
421 struct fc_rport_libfc_priv *rdata = rport->dd_data; 423 struct fc_rport_libfc_priv *rdata = rport->dd_data;
422 unsigned long delay = 0;
423 424
424 FC_DEBUG_RPORT("Error %ld in state %s, retries %d\n", 425 FC_DEBUG_RPORT("Error %ld in state %s, retries %d\n",
425 PTR_ERR(fp), fc_rport_state(rport), rdata->retries); 426 PTR_ERR(fp), fc_rport_state(rport), rdata->retries);
426 427
427 if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) { 428 switch (rdata->rp_state) {
428 /* 429 case RPORT_ST_PLOGI:
429 * Memory allocation failure, or the exchange timed out. 430 case RPORT_ST_PRLI:
430 * Retry after delay 431 case RPORT_ST_LOGO:
431 */ 432 rdata->event = RPORT_EV_FAILED;
432 if (rdata->retries < rdata->local_port->max_retry_count) { 433 queue_work(rport_event_queue,
433 rdata->retries++; 434 &rdata->event_work);
434 if (!fp) 435 break;
435 delay = msecs_to_jiffies(500); 436 case RPORT_ST_RTV:
436 get_device(&rport->dev); 437 fc_rport_enter_ready(rport);
437 schedule_delayed_work(&rdata->retry_work, delay); 438 break;
438 } else { 439 case RPORT_ST_NONE:
439 switch (rdata->rp_state) { 440 case RPORT_ST_READY:
440 case RPORT_ST_PLOGI: 441 case RPORT_ST_INIT:
441 case RPORT_ST_PRLI: 442 break;
442 case RPORT_ST_LOGO:
443 rdata->event = RPORT_EV_FAILED;
444 queue_work(rport_event_queue,
445 &rdata->event_work);
446 break;
447 case RPORT_ST_RTV:
448 fc_rport_enter_ready(rport);
449 break;
450 case RPORT_ST_NONE:
451 case RPORT_ST_READY:
452 case RPORT_ST_INIT:
453 break;
454 }
455 }
456 } 443 }
457} 444}
458 445
459/** 446/**
460 * fc_rport_plogi_recv_resp - Handle incoming ELS PLOGI response 447 * fc_rport_error_retry() - Error handler when retries are desired
448 * @rport: The fc_rport object
449 * @fp: The frame pointer
450 *
451 * If the error was an exchange timeout retry immediately,
452 * otherwise wait for E_D_TOV.
453 *
454 * Locking Note: The rport lock is expected to be held before
455 * calling this routine
456 */
457static void fc_rport_error_retry(struct fc_rport *rport, struct fc_frame *fp)
458{
459 struct fc_rport_libfc_priv *rdata = rport->dd_data;
460 unsigned long delay = FC_DEF_E_D_TOV;
461
462 /* make sure this isn't an FC_EX_CLOSED error, never retry those */
463 if (PTR_ERR(fp) == -FC_EX_CLOSED)
464 return fc_rport_error(rport, fp);
465
466 if (rdata->retries < rdata->local_port->max_retry_count) {
467 FC_DEBUG_RPORT("Error %ld in state %s, retrying\n",
468 PTR_ERR(fp), fc_rport_state(rport));
469 rdata->retries++;
470 /* no additional delay on exchange timeouts */
471 if (PTR_ERR(fp) == -FC_EX_TIMEOUT)
472 delay = 0;
473 get_device(&rport->dev);
474 schedule_delayed_work(&rdata->retry_work, delay);
475 return;
476 }
477
478 return fc_rport_error(rport, fp);
479}
480
481/**
482 * fc_rport_plogi_recv_resp() - Handle incoming ELS PLOGI response
461 * @sp: current sequence in the PLOGI exchange 483 * @sp: current sequence in the PLOGI exchange
462 * @fp: response frame 484 * @fp: response frame
463 * @rp_arg: Fibre Channel remote port 485 * @rp_arg: Fibre Channel remote port
@@ -483,17 +505,17 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp,
483 FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n", 505 FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n",
484 rport->port_id); 506 rport->port_id);
485 507
508 if (IS_ERR(fp)) {
509 fc_rport_error_retry(rport, fp);
510 goto err;
511 }
512
486 if (rdata->rp_state != RPORT_ST_PLOGI) { 513 if (rdata->rp_state != RPORT_ST_PLOGI) {
487 FC_DBG("Received a PLOGI response, but in state %s\n", 514 FC_DBG("Received a PLOGI response, but in state %s\n",
488 fc_rport_state(rport)); 515 fc_rport_state(rport));
489 goto out; 516 goto out;
490 } 517 }
491 518
492 if (IS_ERR(fp)) {
493 fc_rport_error(rport, fp);
494 goto err;
495 }
496
497 op = fc_frame_payload_op(fp); 519 op = fc_frame_payload_op(fp);
498 if (op == ELS_LS_ACC && 520 if (op == ELS_LS_ACC &&
499 (plp = fc_frame_payload_get(fp, sizeof(*plp))) != NULL) { 521 (plp = fc_frame_payload_get(fp, sizeof(*plp))) != NULL) {
@@ -522,7 +544,7 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp,
522 else 544 else
523 fc_rport_enter_prli(rport); 545 fc_rport_enter_prli(rport);
524 } else 546 } else
525 fc_rport_error(rport, fp); 547 fc_rport_error_retry(rport, fp);
526 548
527out: 549out:
528 fc_frame_free(fp); 550 fc_frame_free(fp);
@@ -532,7 +554,7 @@ err:
532} 554}
533 555
534/** 556/**
535 * fc_rport_enter_plogi - Send Port Login (PLOGI) request to peer 557 * fc_rport_enter_plogi() - Send Port Login (PLOGI) request to peer
536 * @rport: Fibre Channel remote port to send PLOGI to 558 * @rport: Fibre Channel remote port to send PLOGI to
537 * 559 *
538 * Locking Note: The rport lock is expected to be held before calling 560 * Locking Note: The rport lock is expected to be held before calling
@@ -552,20 +574,20 @@ static void fc_rport_enter_plogi(struct fc_rport *rport)
552 rport->maxframe_size = FC_MIN_MAX_PAYLOAD; 574 rport->maxframe_size = FC_MIN_MAX_PAYLOAD;
553 fp = fc_frame_alloc(lport, sizeof(struct fc_els_flogi)); 575 fp = fc_frame_alloc(lport, sizeof(struct fc_els_flogi));
554 if (!fp) { 576 if (!fp) {
555 fc_rport_error(rport, fp); 577 fc_rport_error_retry(rport, fp);
556 return; 578 return;
557 } 579 }
558 rdata->e_d_tov = lport->e_d_tov; 580 rdata->e_d_tov = lport->e_d_tov;
559 581
560 if (!lport->tt.elsct_send(lport, rport, fp, ELS_PLOGI, 582 if (!lport->tt.elsct_send(lport, rport, fp, ELS_PLOGI,
561 fc_rport_plogi_resp, rport, lport->e_d_tov)) 583 fc_rport_plogi_resp, rport, lport->e_d_tov))
562 fc_rport_error(rport, fp); 584 fc_rport_error_retry(rport, fp);
563 else 585 else
564 get_device(&rport->dev); 586 get_device(&rport->dev);
565} 587}
566 588
567/** 589/**
568 * fc_rport_prli_resp - Process Login (PRLI) response handler 590 * fc_rport_prli_resp() - Process Login (PRLI) response handler
569 * @sp: current sequence in the PRLI exchange 591 * @sp: current sequence in the PRLI exchange
570 * @fp: response frame 592 * @fp: response frame
571 * @rp_arg: Fibre Channel remote port 593 * @rp_arg: Fibre Channel remote port
@@ -592,17 +614,17 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp,
592 FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n", 614 FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n",
593 rport->port_id); 615 rport->port_id);
594 616
617 if (IS_ERR(fp)) {
618 fc_rport_error_retry(rport, fp);
619 goto err;
620 }
621
595 if (rdata->rp_state != RPORT_ST_PRLI) { 622 if (rdata->rp_state != RPORT_ST_PRLI) {
596 FC_DBG("Received a PRLI response, but in state %s\n", 623 FC_DBG("Received a PRLI response, but in state %s\n",
597 fc_rport_state(rport)); 624 fc_rport_state(rport));
598 goto out; 625 goto out;
599 } 626 }
600 627
601 if (IS_ERR(fp)) {
602 fc_rport_error(rport, fp);
603 goto err;
604 }
605
606 op = fc_frame_payload_op(fp); 628 op = fc_frame_payload_op(fp);
607 if (op == ELS_LS_ACC) { 629 if (op == ELS_LS_ACC) {
608 pp = fc_frame_payload_get(fp, sizeof(*pp)); 630 pp = fc_frame_payload_get(fp, sizeof(*pp));
@@ -635,7 +657,7 @@ err:
635} 657}
636 658
637/** 659/**
638 * fc_rport_logo_resp - Logout (LOGO) response handler 660 * fc_rport_logo_resp() - Logout (LOGO) response handler
639 * @sp: current sequence in the LOGO exchange 661 * @sp: current sequence in the LOGO exchange
640 * @fp: response frame 662 * @fp: response frame
641 * @rp_arg: Fibre Channel remote port 663 * @rp_arg: Fibre Channel remote port
@@ -657,7 +679,7 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
657 rport->port_id); 679 rport->port_id);
658 680
659 if (IS_ERR(fp)) { 681 if (IS_ERR(fp)) {
660 fc_rport_error(rport, fp); 682 fc_rport_error_retry(rport, fp);
661 goto err; 683 goto err;
662 } 684 }
663 685
@@ -684,7 +706,7 @@ err:
684} 706}
685 707
686/** 708/**
687 * fc_rport_enter_prli - Send Process Login (PRLI) request to peer 709 * fc_rport_enter_prli() - Send Process Login (PRLI) request to peer
688 * @rport: Fibre Channel remote port to send PRLI to 710 * @rport: Fibre Channel remote port to send PRLI to
689 * 711 *
690 * Locking Note: The rport lock is expected to be held before calling 712 * Locking Note: The rport lock is expected to be held before calling
@@ -707,19 +729,19 @@ static void fc_rport_enter_prli(struct fc_rport *rport)
707 729
708 fp = fc_frame_alloc(lport, sizeof(*pp)); 730 fp = fc_frame_alloc(lport, sizeof(*pp));
709 if (!fp) { 731 if (!fp) {
710 fc_rport_error(rport, fp); 732 fc_rport_error_retry(rport, fp);
711 return; 733 return;
712 } 734 }
713 735
714 if (!lport->tt.elsct_send(lport, rport, fp, ELS_PRLI, 736 if (!lport->tt.elsct_send(lport, rport, fp, ELS_PRLI,
715 fc_rport_prli_resp, rport, lport->e_d_tov)) 737 fc_rport_prli_resp, rport, lport->e_d_tov))
716 fc_rport_error(rport, fp); 738 fc_rport_error_retry(rport, fp);
717 else 739 else
718 get_device(&rport->dev); 740 get_device(&rport->dev);
719} 741}
720 742
721/** 743/**
722 * fc_rport_els_rtv_resp - Request Timeout Value response handler 744 * fc_rport_els_rtv_resp() - Request Timeout Value response handler
723 * @sp: current sequence in the RTV exchange 745 * @sp: current sequence in the RTV exchange
724 * @fp: response frame 746 * @fp: response frame
725 * @rp_arg: Fibre Channel remote port 747 * @rp_arg: Fibre Channel remote port
@@ -742,17 +764,17 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp,
742 FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n", 764 FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n",
743 rport->port_id); 765 rport->port_id);
744 766
767 if (IS_ERR(fp)) {
768 fc_rport_error(rport, fp);
769 goto err;
770 }
771
745 if (rdata->rp_state != RPORT_ST_RTV) { 772 if (rdata->rp_state != RPORT_ST_RTV) {
746 FC_DBG("Received a RTV response, but in state %s\n", 773 FC_DBG("Received a RTV response, but in state %s\n",
747 fc_rport_state(rport)); 774 fc_rport_state(rport));
748 goto out; 775 goto out;
749 } 776 }
750 777
751 if (IS_ERR(fp)) {
752 fc_rport_error(rport, fp);
753 goto err;
754 }
755
756 op = fc_frame_payload_op(fp); 778 op = fc_frame_payload_op(fp);
757 if (op == ELS_LS_ACC) { 779 if (op == ELS_LS_ACC) {
758 struct fc_els_rtv_acc *rtv; 780 struct fc_els_rtv_acc *rtv;
@@ -785,7 +807,7 @@ err:
785} 807}
786 808
787/** 809/**
788 * fc_rport_enter_rtv - Send Request Timeout Value (RTV) request to peer 810 * fc_rport_enter_rtv() - Send Request Timeout Value (RTV) request to peer
789 * @rport: Fibre Channel remote port to send RTV to 811 * @rport: Fibre Channel remote port to send RTV to
790 * 812 *
791 * Locking Note: The rport lock is expected to be held before calling 813 * Locking Note: The rport lock is expected to be held before calling
@@ -804,19 +826,19 @@ static void fc_rport_enter_rtv(struct fc_rport *rport)
804 826
805 fp = fc_frame_alloc(lport, sizeof(struct fc_els_rtv)); 827 fp = fc_frame_alloc(lport, sizeof(struct fc_els_rtv));
806 if (!fp) { 828 if (!fp) {
807 fc_rport_error(rport, fp); 829 fc_rport_error_retry(rport, fp);
808 return; 830 return;
809 } 831 }
810 832
811 if (!lport->tt.elsct_send(lport, rport, fp, ELS_RTV, 833 if (!lport->tt.elsct_send(lport, rport, fp, ELS_RTV,
812 fc_rport_rtv_resp, rport, lport->e_d_tov)) 834 fc_rport_rtv_resp, rport, lport->e_d_tov))
813 fc_rport_error(rport, fp); 835 fc_rport_error_retry(rport, fp);
814 else 836 else
815 get_device(&rport->dev); 837 get_device(&rport->dev);
816} 838}
817 839
818/** 840/**
819 * fc_rport_enter_logo - Send Logout (LOGO) request to peer 841 * fc_rport_enter_logo() - Send Logout (LOGO) request to peer
820 * @rport: Fibre Channel remote port to send LOGO to 842 * @rport: Fibre Channel remote port to send LOGO to
821 * 843 *
822 * Locking Note: The rport lock is expected to be held before calling 844 * Locking Note: The rport lock is expected to be held before calling
@@ -835,20 +857,20 @@ static void fc_rport_enter_logo(struct fc_rport *rport)
835 857
836 fp = fc_frame_alloc(lport, sizeof(struct fc_els_logo)); 858 fp = fc_frame_alloc(lport, sizeof(struct fc_els_logo));
837 if (!fp) { 859 if (!fp) {
838 fc_rport_error(rport, fp); 860 fc_rport_error_retry(rport, fp);
839 return; 861 return;
840 } 862 }
841 863
842 if (!lport->tt.elsct_send(lport, rport, fp, ELS_LOGO, 864 if (!lport->tt.elsct_send(lport, rport, fp, ELS_LOGO,
843 fc_rport_logo_resp, rport, lport->e_d_tov)) 865 fc_rport_logo_resp, rport, lport->e_d_tov))
844 fc_rport_error(rport, fp); 866 fc_rport_error_retry(rport, fp);
845 else 867 else
846 get_device(&rport->dev); 868 get_device(&rport->dev);
847} 869}
848 870
849 871
850/** 872/**
851 * fc_rport_recv_req - Receive a request from a rport 873 * fc_rport_recv_req() - Receive a request from a rport
852 * @sp: current sequence in the PLOGI exchange 874 * @sp: current sequence in the PLOGI exchange
853 * @fp: response frame 875 * @fp: response frame
854 * @rp_arg: Fibre Channel remote port 876 * @rp_arg: Fibre Channel remote port
@@ -909,7 +931,7 @@ void fc_rport_recv_req(struct fc_seq *sp, struct fc_frame *fp,
909} 931}
910 932
911/** 933/**
912 * fc_rport_recv_plogi_req - Handle incoming Port Login (PLOGI) request 934 * fc_rport_recv_plogi_req() - Handle incoming Port Login (PLOGI) request
913 * @rport: Fibre Channel remote port that initiated PLOGI 935 * @rport: Fibre Channel remote port that initiated PLOGI
914 * @sp: current sequence in the PLOGI exchange 936 * @sp: current sequence in the PLOGI exchange
915 * @fp: PLOGI request frame 937 * @fp: PLOGI request frame
@@ -1031,7 +1053,7 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
1031} 1053}
1032 1054
1033/** 1055/**
1034 * fc_rport_recv_prli_req - Handle incoming Process Login (PRLI) request 1056 * fc_rport_recv_prli_req() - Handle incoming Process Login (PRLI) request
1035 * @rport: Fibre Channel remote port that initiated PRLI 1057 * @rport: Fibre Channel remote port that initiated PRLI
1036 * @sp: current sequence in the PRLI exchange 1058 * @sp: current sequence in the PRLI exchange
1037 * @fp: PRLI request frame 1059 * @fp: PRLI request frame
@@ -1182,7 +1204,7 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport,
1182} 1204}
1183 1205
1184/** 1206/**
1185 * fc_rport_recv_prlo_req - Handle incoming Process Logout (PRLO) request 1207 * fc_rport_recv_prlo_req() - Handle incoming Process Logout (PRLO) request
1186 * @rport: Fibre Channel remote port that initiated PRLO 1208 * @rport: Fibre Channel remote port that initiated PRLO
1187 * @sp: current sequence in the PRLO exchange 1209 * @sp: current sequence in the PRLO exchange
1188 * @fp: PRLO request frame 1210 * @fp: PRLO request frame
@@ -1213,7 +1235,7 @@ static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp,
1213} 1235}
1214 1236
1215/** 1237/**
1216 * fc_rport_recv_logo_req - Handle incoming Logout (LOGO) request 1238 * fc_rport_recv_logo_req() - Handle incoming Logout (LOGO) request
1217 * @rport: Fibre Channel remote port that initiated LOGO 1239 * @rport: Fibre Channel remote port that initiated LOGO
1218 * @sp: current sequence in the LOGO exchange 1240 * @sp: current sequence in the LOGO exchange
1219 * @fp: LOGO request frame 1241 * @fp: LOGO request frame
@@ -1249,6 +1271,9 @@ static void fc_rport_flush_queue(void)
1249 1271
1250int fc_rport_init(struct fc_lport *lport) 1272int fc_rport_init(struct fc_lport *lport)
1251{ 1273{
1274 if (!lport->tt.rport_create)
1275 lport->tt.rport_create = fc_rport_rogue_create;
1276
1252 if (!lport->tt.rport_login) 1277 if (!lport->tt.rport_login)
1253 lport->tt.rport_login = fc_rport_login; 1278 lport->tt.rport_login = fc_rport_login;
1254 1279
@@ -1285,7 +1310,7 @@ void fc_rport_terminate_io(struct fc_rport *rport)
1285 struct fc_rport_libfc_priv *rdata = rport->dd_data; 1310 struct fc_rport_libfc_priv *rdata = rport->dd_data;
1286 struct fc_lport *lport = rdata->local_port; 1311 struct fc_lport *lport = rdata->local_port;
1287 1312
1288 lport->tt.exch_mgr_reset(lport->emp, 0, rport->port_id); 1313 lport->tt.exch_mgr_reset(lport, 0, rport->port_id);
1289 lport->tt.exch_mgr_reset(lport->emp, rport->port_id, 0); 1314 lport->tt.exch_mgr_reset(lport, rport->port_id, 0);
1290} 1315}
1291EXPORT_SYMBOL(fc_rport_terminate_io); 1316EXPORT_SYMBOL(fc_rport_terminate_io);
diff --git a/drivers/scsi/mvme16x_scsi.c b/drivers/scsi/mvme16x_scsi.c
index b264b499d982..b5fbfd6ce870 100644
--- a/drivers/scsi/mvme16x_scsi.c
+++ b/drivers/scsi/mvme16x_scsi.c
@@ -34,7 +34,7 @@ static struct scsi_host_template mvme16x_scsi_driver_template = {
34static struct platform_device *mvme16x_scsi_device; 34static struct platform_device *mvme16x_scsi_device;
35 35
36static __devinit int 36static __devinit int
37mvme16x_probe(struct device *dev) 37mvme16x_probe(struct platform_device *dev)
38{ 38{
39 struct Scsi_Host * host = NULL; 39 struct Scsi_Host * host = NULL;
40 struct NCR_700_Host_Parameters *hostdata; 40 struct NCR_700_Host_Parameters *hostdata;
@@ -64,7 +64,8 @@ mvme16x_probe(struct device *dev)
64 hostdata->ctest7_extra = CTEST7_TT1; 64 hostdata->ctest7_extra = CTEST7_TT1;
65 65
66 /* and register the chip */ 66 /* and register the chip */
67 host = NCR_700_detect(&mvme16x_scsi_driver_template, hostdata, dev); 67 host = NCR_700_detect(&mvme16x_scsi_driver_template, hostdata,
68 &dev->dev);
68 if (!host) { 69 if (!host) {
69 printk(KERN_ERR "mvme16x-scsi: No host detected; " 70 printk(KERN_ERR "mvme16x-scsi: No host detected; "
70 "board configuration problem?\n"); 71 "board configuration problem?\n");
@@ -88,7 +89,7 @@ mvme16x_probe(struct device *dev)
88 out_be32(0xfff4202c, v); 89 out_be32(0xfff4202c, v);
89 } 90 }
90 91
91 dev_set_drvdata(dev, host); 92 platform_set_drvdata(dev, host);
92 scsi_scan_host(host); 93 scsi_scan_host(host);
93 94
94 return 0; 95 return 0;
@@ -102,9 +103,9 @@ mvme16x_probe(struct device *dev)
102} 103}
103 104
104static __devexit int 105static __devexit int
105mvme16x_device_remove(struct device *dev) 106mvme16x_device_remove(struct platform_device *dev)
106{ 107{
107 struct Scsi_Host *host = dev_get_drvdata(dev); 108 struct Scsi_Host *host = platform_get_drvdata(dev);
108 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 109 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
109 110
110 /* Disable scsi chip ints */ 111 /* Disable scsi chip ints */
@@ -123,25 +124,27 @@ mvme16x_device_remove(struct device *dev)
123 return 0; 124 return 0;
124} 125}
125 126
126static struct device_driver mvme16x_scsi_driver = { 127static struct platform_driver mvme16x_scsi_driver = {
127 .name = "mvme16x-scsi", 128 .driver = {
128 .bus = &platform_bus_type, 129 .name = "mvme16x-scsi",
129 .probe = mvme16x_probe, 130 .owner = THIS_MODULE,
130 .remove = __devexit_p(mvme16x_device_remove), 131 },
132 .probe = mvme16x_probe,
133 .remove = __devexit_p(mvme16x_device_remove),
131}; 134};
132 135
133static int __init mvme16x_scsi_init(void) 136static int __init mvme16x_scsi_init(void)
134{ 137{
135 int err; 138 int err;
136 139
137 err = driver_register(&mvme16x_scsi_driver); 140 err = platform_driver_register(&mvme16x_scsi_driver);
138 if (err) 141 if (err)
139 return err; 142 return err;
140 143
141 mvme16x_scsi_device = platform_device_register_simple("mvme16x-scsi", 144 mvme16x_scsi_device = platform_device_register_simple("mvme16x-scsi",
142 -1, NULL, 0); 145 -1, NULL, 0);
143 if (IS_ERR(mvme16x_scsi_device)) { 146 if (IS_ERR(mvme16x_scsi_device)) {
144 driver_unregister(&mvme16x_scsi_driver); 147 platform_driver_unregister(&mvme16x_scsi_driver);
145 return PTR_ERR(mvme16x_scsi_device); 148 return PTR_ERR(mvme16x_scsi_device);
146 } 149 }
147 150
@@ -151,7 +154,7 @@ static int __init mvme16x_scsi_init(void)
151static void __exit mvme16x_scsi_exit(void) 154static void __exit mvme16x_scsi_exit(void)
152{ 155{
153 platform_device_unregister(mvme16x_scsi_device); 156 platform_device_unregister(mvme16x_scsi_device);
154 driver_unregister(&mvme16x_scsi_driver); 157 platform_driver_unregister(&mvme16x_scsi_driver);
155} 158}
156 159
157module_init(mvme16x_scsi_init); 160module_init(mvme16x_scsi_init);
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index f4c57227ec18..ee9d40152430 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -244,12 +244,6 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
244 if (ha->optrom_state != QLA_SWAITING) 244 if (ha->optrom_state != QLA_SWAITING)
245 break; 245 break;
246 246
247 if (start & 0xfff) {
248 qla_printk(KERN_WARNING, ha,
249 "Invalid start region 0x%x/0x%x.\n", start, size);
250 return -EINVAL;
251 }
252
253 ha->optrom_region_start = start; 247 ha->optrom_region_start = start;
254 ha->optrom_region_size = start + size > ha->optrom_size ? 248 ha->optrom_region_size = start + size > ha->optrom_size ?
255 ha->optrom_size - start : size; 249 ha->optrom_size - start : size;
@@ -303,8 +297,7 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
303 else if (start == (ha->flt_region_boot * 4) || 297 else if (start == (ha->flt_region_boot * 4) ||
304 start == (ha->flt_region_fw * 4)) 298 start == (ha->flt_region_fw * 4))
305 valid = 1; 299 valid = 1;
306 else if ((IS_QLA25XX(ha) || IS_QLA81XX(ha)) && 300 else if (IS_QLA25XX(ha) || IS_QLA81XX(ha))
307 start == (ha->flt_region_vpd_nvram * 4))
308 valid = 1; 301 valid = 1;
309 if (!valid) { 302 if (!valid) {
310 qla_printk(KERN_WARNING, ha, 303 qla_printk(KERN_WARNING, ha,
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 986501759ad4..87f9abc71460 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1308,8 +1308,12 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
1308 1308
1309 DEBUG(printk("scsi(%ld): Issue init firmware.\n", vha->host_no)); 1309 DEBUG(printk("scsi(%ld): Issue init firmware.\n", vha->host_no));
1310 1310
1311 if (ha->flags.npiv_supported) 1311 if (ha->flags.npiv_supported) {
1312 if (ha->operating_mode == LOOP)
1313 ha->max_npiv_vports = MIN_MULTI_ID_FABRIC - 1;
1312 mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); 1314 mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports);
1315 }
1316
1313 1317
1314 mid_init_cb->options = __constant_cpu_to_le16(BIT_1); 1318 mid_init_cb->options = __constant_cpu_to_le16(BIT_1);
1315 1319
@@ -2610,6 +2614,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
2610 port_id_t wrap, nxt_d_id; 2614 port_id_t wrap, nxt_d_id;
2611 struct qla_hw_data *ha = vha->hw; 2615 struct qla_hw_data *ha = vha->hw;
2612 struct scsi_qla_host *vp, *base_vha = pci_get_drvdata(ha->pdev); 2616 struct scsi_qla_host *vp, *base_vha = pci_get_drvdata(ha->pdev);
2617 struct scsi_qla_host *tvp;
2613 2618
2614 rval = QLA_SUCCESS; 2619 rval = QLA_SUCCESS;
2615 2620
@@ -2709,7 +2714,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
2709 /* Bypass virtual ports of the same host. */ 2714 /* Bypass virtual ports of the same host. */
2710 found = 0; 2715 found = 0;
2711 if (ha->num_vhosts) { 2716 if (ha->num_vhosts) {
2712 list_for_each_entry(vp, &ha->vp_list, list) { 2717 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
2713 if (new_fcport->d_id.b24 == vp->d_id.b24) { 2718 if (new_fcport->d_id.b24 == vp->d_id.b24) {
2714 found = 1; 2719 found = 1;
2715 break; 2720 break;
@@ -2832,6 +2837,7 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev)
2832 uint16_t first_loop_id; 2837 uint16_t first_loop_id;
2833 struct qla_hw_data *ha = vha->hw; 2838 struct qla_hw_data *ha = vha->hw;
2834 struct scsi_qla_host *vp; 2839 struct scsi_qla_host *vp;
2840 struct scsi_qla_host *tvp;
2835 2841
2836 rval = QLA_SUCCESS; 2842 rval = QLA_SUCCESS;
2837 2843
@@ -2856,7 +2862,7 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev)
2856 /* Check for loop ID being already in use. */ 2862 /* Check for loop ID being already in use. */
2857 found = 0; 2863 found = 0;
2858 fcport = NULL; 2864 fcport = NULL;
2859 list_for_each_entry(vp, &ha->vp_list, list) { 2865 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
2860 list_for_each_entry(fcport, &vp->vp_fcports, list) { 2866 list_for_each_entry(fcport, &vp->vp_fcports, list) {
2861 if (fcport->loop_id == dev->loop_id && 2867 if (fcport->loop_id == dev->loop_id &&
2862 fcport != dev) { 2868 fcport != dev) {
@@ -3291,6 +3297,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
3291 uint8_t status = 0; 3297 uint8_t status = 0;
3292 struct qla_hw_data *ha = vha->hw; 3298 struct qla_hw_data *ha = vha->hw;
3293 struct scsi_qla_host *vp; 3299 struct scsi_qla_host *vp;
3300 struct scsi_qla_host *tvp;
3294 struct req_que *req = ha->req_q_map[0]; 3301 struct req_que *req = ha->req_q_map[0];
3295 3302
3296 if (vha->flags.online) { 3303 if (vha->flags.online) {
@@ -3306,7 +3313,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
3306 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { 3313 if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
3307 atomic_set(&vha->loop_state, LOOP_DOWN); 3314 atomic_set(&vha->loop_state, LOOP_DOWN);
3308 qla2x00_mark_all_devices_lost(vha, 0); 3315 qla2x00_mark_all_devices_lost(vha, 0);
3309 list_for_each_entry(vp, &ha->vp_list, list) 3316 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list)
3310 qla2x00_mark_all_devices_lost(vp, 0); 3317 qla2x00_mark_all_devices_lost(vp, 0);
3311 } else { 3318 } else {
3312 if (!atomic_read(&vha->loop_down_timer)) 3319 if (!atomic_read(&vha->loop_down_timer))
@@ -3403,7 +3410,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
3403 DEBUG(printk(KERN_INFO 3410 DEBUG(printk(KERN_INFO
3404 "qla2x00_abort_isp(%ld): succeeded.\n", 3411 "qla2x00_abort_isp(%ld): succeeded.\n",
3405 vha->host_no)); 3412 vha->host_no));
3406 list_for_each_entry(vp, &ha->vp_list, list) { 3413 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
3407 if (vp->vp_idx) 3414 if (vp->vp_idx)
3408 qla2x00_vp_abort_isp(vp); 3415 qla2x00_vp_abort_isp(vp);
3409 } 3416 }
@@ -3428,7 +3435,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
3428static int 3435static int
3429qla2x00_restart_isp(scsi_qla_host_t *vha) 3436qla2x00_restart_isp(scsi_qla_host_t *vha)
3430{ 3437{
3431 uint8_t status = 0; 3438 int status = 0;
3432 uint32_t wait_time; 3439 uint32_t wait_time;
3433 struct qla_hw_data *ha = vha->hw; 3440 struct qla_hw_data *ha = vha->hw;
3434 struct req_que *req = ha->req_q_map[0]; 3441 struct req_que *req = ha->req_q_map[0];
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 4c7504cb3990..4aab7acf7525 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -2685,6 +2685,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
2685 uint16_t stat = le16_to_cpu(rptid_entry->vp_idx); 2685 uint16_t stat = le16_to_cpu(rptid_entry->vp_idx);
2686 struct qla_hw_data *ha = vha->hw; 2686 struct qla_hw_data *ha = vha->hw;
2687 scsi_qla_host_t *vp; 2687 scsi_qla_host_t *vp;
2688 scsi_qla_host_t *tvp;
2688 2689
2689 if (rptid_entry->entry_status != 0) 2690 if (rptid_entry->entry_status != 0)
2690 return; 2691 return;
@@ -2710,7 +2711,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
2710 if (MSB(stat) == 1) 2711 if (MSB(stat) == 1)
2711 return; 2712 return;
2712 2713
2713 list_for_each_entry(vp, &ha->vp_list, list) 2714 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list)
2714 if (vp_idx == vp->vp_idx) 2715 if (vp_idx == vp->vp_idx)
2715 break; 2716 break;
2716 if (!vp) 2717 if (!vp)
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 3f23932210c4..785c61279e6e 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -69,9 +69,10 @@ static scsi_qla_host_t *
69qla24xx_find_vhost_by_name(struct qla_hw_data *ha, uint8_t *port_name) 69qla24xx_find_vhost_by_name(struct qla_hw_data *ha, uint8_t *port_name)
70{ 70{
71 scsi_qla_host_t *vha; 71 scsi_qla_host_t *vha;
72 struct scsi_qla_host *tvha;
72 73
73 /* Locate matching device in database. */ 74 /* Locate matching device in database. */
74 list_for_each_entry(vha, &ha->vp_list, list) { 75 list_for_each_entry_safe(vha, tvha, &ha->vp_list, list) {
75 if (!memcmp(port_name, vha->port_name, WWN_SIZE)) 76 if (!memcmp(port_name, vha->port_name, WWN_SIZE))
76 return vha; 77 return vha;
77 } 78 }
@@ -194,11 +195,11 @@ qla24xx_configure_vp(scsi_qla_host_t *vha)
194void 195void
195qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb) 196qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb)
196{ 197{
197 scsi_qla_host_t *vha; 198 scsi_qla_host_t *vha, *tvha;
198 struct qla_hw_data *ha = rsp->hw; 199 struct qla_hw_data *ha = rsp->hw;
199 int i = 0; 200 int i = 0;
200 201
201 list_for_each_entry(vha, &ha->vp_list, list) { 202 list_for_each_entry_safe(vha, tvha, &ha->vp_list, list) {
202 if (vha->vp_idx) { 203 if (vha->vp_idx) {
203 switch (mb[0]) { 204 switch (mb[0]) {
204 case MBA_LIP_OCCURRED: 205 case MBA_LIP_OCCURRED:
@@ -300,6 +301,7 @@ qla2x00_do_dpc_all_vps(scsi_qla_host_t *vha)
300 int ret; 301 int ret;
301 struct qla_hw_data *ha = vha->hw; 302 struct qla_hw_data *ha = vha->hw;
302 scsi_qla_host_t *vp; 303 scsi_qla_host_t *vp;
304 struct scsi_qla_host *tvp;
303 305
304 if (vha->vp_idx) 306 if (vha->vp_idx)
305 return; 307 return;
@@ -308,7 +310,7 @@ qla2x00_do_dpc_all_vps(scsi_qla_host_t *vha)
308 310
309 clear_bit(VP_DPC_NEEDED, &vha->dpc_flags); 311 clear_bit(VP_DPC_NEEDED, &vha->dpc_flags);
310 312
311 list_for_each_entry(vp, &ha->vp_list, list) { 313 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
312 if (vp->vp_idx) 314 if (vp->vp_idx)
313 ret = qla2x00_do_dpc_vp(vp); 315 ret = qla2x00_do_dpc_vp(vp);
314 } 316 }
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 2f5f72531e23..3ddfa889e949 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -2222,10 +2222,6 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
2222{ 2222{
2223 char name[16]; 2223 char name[16];
2224 2224
2225 ha->init_cb_size = sizeof(init_cb_t);
2226 if (IS_QLA2XXX_MIDTYPE(ha))
2227 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
2228
2229 ha->init_cb = dma_alloc_coherent(&ha->pdev->dev, ha->init_cb_size, 2225 ha->init_cb = dma_alloc_coherent(&ha->pdev->dev, ha->init_cb_size,
2230 &ha->init_cb_dma, GFP_KERNEL); 2226 &ha->init_cb_dma, GFP_KERNEL);
2231 if (!ha->init_cb) 2227 if (!ha->init_cb)
@@ -2568,7 +2564,7 @@ qla2x00_do_work(struct scsi_qla_host *vha)
2568void qla2x00_relogin(struct scsi_qla_host *vha) 2564void qla2x00_relogin(struct scsi_qla_host *vha)
2569{ 2565{
2570 fc_port_t *fcport; 2566 fc_port_t *fcport;
2571 uint8_t status; 2567 int status;
2572 uint16_t next_loopid = 0; 2568 uint16_t next_loopid = 0;
2573 struct qla_hw_data *ha = vha->hw; 2569 struct qla_hw_data *ha = vha->hw;
2574 2570
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 79f7053da99b..a772eab2f0ea 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.03.00-k3" 10#define QLA2XXX_VERSION "8.03.00-k4"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 3 13#define QLA_DRIVER_MINOR_VER 3
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 55310dbc10a6..4970ae4a62d6 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1167,23 +1167,19 @@ sd_spinup_disk(struct scsi_disk *sdkp)
1167 /* 1167 /*
1168 * The device does not want the automatic start to be issued. 1168 * The device does not want the automatic start to be issued.
1169 */ 1169 */
1170 if (sdkp->device->no_start_on_add) { 1170 if (sdkp->device->no_start_on_add)
1171 break; 1171 break;
1172 }
1173
1174 /*
1175 * If manual intervention is required, or this is an
1176 * absent USB storage device, a spinup is meaningless.
1177 */
1178 if (sense_valid &&
1179 sshdr.sense_key == NOT_READY &&
1180 sshdr.asc == 4 && sshdr.ascq == 3) {
1181 break; /* manual intervention required */
1182 1172
1183 /* 1173 if (sense_valid && sshdr.sense_key == NOT_READY) {
1184 * Issue command to spin up drive when not ready 1174 if (sshdr.asc == 4 && sshdr.ascq == 3)
1185 */ 1175 break; /* manual intervention required */
1186 } else if (sense_valid && sshdr.sense_key == NOT_READY) { 1176 if (sshdr.asc == 4 && sshdr.ascq == 0xb)
1177 break; /* standby */
1178 if (sshdr.asc == 4 && sshdr.ascq == 0xc)
1179 break; /* unavailable */
1180 /*
1181 * Issue command to spin up drive when not ready
1182 */
1187 if (!spintime) { 1183 if (!spintime) {
1188 sd_printk(KERN_NOTICE, sdkp, "Spinning up disk..."); 1184 sd_printk(KERN_NOTICE, sdkp, "Spinning up disk...");
1189 cmd[0] = START_STOP; 1185 cmd[0] = START_STOP;
diff --git a/drivers/scsi/zalon.c b/drivers/scsi/zalon.c
index a8d61a62522e..97f3158fa7b5 100644
--- a/drivers/scsi/zalon.c
+++ b/drivers/scsi/zalon.c
@@ -137,7 +137,7 @@ 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 dev_printk(KERN_ERR, dev, "irq problem with %d, detaching\n ", 140 dev_printk(KERN_ERR, &dev->dev, "irq problem with %d, detaching\n ",
141 dev->irq); 141 dev->irq);
142 goto fail; 142 goto fail;
143 } 143 }
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 557b54ab2f25..dbf5357a77b3 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -139,7 +139,7 @@ static void sci_poll_put_char(struct uart_port *port, unsigned char c)
139 } while (!(status & SCxSR_TDxE(port))); 139 } while (!(status & SCxSR_TDxE(port)));
140 140
141 sci_in(port, SCxSR); /* Dummy read */ 141 sci_in(port, SCxSR); /* Dummy read */
142 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); 142 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port) & ~SCxSR_TEND(port));
143 sci_out(port, SCxTDR, c); 143 sci_out(port, SCxTDR, c);
144} 144}
145#endif /* CONFIG_CONSOLE_POLL || CONFIG_SERIAL_SH_SCI_CONSOLE */ 145#endif /* CONFIG_CONSOLE_POLL || CONFIG_SERIAL_SH_SCI_CONSOLE */
@@ -263,6 +263,7 @@ static inline void sci_init_pins(struct uart_port *port, unsigned int cflag)
263#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 263#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \
264 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 264 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
265 defined(CONFIG_CPU_SUBTYPE_SH7785) || \ 265 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
266 defined(CONFIG_CPU_SUBTYPE_SH7786) || \
266 defined(CONFIG_CPU_SUBTYPE_SHX3) 267 defined(CONFIG_CPU_SUBTYPE_SHX3)
267static inline void sci_init_pins(struct uart_port *port, unsigned int cflag) 268static inline void sci_init_pins(struct uart_port *port, unsigned int cflag)
268{ 269{
@@ -284,7 +285,8 @@ static inline void sci_init_pins(struct uart_port *port, unsigned int cflag)
284 285
285#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ 286#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \
286 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 287 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
287 defined(CONFIG_CPU_SUBTYPE_SH7785) 288 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
289 defined(CONFIG_CPU_SUBTYPE_SH7786)
288static inline int scif_txroom(struct uart_port *port) 290static inline int scif_txroom(struct uart_port *port)
289{ 291{
290 return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff); 292 return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff);
@@ -1095,6 +1097,7 @@ static void serial_console_write(struct console *co, const char *s,
1095 unsigned count) 1097 unsigned count)
1096{ 1098{
1097 struct uart_port *port = &serial_console_port->port; 1099 struct uart_port *port = &serial_console_port->port;
1100 unsigned short bits;
1098 int i; 1101 int i;
1099 1102
1100 for (i = 0; i < count; i++) { 1103 for (i = 0; i < count; i++) {
@@ -1103,6 +1106,11 @@ static void serial_console_write(struct console *co, const char *s,
1103 1106
1104 sci_poll_put_char(port, *s++); 1107 sci_poll_put_char(port, *s++);
1105 } 1108 }
1109
1110 /* wait until fifo is empty and last bit has been transmitted */
1111 bits = SCxSR_TDxE(port) | SCxSR_TEND(port);
1112 while ((sci_in(port, SCxSR) & bits) != bits)
1113 cpu_relax();
1106} 1114}
1107 1115
1108static int __init serial_console_setup(struct console *co, char *options) 1116static int __init serial_console_setup(struct console *co, char *options)
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 022e89ffec1d..d0aa82d7fce0 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -1,6 +1,6 @@
1#include <linux/serial_core.h> 1#include <linux/serial_core.h>
2#include <asm/io.h> 2#include <asm/io.h>
3#include <asm/gpio.h> 3#include <linux/gpio.h>
4 4
5#if defined(CONFIG_H83007) || defined(CONFIG_H83068) 5#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
6#include <asm/regs306x.h> 6#include <asm/regs306x.h>
@@ -126,7 +126,8 @@
126# define SCSPTR1 0xffe10024 /* 16 bit SCIF */ 126# define SCSPTR1 0xffe10024 /* 16 bit SCIF */
127# define SCIF_ORER 0x0001 /* Overrun error bit */ 127# define SCIF_ORER 0x0001 /* Overrun error bit */
128# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 128# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
129#elif defined(CONFIG_CPU_SUBTYPE_SH7785) 129#elif defined(CONFIG_CPU_SUBTYPE_SH7785) || \
130 defined(CONFIG_CPU_SUBTYPE_SH7786)
130# define SCSPTR0 0xffea0024 /* 16 bit SCIF */ 131# define SCSPTR0 0xffea0024 /* 16 bit SCIF */
131# define SCSPTR1 0xffeb0024 /* 16 bit SCIF */ 132# define SCSPTR1 0xffeb0024 /* 16 bit SCIF */
132# define SCSPTR2 0xffec0024 /* 16 bit SCIF */ 133# define SCSPTR2 0xffec0024 /* 16 bit SCIF */
@@ -182,6 +183,7 @@
182 defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 183 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
183 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 184 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
184 defined(CONFIG_CPU_SUBTYPE_SH7785) || \ 185 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
186 defined(CONFIG_CPU_SUBTYPE_SH7786) || \
185 defined(CONFIG_CPU_SUBTYPE_SHX3) 187 defined(CONFIG_CPU_SUBTYPE_SHX3)
186#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ 188#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */
187#else 189#else
@@ -413,7 +415,8 @@ SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
413SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) 415SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
414#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ 416#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \
415 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 417 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
416 defined(CONFIG_CPU_SUBTYPE_SH7785) 418 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
419 defined(CONFIG_CPU_SUBTYPE_SH7786)
417SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) 420SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
418SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) 421SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
419SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) 422SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
@@ -644,7 +647,8 @@ static inline int sci_rxd_in(struct uart_port *port)
644 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ 647 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
645 return 1; 648 return 1;
646} 649}
647#elif defined(CONFIG_CPU_SUBTYPE_SH7785) 650#elif defined(CONFIG_CPU_SUBTYPE_SH7785) || \
651 defined(CONFIG_CPU_SUBTYPE_SH7786)
648static inline int sci_rxd_in(struct uart_port *port) 652static inline int sci_rxd_in(struct uart_port *port)
649{ 653{
650 if (port->mapbase == 0xffea0000) 654 if (port->mapbase == 0xffea0000)
@@ -746,7 +750,8 @@ static inline int sci_rxd_in(struct uart_port *port)
746 */ 750 */
747 751
748#if defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 752#if defined(CONFIG_CPU_SUBTYPE_SH7780) || \
749 defined(CONFIG_CPU_SUBTYPE_SH7785) 753 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
754 defined(CONFIG_CPU_SUBTYPE_SH7786)
750#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) 755#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
751#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 756#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
752 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 757 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 45a299f35617..e09d3cebb4fb 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1438,12 +1438,12 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m
1438 } else { 1438 } else {
1439 printk(KERN_INFO "%s: Keyboard at MMIO 0x%llx (irq = %d) " 1439 printk(KERN_INFO "%s: Keyboard at MMIO 0x%llx (irq = %d) "
1440 "is a %s\n", 1440 "is a %s\n",
1441 op->dev.bus_id, 1441 dev_name(&op->dev),
1442 (unsigned long long) up[0].port.mapbase, 1442 (unsigned long long) up[0].port.mapbase,
1443 op->irqs[0], sunzilog_type(&up[0].port)); 1443 op->irqs[0], sunzilog_type(&up[0].port));
1444 printk(KERN_INFO "%s: Mouse at MMIO 0x%llx (irq = %d) " 1444 printk(KERN_INFO "%s: Mouse at MMIO 0x%llx (irq = %d) "
1445 "is a %s\n", 1445 "is a %s\n",
1446 op->dev.bus_id, 1446 dev_name(&op->dev),
1447 (unsigned long long) up[1].port.mapbase, 1447 (unsigned long long) up[1].port.mapbase,
1448 op->irqs[0], sunzilog_type(&up[1].port)); 1448 op->irqs[0], sunzilog_type(&up[1].port));
1449 kbm_inst++; 1449 kbm_inst++;
diff --git a/drivers/sh/intc.c b/drivers/sh/intc.c
index 58d24c5a76ce..2269fbcaa182 100644
--- a/drivers/sh/intc.c
+++ b/drivers/sh/intc.c
@@ -568,6 +568,10 @@ static void __init intc_register_irq(struct intc_desc *desc,
568 if (!data[0] && data[1]) 568 if (!data[0] && data[1])
569 primary = 1; 569 primary = 1;
570 570
571 if (!data[0] && !data[1])
572 pr_warning("intc: missing unique irq mask for "
573 "irq %d (vect 0x%04x)\n", irq, irq2evt(irq));
574
571 data[0] = data[0] ? data[0] : intc_mask_data(desc, d, enum_id, 1); 575 data[0] = data[0] ? data[0] : intc_mask_data(desc, d, enum_id, 1);
572 data[1] = data[1] ? data[1] : intc_prio_data(desc, d, enum_id, 1); 576 data[1] = data[1] ? data[1] : intc_prio_data(desc, d, enum_id, 1);
573 577
@@ -641,6 +645,17 @@ static unsigned int __init save_reg(struct intc_desc_int *d,
641 return 0; 645 return 0;
642} 646}
643 647
648static unsigned char *intc_evt2irq_table;
649
650unsigned int intc_evt2irq(unsigned int vector)
651{
652 unsigned int irq = evt2irq(vector);
653
654 if (intc_evt2irq_table && intc_evt2irq_table[irq])
655 irq = intc_evt2irq_table[irq];
656
657 return irq;
658}
644 659
645void __init register_intc_controller(struct intc_desc *desc) 660void __init register_intc_controller(struct intc_desc *desc)
646{ 661{
@@ -705,9 +720,41 @@ void __init register_intc_controller(struct intc_desc *desc)
705 720
706 BUG_ON(k > 256); /* _INTC_ADDR_E() and _INTC_ADDR_D() are 8 bits */ 721 BUG_ON(k > 256); /* _INTC_ADDR_E() and _INTC_ADDR_D() are 8 bits */
707 722
723 /* keep the first vector only if same enum is used multiple times */
724 for (i = 0; i < desc->nr_vectors; i++) {
725 struct intc_vect *vect = desc->vectors + i;
726 int first_irq = evt2irq(vect->vect);
727
728 if (!vect->enum_id)
729 continue;
730
731 for (k = i + 1; k < desc->nr_vectors; k++) {
732 struct intc_vect *vect2 = desc->vectors + k;
733
734 if (vect->enum_id != vect2->enum_id)
735 continue;
736
737 vect2->enum_id = 0;
738
739 if (!intc_evt2irq_table)
740 intc_evt2irq_table = alloc_bootmem(NR_IRQS);
741
742 if (!intc_evt2irq_table) {
743 pr_warning("intc: cannot allocate evt2irq!\n");
744 continue;
745 }
746
747 intc_evt2irq_table[evt2irq(vect2->vect)] = first_irq;
748 }
749 }
750
751 /* register the vectors one by one */
708 for (i = 0; i < desc->nr_vectors; i++) { 752 for (i = 0; i < desc->nr_vectors; i++) {
709 struct intc_vect *vect = desc->vectors + i; 753 struct intc_vect *vect = desc->vectors + i;
710 754
755 if (!vect->enum_id)
756 continue;
757
711 intc_register_irq(desc, d, vect->enum_id, evt2irq(vect->vect)); 758 intc_register_irq(desc, d, vect->enum_id, evt2irq(vect->vect));
712 } 759 }
713} 760}
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 63f0de29aa14..cab1ab7cfb78 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -1,16 +1,10 @@
1/* 1/*
2 * Core maple bus functionality 2 * Core maple bus functionality
3 * 3 *
4 * Copyright (C) 2007, 2008 Adrian McMenamin 4 * Copyright (C) 2007 - 2009 Adrian McMenamin
5 * Copyright (C) 2001 - 2008 Paul Mundt 5 * Copyright (C) 2001 - 2008 Paul Mundt
6 * 6 * Copyright (C) 2000 - 2001 YAEGASHI Takeshi
7 * Based on 2.4 code by:
8 *
9 * Copyright (C) 2000-2001 YAEGASHI Takeshi
10 * Copyright (C) 2001 M. R. Brown 7 * Copyright (C) 2001 M. R. Brown
11 * Copyright (C) 2001 Paul Mundt
12 *
13 * and others.
14 * 8 *
15 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
@@ -32,7 +26,7 @@
32#include <mach/dma.h> 26#include <mach/dma.h>
33#include <mach/sysasic.h> 27#include <mach/sysasic.h>
34 28
35MODULE_AUTHOR("Yaegashi Takeshi, Paul Mundt, M. R. Brown, Adrian McMenamin"); 29MODULE_AUTHOR("Adrian McMenamin <adrian@mcmen.demon.co.uk>");
36MODULE_DESCRIPTION("Maple bus driver for Dreamcast"); 30MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
37MODULE_LICENSE("GPL v2"); 31MODULE_LICENSE("GPL v2");
38MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}"); 32MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}");
@@ -49,7 +43,7 @@ static LIST_HEAD(maple_sentq);
49/* mutex to protect queue of waiting packets */ 43/* mutex to protect queue of waiting packets */
50static DEFINE_MUTEX(maple_wlist_lock); 44static DEFINE_MUTEX(maple_wlist_lock);
51 45
52static struct maple_driver maple_dummy_driver; 46static struct maple_driver maple_unsupported_device;
53static struct device maple_bus; 47static struct device maple_bus;
54static int subdevice_map[MAPLE_PORTS]; 48static int subdevice_map[MAPLE_PORTS];
55static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr; 49static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
@@ -62,8 +56,9 @@ struct maple_device_specify {
62 int unit; 56 int unit;
63}; 57};
64 58
65static bool checked[4]; 59static bool checked[MAPLE_PORTS];
66static struct maple_device *baseunits[4]; 60static bool empty[MAPLE_PORTS];
61static struct maple_device *baseunits[MAPLE_PORTS];
67 62
68/** 63/**
69 * maple_driver_register - register a maple driver 64 * maple_driver_register - register a maple driver
@@ -97,12 +92,20 @@ void maple_driver_unregister(struct maple_driver *drv)
97EXPORT_SYMBOL_GPL(maple_driver_unregister); 92EXPORT_SYMBOL_GPL(maple_driver_unregister);
98 93
99/* set hardware registers to enable next round of dma */ 94/* set hardware registers to enable next round of dma */
100static void maplebus_dma_reset(void) 95static void maple_dma_reset(void)
101{ 96{
102 ctrl_outl(MAPLE_MAGIC, MAPLE_RESET); 97 ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
103 /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */ 98 /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
104 ctrl_outl(1, MAPLE_TRIGTYPE); 99 ctrl_outl(1, MAPLE_TRIGTYPE);
105 ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(50000), MAPLE_SPEED); 100 /*
101 * Maple system register
102 * bits 31 - 16 timeout in units of 20nsec
103 * bit 12 hard trigger - set 0 to keep responding to VBLANK
104 * bits 9 - 8 set 00 for 2 Mbps, 01 for 1 Mbps
105 * bits 3 - 0 delay (in 1.3ms) between VBLANK and start of DMA
106 * max delay is 11
107 */
108 ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(0xFFFF), MAPLE_SPEED);
106 ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR); 109 ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
107 ctrl_outl(1, MAPLE_ENABLE); 110 ctrl_outl(1, MAPLE_ENABLE);
108} 111}
@@ -134,21 +137,16 @@ static void maple_release_device(struct device *dev)
134{ 137{
135 struct maple_device *mdev; 138 struct maple_device *mdev;
136 struct mapleq *mq; 139 struct mapleq *mq;
137 if (!dev) 140
138 return;
139 mdev = to_maple_dev(dev); 141 mdev = to_maple_dev(dev);
140 mq = mdev->mq; 142 mq = mdev->mq;
141 if (mq) { 143 kmem_cache_free(maple_queue_cache, mq->recvbuf);
142 if (mq->recvbufdcsp) 144 kfree(mq);
143 kmem_cache_free(maple_queue_cache, mq->recvbufdcsp);
144 kfree(mq);
145 mq = NULL;
146 }
147 kfree(mdev); 145 kfree(mdev);
148} 146}
149 147
150/** 148/**
151 * maple_add_packet - add a single instruction to the queue 149 * maple_add_packet - add a single instruction to the maple bus queue
152 * @mdev: maple device 150 * @mdev: maple device
153 * @function: function on device being queried 151 * @function: function on device being queried
154 * @command: maple command to add 152 * @command: maple command to add
@@ -158,68 +156,12 @@ static void maple_release_device(struct device *dev)
158int maple_add_packet(struct maple_device *mdev, u32 function, u32 command, 156int maple_add_packet(struct maple_device *mdev, u32 function, u32 command,
159 size_t length, void *data) 157 size_t length, void *data)
160{ 158{
161 int locking, ret = 0; 159 int ret = 0;
162 void *sendbuf = NULL; 160 void *sendbuf = NULL;
163 161
164 mutex_lock(&maple_wlist_lock);
165 /* bounce if device already locked */
166 locking = mutex_is_locked(&mdev->mq->mutex);
167 if (locking) {
168 ret = -EBUSY;
169 goto out;
170 }
171
172 mutex_lock(&mdev->mq->mutex);
173
174 if (length) { 162 if (length) {
175 sendbuf = kmalloc(length * 4, GFP_KERNEL); 163 sendbuf = kzalloc(length * 4, GFP_KERNEL);
176 if (!sendbuf) { 164 if (!sendbuf) {
177 mutex_unlock(&mdev->mq->mutex);
178 ret = -ENOMEM;
179 goto out;
180 }
181 ((__be32 *)sendbuf)[0] = cpu_to_be32(function);
182 }
183
184 mdev->mq->command = command;
185 mdev->mq->length = length;
186 if (length > 1)
187 memcpy(sendbuf + 4, data, (length - 1) * 4);
188 mdev->mq->sendbuf = sendbuf;
189
190 list_add(&mdev->mq->list, &maple_waitq);
191out:
192 mutex_unlock(&maple_wlist_lock);
193 return ret;
194}
195EXPORT_SYMBOL_GPL(maple_add_packet);
196
197/**
198 * maple_add_packet_sleeps - add a single instruction to the queue
199 * @mdev: maple device
200 * @function: function on device being queried
201 * @command: maple command to add
202 * @length: length of command string (in 32 bit words)
203 * @data: remainder of command string
204 *
205 * Same as maple_add_packet(), but waits for the lock to become free.
206 */
207int maple_add_packet_sleeps(struct maple_device *mdev, u32 function,
208 u32 command, size_t length, void *data)
209{
210 int locking, ret = 0;
211 void *sendbuf = NULL;
212
213 locking = mutex_lock_interruptible(&mdev->mq->mutex);
214 if (locking) {
215 ret = -EIO;
216 goto out;
217 }
218
219 if (length) {
220 sendbuf = kmalloc(length * 4, GFP_KERNEL);
221 if (!sendbuf) {
222 mutex_unlock(&mdev->mq->mutex);
223 ret = -ENOMEM; 165 ret = -ENOMEM;
224 goto out; 166 goto out;
225 } 167 }
@@ -233,38 +175,35 @@ int maple_add_packet_sleeps(struct maple_device *mdev, u32 function,
233 mdev->mq->sendbuf = sendbuf; 175 mdev->mq->sendbuf = sendbuf;
234 176
235 mutex_lock(&maple_wlist_lock); 177 mutex_lock(&maple_wlist_lock);
236 list_add(&mdev->mq->list, &maple_waitq); 178 list_add_tail(&mdev->mq->list, &maple_waitq);
237 mutex_unlock(&maple_wlist_lock); 179 mutex_unlock(&maple_wlist_lock);
238out: 180out:
239 return ret; 181 return ret;
240} 182}
241EXPORT_SYMBOL_GPL(maple_add_packet_sleeps); 183EXPORT_SYMBOL_GPL(maple_add_packet);
242 184
243static struct mapleq *maple_allocq(struct maple_device *mdev) 185static struct mapleq *maple_allocq(struct maple_device *mdev)
244{ 186{
245 struct mapleq *mq; 187 struct mapleq *mq;
246 188
247 mq = kmalloc(sizeof(*mq), GFP_KERNEL); 189 mq = kzalloc(sizeof(*mq), GFP_KERNEL);
248 if (!mq) 190 if (!mq)
249 goto failed_nomem; 191 goto failed_nomem;
250 192
193 INIT_LIST_HEAD(&mq->list);
251 mq->dev = mdev; 194 mq->dev = mdev;
252 mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL); 195 mq->recvbuf = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
253 mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
254 if (!mq->recvbuf) 196 if (!mq->recvbuf)
255 goto failed_p2; 197 goto failed_p2;
256 /* 198 mq->recvbuf->buf = &((mq->recvbuf->bufx)[0]);
257 * most devices do not need the mutex - but
258 * anything that injects block reads or writes
259 * will rely on it
260 */
261 mutex_init(&mq->mutex);
262 199
263 return mq; 200 return mq;
264 201
265failed_p2: 202failed_p2:
266 kfree(mq); 203 kfree(mq);
267failed_nomem: 204failed_nomem:
205 dev_err(&mdev->dev, "could not allocate memory for device (%d, %d)\n",
206 mdev->port, mdev->unit);
268 return NULL; 207 return NULL;
269} 208}
270 209
@@ -272,12 +211,16 @@ static struct maple_device *maple_alloc_dev(int port, int unit)
272{ 211{
273 struct maple_device *mdev; 212 struct maple_device *mdev;
274 213
214 /* zero this out to avoid kobj subsystem
215 * thinking it has already been registered */
216
275 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); 217 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
276 if (!mdev) 218 if (!mdev)
277 return NULL; 219 return NULL;
278 220
279 mdev->port = port; 221 mdev->port = port;
280 mdev->unit = unit; 222 mdev->unit = unit;
223
281 mdev->mq = maple_allocq(mdev); 224 mdev->mq = maple_allocq(mdev);
282 225
283 if (!mdev->mq) { 226 if (!mdev->mq) {
@@ -286,19 +229,14 @@ static struct maple_device *maple_alloc_dev(int port, int unit)
286 } 229 }
287 mdev->dev.bus = &maple_bus_type; 230 mdev->dev.bus = &maple_bus_type;
288 mdev->dev.parent = &maple_bus; 231 mdev->dev.parent = &maple_bus;
232 init_waitqueue_head(&mdev->maple_wait);
289 return mdev; 233 return mdev;
290} 234}
291 235
292static void maple_free_dev(struct maple_device *mdev) 236static void maple_free_dev(struct maple_device *mdev)
293{ 237{
294 if (!mdev) 238 kmem_cache_free(maple_queue_cache, mdev->mq->recvbuf);
295 return; 239 kfree(mdev->mq);
296 if (mdev->mq) {
297 if (mdev->mq->recvbufdcsp)
298 kmem_cache_free(maple_queue_cache,
299 mdev->mq->recvbufdcsp);
300 kfree(mdev->mq);
301 }
302 kfree(mdev); 240 kfree(mdev);
303} 241}
304 242
@@ -320,7 +258,7 @@ static void maple_build_block(struct mapleq *mq)
320 maple_lastptr = maple_sendptr; 258 maple_lastptr = maple_sendptr;
321 259
322 *maple_sendptr++ = (port << 16) | len | 0x80000000; 260 *maple_sendptr++ = (port << 16) | len | 0x80000000;
323 *maple_sendptr++ = PHYSADDR(mq->recvbuf); 261 *maple_sendptr++ = PHYSADDR(mq->recvbuf->buf);
324 *maple_sendptr++ = 262 *maple_sendptr++ =
325 mq->command | (to << 8) | (from << 16) | (len << 24); 263 mq->command | (to << 8) | (from << 16) | (len << 24);
326 while (len-- > 0) 264 while (len-- > 0)
@@ -333,20 +271,28 @@ static void maple_send(void)
333 int i, maple_packets = 0; 271 int i, maple_packets = 0;
334 struct mapleq *mq, *nmq; 272 struct mapleq *mq, *nmq;
335 273
336 if (!list_empty(&maple_sentq)) 274 if (!maple_dma_done())
337 return; 275 return;
276
277 /* disable DMA */
278 ctrl_outl(0, MAPLE_ENABLE);
279
280 if (!list_empty(&maple_sentq))
281 goto finish;
282
338 mutex_lock(&maple_wlist_lock); 283 mutex_lock(&maple_wlist_lock);
339 if (list_empty(&maple_waitq) || !maple_dma_done()) { 284 if (list_empty(&maple_waitq)) {
340 mutex_unlock(&maple_wlist_lock); 285 mutex_unlock(&maple_wlist_lock);
341 return; 286 goto finish;
342 } 287 }
343 mutex_unlock(&maple_wlist_lock); 288
344 maple_lastptr = maple_sendbuf; 289 maple_lastptr = maple_sendbuf;
345 maple_sendptr = maple_sendbuf; 290 maple_sendptr = maple_sendbuf;
346 mutex_lock(&maple_wlist_lock); 291
347 list_for_each_entry_safe(mq, nmq, &maple_waitq, list) { 292 list_for_each_entry_safe(mq, nmq, &maple_waitq, list) {
348 maple_build_block(mq); 293 maple_build_block(mq);
349 list_move(&mq->list, &maple_sentq); 294 list_del_init(&mq->list);
295 list_add_tail(&mq->list, &maple_sentq);
350 if (maple_packets++ > MAPLE_MAXPACKETS) 296 if (maple_packets++ > MAPLE_MAXPACKETS)
351 break; 297 break;
352 } 298 }
@@ -356,10 +302,13 @@ static void maple_send(void)
356 dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE, 302 dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE,
357 PAGE_SIZE, DMA_BIDIRECTIONAL); 303 PAGE_SIZE, DMA_BIDIRECTIONAL);
358 } 304 }
305
306finish:
307 maple_dma_reset();
359} 308}
360 309
361/* check if there is a driver registered likely to match this device */ 310/* check if there is a driver registered likely to match this device */
362static int check_matching_maple_driver(struct device_driver *driver, 311static int maple_check_matching_driver(struct device_driver *driver,
363 void *devptr) 312 void *devptr)
364{ 313{
365 struct maple_driver *maple_drv; 314 struct maple_driver *maple_drv;
@@ -374,10 +323,7 @@ static int check_matching_maple_driver(struct device_driver *driver,
374 323
375static void maple_detach_driver(struct maple_device *mdev) 324static void maple_detach_driver(struct maple_device *mdev)
376{ 325{
377 if (!mdev)
378 return;
379 device_unregister(&mdev->dev); 326 device_unregister(&mdev->dev);
380 mdev = NULL;
381} 327}
382 328
383/* process initial MAPLE_COMMAND_DEVINFO for each device or port */ 329/* process initial MAPLE_COMMAND_DEVINFO for each device or port */
@@ -385,9 +331,9 @@ static void maple_attach_driver(struct maple_device *mdev)
385{ 331{
386 char *p, *recvbuf; 332 char *p, *recvbuf;
387 unsigned long function; 333 unsigned long function;
388 int matched, retval; 334 int matched, error;
389 335
390 recvbuf = mdev->mq->recvbuf; 336 recvbuf = mdev->mq->recvbuf->buf;
391 /* copy the data as individual elements in 337 /* copy the data as individual elements in
392 * case of memory optimisation */ 338 * case of memory optimisation */
393 memcpy(&mdev->devinfo.function, recvbuf + 4, 4); 339 memcpy(&mdev->devinfo.function, recvbuf + 4, 4);
@@ -395,7 +341,6 @@ static void maple_attach_driver(struct maple_device *mdev)
395 memcpy(&mdev->devinfo.area_code, recvbuf + 20, 1); 341 memcpy(&mdev->devinfo.area_code, recvbuf + 20, 1);
396 memcpy(&mdev->devinfo.connector_direction, recvbuf + 21, 1); 342 memcpy(&mdev->devinfo.connector_direction, recvbuf + 21, 1);
397 memcpy(&mdev->devinfo.product_name[0], recvbuf + 22, 30); 343 memcpy(&mdev->devinfo.product_name[0], recvbuf + 22, 30);
398 memcpy(&mdev->devinfo.product_licence[0], recvbuf + 52, 60);
399 memcpy(&mdev->devinfo.standby_power, recvbuf + 112, 2); 344 memcpy(&mdev->devinfo.standby_power, recvbuf + 112, 2);
400 memcpy(&mdev->devinfo.max_power, recvbuf + 114, 2); 345 memcpy(&mdev->devinfo.max_power, recvbuf + 114, 2);
401 memcpy(mdev->product_name, mdev->devinfo.product_name, 30); 346 memcpy(mdev->product_name, mdev->devinfo.product_name, 30);
@@ -414,43 +359,39 @@ static void maple_attach_driver(struct maple_device *mdev)
414 else 359 else
415 break; 360 break;
416 361
417 printk(KERN_INFO "Maple device detected: %s\n",
418 mdev->product_name);
419 printk(KERN_INFO "Maple device: %s\n", mdev->product_licence);
420
421 function = be32_to_cpu(mdev->devinfo.function); 362 function = be32_to_cpu(mdev->devinfo.function);
422 363
364 dev_info(&mdev->dev, "detected %s: function 0x%lX: at (%d, %d)\n",
365 mdev->product_name, function, mdev->port, mdev->unit);
366
423 if (function > 0x200) { 367 if (function > 0x200) {
424 /* Do this silently - as not a real device */ 368 /* Do this silently - as not a real device */
425 function = 0; 369 function = 0;
426 mdev->driver = &maple_dummy_driver; 370 mdev->driver = &maple_unsupported_device;
427 sprintf(mdev->dev.bus_id, "%d:0.port", mdev->port); 371 dev_set_name(&mdev->dev, "%d:0.port", mdev->port);
428 } else { 372 } else {
429 printk(KERN_INFO
430 "Maple bus at (%d, %d): Function 0x%lX\n",
431 mdev->port, mdev->unit, function);
432
433 matched = 373 matched =
434 bus_for_each_drv(&maple_bus_type, NULL, mdev, 374 bus_for_each_drv(&maple_bus_type, NULL, mdev,
435 check_matching_maple_driver); 375 maple_check_matching_driver);
436 376
437 if (matched == 0) { 377 if (matched == 0) {
438 /* Driver does not exist yet */ 378 /* Driver does not exist yet */
439 printk(KERN_INFO 379 dev_info(&mdev->dev, "no driver found\n");
440 "No maple driver found.\n"); 380 mdev->driver = &maple_unsupported_device;
441 mdev->driver = &maple_dummy_driver;
442 } 381 }
443 sprintf(mdev->dev.bus_id, "%d:0%d.%lX", mdev->port, 382 dev_set_name(&mdev->dev, "%d:0%d.%lX", mdev->port,
444 mdev->unit, function); 383 mdev->unit, function);
445 } 384 }
385
446 mdev->function = function; 386 mdev->function = function;
447 mdev->dev.release = &maple_release_device; 387 mdev->dev.release = &maple_release_device;
448 retval = device_register(&mdev->dev); 388
449 if (retval) { 389 atomic_set(&mdev->busy, 0);
450 printk(KERN_INFO 390 error = device_register(&mdev->dev);
451 "Maple bus: Attempt to register device" 391 if (error) {
452 " (%x, %x) failed.\n", 392 dev_warn(&mdev->dev, "could not register device at"
453 mdev->port, mdev->unit); 393 " (%d, %d), with error 0x%X\n", mdev->unit,
394 mdev->port, error);
454 maple_free_dev(mdev); 395 maple_free_dev(mdev);
455 mdev = NULL; 396 mdev = NULL;
456 return; 397 return;
@@ -462,7 +403,7 @@ static void maple_attach_driver(struct maple_device *mdev)
462 * port and unit then return 1 - allows identification 403 * port and unit then return 1 - allows identification
463 * of which devices need to be attached or detached 404 * of which devices need to be attached or detached
464 */ 405 */
465static int detach_maple_device(struct device *device, void *portptr) 406static int check_maple_device(struct device *device, void *portptr)
466{ 407{
467 struct maple_device_specify *ds; 408 struct maple_device_specify *ds;
468 struct maple_device *mdev; 409 struct maple_device *mdev;
@@ -477,21 +418,25 @@ static int detach_maple_device(struct device *device, void *portptr)
477static int setup_maple_commands(struct device *device, void *ignored) 418static int setup_maple_commands(struct device *device, void *ignored)
478{ 419{
479 int add; 420 int add;
480 struct maple_device *maple_dev = to_maple_dev(device); 421 struct maple_device *mdev = to_maple_dev(device);
481 422 if (mdev->interval > 0 && atomic_read(&mdev->busy) == 0 &&
482 if ((maple_dev->interval > 0) 423 time_after(jiffies, mdev->when)) {
483 && time_after(jiffies, maple_dev->when)) { 424 /* bounce if we cannot add */
484 /* bounce if we cannot lock */ 425 add = maple_add_packet(mdev,
485 add = maple_add_packet(maple_dev, 426 be32_to_cpu(mdev->devinfo.function),
486 be32_to_cpu(maple_dev->devinfo.function),
487 MAPLE_COMMAND_GETCOND, 1, NULL); 427 MAPLE_COMMAND_GETCOND, 1, NULL);
488 if (!add) 428 if (!add)
489 maple_dev->when = jiffies + maple_dev->interval; 429 mdev->when = jiffies + mdev->interval;
490 } else { 430 } else {
491 if (time_after(jiffies, maple_pnp_time)) 431 if (time_after(jiffies, maple_pnp_time))
492 /* This will also bounce */ 432 /* Ensure we don't have block reads and devinfo
493 maple_add_packet(maple_dev, 0, 433 * calls interfering with one another - so flag the
494 MAPLE_COMMAND_DEVINFO, 0, NULL); 434 * device as busy */
435 if (atomic_read(&mdev->busy) == 0) {
436 atomic_set(&mdev->busy, 1);
437 maple_add_packet(mdev, 0,
438 MAPLE_COMMAND_DEVINFO, 0, NULL);
439 }
495 } 440 }
496 return 0; 441 return 0;
497} 442}
@@ -499,29 +444,50 @@ static int setup_maple_commands(struct device *device, void *ignored)
499/* VBLANK bottom half - implemented via workqueue */ 444/* VBLANK bottom half - implemented via workqueue */
500static void maple_vblank_handler(struct work_struct *work) 445static void maple_vblank_handler(struct work_struct *work)
501{ 446{
502 if (!list_empty(&maple_sentq) || !maple_dma_done()) 447 int x, locking;
448 struct maple_device *mdev;
449
450 if (!maple_dma_done())
503 return; 451 return;
504 452
505 ctrl_outl(0, MAPLE_ENABLE); 453 ctrl_outl(0, MAPLE_ENABLE);
506 454
455 if (!list_empty(&maple_sentq))
456 goto finish;
457
458 /*
459 * Set up essential commands - to fetch data and
460 * check devices are still present
461 */
507 bus_for_each_dev(&maple_bus_type, NULL, NULL, 462 bus_for_each_dev(&maple_bus_type, NULL, NULL,
508 setup_maple_commands); 463 setup_maple_commands);
464
465 if (time_after(jiffies, maple_pnp_time)) {
466 /*
467 * Scan the empty ports - bus is flakey and may have
468 * mis-reported emptyness
469 */
470 for (x = 0; x < MAPLE_PORTS; x++) {
471 if (checked[x] && empty[x]) {
472 mdev = baseunits[x];
473 if (!mdev)
474 break;
475 atomic_set(&mdev->busy, 1);
476 locking = maple_add_packet(mdev, 0,
477 MAPLE_COMMAND_DEVINFO, 0, NULL);
478 if (!locking)
479 break;
480 }
481 }
509 482
510 if (time_after(jiffies, maple_pnp_time))
511 maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL; 483 maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL;
512
513 mutex_lock(&maple_wlist_lock);
514 if (!list_empty(&maple_waitq) && list_empty(&maple_sentq)) {
515 mutex_unlock(&maple_wlist_lock);
516 maple_send();
517 } else {
518 mutex_unlock(&maple_wlist_lock);
519 } 484 }
520 485
521 maplebus_dma_reset(); 486finish:
487 maple_send();
522} 488}
523 489
524/* handle devices added via hotplugs - placing them on queue for DEVINFO*/ 490/* handle devices added via hotplugs - placing them on queue for DEVINFO */
525static void maple_map_subunits(struct maple_device *mdev, int submask) 491static void maple_map_subunits(struct maple_device *mdev, int submask)
526{ 492{
527 int retval, k, devcheck; 493 int retval, k, devcheck;
@@ -533,7 +499,7 @@ static void maple_map_subunits(struct maple_device *mdev, int submask)
533 ds.unit = k + 1; 499 ds.unit = k + 1;
534 retval = 500 retval =
535 bus_for_each_dev(&maple_bus_type, NULL, &ds, 501 bus_for_each_dev(&maple_bus_type, NULL, &ds,
536 detach_maple_device); 502 check_maple_device);
537 if (retval) { 503 if (retval) {
538 submask = submask >> 1; 504 submask = submask >> 1;
539 continue; 505 continue;
@@ -543,6 +509,7 @@ static void maple_map_subunits(struct maple_device *mdev, int submask)
543 mdev_add = maple_alloc_dev(mdev->port, k + 1); 509 mdev_add = maple_alloc_dev(mdev->port, k + 1);
544 if (!mdev_add) 510 if (!mdev_add)
545 return; 511 return;
512 atomic_set(&mdev_add->busy, 1);
546 maple_add_packet(mdev_add, 0, MAPLE_COMMAND_DEVINFO, 513 maple_add_packet(mdev_add, 0, MAPLE_COMMAND_DEVINFO,
547 0, NULL); 514 0, NULL);
548 /* mark that we are checking sub devices */ 515 /* mark that we are checking sub devices */
@@ -564,27 +531,45 @@ static void maple_clean_submap(struct maple_device *mdev)
564} 531}
565 532
566/* handle empty port or hotplug removal */ 533/* handle empty port or hotplug removal */
567static void maple_response_none(struct maple_device *mdev, 534static void maple_response_none(struct maple_device *mdev)
568 struct mapleq *mq) 535{
569{ 536 maple_clean_submap(mdev);
570 if (mdev->unit != 0) { 537
571 list_del(&mq->list); 538 if (likely(mdev->unit != 0)) {
572 maple_clean_submap(mdev); 539 /*
573 printk(KERN_INFO 540 * Block devices play up
574 "Maple bus device detaching at (%d, %d)\n", 541 * and give the impression they have
575 mdev->port, mdev->unit); 542 * been removed even when still in place or
543 * trip the mtd layer when they have
544 * really gone - this code traps that eventuality
545 * and ensures we aren't overloaded with useless
546 * error messages
547 */
548 if (mdev->can_unload) {
549 if (!mdev->can_unload(mdev)) {
550 atomic_set(&mdev->busy, 2);
551 wake_up(&mdev->maple_wait);
552 return;
553 }
554 }
555
556 dev_info(&mdev->dev, "detaching device at (%d, %d)\n",
557 mdev->port, mdev->unit);
576 maple_detach_driver(mdev); 558 maple_detach_driver(mdev);
577 return; 559 return;
578 } 560 } else {
579 if (!started || !fullscan) { 561 if (!started || !fullscan) {
580 if (checked[mdev->port] == false) { 562 if (checked[mdev->port] == false) {
581 checked[mdev->port] = true; 563 checked[mdev->port] = true;
582 printk(KERN_INFO "No maple devices attached" 564 empty[mdev->port] = true;
583 " to port %d\n", mdev->port); 565 dev_info(&mdev->dev, "no devices"
566 " to port %d\n", mdev->port);
567 }
568 return;
584 } 569 }
585 return;
586 } 570 }
587 maple_clean_submap(mdev); 571 /* Some hardware devices generate false detach messages on unit 0 */
572 atomic_set(&mdev->busy, 0);
588} 573}
589 574
590/* preprocess hotplugs or scans */ 575/* preprocess hotplugs or scans */
@@ -599,8 +584,11 @@ static void maple_response_devinfo(struct maple_device *mdev,
599 } else { 584 } else {
600 if (mdev->unit != 0) 585 if (mdev->unit != 0)
601 maple_attach_driver(mdev); 586 maple_attach_driver(mdev);
587 if (mdev->unit == 0) {
588 empty[mdev->port] = false;
589 maple_attach_driver(mdev);
590 }
602 } 591 }
603 return;
604 } 592 }
605 if (mdev->unit == 0) { 593 if (mdev->unit == 0) {
606 submask = recvbuf[2] & 0x1F; 594 submask = recvbuf[2] & 0x1F;
@@ -611,6 +599,17 @@ static void maple_response_devinfo(struct maple_device *mdev,
611 } 599 }
612} 600}
613 601
602static void maple_response_fileerr(struct maple_device *mdev, void *recvbuf)
603{
604 if (mdev->fileerr_handler) {
605 mdev->fileerr_handler(mdev, recvbuf);
606 return;
607 } else
608 dev_warn(&mdev->dev, "device at (%d, %d) reports"
609 "file error 0x%X\n", mdev->port, mdev->unit,
610 ((int *)recvbuf)[1]);
611}
612
614static void maple_port_rescan(void) 613static void maple_port_rescan(void)
615{ 614{
616 int i; 615 int i;
@@ -621,12 +620,6 @@ static void maple_port_rescan(void)
621 if (checked[i] == false) { 620 if (checked[i] == false) {
622 fullscan = 0; 621 fullscan = 0;
623 mdev = baseunits[i]; 622 mdev = baseunits[i];
624 /*
625 * test lock in case scan has failed
626 * but device is still locked
627 */
628 if (mutex_is_locked(&mdev->mq->mutex))
629 mutex_unlock(&mdev->mq->mutex);
630 maple_add_packet(mdev, 0, MAPLE_COMMAND_DEVINFO, 623 maple_add_packet(mdev, 0, MAPLE_COMMAND_DEVINFO,
631 0, NULL); 624 0, NULL);
632 } 625 }
@@ -637,7 +630,7 @@ static void maple_port_rescan(void)
637static void maple_dma_handler(struct work_struct *work) 630static void maple_dma_handler(struct work_struct *work)
638{ 631{
639 struct mapleq *mq, *nmq; 632 struct mapleq *mq, *nmq;
640 struct maple_device *dev; 633 struct maple_device *mdev;
641 char *recvbuf; 634 char *recvbuf;
642 enum maple_code code; 635 enum maple_code code;
643 636
@@ -646,43 +639,56 @@ static void maple_dma_handler(struct work_struct *work)
646 ctrl_outl(0, MAPLE_ENABLE); 639 ctrl_outl(0, MAPLE_ENABLE);
647 if (!list_empty(&maple_sentq)) { 640 if (!list_empty(&maple_sentq)) {
648 list_for_each_entry_safe(mq, nmq, &maple_sentq, list) { 641 list_for_each_entry_safe(mq, nmq, &maple_sentq, list) {
649 recvbuf = mq->recvbuf; 642 mdev = mq->dev;
643 recvbuf = mq->recvbuf->buf;
644 dma_cache_sync(&mdev->dev, recvbuf, 0x400,
645 DMA_FROM_DEVICE);
650 code = recvbuf[0]; 646 code = recvbuf[0];
651 dev = mq->dev;
652 kfree(mq->sendbuf); 647 kfree(mq->sendbuf);
653 mutex_unlock(&mq->mutex);
654 list_del_init(&mq->list); 648 list_del_init(&mq->list);
655
656 switch (code) { 649 switch (code) {
657 case MAPLE_RESPONSE_NONE: 650 case MAPLE_RESPONSE_NONE:
658 maple_response_none(dev, mq); 651 maple_response_none(mdev);
659 break; 652 break;
660 653
661 case MAPLE_RESPONSE_DEVINFO: 654 case MAPLE_RESPONSE_DEVINFO:
662 maple_response_devinfo(dev, recvbuf); 655 maple_response_devinfo(mdev, recvbuf);
656 atomic_set(&mdev->busy, 0);
663 break; 657 break;
664 658
665 case MAPLE_RESPONSE_DATATRF: 659 case MAPLE_RESPONSE_DATATRF:
666 if (dev->callback) 660 if (mdev->callback)
667 dev->callback(mq); 661 mdev->callback(mq);
662 atomic_set(&mdev->busy, 0);
663 wake_up(&mdev->maple_wait);
668 break; 664 break;
669 665
670 case MAPLE_RESPONSE_FILEERR: 666 case MAPLE_RESPONSE_FILEERR:
667 maple_response_fileerr(mdev, recvbuf);
668 atomic_set(&mdev->busy, 0);
669 wake_up(&mdev->maple_wait);
670 break;
671
671 case MAPLE_RESPONSE_AGAIN: 672 case MAPLE_RESPONSE_AGAIN:
672 case MAPLE_RESPONSE_BADCMD: 673 case MAPLE_RESPONSE_BADCMD:
673 case MAPLE_RESPONSE_BADFUNC: 674 case MAPLE_RESPONSE_BADFUNC:
674 printk(KERN_DEBUG 675 dev_warn(&mdev->dev, "non-fatal error"
675 "Maple non-fatal error 0x%X\n", 676 " 0x%X at (%d, %d)\n", code,
676 code); 677 mdev->port, mdev->unit);
678 atomic_set(&mdev->busy, 0);
677 break; 679 break;
678 680
679 case MAPLE_RESPONSE_ALLINFO: 681 case MAPLE_RESPONSE_ALLINFO:
680 printk(KERN_DEBUG 682 dev_notice(&mdev->dev, "extended"
681 "Maple - extended device information" 683 " device information request for (%d, %d)"
682 " not supported\n"); 684 " but call is not supported\n", mdev->port,
685 mdev->unit);
686 atomic_set(&mdev->busy, 0);
683 break; 687 break;
684 688
685 case MAPLE_RESPONSE_OK: 689 case MAPLE_RESPONSE_OK:
690 atomic_set(&mdev->busy, 0);
691 wake_up(&mdev->maple_wait);
686 break; 692 break;
687 693
688 default: 694 default:
@@ -699,20 +705,19 @@ static void maple_dma_handler(struct work_struct *work)
699 if (!fullscan) 705 if (!fullscan)
700 maple_port_rescan(); 706 maple_port_rescan();
701 /* mark that we have been through the first scan */ 707 /* mark that we have been through the first scan */
702 if (started == 0) 708 started = 1;
703 started = 1;
704 } 709 }
705 maplebus_dma_reset(); 710 maple_send();
706} 711}
707 712
708static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id) 713static irqreturn_t maple_dma_interrupt(int irq, void *dev_id)
709{ 714{
710 /* Load everything into the bottom half */ 715 /* Load everything into the bottom half */
711 schedule_work(&maple_dma_process); 716 schedule_work(&maple_dma_process);
712 return IRQ_HANDLED; 717 return IRQ_HANDLED;
713} 718}
714 719
715static irqreturn_t maplebus_vblank_interrupt(int irq, void *dev_id) 720static irqreturn_t maple_vblank_interrupt(int irq, void *dev_id)
716{ 721{
717 schedule_work(&maple_vblank_process); 722 schedule_work(&maple_vblank_process);
718 return IRQ_HANDLED; 723 return IRQ_HANDLED;
@@ -720,14 +725,14 @@ static irqreturn_t maplebus_vblank_interrupt(int irq, void *dev_id)
720 725
721static int maple_set_dma_interrupt_handler(void) 726static int maple_set_dma_interrupt_handler(void)
722{ 727{
723 return request_irq(HW_EVENT_MAPLE_DMA, maplebus_dma_interrupt, 728 return request_irq(HW_EVENT_MAPLE_DMA, maple_dma_interrupt,
724 IRQF_SHARED, "maple bus DMA", &maple_dummy_driver); 729 IRQF_SHARED, "maple bus DMA", &maple_unsupported_device);
725} 730}
726 731
727static int maple_set_vblank_interrupt_handler(void) 732static int maple_set_vblank_interrupt_handler(void)
728{ 733{
729 return request_irq(HW_EVENT_VSYNC, maplebus_vblank_interrupt, 734 return request_irq(HW_EVENT_VSYNC, maple_vblank_interrupt,
730 IRQF_SHARED, "maple bus VBLANK", &maple_dummy_driver); 735 IRQF_SHARED, "maple bus VBLANK", &maple_unsupported_device);
731} 736}
732 737
733static int maple_get_dma_buffer(void) 738static int maple_get_dma_buffer(void)
@@ -740,7 +745,7 @@ static int maple_get_dma_buffer(void)
740 return 0; 745 return 0;
741} 746}
742 747
743static int match_maple_bus_driver(struct device *devptr, 748static int maple_match_bus_driver(struct device *devptr,
744 struct device_driver *drvptr) 749 struct device_driver *drvptr)
745{ 750{
746 struct maple_driver *maple_drv = to_maple_driver(drvptr); 751 struct maple_driver *maple_drv = to_maple_driver(drvptr);
@@ -765,22 +770,24 @@ static void maple_bus_release(struct device *dev)
765{ 770{
766} 771}
767 772
768static struct maple_driver maple_dummy_driver = { 773static struct maple_driver maple_unsupported_device = {
769 .drv = { 774 .drv = {
770 .name = "maple_dummy_driver", 775 .name = "maple_unsupported_device",
771 .bus = &maple_bus_type, 776 .bus = &maple_bus_type,
772 }, 777 },
773}; 778};
774 779/**
780 * maple_bus_type - core maple bus structure
781 */
775struct bus_type maple_bus_type = { 782struct bus_type maple_bus_type = {
776 .name = "maple", 783 .name = "maple",
777 .match = match_maple_bus_driver, 784 .match = maple_match_bus_driver,
778 .uevent = maple_bus_uevent, 785 .uevent = maple_bus_uevent,
779}; 786};
780EXPORT_SYMBOL_GPL(maple_bus_type); 787EXPORT_SYMBOL_GPL(maple_bus_type);
781 788
782static struct device maple_bus = { 789static struct device maple_bus = {
783 .bus_id = "maple", 790 .init_name = "maple",
784 .release = maple_bus_release, 791 .release = maple_bus_release,
785}; 792};
786 793
@@ -788,7 +795,8 @@ static int __init maple_bus_init(void)
788{ 795{
789 int retval, i; 796 int retval, i;
790 struct maple_device *mdev[MAPLE_PORTS]; 797 struct maple_device *mdev[MAPLE_PORTS];
791 ctrl_outl(0, MAPLE_STATE); 798
799 ctrl_outl(0, MAPLE_ENABLE);
792 800
793 retval = device_register(&maple_bus); 801 retval = device_register(&maple_bus);
794 if (retval) 802 if (retval)
@@ -798,36 +806,33 @@ static int __init maple_bus_init(void)
798 if (retval) 806 if (retval)
799 goto cleanup_device; 807 goto cleanup_device;
800 808
801 retval = driver_register(&maple_dummy_driver.drv); 809 retval = driver_register(&maple_unsupported_device.drv);
802 if (retval) 810 if (retval)
803 goto cleanup_bus; 811 goto cleanup_bus;
804 812
805 /* allocate memory for maple bus dma */ 813 /* allocate memory for maple bus dma */
806 retval = maple_get_dma_buffer(); 814 retval = maple_get_dma_buffer();
807 if (retval) { 815 if (retval) {
808 printk(KERN_INFO 816 dev_err(&maple_bus, "failed to allocate DMA buffers\n");
809 "Maple bus: Failed to allocate Maple DMA buffers\n");
810 goto cleanup_basic; 817 goto cleanup_basic;
811 } 818 }
812 819
813 /* set up DMA interrupt handler */ 820 /* set up DMA interrupt handler */
814 retval = maple_set_dma_interrupt_handler(); 821 retval = maple_set_dma_interrupt_handler();
815 if (retval) { 822 if (retval) {
816 printk(KERN_INFO 823 dev_err(&maple_bus, "bus failed to grab maple "
817 "Maple bus: Failed to grab maple DMA IRQ\n"); 824 "DMA IRQ\n");
818 goto cleanup_dma; 825 goto cleanup_dma;
819 } 826 }
820 827
821 /* set up VBLANK interrupt handler */ 828 /* set up VBLANK interrupt handler */
822 retval = maple_set_vblank_interrupt_handler(); 829 retval = maple_set_vblank_interrupt_handler();
823 if (retval) { 830 if (retval) {
824 printk(KERN_INFO "Maple bus: Failed to grab VBLANK IRQ\n"); 831 dev_err(&maple_bus, "bus failed to grab VBLANK IRQ\n");
825 goto cleanup_irq; 832 goto cleanup_irq;
826 } 833 }
827 834
828 maple_queue_cache = 835 maple_queue_cache = KMEM_CACHE(maple_buffer, SLAB_HWCACHE_ALIGN);
829 kmem_cache_create("maple_queue_cache", 0x400, 0,
830 SLAB_HWCACHE_ALIGN, NULL);
831 836
832 if (!maple_queue_cache) 837 if (!maple_queue_cache)
833 goto cleanup_bothirqs; 838 goto cleanup_bothirqs;
@@ -838,23 +843,23 @@ static int __init maple_bus_init(void)
838 /* setup maple ports */ 843 /* setup maple ports */
839 for (i = 0; i < MAPLE_PORTS; i++) { 844 for (i = 0; i < MAPLE_PORTS; i++) {
840 checked[i] = false; 845 checked[i] = false;
846 empty[i] = false;
841 mdev[i] = maple_alloc_dev(i, 0); 847 mdev[i] = maple_alloc_dev(i, 0);
842 baseunits[i] = mdev[i];
843 if (!mdev[i]) { 848 if (!mdev[i]) {
844 while (i-- > 0) 849 while (i-- > 0)
845 maple_free_dev(mdev[i]); 850 maple_free_dev(mdev[i]);
846 goto cleanup_cache; 851 goto cleanup_cache;
847 } 852 }
853 baseunits[i] = mdev[i];
854 atomic_set(&mdev[i]->busy, 1);
848 maple_add_packet(mdev[i], 0, MAPLE_COMMAND_DEVINFO, 0, NULL); 855 maple_add_packet(mdev[i], 0, MAPLE_COMMAND_DEVINFO, 0, NULL);
849 subdevice_map[i] = 0; 856 subdevice_map[i] = 0;
850 } 857 }
851 858
852 /* setup maplebus hardware */ 859 maple_pnp_time = jiffies + HZ;
853 maplebus_dma_reset(); 860 /* prepare initial queue */
854 /* initial detection */
855 maple_send(); 861 maple_send();
856 maple_pnp_time = jiffies; 862 dev_info(&maple_bus, "bus core now registered\n");
857 printk(KERN_INFO "Maple bus core now registered.\n");
858 863
859 return 0; 864 return 0;
860 865
@@ -871,7 +876,7 @@ cleanup_dma:
871 free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES); 876 free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES);
872 877
873cleanup_basic: 878cleanup_basic:
874 driver_unregister(&maple_dummy_driver.drv); 879 driver_unregister(&maple_unsupported_device.drv);
875 880
876cleanup_bus: 881cleanup_bus:
877 bus_unregister(&maple_bus_type); 882 bus_unregister(&maple_bus_type);
@@ -880,7 +885,7 @@ cleanup_device:
880 device_unregister(&maple_bus); 885 device_unregister(&maple_bus);
881 886
882cleanup: 887cleanup:
883 printk(KERN_INFO "Maple bus registration failed\n"); 888 printk(KERN_ERR "Maple bus registration failed\n");
884 return retval; 889 return retval;
885} 890}
886/* Push init to later to ensure hardware gets detected */ 891/* Push init to later to ensure hardware gets detected */
diff --git a/drivers/sh/superhyway/superhyway.c b/drivers/sh/superhyway/superhyway.c
index 4d0282b821b5..2d9e7f3d5611 100644
--- a/drivers/sh/superhyway/superhyway.c
+++ b/drivers/sh/superhyway/superhyway.c
@@ -22,7 +22,7 @@
22static int superhyway_devices; 22static int superhyway_devices;
23 23
24static struct device superhyway_bus_device = { 24static struct device superhyway_bus_device = {
25 .bus_id = "superhyway", 25 .init_name = "superhyway",
26}; 26};
27 27
28static void superhyway_device_release(struct device *dev) 28static void superhyway_device_release(struct device *dev)
@@ -83,7 +83,7 @@ int superhyway_add_device(unsigned long base, struct superhyway_device *sdev,
83 dev->id.id = dev->vcr.mod_id; 83 dev->id.id = dev->vcr.mod_id;
84 84
85 sprintf(dev->name, "SuperHyway device %04x", dev->id.id); 85 sprintf(dev->name, "SuperHyway device %04x", dev->id.id);
86 sprintf(dev->dev.bus_id, "%02x", superhyway_devices); 86 dev_set_name(&dev->dev, "%02x", superhyway_devices);
87 87
88 superhyway_devices++; 88 superhyway_devices++;
89 89
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 56ff3e6864ea..12e443cc4ac9 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -322,7 +322,7 @@ static void atmel_spi_next_message(struct spi_master *master)
322 spi = msg->spi; 322 spi = msg->spi;
323 323
324 dev_dbg(master->dev.parent, "start message %p for %s\n", 324 dev_dbg(master->dev.parent, "start message %p for %s\n",
325 msg, spi->dev.bus_id); 325 msg, dev_name(&spi->dev));
326 326
327 /* select chip if it's not still active */ 327 /* select chip if it's not still active */
328 if (as->stay) { 328 if (as->stay) {
@@ -627,7 +627,7 @@ static int atmel_spi_setup(struct spi_device *spi)
627 if (!asd) 627 if (!asd)
628 return -ENOMEM; 628 return -ENOMEM;
629 629
630 ret = gpio_request(npcs_pin, spi->dev.bus_id); 630 ret = gpio_request(npcs_pin, dev_name(&spi->dev));
631 if (ret) { 631 if (ret) {
632 kfree(asd); 632 kfree(asd);
633 return ret; 633 return ret;
@@ -668,7 +668,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
668 as = spi_master_get_devdata(spi->master); 668 as = spi_master_get_devdata(spi->master);
669 669
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, dev_name(&spi->dev));
672 672
673 if (unlikely(list_empty(&msg->transfers))) 673 if (unlikely(list_empty(&msg->transfers)))
674 return -EINVAL; 674 return -EINVAL;
@@ -803,7 +803,7 @@ static int __init atmel_spi_probe(struct platform_device *pdev)
803 as->clk = clk; 803 as->clk = clk;
804 804
805 ret = request_irq(irq, atmel_spi_interrupt, 0, 805 ret = request_irq(irq, atmel_spi_interrupt, 0,
806 pdev->dev.bus_id, master); 806 dev_name(&pdev->dev), master);
807 if (ret) 807 if (ret)
808 goto out_unmap_regs; 808 goto out_unmap_regs;
809 809
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 3b97803e1d11..68c77a911595 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -429,7 +429,7 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
429 INIT_LIST_HEAD(&mps->queue); 429 INIT_LIST_HEAD(&mps->queue);
430 430
431 mps->workqueue = create_singlethread_workqueue( 431 mps->workqueue = create_singlethread_workqueue(
432 master->dev.parent->bus_id); 432 dev_name(master->dev.parent));
433 if (mps->workqueue == NULL) { 433 if (mps->workqueue == NULL) {
434 ret = -EBUSY; 434 ret = -EBUSY;
435 goto free_irq; 435 goto free_irq;
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index 454a2712e629..1c65e380c845 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -1003,7 +1003,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
1003 goto err1; 1003 goto err1;
1004 } 1004 }
1005 if (!request_mem_region(r->start, (r->end - r->start) + 1, 1005 if (!request_mem_region(r->start, (r->end - r->start) + 1,
1006 pdev->dev.bus_id)) { 1006 dev_name(&pdev->dev))) {
1007 status = -EBUSY; 1007 status = -EBUSY;
1008 goto err1; 1008 goto err1;
1009 } 1009 }
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/omap_uwire.c
index bab6ff061e91..60b5381c65c4 100644
--- a/drivers/spi/omap_uwire.c
+++ b/drivers/spi/omap_uwire.c
@@ -245,7 +245,7 @@ static int uwire_txrx(struct spi_device *spi, struct spi_transfer *t)
245 245
246#ifdef VERBOSE 246#ifdef VERBOSE
247 pr_debug("%s: write-%d =%04x\n", 247 pr_debug("%s: write-%d =%04x\n",
248 spi->dev.bus_id, bits, val); 248 dev_name(&spi->dev), bits, val);
249#endif 249#endif
250 if (wait_uwire_csr_flag(CSRB, 0, 0)) 250 if (wait_uwire_csr_flag(CSRB, 0, 0))
251 goto eio; 251 goto eio;
@@ -305,7 +305,7 @@ static int uwire_txrx(struct spi_device *spi, struct spi_transfer *t)
305 status += bytes; 305 status += bytes;
306#ifdef VERBOSE 306#ifdef VERBOSE
307 pr_debug("%s: read-%d =%04x\n", 307 pr_debug("%s: read-%d =%04x\n",
308 spi->dev.bus_id, bits, val); 308 dev_name(&spi->dev), bits, val);
309#endif 309#endif
310 310
311 } 311 }
@@ -331,7 +331,7 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
331 uwire = spi_master_get_devdata(spi->master); 331 uwire = spi_master_get_devdata(spi->master);
332 332
333 if (spi->chip_select > 3) { 333 if (spi->chip_select > 3) {
334 pr_debug("%s: cs%d?\n", spi->dev.bus_id, spi->chip_select); 334 pr_debug("%s: cs%d?\n", dev_name(&spi->dev), spi->chip_select);
335 status = -ENODEV; 335 status = -ENODEV;
336 goto done; 336 goto done;
337 } 337 }
@@ -343,7 +343,7 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
343 bits = 8; 343 bits = 8;
344 344
345 if (bits > 16) { 345 if (bits > 16) {
346 pr_debug("%s: wordsize %d?\n", spi->dev.bus_id, bits); 346 pr_debug("%s: wordsize %d?\n", dev_name(&spi->dev), bits);
347 status = -ENODEV; 347 status = -ENODEV;
348 goto done; 348 goto done;
349 } 349 }
@@ -378,7 +378,7 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
378 hz = t->speed_hz; 378 hz = t->speed_hz;
379 379
380 if (!hz) { 380 if (!hz) {
381 pr_debug("%s: zero speed?\n", spi->dev.bus_id); 381 pr_debug("%s: zero speed?\n", dev_name(&spi->dev));
382 status = -EINVAL; 382 status = -EINVAL;
383 goto done; 383 goto done;
384 } 384 }
@@ -406,7 +406,7 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
406 } 406 }
407 if (div1_idx == 4) { 407 if (div1_idx == 4) {
408 pr_debug("%s: lowest clock %ld, need %d\n", 408 pr_debug("%s: lowest clock %ld, need %d\n",
409 spi->dev.bus_id, rate / 10 / 8, hz); 409 dev_name(&spi->dev), rate / 10 / 8, hz);
410 status = -EDOM; 410 status = -EDOM;
411 goto done; 411 goto done;
412 } 412 }
diff --git a/drivers/spi/orion_spi.c b/drivers/spi/orion_spi.c
index 014becb7d530..c8b0babdc2a6 100644
--- a/drivers/spi/orion_spi.c
+++ b/drivers/spi/orion_spi.c
@@ -496,7 +496,7 @@ static int __init orion_spi_probe(struct platform_device *pdev)
496 } 496 }
497 497
498 if (!request_mem_region(r->start, (r->end - r->start) + 1, 498 if (!request_mem_region(r->start, (r->end - r->start) + 1,
499 pdev->dev.bus_id)) { 499 dev_name(&pdev->dev))) {
500 status = -EBUSY; 500 status = -EBUSY;
501 goto out; 501 goto out;
502 } 502 }
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index d0fc4ca2f656..ec24f2d16f3c 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1333,7 +1333,7 @@ static int __init init_queue(struct driver_data *drv_data)
1333 1333
1334 INIT_WORK(&drv_data->pump_messages, pump_messages); 1334 INIT_WORK(&drv_data->pump_messages, pump_messages);
1335 drv_data->workqueue = create_singlethread_workqueue( 1335 drv_data->workqueue = create_singlethread_workqueue(
1336 drv_data->master->dev.parent->bus_id); 1336 dev_name(drv_data->master->dev.parent));
1337 if (drv_data->workqueue == NULL) 1337 if (drv_data->workqueue == NULL)
1338 return -EBUSY; 1338 return -EBUSY;
1339 1339
@@ -1462,7 +1462,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1462 drv_data->mask_sr = SSSR_TINT | SSSR_RFS | SSSR_TFS | SSSR_ROR; 1462 drv_data->mask_sr = SSSR_TINT | SSSR_RFS | SSSR_TFS | SSSR_ROR;
1463 } 1463 }
1464 1464
1465 status = request_irq(ssp->irq, ssp_int, 0, dev->bus_id, drv_data); 1465 status = request_irq(ssp->irq, ssp_int, 0, dev_name(dev), drv_data);
1466 if (status < 0) { 1466 if (status < 0) {
1467 dev_err(&pdev->dev, "cannot get IRQ %d\n", ssp->irq); 1467 dev_err(&pdev->dev, "cannot get IRQ %d\n", ssp->irq);
1468 goto out_error_master_alloc; 1468 goto out_error_master_alloc;
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 7fea3cf4588a..3410b0c55ed2 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -1160,8 +1160,8 @@ static inline int init_queue(struct driver_data *drv_data)
1160 1160
1161 /* init messages workqueue */ 1161 /* init messages workqueue */
1162 INIT_WORK(&drv_data->pump_messages, pump_messages); 1162 INIT_WORK(&drv_data->pump_messages, pump_messages);
1163 drv_data->workqueue = 1163 drv_data->workqueue = create_singlethread_workqueue(
1164 create_singlethread_workqueue(drv_data->master->dev.parent->bus_id); 1164 dev_name(drv_data->master->dev.parent));
1165 if (drv_data->workqueue == NULL) 1165 if (drv_data->workqueue == NULL)
1166 return -EBUSY; 1166 return -EBUSY;
1167 1167
diff --git a/drivers/spi/spi_gpio.c b/drivers/spi/spi_gpio.c
index f5ed9721aabb..d2866c293dee 100644
--- a/drivers/spi/spi_gpio.c
+++ b/drivers/spi/spi_gpio.c
@@ -191,7 +191,7 @@ static int spi_gpio_setup(struct spi_device *spi)
191 return -EINVAL; 191 return -EINVAL;
192 192
193 if (!spi->controller_state) { 193 if (!spi->controller_state) {
194 status = gpio_request(cs, spi->dev.bus_id); 194 status = gpio_request(cs, dev_name(&spi->dev));
195 if (status) 195 if (status)
196 return status; 196 return status;
197 status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH); 197 status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 269a55ec52ef..0480d8bb19d3 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -1381,7 +1381,7 @@ static int __init init_queue(struct driver_data *drv_data)
1381 1381
1382 INIT_WORK(&drv_data->work, pump_messages); 1382 INIT_WORK(&drv_data->work, pump_messages);
1383 drv_data->workqueue = create_singlethread_workqueue( 1383 drv_data->workqueue = create_singlethread_workqueue(
1384 drv_data->master->dev.parent->bus_id); 1384 dev_name(drv_data->master->dev.parent));
1385 if (drv_data->workqueue == NULL) 1385 if (drv_data->workqueue == NULL)
1386 return -EBUSY; 1386 return -EBUSY;
1387 1387
@@ -1525,7 +1525,8 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1525 status = -ENODEV; 1525 status = -ENODEV;
1526 goto err_no_irqres; 1526 goto err_no_irqres;
1527 } 1527 }
1528 status = request_irq(irq, spi_int, IRQF_DISABLED, dev->bus_id, drv_data); 1528 status = request_irq(irq, spi_int, IRQF_DISABLED,
1529 dev_name(dev), drv_data);
1529 if (status < 0) { 1530 if (status < 0) {
1530 dev_err(&pdev->dev, "probe - cannot get IRQ (%d)\n", status); 1531 dev_err(&pdev->dev, "probe - cannot get IRQ (%d)\n", status);
1531 goto err_no_irqres; 1532 goto err_no_irqres;
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index ac0e3e4b3c54..44a2b46ccb79 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -637,7 +637,7 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
637 INIT_LIST_HEAD(&mpc83xx_spi->queue); 637 INIT_LIST_HEAD(&mpc83xx_spi->queue);
638 638
639 mpc83xx_spi->workqueue = create_singlethread_workqueue( 639 mpc83xx_spi->workqueue = create_singlethread_workqueue(
640 master->dev.parent->bus_id); 640 dev_name(master->dev.parent));
641 if (mpc83xx_spi->workqueue == NULL) { 641 if (mpc83xx_spi->workqueue == NULL) {
642 ret = -EBUSY; 642 ret = -EBUSY;
643 goto free_irq; 643 goto free_irq;
@@ -649,7 +649,7 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
649 649
650 printk(KERN_INFO 650 printk(KERN_INFO
651 "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n", 651 "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n",
652 dev->dev.bus_id, mpc83xx_spi->base, mpc83xx_spi->irq); 652 dev_name(&dev->dev), mpc83xx_spi->base, mpc83xx_spi->irq);
653 653
654 return ret; 654 return ret;
655 655
diff --git a/drivers/spi/spi_txx9.c b/drivers/spi/spi_txx9.c
index 2296f37ea3c6..29cbb065618a 100644
--- a/drivers/spi/spi_txx9.c
+++ b/drivers/spi/spi_txx9.c
@@ -404,7 +404,8 @@ static int __init txx9spi_probe(struct platform_device *dev)
404 if (ret) 404 if (ret)
405 goto exit; 405 goto exit;
406 406
407 c->workqueue = create_singlethread_workqueue(master->dev.parent->bus_id); 407 c->workqueue = create_singlethread_workqueue(
408 dev_name(master->dev.parent));
408 if (!c->workqueue) 409 if (!c->workqueue)
409 goto exit_busy; 410 goto exit_busy;
410 c->last_chipselect = -1; 411 c->last_chipselect = -1;
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index ce6badded47a..211af86a6c55 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -73,8 +73,6 @@ source "drivers/staging/rt2860/Kconfig"
73 73
74source "drivers/staging/rt2870/Kconfig" 74source "drivers/staging/rt2870/Kconfig"
75 75
76source "drivers/staging/benet/Kconfig"
77
78source "drivers/staging/comedi/Kconfig" 76source "drivers/staging/comedi/Kconfig"
79 77
80source "drivers/staging/asus_oled/Kconfig" 78source "drivers/staging/asus_oled/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 9ddcc2bb3365..47a56f5ffabc 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -19,7 +19,6 @@ obj-$(CONFIG_AGNX) += agnx/
19obj-$(CONFIG_OTUS) += otus/ 19obj-$(CONFIG_OTUS) += otus/
20obj-$(CONFIG_RT2860) += rt2860/ 20obj-$(CONFIG_RT2860) += rt2860/
21obj-$(CONFIG_RT2870) += rt2870/ 21obj-$(CONFIG_RT2870) += rt2870/
22obj-$(CONFIG_BENET) += benet/
23obj-$(CONFIG_COMEDI) += comedi/ 22obj-$(CONFIG_COMEDI) += comedi/
24obj-$(CONFIG_ASUS_OLED) += asus_oled/ 23obj-$(CONFIG_ASUS_OLED) += asus_oled/
25obj-$(CONFIG_PANEL) += panel/ 24obj-$(CONFIG_PANEL) += panel/
diff --git a/drivers/staging/benet/Kconfig b/drivers/staging/benet/Kconfig
deleted file mode 100644
index f6806074f998..000000000000
--- a/drivers/staging/benet/Kconfig
+++ /dev/null
@@ -1,7 +0,0 @@
1config BENET
2 tristate "ServerEngines 10Gb NIC - BladeEngine"
3 depends on PCI && INET
4 select INET_LRO
5 help
6 This driver implements the NIC functionality for ServerEngines
7 10Gb network adapter BladeEngine (EC 3210).
diff --git a/drivers/staging/benet/MAINTAINERS b/drivers/staging/benet/MAINTAINERS
deleted file mode 100644
index d5ce340218b3..000000000000
--- a/drivers/staging/benet/MAINTAINERS
+++ /dev/null
@@ -1,6 +0,0 @@
1SERVER ENGINES 10Gbe NIC - BLADE-ENGINE
2P: Subbu Seetharaman
3M: subbus@serverengines.com
4L: netdev@vger.kernel.org
5W: http://www.serverengines.com
6S: Supported
diff --git a/drivers/staging/benet/Makefile b/drivers/staging/benet/Makefile
deleted file mode 100644
index 460b923b99bd..000000000000
--- a/drivers/staging/benet/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
1#
2# Makefile to build the network driver for ServerEngine's BladeEngine
3#
4obj-$(CONFIG_BENET) += benet.o
5
6benet-y := be_init.o \
7 be_int.o \
8 be_netif.o \
9 be_ethtool.o \
10 funcobj.o \
11 cq.o \
12 eq.o \
13 mpu.o \
14 eth.o
diff --git a/drivers/staging/benet/TODO b/drivers/staging/benet/TODO
deleted file mode 100644
index a51dfb59a62f..000000000000
--- a/drivers/staging/benet/TODO
+++ /dev/null
@@ -1,6 +0,0 @@
1TODO:
2 - remove wrappers around common iowrite functions
3 - full netdev audit of common problems/issues
4
5Please send all patches and questions to Subbu Seetharaman
6<subbus@serverengines.com> and Greg Kroah-Hartman <greg@kroah.com>
diff --git a/drivers/staging/benet/asyncmesg.h b/drivers/staging/benet/asyncmesg.h
deleted file mode 100644
index d1e779adb848..000000000000
--- a/drivers/staging/benet/asyncmesg.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __asyncmesg_amap_h__
21#define __asyncmesg_amap_h__
22#include "fwcmd_common.h"
23
24/* --- ASYNC_EVENT_CODES --- */
25#define ASYNC_EVENT_CODE_LINK_STATE (1)
26#define ASYNC_EVENT_CODE_ISCSI (2)
27
28/* --- ASYNC_LINK_STATES --- */
29#define ASYNC_EVENT_LINK_DOWN (0) /* Link Down on a port */
30#define ASYNC_EVENT_LINK_UP (1) /* Link Up on a port */
31
32/*
33 * The last 4 bytes of the async events have this common format. It allows
34 * the driver to distinguish [link]MCC_CQ_ENTRY[/link] structs from
35 * asynchronous events. Both arrive on the same completion queue. This
36 * structure also contains the common fields used to decode the async event.
37 */
38struct BE_ASYNC_EVENT_TRAILER_AMAP {
39 u8 rsvd0[8]; /* DWORD 0 */
40 u8 event_code[8]; /* DWORD 0 */
41 u8 event_type[8]; /* DWORD 0 */
42 u8 rsvd1[6]; /* DWORD 0 */
43 u8 async_event; /* DWORD 0 */
44 u8 valid; /* DWORD 0 */
45} __packed;
46struct ASYNC_EVENT_TRAILER_AMAP {
47 u32 dw[1];
48};
49
50/*
51 * Applicable in Initiator, Target and NIC modes.
52 * A link state async event is seen by all device drivers as soon they
53 * create an MCC ring. Thereafter, anytime the link status changes the
54 * drivers will receive a link state async event. Notifications continue to
55 * be sent until a driver destroys its MCC ring. A link down event is
56 * reported when either port loses link. A link up event is reported
57 * when either port regains link. When BE's failover mechanism is enabled, a
58 * link down on the active port causes traffic to be diverted to the standby
59 * port by the BE's ARM firmware (assuming the standby port has link). In
60 * this case, the standy port assumes the active status. Note: when link is
61 * restored on the failed port, traffic continues on the currently active
62 * port. The ARM firmware does not attempt to 'fail back' traffic to
63 * the restored port.
64 */
65struct BE_ASYNC_EVENT_LINK_STATE_AMAP {
66 u8 port0_link_status[8];
67 u8 port1_link_status[8];
68 u8 active_port[8];
69 u8 rsvd0[8]; /* DWORD 0 */
70 u8 port0_duplex[8];
71 u8 port0_speed[8];
72 u8 port1_duplex[8];
73 u8 port1_speed[8];
74 u8 port0_fault[8];
75 u8 port1_fault[8];
76 u8 rsvd1[2][8]; /* DWORD 2 */
77 struct BE_ASYNC_EVENT_TRAILER_AMAP trailer;
78} __packed;
79struct ASYNC_EVENT_LINK_STATE_AMAP {
80 u32 dw[4];
81};
82#endif /* __asyncmesg_amap_h__ */
diff --git a/drivers/staging/benet/be_cm.h b/drivers/staging/benet/be_cm.h
deleted file mode 100644
index b7a1dfd20c36..000000000000
--- a/drivers/staging/benet/be_cm.h
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __be_cm_amap_h__
21#define __be_cm_amap_h__
22#include "be_common.h"
23#include "etx_context.h"
24#include "mpu_context.h"
25
26/*
27 * --- CEV_WATERMARK_ENUM ---
28 * CQ/EQ Watermark Encodings. Encoded as number of free entries in
29 * Queue when Watermark is reached.
30 */
31#define CEV_WMARK_0 (0) /* Watermark when Queue full */
32#define CEV_WMARK_16 (1) /* Watermark at 16 free entries */
33#define CEV_WMARK_32 (2) /* Watermark at 32 free entries */
34#define CEV_WMARK_48 (3) /* Watermark at 48 free entries */
35#define CEV_WMARK_64 (4) /* Watermark at 64 free entries */
36#define CEV_WMARK_80 (5) /* Watermark at 80 free entries */
37#define CEV_WMARK_96 (6) /* Watermark at 96 free entries */
38#define CEV_WMARK_112 (7) /* Watermark at 112 free entries */
39#define CEV_WMARK_128 (8) /* Watermark at 128 free entries */
40#define CEV_WMARK_144 (9) /* Watermark at 144 free entries */
41#define CEV_WMARK_160 (10) /* Watermark at 160 free entries */
42#define CEV_WMARK_176 (11) /* Watermark at 176 free entries */
43#define CEV_WMARK_192 (12) /* Watermark at 192 free entries */
44#define CEV_WMARK_208 (13) /* Watermark at 208 free entries */
45#define CEV_WMARK_224 (14) /* Watermark at 224 free entries */
46#define CEV_WMARK_240 (15) /* Watermark at 240 free entries */
47
48/*
49 * --- CQ_CNT_ENUM ---
50 * Completion Queue Count Encodings.
51 */
52#define CEV_CQ_CNT_256 (0) /* CQ has 256 entries */
53#define CEV_CQ_CNT_512 (1) /* CQ has 512 entries */
54#define CEV_CQ_CNT_1024 (2) /* CQ has 1024 entries */
55
56/*
57 * --- EQ_CNT_ENUM ---
58 * Event Queue Count Encodings.
59 */
60#define CEV_EQ_CNT_256 (0) /* EQ has 256 entries (16-byte EQEs only) */
61#define CEV_EQ_CNT_512 (1) /* EQ has 512 entries (16-byte EQEs only) */
62#define CEV_EQ_CNT_1024 (2) /* EQ has 1024 entries (4-byte or */
63 /* 16-byte EQEs only) */
64#define CEV_EQ_CNT_2048 (3) /* EQ has 2048 entries (4-byte or */
65 /* 16-byte EQEs only) */
66#define CEV_EQ_CNT_4096 (4) /* EQ has 4096 entries (4-byte EQEs only) */
67
68/*
69 * --- EQ_SIZE_ENUM ---
70 * Event Queue Entry Size Encoding.
71 */
72#define CEV_EQ_SIZE_4 (0) /* EQE is 4 bytes */
73#define CEV_EQ_SIZE_16 (1) /* EQE is 16 bytes */
74
75/*
76 * Completion Queue Context Table Entry. Contains the state of a CQ.
77 * Located in RAM within the CEV block.
78 */
79struct BE_CQ_CONTEXT_AMAP {
80 u8 Cidx[11]; /* DWORD 0 */
81 u8 Watermark[4]; /* DWORD 0 */
82 u8 NoDelay; /* DWORD 0 */
83 u8 EPIdx[11]; /* DWORD 0 */
84 u8 Count[2]; /* DWORD 0 */
85 u8 valid; /* DWORD 0 */
86 u8 SolEvent; /* DWORD 0 */
87 u8 Eventable; /* DWORD 0 */
88 u8 Pidx[11]; /* DWORD 1 */
89 u8 PD[10]; /* DWORD 1 */
90 u8 EQID[7]; /* DWORD 1 */
91 u8 Func; /* DWORD 1 */
92 u8 WME; /* DWORD 1 */
93 u8 Stalled; /* DWORD 1 */
94 u8 Armed; /* DWORD 1 */
95} __packed;
96struct CQ_CONTEXT_AMAP {
97 u32 dw[2];
98};
99
100/*
101 * Event Queue Context Table Entry. Contains the state of an EQ.
102 * Located in RAM in the CEV block.
103 */
104struct BE_EQ_CONTEXT_AMAP {
105 u8 Cidx[13]; /* DWORD 0 */
106 u8 rsvd0[2]; /* DWORD 0 */
107 u8 Func; /* DWORD 0 */
108 u8 EPIdx[13]; /* DWORD 0 */
109 u8 valid; /* DWORD 0 */
110 u8 rsvd1; /* DWORD 0 */
111 u8 Size; /* DWORD 0 */
112 u8 Pidx[13]; /* DWORD 1 */
113 u8 rsvd2[3]; /* DWORD 1 */
114 u8 PD[10]; /* DWORD 1 */
115 u8 Count[3]; /* DWORD 1 */
116 u8 SolEvent; /* DWORD 1 */
117 u8 Stalled; /* DWORD 1 */
118 u8 Armed; /* DWORD 1 */
119 u8 Watermark[4]; /* DWORD 2 */
120 u8 WME; /* DWORD 2 */
121 u8 rsvd3[3]; /* DWORD 2 */
122 u8 EventVect[6]; /* DWORD 2 */
123 u8 rsvd4[2]; /* DWORD 2 */
124 u8 Delay[8]; /* DWORD 2 */
125 u8 rsvd5[6]; /* DWORD 2 */
126 u8 TMR; /* DWORD 2 */
127 u8 rsvd6; /* DWORD 2 */
128 u8 rsvd7[32]; /* DWORD 3 */
129} __packed;
130struct EQ_CONTEXT_AMAP {
131 u32 dw[4];
132};
133
134#endif /* __be_cm_amap_h__ */
diff --git a/drivers/staging/benet/be_common.h b/drivers/staging/benet/be_common.h
deleted file mode 100644
index 7e63dc5e3348..000000000000
--- a/drivers/staging/benet/be_common.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __be_common_amap_h__
21#define __be_common_amap_h__
22
23/* Physical Address. */
24struct BE_PHYS_ADDR_AMAP {
25 u8 lo[32]; /* DWORD 0 */
26 u8 hi[32]; /* DWORD 1 */
27} __packed;
28struct PHYS_ADDR_AMAP {
29 u32 dw[2];
30};
31
32/* Virtual Address. */
33struct BE_VIRT_ADDR_AMAP {
34 u8 lo[32]; /* DWORD 0 */
35 u8 hi[32]; /* DWORD 1 */
36} __packed;
37struct VIRT_ADDR_AMAP {
38 u32 dw[2];
39};
40
41/* Scatter gather element. */
42struct BE_SGE_AMAP {
43 u8 addr_hi[32]; /* DWORD 0 */
44 u8 addr_lo[32]; /* DWORD 1 */
45 u8 rsvd0[32]; /* DWORD 2 */
46 u8 len[16]; /* DWORD 3 */
47 u8 rsvd1[16]; /* DWORD 3 */
48} __packed;
49struct SGE_AMAP {
50 u32 dw[4];
51};
52
53#endif /* __be_common_amap_h__ */
diff --git a/drivers/staging/benet/be_ethtool.c b/drivers/staging/benet/be_ethtool.c
deleted file mode 100644
index 027af85707aa..000000000000
--- a/drivers/staging/benet/be_ethtool.c
+++ /dev/null
@@ -1,348 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * be_ethtool.c
19 *
20 * This file contains various functions that ethtool can use
21 * to talk to the driver and the BE H/W.
22 */
23
24#include "benet.h"
25
26#include <linux/ethtool.h>
27
28static const char benet_gstrings_stats[][ETH_GSTRING_LEN] = {
29/* net_device_stats */
30 "rx_packets",
31 "tx_packets",
32 "rx_bytes",
33 "tx_bytes",
34 "rx_errors",
35 "tx_errors",
36 "rx_dropped",
37 "tx_dropped",
38 "multicast",
39 "collisions",
40 "rx_length_errors",
41 "rx_over_errors",
42 "rx_crc_errors",
43 "rx_frame_errors",
44 "rx_fifo_errors",
45 "rx_missed_errors",
46 "tx_aborted_errors",
47 "tx_carrier_errors",
48 "tx_fifo_errors",
49 "tx_heartbeat_errors",
50 "tx_window_errors",
51 "rx_compressed",
52 "tc_compressed",
53/* BE driver Stats */
54 "bes_tx_reqs",
55 "bes_tx_fails",
56 "bes_fwd_reqs",
57 "bes_tx_wrbs",
58 "bes_interrupts",
59 "bes_events",
60 "bes_tx_events",
61 "bes_rx_events",
62 "bes_tx_compl",
63 "bes_rx_compl",
64 "bes_ethrx_post_fail",
65 "bes_802_3_dropped_frames",
66 "bes_802_3_malformed_frames",
67 "bes_rx_misc_pkts",
68 "bes_eth_tx_rate",
69 "bes_eth_rx_rate",
70 "Num Packets collected",
71 "Num Times Flushed",
72};
73
74#define NET_DEV_STATS_LEN \
75 (sizeof(struct net_device_stats)/sizeof(unsigned long))
76
77#define BENET_STATS_LEN ARRAY_SIZE(benet_gstrings_stats)
78
79static void
80be_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
81{
82 struct be_net_object *pnob = netdev_priv(netdev);
83 struct be_adapter *adapter = pnob->adapter;
84
85 strncpy(drvinfo->driver, be_driver_name, 32);
86 strncpy(drvinfo->version, be_drvr_ver, 32);
87 strncpy(drvinfo->fw_version, be_fw_ver, 32);
88 strcpy(drvinfo->bus_info, pci_name(adapter->pdev));
89 drvinfo->testinfo_len = 0;
90 drvinfo->regdump_len = 0;
91 drvinfo->eedump_len = 0;
92}
93
94static int
95be_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
96{
97 struct be_net_object *pnob = netdev_priv(netdev);
98 struct be_adapter *adapter = pnob->adapter;
99
100 coalesce->rx_max_coalesced_frames = adapter->max_rx_coal;
101
102 coalesce->rx_coalesce_usecs = adapter->cur_eqd;
103 coalesce->rx_coalesce_usecs_high = adapter->max_eqd;
104 coalesce->rx_coalesce_usecs_low = adapter->min_eqd;
105
106 coalesce->tx_coalesce_usecs = adapter->cur_eqd;
107 coalesce->tx_coalesce_usecs_high = adapter->max_eqd;
108 coalesce->tx_coalesce_usecs_low = adapter->min_eqd;
109
110 coalesce->use_adaptive_rx_coalesce = adapter->enable_aic;
111 coalesce->use_adaptive_tx_coalesce = adapter->enable_aic;
112
113 return 0;
114}
115
116/*
117 * This routine is used to set interrup coalescing delay *as well as*
118 * the number of pkts to coalesce for LRO.
119 */
120static int
121be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
122{
123 struct be_net_object *pnob = netdev_priv(netdev);
124 struct be_adapter *adapter = pnob->adapter;
125 struct be_eq_object *eq_objectp;
126 u32 max, min, cur;
127 int status;
128
129 adapter->max_rx_coal = coalesce->rx_max_coalesced_frames;
130 if (adapter->max_rx_coal >= BE_LRO_MAX_PKTS)
131 adapter->max_rx_coal = BE_LRO_MAX_PKTS;
132
133 if (adapter->enable_aic == 0 &&
134 coalesce->use_adaptive_rx_coalesce == 1) {
135 /* if AIC is being turned on now, start with an EQD of 0 */
136 adapter->cur_eqd = 0;
137 }
138 adapter->enable_aic = coalesce->use_adaptive_rx_coalesce;
139
140 /* round off to nearest multiple of 8 */
141 max = (((coalesce->rx_coalesce_usecs_high + 4) >> 3) << 3);
142 min = (((coalesce->rx_coalesce_usecs_low + 4) >> 3) << 3);
143 cur = (((coalesce->rx_coalesce_usecs + 4) >> 3) << 3);
144
145 if (adapter->enable_aic) {
146 /* accept low and high if AIC is enabled */
147 if (max > MAX_EQD)
148 max = MAX_EQD;
149 if (min > max)
150 min = max;
151 adapter->max_eqd = max;
152 adapter->min_eqd = min;
153 if (adapter->cur_eqd > max)
154 adapter->cur_eqd = max;
155 if (adapter->cur_eqd < min)
156 adapter->cur_eqd = min;
157 } else {
158 /* accept specified coalesce_usecs only if AIC is disabled */
159 if (cur > MAX_EQD)
160 cur = MAX_EQD;
161 eq_objectp = &pnob->event_q_obj;
162 status =
163 be_eq_modify_delay(&pnob->fn_obj, 1, &eq_objectp, &cur,
164 NULL, NULL, NULL);
165 if (status == BE_SUCCESS)
166 adapter->cur_eqd = cur;
167 }
168 return 0;
169}
170
171static u32 be_get_rx_csum(struct net_device *netdev)
172{
173 struct be_net_object *pnob = netdev_priv(netdev);
174 struct be_adapter *adapter = pnob->adapter;
175 return adapter->rx_csum;
176}
177
178static int be_set_rx_csum(struct net_device *netdev, uint32_t data)
179{
180 struct be_net_object *pnob = netdev_priv(netdev);
181 struct be_adapter *adapter = pnob->adapter;
182
183 if (data)
184 adapter->rx_csum = 1;
185 else
186 adapter->rx_csum = 0;
187
188 return 0;
189}
190
191static void
192be_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
193{
194 switch (stringset) {
195 case ETH_SS_STATS:
196 memcpy(data, *benet_gstrings_stats,
197 sizeof(benet_gstrings_stats));
198 break;
199 }
200}
201
202static int be_get_stats_count(struct net_device *netdev)
203{
204 return BENET_STATS_LEN;
205}
206
207static void
208be_get_ethtool_stats(struct net_device *netdev,
209 struct ethtool_stats *stats, uint64_t *data)
210{
211 struct be_net_object *pnob = netdev_priv(netdev);
212 struct be_adapter *adapter = pnob->adapter;
213 int i;
214
215 benet_get_stats(netdev);
216
217 for (i = 0; i <= NET_DEV_STATS_LEN; i++)
218 data[i] = ((unsigned long *)&adapter->benet_stats)[i];
219
220 data[i] = adapter->be_stat.bes_tx_reqs;
221 data[i++] = adapter->be_stat.bes_tx_fails;
222 data[i++] = adapter->be_stat.bes_fwd_reqs;
223 data[i++] = adapter->be_stat.bes_tx_wrbs;
224
225 data[i++] = adapter->be_stat.bes_ints;
226 data[i++] = adapter->be_stat.bes_events;
227 data[i++] = adapter->be_stat.bes_tx_events;
228 data[i++] = adapter->be_stat.bes_rx_events;
229 data[i++] = adapter->be_stat.bes_tx_compl;
230 data[i++] = adapter->be_stat.bes_rx_compl;
231 data[i++] = adapter->be_stat.bes_ethrx_post_fail;
232 data[i++] = adapter->be_stat.bes_802_3_dropped_frames;
233 data[i++] = adapter->be_stat.bes_802_3_malformed_frames;
234 data[i++] = adapter->be_stat.bes_rx_misc_pkts;
235 data[i++] = adapter->be_stat.bes_eth_tx_rate;
236 data[i++] = adapter->be_stat.bes_eth_rx_rate;
237 data[i++] = adapter->be_stat.bes_rx_coal;
238 data[i++] = adapter->be_stat.bes_rx_flush;
239
240}
241
242static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
243{
244 ecmd->speed = SPEED_10000;
245 ecmd->duplex = DUPLEX_FULL;
246 ecmd->autoneg = AUTONEG_DISABLE;
247 return 0;
248}
249
250/* Get the Ring parameters from the pnob */
251static void
252be_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
253{
254 struct be_net_object *pnob = netdev_priv(netdev);
255
256 /* Pre Set Maxims */
257 ring->rx_max_pending = pnob->rx_q_len;
258 ring->rx_mini_max_pending = ring->rx_mini_max_pending;
259 ring->rx_jumbo_max_pending = ring->rx_jumbo_max_pending;
260 ring->tx_max_pending = pnob->tx_q_len;
261
262 /* Current hardware Settings */
263 ring->rx_pending = atomic_read(&pnob->rx_q_posted);
264 ring->rx_mini_pending = ring->rx_mini_pending;
265 ring->rx_jumbo_pending = ring->rx_jumbo_pending;
266 ring->tx_pending = atomic_read(&pnob->tx_q_used);
267
268}
269
270static void
271be_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
272{
273 struct be_net_object *pnob = netdev_priv(netdev);
274 bool rxfc, txfc;
275 int status;
276
277 status = be_eth_get_flow_control(&pnob->fn_obj, &txfc, &rxfc);
278 if (status != BE_SUCCESS) {
279 dev_info(&netdev->dev, "Unable to get pause frame settings\n");
280 /* return defaults */
281 ecmd->rx_pause = 1;
282 ecmd->tx_pause = 0;
283 ecmd->autoneg = AUTONEG_ENABLE;
284 return;
285 }
286
287 if (txfc == true)
288 ecmd->tx_pause = 1;
289 else
290 ecmd->tx_pause = 0;
291
292 if (rxfc == true)
293 ecmd->rx_pause = 1;
294 else
295 ecmd->rx_pause = 0;
296
297 ecmd->autoneg = AUTONEG_ENABLE;
298}
299
300static int
301be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
302{
303 struct be_net_object *pnob = netdev_priv(netdev);
304 bool txfc, rxfc;
305 int status;
306
307 if (ecmd->autoneg != AUTONEG_ENABLE)
308 return -EINVAL;
309
310 if (ecmd->tx_pause)
311 txfc = true;
312 else
313 txfc = false;
314
315 if (ecmd->rx_pause)
316 rxfc = true;
317 else
318 rxfc = false;
319
320 status = be_eth_set_flow_control(&pnob->fn_obj, txfc, rxfc);
321 if (status != BE_SUCCESS) {
322 dev_info(&netdev->dev, "Unable to set pause frame settings\n");
323 return -1;
324 }
325 return 0;
326}
327
328struct ethtool_ops be_ethtool_ops = {
329 .get_settings = be_get_settings,
330 .get_drvinfo = be_get_drvinfo,
331 .get_link = ethtool_op_get_link,
332 .get_coalesce = be_get_coalesce,
333 .set_coalesce = be_set_coalesce,
334 .get_ringparam = be_get_ringparam,
335 .get_pauseparam = be_get_pauseparam,
336 .set_pauseparam = be_set_pauseparam,
337 .get_rx_csum = be_get_rx_csum,
338 .set_rx_csum = be_set_rx_csum,
339 .get_tx_csum = ethtool_op_get_tx_csum,
340 .set_tx_csum = ethtool_op_set_tx_csum,
341 .get_sg = ethtool_op_get_sg,
342 .set_sg = ethtool_op_set_sg,
343 .get_tso = ethtool_op_get_tso,
344 .set_tso = ethtool_op_set_tso,
345 .get_strings = be_get_strings,
346 .get_stats_count = be_get_stats_count,
347 .get_ethtool_stats = be_get_ethtool_stats,
348};
diff --git a/drivers/staging/benet/be_init.c b/drivers/staging/benet/be_init.c
deleted file mode 100644
index 12a026c3f9e1..000000000000
--- a/drivers/staging/benet/be_init.c
+++ /dev/null
@@ -1,1382 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#include <linux/etherdevice.h>
18#include "benet.h"
19
20#define DRVR_VERSION "1.0.728"
21
22static const struct pci_device_id be_device_id_table[] = {
23 {PCI_DEVICE(0x19a2, 0x0201)},
24 {0}
25};
26
27MODULE_DEVICE_TABLE(pci, be_device_id_table);
28
29MODULE_VERSION(DRVR_VERSION);
30
31#define DRV_DESCRIPTION "ServerEngines BladeEngine Network Driver Version "
32
33MODULE_DESCRIPTION(DRV_DESCRIPTION DRVR_VERSION);
34MODULE_AUTHOR("ServerEngines");
35MODULE_LICENSE("GPL");
36
37static unsigned int msix = 1;
38module_param(msix, uint, S_IRUGO);
39MODULE_PARM_DESC(msix, "Use MSI-x interrupts");
40
41static unsigned int rxbuf_size = 2048; /* Default RX frag size */
42module_param(rxbuf_size, uint, S_IRUGO);
43MODULE_PARM_DESC(rxbuf_size, "Size of buffers to hold Rx data");
44
45const char be_drvr_ver[] = DRVR_VERSION;
46char be_fw_ver[32]; /* F/W version filled in by be_probe */
47char be_driver_name[] = "benet";
48
49/*
50 * Number of entries in each queue.
51 */
52#define EVENT_Q_LEN 1024
53#define ETH_TXQ_LEN 2048
54#define ETH_TXCQ_LEN 1024
55#define ETH_RXQ_LEN 1024 /* Does not support any other value */
56#define ETH_UC_RXCQ_LEN 1024
57#define ETH_BC_RXCQ_LEN 256
58#define MCC_Q_LEN 64 /* total size not to exceed 8 pages */
59#define MCC_CQ_LEN 256
60
61/* Bit mask describing events of interest to be traced */
62unsigned int trace_level;
63
64static int
65init_pci_be_function(struct be_adapter *adapter, struct pci_dev *pdev)
66{
67 u64 pa;
68
69 /* CSR */
70 pa = pci_resource_start(pdev, 2);
71 adapter->csr_va = ioremap_nocache(pa, pci_resource_len(pdev, 2));
72 if (adapter->csr_va == NULL)
73 return -ENOMEM;
74
75 /* Door Bell */
76 pa = pci_resource_start(pdev, 4);
77 adapter->db_va = ioremap_nocache(pa, (128 * 1024));
78 if (adapter->db_va == NULL) {
79 iounmap(adapter->csr_va);
80 return -ENOMEM;
81 }
82
83 /* PCI */
84 pa = pci_resource_start(pdev, 1);
85 adapter->pci_va = ioremap_nocache(pa, pci_resource_len(pdev, 1));
86 if (adapter->pci_va == NULL) {
87 iounmap(adapter->csr_va);
88 iounmap(adapter->db_va);
89 return -ENOMEM;
90 }
91 return 0;
92}
93
94/*
95 This function enables the interrupt corresponding to the Event
96 queue ID for the given NetObject
97*/
98void be_enable_eq_intr(struct be_net_object *pnob)
99{
100 struct CQ_DB_AMAP cqdb;
101 cqdb.dw[0] = 0;
102 AMAP_SET_BITS_PTR(CQ_DB, event, &cqdb, 1);
103 AMAP_SET_BITS_PTR(CQ_DB, rearm, &cqdb, 1);
104 AMAP_SET_BITS_PTR(CQ_DB, num_popped, &cqdb, 0);
105 AMAP_SET_BITS_PTR(CQ_DB, qid, &cqdb, pnob->event_q_id);
106 PD_WRITE(&pnob->fn_obj, cq_db, cqdb.dw[0]);
107}
108
109/*
110 This function disables the interrupt corresponding to the Event
111 queue ID for the given NetObject
112*/
113void be_disable_eq_intr(struct be_net_object *pnob)
114{
115 struct CQ_DB_AMAP cqdb;
116 cqdb.dw[0] = 0;
117 AMAP_SET_BITS_PTR(CQ_DB, event, &cqdb, 1);
118 AMAP_SET_BITS_PTR(CQ_DB, rearm, &cqdb, 0);
119 AMAP_SET_BITS_PTR(CQ_DB, num_popped, &cqdb, 0);
120 AMAP_SET_BITS_PTR(CQ_DB, qid, &cqdb, pnob->event_q_id);
121 PD_WRITE(&pnob->fn_obj, cq_db, cqdb.dw[0]);
122}
123
124/*
125 This function enables the interrupt from the network function
126 of the BladeEngine. Use the function be_disable_eq_intr()
127 to enable the interrupt from the event queue of only one specific
128 NetObject
129*/
130void be_enable_intr(struct be_net_object *pnob)
131{
132 struct PCICFG_HOST_TIMER_INT_CTRL_CSR_AMAP ctrl;
133 u32 host_intr;
134
135 ctrl.dw[0] = PCICFG1_READ(&pnob->fn_obj, host_timer_int_ctrl);
136 host_intr = AMAP_GET_BITS_PTR(PCICFG_HOST_TIMER_INT_CTRL_CSR,
137 hostintr, ctrl.dw);
138 if (!host_intr) {
139 AMAP_SET_BITS_PTR(PCICFG_HOST_TIMER_INT_CTRL_CSR,
140 hostintr, ctrl.dw, 1);
141 PCICFG1_WRITE(&pnob->fn_obj, host_timer_int_ctrl,
142 ctrl.dw[0]);
143 }
144}
145
146/*
147 This function disables the interrupt from the network function of
148 the BladeEngine. Use the function be_disable_eq_intr() to
149 disable the interrupt from the event queue of only one specific NetObject
150*/
151void be_disable_intr(struct be_net_object *pnob)
152{
153
154 struct PCICFG_HOST_TIMER_INT_CTRL_CSR_AMAP ctrl;
155 u32 host_intr;
156 ctrl.dw[0] = PCICFG1_READ(&pnob->fn_obj, host_timer_int_ctrl);
157 host_intr = AMAP_GET_BITS_PTR(PCICFG_HOST_TIMER_INT_CTRL_CSR,
158 hostintr, ctrl.dw);
159 if (host_intr) {
160 AMAP_SET_BITS_PTR(PCICFG_HOST_TIMER_INT_CTRL_CSR, hostintr,
161 ctrl.dw, 0);
162 PCICFG1_WRITE(&pnob->fn_obj, host_timer_int_ctrl,
163 ctrl.dw[0]);
164 }
165}
166
167static int be_enable_msix(struct be_adapter *adapter)
168{
169 int i, ret;
170
171 if (!msix)
172 return -1;
173
174 for (i = 0; i < BE_MAX_REQ_MSIX_VECTORS; i++)
175 adapter->msix_entries[i].entry = i;
176
177 ret = pci_enable_msix(adapter->pdev, adapter->msix_entries,
178 BE_MAX_REQ_MSIX_VECTORS);
179
180 if (ret == 0)
181 adapter->msix_enabled = 1;
182 return ret;
183}
184
185static int be_register_isr(struct be_adapter *adapter,
186 struct be_net_object *pnob)
187{
188 struct net_device *netdev = pnob->netdev;
189 int intx = 0, r;
190
191 netdev->irq = adapter->pdev->irq;
192 r = be_enable_msix(adapter);
193
194 if (r == 0) {
195 r = request_irq(adapter->msix_entries[0].vector,
196 be_int, IRQF_SHARED, netdev->name, netdev);
197 if (r) {
198 printk(KERN_WARNING
199 "MSIX Request IRQ failed - Errno %d\n", r);
200 intx = 1;
201 pci_disable_msix(adapter->pdev);
202 adapter->msix_enabled = 0;
203 }
204 } else {
205 intx = 1;
206 }
207
208 if (intx) {
209 r = request_irq(netdev->irq, be_int, IRQF_SHARED,
210 netdev->name, netdev);
211 if (r) {
212 printk(KERN_WARNING
213 "INTx Request IRQ failed - Errno %d\n", r);
214 return -1;
215 }
216 }
217 adapter->isr_registered = 1;
218 return 0;
219}
220
221static void be_unregister_isr(struct be_adapter *adapter)
222{
223 struct net_device *netdev = adapter->netdevp;
224 if (adapter->isr_registered) {
225 if (adapter->msix_enabled) {
226 free_irq(adapter->msix_entries[0].vector, netdev);
227 pci_disable_msix(adapter->pdev);
228 adapter->msix_enabled = 0;
229 } else {
230 free_irq(netdev->irq, netdev);
231 }
232 adapter->isr_registered = 0;
233 }
234}
235
236/*
237 This function processes the Flush Completions that are issued by the
238 ARM F/W, when a Recv Ring is destroyed. A flush completion is
239 identified when a Rx COmpl descriptor has the tcpcksum and udpcksum
240 set and the pktsize is 32. These completions are received on the
241 Rx Completion Queue.
242*/
243static u32 be_process_rx_flush_cmpl(struct be_net_object *pnob)
244{
245 struct ETH_RX_COMPL_AMAP *rxcp;
246 unsigned int i = 0;
247 while ((rxcp = be_get_rx_cmpl(pnob)) != NULL) {
248 be_notify_cmpl(pnob, 1, pnob->rx_cq_id, 1);
249 i++;
250 }
251 return i;
252}
253
254static void be_tx_q_clean(struct be_net_object *pnob)
255{
256 while (atomic_read(&pnob->tx_q_used))
257 process_one_tx_compl(pnob, tx_compl_lastwrb_idx_get(pnob));
258}
259
260static void be_rx_q_clean(struct be_net_object *pnob)
261{
262 if (pnob->rx_ctxt) {
263 int i;
264 struct be_rx_page_info *rx_page_info;
265 for (i = 0; i < pnob->rx_q_len; i++) {
266 rx_page_info = &(pnob->rx_page_info[i]);
267 if (!pnob->rx_pg_shared || rx_page_info->page_offset) {
268 pci_unmap_page(pnob->adapter->pdev,
269 pci_unmap_addr(rx_page_info, bus),
270 pnob->rx_buf_size,
271 PCI_DMA_FROMDEVICE);
272 }
273 if (rx_page_info->page)
274 put_page(rx_page_info->page);
275 memset(rx_page_info, 0, sizeof(struct be_rx_page_info));
276 }
277 pnob->rx_pg_info_hd = 0;
278 }
279}
280
281static void be_destroy_netobj(struct be_net_object *pnob)
282{
283 int status;
284
285 if (pnob->tx_q_created) {
286 status = be_eth_sq_destroy(&pnob->tx_q_obj);
287 pnob->tx_q_created = 0;
288 }
289
290 if (pnob->rx_q_created) {
291 status = be_eth_rq_destroy(&pnob->rx_q_obj);
292 if (status != 0) {
293 status = be_eth_rq_destroy_options(&pnob->rx_q_obj, 0,
294 NULL, NULL);
295 BUG_ON(status);
296 }
297 pnob->rx_q_created = 0;
298 }
299
300 be_process_rx_flush_cmpl(pnob);
301
302 if (pnob->tx_cq_created) {
303 status = be_cq_destroy(&pnob->tx_cq_obj);
304 pnob->tx_cq_created = 0;
305 }
306
307 if (pnob->rx_cq_created) {
308 status = be_cq_destroy(&pnob->rx_cq_obj);
309 pnob->rx_cq_created = 0;
310 }
311
312 if (pnob->mcc_q_created) {
313 status = be_mcc_ring_destroy(&pnob->mcc_q_obj);
314 pnob->mcc_q_created = 0;
315 }
316 if (pnob->mcc_cq_created) {
317 status = be_cq_destroy(&pnob->mcc_cq_obj);
318 pnob->mcc_cq_created = 0;
319 }
320
321 if (pnob->event_q_created) {
322 status = be_eq_destroy(&pnob->event_q_obj);
323 pnob->event_q_created = 0;
324 }
325 be_function_cleanup(&pnob->fn_obj);
326}
327
328/*
329 * free all resources associated with a pnob
330 * Called at the time of module cleanup as well a any error during
331 * module init. Some resources may be partially allocated in a NetObj.
332 */
333static void netobject_cleanup(struct be_adapter *adapter,
334 struct be_net_object *pnob)
335{
336 struct net_device *netdev = adapter->netdevp;
337
338 if (netif_running(netdev)) {
339 netif_stop_queue(netdev);
340 be_wait_nic_tx_cmplx_cmpl(pnob);
341 be_disable_eq_intr(pnob);
342 }
343
344 be_unregister_isr(adapter);
345
346 if (adapter->tasklet_started) {
347 tasklet_kill(&(adapter->sts_handler));
348 adapter->tasklet_started = 0;
349 }
350 if (pnob->fn_obj_created)
351 be_disable_intr(pnob);
352
353 if (adapter->dev_state != BE_DEV_STATE_NONE)
354 unregister_netdev(netdev);
355
356 if (pnob->fn_obj_created)
357 be_destroy_netobj(pnob);
358
359 adapter->net_obj = NULL;
360 adapter->netdevp = NULL;
361
362 be_rx_q_clean(pnob);
363 if (pnob->rx_ctxt) {
364 kfree(pnob->rx_page_info);
365 kfree(pnob->rx_ctxt);
366 }
367
368 be_tx_q_clean(pnob);
369 kfree(pnob->tx_ctxt);
370
371 if (pnob->mcc_q)
372 pci_free_consistent(adapter->pdev, pnob->mcc_q_size,
373 pnob->mcc_q, pnob->mcc_q_bus);
374
375 if (pnob->mcc_wrb_ctxt)
376 free_pages((unsigned long)pnob->mcc_wrb_ctxt,
377 get_order(pnob->mcc_wrb_ctxt_size));
378
379 if (pnob->mcc_cq)
380 pci_free_consistent(adapter->pdev, pnob->mcc_cq_size,
381 pnob->mcc_cq, pnob->mcc_cq_bus);
382
383 if (pnob->event_q)
384 pci_free_consistent(adapter->pdev, pnob->event_q_size,
385 pnob->event_q, pnob->event_q_bus);
386
387 if (pnob->tx_cq)
388 pci_free_consistent(adapter->pdev, pnob->tx_cq_size,
389 pnob->tx_cq, pnob->tx_cq_bus);
390
391 if (pnob->tx_q)
392 pci_free_consistent(adapter->pdev, pnob->tx_q_size,
393 pnob->tx_q, pnob->tx_q_bus);
394
395 if (pnob->rx_q)
396 pci_free_consistent(adapter->pdev, pnob->rx_q_size,
397 pnob->rx_q, pnob->rx_q_bus);
398
399 if (pnob->rx_cq)
400 pci_free_consistent(adapter->pdev, pnob->rx_cq_size,
401 pnob->rx_cq, pnob->rx_cq_bus);
402
403
404 if (pnob->mb_ptr)
405 pci_free_consistent(adapter->pdev, pnob->mb_size, pnob->mb_ptr,
406 pnob->mb_bus);
407
408 free_netdev(netdev);
409}
410
411
412static int be_nob_ring_alloc(struct be_adapter *adapter,
413 struct be_net_object *pnob)
414{
415 u32 size;
416
417 /* Mail box rd; mailbox pointer needs to be 16 byte aligned */
418 pnob->mb_size = sizeof(struct MCC_MAILBOX_AMAP) + 16;
419 pnob->mb_ptr = pci_alloc_consistent(adapter->pdev, pnob->mb_size,
420 &pnob->mb_bus);
421 if (!pnob->mb_bus)
422 return -1;
423 memset(pnob->mb_ptr, 0, pnob->mb_size);
424 pnob->mb_rd.va = PTR_ALIGN(pnob->mb_ptr, 16);
425 pnob->mb_rd.pa = PTR_ALIGN(pnob->mb_bus, 16);
426 pnob->mb_rd.length = sizeof(struct MCC_MAILBOX_AMAP);
427 /*
428 * Event queue
429 */
430 pnob->event_q_len = EVENT_Q_LEN;
431 pnob->event_q_size = pnob->event_q_len * sizeof(struct EQ_ENTRY_AMAP);
432 pnob->event_q = pci_alloc_consistent(adapter->pdev, pnob->event_q_size,
433 &pnob->event_q_bus);
434 if (!pnob->event_q_bus)
435 return -1;
436 memset(pnob->event_q, 0, pnob->event_q_size);
437 /*
438 * Eth TX queue
439 */
440 pnob->tx_q_len = ETH_TXQ_LEN;
441 pnob->tx_q_port = 0;
442 pnob->tx_q_size = pnob->tx_q_len * sizeof(struct ETH_WRB_AMAP);
443 pnob->tx_q = pci_alloc_consistent(adapter->pdev, pnob->tx_q_size,
444 &pnob->tx_q_bus);
445 if (!pnob->tx_q_bus)
446 return -1;
447 memset(pnob->tx_q, 0, pnob->tx_q_size);
448 /*
449 * Eth TX Compl queue
450 */
451 pnob->txcq_len = ETH_TXCQ_LEN;
452 pnob->tx_cq_size = pnob->txcq_len * sizeof(struct ETH_TX_COMPL_AMAP);
453 pnob->tx_cq = pci_alloc_consistent(adapter->pdev, pnob->tx_cq_size,
454 &pnob->tx_cq_bus);
455 if (!pnob->tx_cq_bus)
456 return -1;
457 memset(pnob->tx_cq, 0, pnob->tx_cq_size);
458 /*
459 * Eth RX queue
460 */
461 pnob->rx_q_len = ETH_RXQ_LEN;
462 pnob->rx_q_size = pnob->rx_q_len * sizeof(struct ETH_RX_D_AMAP);
463 pnob->rx_q = pci_alloc_consistent(adapter->pdev, pnob->rx_q_size,
464 &pnob->rx_q_bus);
465 if (!pnob->rx_q_bus)
466 return -1;
467 memset(pnob->rx_q, 0, pnob->rx_q_size);
468 /*
469 * Eth Unicast RX Compl queue
470 */
471 pnob->rx_cq_len = ETH_UC_RXCQ_LEN;
472 pnob->rx_cq_size = pnob->rx_cq_len *
473 sizeof(struct ETH_RX_COMPL_AMAP);
474 pnob->rx_cq = pci_alloc_consistent(adapter->pdev, pnob->rx_cq_size,
475 &pnob->rx_cq_bus);
476 if (!pnob->rx_cq_bus)
477 return -1;
478 memset(pnob->rx_cq, 0, pnob->rx_cq_size);
479
480 /* TX resources */
481 size = pnob->tx_q_len * sizeof(void **);
482 pnob->tx_ctxt = kzalloc(size, GFP_KERNEL);
483 if (pnob->tx_ctxt == NULL)
484 return -1;
485
486 /* RX resources */
487 size = pnob->rx_q_len * sizeof(void *);
488 pnob->rx_ctxt = kzalloc(size, GFP_KERNEL);
489 if (pnob->rx_ctxt == NULL)
490 return -1;
491
492 size = (pnob->rx_q_len * sizeof(struct be_rx_page_info));
493 pnob->rx_page_info = kzalloc(size, GFP_KERNEL);
494 if (pnob->rx_page_info == NULL)
495 return -1;
496
497 adapter->eth_statsp = kzalloc(sizeof(struct FWCMD_ETH_GET_STATISTICS),
498 GFP_KERNEL);
499 if (adapter->eth_statsp == NULL)
500 return -1;
501 pnob->rx_buf_size = rxbuf_size;
502 return 0;
503}
504
505/*
506 This function initializes the be_net_object for subsequent
507 network operations.
508
509 Before calling this function, the driver must have allocated
510 space for the NetObject structure, initialized the structure,
511 allocated DMAable memory for all the network queues that form
512 part of the NetObject and populated the start address (virtual)
513 and number of entries allocated for each queue in the NetObject structure.
514
515 The driver must also have allocated memory to hold the
516 mailbox structure (MCC_MAILBOX) and post the physical address,
517 virtual addresses and the size of the mailbox memory in the
518 NetObj.mb_rd. This structure is used by BECLIB for
519 initial communication with the embedded MCC processor. BECLIB
520 uses the mailbox until MCC rings are created for more efficient
521 communication with the MCC processor.
522
523 If the driver wants to create multiple network interface for more
524 than one protection domain, it can call be_create_netobj()
525 multiple times once for each protection domain. A Maximum of
526 32 protection domains are supported.
527
528*/
529static int
530be_create_netobj(struct be_net_object *pnob, u8 __iomem *csr_va,
531 u8 __iomem *db_va, u8 __iomem *pci_va)
532{
533 int status = 0;
534 bool eventable = false, tx_no_delay = false, rx_no_delay = false;
535 struct be_eq_object *eq_objectp = NULL;
536 struct be_function_object *pfob = &pnob->fn_obj;
537 struct ring_desc rd;
538 u32 set_rxbuf_size;
539 u32 tx_cmpl_wm = CEV_WMARK_96; /* 0xffffffff to disable */
540 u32 rx_cmpl_wm = CEV_WMARK_160; /* 0xffffffff to disable */
541 u32 eq_delay = 0; /* delay in 8usec units. 0xffffffff to disable */
542
543 memset(&rd, 0, sizeof(struct ring_desc));
544
545 status = be_function_object_create(csr_va, db_va, pci_va,
546 BE_FUNCTION_TYPE_NETWORK, &pnob->mb_rd, pfob);
547 if (status != BE_SUCCESS)
548 return status;
549 pnob->fn_obj_created = true;
550
551 if (tx_cmpl_wm == 0xffffffff)
552 tx_no_delay = true;
553 if (rx_cmpl_wm == 0xffffffff)
554 rx_no_delay = true;
555 /*
556 * now create the necessary rings
557 * Event Queue first.
558 */
559 if (pnob->event_q_len) {
560 rd.va = pnob->event_q;
561 rd.pa = pnob->event_q_bus;
562 rd.length = pnob->event_q_size;
563
564 status = be_eq_create(pfob, &rd, 4, pnob->event_q_len,
565 (u32) -1, /* CEV_WMARK_* or -1 */
566 eq_delay, /* in 8us units, or -1 */
567 &pnob->event_q_obj);
568 if (status != BE_SUCCESS)
569 goto error_ret;
570 pnob->event_q_id = pnob->event_q_obj.eq_id;
571 pnob->event_q_created = 1;
572 eventable = true;
573 eq_objectp = &pnob->event_q_obj;
574 }
575 /*
576 * Now Eth Tx Compl. queue.
577 */
578 if (pnob->txcq_len) {
579 rd.va = pnob->tx_cq;
580 rd.pa = pnob->tx_cq_bus;
581 rd.length = pnob->tx_cq_size;
582
583 status = be_cq_create(pfob, &rd,
584 pnob->txcq_len * sizeof(struct ETH_TX_COMPL_AMAP),
585 false, /* solicted events, */
586 tx_no_delay, /* nodelay */
587 tx_cmpl_wm, /* Watermark encodings */
588 eq_objectp, &pnob->tx_cq_obj);
589 if (status != BE_SUCCESS)
590 goto error_ret;
591
592 pnob->tx_cq_id = pnob->tx_cq_obj.cq_id;
593 pnob->tx_cq_created = 1;
594 }
595 /*
596 * Eth Tx queue
597 */
598 if (pnob->tx_q_len) {
599 struct be_eth_sq_parameters ex_params = { 0 };
600 u32 type;
601
602 if (pnob->tx_q_port) {
603 /* TXQ to be bound to a specific port */
604 type = BE_ETH_TX_RING_TYPE_BOUND;
605 ex_params.port = pnob->tx_q_port - 1;
606 } else
607 type = BE_ETH_TX_RING_TYPE_STANDARD;
608
609 rd.va = pnob->tx_q;
610 rd.pa = pnob->tx_q_bus;
611 rd.length = pnob->tx_q_size;
612
613 status = be_eth_sq_create_ex(pfob, &rd,
614 pnob->tx_q_len * sizeof(struct ETH_WRB_AMAP),
615 type, 2, &pnob->tx_cq_obj,
616 &ex_params, &pnob->tx_q_obj);
617
618 if (status != BE_SUCCESS)
619 goto error_ret;
620
621 pnob->tx_q_id = pnob->tx_q_obj.bid;
622 pnob->tx_q_created = 1;
623 }
624 /*
625 * Now Eth Rx compl. queue. Always needed.
626 */
627 rd.va = pnob->rx_cq;
628 rd.pa = pnob->rx_cq_bus;
629 rd.length = pnob->rx_cq_size;
630
631 status = be_cq_create(pfob, &rd,
632 pnob->rx_cq_len * sizeof(struct ETH_RX_COMPL_AMAP),
633 false, /* solicted events, */
634 rx_no_delay, /* nodelay */
635 rx_cmpl_wm, /* Watermark encodings */
636 eq_objectp, &pnob->rx_cq_obj);
637 if (status != BE_SUCCESS)
638 goto error_ret;
639
640 pnob->rx_cq_id = pnob->rx_cq_obj.cq_id;
641 pnob->rx_cq_created = 1;
642
643 status = be_eth_rq_set_frag_size(pfob, pnob->rx_buf_size,
644 (u32 *) &set_rxbuf_size);
645 if (status != BE_SUCCESS) {
646 be_eth_rq_get_frag_size(pfob, (u32 *) &pnob->rx_buf_size);
647 if ((pnob->rx_buf_size != 2048) && (pnob->rx_buf_size != 4096)
648 && (pnob->rx_buf_size != 8192))
649 goto error_ret;
650 } else {
651 if (pnob->rx_buf_size != set_rxbuf_size)
652 pnob->rx_buf_size = set_rxbuf_size;
653 }
654 /*
655 * Eth RX queue. be_eth_rq_create() always assumes 2 pages size
656 */
657 rd.va = pnob->rx_q;
658 rd.pa = pnob->rx_q_bus;
659 rd.length = pnob->rx_q_size;
660
661 status = be_eth_rq_create(pfob, &rd, &pnob->rx_cq_obj,
662 &pnob->rx_cq_obj, &pnob->rx_q_obj);
663
664 if (status != BE_SUCCESS)
665 goto error_ret;
666
667 pnob->rx_q_id = pnob->rx_q_obj.rid;
668 pnob->rx_q_created = 1;
669
670 return BE_SUCCESS; /* All required queues created. */
671
672error_ret:
673 be_destroy_netobj(pnob);
674 return status;
675}
676
677static int be_nob_ring_init(struct be_adapter *adapter,
678 struct be_net_object *pnob)
679{
680 int status;
681
682 pnob->event_q_tl = 0;
683
684 pnob->tx_q_hd = 0;
685 pnob->tx_q_tl = 0;
686
687 pnob->tx_cq_tl = 0;
688
689 pnob->rx_cq_tl = 0;
690
691 memset(pnob->event_q, 0, pnob->event_q_size);
692 memset(pnob->tx_cq, 0, pnob->tx_cq_size);
693 memset(pnob->tx_ctxt, 0, pnob->tx_q_len * sizeof(void **));
694 memset(pnob->rx_ctxt, 0, pnob->rx_q_len * sizeof(void *));
695 pnob->rx_pg_info_hd = 0;
696 pnob->rx_q_hd = 0;
697 atomic_set(&pnob->rx_q_posted, 0);
698
699 status = be_create_netobj(pnob, adapter->csr_va, adapter->db_va,
700 adapter->pci_va);
701 if (status != BE_SUCCESS)
702 return -1;
703
704 be_post_eth_rx_buffs(pnob);
705 return 0;
706}
707
708/* This function handles async callback for link status */
709static void
710be_link_status_async_callback(void *context, u32 event_code, void *event)
711{
712 struct ASYNC_EVENT_LINK_STATE_AMAP *link_status = event;
713 struct be_adapter *adapter = context;
714 bool link_enable = false;
715 struct be_net_object *pnob;
716 struct ASYNC_EVENT_TRAILER_AMAP *async_trailer;
717 struct net_device *netdev;
718 u32 async_event_code, async_event_type, active_port;
719 u32 port0_link_status, port1_link_status, port0_duplex, port1_duplex;
720 u32 port0_speed, port1_speed;
721
722 if (event_code != ASYNC_EVENT_CODE_LINK_STATE) {
723 /* Not our event to handle */
724 return;
725 }
726 async_trailer = (struct ASYNC_EVENT_TRAILER_AMAP *)
727 ((u8 *) event + sizeof(struct MCC_CQ_ENTRY_AMAP) -
728 sizeof(struct ASYNC_EVENT_TRAILER_AMAP));
729
730 async_event_code = AMAP_GET_BITS_PTR(ASYNC_EVENT_TRAILER, event_code,
731 async_trailer);
732 BUG_ON(async_event_code != ASYNC_EVENT_CODE_LINK_STATE);
733
734 pnob = adapter->net_obj;
735 netdev = pnob->netdev;
736
737 /* Determine if this event is a switch VLD or a physical link event */
738 async_event_type = AMAP_GET_BITS_PTR(ASYNC_EVENT_TRAILER, event_type,
739 async_trailer);
740 active_port = AMAP_GET_BITS_PTR(ASYNC_EVENT_LINK_STATE,
741 active_port, link_status);
742 port0_link_status = AMAP_GET_BITS_PTR(ASYNC_EVENT_LINK_STATE,
743 port0_link_status, link_status);
744 port1_link_status = AMAP_GET_BITS_PTR(ASYNC_EVENT_LINK_STATE,
745 port1_link_status, link_status);
746 port0_duplex = AMAP_GET_BITS_PTR(ASYNC_EVENT_LINK_STATE,
747 port0_duplex, link_status);
748 port1_duplex = AMAP_GET_BITS_PTR(ASYNC_EVENT_LINK_STATE,
749 port1_duplex, link_status);
750 port0_speed = AMAP_GET_BITS_PTR(ASYNC_EVENT_LINK_STATE,
751 port0_speed, link_status);
752 port1_speed = AMAP_GET_BITS_PTR(ASYNC_EVENT_LINK_STATE,
753 port1_speed, link_status);
754 if (async_event_type == NTWK_LINK_TYPE_VIRTUAL) {
755 adapter->be_stat.bes_link_change_virtual++;
756 if (adapter->be_link_sts->active_port != active_port) {
757 dev_notice(&netdev->dev,
758 "Active port changed due to VLD on switch\n");
759 } else {
760 dev_notice(&netdev->dev, "Link status update\n");
761 }
762
763 } else {
764 adapter->be_stat.bes_link_change_physical++;
765 if (adapter->be_link_sts->active_port != active_port) {
766 dev_notice(&netdev->dev,
767 "Active port changed due to port link"
768 " status change\n");
769 } else {
770 dev_notice(&netdev->dev, "Link status update\n");
771 }
772 }
773
774 memset(adapter->be_link_sts, 0, sizeof(adapter->be_link_sts));
775
776 if ((port0_link_status == ASYNC_EVENT_LINK_UP) ||
777 (port1_link_status == ASYNC_EVENT_LINK_UP)) {
778 if ((adapter->port0_link_sts == BE_PORT_LINK_DOWN) &&
779 (adapter->port1_link_sts == BE_PORT_LINK_DOWN)) {
780 /* Earlier both the ports are down So link is up */
781 link_enable = true;
782 }
783
784 if (port0_link_status == ASYNC_EVENT_LINK_UP) {
785 adapter->port0_link_sts = BE_PORT_LINK_UP;
786 adapter->be_link_sts->mac0_duplex = port0_duplex;
787 adapter->be_link_sts->mac0_speed = port0_speed;
788 if (active_port == NTWK_PORT_A)
789 adapter->be_link_sts->active_port = 0;
790 } else
791 adapter->port0_link_sts = BE_PORT_LINK_DOWN;
792
793 if (port1_link_status == ASYNC_EVENT_LINK_UP) {
794 adapter->port1_link_sts = BE_PORT_LINK_UP;
795 adapter->be_link_sts->mac1_duplex = port1_duplex;
796 adapter->be_link_sts->mac1_speed = port1_speed;
797 if (active_port == NTWK_PORT_B)
798 adapter->be_link_sts->active_port = 1;
799 } else
800 adapter->port1_link_sts = BE_PORT_LINK_DOWN;
801
802 printk(KERN_INFO "Link Properties for %s:\n", netdev->name);
803 dev_info(&netdev->dev, "Link Properties:\n");
804 be_print_link_info(adapter->be_link_sts);
805
806 if (!link_enable)
807 return;
808 /*
809 * Both ports were down previously, but atleast one of
810 * them has come up if this netdevice's carrier is not up,
811 * then indicate to stack
812 */
813 if (!netif_carrier_ok(netdev)) {
814 netif_start_queue(netdev);
815 netif_carrier_on(netdev);
816 }
817 return;
818 }
819
820 /* Now both the ports are down. Tell the stack about it */
821 dev_info(&netdev->dev, "Both ports are down\n");
822 adapter->port0_link_sts = BE_PORT_LINK_DOWN;
823 adapter->port1_link_sts = BE_PORT_LINK_DOWN;
824 if (netif_carrier_ok(netdev)) {
825 netif_carrier_off(netdev);
826 netif_stop_queue(netdev);
827 }
828 return;
829}
830
831static int be_mcc_create(struct be_adapter *adapter)
832{
833 struct be_net_object *pnob;
834
835 pnob = adapter->net_obj;
836 /*
837 * Create the MCC ring so that all further communication with
838 * MCC can go thru the ring. we do this at the end since
839 * we do not want to be dealing with interrupts until the
840 * initialization is complete.
841 */
842 pnob->mcc_q_len = MCC_Q_LEN;
843 pnob->mcc_q_size = pnob->mcc_q_len * sizeof(struct MCC_WRB_AMAP);
844 pnob->mcc_q = pci_alloc_consistent(adapter->pdev, pnob->mcc_q_size,
845 &pnob->mcc_q_bus);
846 if (!pnob->mcc_q_bus)
847 return -1;
848 /*
849 * space for MCC WRB context
850 */
851 pnob->mcc_wrb_ctxtLen = MCC_Q_LEN;
852 pnob->mcc_wrb_ctxt_size = pnob->mcc_wrb_ctxtLen *
853 sizeof(struct be_mcc_wrb_context);
854 pnob->mcc_wrb_ctxt = (void *)__get_free_pages(GFP_KERNEL,
855 get_order(pnob->mcc_wrb_ctxt_size));
856 if (pnob->mcc_wrb_ctxt == NULL)
857 return -1;
858 /*
859 * Space for MCC compl. ring
860 */
861 pnob->mcc_cq_len = MCC_CQ_LEN;
862 pnob->mcc_cq_size = pnob->mcc_cq_len * sizeof(struct MCC_CQ_ENTRY_AMAP);
863 pnob->mcc_cq = pci_alloc_consistent(adapter->pdev, pnob->mcc_cq_size,
864 &pnob->mcc_cq_bus);
865 if (!pnob->mcc_cq_bus)
866 return -1;
867 return 0;
868}
869
870/*
871 This function creates the MCC request and completion ring required
872 for communicating with the ARM processor. The caller must have
873 allocated required amount of memory for the MCC ring and MCC
874 completion ring and posted the virtual address and number of
875 entries in the corresponding members (mcc_q and mcc_cq) in the
876 NetObject struture.
877
878 When this call is completed, all further communication with
879 ARM will switch from mailbox to this ring.
880
881 pnob - Pointer to the NetObject structure. This NetObject should
882 have been created using a previous call to be_create_netobj()
883*/
884int be_create_mcc_rings(struct be_net_object *pnob)
885{
886 int status = 0;
887 struct ring_desc rd;
888 struct be_function_object *pfob = &pnob->fn_obj;
889
890 memset(&rd, 0, sizeof(struct ring_desc));
891 if (pnob->mcc_cq_len) {
892 rd.va = pnob->mcc_cq;
893 rd.pa = pnob->mcc_cq_bus;
894 rd.length = pnob->mcc_cq_size;
895
896 status = be_cq_create(pfob, &rd,
897 pnob->mcc_cq_len * sizeof(struct MCC_CQ_ENTRY_AMAP),
898 false, /* solicted events, */
899 true, /* nodelay */
900 0, /* 0 Watermark since Nodelay is true */
901 &pnob->event_q_obj,
902 &pnob->mcc_cq_obj);
903
904 if (status != BE_SUCCESS)
905 return status;
906
907 pnob->mcc_cq_id = pnob->mcc_cq_obj.cq_id;
908 pnob->mcc_cq_created = 1;
909 }
910 if (pnob->mcc_q_len) {
911 rd.va = pnob->mcc_q;
912 rd.pa = pnob->mcc_q_bus;
913 rd.length = pnob->mcc_q_size;
914
915 status = be_mcc_ring_create(pfob, &rd,
916 pnob->mcc_q_len * sizeof(struct MCC_WRB_AMAP),
917 pnob->mcc_wrb_ctxt, pnob->mcc_wrb_ctxtLen,
918 &pnob->mcc_cq_obj, &pnob->mcc_q_obj);
919
920 if (status != BE_SUCCESS)
921 return status;
922
923 pnob->mcc_q_created = 1;
924 }
925 return BE_SUCCESS;
926}
927
928static int be_mcc_init(struct be_adapter *adapter)
929{
930 u32 r;
931 struct be_net_object *pnob;
932
933 pnob = adapter->net_obj;
934 memset(pnob->mcc_q, 0, pnob->mcc_q_size);
935 pnob->mcc_q_hd = 0;
936
937 memset(pnob->mcc_wrb_ctxt, 0, pnob->mcc_wrb_ctxt_size);
938
939 memset(pnob->mcc_cq, 0, pnob->mcc_cq_size);
940 pnob->mcc_cq_tl = 0;
941
942 r = be_create_mcc_rings(adapter->net_obj);
943 if (r != BE_SUCCESS)
944 return -1;
945
946 return 0;
947}
948
949static void be_remove(struct pci_dev *pdev)
950{
951 struct be_net_object *pnob;
952 struct be_adapter *adapter;
953
954 adapter = pci_get_drvdata(pdev);
955 if (!adapter)
956 return;
957
958 pci_set_drvdata(pdev, NULL);
959 pnob = (struct be_net_object *)adapter->net_obj;
960
961 flush_scheduled_work();
962
963 if (pnob) {
964 /* Unregister async callback function for link status updates */
965 if (pnob->mcc_q_created)
966 be_mcc_add_async_event_callback(&pnob->mcc_q_obj,
967 NULL, NULL);
968 netobject_cleanup(adapter, pnob);
969 }
970
971 if (adapter->csr_va)
972 iounmap(adapter->csr_va);
973 if (adapter->db_va)
974 iounmap(adapter->db_va);
975 if (adapter->pci_va)
976 iounmap(adapter->pci_va);
977
978 pci_release_regions(adapter->pdev);
979 pci_disable_device(adapter->pdev);
980
981 kfree(adapter->be_link_sts);
982 kfree(adapter->eth_statsp);
983
984 if (adapter->timer_ctxt.get_stats_timer.function)
985 del_timer_sync(&adapter->timer_ctxt.get_stats_timer);
986 kfree(adapter);
987}
988
989/*
990 * This function is called by the PCI sub-system when it finds a PCI
991 * device with dev/vendor IDs that match with one of our devices.
992 * All of the driver initialization is done in this function.
993 */
994static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id)
995{
996 int status = 0;
997 struct be_adapter *adapter;
998 struct FWCMD_COMMON_GET_FW_VERSION_RESPONSE_PAYLOAD get_fwv;
999 struct be_net_object *pnob;
1000 struct net_device *netdev;
1001
1002 status = pci_enable_device(pdev);
1003 if (status)
1004 goto error;
1005
1006 status = pci_request_regions(pdev, be_driver_name);
1007 if (status)
1008 goto error_pci_req;
1009
1010 pci_set_master(pdev);
1011 adapter = kzalloc(sizeof(struct be_adapter), GFP_KERNEL);
1012 if (adapter == NULL) {
1013 status = -ENOMEM;
1014 goto error_adapter;
1015 }
1016 adapter->dev_state = BE_DEV_STATE_NONE;
1017 adapter->pdev = pdev;
1018 pci_set_drvdata(pdev, adapter);
1019
1020 adapter->enable_aic = 1;
1021 adapter->max_eqd = MAX_EQD;
1022 adapter->min_eqd = 0;
1023 adapter->cur_eqd = 0;
1024
1025 status = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
1026 if (!status) {
1027 adapter->dma_64bit_cap = true;
1028 } else {
1029 adapter->dma_64bit_cap = false;
1030 status = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
1031 if (status != 0) {
1032 printk(KERN_ERR "Could not set PCI DMA Mask\n");
1033 goto cleanup;
1034 }
1035 }
1036
1037 status = init_pci_be_function(adapter, pdev);
1038 if (status != 0) {
1039 printk(KERN_ERR "Failed to map PCI BARS\n");
1040 status = -ENOMEM;
1041 goto cleanup;
1042 }
1043
1044 be_trace_set_level(DL_ALWAYS | DL_ERR);
1045
1046 adapter->be_link_sts = kmalloc(sizeof(struct BE_LINK_STATUS),
1047 GFP_KERNEL);
1048 if (adapter->be_link_sts == NULL) {
1049 printk(KERN_ERR "Memory allocation for link status "
1050 "buffer failed\n");
1051 goto cleanup;
1052 }
1053 spin_lock_init(&adapter->txq_lock);
1054
1055 netdev = alloc_etherdev(sizeof(struct be_net_object));
1056 if (netdev == NULL) {
1057 status = -ENOMEM;
1058 goto cleanup;
1059 }
1060 pnob = netdev_priv(netdev);
1061 adapter->net_obj = pnob;
1062 adapter->netdevp = netdev;
1063 pnob->adapter = adapter;
1064 pnob->netdev = netdev;
1065
1066 status = be_nob_ring_alloc(adapter, pnob);
1067 if (status != 0)
1068 goto cleanup;
1069
1070 status = be_nob_ring_init(adapter, pnob);
1071 if (status != 0)
1072 goto cleanup;
1073
1074 be_rxf_mac_address_read_write(&pnob->fn_obj, false, false, false,
1075 false, false, netdev->dev_addr, NULL, NULL);
1076
1077 netdev->init = &benet_init;
1078 netif_carrier_off(netdev);
1079 netif_stop_queue(netdev);
1080
1081 SET_NETDEV_DEV(netdev, &(adapter->pdev->dev));
1082
1083 netif_napi_add(netdev, &pnob->napi, be_poll, 64);
1084
1085 /* if the rx_frag size if 2K, one page is shared as two RX frags */
1086 pnob->rx_pg_shared =
1087 (pnob->rx_buf_size <= PAGE_SIZE / 2) ? true : false;
1088 if (pnob->rx_buf_size != rxbuf_size) {
1089 printk(KERN_WARNING
1090 "Could not set Rx buffer size to %d. Using %d\n",
1091 rxbuf_size, pnob->rx_buf_size);
1092 rxbuf_size = pnob->rx_buf_size;
1093 }
1094
1095 tasklet_init(&(adapter->sts_handler), be_process_intr,
1096 (unsigned long)adapter);
1097 adapter->tasklet_started = 1;
1098 spin_lock_init(&(adapter->int_lock));
1099
1100 status = be_register_isr(adapter, pnob);
1101 if (status != 0)
1102 goto cleanup;
1103
1104 adapter->rx_csum = 1;
1105 adapter->max_rx_coal = BE_LRO_MAX_PKTS;
1106
1107 memset(&get_fwv, 0,
1108 sizeof(struct FWCMD_COMMON_GET_FW_VERSION_RESPONSE_PAYLOAD));
1109 printk(KERN_INFO "BladeEngine Driver version:%s. "
1110 "Copyright ServerEngines, Corporation 2005 - 2008\n",
1111 be_drvr_ver);
1112 status = be_function_get_fw_version(&pnob->fn_obj, &get_fwv, NULL,
1113 NULL);
1114 if (status == BE_SUCCESS) {
1115 strncpy(be_fw_ver, get_fwv.firmware_version_string, 32);
1116 printk(KERN_INFO "BladeEngine Firmware Version:%s\n",
1117 get_fwv.firmware_version_string);
1118 } else {
1119 printk(KERN_WARNING "Unable to get BE Firmware Version\n");
1120 }
1121
1122 sema_init(&adapter->get_eth_stat_sem, 0);
1123 init_timer(&adapter->timer_ctxt.get_stats_timer);
1124 atomic_set(&adapter->timer_ctxt.get_stat_flag, 0);
1125 adapter->timer_ctxt.get_stats_timer.function =
1126 &be_get_stats_timer_handler;
1127
1128 status = be_mcc_create(adapter);
1129 if (status < 0)
1130 goto cleanup;
1131 status = be_mcc_init(adapter);
1132 if (status < 0)
1133 goto cleanup;
1134
1135
1136 status = be_mcc_add_async_event_callback(&adapter->net_obj->mcc_q_obj,
1137 be_link_status_async_callback, (void *)adapter);
1138 if (status != BE_SUCCESS) {
1139 printk(KERN_WARNING "add_async_event_callback failed");
1140 printk(KERN_WARNING
1141 "Link status changes may not be reflected\n");
1142 }
1143
1144 status = register_netdev(netdev);
1145 if (status != 0)
1146 goto cleanup;
1147 be_update_link_status(adapter);
1148 adapter->dev_state = BE_DEV_STATE_INIT;
1149 return 0;
1150
1151cleanup:
1152 be_remove(pdev);
1153 return status;
1154error_adapter:
1155 pci_release_regions(pdev);
1156error_pci_req:
1157 pci_disable_device(pdev);
1158error:
1159 printk(KERN_ERR "BladeEngine initalization failed\n");
1160 return status;
1161}
1162
1163/*
1164 * Get the current link status and print the status on console
1165 */
1166void be_update_link_status(struct be_adapter *adapter)
1167{
1168 int status;
1169 struct be_net_object *pnob = adapter->net_obj;
1170
1171 status = be_rxf_link_status(&pnob->fn_obj, adapter->be_link_sts, NULL,
1172 NULL, NULL);
1173 if (status == BE_SUCCESS) {
1174 if (adapter->be_link_sts->mac0_speed &&
1175 adapter->be_link_sts->mac0_duplex)
1176 adapter->port0_link_sts = BE_PORT_LINK_UP;
1177 else
1178 adapter->port0_link_sts = BE_PORT_LINK_DOWN;
1179
1180 if (adapter->be_link_sts->mac1_speed &&
1181 adapter->be_link_sts->mac1_duplex)
1182 adapter->port1_link_sts = BE_PORT_LINK_UP;
1183 else
1184 adapter->port1_link_sts = BE_PORT_LINK_DOWN;
1185
1186 dev_info(&pnob->netdev->dev, "Link Properties:\n");
1187 be_print_link_info(adapter->be_link_sts);
1188 return;
1189 }
1190 dev_info(&pnob->netdev->dev, "Could not get link status\n");
1191 return;
1192}
1193
1194
1195#ifdef CONFIG_PM
1196static void
1197be_pm_cleanup(struct be_adapter *adapter,
1198 struct be_net_object *pnob, struct net_device *netdev)
1199{
1200 netif_carrier_off(netdev);
1201 netif_stop_queue(netdev);
1202
1203 be_wait_nic_tx_cmplx_cmpl(pnob);
1204 be_disable_eq_intr(pnob);
1205
1206 if (adapter->tasklet_started) {
1207 tasklet_kill(&adapter->sts_handler);
1208 adapter->tasklet_started = 0;
1209 }
1210
1211 be_unregister_isr(adapter);
1212 be_disable_intr(pnob);
1213
1214 be_tx_q_clean(pnob);
1215 be_rx_q_clean(pnob);
1216
1217 be_destroy_netobj(pnob);
1218}
1219
1220static int be_suspend(struct pci_dev *pdev, pm_message_t state)
1221{
1222 struct be_adapter *adapter = pci_get_drvdata(pdev);
1223 struct net_device *netdev = adapter->netdevp;
1224 struct be_net_object *pnob = netdev_priv(netdev);
1225
1226 adapter->dev_pm_state = adapter->dev_state;
1227 adapter->dev_state = BE_DEV_STATE_SUSPEND;
1228
1229 netif_device_detach(netdev);
1230 if (netif_running(netdev))
1231 be_pm_cleanup(adapter, pnob, netdev);
1232
1233 pci_enable_wake(pdev, 3, 1);
1234 pci_enable_wake(pdev, 4, 1); /* D3 Cold = 4 */
1235 pci_save_state(pdev);
1236 pci_disable_device(pdev);
1237 pci_set_power_state(pdev, pci_choose_state(pdev, state));
1238 return 0;
1239}
1240
1241static void be_up(struct be_adapter *adapter)
1242{
1243 struct be_net_object *pnob = adapter->net_obj;
1244
1245 if (pnob->num_vlans != 0)
1246 be_rxf_vlan_config(&pnob->fn_obj, false, pnob->num_vlans,
1247 pnob->vlan_tag, NULL, NULL, NULL);
1248
1249}
1250
1251static int be_resume(struct pci_dev *pdev)
1252{
1253 int status = 0;
1254 struct be_adapter *adapter = pci_get_drvdata(pdev);
1255 struct net_device *netdev = adapter->netdevp;
1256 struct be_net_object *pnob = netdev_priv(netdev);
1257
1258 netif_device_detach(netdev);
1259
1260 status = pci_enable_device(pdev);
1261 if (status)
1262 return status;
1263
1264 pci_set_power_state(pdev, 0);
1265 pci_restore_state(pdev);
1266 pci_enable_wake(pdev, 3, 0);
1267 pci_enable_wake(pdev, 4, 0); /* 4 is D3 cold */
1268
1269 netif_carrier_on(netdev);
1270 netif_start_queue(netdev);
1271
1272 if (netif_running(netdev)) {
1273 be_rxf_mac_address_read_write(&pnob->fn_obj, false, false,
1274 false, true, false, netdev->dev_addr, NULL, NULL);
1275
1276 status = be_nob_ring_init(adapter, pnob);
1277 if (status < 0)
1278 return status;
1279
1280 tasklet_init(&(adapter->sts_handler), be_process_intr,
1281 (unsigned long)adapter);
1282 adapter->tasklet_started = 1;
1283
1284 if (be_register_isr(adapter, pnob) != 0) {
1285 printk(KERN_ERR "be_register_isr failed\n");
1286 return status;
1287 }
1288
1289
1290 status = be_mcc_init(adapter);
1291 if (status < 0) {
1292 printk(KERN_ERR "be_mcc_init failed\n");
1293 return status;
1294 }
1295 be_update_link_status(adapter);
1296 /*
1297 * Register async call back function to handle link
1298 * status updates
1299 */
1300 status = be_mcc_add_async_event_callback(
1301 &adapter->net_obj->mcc_q_obj,
1302 be_link_status_async_callback, (void *)adapter);
1303 if (status != BE_SUCCESS) {
1304 printk(KERN_WARNING "add_async_event_callback failed");
1305 printk(KERN_WARNING
1306 "Link status changes may not be reflected\n");
1307 }
1308 be_enable_intr(pnob);
1309 be_enable_eq_intr(pnob);
1310 be_up(adapter);
1311 }
1312 netif_device_attach(netdev);
1313 adapter->dev_state = adapter->dev_pm_state;
1314 return 0;
1315
1316}
1317
1318#endif
1319
1320/* Wait until no more pending transmits */
1321void be_wait_nic_tx_cmplx_cmpl(struct be_net_object *pnob)
1322{
1323 int i;
1324
1325 /* Wait for 20us * 50000 (= 1s) and no more */
1326 i = 0;
1327 while ((pnob->tx_q_tl != pnob->tx_q_hd) && (i < 50000)) {
1328 ++i;
1329 udelay(20);
1330 }
1331
1332 /* Check for no more pending transmits */
1333 if (i >= 50000) {
1334 printk(KERN_WARNING
1335 "Did not receive completions for all TX requests\n");
1336 }
1337}
1338
1339static struct pci_driver be_driver = {
1340 .name = be_driver_name,
1341 .id_table = be_device_id_table,
1342 .probe = be_probe,
1343#ifdef CONFIG_PM
1344 .suspend = be_suspend,
1345 .resume = be_resume,
1346#endif
1347 .remove = be_remove
1348};
1349
1350/*
1351 * Module init entry point. Registers our our device and return.
1352 * Our probe will be called if the device is found.
1353 */
1354static int __init be_init_module(void)
1355{
1356 int ret;
1357
1358 if (rxbuf_size != 8192 && rxbuf_size != 4096 && rxbuf_size != 2048) {
1359 printk(KERN_WARNING
1360 "Unsupported receive buffer size (%d) requested\n",
1361 rxbuf_size);
1362 printk(KERN_WARNING
1363 "Must be 2048, 4096 or 8192. Defaulting to 2048\n");
1364 rxbuf_size = 2048;
1365 }
1366
1367 ret = pci_register_driver(&be_driver);
1368
1369 return ret;
1370}
1371
1372module_init(be_init_module);
1373
1374/*
1375 * be_exit_module - Driver Exit Cleanup Routine
1376 */
1377static void __exit be_exit_module(void)
1378{
1379 pci_unregister_driver(&be_driver);
1380}
1381
1382module_exit(be_exit_module);
diff --git a/drivers/staging/benet/be_int.c b/drivers/staging/benet/be_int.c
deleted file mode 100644
index cba95d09a8b6..000000000000
--- a/drivers/staging/benet/be_int.c
+++ /dev/null
@@ -1,863 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#include <linux/if_vlan.h>
18#include <linux/inet_lro.h>
19
20#include "benet.h"
21
22/* number of bytes of RX frame that are copied to skb->data */
23#define BE_HDR_LEN 64
24
25#define NETIF_RX(skb) netif_receive_skb(skb)
26#define VLAN_ACCEL_RX(skb, pnob, vt) \
27 vlan_hwaccel_rx(skb, pnob->vlan_grp, vt)
28
29/*
30 This function notifies BladeEngine of the number of completion
31 entries processed from the specified completion queue by writing
32 the number of popped entries to the door bell.
33
34 pnob - Pointer to the NetObject structure
35 n - Number of completion entries processed
36 cq_id - Queue ID of the completion queue for which notification
37 is being done.
38 re_arm - 1 - rearm the completion ring to generate an event.
39 - 0 - dont rearm the completion ring to generate an event
40*/
41void be_notify_cmpl(struct be_net_object *pnob, int n, int cq_id, int re_arm)
42{
43 struct CQ_DB_AMAP cqdb;
44
45 cqdb.dw[0] = 0;
46 AMAP_SET_BITS_PTR(CQ_DB, qid, &cqdb, cq_id);
47 AMAP_SET_BITS_PTR(CQ_DB, rearm, &cqdb, re_arm);
48 AMAP_SET_BITS_PTR(CQ_DB, num_popped, &cqdb, n);
49 PD_WRITE(&pnob->fn_obj, cq_db, cqdb.dw[0]);
50}
51
52/*
53 * adds additional receive frags indicated by BE starting from given
54 * frag index (fi) to specified skb's frag list
55 */
56static void
57add_skb_frags(struct be_net_object *pnob, struct sk_buff *skb,
58 u32 nresid, u32 fi)
59{
60 struct be_adapter *adapter = pnob->adapter;
61 u32 sk_frag_idx, n;
62 struct be_rx_page_info *rx_page_info;
63 u32 frag_sz = pnob->rx_buf_size;
64
65 sk_frag_idx = skb_shinfo(skb)->nr_frags;
66 while (nresid) {
67 index_inc(&fi, pnob->rx_q_len);
68
69 rx_page_info = (struct be_rx_page_info *)pnob->rx_ctxt[fi];
70 pnob->rx_ctxt[fi] = NULL;
71 if ((rx_page_info->page_offset) ||
72 (pnob->rx_pg_shared == false)) {
73 pci_unmap_page(adapter->pdev,
74 pci_unmap_addr(rx_page_info, bus),
75 frag_sz, PCI_DMA_FROMDEVICE);
76 }
77
78 n = min(nresid, frag_sz);
79 skb_shinfo(skb)->frags[sk_frag_idx].page = rx_page_info->page;
80 skb_shinfo(skb)->frags[sk_frag_idx].page_offset
81 = rx_page_info->page_offset;
82 skb_shinfo(skb)->frags[sk_frag_idx].size = n;
83
84 sk_frag_idx++;
85 skb->len += n;
86 skb->data_len += n;
87 skb_shinfo(skb)->nr_frags++;
88 nresid -= n;
89
90 memset(rx_page_info, 0, sizeof(struct be_rx_page_info));
91 atomic_dec(&pnob->rx_q_posted);
92 }
93}
94
95/*
96 * This function processes incoming nic packets over various Rx queues.
97 * This function takes the adapter, the current Rx status descriptor
98 * entry and the Rx completion queue ID as argument.
99 */
100static inline int process_nic_rx_completion(struct be_net_object *pnob,
101 struct ETH_RX_COMPL_AMAP *rxcp)
102{
103 struct be_adapter *adapter = pnob->adapter;
104 struct sk_buff *skb;
105 int udpcksm, tcpcksm;
106 int n;
107 u32 nresid, fi;
108 u32 frag_sz = pnob->rx_buf_size;
109 u8 *va;
110 struct be_rx_page_info *rx_page_info;
111 u32 numfrags, vtp, vtm, vlan_tag, pktsize;
112
113 fi = AMAP_GET_BITS_PTR(ETH_RX_COMPL, fragndx, rxcp);
114 BUG_ON(fi >= (int)pnob->rx_q_len);
115 BUG_ON(fi < 0);
116
117 rx_page_info = (struct be_rx_page_info *)pnob->rx_ctxt[fi];
118 BUG_ON(!rx_page_info->page);
119 pnob->rx_ctxt[fi] = NULL;
120
121 /*
122 * If one page is used per fragment or if this is the second half of
123 * of the page, unmap the page here
124 */
125 if ((rx_page_info->page_offset) || (pnob->rx_pg_shared == false)) {
126 pci_unmap_page(adapter->pdev,
127 pci_unmap_addr(rx_page_info, bus), frag_sz,
128 PCI_DMA_FROMDEVICE);
129 }
130
131 atomic_dec(&pnob->rx_q_posted);
132 udpcksm = AMAP_GET_BITS_PTR(ETH_RX_COMPL, udpcksm, rxcp);
133 tcpcksm = AMAP_GET_BITS_PTR(ETH_RX_COMPL, tcpcksm, rxcp);
134 pktsize = AMAP_GET_BITS_PTR(ETH_RX_COMPL, pktsize, rxcp);
135 /*
136 * get rid of RX flush completions first.
137 */
138 if ((tcpcksm) && (udpcksm) && (pktsize == 32)) {
139 put_page(rx_page_info->page);
140 memset(rx_page_info, 0, sizeof(struct be_rx_page_info));
141 return 0;
142 }
143 skb = netdev_alloc_skb(pnob->netdev, BE_HDR_LEN + NET_IP_ALIGN);
144 if (skb == NULL) {
145 dev_info(&pnob->netdev->dev, "alloc_skb() failed\n");
146 put_page(rx_page_info->page);
147 memset(rx_page_info, 0, sizeof(struct be_rx_page_info));
148 goto free_frags;
149 }
150 skb_reserve(skb, NET_IP_ALIGN);
151
152 skb->dev = pnob->netdev;
153
154 n = min(pktsize, frag_sz);
155
156 va = page_address(rx_page_info->page) + rx_page_info->page_offset;
157 prefetch(va);
158
159 skb->len = n;
160 skb->data_len = n;
161 if (n <= BE_HDR_LEN) {
162 memcpy(skb->data, va, n);
163 put_page(rx_page_info->page);
164 skb->data_len -= n;
165 skb->tail += n;
166 } else {
167
168 /* Setup the SKB with page buffer information */
169 skb_shinfo(skb)->frags[0].page = rx_page_info->page;
170 skb_shinfo(skb)->nr_frags++;
171
172 /* Copy the header into the skb_data */
173 memcpy(skb->data, va, BE_HDR_LEN);
174 skb_shinfo(skb)->frags[0].page_offset =
175 rx_page_info->page_offset + BE_HDR_LEN;
176 skb_shinfo(skb)->frags[0].size = n - BE_HDR_LEN;
177 skb->data_len -= BE_HDR_LEN;
178 skb->tail += BE_HDR_LEN;
179 }
180 memset(rx_page_info, 0, sizeof(struct be_rx_page_info));
181 nresid = pktsize - n;
182
183 skb->protocol = eth_type_trans(skb, pnob->netdev);
184
185 if ((tcpcksm || udpcksm) && adapter->rx_csum)
186 skb->ip_summed = CHECKSUM_UNNECESSARY;
187 else
188 skb->ip_summed = CHECKSUM_NONE;
189 /*
190 * if we have more bytes left, the frame has been
191 * given to us in multiple fragments. This happens
192 * with Jumbo frames. Add the remaining fragments to
193 * skb->frags[] array.
194 */
195 if (nresid)
196 add_skb_frags(pnob, skb, nresid, fi);
197
198 /* update the the true size of the skb. */
199 skb->truesize = skb->len + sizeof(struct sk_buff);
200
201 /*
202 * If a 802.3 frame or 802.2 LLC frame
203 * (i.e) contains length field in MAC Hdr
204 * and frame len is greater than 64 bytes
205 */
206 if (((skb->protocol == ntohs(ETH_P_802_2)) ||
207 (skb->protocol == ntohs(ETH_P_802_3)))
208 && (pktsize > BE_HDR_LEN)) {
209 /*
210 * If the length given in Mac Hdr is less than frame size
211 * Erraneous frame, Drop it
212 */
213 if ((ntohs(*(u16 *) (va + 12)) + ETH_HLEN) < pktsize) {
214 /* Increment Non Ether type II frames dropped */
215 adapter->be_stat.bes_802_3_dropped_frames++;
216
217 kfree_skb(skb);
218 return 0;
219 }
220 /*
221 * else if the length given in Mac Hdr is greater than
222 * frame size, should not be seeing this sort of frames
223 * dump the pkt and pass to stack
224 */
225 else if ((ntohs(*(u16 *) (va + 12)) + ETH_HLEN) > pktsize) {
226 /* Increment Non Ether type II frames malformed */
227 adapter->be_stat.bes_802_3_malformed_frames++;
228 }
229 }
230
231 vtp = AMAP_GET_BITS_PTR(ETH_RX_COMPL, vtp, rxcp);
232 vtm = AMAP_GET_BITS_PTR(ETH_RX_COMPL, vtm, rxcp);
233 if (vtp && vtm) {
234 /* Vlan tag present in pkt and BE found
235 * that the tag matched an entry in VLAN table
236 */
237 if (!pnob->vlan_grp || pnob->num_vlans == 0) {
238 /* But we have no VLANs configured.
239 * This should never happen. Drop the packet.
240 */
241 dev_info(&pnob->netdev->dev,
242 "BladeEngine: Unexpected vlan tagged packet\n");
243 kfree_skb(skb);
244 return 0;
245 }
246 /* pass the VLAN packet to stack */
247 vlan_tag = AMAP_GET_BITS_PTR(ETH_RX_COMPL, vlan_tag, rxcp);
248 VLAN_ACCEL_RX(skb, pnob, be16_to_cpu(vlan_tag));
249
250 } else {
251 NETIF_RX(skb);
252 }
253 return 0;
254
255free_frags:
256 /* free all frags associated with the current rxcp */
257 numfrags = AMAP_GET_BITS_PTR(ETH_RX_COMPL, numfrags, rxcp);
258 while (numfrags-- > 1) {
259 index_inc(&fi, pnob->rx_q_len);
260
261 rx_page_info = (struct be_rx_page_info *)
262 pnob->rx_ctxt[fi];
263 pnob->rx_ctxt[fi] = (void *)NULL;
264 if (rx_page_info->page_offset || !pnob->rx_pg_shared) {
265 pci_unmap_page(adapter->pdev,
266 pci_unmap_addr(rx_page_info, bus),
267 frag_sz, PCI_DMA_FROMDEVICE);
268 }
269
270 put_page(rx_page_info->page);
271 memset(rx_page_info, 0, sizeof(struct be_rx_page_info));
272 atomic_dec(&pnob->rx_q_posted);
273 }
274 return -ENOMEM;
275}
276
277static void process_nic_rx_completion_lro(struct be_net_object *pnob,
278 struct ETH_RX_COMPL_AMAP *rxcp)
279{
280 struct be_adapter *adapter = pnob->adapter;
281 struct skb_frag_struct rx_frags[BE_MAX_FRAGS_PER_FRAME];
282 unsigned int udpcksm, tcpcksm;
283 u32 numfrags, vlanf, vtm, vlan_tag, nresid;
284 u16 vlant;
285 unsigned int fi, idx, n;
286 struct be_rx_page_info *rx_page_info;
287 u32 frag_sz = pnob->rx_buf_size, pktsize;
288 bool rx_coal = (adapter->max_rx_coal <= 1) ? 0 : 1;
289 u8 err, *va;
290 __wsum csum = 0;
291
292 if (AMAP_GET_BITS_PTR(ETH_RX_COMPL, ipsec, rxcp)) {
293 /* Drop the pkt and move to the next completion. */
294 adapter->be_stat.bes_rx_misc_pkts++;
295 return;
296 }
297 err = AMAP_GET_BITS_PTR(ETH_RX_COMPL, err, rxcp);
298 if (err || !rx_coal) {
299 /* We won't coalesce Rx pkts if the err bit set.
300 * take the path of normal completion processing */
301 process_nic_rx_completion(pnob, rxcp);
302 return;
303 }
304
305 fi = AMAP_GET_BITS_PTR(ETH_RX_COMPL, fragndx, rxcp);
306 BUG_ON(fi >= (int)pnob->rx_q_len);
307 BUG_ON(fi < 0);
308 rx_page_info = (struct be_rx_page_info *)pnob->rx_ctxt[fi];
309 BUG_ON(!rx_page_info->page);
310 pnob->rx_ctxt[fi] = (void *)NULL;
311 /* If one page is used per fragment or if this is the
312 * second half of the page, unmap the page here
313 */
314 if (rx_page_info->page_offset || !pnob->rx_pg_shared) {
315 pci_unmap_page(adapter->pdev,
316 pci_unmap_addr(rx_page_info, bus),
317 frag_sz, PCI_DMA_FROMDEVICE);
318 }
319
320 numfrags = AMAP_GET_BITS_PTR(ETH_RX_COMPL, numfrags, rxcp);
321 udpcksm = AMAP_GET_BITS_PTR(ETH_RX_COMPL, udpcksm, rxcp);
322 tcpcksm = AMAP_GET_BITS_PTR(ETH_RX_COMPL, tcpcksm, rxcp);
323 vlan_tag = AMAP_GET_BITS_PTR(ETH_RX_COMPL, vlan_tag, rxcp);
324 vlant = be16_to_cpu(vlan_tag);
325 vlanf = AMAP_GET_BITS_PTR(ETH_RX_COMPL, vtp, rxcp);
326 vtm = AMAP_GET_BITS_PTR(ETH_RX_COMPL, vtm, rxcp);
327 pktsize = AMAP_GET_BITS_PTR(ETH_RX_COMPL, pktsize, rxcp);
328
329 atomic_dec(&pnob->rx_q_posted);
330
331 if (tcpcksm && udpcksm && pktsize == 32) {
332 /* flush completion entries */
333 put_page(rx_page_info->page);
334 memset(rx_page_info, 0, sizeof(struct be_rx_page_info));
335 return;
336 }
337 /* Only one of udpcksum and tcpcksum can be set */
338 BUG_ON(udpcksm && tcpcksm);
339
340 /* jumbo frames could come in multiple fragments */
341 BUG_ON(numfrags != ((pktsize + (frag_sz - 1)) / frag_sz));
342 n = min(pktsize, frag_sz);
343 nresid = pktsize - n; /* will be useful for jumbo pkts */
344 idx = 0;
345
346 va = page_address(rx_page_info->page) + rx_page_info->page_offset;
347 prefetch(va);
348 rx_frags[idx].page = rx_page_info->page;
349 rx_frags[idx].page_offset = (rx_page_info->page_offset);
350 rx_frags[idx].size = n;
351 memset(rx_page_info, 0, sizeof(struct be_rx_page_info));
352
353 /* If we got multiple fragments, we have more data. */
354 while (nresid) {
355 idx++;
356 index_inc(&fi, pnob->rx_q_len);
357
358 rx_page_info = (struct be_rx_page_info *)pnob->rx_ctxt[fi];
359 pnob->rx_ctxt[fi] = (void *)NULL;
360 if (rx_page_info->page_offset || !pnob->rx_pg_shared) {
361 pci_unmap_page(adapter->pdev,
362 pci_unmap_addr(rx_page_info, bus),
363 frag_sz, PCI_DMA_FROMDEVICE);
364 }
365
366 n = min(nresid, frag_sz);
367 rx_frags[idx].page = rx_page_info->page;
368 rx_frags[idx].page_offset = (rx_page_info->page_offset);
369 rx_frags[idx].size = n;
370
371 nresid -= n;
372 memset(rx_page_info, 0, sizeof(struct be_rx_page_info));
373 atomic_dec(&pnob->rx_q_posted);
374 }
375
376 if (likely(!(vlanf && vtm))) {
377 lro_receive_frags(&pnob->lro_mgr, rx_frags,
378 pktsize, pktsize,
379 (void *)(unsigned long)csum, csum);
380 } else {
381 /* Vlan tag present in pkt and BE found
382 * that the tag matched an entry in VLAN table
383 */
384 if (unlikely(!pnob->vlan_grp || pnob->num_vlans == 0)) {
385 /* But we have no VLANs configured.
386 * This should never happen. Drop the packet.
387 */
388 dev_info(&pnob->netdev->dev,
389 "BladeEngine: Unexpected vlan tagged packet\n");
390 return;
391 }
392 /* pass the VLAN packet to stack */
393 lro_vlan_hwaccel_receive_frags(&pnob->lro_mgr,
394 rx_frags, pktsize, pktsize,
395 pnob->vlan_grp, vlant,
396 (void *)(unsigned long)csum,
397 csum);
398 }
399
400 adapter->be_stat.bes_rx_coal++;
401}
402
403struct ETH_RX_COMPL_AMAP *be_get_rx_cmpl(struct be_net_object *pnob)
404{
405 struct ETH_RX_COMPL_AMAP *rxcp = &pnob->rx_cq[pnob->rx_cq_tl];
406 u32 valid, ct;
407
408 valid = AMAP_GET_BITS_PTR(ETH_RX_COMPL, valid, rxcp);
409 if (valid == 0)
410 return NULL;
411
412 ct = AMAP_GET_BITS_PTR(ETH_RX_COMPL, ct, rxcp);
413 if (ct != 0) {
414 /* Invalid chute #. treat as error */
415 AMAP_SET_BITS_PTR(ETH_RX_COMPL, err, rxcp, 1);
416 }
417
418 be_adv_rxcq_tl(pnob);
419 AMAP_SET_BITS_PTR(ETH_RX_COMPL, valid, rxcp, 0);
420 return rxcp;
421}
422
423static void update_rx_rate(struct be_adapter *adapter)
424{
425 /* update the rate once in two seconds */
426 if ((jiffies - adapter->eth_rx_jiffies) > 2 * (HZ)) {
427 u32 r;
428 r = adapter->eth_rx_bytes /
429 ((jiffies - adapter->eth_rx_jiffies) / (HZ));
430 r = (r / 1000000); /* MB/Sec */
431
432 /* Mega Bits/Sec */
433 adapter->be_stat.bes_eth_rx_rate = (r * 8);
434 adapter->eth_rx_jiffies = jiffies;
435 adapter->eth_rx_bytes = 0;
436 }
437}
438
439static int process_rx_completions(struct be_net_object *pnob, int max_work)
440{
441 struct be_adapter *adapter = pnob->adapter;
442 struct ETH_RX_COMPL_AMAP *rxcp;
443 u32 nc = 0;
444 unsigned int pktsize;
445
446 while (max_work && (rxcp = be_get_rx_cmpl(pnob))) {
447 prefetch(rxcp);
448 pktsize = AMAP_GET_BITS_PTR(ETH_RX_COMPL, pktsize, rxcp);
449 process_nic_rx_completion_lro(pnob, rxcp);
450 adapter->eth_rx_bytes += pktsize;
451 update_rx_rate(adapter);
452 nc++;
453 max_work--;
454 adapter->be_stat.bes_rx_compl++;
455 }
456 if (likely(adapter->max_rx_coal > 1)) {
457 adapter->be_stat.bes_rx_flush++;
458 lro_flush_all(&pnob->lro_mgr);
459 }
460
461 /* Refill the queue */
462 if (atomic_read(&pnob->rx_q_posted) < 900)
463 be_post_eth_rx_buffs(pnob);
464
465 return nc;
466}
467
468static struct ETH_TX_COMPL_AMAP *be_get_tx_cmpl(struct be_net_object *pnob)
469{
470 struct ETH_TX_COMPL_AMAP *txcp = &pnob->tx_cq[pnob->tx_cq_tl];
471 u32 valid;
472
473 valid = AMAP_GET_BITS_PTR(ETH_TX_COMPL, valid, txcp);
474 if (valid == 0)
475 return NULL;
476
477 AMAP_SET_BITS_PTR(ETH_TX_COMPL, valid, txcp, 0);
478 be_adv_txcq_tl(pnob);
479 return txcp;
480
481}
482
483void process_one_tx_compl(struct be_net_object *pnob, u32 end_idx)
484{
485 struct be_adapter *adapter = pnob->adapter;
486 int cur_index, tx_wrbs_completed = 0;
487 struct sk_buff *skb;
488 u64 busaddr, pa, pa_lo, pa_hi;
489 struct ETH_WRB_AMAP *wrb;
490 u32 frag_len, last_index, j;
491
492 last_index = tx_compl_lastwrb_idx_get(pnob);
493 BUG_ON(last_index != end_idx);
494 pnob->tx_ctxt[pnob->tx_q_tl] = NULL;
495 do {
496 cur_index = pnob->tx_q_tl;
497 wrb = &pnob->tx_q[cur_index];
498 pa_hi = AMAP_GET_BITS_PTR(ETH_WRB, frag_pa_hi, wrb);
499 pa_lo = AMAP_GET_BITS_PTR(ETH_WRB, frag_pa_lo, wrb);
500 frag_len = AMAP_GET_BITS_PTR(ETH_WRB, frag_len, wrb);
501 busaddr = (pa_hi << 32) | pa_lo;
502 if (busaddr != 0) {
503 pa = le64_to_cpu(busaddr);
504 pci_unmap_single(adapter->pdev, pa,
505 frag_len, PCI_DMA_TODEVICE);
506 }
507 if (cur_index == last_index) {
508 skb = (struct sk_buff *)pnob->tx_ctxt[cur_index];
509 BUG_ON(!skb);
510 for (j = 0; j < skb_shinfo(skb)->nr_frags; j++) {
511 struct skb_frag_struct *frag;
512 frag = &skb_shinfo(skb)->frags[j];
513 pci_unmap_page(adapter->pdev,
514 (ulong) frag->page, frag->size,
515 PCI_DMA_TODEVICE);
516 }
517 kfree_skb(skb);
518 pnob->tx_ctxt[cur_index] = NULL;
519 } else {
520 BUG_ON(pnob->tx_ctxt[cur_index]);
521 }
522 tx_wrbs_completed++;
523 be_adv_txq_tl(pnob);
524 } while (cur_index != last_index);
525 atomic_sub(tx_wrbs_completed, &pnob->tx_q_used);
526}
527
528/* there is no need to take an SMP lock here since currently
529 * we have only one instance of the tasklet that does completion
530 * processing.
531 */
532static void process_nic_tx_completions(struct be_net_object *pnob)
533{
534 struct be_adapter *adapter = pnob->adapter;
535 struct ETH_TX_COMPL_AMAP *txcp;
536 struct net_device *netdev = pnob->netdev;
537 u32 end_idx, num_processed = 0;
538
539 adapter->be_stat.bes_tx_events++;
540
541 while ((txcp = be_get_tx_cmpl(pnob))) {
542 end_idx = AMAP_GET_BITS_PTR(ETH_TX_COMPL, wrb_index, txcp);
543 process_one_tx_compl(pnob, end_idx);
544 num_processed++;
545 adapter->be_stat.bes_tx_compl++;
546 }
547 be_notify_cmpl(pnob, num_processed, pnob->tx_cq_id, 1);
548 /*
549 * We got Tx completions and have usable WRBs.
550 * If the netdev's queue has been stopped
551 * because we had run out of WRBs, wake it now.
552 */
553 spin_lock(&adapter->txq_lock);
554 if (netif_queue_stopped(netdev)
555 && atomic_read(&pnob->tx_q_used) < pnob->tx_q_len / 2) {
556 netif_wake_queue(netdev);
557 }
558 spin_unlock(&adapter->txq_lock);
559}
560
561static u32 post_rx_buffs(struct be_net_object *pnob, struct list_head *rxbl)
562{
563 u32 nposted = 0;
564 struct ETH_RX_D_AMAP *rxd = NULL;
565 struct be_recv_buffer *rxbp;
566 void **rx_ctxp;
567 struct RQ_DB_AMAP rqdb;
568
569 rx_ctxp = pnob->rx_ctxt;
570
571 while (!list_empty(rxbl) &&
572 (rx_ctxp[pnob->rx_q_hd] == NULL) && nposted < 255) {
573
574 rxbp = list_first_entry(rxbl, struct be_recv_buffer, rxb_list);
575 list_del(&rxbp->rxb_list);
576 rxd = pnob->rx_q + pnob->rx_q_hd;
577 AMAP_SET_BITS_PTR(ETH_RX_D, fragpa_lo, rxd, rxbp->rxb_pa_lo);
578 AMAP_SET_BITS_PTR(ETH_RX_D, fragpa_hi, rxd, rxbp->rxb_pa_hi);
579
580 rx_ctxp[pnob->rx_q_hd] = rxbp->rxb_ctxt;
581 be_adv_rxq_hd(pnob);
582 nposted++;
583 }
584
585 if (nposted) {
586 /* Now press the door bell to notify BladeEngine. */
587 rqdb.dw[0] = 0;
588 AMAP_SET_BITS_PTR(RQ_DB, numPosted, &rqdb, nposted);
589 AMAP_SET_BITS_PTR(RQ_DB, rq, &rqdb, pnob->rx_q_id);
590 PD_WRITE(&pnob->fn_obj, erx_rq_db, rqdb.dw[0]);
591 }
592 atomic_add(nposted, &pnob->rx_q_posted);
593 return nposted;
594}
595
596void be_post_eth_rx_buffs(struct be_net_object *pnob)
597{
598 struct be_adapter *adapter = pnob->adapter;
599 u32 num_bufs, r;
600 u64 busaddr = 0, tmp_pa;
601 u32 max_bufs, pg_hd;
602 u32 frag_size;
603 struct be_recv_buffer *rxbp;
604 struct list_head rxbl;
605 struct be_rx_page_info *rx_page_info;
606 struct page *page = NULL;
607 u32 page_order = 0;
608 gfp_t alloc_flags = GFP_ATOMIC;
609
610 BUG_ON(!adapter);
611
612 max_bufs = 64; /* should be even # <= 255. */
613
614 frag_size = pnob->rx_buf_size;
615 page_order = get_order(frag_size);
616
617 if (frag_size == 8192)
618 alloc_flags |= (gfp_t) __GFP_COMP;
619 /*
620 * Form a linked list of RECV_BUFFFER structure to be be posted.
621 * We will post even number of buffer so that pages can be
622 * shared.
623 */
624 INIT_LIST_HEAD(&rxbl);
625
626 for (num_bufs = 0; num_bufs < max_bufs &&
627 !pnob->rx_page_info[pnob->rx_pg_info_hd].page; ++num_bufs) {
628
629 rxbp = &pnob->eth_rx_bufs[num_bufs];
630 pg_hd = pnob->rx_pg_info_hd;
631 rx_page_info = &pnob->rx_page_info[pg_hd];
632
633 if (!page) {
634 page = alloc_pages(alloc_flags, page_order);
635 if (unlikely(page == NULL)) {
636 adapter->be_stat.bes_ethrx_post_fail++;
637 pnob->rxbuf_post_fail++;
638 break;
639 }
640 pnob->rxbuf_post_fail = 0;
641 busaddr = pci_map_page(adapter->pdev, page, 0,
642 frag_size, PCI_DMA_FROMDEVICE);
643 rx_page_info->page_offset = 0;
644 rx_page_info->page = page;
645 /*
646 * If we are sharing a page among two skbs,
647 * alloc a new one on the next iteration
648 */
649 if (pnob->rx_pg_shared == false)
650 page = NULL;
651 } else {
652 get_page(page);
653 rx_page_info->page_offset += frag_size;
654 rx_page_info->page = page;
655 /*
656 * We are finished with the alloced page,
657 * Alloc a new one on the next iteration
658 */
659 page = NULL;
660 }
661 rxbp->rxb_ctxt = (void *)rx_page_info;
662 index_inc(&pnob->rx_pg_info_hd, pnob->rx_q_len);
663
664 pci_unmap_addr_set(rx_page_info, bus, busaddr);
665 tmp_pa = busaddr + rx_page_info->page_offset;
666 rxbp->rxb_pa_lo = (tmp_pa & 0xFFFFFFFF);
667 rxbp->rxb_pa_hi = (tmp_pa >> 32);
668 rxbp->rxb_len = frag_size;
669 list_add_tail(&rxbp->rxb_list, &rxbl);
670 } /* End of for */
671
672 r = post_rx_buffs(pnob, &rxbl);
673 BUG_ON(r != num_bufs);
674 return;
675}
676
677/*
678 * Interrupt service for network function. We just schedule the
679 * tasklet which does all completion processing.
680 */
681irqreturn_t be_int(int irq, void *dev)
682{
683 struct net_device *netdev = dev;
684 struct be_net_object *pnob = netdev_priv(netdev);
685 struct be_adapter *adapter = pnob->adapter;
686 u32 isr;
687
688 isr = CSR_READ(&pnob->fn_obj, cev.isr1);
689 if (unlikely(!isr))
690 return IRQ_NONE;
691
692 spin_lock(&adapter->int_lock);
693 adapter->isr |= isr;
694 spin_unlock(&adapter->int_lock);
695
696 adapter->be_stat.bes_ints++;
697
698 tasklet_schedule(&adapter->sts_handler);
699 return IRQ_HANDLED;
700}
701
702/*
703 * Poll function called by NAPI with a work budget.
704 * We process as many UC. BC and MC receive completions
705 * as the budget allows and return the actual number of
706 * RX ststutses processed.
707 */
708int be_poll(struct napi_struct *napi, int budget)
709{
710 struct be_net_object *pnob =
711 container_of(napi, struct be_net_object, napi);
712 u32 work_done;
713
714 pnob->adapter->be_stat.bes_polls++;
715 work_done = process_rx_completions(pnob, budget);
716 BUG_ON(work_done > budget);
717
718 /* All consumed */
719 if (work_done < budget) {
720 netif_rx_complete(napi);
721 /* enable intr */
722 be_notify_cmpl(pnob, work_done, pnob->rx_cq_id, 1);
723 } else {
724 /* More to be consumed; continue with interrupts disabled */
725 be_notify_cmpl(pnob, work_done, pnob->rx_cq_id, 0);
726 }
727 return work_done;
728}
729
730static struct EQ_ENTRY_AMAP *get_event(struct be_net_object *pnob)
731{
732 struct EQ_ENTRY_AMAP *eqp = &(pnob->event_q[pnob->event_q_tl]);
733 if (!AMAP_GET_BITS_PTR(EQ_ENTRY, Valid, eqp))
734 return NULL;
735 be_adv_eq_tl(pnob);
736 return eqp;
737}
738
739/*
740 * Processes all valid events in the event ring associated with given
741 * NetObject. Also, notifies BE the number of events processed.
742 */
743static inline u32 process_events(struct be_net_object *pnob)
744{
745 struct be_adapter *adapter = pnob->adapter;
746 struct EQ_ENTRY_AMAP *eqp;
747 u32 rid, num_events = 0;
748 struct net_device *netdev = pnob->netdev;
749
750 while ((eqp = get_event(pnob)) != NULL) {
751 adapter->be_stat.bes_events++;
752 rid = AMAP_GET_BITS_PTR(EQ_ENTRY, ResourceID, eqp);
753 if (rid == pnob->rx_cq_id) {
754 adapter->be_stat.bes_rx_events++;
755 netif_rx_schedule(&pnob->napi);
756 } else if (rid == pnob->tx_cq_id) {
757 process_nic_tx_completions(pnob);
758 } else if (rid == pnob->mcc_cq_id) {
759 be_mcc_process_cq(&pnob->mcc_q_obj, 1);
760 } else {
761 dev_info(&netdev->dev,
762 "Invalid EQ ResourceID %d\n", rid);
763 }
764 AMAP_SET_BITS_PTR(EQ_ENTRY, Valid, eqp, 0);
765 AMAP_SET_BITS_PTR(EQ_ENTRY, ResourceID, eqp, 0);
766 num_events++;
767 }
768 return num_events;
769}
770
771static void update_eqd(struct be_adapter *adapter, struct be_net_object *pnob)
772{
773 int status;
774 struct be_eq_object *eq_objectp;
775
776 /* update once a second */
777 if ((jiffies - adapter->ips_jiffies) > 1 * (HZ)) {
778 /* One second elapsed since last update */
779 u32 r, new_eqd = -1;
780 r = adapter->be_stat.bes_ints - adapter->be_stat.bes_prev_ints;
781 r = r / ((jiffies - adapter->ips_jiffies) / (HZ));
782 adapter->be_stat.bes_ips = r;
783 adapter->ips_jiffies = jiffies;
784 adapter->be_stat.bes_prev_ints = adapter->be_stat.bes_ints;
785 if (r > IPS_HI_WM && adapter->cur_eqd < adapter->max_eqd)
786 new_eqd = (adapter->cur_eqd + 8);
787 if (r < IPS_LO_WM && adapter->cur_eqd > adapter->min_eqd)
788 new_eqd = (adapter->cur_eqd - 8);
789 if (adapter->enable_aic && new_eqd != -1) {
790 eq_objectp = &pnob->event_q_obj;
791 status = be_eq_modify_delay(&pnob->fn_obj, 1,
792 &eq_objectp, &new_eqd, NULL,
793 NULL, NULL);
794 if (status == BE_SUCCESS)
795 adapter->cur_eqd = new_eqd;
796 }
797 }
798}
799
800/*
801 This function notifies BladeEngine of how many events were processed
802 from the event queue by ringing the corresponding door bell and
803 optionally re-arms the event queue.
804 n - number of events processed
805 re_arm - 1 - re-arm the EQ, 0 - do not re-arm the EQ
806
807*/
808static void be_notify_event(struct be_net_object *pnob, int n, int re_arm)
809{
810 struct CQ_DB_AMAP eqdb;
811 eqdb.dw[0] = 0;
812
813 AMAP_SET_BITS_PTR(CQ_DB, qid, &eqdb, pnob->event_q_id);
814 AMAP_SET_BITS_PTR(CQ_DB, rearm, &eqdb, re_arm);
815 AMAP_SET_BITS_PTR(CQ_DB, event, &eqdb, 1);
816 AMAP_SET_BITS_PTR(CQ_DB, num_popped, &eqdb, n);
817 /*
818 * Under some situations we see an interrupt and no valid
819 * EQ entry. To keep going, we need to ring the DB even if
820 * numPOsted is 0.
821 */
822 PD_WRITE(&pnob->fn_obj, cq_db, eqdb.dw[0]);
823 return;
824}
825
826/*
827 * Called from the tasklet scheduled by ISR. All real interrupt processing
828 * is done here.
829 */
830void be_process_intr(unsigned long context)
831{
832 struct be_adapter *adapter = (struct be_adapter *)context;
833 struct be_net_object *pnob = adapter->net_obj;
834 u32 isr, n;
835 ulong flags = 0;
836
837 isr = adapter->isr;
838
839 /*
840 * we create only one NIC event queue in Linux. Event is
841 * expected only in the first event queue
842 */
843 BUG_ON(isr & 0xfffffffe);
844 if ((isr & 1) == 0)
845 return; /* not our interrupt */
846 n = process_events(pnob);
847 /*
848 * Clear the event bit. adapter->isr is set by
849 * hard interrupt. Prevent race with lock.
850 */
851 spin_lock_irqsave(&adapter->int_lock, flags);
852 adapter->isr &= ~1;
853 spin_unlock_irqrestore(&adapter->int_lock, flags);
854 be_notify_event(pnob, n, 1);
855 /*
856 * If previous allocation attempts had failed and
857 * BE has used up all posted buffers, post RX buffers here
858 */
859 if (pnob->rxbuf_post_fail && atomic_read(&pnob->rx_q_posted) == 0)
860 be_post_eth_rx_buffs(pnob);
861 update_eqd(adapter, pnob);
862 return;
863}
diff --git a/drivers/staging/benet/be_netif.c b/drivers/staging/benet/be_netif.c
deleted file mode 100644
index 2b8daf63dc7d..000000000000
--- a/drivers/staging/benet/be_netif.c
+++ /dev/null
@@ -1,705 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * be_netif.c
19 *
20 * This file contains various entry points of drivers seen by tcp/ip stack.
21 */
22
23#include <linux/if_vlan.h>
24#include <linux/in.h>
25#include "benet.h"
26#include <linux/ip.h>
27#include <linux/inet_lro.h>
28
29/* Strings to print Link properties */
30static const char *link_speed[] = {
31 "Invalid link Speed Value",
32 "10 Mbps",
33 "100 Mbps",
34 "1 Gbps",
35 "10 Gbps"
36};
37
38static const char *link_duplex[] = {
39 "Invalid Duplex Value",
40 "Half Duplex",
41 "Full Duplex"
42};
43
44static const char *link_state[] = {
45 "",
46 "(active)"
47};
48
49void be_print_link_info(struct BE_LINK_STATUS *lnk_status)
50{
51 u16 si, di, ai;
52
53 /* Port 0 */
54 if (lnk_status->mac0_speed && lnk_status->mac0_duplex) {
55 /* Port is up and running */
56 si = (lnk_status->mac0_speed < 5) ? lnk_status->mac0_speed : 0;
57 di = (lnk_status->mac0_duplex < 3) ?
58 lnk_status->mac0_duplex : 0;
59 ai = (lnk_status->active_port == 0) ? 1 : 0;
60 printk(KERN_INFO "PortNo. 0: Speed - %s %s %s\n",
61 link_speed[si], link_duplex[di], link_state[ai]);
62 } else
63 printk(KERN_INFO "PortNo. 0: Down\n");
64
65 /* Port 1 */
66 if (lnk_status->mac1_speed && lnk_status->mac1_duplex) {
67 /* Port is up and running */
68 si = (lnk_status->mac1_speed < 5) ? lnk_status->mac1_speed : 0;
69 di = (lnk_status->mac1_duplex < 3) ?
70 lnk_status->mac1_duplex : 0;
71 ai = (lnk_status->active_port == 0) ? 1 : 0;
72 printk(KERN_INFO "PortNo. 1: Speed - %s %s %s\n",
73 link_speed[si], link_duplex[di], link_state[ai]);
74 } else
75 printk(KERN_INFO "PortNo. 1: Down\n");
76
77 return;
78}
79
80static int
81be_get_frag_header(struct skb_frag_struct *frag, void **mac_hdr,
82 void **ip_hdr, void **tcpudp_hdr,
83 u64 *hdr_flags, void *priv)
84{
85 struct ethhdr *eh;
86 struct vlan_ethhdr *veh;
87 struct iphdr *iph;
88 u8 *va = page_address(frag->page) + frag->page_offset;
89 unsigned long ll_hlen;
90
91 /* find the mac header, abort if not IPv4 */
92
93 prefetch(va);
94 eh = (struct ethhdr *)va;
95 *mac_hdr = eh;
96 ll_hlen = ETH_HLEN;
97 if (eh->h_proto != htons(ETH_P_IP)) {
98 if (eh->h_proto == htons(ETH_P_8021Q)) {
99 veh = (struct vlan_ethhdr *)va;
100 if (veh->h_vlan_encapsulated_proto != htons(ETH_P_IP))
101 return -1;
102
103 ll_hlen += VLAN_HLEN;
104
105 } else {
106 return -1;
107 }
108 }
109 *hdr_flags = LRO_IPV4;
110
111 iph = (struct iphdr *)(va + ll_hlen);
112 *ip_hdr = iph;
113 if (iph->protocol != IPPROTO_TCP)
114 return -1;
115 *hdr_flags |= LRO_TCP;
116 *tcpudp_hdr = (u8 *) (*ip_hdr) + (iph->ihl << 2);
117
118 return 0;
119}
120
121static int benet_open(struct net_device *netdev)
122{
123 struct be_net_object *pnob = netdev_priv(netdev);
124 struct be_adapter *adapter = pnob->adapter;
125 struct net_lro_mgr *lro_mgr;
126
127 if (adapter->dev_state < BE_DEV_STATE_INIT)
128 return -EAGAIN;
129
130 lro_mgr = &pnob->lro_mgr;
131 lro_mgr->dev = netdev;
132
133 lro_mgr->features = LRO_F_NAPI;
134 lro_mgr->ip_summed = CHECKSUM_UNNECESSARY;
135 lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY;
136 lro_mgr->max_desc = BE_MAX_LRO_DESCRIPTORS;
137 lro_mgr->lro_arr = pnob->lro_desc;
138 lro_mgr->get_frag_header = be_get_frag_header;
139 lro_mgr->max_aggr = adapter->max_rx_coal;
140 lro_mgr->frag_align_pad = 2;
141 if (lro_mgr->max_aggr > MAX_SKB_FRAGS)
142 lro_mgr->max_aggr = MAX_SKB_FRAGS;
143
144 adapter->max_rx_coal = BE_LRO_MAX_PKTS;
145
146 be_update_link_status(adapter);
147
148 /*
149 * Set carrier on only if Physical Link up
150 * Either of the port link status up signifies this
151 */
152 if ((adapter->port0_link_sts == BE_PORT_LINK_UP) ||
153 (adapter->port1_link_sts == BE_PORT_LINK_UP)) {
154 netif_start_queue(netdev);
155 netif_carrier_on(netdev);
156 }
157
158 adapter->dev_state = BE_DEV_STATE_OPEN;
159 napi_enable(&pnob->napi);
160 be_enable_intr(pnob);
161 be_enable_eq_intr(pnob);
162 /*
163 * RX completion queue may be in dis-armed state. Arm it.
164 */
165 be_notify_cmpl(pnob, 0, pnob->rx_cq_id, 1);
166
167 return 0;
168}
169
170static int benet_close(struct net_device *netdev)
171{
172 struct be_net_object *pnob = netdev_priv(netdev);
173 struct be_adapter *adapter = pnob->adapter;
174
175 netif_stop_queue(netdev);
176 synchronize_irq(netdev->irq);
177
178 be_wait_nic_tx_cmplx_cmpl(pnob);
179 adapter->dev_state = BE_DEV_STATE_INIT;
180 netif_carrier_off(netdev);
181
182 adapter->port0_link_sts = BE_PORT_LINK_DOWN;
183 adapter->port1_link_sts = BE_PORT_LINK_DOWN;
184 be_disable_intr(pnob);
185 be_disable_eq_intr(pnob);
186 napi_disable(&pnob->napi);
187
188 return 0;
189}
190
191/*
192 * Setting a Mac Address for BE
193 * Takes netdev and a void pointer as arguments.
194 * The pointer holds the new addres to be used.
195 */
196static int benet_set_mac_addr(struct net_device *netdev, void *p)
197{
198 struct sockaddr *addr = p;
199 struct be_net_object *pnob = netdev_priv(netdev);
200
201 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
202 be_rxf_mac_address_read_write(&pnob->fn_obj, 0, 0, false, true, false,
203 netdev->dev_addr, NULL, NULL);
204 /*
205 * Since we are doing Active-Passive failover, both
206 * ports should have matching MAC addresses everytime.
207 */
208 be_rxf_mac_address_read_write(&pnob->fn_obj, 1, 0, false, true, false,
209 netdev->dev_addr, NULL, NULL);
210
211 return 0;
212}
213
214void be_get_stats_timer_handler(unsigned long context)
215{
216 struct be_timer_ctxt *ctxt = (struct be_timer_ctxt *)context;
217
218 if (atomic_read(&ctxt->get_stat_flag)) {
219 atomic_dec(&ctxt->get_stat_flag);
220 up((void *)ctxt->get_stat_sem_addr);
221 }
222 del_timer(&ctxt->get_stats_timer);
223 return;
224}
225
226void be_get_stat_cb(void *context, int status,
227 struct MCC_WRB_AMAP *optional_wrb)
228{
229 struct be_timer_ctxt *ctxt = (struct be_timer_ctxt *)context;
230 /*
231 * just up the semaphore if the get_stat_flag
232 * reads 1. so that the waiter can continue.
233 * If it is 0, then it was handled by the timer handler.
234 */
235 del_timer(&ctxt->get_stats_timer);
236 if (atomic_read(&ctxt->get_stat_flag)) {
237 atomic_dec(&ctxt->get_stat_flag);
238 up((void *)ctxt->get_stat_sem_addr);
239 }
240}
241
242struct net_device_stats *benet_get_stats(struct net_device *dev)
243{
244 struct be_net_object *pnob = netdev_priv(dev);
245 struct be_adapter *adapter = pnob->adapter;
246 u64 pa;
247 struct be_timer_ctxt *ctxt = &adapter->timer_ctxt;
248
249 if (adapter->dev_state != BE_DEV_STATE_OPEN) {
250 /* Return previously read stats */
251 return &(adapter->benet_stats);
252 }
253 /* Get Physical Addr */
254 pa = pci_map_single(adapter->pdev, adapter->eth_statsp,
255 sizeof(struct FWCMD_ETH_GET_STATISTICS),
256 PCI_DMA_FROMDEVICE);
257 ctxt->get_stat_sem_addr = (unsigned long)&adapter->get_eth_stat_sem;
258 atomic_inc(&ctxt->get_stat_flag);
259
260 be_rxf_query_eth_statistics(&pnob->fn_obj, adapter->eth_statsp,
261 cpu_to_le64(pa), be_get_stat_cb, ctxt,
262 NULL);
263
264 ctxt->get_stats_timer.data = (unsigned long)ctxt;
265 mod_timer(&ctxt->get_stats_timer, (jiffies + (HZ * 2)));
266 down((void *)ctxt->get_stat_sem_addr); /* callback will unblock us */
267
268 /* Adding port0 and port1 stats. */
269 adapter->benet_stats.rx_packets =
270 adapter->eth_statsp->params.response.p0recvdtotalframes +
271 adapter->eth_statsp->params.response.p1recvdtotalframes;
272 adapter->benet_stats.tx_packets =
273 adapter->eth_statsp->params.response.p0xmitunicastframes +
274 adapter->eth_statsp->params.response.p1xmitunicastframes;
275 adapter->benet_stats.tx_bytes =
276 adapter->eth_statsp->params.response.p0xmitbyteslsd +
277 adapter->eth_statsp->params.response.p1xmitbyteslsd;
278 adapter->benet_stats.rx_errors =
279 adapter->eth_statsp->params.response.p0crcerrors +
280 adapter->eth_statsp->params.response.p1crcerrors;
281 adapter->benet_stats.rx_errors +=
282 adapter->eth_statsp->params.response.p0alignmentsymerrs +
283 adapter->eth_statsp->params.response.p1alignmentsymerrs;
284 adapter->benet_stats.rx_errors +=
285 adapter->eth_statsp->params.response.p0inrangelenerrors +
286 adapter->eth_statsp->params.response.p1inrangelenerrors;
287 adapter->benet_stats.rx_bytes =
288 adapter->eth_statsp->params.response.p0recvdtotalbytesLSD +
289 adapter->eth_statsp->params.response.p1recvdtotalbytesLSD;
290 adapter->benet_stats.rx_crc_errors =
291 adapter->eth_statsp->params.response.p0crcerrors +
292 adapter->eth_statsp->params.response.p1crcerrors;
293
294 adapter->benet_stats.tx_packets +=
295 adapter->eth_statsp->params.response.p0xmitmulticastframes +
296 adapter->eth_statsp->params.response.p1xmitmulticastframes;
297 adapter->benet_stats.tx_packets +=
298 adapter->eth_statsp->params.response.p0xmitbroadcastframes +
299 adapter->eth_statsp->params.response.p1xmitbroadcastframes;
300 adapter->benet_stats.tx_errors = 0;
301
302 adapter->benet_stats.multicast =
303 adapter->eth_statsp->params.response.p0xmitmulticastframes +
304 adapter->eth_statsp->params.response.p1xmitmulticastframes;
305
306 adapter->benet_stats.rx_fifo_errors =
307 adapter->eth_statsp->params.response.p0rxfifooverflowdropped +
308 adapter->eth_statsp->params.response.p1rxfifooverflowdropped;
309 adapter->benet_stats.rx_frame_errors =
310 adapter->eth_statsp->params.response.p0alignmentsymerrs +
311 adapter->eth_statsp->params.response.p1alignmentsymerrs;
312 adapter->benet_stats.rx_length_errors =
313 adapter->eth_statsp->params.response.p0inrangelenerrors +
314 adapter->eth_statsp->params.response.p1inrangelenerrors;
315 adapter->benet_stats.rx_length_errors +=
316 adapter->eth_statsp->params.response.p0outrangeerrors +
317 adapter->eth_statsp->params.response.p1outrangeerrors;
318 adapter->benet_stats.rx_length_errors +=
319 adapter->eth_statsp->params.response.p0frametoolongerrors +
320 adapter->eth_statsp->params.response.p1frametoolongerrors;
321
322 pci_unmap_single(adapter->pdev, (ulong) adapter->eth_statsp,
323 sizeof(struct FWCMD_ETH_GET_STATISTICS),
324 PCI_DMA_FROMDEVICE);
325 return &(adapter->benet_stats);
326
327}
328
329static void be_start_tx(struct be_net_object *pnob, u32 nposted)
330{
331#define CSR_ETH_MAX_SQPOSTS 255
332 struct SQ_DB_AMAP sqdb;
333
334 sqdb.dw[0] = 0;
335
336 AMAP_SET_BITS_PTR(SQ_DB, cid, &sqdb, pnob->tx_q_id);
337 while (nposted) {
338 if (nposted > CSR_ETH_MAX_SQPOSTS) {
339 AMAP_SET_BITS_PTR(SQ_DB, numPosted, &sqdb,
340 CSR_ETH_MAX_SQPOSTS);
341 nposted -= CSR_ETH_MAX_SQPOSTS;
342 } else {
343 AMAP_SET_BITS_PTR(SQ_DB, numPosted, &sqdb, nposted);
344 nposted = 0;
345 }
346 PD_WRITE(&pnob->fn_obj, etx_sq_db, sqdb.dw[0]);
347 }
348
349 return;
350}
351
352static void update_tx_rate(struct be_adapter *adapter)
353{
354 /* update the rate once in two seconds */
355 if ((jiffies - adapter->eth_tx_jiffies) > 2 * (HZ)) {
356 u32 r;
357 r = adapter->eth_tx_bytes /
358 ((jiffies - adapter->eth_tx_jiffies) / (HZ));
359 r = (r / 1000000); /* M bytes/s */
360 adapter->be_stat.bes_eth_tx_rate = (r * 8); /* M bits/s */
361 adapter->eth_tx_jiffies = jiffies;
362 adapter->eth_tx_bytes = 0;
363 }
364}
365
366static int wrb_cnt_in_skb(struct sk_buff *skb)
367{
368 int cnt = 0;
369 while (skb) {
370 if (skb->len > skb->data_len)
371 cnt++;
372 cnt += skb_shinfo(skb)->nr_frags;
373 skb = skb_shinfo(skb)->frag_list;
374 }
375 BUG_ON(cnt > BE_MAX_TX_FRAG_COUNT);
376 return cnt;
377}
378
379static void wrb_fill(struct ETH_WRB_AMAP *wrb, u64 addr, int len)
380{
381 AMAP_SET_BITS_PTR(ETH_WRB, frag_pa_hi, wrb, addr >> 32);
382 AMAP_SET_BITS_PTR(ETH_WRB, frag_pa_lo, wrb, addr & 0xFFFFFFFF);
383 AMAP_SET_BITS_PTR(ETH_WRB, frag_len, wrb, len);
384}
385
386static void wrb_fill_extra(struct ETH_WRB_AMAP *wrb, struct sk_buff *skb,
387 struct be_net_object *pnob)
388{
389 wrb->dw[2] = 0;
390 wrb->dw[3] = 0;
391 AMAP_SET_BITS_PTR(ETH_WRB, crc, wrb, 1);
392 if (skb_shinfo(skb)->gso_segs > 1 && skb_shinfo(skb)->gso_size) {
393 AMAP_SET_BITS_PTR(ETH_WRB, lso, wrb, 1);
394 AMAP_SET_BITS_PTR(ETH_WRB, lso_mss, wrb,
395 skb_shinfo(skb)->gso_size);
396 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
397 u8 proto = ((struct iphdr *)ip_hdr(skb))->protocol;
398 if (proto == IPPROTO_TCP)
399 AMAP_SET_BITS_PTR(ETH_WRB, tcpcs, wrb, 1);
400 else if (proto == IPPROTO_UDP)
401 AMAP_SET_BITS_PTR(ETH_WRB, udpcs, wrb, 1);
402 }
403 if (pnob->vlan_grp && vlan_tx_tag_present(skb)) {
404 AMAP_SET_BITS_PTR(ETH_WRB, vlan, wrb, 1);
405 AMAP_SET_BITS_PTR(ETH_WRB, vlan_tag, wrb, vlan_tx_tag_get(skb));
406 }
407}
408
409static inline void wrb_copy_extra(struct ETH_WRB_AMAP *to,
410 struct ETH_WRB_AMAP *from)
411{
412
413 to->dw[2] = from->dw[2];
414 to->dw[3] = from->dw[3];
415}
416
417/* Returns the actual count of wrbs used including a possible dummy */
418static int copy_skb_to_txq(struct be_net_object *pnob, struct sk_buff *skb,
419 u32 wrb_cnt, u32 *copied)
420{
421 u64 busaddr;
422 struct ETH_WRB_AMAP *wrb = NULL, *first = NULL;
423 u32 i;
424 bool dummy = true;
425 struct pci_dev *pdev = pnob->adapter->pdev;
426
427 if (wrb_cnt & 1)
428 wrb_cnt++;
429 else
430 dummy = false;
431
432 atomic_add(wrb_cnt, &pnob->tx_q_used);
433
434 while (skb) {
435 if (skb->len > skb->data_len) {
436 int len = skb->len - skb->data_len;
437 busaddr = pci_map_single(pdev, skb->data, len,
438 PCI_DMA_TODEVICE);
439 busaddr = cpu_to_le64(busaddr);
440 wrb = &pnob->tx_q[pnob->tx_q_hd];
441 if (first == NULL) {
442 wrb_fill_extra(wrb, skb, pnob);
443 first = wrb;
444 } else {
445 wrb_copy_extra(wrb, first);
446 }
447 wrb_fill(wrb, busaddr, len);
448 be_adv_txq_hd(pnob);
449 *copied += len;
450 }
451
452 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
453 struct skb_frag_struct *frag =
454 &skb_shinfo(skb)->frags[i];
455 busaddr = pci_map_page(pdev, frag->page,
456 frag->page_offset, frag->size,
457 PCI_DMA_TODEVICE);
458 busaddr = cpu_to_le64(busaddr);
459 wrb = &pnob->tx_q[pnob->tx_q_hd];
460 if (first == NULL) {
461 wrb_fill_extra(wrb, skb, pnob);
462 first = wrb;
463 } else {
464 wrb_copy_extra(wrb, first);
465 }
466 wrb_fill(wrb, busaddr, frag->size);
467 be_adv_txq_hd(pnob);
468 *copied += frag->size;
469 }
470 skb = skb_shinfo(skb)->frag_list;
471 }
472
473 if (dummy) {
474 wrb = &pnob->tx_q[pnob->tx_q_hd];
475 BUG_ON(first == NULL);
476 wrb_copy_extra(wrb, first);
477 wrb_fill(wrb, 0, 0);
478 be_adv_txq_hd(pnob);
479 }
480 AMAP_SET_BITS_PTR(ETH_WRB, complete, wrb, 1);
481 AMAP_SET_BITS_PTR(ETH_WRB, last, wrb, 1);
482 return wrb_cnt;
483}
484
485/* For each skb transmitted, tx_ctxt stores the num of wrbs in the
486 * start index and skb pointer in the end index
487 */
488static inline void be_tx_wrb_info_remember(struct be_net_object *pnob,
489 struct sk_buff *skb, int wrb_cnt,
490 u32 start)
491{
492 *(u32 *) (&pnob->tx_ctxt[start]) = wrb_cnt;
493 index_adv(&start, wrb_cnt - 1, pnob->tx_q_len);
494 pnob->tx_ctxt[start] = skb;
495}
496
497static int benet_xmit(struct sk_buff *skb, struct net_device *netdev)
498{
499 struct be_net_object *pnob = netdev_priv(netdev);
500 struct be_adapter *adapter = pnob->adapter;
501 u32 wrb_cnt, copied = 0;
502 u32 start = pnob->tx_q_hd;
503
504 adapter->be_stat.bes_tx_reqs++;
505
506 wrb_cnt = wrb_cnt_in_skb(skb);
507 spin_lock_bh(&adapter->txq_lock);
508 if ((pnob->tx_q_len - 2 - atomic_read(&pnob->tx_q_used)) <= wrb_cnt) {
509 netif_stop_queue(pnob->netdev);
510 spin_unlock_bh(&adapter->txq_lock);
511 adapter->be_stat.bes_tx_fails++;
512 return NETDEV_TX_BUSY;
513 }
514 spin_unlock_bh(&adapter->txq_lock);
515
516 wrb_cnt = copy_skb_to_txq(pnob, skb, wrb_cnt, &copied);
517 be_tx_wrb_info_remember(pnob, skb, wrb_cnt, start);
518
519 be_start_tx(pnob, wrb_cnt);
520
521 adapter->eth_tx_bytes += copied;
522 adapter->be_stat.bes_tx_wrbs += wrb_cnt;
523 update_tx_rate(adapter);
524 netdev->trans_start = jiffies;
525
526 return NETDEV_TX_OK;
527}
528
529/*
530 * This is the driver entry point to change the mtu of the device
531 * Returns 0 for success and errno for failure.
532 */
533static int benet_change_mtu(struct net_device *netdev, int new_mtu)
534{
535 /*
536 * BE supports jumbo frame size upto 9000 bytes including the link layer
537 * header. Considering the different variants of frame formats possible
538 * like VLAN, SNAP/LLC, the maximum possible value for MTU is 8974 bytes
539 */
540
541 if (new_mtu < (ETH_ZLEN + ETH_FCS_LEN) || (new_mtu > BE_MAX_MTU)) {
542 dev_info(&netdev->dev, "Invalid MTU requested. "
543 "Must be between %d and %d bytes\n",
544 (ETH_ZLEN + ETH_FCS_LEN), BE_MAX_MTU);
545 return -EINVAL;
546 }
547 dev_info(&netdev->dev, "MTU changed from %d to %d\n",
548 netdev->mtu, new_mtu);
549 netdev->mtu = new_mtu;
550 return 0;
551}
552
553/*
554 * This is the driver entry point to register a vlan with the device
555 */
556static void benet_vlan_register(struct net_device *netdev,
557 struct vlan_group *grp)
558{
559 struct be_net_object *pnob = netdev_priv(netdev);
560
561 be_disable_eq_intr(pnob);
562 pnob->vlan_grp = grp;
563 pnob->num_vlans = 0;
564 be_enable_eq_intr(pnob);
565}
566
567/*
568 * This is the driver entry point to add a vlan vlan_id
569 * with the device netdev
570 */
571static void benet_vlan_add_vid(struct net_device *netdev, u16 vlan_id)
572{
573 struct be_net_object *pnob = netdev_priv(netdev);
574
575 if (pnob->num_vlans == (BE_NUM_VLAN_SUPPORTED - 1)) {
576 /* no way to return an error */
577 dev_info(&netdev->dev,
578 "BladeEngine: Cannot configure more than %d Vlans\n",
579 BE_NUM_VLAN_SUPPORTED);
580 return;
581 }
582 /* The new vlan tag will be in the slot indicated by num_vlans. */
583 pnob->vlan_tag[pnob->num_vlans++] = vlan_id;
584 be_rxf_vlan_config(&pnob->fn_obj, false, pnob->num_vlans,
585 pnob->vlan_tag, NULL, NULL, NULL);
586}
587
588/*
589 * This is the driver entry point to remove a vlan vlan_id
590 * with the device netdev
591 */
592static void benet_vlan_rem_vid(struct net_device *netdev, u16 vlan_id)
593{
594 struct be_net_object *pnob = netdev_priv(netdev);
595
596 u32 i, value;
597
598 /*
599 * In Blade Engine, we support 32 vlan tag filters across both ports.
600 * To program a vlan tag, the RXF_RTPR_CSR register is used.
601 * Each 32-bit value of RXF_RTDR_CSR can address 2 vlan tag entries.
602 * The Vlan table is of depth 16. thus we support 32 tags.
603 */
604
605 value = vlan_id | VLAN_VALID_BIT;
606 for (i = 0; i < BE_NUM_VLAN_SUPPORTED; i++) {
607 if (pnob->vlan_tag[i] == vlan_id)
608 break;
609 }
610
611 if (i == BE_NUM_VLAN_SUPPORTED)
612 return;
613 /* Now compact the vlan tag array by removing hole created. */
614 while ((i + 1) < BE_NUM_VLAN_SUPPORTED) {
615 pnob->vlan_tag[i] = pnob->vlan_tag[i + 1];
616 i++;
617 }
618 if ((i + 1) == BE_NUM_VLAN_SUPPORTED)
619 pnob->vlan_tag[i] = (u16) 0x0;
620 pnob->num_vlans--;
621 be_rxf_vlan_config(&pnob->fn_obj, false, pnob->num_vlans,
622 pnob->vlan_tag, NULL, NULL, NULL);
623}
624
625/*
626 * This function is called to program multicast
627 * address in the multicast filter of the ASIC.
628 */
629static void be_set_multicast_filter(struct net_device *netdev)
630{
631 struct be_net_object *pnob = netdev_priv(netdev);
632 struct dev_mc_list *mc_ptr;
633 u8 mac_addr[32][ETH_ALEN];
634 int i;
635
636 if (netdev->flags & IFF_ALLMULTI) {
637 /* set BE in Multicast promiscuous */
638 be_rxf_multicast_config(&pnob->fn_obj, true, 0, NULL, NULL,
639 NULL, NULL);
640 return;
641 }
642
643 for (mc_ptr = netdev->mc_list, i = 0; mc_ptr;
644 mc_ptr = mc_ptr->next, i++) {
645 memcpy(&mac_addr[i][0], mc_ptr->dmi_addr, ETH_ALEN);
646 }
647
648 /* reset the promiscuous mode also. */
649 be_rxf_multicast_config(&pnob->fn_obj, false, i,
650 &mac_addr[0][0], NULL, NULL, NULL);
651}
652
653/*
654 * This is the driver entry point to set multicast list
655 * with the device netdev. This function will be used to
656 * set promiscuous mode or multicast promiscuous mode
657 * or multicast mode....
658 */
659static void benet_set_multicast_list(struct net_device *netdev)
660{
661 struct be_net_object *pnob = netdev_priv(netdev);
662
663 if (netdev->flags & IFF_PROMISC) {
664 be_rxf_promiscuous(&pnob->fn_obj, 1, 1, NULL, NULL, NULL);
665 } else {
666 be_rxf_promiscuous(&pnob->fn_obj, 0, 0, NULL, NULL, NULL);
667 be_set_multicast_filter(netdev);
668 }
669}
670
671int benet_init(struct net_device *netdev)
672{
673 struct be_net_object *pnob = netdev_priv(netdev);
674 struct be_adapter *adapter = pnob->adapter;
675
676 ether_setup(netdev);
677
678 netdev->open = &benet_open;
679 netdev->stop = &benet_close;
680 netdev->hard_start_xmit = &benet_xmit;
681
682 netdev->get_stats = &benet_get_stats;
683
684 netdev->set_multicast_list = &benet_set_multicast_list;
685
686 netdev->change_mtu = &benet_change_mtu;
687 netdev->set_mac_address = &benet_set_mac_addr;
688
689 netdev->vlan_rx_register = benet_vlan_register;
690 netdev->vlan_rx_add_vid = benet_vlan_add_vid;
691 netdev->vlan_rx_kill_vid = benet_vlan_rem_vid;
692
693 netdev->features =
694 NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_RX | NETIF_F_TSO |
695 NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_FILTER | NETIF_F_IP_CSUM;
696
697 netdev->flags |= IFF_MULTICAST;
698
699 /* If device is DAC Capable, set the HIGHDMA flag for netdevice. */
700 if (adapter->dma_64bit_cap)
701 netdev->features |= NETIF_F_HIGHDMA;
702
703 SET_ETHTOOL_OPS(netdev, &be_ethtool_ops);
704 return 0;
705}
diff --git a/drivers/staging/benet/benet.h b/drivers/staging/benet/benet.h
deleted file mode 100644
index 09a1f0817722..000000000000
--- a/drivers/staging/benet/benet.h
+++ /dev/null
@@ -1,429 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#ifndef _BENET_H_
18#define _BENET_H_
19
20#include <linux/pci.h>
21#include <linux/netdevice.h>
22#include <linux/inet_lro.h>
23#include "hwlib.h"
24
25#define _SA_MODULE_NAME "net-driver"
26
27#define VLAN_VALID_BIT 0x8000
28#define BE_NUM_VLAN_SUPPORTED 32
29#define BE_PORT_LINK_DOWN 0000
30#define BE_PORT_LINK_UP 0001
31#define BE_MAX_TX_FRAG_COUNT (30)
32
33/* Flag bits for send operation */
34#define IPCS (1 << 0) /* Enable IP checksum offload */
35#define UDPCS (1 << 1) /* Enable UDP checksum offload */
36#define TCPCS (1 << 2) /* Enable TCP checksum offload */
37#define LSO (1 << 3) /* Enable Large Segment offload */
38#define ETHVLAN (1 << 4) /* Enable VLAN insert */
39#define ETHEVENT (1 << 5) /* Generate event on completion */
40#define ETHCOMPLETE (1 << 6) /* Generate completion when done */
41#define IPSEC (1 << 7) /* Enable IPSEC */
42#define FORWARD (1 << 8) /* Send the packet in forwarding path */
43#define FIN (1 << 9) /* Issue FIN segment */
44
45#define BE_MAX_MTU 8974
46
47#define BE_MAX_LRO_DESCRIPTORS 8
48#define BE_LRO_MAX_PKTS 64
49#define BE_MAX_FRAGS_PER_FRAME 6
50
51extern const char be_drvr_ver[];
52extern char be_fw_ver[];
53extern char be_driver_name[];
54
55extern struct ethtool_ops be_ethtool_ops;
56
57#define BE_DEV_STATE_NONE 0
58#define BE_DEV_STATE_INIT 1
59#define BE_DEV_STATE_OPEN 2
60#define BE_DEV_STATE_SUSPEND 3
61
62/* This structure is used to describe physical fragments to use
63 * for DMAing data from NIC.
64 */
65struct be_recv_buffer {
66 struct list_head rxb_list; /* for maintaining a linked list */
67 void *rxb_va; /* buffer virtual address */
68 u32 rxb_pa_lo; /* low part of physical address */
69 u32 rxb_pa_hi; /* high part of physical address */
70 u32 rxb_len; /* length of recv buffer */
71 void *rxb_ctxt; /* context for OSM driver to use */
72};
73
74/*
75 * fragment list to describe scattered data.
76 */
77struct be_tx_frag_list {
78 u32 txb_len; /* Size of this fragment */
79 u32 txb_pa_lo; /* Lower 32 bits of 64 bit physical addr */
80 u32 txb_pa_hi; /* Higher 32 bits of 64 bit physical addr */
81};
82
83struct be_rx_page_info {
84 struct page *page;
85 dma_addr_t bus;
86 u16 page_offset;
87};
88
89/*
90 * This structure is the main tracking structure for a NIC interface.
91 */
92struct be_net_object {
93 /* MCC Ring - used to send fwcmds to embedded ARM processor */
94 struct MCC_WRB_AMAP *mcc_q; /* VA of the start of the ring */
95 u32 mcc_q_len; /* # of WRB entries in this ring */
96 u32 mcc_q_size;
97 u32 mcc_q_hd; /* MCC ring head */
98 u8 mcc_q_created; /* flag to help cleanup */
99 struct be_mcc_object mcc_q_obj; /* BECLIB's MCC ring Object */
100 dma_addr_t mcc_q_bus; /* DMA'ble bus address */
101
102 /* MCC Completion Ring - FW responses to fwcmds sent from MCC ring */
103 struct MCC_CQ_ENTRY_AMAP *mcc_cq; /* VA of the start of the ring */
104 u32 mcc_cq_len; /* # of compl. entries in this ring */
105 u32 mcc_cq_size;
106 u32 mcc_cq_tl; /* compl. ring tail */
107 u8 mcc_cq_created; /* flag to help cleanup */
108 struct be_cq_object mcc_cq_obj; /* BECLIB's MCC compl. ring object */
109 u32 mcc_cq_id; /* MCC ring ID */
110 dma_addr_t mcc_cq_bus; /* DMA'ble bus address */
111
112 struct ring_desc mb_rd; /* RD for MCC_MAIL_BOX */
113 void *mb_ptr; /* mailbox ptr to be freed */
114 dma_addr_t mb_bus; /* DMA'ble bus address */
115 u32 mb_size;
116
117 /* BEClib uses an array of context objects to track outstanding
118 * requests to the MCC. We need allocate the same number of
119 * conext entries as the number of entries in the MCC WRB ring
120 */
121 u32 mcc_wrb_ctxt_size;
122 void *mcc_wrb_ctxt; /* pointer to the context area */
123 u32 mcc_wrb_ctxtLen; /* Number of entries in the context */
124 /*
125 * NIC send request ring - used for xmitting raw ether frames.
126 */
127 struct ETH_WRB_AMAP *tx_q; /* VA of the start of the ring */
128 u32 tx_q_len; /* # if entries in the send ring */
129 u32 tx_q_size;
130 u32 tx_q_hd; /* Head index. Next req. goes here */
131 u32 tx_q_tl; /* Tail indx. oldest outstanding req. */
132 u8 tx_q_created; /* flag to help cleanup */
133 struct be_ethsq_object tx_q_obj;/* BECLIB's send Q handle */
134 dma_addr_t tx_q_bus; /* DMA'ble bus address */
135 u32 tx_q_id; /* send queue ring ID */
136 u32 tx_q_port; /* 0 no binding, 1 port A, 2 port B */
137 atomic_t tx_q_used; /* # of WRBs used */
138 /* ptr to an array in which we store context info for each send req. */
139 void **tx_ctxt;
140 /*
141 * NIC Send compl. ring - completion status for all NIC frames xmitted.
142 */
143 struct ETH_TX_COMPL_AMAP *tx_cq;/* VA of start of the ring */
144 u32 txcq_len; /* # of entries in the ring */
145 u32 tx_cq_size;
146 /*
147 * index into compl ring where the host expects next completion entry
148 */
149 u32 tx_cq_tl;
150 u32 tx_cq_id; /* completion queue id */
151 u8 tx_cq_created; /* flag to help cleanup */
152 struct be_cq_object tx_cq_obj;
153 dma_addr_t tx_cq_bus; /* DMA'ble bus address */
154 /*
155 * Event Queue - all completion entries post events here.
156 */
157 struct EQ_ENTRY_AMAP *event_q; /* VA of start of event queue */
158 u32 event_q_len; /* # of entries */
159 u32 event_q_size;
160 u32 event_q_tl; /* Tail of the event queue */
161 u32 event_q_id; /* Event queue ID */
162 u8 event_q_created; /* flag to help cleanup */
163 struct be_eq_object event_q_obj; /* Queue handle */
164 dma_addr_t event_q_bus; /* DMA'ble bus address */
165 /*
166 * NIC receive queue - Data buffers to be used for receiving unicast,
167 * broadcast and multi-cast frames are posted here.
168 */
169 struct ETH_RX_D_AMAP *rx_q; /* VA of start of the queue */
170 u32 rx_q_len; /* # of entries */
171 u32 rx_q_size;
172 u32 rx_q_hd; /* Head of the queue */
173 atomic_t rx_q_posted; /* number of posted buffers */
174 u32 rx_q_id; /* queue ID */
175 u8 rx_q_created; /* flag to help cleanup */
176 struct be_ethrq_object rx_q_obj; /* NIC RX queue handle */
177 dma_addr_t rx_q_bus; /* DMA'ble bus address */
178 /*
179 * Pointer to an array of opaque context object for use by OSM driver
180 */
181 void **rx_ctxt;
182 /*
183 * NIC unicast RX completion queue - all unicast ether frame completion
184 * statuses from BE come here.
185 */
186 struct ETH_RX_COMPL_AMAP *rx_cq; /* VA of start of the queue */
187 u32 rx_cq_len; /* # of entries */
188 u32 rx_cq_size;
189 u32 rx_cq_tl; /* Tail of the queue */
190 u32 rx_cq_id; /* queue ID */
191 u8 rx_cq_created; /* flag to help cleanup */
192 struct be_cq_object rx_cq_obj; /* queue handle */
193 dma_addr_t rx_cq_bus; /* DMA'ble bus address */
194 struct be_function_object fn_obj; /* function object */
195 bool fn_obj_created;
196 u32 rx_buf_size; /* Size of the RX buffers */
197
198 struct net_device *netdev;
199 struct be_recv_buffer eth_rx_bufs[256]; /* to pass Rx buffer
200 addresses */
201 struct be_adapter *adapter; /* Pointer to OSM adapter */
202 u32 devno; /* OSM, network dev no. */
203 u32 use_port; /* Current active port */
204 struct be_rx_page_info *rx_page_info; /* Array of Rx buf pages */
205 u32 rx_pg_info_hd; /* Head of queue */
206 int rxbuf_post_fail; /* RxBuff posting fail count */
207 bool rx_pg_shared; /* Is an allocsted page shared as two frags ? */
208 struct vlan_group *vlan_grp;
209 u32 num_vlans; /* Number of vlans in BE's filter */
210 u16 vlan_tag[BE_NUM_VLAN_SUPPORTED]; /* vlans currently configured */
211 struct napi_struct napi;
212 struct net_lro_mgr lro_mgr;
213 struct net_lro_desc lro_desc[BE_MAX_LRO_DESCRIPTORS];
214};
215
216#define NET_FH(np) (&(np)->fn_obj)
217
218/*
219 * BE driver statistics.
220 */
221struct be_drvr_stat {
222 u32 bes_tx_reqs; /* number of TX requests initiated */
223 u32 bes_tx_fails; /* number of TX requests that failed */
224 u32 bes_fwd_reqs; /* number of send reqs through forwarding i/f */
225 u32 bes_tx_wrbs; /* number of tx WRBs used */
226
227 u32 bes_ints; /* number of interrupts */
228 u32 bes_polls; /* number of times NAPI called poll function */
229 u32 bes_events; /* total evet entries processed */
230 u32 bes_tx_events; /* number of tx completion events */
231 u32 bes_rx_events; /* number of ucast rx completion events */
232 u32 bes_tx_compl; /* number of tx completion entries processed */
233 u32 bes_rx_compl; /* number of rx completion entries
234 processed */
235 u32 bes_ethrx_post_fail; /* number of ethrx buffer alloc
236 failures */
237 /*
238 * number of non ether type II frames dropped where
239 * frame len > length field of Mac Hdr
240 */
241 u32 bes_802_3_dropped_frames;
242 /*
243 * number of non ether type II frames malformed where
244 * in frame len < length field of Mac Hdr
245 */
246 u32 bes_802_3_malformed_frames;
247 u32 bes_ips; /* interrupts / sec */
248 u32 bes_prev_ints; /* bes_ints at last IPS calculation */
249 u16 bes_eth_tx_rate; /* ETH TX rate - Mb/sec */
250 u16 bes_eth_rx_rate; /* ETH RX rate - Mb/sec */
251 u32 bes_rx_coal; /* Num pkts coalasced */
252 u32 bes_rx_flush; /* Num times coalasced */
253 u32 bes_link_change_physical; /*Num of times physical link changed */
254 u32 bes_link_change_virtual; /*Num of times virtual link changed */
255 u32 bes_rx_misc_pkts; /* Misc pkts received */
256};
257
258/* Maximum interrupt delay (in microseconds) allowed */
259#define MAX_EQD 120
260
261/*
262 * timer to prevent system shutdown hang for ever if h/w stops responding
263 */
264struct be_timer_ctxt {
265 atomic_t get_stat_flag;
266 struct timer_list get_stats_timer;
267 unsigned long get_stat_sem_addr;
268} ;
269
270/* This structure is the main BladeEngine driver context. */
271struct be_adapter {
272 struct net_device *netdevp;
273 struct be_drvr_stat be_stat;
274 struct net_device_stats benet_stats;
275
276 /* PCI BAR mapped addresses */
277 u8 __iomem *csr_va; /* CSR */
278 u8 __iomem *db_va; /* Door Bell */
279 u8 __iomem *pci_va; /* PCI Config */
280
281 struct tasklet_struct sts_handler;
282 struct timer_list cq_timer;
283 spinlock_t int_lock; /* to protect the isr field in adapter */
284
285 struct FWCMD_ETH_GET_STATISTICS *eth_statsp;
286 /*
287 * This will enable the use of ethtool to enable or disable
288 * Checksum on Rx pkts to be obeyed or disobeyed.
289 * If this is true = 1, then whatever is the checksum on the
290 * Received pkt as per BE, it will be given to the stack.
291 * Else the stack will re calculate it.
292 */
293 bool rx_csum;
294 /*
295 * This will enable the use of ethtool to enable or disable
296 * Coalese on Rx pkts to be obeyed or disobeyed.
297 * If this is grater than 0 and less than 16 then coalascing
298 * is enabled else it is disabled
299 */
300 u32 max_rx_coal;
301 struct pci_dev *pdev; /* Pointer to OS's PCI dvice */
302
303 spinlock_t txq_lock; /* to stop/wake queue based on tx_q_used */
304
305 u32 isr; /* copy of Intr status reg. */
306
307 u32 port0_link_sts; /* Port 0 link status */
308 u32 port1_link_sts; /* port 1 list status */
309 struct BE_LINK_STATUS *be_link_sts;
310
311 /* pointer to the first netobject of this adapter */
312 struct be_net_object *net_obj;
313
314 /* Flags to indicate what to clean up */
315 bool tasklet_started;
316 bool isr_registered;
317 /*
318 * adaptive interrupt coalescing (AIC) related
319 */
320 bool enable_aic; /* 1 if AIC is enabled */
321 u16 min_eqd; /* minimum EQ delay in usec */
322 u16 max_eqd; /* minimum EQ delay in usec */
323 u16 cur_eqd; /* current EQ delay in usec */
324 /*
325 * book keeping for interrupt / sec and TX/RX rate calculation
326 */
327 ulong ips_jiffies; /* jiffies at last IPS calc */
328 u32 eth_tx_bytes;
329 ulong eth_tx_jiffies;
330 u32 eth_rx_bytes;
331 ulong eth_rx_jiffies;
332
333 struct semaphore get_eth_stat_sem;
334
335 /* timer ctxt to prevent shutdown hanging due to un-responsive BE */
336 struct be_timer_ctxt timer_ctxt;
337
338#define BE_MAX_MSIX_VECTORS 32
339#define BE_MAX_REQ_MSIX_VECTORS 1 /* only one EQ in Linux driver */
340 struct msix_entry msix_entries[BE_MAX_MSIX_VECTORS];
341 bool msix_enabled;
342 bool dma_64bit_cap; /* the Device DAC capable or not */
343 u8 dev_state; /* The current state of the device */
344 u8 dev_pm_state; /* The State of device before going to suspend */
345};
346
347/*
348 * Every second we look at the ints/sec and adjust eq_delay
349 * between adapter->min_eqd and adapter->max_eqd to keep the ints/sec between
350 * IPS_HI_WM and IPS_LO_WM.
351 */
352#define IPS_HI_WM 18000
353#define IPS_LO_WM 8000
354
355
356static inline void index_adv(u32 *index, u32 val, u32 limit)
357{
358 BUG_ON(limit & (limit-1));
359 *index = (*index + val) & (limit - 1);
360}
361
362static inline void index_inc(u32 *index, u32 limit)
363{
364 BUG_ON(limit & (limit-1));
365 *index = (*index + 1) & (limit - 1);
366}
367
368static inline void be_adv_eq_tl(struct be_net_object *pnob)
369{
370 index_inc(&pnob->event_q_tl, pnob->event_q_len);
371}
372
373static inline void be_adv_txq_hd(struct be_net_object *pnob)
374{
375 index_inc(&pnob->tx_q_hd, pnob->tx_q_len);
376}
377
378static inline void be_adv_txq_tl(struct be_net_object *pnob)
379{
380 index_inc(&pnob->tx_q_tl, pnob->tx_q_len);
381}
382
383static inline void be_adv_txcq_tl(struct be_net_object *pnob)
384{
385 index_inc(&pnob->tx_cq_tl, pnob->txcq_len);
386}
387
388static inline void be_adv_rxq_hd(struct be_net_object *pnob)
389{
390 index_inc(&pnob->rx_q_hd, pnob->rx_q_len);
391}
392
393static inline void be_adv_rxcq_tl(struct be_net_object *pnob)
394{
395 index_inc(&pnob->rx_cq_tl, pnob->rx_cq_len);
396}
397
398static inline u32 tx_compl_lastwrb_idx_get(struct be_net_object *pnob)
399{
400 return (pnob->tx_q_tl + *(u32 *)&pnob->tx_ctxt[pnob->tx_q_tl] - 1)
401 & (pnob->tx_q_len - 1);
402}
403
404int benet_init(struct net_device *);
405int be_ethtool_ioctl(struct net_device *, struct ifreq *);
406struct net_device_stats *benet_get_stats(struct net_device *);
407void be_process_intr(unsigned long context);
408irqreturn_t be_int(int irq, void *dev);
409void be_post_eth_rx_buffs(struct be_net_object *);
410void be_get_stat_cb(void *, int, struct MCC_WRB_AMAP *);
411void be_get_stats_timer_handler(unsigned long);
412void be_wait_nic_tx_cmplx_cmpl(struct be_net_object *);
413void be_print_link_info(struct BE_LINK_STATUS *);
414void be_update_link_status(struct be_adapter *);
415void be_init_procfs(struct be_adapter *);
416void be_cleanup_procfs(struct be_adapter *);
417int be_poll(struct napi_struct *, int);
418struct ETH_RX_COMPL_AMAP *be_get_rx_cmpl(struct be_net_object *);
419void be_notify_cmpl(struct be_net_object *, int, int, int);
420void be_enable_intr(struct be_net_object *);
421void be_enable_eq_intr(struct be_net_object *);
422void be_disable_intr(struct be_net_object *);
423void be_disable_eq_intr(struct be_net_object *);
424int be_set_uc_mac_adr(struct be_net_object *, u8, u8, u8,
425 u8 *, mcc_wrb_cqe_callback, void *);
426int be_get_flow_ctl(struct be_function_object *pFnObj, bool *, bool *);
427void process_one_tx_compl(struct be_net_object *pnob, u32 end_idx);
428
429#endif /* _BENET_H_ */
diff --git a/drivers/staging/benet/bestatus.h b/drivers/staging/benet/bestatus.h
deleted file mode 100644
index 59c7a4b62223..000000000000
--- a/drivers/staging/benet/bestatus.h
+++ /dev/null
@@ -1,103 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#ifndef _BESTATUS_H_
18#define _BESTATUS_H_
19
20#define BE_SUCCESS (0x00000000L)
21/*
22 * MessageId: BE_PENDING
23 * The BladeEngine Driver call succeeded, and pended operation.
24 */
25#define BE_PENDING (0x20070001L)
26#define BE_STATUS_PENDING (BE_PENDING)
27/*
28 * MessageId: BE_NOT_OK
29 * An error occurred.
30 */
31#define BE_NOT_OK (0xE0070002L)
32/*
33 * MessageId: BE_STATUS_SYSTEM_RESOURCES
34 * Insufficient host system resources exist to complete the API.
35 */
36#define BE_STATUS_SYSTEM_RESOURCES (0xE0070003L)
37/*
38 * MessageId: BE_STATUS_CHIP_RESOURCES
39 * Insufficient chip resources exist to complete the API.
40 */
41#define BE_STATUS_CHIP_RESOURCES (0xE0070004L)
42/*
43 * MessageId: BE_STATUS_NO_RESOURCE
44 * Insufficient resources to complete request.
45 */
46#define BE_STATUS_NO_RESOURCE (0xE0070005L)
47/*
48 * MessageId: BE_STATUS_BUSY
49 * Resource is currently busy.
50 */
51#define BE_STATUS_BUSY (0xE0070006L)
52/*
53 * MessageId: BE_STATUS_INVALID_PARAMETER
54 * Invalid Parameter in request.
55 */
56#define BE_STATUS_INVALID_PARAMETER (0xE0000007L)
57/*
58 * MessageId: BE_STATUS_NOT_SUPPORTED
59 * Requested operation is not supported.
60 */
61#define BE_STATUS_NOT_SUPPORTED (0xE000000DL)
62
63/*
64 * ***************************************************************************
65 * E T H E R N E T S T A T U S
66 * ***************************************************************************
67 */
68
69/*
70 * MessageId: BE_ETH_TX_ERROR
71 * The Ethernet device driver failed to transmit a packet.
72 */
73#define BE_ETH_TX_ERROR (0xE0070101L)
74
75/*
76 * ***************************************************************************
77 * S H A R E D S T A T U S
78 * ***************************************************************************
79 */
80
81/*
82 * MessageId: BE_STATUS_VBD_INVALID_VERSION
83 * The device driver is not compatible with this version of the VBD.
84 */
85#define BE_STATUS_INVALID_VERSION (0xE0070402L)
86/*
87 * MessageId: BE_STATUS_DOMAIN_DENIED
88 * The operation failed to complete due to insufficient access
89 * rights for the requesting domain.
90 */
91#define BE_STATUS_DOMAIN_DENIED (0xE0070403L)
92/*
93 * MessageId: BE_STATUS_TCP_NOT_STARTED
94 * The embedded TCP/IP stack has not been started.
95 */
96#define BE_STATUS_TCP_NOT_STARTED (0xE0070409L)
97/*
98 * MessageId: BE_STATUS_NO_MCC_WRB
99 * No free MCC WRB are available for posting the request.
100 */
101#define BE_STATUS_NO_MCC_WRB (0xE0070414L)
102
103#endif /* _BESTATUS_ */
diff --git a/drivers/staging/benet/cev.h b/drivers/staging/benet/cev.h
deleted file mode 100644
index 30996920a544..000000000000
--- a/drivers/staging/benet/cev.h
+++ /dev/null
@@ -1,243 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __cev_amap_h__
21#define __cev_amap_h__
22#include "ep.h"
23
24/*
25 * Host Interrupt Status Register 0. The first of four application
26 * interrupt status registers. This register contains the interrupts
27 * for Event Queues EQ0 through EQ31.
28 */
29struct BE_CEV_ISR0_CSR_AMAP {
30 u8 interrupt0; /* DWORD 0 */
31 u8 interrupt1; /* DWORD 0 */
32 u8 interrupt2; /* DWORD 0 */
33 u8 interrupt3; /* DWORD 0 */
34 u8 interrupt4; /* DWORD 0 */
35 u8 interrupt5; /* DWORD 0 */
36 u8 interrupt6; /* DWORD 0 */
37 u8 interrupt7; /* DWORD 0 */
38 u8 interrupt8; /* DWORD 0 */
39 u8 interrupt9; /* DWORD 0 */
40 u8 interrupt10; /* DWORD 0 */
41 u8 interrupt11; /* DWORD 0 */
42 u8 interrupt12; /* DWORD 0 */
43 u8 interrupt13; /* DWORD 0 */
44 u8 interrupt14; /* DWORD 0 */
45 u8 interrupt15; /* DWORD 0 */
46 u8 interrupt16; /* DWORD 0 */
47 u8 interrupt17; /* DWORD 0 */
48 u8 interrupt18; /* DWORD 0 */
49 u8 interrupt19; /* DWORD 0 */
50 u8 interrupt20; /* DWORD 0 */
51 u8 interrupt21; /* DWORD 0 */
52 u8 interrupt22; /* DWORD 0 */
53 u8 interrupt23; /* DWORD 0 */
54 u8 interrupt24; /* DWORD 0 */
55 u8 interrupt25; /* DWORD 0 */
56 u8 interrupt26; /* DWORD 0 */
57 u8 interrupt27; /* DWORD 0 */
58 u8 interrupt28; /* DWORD 0 */
59 u8 interrupt29; /* DWORD 0 */
60 u8 interrupt30; /* DWORD 0 */
61 u8 interrupt31; /* DWORD 0 */
62} __packed;
63struct CEV_ISR0_CSR_AMAP {
64 u32 dw[1];
65};
66
67/*
68 * Host Interrupt Status Register 1. The second of four application
69 * interrupt status registers. This register contains the interrupts
70 * for Event Queues EQ32 through EQ63.
71 */
72struct BE_CEV_ISR1_CSR_AMAP {
73 u8 interrupt32; /* DWORD 0 */
74 u8 interrupt33; /* DWORD 0 */
75 u8 interrupt34; /* DWORD 0 */
76 u8 interrupt35; /* DWORD 0 */
77 u8 interrupt36; /* DWORD 0 */
78 u8 interrupt37; /* DWORD 0 */
79 u8 interrupt38; /* DWORD 0 */
80 u8 interrupt39; /* DWORD 0 */
81 u8 interrupt40; /* DWORD 0 */
82 u8 interrupt41; /* DWORD 0 */
83 u8 interrupt42; /* DWORD 0 */
84 u8 interrupt43; /* DWORD 0 */
85 u8 interrupt44; /* DWORD 0 */
86 u8 interrupt45; /* DWORD 0 */
87 u8 interrupt46; /* DWORD 0 */
88 u8 interrupt47; /* DWORD 0 */
89 u8 interrupt48; /* DWORD 0 */
90 u8 interrupt49; /* DWORD 0 */
91 u8 interrupt50; /* DWORD 0 */
92 u8 interrupt51; /* DWORD 0 */
93 u8 interrupt52; /* DWORD 0 */
94 u8 interrupt53; /* DWORD 0 */
95 u8 interrupt54; /* DWORD 0 */
96 u8 interrupt55; /* DWORD 0 */
97 u8 interrupt56; /* DWORD 0 */
98 u8 interrupt57; /* DWORD 0 */
99 u8 interrupt58; /* DWORD 0 */
100 u8 interrupt59; /* DWORD 0 */
101 u8 interrupt60; /* DWORD 0 */
102 u8 interrupt61; /* DWORD 0 */
103 u8 interrupt62; /* DWORD 0 */
104 u8 interrupt63; /* DWORD 0 */
105} __packed;
106struct CEV_ISR1_CSR_AMAP {
107 u32 dw[1];
108};
109/*
110 * Host Interrupt Status Register 2. The third of four application
111 * interrupt status registers. This register contains the interrupts
112 * for Event Queues EQ64 through EQ95.
113 */
114struct BE_CEV_ISR2_CSR_AMAP {
115 u8 interrupt64; /* DWORD 0 */
116 u8 interrupt65; /* DWORD 0 */
117 u8 interrupt66; /* DWORD 0 */
118 u8 interrupt67; /* DWORD 0 */
119 u8 interrupt68; /* DWORD 0 */
120 u8 interrupt69; /* DWORD 0 */
121 u8 interrupt70; /* DWORD 0 */
122 u8 interrupt71; /* DWORD 0 */
123 u8 interrupt72; /* DWORD 0 */
124 u8 interrupt73; /* DWORD 0 */
125 u8 interrupt74; /* DWORD 0 */
126 u8 interrupt75; /* DWORD 0 */
127 u8 interrupt76; /* DWORD 0 */
128 u8 interrupt77; /* DWORD 0 */
129 u8 interrupt78; /* DWORD 0 */
130 u8 interrupt79; /* DWORD 0 */
131 u8 interrupt80; /* DWORD 0 */
132 u8 interrupt81; /* DWORD 0 */
133 u8 interrupt82; /* DWORD 0 */
134 u8 interrupt83; /* DWORD 0 */
135 u8 interrupt84; /* DWORD 0 */
136 u8 interrupt85; /* DWORD 0 */
137 u8 interrupt86; /* DWORD 0 */
138 u8 interrupt87; /* DWORD 0 */
139 u8 interrupt88; /* DWORD 0 */
140 u8 interrupt89; /* DWORD 0 */
141 u8 interrupt90; /* DWORD 0 */
142 u8 interrupt91; /* DWORD 0 */
143 u8 interrupt92; /* DWORD 0 */
144 u8 interrupt93; /* DWORD 0 */
145 u8 interrupt94; /* DWORD 0 */
146 u8 interrupt95; /* DWORD 0 */
147} __packed;
148struct CEV_ISR2_CSR_AMAP {
149 u32 dw[1];
150};
151
152/*
153 * Host Interrupt Status Register 3. The fourth of four application
154 * interrupt status registers. This register contains the interrupts
155 * for Event Queues EQ96 through EQ127.
156 */
157struct BE_CEV_ISR3_CSR_AMAP {
158 u8 interrupt96; /* DWORD 0 */
159 u8 interrupt97; /* DWORD 0 */
160 u8 interrupt98; /* DWORD 0 */
161 u8 interrupt99; /* DWORD 0 */
162 u8 interrupt100; /* DWORD 0 */
163 u8 interrupt101; /* DWORD 0 */
164 u8 interrupt102; /* DWORD 0 */
165 u8 interrupt103; /* DWORD 0 */
166 u8 interrupt104; /* DWORD 0 */
167 u8 interrupt105; /* DWORD 0 */
168 u8 interrupt106; /* DWORD 0 */
169 u8 interrupt107; /* DWORD 0 */
170 u8 interrupt108; /* DWORD 0 */
171 u8 interrupt109; /* DWORD 0 */
172 u8 interrupt110; /* DWORD 0 */
173 u8 interrupt111; /* DWORD 0 */
174 u8 interrupt112; /* DWORD 0 */
175 u8 interrupt113; /* DWORD 0 */
176 u8 interrupt114; /* DWORD 0 */
177 u8 interrupt115; /* DWORD 0 */
178 u8 interrupt116; /* DWORD 0 */
179 u8 interrupt117; /* DWORD 0 */
180 u8 interrupt118; /* DWORD 0 */
181 u8 interrupt119; /* DWORD 0 */
182 u8 interrupt120; /* DWORD 0 */
183 u8 interrupt121; /* DWORD 0 */
184 u8 interrupt122; /* DWORD 0 */
185 u8 interrupt123; /* DWORD 0 */
186 u8 interrupt124; /* DWORD 0 */
187 u8 interrupt125; /* DWORD 0 */
188 u8 interrupt126; /* DWORD 0 */
189 u8 interrupt127; /* DWORD 0 */
190} __packed;
191struct CEV_ISR3_CSR_AMAP {
192 u32 dw[1];
193};
194
195/* Completions and Events block Registers. */
196struct BE_CEV_CSRMAP_AMAP {
197 u8 rsvd0[32]; /* DWORD 0 */
198 u8 rsvd1[32]; /* DWORD 1 */
199 u8 rsvd2[32]; /* DWORD 2 */
200 u8 rsvd3[32]; /* DWORD 3 */
201 struct BE_CEV_ISR0_CSR_AMAP isr0;
202 struct BE_CEV_ISR1_CSR_AMAP isr1;
203 struct BE_CEV_ISR2_CSR_AMAP isr2;
204 struct BE_CEV_ISR3_CSR_AMAP isr3;
205 u8 rsvd4[32]; /* DWORD 8 */
206 u8 rsvd5[32]; /* DWORD 9 */
207 u8 rsvd6[32]; /* DWORD 10 */
208 u8 rsvd7[32]; /* DWORD 11 */
209 u8 rsvd8[32]; /* DWORD 12 */
210 u8 rsvd9[32]; /* DWORD 13 */
211 u8 rsvd10[32]; /* DWORD 14 */
212 u8 rsvd11[32]; /* DWORD 15 */
213 u8 rsvd12[32]; /* DWORD 16 */
214 u8 rsvd13[32]; /* DWORD 17 */
215 u8 rsvd14[32]; /* DWORD 18 */
216 u8 rsvd15[32]; /* DWORD 19 */
217 u8 rsvd16[32]; /* DWORD 20 */
218 u8 rsvd17[32]; /* DWORD 21 */
219 u8 rsvd18[32]; /* DWORD 22 */
220 u8 rsvd19[32]; /* DWORD 23 */
221 u8 rsvd20[32]; /* DWORD 24 */
222 u8 rsvd21[32]; /* DWORD 25 */
223 u8 rsvd22[32]; /* DWORD 26 */
224 u8 rsvd23[32]; /* DWORD 27 */
225 u8 rsvd24[32]; /* DWORD 28 */
226 u8 rsvd25[32]; /* DWORD 29 */
227 u8 rsvd26[32]; /* DWORD 30 */
228 u8 rsvd27[32]; /* DWORD 31 */
229 u8 rsvd28[32]; /* DWORD 32 */
230 u8 rsvd29[32]; /* DWORD 33 */
231 u8 rsvd30[192]; /* DWORD 34 */
232 u8 rsvd31[192]; /* DWORD 40 */
233 u8 rsvd32[160]; /* DWORD 46 */
234 u8 rsvd33[160]; /* DWORD 51 */
235 u8 rsvd34[160]; /* DWORD 56 */
236 u8 rsvd35[96]; /* DWORD 61 */
237 u8 rsvd36[192][32]; /* DWORD 64 */
238} __packed;
239struct CEV_CSRMAP_AMAP {
240 u32 dw[256];
241};
242
243#endif /* __cev_amap_h__ */
diff --git a/drivers/staging/benet/cq.c b/drivers/staging/benet/cq.c
deleted file mode 100644
index 650458645433..000000000000
--- a/drivers/staging/benet/cq.c
+++ /dev/null
@@ -1,211 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#include "hwlib.h"
18#include "bestatus.h"
19
20/*
21 * Completion Queue Objects
22 */
23/*
24 *============================================================================
25 * P U B L I C R O U T I N E S
26 *============================================================================
27 */
28
29/*
30 This routine creates a completion queue based on the client completion
31 queue configuration information.
32
33
34 FunctionObject - Handle to a function object
35 CqBaseVa - Base VA for a the CQ ring
36 NumEntries - CEV_CQ_CNT_* values
37 solEventEnable - 0 = All CQEs can generate Events if CQ is eventable
38 1 = only CQEs with solicited bit set are eventable
39 eventable - Eventable CQ, generates interrupts.
40 nodelay - 1 = Force interrupt, relevent if CQ eventable.
41 Interrupt is asserted immediately after EQE
42 write is confirmed, regardless of EQ Timer
43 or watermark settings.
44 wme - Enable watermark based coalescing
45 wmThresh - High watermark(CQ fullness at which event
46 or interrupt should be asserted). These are the
47 CEV_WATERMARK encoded values.
48 EqObject - EQ Handle to assign to this CQ
49 ppCqObject - Internal CQ Handle returned.
50
51 Returns BE_SUCCESS if successfull, otherwise a useful error code is
52 returned.
53
54 IRQL < DISPATCH_LEVEL
55
56*/
57int be_cq_create(struct be_function_object *pfob,
58 struct ring_desc *rd, u32 length, bool solicited_eventable,
59 bool no_delay, u32 wm_thresh,
60 struct be_eq_object *eq_object, struct be_cq_object *cq_object)
61{
62 int status = BE_SUCCESS;
63 u32 num_entries_encoding;
64 u32 num_entries = length / sizeof(struct MCC_CQ_ENTRY_AMAP);
65 struct FWCMD_COMMON_CQ_CREATE *fwcmd = NULL;
66 struct MCC_WRB_AMAP *wrb = NULL;
67 u32 n;
68 unsigned long irql;
69
70 ASSERT(rd);
71 ASSERT(cq_object);
72 ASSERT(length % sizeof(struct MCC_CQ_ENTRY_AMAP) == 0);
73
74 switch (num_entries) {
75 case 256:
76 num_entries_encoding = CEV_CQ_CNT_256;
77 break;
78 case 512:
79 num_entries_encoding = CEV_CQ_CNT_512;
80 break;
81 case 1024:
82 num_entries_encoding = CEV_CQ_CNT_1024;
83 break;
84 default:
85 ASSERT(0);
86 return BE_STATUS_INVALID_PARAMETER;
87 }
88
89 /*
90 * All cq entries all the same size. Use iSCSI version
91 * as a test for the proper rd length.
92 */
93 memset(cq_object, 0, sizeof(*cq_object));
94
95 atomic_set(&cq_object->ref_count, 0);
96 cq_object->parent_function = pfob;
97 cq_object->eq_object = eq_object;
98 cq_object->num_entries = num_entries;
99 /* save for MCC cq processing */
100 cq_object->va = rd->va;
101
102 /* map into UT. */
103 length = num_entries * sizeof(struct MCC_CQ_ENTRY_AMAP);
104
105 spin_lock_irqsave(&pfob->post_lock, irql);
106
107 wrb = be_function_peek_mcc_wrb(pfob);
108 if (!wrb) {
109 ASSERT(wrb);
110 TRACE(DL_ERR, "No free MCC WRBs in create EQ.");
111 status = BE_STATUS_NO_MCC_WRB;
112 goto Error;
113 }
114 /* Prepares an embedded fwcmd, including request/response sizes. */
115 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_CQ_CREATE);
116
117 fwcmd->params.request.num_pages = PAGES_SPANNED(OFFSET_IN_PAGE(rd->va),
118 length);
119
120 AMAP_SET_BITS_PTR(CQ_CONTEXT, valid, &fwcmd->params.request.context, 1);
121 n = pfob->pci_function_number;
122 AMAP_SET_BITS_PTR(CQ_CONTEXT, Func, &fwcmd->params.request.context, n);
123
124 n = (eq_object != NULL);
125 AMAP_SET_BITS_PTR(CQ_CONTEXT, Eventable,
126 &fwcmd->params.request.context, n);
127 AMAP_SET_BITS_PTR(CQ_CONTEXT, Armed, &fwcmd->params.request.context, 1);
128
129 n = eq_object ? eq_object->eq_id : 0;
130 AMAP_SET_BITS_PTR(CQ_CONTEXT, EQID, &fwcmd->params.request.context, n);
131 AMAP_SET_BITS_PTR(CQ_CONTEXT, Count,
132 &fwcmd->params.request.context, num_entries_encoding);
133
134 n = 0; /* Protection Domain is always 0 in Linux driver */
135 AMAP_SET_BITS_PTR(CQ_CONTEXT, PD, &fwcmd->params.request.context, n);
136 AMAP_SET_BITS_PTR(CQ_CONTEXT, NoDelay,
137 &fwcmd->params.request.context, no_delay);
138 AMAP_SET_BITS_PTR(CQ_CONTEXT, SolEvent,
139 &fwcmd->params.request.context, solicited_eventable);
140
141 n = (wm_thresh != 0xFFFFFFFF);
142 AMAP_SET_BITS_PTR(CQ_CONTEXT, WME, &fwcmd->params.request.context, n);
143
144 n = (n ? wm_thresh : 0);
145 AMAP_SET_BITS_PTR(CQ_CONTEXT, Watermark,
146 &fwcmd->params.request.context, n);
147 /* Create a page list for the FWCMD. */
148 be_rd_to_pa_list(rd, fwcmd->params.request.pages,
149 ARRAY_SIZE(fwcmd->params.request.pages));
150
151 /* Post the f/w command */
152 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
153 NULL, NULL, fwcmd, NULL);
154 if (status != BE_SUCCESS) {
155 TRACE(DL_ERR, "MCC to create CQ failed.");
156 goto Error;
157 }
158 /* Remember the CQ id. */
159 cq_object->cq_id = fwcmd->params.response.cq_id;
160
161 /* insert this cq into eq_object reference */
162 if (eq_object) {
163 atomic_inc(&eq_object->ref_count);
164 list_add_tail(&cq_object->cqlist_for_eq,
165 &eq_object->cq_list_head);
166 }
167
168Error:
169 spin_unlock_irqrestore(&pfob->post_lock, irql);
170
171 if (pfob->pend_queue_driving && pfob->mcc) {
172 pfob->pend_queue_driving = 0;
173 be_drive_mcc_wrb_queue(pfob->mcc);
174 }
175 return status;
176}
177
178/*
179
180 Deferences the given object. Once the object's reference count drops to
181 zero, the object is destroyed and all resources that are held by this object
182 are released. The on-chip context is also destroyed along with the queue
183 ID, and any mappings made into the UT.
184
185 cq_object - CQ handle returned from cq_object_create.
186
187 returns the current reference count on the object
188
189 IRQL: IRQL < DISPATCH_LEVEL
190*/
191int be_cq_destroy(struct be_cq_object *cq_object)
192{
193 int status = 0;
194
195 /* Nothing should reference this CQ at this point. */
196 ASSERT(atomic_read(&cq_object->ref_count) == 0);
197
198 /* Send fwcmd to destroy the CQ. */
199 status = be_function_ring_destroy(cq_object->parent_function,
200 cq_object->cq_id, FWCMD_RING_TYPE_CQ,
201 NULL, NULL, NULL, NULL);
202 ASSERT(status == 0);
203
204 /* Remove reference if this is an eventable CQ. */
205 if (cq_object->eq_object) {
206 atomic_dec(&cq_object->eq_object->ref_count);
207 list_del(&cq_object->cqlist_for_eq);
208 }
209 return BE_SUCCESS;
210}
211
diff --git a/drivers/staging/benet/descriptors.h b/drivers/staging/benet/descriptors.h
deleted file mode 100644
index 8da438c407d2..000000000000
--- a/drivers/staging/benet/descriptors.h
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __descriptors_amap_h__
21#define __descriptors_amap_h__
22
23/*
24 * --- IPC_NODE_ID_ENUM ---
25 * IPC processor id values
26 */
27#define TPOST_NODE_ID (0) /* TPOST ID */
28#define TPRE_NODE_ID (1) /* TPRE ID */
29#define TXULP0_NODE_ID (2) /* TXULP0 ID */
30#define TXULP1_NODE_ID (3) /* TXULP1 ID */
31#define TXULP2_NODE_ID (4) /* TXULP2 ID */
32#define RXULP0_NODE_ID (5) /* RXULP0 ID */
33#define RXULP1_NODE_ID (6) /* RXULP1 ID */
34#define RXULP2_NODE_ID (7) /* RXULP2 ID */
35#define MPU_NODE_ID (15) /* MPU ID */
36
37/*
38 * --- MAC_ID_ENUM ---
39 * Meaning of the mac_id field in rxpp_eth_d
40 */
41#define PORT0_HOST_MAC0 (0) /* PD 0, Port 0, host networking, MAC 0. */
42#define PORT0_HOST_MAC1 (1) /* PD 0, Port 0, host networking, MAC 1. */
43#define PORT0_STORAGE_MAC0 (2) /* PD 0, Port 0, host storage, MAC 0. */
44#define PORT0_STORAGE_MAC1 (3) /* PD 0, Port 0, host storage, MAC 1. */
45#define PORT1_HOST_MAC0 (4) /* PD 0, Port 1 host networking, MAC 0. */
46#define PORT1_HOST_MAC1 (5) /* PD 0, Port 1 host networking, MAC 1. */
47#define PORT1_STORAGE_MAC0 (6) /* PD 0, Port 1 host storage, MAC 0. */
48#define PORT1_STORAGE_MAC1 (7) /* PD 0, Port 1 host storage, MAC 1. */
49#define FIRST_VM_MAC (8) /* PD 1 MAC. Protection domains have IDs */
50 /* from 0x8-0x26, one per PD. */
51#define LAST_VM_MAC (38) /* PD 31 MAC. */
52#define MGMT_MAC (39) /* Management port MAC. */
53#define MARBLE_MAC0 (59) /* Used for flushing function 0 receive */
54 /*
55 * queues before re-using a torn-down
56 * receive ring. the DA =
57 * 00-00-00-00-00-00, and the MSB of the
58 * SA = 00
59 */
60#define MARBLE_MAC1 (60) /* Used for flushing function 1 receive */
61 /*
62 * queues before re-using a torn-down
63 * receive ring. the DA =
64 * 00-00-00-00-00-00, and the MSB of the
65 * SA != 00
66 */
67#define NULL_MAC (61) /* Promiscuous mode, indicates no match */
68#define MCAST_MAC (62) /* Multicast match. */
69#define BCAST_MATCH (63) /* Broadcast match. */
70
71#endif /* __descriptors_amap_h__ */
diff --git a/drivers/staging/benet/doorbells.h b/drivers/staging/benet/doorbells.h
deleted file mode 100644
index 550cc4d5d6f7..000000000000
--- a/drivers/staging/benet/doorbells.h
+++ /dev/null
@@ -1,179 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __doorbells_amap_h__
21#define __doorbells_amap_h__
22
23/* The TX/RDMA send queue doorbell. */
24struct BE_SQ_DB_AMAP {
25 u8 cid[11]; /* DWORD 0 */
26 u8 rsvd0[5]; /* DWORD 0 */
27 u8 numPosted[14]; /* DWORD 0 */
28 u8 rsvd1[2]; /* DWORD 0 */
29} __packed;
30struct SQ_DB_AMAP {
31 u32 dw[1];
32};
33
34/* The receive queue doorbell. */
35struct BE_RQ_DB_AMAP {
36 u8 rq[10]; /* DWORD 0 */
37 u8 rsvd0[13]; /* DWORD 0 */
38 u8 Invalidate; /* DWORD 0 */
39 u8 numPosted[8]; /* DWORD 0 */
40} __packed;
41struct RQ_DB_AMAP {
42 u32 dw[1];
43};
44
45/*
46 * The CQ/EQ doorbell. Software MUST set reserved fields in this
47 * descriptor to zero, otherwise (CEV) hardware will not execute the
48 * doorbell (flagging a bad_db_qid error instead).
49 */
50struct BE_CQ_DB_AMAP {
51 u8 qid[10]; /* DWORD 0 */
52 u8 rsvd0[4]; /* DWORD 0 */
53 u8 rearm; /* DWORD 0 */
54 u8 event; /* DWORD 0 */
55 u8 num_popped[13]; /* DWORD 0 */
56 u8 rsvd1[3]; /* DWORD 0 */
57} __packed;
58struct CQ_DB_AMAP {
59 u32 dw[1];
60};
61
62struct BE_TPM_RQ_DB_AMAP {
63 u8 qid[10]; /* DWORD 0 */
64 u8 rsvd0[6]; /* DWORD 0 */
65 u8 numPosted[11]; /* DWORD 0 */
66 u8 mss_cnt[5]; /* DWORD 0 */
67} __packed;
68struct TPM_RQ_DB_AMAP {
69 u32 dw[1];
70};
71
72/*
73 * Post WRB Queue Doorbell Register used by the host Storage stack
74 * to notify the controller of a posted Work Request Block
75 */
76struct BE_WRB_POST_DB_AMAP {
77 u8 wrb_cid[10]; /* DWORD 0 */
78 u8 rsvd0[6]; /* DWORD 0 */
79 u8 wrb_index[8]; /* DWORD 0 */
80 u8 numberPosted[8]; /* DWORD 0 */
81} __packed;
82struct WRB_POST_DB_AMAP {
83 u32 dw[1];
84};
85
86/*
87 * Update Default PDU Queue Doorbell Register used to communicate
88 * to the controller that the driver has stopped processing the queue
89 * and where in the queue it stopped, this is
90 * a CQ Entry Type. Used by storage driver.
91 */
92struct BE_DEFAULT_PDU_DB_AMAP {
93 u8 qid[10]; /* DWORD 0 */
94 u8 rsvd0[4]; /* DWORD 0 */
95 u8 rearm; /* DWORD 0 */
96 u8 event; /* DWORD 0 */
97 u8 cqproc[14]; /* DWORD 0 */
98 u8 rsvd1[2]; /* DWORD 0 */
99} __packed;
100struct DEFAULT_PDU_DB_AMAP {
101 u32 dw[1];
102};
103
104/* Management Command and Controller default fragment ring */
105struct BE_MCC_DB_AMAP {
106 u8 rid[11]; /* DWORD 0 */
107 u8 rsvd0[5]; /* DWORD 0 */
108 u8 numPosted[14]; /* DWORD 0 */
109 u8 rsvd1[2]; /* DWORD 0 */
110} __packed;
111struct MCC_DB_AMAP {
112 u32 dw[1];
113};
114
115/*
116 * Used for bootstrapping the Host interface. This register is
117 * used for driver communication with the MPU when no MCC Rings exist.
118 * The software must write this register twice to post any MCC
119 * command. First, it writes the register with hi=1 and the upper bits of
120 * the physical address for the MCC_MAILBOX structure. Software must poll
121 * the ready bit until this is acknowledged. Then, sotware writes the
122 * register with hi=0 with the lower bits in the address. It must
123 * poll the ready bit until the MCC command is complete. Upon completion,
124 * the MCC_MAILBOX will contain a valid completion queue entry.
125 */
126struct BE_MPU_MAILBOX_DB_AMAP {
127 u8 ready; /* DWORD 0 */
128 u8 hi; /* DWORD 0 */
129 u8 address[30]; /* DWORD 0 */
130} __packed;
131struct MPU_MAILBOX_DB_AMAP {
132 u32 dw[1];
133};
134
135/*
136 * This is the protection domain doorbell register map. Note that
137 * while this map shows doorbells for all Blade Engine supported
138 * protocols, not all of these may be valid in a given function or
139 * protection domain. It is the responsibility of the application
140 * accessing the doorbells to know which are valid. Each doorbell
141 * occupies 32 bytes of space, but unless otherwise specified,
142 * only the first 4 bytes should be written. There are 32 instances
143 * of these doorbells for the host and 31 virtual machines respectively.
144 * The host and VMs will only map the doorbell pages belonging to its
145 * protection domain. It will not be able to touch the doorbells for
146 * another VM. The doorbells are the only registers directly accessible
147 * by a virtual machine. Similarly, there are 511 additional
148 * doorbells for RDMA protection domains. PD 0 for RDMA shares
149 * the same physical protection domain doorbell page as ETH/iSCSI.
150 *
151 */
152struct BE_PROTECTION_DOMAIN_DBMAP_AMAP {
153 u8 rsvd0[512]; /* DWORD 0 */
154 struct BE_SQ_DB_AMAP rdma_sq_db;
155 u8 rsvd1[7][32]; /* DWORD 17 */
156 struct BE_WRB_POST_DB_AMAP iscsi_wrb_post_db;
157 u8 rsvd2[7][32]; /* DWORD 25 */
158 struct BE_SQ_DB_AMAP etx_sq_db;
159 u8 rsvd3[7][32]; /* DWORD 33 */
160 struct BE_RQ_DB_AMAP rdma_rq_db;
161 u8 rsvd4[7][32]; /* DWORD 41 */
162 struct BE_DEFAULT_PDU_DB_AMAP iscsi_default_pdu_db;
163 u8 rsvd5[7][32]; /* DWORD 49 */
164 struct BE_TPM_RQ_DB_AMAP tpm_rq_db;
165 u8 rsvd6[7][32]; /* DWORD 57 */
166 struct BE_RQ_DB_AMAP erx_rq_db;
167 u8 rsvd7[7][32]; /* DWORD 65 */
168 struct BE_CQ_DB_AMAP cq_db;
169 u8 rsvd8[7][32]; /* DWORD 73 */
170 struct BE_MCC_DB_AMAP mpu_mcc_db;
171 u8 rsvd9[7][32]; /* DWORD 81 */
172 struct BE_MPU_MAILBOX_DB_AMAP mcc_bootstrap_db;
173 u8 rsvd10[935][32]; /* DWORD 89 */
174} __packed;
175struct PROTECTION_DOMAIN_DBMAP_AMAP {
176 u32 dw[1024];
177};
178
179#endif /* __doorbells_amap_h__ */
diff --git a/drivers/staging/benet/ep.h b/drivers/staging/benet/ep.h
deleted file mode 100644
index 72fcf64a9ffb..000000000000
--- a/drivers/staging/benet/ep.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __ep_amap_h__
21#define __ep_amap_h__
22
23/* General Control and Status Register. */
24struct BE_EP_CONTROL_CSR_AMAP {
25 u8 m0_RxPbuf; /* DWORD 0 */
26 u8 m1_RxPbuf; /* DWORD 0 */
27 u8 m2_RxPbuf; /* DWORD 0 */
28 u8 ff_en; /* DWORD 0 */
29 u8 rsvd0[27]; /* DWORD 0 */
30 u8 CPU_reset; /* DWORD 0 */
31} __packed;
32struct EP_CONTROL_CSR_AMAP {
33 u32 dw[1];
34};
35
36/* Semaphore Register. */
37struct BE_EP_SEMAPHORE_CSR_AMAP {
38 u8 value[32]; /* DWORD 0 */
39} __packed;
40struct EP_SEMAPHORE_CSR_AMAP {
41 u32 dw[1];
42};
43
44/* Embedded Processor Specific Registers. */
45struct BE_EP_CSRMAP_AMAP {
46 struct BE_EP_CONTROL_CSR_AMAP ep_control;
47 u8 rsvd0[32]; /* DWORD 1 */
48 u8 rsvd1[32]; /* DWORD 2 */
49 u8 rsvd2[32]; /* DWORD 3 */
50 u8 rsvd3[32]; /* DWORD 4 */
51 u8 rsvd4[32]; /* DWORD 5 */
52 u8 rsvd5[8][128]; /* DWORD 6 */
53 u8 rsvd6[32]; /* DWORD 38 */
54 u8 rsvd7[32]; /* DWORD 39 */
55 u8 rsvd8[32]; /* DWORD 40 */
56 u8 rsvd9[32]; /* DWORD 41 */
57 u8 rsvd10[32]; /* DWORD 42 */
58 struct BE_EP_SEMAPHORE_CSR_AMAP ep_semaphore;
59 u8 rsvd11[32]; /* DWORD 44 */
60 u8 rsvd12[19][32]; /* DWORD 45 */
61} __packed;
62struct EP_CSRMAP_AMAP {
63 u32 dw[64];
64};
65
66#endif /* __ep_amap_h__ */
diff --git a/drivers/staging/benet/eq.c b/drivers/staging/benet/eq.c
deleted file mode 100644
index db92ccd8fed8..000000000000
--- a/drivers/staging/benet/eq.c
+++ /dev/null
@@ -1,299 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#include "hwlib.h"
18#include "bestatus.h"
19/*
20 This routine creates an event queue based on the client completion
21 queue configuration information.
22
23 FunctionObject - Handle to a function object
24 EqBaseVa - Base VA for a the EQ ring
25 SizeEncoding - The encoded size for the EQ entries. This value is
26 either CEV_EQ_SIZE_4 or CEV_EQ_SIZE_16
27 NumEntries - CEV_CQ_CNT_* values.
28 Watermark - Enables watermark based coalescing. This parameter
29 must be of the type CEV_WMARK_* if watermarks
30 are enabled. If watermarks to to be disabled
31 this value should be-1.
32 TimerDelay - If a timer delay is enabled this value should be the
33 time of the delay in 8 microsecond units. If
34 delays are not used this parameter should be
35 set to -1.
36 ppEqObject - Internal EQ Handle returned.
37
38 Returns BE_SUCCESS if successfull,, otherwise a useful error code
39 is returned.
40
41 IRQL < DISPATCH_LEVEL
42*/
43int
44be_eq_create(struct be_function_object *pfob,
45 struct ring_desc *rd, u32 eqe_size, u32 num_entries,
46 u32 watermark, /* CEV_WMARK_* or -1 */
47 u32 timer_delay, /* in 8us units, or -1 */
48 struct be_eq_object *eq_object)
49{
50 int status = BE_SUCCESS;
51 u32 num_entries_encoding, eqe_size_encoding, length;
52 struct FWCMD_COMMON_EQ_CREATE *fwcmd = NULL;
53 struct MCC_WRB_AMAP *wrb = NULL;
54 u32 n;
55 unsigned long irql;
56
57 ASSERT(rd);
58 ASSERT(eq_object);
59
60 switch (num_entries) {
61 case 256:
62 num_entries_encoding = CEV_EQ_CNT_256;
63 break;
64 case 512:
65 num_entries_encoding = CEV_EQ_CNT_512;
66 break;
67 case 1024:
68 num_entries_encoding = CEV_EQ_CNT_1024;
69 break;
70 case 2048:
71 num_entries_encoding = CEV_EQ_CNT_2048;
72 break;
73 case 4096:
74 num_entries_encoding = CEV_EQ_CNT_4096;
75 break;
76 default:
77 ASSERT(0);
78 return BE_STATUS_INVALID_PARAMETER;
79 }
80
81 switch (eqe_size) {
82 case 4:
83 eqe_size_encoding = CEV_EQ_SIZE_4;
84 break;
85 case 16:
86 eqe_size_encoding = CEV_EQ_SIZE_16;
87 break;
88 default:
89 ASSERT(0);
90 return BE_STATUS_INVALID_PARAMETER;
91 }
92
93 if ((eqe_size == 4 && num_entries < 1024) ||
94 (eqe_size == 16 && num_entries == 4096)) {
95 TRACE(DL_ERR, "Bad EQ size. eqe_size:%d num_entries:%d",
96 eqe_size, num_entries);
97 ASSERT(0);
98 return BE_STATUS_INVALID_PARAMETER;
99 }
100
101 memset(eq_object, 0, sizeof(*eq_object));
102
103 atomic_set(&eq_object->ref_count, 0);
104 eq_object->parent_function = pfob;
105 eq_object->eq_id = 0xFFFFFFFF;
106
107 INIT_LIST_HEAD(&eq_object->cq_list_head);
108
109 length = num_entries * eqe_size;
110
111 spin_lock_irqsave(&pfob->post_lock, irql);
112
113 wrb = be_function_peek_mcc_wrb(pfob);
114 if (!wrb) {
115 ASSERT(wrb);
116 TRACE(DL_ERR, "No free MCC WRBs in create EQ.");
117 status = BE_STATUS_NO_MCC_WRB;
118 goto Error;
119 }
120 /* Prepares an embedded fwcmd, including request/response sizes. */
121 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_EQ_CREATE);
122
123 fwcmd->params.request.num_pages = PAGES_SPANNED(OFFSET_IN_PAGE(rd->va),
124 length);
125 n = pfob->pci_function_number;
126 AMAP_SET_BITS_PTR(EQ_CONTEXT, Func, &fwcmd->params.request.context, n);
127
128 AMAP_SET_BITS_PTR(EQ_CONTEXT, valid, &fwcmd->params.request.context, 1);
129
130 AMAP_SET_BITS_PTR(EQ_CONTEXT, Size,
131 &fwcmd->params.request.context, eqe_size_encoding);
132
133 n = 0; /* Protection Domain is always 0 in Linux driver */
134 AMAP_SET_BITS_PTR(EQ_CONTEXT, PD, &fwcmd->params.request.context, n);
135
136 /* Let the caller ARM the EQ with the doorbell. */
137 AMAP_SET_BITS_PTR(EQ_CONTEXT, Armed, &fwcmd->params.request.context, 0);
138
139 AMAP_SET_BITS_PTR(EQ_CONTEXT, Count, &fwcmd->params.request.context,
140 num_entries_encoding);
141
142 n = pfob->pci_function_number * 32;
143 AMAP_SET_BITS_PTR(EQ_CONTEXT, EventVect,
144 &fwcmd->params.request.context, n);
145 if (watermark != -1) {
146 AMAP_SET_BITS_PTR(EQ_CONTEXT, WME,
147 &fwcmd->params.request.context, 1);
148 AMAP_SET_BITS_PTR(EQ_CONTEXT, Watermark,
149 &fwcmd->params.request.context, watermark);
150 ASSERT(watermark <= CEV_WMARK_240);
151 } else
152 AMAP_SET_BITS_PTR(EQ_CONTEXT, WME,
153 &fwcmd->params.request.context, 0);
154 if (timer_delay != -1) {
155 AMAP_SET_BITS_PTR(EQ_CONTEXT, TMR,
156 &fwcmd->params.request.context, 1);
157
158 ASSERT(timer_delay <= 250); /* max value according to EAS */
159 timer_delay = min(timer_delay, (u32)250);
160
161 AMAP_SET_BITS_PTR(EQ_CONTEXT, Delay,
162 &fwcmd->params.request.context, timer_delay);
163 } else {
164 AMAP_SET_BITS_PTR(EQ_CONTEXT, TMR,
165 &fwcmd->params.request.context, 0);
166 }
167 /* Create a page list for the FWCMD. */
168 be_rd_to_pa_list(rd, fwcmd->params.request.pages,
169 ARRAY_SIZE(fwcmd->params.request.pages));
170
171 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
172 NULL, NULL, fwcmd, NULL);
173 if (status != BE_SUCCESS) {
174 TRACE(DL_ERR, "MCC to create EQ failed.");
175 goto Error;
176 }
177 /* Get the EQ id. The MPU allocates the IDs. */
178 eq_object->eq_id = fwcmd->params.response.eq_id;
179
180Error:
181 spin_unlock_irqrestore(&pfob->post_lock, irql);
182
183 if (pfob->pend_queue_driving && pfob->mcc) {
184 pfob->pend_queue_driving = 0;
185 be_drive_mcc_wrb_queue(pfob->mcc);
186 }
187 return status;
188}
189
190/*
191 Deferences the given object. Once the object's reference count drops to
192 zero, the object is destroyed and all resources that are held by this
193 object are released. The on-chip context is also destroyed along with
194 the queue ID, and any mappings made into the UT.
195
196 eq_object - EQ handle returned from eq_object_create.
197
198 Returns BE_SUCCESS if successfull, otherwise a useful error code
199 is returned.
200
201 IRQL: IRQL < DISPATCH_LEVEL
202*/
203int be_eq_destroy(struct be_eq_object *eq_object)
204{
205 int status = 0;
206
207 ASSERT(atomic_read(&eq_object->ref_count) == 0);
208 /* no CQs should reference this EQ now */
209 ASSERT(list_empty(&eq_object->cq_list_head));
210
211 /* Send fwcmd to destroy the EQ. */
212 status = be_function_ring_destroy(eq_object->parent_function,
213 eq_object->eq_id, FWCMD_RING_TYPE_EQ,
214 NULL, NULL, NULL, NULL);
215 ASSERT(status == 0);
216
217 return BE_SUCCESS;
218}
219/*
220 *---------------------------------------------------------------------------
221 * Function: be_eq_modify_delay
222 * Changes the EQ delay for a group of EQs.
223 * num_eq - The number of EQs in the eq_array to adjust.
224 * This also is the number of delay values in
225 * the eq_delay_array.
226 * eq_array - Array of struct be_eq_object pointers to adjust.
227 * eq_delay_array - Array of "num_eq" timer delays in units
228 * of microseconds. The be_eq_query_delay_range
229 * fwcmd returns the resolution and range of
230 * legal EQ delays.
231 * cb -
232 * cb_context -
233 * q_ctxt - Optional. Pointer to a previously allocated
234 * struct. If the MCC WRB ring is full, this
235 * structure is used to queue the operation. It
236 * will be posted to the MCC ring when space
237 * becomes available. All queued commands will
238 * be posted to the ring in the order they are
239 * received. It is always valid to pass a pointer to
240 * a generic be_generic_q_cntxt. However,
241 * the specific context structs
242 * are generally smaller than the generic struct.
243 * return pend_status - BE_SUCCESS (0) on success.
244 * BE_PENDING (postive value) if the FWCMD
245 * completion is pending. Negative error code on failure.
246 *-------------------------------------------------------------------------
247 */
248int
249be_eq_modify_delay(struct be_function_object *pfob,
250 u32 num_eq, struct be_eq_object **eq_array,
251 u32 *eq_delay_array, mcc_wrb_cqe_callback cb,
252 void *cb_context, struct be_eq_modify_delay_q_ctxt *q_ctxt)
253{
254 struct FWCMD_COMMON_MODIFY_EQ_DELAY *fwcmd = NULL;
255 struct MCC_WRB_AMAP *wrb = NULL;
256 int status = 0;
257 struct be_generic_q_ctxt *gen_ctxt = NULL;
258 u32 i;
259 unsigned long irql;
260
261 spin_lock_irqsave(&pfob->post_lock, irql);
262
263 wrb = be_function_peek_mcc_wrb(pfob);
264 if (!wrb) {
265 if (q_ctxt && cb) {
266 wrb = (struct MCC_WRB_AMAP *) &q_ctxt->wrb_header;
267 gen_ctxt = (struct be_generic_q_ctxt *) q_ctxt;
268 gen_ctxt->context.bytes = sizeof(*q_ctxt);
269 } else {
270 status = BE_STATUS_NO_MCC_WRB;
271 goto Error;
272 }
273 }
274 /* Prepares an embedded fwcmd, including request/response sizes. */
275 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_MODIFY_EQ_DELAY);
276
277 ASSERT(num_eq > 0);
278 ASSERT(num_eq <= ARRAY_SIZE(fwcmd->params.request.delay));
279 fwcmd->params.request.num_eq = num_eq;
280 for (i = 0; i < num_eq; i++) {
281 fwcmd->params.request.delay[i].eq_id = eq_array[i]->eq_id;
282 fwcmd->params.request.delay[i].delay_in_microseconds =
283 eq_delay_array[i];
284 }
285
286 /* Post the f/w command */
287 status = be_function_post_mcc_wrb(pfob, wrb, gen_ctxt,
288 cb, cb_context, NULL, NULL, fwcmd, NULL);
289
290Error:
291 spin_unlock_irqrestore(&pfob->post_lock, irql);
292
293 if (pfob->pend_queue_driving && pfob->mcc) {
294 pfob->pend_queue_driving = 0;
295 be_drive_mcc_wrb_queue(pfob->mcc);
296 }
297 return status;
298}
299
diff --git a/drivers/staging/benet/eth.c b/drivers/staging/benet/eth.c
deleted file mode 100644
index f641b6260d07..000000000000
--- a/drivers/staging/benet/eth.c
+++ /dev/null
@@ -1,1273 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#include <linux/if_ether.h>
18#include "hwlib.h"
19#include "bestatus.h"
20
21/*
22 *---------------------------------------------------------
23 * Function: be_eth_sq_create_ex
24 * Creates an ethernet send ring - extended version with
25 * additional parameters.
26 * pfob -
27 * rd - ring address
28 * length_in_bytes -
29 * type - The type of ring to create.
30 * ulp - The requested ULP number for the ring.
31 * This should be zero based, i.e. 0,1,2. This must
32 * be valid NIC ULP based on the firmware config.
33 * All doorbells for this ring must be sent to
34 * this ULP. The first network ring allocated for
35 * each ULP are higher performance than subsequent rings.
36 * cq_object - cq object for completions
37 * ex_parameters - Additional parameters (that may increase in
38 * future revisions). These parameters are only used
39 * for certain ring types -- see
40 * struct be_eth_sq_parameters for details.
41 * eth_sq -
42 * return status - BE_SUCCESS (0) on success. Negative error code on failure.
43 *---------------------------------------------------------
44 */
45int
46be_eth_sq_create_ex(struct be_function_object *pfob, struct ring_desc *rd,
47 u32 length, u32 type, u32 ulp, struct be_cq_object *cq_object,
48 struct be_eth_sq_parameters *ex_parameters,
49 struct be_ethsq_object *eth_sq)
50{
51 struct FWCMD_COMMON_ETH_TX_CREATE *fwcmd = NULL;
52 struct MCC_WRB_AMAP *wrb = NULL;
53 int status = 0;
54 u32 n;
55 unsigned long irql;
56
57 ASSERT(rd);
58 ASSERT(eth_sq);
59 ASSERT(ex_parameters);
60
61 spin_lock_irqsave(&pfob->post_lock, irql);
62
63 memset(eth_sq, 0, sizeof(*eth_sq));
64
65 eth_sq->parent_function = pfob;
66 eth_sq->bid = 0xFFFFFFFF;
67 eth_sq->cq_object = cq_object;
68
69 /* Translate hwlib interface to arm interface. */
70 switch (type) {
71 case BE_ETH_TX_RING_TYPE_FORWARDING:
72 type = ETH_TX_RING_TYPE_FORWARDING;
73 break;
74 case BE_ETH_TX_RING_TYPE_STANDARD:
75 type = ETH_TX_RING_TYPE_STANDARD;
76 break;
77 case BE_ETH_TX_RING_TYPE_BOUND:
78 ASSERT(ex_parameters->port < 2);
79 type = ETH_TX_RING_TYPE_BOUND;
80 break;
81 default:
82 TRACE(DL_ERR, "Invalid eth tx ring type:%d", type);
83 return BE_NOT_OK;
84 break;
85 }
86
87 wrb = be_function_peek_mcc_wrb(pfob);
88 if (!wrb) {
89 ASSERT(wrb);
90 TRACE(DL_ERR, "No free MCC WRBs in create EQ.");
91 status = BE_STATUS_NO_MCC_WRB;
92 goto Error;
93 }
94 /* NIC must be supported by the current config. */
95 ASSERT(pfob->fw_config.nic_ulp_mask);
96
97 /*
98 * The ulp parameter must select a valid NIC ULP
99 * for the current config.
100 */
101 ASSERT((1 << ulp) & pfob->fw_config.nic_ulp_mask);
102
103 /* Prepares an embedded fwcmd, including request/response sizes. */
104 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_ETH_TX_CREATE);
105 fwcmd->header.request.port_number = ex_parameters->port;
106
107 AMAP_SET_BITS_PTR(ETX_CONTEXT, pd_id,
108 &fwcmd->params.request.context, 0);
109
110 n = be_ring_length_to_encoding(length, sizeof(struct ETH_WRB_AMAP));
111 AMAP_SET_BITS_PTR(ETX_CONTEXT, tx_ring_size,
112 &fwcmd->params.request.context, n);
113
114 AMAP_SET_BITS_PTR(ETX_CONTEXT, cq_id_send,
115 &fwcmd->params.request.context, cq_object->cq_id);
116
117 n = pfob->pci_function_number;
118 AMAP_SET_BITS_PTR(ETX_CONTEXT, func, &fwcmd->params.request.context, n);
119
120 fwcmd->params.request.type = type;
121 fwcmd->params.request.ulp_num = (1 << ulp);
122 fwcmd->params.request.num_pages = DIV_ROUND_UP(length, PAGE_SIZE);
123 ASSERT(PAGES_SPANNED(rd->va, rd->length) >=
124 fwcmd->params.request.num_pages);
125
126 /* Create a page list for the FWCMD. */
127 be_rd_to_pa_list(rd, fwcmd->params.request.pages,
128 ARRAY_SIZE(fwcmd->params.request.pages));
129
130 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
131 NULL, NULL, fwcmd, NULL);
132 if (status != BE_SUCCESS) {
133 TRACE(DL_ERR, "MCC to create etx queue failed.");
134 goto Error;
135 }
136 /* save the butler ID */
137 eth_sq->bid = fwcmd->params.response.cid;
138
139 /* add a reference to the corresponding CQ */
140 atomic_inc(&cq_object->ref_count);
141
142Error:
143 spin_unlock_irqrestore(&pfob->post_lock, irql);
144
145 if (pfob->pend_queue_driving && pfob->mcc) {
146 pfob->pend_queue_driving = 0;
147 be_drive_mcc_wrb_queue(pfob->mcc);
148 }
149 return status;
150}
151
152
153/*
154 This routine destroys an ethernet send queue
155
156 EthSq - EthSq Handle returned from EthSqCreate
157
158 This function always return BE_SUCCESS.
159
160 This function frees memory allocated by EthSqCreate for the EthSq Object.
161
162*/
163int be_eth_sq_destroy(struct be_ethsq_object *eth_sq)
164{
165 int status = 0;
166
167 /* Send fwcmd to destroy the queue. */
168 status = be_function_ring_destroy(eth_sq->parent_function, eth_sq->bid,
169 FWCMD_RING_TYPE_ETH_TX, NULL, NULL, NULL, NULL);
170 ASSERT(status == 0);
171
172 /* Derefence any associated CQs. */
173 atomic_dec(&eth_sq->cq_object->ref_count);
174 return status;
175}
176/*
177 This routine attempts to set the transmit flow control parameters.
178
179 FunctionObject - Handle to a function object
180
181 txfc_enable - transmit flow control enable - true for
182 enable, false for disable
183
184 rxfc_enable - receive flow control enable - true for
185 enable, false for disable
186
187 Returns BE_SUCCESS if successfull, otherwise a useful int error
188 code is returned.
189
190 IRQL: < DISPATCH_LEVEL
191
192 This function always fails in non-privileged machine context.
193*/
194int
195be_eth_set_flow_control(struct be_function_object *pfob,
196 bool txfc_enable, bool rxfc_enable)
197{
198 struct FWCMD_COMMON_SET_FLOW_CONTROL *fwcmd = NULL;
199 struct MCC_WRB_AMAP *wrb = NULL;
200 int status = 0;
201 unsigned long irql;
202
203 spin_lock_irqsave(&pfob->post_lock, irql);
204
205 wrb = be_function_peek_mcc_wrb(pfob);
206 if (!wrb) {
207 TRACE(DL_ERR, "MCC wrb peek failed.");
208 status = BE_STATUS_NO_MCC_WRB;
209 goto error;
210 }
211 /* Prepares an embedded fwcmd, including request/response sizes. */
212 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_SET_FLOW_CONTROL);
213
214 fwcmd->params.request.rx_flow_control = rxfc_enable;
215 fwcmd->params.request.tx_flow_control = txfc_enable;
216
217 /* Post the f/w command */
218 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
219 NULL, NULL, fwcmd, NULL);
220
221 if (status != 0) {
222 TRACE(DL_ERR, "set flow control fwcmd failed.");
223 goto error;
224 }
225
226error:
227 spin_unlock_irqrestore(&pfob->post_lock, irql);
228
229 if (pfob->pend_queue_driving && pfob->mcc) {
230 pfob->pend_queue_driving = 0;
231 be_drive_mcc_wrb_queue(pfob->mcc);
232 }
233 return status;
234}
235
236/*
237 This routine attempts to get the transmit flow control parameters.
238
239 pfob - Handle to a function object
240
241 txfc_enable - transmit flow control enable - true for
242 enable, false for disable
243
244 rxfc_enable - receive flow control enable - true for enable,
245 false for disable
246
247 Returns BE_SUCCESS if successfull, otherwise a useful int error code
248 is returned.
249
250 IRQL: < DISPATCH_LEVEL
251
252 This function always fails in non-privileged machine context.
253*/
254int
255be_eth_get_flow_control(struct be_function_object *pfob,
256 bool *txfc_enable, bool *rxfc_enable)
257{
258 struct FWCMD_COMMON_GET_FLOW_CONTROL *fwcmd = NULL;
259 struct MCC_WRB_AMAP *wrb = NULL;
260 int status = 0;
261 unsigned long irql;
262
263 spin_lock_irqsave(&pfob->post_lock, irql);
264
265 wrb = be_function_peek_mcc_wrb(pfob);
266 if (!wrb) {
267 TRACE(DL_ERR, "MCC wrb peek failed.");
268 status = BE_STATUS_NO_MCC_WRB;
269 goto error;
270 }
271 /* Prepares an embedded fwcmd, including request/response sizes. */
272 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_GET_FLOW_CONTROL);
273
274 /* Post the f/w command */
275 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
276 NULL, NULL, fwcmd, NULL);
277
278 if (status != 0) {
279 TRACE(DL_ERR, "get flow control fwcmd failed.");
280 goto error;
281 }
282
283 *txfc_enable = fwcmd->params.response.tx_flow_control;
284 *rxfc_enable = fwcmd->params.response.rx_flow_control;
285
286error:
287 spin_unlock_irqrestore(&pfob->post_lock, irql);
288
289 if (pfob->pend_queue_driving && pfob->mcc) {
290 pfob->pend_queue_driving = 0;
291 be_drive_mcc_wrb_queue(pfob->mcc);
292 }
293 return status;
294}
295
296/*
297 *---------------------------------------------------------
298 * Function: be_eth_set_qos
299 * This function sets the ethernet transmit Quality of Service (QoS)
300 * characteristics of BladeEngine for the domain. All ethernet
301 * transmit rings of the domain will evenly share the bandwidth.
302 * The exeception to sharing is the host primary (super) ethernet
303 * transmit ring as well as the host ethernet forwarding ring
304 * for missed offload data.
305 * pfob -
306 * max_bps - the maximum bits per second in units of
307 * 10 Mbps (valid 0-100)
308 * max_pps - the maximum packets per second in units
309 * of 1 Kpps (0 indicates no limit)
310 * return status - BE_SUCCESS (0) on success. Negative error code on failure.
311 *---------------------------------------------------------
312 */
313int
314be_eth_set_qos(struct be_function_object *pfob, u32 max_bps, u32 max_pps)
315{
316 struct FWCMD_COMMON_SET_QOS *fwcmd = NULL;
317 struct MCC_WRB_AMAP *wrb = NULL;
318 int status = 0;
319 unsigned long irql;
320
321 spin_lock_irqsave(&pfob->post_lock, irql);
322
323 wrb = be_function_peek_mcc_wrb(pfob);
324 if (!wrb) {
325 TRACE(DL_ERR, "MCC wrb peek failed.");
326 status = BE_STATUS_NO_MCC_WRB;
327 goto error;
328 }
329 /* Prepares an embedded fwcmd, including request/response sizes. */
330 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_SET_QOS);
331
332 /* Set fields in fwcmd */
333 fwcmd->params.request.max_bits_per_second_NIC = max_bps;
334 fwcmd->params.request.max_packets_per_second_NIC = max_pps;
335 fwcmd->params.request.valid_flags = QOS_BITS_NIC | QOS_PKTS_NIC;
336
337 /* Post the f/w command */
338 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
339 NULL, NULL, fwcmd, NULL);
340
341 if (status != 0)
342 TRACE(DL_ERR, "network set qos fwcmd failed.");
343
344error:
345 spin_unlock_irqrestore(&pfob->post_lock, irql);
346 if (pfob->pend_queue_driving && pfob->mcc) {
347 pfob->pend_queue_driving = 0;
348 be_drive_mcc_wrb_queue(pfob->mcc);
349 }
350 return status;
351}
352
353/*
354 *---------------------------------------------------------
355 * Function: be_eth_get_qos
356 * This function retrieves the ethernet transmit Quality of Service (QoS)
357 * characteristics for the domain.
358 * max_bps - the maximum bits per second in units of
359 * 10 Mbps (valid 0-100)
360 * max_pps - the maximum packets per second in units of
361 * 1 Kpps (0 indicates no limit)
362 * return status - BE_SUCCESS (0) on success. Negative error code on failure.
363 *---------------------------------------------------------
364 */
365int
366be_eth_get_qos(struct be_function_object *pfob, u32 *max_bps, u32 *max_pps)
367{
368 struct FWCMD_COMMON_GET_QOS *fwcmd = NULL;
369 struct MCC_WRB_AMAP *wrb = NULL;
370 int status = 0;
371 unsigned long irql;
372
373 spin_lock_irqsave(&pfob->post_lock, irql);
374
375 wrb = be_function_peek_mcc_wrb(pfob);
376 if (!wrb) {
377 TRACE(DL_ERR, "MCC wrb peek failed.");
378 status = BE_STATUS_NO_MCC_WRB;
379 goto error;
380 }
381 /* Prepares an embedded fwcmd, including request/response sizes. */
382 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_GET_QOS);
383
384 /* Post the f/w command */
385 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
386 NULL, NULL, fwcmd, NULL);
387
388 if (status != 0) {
389 TRACE(DL_ERR, "network get qos fwcmd failed.");
390 goto error;
391 }
392
393 *max_bps = fwcmd->params.response.max_bits_per_second_NIC;
394 *max_pps = fwcmd->params.response.max_packets_per_second_NIC;
395
396error:
397 spin_unlock_irqrestore(&pfob->post_lock, irql);
398 if (pfob->pend_queue_driving && pfob->mcc) {
399 pfob->pend_queue_driving = 0;
400 be_drive_mcc_wrb_queue(pfob->mcc);
401 }
402 return status;
403}
404
405/*
406 *---------------------------------------------------------
407 * Function: be_eth_set_frame_size
408 * This function sets the ethernet maximum frame size. The previous
409 * values are returned.
410 * pfob -
411 * tx_frame_size - maximum transmit frame size in bytes
412 * rx_frame_size - maximum receive frame size in bytes
413 * return status - BE_SUCCESS (0) on success. Negative error code on failure.
414 *---------------------------------------------------------
415 */
416int
417be_eth_set_frame_size(struct be_function_object *pfob,
418 u32 *tx_frame_size, u32 *rx_frame_size)
419{
420 struct FWCMD_COMMON_SET_FRAME_SIZE *fwcmd = NULL;
421 struct MCC_WRB_AMAP *wrb = NULL;
422 int status = 0;
423 unsigned long irql;
424
425 spin_lock_irqsave(&pfob->post_lock, irql);
426
427 wrb = be_function_peek_mcc_wrb(pfob);
428 if (!wrb) {
429 TRACE(DL_ERR, "MCC wrb peek failed.");
430 status = BE_STATUS_NO_MCC_WRB;
431 goto error;
432 }
433 /* Prepares an embedded fwcmd, including request/response sizes. */
434 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_SET_FRAME_SIZE);
435 fwcmd->params.request.max_tx_frame_size = *tx_frame_size;
436 fwcmd->params.request.max_rx_frame_size = *rx_frame_size;
437
438 /* Post the f/w command */
439 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
440 NULL, NULL, fwcmd, NULL);
441
442 if (status != 0) {
443 TRACE(DL_ERR, "network set frame size fwcmd failed.");
444 goto error;
445 }
446
447 *tx_frame_size = fwcmd->params.response.chip_max_tx_frame_size;
448 *rx_frame_size = fwcmd->params.response.chip_max_rx_frame_size;
449
450error:
451 spin_unlock_irqrestore(&pfob->post_lock, irql);
452 if (pfob->pend_queue_driving && pfob->mcc) {
453 pfob->pend_queue_driving = 0;
454 be_drive_mcc_wrb_queue(pfob->mcc);
455 }
456 return status;
457}
458
459
460/*
461 This routine creates a Ethernet receive ring.
462
463 pfob - handle to a function object
464 rq_base_va - base VA for the default receive ring. this must be
465 exactly 8K in length and continguous physical memory.
466 cq_object - handle to a previously created CQ to be associated
467 with the RQ.
468 pp_eth_rq - pointer to an opqaue handle where an eth
469 receive object is returned.
470 Returns BE_SUCCESS if successfull, , otherwise a useful
471 int error code is returned.
472
473 IRQL: < DISPATCH_LEVEL
474 this function allocates a struct be_ethrq_object *object.
475 there must be no more than 1 of these per function object, unless the
476 function object supports RSS (is networking and on the host).
477 the rq_base_va must point to a buffer of exactly 8K.
478 the erx::host_cqid (or host_stor_cqid) register and erx::ring_page registers
479 will be updated as appropriate on return
480*/
481int
482be_eth_rq_create(struct be_function_object *pfob,
483 struct ring_desc *rd, struct be_cq_object *cq_object,
484 struct be_cq_object *bcmc_cq_object,
485 struct be_ethrq_object *eth_rq)
486{
487 int status = 0;
488 struct MCC_WRB_AMAP *wrb = NULL;
489 struct FWCMD_COMMON_ETH_RX_CREATE *fwcmd = NULL;
490 unsigned long irql;
491
492 /* MPU will set the */
493 ASSERT(rd);
494 ASSERT(eth_rq);
495
496 spin_lock_irqsave(&pfob->post_lock, irql);
497
498 eth_rq->parent_function = pfob;
499 eth_rq->cq_object = cq_object;
500
501 wrb = be_function_peek_mcc_wrb(pfob);
502 if (!wrb) {
503 TRACE(DL_ERR, "MCC wrb peek failed.");
504 status = BE_STATUS_NO_MCC_WRB;
505 goto Error;
506 }
507 /* Prepares an embedded fwcmd, including request/response sizes. */
508 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_ETH_RX_CREATE);
509
510 fwcmd->params.request.num_pages = 2; /* required length */
511 fwcmd->params.request.cq_id = cq_object->cq_id;
512
513 if (bcmc_cq_object)
514 fwcmd->params.request.bcmc_cq_id = bcmc_cq_object->cq_id;
515 else
516 fwcmd->params.request.bcmc_cq_id = 0xFFFF;
517
518 /* Create a page list for the FWCMD. */
519 be_rd_to_pa_list(rd, fwcmd->params.request.pages,
520 ARRAY_SIZE(fwcmd->params.request.pages));
521
522 /* Post the f/w command */
523 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
524 NULL, NULL, fwcmd, NULL);
525 if (status != BE_SUCCESS) {
526 TRACE(DL_ERR, "fwcmd to map eth rxq frags failed.");
527 goto Error;
528 }
529 /* Save the ring ID for cleanup. */
530 eth_rq->rid = fwcmd->params.response.id;
531
532 atomic_inc(&cq_object->ref_count);
533
534Error:
535 spin_unlock_irqrestore(&pfob->post_lock, irql);
536
537 if (pfob->pend_queue_driving && pfob->mcc) {
538 pfob->pend_queue_driving = 0;
539 be_drive_mcc_wrb_queue(pfob->mcc);
540 }
541 return status;
542}
543
544/*
545 This routine destroys an Ethernet receive queue
546
547 eth_rq - ethernet receive queue handle returned from eth_rq_create
548
549 Returns BE_SUCCESS on success and an appropriate int on failure.
550
551 This function frees resourcs allocated by EthRqCreate.
552 The erx::host_cqid (or host_stor_cqid) register and erx::ring_page
553 registers will be updated as appropriate on return
554 IRQL: < DISPATCH_LEVEL
555*/
556
557static void be_eth_rq_destroy_internal_cb(void *context, int status,
558 struct MCC_WRB_AMAP *wrb)
559{
560 struct be_ethrq_object *eth_rq = (struct be_ethrq_object *) context;
561
562 if (status != BE_SUCCESS) {
563 TRACE(DL_ERR, "Destroy eth rq failed in internal callback.\n");
564 } else {
565 /* Dereference any CQs associated with this queue. */
566 atomic_dec(&eth_rq->cq_object->ref_count);
567 }
568
569 return;
570}
571
572int be_eth_rq_destroy(struct be_ethrq_object *eth_rq)
573{
574 int status = BE_SUCCESS;
575
576 /* Send fwcmd to destroy the RQ. */
577 status = be_function_ring_destroy(eth_rq->parent_function,
578 eth_rq->rid, FWCMD_RING_TYPE_ETH_RX, NULL, NULL,
579 be_eth_rq_destroy_internal_cb, eth_rq);
580
581 return status;
582}
583
584/*
585 *---------------------------------------------------------------------------
586 * Function: be_eth_rq_destroy_options
587 * Destroys an ethernet receive ring with finer granularity options
588 * than the standard be_eth_rq_destroy() API function.
589 * eth_rq -
590 * flush - Set to 1 to flush the ring, set to 0 to bypass the flush
591 * cb - Callback function on completion
592 * cb_context - Callback context
593 * return status - BE_SUCCESS (0) on success. Negative error code on failure.
594 *----------------------------------------------------------------------------
595 */
596int
597be_eth_rq_destroy_options(struct be_ethrq_object *eth_rq, bool flush,
598 mcc_wrb_cqe_callback cb, void *cb_context)
599{
600 struct FWCMD_COMMON_RING_DESTROY *fwcmd = NULL;
601 struct MCC_WRB_AMAP *wrb = NULL;
602 int status = BE_SUCCESS;
603 struct be_function_object *pfob = NULL;
604 unsigned long irql;
605
606 pfob = eth_rq->parent_function;
607
608 spin_lock_irqsave(&pfob->post_lock, irql);
609
610 TRACE(DL_INFO, "Destroy eth_rq ring id:%d, flush:%d", eth_rq->rid,
611 flush);
612
613 wrb = be_function_peek_mcc_wrb(pfob);
614 if (!wrb) {
615 ASSERT(wrb);
616 TRACE(DL_ERR, "No free MCC WRBs in destroy eth_rq ring.");
617 status = BE_STATUS_NO_MCC_WRB;
618 goto Error;
619 }
620 /* Prepares an embedded fwcmd, including request/response sizes. */
621 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_RING_DESTROY);
622
623 fwcmd->params.request.id = eth_rq->rid;
624 fwcmd->params.request.ring_type = FWCMD_RING_TYPE_ETH_RX;
625 fwcmd->params.request.bypass_flush = ((0 == flush) ? 1 : 0);
626
627 /* Post the f/w command */
628 status = be_function_post_mcc_wrb(pfob, wrb, NULL, cb, cb_context,
629 be_eth_rq_destroy_internal_cb, eth_rq, fwcmd, NULL);
630
631 if (status != BE_SUCCESS && status != BE_PENDING) {
632 TRACE(DL_ERR, "eth_rq ring destroy failed. id:%d, flush:%d",
633 eth_rq->rid, flush);
634 goto Error;
635 }
636
637Error:
638 spin_unlock_irqrestore(&pfob->post_lock, irql);
639
640 if (pfob->pend_queue_driving && pfob->mcc) {
641 pfob->pend_queue_driving = 0;
642 be_drive_mcc_wrb_queue(pfob->mcc);
643 }
644 return status;
645}
646
647/*
648 This routine queries the frag size for erx.
649
650 pfob - handle to a function object
651
652 frag_size_bytes - erx frag size in bytes that is/was set.
653
654 Returns BE_SUCCESS if successfull, otherwise a useful int error
655 code is returned.
656
657 IRQL: < DISPATCH_LEVEL
658
659*/
660int
661be_eth_rq_get_frag_size(struct be_function_object *pfob, u32 *frag_size_bytes)
662{
663 struct FWCMD_ETH_GET_RX_FRAG_SIZE *fwcmd = NULL;
664 struct MCC_WRB_AMAP *wrb = NULL;
665 int status = 0;
666 unsigned long irql;
667
668 ASSERT(frag_size_bytes);
669
670 spin_lock_irqsave(&pfob->post_lock, irql);
671
672 wrb = be_function_peek_mcc_wrb(pfob);
673 if (!wrb) {
674 TRACE(DL_ERR, "MCC wrb peek failed.");
675 return BE_STATUS_NO_MCC_WRB;
676 }
677 /* Prepares an embedded fwcmd, including request/response sizes. */
678 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, ETH_GET_RX_FRAG_SIZE);
679
680 /* Post the f/w command */
681 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
682 NULL, NULL, fwcmd, NULL);
683
684 if (status != 0) {
685 TRACE(DL_ERR, "get frag size fwcmd failed.");
686 goto error;
687 }
688
689 *frag_size_bytes = 1 << fwcmd->params.response.actual_fragsize_log2;
690
691error:
692 spin_unlock_irqrestore(&pfob->post_lock, irql);
693
694 if (pfob->pend_queue_driving && pfob->mcc) {
695 pfob->pend_queue_driving = 0;
696 be_drive_mcc_wrb_queue(pfob->mcc);
697 }
698 return status;
699}
700
701/*
702 This routine attempts to set the frag size for erx. If the frag size is
703 already set, the attempt fails and the current frag size is returned.
704
705 pfob - Handle to a function object
706
707 frag_size - Erx frag size in bytes that is/was set.
708
709 current_frag_size_bytes - Pointer to location where currrent frag
710 is to be rturned
711
712 Returns BE_SUCCESS if successfull, otherwise a useful int error
713 code is returned.
714
715 IRQL: < DISPATCH_LEVEL
716
717 This function always fails in non-privileged machine context.
718*/
719int
720be_eth_rq_set_frag_size(struct be_function_object *pfob,
721 u32 frag_size, u32 *frag_size_bytes)
722{
723 struct FWCMD_ETH_SET_RX_FRAG_SIZE *fwcmd = NULL;
724 struct MCC_WRB_AMAP *wrb = NULL;
725 int status = 0;
726 unsigned long irql;
727
728 ASSERT(frag_size_bytes);
729
730 spin_lock_irqsave(&pfob->post_lock, irql);
731
732 wrb = be_function_peek_mcc_wrb(pfob);
733 if (!wrb) {
734 TRACE(DL_ERR, "MCC wrb peek failed.");
735 status = BE_STATUS_NO_MCC_WRB;
736 goto error;
737 }
738 /* Prepares an embedded fwcmd, including request/response sizes. */
739 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, ETH_SET_RX_FRAG_SIZE);
740
741 ASSERT(frag_size >= 128 && frag_size <= 16 * 1024);
742
743 /* This is the log2 of the fragsize. This is not the exact
744 * ERX encoding. */
745 fwcmd->params.request.new_fragsize_log2 = __ilog2_u32(frag_size);
746
747 /* Post the f/w command */
748 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
749 NULL, NULL, fwcmd, NULL);
750
751 if (status != 0) {
752 TRACE(DL_ERR, "set frag size fwcmd failed.");
753 goto error;
754 }
755
756 *frag_size_bytes = 1 << fwcmd->params.response.actual_fragsize_log2;
757error:
758 spin_unlock_irqrestore(&pfob->post_lock, irql);
759
760 if (pfob->pend_queue_driving && pfob->mcc) {
761 pfob->pend_queue_driving = 0;
762 be_drive_mcc_wrb_queue(pfob->mcc);
763 }
764 return status;
765}
766
767
768/*
769 This routine gets or sets a mac address for a domain
770 given the port and mac.
771
772 FunctionObject - Function object handle.
773 port1 - Set to TRUE if this function will set/get the Port 1
774 address. Only the host may set this to TRUE.
775 mac1 - Set to TRUE if this function will set/get the
776 MAC 1 address. Only the host may set this to TRUE.
777 write - Set to TRUE if this function should write the mac address.
778 mac_address - Buffer of the mac address to read or write.
779
780 Returns BE_SUCCESS if successfull, otherwise a useful int is returned.
781
782 IRQL: < DISPATCH_LEVEL
783*/
784int be_rxf_mac_address_read_write(struct be_function_object *pfob,
785 bool port1, /* VM must always set to false */
786 bool mac1, /* VM must always set to false */
787 bool mgmt, bool write,
788 bool permanent, u8 *mac_address,
789 mcc_wrb_cqe_callback cb, /* optional */
790 void *cb_context) /* optional */
791{
792 int status = BE_SUCCESS;
793 union {
794 struct FWCMD_COMMON_NTWK_MAC_QUERY *query;
795 struct FWCMD_COMMON_NTWK_MAC_SET *set;
796 } fwcmd = {NULL};
797 struct MCC_WRB_AMAP *wrb = NULL;
798 u32 type = 0;
799 unsigned long irql;
800 struct be_mcc_wrb_response_copy rc;
801
802 spin_lock_irqsave(&pfob->post_lock, irql);
803
804 ASSERT(mac_address);
805
806 ASSERT(port1 == false);
807 ASSERT(mac1 == false);
808
809 wrb = be_function_peek_mcc_wrb(pfob);
810 if (!wrb) {
811 TRACE(DL_ERR, "MCC wrb peek failed.");
812 status = BE_STATUS_NO_MCC_WRB;
813 goto Error;
814 }
815
816 if (mgmt) {
817 type = MAC_ADDRESS_TYPE_MANAGEMENT;
818 } else {
819 if (pfob->type == BE_FUNCTION_TYPE_NETWORK)
820 type = MAC_ADDRESS_TYPE_NETWORK;
821 else
822 type = MAC_ADDRESS_TYPE_STORAGE;
823 }
824
825 if (write) {
826 /* Prepares an embedded fwcmd, including
827 * request/response sizes.
828 */
829 fwcmd.set = BE_PREPARE_EMBEDDED_FWCMD(pfob,
830 wrb, COMMON_NTWK_MAC_SET);
831
832 fwcmd.set->params.request.invalidate = 0;
833 fwcmd.set->params.request.mac1 = (mac1 ? 1 : 0);
834 fwcmd.set->params.request.port = (port1 ? 1 : 0);
835 fwcmd.set->params.request.type = type;
836
837 /* Copy the mac address to set. */
838 fwcmd.set->params.request.mac.SizeOfStructure =
839 sizeof(fwcmd.set->params.request.mac);
840 memcpy(fwcmd.set->params.request.mac.MACAddress,
841 mac_address, ETH_ALEN);
842
843 /* Post the f/w command */
844 status = be_function_post_mcc_wrb(pfob, wrb, NULL,
845 cb, cb_context, NULL, NULL, fwcmd.set, NULL);
846
847 } else {
848
849 /*
850 * Prepares an embedded fwcmd, including
851 * request/response sizes.
852 */
853 fwcmd.query = BE_PREPARE_EMBEDDED_FWCMD(pfob,
854 wrb, COMMON_NTWK_MAC_QUERY);
855
856 fwcmd.query->params.request.mac1 = (mac1 ? 1 : 0);
857 fwcmd.query->params.request.port = (port1 ? 1 : 0);
858 fwcmd.query->params.request.type = type;
859 fwcmd.query->params.request.permanent = permanent;
860
861 rc.length = FIELD_SIZEOF(struct FWCMD_COMMON_NTWK_MAC_QUERY,
862 params.response.mac.MACAddress);
863 rc.fwcmd_offset = offsetof(struct FWCMD_COMMON_NTWK_MAC_QUERY,
864 params.response.mac.MACAddress);
865 rc.va = mac_address;
866 /* Post the f/w command (with a copy for the response) */
867 status = be_function_post_mcc_wrb(pfob, wrb, NULL, cb,
868 cb_context, NULL, NULL, fwcmd.query, &rc);
869 }
870
871 if (status < 0) {
872 TRACE(DL_ERR, "mac set/query failed.");
873 goto Error;
874 }
875
876Error:
877 spin_unlock_irqrestore(&pfob->post_lock, irql);
878 if (pfob->pend_queue_driving && pfob->mcc) {
879 pfob->pend_queue_driving = 0;
880 be_drive_mcc_wrb_queue(pfob->mcc);
881 }
882 return status;
883}
884
885/*
886 This routine writes data to context memory.
887
888 pfob - Function object handle.
889 mac_table - Set to the 128-bit multicast address hash table.
890
891 Returns BE_SUCCESS if successfull, otherwise a useful int is returned.
892
893 IRQL: < DISPATCH_LEVEL
894*/
895
896int be_rxf_multicast_config(struct be_function_object *pfob,
897 bool promiscuous, u32 num, u8 *mac_table,
898 mcc_wrb_cqe_callback cb, /* optional */
899 void *cb_context,
900 struct be_multicast_q_ctxt *q_ctxt)
901{
902 int status = BE_SUCCESS;
903 struct FWCMD_COMMON_NTWK_MULTICAST_SET *fwcmd = NULL;
904 struct MCC_WRB_AMAP *wrb = NULL;
905 struct be_generic_q_ctxt *generic_ctxt = NULL;
906 unsigned long irql;
907
908 ASSERT(num <= ARRAY_SIZE(fwcmd->params.request.mac));
909
910 if (num > ARRAY_SIZE(fwcmd->params.request.mac)) {
911 TRACE(DL_ERR, "Too many multicast addresses. BE supports %d.",
912 (int) ARRAY_SIZE(fwcmd->params.request.mac));
913 return BE_NOT_OK;
914 }
915
916 spin_lock_irqsave(&pfob->post_lock, irql);
917
918 wrb = be_function_peek_mcc_wrb(pfob);
919 if (!wrb) {
920 if (q_ctxt && cb) {
921 wrb = (struct MCC_WRB_AMAP *) &q_ctxt->wrb_header;
922 generic_ctxt = (struct be_generic_q_ctxt *) q_ctxt;
923 generic_ctxt->context.bytes = sizeof(*q_ctxt);
924 } else {
925 status = BE_STATUS_NO_MCC_WRB;
926 goto Error;
927 }
928 }
929 /* Prepares an embedded fwcmd, including request/response sizes. */
930 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_NTWK_MULTICAST_SET);
931
932 fwcmd->params.request.promiscuous = promiscuous;
933 if (!promiscuous) {
934 fwcmd->params.request.num_mac = num;
935 if (num > 0) {
936 ASSERT(mac_table);
937 memcpy(fwcmd->params.request.mac,
938 mac_table, ETH_ALEN * num);
939 }
940 }
941
942 /* Post the f/w command */
943 status = be_function_post_mcc_wrb(pfob, wrb, generic_ctxt,
944 cb, cb_context, NULL, NULL, fwcmd, NULL);
945 if (status < 0) {
946 TRACE(DL_ERR, "multicast fwcmd failed.");
947 goto Error;
948 }
949
950Error:
951 spin_unlock_irqrestore(&pfob->post_lock, irql);
952 if (pfob->pend_queue_driving && pfob->mcc) {
953 pfob->pend_queue_driving = 0;
954 be_drive_mcc_wrb_queue(pfob->mcc);
955 }
956 return status;
957}
958
959/*
960 This routine adds or removes a vlan tag from the rxf table.
961
962 FunctionObject - Function object handle.
963 VLanTag - VLan tag to add or remove.
964 Add - Set to TRUE if this will add a vlan tag
965
966 Returns BE_SUCCESS if successfull, otherwise a useful int is returned.
967
968 IRQL: < DISPATCH_LEVEL
969*/
970int be_rxf_vlan_config(struct be_function_object *pfob,
971 bool promiscuous, u32 num, u16 *vlan_tag_array,
972 mcc_wrb_cqe_callback cb, /* optional */
973 void *cb_context,
974 struct be_vlan_q_ctxt *q_ctxt) /* optional */
975{
976 int status = BE_SUCCESS;
977 struct FWCMD_COMMON_NTWK_VLAN_CONFIG *fwcmd = NULL;
978 struct MCC_WRB_AMAP *wrb = NULL;
979 struct be_generic_q_ctxt *generic_ctxt = NULL;
980 unsigned long irql;
981
982 if (num > ARRAY_SIZE(fwcmd->params.request.vlan_tag)) {
983 TRACE(DL_ERR, "Too many VLAN tags.");
984 return BE_NOT_OK;
985 }
986
987 spin_lock_irqsave(&pfob->post_lock, irql);
988
989 wrb = be_function_peek_mcc_wrb(pfob);
990 if (!wrb) {
991 if (q_ctxt && cb) {
992 wrb = (struct MCC_WRB_AMAP *) &q_ctxt->wrb_header;
993 generic_ctxt = (struct be_generic_q_ctxt *) q_ctxt;
994 generic_ctxt->context.bytes = sizeof(*q_ctxt);
995 } else {
996 status = BE_STATUS_NO_MCC_WRB;
997 goto Error;
998 }
999 }
1000 /* Prepares an embedded fwcmd, including request/response sizes. */
1001 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_NTWK_VLAN_CONFIG);
1002
1003 fwcmd->params.request.promiscuous = promiscuous;
1004 if (!promiscuous) {
1005 fwcmd->params.request.num_vlan = num;
1006
1007 if (num > 0) {
1008 ASSERT(vlan_tag_array);
1009 memcpy(fwcmd->params.request.vlan_tag, vlan_tag_array,
1010 num * sizeof(vlan_tag_array[0]));
1011 }
1012 }
1013
1014 /* Post the commadn */
1015 status = be_function_post_mcc_wrb(pfob, wrb, generic_ctxt,
1016 cb, cb_context, NULL, NULL, fwcmd, NULL);
1017 if (status < 0) {
1018 TRACE(DL_ERR, "vlan fwcmd failed.");
1019 goto Error;
1020 }
1021
1022Error:
1023 spin_unlock_irqrestore(&pfob->post_lock, irql);
1024 if (pfob->pend_queue_driving && pfob->mcc) {
1025 pfob->pend_queue_driving = 0;
1026 be_drive_mcc_wrb_queue(pfob->mcc);
1027 }
1028 return status;
1029}
1030
1031
1032int be_rxf_link_status(struct be_function_object *pfob,
1033 struct BE_LINK_STATUS *link_status,
1034 mcc_wrb_cqe_callback cb,
1035 void *cb_context,
1036 struct be_link_status_q_ctxt *q_ctxt)
1037{
1038 struct FWCMD_COMMON_NTWK_LINK_STATUS_QUERY *fwcmd = NULL;
1039 struct MCC_WRB_AMAP *wrb = NULL;
1040 int status = 0;
1041 struct be_generic_q_ctxt *generic_ctxt = NULL;
1042 unsigned long irql;
1043 struct be_mcc_wrb_response_copy rc;
1044
1045 ASSERT(link_status);
1046
1047 spin_lock_irqsave(&pfob->post_lock, irql);
1048
1049 wrb = be_function_peek_mcc_wrb(pfob);
1050
1051 if (!wrb) {
1052 if (q_ctxt && cb) {
1053 wrb = (struct MCC_WRB_AMAP *) &q_ctxt->wrb_header;
1054 generic_ctxt = (struct be_generic_q_ctxt *) q_ctxt;
1055 generic_ctxt->context.bytes = sizeof(*q_ctxt);
1056 } else {
1057 status = BE_STATUS_NO_MCC_WRB;
1058 goto Error;
1059 }
1060 }
1061 /* Prepares an embedded fwcmd, including request/response sizes. */
1062 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb,
1063 COMMON_NTWK_LINK_STATUS_QUERY);
1064
1065 rc.length = FIELD_SIZEOF(struct FWCMD_COMMON_NTWK_LINK_STATUS_QUERY,
1066 params.response);
1067 rc.fwcmd_offset = offsetof(struct FWCMD_COMMON_NTWK_LINK_STATUS_QUERY,
1068 params.response);
1069 rc.va = link_status;
1070 /* Post or queue the f/w command */
1071 status = be_function_post_mcc_wrb(pfob, wrb, generic_ctxt,
1072 cb, cb_context, NULL, NULL, fwcmd, &rc);
1073
1074 if (status < 0) {
1075 TRACE(DL_ERR, "link status fwcmd failed.");
1076 goto Error;
1077 }
1078
1079Error:
1080 spin_unlock_irqrestore(&pfob->post_lock, irql);
1081 if (pfob->pend_queue_driving && pfob->mcc) {
1082 pfob->pend_queue_driving = 0;
1083 be_drive_mcc_wrb_queue(pfob->mcc);
1084 }
1085 return status;
1086}
1087
1088int
1089be_rxf_query_eth_statistics(struct be_function_object *pfob,
1090 struct FWCMD_ETH_GET_STATISTICS *va_for_fwcmd,
1091 u64 pa_for_fwcmd, mcc_wrb_cqe_callback cb,
1092 void *cb_context,
1093 struct be_nonembedded_q_ctxt *q_ctxt)
1094{
1095 struct MCC_WRB_AMAP *wrb = NULL;
1096 int status = 0;
1097 struct be_generic_q_ctxt *generic_ctxt = NULL;
1098 unsigned long irql;
1099
1100 ASSERT(va_for_fwcmd);
1101 ASSERT(pa_for_fwcmd);
1102
1103 spin_lock_irqsave(&pfob->post_lock, irql);
1104
1105 wrb = be_function_peek_mcc_wrb(pfob);
1106
1107 if (!wrb) {
1108 if (q_ctxt && cb) {
1109 wrb = (struct MCC_WRB_AMAP *) &q_ctxt->wrb_header;
1110 generic_ctxt = (struct be_generic_q_ctxt *) q_ctxt;
1111 generic_ctxt->context.bytes = sizeof(*q_ctxt);
1112 } else {
1113 status = BE_STATUS_NO_MCC_WRB;
1114 goto Error;
1115 }
1116 }
1117
1118 TRACE(DL_INFO, "Query eth stats. fwcmd va:%p pa:0x%08x_%08x",
1119 va_for_fwcmd, upper_32_bits(pa_for_fwcmd), (u32)pa_for_fwcmd);
1120
1121 /* Prepares an embedded fwcmd, including request/response sizes. */
1122 va_for_fwcmd = BE_PREPARE_NONEMBEDDED_FWCMD(pfob, wrb,
1123 va_for_fwcmd, pa_for_fwcmd, ETH_GET_STATISTICS);
1124
1125 /* Post the f/w command */
1126 status = be_function_post_mcc_wrb(pfob, wrb, generic_ctxt,
1127 cb, cb_context, NULL, NULL, va_for_fwcmd, NULL);
1128 if (status < 0) {
1129 TRACE(DL_ERR, "eth stats fwcmd failed.");
1130 goto Error;
1131 }
1132
1133Error:
1134 spin_unlock_irqrestore(&pfob->post_lock, irql);
1135 if (pfob->pend_queue_driving && pfob->mcc) {
1136 pfob->pend_queue_driving = 0;
1137 be_drive_mcc_wrb_queue(pfob->mcc);
1138 }
1139 return status;
1140}
1141
1142int
1143be_rxf_promiscuous(struct be_function_object *pfob,
1144 bool enable_port0, bool enable_port1,
1145 mcc_wrb_cqe_callback cb, void *cb_context,
1146 struct be_promiscuous_q_ctxt *q_ctxt)
1147{
1148 struct FWCMD_ETH_PROMISCUOUS *fwcmd = NULL;
1149 struct MCC_WRB_AMAP *wrb = NULL;
1150 int status = 0;
1151 struct be_generic_q_ctxt *generic_ctxt = NULL;
1152 unsigned long irql;
1153
1154
1155 spin_lock_irqsave(&pfob->post_lock, irql);
1156
1157 wrb = be_function_peek_mcc_wrb(pfob);
1158
1159 if (!wrb) {
1160 if (q_ctxt && cb) {
1161 wrb = (struct MCC_WRB_AMAP *) &q_ctxt->wrb_header;
1162 generic_ctxt = (struct be_generic_q_ctxt *) q_ctxt;
1163 generic_ctxt->context.bytes = sizeof(*q_ctxt);
1164 } else {
1165 status = BE_STATUS_NO_MCC_WRB;
1166 goto Error;
1167 }
1168 }
1169 /* Prepares an embedded fwcmd, including request/response sizes. */
1170 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, ETH_PROMISCUOUS);
1171
1172 fwcmd->params.request.port0_promiscuous = enable_port0;
1173 fwcmd->params.request.port1_promiscuous = enable_port1;
1174
1175 /* Post the f/w command */
1176 status = be_function_post_mcc_wrb(pfob, wrb, generic_ctxt,
1177 cb, cb_context, NULL, NULL, fwcmd, NULL);
1178
1179 if (status < 0) {
1180 TRACE(DL_ERR, "promiscuous fwcmd failed.");
1181 goto Error;
1182 }
1183
1184Error:
1185 spin_unlock_irqrestore(&pfob->post_lock, irql);
1186 if (pfob->pend_queue_driving && pfob->mcc) {
1187 pfob->pend_queue_driving = 0;
1188 be_drive_mcc_wrb_queue(pfob->mcc);
1189 }
1190 return status;
1191}
1192
1193
1194/*
1195 *-------------------------------------------------------------------------
1196 * Function: be_rxf_filter_config
1197 * Configures BladeEngine ethernet receive filter settings.
1198 * pfob -
1199 * settings - Pointer to the requested filter settings.
1200 * The response from BladeEngine will be placed back
1201 * in this structure.
1202 * cb - optional
1203 * cb_context - optional
1204 * q_ctxt - Optional. Pointer to a previously allocated struct.
1205 * If the MCC WRB ring is full, this structure is
1206 * used to queue the operation. It will be posted
1207 * to the MCC ring when space becomes available. All
1208 * queued commands will be posted to the ring in
1209 * the order they are received. It is always valid
1210 * to pass a pointer to a generic
1211 * be_generic_q_ctxt. However, the specific
1212 * context structs are generally smaller than
1213 * the generic struct.
1214 * return pend_status - BE_SUCCESS (0) on success.
1215 * BE_PENDING (postive value) if the FWCMD
1216 * completion is pending. Negative error code on failure.
1217 *---------------------------------------------------------------------------
1218 */
1219int
1220be_rxf_filter_config(struct be_function_object *pfob,
1221 struct NTWK_RX_FILTER_SETTINGS *settings,
1222 mcc_wrb_cqe_callback cb, void *cb_context,
1223 struct be_rxf_filter_q_ctxt *q_ctxt)
1224{
1225 struct FWCMD_COMMON_NTWK_RX_FILTER *fwcmd = NULL;
1226 struct MCC_WRB_AMAP *wrb = NULL;
1227 int status = 0;
1228 struct be_generic_q_ctxt *generic_ctxt = NULL;
1229 unsigned long irql;
1230 struct be_mcc_wrb_response_copy rc;
1231
1232 ASSERT(settings);
1233
1234 spin_lock_irqsave(&pfob->post_lock, irql);
1235
1236 wrb = be_function_peek_mcc_wrb(pfob);
1237
1238 if (!wrb) {
1239 if (q_ctxt && cb) {
1240 wrb = (struct MCC_WRB_AMAP *) &q_ctxt->wrb_header;
1241 generic_ctxt = (struct be_generic_q_ctxt *) q_ctxt;
1242 generic_ctxt->context.bytes = sizeof(*q_ctxt);
1243 } else {
1244 status = BE_STATUS_NO_MCC_WRB;
1245 goto Error;
1246 }
1247 }
1248 /* Prepares an embedded fwcmd, including request/response sizes. */
1249 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_NTWK_RX_FILTER);
1250 memcpy(&fwcmd->params.request, settings, sizeof(*settings));
1251
1252 rc.length = FIELD_SIZEOF(struct FWCMD_COMMON_NTWK_RX_FILTER,
1253 params.response);
1254 rc.fwcmd_offset = offsetof(struct FWCMD_COMMON_NTWK_RX_FILTER,
1255 params.response);
1256 rc.va = settings;
1257 /* Post or queue the f/w command */
1258 status = be_function_post_mcc_wrb(pfob, wrb, generic_ctxt,
1259 cb, cb_context, NULL, NULL, fwcmd, &rc);
1260
1261 if (status < 0) {
1262 TRACE(DL_ERR, "RXF/ERX filter config fwcmd failed.");
1263 goto Error;
1264 }
1265
1266Error:
1267 spin_unlock_irqrestore(&pfob->post_lock, irql);
1268 if (pfob->pend_queue_driving && pfob->mcc) {
1269 pfob->pend_queue_driving = 0;
1270 be_drive_mcc_wrb_queue(pfob->mcc);
1271 }
1272 return status;
1273}
diff --git a/drivers/staging/benet/etx_context.h b/drivers/staging/benet/etx_context.h
deleted file mode 100644
index 554fbe5d127b..000000000000
--- a/drivers/staging/benet/etx_context.h
+++ /dev/null
@@ -1,55 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __etx_context_amap_h__
21#define __etx_context_amap_h__
22
23/* ETX ring context structure. */
24struct BE_ETX_CONTEXT_AMAP {
25 u8 tx_cidx[11]; /* DWORD 0 */
26 u8 rsvd0[5]; /* DWORD 0 */
27 u8 rsvd1[16]; /* DWORD 0 */
28 u8 tx_pidx[11]; /* DWORD 1 */
29 u8 rsvd2; /* DWORD 1 */
30 u8 tx_ring_size[4]; /* DWORD 1 */
31 u8 pd_id[5]; /* DWORD 1 */
32 u8 pd_id_not_valid; /* DWORD 1 */
33 u8 cq_id_send[10]; /* DWORD 1 */
34 u8 rsvd3[32]; /* DWORD 2 */
35 u8 rsvd4[32]; /* DWORD 3 */
36 u8 cur_bytes[32]; /* DWORD 4 */
37 u8 max_bytes[32]; /* DWORD 5 */
38 u8 time_stamp[32]; /* DWORD 6 */
39 u8 rsvd5[11]; /* DWORD 7 */
40 u8 func; /* DWORD 7 */
41 u8 rsvd6[20]; /* DWORD 7 */
42 u8 cur_txd_count[32]; /* DWORD 8 */
43 u8 max_txd_count[32]; /* DWORD 9 */
44 u8 rsvd7[32]; /* DWORD 10 */
45 u8 rsvd8[32]; /* DWORD 11 */
46 u8 rsvd9[32]; /* DWORD 12 */
47 u8 rsvd10[32]; /* DWORD 13 */
48 u8 rsvd11[32]; /* DWORD 14 */
49 u8 rsvd12[32]; /* DWORD 15 */
50} __packed;
51struct ETX_CONTEXT_AMAP {
52 u32 dw[16];
53};
54
55#endif /* __etx_context_amap_h__ */
diff --git a/drivers/staging/benet/funcobj.c b/drivers/staging/benet/funcobj.c
deleted file mode 100644
index 0f57eb58daef..000000000000
--- a/drivers/staging/benet/funcobj.c
+++ /dev/null
@@ -1,565 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#include "hwlib.h"
18#include "bestatus.h"
19
20
21int
22be_function_internal_query_firmware_config(struct be_function_object *pfob,
23 struct BE_FIRMWARE_CONFIG *config)
24{
25 struct FWCMD_COMMON_FIRMWARE_CONFIG *fwcmd = NULL;
26 struct MCC_WRB_AMAP *wrb = NULL;
27 int status = 0;
28 unsigned long irql;
29 struct be_mcc_wrb_response_copy rc;
30
31 spin_lock_irqsave(&pfob->post_lock, irql);
32
33 wrb = be_function_peek_mcc_wrb(pfob);
34 if (!wrb) {
35 TRACE(DL_ERR, "MCC wrb peek failed.");
36 status = BE_STATUS_NO_MCC_WRB;
37 goto error;
38 }
39 /* Prepares an embedded fwcmd, including request/response sizes. */
40 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_FIRMWARE_CONFIG);
41
42 rc.length = FIELD_SIZEOF(struct FWCMD_COMMON_FIRMWARE_CONFIG,
43 params.response);
44 rc.fwcmd_offset = offsetof(struct FWCMD_COMMON_FIRMWARE_CONFIG,
45 params.response);
46 rc.va = config;
47
48 /* Post the f/w command */
49 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL,
50 NULL, NULL, NULL, fwcmd, &rc);
51error:
52 spin_unlock_irqrestore(&pfob->post_lock, irql);
53 if (pfob->pend_queue_driving && pfob->mcc) {
54 pfob->pend_queue_driving = 0;
55 be_drive_mcc_wrb_queue(pfob->mcc);
56 }
57 return status;
58}
59
60/*
61 This allocates and initializes a function object based on the information
62 provided by upper layer drivers.
63
64 Returns BE_SUCCESS on success and an appropriate int on failure.
65
66 A function object represents a single BladeEngine (logical) PCI function.
67 That is a function object either represents
68 the networking side of BladeEngine or the iSCSI side of BladeEngine.
69
70 This routine will also detect and create an appropriate PD object for the
71 PCI function as needed.
72*/
73int
74be_function_object_create(u8 __iomem *csr_va, u8 __iomem *db_va,
75 u8 __iomem *pci_va, u32 function_type,
76 struct ring_desc *mailbox, struct be_function_object *pfob)
77{
78 int status;
79
80 ASSERT(pfob); /* not a magic assert */
81 ASSERT(function_type <= 2);
82
83 TRACE(DL_INFO, "Create function object. type:%s object:0x%p",
84 (function_type == BE_FUNCTION_TYPE_ISCSI ? "iSCSI" :
85 (function_type == BE_FUNCTION_TYPE_NETWORK ? "Network" :
86 "Arm")), pfob);
87
88 memset(pfob, 0, sizeof(*pfob));
89
90 pfob->type = function_type;
91 pfob->csr_va = csr_va;
92 pfob->db_va = db_va;
93 pfob->pci_va = pci_va;
94
95 spin_lock_init(&pfob->cq_lock);
96 spin_lock_init(&pfob->post_lock);
97 spin_lock_init(&pfob->mcc_context_lock);
98
99
100 pfob->pci_function_number = 1;
101
102
103 pfob->emulate = false;
104 TRACE(DL_NOTE, "Non-emulation mode");
105 status = be_drive_POST(pfob);
106 if (status != BE_SUCCESS) {
107 TRACE(DL_ERR, "BladeEngine POST failed.");
108 goto error;
109 }
110
111 /* Initialize the mailbox */
112 status = be_mpu_init_mailbox(pfob, mailbox);
113 if (status != BE_SUCCESS) {
114 TRACE(DL_ERR, "Failed to initialize mailbox.");
115 goto error;
116 }
117 /*
118 * Cache the firmware config for ASSERTs in hwclib and later
119 * driver queries.
120 */
121 status = be_function_internal_query_firmware_config(pfob,
122 &pfob->fw_config);
123 if (status != BE_SUCCESS) {
124 TRACE(DL_ERR, "Failed to query firmware config.");
125 goto error;
126 }
127
128error:
129 if (status != BE_SUCCESS) {
130 /* No cleanup necessary */
131 TRACE(DL_ERR, "Failed to create function.");
132 memset(pfob, 0, sizeof(*pfob));
133 }
134 return status;
135}
136
137/*
138 This routine drops the reference count on a given function object. Once
139 the reference count falls to zero, the function object is destroyed and all
140 resources held are freed.
141
142 FunctionObject - The function object to drop the reference to.
143*/
144int be_function_object_destroy(struct be_function_object *pfob)
145{
146 TRACE(DL_INFO, "Destroy pfob. Object:0x%p",
147 pfob);
148
149
150 ASSERT(pfob->mcc == NULL);
151
152 return BE_SUCCESS;
153}
154
155int be_function_cleanup(struct be_function_object *pfob)
156{
157 int status = 0;
158 u32 isr;
159 u32 host_intr;
160 struct PCICFG_HOST_TIMER_INT_CTRL_CSR_AMAP ctrl;
161
162
163 if (pfob->type == BE_FUNCTION_TYPE_NETWORK) {
164 status = be_rxf_multicast_config(pfob, false, 0,
165 NULL, NULL, NULL, NULL);
166 ASSERT(status == BE_SUCCESS);
167 }
168 /* VLAN */
169 status = be_rxf_vlan_config(pfob, false, 0, NULL, NULL, NULL, NULL);
170 ASSERT(status == BE_SUCCESS);
171 /*
172 * MCC Queue -- Switches to mailbox mode. May want to destroy
173 * all but the MCC CQ before this call if polling CQ is much better
174 * performance than polling mailbox register.
175 */
176 if (pfob->mcc)
177 status = be_mcc_ring_destroy(pfob->mcc);
178 /*
179 * If interrupts are disabled, clear any CEV interrupt assertions that
180 * fired after we stopped processing EQs.
181 */
182 ctrl.dw[0] = PCICFG1_READ(pfob, host_timer_int_ctrl);
183 host_intr = AMAP_GET_BITS_PTR(PCICFG_HOST_TIMER_INT_CTRL_CSR,
184 hostintr, ctrl.dw);
185 if (!host_intr)
186 if (pfob->type == BE_FUNCTION_TYPE_NETWORK)
187 isr = CSR_READ(pfob, cev.isr1);
188 else
189 isr = CSR_READ(pfob, cev.isr0);
190 else
191 /* This should never happen... */
192 TRACE(DL_ERR, "function_cleanup called with interrupt enabled");
193 /* Function object destroy */
194 status = be_function_object_destroy(pfob);
195 ASSERT(status == BE_SUCCESS);
196
197 return status;
198}
199
200
201void *
202be_function_prepare_embedded_fwcmd(struct be_function_object *pfob,
203 struct MCC_WRB_AMAP *wrb, u32 payld_len, u32 request_length,
204 u32 response_length, u32 opcode, u32 subsystem)
205{
206 struct FWCMD_REQUEST_HEADER *header = NULL;
207 u32 n;
208
209 ASSERT(wrb);
210
211 n = offsetof(struct BE_MCC_WRB_AMAP, payload)/8;
212 AMAP_SET_BITS_PTR(MCC_WRB, embedded, wrb, 1);
213 AMAP_SET_BITS_PTR(MCC_WRB, payload_length, wrb, min(payld_len, n));
214 header = (struct FWCMD_REQUEST_HEADER *)((u8 *)wrb + n);
215
216 header->timeout = 0;
217 header->domain = 0;
218 header->request_length = max(request_length, response_length);
219 header->opcode = opcode;
220 header->subsystem = subsystem;
221
222 return header;
223}
224
225void *
226be_function_prepare_nonembedded_fwcmd(struct be_function_object *pfob,
227 struct MCC_WRB_AMAP *wrb,
228 void *fwcmd_va, u64 fwcmd_pa,
229 u32 payld_len,
230 u32 request_length,
231 u32 response_length,
232 u32 opcode, u32 subsystem)
233{
234 struct FWCMD_REQUEST_HEADER *header = NULL;
235 u32 n;
236 struct MCC_WRB_PAYLOAD_AMAP *plp;
237
238 ASSERT(wrb);
239 ASSERT(fwcmd_va);
240
241 header = (struct FWCMD_REQUEST_HEADER *) fwcmd_va;
242
243 AMAP_SET_BITS_PTR(MCC_WRB, embedded, wrb, 0);
244 AMAP_SET_BITS_PTR(MCC_WRB, payload_length, wrb, payld_len);
245
246 /*
247 * Assume one fragment. The caller may override the SGL by
248 * rewriting the 0th length and adding more entries. They
249 * will also need to update the sge_count.
250 */
251 AMAP_SET_BITS_PTR(MCC_WRB, sge_count, wrb, 1);
252
253 n = offsetof(struct BE_MCC_WRB_AMAP, payload)/8;
254 plp = (struct MCC_WRB_PAYLOAD_AMAP *)((u8 *)wrb + n);
255 AMAP_SET_BITS_PTR(MCC_WRB_PAYLOAD, sgl[0].length, plp, payld_len);
256 AMAP_SET_BITS_PTR(MCC_WRB_PAYLOAD, sgl[0].pa_lo, plp, (u32)fwcmd_pa);
257 AMAP_SET_BITS_PTR(MCC_WRB_PAYLOAD, sgl[0].pa_hi, plp,
258 upper_32_bits(fwcmd_pa));
259
260 header->timeout = 0;
261 header->domain = 0;
262 header->request_length = max(request_length, response_length);
263 header->opcode = opcode;
264 header->subsystem = subsystem;
265
266 return header;
267}
268
269struct MCC_WRB_AMAP *
270be_function_peek_mcc_wrb(struct be_function_object *pfob)
271{
272 struct MCC_WRB_AMAP *wrb = NULL;
273 u32 offset;
274
275 if (pfob->mcc)
276 wrb = _be_mpu_peek_ring_wrb(pfob->mcc, false);
277 else {
278 offset = offsetof(struct BE_MCC_MAILBOX_AMAP, wrb)/8;
279 wrb = (struct MCC_WRB_AMAP *) ((u8 *) pfob->mailbox.va +
280 offset);
281 }
282
283 if (wrb)
284 memset(wrb, 0, sizeof(struct MCC_WRB_AMAP));
285
286 return wrb;
287}
288
289#if defined(BE_DEBUG)
290void be_function_debug_print_wrb(struct be_function_object *pfob,
291 struct MCC_WRB_AMAP *wrb, void *optional_fwcmd_va,
292 struct be_mcc_wrb_context *wrb_context)
293{
294
295 struct FWCMD_REQUEST_HEADER *header = NULL;
296 u8 embedded;
297 u32 n;
298
299 embedded = AMAP_GET_BITS_PTR(MCC_WRB, embedded, wrb);
300
301 if (embedded) {
302 n = offsetof(struct BE_MCC_WRB_AMAP, payload)/8;
303 header = (struct FWCMD_REQUEST_HEADER *)((u8 *)wrb + n);
304 } else {
305 header = (struct FWCMD_REQUEST_HEADER *) optional_fwcmd_va;
306 }
307
308 /* Save the completed count before posting for a debug assert. */
309
310 if (header) {
311 wrb_context->opcode = header->opcode;
312 wrb_context->subsystem = header->subsystem;
313
314 } else {
315 wrb_context->opcode = 0;
316 wrb_context->subsystem = 0;
317 }
318}
319#else
320#define be_function_debug_print_wrb(a_, b_, c_, d_)
321#endif
322
323int
324be_function_post_mcc_wrb(struct be_function_object *pfob,
325 struct MCC_WRB_AMAP *wrb,
326 struct be_generic_q_ctxt *q_ctxt,
327 mcc_wrb_cqe_callback cb, void *cb_context,
328 mcc_wrb_cqe_callback internal_cb,
329 void *internal_cb_context, void *optional_fwcmd_va,
330 struct be_mcc_wrb_response_copy *rc)
331{
332 int status;
333 struct be_mcc_wrb_context *wrb_context = NULL;
334 u64 *p;
335
336 if (q_ctxt) {
337 /* Initialize context. */
338 q_ctxt->context.internal_cb = internal_cb;
339 q_ctxt->context.internal_cb_context = internal_cb_context;
340 q_ctxt->context.cb = cb;
341 q_ctxt->context.cb_context = cb_context;
342 if (rc) {
343 q_ctxt->context.copy.length = rc->length;
344 q_ctxt->context.copy.fwcmd_offset = rc->fwcmd_offset;
345 q_ctxt->context.copy.va = rc->va;
346 } else
347 q_ctxt->context.copy.length = 0;
348
349 q_ctxt->context.optional_fwcmd_va = optional_fwcmd_va;
350
351 /* Queue this request */
352 status = be_function_queue_mcc_wrb(pfob, q_ctxt);
353
354 goto Error;
355 }
356 /*
357 * Allocate a WRB context struct to hold the callback pointers,
358 * status, etc. This is required if commands complete out of order.
359 */
360 wrb_context = _be_mcc_allocate_wrb_context(pfob);
361 if (!wrb_context) {
362 TRACE(DL_WARN, "Failed to allocate MCC WRB context.");
363 status = BE_STATUS_SYSTEM_RESOURCES;
364 goto Error;
365 }
366 /* Initialize context. */
367 memset(wrb_context, 0, sizeof(*wrb_context));
368 wrb_context->internal_cb = internal_cb;
369 wrb_context->internal_cb_context = internal_cb_context;
370 wrb_context->cb = cb;
371 wrb_context->cb_context = cb_context;
372 if (rc) {
373 wrb_context->copy.length = rc->length;
374 wrb_context->copy.fwcmd_offset = rc->fwcmd_offset;
375 wrb_context->copy.va = rc->va;
376 } else
377 wrb_context->copy.length = 0;
378 wrb_context->wrb = wrb;
379
380 /*
381 * Copy the context pointer into the WRB opaque tag field.
382 * Verify assumption of 64-bit tag with a compile time assert.
383 */
384 p = (u64 *) ((u8 *)wrb + offsetof(struct BE_MCC_WRB_AMAP, tag)/8);
385 *p = (u64)(size_t)wrb_context;
386
387 /* Print info about this FWCMD for debug builds. */
388 be_function_debug_print_wrb(pfob, wrb, optional_fwcmd_va, wrb_context);
389
390 /*
391 * issue the WRB to the MPU as appropriate
392 */
393 if (pfob->mcc) {
394 /*
395 * we're in WRB mode, pass to the mcc layer
396 */
397 status = _be_mpu_post_wrb_ring(pfob->mcc, wrb, wrb_context);
398 } else {
399 /*
400 * we're in mailbox mode
401 */
402 status = _be_mpu_post_wrb_mailbox(pfob, wrb, wrb_context);
403
404 /* mailbox mode always completes synchronously */
405 ASSERT(status != BE_STATUS_PENDING);
406 }
407
408Error:
409
410 return status;
411}
412
413int
414be_function_ring_destroy(struct be_function_object *pfob,
415 u32 id, u32 ring_type, mcc_wrb_cqe_callback cb,
416 void *cb_context, mcc_wrb_cqe_callback internal_cb,
417 void *internal_cb_context)
418{
419
420 struct FWCMD_COMMON_RING_DESTROY *fwcmd = NULL;
421 struct MCC_WRB_AMAP *wrb = NULL;
422 int status = 0;
423 unsigned long irql;
424
425 spin_lock_irqsave(&pfob->post_lock, irql);
426
427 TRACE(DL_INFO, "Destroy ring id:%d type:%d", id, ring_type);
428
429 wrb = be_function_peek_mcc_wrb(pfob);
430 if (!wrb) {
431 ASSERT(wrb);
432 TRACE(DL_ERR, "No free MCC WRBs in destroy ring.");
433 status = BE_STATUS_NO_MCC_WRB;
434 goto Error;
435 }
436 /* Prepares an embedded fwcmd, including request/response sizes. */
437 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_RING_DESTROY);
438
439 fwcmd->params.request.id = id;
440 fwcmd->params.request.ring_type = ring_type;
441
442 /* Post the f/w command */
443 status = be_function_post_mcc_wrb(pfob, wrb, NULL, cb, cb_context,
444 internal_cb, internal_cb_context, fwcmd, NULL);
445 if (status != BE_SUCCESS && status != BE_PENDING) {
446 TRACE(DL_ERR, "Ring destroy fwcmd failed. id:%d ring_type:%d",
447 id, ring_type);
448 goto Error;
449 }
450
451Error:
452 spin_unlock_irqrestore(&pfob->post_lock, irql);
453 if (pfob->pend_queue_driving && pfob->mcc) {
454 pfob->pend_queue_driving = 0;
455 be_drive_mcc_wrb_queue(pfob->mcc);
456 }
457 return status;
458}
459
460void
461be_rd_to_pa_list(struct ring_desc *rd, struct PHYS_ADDR *pa_list, u32 max_num)
462{
463 u32 num_pages = PAGES_SPANNED(rd->va, rd->length);
464 u32 i = 0;
465 u64 pa = rd->pa;
466 __le64 lepa;
467
468 ASSERT(pa_list);
469 ASSERT(pa);
470
471 for (i = 0; i < min(num_pages, max_num); i++) {
472 lepa = cpu_to_le64(pa);
473 pa_list[i].lo = (u32)lepa;
474 pa_list[i].hi = upper_32_bits(lepa);
475 pa += PAGE_SIZE;
476 }
477}
478
479
480
481/*-----------------------------------------------------------------------------
482 * Function: be_function_get_fw_version
483 * Retrieves the firmware version on the adpater. If the callback is
484 * NULL this call executes synchronously. If the callback is not NULL,
485 * the returned status will be BE_PENDING if the command was issued
486 * successfully.
487 * pfob -
488 * fwv - Pointer to response buffer if callback is NULL.
489 * cb - Callback function invoked when the FWCMD completes.
490 * cb_context - Passed to the callback function.
491 * return pend_status - BE_SUCCESS (0) on success.
492 * BE_PENDING (postive value) if the FWCMD
493 * completion is pending. Negative error code on failure.
494 *---------------------------------------------------------------------------
495 */
496int
497be_function_get_fw_version(struct be_function_object *pfob,
498 struct FWCMD_COMMON_GET_FW_VERSION_RESPONSE_PAYLOAD *fwv,
499 mcc_wrb_cqe_callback cb, void *cb_context)
500{
501 int status = BE_SUCCESS;
502 struct MCC_WRB_AMAP *wrb = NULL;
503 struct FWCMD_COMMON_GET_FW_VERSION *fwcmd = NULL;
504 unsigned long irql;
505 struct be_mcc_wrb_response_copy rc;
506
507 spin_lock_irqsave(&pfob->post_lock, irql);
508
509 wrb = be_function_peek_mcc_wrb(pfob);
510 if (!wrb) {
511 TRACE(DL_ERR, "MCC wrb peek failed.");
512 status = BE_STATUS_NO_MCC_WRB;
513 goto Error;
514 }
515
516 if (!cb && !fwv) {
517 TRACE(DL_ERR, "callback and response buffer NULL!");
518 status = BE_NOT_OK;
519 goto Error;
520 }
521 /* Prepares an embedded fwcmd, including request/response sizes. */
522 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_GET_FW_VERSION);
523
524 rc.length = FIELD_SIZEOF(struct FWCMD_COMMON_GET_FW_VERSION,
525 params.response);
526 rc.fwcmd_offset = offsetof(struct FWCMD_COMMON_GET_FW_VERSION,
527 params.response);
528 rc.va = fwv;
529
530 /* Post the f/w command */
531 status = be_function_post_mcc_wrb(pfob, wrb, NULL, cb,
532 cb_context, NULL, NULL, fwcmd, &rc);
533
534Error:
535 spin_unlock_irqrestore(&pfob->post_lock, irql);
536 if (pfob->pend_queue_driving && pfob->mcc) {
537 pfob->pend_queue_driving = 0;
538 be_drive_mcc_wrb_queue(pfob->mcc);
539 }
540 return status;
541}
542
543int
544be_function_queue_mcc_wrb(struct be_function_object *pfob,
545 struct be_generic_q_ctxt *q_ctxt)
546{
547 int status;
548
549 ASSERT(q_ctxt);
550
551 /*
552 * issue the WRB to the MPU as appropriate
553 */
554 if (pfob->mcc) {
555
556 /* We're in ring mode. Queue this item. */
557 pfob->mcc->backlog_length++;
558 list_add_tail(&q_ctxt->context.list, &pfob->mcc->backlog);
559 status = BE_PENDING;
560 } else {
561 status = BE_NOT_OK;
562 }
563 return status;
564}
565
diff --git a/drivers/staging/benet/fwcmd_common.h b/drivers/staging/benet/fwcmd_common.h
deleted file mode 100644
index 406e0d6fa985..000000000000
--- a/drivers/staging/benet/fwcmd_common.h
+++ /dev/null
@@ -1,222 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __fwcmd_common_amap_h__
21#define __fwcmd_common_amap_h__
22#include "host_struct.h"
23
24/* --- PHY_LINK_DUPLEX_ENUM --- */
25#define PHY_LINK_DUPLEX_NONE (0)
26#define PHY_LINK_DUPLEX_HALF (1)
27#define PHY_LINK_DUPLEX_FULL (2)
28
29/* --- PHY_LINK_SPEED_ENUM --- */
30#define PHY_LINK_SPEED_ZERO (0) /* No link. */
31#define PHY_LINK_SPEED_10MBPS (1) /* 10 Mbps */
32#define PHY_LINK_SPEED_100MBPS (2) /* 100 Mbps */
33#define PHY_LINK_SPEED_1GBPS (3) /* 1 Gbps */
34#define PHY_LINK_SPEED_10GBPS (4) /* 10 Gbps */
35
36/* --- PHY_LINK_FAULT_ENUM --- */
37#define PHY_LINK_FAULT_NONE (0) /* No fault status
38 available or detected */
39#define PHY_LINK_FAULT_LOCAL (1) /* Local fault detected */
40#define PHY_LINK_FAULT_REMOTE (2) /* Remote fault detected */
41
42/* --- BE_ULP_MASK --- */
43#define BE_ULP0_MASK (1)
44#define BE_ULP1_MASK (2)
45#define BE_ULP2_MASK (4)
46
47/* --- NTWK_ACTIVE_PORT --- */
48#define NTWK_PORT_A (0) /* Port A is currently active */
49#define NTWK_PORT_B (1) /* Port B is currently active */
50#define NTWK_NO_ACTIVE_PORT (15) /* Both ports have lost link */
51
52/* --- NTWK_LINK_TYPE --- */
53#define NTWK_LINK_TYPE_PHYSICAL (0) /* link up/down event
54 applies to BladeEngine's
55 Physical Ports
56 */
57#define NTWK_LINK_TYPE_VIRTUAL (1) /* Virtual link up/down event
58 reported by BladeExchange.
59 This applies only when the
60 VLD feature is enabled
61 */
62
63/*
64 * --- FWCMD_MAC_TYPE_ENUM ---
65 * This enum defines the types of MAC addresses in the RXF MAC Address Table.
66 */
67#define MAC_ADDRESS_TYPE_STORAGE (0) /* Storage MAC Address */
68#define MAC_ADDRESS_TYPE_NETWORK (1) /* Network MAC Address */
69#define MAC_ADDRESS_TYPE_PD (2) /* Protection Domain MAC Addr */
70#define MAC_ADDRESS_TYPE_MANAGEMENT (3) /* Managment MAC Address */
71
72
73/* --- FWCMD_RING_TYPE_ENUM --- */
74#define FWCMD_RING_TYPE_ETH_RX (1) /* Ring created with */
75 /* FWCMD_COMMON_ETH_RX_CREATE. */
76#define FWCMD_RING_TYPE_ETH_TX (2) /* Ring created with */
77 /* FWCMD_COMMON_ETH_TX_CREATE. */
78#define FWCMD_RING_TYPE_ISCSI_WRBQ (3) /* Ring created with */
79 /* FWCMD_COMMON_ISCSI_WRBQ_CREATE. */
80#define FWCMD_RING_TYPE_ISCSI_DEFQ (4) /* Ring created with */
81 /* FWCMD_COMMON_ISCSI_DEFQ_CREATE. */
82#define FWCMD_RING_TYPE_TPM_WRBQ (5) /* Ring created with */
83 /* FWCMD_COMMON_TPM_WRBQ_CREATE. */
84#define FWCMD_RING_TYPE_TPM_DEFQ (6) /* Ring created with */
85 /* FWCMD_COMMONTPM_TDEFQ_CREATE. */
86#define FWCMD_RING_TYPE_TPM_RQ (7) /* Ring created with */
87 /* FWCMD_COMMON_TPM_RQ_CREATE. */
88#define FWCMD_RING_TYPE_MCC (8) /* Ring created with */
89 /* FWCMD_COMMON_MCC_CREATE. */
90#define FWCMD_RING_TYPE_CQ (9) /* Ring created with */
91 /* FWCMD_COMMON_CQ_CREATE. */
92#define FWCMD_RING_TYPE_EQ (10) /* Ring created with */
93 /* FWCMD_COMMON_EQ_CREATE. */
94#define FWCMD_RING_TYPE_QP (11) /* Ring created with */
95 /* FWCMD_RDMA_QP_CREATE. */
96
97
98/* --- ETH_TX_RING_TYPE_ENUM --- */
99#define ETH_TX_RING_TYPE_FORWARDING (1) /* Ethernet ring for
100 forwarding packets */
101#define ETH_TX_RING_TYPE_STANDARD (2) /* Ethernet ring for sending
102 network packets. */
103#define ETH_TX_RING_TYPE_BOUND (3) /* Ethernet ring bound to the
104 port specified in the command
105 header.port_number field.
106 Rings of this type are
107 NOT subject to the
108 failover logic implemented
109 in the BladeEngine.
110 */
111
112/* --- FWCMD_COMMON_QOS_TYPE_ENUM --- */
113#define QOS_BITS_NIC (1) /* max_bits_per_second_NIC */
114 /* field is valid. */
115#define QOS_PKTS_NIC (2) /* max_packets_per_second_NIC */
116 /* field is valid. */
117#define QOS_IOPS_ISCSI (4) /* max_ios_per_second_iSCSI */
118 /*field is valid. */
119#define QOS_VLAN_TAG (8) /* domain_VLAN_tag field
120 is valid. */
121#define QOS_FABRIC_ID (16) /* fabric_domain_ID field
122 is valid. */
123#define QOS_OEM_PARAMS (32) /* qos_params_oem field
124 is valid. */
125#define QOS_TPUT_ISCSI (64) /* max_bytes_per_second_iSCSI
126 field is valid. */
127
128
129/*
130 * --- FAILOVER_CONFIG_ENUM ---
131 * Failover configuration setting used in FWCMD_COMMON_FORCE_FAILOVER
132 */
133#define FAILOVER_CONFIG_NO_CHANGE (0) /* No change to automatic */
134 /* port failover setting. */
135#define FAILOVER_CONFIG_ON (1) /* Automatic port failover
136 on link down is enabled. */
137#define FAILOVER_CONFIG_OFF (2) /* Automatic port failover
138 on link down is disabled. */
139
140/*
141 * --- FAILOVER_PORT_ENUM ---
142 * Failover port setting used in FWCMD_COMMON_FORCE_FAILOVER
143 */
144#define FAILOVER_PORT_A (0) /* Selects port A. */
145#define FAILOVER_PORT_B (1) /* Selects port B. */
146#define FAILOVER_PORT_NONE (15) /* No port change requested. */
147
148
149/*
150 * --- MGMT_FLASHROM_OPCODE ---
151 * Flash ROM operation code
152 */
153#define MGMT_FLASHROM_OPCODE_FLASH (1) /* Commit downloaded data
154 to Flash ROM */
155#define MGMT_FLASHROM_OPCODE_SAVE (2) /* Save downloaded data to
156 ARM's DDR - do not flash */
157#define MGMT_FLASHROM_OPCODE_CLEAR (3) /* Erase specified component
158 from FlashROM */
159#define MGMT_FLASHROM_OPCODE_REPORT (4) /* Read specified component
160 from Flash ROM */
161#define MGMT_FLASHROM_OPCODE_IMAGE_INFO (5) /* Returns size of a
162 component */
163
164/*
165 * --- MGMT_FLASHROM_OPTYPE ---
166 * Flash ROM operation type
167 */
168#define MGMT_FLASHROM_OPTYPE_CODE_FIRMWARE (0) /* Includes ARM firmware,
169 IPSec (optional) and EP
170 firmware */
171#define MGMT_FLASHROM_OPTYPE_CODE_REDBOOT (1)
172#define MGMT_FLASHROM_OPTYPE_CODE_BIOS (2)
173#define MGMT_FLASHROM_OPTYPE_CODE_PXE_BIOS (3)
174#define MGMT_FLASHROM_OPTYPE_CODE_CTRLS (4)
175#define MGMT_FLASHROM_OPTYPE_CFG_IPSEC (5)
176#define MGMT_FLASHROM_OPTYPE_CFG_INI (6)
177#define MGMT_FLASHROM_OPTYPE_ROM_OFFSET_SPECIFIED (7)
178
179/*
180 * --- FLASHROM_TYPE ---
181 * Flash ROM manufacturers supported in the f/w
182 */
183#define INTEL (0)
184#define SPANSION (1)
185#define MICRON (2)
186
187/* --- DDR_CAS_TYPE --- */
188#define CAS_3 (0)
189#define CAS_4 (1)
190#define CAS_5 (2)
191
192/* --- DDR_SIZE_TYPE --- */
193#define SIZE_256MB (0)
194#define SIZE_512MB (1)
195
196/* --- DDR_MODE_TYPE --- */
197#define DDR_NO_ECC (0)
198#define DDR_ECC (1)
199
200/* --- INTERFACE_10GB_TYPE --- */
201#define CX4_TYPE (0)
202#define XFP_TYPE (1)
203
204/* --- BE_CHIP_MAX_MTU --- */
205#define CHIP_MAX_MTU (9000)
206
207/* --- XAUI_STATE_ENUM --- */
208#define XAUI_STATE_ENABLE (0) /* This MUST be the default
209 value for all requests
210 which set/change
211 equalization parameter. */
212#define XAUI_STATE_DISABLE (255) /* The XAUI for both ports
213 may be disabled for EMI
214 tests. There is no
215 provision for turning off
216 individual ports.
217 */
218/* --- BE_ASIC_REVISION --- */
219#define BE_ASIC_REV_A0 (1)
220#define BE_ASIC_REV_A1 (2)
221
222#endif /* __fwcmd_common_amap_h__ */
diff --git a/drivers/staging/benet/fwcmd_common_bmap.h b/drivers/staging/benet/fwcmd_common_bmap.h
deleted file mode 100644
index a007cf276500..000000000000
--- a/drivers/staging/benet/fwcmd_common_bmap.h
+++ /dev/null
@@ -1,717 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __fwcmd_common_bmap_h__
21#define __fwcmd_common_bmap_h__
22#include "fwcmd_types_bmap.h"
23#include "fwcmd_hdr_bmap.h"
24
25#if defined(__BIG_ENDIAN)
26 /* Physical Address. */
27struct PHYS_ADDR {
28 union {
29 struct {
30 u32 lo; /* DWORD 0 */
31 u32 hi; /* DWORD 1 */
32 } __packed; /* unnamed struct */
33 u32 dw[2]; /* dword union */
34 }; /* unnamed union */
35} __packed ;
36
37
38#else
39 /* Physical Address. */
40struct PHYS_ADDR {
41 union {
42 struct {
43 u32 lo; /* DWORD 0 */
44 u32 hi; /* DWORD 1 */
45 } __packed; /* unnamed struct */
46 u32 dw[2]; /* dword union */
47 }; /* unnamed union */
48} __packed ;
49
50struct BE_LINK_STATUS {
51 u8 mac0_duplex;
52 u8 mac0_speed;
53 u8 mac1_duplex;
54 u8 mac1_speed;
55 u8 mgmt_mac_duplex;
56 u8 mgmt_mac_speed;
57 u8 active_port;
58 u8 rsvd0;
59 u8 mac0_fault;
60 u8 mac1_fault;
61 u16 rsvd1;
62} __packed;
63#endif
64
65struct FWCMD_COMMON_ANON_170_REQUEST {
66 u32 rsvd0;
67} __packed;
68
69union LINK_STATUS_QUERY_PARAMS {
70 struct BE_LINK_STATUS response;
71 struct FWCMD_COMMON_ANON_170_REQUEST request;
72} __packed;
73
74/*
75 * Queries the the link status for all ports. The valid values below
76 * DO NOT indicate that a particular duplex or speed is supported by
77 * BladeEngine. These enumerations simply list all possible duplexes
78 * and speeds for any port. Consult BladeEngine product documentation
79 * for the supported parameters.
80 */
81struct FWCMD_COMMON_NTWK_LINK_STATUS_QUERY {
82 union FWCMD_HEADER header;
83 union LINK_STATUS_QUERY_PARAMS params;
84} __packed;
85
86struct FWCMD_COMMON_ANON_171_REQUEST {
87 u8 type;
88 u8 port;
89 u8 mac1;
90 u8 permanent;
91} __packed;
92
93struct FWCMD_COMMON_ANON_172_RESPONSE {
94 struct MAC_ADDRESS_FORMAT mac;
95} __packed;
96
97union NTWK_MAC_QUERY_PARAMS {
98 struct FWCMD_COMMON_ANON_171_REQUEST request;
99 struct FWCMD_COMMON_ANON_172_RESPONSE response;
100} __packed;
101
102/* Queries one MAC address. */
103struct FWCMD_COMMON_NTWK_MAC_QUERY {
104 union FWCMD_HEADER header;
105 union NTWK_MAC_QUERY_PARAMS params;
106} __packed;
107
108struct MAC_SET_PARAMS_IN {
109 u8 type;
110 u8 port;
111 u8 mac1;
112 u8 invalidate;
113 struct MAC_ADDRESS_FORMAT mac;
114} __packed;
115
116struct MAC_SET_PARAMS_OUT {
117 u32 rsvd0;
118} __packed;
119
120union MAC_SET_PARAMS {
121 struct MAC_SET_PARAMS_IN request;
122 struct MAC_SET_PARAMS_OUT response;
123} __packed;
124
125/* Sets a MAC address. */
126struct FWCMD_COMMON_NTWK_MAC_SET {
127 union FWCMD_HEADER header;
128 union MAC_SET_PARAMS params;
129} __packed;
130
131/* MAC address list. */
132struct NTWK_MULTICAST_MAC_LIST {
133 u8 byte[6];
134} __packed;
135
136struct FWCMD_COMMON_NTWK_MULTICAST_SET_REQUEST_PAYLOAD {
137 u16 num_mac;
138 u8 promiscuous;
139 u8 rsvd0;
140 struct NTWK_MULTICAST_MAC_LIST mac[32];
141} __packed;
142
143struct FWCMD_COMMON_ANON_174_RESPONSE {
144 u32 rsvd0;
145} __packed;
146
147union FWCMD_COMMON_ANON_173_PARAMS {
148 struct FWCMD_COMMON_NTWK_MULTICAST_SET_REQUEST_PAYLOAD request;
149 struct FWCMD_COMMON_ANON_174_RESPONSE response;
150} __packed;
151
152/*
153 * Sets multicast address hash. The MPU will merge the MAC address lists
154 * from all clients, including the networking and storage functions.
155 * This command may fail if the final merged list of MAC addresses exceeds
156 * 32 entries.
157 */
158struct FWCMD_COMMON_NTWK_MULTICAST_SET {
159 union FWCMD_HEADER header;
160 union FWCMD_COMMON_ANON_173_PARAMS params;
161} __packed;
162
163struct FWCMD_COMMON_NTWK_VLAN_CONFIG_REQUEST_PAYLOAD {
164 u16 num_vlan;
165 u8 promiscuous;
166 u8 rsvd0;
167 u16 vlan_tag[32];
168} __packed;
169
170struct FWCMD_COMMON_ANON_176_RESPONSE {
171 u32 rsvd0;
172} __packed;
173
174union FWCMD_COMMON_ANON_175_PARAMS {
175 struct FWCMD_COMMON_NTWK_VLAN_CONFIG_REQUEST_PAYLOAD request;
176 struct FWCMD_COMMON_ANON_176_RESPONSE response;
177} __packed;
178
179/*
180 * Sets VLAN tag filter. The MPU will merge the VLAN tag list from all
181 * clients, including the networking and storage functions. This command
182 * may fail if the final vlan_tag array (from all functions) is longer
183 * than 32 entries.
184 */
185struct FWCMD_COMMON_NTWK_VLAN_CONFIG {
186 union FWCMD_HEADER header;
187 union FWCMD_COMMON_ANON_175_PARAMS params;
188} __packed;
189
190struct RING_DESTROY_REQUEST {
191 u16 ring_type;
192 u16 id;
193 u8 bypass_flush;
194 u8 rsvd0;
195 u16 rsvd1;
196} __packed;
197
198struct FWCMD_COMMON_ANON_190_RESPONSE {
199 u32 rsvd0;
200} __packed;
201
202union FWCMD_COMMON_ANON_189_PARAMS {
203 struct RING_DESTROY_REQUEST request;
204 struct FWCMD_COMMON_ANON_190_RESPONSE response;
205} __packed;
206/*
207 * Command for destroying any ring. The connection(s) using the ring should
208 * be quiesced before destroying the ring.
209 */
210struct FWCMD_COMMON_RING_DESTROY {
211 union FWCMD_HEADER header;
212 union FWCMD_COMMON_ANON_189_PARAMS params;
213} __packed;
214
215struct FWCMD_COMMON_ANON_192_REQUEST {
216 u16 num_pages;
217 u16 rsvd0;
218 struct CQ_CONTEXT_AMAP context;
219 struct PHYS_ADDR pages[4];
220} __packed ;
221
222struct FWCMD_COMMON_ANON_193_RESPONSE {
223 u16 cq_id;
224} __packed ;
225
226union FWCMD_COMMON_ANON_191_PARAMS {
227 struct FWCMD_COMMON_ANON_192_REQUEST request;
228 struct FWCMD_COMMON_ANON_193_RESPONSE response;
229} __packed ;
230
231/*
232 * Command for creating a completion queue. A Completion Queue must span
233 * at least 1 page and at most 4 pages. Each completion queue entry
234 * is 16 bytes regardless of CQ entry format. Thus the ring must be
235 * at least 256 entries deep (corresponding to 1 page) and can be at
236 * most 1024 entries deep (corresponding to 4 pages). The number of
237 * pages posted must contain the CQ ring size as encoded in the context.
238 *
239 */
240struct FWCMD_COMMON_CQ_CREATE {
241 union FWCMD_HEADER header;
242 union FWCMD_COMMON_ANON_191_PARAMS params;
243} __packed ;
244
245struct FWCMD_COMMON_ANON_198_REQUEST {
246 u16 num_pages;
247 u16 rsvd0;
248 struct EQ_CONTEXT_AMAP context;
249 struct PHYS_ADDR pages[8];
250} __packed ;
251
252struct FWCMD_COMMON_ANON_199_RESPONSE {
253 u16 eq_id;
254} __packed ;
255
256union FWCMD_COMMON_ANON_197_PARAMS {
257 struct FWCMD_COMMON_ANON_198_REQUEST request;
258 struct FWCMD_COMMON_ANON_199_RESPONSE response;
259} __packed ;
260
261/*
262 * Command for creating a event queue. An Event Queue must span at least
263 * 1 page and at most 8 pages. The number of pages posted must contain
264 * the EQ ring. The ring is defined by the size of the EQ entries (encoded
265 * in the context) and the number of EQ entries (also encoded in the
266 * context).
267 */
268struct FWCMD_COMMON_EQ_CREATE {
269 union FWCMD_HEADER header;
270 union FWCMD_COMMON_ANON_197_PARAMS params;
271} __packed ;
272
273struct FWCMD_COMMON_ANON_201_REQUEST {
274 u16 cq_id;
275 u16 bcmc_cq_id;
276 u16 num_pages;
277 u16 rsvd0;
278 struct PHYS_ADDR pages[2];
279} __packed;
280
281struct FWCMD_COMMON_ANON_202_RESPONSE {
282 u16 id;
283} __packed;
284
285union FWCMD_COMMON_ANON_200_PARAMS {
286 struct FWCMD_COMMON_ANON_201_REQUEST request;
287 struct FWCMD_COMMON_ANON_202_RESPONSE response;
288} __packed;
289
290/*
291 * Command for creating Ethernet receive ring. An ERX ring contains ETH_RX_D
292 * entries (8 bytes each). An ERX ring must be 1024 entries deep
293 * (corresponding to 2 pages).
294 */
295struct FWCMD_COMMON_ETH_RX_CREATE {
296 union FWCMD_HEADER header;
297 union FWCMD_COMMON_ANON_200_PARAMS params;
298} __packed;
299
300struct FWCMD_COMMON_ANON_204_REQUEST {
301 u16 num_pages;
302 u8 ulp_num;
303 u8 type;
304 struct ETX_CONTEXT_AMAP context;
305 struct PHYS_ADDR pages[8];
306} __packed ;
307
308struct FWCMD_COMMON_ANON_205_RESPONSE {
309 u16 cid;
310 u8 ulp_num;
311 u8 rsvd0;
312} __packed ;
313
314union FWCMD_COMMON_ANON_203_PARAMS {
315 struct FWCMD_COMMON_ANON_204_REQUEST request;
316 struct FWCMD_COMMON_ANON_205_RESPONSE response;
317} __packed ;
318
319/*
320 * Command for creating an Ethernet transmit ring. An ETX ring contains
321 * ETH_WRB entries (16 bytes each). An ETX ring must be at least 256
322 * entries deep (corresponding to 1 page) and at most 2k entries deep
323 * (corresponding to 8 pages).
324 */
325struct FWCMD_COMMON_ETH_TX_CREATE {
326 union FWCMD_HEADER header;
327 union FWCMD_COMMON_ANON_203_PARAMS params;
328} __packed ;
329
330struct FWCMD_COMMON_ANON_222_REQUEST {
331 u16 num_pages;
332 u16 rsvd0;
333 struct MCC_RING_CONTEXT_AMAP context;
334 struct PHYS_ADDR pages[8];
335} __packed ;
336
337struct FWCMD_COMMON_ANON_223_RESPONSE {
338 u16 id;
339} __packed ;
340
341union FWCMD_COMMON_ANON_221_PARAMS {
342 struct FWCMD_COMMON_ANON_222_REQUEST request;
343 struct FWCMD_COMMON_ANON_223_RESPONSE response;
344} __packed ;
345
346/*
347 * Command for creating the MCC ring. An MCC ring must be at least 16
348 * entries deep (corresponding to 1 page) and at most 128 entries deep
349 * (corresponding to 8 pages).
350 */
351struct FWCMD_COMMON_MCC_CREATE {
352 union FWCMD_HEADER header;
353 union FWCMD_COMMON_ANON_221_PARAMS params;
354} __packed ;
355
356struct GET_QOS_IN {
357 u32 qos_params_rsvd;
358} __packed;
359
360struct GET_QOS_OUT {
361 u32 max_bits_per_second_NIC;
362 u32 max_packets_per_second_NIC;
363 u32 max_ios_per_second_iSCSI;
364 u32 max_bytes_per_second_iSCSI;
365 u16 domain_VLAN_tag;
366 u16 fabric_domain_ID;
367 u32 qos_params_oem[4];
368} __packed;
369
370union GET_QOS_PARAMS {
371 struct GET_QOS_IN request;
372 struct GET_QOS_OUT response;
373} __packed;
374
375/* QOS/Bandwidth settings per domain. Applicable only in VMs. */
376struct FWCMD_COMMON_GET_QOS {
377 union FWCMD_HEADER header;
378 union GET_QOS_PARAMS params;
379} __packed;
380
381struct SET_QOS_IN {
382 u32 valid_flags;
383 u32 max_bits_per_second_NIC;
384 u32 max_packets_per_second_NIC;
385 u32 max_ios_per_second_iSCSI;
386 u32 max_bytes_per_second_iSCSI;
387 u16 domain_VLAN_tag;
388 u16 fabric_domain_ID;
389 u32 qos_params_oem[4];
390} __packed;
391
392struct SET_QOS_OUT {
393 u32 qos_params_rsvd;
394} __packed;
395
396union SET_QOS_PARAMS {
397 struct SET_QOS_IN request;
398 struct SET_QOS_OUT response;
399} __packed;
400
401/* QOS/Bandwidth settings per domain. Applicable only in VMs. */
402struct FWCMD_COMMON_SET_QOS {
403 union FWCMD_HEADER header;
404 union SET_QOS_PARAMS params;
405} __packed;
406
407struct SET_FRAME_SIZE_IN {
408 u32 max_tx_frame_size;
409 u32 max_rx_frame_size;
410} __packed;
411
412struct SET_FRAME_SIZE_OUT {
413 u32 chip_max_tx_frame_size;
414 u32 chip_max_rx_frame_size;
415} __packed;
416
417union SET_FRAME_SIZE_PARAMS {
418 struct SET_FRAME_SIZE_IN request;
419 struct SET_FRAME_SIZE_OUT response;
420} __packed;
421
422/* Set frame size command. Only host domain may issue this command. */
423struct FWCMD_COMMON_SET_FRAME_SIZE {
424 union FWCMD_HEADER header;
425 union SET_FRAME_SIZE_PARAMS params;
426} __packed;
427
428struct FORCE_FAILOVER_IN {
429 u32 move_to_port;
430 u32 failover_config;
431} __packed;
432
433struct FWCMD_COMMON_ANON_231_RESPONSE {
434 u32 rsvd0;
435} __packed;
436
437union FWCMD_COMMON_ANON_230_PARAMS {
438 struct FORCE_FAILOVER_IN request;
439 struct FWCMD_COMMON_ANON_231_RESPONSE response;
440} __packed;
441
442/*
443 * Use this command to control failover in BladeEngine. It may be used
444 * to failback to a restored port or to forcibly move traffic from
445 * one port to another. It may also be used to enable or disable the
446 * automatic failover feature. This command can only be issued by domain
447 * 0.
448 */
449struct FWCMD_COMMON_FORCE_FAILOVER {
450 union FWCMD_HEADER header;
451 union FWCMD_COMMON_ANON_230_PARAMS params;
452} __packed;
453
454struct FWCMD_COMMON_ANON_240_REQUEST {
455 u64 context;
456} __packed;
457
458struct FWCMD_COMMON_ANON_241_RESPONSE {
459 u64 context;
460} __packed;
461
462union FWCMD_COMMON_ANON_239_PARAMS {
463 struct FWCMD_COMMON_ANON_240_REQUEST request;
464 struct FWCMD_COMMON_ANON_241_RESPONSE response;
465} __packed;
466
467/*
468 * This command can be used by clients as a no-operation request. Typical
469 * uses for drivers are as a heartbeat mechanism, or deferred processing
470 * catalyst. The ARM will always complete this command with a good completion.
471 * The 64-bit parameter is not touched by the ARM processor.
472 */
473struct FWCMD_COMMON_NOP {
474 union FWCMD_HEADER header;
475 union FWCMD_COMMON_ANON_239_PARAMS params;
476} __packed;
477
478struct NTWK_RX_FILTER_SETTINGS {
479 u8 promiscuous;
480 u8 ip_cksum;
481 u8 tcp_cksum;
482 u8 udp_cksum;
483 u8 pass_err;
484 u8 pass_ckerr;
485 u8 strip_crc;
486 u8 mcast_en;
487 u8 bcast_en;
488 u8 mcast_promiscuous_en;
489 u8 unicast_en;
490 u8 vlan_promiscuous;
491} __packed;
492
493union FWCMD_COMMON_ANON_242_PARAMS {
494 struct NTWK_RX_FILTER_SETTINGS request;
495 struct NTWK_RX_FILTER_SETTINGS response;
496} __packed;
497
498/*
499 * This command is used to modify the ethernet receive filter configuration.
500 * Only domain 0 network function drivers may issue this command. The
501 * applied configuration is returned in the response payload. Note:
502 * Some receive packet filter settings are global on BladeEngine and
503 * can affect both the storage and network function clients that the
504 * BladeEngine hardware and firmware serve. Additionaly, depending
505 * on the revision of BladeEngine, some ethernet receive filter settings
506 * are dependent on others. If a dependency exists between settings
507 * for the BladeEngine revision, and the command request settings do
508 * not meet the dependency requirement, the invalid settings will not
509 * be applied despite the comand succeeding. For example: a driver may
510 * request to enable broadcast packets, but not enable multicast packets.
511 * On early revisions of BladeEngine, there may be no distinction between
512 * broadcast and multicast filters, so broadcast could not be enabled
513 * without enabling multicast. In this scenario, the comand would still
514 * succeed, but the response payload would indicate the previously
515 * configured broadcast and multicast setting.
516 */
517struct FWCMD_COMMON_NTWK_RX_FILTER {
518 union FWCMD_HEADER header;
519 union FWCMD_COMMON_ANON_242_PARAMS params;
520} __packed;
521
522
523struct FWCMD_COMMON_ANON_244_REQUEST {
524 u32 rsvd0;
525} __packed;
526
527struct FWCMD_COMMON_GET_FW_VERSION_RESPONSE_PAYLOAD {
528 u8 firmware_version_string[32];
529 u8 fw_on_flash_version_string[32];
530} __packed;
531
532union FWCMD_COMMON_ANON_243_PARAMS {
533 struct FWCMD_COMMON_ANON_244_REQUEST request;
534 struct FWCMD_COMMON_GET_FW_VERSION_RESPONSE_PAYLOAD response;
535} __packed;
536
537/* This comand retrieves the firmware version. */
538struct FWCMD_COMMON_GET_FW_VERSION {
539 union FWCMD_HEADER header;
540 union FWCMD_COMMON_ANON_243_PARAMS params;
541} __packed;
542
543struct FWCMD_COMMON_ANON_246_REQUEST {
544 u16 tx_flow_control;
545 u16 rx_flow_control;
546} __packed;
547
548struct FWCMD_COMMON_ANON_247_RESPONSE {
549 u32 rsvd0;
550} __packed;
551
552union FWCMD_COMMON_ANON_245_PARAMS {
553 struct FWCMD_COMMON_ANON_246_REQUEST request;
554 struct FWCMD_COMMON_ANON_247_RESPONSE response;
555} __packed;
556
557/*
558 * This comand is used to program BladeEngine flow control behavior.
559 * Only the host networking driver is allowed to use this comand.
560 */
561struct FWCMD_COMMON_SET_FLOW_CONTROL {
562 union FWCMD_HEADER header;
563 union FWCMD_COMMON_ANON_245_PARAMS params;
564} __packed;
565
566struct FWCMD_COMMON_ANON_249_REQUEST {
567 u32 rsvd0;
568} __packed;
569
570struct FWCMD_COMMON_ANON_250_RESPONSE {
571 u16 tx_flow_control;
572 u16 rx_flow_control;
573} __packed;
574
575union FWCMD_COMMON_ANON_248_PARAMS {
576 struct FWCMD_COMMON_ANON_249_REQUEST request;
577 struct FWCMD_COMMON_ANON_250_RESPONSE response;
578} __packed;
579
580/* This comand is used to read BladeEngine flow control settings. */
581struct FWCMD_COMMON_GET_FLOW_CONTROL {
582 union FWCMD_HEADER header;
583 union FWCMD_COMMON_ANON_248_PARAMS params;
584} __packed;
585
586struct EQ_DELAY_PARAMS {
587 u32 eq_id;
588 u32 delay_in_microseconds;
589} __packed;
590
591struct FWCMD_COMMON_ANON_257_REQUEST {
592 u32 num_eq;
593 u32 rsvd0;
594 struct EQ_DELAY_PARAMS delay[16];
595} __packed;
596
597struct FWCMD_COMMON_ANON_258_RESPONSE {
598 u32 delay_resolution_in_microseconds;
599 u32 delay_max_in_microseconds;
600} __packed;
601
602union MODIFY_EQ_DELAY_PARAMS {
603 struct FWCMD_COMMON_ANON_257_REQUEST request;
604 struct FWCMD_COMMON_ANON_258_RESPONSE response;
605} __packed;
606
607/* This comand changes the EQ delay for a given set of EQs. */
608struct FWCMD_COMMON_MODIFY_EQ_DELAY {
609 union FWCMD_HEADER header;
610 union MODIFY_EQ_DELAY_PARAMS params;
611} __packed;
612
613struct FWCMD_COMMON_ANON_260_REQUEST {
614 u32 rsvd0;
615} __packed;
616
617struct BE_FIRMWARE_CONFIG {
618 u16 be_config_number;
619 u16 asic_revision;
620 u32 nic_ulp_mask;
621 u32 tulp_mask;
622 u32 iscsi_ulp_mask;
623 u32 rdma_ulp_mask;
624 u32 rsvd0[4];
625 u32 eth_tx_id_start;
626 u32 eth_tx_id_count;
627 u32 eth_rx_id_start;
628 u32 eth_rx_id_count;
629 u32 tpm_wrbq_id_start;
630 u32 tpm_wrbq_id_count;
631 u32 tpm_defq_id_start;
632 u32 tpm_defq_id_count;
633 u32 iscsi_wrbq_id_start;
634 u32 iscsi_wrbq_id_count;
635 u32 iscsi_defq_id_start;
636 u32 iscsi_defq_id_count;
637 u32 rdma_qp_id_start;
638 u32 rdma_qp_id_count;
639 u32 rsvd1[8];
640} __packed;
641
642union FWCMD_COMMON_ANON_259_PARAMS {
643 struct FWCMD_COMMON_ANON_260_REQUEST request;
644 struct BE_FIRMWARE_CONFIG response;
645} __packed;
646
647/*
648 * This comand queries the current firmware configuration parameters.
649 * The static configuration type is defined by be_config_number. This
650 * differentiates different BladeEngine builds, such as iSCSI Initiator
651 * versus iSCSI Target. For a given static configuration, the Upper
652 * Layer Protocol (ULP) processors may be reconfigured to support different
653 * protocols. Each ULP processor supports one or more protocols. The
654 * masks indicate which processors are configured for each protocol.
655 * For a given static configuration, the number of TCP connections
656 * supported for each protocol may vary. The *_id_start and *_id_count
657 * variables define a linear range of IDs that are available for each
658 * supported protocol. The *_id_count may be used by the driver to allocate
659 * the appropriate number of connection resources. The *_id_start may
660 * be used to map the arbitrary range of IDs to a zero-based range
661 * of indices.
662 */
663struct FWCMD_COMMON_FIRMWARE_CONFIG {
664 union FWCMD_HEADER header;
665 union FWCMD_COMMON_ANON_259_PARAMS params;
666} __packed;
667
668struct FWCMD_COMMON_PORT_EQUALIZATION_PARAMS {
669 u32 emph_lev_sel_port0;
670 u32 emph_lev_sel_port1;
671 u8 xaui_vo_sel;
672 u8 xaui_state;
673 u16 rsvd0;
674 u32 xaui_eq_vector;
675} __packed;
676
677struct FWCMD_COMMON_ANON_262_REQUEST {
678 u32 rsvd0;
679} __packed;
680
681union FWCMD_COMMON_ANON_261_PARAMS {
682 struct FWCMD_COMMON_ANON_262_REQUEST request;
683 struct FWCMD_COMMON_PORT_EQUALIZATION_PARAMS response;
684} __packed;
685
686/*
687 * This comand can be used to read XAUI equalization parameters. The
688 * ARM firmware applies default equalization parameters during initialization.
689 * These parameters may be customer-specific when derived from the
690 * SEEPROM. See SEEPROM_DATA for equalization specific fields.
691 */
692struct FWCMD_COMMON_GET_PORT_EQUALIZATION {
693 union FWCMD_HEADER header;
694 union FWCMD_COMMON_ANON_261_PARAMS params;
695} __packed;
696
697struct FWCMD_COMMON_ANON_264_RESPONSE {
698 u32 rsvd0;
699} __packed;
700
701union FWCMD_COMMON_ANON_263_PARAMS {
702 struct FWCMD_COMMON_PORT_EQUALIZATION_PARAMS request;
703 struct FWCMD_COMMON_ANON_264_RESPONSE response;
704} __packed;
705
706/*
707 * This comand can be used to set XAUI equalization parameters. The ARM
708 * firmware applies default equalization parameters during initialization.
709 * These parameters may be customer-specific when derived from the
710 * SEEPROM. See SEEPROM_DATA for equalization specific fields.
711 */
712struct FWCMD_COMMON_SET_PORT_EQUALIZATION {
713 union FWCMD_HEADER header;
714 union FWCMD_COMMON_ANON_263_PARAMS params;
715} __packed;
716
717#endif /* __fwcmd_common_bmap_h__ */
diff --git a/drivers/staging/benet/fwcmd_eth_bmap.h b/drivers/staging/benet/fwcmd_eth_bmap.h
deleted file mode 100644
index 234b179eace6..000000000000
--- a/drivers/staging/benet/fwcmd_eth_bmap.h
+++ /dev/null
@@ -1,280 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __fwcmd_eth_bmap_h__
21#define __fwcmd_eth_bmap_h__
22#include "fwcmd_hdr_bmap.h"
23#include "fwcmd_types_bmap.h"
24
25struct MIB_ETH_STATISTICS_PARAMS_IN {
26 u32 rsvd0;
27} __packed;
28
29struct BE_RXF_STATS {
30 u32 p0recvdtotalbytesLSD; /* DWORD 0 */
31 u32 p0recvdtotalbytesMSD; /* DWORD 1 */
32 u32 p0recvdtotalframes; /* DWORD 2 */
33 u32 p0recvdunicastframes; /* DWORD 3 */
34 u32 p0recvdmulticastframes; /* DWORD 4 */
35 u32 p0recvdbroadcastframes; /* DWORD 5 */
36 u32 p0crcerrors; /* DWORD 6 */
37 u32 p0alignmentsymerrs; /* DWORD 7 */
38 u32 p0pauseframesrecvd; /* DWORD 8 */
39 u32 p0controlframesrecvd; /* DWORD 9 */
40 u32 p0inrangelenerrors; /* DWORD 10 */
41 u32 p0outrangeerrors; /* DWORD 11 */
42 u32 p0frametoolongerrors; /* DWORD 12 */
43 u32 p0droppedaddressmatch; /* DWORD 13 */
44 u32 p0droppedvlanmismatch; /* DWORD 14 */
45 u32 p0ipdroppedtoosmall; /* DWORD 15 */
46 u32 p0ipdroppedtooshort; /* DWORD 16 */
47 u32 p0ipdroppedhdrtoosmall; /* DWORD 17 */
48 u32 p0tcpdroppedlen; /* DWORD 18 */
49 u32 p0droppedrunt; /* DWORD 19 */
50 u32 p0recvd64; /* DWORD 20 */
51 u32 p0recvd65_127; /* DWORD 21 */
52 u32 p0recvd128_256; /* DWORD 22 */
53 u32 p0recvd256_511; /* DWORD 23 */
54 u32 p0recvd512_1023; /* DWORD 24 */
55 u32 p0recvd1518_1522; /* DWORD 25 */
56 u32 p0recvd1522_2047; /* DWORD 26 */
57 u32 p0recvd2048_4095; /* DWORD 27 */
58 u32 p0recvd4096_8191; /* DWORD 28 */
59 u32 p0recvd8192_9216; /* DWORD 29 */
60 u32 p0rcvdipcksmerrs; /* DWORD 30 */
61 u32 p0recvdtcpcksmerrs; /* DWORD 31 */
62 u32 p0recvdudpcksmerrs; /* DWORD 32 */
63 u32 p0recvdnonrsspackets; /* DWORD 33 */
64 u32 p0recvdippackets; /* DWORD 34 */
65 u32 p0recvdchute1packets; /* DWORD 35 */
66 u32 p0recvdchute2packets; /* DWORD 36 */
67 u32 p0recvdchute3packets; /* DWORD 37 */
68 u32 p0recvdipsecpackets; /* DWORD 38 */
69 u32 p0recvdmanagementpackets; /* DWORD 39 */
70 u32 p0xmitbyteslsd; /* DWORD 40 */
71 u32 p0xmitbytesmsd; /* DWORD 41 */
72 u32 p0xmitunicastframes; /* DWORD 42 */
73 u32 p0xmitmulticastframes; /* DWORD 43 */
74 u32 p0xmitbroadcastframes; /* DWORD 44 */
75 u32 p0xmitpauseframes; /* DWORD 45 */
76 u32 p0xmitcontrolframes; /* DWORD 46 */
77 u32 p0xmit64; /* DWORD 47 */
78 u32 p0xmit65_127; /* DWORD 48 */
79 u32 p0xmit128_256; /* DWORD 49 */
80 u32 p0xmit256_511; /* DWORD 50 */
81 u32 p0xmit512_1023; /* DWORD 51 */
82 u32 p0xmit1518_1522; /* DWORD 52 */
83 u32 p0xmit1522_2047; /* DWORD 53 */
84 u32 p0xmit2048_4095; /* DWORD 54 */
85 u32 p0xmit4096_8191; /* DWORD 55 */
86 u32 p0xmit8192_9216; /* DWORD 56 */
87 u32 p0rxfifooverflowdropped; /* DWORD 57 */
88 u32 p0ipseclookupfaileddropped; /* DWORD 58 */
89 u32 p1recvdtotalbytesLSD; /* DWORD 59 */
90 u32 p1recvdtotalbytesMSD; /* DWORD 60 */
91 u32 p1recvdtotalframes; /* DWORD 61 */
92 u32 p1recvdunicastframes; /* DWORD 62 */
93 u32 p1recvdmulticastframes; /* DWORD 63 */
94 u32 p1recvdbroadcastframes; /* DWORD 64 */
95 u32 p1crcerrors; /* DWORD 65 */
96 u32 p1alignmentsymerrs; /* DWORD 66 */
97 u32 p1pauseframesrecvd; /* DWORD 67 */
98 u32 p1controlframesrecvd; /* DWORD 68 */
99 u32 p1inrangelenerrors; /* DWORD 69 */
100 u32 p1outrangeerrors; /* DWORD 70 */
101 u32 p1frametoolongerrors; /* DWORD 71 */
102 u32 p1droppedaddressmatch; /* DWORD 72 */
103 u32 p1droppedvlanmismatch; /* DWORD 73 */
104 u32 p1ipdroppedtoosmall; /* DWORD 74 */
105 u32 p1ipdroppedtooshort; /* DWORD 75 */
106 u32 p1ipdroppedhdrtoosmall; /* DWORD 76 */
107 u32 p1tcpdroppedlen; /* DWORD 77 */
108 u32 p1droppedrunt; /* DWORD 78 */
109 u32 p1recvd64; /* DWORD 79 */
110 u32 p1recvd65_127; /* DWORD 80 */
111 u32 p1recvd128_256; /* DWORD 81 */
112 u32 p1recvd256_511; /* DWORD 82 */
113 u32 p1recvd512_1023; /* DWORD 83 */
114 u32 p1recvd1518_1522; /* DWORD 84 */
115 u32 p1recvd1522_2047; /* DWORD 85 */
116 u32 p1recvd2048_4095; /* DWORD 86 */
117 u32 p1recvd4096_8191; /* DWORD 87 */
118 u32 p1recvd8192_9216; /* DWORD 88 */
119 u32 p1rcvdipcksmerrs; /* DWORD 89 */
120 u32 p1recvdtcpcksmerrs; /* DWORD 90 */
121 u32 p1recvdudpcksmerrs; /* DWORD 91 */
122 u32 p1recvdnonrsspackets; /* DWORD 92 */
123 u32 p1recvdippackets; /* DWORD 93 */
124 u32 p1recvdchute1packets; /* DWORD 94 */
125 u32 p1recvdchute2packets; /* DWORD 95 */
126 u32 p1recvdchute3packets; /* DWORD 96 */
127 u32 p1recvdipsecpackets; /* DWORD 97 */
128 u32 p1recvdmanagementpackets; /* DWORD 98 */
129 u32 p1xmitbyteslsd; /* DWORD 99 */
130 u32 p1xmitbytesmsd; /* DWORD 100 */
131 u32 p1xmitunicastframes; /* DWORD 101 */
132 u32 p1xmitmulticastframes; /* DWORD 102 */
133 u32 p1xmitbroadcastframes; /* DWORD 103 */
134 u32 p1xmitpauseframes; /* DWORD 104 */
135 u32 p1xmitcontrolframes; /* DWORD 105 */
136 u32 p1xmit64; /* DWORD 106 */
137 u32 p1xmit65_127; /* DWORD 107 */
138 u32 p1xmit128_256; /* DWORD 108 */
139 u32 p1xmit256_511; /* DWORD 109 */
140 u32 p1xmit512_1023; /* DWORD 110 */
141 u32 p1xmit1518_1522; /* DWORD 111 */
142 u32 p1xmit1522_2047; /* DWORD 112 */
143 u32 p1xmit2048_4095; /* DWORD 113 */
144 u32 p1xmit4096_8191; /* DWORD 114 */
145 u32 p1xmit8192_9216; /* DWORD 115 */
146 u32 p1rxfifooverflowdropped; /* DWORD 116 */
147 u32 p1ipseclookupfaileddropped; /* DWORD 117 */
148 u32 pxdroppednopbuf; /* DWORD 118 */
149 u32 pxdroppednotxpb; /* DWORD 119 */
150 u32 pxdroppednoipsecbuf; /* DWORD 120 */
151 u32 pxdroppednoerxdescr; /* DWORD 121 */
152 u32 pxdroppednotpredescr; /* DWORD 122 */
153 u32 pxrecvdmanagementportpackets; /* DWORD 123 */
154 u32 pxrecvdmanagementportbytes; /* DWORD 124 */
155 u32 pxrecvdmanagementportpauseframes; /* DWORD 125 */
156 u32 pxrecvdmanagementporterrors; /* DWORD 126 */
157 u32 pxxmitmanagementportpackets; /* DWORD 127 */
158 u32 pxxmitmanagementportbytes; /* DWORD 128 */
159 u32 pxxmitmanagementportpause; /* DWORD 129 */
160 u32 pxxmitmanagementportrxfifooverflow; /* DWORD 130 */
161 u32 pxrecvdipsecipcksmerrs; /* DWORD 131 */
162 u32 pxrecvdtcpsecipcksmerrs; /* DWORD 132 */
163 u32 pxrecvdudpsecipcksmerrs; /* DWORD 133 */
164 u32 pxipsecrunt; /* DWORD 134 */
165 u32 pxipsecaddressmismatchdropped; /* DWORD 135 */
166 u32 pxipsecrxfifooverflowdropped; /* DWORD 136 */
167 u32 pxipsecframestoolong; /* DWORD 137 */
168 u32 pxipsectotalipframes; /* DWORD 138 */
169 u32 pxipseciptoosmall; /* DWORD 139 */
170 u32 pxipseciptooshort; /* DWORD 140 */
171 u32 pxipseciphdrtoosmall; /* DWORD 141 */
172 u32 pxipsectcphdrbad; /* DWORD 142 */
173 u32 pxrecvdipsecchute1; /* DWORD 143 */
174 u32 pxrecvdipsecchute2; /* DWORD 144 */
175 u32 pxrecvdipsecchute3; /* DWORD 145 */
176 u32 pxdropped7frags; /* DWORD 146 */
177 u32 pxdroppedfrags; /* DWORD 147 */
178 u32 pxdroppedinvalidfragring; /* DWORD 148 */
179 u32 pxnumforwardedpackets; /* DWORD 149 */
180} __packed;
181
182union MIB_ETH_STATISTICS_PARAMS {
183 struct MIB_ETH_STATISTICS_PARAMS_IN request;
184 struct BE_RXF_STATS response;
185} __packed;
186
187/*
188 * Query ethernet statistics. All domains may issue this command. The
189 * host domain drivers may optionally reset internal statistic counters
190 * with a query.
191 */
192struct FWCMD_ETH_GET_STATISTICS {
193 union FWCMD_HEADER header;
194 union MIB_ETH_STATISTICS_PARAMS params;
195} __packed;
196
197
198struct FWCMD_ETH_ANON_175_REQUEST {
199 u8 port0_promiscuous;
200 u8 port1_promiscuous;
201 u16 rsvd0;
202} __packed;
203
204struct FWCMD_ETH_ANON_176_RESPONSE {
205 u32 rsvd0;
206} __packed;
207
208union FWCMD_ETH_ANON_174_PARAMS {
209 struct FWCMD_ETH_ANON_175_REQUEST request;
210 struct FWCMD_ETH_ANON_176_RESPONSE response;
211} __packed;
212
213/* Enables/Disables promiscuous ethernet receive mode. */
214struct FWCMD_ETH_PROMISCUOUS {
215 union FWCMD_HEADER header;
216 union FWCMD_ETH_ANON_174_PARAMS params;
217} __packed;
218
219struct FWCMD_ETH_ANON_178_REQUEST {
220 u32 new_fragsize_log2;
221} __packed;
222
223struct FWCMD_ETH_ANON_179_RESPONSE {
224 u32 actual_fragsize_log2;
225} __packed;
226
227union FWCMD_ETH_ANON_177_PARAMS {
228 struct FWCMD_ETH_ANON_178_REQUEST request;
229 struct FWCMD_ETH_ANON_179_RESPONSE response;
230} __packed;
231
232/*
233 * Sets the Ethernet RX fragment size. Only host (domain 0) networking
234 * drivers may issue this command. This call will fail for non-host
235 * protection domains. In this situation the MCC CQ status will indicate
236 * a failure due to insufficient priviledges. The response should be
237 * ignored, and the driver should use the FWCMD_ETH_GET_FRAG_SIZE to
238 * query the existing ethernet receive fragment size. It must use this
239 * fragment size for all fragments in the ethernet receive ring. If
240 * the command succeeds, the driver must use the frag size indicated
241 * in the command response since the requested frag size may not be applied
242 * until the next reboot. When the requested fragsize matches the response
243 * fragsize, this indicates the request was applied immediately.
244 */
245struct FWCMD_ETH_SET_RX_FRAG_SIZE {
246 union FWCMD_HEADER header;
247 union FWCMD_ETH_ANON_177_PARAMS params;
248} __packed;
249
250struct FWCMD_ETH_ANON_181_REQUEST {
251 u32 rsvd0;
252} __packed;
253
254struct FWCMD_ETH_ANON_182_RESPONSE {
255 u32 actual_fragsize_log2;
256} __packed;
257
258union FWCMD_ETH_ANON_180_PARAMS {
259 struct FWCMD_ETH_ANON_181_REQUEST request;
260 struct FWCMD_ETH_ANON_182_RESPONSE response;
261} __packed;
262
263/*
264 * Queries the Ethernet RX fragment size. All domains may issue this
265 * command. The driver should call this command to determine the minimum
266 * required fragment size for the ethernet RX ring buffers. Drivers
267 * may choose to use a larger size for each fragment buffer, but BladeEngine
268 * will use up to the configured minimum required fragsize in each ethernet
269 * receive fragment buffer. For example, if the ethernet receive fragment
270 * size is configured to 4kB, and a driver uses 8kB fragments, a 6kB
271 * ethernet packet received by BladeEngine will be split accross two
272 * of the driver's receive framgents (4kB in one fragment buffer, and
273 * 2kB in the subsequent fragment buffer).
274 */
275struct FWCMD_ETH_GET_RX_FRAG_SIZE {
276 union FWCMD_HEADER header;
277 union FWCMD_ETH_ANON_180_PARAMS params;
278} __packed;
279
280#endif /* __fwcmd_eth_bmap_h__ */
diff --git a/drivers/staging/benet/fwcmd_hdr_bmap.h b/drivers/staging/benet/fwcmd_hdr_bmap.h
deleted file mode 100644
index 28b45328fe7b..000000000000
--- a/drivers/staging/benet/fwcmd_hdr_bmap.h
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __fwcmd_hdr_bmap_h__
21#define __fwcmd_hdr_bmap_h__
22
23struct FWCMD_REQUEST_HEADER {
24 u8 opcode;
25 u8 subsystem;
26 u8 port_number;
27 u8 domain;
28 u32 timeout;
29 u32 request_length;
30 u32 rsvd0;
31} __packed;
32
33struct FWCMD_RESPONSE_HEADER {
34 u8 opcode;
35 u8 subsystem;
36 u8 rsvd0;
37 u8 domain;
38 u8 status;
39 u8 additional_status;
40 u16 rsvd1;
41 u32 response_length;
42 u32 actual_response_length;
43} __packed;
44
45/*
46 * The firmware/driver overwrites the input FWCMD_REQUEST_HEADER with
47 * the output FWCMD_RESPONSE_HEADER.
48 */
49union FWCMD_HEADER {
50 struct FWCMD_REQUEST_HEADER request;
51 struct FWCMD_RESPONSE_HEADER response;
52} __packed;
53
54#endif /* __fwcmd_hdr_bmap_h__ */
diff --git a/drivers/staging/benet/fwcmd_mcc.h b/drivers/staging/benet/fwcmd_mcc.h
deleted file mode 100644
index 9eeca878c1fb..000000000000
--- a/drivers/staging/benet/fwcmd_mcc.h
+++ /dev/null
@@ -1,94 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __fwcmd_mcc_amap_h__
21#define __fwcmd_mcc_amap_h__
22#include "fwcmd_opcodes.h"
23/*
24 * Where applicable, a WRB, may contain a list of Scatter-gather elements.
25 * Each element supports a 64 bit address and a 32bit length field.
26 */
27struct BE_MCC_SGE_AMAP {
28 u8 pa_lo[32]; /* DWORD 0 */
29 u8 pa_hi[32]; /* DWORD 1 */
30 u8 length[32]; /* DWORD 2 */
31} __packed;
32struct MCC_SGE_AMAP {
33 u32 dw[3];
34};
35/*
36 * The design of an MCC_SGE allows up to 19 elements to be embedded
37 * in a WRB, supporting 64KB data transfers (assuming a 4KB page size).
38 */
39struct BE_MCC_WRB_PAYLOAD_AMAP {
40 union {
41 struct BE_MCC_SGE_AMAP sgl[19];
42 u8 embedded[59][32]; /* DWORD 0 */
43 };
44} __packed;
45struct MCC_WRB_PAYLOAD_AMAP {
46 u32 dw[59];
47};
48
49/*
50 * This is the structure of the MCC Command WRB for commands
51 * sent to the Management Processing Unit (MPU). See section
52 * for usage in embedded and non-embedded modes.
53 */
54struct BE_MCC_WRB_AMAP {
55 u8 embedded; /* DWORD 0 */
56 u8 rsvd0[2]; /* DWORD 0 */
57 u8 sge_count[5]; /* DWORD 0 */
58 u8 rsvd1[16]; /* DWORD 0 */
59 u8 special[8]; /* DWORD 0 */
60 u8 payload_length[32]; /* DWORD 1 */
61 u8 tag[2][32]; /* DWORD 2 */
62 u8 rsvd2[32]; /* DWORD 4 */
63 struct BE_MCC_WRB_PAYLOAD_AMAP payload;
64} __packed;
65struct MCC_WRB_AMAP {
66 u32 dw[64];
67};
68
69/* This is the structure of the MCC Completion queue entry */
70struct BE_MCC_CQ_ENTRY_AMAP {
71 u8 completion_status[16]; /* DWORD 0 */
72 u8 extended_status[16]; /* DWORD 0 */
73 u8 mcc_tag[2][32]; /* DWORD 1 */
74 u8 rsvd0[27]; /* DWORD 3 */
75 u8 consumed; /* DWORD 3 */
76 u8 completed; /* DWORD 3 */
77 u8 hpi_buffer_completion; /* DWORD 3 */
78 u8 async_event; /* DWORD 3 */
79 u8 valid; /* DWORD 3 */
80} __packed;
81struct MCC_CQ_ENTRY_AMAP {
82 u32 dw[4];
83};
84
85/* Mailbox structures used by the MPU during bootstrap */
86struct BE_MCC_MAILBOX_AMAP {
87 struct BE_MCC_WRB_AMAP wrb;
88 struct BE_MCC_CQ_ENTRY_AMAP cq;
89} __packed;
90struct MCC_MAILBOX_AMAP {
91 u32 dw[68];
92};
93
94#endif /* __fwcmd_mcc_amap_h__ */
diff --git a/drivers/staging/benet/fwcmd_opcodes.h b/drivers/staging/benet/fwcmd_opcodes.h
deleted file mode 100644
index 23d569386b46..000000000000
--- a/drivers/staging/benet/fwcmd_opcodes.h
+++ /dev/null
@@ -1,244 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __fwcmd_opcodes_amap_h__
21#define __fwcmd_opcodes_amap_h__
22
23/*
24 * --- FWCMD_SUBSYSTEMS ---
25 * The commands are grouped into the following subsystems. The subsystem
26 * code along with the opcode uniquely identify a particular fwcmd.
27 */
28#define FWCMD_SUBSYSTEM_RSVD (0) /* This subsystem is reserved. It is */
29 /* never used. */
30#define FWCMD_SUBSYSTEM_COMMON (1) /* CMDs in this group are common to
31 * all subsystems. See
32 * COMMON_SUBSYSTEM_OPCODES for opcodes
33 * and Common Host Configuration CMDs
34 * for the FWCMD descriptions.
35 */
36#define FWCMD_SUBSYSTEM_COMMON_ISCSI (2) /* CMDs in this group are */
37 /*
38 * common to Initiator and Target. See
39 * COMMON_ISCSI_SUBSYSTEM_OPCODES and
40 * Common iSCSI Initiator and Target
41 * CMDs for the command descriptions.
42 */
43#define FWCMD_SUBSYSTEM_ETH (3) /* This subsystem is used to
44 execute Ethernet commands. */
45
46#define FWCMD_SUBSYSTEM_TPM (4) /* This subsystem is used
47 to execute TPM commands. */
48#define FWCMD_SUBSYSTEM_PXE_UNDI (5) /* This subsystem is used
49 * to execute PXE
50 * and UNDI specific commands.
51 */
52
53#define FWCMD_SUBSYSTEM_ISCSI_INI (6) /* This subsystem is used to
54 execute ISCSI Initiator
55 specific commands.
56 */
57#define FWCMD_SUBSYSTEM_ISCSI_TGT (7) /* This subsystem is used
58 to execute iSCSI Target
59 specific commands.between
60 PTL and ARM firmware.
61 */
62#define FWCMD_SUBSYSTEM_MILI_PTL (8) /* This subsystem is used to
63 execute iSCSI Target specific
64 commands.between MILI
65 and PTL. */
66#define FWCMD_SUBSYSTEM_MILI_TMD (9) /* This subsystem is used to
67 execute iSCSI Target specific
68 commands between MILI
69 and TMD. */
70#define FWCMD_SUBSYSTEM_PROXY (11) /* This subsystem is used
71 to execute proxied commands
72 within the host at the
73 explicit request of a
74 non priviledged domain.
75 This 'subsystem' is entirely
76 virtual from the controller
77 and firmware perspective as
78 it is implemented in host
79 drivers.
80 */
81
82/*
83 * --- COMMON_SUBSYSTEM_OPCODES ---
84 * These opcodes are common to both networking and storage PCI
85 * functions. They are used to reserve resources and configure
86 * BladeEngine. These opcodes all use the FWCMD_SUBSYSTEM_COMMON
87 * subsystem code.
88 */
89#define OPCODE_COMMON_NTWK_MAC_QUERY (1)
90#define SUBSYSTEM_COMMON_NTWK_MAC_QUERY (1)
91#define SUBSYSTEM_COMMON_NTWK_MAC_SET (1)
92#define SUBSYSTEM_COMMON_NTWK_MULTICAST_SET (1)
93#define SUBSYSTEM_COMMON_NTWK_VLAN_CONFIG (1)
94#define SUBSYSTEM_COMMON_NTWK_LINK_STATUS_QUERY (1)
95#define SUBSYSTEM_COMMON_READ_FLASHROM (1)
96#define SUBSYSTEM_COMMON_WRITE_FLASHROM (1)
97#define SUBSYSTEM_COMMON_QUERY_MAX_FWCMD_BUFFER_SIZE (1)
98#define SUBSYSTEM_COMMON_ADD_PAGE_TABLES (1)
99#define SUBSYSTEM_COMMON_REMOVE_PAGE_TABLES (1)
100#define SUBSYSTEM_COMMON_RING_DESTROY (1)
101#define SUBSYSTEM_COMMON_CQ_CREATE (1)
102#define SUBSYSTEM_COMMON_EQ_CREATE (1)
103#define SUBSYSTEM_COMMON_ETH_RX_CREATE (1)
104#define SUBSYSTEM_COMMON_ETH_TX_CREATE (1)
105#define SUBSYSTEM_COMMON_ISCSI_DEFQ_CREATE (1)
106#define SUBSYSTEM_COMMON_ISCSI_WRBQ_CREATE (1)
107#define SUBSYSTEM_COMMON_MCC_CREATE (1)
108#define SUBSYSTEM_COMMON_JELL_CONFIG (1)
109#define SUBSYSTEM_COMMON_FORCE_FAILOVER (1)
110#define SUBSYSTEM_COMMON_ADD_TEMPLATE_HEADER_BUFFERS (1)
111#define SUBSYSTEM_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS (1)
112#define SUBSYSTEM_COMMON_POST_ZERO_BUFFER (1)
113#define SUBSYSTEM_COMMON_GET_QOS (1)
114#define SUBSYSTEM_COMMON_SET_QOS (1)
115#define SUBSYSTEM_COMMON_TCP_GET_STATISTICS (1)
116#define SUBSYSTEM_COMMON_SEEPROM_READ (1)
117#define SUBSYSTEM_COMMON_TCP_STATE_QUERY (1)
118#define SUBSYSTEM_COMMON_GET_CNTL_ATTRIBUTES (1)
119#define SUBSYSTEM_COMMON_NOP (1)
120#define SUBSYSTEM_COMMON_NTWK_RX_FILTER (1)
121#define SUBSYSTEM_COMMON_GET_FW_VERSION (1)
122#define SUBSYSTEM_COMMON_SET_FLOW_CONTROL (1)
123#define SUBSYSTEM_COMMON_GET_FLOW_CONTROL (1)
124#define SUBSYSTEM_COMMON_SET_TCP_PARAMETERS (1)
125#define SUBSYSTEM_COMMON_SET_FRAME_SIZE (1)
126#define SUBSYSTEM_COMMON_GET_FAT (1)
127#define SUBSYSTEM_COMMON_MODIFY_EQ_DELAY (1)
128#define SUBSYSTEM_COMMON_FIRMWARE_CONFIG (1)
129#define SUBSYSTEM_COMMON_ENABLE_DISABLE_DOMAINS (1)
130#define SUBSYSTEM_COMMON_GET_DOMAIN_CONFIG (1)
131#define SUBSYSTEM_COMMON_SET_VLD_CONFIG (1)
132#define SUBSYSTEM_COMMON_GET_VLD_CONFIG (1)
133#define SUBSYSTEM_COMMON_GET_PORT_EQUALIZATION (1)
134#define SUBSYSTEM_COMMON_SET_PORT_EQUALIZATION (1)
135#define SUBSYSTEM_COMMON_RED_CONFIG (1)
136#define OPCODE_COMMON_NTWK_MAC_SET (2)
137#define OPCODE_COMMON_NTWK_MULTICAST_SET (3)
138#define OPCODE_COMMON_NTWK_VLAN_CONFIG (4)
139#define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY (5)
140#define OPCODE_COMMON_READ_FLASHROM (6)
141#define OPCODE_COMMON_WRITE_FLASHROM (7)
142#define OPCODE_COMMON_QUERY_MAX_FWCMD_BUFFER_SIZE (8)
143#define OPCODE_COMMON_ADD_PAGE_TABLES (9)
144#define OPCODE_COMMON_REMOVE_PAGE_TABLES (10)
145#define OPCODE_COMMON_RING_DESTROY (11)
146#define OPCODE_COMMON_CQ_CREATE (12)
147#define OPCODE_COMMON_EQ_CREATE (13)
148#define OPCODE_COMMON_ETH_RX_CREATE (14)
149#define OPCODE_COMMON_ETH_TX_CREATE (15)
150#define OPCODE_COMMON_NET_RESERVED0 (16) /* Reserved */
151#define OPCODE_COMMON_NET_RESERVED1 (17) /* Reserved */
152#define OPCODE_COMMON_NET_RESERVED2 (18) /* Reserved */
153#define OPCODE_COMMON_ISCSI_DEFQ_CREATE (19)
154#define OPCODE_COMMON_ISCSI_WRBQ_CREATE (20)
155#define OPCODE_COMMON_MCC_CREATE (21)
156#define OPCODE_COMMON_JELL_CONFIG (22)
157#define OPCODE_COMMON_FORCE_FAILOVER (23)
158#define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS (24)
159#define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS (25)
160#define OPCODE_COMMON_POST_ZERO_BUFFER (26)
161#define OPCODE_COMMON_GET_QOS (27)
162#define OPCODE_COMMON_SET_QOS (28)
163#define OPCODE_COMMON_TCP_GET_STATISTICS (29)
164#define OPCODE_COMMON_SEEPROM_READ (30)
165#define OPCODE_COMMON_TCP_STATE_QUERY (31)
166#define OPCODE_COMMON_GET_CNTL_ATTRIBUTES (32)
167#define OPCODE_COMMON_NOP (33)
168#define OPCODE_COMMON_NTWK_RX_FILTER (34)
169#define OPCODE_COMMON_GET_FW_VERSION (35)
170#define OPCODE_COMMON_SET_FLOW_CONTROL (36)
171#define OPCODE_COMMON_GET_FLOW_CONTROL (37)
172#define OPCODE_COMMON_SET_TCP_PARAMETERS (38)
173#define OPCODE_COMMON_SET_FRAME_SIZE (39)
174#define OPCODE_COMMON_GET_FAT (40)
175#define OPCODE_COMMON_MODIFY_EQ_DELAY (41)
176#define OPCODE_COMMON_FIRMWARE_CONFIG (42)
177#define OPCODE_COMMON_ENABLE_DISABLE_DOMAINS (43)
178#define OPCODE_COMMON_GET_DOMAIN_CONFIG (44)
179#define OPCODE_COMMON_SET_VLD_CONFIG (45)
180#define OPCODE_COMMON_GET_VLD_CONFIG (46)
181#define OPCODE_COMMON_GET_PORT_EQUALIZATION (47)
182#define OPCODE_COMMON_SET_PORT_EQUALIZATION (48)
183#define OPCODE_COMMON_RED_CONFIG (49)
184
185
186
187/*
188 * --- ETH_SUBSYSTEM_OPCODES ---
189 * These opcodes are used for configuring the Ethernet interfaces. These
190 * opcodes all use the FWCMD_SUBSYSTEM_ETH subsystem code.
191 */
192#define OPCODE_ETH_RSS_CONFIG (1)
193#define OPCODE_ETH_ACPI_CONFIG (2)
194#define SUBSYSTEM_ETH_RSS_CONFIG (3)
195#define SUBSYSTEM_ETH_ACPI_CONFIG (3)
196#define OPCODE_ETH_PROMISCUOUS (3)
197#define SUBSYSTEM_ETH_PROMISCUOUS (3)
198#define SUBSYSTEM_ETH_GET_STATISTICS (3)
199#define SUBSYSTEM_ETH_GET_RX_FRAG_SIZE (3)
200#define SUBSYSTEM_ETH_SET_RX_FRAG_SIZE (3)
201#define OPCODE_ETH_GET_STATISTICS (4)
202#define OPCODE_ETH_GET_RX_FRAG_SIZE (5)
203#define OPCODE_ETH_SET_RX_FRAG_SIZE (6)
204
205
206
207
208
209/*
210 * --- MCC_STATUS_CODE ---
211 * These are the global status codes used by all subsystems
212 */
213#define MCC_STATUS_SUCCESS (0) /* Indicates a successful
214 completion of the command */
215#define MCC_STATUS_INSUFFICIENT_PRIVILEGES (1) /* The client does not have
216 sufficient privileges to
217 execute the command */
218#define MCC_STATUS_INVALID_PARAMETER (2) /* A parameter in the command
219 was invalid. The extended
220 status contains the index
221 of the parameter */
222#define MCC_STATUS_INSUFFICIENT_RESOURCES (3) /* There are insufficient
223 chip resources to execute
224 the command */
225#define MCC_STATUS_QUEUE_FLUSHING (4) /* The command is completing
226 because the queue was
227 getting flushed */
228#define MCC_STATUS_DMA_FAILED (5) /* The command is completing
229 with a DMA error */
230
231/*
232 * --- MGMT_ERROR_CODES ---
233 * Error Codes returned in the status field of the FWCMD response header
234 */
235#define MGMT_STATUS_SUCCESS (0) /* The FWCMD completed
236 without errors */
237#define MGMT_STATUS_FAILED (1) /* Error status in the Status
238 field of the
239 struct FWCMD_RESPONSE_HEADER */
240#define MGMT_STATUS_ILLEGAL_REQUEST (2) /* Invalid FWCMD opcode */
241#define MGMT_STATUS_ILLEGAL_FIELD (3) /* Invalid parameter in
242 the FWCMD payload */
243
244#endif /* __fwcmd_opcodes_amap_h__ */
diff --git a/drivers/staging/benet/fwcmd_types_bmap.h b/drivers/staging/benet/fwcmd_types_bmap.h
deleted file mode 100644
index 92217aff3a16..000000000000
--- a/drivers/staging/benet/fwcmd_types_bmap.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __fwcmd_types_bmap_h__
21#define __fwcmd_types_bmap_h__
22
23/* MAC address format */
24struct MAC_ADDRESS_FORMAT {
25 u16 SizeOfStructure;
26 u8 MACAddress[6];
27} __packed;
28
29#endif /* __fwcmd_types_bmap_h__ */
diff --git a/drivers/staging/benet/host_struct.h b/drivers/staging/benet/host_struct.h
deleted file mode 100644
index 3de6722b980f..000000000000
--- a/drivers/staging/benet/host_struct.h
+++ /dev/null
@@ -1,182 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __host_struct_amap_h__
21#define __host_struct_amap_h__
22#include "be_cm.h"
23#include "be_common.h"
24#include "descriptors.h"
25
26/* --- EQ_COMPLETION_MAJOR_CODE_ENUM --- */
27#define EQ_MAJOR_CODE_COMPLETION (0) /* Completion event on a */
28 /* qcompletion ueue. */
29#define EQ_MAJOR_CODE_ETH (1) /* Affiliated Ethernet Event. */
30#define EQ_MAJOR_CODE_RESERVED (2) /* Reserved */
31#define EQ_MAJOR_CODE_RDMA (3) /* Affiliated RDMA Event. */
32#define EQ_MAJOR_CODE_ISCSI (4) /* Affiliated ISCSI Event */
33#define EQ_MAJOR_CODE_UNAFFILIATED (5) /* Unaffiliated Event */
34
35/* --- EQ_COMPLETION_MINOR_CODE_ENUM --- */
36#define EQ_MINOR_CODE_COMPLETION (0) /* Completion event on a */
37 /* completion queue. */
38#define EQ_MINOR_CODE_OTHER (1) /* Other Event (TBD). */
39
40/* Queue Entry Definition for all 4 byte event queue types. */
41struct BE_EQ_ENTRY_AMAP {
42 u8 Valid; /* DWORD 0 */
43 u8 MajorCode[3]; /* DWORD 0 */
44 u8 MinorCode[12]; /* DWORD 0 */
45 u8 ResourceID[16]; /* DWORD 0 */
46} __packed;
47struct EQ_ENTRY_AMAP {
48 u32 dw[1];
49};
50
51/*
52 * --- ETH_EVENT_CODE ---
53 * These codes are returned by the MPU when one of these events has occurred,
54 * and the event is configured to report to an Event Queue when an event
55 * is detected.
56 */
57#define ETH_EQ_LINK_STATUS (0) /* Link status change event */
58 /* detected. */
59#define ETH_EQ_WATERMARK (1) /* watermark event detected. */
60#define ETH_EQ_MAGIC_PKT (2) /* magic pkt event detected. */
61#define ETH_EQ_ACPI_PKT0 (3) /* ACPI interesting packet */
62 /* detected. */
63#define ETH_EQ_ACPI_PKT1 (3) /* ACPI interesting packet */
64 /* detected. */
65#define ETH_EQ_ACPI_PKT2 (3) /* ACPI interesting packet */
66 /* detected. */
67#define ETH_EQ_ACPI_PKT3 (3) /* ACPI interesting packet */
68 /* detected. */
69
70/*
71 * --- ETH_TX_COMPL_STATUS_ENUM ---
72 * Status codes contained in Ethernet TX completion descriptors.
73 */
74#define ETH_COMP_VALID (0)
75#define ETH_COMP_ERROR (1)
76#define ETH_COMP_INVALID (15)
77
78/*
79 * --- ETH_TX_COMPL_PORT_ENUM ---
80 * Port indicator contained in Ethernet TX completion descriptors.
81 */
82#define ETH_COMP_PORT0 (0)
83#define ETH_COMP_PORT1 (1)
84#define ETH_COMP_MGMT (2)
85
86/*
87 * --- ETH_TX_COMPL_CT_ENUM ---
88 * Completion type indicator contained in Ethernet TX completion descriptors.
89 */
90#define ETH_COMP_ETH (0)
91
92/*
93 * Work request block that the driver issues to the chip for
94 * Ethernet transmissions. All control fields must be valid in each WRB for
95 * a message. The controller, as specified by the flags, optionally writes
96 * an entry to the Completion Ring and generate an event.
97 */
98struct BE_ETH_WRB_AMAP {
99 u8 frag_pa_hi[32]; /* DWORD 0 */
100 u8 frag_pa_lo[32]; /* DWORD 1 */
101 u8 complete; /* DWORD 2 */
102 u8 event; /* DWORD 2 */
103 u8 crc; /* DWORD 2 */
104 u8 forward; /* DWORD 2 */
105 u8 ipsec; /* DWORD 2 */
106 u8 mgmt; /* DWORD 2 */
107 u8 ipcs; /* DWORD 2 */
108 u8 udpcs; /* DWORD 2 */
109 u8 tcpcs; /* DWORD 2 */
110 u8 lso; /* DWORD 2 */
111 u8 last; /* DWORD 2 */
112 u8 vlan; /* DWORD 2 */
113 u8 dbg[3]; /* DWORD 2 */
114 u8 hash_val[3]; /* DWORD 2 */
115 u8 lso_mss[14]; /* DWORD 2 */
116 u8 frag_len[16]; /* DWORD 3 */
117 u8 vlan_tag[16]; /* DWORD 3 */
118} __packed;
119struct ETH_WRB_AMAP {
120 u32 dw[4];
121};
122
123/* This is an Ethernet transmit completion descriptor */
124struct BE_ETH_TX_COMPL_AMAP {
125 u8 user_bytes[16]; /* DWORD 0 */
126 u8 nwh_bytes[8]; /* DWORD 0 */
127 u8 lso; /* DWORD 0 */
128 u8 rsvd0[7]; /* DWORD 0 */
129 u8 wrb_index[16]; /* DWORD 1 */
130 u8 ct[2]; /* DWORD 1 */
131 u8 port[2]; /* DWORD 1 */
132 u8 rsvd1[8]; /* DWORD 1 */
133 u8 status[4]; /* DWORD 1 */
134 u8 rsvd2[16]; /* DWORD 2 */
135 u8 ringid[11]; /* DWORD 2 */
136 u8 hash_val[4]; /* DWORD 2 */
137 u8 valid; /* DWORD 2 */
138 u8 rsvd3[32]; /* DWORD 3 */
139} __packed;
140struct ETH_TX_COMPL_AMAP {
141 u32 dw[4];
142};
143
144/* Ethernet Receive Buffer descriptor */
145struct BE_ETH_RX_D_AMAP {
146 u8 fragpa_hi[32]; /* DWORD 0 */
147 u8 fragpa_lo[32]; /* DWORD 1 */
148} __packed;
149struct ETH_RX_D_AMAP {
150 u32 dw[2];
151};
152
153/* This is an Ethernet Receive Completion Descriptor */
154struct BE_ETH_RX_COMPL_AMAP {
155 u8 vlan_tag[16]; /* DWORD 0 */
156 u8 pktsize[14]; /* DWORD 0 */
157 u8 port; /* DWORD 0 */
158 u8 rsvd0; /* DWORD 0 */
159 u8 err; /* DWORD 1 */
160 u8 rsshp; /* DWORD 1 */
161 u8 ipf; /* DWORD 1 */
162 u8 tcpf; /* DWORD 1 */
163 u8 udpf; /* DWORD 1 */
164 u8 ipcksm; /* DWORD 1 */
165 u8 tcpcksm; /* DWORD 1 */
166 u8 udpcksm; /* DWORD 1 */
167 u8 macdst[6]; /* DWORD 1 */
168 u8 vtp; /* DWORD 1 */
169 u8 vtm; /* DWORD 1 */
170 u8 fragndx[10]; /* DWORD 1 */
171 u8 ct[2]; /* DWORD 1 */
172 u8 ipsec; /* DWORD 1 */
173 u8 numfrags[3]; /* DWORD 1 */
174 u8 rsvd1[31]; /* DWORD 2 */
175 u8 valid; /* DWORD 2 */
176 u8 rsshash[32]; /* DWORD 3 */
177} __packed;
178struct ETH_RX_COMPL_AMAP {
179 u32 dw[4];
180};
181
182#endif /* __host_struct_amap_h__ */
diff --git a/drivers/staging/benet/hwlib.h b/drivers/staging/benet/hwlib.h
deleted file mode 100644
index afedf4dc5903..000000000000
--- a/drivers/staging/benet/hwlib.h
+++ /dev/null
@@ -1,830 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#ifndef __hwlib_h__
18#define __hwlib_h__
19
20#include <linux/module.h>
21#include <linux/io.h>
22#include <linux/list.h>
23#include <linux/spinlock.h>
24
25#include "regmap.h" /* srcgen array map output */
26
27#include "asyncmesg.h"
28#include "fwcmd_opcodes.h"
29#include "post_codes.h"
30#include "fwcmd_mcc.h"
31
32#include "fwcmd_types_bmap.h"
33#include "fwcmd_common_bmap.h"
34#include "fwcmd_eth_bmap.h"
35#include "bestatus.h"
36/*
37 *
38 * Macros for reading/writing a protection domain or CSR registers
39 * in BladeEngine.
40 */
41#define PD_READ(fo, field) ioread32((fo)->db_va + \
42 offsetof(struct BE_PROTECTION_DOMAIN_DBMAP_AMAP, field)/8)
43
44#define PD_WRITE(fo, field, val) iowrite32(val, (fo)->db_va + \
45 offsetof(struct BE_PROTECTION_DOMAIN_DBMAP_AMAP, field)/8)
46
47#define CSR_READ(fo, field) ioread32((fo)->csr_va + \
48 offsetof(struct BE_BLADE_ENGINE_CSRMAP_AMAP, field)/8)
49
50#define CSR_WRITE(fo, field, val) iowrite32(val, (fo)->csr_va + \
51 offsetof(struct BE_BLADE_ENGINE_CSRMAP_AMAP, field)/8)
52
53#define PCICFG0_READ(fo, field) ioread32((fo)->pci_va + \
54 offsetof(struct BE_PCICFG0_CSRMAP_AMAP, field)/8)
55
56#define PCICFG0_WRITE(fo, field, val) iowrite32(val, (fo)->pci_va + \
57 offsetof(struct BE_PCICFG0_CSRMAP_AMAP, field)/8)
58
59#define PCICFG1_READ(fo, field) ioread32((fo)->pci_va + \
60 offsetof(struct BE_PCICFG1_CSRMAP_AMAP, field)/8)
61
62#define PCICFG1_WRITE(fo, field, val) iowrite32(val, (fo)->pci_va + \
63 offsetof(struct BE_PCICFG1_CSRMAP_AMAP, field)/8)
64
65#ifdef BE_DEBUG
66#define ASSERT(c) BUG_ON(!(c));
67#else
68#define ASSERT(c)
69#endif
70
71/* debug levels */
72enum BE_DEBUG_LEVELS {
73 DL_ALWAYS = 0, /* cannot be masked */
74 DL_ERR = 0x1, /* errors that should never happen */
75 DL_WARN = 0x2, /* something questionable.
76 recoverable errors */
77 DL_NOTE = 0x4, /* infrequent, important debug info */
78 DL_INFO = 0x8, /* debug information */
79 DL_VERBOSE = 0x10, /* detailed info, such as buffer traces */
80 BE_DL_MIN_VALUE = 0x1, /* this is the min value used */
81 BE_DL_MAX_VALUE = 0x80 /* this is the higheset value used */
82} ;
83
84extern unsigned int trace_level;
85
86#define TRACE(lm, fmt, args...) { \
87 if (trace_level & lm) { \
88 printk(KERN_NOTICE "BE: %s:%d \n" fmt, \
89 __FILE__ , __LINE__ , ## args); \
90 } \
91 }
92
93static inline unsigned int be_trace_set_level(unsigned int level)
94{
95 unsigned int old_level = trace_level;
96 trace_level = level;
97 return old_level;
98}
99
100#define be_trace_get_level() trace_level
101/*
102 * Returns number of pages spanned by the size of data
103 * starting at the given address.
104 */
105#define PAGES_SPANNED(_address, _size) \
106 ((u32)((((size_t)(_address) & (PAGE_SIZE - 1)) + \
107 (_size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
108/* Byte offset into the page corresponding to given address */
109#define OFFSET_IN_PAGE(_addr_) ((size_t)(_addr_) & (PAGE_SIZE-1))
110
111/*
112 * circular subtract.
113 * Returns a - b assuming a circular number system, where a and b are
114 * in range (0, maxValue-1). If a==b, zero is returned so the
115 * highest value possible with this subtraction is maxValue-1.
116 */
117static inline u32 be_subc(u32 a, u32 b, u32 max)
118{
119 ASSERT(a <= max && b <= max);
120 ASSERT(max > 0);
121 return a >= b ? (a - b) : (max - b + a);
122}
123
124static inline u32 be_addc(u32 a, u32 b, u32 max)
125{
126 ASSERT(a < max);
127 ASSERT(max > 0);
128 return (max - a > b) ? (a + b) : (b + a - max);
129}
130
131/* descriptor for a physically contiguous memory used for ring */
132struct ring_desc {
133 u32 length; /* length in bytes */
134 void *va; /* virtual address */
135 u64 pa; /* bus address */
136} ;
137
138/*
139 * This structure stores information about a ring shared between hardware
140 * and software. Each ring is allocated by the driver in the uncached
141 * extension and mapped into BladeEngine's unified table.
142 */
143struct mp_ring {
144 u32 pages; /* queue size in pages */
145 u32 id; /* queue id assigned by beklib */
146 u32 num; /* number of elements in queue */
147 u32 cidx; /* consumer index */
148 u32 pidx; /* producer index -- not used by most rings */
149 u32 itemSize; /* size in bytes of one object */
150
151 void *va; /* The virtual address of the ring.
152 This should be last to allow 32 & 64
153 bit debugger extensions to work. */
154} ;
155
156/*----------- amap bit filed get / set macros and functions -----*/
157/*
158 * Structures defined in the map header files (under fw/amap/) with names
159 * in the format BE_<name>_AMAP are pseudo structures with members
160 * of type u8. These structures are templates that are used in
161 * conjuntion with the structures with names in the format
162 * <name>_AMAP to calculate the bit masks and bit offsets to get or set
163 * bit fields in structures. The structures <name>_AMAP are arrays
164 * of 32 bits words and have the correct size. The following macros
165 * provide convenient ways to get and set the various members
166 * in the structures without using strucctures with bit fields.
167 * Always use the macros AMAP_GET_BITS_PTR and AMAP_SET_BITS_PTR
168 * macros to extract and set various members.
169 */
170
171/*
172 * Returns the a bit mask for the register that is NOT shifted into location.
173 * That means return values always look like: 0x1, 0xFF, 0x7FF, etc...
174 */
175static inline u32 amap_mask(u32 bit_size)
176{
177 return bit_size == 32 ? 0xFFFFFFFF : (1 << bit_size) - 1;
178}
179
180#define AMAP_BIT_MASK(_struct_, field) \
181 amap_mask(AMAP_BIT_SIZE(_struct_, field))
182
183/*
184 * non-optimized set bits function. First clears the bits and then assigns them.
185 * This does not require knowledge of the particular DWORD you are setting.
186 * e.g. AMAP_SET_BITS_PTR (struct, field1, &contextMemory, 123);
187 */
188static inline void
189amap_set(void *ptr, u32 dw_offset, u32 mask, u32 offset, u32 value)
190{
191 u32 *dw = (u32 *)ptr;
192 *(dw + dw_offset) &= ~(mask << offset);
193 *(dw + dw_offset) |= (mask & value) << offset;
194}
195
196#define AMAP_SET_BITS_PTR(_struct_, field, _structPtr_, val) \
197 amap_set(_structPtr_, AMAP_WORD_OFFSET(_struct_, field),\
198 AMAP_BIT_MASK(_struct_, field), \
199 AMAP_BIT_OFFSET(_struct_, field), val)
200/*
201 * Non-optimized routine that gets the bits without knowing the correct DWORD.
202 * e.g. fieldValue = AMAP_GET_BITS_PTR (struct, field1, &contextMemory);
203 */
204static inline u32
205amap_get(void *ptr, u32 dw_offset, u32 mask, u32 offset)
206{
207 u32 *dw = (u32 *)ptr;
208 return mask & (*(dw + dw_offset) >> offset);
209}
210#define AMAP_GET_BITS_PTR(_struct_, field, _structPtr_) \
211 amap_get(_structPtr_, AMAP_WORD_OFFSET(_struct_, field), \
212 AMAP_BIT_MASK(_struct_, field), \
213 AMAP_BIT_OFFSET(_struct_, field))
214
215/* Returns 0-31 representing bit offset within a DWORD of a bitfield. */
216#define AMAP_BIT_OFFSET(_struct_, field) \
217 (offsetof(struct BE_ ## _struct_ ## _AMAP, field) % 32)
218
219/* Returns 0-n representing DWORD offset of bitfield within the structure. */
220#define AMAP_WORD_OFFSET(_struct_, field) \
221 (offsetof(struct BE_ ## _struct_ ## _AMAP, field)/32)
222
223/* Returns size of bitfield in bits. */
224#define AMAP_BIT_SIZE(_struct_, field) \
225 sizeof(((struct BE_ ## _struct_ ## _AMAP*)0)->field)
226
227struct be_mcc_wrb_response_copy {
228 u16 length; /* bytes in response */
229 u16 fwcmd_offset; /* offset within the wrb of the response */
230 void *va; /* user's va to copy response into */
231
232} ;
233typedef void (*mcc_wrb_cqe_callback) (void *context, int status,
234 struct MCC_WRB_AMAP *optional_wrb);
235struct be_mcc_wrb_context {
236
237 mcc_wrb_cqe_callback internal_cb; /* Function to call on
238 completion */
239 void *internal_cb_context; /* Parameter to pass
240 to completion function */
241
242 mcc_wrb_cqe_callback cb; /* Function to call on completion */
243 void *cb_context; /* Parameter to pass to completion function */
244
245 int *users_final_status; /* pointer to a local
246 variable for synchronous
247 commands */
248 struct MCC_WRB_AMAP *wrb; /* pointer to original wrb for embedded
249 commands only */
250 struct list_head next; /* links context structs together in
251 free list */
252
253 struct be_mcc_wrb_response_copy copy; /* Optional parameters to copy
254 embedded response to user's va */
255
256#if defined(BE_DEBUG)
257 u16 subsystem, opcode; /* Track this FWCMD for debug builds. */
258 struct MCC_WRB_AMAP *ring_wrb;
259 u32 consumed_count;
260#endif
261} ;
262
263/*
264 Represents a function object for network or storage. This
265 is used to manage per-function resources like MCC CQs, etc.
266*/
267struct be_function_object {
268
269 u32 magic; /*!< magic for detecting memory corruption. */
270
271 /* PCI BAR mapped addresses */
272 u8 __iomem *csr_va; /* CSR */
273 u8 __iomem *db_va; /* Door Bell */
274 u8 __iomem *pci_va; /* PCI config space */
275 u32 emulate; /* if set, MPU is not available.
276 Emulate everything. */
277 u32 pend_queue_driving; /* if set, drive the queued WRBs
278 after releasing the WRB lock */
279
280 spinlock_t post_lock; /* lock for verifying one thread posting wrbs */
281 spinlock_t cq_lock; /* lock for verifying one thread
282 processing cq */
283 spinlock_t mcc_context_lock; /* lock for protecting mcc
284 context free list */
285 unsigned long post_irq;
286 unsigned long cq_irq;
287
288 u32 type;
289 u32 pci_function_number;
290
291 struct be_mcc_object *mcc; /* mcc rings. */
292
293 struct {
294 struct MCC_MAILBOX_AMAP *va; /* VA to the mailbox */
295 u64 pa; /* PA to the mailbox */
296 u32 length; /* byte length of mailbox */
297
298 /* One default context struct used for posting at
299 * least one MCC_WRB
300 */
301 struct be_mcc_wrb_context default_context;
302 bool default_context_allocated;
303 } mailbox;
304
305 struct {
306
307 /* Wake on lans configured. */
308 u32 wol_bitmask; /* bits 0,1,2,3 are set if
309 corresponding index is enabled */
310 } config;
311
312
313 struct BE_FIRMWARE_CONFIG fw_config;
314} ;
315
316/*
317 Represents an Event Queue
318*/
319struct be_eq_object {
320 u32 magic;
321 atomic_t ref_count;
322
323 struct be_function_object *parent_function;
324
325 struct list_head eq_list;
326 struct list_head cq_list_head;
327
328 u32 eq_id;
329 void *cb_context;
330
331} ;
332
333/*
334 Manages a completion queue
335*/
336struct be_cq_object {
337 u32 magic;
338 atomic_t ref_count;
339
340 struct be_function_object *parent_function;
341 struct be_eq_object *eq_object;
342
343 struct list_head cq_list;
344 struct list_head cqlist_for_eq;
345
346 void *va;
347 u32 num_entries;
348
349 void *cb_context;
350
351 u32 cq_id;
352
353} ;
354
355/*
356 Manages an ethernet send queue
357*/
358struct be_ethsq_object {
359 u32 magic;
360
361 struct list_head list;
362
363 struct be_function_object *parent_function;
364 struct be_cq_object *cq_object;
365 u32 bid;
366
367} ;
368
369/*
370@brief
371 Manages an ethernet receive queue
372*/
373struct be_ethrq_object {
374 u32 magic;
375 struct list_head list;
376 struct be_function_object *parent_function;
377 u32 rid;
378 struct be_cq_object *cq_object;
379 struct be_cq_object *rss_cq_object[4];
380
381} ;
382
383/*
384 Manages an MCC
385*/
386typedef void (*mcc_async_event_callback) (void *context, u32 event_code,
387 void *event);
388struct be_mcc_object {
389 u32 magic;
390
391 struct be_function_object *parent_function;
392 struct list_head mcc_list;
393
394 struct be_cq_object *cq_object;
395
396 /* Async event callback for MCC CQ. */
397 mcc_async_event_callback async_cb;
398 void *async_context;
399
400 struct {
401 struct be_mcc_wrb_context *base;
402 u32 num;
403 struct list_head list_head;
404 } wrb_context;
405
406 struct {
407 struct ring_desc *rd;
408 struct mp_ring ring;
409 } sq;
410
411 struct {
412 struct mp_ring ring;
413 } cq;
414
415 u32 processing; /* flag indicating that one thread
416 is processing CQ */
417 u32 rearm; /* doorbell rearm setting to make
418 sure the active processing thread */
419 /* rearms the CQ if any of the threads requested it. */
420
421 struct list_head backlog;
422 u32 backlog_length;
423 u32 driving_backlog;
424 u32 consumed_index;
425
426} ;
427
428
429/* Queue context header -- the required software information for
430 * queueing a WRB.
431 */
432struct be_queue_driver_context {
433 mcc_wrb_cqe_callback internal_cb; /* Function to call on
434 completion */
435 void *internal_cb_context; /* Parameter to pass
436 to completion function */
437
438 mcc_wrb_cqe_callback cb; /* Function to call on completion */
439 void *cb_context; /* Parameter to pass to completion function */
440
441 struct be_mcc_wrb_response_copy copy; /* Optional parameters to copy
442 embedded response to user's va */
443 void *optional_fwcmd_va;
444 struct list_head list;
445 u32 bytes;
446} ;
447
448/*
449 * Common MCC WRB header that all commands require.
450 */
451struct be_mcc_wrb_header {
452 u8 rsvd[offsetof(struct BE_MCC_WRB_AMAP, payload)/8];
453} ;
454
455/*
456 * All non embedded commands supported by hwlib functions only allow
457 * 1 SGE. This queue context handles them all.
458 */
459struct be_nonembedded_q_ctxt {
460 struct be_queue_driver_context context;
461 struct be_mcc_wrb_header wrb_header;
462 struct MCC_SGE_AMAP sge[1];
463} ;
464
465/*
466 * ------------------------------------------------------------------------
467 * This section contains the specific queue struct for each command.
468 * The user could always provide a be_generic_q_ctxt but this is a
469 * rather large struct. By using the specific struct, memory consumption
470 * can be reduced.
471 * ------------------------------------------------------------------------
472 */
473
474struct be_link_status_q_ctxt {
475 struct be_queue_driver_context context;
476 struct be_mcc_wrb_header wrb_header;
477 struct FWCMD_COMMON_NTWK_LINK_STATUS_QUERY fwcmd;
478} ;
479
480struct be_multicast_q_ctxt {
481 struct be_queue_driver_context context;
482 struct be_mcc_wrb_header wrb_header;
483 struct FWCMD_COMMON_NTWK_MULTICAST_SET fwcmd;
484} ;
485
486
487struct be_vlan_q_ctxt {
488 struct be_queue_driver_context context;
489 struct be_mcc_wrb_header wrb_header;
490 struct FWCMD_COMMON_NTWK_VLAN_CONFIG fwcmd;
491} ;
492
493struct be_promiscuous_q_ctxt {
494 struct be_queue_driver_context context;
495 struct be_mcc_wrb_header wrb_header;
496 struct FWCMD_ETH_PROMISCUOUS fwcmd;
497} ;
498
499struct be_force_failover_q_ctxt {
500 struct be_queue_driver_context context;
501 struct be_mcc_wrb_header wrb_header;
502 struct FWCMD_COMMON_FORCE_FAILOVER fwcmd;
503} ;
504
505
506struct be_rxf_filter_q_ctxt {
507 struct be_queue_driver_context context;
508 struct be_mcc_wrb_header wrb_header;
509 struct FWCMD_COMMON_NTWK_RX_FILTER fwcmd;
510} ;
511
512struct be_eq_modify_delay_q_ctxt {
513 struct be_queue_driver_context context;
514 struct be_mcc_wrb_header wrb_header;
515 struct FWCMD_COMMON_MODIFY_EQ_DELAY fwcmd;
516} ;
517
518/*
519 * The generic context is the largest size that would be required.
520 * It is the software context plus an entire WRB.
521 */
522struct be_generic_q_ctxt {
523 struct be_queue_driver_context context;
524 struct be_mcc_wrb_header wrb_header;
525 struct MCC_WRB_PAYLOAD_AMAP payload;
526} ;
527
528/*
529 * Types for the BE_QUEUE_CONTEXT object.
530 */
531#define BE_QUEUE_INVALID (0)
532#define BE_QUEUE_LINK_STATUS (0xA006)
533#define BE_QUEUE_ETH_STATS (0xA007)
534#define BE_QUEUE_TPM_STATS (0xA008)
535#define BE_QUEUE_TCP_STATS (0xA009)
536#define BE_QUEUE_MULTICAST (0xA00A)
537#define BE_QUEUE_VLAN (0xA00B)
538#define BE_QUEUE_RSS (0xA00C)
539#define BE_QUEUE_FORCE_FAILOVER (0xA00D)
540#define BE_QUEUE_PROMISCUOUS (0xA00E)
541#define BE_QUEUE_WAKE_ON_LAN (0xA00F)
542#define BE_QUEUE_NOP (0xA010)
543
544/* --- BE_FUNCTION_ENUM --- */
545#define BE_FUNCTION_TYPE_ISCSI (0)
546#define BE_FUNCTION_TYPE_NETWORK (1)
547#define BE_FUNCTION_TYPE_ARM (2)
548
549/* --- BE_ETH_TX_RING_TYPE_ENUM --- */
550#define BE_ETH_TX_RING_TYPE_FORWARDING (1) /* Ether ring for forwarding */
551#define BE_ETH_TX_RING_TYPE_STANDARD (2) /* Ether ring for sending */
552 /* network packets. */
553#define BE_ETH_TX_RING_TYPE_BOUND (3) /* Ethernet ring for sending */
554 /* network packets, bound */
555 /* to a physical port. */
556/*
557 * ----------------------------------------------------------------------
558 * API MACROS
559 * ----------------------------------------------------------------------
560 */
561#define BE_FWCMD_NAME(_short_name_) struct FWCMD_##_short_name_
562#define BE_OPCODE_NAME(_short_name_) OPCODE_##_short_name_
563#define BE_SUBSYSTEM_NAME(_short_name_) SUBSYSTEM_##_short_name_
564
565
566#define BE_PREPARE_EMBEDDED_FWCMD(_pfob_, _wrb_, _short_name_) \
567 ((BE_FWCMD_NAME(_short_name_) *) \
568 be_function_prepare_embedded_fwcmd(_pfob_, _wrb_, \
569 sizeof(BE_FWCMD_NAME(_short_name_)), \
570 FIELD_SIZEOF(BE_FWCMD_NAME(_short_name_), params.request), \
571 FIELD_SIZEOF(BE_FWCMD_NAME(_short_name_), params.response), \
572 BE_OPCODE_NAME(_short_name_), \
573 BE_SUBSYSTEM_NAME(_short_name_)));
574
575#define BE_PREPARE_NONEMBEDDED_FWCMD(_pfob_, _wrb_, _iva_, _ipa_, _short_name_)\
576 ((BE_FWCMD_NAME(_short_name_) *) \
577 be_function_prepare_nonembedded_fwcmd(_pfob_, _wrb_, (_iva_), (_ipa_), \
578 sizeof(BE_FWCMD_NAME(_short_name_)), \
579 FIELD_SIZEOF(BE_FWCMD_NAME(_short_name_), params.request), \
580 FIELD_SIZEOF(BE_FWCMD_NAME(_short_name_), params.response), \
581 BE_OPCODE_NAME(_short_name_), \
582 BE_SUBSYSTEM_NAME(_short_name_)));
583
584int be_function_object_create(u8 __iomem *csr_va, u8 __iomem *db_va,
585 u8 __iomem *pci_va, u32 function_type, struct ring_desc *mailbox_rd,
586 struct be_function_object *pfob);
587
588int be_function_object_destroy(struct be_function_object *pfob);
589int be_function_cleanup(struct be_function_object *pfob);
590
591
592int be_function_get_fw_version(struct be_function_object *pfob,
593 struct FWCMD_COMMON_GET_FW_VERSION_RESPONSE_PAYLOAD *fw_version,
594 mcc_wrb_cqe_callback cb, void *cb_context);
595
596
597int be_eq_modify_delay(struct be_function_object *pfob,
598 u32 num_eq, struct be_eq_object **eq_array,
599 u32 *eq_delay_array, mcc_wrb_cqe_callback cb,
600 void *cb_context,
601 struct be_eq_modify_delay_q_ctxt *q_ctxt);
602
603
604
605int be_eq_create(struct be_function_object *pfob,
606 struct ring_desc *rd, u32 eqe_size, u32 num_entries,
607 u32 watermark, u32 timer_delay, struct be_eq_object *eq_object);
608
609int be_eq_destroy(struct be_eq_object *eq);
610
611int be_cq_create(struct be_function_object *pfob,
612 struct ring_desc *rd, u32 length,
613 bool solicited_eventable, bool no_delay,
614 u32 wm_thresh, struct be_eq_object *eq_object,
615 struct be_cq_object *cq_object);
616
617int be_cq_destroy(struct be_cq_object *cq);
618
619int be_mcc_ring_create(struct be_function_object *pfob,
620 struct ring_desc *rd, u32 length,
621 struct be_mcc_wrb_context *context_array,
622 u32 num_context_entries,
623 struct be_cq_object *cq, struct be_mcc_object *mcc);
624int be_mcc_ring_destroy(struct be_mcc_object *mcc_object);
625
626int be_mcc_process_cq(struct be_mcc_object *mcc_object, bool rearm);
627
628int be_mcc_add_async_event_callback(struct be_mcc_object *mcc_object,
629 mcc_async_event_callback cb, void *cb_context);
630
631int be_pci_soft_reset(struct be_function_object *pfob);
632
633
634int be_drive_POST(struct be_function_object *pfob);
635
636
637int be_eth_sq_create(struct be_function_object *pfob,
638 struct ring_desc *rd, u32 length_in_bytes,
639 u32 type, u32 ulp, struct be_cq_object *cq_object,
640 struct be_ethsq_object *eth_sq);
641
642struct be_eth_sq_parameters {
643 u32 port;
644 u32 rsvd0[2];
645} ;
646
647int be_eth_sq_create_ex(struct be_function_object *pfob,
648 struct ring_desc *rd, u32 length_in_bytes,
649 u32 type, u32 ulp, struct be_cq_object *cq_object,
650 struct be_eth_sq_parameters *ex_parameters,
651 struct be_ethsq_object *eth_sq);
652int be_eth_sq_destroy(struct be_ethsq_object *eth_sq);
653
654int be_eth_set_flow_control(struct be_function_object *pfob,
655 bool txfc_enable, bool rxfc_enable);
656
657int be_eth_get_flow_control(struct be_function_object *pfob,
658 bool *txfc_enable, bool *rxfc_enable);
659int be_eth_set_qos(struct be_function_object *pfob, u32 max_bps, u32 max_pps);
660
661int be_eth_get_qos(struct be_function_object *pfob, u32 *max_bps, u32 *max_pps);
662
663int be_eth_set_frame_size(struct be_function_object *pfob,
664 u32 *tx_frame_size, u32 *rx_frame_size);
665
666int be_eth_rq_create(struct be_function_object *pfob,
667 struct ring_desc *rd, struct be_cq_object *cq_object,
668 struct be_cq_object *bcmc_cq_object,
669 struct be_ethrq_object *eth_rq);
670
671int be_eth_rq_destroy(struct be_ethrq_object *eth_rq);
672
673int be_eth_rq_destroy_options(struct be_ethrq_object *eth_rq, bool flush,
674 mcc_wrb_cqe_callback cb, void *cb_context);
675int be_eth_rq_set_frag_size(struct be_function_object *pfob,
676 u32 new_frag_size_bytes, u32 *actual_frag_size_bytes);
677int be_eth_rq_get_frag_size(struct be_function_object *pfob,
678 u32 *frag_size_bytes);
679
680void *be_function_prepare_embedded_fwcmd(struct be_function_object *pfob,
681 struct MCC_WRB_AMAP *wrb,
682 u32 payload_length, u32 request_length,
683 u32 response_length, u32 opcode, u32 subsystem);
684void *be_function_prepare_nonembedded_fwcmd(struct be_function_object *pfob,
685 struct MCC_WRB_AMAP *wrb, void *fwcmd_header_va, u64 fwcmd_header_pa,
686 u32 payload_length, u32 request_length, u32 response_length,
687 u32 opcode, u32 subsystem);
688
689
690struct MCC_WRB_AMAP *
691be_function_peek_mcc_wrb(struct be_function_object *pfob);
692
693int be_rxf_mac_address_read_write(struct be_function_object *pfob,
694 bool port1, bool mac1, bool mgmt,
695 bool write, bool permanent, u8 *mac_address,
696 mcc_wrb_cqe_callback cb,
697 void *cb_context);
698
699int be_rxf_multicast_config(struct be_function_object *pfob,
700 bool promiscuous, u32 num, u8 *mac_table,
701 mcc_wrb_cqe_callback cb,
702 void *cb_context,
703 struct be_multicast_q_ctxt *q_ctxt);
704
705int be_rxf_vlan_config(struct be_function_object *pfob,
706 bool promiscuous, u32 num, u16 *vlan_tag_array,
707 mcc_wrb_cqe_callback cb, void *cb_context,
708 struct be_vlan_q_ctxt *q_ctxt);
709
710
711int be_rxf_link_status(struct be_function_object *pfob,
712 struct BE_LINK_STATUS *link_status,
713 mcc_wrb_cqe_callback cb,
714 void *cb_context,
715 struct be_link_status_q_ctxt *q_ctxt);
716
717
718int be_rxf_query_eth_statistics(struct be_function_object *pfob,
719 struct FWCMD_ETH_GET_STATISTICS *va_for_fwcmd,
720 u64 pa_for_fwcmd, mcc_wrb_cqe_callback cb,
721 void *cb_context,
722 struct be_nonembedded_q_ctxt *q_ctxt);
723
724int be_rxf_promiscuous(struct be_function_object *pfob,
725 bool enable_port0, bool enable_port1,
726 mcc_wrb_cqe_callback cb, void *cb_context,
727 struct be_promiscuous_q_ctxt *q_ctxt);
728
729
730int be_rxf_filter_config(struct be_function_object *pfob,
731 struct NTWK_RX_FILTER_SETTINGS *settings,
732 mcc_wrb_cqe_callback cb,
733 void *cb_context,
734 struct be_rxf_filter_q_ctxt *q_ctxt);
735
736/*
737 * ------------------------------------------------------
738 * internal functions used by hwlib
739 * ------------------------------------------------------
740 */
741
742
743int be_function_ring_destroy(struct be_function_object *pfob,
744 u32 id, u32 ring_type, mcc_wrb_cqe_callback cb,
745 void *cb_context,
746 mcc_wrb_cqe_callback internal_cb,
747 void *internal_callback_context);
748
749int be_function_post_mcc_wrb(struct be_function_object *pfob,
750 struct MCC_WRB_AMAP *wrb,
751 struct be_generic_q_ctxt *q_ctxt,
752 mcc_wrb_cqe_callback cb, void *cb_context,
753 mcc_wrb_cqe_callback internal_cb,
754 void *internal_cb_context, void *optional_fwcmd_va,
755 struct be_mcc_wrb_response_copy *response_copy);
756
757int be_function_queue_mcc_wrb(struct be_function_object *pfob,
758 struct be_generic_q_ctxt *q_ctxt);
759
760/*
761 * ------------------------------------------------------
762 * MCC QUEUE
763 * ------------------------------------------------------
764 */
765
766int be_mpu_init_mailbox(struct be_function_object *pfob, struct ring_desc *rd);
767
768
769struct MCC_WRB_AMAP *
770_be_mpu_peek_ring_wrb(struct be_mcc_object *mcc, bool driving_queue);
771
772struct be_mcc_wrb_context *
773_be_mcc_allocate_wrb_context(struct be_function_object *pfob);
774
775void _be_mcc_free_wrb_context(struct be_function_object *pfob,
776 struct be_mcc_wrb_context *context);
777
778int _be_mpu_post_wrb_mailbox(struct be_function_object *pfob,
779 struct MCC_WRB_AMAP *wrb, struct be_mcc_wrb_context *wrb_context);
780
781int _be_mpu_post_wrb_ring(struct be_mcc_object *mcc,
782 struct MCC_WRB_AMAP *wrb, struct be_mcc_wrb_context *wrb_context);
783
784void be_drive_mcc_wrb_queue(struct be_mcc_object *mcc);
785
786
787/*
788 * ------------------------------------------------------
789 * Ring Sizes
790 * ------------------------------------------------------
791 */
792static inline u32 be_ring_encoding_to_length(u32 encoding, u32 object_size)
793{
794
795 ASSERT(encoding != 1); /* 1 is rsvd */
796 ASSERT(encoding < 16);
797 ASSERT(object_size > 0);
798
799 if (encoding == 0) /* 32k deep */
800 encoding = 16;
801
802 return (1 << (encoding - 1)) * object_size;
803}
804
805static inline
806u32 be_ring_length_to_encoding(u32 length_in_bytes, u32 object_size)
807{
808
809 u32 count, encoding;
810
811 ASSERT(object_size > 0);
812 ASSERT(length_in_bytes % object_size == 0);
813
814 count = length_in_bytes / object_size;
815
816 ASSERT(count > 1);
817 ASSERT(count <= 32 * 1024);
818 ASSERT(length_in_bytes <= 8 * PAGE_SIZE); /* max ring size in UT */
819
820 encoding = __ilog2_u32(count) + 1;
821
822 if (encoding == 16)
823 encoding = 0; /* 32k deep */
824
825 return encoding;
826}
827
828void be_rd_to_pa_list(struct ring_desc *rd, struct PHYS_ADDR *pa_list,
829 u32 max_num);
830#endif /* __hwlib_h__ */
diff --git a/drivers/staging/benet/mpu.c b/drivers/staging/benet/mpu.c
deleted file mode 100644
index 269cc11d3055..000000000000
--- a/drivers/staging/benet/mpu.c
+++ /dev/null
@@ -1,1364 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17#include <linux/delay.h>
18#include "hwlib.h"
19#include "bestatus.h"
20
21static
22inline void mp_ring_create(struct mp_ring *ring, u32 num, u32 size, void *va)
23{
24 ASSERT(ring);
25 memset(ring, 0, sizeof(struct mp_ring));
26 ring->num = num;
27 ring->pages = DIV_ROUND_UP(num * size, PAGE_SIZE);
28 ring->itemSize = size;
29 ring->va = va;
30}
31
32/*
33 * -----------------------------------------------------------------------
34 * Interface for 2 index rings. i.e. consumer/producer rings
35 * --------------------------------------------------------------------------
36 */
37
38/* Returns number items pending on ring. */
39static inline u32 mp_ring_num_pending(struct mp_ring *ring)
40{
41 ASSERT(ring);
42 if (ring->num == 0)
43 return 0;
44 return be_subc(ring->pidx, ring->cidx, ring->num);
45}
46
47/* Returns number items free on ring. */
48static inline u32 mp_ring_num_empty(struct mp_ring *ring)
49{
50 ASSERT(ring);
51 return ring->num - 1 - mp_ring_num_pending(ring);
52}
53
54/* Consume 1 item */
55static inline void mp_ring_consume(struct mp_ring *ring)
56{
57 ASSERT(ring);
58 ASSERT(ring->pidx != ring->cidx);
59
60 ring->cidx = be_addc(ring->cidx, 1, ring->num);
61}
62
63/* Produce 1 item */
64static inline void mp_ring_produce(struct mp_ring *ring)
65{
66 ASSERT(ring);
67 ring->pidx = be_addc(ring->pidx, 1, ring->num);
68}
69
70/* Consume count items */
71static inline void mp_ring_consume_multiple(struct mp_ring *ring, u32 count)
72{
73 ASSERT(ring);
74 ASSERT(mp_ring_num_pending(ring) >= count);
75 ring->cidx = be_addc(ring->cidx, count, ring->num);
76}
77
78static inline void *mp_ring_item(struct mp_ring *ring, u32 index)
79{
80 ASSERT(ring);
81 ASSERT(index < ring->num);
82 ASSERT(ring->itemSize > 0);
83 return (u8 *) ring->va + index * ring->itemSize;
84}
85
86/* Ptr to produce item */
87static inline void *mp_ring_producer_ptr(struct mp_ring *ring)
88{
89 ASSERT(ring);
90 return mp_ring_item(ring, ring->pidx);
91}
92
93/*
94 * Returns a pointer to the current location in the ring.
95 * This is used for rings with 1 index.
96 */
97static inline void *mp_ring_current(struct mp_ring *ring)
98{
99 ASSERT(ring);
100 ASSERT(ring->pidx == 0); /* not used */
101
102 return mp_ring_item(ring, ring->cidx);
103}
104
105/*
106 * Increment index for rings with only 1 index.
107 * This is used for rings with 1 index.
108 */
109static inline void *mp_ring_next(struct mp_ring *ring)
110{
111 ASSERT(ring);
112 ASSERT(ring->num > 0);
113 ASSERT(ring->pidx == 0); /* not used */
114
115 ring->cidx = be_addc(ring->cidx, 1, ring->num);
116 return mp_ring_current(ring);
117}
118
119/*
120 This routine waits for a previously posted mailbox WRB to be completed.
121 Specifically it waits for the mailbox to say that it's ready to accept
122 more data by setting the LSB of the mailbox pd register to 1.
123
124 pcontroller - The function object to post this data to
125
126 IRQL < DISPATCH_LEVEL
127*/
128static void be_mcc_mailbox_wait(struct be_function_object *pfob)
129{
130 struct MPU_MAILBOX_DB_AMAP mailbox_db;
131 u32 i = 0;
132 u32 ready;
133
134 if (pfob->emulate) {
135 /* No waiting for mailbox in emulated mode. */
136 return;
137 }
138
139 mailbox_db.dw[0] = PD_READ(pfob, mcc_bootstrap_db);
140 ready = AMAP_GET_BITS_PTR(MPU_MAILBOX_DB, ready, &mailbox_db);
141
142 while (ready == false) {
143 if ((++i & 0x3FFFF) == 0) {
144 TRACE(DL_WARN, "Waiting for mailbox ready - %dk polls",
145 i / 1000);
146 }
147 udelay(1);
148 mailbox_db.dw[0] = PD_READ(pfob, mcc_bootstrap_db);
149 ready = AMAP_GET_BITS_PTR(MPU_MAILBOX_DB, ready, &mailbox_db);
150 }
151}
152
153/*
154 This routine tells the MCC mailbox that there is data to processed
155 in the mailbox. It does this by setting the physical address for the
156 mailbox location and clearing the LSB. This routine returns immediately
157 and does not wait for the WRB to be processed.
158
159 pcontroller - The function object to post this data to
160
161 IRQL < DISPATCH_LEVEL
162
163*/
164static void be_mcc_mailbox_notify(struct be_function_object *pfob)
165{
166 struct MPU_MAILBOX_DB_AMAP mailbox_db;
167 u32 pa;
168
169 ASSERT(pfob->mailbox.pa);
170 ASSERT(pfob->mailbox.va);
171
172 /* If emulated, do not ring the mailbox */
173 if (pfob->emulate) {
174 TRACE(DL_WARN, "MPU disabled. Skipping mailbox notify.");
175 return;
176 }
177
178 /* form the higher bits in the address */
179 mailbox_db.dw[0] = 0; /* init */
180 AMAP_SET_BITS_PTR(MPU_MAILBOX_DB, hi, &mailbox_db, 1);
181 AMAP_SET_BITS_PTR(MPU_MAILBOX_DB, ready, &mailbox_db, 0);
182
183 /* bits 34 to 63 */
184 pa = (u32) (pfob->mailbox.pa >> 34);
185 AMAP_SET_BITS_PTR(MPU_MAILBOX_DB, address, &mailbox_db, pa);
186
187 /* Wait for the MPU to be ready */
188 be_mcc_mailbox_wait(pfob);
189
190 /* Ring doorbell 1st time */
191 PD_WRITE(pfob, mcc_bootstrap_db, mailbox_db.dw[0]);
192
193 /* Wait for 1st write to be acknowledged. */
194 be_mcc_mailbox_wait(pfob);
195
196 /* lower bits 30 bits from 4th bit (bits 4 to 33)*/
197 pa = (u32) (pfob->mailbox.pa >> 4) & 0x3FFFFFFF;
198
199 AMAP_SET_BITS_PTR(MPU_MAILBOX_DB, hi, &mailbox_db, 0);
200 AMAP_SET_BITS_PTR(MPU_MAILBOX_DB, ready, &mailbox_db, 0);
201 AMAP_SET_BITS_PTR(MPU_MAILBOX_DB, address, &mailbox_db, pa);
202
203 /* Ring doorbell 2nd time */
204 PD_WRITE(pfob, mcc_bootstrap_db, mailbox_db.dw[0]);
205}
206
207/*
208 This routine tells the MCC mailbox that there is data to processed
209 in the mailbox. It does this by setting the physical address for the
210 mailbox location and clearing the LSB. This routine spins until the
211 MPU writes a 1 into the LSB indicating that the data has been received
212 and is ready to be processed.
213
214 pcontroller - The function object to post this data to
215
216 IRQL < DISPATCH_LEVEL
217*/
218static void
219be_mcc_mailbox_notify_and_wait(struct be_function_object *pfob)
220{
221 /*
222 * Notify it
223 */
224 be_mcc_mailbox_notify(pfob);
225 /*
226 * Now wait for completion of WRB
227 */
228 be_mcc_mailbox_wait(pfob);
229}
230
231void
232be_mcc_process_cqe(struct be_function_object *pfob,
233 struct MCC_CQ_ENTRY_AMAP *cqe)
234{
235 struct be_mcc_wrb_context *wrb_context = NULL;
236 u32 offset, status;
237 u8 *p;
238
239 ASSERT(cqe);
240 /*
241 * A command completed. Commands complete out-of-order.
242 * Determine which command completed from the TAG.
243 */
244 offset = offsetof(struct BE_MCC_CQ_ENTRY_AMAP, mcc_tag)/8;
245 p = (u8 *) cqe + offset;
246 wrb_context = (struct be_mcc_wrb_context *)(void *)(size_t)(*(u64 *)p);
247 ASSERT(wrb_context);
248
249 /*
250 * Perform a response copy if requested.
251 * Only copy data if the FWCMD is successful.
252 */
253 status = AMAP_GET_BITS_PTR(MCC_CQ_ENTRY, completion_status, cqe);
254 if (status == MGMT_STATUS_SUCCESS && wrb_context->copy.length > 0) {
255 ASSERT(wrb_context->wrb);
256 ASSERT(wrb_context->copy.va);
257 p = (u8 *)wrb_context->wrb +
258 offsetof(struct BE_MCC_WRB_AMAP, payload)/8;
259 memcpy(wrb_context->copy.va,
260 (u8 *)p + wrb_context->copy.fwcmd_offset,
261 wrb_context->copy.length);
262 }
263
264 if (status)
265 status = BE_NOT_OK;
266 /* internal callback */
267 if (wrb_context->internal_cb) {
268 wrb_context->internal_cb(wrb_context->internal_cb_context,
269 status, wrb_context->wrb);
270 }
271
272 /* callback */
273 if (wrb_context->cb) {
274 wrb_context->cb(wrb_context->cb_context,
275 status, wrb_context->wrb);
276 }
277 /* Free the context structure */
278 _be_mcc_free_wrb_context(pfob, wrb_context);
279}
280
281void be_drive_mcc_wrb_queue(struct be_mcc_object *mcc)
282{
283 struct be_function_object *pfob = NULL;
284 int status = BE_PENDING;
285 struct be_generic_q_ctxt *q_ctxt;
286 struct MCC_WRB_AMAP *wrb;
287 struct MCC_WRB_AMAP *queue_wrb;
288 u32 length, payload_length, sge_count, embedded;
289 unsigned long irql;
290
291 BUILD_BUG_ON((sizeof(struct be_generic_q_ctxt) <
292 sizeof(struct be_queue_driver_context) +
293 sizeof(struct MCC_WRB_AMAP)));
294 pfob = mcc->parent_function;
295
296 spin_lock_irqsave(&pfob->post_lock, irql);
297
298 if (mcc->driving_backlog) {
299 spin_unlock_irqrestore(&pfob->post_lock, irql);
300 if (pfob->pend_queue_driving && pfob->mcc) {
301 pfob->pend_queue_driving = 0;
302 be_drive_mcc_wrb_queue(pfob->mcc);
303 }
304 return;
305 }
306 /* Acquire the flag to limit 1 thread to redrive posts. */
307 mcc->driving_backlog = 1;
308
309 while (!list_empty(&mcc->backlog)) {
310 wrb = _be_mpu_peek_ring_wrb(mcc, true); /* Driving the queue */
311 if (!wrb)
312 break; /* No space in the ring yet. */
313 /* Get the next queued entry to process. */
314 q_ctxt = list_first_entry(&mcc->backlog,
315 struct be_generic_q_ctxt, context.list);
316 list_del(&q_ctxt->context.list);
317 pfob->mcc->backlog_length--;
318 /*
319 * Compute the required length of the WRB.
320 * Since the queue element may be smaller than
321 * the complete WRB, copy only the required number of bytes.
322 */
323 queue_wrb = (struct MCC_WRB_AMAP *) &q_ctxt->wrb_header;
324 embedded = AMAP_GET_BITS_PTR(MCC_WRB, embedded, queue_wrb);
325 if (embedded) {
326 payload_length = AMAP_GET_BITS_PTR(MCC_WRB,
327 payload_length, queue_wrb);
328 length = sizeof(struct be_mcc_wrb_header) +
329 payload_length;
330 } else {
331 sge_count = AMAP_GET_BITS_PTR(MCC_WRB, sge_count,
332 queue_wrb);
333 ASSERT(sge_count == 1); /* only 1 frag. */
334 length = sizeof(struct be_mcc_wrb_header) +
335 sge_count * sizeof(struct MCC_SGE_AMAP);
336 }
337
338 /*
339 * Truncate the length based on the size of the
340 * queue element. Some elements that have output parameters
341 * can be smaller than the payload_length field would
342 * indicate. We really only need to copy the request
343 * parameters, not the response.
344 */
345 length = min(length, (u32) (q_ctxt->context.bytes -
346 offsetof(struct be_generic_q_ctxt, wrb_header)));
347
348 /* Copy the queue element WRB into the ring. */
349 memcpy(wrb, &q_ctxt->wrb_header, length);
350
351 /* Post the wrb. This should not fail assuming we have
352 * enough context structs. */
353 status = be_function_post_mcc_wrb(pfob, wrb, NULL,
354 q_ctxt->context.cb, q_ctxt->context.cb_context,
355 q_ctxt->context.internal_cb,
356 q_ctxt->context.internal_cb_context,
357 q_ctxt->context.optional_fwcmd_va,
358 &q_ctxt->context.copy);
359
360 if (status == BE_SUCCESS) {
361 /*
362 * Synchronous completion. Since it was queued,
363 * we will invoke the callback.
364 * To the user, this is an asynchronous request.
365 */
366 spin_unlock_irqrestore(&pfob->post_lock, irql);
367 if (pfob->pend_queue_driving && pfob->mcc) {
368 pfob->pend_queue_driving = 0;
369 be_drive_mcc_wrb_queue(pfob->mcc);
370 }
371
372 ASSERT(q_ctxt->context.cb);
373
374 q_ctxt->context.cb(
375 q_ctxt->context.cb_context,
376 BE_SUCCESS, NULL);
377
378 spin_lock_irqsave(&pfob->post_lock, irql);
379
380 } else if (status != BE_PENDING) {
381 /*
382 * Another resource failed. Should never happen
383 * if we have sufficient MCC_WRB_CONTEXT structs.
384 * Return to head of the queue.
385 */
386 TRACE(DL_WARN, "Failed to post a queued WRB. 0x%x",
387 status);
388 list_add(&q_ctxt->context.list, &mcc->backlog);
389 pfob->mcc->backlog_length++;
390 break;
391 }
392 }
393
394 /* Free the flag to limit 1 thread to redrive posts. */
395 mcc->driving_backlog = 0;
396 spin_unlock_irqrestore(&pfob->post_lock, irql);
397}
398
399/* This function asserts that the WRB was consumed in order. */
400#ifdef BE_DEBUG
401u32 be_mcc_wrb_consumed_in_order(struct be_mcc_object *mcc,
402 struct MCC_CQ_ENTRY_AMAP *cqe)
403{
404 struct be_mcc_wrb_context *wrb_context = NULL;
405 u32 wrb_index;
406 u32 wrb_consumed_in_order;
407 u32 offset;
408 u8 *p;
409
410 ASSERT(cqe);
411 /*
412 * A command completed. Commands complete out-of-order.
413 * Determine which command completed from the TAG.
414 */
415 offset = offsetof(struct BE_MCC_CQ_ENTRY_AMAP, mcc_tag)/8;
416 p = (u8 *) cqe + offset;
417 wrb_context = (struct be_mcc_wrb_context *)(void *)(size_t)(*(u64 *)p);
418
419 ASSERT(wrb_context);
420
421 wrb_index = (u32) (((u64)(size_t)wrb_context->ring_wrb -
422 (u64)(size_t)mcc->sq.ring.va) / sizeof(struct MCC_WRB_AMAP));
423
424 ASSERT(wrb_index < mcc->sq.ring.num);
425
426 wrb_consumed_in_order = (u32) (wrb_index == mcc->consumed_index);
427 mcc->consumed_index = be_addc(mcc->consumed_index, 1, mcc->sq.ring.num);
428 return wrb_consumed_in_order;
429}
430#endif
431
432int be_mcc_process_cq(struct be_mcc_object *mcc, bool rearm)
433{
434 struct be_function_object *pfob = NULL;
435 struct MCC_CQ_ENTRY_AMAP *cqe;
436 struct CQ_DB_AMAP db;
437 struct mp_ring *cq_ring = &mcc->cq.ring;
438 struct mp_ring *mp_ring = &mcc->sq.ring;
439 u32 num_processed = 0;
440 u32 consumed = 0, valid, completed, cqe_consumed, async_event;
441
442 pfob = mcc->parent_function;
443
444 spin_lock_irqsave(&pfob->cq_lock, pfob->cq_irq);
445
446 /*
447 * Verify that only one thread is processing the CQ at once.
448 * We cannot hold the lock while processing the CQ due to
449 * the callbacks into the OS. Therefore, this flag is used
450 * to control it. If any of the threads want to
451 * rearm the CQ, we need to honor that.
452 */
453 if (mcc->processing != 0) {
454 mcc->rearm = mcc->rearm || rearm;
455 goto Error;
456 } else {
457 mcc->processing = 1; /* lock processing for this thread. */
458 mcc->rearm = rearm; /* set our rearm setting */
459 }
460
461 spin_unlock_irqrestore(&pfob->cq_lock, pfob->cq_irq);
462
463 cqe = mp_ring_current(cq_ring);
464 valid = AMAP_GET_BITS_PTR(MCC_CQ_ENTRY, valid, cqe);
465 while (valid) {
466
467 if (num_processed >= 8) {
468 /* coalesce doorbells, but free space in cq
469 * ring while processing. */
470 db.dw[0] = 0; /* clear */
471 AMAP_SET_BITS_PTR(CQ_DB, qid, &db, cq_ring->id);
472 AMAP_SET_BITS_PTR(CQ_DB, rearm, &db, false);
473 AMAP_SET_BITS_PTR(CQ_DB, event, &db, false);
474 AMAP_SET_BITS_PTR(CQ_DB, num_popped, &db,
475 num_processed);
476 num_processed = 0;
477
478 PD_WRITE(pfob, cq_db, db.dw[0]);
479 }
480
481 async_event = AMAP_GET_BITS_PTR(MCC_CQ_ENTRY, async_event, cqe);
482 if (async_event) {
483 /* This is an asynchronous event. */
484 struct ASYNC_EVENT_TRAILER_AMAP *async_trailer =
485 (struct ASYNC_EVENT_TRAILER_AMAP *)
486 ((u8 *) cqe + sizeof(struct MCC_CQ_ENTRY_AMAP) -
487 sizeof(struct ASYNC_EVENT_TRAILER_AMAP));
488 u32 event_code;
489 async_event = AMAP_GET_BITS_PTR(ASYNC_EVENT_TRAILER,
490 async_event, async_trailer);
491 ASSERT(async_event == 1);
492
493
494 valid = AMAP_GET_BITS_PTR(ASYNC_EVENT_TRAILER,
495 valid, async_trailer);
496 ASSERT(valid == 1);
497
498 /* Call the async event handler if it is installed. */
499 if (mcc->async_cb) {
500 event_code =
501 AMAP_GET_BITS_PTR(ASYNC_EVENT_TRAILER,
502 event_code, async_trailer);
503 mcc->async_cb(mcc->async_context,
504 (u32) event_code, (void *) cqe);
505 }
506
507 } else {
508 /* This is a completion entry. */
509
510 /* No vm forwarding in this driver. */
511
512 cqe_consumed = AMAP_GET_BITS_PTR(MCC_CQ_ENTRY,
513 consumed, cqe);
514 if (cqe_consumed) {
515 /*
516 * A command on the MCC ring was consumed.
517 * Update the consumer index.
518 * These occur in order.
519 */
520 ASSERT(be_mcc_wrb_consumed_in_order(mcc, cqe));
521 consumed++;
522 }
523
524 completed = AMAP_GET_BITS_PTR(MCC_CQ_ENTRY,
525 completed, cqe);
526 if (completed) {
527 /* A command completed. Use tag to
528 * determine which command. */
529 be_mcc_process_cqe(pfob, cqe);
530 }
531 }
532
533 /* Reset the CQE */
534 AMAP_SET_BITS_PTR(MCC_CQ_ENTRY, valid, cqe, false);
535 num_processed++;
536
537 /* Update our tracking for the CQ ring. */
538 cqe = mp_ring_next(cq_ring);
539 valid = AMAP_GET_BITS_PTR(MCC_CQ_ENTRY, valid, cqe);
540 }
541
542 TRACE(DL_INFO, "num_processed:0x%x, and consumed:0x%x",
543 num_processed, consumed);
544 /*
545 * Grab the CQ lock to synchronize the "rearm" setting for
546 * the doorbell, and for clearing the "processing" flag.
547 */
548 spin_lock_irqsave(&pfob->cq_lock, pfob->cq_irq);
549
550 /*
551 * Rearm the cq. This is done based on the global mcc->rearm
552 * flag which combines the rearm parameter from the current
553 * call to process_cq and any other threads
554 * that tried to process the CQ while this one was active.
555 * This handles the situation where a sync. fwcmd was processing
556 * the CQ while the interrupt/dpc tries to process it.
557 * The sync process gets to continue -- but it is now
558 * responsible for the rearming.
559 */
560 if (num_processed > 0 || mcc->rearm == true) {
561 db.dw[0] = 0; /* clear */
562 AMAP_SET_BITS_PTR(CQ_DB, qid, &db, cq_ring->id);
563 AMAP_SET_BITS_PTR(CQ_DB, rearm, &db, mcc->rearm);
564 AMAP_SET_BITS_PTR(CQ_DB, event, &db, false);
565 AMAP_SET_BITS_PTR(CQ_DB, num_popped, &db, num_processed);
566
567 PD_WRITE(pfob, cq_db, db.dw[0]);
568 }
569 /*
570 * Update the consumer index after ringing the CQ doorbell.
571 * We don't want another thread to post more WRBs before we
572 * have CQ space available.
573 */
574 mp_ring_consume_multiple(mp_ring, consumed);
575
576 /* Clear the processing flag. */
577 mcc->processing = 0;
578
579Error:
580 spin_unlock_irqrestore(&pfob->cq_lock, pfob->cq_irq);
581 /*
582 * Use the local variable to detect if the current thread
583 * holds the WRB post lock. If rearm is false, this is
584 * either a synchronous command, or the upper layer driver is polling
585 * from a thread. We do not drive the queue from that
586 * context since the driver may hold the
587 * wrb post lock already.
588 */
589 if (rearm)
590 be_drive_mcc_wrb_queue(mcc);
591 else
592 pfob->pend_queue_driving = 1;
593
594 return BE_SUCCESS;
595}
596
597/*
598 *============================================================================
599 * P U B L I C R O U T I N E S
600 *============================================================================
601 */
602
603/*
604 This routine creates an MCC object. This object contains an MCC send queue
605 and a CQ private to the MCC.
606
607 pcontroller - Handle to a function object
608
609 EqObject - EQ object that will be used to dispatch this MCC
610
611 ppMccObject - Pointer to an internal Mcc Object returned.
612
613 Returns BE_SUCCESS if successfull,, otherwise a useful error code
614 is returned.
615
616 IRQL < DISPATCH_LEVEL
617
618*/
619int
620be_mcc_ring_create(struct be_function_object *pfob,
621 struct ring_desc *rd, u32 length,
622 struct be_mcc_wrb_context *context_array,
623 u32 num_context_entries,
624 struct be_cq_object *cq, struct be_mcc_object *mcc)
625{
626 int status = 0;
627
628 struct FWCMD_COMMON_MCC_CREATE *fwcmd = NULL;
629 struct MCC_WRB_AMAP *wrb = NULL;
630 u32 num_entries_encoded, n, i;
631 void *va = NULL;
632 unsigned long irql;
633
634 if (length < sizeof(struct MCC_WRB_AMAP) * 2) {
635 TRACE(DL_ERR, "Invalid MCC ring length:%d", length);
636 return BE_NOT_OK;
637 }
638 /*
639 * Reduce the actual ring size to be less than the number
640 * of context entries. This ensures that we run out of
641 * ring WRBs first so the queuing works correctly. We never
642 * queue based on context structs.
643 */
644 if (num_context_entries + 1 <
645 length / sizeof(struct MCC_WRB_AMAP) - 1) {
646
647 u32 max_length =
648 (num_context_entries + 2) * sizeof(struct MCC_WRB_AMAP);
649
650 if (is_power_of_2(max_length))
651 length = __roundup_pow_of_two(max_length+1) / 2;
652 else
653 length = __roundup_pow_of_two(max_length) / 2;
654
655 ASSERT(length <= max_length);
656
657 TRACE(DL_WARN,
658 "MCC ring length reduced based on context entries."
659 " length:%d wrbs:%d context_entries:%d", length,
660 (int) (length / sizeof(struct MCC_WRB_AMAP)),
661 num_context_entries);
662 }
663
664 spin_lock_irqsave(&pfob->post_lock, irql);
665
666 num_entries_encoded =
667 be_ring_length_to_encoding(length, sizeof(struct MCC_WRB_AMAP));
668
669 /* Init MCC object. */
670 memset(mcc, 0, sizeof(*mcc));
671 mcc->parent_function = pfob;
672 mcc->cq_object = cq;
673
674 INIT_LIST_HEAD(&mcc->backlog);
675
676 wrb = be_function_peek_mcc_wrb(pfob);
677 if (!wrb) {
678 ASSERT(wrb);
679 TRACE(DL_ERR, "No free MCC WRBs in create EQ.");
680 status = BE_STATUS_NO_MCC_WRB;
681 goto error;
682 }
683 /* Prepares an embedded fwcmd, including request/response sizes. */
684 fwcmd = BE_PREPARE_EMBEDDED_FWCMD(pfob, wrb, COMMON_MCC_CREATE);
685
686 fwcmd->params.request.num_pages = DIV_ROUND_UP(length, PAGE_SIZE);
687 /*
688 * Program MCC ring context
689 */
690 AMAP_SET_BITS_PTR(MCC_RING_CONTEXT, pdid,
691 &fwcmd->params.request.context, 0);
692 AMAP_SET_BITS_PTR(MCC_RING_CONTEXT, invalid,
693 &fwcmd->params.request.context, false);
694 AMAP_SET_BITS_PTR(MCC_RING_CONTEXT, ring_size,
695 &fwcmd->params.request.context, num_entries_encoded);
696
697 n = cq->cq_id;
698 AMAP_SET_BITS_PTR(MCC_RING_CONTEXT,
699 cq_id, &fwcmd->params.request.context, n);
700 be_rd_to_pa_list(rd, fwcmd->params.request.pages,
701 ARRAY_SIZE(fwcmd->params.request.pages));
702 /* Post the f/w command */
703 status = be_function_post_mcc_wrb(pfob, wrb, NULL, NULL, NULL,
704 NULL, NULL, fwcmd, NULL);
705 if (status != BE_SUCCESS) {
706 TRACE(DL_ERR, "MCC to create CQ failed.");
707 goto error;
708 }
709 /*
710 * Create a linked list of context structures
711 */
712 mcc->wrb_context.base = context_array;
713 mcc->wrb_context.num = num_context_entries;
714 INIT_LIST_HEAD(&mcc->wrb_context.list_head);
715 memset(context_array, 0,
716 sizeof(struct be_mcc_wrb_context) * num_context_entries);
717 for (i = 0; i < mcc->wrb_context.num; i++) {
718 list_add_tail(&context_array[i].next,
719 &mcc->wrb_context.list_head);
720 }
721
722 /*
723 *
724 * Create an mcc_ring for tracking WRB hw ring
725 */
726 va = rd->va;
727 ASSERT(va);
728 mp_ring_create(&mcc->sq.ring, length / sizeof(struct MCC_WRB_AMAP),
729 sizeof(struct MCC_WRB_AMAP), va);
730 mcc->sq.ring.id = fwcmd->params.response.id;
731 /*
732 * Init a mcc_ring for tracking the MCC CQ.
733 */
734 ASSERT(cq->va);
735 mp_ring_create(&mcc->cq.ring, cq->num_entries,
736 sizeof(struct MCC_CQ_ENTRY_AMAP), cq->va);
737 mcc->cq.ring.id = cq->cq_id;
738
739 /* Force zeroing of CQ. */
740 memset(cq->va, 0, cq->num_entries * sizeof(struct MCC_CQ_ENTRY_AMAP));
741
742 /* Initialize debug index. */
743 mcc->consumed_index = 0;
744
745 atomic_inc(&cq->ref_count);
746 pfob->mcc = mcc;
747
748 TRACE(DL_INFO, "MCC ring created. id:%d bytes:%d cq_id:%d cq_entries:%d"
749 " num_context:%d", mcc->sq.ring.id, length,
750 cq->cq_id, cq->num_entries, num_context_entries);
751
752error:
753 spin_unlock_irqrestore(&pfob->post_lock, irql);
754 if (pfob->pend_queue_driving && pfob->mcc) {
755 pfob->pend_queue_driving = 0;
756 be_drive_mcc_wrb_queue(pfob->mcc);
757 }
758 return status;
759}
760
761/*
762 This routine destroys an MCC send queue
763
764 MccObject - Internal Mcc Object to be destroyed.
765
766 Returns BE_SUCCESS if successfull, otherwise an error code is returned.
767
768 IRQL < DISPATCH_LEVEL
769
770 The caller of this routine must ensure that no other WRB may be posted
771 until this routine returns.
772
773*/
774int be_mcc_ring_destroy(struct be_mcc_object *mcc)
775{
776 int status = 0;
777 struct be_function_object *pfob = mcc->parent_function;
778
779
780 ASSERT(mcc->processing == 0);
781
782 /*
783 * Remove the ring from the function object.
784 * This transitions back to mailbox mode.
785 */
786 pfob->mcc = NULL;
787
788 /* Send fwcmd to destroy the queue. (Using the mailbox.) */
789 status = be_function_ring_destroy(mcc->parent_function, mcc->sq.ring.id,
790 FWCMD_RING_TYPE_MCC, NULL, NULL, NULL, NULL);
791 ASSERT(status == 0);
792
793 /* Release the SQ reference to the CQ */
794 atomic_dec(&mcc->cq_object->ref_count);
795
796 return status;
797}
798
799static void
800mcc_wrb_sync_cb(void *context, int staus, struct MCC_WRB_AMAP *wrb)
801{
802 struct be_mcc_wrb_context *wrb_context =
803 (struct be_mcc_wrb_context *) context;
804 ASSERT(wrb_context);
805 *wrb_context->users_final_status = staus;
806}
807
808/*
809 This routine posts a command to the MCC send queue
810
811 mcc - Internal Mcc Object to be destroyed.
812
813 wrb - wrb to post.
814
815 Returns BE_SUCCESS if successfull, otherwise an error code is returned.
816
817 IRQL < DISPATCH_LEVEL if CompletionCallback is not NULL
818 IRQL <=DISPATCH_LEVEL if CompletionCallback is NULL
819
820 If this routine is called with CompletionCallback != NULL the
821 call is considered to be asynchronous and will return as soon
822 as the WRB is posted to the MCC with BE_PENDING.
823
824 If CompletionCallback is NULL, then this routine will not return until
825 a completion for this MCC command has been processed.
826 If called at DISPATCH_LEVEL the CompletionCallback must be NULL.
827
828 This routine should only be called if the MPU has been boostraped past
829 mailbox mode.
830
831
832*/
833int
834_be_mpu_post_wrb_ring(struct be_mcc_object *mcc, struct MCC_WRB_AMAP *wrb,
835 struct be_mcc_wrb_context *wrb_context)
836{
837
838 struct MCC_WRB_AMAP *ring_wrb = NULL;
839 int status = BE_PENDING;
840 int final_status = BE_PENDING;
841 mcc_wrb_cqe_callback cb = NULL;
842 struct MCC_DB_AMAP mcc_db;
843 u32 embedded;
844
845 ASSERT(mp_ring_num_empty(&mcc->sq.ring) > 0);
846 /*
847 * Input wrb is most likely the next wrb in the ring, since the client
848 * can peek at the address.
849 */
850 ring_wrb = mp_ring_producer_ptr(&mcc->sq.ring);
851 if (wrb != ring_wrb) {
852 /* If not equal, copy it into the ring. */
853 memcpy(ring_wrb, wrb, sizeof(struct MCC_WRB_AMAP));
854 }
855#ifdef BE_DEBUG
856 wrb_context->ring_wrb = ring_wrb;
857#endif
858 embedded = AMAP_GET_BITS_PTR(MCC_WRB, embedded, ring_wrb);
859 if (embedded) {
860 /* embedded commands will have the response within the WRB. */
861 wrb_context->wrb = ring_wrb;
862 } else {
863 /*
864 * non-embedded commands will not have the response
865 * within the WRB, and they may complete out-of-order.
866 * The WRB will not be valid to inspect
867 * during the completion.
868 */
869 wrb_context->wrb = NULL;
870 }
871 cb = wrb_context->cb;
872
873 if (cb == NULL) {
874 /* Assign our internal callback if this is a
875 * synchronous call. */
876 wrb_context->cb = mcc_wrb_sync_cb;
877 wrb_context->cb_context = wrb_context;
878 wrb_context->users_final_status = &final_status;
879 }
880 /* Increment producer index */
881
882 mcc_db.dw[0] = 0; /* initialize */
883 AMAP_SET_BITS_PTR(MCC_DB, rid, &mcc_db, mcc->sq.ring.id);
884 AMAP_SET_BITS_PTR(MCC_DB, numPosted, &mcc_db, 1);
885
886 mp_ring_produce(&mcc->sq.ring);
887 PD_WRITE(mcc->parent_function, mpu_mcc_db, mcc_db.dw[0]);
888 TRACE(DL_INFO, "pidx: %x and cidx: %x.", mcc->sq.ring.pidx,
889 mcc->sq.ring.cidx);
890
891 if (cb == NULL) {
892 int polls = 0; /* At >= 1 us per poll */
893 /* Wait until this command completes, polling the CQ. */
894 do {
895 TRACE(DL_INFO, "FWCMD submitted in the poll mode.");
896 /* Do not rearm CQ in this context. */
897 be_mcc_process_cq(mcc, false);
898
899 if (final_status == BE_PENDING) {
900 if ((++polls & 0x7FFFF) == 0) {
901 TRACE(DL_WARN,
902 "Warning : polling MCC CQ for %d"
903 "ms.", polls / 1000);
904 }
905
906 udelay(1);
907 }
908
909 /* final_status changed when the command completes */
910 } while (final_status == BE_PENDING);
911
912 status = final_status;
913 }
914
915 return status;
916}
917
918struct MCC_WRB_AMAP *
919_be_mpu_peek_ring_wrb(struct be_mcc_object *mcc, bool driving_queue)
920{
921 /* If we have queued items, do not allow a post to bypass the queue. */
922 if (!driving_queue && !list_empty(&mcc->backlog))
923 return NULL;
924
925 if (mp_ring_num_empty(&mcc->sq.ring) <= 0)
926 return NULL;
927 return (struct MCC_WRB_AMAP *) mp_ring_producer_ptr(&mcc->sq.ring);
928}
929
930int
931be_mpu_init_mailbox(struct be_function_object *pfob, struct ring_desc *mailbox)
932{
933 ASSERT(mailbox);
934 pfob->mailbox.va = mailbox->va;
935 pfob->mailbox.pa = cpu_to_le64(mailbox->pa);
936 pfob->mailbox.length = mailbox->length;
937
938 ASSERT(((u32)(size_t)pfob->mailbox.va & 0xf) == 0);
939 ASSERT(((u32)(size_t)pfob->mailbox.pa & 0xf) == 0);
940 /*
941 * Issue the WRB to set MPU endianness
942 */
943 {
944 u64 *endian_check = (u64 *) (pfob->mailbox.va +
945 offsetof(struct BE_MCC_MAILBOX_AMAP, wrb)/8);
946 *endian_check = 0xFF1234FFFF5678FFULL;
947 }
948
949 be_mcc_mailbox_notify_and_wait(pfob);
950
951 return BE_SUCCESS;
952}
953
954
955/*
956 This routine posts a command to the MCC mailbox.
957
958 FuncObj - Function Object to post the WRB on behalf of.
959 wrb - wrb to post.
960 CompletionCallback - Address of a callback routine to invoke once the WRB
961 is completed.
962 CompletionCallbackContext - Opaque context to be passed during the call to
963 the CompletionCallback.
964 Returns BE_SUCCESS if successfull, otherwise an error code is returned.
965
966 IRQL <=DISPATCH_LEVEL if CompletionCallback is NULL
967
968 This routine will block until a completion for this MCC command has been
969 processed. If called at DISPATCH_LEVEL the CompletionCallback must be NULL.
970
971 This routine should only be called if the MPU has not been boostraped past
972 mailbox mode.
973*/
974int
975_be_mpu_post_wrb_mailbox(struct be_function_object *pfob,
976 struct MCC_WRB_AMAP *wrb, struct be_mcc_wrb_context *wrb_context)
977{
978 struct MCC_MAILBOX_AMAP *mailbox = NULL;
979 struct MCC_WRB_AMAP *mb_wrb;
980 struct MCC_CQ_ENTRY_AMAP *mb_cq;
981 u32 offset, status;
982
983 ASSERT(pfob->mcc == NULL);
984 mailbox = pfob->mailbox.va;
985 ASSERT(mailbox);
986
987 offset = offsetof(struct BE_MCC_MAILBOX_AMAP, wrb)/8;
988 mb_wrb = (struct MCC_WRB_AMAP *) (u8 *)mailbox + offset;
989 if (mb_wrb != wrb) {
990 memset(mailbox, 0, sizeof(*mailbox));
991 memcpy(mb_wrb, wrb, sizeof(struct MCC_WRB_AMAP));
992 }
993 /* The callback can inspect the final WRB to get output parameters. */
994 wrb_context->wrb = mb_wrb;
995
996 be_mcc_mailbox_notify_and_wait(pfob);
997
998 /* A command completed. Use tag to determine which command. */
999 offset = offsetof(struct BE_MCC_MAILBOX_AMAP, cq)/8;
1000 mb_cq = (struct MCC_CQ_ENTRY_AMAP *) ((u8 *)mailbox + offset);
1001 be_mcc_process_cqe(pfob, mb_cq);
1002
1003 status = AMAP_GET_BITS_PTR(MCC_CQ_ENTRY, completion_status, mb_cq);
1004 if (status)
1005 status = BE_NOT_OK;
1006 return status;
1007}
1008
1009struct be_mcc_wrb_context *
1010_be_mcc_allocate_wrb_context(struct be_function_object *pfob)
1011{
1012 struct be_mcc_wrb_context *context = NULL;
1013 unsigned long irq;
1014
1015 spin_lock_irqsave(&pfob->mcc_context_lock, irq);
1016
1017 if (!pfob->mailbox.default_context_allocated) {
1018 /* Use the single default context that we
1019 * always have allocated. */
1020 pfob->mailbox.default_context_allocated = true;
1021 context = &pfob->mailbox.default_context;
1022 } else if (pfob->mcc) {
1023 /* Get a context from the free list. If any are available. */
1024 if (!list_empty(&pfob->mcc->wrb_context.list_head)) {
1025 context = list_first_entry(
1026 &pfob->mcc->wrb_context.list_head,
1027 struct be_mcc_wrb_context, next);
1028 }
1029 }
1030
1031 spin_unlock_irqrestore(&pfob->mcc_context_lock, irq);
1032
1033 return context;
1034}
1035
1036void
1037_be_mcc_free_wrb_context(struct be_function_object *pfob,
1038 struct be_mcc_wrb_context *context)
1039{
1040 unsigned long irq;
1041
1042 ASSERT(context);
1043 /*
1044 * Zero during free to try and catch any bugs where the context
1045 * is accessed after a free.
1046 */
1047 memset(context, 0, sizeof(context));
1048
1049 spin_lock_irqsave(&pfob->mcc_context_lock, irq);
1050
1051 if (context == &pfob->mailbox.default_context) {
1052 /* Free the default context. */
1053 ASSERT(pfob->mailbox.default_context_allocated);
1054 pfob->mailbox.default_context_allocated = false;
1055 } else {
1056 /* Add to free list. */
1057 ASSERT(pfob->mcc);
1058 list_add_tail(&context->next,
1059 &pfob->mcc->wrb_context.list_head);
1060 }
1061
1062 spin_unlock_irqrestore(&pfob->mcc_context_lock, irq);
1063}
1064
1065int
1066be_mcc_add_async_event_callback(struct be_mcc_object *mcc_object,
1067 mcc_async_event_callback cb, void *cb_context)
1068{
1069 /* Lock against anyone trying to change the callback/context pointers
1070 * while being used. */
1071 spin_lock_irqsave(&mcc_object->parent_function->cq_lock,
1072 mcc_object->parent_function->cq_irq);
1073
1074 /* Assign the async callback. */
1075 mcc_object->async_context = cb_context;
1076 mcc_object->async_cb = cb;
1077
1078 spin_unlock_irqrestore(&mcc_object->parent_function->cq_lock,
1079 mcc_object->parent_function->cq_irq);
1080
1081 return BE_SUCCESS;
1082}
1083
1084#define MPU_EP_CONTROL 0
1085#define MPU_EP_SEMAPHORE 0xac
1086
1087/*
1088 *-------------------------------------------------------------------
1089 * Function: be_wait_for_POST_complete
1090 * Waits until the BladeEngine POST completes (either in error or success).
1091 * pfob -
1092 * return status - BE_SUCCESS (0) on success. Negative error code on failure.
1093 *-------------------------------------------------------------------
1094 */
1095static int be_wait_for_POST_complete(struct be_function_object *pfob)
1096{
1097 struct MGMT_HBA_POST_STATUS_STRUCT_AMAP status;
1098 int s;
1099 u32 post_error, post_stage;
1100
1101 const u32 us_per_loop = 1000; /* 1000us */
1102 const u32 print_frequency_loops = 1000000 / us_per_loop;
1103 const u32 max_loops = 60 * print_frequency_loops;
1104 u32 loops = 0;
1105
1106 /*
1107 * Wait for arm fw indicating it is done or a fatal error happened.
1108 * Note: POST can take some time to complete depending on configuration
1109 * settings (consider ARM attempts to acquire an IP address
1110 * over DHCP!!!).
1111 *
1112 */
1113 do {
1114 status.dw[0] = ioread32(pfob->csr_va + MPU_EP_SEMAPHORE);
1115 post_error = AMAP_GET_BITS_PTR(MGMT_HBA_POST_STATUS_STRUCT,
1116 error, &status);
1117 post_stage = AMAP_GET_BITS_PTR(MGMT_HBA_POST_STATUS_STRUCT,
1118 stage, &status);
1119 if (0 == (loops % print_frequency_loops)) {
1120 /* Print current status */
1121 TRACE(DL_INFO, "POST status = 0x%x (stage = 0x%x)",
1122 status.dw[0], post_stage);
1123 }
1124 udelay(us_per_loop);
1125 } while ((post_error != 1) &&
1126 (post_stage != POST_STAGE_ARMFW_READY) &&
1127 (++loops < max_loops));
1128
1129 if (post_error == 1) {
1130 TRACE(DL_ERR, "POST error! Status = 0x%x (stage = 0x%x)",
1131 status.dw[0], post_stage);
1132 s = BE_NOT_OK;
1133 } else if (post_stage != POST_STAGE_ARMFW_READY) {
1134 TRACE(DL_ERR, "POST time-out! Status = 0x%x (stage = 0x%x)",
1135 status.dw[0], post_stage);
1136 s = BE_NOT_OK;
1137 } else {
1138 s = BE_SUCCESS;
1139 }
1140 return s;
1141}
1142
1143/*
1144 *-------------------------------------------------------------------
1145 * Function: be_kickoff_and_wait_for_POST
1146 * Interacts with the BladeEngine management processor to initiate POST, and
1147 * subsequently waits until POST completes (either in error or success).
1148 * The caller must acquire the reset semaphore before initiating POST
1149 * to prevent multiple drivers interacting with the management processor.
1150 * Once POST is complete the caller must release the reset semaphore.
1151 * Callers who only want to wait for POST complete may call
1152 * be_wait_for_POST_complete.
1153 * pfob -
1154 * return status - BE_SUCCESS (0) on success. Negative error code on failure.
1155 *-------------------------------------------------------------------
1156 */
1157static int
1158be_kickoff_and_wait_for_POST(struct be_function_object *pfob)
1159{
1160 struct MGMT_HBA_POST_STATUS_STRUCT_AMAP status;
1161 int s;
1162
1163 const u32 us_per_loop = 1000; /* 1000us */
1164 const u32 print_frequency_loops = 1000000 / us_per_loop;
1165 const u32 max_loops = 5 * print_frequency_loops;
1166 u32 loops = 0;
1167 u32 post_error, post_stage;
1168
1169 /* Wait for arm fw awaiting host ready or a fatal error happened. */
1170 TRACE(DL_INFO, "Wait for BladeEngine ready to POST");
1171 do {
1172 status.dw[0] = ioread32(pfob->csr_va + MPU_EP_SEMAPHORE);
1173 post_error = AMAP_GET_BITS_PTR(MGMT_HBA_POST_STATUS_STRUCT,
1174 error, &status);
1175 post_stage = AMAP_GET_BITS_PTR(MGMT_HBA_POST_STATUS_STRUCT,
1176 stage, &status);
1177 if (0 == (loops % print_frequency_loops)) {
1178 /* Print current status */
1179 TRACE(DL_INFO, "POST status = 0x%x (stage = 0x%x)",
1180 status.dw[0], post_stage);
1181 }
1182 udelay(us_per_loop);
1183 } while ((post_error != 1) &&
1184 (post_stage < POST_STAGE_AWAITING_HOST_RDY) &&
1185 (++loops < max_loops));
1186
1187 if (post_error == 1) {
1188 TRACE(DL_ERR, "Pre-POST error! Status = 0x%x (stage = 0x%x)",
1189 status.dw[0], post_stage);
1190 s = BE_NOT_OK;
1191 } else if (post_stage == POST_STAGE_AWAITING_HOST_RDY) {
1192 iowrite32(POST_STAGE_HOST_RDY, pfob->csr_va + MPU_EP_SEMAPHORE);
1193
1194 /* Wait for POST to complete */
1195 s = be_wait_for_POST_complete(pfob);
1196 } else {
1197 /*
1198 * Either a timeout waiting for host ready signal or POST has
1199 * moved ahead without requiring a host ready signal.
1200 * Might as well give POST a chance to complete
1201 * (or timeout again).
1202 */
1203 s = be_wait_for_POST_complete(pfob);
1204 }
1205 return s;
1206}
1207
1208/*
1209 *-------------------------------------------------------------------
1210 * Function: be_pci_soft_reset
1211 * This function is called to issue a BladeEngine soft reset.
1212 * Callers should acquire the soft reset semaphore before calling this
1213 * function. Additionaly, callers should ensure they cannot be pre-empted
1214 * while the routine executes. Upon completion of this routine, callers
1215 * should release the reset semaphore. This routine implicitly waits
1216 * for BladeEngine POST to complete.
1217 * pfob -
1218 * return status - BE_SUCCESS (0) on success. Negative error code on failure.
1219 *-------------------------------------------------------------------
1220 */
1221int be_pci_soft_reset(struct be_function_object *pfob)
1222{
1223 struct PCICFG_SOFT_RESET_CSR_AMAP soft_reset;
1224 struct PCICFG_ONLINE0_CSR_AMAP pciOnline0;
1225 struct PCICFG_ONLINE1_CSR_AMAP pciOnline1;
1226 struct EP_CONTROL_CSR_AMAP epControlCsr;
1227 int status = BE_SUCCESS;
1228 u32 i, soft_reset_bit;
1229
1230 TRACE(DL_NOTE, "PCI reset...");
1231
1232 /* Issue soft reset #1 to get BladeEngine into a known state. */
1233 soft_reset.dw[0] = PCICFG0_READ(pfob, soft_reset);
1234 AMAP_SET_BITS_PTR(PCICFG_SOFT_RESET_CSR, softreset, soft_reset.dw, 1);
1235 PCICFG0_WRITE(pfob, host_timer_int_ctrl, soft_reset.dw[0]);
1236 /*
1237 * wait til soft reset is deasserted - hardware
1238 * deasserts after some time.
1239 */
1240 i = 0;
1241 do {
1242 udelay(50);
1243 soft_reset.dw[0] = PCICFG0_READ(pfob, soft_reset);
1244 soft_reset_bit = AMAP_GET_BITS_PTR(PCICFG_SOFT_RESET_CSR,
1245 softreset, soft_reset.dw);
1246 } while (soft_reset_bit && (i++ < 1024));
1247 if (soft_reset_bit != 0) {
1248 TRACE(DL_ERR, "Soft-reset #1 did not deassert as expected.");
1249 status = BE_NOT_OK;
1250 goto Error_label;
1251 }
1252 /* Mask everything */
1253 PCICFG0_WRITE(pfob, ue_status_low_mask, 0xFFFFFFFF);
1254 PCICFG0_WRITE(pfob, ue_status_hi_mask, 0xFFFFFFFF);
1255 /*
1256 * Set everything offline except MPU IRAM (it is offline with
1257 * the soft-reset, but soft-reset does not reset the PCICFG registers!)
1258 */
1259 pciOnline0.dw[0] = 0;
1260 pciOnline1.dw[0] = 0;
1261 AMAP_SET_BITS_PTR(PCICFG_ONLINE1_CSR, mpu_iram_online,
1262 pciOnline1.dw, 1);
1263 PCICFG0_WRITE(pfob, online0, pciOnline0.dw[0]);
1264 PCICFG0_WRITE(pfob, online1, pciOnline1.dw[0]);
1265
1266 udelay(20000);
1267
1268 /* Issue soft reset #2. */
1269 AMAP_SET_BITS_PTR(PCICFG_SOFT_RESET_CSR, softreset, soft_reset.dw, 1);
1270 PCICFG0_WRITE(pfob, host_timer_int_ctrl, soft_reset.dw[0]);
1271 /*
1272 * wait til soft reset is deasserted - hardware
1273 * deasserts after some time.
1274 */
1275 i = 0;
1276 do {
1277 udelay(50);
1278 soft_reset.dw[0] = PCICFG0_READ(pfob, soft_reset);
1279 soft_reset_bit = AMAP_GET_BITS_PTR(PCICFG_SOFT_RESET_CSR,
1280 softreset, soft_reset.dw);
1281 } while (soft_reset_bit && (i++ < 1024));
1282 if (soft_reset_bit != 0) {
1283 TRACE(DL_ERR, "Soft-reset #1 did not deassert as expected.");
1284 status = BE_NOT_OK;
1285 goto Error_label;
1286 }
1287
1288
1289 udelay(20000);
1290
1291 /* Take MPU out of reset. */
1292
1293 epControlCsr.dw[0] = ioread32(pfob->csr_va + MPU_EP_CONTROL);
1294 AMAP_SET_BITS_PTR(EP_CONTROL_CSR, CPU_reset, &epControlCsr, 0);
1295 iowrite32((u32)epControlCsr.dw[0], pfob->csr_va + MPU_EP_CONTROL);
1296
1297 /* Kickoff BE POST and wait for completion */
1298 status = be_kickoff_and_wait_for_POST(pfob);
1299
1300Error_label:
1301 return status;
1302}
1303
1304
1305/*
1306 *-------------------------------------------------------------------
1307 * Function: be_pci_reset_required
1308 * This private function is called to detect if a host entity is
1309 * required to issue a PCI soft reset and subsequently drive
1310 * BladeEngine POST. Scenarios where this is required:
1311 * 1) BIOS-less configuration
1312 * 2) Hot-swap/plug/power-on
1313 * pfob -
1314 * return true if a reset is required, false otherwise
1315 *-------------------------------------------------------------------
1316 */
1317static bool be_pci_reset_required(struct be_function_object *pfob)
1318{
1319 struct MGMT_HBA_POST_STATUS_STRUCT_AMAP status;
1320 bool do_reset = false;
1321 u32 post_error, post_stage;
1322
1323 /*
1324 * Read the POST status register
1325 */
1326 status.dw[0] = ioread32(pfob->csr_va + MPU_EP_SEMAPHORE);
1327 post_error = AMAP_GET_BITS_PTR(MGMT_HBA_POST_STATUS_STRUCT, error,
1328 &status);
1329 post_stage = AMAP_GET_BITS_PTR(MGMT_HBA_POST_STATUS_STRUCT, stage,
1330 &status);
1331 if (post_stage <= POST_STAGE_AWAITING_HOST_RDY) {
1332 /*
1333 * If BladeEngine is waiting for host ready indication,
1334 * we want to do a PCI reset.
1335 */
1336 do_reset = true;
1337 }
1338
1339 return do_reset;
1340}
1341
1342/*
1343 *-------------------------------------------------------------------
1344 * Function: be_drive_POST
1345 * This function is called to drive BladeEngine POST. The
1346 * caller should ensure they cannot be pre-empted while this routine executes.
1347 * pfob -
1348 * return status - BE_SUCCESS (0) on success. Negative error code on failure.
1349 *-------------------------------------------------------------------
1350 */
1351int be_drive_POST(struct be_function_object *pfob)
1352{
1353 int status;
1354
1355 if (false != be_pci_reset_required(pfob)) {
1356 /* PCI reset is needed (implicitly starts and waits for POST) */
1357 status = be_pci_soft_reset(pfob);
1358 } else {
1359 /* No PCI reset is needed, start POST */
1360 status = be_kickoff_and_wait_for_POST(pfob);
1361 }
1362
1363 return status;
1364}
diff --git a/drivers/staging/benet/mpu.h b/drivers/staging/benet/mpu.h
deleted file mode 100644
index 41f3f87516e5..000000000000
--- a/drivers/staging/benet/mpu.h
+++ /dev/null
@@ -1,74 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __mpu_amap_h__
21#define __mpu_amap_h__
22#include "ep.h"
23
24/* Provide control parameters for the Managment Processor Unit. */
25struct BE_MPU_CSRMAP_AMAP {
26 struct BE_EP_CSRMAP_AMAP ep;
27 u8 rsvd0[128]; /* DWORD 64 */
28 u8 rsvd1[32]; /* DWORD 68 */
29 u8 rsvd2[192]; /* DWORD 69 */
30 u8 rsvd3[192]; /* DWORD 75 */
31 u8 rsvd4[32]; /* DWORD 81 */
32 u8 rsvd5[32]; /* DWORD 82 */
33 u8 rsvd6[32]; /* DWORD 83 */
34 u8 rsvd7[32]; /* DWORD 84 */
35 u8 rsvd8[32]; /* DWORD 85 */
36 u8 rsvd9[32]; /* DWORD 86 */
37 u8 rsvd10[32]; /* DWORD 87 */
38 u8 rsvd11[32]; /* DWORD 88 */
39 u8 rsvd12[32]; /* DWORD 89 */
40 u8 rsvd13[32]; /* DWORD 90 */
41 u8 rsvd14[32]; /* DWORD 91 */
42 u8 rsvd15[32]; /* DWORD 92 */
43 u8 rsvd16[32]; /* DWORD 93 */
44 u8 rsvd17[32]; /* DWORD 94 */
45 u8 rsvd18[32]; /* DWORD 95 */
46 u8 rsvd19[32]; /* DWORD 96 */
47 u8 rsvd20[32]; /* DWORD 97 */
48 u8 rsvd21[32]; /* DWORD 98 */
49 u8 rsvd22[32]; /* DWORD 99 */
50 u8 rsvd23[32]; /* DWORD 100 */
51 u8 rsvd24[32]; /* DWORD 101 */
52 u8 rsvd25[32]; /* DWORD 102 */
53 u8 rsvd26[32]; /* DWORD 103 */
54 u8 rsvd27[32]; /* DWORD 104 */
55 u8 rsvd28[96]; /* DWORD 105 */
56 u8 rsvd29[32]; /* DWORD 108 */
57 u8 rsvd30[32]; /* DWORD 109 */
58 u8 rsvd31[32]; /* DWORD 110 */
59 u8 rsvd32[32]; /* DWORD 111 */
60 u8 rsvd33[32]; /* DWORD 112 */
61 u8 rsvd34[96]; /* DWORD 113 */
62 u8 rsvd35[32]; /* DWORD 116 */
63 u8 rsvd36[32]; /* DWORD 117 */
64 u8 rsvd37[32]; /* DWORD 118 */
65 u8 rsvd38[32]; /* DWORD 119 */
66 u8 rsvd39[32]; /* DWORD 120 */
67 u8 rsvd40[32]; /* DWORD 121 */
68 u8 rsvd41[134][32]; /* DWORD 122 */
69} __packed;
70struct MPU_CSRMAP_AMAP {
71 u32 dw[256];
72};
73
74#endif /* __mpu_amap_h__ */
diff --git a/drivers/staging/benet/mpu_context.h b/drivers/staging/benet/mpu_context.h
deleted file mode 100644
index 8ce90f9c46c2..000000000000
--- a/drivers/staging/benet/mpu_context.h
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __mpu_context_amap_h__
21#define __mpu_context_amap_h__
22
23/*
24 * Management command and control ring context. The MPUs BTLR_CTRL1 CSR
25 * controls the writeback behavior of the producer and consumer index values.
26 */
27struct BE_MCC_RING_CONTEXT_AMAP {
28 u8 con_index[16]; /* DWORD 0 */
29 u8 ring_size[4]; /* DWORD 0 */
30 u8 cq_id[11]; /* DWORD 0 */
31 u8 rsvd0; /* DWORD 0 */
32 u8 prod_index[16]; /* DWORD 1 */
33 u8 pdid[15]; /* DWORD 1 */
34 u8 invalid; /* DWORD 1 */
35 u8 cmd_pending_current[7]; /* DWORD 2 */
36 u8 rsvd1[25]; /* DWORD 2 */
37 u8 hpi_port_cq_id[11]; /* DWORD 3 */
38 u8 rsvd2[5]; /* DWORD 3 */
39 u8 cmd_pending_max[7]; /* DWORD 3 */
40 u8 rsvd3[9]; /* DWORD 3 */
41} __packed;
42struct MCC_RING_CONTEXT_AMAP {
43 u32 dw[4];
44};
45
46#endif /* __mpu_context_amap_h__ */
diff --git a/drivers/staging/benet/pcicfg.h b/drivers/staging/benet/pcicfg.h
deleted file mode 100644
index 7c15684adf4a..000000000000
--- a/drivers/staging/benet/pcicfg.h
+++ /dev/null
@@ -1,825 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __pcicfg_amap_h__
21#define __pcicfg_amap_h__
22
23/* Vendor and Device ID Register. */
24struct BE_PCICFG_ID_CSR_AMAP {
25 u8 vendorid[16]; /* DWORD 0 */
26 u8 deviceid[16]; /* DWORD 0 */
27} __packed;
28struct PCICFG_ID_CSR_AMAP {
29 u32 dw[1];
30};
31
32/* IO Bar Register. */
33struct BE_PCICFG_IOBAR_CSR_AMAP {
34 u8 iospace; /* DWORD 0 */
35 u8 rsvd0[7]; /* DWORD 0 */
36 u8 iobar[24]; /* DWORD 0 */
37} __packed;
38struct PCICFG_IOBAR_CSR_AMAP {
39 u32 dw[1];
40};
41
42/* Memory BAR 0 Register. */
43struct BE_PCICFG_MEMBAR0_CSR_AMAP {
44 u8 memspace; /* DWORD 0 */
45 u8 type[2]; /* DWORD 0 */
46 u8 pf; /* DWORD 0 */
47 u8 rsvd0[10]; /* DWORD 0 */
48 u8 membar0[18]; /* DWORD 0 */
49} __packed;
50struct PCICFG_MEMBAR0_CSR_AMAP {
51 u32 dw[1];
52};
53
54/* Memory BAR 1 - Low Address Register. */
55struct BE_PCICFG_MEMBAR1_LO_CSR_AMAP {
56 u8 memspace; /* DWORD 0 */
57 u8 type[2]; /* DWORD 0 */
58 u8 pf; /* DWORD 0 */
59 u8 rsvd0[13]; /* DWORD 0 */
60 u8 membar1lo[15]; /* DWORD 0 */
61} __packed;
62struct PCICFG_MEMBAR1_LO_CSR_AMAP {
63 u32 dw[1];
64};
65
66/* Memory BAR 1 - High Address Register. */
67struct BE_PCICFG_MEMBAR1_HI_CSR_AMAP {
68 u8 membar1hi[32]; /* DWORD 0 */
69} __packed;
70struct PCICFG_MEMBAR1_HI_CSR_AMAP {
71 u32 dw[1];
72};
73
74/* Memory BAR 2 - Low Address Register. */
75struct BE_PCICFG_MEMBAR2_LO_CSR_AMAP {
76 u8 memspace; /* DWORD 0 */
77 u8 type[2]; /* DWORD 0 */
78 u8 pf; /* DWORD 0 */
79 u8 rsvd0[17]; /* DWORD 0 */
80 u8 membar2lo[11]; /* DWORD 0 */
81} __packed;
82struct PCICFG_MEMBAR2_LO_CSR_AMAP {
83 u32 dw[1];
84};
85
86/* Memory BAR 2 - High Address Register. */
87struct BE_PCICFG_MEMBAR2_HI_CSR_AMAP {
88 u8 membar2hi[32]; /* DWORD 0 */
89} __packed;
90struct PCICFG_MEMBAR2_HI_CSR_AMAP {
91 u32 dw[1];
92};
93
94/* Subsystem Vendor and ID (Function 0) Register. */
95struct BE_PCICFG_SUBSYSTEM_ID_F0_CSR_AMAP {
96 u8 subsys_vendor_id[16]; /* DWORD 0 */
97 u8 subsys_id[16]; /* DWORD 0 */
98} __packed;
99struct PCICFG_SUBSYSTEM_ID_F0_CSR_AMAP {
100 u32 dw[1];
101};
102
103/* Subsystem Vendor and ID (Function 1) Register. */
104struct BE_PCICFG_SUBSYSTEM_ID_F1_CSR_AMAP {
105 u8 subsys_vendor_id[16]; /* DWORD 0 */
106 u8 subsys_id[16]; /* DWORD 0 */
107} __packed;
108struct PCICFG_SUBSYSTEM_ID_F1_CSR_AMAP {
109 u32 dw[1];
110};
111
112/* Semaphore Register. */
113struct BE_PCICFG_SEMAPHORE_CSR_AMAP {
114 u8 locked; /* DWORD 0 */
115 u8 rsvd0[31]; /* DWORD 0 */
116} __packed;
117struct PCICFG_SEMAPHORE_CSR_AMAP {
118 u32 dw[1];
119};
120
121/* Soft Reset Register. */
122struct BE_PCICFG_SOFT_RESET_CSR_AMAP {
123 u8 rsvd0[7]; /* DWORD 0 */
124 u8 softreset; /* DWORD 0 */
125 u8 rsvd1[16]; /* DWORD 0 */
126 u8 nec_ll_rcvdetect_i[8]; /* DWORD 0 */
127} __packed;
128struct PCICFG_SOFT_RESET_CSR_AMAP {
129 u32 dw[1];
130};
131
132/* Unrecoverable Error Status (Low) Register. Each bit corresponds to
133 * an internal Unrecoverable Error. These are set by hardware and may be
134 * cleared by writing a one to the respective bit(s) to be cleared. Any
135 * bit being set that is also unmasked will result in Unrecoverable Error
136 * interrupt notification to the host CPU and/or Server Management chip
137 * and the transitioning of BladeEngine to an Offline state.
138 */
139struct BE_PCICFG_UE_STATUS_LOW_CSR_AMAP {
140 u8 cev_ue_status; /* DWORD 0 */
141 u8 ctx_ue_status; /* DWORD 0 */
142 u8 dbuf_ue_status; /* DWORD 0 */
143 u8 erx_ue_status; /* DWORD 0 */
144 u8 host_ue_status; /* DWORD 0 */
145 u8 mpu_ue_status; /* DWORD 0 */
146 u8 ndma_ue_status; /* DWORD 0 */
147 u8 ptc_ue_status; /* DWORD 0 */
148 u8 rdma_ue_status; /* DWORD 0 */
149 u8 rxf_ue_status; /* DWORD 0 */
150 u8 rxips_ue_status; /* DWORD 0 */
151 u8 rxulp0_ue_status; /* DWORD 0 */
152 u8 rxulp1_ue_status; /* DWORD 0 */
153 u8 rxulp2_ue_status; /* DWORD 0 */
154 u8 tim_ue_status; /* DWORD 0 */
155 u8 tpost_ue_status; /* DWORD 0 */
156 u8 tpre_ue_status; /* DWORD 0 */
157 u8 txips_ue_status; /* DWORD 0 */
158 u8 txulp0_ue_status; /* DWORD 0 */
159 u8 txulp1_ue_status; /* DWORD 0 */
160 u8 uc_ue_status; /* DWORD 0 */
161 u8 wdma_ue_status; /* DWORD 0 */
162 u8 txulp2_ue_status; /* DWORD 0 */
163 u8 host1_ue_status; /* DWORD 0 */
164 u8 p0_ob_link_ue_status; /* DWORD 0 */
165 u8 p1_ob_link_ue_status; /* DWORD 0 */
166 u8 host_gpio_ue_status; /* DWORD 0 */
167 u8 mbox_netw_ue_status; /* DWORD 0 */
168 u8 mbox_stor_ue_status; /* DWORD 0 */
169 u8 axgmac0_ue_status; /* DWORD 0 */
170 u8 axgmac1_ue_status; /* DWORD 0 */
171 u8 mpu_intpend_ue_status; /* DWORD 0 */
172} __packed;
173struct PCICFG_UE_STATUS_LOW_CSR_AMAP {
174 u32 dw[1];
175};
176
177/* Unrecoverable Error Status (High) Register. Each bit corresponds to
178 * an internal Unrecoverable Error. These are set by hardware and may be
179 * cleared by writing a one to the respective bit(s) to be cleared. Any
180 * bit being set that is also unmasked will result in Unrecoverable Error
181 * interrupt notification to the host CPU and/or Server Management chip;
182 * and the transitioning of BladeEngine to an Offline state.
183 */
184struct BE_PCICFG_UE_STATUS_HI_CSR_AMAP {
185 u8 jtag_ue_status; /* DWORD 0 */
186 u8 lpcmemhost_ue_status; /* DWORD 0 */
187 u8 mgmt_mac_ue_status; /* DWORD 0 */
188 u8 mpu_iram_ue_status; /* DWORD 0 */
189 u8 pcs0online_ue_status; /* DWORD 0 */
190 u8 pcs1online_ue_status; /* DWORD 0 */
191 u8 pctl0_ue_status; /* DWORD 0 */
192 u8 pctl1_ue_status; /* DWORD 0 */
193 u8 pmem_ue_status; /* DWORD 0 */
194 u8 rr_ue_status; /* DWORD 0 */
195 u8 rxpp_ue_status; /* DWORD 0 */
196 u8 txpb_ue_status; /* DWORD 0 */
197 u8 txp_ue_status; /* DWORD 0 */
198 u8 xaui_ue_status; /* DWORD 0 */
199 u8 arm_ue_status; /* DWORD 0 */
200 u8 ipc_ue_status; /* DWORD 0 */
201 u8 rsvd0[16]; /* DWORD 0 */
202} __packed;
203struct PCICFG_UE_STATUS_HI_CSR_AMAP {
204 u32 dw[1];
205};
206
207/* Unrecoverable Error Mask (Low) Register. Each bit, when set to one,
208 * will mask the associated Unrecoverable Error status bit from notification
209 * of Unrecoverable Error to the host CPU and/or Server Managment chip and the
210 * transitioning of all BladeEngine units to an Offline state.
211 */
212struct BE_PCICFG_UE_STATUS_LOW_MASK_CSR_AMAP {
213 u8 cev_ue_mask; /* DWORD 0 */
214 u8 ctx_ue_mask; /* DWORD 0 */
215 u8 dbuf_ue_mask; /* DWORD 0 */
216 u8 erx_ue_mask; /* DWORD 0 */
217 u8 host_ue_mask; /* DWORD 0 */
218 u8 mpu_ue_mask; /* DWORD 0 */
219 u8 ndma_ue_mask; /* DWORD 0 */
220 u8 ptc_ue_mask; /* DWORD 0 */
221 u8 rdma_ue_mask; /* DWORD 0 */
222 u8 rxf_ue_mask; /* DWORD 0 */
223 u8 rxips_ue_mask; /* DWORD 0 */
224 u8 rxulp0_ue_mask; /* DWORD 0 */
225 u8 rxulp1_ue_mask; /* DWORD 0 */
226 u8 rxulp2_ue_mask; /* DWORD 0 */
227 u8 tim_ue_mask; /* DWORD 0 */
228 u8 tpost_ue_mask; /* DWORD 0 */
229 u8 tpre_ue_mask; /* DWORD 0 */
230 u8 txips_ue_mask; /* DWORD 0 */
231 u8 txulp0_ue_mask; /* DWORD 0 */
232 u8 txulp1_ue_mask; /* DWORD 0 */
233 u8 uc_ue_mask; /* DWORD 0 */
234 u8 wdma_ue_mask; /* DWORD 0 */
235 u8 txulp2_ue_mask; /* DWORD 0 */
236 u8 host1_ue_mask; /* DWORD 0 */
237 u8 p0_ob_link_ue_mask; /* DWORD 0 */
238 u8 p1_ob_link_ue_mask; /* DWORD 0 */
239 u8 host_gpio_ue_mask; /* DWORD 0 */
240 u8 mbox_netw_ue_mask; /* DWORD 0 */
241 u8 mbox_stor_ue_mask; /* DWORD 0 */
242 u8 axgmac0_ue_mask; /* DWORD 0 */
243 u8 axgmac1_ue_mask; /* DWORD 0 */
244 u8 mpu_intpend_ue_mask; /* DWORD 0 */
245} __packed;
246struct PCICFG_UE_STATUS_LOW_MASK_CSR_AMAP {
247 u32 dw[1];
248};
249
250/* Unrecoverable Error Mask (High) Register. Each bit, when set to one,
251 * will mask the associated Unrecoverable Error status bit from notification
252 * of Unrecoverable Error to the host CPU and/or Server Managment chip and the
253 * transitioning of all BladeEngine units to an Offline state.
254 */
255struct BE_PCICFG_UE_STATUS_HI_MASK_CSR_AMAP {
256 u8 jtag_ue_mask; /* DWORD 0 */
257 u8 lpcmemhost_ue_mask; /* DWORD 0 */
258 u8 mgmt_mac_ue_mask; /* DWORD 0 */
259 u8 mpu_iram_ue_mask; /* DWORD 0 */
260 u8 pcs0online_ue_mask; /* DWORD 0 */
261 u8 pcs1online_ue_mask; /* DWORD 0 */
262 u8 pctl0_ue_mask; /* DWORD 0 */
263 u8 pctl1_ue_mask; /* DWORD 0 */
264 u8 pmem_ue_mask; /* DWORD 0 */
265 u8 rr_ue_mask; /* DWORD 0 */
266 u8 rxpp_ue_mask; /* DWORD 0 */
267 u8 txpb_ue_mask; /* DWORD 0 */
268 u8 txp_ue_mask; /* DWORD 0 */
269 u8 xaui_ue_mask; /* DWORD 0 */
270 u8 arm_ue_mask; /* DWORD 0 */
271 u8 ipc_ue_mask; /* DWORD 0 */
272 u8 rsvd0[16]; /* DWORD 0 */
273} __packed;
274struct PCICFG_UE_STATUS_HI_MASK_CSR_AMAP {
275 u32 dw[1];
276};
277
278/* Online Control Register 0. This register controls various units within
279 * BladeEngine being in an Online or Offline state.
280 */
281struct BE_PCICFG_ONLINE0_CSR_AMAP {
282 u8 cev_online; /* DWORD 0 */
283 u8 ctx_online; /* DWORD 0 */
284 u8 dbuf_online; /* DWORD 0 */
285 u8 erx_online; /* DWORD 0 */
286 u8 host_online; /* DWORD 0 */
287 u8 mpu_online; /* DWORD 0 */
288 u8 ndma_online; /* DWORD 0 */
289 u8 ptc_online; /* DWORD 0 */
290 u8 rdma_online; /* DWORD 0 */
291 u8 rxf_online; /* DWORD 0 */
292 u8 rxips_online; /* DWORD 0 */
293 u8 rxulp0_online; /* DWORD 0 */
294 u8 rxulp1_online; /* DWORD 0 */
295 u8 rxulp2_online; /* DWORD 0 */
296 u8 tim_online; /* DWORD 0 */
297 u8 tpost_online; /* DWORD 0 */
298 u8 tpre_online; /* DWORD 0 */
299 u8 txips_online; /* DWORD 0 */
300 u8 txulp0_online; /* DWORD 0 */
301 u8 txulp1_online; /* DWORD 0 */
302 u8 uc_online; /* DWORD 0 */
303 u8 wdma_online; /* DWORD 0 */
304 u8 txulp2_online; /* DWORD 0 */
305 u8 host1_online; /* DWORD 0 */
306 u8 p0_ob_link_online; /* DWORD 0 */
307 u8 p1_ob_link_online; /* DWORD 0 */
308 u8 host_gpio_online; /* DWORD 0 */
309 u8 mbox_netw_online; /* DWORD 0 */
310 u8 mbox_stor_online; /* DWORD 0 */
311 u8 axgmac0_online; /* DWORD 0 */
312 u8 axgmac1_online; /* DWORD 0 */
313 u8 mpu_intpend_online; /* DWORD 0 */
314} __packed;
315struct PCICFG_ONLINE0_CSR_AMAP {
316 u32 dw[1];
317};
318
319/* Online Control Register 1. This register controls various units within
320 * BladeEngine being in an Online or Offline state.
321 */
322struct BE_PCICFG_ONLINE1_CSR_AMAP {
323 u8 jtag_online; /* DWORD 0 */
324 u8 lpcmemhost_online; /* DWORD 0 */
325 u8 mgmt_mac_online; /* DWORD 0 */
326 u8 mpu_iram_online; /* DWORD 0 */
327 u8 pcs0online_online; /* DWORD 0 */
328 u8 pcs1online_online; /* DWORD 0 */
329 u8 pctl0_online; /* DWORD 0 */
330 u8 pctl1_online; /* DWORD 0 */
331 u8 pmem_online; /* DWORD 0 */
332 u8 rr_online; /* DWORD 0 */
333 u8 rxpp_online; /* DWORD 0 */
334 u8 txpb_online; /* DWORD 0 */
335 u8 txp_online; /* DWORD 0 */
336 u8 xaui_online; /* DWORD 0 */
337 u8 arm_online; /* DWORD 0 */
338 u8 ipc_online; /* DWORD 0 */
339 u8 rsvd0[16]; /* DWORD 0 */
340} __packed;
341struct PCICFG_ONLINE1_CSR_AMAP {
342 u32 dw[1];
343};
344
345/* Host Timer Register. */
346struct BE_PCICFG_HOST_TIMER_INT_CTRL_CSR_AMAP {
347 u8 hosttimer[24]; /* DWORD 0 */
348 u8 hostintr; /* DWORD 0 */
349 u8 rsvd0[7]; /* DWORD 0 */
350} __packed;
351struct PCICFG_HOST_TIMER_INT_CTRL_CSR_AMAP {
352 u32 dw[1];
353};
354
355/* Scratchpad Register (for software use). */
356struct BE_PCICFG_SCRATCHPAD_CSR_AMAP {
357 u8 scratchpad[32]; /* DWORD 0 */
358} __packed;
359struct PCICFG_SCRATCHPAD_CSR_AMAP {
360 u32 dw[1];
361};
362
363/* PCI Express Capabilities Register. */
364struct BE_PCICFG_PCIE_CAP_CSR_AMAP {
365 u8 capid[8]; /* DWORD 0 */
366 u8 nextcap[8]; /* DWORD 0 */
367 u8 capver[4]; /* DWORD 0 */
368 u8 devport[4]; /* DWORD 0 */
369 u8 rsvd0[6]; /* DWORD 0 */
370 u8 rsvd1[2]; /* DWORD 0 */
371} __packed;
372struct PCICFG_PCIE_CAP_CSR_AMAP {
373 u32 dw[1];
374};
375
376/* PCI Express Device Capabilities Register. */
377struct BE_PCICFG_PCIE_DEVCAP_CSR_AMAP {
378 u8 payload[3]; /* DWORD 0 */
379 u8 rsvd0[3]; /* DWORD 0 */
380 u8 lo_lat[3]; /* DWORD 0 */
381 u8 l1_lat[3]; /* DWORD 0 */
382 u8 rsvd1[3]; /* DWORD 0 */
383 u8 rsvd2[3]; /* DWORD 0 */
384 u8 pwr_value[8]; /* DWORD 0 */
385 u8 pwr_scale[2]; /* DWORD 0 */
386 u8 rsvd3[4]; /* DWORD 0 */
387} __packed;
388struct PCICFG_PCIE_DEVCAP_CSR_AMAP {
389 u32 dw[1];
390};
391
392/* PCI Express Device Control/Status Registers. */
393struct BE_PCICFG_PCIE_CONTROL_STATUS_CSR_AMAP {
394 u8 CorrErrReportEn; /* DWORD 0 */
395 u8 NonFatalErrReportEn; /* DWORD 0 */
396 u8 FatalErrReportEn; /* DWORD 0 */
397 u8 UnsuppReqReportEn; /* DWORD 0 */
398 u8 EnableRelaxOrder; /* DWORD 0 */
399 u8 Max_Payload_Size[3]; /* DWORD 0 */
400 u8 ExtendTagFieldEnable; /* DWORD 0 */
401 u8 PhantomFnEnable; /* DWORD 0 */
402 u8 AuxPwrPMEnable; /* DWORD 0 */
403 u8 EnableNoSnoop; /* DWORD 0 */
404 u8 Max_Read_Req_Size[3]; /* DWORD 0 */
405 u8 rsvd0; /* DWORD 0 */
406 u8 CorrErrDetect; /* DWORD 0 */
407 u8 NonFatalErrDetect; /* DWORD 0 */
408 u8 FatalErrDetect; /* DWORD 0 */
409 u8 UnsuppReqDetect; /* DWORD 0 */
410 u8 AuxPwrDetect; /* DWORD 0 */
411 u8 TransPending; /* DWORD 0 */
412 u8 rsvd1[10]; /* DWORD 0 */
413} __packed;
414struct PCICFG_PCIE_CONTROL_STATUS_CSR_AMAP {
415 u32 dw[1];
416};
417
418/* PCI Express Link Capabilities Register. */
419struct BE_PCICFG_PCIE_LINK_CAP_CSR_AMAP {
420 u8 MaxLinkSpeed[4]; /* DWORD 0 */
421 u8 MaxLinkWidth[6]; /* DWORD 0 */
422 u8 ASPMSupport[2]; /* DWORD 0 */
423 u8 L0sExitLat[3]; /* DWORD 0 */
424 u8 L1ExitLat[3]; /* DWORD 0 */
425 u8 rsvd0[6]; /* DWORD 0 */
426 u8 PortNum[8]; /* DWORD 0 */
427} __packed;
428struct PCICFG_PCIE_LINK_CAP_CSR_AMAP {
429 u32 dw[1];
430};
431
432/* PCI Express Link Status Register. */
433struct BE_PCICFG_PCIE_LINK_STATUS_CSR_AMAP {
434 u8 ASPMCtl[2]; /* DWORD 0 */
435 u8 rsvd0; /* DWORD 0 */
436 u8 ReadCmplBndry; /* DWORD 0 */
437 u8 LinkDisable; /* DWORD 0 */
438 u8 RetrainLink; /* DWORD 0 */
439 u8 CommonClkConfig; /* DWORD 0 */
440 u8 ExtendSync; /* DWORD 0 */
441 u8 rsvd1[8]; /* DWORD 0 */
442 u8 LinkSpeed[4]; /* DWORD 0 */
443 u8 NegLinkWidth[6]; /* DWORD 0 */
444 u8 LinkTrainErr; /* DWORD 0 */
445 u8 LinkTrain; /* DWORD 0 */
446 u8 SlotClkConfig; /* DWORD 0 */
447 u8 rsvd2[3]; /* DWORD 0 */
448} __packed;
449struct PCICFG_PCIE_LINK_STATUS_CSR_AMAP {
450 u32 dw[1];
451};
452
453/* PCI Express MSI Configuration Register. */
454struct BE_PCICFG_MSI_CSR_AMAP {
455 u8 capid[8]; /* DWORD 0 */
456 u8 nextptr[8]; /* DWORD 0 */
457 u8 tablesize[11]; /* DWORD 0 */
458 u8 rsvd0[3]; /* DWORD 0 */
459 u8 funcmask; /* DWORD 0 */
460 u8 en; /* DWORD 0 */
461} __packed;
462struct PCICFG_MSI_CSR_AMAP {
463 u32 dw[1];
464};
465
466/* MSI-X Table Offset Register. */
467struct BE_PCICFG_MSIX_TABLE_CSR_AMAP {
468 u8 tablebir[3]; /* DWORD 0 */
469 u8 offset[29]; /* DWORD 0 */
470} __packed;
471struct PCICFG_MSIX_TABLE_CSR_AMAP {
472 u32 dw[1];
473};
474
475/* MSI-X PBA Offset Register. */
476struct BE_PCICFG_MSIX_PBA_CSR_AMAP {
477 u8 pbabir[3]; /* DWORD 0 */
478 u8 offset[29]; /* DWORD 0 */
479} __packed;
480struct PCICFG_MSIX_PBA_CSR_AMAP {
481 u32 dw[1];
482};
483
484/* PCI Express MSI-X Message Vector Control Register. */
485struct BE_PCICFG_MSIX_VECTOR_CONTROL_CSR_AMAP {
486 u8 vector_control; /* DWORD 0 */
487 u8 rsvd0[31]; /* DWORD 0 */
488} __packed;
489struct PCICFG_MSIX_VECTOR_CONTROL_CSR_AMAP {
490 u32 dw[1];
491};
492
493/* PCI Express MSI-X Message Data Register. */
494struct BE_PCICFG_MSIX_MSG_DATA_CSR_AMAP {
495 u8 data[16]; /* DWORD 0 */
496 u8 rsvd0[16]; /* DWORD 0 */
497} __packed;
498struct PCICFG_MSIX_MSG_DATA_CSR_AMAP {
499 u32 dw[1];
500};
501
502/* PCI Express MSI-X Message Address Register - High Part. */
503struct BE_PCICFG_MSIX_MSG_ADDR_HI_CSR_AMAP {
504 u8 addr[32]; /* DWORD 0 */
505} __packed;
506struct PCICFG_MSIX_MSG_ADDR_HI_CSR_AMAP {
507 u32 dw[1];
508};
509
510/* PCI Express MSI-X Message Address Register - Low Part. */
511struct BE_PCICFG_MSIX_MSG_ADDR_LO_CSR_AMAP {
512 u8 rsvd0[2]; /* DWORD 0 */
513 u8 addr[30]; /* DWORD 0 */
514} __packed;
515struct PCICFG_MSIX_MSG_ADDR_LO_CSR_AMAP {
516 u32 dw[1];
517};
518
519struct BE_PCICFG_ANON_18_RSVD_AMAP {
520 u8 rsvd0[32]; /* DWORD 0 */
521} __packed;
522struct PCICFG_ANON_18_RSVD_AMAP {
523 u32 dw[1];
524};
525
526struct BE_PCICFG_ANON_19_RSVD_AMAP {
527 u8 rsvd0[32]; /* DWORD 0 */
528} __packed;
529struct PCICFG_ANON_19_RSVD_AMAP {
530 u32 dw[1];
531};
532
533struct BE_PCICFG_ANON_20_RSVD_AMAP {
534 u8 rsvd0[32]; /* DWORD 0 */
535 u8 rsvd1[25][32]; /* DWORD 1 */
536} __packed;
537struct PCICFG_ANON_20_RSVD_AMAP {
538 u32 dw[26];
539};
540
541struct BE_PCICFG_ANON_21_RSVD_AMAP {
542 u8 rsvd0[32]; /* DWORD 0 */
543 u8 rsvd1[1919][32]; /* DWORD 1 */
544} __packed;
545struct PCICFG_ANON_21_RSVD_AMAP {
546 u32 dw[1920];
547};
548
549struct BE_PCICFG_ANON_22_MESSAGE_AMAP {
550 struct BE_PCICFG_MSIX_VECTOR_CONTROL_CSR_AMAP vec_ctrl;
551 struct BE_PCICFG_MSIX_MSG_DATA_CSR_AMAP msg_data;
552 struct BE_PCICFG_MSIX_MSG_ADDR_HI_CSR_AMAP addr_hi;
553 struct BE_PCICFG_MSIX_MSG_ADDR_LO_CSR_AMAP addr_low;
554} __packed;
555struct PCICFG_ANON_22_MESSAGE_AMAP {
556 u32 dw[4];
557};
558
559struct BE_PCICFG_ANON_23_RSVD_AMAP {
560 u8 rsvd0[32]; /* DWORD 0 */
561 u8 rsvd1[895][32]; /* DWORD 1 */
562} __packed;
563struct PCICFG_ANON_23_RSVD_AMAP {
564 u32 dw[896];
565};
566
567/* These PCI Configuration Space registers are for the Storage Function of
568 * BladeEngine (Function 0). In the memory map of the registers below their
569 * table,
570 */
571struct BE_PCICFG0_CSRMAP_AMAP {
572 struct BE_PCICFG_ID_CSR_AMAP id;
573 u8 rsvd0[32]; /* DWORD 1 */
574 u8 rsvd1[32]; /* DWORD 2 */
575 u8 rsvd2[32]; /* DWORD 3 */
576 struct BE_PCICFG_IOBAR_CSR_AMAP iobar;
577 struct BE_PCICFG_MEMBAR0_CSR_AMAP membar0;
578 struct BE_PCICFG_MEMBAR1_LO_CSR_AMAP membar1_lo;
579 struct BE_PCICFG_MEMBAR1_HI_CSR_AMAP membar1_hi;
580 struct BE_PCICFG_MEMBAR2_LO_CSR_AMAP membar2_lo;
581 struct BE_PCICFG_MEMBAR2_HI_CSR_AMAP membar2_hi;
582 u8 rsvd3[32]; /* DWORD 10 */
583 struct BE_PCICFG_SUBSYSTEM_ID_F0_CSR_AMAP subsystem_id;
584 u8 rsvd4[32]; /* DWORD 12 */
585 u8 rsvd5[32]; /* DWORD 13 */
586 u8 rsvd6[32]; /* DWORD 14 */
587 u8 rsvd7[32]; /* DWORD 15 */
588 struct BE_PCICFG_SEMAPHORE_CSR_AMAP semaphore[4];
589 struct BE_PCICFG_SOFT_RESET_CSR_AMAP soft_reset;
590 u8 rsvd8[32]; /* DWORD 21 */
591 struct BE_PCICFG_SCRATCHPAD_CSR_AMAP scratchpad;
592 u8 rsvd9[32]; /* DWORD 23 */
593 u8 rsvd10[32]; /* DWORD 24 */
594 u8 rsvd11[32]; /* DWORD 25 */
595 u8 rsvd12[32]; /* DWORD 26 */
596 u8 rsvd13[32]; /* DWORD 27 */
597 u8 rsvd14[2][32]; /* DWORD 28 */
598 u8 rsvd15[32]; /* DWORD 30 */
599 u8 rsvd16[32]; /* DWORD 31 */
600 u8 rsvd17[8][32]; /* DWORD 32 */
601 struct BE_PCICFG_UE_STATUS_LOW_CSR_AMAP ue_status_low;
602 struct BE_PCICFG_UE_STATUS_HI_CSR_AMAP ue_status_hi;
603 struct BE_PCICFG_UE_STATUS_LOW_MASK_CSR_AMAP ue_status_low_mask;
604 struct BE_PCICFG_UE_STATUS_HI_MASK_CSR_AMAP ue_status_hi_mask;
605 struct BE_PCICFG_ONLINE0_CSR_AMAP online0;
606 struct BE_PCICFG_ONLINE1_CSR_AMAP online1;
607 u8 rsvd18[32]; /* DWORD 46 */
608 u8 rsvd19[32]; /* DWORD 47 */
609 u8 rsvd20[32]; /* DWORD 48 */
610 u8 rsvd21[32]; /* DWORD 49 */
611 struct BE_PCICFG_HOST_TIMER_INT_CTRL_CSR_AMAP host_timer_int_ctrl;
612 u8 rsvd22[32]; /* DWORD 51 */
613 struct BE_PCICFG_PCIE_CAP_CSR_AMAP pcie_cap;
614 struct BE_PCICFG_PCIE_DEVCAP_CSR_AMAP pcie_devcap;
615 struct BE_PCICFG_PCIE_CONTROL_STATUS_CSR_AMAP pcie_control_status;
616 struct BE_PCICFG_PCIE_LINK_CAP_CSR_AMAP pcie_link_cap;
617 struct BE_PCICFG_PCIE_LINK_STATUS_CSR_AMAP pcie_link_status;
618 struct BE_PCICFG_MSI_CSR_AMAP msi;
619 struct BE_PCICFG_MSIX_TABLE_CSR_AMAP msix_table_offset;
620 struct BE_PCICFG_MSIX_PBA_CSR_AMAP msix_pba_offset;
621 u8 rsvd23[32]; /* DWORD 60 */
622 u8 rsvd24[32]; /* DWORD 61 */
623 u8 rsvd25[32]; /* DWORD 62 */
624 u8 rsvd26[32]; /* DWORD 63 */
625 u8 rsvd27[32]; /* DWORD 64 */
626 u8 rsvd28[32]; /* DWORD 65 */
627 u8 rsvd29[32]; /* DWORD 66 */
628 u8 rsvd30[32]; /* DWORD 67 */
629 u8 rsvd31[32]; /* DWORD 68 */
630 u8 rsvd32[32]; /* DWORD 69 */
631 u8 rsvd33[32]; /* DWORD 70 */
632 u8 rsvd34[32]; /* DWORD 71 */
633 u8 rsvd35[32]; /* DWORD 72 */
634 u8 rsvd36[32]; /* DWORD 73 */
635 u8 rsvd37[32]; /* DWORD 74 */
636 u8 rsvd38[32]; /* DWORD 75 */
637 u8 rsvd39[32]; /* DWORD 76 */
638 u8 rsvd40[32]; /* DWORD 77 */
639 u8 rsvd41[32]; /* DWORD 78 */
640 u8 rsvd42[32]; /* DWORD 79 */
641 u8 rsvd43[32]; /* DWORD 80 */
642 u8 rsvd44[32]; /* DWORD 81 */
643 u8 rsvd45[32]; /* DWORD 82 */
644 u8 rsvd46[32]; /* DWORD 83 */
645 u8 rsvd47[32]; /* DWORD 84 */
646 u8 rsvd48[32]; /* DWORD 85 */
647 u8 rsvd49[32]; /* DWORD 86 */
648 u8 rsvd50[32]; /* DWORD 87 */
649 u8 rsvd51[32]; /* DWORD 88 */
650 u8 rsvd52[32]; /* DWORD 89 */
651 u8 rsvd53[32]; /* DWORD 90 */
652 u8 rsvd54[32]; /* DWORD 91 */
653 u8 rsvd55[32]; /* DWORD 92 */
654 u8 rsvd56[832]; /* DWORD 93 */
655 u8 rsvd57[32]; /* DWORD 119 */
656 u8 rsvd58[32]; /* DWORD 120 */
657 u8 rsvd59[32]; /* DWORD 121 */
658 u8 rsvd60[32]; /* DWORD 122 */
659 u8 rsvd61[32]; /* DWORD 123 */
660 u8 rsvd62[32]; /* DWORD 124 */
661 u8 rsvd63[32]; /* DWORD 125 */
662 u8 rsvd64[32]; /* DWORD 126 */
663 u8 rsvd65[32]; /* DWORD 127 */
664 u8 rsvd66[61440]; /* DWORD 128 */
665 struct BE_PCICFG_ANON_22_MESSAGE_AMAP message[32];
666 u8 rsvd67[28672]; /* DWORD 2176 */
667 u8 rsvd68[32]; /* DWORD 3072 */
668 u8 rsvd69[1023][32]; /* DWORD 3073 */
669} __packed;
670struct PCICFG0_CSRMAP_AMAP {
671 u32 dw[4096];
672};
673
674struct BE_PCICFG_ANON_24_RSVD_AMAP {
675 u8 rsvd0[32]; /* DWORD 0 */
676} __packed;
677struct PCICFG_ANON_24_RSVD_AMAP {
678 u32 dw[1];
679};
680
681struct BE_PCICFG_ANON_25_RSVD_AMAP {
682 u8 rsvd0[32]; /* DWORD 0 */
683} __packed;
684struct PCICFG_ANON_25_RSVD_AMAP {
685 u32 dw[1];
686};
687
688struct BE_PCICFG_ANON_26_RSVD_AMAP {
689 u8 rsvd0[32]; /* DWORD 0 */
690} __packed;
691struct PCICFG_ANON_26_RSVD_AMAP {
692 u32 dw[1];
693};
694
695struct BE_PCICFG_ANON_27_RSVD_AMAP {
696 u8 rsvd0[32]; /* DWORD 0 */
697 u8 rsvd1[32]; /* DWORD 1 */
698} __packed;
699struct PCICFG_ANON_27_RSVD_AMAP {
700 u32 dw[2];
701};
702
703struct BE_PCICFG_ANON_28_RSVD_AMAP {
704 u8 rsvd0[32]; /* DWORD 0 */
705 u8 rsvd1[3][32]; /* DWORD 1 */
706} __packed;
707struct PCICFG_ANON_28_RSVD_AMAP {
708 u32 dw[4];
709};
710
711struct BE_PCICFG_ANON_29_RSVD_AMAP {
712 u8 rsvd0[32]; /* DWORD 0 */
713 u8 rsvd1[36][32]; /* DWORD 1 */
714} __packed;
715struct PCICFG_ANON_29_RSVD_AMAP {
716 u32 dw[37];
717};
718
719struct BE_PCICFG_ANON_30_RSVD_AMAP {
720 u8 rsvd0[32]; /* DWORD 0 */
721 u8 rsvd1[1930][32]; /* DWORD 1 */
722} __packed;
723struct PCICFG_ANON_30_RSVD_AMAP {
724 u32 dw[1931];
725};
726
727struct BE_PCICFG_ANON_31_MESSAGE_AMAP {
728 struct BE_PCICFG_MSIX_VECTOR_CONTROL_CSR_AMAP vec_ctrl;
729 struct BE_PCICFG_MSIX_MSG_DATA_CSR_AMAP msg_data;
730 struct BE_PCICFG_MSIX_MSG_ADDR_HI_CSR_AMAP addr_hi;
731 struct BE_PCICFG_MSIX_MSG_ADDR_LO_CSR_AMAP addr_low;
732} __packed;
733struct PCICFG_ANON_31_MESSAGE_AMAP {
734 u32 dw[4];
735};
736
737struct BE_PCICFG_ANON_32_RSVD_AMAP {
738 u8 rsvd0[32]; /* DWORD 0 */
739 u8 rsvd1[895][32]; /* DWORD 1 */
740} __packed;
741struct PCICFG_ANON_32_RSVD_AMAP {
742 u32 dw[896];
743};
744
745/* This PCI configuration space register map is for the Networking Function of
746 * BladeEngine (Function 1).
747 */
748struct BE_PCICFG1_CSRMAP_AMAP {
749 struct BE_PCICFG_ID_CSR_AMAP id;
750 u8 rsvd0[32]; /* DWORD 1 */
751 u8 rsvd1[32]; /* DWORD 2 */
752 u8 rsvd2[32]; /* DWORD 3 */
753 struct BE_PCICFG_IOBAR_CSR_AMAP iobar;
754 struct BE_PCICFG_MEMBAR0_CSR_AMAP membar0;
755 struct BE_PCICFG_MEMBAR1_LO_CSR_AMAP membar1_lo;
756 struct BE_PCICFG_MEMBAR1_HI_CSR_AMAP membar1_hi;
757 struct BE_PCICFG_MEMBAR2_LO_CSR_AMAP membar2_lo;
758 struct BE_PCICFG_MEMBAR2_HI_CSR_AMAP membar2_hi;
759 u8 rsvd3[32]; /* DWORD 10 */
760 struct BE_PCICFG_SUBSYSTEM_ID_F1_CSR_AMAP subsystem_id;
761 u8 rsvd4[32]; /* DWORD 12 */
762 u8 rsvd5[32]; /* DWORD 13 */
763 u8 rsvd6[32]; /* DWORD 14 */
764 u8 rsvd7[32]; /* DWORD 15 */
765 struct BE_PCICFG_SEMAPHORE_CSR_AMAP semaphore[4];
766 struct BE_PCICFG_SOFT_RESET_CSR_AMAP soft_reset;
767 u8 rsvd8[32]; /* DWORD 21 */
768 struct BE_PCICFG_SCRATCHPAD_CSR_AMAP scratchpad;
769 u8 rsvd9[32]; /* DWORD 23 */
770 u8 rsvd10[32]; /* DWORD 24 */
771 u8 rsvd11[32]; /* DWORD 25 */
772 u8 rsvd12[32]; /* DWORD 26 */
773 u8 rsvd13[32]; /* DWORD 27 */
774 u8 rsvd14[2][32]; /* DWORD 28 */
775 u8 rsvd15[32]; /* DWORD 30 */
776 u8 rsvd16[32]; /* DWORD 31 */
777 u8 rsvd17[8][32]; /* DWORD 32 */
778 struct BE_PCICFG_UE_STATUS_LOW_CSR_AMAP ue_status_low;
779 struct BE_PCICFG_UE_STATUS_HI_CSR_AMAP ue_status_hi;
780 struct BE_PCICFG_UE_STATUS_LOW_MASK_CSR_AMAP ue_status_low_mask;
781 struct BE_PCICFG_UE_STATUS_HI_MASK_CSR_AMAP ue_status_hi_mask;
782 struct BE_PCICFG_ONLINE0_CSR_AMAP online0;
783 struct BE_PCICFG_ONLINE1_CSR_AMAP online1;
784 u8 rsvd18[32]; /* DWORD 46 */
785 u8 rsvd19[32]; /* DWORD 47 */
786 u8 rsvd20[32]; /* DWORD 48 */
787 u8 rsvd21[32]; /* DWORD 49 */
788 struct BE_PCICFG_HOST_TIMER_INT_CTRL_CSR_AMAP host_timer_int_ctrl;
789 u8 rsvd22[32]; /* DWORD 51 */
790 struct BE_PCICFG_PCIE_CAP_CSR_AMAP pcie_cap;
791 struct BE_PCICFG_PCIE_DEVCAP_CSR_AMAP pcie_devcap;
792 struct BE_PCICFG_PCIE_CONTROL_STATUS_CSR_AMAP pcie_control_status;
793 struct BE_PCICFG_PCIE_LINK_CAP_CSR_AMAP pcie_link_cap;
794 struct BE_PCICFG_PCIE_LINK_STATUS_CSR_AMAP pcie_link_status;
795 struct BE_PCICFG_MSI_CSR_AMAP msi;
796 struct BE_PCICFG_MSIX_TABLE_CSR_AMAP msix_table_offset;
797 struct BE_PCICFG_MSIX_PBA_CSR_AMAP msix_pba_offset;
798 u8 rsvd23[64]; /* DWORD 60 */
799 u8 rsvd24[32]; /* DWORD 62 */
800 u8 rsvd25[32]; /* DWORD 63 */
801 u8 rsvd26[32]; /* DWORD 64 */
802 u8 rsvd27[32]; /* DWORD 65 */
803 u8 rsvd28[32]; /* DWORD 66 */
804 u8 rsvd29[32]; /* DWORD 67 */
805 u8 rsvd30[32]; /* DWORD 68 */
806 u8 rsvd31[32]; /* DWORD 69 */
807 u8 rsvd32[32]; /* DWORD 70 */
808 u8 rsvd33[32]; /* DWORD 71 */
809 u8 rsvd34[32]; /* DWORD 72 */
810 u8 rsvd35[32]; /* DWORD 73 */
811 u8 rsvd36[32]; /* DWORD 74 */
812 u8 rsvd37[128]; /* DWORD 75 */
813 u8 rsvd38[32]; /* DWORD 79 */
814 u8 rsvd39[1184]; /* DWORD 80 */
815 u8 rsvd40[61792]; /* DWORD 117 */
816 struct BE_PCICFG_ANON_31_MESSAGE_AMAP message[32];
817 u8 rsvd41[28672]; /* DWORD 2176 */
818 u8 rsvd42[32]; /* DWORD 3072 */
819 u8 rsvd43[1023][32]; /* DWORD 3073 */
820} __packed;
821struct PCICFG1_CSRMAP_AMAP {
822 u32 dw[4096];
823};
824
825#endif /* __pcicfg_amap_h__ */
diff --git a/drivers/staging/benet/post_codes.h b/drivers/staging/benet/post_codes.h
deleted file mode 100644
index 6d1621f5f5fb..000000000000
--- a/drivers/staging/benet/post_codes.h
+++ /dev/null
@@ -1,111 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __post_codes_amap_h__
21#define __post_codes_amap_h__
22
23/* --- MGMT_HBA_POST_STAGE_ENUM --- */
24#define POST_STAGE_POWER_ON_RESET (0) /* State after a cold or warm boot. */
25#define POST_STAGE_AWAITING_HOST_RDY (1) /* ARM boot code awaiting a
26 go-ahed from the host. */
27#define POST_STAGE_HOST_RDY (2) /* Host has given go-ahed to ARM. */
28#define POST_STAGE_BE_RESET (3) /* Host wants to reset chip, this is a chip
29 workaround */
30#define POST_STAGE_SEEPROM_CS_START (256) /* SEEPROM checksum
31 test start. */
32#define POST_STAGE_SEEPROM_CS_DONE (257) /* SEEPROM checksum test
33 done. */
34#define POST_STAGE_DDR_CONFIG_START (512) /* DDR configuration start. */
35#define POST_STAGE_DDR_CONFIG_DONE (513) /* DDR configuration done. */
36#define POST_STAGE_DDR_CALIBRATE_START (768) /* DDR calibration start. */
37#define POST_STAGE_DDR_CALIBRATE_DONE (769) /* DDR calibration done. */
38#define POST_STAGE_DDR_TEST_START (1024) /* DDR memory test start. */
39#define POST_STAGE_DDR_TEST_DONE (1025) /* DDR memory test done. */
40#define POST_STAGE_REDBOOT_INIT_START (1536) /* Redboot starts execution. */
41#define POST_STAGE_REDBOOT_INIT_DONE (1537) /* Redboot done execution. */
42#define POST_STAGE_FW_IMAGE_LOAD_START (1792) /* Firmware image load to
43 DDR start. */
44#define POST_STAGE_FW_IMAGE_LOAD_DONE (1793) /* Firmware image load
45 to DDR done. */
46#define POST_STAGE_ARMFW_START (2048) /* ARMfw runtime code
47 starts execution. */
48#define POST_STAGE_DHCP_QUERY_START (2304) /* DHCP server query start. */
49#define POST_STAGE_DHCP_QUERY_DONE (2305) /* DHCP server query done. */
50#define POST_STAGE_BOOT_TARGET_DISCOVERY_START (2560) /* Boot Target
51 Discovery Start. */
52#define POST_STAGE_BOOT_TARGET_DISCOVERY_DONE (2561) /* Boot Target
53 Discovery Done. */
54#define POST_STAGE_RC_OPTION_SET (2816) /* Remote configuration
55 option is set in SEEPROM */
56#define POST_STAGE_SWITCH_LINK (2817) /* Wait for link up on switch */
57#define POST_STAGE_SEND_ICDS_MESSAGE (2818) /* Send the ICDS message
58 to switch */
59#define POST_STAGE_PERFROM_TFTP (2819) /* Download xml using TFTP */
60#define POST_STAGE_PARSE_XML (2820) /* Parse XML file */
61#define POST_STAGE_DOWNLOAD_IMAGE (2821) /* Download IMAGE from
62 TFTP server */
63#define POST_STAGE_FLASH_IMAGE (2822) /* Flash the IMAGE */
64#define POST_STAGE_RC_DONE (2823) /* Remote configuration
65 complete */
66#define POST_STAGE_REBOOT_SYSTEM (2824) /* Upgrade IMAGE done,
67 reboot required */
68#define POST_STAGE_MAC_ADDRESS (3072) /* MAC Address Check */
69#define POST_STAGE_ARMFW_READY (49152) /* ARMfw is done with POST
70 and ready. */
71#define POST_STAGE_ARMFW_UE (61440) /* ARMfw has asserted an
72 unrecoverable error. The
73 lower 3 hex digits of the
74 stage code identify the
75 unique error code.
76 */
77
78/* This structure defines the format of the MPU semaphore
79 * register when used for POST.
80 */
81struct BE_MGMT_HBA_POST_STATUS_STRUCT_AMAP {
82 u8 stage[16]; /* DWORD 0 */
83 u8 rsvd0[10]; /* DWORD 0 */
84 u8 iscsi_driver_loaded; /* DWORD 0 */
85 u8 option_rom_installed; /* DWORD 0 */
86 u8 iscsi_ip_conflict; /* DWORD 0 */
87 u8 iscsi_no_ip; /* DWORD 0 */
88 u8 backup_fw; /* DWORD 0 */
89 u8 error; /* DWORD 0 */
90} __packed;
91struct MGMT_HBA_POST_STATUS_STRUCT_AMAP {
92 u32 dw[1];
93};
94
95/* --- MGMT_HBA_POST_DUMMY_BITS_ENUM --- */
96#define POST_BIT_ISCSI_LOADED (26)
97#define POST_BIT_OPTROM_INST (27)
98#define POST_BIT_BAD_IP_ADDR (28)
99#define POST_BIT_NO_IP_ADDR (29)
100#define POST_BIT_BACKUP_FW (30)
101#define POST_BIT_ERROR (31)
102
103/* --- MGMT_HBA_POST_DUMMY_VALUES_ENUM --- */
104#define POST_ISCSI_DRIVER_LOADED (67108864)
105#define POST_OPTROM_INSTALLED (134217728)
106#define POST_ISCSI_IP_ADDRESS_CONFLICT (268435456)
107#define POST_ISCSI_NO_IP_ADDRESS (536870912)
108#define POST_BACKUP_FW_LOADED (1073741824)
109#define POST_FATAL_ERROR (2147483648)
110
111#endif /* __post_codes_amap_h__ */
diff --git a/drivers/staging/benet/regmap.h b/drivers/staging/benet/regmap.h
deleted file mode 100644
index e816ba210e83..000000000000
--- a/drivers/staging/benet/regmap.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * Copyright (C) 2005 - 2008 ServerEngines
3 * All rights reserved.
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 version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17/*
18 * Autogenerated by srcgen version: 0127
19 */
20#ifndef __regmap_amap_h__
21#define __regmap_amap_h__
22#include "pcicfg.h"
23#include "ep.h"
24#include "cev.h"
25#include "mpu.h"
26#include "doorbells.h"
27
28/*
29 * This is the control and status register map for BladeEngine, showing
30 * the relative size and offset of each sub-module. The CSR registers
31 * are identical for the network and storage PCI functions. The
32 * CSR map is shown below, followed by details of each block,
33 * in sub-sections. The sub-sections begin with a description
34 * of CSRs that are instantiated in multiple blocks.
35 */
36struct BE_BLADE_ENGINE_CSRMAP_AMAP {
37 struct BE_MPU_CSRMAP_AMAP mpu;
38 u8 rsvd0[8192]; /* DWORD 256 */
39 u8 rsvd1[8192]; /* DWORD 512 */
40 struct BE_CEV_CSRMAP_AMAP cev;
41 u8 rsvd2[8192]; /* DWORD 1024 */
42 u8 rsvd3[8192]; /* DWORD 1280 */
43 u8 rsvd4[8192]; /* DWORD 1536 */
44 u8 rsvd5[8192]; /* DWORD 1792 */
45 u8 rsvd6[8192]; /* DWORD 2048 */
46 u8 rsvd7[8192]; /* DWORD 2304 */
47 u8 rsvd8[8192]; /* DWORD 2560 */
48 u8 rsvd9[8192]; /* DWORD 2816 */
49 u8 rsvd10[8192]; /* DWORD 3072 */
50 u8 rsvd11[8192]; /* DWORD 3328 */
51 u8 rsvd12[8192]; /* DWORD 3584 */
52 u8 rsvd13[8192]; /* DWORD 3840 */
53 u8 rsvd14[8192]; /* DWORD 4096 */
54 u8 rsvd15[8192]; /* DWORD 4352 */
55 u8 rsvd16[8192]; /* DWORD 4608 */
56 u8 rsvd17[8192]; /* DWORD 4864 */
57 u8 rsvd18[8192]; /* DWORD 5120 */
58 u8 rsvd19[8192]; /* DWORD 5376 */
59 u8 rsvd20[8192]; /* DWORD 5632 */
60 u8 rsvd21[8192]; /* DWORD 5888 */
61 u8 rsvd22[8192]; /* DWORD 6144 */
62 u8 rsvd23[17152][32]; /* DWORD 6400 */
63} __packed;
64struct BLADE_ENGINE_CSRMAP_AMAP {
65 u32 dw[23552];
66};
67
68#endif /* __regmap_amap_h__ */
diff --git a/drivers/staging/go7007/snd-go7007.c b/drivers/staging/go7007/snd-go7007.c
index a7de401f61ab..cd19be6c00e0 100644
--- a/drivers/staging/go7007/snd-go7007.c
+++ b/drivers/staging/go7007/snd-go7007.c
@@ -248,10 +248,11 @@ int go7007_snd_init(struct go7007 *go)
248 spin_lock_init(&gosnd->lock); 248 spin_lock_init(&gosnd->lock);
249 gosnd->hw_ptr = gosnd->w_idx = gosnd->avail = 0; 249 gosnd->hw_ptr = gosnd->w_idx = gosnd->avail = 0;
250 gosnd->capturing = 0; 250 gosnd->capturing = 0;
251 gosnd->card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 251 ret = snd_card_create(index[dev], id[dev], THIS_MODULE, 0,
252 if (gosnd->card == NULL) { 252 &gosnd->card);
253 if (ret < 0) {
253 kfree(gosnd); 254 kfree(gosnd);
254 return -ENOMEM; 255 return ret;
255 } 256 }
256 ret = snd_device_new(gosnd->card, SNDRV_DEV_LOWLEVEL, go, 257 ret = snd_device_new(gosnd->card, SNDRV_DEV_LOWLEVEL, go,
257 &go7007_snd_device_ops); 258 &go7007_snd_device_ops);
diff --git a/drivers/tc/tc.c b/drivers/tc/tc.c
index f77f62a4b325..e5bd4470a570 100644
--- a/drivers/tc/tc.c
+++ b/drivers/tc/tc.c
@@ -86,7 +86,7 @@ static void __init tc_bus_add_devices(struct tc_bus *tbus)
86 slot); 86 slot);
87 goto out_err; 87 goto out_err;
88 } 88 }
89 sprintf(tdev->dev.bus_id, "tc%x", slot); 89 dev_set_name(&tdev->dev, "tc%x", slot);
90 tdev->bus = tbus; 90 tdev->bus = tbus;
91 tdev->dev.parent = &tbus->dev; 91 tdev->dev.parent = &tbus->dev;
92 tdev->dev.bus = &tc_bus_type; 92 tdev->dev.bus = &tc_bus_type;
@@ -104,7 +104,7 @@ static void __init tc_bus_add_devices(struct tc_bus *tbus)
104 tdev->vendor[8] = 0; 104 tdev->vendor[8] = 0;
105 tdev->name[8] = 0; 105 tdev->name[8] = 0;
106 106
107 pr_info("%s: %s %s %s\n", tdev->dev.bus_id, tdev->vendor, 107 pr_info("%s: %s %s %s\n", dev_name(&tdev->dev), tdev->vendor,
108 tdev->name, tdev->firmware); 108 tdev->name, tdev->firmware);
109 109
110 devsize = readb(module + offset + TC_SLOT_SIZE); 110 devsize = readb(module + offset + TC_SLOT_SIZE);
@@ -118,7 +118,7 @@ static void __init tc_bus_add_devices(struct tc_bus *tbus)
118 } else { 118 } else {
119 printk(KERN_ERR "%s: Cannot provide slot space " 119 printk(KERN_ERR "%s: Cannot provide slot space "
120 "(%dMiB required, up to %dMiB supported)\n", 120 "(%dMiB required, up to %dMiB supported)\n",
121 tdev->dev.bus_id, devsize >> 20, 121 dev_name(&tdev->dev), devsize >> 20,
122 max(slotsize, extslotsize) >> 20); 122 max(slotsize, extslotsize) >> 20);
123 kfree(tdev); 123 kfree(tdev);
124 goto out_err; 124 goto out_err;
@@ -146,7 +146,7 @@ static int __init tc_init(void)
146 return 0; 146 return 0;
147 147
148 INIT_LIST_HEAD(&tc_bus.devices); 148 INIT_LIST_HEAD(&tc_bus.devices);
149 strcpy(tc_bus.dev.bus_id, "tc"); 149 dev_set_name(&tc_bus.dev, "tc");
150 device_register(&tc_bus.dev); 150 device_register(&tc_bus.dev);
151 151
152 if (tc_bus.info.slot_size) { 152 if (tc_bus.info.slot_size) {
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 04b954cfce76..7f86534de269 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -58,6 +58,24 @@ config UIO_SMX
58 58
59 If you compile this as a module, it will be called uio_smx. 59 If you compile this as a module, it will be called uio_smx.
60 60
61config UIO_AEC
62 tristate "AEC video timestamp device"
63 depends on PCI
64 default n
65 help
66
67 UIO driver for the Adrienne Electronics Corporation PCI time
68 code device.
69
70 This device differs from other UIO devices since it uses I/O
71 ports instead of memory mapped I/O. In order to make it
72 possible for UIO to work with this device a utility, uioport,
73 can be used to read and write the ports:
74
75 git clone git://ifup.org/philips/uioport.git
76
77 If you compile this as a module, it will be called uio_aec.
78
61config UIO_SERCOS3 79config UIO_SERCOS3
62 tristate "Automata Sercos III PCI card driver" 80 tristate "Automata Sercos III PCI card driver"
63 default n 81 default n
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index e69558149859..5c2586d75797 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -3,4 +3,5 @@ obj-$(CONFIG_UIO_CIF) += uio_cif.o
3obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o 3obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o
4obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o 4obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o
5obj-$(CONFIG_UIO_SMX) += uio_smx.o 5obj-$(CONFIG_UIO_SMX) += uio_smx.o
6obj-$(CONFIG_UIO_AEC) += uio_aec.o
6obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o 7obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 4ca85a113aa2..03efb065455f 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -61,6 +61,14 @@ struct uio_map {
61}; 61};
62#define to_map(map) container_of(map, struct uio_map, kobj) 62#define to_map(map) container_of(map, struct uio_map, kobj)
63 63
64static ssize_t map_name_show(struct uio_mem *mem, char *buf)
65{
66 if (unlikely(!mem->name))
67 mem->name = "";
68
69 return sprintf(buf, "%s\n", mem->name);
70}
71
64static ssize_t map_addr_show(struct uio_mem *mem, char *buf) 72static ssize_t map_addr_show(struct uio_mem *mem, char *buf)
65{ 73{
66 return sprintf(buf, "0x%lx\n", mem->addr); 74 return sprintf(buf, "0x%lx\n", mem->addr);
@@ -82,6 +90,8 @@ struct map_sysfs_entry {
82 ssize_t (*store)(struct uio_mem *, const char *, size_t); 90 ssize_t (*store)(struct uio_mem *, const char *, size_t);
83}; 91};
84 92
93static struct map_sysfs_entry name_attribute =
94 __ATTR(name, S_IRUGO, map_name_show, NULL);
85static struct map_sysfs_entry addr_attribute = 95static struct map_sysfs_entry addr_attribute =
86 __ATTR(addr, S_IRUGO, map_addr_show, NULL); 96 __ATTR(addr, S_IRUGO, map_addr_show, NULL);
87static struct map_sysfs_entry size_attribute = 97static struct map_sysfs_entry size_attribute =
@@ -90,6 +100,7 @@ static struct map_sysfs_entry offset_attribute =
90 __ATTR(offset, S_IRUGO, map_offset_show, NULL); 100 __ATTR(offset, S_IRUGO, map_offset_show, NULL);
91 101
92static struct attribute *attrs[] = { 102static struct attribute *attrs[] = {
103 &name_attribute.attr,
93 &addr_attribute.attr, 104 &addr_attribute.attr,
94 &size_attribute.attr, 105 &size_attribute.attr,
95 &offset_attribute.attr, 106 &offset_attribute.attr,
@@ -133,6 +144,14 @@ struct uio_portio {
133}; 144};
134#define to_portio(portio) container_of(portio, struct uio_portio, kobj) 145#define to_portio(portio) container_of(portio, struct uio_portio, kobj)
135 146
147static ssize_t portio_name_show(struct uio_port *port, char *buf)
148{
149 if (unlikely(!port->name))
150 port->name = "";
151
152 return sprintf(buf, "%s\n", port->name);
153}
154
136static ssize_t portio_start_show(struct uio_port *port, char *buf) 155static ssize_t portio_start_show(struct uio_port *port, char *buf)
137{ 156{
138 return sprintf(buf, "0x%lx\n", port->start); 157 return sprintf(buf, "0x%lx\n", port->start);
@@ -159,6 +178,8 @@ struct portio_sysfs_entry {
159 ssize_t (*store)(struct uio_port *, const char *, size_t); 178 ssize_t (*store)(struct uio_port *, const char *, size_t);
160}; 179};
161 180
181static struct portio_sysfs_entry portio_name_attribute =
182 __ATTR(name, S_IRUGO, portio_name_show, NULL);
162static struct portio_sysfs_entry portio_start_attribute = 183static struct portio_sysfs_entry portio_start_attribute =
163 __ATTR(start, S_IRUGO, portio_start_show, NULL); 184 __ATTR(start, S_IRUGO, portio_start_show, NULL);
164static struct portio_sysfs_entry portio_size_attribute = 185static struct portio_sysfs_entry portio_size_attribute =
@@ -167,6 +188,7 @@ static struct portio_sysfs_entry portio_porttype_attribute =
167 __ATTR(porttype, S_IRUGO, portio_porttype_show, NULL); 188 __ATTR(porttype, S_IRUGO, portio_porttype_show, NULL);
168 189
169static struct attribute *portio_attrs[] = { 190static struct attribute *portio_attrs[] = {
191 &portio_name_attribute.attr,
170 &portio_start_attribute.attr, 192 &portio_start_attribute.attr,
171 &portio_size_attribute.attr, 193 &portio_size_attribute.attr,
172 &portio_porttype_attribute.attr, 194 &portio_porttype_attribute.attr,
@@ -686,7 +708,8 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
686 return -EINVAL; 708 return -EINVAL;
687 709
688 requested_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; 710 requested_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
689 actual_pages = (idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT; 711 actual_pages = ((idev->info->mem[mi].addr & ~PAGE_MASK)
712 + idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT;
690 if (requested_pages > actual_pages) 713 if (requested_pages > actual_pages)
691 return -EINVAL; 714 return -EINVAL;
692 715
diff --git a/drivers/uio/uio_aec.c b/drivers/uio/uio_aec.c
new file mode 100644
index 000000000000..b7830e9a3baa
--- /dev/null
+++ b/drivers/uio/uio_aec.c
@@ -0,0 +1,175 @@
1/*
2 * uio_aec.c -- simple driver for Adrienne Electronics Corp time code PCI device
3 *
4 * Copyright (C) 2008 Brandon Philips <brandon@ifup.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc., 59
17 * Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/pci.h>
23#include <linux/init.h>
24#include <linux/interrupt.h>
25#include <linux/cdev.h>
26#include <linux/fs.h>
27#include <linux/io.h>
28#include <linux/uaccess.h>
29#include <linux/uio_driver.h>
30
31#define PCI_VENDOR_ID_AEC 0xaecb
32#define PCI_DEVICE_ID_AEC_VITCLTC 0x6250
33
34#define INT_ENABLE_ADDR 0xFC
35#define INT_ENABLE 0x10
36#define INT_DISABLE 0x0
37
38#define INT_MASK_ADDR 0x2E
39#define INT_MASK_ALL 0x3F
40
41#define INTA_DRVR_ADDR 0xFE
42#define INTA_ENABLED_FLAG 0x08
43#define INTA_FLAG 0x01
44
45#define MAILBOX 0x0F
46
47static struct pci_device_id ids[] = {
48 { PCI_DEVICE(PCI_VENDOR_ID_AEC, PCI_DEVICE_ID_AEC_VITCLTC), },
49 { 0, }
50};
51MODULE_DEVICE_TABLE(pci, ids);
52
53static irqreturn_t aectc_irq(int irq, struct uio_info *dev_info)
54{
55 void __iomem *int_flag = dev_info->priv + INTA_DRVR_ADDR;
56 unsigned char status = ioread8(int_flag);
57
58
59 if ((status & INTA_ENABLED_FLAG) && (status & INTA_FLAG)) {
60 /* application writes 0x00 to 0x2F to get next interrupt */
61 status = ioread8(dev_info->priv + MAILBOX);
62 return IRQ_HANDLED;
63 }
64
65 return IRQ_NONE;
66}
67
68static void print_board_data(struct pci_dev *pdev, struct uio_info *i)
69{
70 dev_info(&pdev->dev, "PCI-TC board vendor: %x%x number: %x%x"
71 " revision: %c%c\n",
72 ioread8(i->priv + 0x01),
73 ioread8(i->priv + 0x00),
74 ioread8(i->priv + 0x03),
75 ioread8(i->priv + 0x02),
76 ioread8(i->priv + 0x06),
77 ioread8(i->priv + 0x07));
78}
79
80static int __devinit probe(struct pci_dev *pdev, const struct pci_device_id *id)
81{
82 struct uio_info *info;
83 int ret;
84
85 info = kzalloc(sizeof(struct uio_info), GFP_KERNEL);
86 if (!info)
87 return -ENOMEM;
88
89 if (pci_enable_device(pdev))
90 goto out_free;
91
92 if (pci_request_regions(pdev, "aectc"))
93 goto out_disable;
94
95 info->name = "aectc";
96 info->port[0].start = pci_resource_start(pdev, 0);
97 if (!info->port[0].start)
98 goto out_release;
99 info->priv = pci_iomap(pdev, 0, 0);
100 if (!info->priv)
101 goto out_release;
102 info->port[0].size = pci_resource_len(pdev, 0);
103 info->port[0].porttype = UIO_PORT_GPIO;
104
105 info->version = "0.0.1";
106 info->irq = pdev->irq;
107 info->irq_flags = IRQF_SHARED;
108 info->handler = aectc_irq;
109
110 print_board_data(pdev, info);
111 ret = uio_register_device(&pdev->dev, info);
112 if (ret)
113 goto out_unmap;
114
115 iowrite32(INT_ENABLE, info->priv + INT_ENABLE_ADDR);
116 iowrite8(INT_MASK_ALL, info->priv + INT_MASK_ADDR);
117 if (!(ioread8(info->priv + INTA_DRVR_ADDR)
118 & INTA_ENABLED_FLAG))
119 dev_err(&pdev->dev, "aectc: interrupts not enabled\n");
120
121 pci_set_drvdata(pdev, info);
122
123 return 0;
124
125out_unmap:
126 pci_iounmap(pdev, info->priv);
127out_release:
128 pci_release_regions(pdev);
129out_disable:
130 pci_disable_device(pdev);
131out_free:
132 kfree(info);
133 return -ENODEV;
134}
135
136static void remove(struct pci_dev *pdev)
137{
138 struct uio_info *info = pci_get_drvdata(pdev);
139
140 /* disable interrupts */
141 iowrite8(INT_DISABLE, info->priv + INT_MASK_ADDR);
142 iowrite32(INT_DISABLE, info->priv + INT_ENABLE_ADDR);
143 /* read mailbox to ensure board drops irq */
144 ioread8(info->priv + MAILBOX);
145
146 uio_unregister_device(info);
147 pci_release_regions(pdev);
148 pci_disable_device(pdev);
149 pci_set_drvdata(pdev, NULL);
150 iounmap(info->priv);
151
152 kfree(info);
153}
154
155static struct pci_driver pci_driver = {
156 .name = "aectc",
157 .id_table = ids,
158 .probe = probe,
159 .remove = remove,
160};
161
162static int __init aectc_init(void)
163{
164 return pci_register_driver(&pci_driver);
165}
166
167static void __exit aectc_exit(void)
168{
169 pci_unregister_driver(&pci_driver);
170}
171
172MODULE_LICENSE("GPL");
173
174module_init(aectc_init);
175module_exit(aectc_exit);
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 83babb0a1df7..c6c816b7ecb5 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -47,6 +47,7 @@ config USB_ARCH_HAS_OHCI
47 default y if CPU_SUBTYPE_SH7720 47 default y if CPU_SUBTYPE_SH7720
48 default y if CPU_SUBTYPE_SH7721 48 default y if CPU_SUBTYPE_SH7721
49 default y if CPU_SUBTYPE_SH7763 49 default y if CPU_SUBTYPE_SH7763
50 default y if CPU_SUBTYPE_SH7786
50 # more: 51 # more:
51 default PCI 52 default PCI
52 53
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index b2ceb4aff233..89299a5ce168 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_USB_SL811_HCD) += host/
19obj-$(CONFIG_USB_U132_HCD) += host/ 19obj-$(CONFIG_USB_U132_HCD) += host/
20obj-$(CONFIG_USB_R8A66597_HCD) += host/ 20obj-$(CONFIG_USB_R8A66597_HCD) += host/
21obj-$(CONFIG_USB_HWA_HCD) += host/ 21obj-$(CONFIG_USB_HWA_HCD) += host/
22obj-$(CONFIG_USB_ISP1760_HCD) += host/
22 23
23obj-$(CONFIG_USB_C67X00_HCD) += c67x00/ 24obj-$(CONFIG_USB_C67X00_HCD) += c67x00/
24 25
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 5ed4ae07bac1..6789089e2461 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -485,7 +485,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
485 usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n", 485 usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
486 wbuflen, rbuflen); 486 wbuflen, rbuflen);
487 ret = -ENOMEM; 487 ret = -ENOMEM;
488 goto fail; 488 goto err;
489 } 489 }
490 490
491 mutex_lock(&instance->cm_serialize); 491 mutex_lock(&instance->cm_serialize);
@@ -565,6 +565,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
565 dbg("cm %#x", cm); 565 dbg("cm %#x", cm);
566fail: 566fail:
567 mutex_unlock(&instance->cm_serialize); 567 mutex_unlock(&instance->cm_serialize);
568err:
568 return ret; 569 return ret;
569} 570}
570 571
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 3f3ee1351930..d2747a49b974 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -880,16 +880,19 @@ static int usblp_wwait(struct usblp *usblp, int nonblock)
880 if (rc <= 0) 880 if (rc <= 0)
881 break; 881 break;
882 882
883 if (usblp->flags & LP_ABORT) { 883 if (schedule_timeout(msecs_to_jiffies(1500)) == 0) {
884 if (schedule_timeout(msecs_to_jiffies(5000)) == 0) { 884 if (usblp->flags & LP_ABORT) {
885 err = usblp_check_status(usblp, err); 885 err = usblp_check_status(usblp, err);
886 if (err == 1) { /* Paper out */ 886 if (err == 1) { /* Paper out */
887 rc = -ENOSPC; 887 rc = -ENOSPC;
888 break; 888 break;
889 } 889 }
890 } else {
891 /* Prod the printer, Gentoo#251237. */
892 mutex_lock(&usblp->mut);
893 usblp_read_status(usblp, usblp->statusbuf);
894 mutex_unlock(&usblp->mut);
890 } 895 }
891 } else {
892 schedule();
893 } 896 }
894 } 897 }
895 set_current_state(TASK_RUNNING); 898 set_current_state(TASK_RUNNING);
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 0f5c05f6f9df..c40a9b284cc9 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -50,6 +50,7 @@
50 50
51static struct usb_device_id usbtmc_devices[] = { 51static struct usb_device_id usbtmc_devices[] = {
52 { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 0), }, 52 { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 0), },
53 { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 1), },
53 { 0, } /* terminating entry */ 54 { 0, } /* terminating entry */
54}; 55};
55MODULE_DEVICE_TABLE(usb, usbtmc_devices); 56MODULE_DEVICE_TABLE(usb, usbtmc_devices);
@@ -106,12 +107,13 @@ static int usbtmc_open(struct inode *inode, struct file *filp)
106{ 107{
107 struct usb_interface *intf; 108 struct usb_interface *intf;
108 struct usbtmc_device_data *data; 109 struct usbtmc_device_data *data;
109 int retval = -ENODEV; 110 int retval = 0;
110 111
111 intf = usb_find_interface(&usbtmc_driver, iminor(inode)); 112 intf = usb_find_interface(&usbtmc_driver, iminor(inode));
112 if (!intf) { 113 if (!intf) {
113 printk(KERN_ERR KBUILD_MODNAME 114 printk(KERN_ERR KBUILD_MODNAME
114 ": can not find device for minor %d", iminor(inode)); 115 ": can not find device for minor %d", iminor(inode));
116 retval = -ENODEV;
115 goto exit; 117 goto exit;
116 } 118 }
117 119
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 6ec38175a817..73c108d117b4 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -187,7 +187,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
187 } 187 }
188 188
189 /* this isn't checking for illegal values */ 189 /* this isn't checking for illegal values */
190 switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 190 switch (usb_endpoint_type(desc)) {
191 case USB_ENDPOINT_XFER_CONTROL: 191 case USB_ENDPOINT_XFER_CONTROL:
192 type = "Ctrl"; 192 type = "Ctrl";
193 if (speed == USB_SPEED_HIGH) /* uframes per NAK */ 193 if (speed == USB_SPEED_HIGH) /* uframes per NAK */
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 7513bb083c15..df3c539f652a 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -104,7 +104,7 @@ MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic");
104 104
105#define MAX_USBFS_BUFFER_SIZE 16384 105#define MAX_USBFS_BUFFER_SIZE 16384
106 106
107static inline int connected(struct dev_state *ps) 107static int connected(struct dev_state *ps)
108{ 108{
109 return (!list_empty(&ps->list) && 109 return (!list_empty(&ps->list) &&
110 ps->dev->state != USB_STATE_NOTATTACHED); 110 ps->dev->state != USB_STATE_NOTATTACHED);
@@ -248,7 +248,7 @@ static void free_async(struct async *as)
248 kfree(as); 248 kfree(as);
249} 249}
250 250
251static inline void async_newpending(struct async *as) 251static void async_newpending(struct async *as)
252{ 252{
253 struct dev_state *ps = as->ps; 253 struct dev_state *ps = as->ps;
254 unsigned long flags; 254 unsigned long flags;
@@ -258,7 +258,7 @@ static inline void async_newpending(struct async *as)
258 spin_unlock_irqrestore(&ps->lock, flags); 258 spin_unlock_irqrestore(&ps->lock, flags);
259} 259}
260 260
261static inline void async_removepending(struct async *as) 261static void async_removepending(struct async *as)
262{ 262{
263 struct dev_state *ps = as->ps; 263 struct dev_state *ps = as->ps;
264 unsigned long flags; 264 unsigned long flags;
@@ -268,7 +268,7 @@ static inline void async_removepending(struct async *as)
268 spin_unlock_irqrestore(&ps->lock, flags); 268 spin_unlock_irqrestore(&ps->lock, flags);
269} 269}
270 270
271static inline struct async *async_getcompleted(struct dev_state *ps) 271static struct async *async_getcompleted(struct dev_state *ps)
272{ 272{
273 unsigned long flags; 273 unsigned long flags;
274 struct async *as = NULL; 274 struct async *as = NULL;
@@ -283,7 +283,7 @@ static inline struct async *async_getcompleted(struct dev_state *ps)
283 return as; 283 return as;
284} 284}
285 285
286static inline struct async *async_getpending(struct dev_state *ps, 286static struct async *async_getpending(struct dev_state *ps,
287 void __user *userurb) 287 void __user *userurb)
288{ 288{
289 unsigned long flags; 289 unsigned long flags;
@@ -302,7 +302,7 @@ static inline struct async *async_getpending(struct dev_state *ps,
302 302
303static void snoop_urb(struct urb *urb, void __user *userurb) 303static void snoop_urb(struct urb *urb, void __user *userurb)
304{ 304{
305 int j; 305 unsigned j;
306 unsigned char *data = urb->transfer_buffer; 306 unsigned char *data = urb->transfer_buffer;
307 307
308 if (!usbfs_snoop) 308 if (!usbfs_snoop)
@@ -311,9 +311,9 @@ static void snoop_urb(struct urb *urb, void __user *userurb)
311 dev_info(&urb->dev->dev, "direction=%s\n", 311 dev_info(&urb->dev->dev, "direction=%s\n",
312 usb_urb_dir_in(urb) ? "IN" : "OUT"); 312 usb_urb_dir_in(urb) ? "IN" : "OUT");
313 dev_info(&urb->dev->dev, "userurb=%p\n", userurb); 313 dev_info(&urb->dev->dev, "userurb=%p\n", userurb);
314 dev_info(&urb->dev->dev, "transfer_buffer_length=%d\n", 314 dev_info(&urb->dev->dev, "transfer_buffer_length=%u\n",
315 urb->transfer_buffer_length); 315 urb->transfer_buffer_length);
316 dev_info(&urb->dev->dev, "actual_length=%d\n", urb->actual_length); 316 dev_info(&urb->dev->dev, "actual_length=%u\n", urb->actual_length);
317 dev_info(&urb->dev->dev, "data: "); 317 dev_info(&urb->dev->dev, "data: ");
318 for (j = 0; j < urb->transfer_buffer_length; ++j) 318 for (j = 0; j < urb->transfer_buffer_length; ++j)
319 printk("%02x ", data[j]); 319 printk("%02x ", data[j]);
@@ -359,11 +359,6 @@ static void destroy_async(struct dev_state *ps, struct list_head *list)
359 spin_lock_irqsave(&ps->lock, flags); 359 spin_lock_irqsave(&ps->lock, flags);
360 } 360 }
361 spin_unlock_irqrestore(&ps->lock, flags); 361 spin_unlock_irqrestore(&ps->lock, flags);
362 as = async_getcompleted(ps);
363 while (as) {
364 free_async(as);
365 as = async_getcompleted(ps);
366 }
367} 362}
368 363
369static void destroy_async_on_interface(struct dev_state *ps, 364static void destroy_async_on_interface(struct dev_state *ps,
@@ -381,7 +376,7 @@ static void destroy_async_on_interface(struct dev_state *ps,
381 destroy_async(ps, &hitlist); 376 destroy_async(ps, &hitlist);
382} 377}
383 378
384static inline void destroy_all_async(struct dev_state *ps) 379static void destroy_all_async(struct dev_state *ps)
385{ 380{
386 destroy_async(ps, &ps->async_pending); 381 destroy_async(ps, &ps->async_pending);
387} 382}
@@ -530,7 +525,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
530{ 525{
531 int ret = 0; 526 int ret = 0;
532 527
533 if (ps->dev->state != USB_STATE_ADDRESS 528 if (ps->dev->state != USB_STATE_UNAUTHENTICATED
529 && ps->dev->state != USB_STATE_ADDRESS
534 && ps->dev->state != USB_STATE_CONFIGURED) 530 && ps->dev->state != USB_STATE_CONFIGURED)
535 return -EHOSTUNREACH; 531 return -EHOSTUNREACH;
536 if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype)) 532 if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype))
@@ -643,6 +639,7 @@ static int usbdev_release(struct inode *inode, struct file *file)
643 struct dev_state *ps = file->private_data; 639 struct dev_state *ps = file->private_data;
644 struct usb_device *dev = ps->dev; 640 struct usb_device *dev = ps->dev;
645 unsigned int ifnum; 641 unsigned int ifnum;
642 struct async *as;
646 643
647 usb_lock_device(dev); 644 usb_lock_device(dev);
648 645
@@ -661,6 +658,12 @@ static int usbdev_release(struct inode *inode, struct file *file)
661 usb_unlock_device(dev); 658 usb_unlock_device(dev);
662 usb_put_dev(dev); 659 usb_put_dev(dev);
663 put_pid(ps->disc_pid); 660 put_pid(ps->disc_pid);
661
662 as = async_getcompleted(ps);
663 while (as) {
664 free_async(as);
665 as = async_getcompleted(ps);
666 }
664 kfree(ps); 667 kfree(ps);
665 return 0; 668 return 0;
666} 669}
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index e1710f260b4f..40dee2ac0133 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -66,7 +66,7 @@ static ssize_t show_ep_type(struct device *dev, struct device_attribute *attr,
66 struct ep_device *ep = to_ep_device(dev); 66 struct ep_device *ep = to_ep_device(dev);
67 char *type = "unknown"; 67 char *type = "unknown";
68 68
69 switch (ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 69 switch (usb_endpoint_type(ep->desc)) {
70 case USB_ENDPOINT_XFER_CONTROL: 70 case USB_ENDPOINT_XFER_CONTROL:
71 type = "Control"; 71 type = "Control";
72 break; 72 break;
@@ -94,7 +94,7 @@ static ssize_t show_ep_interval(struct device *dev,
94 94
95 in = (ep->desc->bEndpointAddress & USB_DIR_IN); 95 in = (ep->desc->bEndpointAddress & USB_DIR_IN);
96 96
97 switch (ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 97 switch (usb_endpoint_type(ep->desc)) {
98 case USB_ENDPOINT_XFER_CONTROL: 98 case USB_ENDPOINT_XFER_CONTROL:
99 if (ep->udev->speed == USB_SPEED_HIGH) /* uframes per NAK */ 99 if (ep->udev->speed == USB_SPEED_HIGH) /* uframes per NAK */
100 interval = ep->desc->bInterval; 100 interval = ep->desc->bInterval;
@@ -131,10 +131,9 @@ static ssize_t show_ep_direction(struct device *dev,
131 struct ep_device *ep = to_ep_device(dev); 131 struct ep_device *ep = to_ep_device(dev);
132 char *direction; 132 char *direction;
133 133
134 if ((ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 134 if (usb_endpoint_xfer_control(ep->desc))
135 USB_ENDPOINT_XFER_CONTROL)
136 direction = "both"; 135 direction = "both";
137 else if (ep->desc->bEndpointAddress & USB_DIR_IN) 136 else if (usb_endpoint_dir_in(ep->desc))
138 direction = "in"; 137 direction = "in";
139 else 138 else
140 direction = "out"; 139 direction = "out";
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 3c711db55d86..81fa8506825d 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -279,9 +279,9 @@ static const u8 hs_rh_config_descriptor [] = {
279 * helper routine for returning string descriptors in UTF-16LE 279 * helper routine for returning string descriptors in UTF-16LE
280 * input can actually be ISO-8859-1; ASCII is its 7-bit subset 280 * input can actually be ISO-8859-1; ASCII is its 7-bit subset
281 */ 281 */
282static int ascii2utf (char *s, u8 *utf, int utfmax) 282static unsigned ascii2utf(char *s, u8 *utf, int utfmax)
283{ 283{
284 int retval; 284 unsigned retval;
285 285
286 for (retval = 0; *s && utfmax > 1; utfmax -= 2, retval += 2) { 286 for (retval = 0; *s && utfmax > 1; utfmax -= 2, retval += 2) {
287 *utf++ = *s++; 287 *utf++ = *s++;
@@ -304,19 +304,15 @@ static int ascii2utf (char *s, u8 *utf, int utfmax)
304 * Produces either a manufacturer, product or serial number string for the 304 * Produces either a manufacturer, product or serial number string for the
305 * virtual root hub device. 305 * virtual root hub device.
306 */ 306 */
307static int rh_string ( 307static unsigned rh_string(int id, struct usb_hcd *hcd, u8 *data, unsigned len)
308 int id, 308{
309 struct usb_hcd *hcd,
310 u8 *data,
311 int len
312) {
313 char buf [100]; 309 char buf [100];
314 310
315 // language ids 311 // language ids
316 if (id == 0) { 312 if (id == 0) {
317 buf[0] = 4; buf[1] = 3; /* 4 bytes string data */ 313 buf[0] = 4; buf[1] = 3; /* 4 bytes string data */
318 buf[2] = 0x09; buf[3] = 0x04; /* MSFT-speak for "en-us" */ 314 buf[2] = 0x09; buf[3] = 0x04; /* MSFT-speak for "en-us" */
319 len = min (len, 4); 315 len = min_t(unsigned, len, 4);
320 memcpy (data, buf, len); 316 memcpy (data, buf, len);
321 return len; 317 return len;
322 318
@@ -332,10 +328,7 @@ static int rh_string (
332 } else if (id == 3) { 328 } else if (id == 3) {
333 snprintf (buf, sizeof buf, "%s %s %s", init_utsname()->sysname, 329 snprintf (buf, sizeof buf, "%s %s %s", init_utsname()->sysname,
334 init_utsname()->release, hcd->driver->description); 330 init_utsname()->release, hcd->driver->description);
335 331 }
336 // unsupported IDs --> "protocol stall"
337 } else
338 return -EPIPE;
339 332
340 switch (len) { /* All cases fall through */ 333 switch (len) { /* All cases fall through */
341 default: 334 default:
@@ -360,9 +353,8 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
360 u8 tbuf [sizeof (struct usb_hub_descriptor)] 353 u8 tbuf [sizeof (struct usb_hub_descriptor)]
361 __attribute__((aligned(4))); 354 __attribute__((aligned(4)));
362 const u8 *bufp = tbuf; 355 const u8 *bufp = tbuf;
363 int len = 0; 356 unsigned len = 0;
364 int status; 357 int status;
365 int n;
366 u8 patch_wakeup = 0; 358 u8 patch_wakeup = 0;
367 u8 patch_protocol = 0; 359 u8 patch_protocol = 0;
368 360
@@ -456,10 +448,11 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
456 patch_wakeup = 1; 448 patch_wakeup = 1;
457 break; 449 break;
458 case USB_DT_STRING << 8: 450 case USB_DT_STRING << 8:
459 n = rh_string (wValue & 0xff, hcd, ubuf, wLength); 451 if ((wValue & 0xff) < 4)
460 if (n < 0) 452 urb->actual_length = rh_string(wValue & 0xff,
453 hcd, ubuf, wLength);
454 else /* unsupported IDs --> "protocol stall" */
461 goto error; 455 goto error;
462 urb->actual_length = n;
463 break; 456 break;
464 default: 457 default:
465 goto error; 458 goto error;
@@ -629,7 +622,7 @@ static int rh_queue_status (struct usb_hcd *hcd, struct urb *urb)
629{ 622{
630 int retval; 623 int retval;
631 unsigned long flags; 624 unsigned long flags;
632 int len = 1 + (urb->dev->maxchild / 8); 625 unsigned len = 1 + (urb->dev->maxchild / 8);
633 626
634 spin_lock_irqsave (&hcd_root_hub_lock, flags); 627 spin_lock_irqsave (&hcd_root_hub_lock, flags);
635 if (hcd->status_urb || urb->transfer_buffer_length < len) { 628 if (hcd->status_urb || urb->transfer_buffer_length < len) {
@@ -901,7 +894,7 @@ static int register_root_hub(struct usb_hcd *hcd)
901 894
902 mutex_lock(&usb_bus_list_lock); 895 mutex_lock(&usb_bus_list_lock);
903 896
904 usb_dev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); 897 usb_dev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
905 retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE); 898 retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE);
906 if (retval != sizeof usb_dev->descriptor) { 899 if (retval != sizeof usb_dev->descriptor) {
907 mutex_unlock(&usb_bus_list_lock); 900 mutex_unlock(&usb_bus_list_lock);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index cd50d86029e7..be86ae3f4088 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -392,7 +392,7 @@ static void hub_irq(struct urb *urb)
392{ 392{
393 struct usb_hub *hub = urb->context; 393 struct usb_hub *hub = urb->context;
394 int status = urb->status; 394 int status = urb->status;
395 int i; 395 unsigned i;
396 unsigned long bits; 396 unsigned long bits;
397 397
398 switch (status) { 398 switch (status) {
@@ -1305,6 +1305,7 @@ void usb_set_device_state(struct usb_device *udev,
1305 recursively_mark_NOTATTACHED(udev); 1305 recursively_mark_NOTATTACHED(udev);
1306 spin_unlock_irqrestore(&device_state_lock, flags); 1306 spin_unlock_irqrestore(&device_state_lock, flags);
1307} 1307}
1308EXPORT_SYMBOL_GPL(usb_set_device_state);
1308 1309
1309/* 1310/*
1310 * WUSB devices are simple: they have no hubs behind, so the mapping 1311 * WUSB devices are simple: they have no hubs behind, so the mapping
@@ -2471,20 +2472,20 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2471 */ 2472 */
2472 switch (udev->speed) { 2473 switch (udev->speed) {
2473 case USB_SPEED_VARIABLE: /* fixed at 512 */ 2474 case USB_SPEED_VARIABLE: /* fixed at 512 */
2474 udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(512); 2475 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512);
2475 break; 2476 break;
2476 case USB_SPEED_HIGH: /* fixed at 64 */ 2477 case USB_SPEED_HIGH: /* fixed at 64 */
2477 udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); 2478 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
2478 break; 2479 break;
2479 case USB_SPEED_FULL: /* 8, 16, 32, or 64 */ 2480 case USB_SPEED_FULL: /* 8, 16, 32, or 64 */
2480 /* to determine the ep0 maxpacket size, try to read 2481 /* to determine the ep0 maxpacket size, try to read
2481 * the device descriptor to get bMaxPacketSize0 and 2482 * the device descriptor to get bMaxPacketSize0 and
2482 * then correct our initial guess. 2483 * then correct our initial guess.
2483 */ 2484 */
2484 udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); 2485 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
2485 break; 2486 break;
2486 case USB_SPEED_LOW: /* fixed at 8 */ 2487 case USB_SPEED_LOW: /* fixed at 8 */
2487 udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(8); 2488 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(8);
2488 break; 2489 break;
2489 default: 2490 default:
2490 goto fail; 2491 goto fail;
@@ -3392,10 +3393,10 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
3392 udev->descriptor = descriptor; /* for disconnect() calls */ 3393 udev->descriptor = descriptor; /* for disconnect() calls */
3393 goto re_enumerate; 3394 goto re_enumerate;
3394 } 3395 }
3395 3396
3397 /* Restore the device's previous configuration */
3396 if (!udev->actconfig) 3398 if (!udev->actconfig)
3397 goto done; 3399 goto done;
3398
3399 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 3400 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
3400 USB_REQ_SET_CONFIGURATION, 0, 3401 USB_REQ_SET_CONFIGURATION, 0,
3401 udev->actconfig->desc.bConfigurationValue, 0, 3402 udev->actconfig->desc.bConfigurationValue, 0,
@@ -3408,16 +3409,25 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
3408 } 3409 }
3409 usb_set_device_state(udev, USB_STATE_CONFIGURED); 3410 usb_set_device_state(udev, USB_STATE_CONFIGURED);
3410 3411
3412 /* Put interfaces back into the same altsettings as before.
3413 * Don't bother to send the Set-Interface request for interfaces
3414 * that were already in altsetting 0; besides being unnecessary,
3415 * many devices can't handle it. Instead just reset the host-side
3416 * endpoint state.
3417 */
3411 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 3418 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
3412 struct usb_interface *intf = udev->actconfig->interface[i]; 3419 struct usb_interface *intf = udev->actconfig->interface[i];
3413 struct usb_interface_descriptor *desc; 3420 struct usb_interface_descriptor *desc;
3414 3421
3415 /* set_interface resets host side toggle even
3416 * for altsetting zero. the interface may have no driver.
3417 */
3418 desc = &intf->cur_altsetting->desc; 3422 desc = &intf->cur_altsetting->desc;
3419 ret = usb_set_interface(udev, desc->bInterfaceNumber, 3423 if (desc->bAlternateSetting == 0) {
3420 desc->bAlternateSetting); 3424 usb_disable_interface(udev, intf, true);
3425 usb_enable_interface(udev, intf, true);
3426 ret = 0;
3427 } else {
3428 ret = usb_set_interface(udev, desc->bInterfaceNumber,
3429 desc->bAlternateSetting);
3430 }
3421 if (ret < 0) { 3431 if (ret < 0) {
3422 dev_err(&udev->dev, "failed to restore interface %d " 3432 dev_err(&udev->dev, "failed to restore interface %d "
3423 "altsetting %d (error=%d)\n", 3433 "altsetting %d (error=%d)\n",
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 49e7f56e0d7f..30a0690f3683 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -59,7 +59,7 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
59 retval = (ctx.status == -ENOENT ? -ETIMEDOUT : ctx.status); 59 retval = (ctx.status == -ENOENT ? -ETIMEDOUT : ctx.status);
60 60
61 dev_dbg(&urb->dev->dev, 61 dev_dbg(&urb->dev->dev,
62 "%s timed out on ep%d%s len=%d/%d\n", 62 "%s timed out on ep%d%s len=%u/%u\n",
63 current->comm, 63 current->comm,
64 usb_endpoint_num(&urb->ep->desc), 64 usb_endpoint_num(&urb->ep->desc),
65 usb_urb_dir_in(urb) ? "in" : "out", 65 usb_urb_dir_in(urb) ? "in" : "out",
@@ -804,18 +804,16 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
804 dev_err(&dev->dev, 804 dev_err(&dev->dev,
805 "string descriptor 0 read error: %d\n", 805 "string descriptor 0 read error: %d\n",
806 err); 806 err);
807 goto errout;
808 } else if (err < 4) { 807 } else if (err < 4) {
809 dev_err(&dev->dev, "string descriptor 0 too short\n"); 808 dev_err(&dev->dev, "string descriptor 0 too short\n");
810 err = -EINVAL;
811 goto errout;
812 } else { 809 } else {
813 dev->have_langid = 1;
814 dev->string_langid = tbuf[2] | (tbuf[3] << 8); 810 dev->string_langid = tbuf[2] | (tbuf[3] << 8);
815 /* always use the first langid listed */ 811 /* always use the first langid listed */
816 dev_dbg(&dev->dev, "default language 0x%04x\n", 812 dev_dbg(&dev->dev, "default language 0x%04x\n",
817 dev->string_langid); 813 dev->string_langid);
818 } 814 }
815
816 dev->have_langid = 1;
819 } 817 }
820 818
821 err = usb_string_sub(dev, dev->string_langid, index, tbuf); 819 err = usb_string_sub(dev, dev->string_langid, index, tbuf);
@@ -1719,7 +1717,8 @@ free_interfaces:
1719 } 1717 }
1720 kfree(new_interfaces); 1718 kfree(new_interfaces);
1721 1719
1722 if (cp->string == NULL) 1720 if (cp->string == NULL &&
1721 !(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS))
1723 cp->string = usb_cache_string(dev, cp->desc.iConfiguration); 1722 cp->string = usb_cache_string(dev, cp->desc.iConfiguration);
1724 1723
1725 /* Now that all the interfaces are set up, register them 1724 /* Now that all the interfaces are set up, register them
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index c070b34b669d..ab93918d9207 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -54,6 +54,10 @@ static const struct usb_device_id usb_quirk_list[] = {
54 { USB_DEVICE(0x0638, 0x0a13), .driver_info = 54 { USB_DEVICE(0x0638, 0x0a13), .driver_info =
55 USB_QUIRK_STRING_FETCH_255 }, 55 USB_QUIRK_STRING_FETCH_255 },
56 56
57 /* Saitek Cyborg Gold Joystick */
58 { USB_DEVICE(0x06a3, 0x0006), .driver_info =
59 USB_QUIRK_CONFIG_INTF_STRINGS },
60
57 /* M-Systems Flash Disk Pioneers */ 61 /* M-Systems Flash Disk Pioneers */
58 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, 62 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
59 63
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 4cc2456ef3be..c66789197927 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include <linux/usb/quirks.h>
16#include "usb.h" 17#include "usb.h"
17 18
18/* Active configuration fields */ 19/* Active configuration fields */
@@ -813,7 +814,8 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
813 if (intf->sysfs_files_created || intf->unregistering) 814 if (intf->sysfs_files_created || intf->unregistering)
814 return 0; 815 return 0;
815 816
816 if (alt->string == NULL) 817 if (alt->string == NULL &&
818 !(udev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS))
817 alt->string = usb_cache_string(udev, alt->desc.iInterface); 819 alt->string = usb_cache_string(udev, alt->desc.iInterface);
818 if (alt->string) 820 if (alt->string)
819 retval = device_create_file(&intf->dev, &dev_attr_interface); 821 retval = device_create_file(&intf->dev, &dev_attr_interface);
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 58bc5e3c2560..3376055f36e7 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -295,7 +295,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
295 if (!urb || urb->hcpriv || !urb->complete) 295 if (!urb || urb->hcpriv || !urb->complete)
296 return -EINVAL; 296 return -EINVAL;
297 dev = urb->dev; 297 dev = urb->dev;
298 if ((!dev) || (dev->state < USB_STATE_DEFAULT)) 298 if ((!dev) || (dev->state < USB_STATE_UNAUTHENTICATED))
299 return -ENODEV; 299 return -ENODEV;
300 300
301 /* For now, get the endpoint from the pipe. Eventually drivers 301 /* For now, get the endpoint from the pipe. Eventually drivers
@@ -370,7 +370,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
370 } 370 }
371 371
372 /* the I/O buffer must be mapped/unmapped, except when length=0 */ 372 /* the I/O buffer must be mapped/unmapped, except when length=0 */
373 if (urb->transfer_buffer_length < 0) 373 if (urb->transfer_buffer_length > INT_MAX)
374 return -EMSGSIZE; 374 return -EMSGSIZE;
375 375
376#ifdef DEBUG 376#ifdef DEBUG
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index e55fef52a5dc..770b3eaa9184 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -254,6 +254,7 @@ config USB_PXA25X_SMALL
254config USB_GADGET_PXA27X 254config USB_GADGET_PXA27X
255 boolean "PXA 27x" 255 boolean "PXA 27x"
256 depends on ARCH_PXA && PXA27x 256 depends on ARCH_PXA && PXA27x
257 select USB_OTG_UTILS
257 help 258 help
258 Intel's PXA 27x series XScale ARM v5TE processors include 259 Intel's PXA 27x series XScale ARM v5TE processors include
259 an integrated full speed USB 1.1 device controller. 260 an integrated full speed USB 1.1 device controller.
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index abf8192f89e8..826f3adde5d8 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -551,7 +551,7 @@ udc_alloc_request(struct usb_ep *usbep, gfp_t gfp)
551 dma_desc->status = AMD_ADDBITS(dma_desc->status, 551 dma_desc->status = AMD_ADDBITS(dma_desc->status,
552 UDC_DMA_STP_STS_BS_HOST_BUSY, 552 UDC_DMA_STP_STS_BS_HOST_BUSY,
553 UDC_DMA_STP_STS_BS); 553 UDC_DMA_STP_STS_BS);
554 dma_desc->bufptr = __constant_cpu_to_le32(DMA_DONT_USE); 554 dma_desc->bufptr = cpu_to_le32(DMA_DONT_USE);
555 req->td_data = dma_desc; 555 req->td_data = dma_desc;
556 req->td_data_last = NULL; 556 req->td_data_last = NULL;
557 req->chain_len = 1; 557 req->chain_len = 1;
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 65b03e3445a1..c22fab164113 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1017,7 +1017,7 @@ static struct usb_endpoint_descriptor usba_ep0_desc = {
1017 .bDescriptorType = USB_DT_ENDPOINT, 1017 .bDescriptorType = USB_DT_ENDPOINT,
1018 .bEndpointAddress = 0, 1018 .bEndpointAddress = 0,
1019 .bmAttributes = USB_ENDPOINT_XFER_CONTROL, 1019 .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
1020 .wMaxPacketSize = __constant_cpu_to_le16(64), 1020 .wMaxPacketSize = cpu_to_le16(64),
1021 /* FIXME: I have no idea what to put here */ 1021 /* FIXME: I have no idea what to put here */
1022 .bInterval = 1, 1022 .bInterval = 1,
1023}; 1023};
@@ -1207,21 +1207,21 @@ static int do_test_mode(struct usba_udc *udc)
1207/* Avoid overly long expressions */ 1207/* Avoid overly long expressions */
1208static inline bool feature_is_dev_remote_wakeup(struct usb_ctrlrequest *crq) 1208static inline bool feature_is_dev_remote_wakeup(struct usb_ctrlrequest *crq)
1209{ 1209{
1210 if (crq->wValue == __constant_cpu_to_le16(USB_DEVICE_REMOTE_WAKEUP)) 1210 if (crq->wValue == cpu_to_le16(USB_DEVICE_REMOTE_WAKEUP))
1211 return true; 1211 return true;
1212 return false; 1212 return false;
1213} 1213}
1214 1214
1215static inline bool feature_is_dev_test_mode(struct usb_ctrlrequest *crq) 1215static inline bool feature_is_dev_test_mode(struct usb_ctrlrequest *crq)
1216{ 1216{
1217 if (crq->wValue == __constant_cpu_to_le16(USB_DEVICE_TEST_MODE)) 1217 if (crq->wValue == cpu_to_le16(USB_DEVICE_TEST_MODE))
1218 return true; 1218 return true;
1219 return false; 1219 return false;
1220} 1220}
1221 1221
1222static inline bool feature_is_ep_halt(struct usb_ctrlrequest *crq) 1222static inline bool feature_is_ep_halt(struct usb_ctrlrequest *crq)
1223{ 1223{
1224 if (crq->wValue == __constant_cpu_to_le16(USB_ENDPOINT_HALT)) 1224 if (crq->wValue == cpu_to_le16(USB_ENDPOINT_HALT))
1225 return true; 1225 return true;
1226 return false; 1226 return false;
1227} 1227}
@@ -1239,7 +1239,7 @@ static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep,
1239 status = cpu_to_le16(udc->devstatus); 1239 status = cpu_to_le16(udc->devstatus);
1240 } else if (crq->bRequestType 1240 } else if (crq->bRequestType
1241 == (USB_DIR_IN | USB_RECIP_INTERFACE)) { 1241 == (USB_DIR_IN | USB_RECIP_INTERFACE)) {
1242 status = __constant_cpu_to_le16(0); 1242 status = cpu_to_le16(0);
1243 } else if (crq->bRequestType 1243 } else if (crq->bRequestType
1244 == (USB_DIR_IN | USB_RECIP_ENDPOINT)) { 1244 == (USB_DIR_IN | USB_RECIP_ENDPOINT)) {
1245 struct usba_ep *target; 1245 struct usba_ep *target;
@@ -1250,12 +1250,12 @@ static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep,
1250 1250
1251 status = 0; 1251 status = 0;
1252 if (is_stalled(udc, target)) 1252 if (is_stalled(udc, target))
1253 status |= __constant_cpu_to_le16(1); 1253 status |= cpu_to_le16(1);
1254 } else 1254 } else
1255 goto delegate; 1255 goto delegate;
1256 1256
1257 /* Write directly to the FIFO. No queueing is done. */ 1257 /* Write directly to the FIFO. No queueing is done. */
1258 if (crq->wLength != __constant_cpu_to_le16(sizeof(status))) 1258 if (crq->wLength != cpu_to_le16(sizeof(status)))
1259 goto stall; 1259 goto stall;
1260 ep->state = DATA_STAGE_IN; 1260 ep->state = DATA_STAGE_IN;
1261 __raw_writew(status, ep->fifo); 1261 __raw_writew(status, ep->fifo);
@@ -1274,7 +1274,7 @@ static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep,
1274 } else if (crq->bRequestType == USB_RECIP_ENDPOINT) { 1274 } else if (crq->bRequestType == USB_RECIP_ENDPOINT) {
1275 struct usba_ep *target; 1275 struct usba_ep *target;
1276 1276
1277 if (crq->wLength != __constant_cpu_to_le16(0) 1277 if (crq->wLength != cpu_to_le16(0)
1278 || !feature_is_ep_halt(crq)) 1278 || !feature_is_ep_halt(crq))
1279 goto stall; 1279 goto stall;
1280 target = get_ep_by_addr(udc, le16_to_cpu(crq->wIndex)); 1280 target = get_ep_by_addr(udc, le16_to_cpu(crq->wIndex));
@@ -1308,7 +1308,7 @@ static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep,
1308 } else if (crq->bRequestType == USB_RECIP_ENDPOINT) { 1308 } else if (crq->bRequestType == USB_RECIP_ENDPOINT) {
1309 struct usba_ep *target; 1309 struct usba_ep *target;
1310 1310
1311 if (crq->wLength != __constant_cpu_to_le16(0) 1311 if (crq->wLength != cpu_to_le16(0)
1312 || !feature_is_ep_halt(crq)) 1312 || !feature_is_ep_halt(crq))
1313 goto stall; 1313 goto stall;
1314 1314
@@ -1514,7 +1514,7 @@ restart:
1514 */ 1514 */
1515 ep->state = DATA_STAGE_IN; 1515 ep->state = DATA_STAGE_IN;
1516 } else { 1516 } else {
1517 if (crq.crq.wLength != __constant_cpu_to_le16(0)) 1517 if (crq.crq.wLength != cpu_to_le16(0))
1518 ep->state = DATA_STAGE_OUT; 1518 ep->state = DATA_STAGE_OUT;
1519 else 1519 else
1520 ep->state = STATUS_STAGE_IN; 1520 ep->state = STATUS_STAGE_IN;
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 5495b171cf29..928137d3dbdc 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -66,7 +66,7 @@ static struct usb_device_descriptor device_desc = {
66 .bLength = sizeof device_desc, 66 .bLength = sizeof device_desc,
67 .bDescriptorType = USB_DT_DEVICE, 67 .bDescriptorType = USB_DT_DEVICE,
68 68
69 .bcdUSB = __constant_cpu_to_le16(0x0200), 69 .bcdUSB = cpu_to_le16(0x0200),
70 70
71 .bDeviceClass = USB_CLASS_COMM, 71 .bDeviceClass = USB_CLASS_COMM,
72 .bDeviceSubClass = 0, 72 .bDeviceSubClass = 0,
@@ -74,8 +74,8 @@ static struct usb_device_descriptor device_desc = {
74 /* .bMaxPacketSize0 = f(hardware) */ 74 /* .bMaxPacketSize0 = f(hardware) */
75 75
76 /* Vendor and product id can be overridden by module parameters. */ 76 /* Vendor and product id can be overridden by module parameters. */
77 .idVendor = __constant_cpu_to_le16(CDC_VENDOR_NUM), 77 .idVendor = cpu_to_le16(CDC_VENDOR_NUM),
78 .idProduct = __constant_cpu_to_le16(CDC_PRODUCT_NUM), 78 .idProduct = cpu_to_le16(CDC_PRODUCT_NUM),
79 /* .bcdDevice = f(hardware) */ 79 /* .bcdDevice = f(hardware) */
80 /* .iManufacturer = DYNAMIC */ 80 /* .iManufacturer = DYNAMIC */
81 /* .iProduct = DYNAMIC */ 81 /* .iProduct = DYNAMIC */
@@ -193,7 +193,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
193 gadget->name, 193 gadget->name,
194 cdc_config_driver.label); 194 cdc_config_driver.label);
195 device_desc.bcdDevice = 195 device_desc.bcdDevice =
196 __constant_cpu_to_le16(0x0300 | 0x0099); 196 cpu_to_le16(0x0300 | 0x0099);
197 } 197 }
198 198
199 199
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index bebf911c7e5f..22c65960c429 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -56,7 +56,6 @@
56#include <linux/dma-mapping.h> 56#include <linux/dma-mapping.h>
57#include <linux/init.h> 57#include <linux/init.h>
58#include <linux/interrupt.h> 58#include <linux/interrupt.h>
59#include <linux/interrupt.h>
60#include <linux/io.h> 59#include <linux/io.h>
61#include <linux/irq.h> 60#include <linux/irq.h>
62#include <linux/kernel.h> 61#include <linux/kernel.h>
@@ -2626,7 +2625,7 @@ static int udc_probe(struct device *dev, void __iomem *regs, const char *name)
2626 INIT_LIST_HEAD(&udc->gadget.ep_list); 2625 INIT_LIST_HEAD(&udc->gadget.ep_list);
2627 udc->gadget.ep0 = NULL; 2626 udc->gadget.ep0 = NULL;
2628 2627
2629 strcpy(udc->gadget.dev.bus_id, "gadget"); 2628 dev_set_name(&udc->gadget.dev, "gadget");
2630 udc->gadget.dev.dma_mask = dev->dma_mask; 2629 udc->gadget.dev.dma_mask = dev->dma_mask;
2631 udc->gadget.dev.parent = dev; 2630 udc->gadget.dev.parent = dev;
2632 udc->gadget.dev.release = udc_release; 2631 udc->gadget.dev.release = udc_release;
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 5d11c291f1ad..59e85234fa0a 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -149,16 +149,17 @@ done:
149int usb_function_deactivate(struct usb_function *function) 149int usb_function_deactivate(struct usb_function *function)
150{ 150{
151 struct usb_composite_dev *cdev = function->config->cdev; 151 struct usb_composite_dev *cdev = function->config->cdev;
152 unsigned long flags;
152 int status = 0; 153 int status = 0;
153 154
154 spin_lock(&cdev->lock); 155 spin_lock_irqsave(&cdev->lock, flags);
155 156
156 if (cdev->deactivations == 0) 157 if (cdev->deactivations == 0)
157 status = usb_gadget_disconnect(cdev->gadget); 158 status = usb_gadget_disconnect(cdev->gadget);
158 if (status == 0) 159 if (status == 0)
159 cdev->deactivations++; 160 cdev->deactivations++;
160 161
161 spin_unlock(&cdev->lock); 162 spin_unlock_irqrestore(&cdev->lock, flags);
162 return status; 163 return status;
163} 164}
164 165
@@ -1013,7 +1014,7 @@ composite_suspend(struct usb_gadget *gadget)
1013 struct usb_composite_dev *cdev = get_gadget_data(gadget); 1014 struct usb_composite_dev *cdev = get_gadget_data(gadget);
1014 struct usb_function *f; 1015 struct usb_function *f;
1015 1016
1016 /* REVISIT: should we have config and device level 1017 /* REVISIT: should we have config level
1017 * suspend/resume callbacks? 1018 * suspend/resume callbacks?
1018 */ 1019 */
1019 DBG(cdev, "suspend\n"); 1020 DBG(cdev, "suspend\n");
@@ -1023,6 +1024,8 @@ composite_suspend(struct usb_gadget *gadget)
1023 f->suspend(f); 1024 f->suspend(f);
1024 } 1025 }
1025 } 1026 }
1027 if (composite->suspend)
1028 composite->suspend(cdev);
1026} 1029}
1027 1030
1028static void 1031static void
@@ -1031,10 +1034,12 @@ composite_resume(struct usb_gadget *gadget)
1031 struct usb_composite_dev *cdev = get_gadget_data(gadget); 1034 struct usb_composite_dev *cdev = get_gadget_data(gadget);
1032 struct usb_function *f; 1035 struct usb_function *f;
1033 1036
1034 /* REVISIT: should we have config and device level 1037 /* REVISIT: should we have config level
1035 * suspend/resume callbacks? 1038 * suspend/resume callbacks?
1036 */ 1039 */
1037 DBG(cdev, "resume\n"); 1040 DBG(cdev, "resume\n");
1041 if (composite->resume)
1042 composite->resume(cdev);
1038 if (cdev->config) { 1043 if (cdev->config) {
1039 list_for_each_entry(f, &cdev->config->functions, list) { 1044 list_for_each_entry(f, &cdev->config->functions, list) {
1040 if (f->resume) 1045 if (f->resume)
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 9064696636ac..a56b24d305f8 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -1437,7 +1437,7 @@ restart:
1437 } 1437 }
1438 if (urb->transfer_buffer_length > 1) 1438 if (urb->transfer_buffer_length > 1)
1439 buf [1] = 0; 1439 buf [1] = 0;
1440 urb->actual_length = min (2, 1440 urb->actual_length = min_t(u32, 2,
1441 urb->transfer_buffer_length); 1441 urb->transfer_buffer_length);
1442 value = 0; 1442 value = 0;
1443 status = 0; 1443 status = 0;
@@ -1626,7 +1626,7 @@ static int dummy_hub_control (
1626 hub_descriptor ((struct usb_hub_descriptor *) buf); 1626 hub_descriptor ((struct usb_hub_descriptor *) buf);
1627 break; 1627 break;
1628 case GetHubStatus: 1628 case GetHubStatus:
1629 *(__le32 *) buf = __constant_cpu_to_le32 (0); 1629 *(__le32 *) buf = cpu_to_le32 (0);
1630 break; 1630 break;
1631 case GetPortStatus: 1631 case GetPortStatus:
1632 if (wIndex != 1) 1632 if (wIndex != 1)
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index a36b1175b18d..cd0914ec898e 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -148,7 +148,7 @@ ep_matches (
148 return 0; 148 return 0;
149 149
150 /* BOTH: "high bandwidth" works only at high speed */ 150 /* BOTH: "high bandwidth" works only at high speed */
151 if ((desc->wMaxPacketSize & __constant_cpu_to_le16(3<<11))) { 151 if ((desc->wMaxPacketSize & cpu_to_le16(3<<11))) {
152 if (!gadget->is_dualspeed) 152 if (!gadget->is_dualspeed)
153 return 0; 153 return 0;
154 /* configure your hardware with enough buffering!! */ 154 /* configure your hardware with enough buffering!! */
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 37252d0012a7..d006dc652e02 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -156,7 +156,7 @@ static struct usb_device_descriptor device_desc = {
156 .bLength = sizeof device_desc, 156 .bLength = sizeof device_desc,
157 .bDescriptorType = USB_DT_DEVICE, 157 .bDescriptorType = USB_DT_DEVICE,
158 158
159 .bcdUSB = __constant_cpu_to_le16 (0x0200), 159 .bcdUSB = cpu_to_le16 (0x0200),
160 160
161 .bDeviceClass = USB_CLASS_COMM, 161 .bDeviceClass = USB_CLASS_COMM,
162 .bDeviceSubClass = 0, 162 .bDeviceSubClass = 0,
@@ -167,8 +167,8 @@ static struct usb_device_descriptor device_desc = {
167 * we support. (As does bNumConfigurations.) These values can 167 * we support. (As does bNumConfigurations.) These values can
168 * also be overridden by module parameters. 168 * also be overridden by module parameters.
169 */ 169 */
170 .idVendor = __constant_cpu_to_le16 (CDC_VENDOR_NUM), 170 .idVendor = cpu_to_le16 (CDC_VENDOR_NUM),
171 .idProduct = __constant_cpu_to_le16 (CDC_PRODUCT_NUM), 171 .idProduct = cpu_to_le16 (CDC_PRODUCT_NUM),
172 /* .bcdDevice = f(hardware) */ 172 /* .bcdDevice = f(hardware) */
173 /* .iManufacturer = DYNAMIC */ 173 /* .iManufacturer = DYNAMIC */
174 /* .iProduct = DYNAMIC */ 174 /* .iProduct = DYNAMIC */
@@ -318,7 +318,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
318 gadget->name, 318 gadget->name,
319 eth_config_driver.label); 319 eth_config_driver.label);
320 device_desc.bcdDevice = 320 device_desc.bcdDevice =
321 __constant_cpu_to_le16(0x0300 | 0x0099); 321 cpu_to_le16(0x0300 | 0x0099);
322 } 322 }
323 323
324 324
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
index c1d34df0b157..7953948bfe4a 100644
--- a/drivers/usb/gadget/f_acm.c
+++ b/drivers/usb/gadget/f_acm.c
@@ -125,7 +125,7 @@ static struct usb_cdc_header_desc acm_header_desc __initdata = {
125 .bLength = sizeof(acm_header_desc), 125 .bLength = sizeof(acm_header_desc),
126 .bDescriptorType = USB_DT_CS_INTERFACE, 126 .bDescriptorType = USB_DT_CS_INTERFACE,
127 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 127 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
128 .bcdCDC = __constant_cpu_to_le16(0x0110), 128 .bcdCDC = cpu_to_le16(0x0110),
129}; 129};
130 130
131static struct usb_cdc_call_mgmt_descriptor 131static struct usb_cdc_call_mgmt_descriptor
@@ -159,7 +159,7 @@ static struct usb_endpoint_descriptor acm_fs_notify_desc __initdata = {
159 .bDescriptorType = USB_DT_ENDPOINT, 159 .bDescriptorType = USB_DT_ENDPOINT,
160 .bEndpointAddress = USB_DIR_IN, 160 .bEndpointAddress = USB_DIR_IN,
161 .bmAttributes = USB_ENDPOINT_XFER_INT, 161 .bmAttributes = USB_ENDPOINT_XFER_INT,
162 .wMaxPacketSize = __constant_cpu_to_le16(GS_NOTIFY_MAXPACKET), 162 .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET),
163 .bInterval = 1 << GS_LOG2_NOTIFY_INTERVAL, 163 .bInterval = 1 << GS_LOG2_NOTIFY_INTERVAL,
164}; 164};
165 165
@@ -197,7 +197,7 @@ static struct usb_endpoint_descriptor acm_hs_notify_desc __initdata = {
197 .bDescriptorType = USB_DT_ENDPOINT, 197 .bDescriptorType = USB_DT_ENDPOINT,
198 .bEndpointAddress = USB_DIR_IN, 198 .bEndpointAddress = USB_DIR_IN,
199 .bmAttributes = USB_ENDPOINT_XFER_INT, 199 .bmAttributes = USB_ENDPOINT_XFER_INT,
200 .wMaxPacketSize = __constant_cpu_to_le16(GS_NOTIFY_MAXPACKET), 200 .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET),
201 .bInterval = GS_LOG2_NOTIFY_INTERVAL+4, 201 .bInterval = GS_LOG2_NOTIFY_INTERVAL+4,
202}; 202};
203 203
@@ -205,14 +205,14 @@ static struct usb_endpoint_descriptor acm_hs_in_desc __initdata = {
205 .bLength = USB_DT_ENDPOINT_SIZE, 205 .bLength = USB_DT_ENDPOINT_SIZE,
206 .bDescriptorType = USB_DT_ENDPOINT, 206 .bDescriptorType = USB_DT_ENDPOINT,
207 .bmAttributes = USB_ENDPOINT_XFER_BULK, 207 .bmAttributes = USB_ENDPOINT_XFER_BULK,
208 .wMaxPacketSize = __constant_cpu_to_le16(512), 208 .wMaxPacketSize = cpu_to_le16(512),
209}; 209};
210 210
211static struct usb_endpoint_descriptor acm_hs_out_desc __initdata = { 211static struct usb_endpoint_descriptor acm_hs_out_desc __initdata = {
212 .bLength = USB_DT_ENDPOINT_SIZE, 212 .bLength = USB_DT_ENDPOINT_SIZE,
213 .bDescriptorType = USB_DT_ENDPOINT, 213 .bDescriptorType = USB_DT_ENDPOINT,
214 .bmAttributes = USB_ENDPOINT_XFER_BULK, 214 .bmAttributes = USB_ENDPOINT_XFER_BULK,
215 .wMaxPacketSize = __constant_cpu_to_le16(512), 215 .wMaxPacketSize = cpu_to_le16(512),
216}; 216};
217 217
218static struct usb_descriptor_header *acm_hs_function[] __initdata = { 218static struct usb_descriptor_header *acm_hs_function[] __initdata = {
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index 4ae579948e54..ecf5bdd0ae06 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -130,7 +130,7 @@ static struct usb_cdc_header_desc ecm_header_desc __initdata = {
130 .bDescriptorType = USB_DT_CS_INTERFACE, 130 .bDescriptorType = USB_DT_CS_INTERFACE,
131 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 131 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
132 132
133 .bcdCDC = __constant_cpu_to_le16(0x0110), 133 .bcdCDC = cpu_to_le16(0x0110),
134}; 134};
135 135
136static struct usb_cdc_union_desc ecm_union_desc __initdata = { 136static struct usb_cdc_union_desc ecm_union_desc __initdata = {
@@ -148,9 +148,9 @@ static struct usb_cdc_ether_desc ecm_desc __initdata = {
148 148
149 /* this descriptor actually adds value, surprise! */ 149 /* this descriptor actually adds value, surprise! */
150 /* .iMACAddress = DYNAMIC */ 150 /* .iMACAddress = DYNAMIC */
151 .bmEthernetStatistics = __constant_cpu_to_le32(0), /* no statistics */ 151 .bmEthernetStatistics = cpu_to_le32(0), /* no statistics */
152 .wMaxSegmentSize = __constant_cpu_to_le16(ETH_FRAME_LEN), 152 .wMaxSegmentSize = cpu_to_le16(ETH_FRAME_LEN),
153 .wNumberMCFilters = __constant_cpu_to_le16(0), 153 .wNumberMCFilters = cpu_to_le16(0),
154 .bNumberPowerFilters = 0, 154 .bNumberPowerFilters = 0,
155}; 155};
156 156
@@ -192,7 +192,7 @@ static struct usb_endpoint_descriptor fs_ecm_notify_desc __initdata = {
192 192
193 .bEndpointAddress = USB_DIR_IN, 193 .bEndpointAddress = USB_DIR_IN,
194 .bmAttributes = USB_ENDPOINT_XFER_INT, 194 .bmAttributes = USB_ENDPOINT_XFER_INT,
195 .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT), 195 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT),
196 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, 196 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC,
197}; 197};
198 198
@@ -236,7 +236,7 @@ static struct usb_endpoint_descriptor hs_ecm_notify_desc __initdata = {
236 236
237 .bEndpointAddress = USB_DIR_IN, 237 .bEndpointAddress = USB_DIR_IN,
238 .bmAttributes = USB_ENDPOINT_XFER_INT, 238 .bmAttributes = USB_ENDPOINT_XFER_INT,
239 .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT), 239 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT),
240 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 240 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4,
241}; 241};
242static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = { 242static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = {
@@ -245,7 +245,7 @@ static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = {
245 245
246 .bEndpointAddress = USB_DIR_IN, 246 .bEndpointAddress = USB_DIR_IN,
247 .bmAttributes = USB_ENDPOINT_XFER_BULK, 247 .bmAttributes = USB_ENDPOINT_XFER_BULK,
248 .wMaxPacketSize = __constant_cpu_to_le16(512), 248 .wMaxPacketSize = cpu_to_le16(512),
249}; 249};
250 250
251static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = { 251static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = {
@@ -254,7 +254,7 @@ static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = {
254 254
255 .bEndpointAddress = USB_DIR_OUT, 255 .bEndpointAddress = USB_DIR_OUT,
256 .bmAttributes = USB_ENDPOINT_XFER_BULK, 256 .bmAttributes = USB_ENDPOINT_XFER_BULK,
257 .wMaxPacketSize = __constant_cpu_to_le16(512), 257 .wMaxPacketSize = cpu_to_le16(512),
258}; 258};
259 259
260static struct usb_descriptor_header *ecm_hs_function[] __initdata = { 260static struct usb_descriptor_header *ecm_hs_function[] __initdata = {
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
index 8affe1dfc2c1..eb6ddfc20857 100644
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -100,7 +100,7 @@ static struct usb_endpoint_descriptor hs_loop_source_desc = {
100 .bDescriptorType = USB_DT_ENDPOINT, 100 .bDescriptorType = USB_DT_ENDPOINT,
101 101
102 .bmAttributes = USB_ENDPOINT_XFER_BULK, 102 .bmAttributes = USB_ENDPOINT_XFER_BULK,
103 .wMaxPacketSize = __constant_cpu_to_le16(512), 103 .wMaxPacketSize = cpu_to_le16(512),
104}; 104};
105 105
106static struct usb_endpoint_descriptor hs_loop_sink_desc = { 106static struct usb_endpoint_descriptor hs_loop_sink_desc = {
@@ -108,7 +108,7 @@ static struct usb_endpoint_descriptor hs_loop_sink_desc = {
108 .bDescriptorType = USB_DT_ENDPOINT, 108 .bDescriptorType = USB_DT_ENDPOINT,
109 109
110 .bmAttributes = USB_ENDPOINT_XFER_BULK, 110 .bmAttributes = USB_ENDPOINT_XFER_BULK,
111 .wMaxPacketSize = __constant_cpu_to_le16(512), 111 .wMaxPacketSize = cpu_to_le16(512),
112}; 112};
113 113
114static struct usb_descriptor_header *hs_loopback_descs[] = { 114static struct usb_descriptor_header *hs_loopback_descs[] = {
@@ -359,7 +359,7 @@ static struct usb_configuration loopback_driver = {
359 * loopback_add - add a loopback testing configuration to a device 359 * loopback_add - add a loopback testing configuration to a device
360 * @cdev: the device to support the loopback configuration 360 * @cdev: the device to support the loopback configuration
361 */ 361 */
362int __init loopback_add(struct usb_composite_dev *cdev) 362int __init loopback_add(struct usb_composite_dev *cdev, bool autoresume)
363{ 363{
364 int id; 364 int id;
365 365
@@ -372,6 +372,10 @@ int __init loopback_add(struct usb_composite_dev *cdev)
372 loopback_intf.iInterface = id; 372 loopback_intf.iInterface = id;
373 loopback_driver.iConfiguration = id; 373 loopback_driver.iConfiguration = id;
374 374
375 /* support autoresume for remote wakeup testing */
376 if (autoresume)
377 sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
378
375 /* support OTG systems */ 379 /* support OTG systems */
376 if (gadget_is_otg(cdev->gadget)) { 380 if (gadget_is_otg(cdev->gadget)) {
377 loopback_driver.descriptors = otg_desc; 381 loopback_driver.descriptors = otg_desc;
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 38aa896cc5db..46d6266f30ec 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -123,7 +123,7 @@ static struct usb_cdc_header_desc obex_cdc_header_desc __initdata = {
123 .bLength = sizeof(obex_cdc_header_desc), 123 .bLength = sizeof(obex_cdc_header_desc),
124 .bDescriptorType = USB_DT_CS_INTERFACE, 124 .bDescriptorType = USB_DT_CS_INTERFACE,
125 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 125 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
126 .bcdCDC = __constant_cpu_to_le16(0x0120), 126 .bcdCDC = cpu_to_le16(0x0120),
127}; 127};
128 128
129static struct usb_cdc_union_desc obex_cdc_union_desc __initdata = { 129static struct usb_cdc_union_desc obex_cdc_union_desc __initdata = {
@@ -138,7 +138,7 @@ static struct usb_cdc_obex_desc obex_desc __initdata = {
138 .bLength = sizeof(obex_desc), 138 .bLength = sizeof(obex_desc),
139 .bDescriptorType = USB_DT_CS_INTERFACE, 139 .bDescriptorType = USB_DT_CS_INTERFACE,
140 .bDescriptorSubType = USB_CDC_OBEX_TYPE, 140 .bDescriptorSubType = USB_CDC_OBEX_TYPE,
141 .bcdVersion = __constant_cpu_to_le16(0x0100), 141 .bcdVersion = cpu_to_le16(0x0100),
142}; 142};
143 143
144/* High-Speed Support */ 144/* High-Speed Support */
@@ -149,7 +149,7 @@ static struct usb_endpoint_descriptor obex_hs_ep_out_desc __initdata = {
149 149
150 .bEndpointAddress = USB_DIR_OUT, 150 .bEndpointAddress = USB_DIR_OUT,
151 .bmAttributes = USB_ENDPOINT_XFER_BULK, 151 .bmAttributes = USB_ENDPOINT_XFER_BULK,
152 .wMaxPacketSize = __constant_cpu_to_le16(512), 152 .wMaxPacketSize = cpu_to_le16(512),
153}; 153};
154 154
155static struct usb_endpoint_descriptor obex_hs_ep_in_desc __initdata = { 155static struct usb_endpoint_descriptor obex_hs_ep_in_desc __initdata = {
@@ -158,7 +158,7 @@ static struct usb_endpoint_descriptor obex_hs_ep_in_desc __initdata = {
158 158
159 .bEndpointAddress = USB_DIR_IN, 159 .bEndpointAddress = USB_DIR_IN,
160 .bmAttributes = USB_ENDPOINT_XFER_BULK, 160 .bmAttributes = USB_ENDPOINT_XFER_BULK,
161 .wMaxPacketSize = __constant_cpu_to_le16(512), 161 .wMaxPacketSize = cpu_to_le16(512),
162}; 162};
163 163
164static struct usb_descriptor_header *hs_function[] __initdata = { 164static struct usb_descriptor_header *hs_function[] __initdata = {
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index c0916c7b217e..c1abeb89b413 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -79,7 +79,7 @@ pn_header_desc = {
79 .bLength = sizeof pn_header_desc, 79 .bLength = sizeof pn_header_desc,
80 .bDescriptorType = USB_DT_CS_INTERFACE, 80 .bDescriptorType = USB_DT_CS_INTERFACE,
81 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 81 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
82 .bcdCDC = __constant_cpu_to_le16(0x0110), 82 .bcdCDC = cpu_to_le16(0x0110),
83}; 83};
84 84
85static const struct usb_cdc_header_desc 85static const struct usb_cdc_header_desc
@@ -87,7 +87,7 @@ pn_phonet_desc = {
87 .bLength = sizeof pn_phonet_desc, 87 .bLength = sizeof pn_phonet_desc,
88 .bDescriptorType = USB_DT_CS_INTERFACE, 88 .bDescriptorType = USB_DT_CS_INTERFACE,
89 .bDescriptorSubType = USB_CDC_PHONET_TYPE, 89 .bDescriptorSubType = USB_CDC_PHONET_TYPE,
90 .bcdCDC = __constant_cpu_to_le16(0x1505), /* ??? */ 90 .bcdCDC = cpu_to_le16(0x1505), /* ??? */
91}; 91};
92 92
93static struct usb_cdc_union_desc 93static struct usb_cdc_union_desc
@@ -138,7 +138,7 @@ pn_hs_sink_desc = {
138 138
139 .bEndpointAddress = USB_DIR_OUT, 139 .bEndpointAddress = USB_DIR_OUT,
140 .bmAttributes = USB_ENDPOINT_XFER_BULK, 140 .bmAttributes = USB_ENDPOINT_XFER_BULK,
141 .wMaxPacketSize = __constant_cpu_to_le16(512), 141 .wMaxPacketSize = cpu_to_le16(512),
142}; 142};
143 143
144static struct usb_endpoint_descriptor 144static struct usb_endpoint_descriptor
@@ -157,7 +157,7 @@ pn_hs_source_desc = {
157 157
158 .bEndpointAddress = USB_DIR_IN, 158 .bEndpointAddress = USB_DIR_IN,
159 .bmAttributes = USB_ENDPOINT_XFER_BULK, 159 .bmAttributes = USB_ENDPOINT_XFER_BULK,
160 .wMaxPacketSize = __constant_cpu_to_le16(512), 160 .wMaxPacketSize = cpu_to_le16(512),
161}; 161};
162 162
163static struct usb_descriptor_header *fs_pn_function[] = { 163static struct usb_descriptor_header *fs_pn_function[] = {
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 3a8bb53fc473..3279a4726042 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -137,7 +137,7 @@ static struct usb_cdc_header_desc header_desc __initdata = {
137 .bDescriptorType = USB_DT_CS_INTERFACE, 137 .bDescriptorType = USB_DT_CS_INTERFACE,
138 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 138 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
139 139
140 .bcdCDC = __constant_cpu_to_le16(0x0110), 140 .bcdCDC = cpu_to_le16(0x0110),
141}; 141};
142 142
143static struct usb_cdc_call_mgmt_descriptor call_mgmt_descriptor __initdata = { 143static struct usb_cdc_call_mgmt_descriptor call_mgmt_descriptor __initdata = {
@@ -187,7 +187,7 @@ static struct usb_endpoint_descriptor fs_notify_desc __initdata = {
187 187
188 .bEndpointAddress = USB_DIR_IN, 188 .bEndpointAddress = USB_DIR_IN,
189 .bmAttributes = USB_ENDPOINT_XFER_INT, 189 .bmAttributes = USB_ENDPOINT_XFER_INT,
190 .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), 190 .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
191 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, 191 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC,
192}; 192};
193 193
@@ -230,7 +230,7 @@ static struct usb_endpoint_descriptor hs_notify_desc __initdata = {
230 230
231 .bEndpointAddress = USB_DIR_IN, 231 .bEndpointAddress = USB_DIR_IN,
232 .bmAttributes = USB_ENDPOINT_XFER_INT, 232 .bmAttributes = USB_ENDPOINT_XFER_INT,
233 .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), 233 .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
234 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 234 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4,
235}; 235};
236static struct usb_endpoint_descriptor hs_in_desc __initdata = { 236static struct usb_endpoint_descriptor hs_in_desc __initdata = {
@@ -239,7 +239,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = {
239 239
240 .bEndpointAddress = USB_DIR_IN, 240 .bEndpointAddress = USB_DIR_IN,
241 .bmAttributes = USB_ENDPOINT_XFER_BULK, 241 .bmAttributes = USB_ENDPOINT_XFER_BULK,
242 .wMaxPacketSize = __constant_cpu_to_le16(512), 242 .wMaxPacketSize = cpu_to_le16(512),
243}; 243};
244 244
245static struct usb_endpoint_descriptor hs_out_desc __initdata = { 245static struct usb_endpoint_descriptor hs_out_desc __initdata = {
@@ -248,7 +248,7 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = {
248 248
249 .bEndpointAddress = USB_DIR_OUT, 249 .bEndpointAddress = USB_DIR_OUT,
250 .bmAttributes = USB_ENDPOINT_XFER_BULK, 250 .bmAttributes = USB_ENDPOINT_XFER_BULK,
251 .wMaxPacketSize = __constant_cpu_to_le16(512), 251 .wMaxPacketSize = cpu_to_le16(512),
252}; 252};
253 253
254static struct usb_descriptor_header *eth_hs_function[] __initdata = { 254static struct usb_descriptor_header *eth_hs_function[] __initdata = {
@@ -437,7 +437,7 @@ invalid:
437 DBG(cdev, "rndis req%02x.%02x v%04x i%04x l%d\n", 437 DBG(cdev, "rndis req%02x.%02x v%04x i%04x l%d\n",
438 ctrl->bRequestType, ctrl->bRequest, 438 ctrl->bRequestType, ctrl->bRequest,
439 w_value, w_index, w_length); 439 w_value, w_index, w_length);
440 req->zero = 0; 440 req->zero = (value < w_length);
441 req->length = value; 441 req->length = value;
442 value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC); 442 value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC);
443 if (value < 0) 443 if (value < 0)
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c
index fe5674db344b..db0aa93606ef 100644
--- a/drivers/usb/gadget/f_serial.c
+++ b/drivers/usb/gadget/f_serial.c
@@ -89,14 +89,14 @@ static struct usb_endpoint_descriptor gser_hs_in_desc __initdata = {
89 .bLength = USB_DT_ENDPOINT_SIZE, 89 .bLength = USB_DT_ENDPOINT_SIZE,
90 .bDescriptorType = USB_DT_ENDPOINT, 90 .bDescriptorType = USB_DT_ENDPOINT,
91 .bmAttributes = USB_ENDPOINT_XFER_BULK, 91 .bmAttributes = USB_ENDPOINT_XFER_BULK,
92 .wMaxPacketSize = __constant_cpu_to_le16(512), 92 .wMaxPacketSize = cpu_to_le16(512),
93}; 93};
94 94
95static struct usb_endpoint_descriptor gser_hs_out_desc __initdata = { 95static struct usb_endpoint_descriptor gser_hs_out_desc __initdata = {
96 .bLength = USB_DT_ENDPOINT_SIZE, 96 .bLength = USB_DT_ENDPOINT_SIZE,
97 .bDescriptorType = USB_DT_ENDPOINT, 97 .bDescriptorType = USB_DT_ENDPOINT,
98 .bmAttributes = USB_ENDPOINT_XFER_BULK, 98 .bmAttributes = USB_ENDPOINT_XFER_BULK,
99 .wMaxPacketSize = __constant_cpu_to_le16(512), 99 .wMaxPacketSize = cpu_to_le16(512),
100}; 100};
101 101
102static struct usb_descriptor_header *gser_hs_function[] __initdata = { 102static struct usb_descriptor_header *gser_hs_function[] __initdata = {
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
index dc84d26d2835..bffe91d525f9 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -59,7 +59,6 @@ struct f_sourcesink {
59 59
60 struct usb_ep *in_ep; 60 struct usb_ep *in_ep;
61 struct usb_ep *out_ep; 61 struct usb_ep *out_ep;
62 struct timer_list resume;
63}; 62};
64 63
65static inline struct f_sourcesink *func_to_ss(struct usb_function *f) 64static inline struct f_sourcesink *func_to_ss(struct usb_function *f)
@@ -67,10 +66,6 @@ static inline struct f_sourcesink *func_to_ss(struct usb_function *f)
67 return container_of(f, struct f_sourcesink, function); 66 return container_of(f, struct f_sourcesink, function);
68} 67}
69 68
70static unsigned autoresume;
71module_param(autoresume, uint, 0);
72MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup");
73
74static unsigned pattern; 69static unsigned pattern;
75module_param(pattern, uint, 0); 70module_param(pattern, uint, 0);
76MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 = mod63 "); 71MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 = mod63 ");
@@ -118,7 +113,7 @@ static struct usb_endpoint_descriptor hs_source_desc = {
118 .bDescriptorType = USB_DT_ENDPOINT, 113 .bDescriptorType = USB_DT_ENDPOINT,
119 114
120 .bmAttributes = USB_ENDPOINT_XFER_BULK, 115 .bmAttributes = USB_ENDPOINT_XFER_BULK,
121 .wMaxPacketSize = __constant_cpu_to_le16(512), 116 .wMaxPacketSize = cpu_to_le16(512),
122}; 117};
123 118
124static struct usb_endpoint_descriptor hs_sink_desc = { 119static struct usb_endpoint_descriptor hs_sink_desc = {
@@ -126,7 +121,7 @@ static struct usb_endpoint_descriptor hs_sink_desc = {
126 .bDescriptorType = USB_DT_ENDPOINT, 121 .bDescriptorType = USB_DT_ENDPOINT,
127 122
128 .bmAttributes = USB_ENDPOINT_XFER_BULK, 123 .bmAttributes = USB_ENDPOINT_XFER_BULK,
129 .wMaxPacketSize = __constant_cpu_to_le16(512), 124 .wMaxPacketSize = cpu_to_le16(512),
130}; 125};
131 126
132static struct usb_descriptor_header *hs_source_sink_descs[] = { 127static struct usb_descriptor_header *hs_source_sink_descs[] = {
@@ -155,21 +150,6 @@ static struct usb_gadget_strings *sourcesink_strings[] = {
155 150
156/*-------------------------------------------------------------------------*/ 151/*-------------------------------------------------------------------------*/
157 152
158static void sourcesink_autoresume(unsigned long _c)
159{
160 struct usb_composite_dev *cdev = (void *)_c;
161 struct usb_gadget *g = cdev->gadget;
162
163 /* Normally the host would be woken up for something
164 * more significant than just a timer firing; likely
165 * because of some direct user request.
166 */
167 if (g->speed != USB_SPEED_UNKNOWN) {
168 int status = usb_gadget_wakeup(g);
169 DBG(cdev, "%s --> %d\n", __func__, status);
170 }
171}
172
173static int __init 153static int __init
174sourcesink_bind(struct usb_configuration *c, struct usb_function *f) 154sourcesink_bind(struct usb_configuration *c, struct usb_function *f)
175{ 155{
@@ -198,9 +178,6 @@ autoconf_fail:
198 goto autoconf_fail; 178 goto autoconf_fail;
199 ss->out_ep->driver_data = cdev; /* claim */ 179 ss->out_ep->driver_data = cdev; /* claim */
200 180
201 setup_timer(&ss->resume, sourcesink_autoresume,
202 (unsigned long) c->cdev);
203
204 /* support high speed hardware */ 181 /* support high speed hardware */
205 if (gadget_is_dualspeed(c->cdev->gadget)) { 182 if (gadget_is_dualspeed(c->cdev->gadget)) {
206 hs_source_desc.bEndpointAddress = 183 hs_source_desc.bEndpointAddress =
@@ -359,7 +336,6 @@ static void disable_source_sink(struct f_sourcesink *ss)
359 336
360 cdev = ss->function.config->cdev; 337 cdev = ss->function.config->cdev;
361 disable_endpoints(cdev, ss->in_ep, ss->out_ep); 338 disable_endpoints(cdev, ss->in_ep, ss->out_ep);
362 del_timer(&ss->resume);
363 VDBG(cdev, "%s disabled\n", ss->function.name); 339 VDBG(cdev, "%s disabled\n", ss->function.name);
364} 340}
365 341
@@ -426,30 +402,6 @@ static void sourcesink_disable(struct usb_function *f)
426 disable_source_sink(ss); 402 disable_source_sink(ss);
427} 403}
428 404
429static void sourcesink_suspend(struct usb_function *f)
430{
431 struct f_sourcesink *ss = func_to_ss(f);
432 struct usb_composite_dev *cdev = f->config->cdev;
433
434 if (cdev->gadget->speed == USB_SPEED_UNKNOWN)
435 return;
436
437 if (autoresume) {
438 mod_timer(&ss->resume, jiffies + (HZ * autoresume));
439 DBG(cdev, "suspend, wakeup in %d seconds\n", autoresume);
440 } else
441 DBG(cdev, "%s\n", __func__);
442}
443
444static void sourcesink_resume(struct usb_function *f)
445{
446 struct f_sourcesink *ss = func_to_ss(f);
447 struct usb_composite_dev *cdev = f->config->cdev;
448
449 DBG(cdev, "%s\n", __func__);
450 del_timer(&ss->resume);
451}
452
453/*-------------------------------------------------------------------------*/ 405/*-------------------------------------------------------------------------*/
454 406
455static int __init sourcesink_bind_config(struct usb_configuration *c) 407static int __init sourcesink_bind_config(struct usb_configuration *c)
@@ -467,8 +419,6 @@ static int __init sourcesink_bind_config(struct usb_configuration *c)
467 ss->function.unbind = sourcesink_unbind; 419 ss->function.unbind = sourcesink_unbind;
468 ss->function.set_alt = sourcesink_set_alt; 420 ss->function.set_alt = sourcesink_set_alt;
469 ss->function.disable = sourcesink_disable; 421 ss->function.disable = sourcesink_disable;
470 ss->function.suspend = sourcesink_suspend;
471 ss->function.resume = sourcesink_resume;
472 422
473 status = usb_add_function(c, &ss->function); 423 status = usb_add_function(c, &ss->function);
474 if (status) 424 if (status)
@@ -559,7 +509,7 @@ static struct usb_configuration sourcesink_driver = {
559 * sourcesink_add - add a source/sink testing configuration to a device 509 * sourcesink_add - add a source/sink testing configuration to a device
560 * @cdev: the device to support the configuration 510 * @cdev: the device to support the configuration
561 */ 511 */
562int __init sourcesink_add(struct usb_composite_dev *cdev) 512int __init sourcesink_add(struct usb_composite_dev *cdev, bool autoresume)
563{ 513{
564 int id; 514 int id;
565 515
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index fe1832875771..a9c98fdb626d 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -108,7 +108,7 @@ static struct usb_cdc_header_desc mdlm_header_desc __initdata = {
108 .bDescriptorType = USB_DT_CS_INTERFACE, 108 .bDescriptorType = USB_DT_CS_INTERFACE,
109 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 109 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
110 110
111 .bcdCDC = __constant_cpu_to_le16(0x0110), 111 .bcdCDC = cpu_to_le16(0x0110),
112}; 112};
113 113
114static struct usb_cdc_mdlm_desc mdlm_desc __initdata = { 114static struct usb_cdc_mdlm_desc mdlm_desc __initdata = {
@@ -116,7 +116,7 @@ static struct usb_cdc_mdlm_desc mdlm_desc __initdata = {
116 .bDescriptorType = USB_DT_CS_INTERFACE, 116 .bDescriptorType = USB_DT_CS_INTERFACE,
117 .bDescriptorSubType = USB_CDC_MDLM_TYPE, 117 .bDescriptorSubType = USB_CDC_MDLM_TYPE,
118 118
119 .bcdVersion = __constant_cpu_to_le16(0x0100), 119 .bcdVersion = cpu_to_le16(0x0100),
120 .bGUID = { 120 .bGUID = {
121 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6, 121 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6,
122 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f, 122 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f,
@@ -144,9 +144,9 @@ static struct usb_cdc_ether_desc ether_desc __initdata = {
144 144
145 /* this descriptor actually adds value, surprise! */ 145 /* this descriptor actually adds value, surprise! */
146 /* .iMACAddress = DYNAMIC */ 146 /* .iMACAddress = DYNAMIC */
147 .bmEthernetStatistics = __constant_cpu_to_le32(0), /* no statistics */ 147 .bmEthernetStatistics = cpu_to_le32(0), /* no statistics */
148 .wMaxSegmentSize = __constant_cpu_to_le16(ETH_FRAME_LEN), 148 .wMaxSegmentSize = cpu_to_le16(ETH_FRAME_LEN),
149 .wNumberMCFilters = __constant_cpu_to_le16(0), 149 .wNumberMCFilters = cpu_to_le16(0),
150 .bNumberPowerFilters = 0, 150 .bNumberPowerFilters = 0,
151}; 151};
152 152
@@ -186,7 +186,7 @@ static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = {
186 .bDescriptorType = USB_DT_ENDPOINT, 186 .bDescriptorType = USB_DT_ENDPOINT,
187 187
188 .bmAttributes = USB_ENDPOINT_XFER_BULK, 188 .bmAttributes = USB_ENDPOINT_XFER_BULK,
189 .wMaxPacketSize = __constant_cpu_to_le16(512), 189 .wMaxPacketSize = cpu_to_le16(512),
190}; 190};
191 191
192static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = { 192static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = {
@@ -194,7 +194,7 @@ static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = {
194 .bDescriptorType = USB_DT_ENDPOINT, 194 .bDescriptorType = USB_DT_ENDPOINT,
195 195
196 .bmAttributes = USB_ENDPOINT_XFER_BULK, 196 .bmAttributes = USB_ENDPOINT_XFER_BULK,
197 .wMaxPacketSize = __constant_cpu_to_le16(512), 197 .wMaxPacketSize = cpu_to_le16(512),
198}; 198};
199 199
200static struct usb_descriptor_header *hs_eth_function[] __initdata = { 200static struct usb_descriptor_header *hs_eth_function[] __initdata = {
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 1ab9dac7e12d..d3c2464dee82 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -847,13 +847,13 @@ device_desc = {
847 .bLength = sizeof device_desc, 847 .bLength = sizeof device_desc,
848 .bDescriptorType = USB_DT_DEVICE, 848 .bDescriptorType = USB_DT_DEVICE,
849 849
850 .bcdUSB = __constant_cpu_to_le16(0x0200), 850 .bcdUSB = cpu_to_le16(0x0200),
851 .bDeviceClass = USB_CLASS_PER_INTERFACE, 851 .bDeviceClass = USB_CLASS_PER_INTERFACE,
852 852
853 /* The next three values can be overridden by module parameters */ 853 /* The next three values can be overridden by module parameters */
854 .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_ID), 854 .idVendor = cpu_to_le16(DRIVER_VENDOR_ID),
855 .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_ID), 855 .idProduct = cpu_to_le16(DRIVER_PRODUCT_ID),
856 .bcdDevice = __constant_cpu_to_le16(0xffff), 856 .bcdDevice = cpu_to_le16(0xffff),
857 857
858 .iManufacturer = STRING_MANUFACTURER, 858 .iManufacturer = STRING_MANUFACTURER,
859 .iProduct = STRING_PRODUCT, 859 .iProduct = STRING_PRODUCT,
@@ -926,7 +926,7 @@ fs_intr_in_desc = {
926 926
927 .bEndpointAddress = USB_DIR_IN, 927 .bEndpointAddress = USB_DIR_IN,
928 .bmAttributes = USB_ENDPOINT_XFER_INT, 928 .bmAttributes = USB_ENDPOINT_XFER_INT,
929 .wMaxPacketSize = __constant_cpu_to_le16(2), 929 .wMaxPacketSize = cpu_to_le16(2),
930 .bInterval = 32, // frames -> 32 ms 930 .bInterval = 32, // frames -> 32 ms
931}; 931};
932 932
@@ -954,7 +954,7 @@ dev_qualifier = {
954 .bLength = sizeof dev_qualifier, 954 .bLength = sizeof dev_qualifier,
955 .bDescriptorType = USB_DT_DEVICE_QUALIFIER, 955 .bDescriptorType = USB_DT_DEVICE_QUALIFIER,
956 956
957 .bcdUSB = __constant_cpu_to_le16(0x0200), 957 .bcdUSB = cpu_to_le16(0x0200),
958 .bDeviceClass = USB_CLASS_PER_INTERFACE, 958 .bDeviceClass = USB_CLASS_PER_INTERFACE,
959 959
960 .bNumConfigurations = 1, 960 .bNumConfigurations = 1,
@@ -967,7 +967,7 @@ hs_bulk_in_desc = {
967 967
968 /* bEndpointAddress copied from fs_bulk_in_desc during fsg_bind() */ 968 /* bEndpointAddress copied from fs_bulk_in_desc during fsg_bind() */
969 .bmAttributes = USB_ENDPOINT_XFER_BULK, 969 .bmAttributes = USB_ENDPOINT_XFER_BULK,
970 .wMaxPacketSize = __constant_cpu_to_le16(512), 970 .wMaxPacketSize = cpu_to_le16(512),
971}; 971};
972 972
973static struct usb_endpoint_descriptor 973static struct usb_endpoint_descriptor
@@ -977,7 +977,7 @@ hs_bulk_out_desc = {
977 977
978 /* bEndpointAddress copied from fs_bulk_out_desc during fsg_bind() */ 978 /* bEndpointAddress copied from fs_bulk_out_desc during fsg_bind() */
979 .bmAttributes = USB_ENDPOINT_XFER_BULK, 979 .bmAttributes = USB_ENDPOINT_XFER_BULK,
980 .wMaxPacketSize = __constant_cpu_to_le16(512), 980 .wMaxPacketSize = cpu_to_le16(512),
981 .bInterval = 1, // NAK every 1 uframe 981 .bInterval = 1, // NAK every 1 uframe
982}; 982};
983 983
@@ -988,7 +988,7 @@ hs_intr_in_desc = {
988 988
989 /* bEndpointAddress copied from fs_intr_in_desc during fsg_bind() */ 989 /* bEndpointAddress copied from fs_intr_in_desc during fsg_bind() */
990 .bmAttributes = USB_ENDPOINT_XFER_INT, 990 .bmAttributes = USB_ENDPOINT_XFER_INT,
991 .wMaxPacketSize = __constant_cpu_to_le16(2), 991 .wMaxPacketSize = cpu_to_le16(2),
992 .bInterval = 9, // 2**(9-1) = 256 uframes -> 32 ms 992 .bInterval = 9, // 2**(9-1) = 256 uframes -> 32 ms
993}; 993};
994 994
@@ -2646,7 +2646,7 @@ static int send_status(struct fsg_dev *fsg)
2646 struct bulk_cs_wrap *csw = bh->buf; 2646 struct bulk_cs_wrap *csw = bh->buf;
2647 2647
2648 /* Store and send the Bulk-only CSW */ 2648 /* Store and send the Bulk-only CSW */
2649 csw->Signature = __constant_cpu_to_le32(USB_BULK_CS_SIG); 2649 csw->Signature = cpu_to_le32(USB_BULK_CS_SIG);
2650 csw->Tag = fsg->tag; 2650 csw->Tag = fsg->tag;
2651 csw->Residue = cpu_to_le32(fsg->residue); 2651 csw->Residue = cpu_to_le32(fsg->residue);
2652 csw->Status = status; 2652 csw->Status = status;
@@ -3089,7 +3089,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh)
3089 3089
3090 /* Is the CBW valid? */ 3090 /* Is the CBW valid? */
3091 if (req->actual != USB_BULK_CB_WRAP_LEN || 3091 if (req->actual != USB_BULK_CB_WRAP_LEN ||
3092 cbw->Signature != __constant_cpu_to_le32( 3092 cbw->Signature != cpu_to_le32(
3093 USB_BULK_CB_SIG)) { 3093 USB_BULK_CB_SIG)) {
3094 DBG(fsg, "invalid CBW: len %u sig 0x%x\n", 3094 DBG(fsg, "invalid CBW: len %u sig 0x%x\n",
3095 req->actual, 3095 req->actual,
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index d8d9a52a44b3..9d7b95d4e3d2 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -1802,7 +1802,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1802 1802
1803out: 1803out:
1804 if (retval) 1804 if (retval)
1805 printk("gadget driver register failed %d\n", retval); 1805 printk(KERN_WARNING "gadget driver register failed %d\n",
1806 retval);
1806 return retval; 1807 return retval;
1807} 1808}
1808EXPORT_SYMBOL(usb_gadget_register_driver); 1809EXPORT_SYMBOL(usb_gadget_register_driver);
@@ -1847,7 +1848,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1847 udc_controller->gadget.dev.driver = NULL; 1848 udc_controller->gadget.dev.driver = NULL;
1848 udc_controller->driver = NULL; 1849 udc_controller->driver = NULL;
1849 1850
1850 printk("unregistered gadget driver '%s'\n", driver->driver.name); 1851 printk(KERN_WARNING "unregistered gadget driver '%s'\n",
1852 driver->driver.name);
1851 return 0; 1853 return 0;
1852} 1854}
1853EXPORT_SYMBOL(usb_gadget_unregister_driver); 1855EXPORT_SYMBOL(usb_gadget_unregister_driver);
@@ -2455,7 +2457,7 @@ module_init(udc_init);
2455static void __exit udc_exit(void) 2457static void __exit udc_exit(void)
2456{ 2458{
2457 platform_driver_unregister(&udc_driver); 2459 platform_driver_unregister(&udc_driver);
2458 printk("%s unregistered\n", driver_desc); 2460 printk(KERN_WARNING "%s unregistered\n", driver_desc);
2459} 2461}
2460 2462
2461module_exit(udc_exit); 2463module_exit(udc_exit);
diff --git a/drivers/usb/gadget/g_zero.h b/drivers/usb/gadget/g_zero.h
index dd2f16ad5a88..e84b3c47ed3c 100644
--- a/drivers/usb/gadget/g_zero.h
+++ b/drivers/usb/gadget/g_zero.h
@@ -19,7 +19,7 @@ void disable_endpoints(struct usb_composite_dev *cdev,
19 struct usb_ep *in, struct usb_ep *out); 19 struct usb_ep *in, struct usb_ep *out);
20 20
21/* configuration-specific linkup */ 21/* configuration-specific linkup */
22int sourcesink_add(struct usb_composite_dev *cdev); 22int sourcesink_add(struct usb_composite_dev *cdev, bool autoresume);
23int loopback_add(struct usb_composite_dev *cdev); 23int loopback_add(struct usb_composite_dev *cdev, bool autoresume);
24 24
25#endif /* __G_ZERO_H */ 25#endif /* __G_ZERO_H */
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 60d3f9e9b51f..b9312dc6e041 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -199,10 +199,10 @@ DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(1);
199static struct usb_device_descriptor device_desc = { 199static struct usb_device_descriptor device_desc = {
200 .bLength = USB_DT_DEVICE_SIZE, 200 .bLength = USB_DT_DEVICE_SIZE,
201 .bDescriptorType = USB_DT_DEVICE, 201 .bDescriptorType = USB_DT_DEVICE,
202 .bcdUSB = __constant_cpu_to_le16(0x0200), 202 .bcdUSB = cpu_to_le16(0x0200),
203 .bDeviceClass = USB_CLASS_PER_INTERFACE, 203 .bDeviceClass = USB_CLASS_PER_INTERFACE,
204 .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_NUM), 204 .idVendor = cpu_to_le16(DRIVER_VENDOR_NUM),
205 .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_NUM), 205 .idProduct = cpu_to_le16(DRIVER_PRODUCT_NUM),
206 .iManufacturer = STRING_MANUFACTURER, 206 .iManufacturer = STRING_MANUFACTURER,
207 .iProduct = STRING_PRODUCT, 207 .iProduct = STRING_PRODUCT,
208 .bNumConfigurations = 1, 208 .bNumConfigurations = 1,
@@ -241,8 +241,8 @@ static const struct usb_ac_header_descriptor_1 ac_header_desc = {
241 .bLength = USB_DT_AC_HEADER_SIZE(1), 241 .bLength = USB_DT_AC_HEADER_SIZE(1),
242 .bDescriptorType = USB_DT_CS_INTERFACE, 242 .bDescriptorType = USB_DT_CS_INTERFACE,
243 .bDescriptorSubtype = USB_MS_HEADER, 243 .bDescriptorSubtype = USB_MS_HEADER,
244 .bcdADC = __constant_cpu_to_le16(0x0100), 244 .bcdADC = cpu_to_le16(0x0100),
245 .wTotalLength = __constant_cpu_to_le16(USB_DT_AC_HEADER_SIZE(1)), 245 .wTotalLength = cpu_to_le16(USB_DT_AC_HEADER_SIZE(1)),
246 .bInCollection = 1, 246 .bInCollection = 1,
247 .baInterfaceNr = { 247 .baInterfaceNr = {
248 [0] = GMIDI_MS_INTERFACE, 248 [0] = GMIDI_MS_INTERFACE,
@@ -265,8 +265,8 @@ static const struct usb_ms_header_descriptor ms_header_desc = {
265 .bLength = USB_DT_MS_HEADER_SIZE, 265 .bLength = USB_DT_MS_HEADER_SIZE,
266 .bDescriptorType = USB_DT_CS_INTERFACE, 266 .bDescriptorType = USB_DT_CS_INTERFACE,
267 .bDescriptorSubtype = USB_MS_HEADER, 267 .bDescriptorSubtype = USB_MS_HEADER,
268 .bcdMSC = __constant_cpu_to_le16(0x0100), 268 .bcdMSC = cpu_to_le16(0x0100),
269 .wTotalLength = __constant_cpu_to_le16(USB_DT_MS_HEADER_SIZE 269 .wTotalLength = cpu_to_le16(USB_DT_MS_HEADER_SIZE
270 + 2*USB_DT_MIDI_IN_SIZE 270 + 2*USB_DT_MIDI_IN_SIZE
271 + 2*USB_DT_MIDI_OUT_SIZE(1)), 271 + 2*USB_DT_MIDI_OUT_SIZE(1)),
272}; 272};
@@ -1099,10 +1099,9 @@ static int gmidi_register_card(struct gmidi_device *dev)
1099 .dev_free = gmidi_snd_free, 1099 .dev_free = gmidi_snd_free,
1100 }; 1100 };
1101 1101
1102 card = snd_card_new(index, id, THIS_MODULE, 0); 1102 err = snd_card_create(index, id, THIS_MODULE, 0, &card);
1103 if (!card) { 1103 if (err < 0) {
1104 ERROR(dev, "snd_card_new failed\n"); 1104 ERROR(dev, "snd_card_create failed\n");
1105 err = -ENOMEM;
1106 goto fail; 1105 goto fail;
1107 } 1106 }
1108 dev->card = card; 1107 dev->card = card;
@@ -1227,7 +1226,7 @@ autoconf_fail:
1227 */ 1226 */
1228 pr_warning("%s: controller '%s' not recognized\n", 1227 pr_warning("%s: controller '%s' not recognized\n",
1229 shortname, gadget->name); 1228 shortname, gadget->name);
1230 device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); 1229 device_desc.bcdDevice = cpu_to_le16(0x9999);
1231 } 1230 }
1232 1231
1233 1232
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 63419c4d503c..de010c939dbb 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1472,7 +1472,7 @@ static void ep0_setup(struct goku_udc *dev)
1472 /* active endpoint */ 1472 /* active endpoint */
1473 if (tmp > 3 || (!dev->ep[tmp].desc && tmp != 0)) 1473 if (tmp > 3 || (!dev->ep[tmp].desc && tmp != 0))
1474 goto stall; 1474 goto stall;
1475 if (ctrl.wIndex & __constant_cpu_to_le16( 1475 if (ctrl.wIndex & cpu_to_le16(
1476 USB_DIR_IN)) { 1476 USB_DIR_IN)) {
1477 if (!dev->ep[tmp].is_in) 1477 if (!dev->ep[tmp].is_in)
1478 goto stall; 1478 goto stall;
@@ -1480,7 +1480,7 @@ static void ep0_setup(struct goku_udc *dev)
1480 if (dev->ep[tmp].is_in) 1480 if (dev->ep[tmp].is_in)
1481 goto stall; 1481 goto stall;
1482 } 1482 }
1483 if (ctrl.wValue != __constant_cpu_to_le16( 1483 if (ctrl.wValue != cpu_to_le16(
1484 USB_ENDPOINT_HALT)) 1484 USB_ENDPOINT_HALT))
1485 goto stall; 1485 goto stall;
1486 if (tmp) 1486 if (tmp)
@@ -1493,7 +1493,7 @@ succeed:
1493 return; 1493 return;
1494 case USB_RECIP_DEVICE: 1494 case USB_RECIP_DEVICE:
1495 /* device remote wakeup: always clear */ 1495 /* device remote wakeup: always clear */
1496 if (ctrl.wValue != __constant_cpu_to_le16(1)) 1496 if (ctrl.wValue != cpu_to_le16(1))
1497 goto stall; 1497 goto stall;
1498 VDBG(dev, "clear dev remote wakeup\n"); 1498 VDBG(dev, "clear dev remote wakeup\n");
1499 goto succeed; 1499 goto succeed;
@@ -1519,7 +1519,7 @@ succeed:
1519 dev->req_config = (ctrl.bRequest == USB_REQ_SET_CONFIGURATION 1519 dev->req_config = (ctrl.bRequest == USB_REQ_SET_CONFIGURATION
1520 && ctrl.bRequestType == USB_RECIP_DEVICE); 1520 && ctrl.bRequestType == USB_RECIP_DEVICE);
1521 if (unlikely(dev->req_config)) 1521 if (unlikely(dev->req_config))
1522 dev->configured = (ctrl.wValue != __constant_cpu_to_le16(0)); 1522 dev->configured = (ctrl.wValue != cpu_to_le16(0));
1523 1523
1524 /* delegate everything to the gadget driver. 1524 /* delegate everything to the gadget driver.
1525 * it may respond after this irq handler returns. 1525 * it may respond after this irq handler returns.
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c
index 77c5d0a8a06e..168658b4b4e2 100644
--- a/drivers/usb/gadget/imx_udc.c
+++ b/drivers/usb/gadget/imx_udc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * driver/usb/gadget/imx_udc.c 2 * driver/usb/gadget/imx_udc.c
3 * 3 *
4 * Copyright (C) 2005 Mike Lee(eemike@gmail.com) 4 * Copyright (C) 2005 Mike Lee <eemike@gmail.com>
5 * Copyright (C) 2008 Darius Augulis <augulis.darius@gmail.com> 5 * Copyright (C) 2008 Darius Augulis <augulis.darius@gmail.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/clk.h> 29#include <linux/clk.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/timer.h>
31 32
32#include <linux/usb/ch9.h> 33#include <linux/usb/ch9.h>
33#include <linux/usb/gadget.h> 34#include <linux/usb/gadget.h>
@@ -51,7 +52,8 @@ void ep0_chg_stat(const char *label, struct imx_udc_struct *imx_usb,
51void imx_udc_enable(struct imx_udc_struct *imx_usb) 52void imx_udc_enable(struct imx_udc_struct *imx_usb)
52{ 53{
53 int temp = __raw_readl(imx_usb->base + USB_CTRL); 54 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 __raw_writel(temp | CTRL_FE_ENA | CTRL_AFE_ENA,
56 imx_usb->base + USB_CTRL);
55 imx_usb->gadget.speed = USB_SPEED_FULL; 57 imx_usb->gadget.speed = USB_SPEED_FULL;
56} 58}
57 59
@@ -126,7 +128,8 @@ void imx_udc_config(struct imx_udc_struct *imx_usb)
126 for (j = 0; j < 5; j++) { 128 for (j = 0; j < 5; j++) {
127 __raw_writeb(ep_conf[j], 129 __raw_writeb(ep_conf[j],
128 imx_usb->base + USB_DDAT); 130 imx_usb->base + USB_DDAT);
129 do {} while (__raw_readl(imx_usb->base + USB_DADR) 131 do {} while (__raw_readl(imx_usb->base
132 + USB_DADR)
130 & DADR_BSY); 133 & DADR_BSY);
131 } 134 }
132 } 135 }
@@ -183,7 +186,8 @@ void imx_udc_init_ep(struct imx_udc_struct *imx_usb)
183 temp = (EP_DIR(imx_ep) << 7) | (max << 5) 186 temp = (EP_DIR(imx_ep) << 7) | (max << 5)
184 | (imx_ep->bmAttributes << 3); 187 | (imx_ep->bmAttributes << 3);
185 __raw_writel(temp, imx_usb->base + USB_EP_STAT(i)); 188 __raw_writel(temp, imx_usb->base + USB_EP_STAT(i));
186 __raw_writel(temp | EPSTAT_FLUSH, imx_usb->base + USB_EP_STAT(i)); 189 __raw_writel(temp | EPSTAT_FLUSH,
190 imx_usb->base + USB_EP_STAT(i));
187 D_INI(imx_usb->dev, "<%s> ep%d_stat %08x\n", __func__, i, 191 D_INI(imx_usb->dev, "<%s> ep%d_stat %08x\n", __func__, i,
188 __raw_readl(imx_usb->base + USB_EP_STAT(i))); 192 __raw_readl(imx_usb->base + USB_EP_STAT(i)));
189 } 193 }
@@ -278,15 +282,18 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep)
278 struct imx_udc_struct *imx_usb = imx_ep->imx_usb; 282 struct imx_udc_struct *imx_usb = imx_ep->imx_usb;
279 int temp, i; 283 int temp, i;
280 284
281 D_ERR(imx_usb->dev, "<%s> Forced stall on %s\n", __func__, imx_ep->ep.name); 285 D_ERR(imx_usb->dev,
286 "<%s> Forced stall on %s\n", __func__, imx_ep->ep.name);
282 287
283 imx_flush(imx_ep); 288 imx_flush(imx_ep);
284 289
285 /* Special care for ep0 */ 290 /* Special care for ep0 */
286 if (EP_NO(imx_ep)) { 291 if (!EP_NO(imx_ep)) {
287 temp = __raw_readl(imx_usb->base + USB_CTRL); 292 temp = __raw_readl(imx_usb->base + USB_CTRL);
288 __raw_writel(temp | CTRL_CMDOVER | CTRL_CMDERROR, imx_usb->base + USB_CTRL); 293 __raw_writel(temp | CTRL_CMDOVER | CTRL_CMDERROR,
289 do { } while (__raw_readl(imx_usb->base + USB_CTRL) & CTRL_CMDOVER); 294 imx_usb->base + USB_CTRL);
295 do { } while (__raw_readl(imx_usb->base + USB_CTRL)
296 & CTRL_CMDOVER);
290 temp = __raw_readl(imx_usb->base + USB_CTRL); 297 temp = __raw_readl(imx_usb->base + USB_CTRL);
291 __raw_writel(temp & ~CTRL_CMDERROR, imx_usb->base + USB_CTRL); 298 __raw_writel(temp & ~CTRL_CMDERROR, imx_usb->base + USB_CTRL);
292 } 299 }
@@ -296,12 +303,13 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep)
296 imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); 303 imx_usb->base + USB_EP_STAT(EP_NO(imx_ep)));
297 304
298 for (i = 0; i < 100; i ++) { 305 for (i = 0; i < 100; i ++) {
299 temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); 306 temp = __raw_readl(imx_usb->base
307 + USB_EP_STAT(EP_NO(imx_ep)));
300 if (!(temp & EPSTAT_STALL)) 308 if (!(temp & EPSTAT_STALL))
301 break; 309 break;
302 udelay(20); 310 udelay(20);
303 } 311 }
304 if (i == 50) 312 if (i == 100)
305 D_ERR(imx_usb->dev, "<%s> Non finished stall on %s\n", 313 D_ERR(imx_usb->dev, "<%s> Non finished stall on %s\n",
306 __func__, imx_ep->ep.name); 314 __func__, imx_ep->ep.name);
307 } 315 }
@@ -325,7 +333,8 @@ static int imx_udc_wakeup(struct usb_gadget *_gadget)
325 ******************************************************************************* 333 *******************************************************************************
326 */ 334 */
327 335
328static void ep_add_request(struct imx_ep_struct *imx_ep, struct imx_request *req) 336static void ep_add_request(struct imx_ep_struct *imx_ep,
337 struct imx_request *req)
329{ 338{
330 if (unlikely(!req)) 339 if (unlikely(!req))
331 return; 340 return;
@@ -334,7 +343,8 @@ static void ep_add_request(struct imx_ep_struct *imx_ep, struct imx_request *req
334 list_add_tail(&req->queue, &imx_ep->queue); 343 list_add_tail(&req->queue, &imx_ep->queue);
335} 344}
336 345
337static void ep_del_request(struct imx_ep_struct *imx_ep, struct imx_request *req) 346static void ep_del_request(struct imx_ep_struct *imx_ep,
347 struct imx_request *req)
338{ 348{
339 if (unlikely(!req)) 349 if (unlikely(!req))
340 return; 350 return;
@@ -343,7 +353,8 @@ static void ep_del_request(struct imx_ep_struct *imx_ep, struct imx_request *req
343 req->in_use = 0; 353 req->in_use = 0;
344} 354}
345 355
346static void done(struct imx_ep_struct *imx_ep, struct imx_request *req, int status) 356static void done(struct imx_ep_struct *imx_ep,
357 struct imx_request *req, int status)
347{ 358{
348 ep_del_request(imx_ep, req); 359 ep_del_request(imx_ep, req);
349 360
@@ -494,7 +505,8 @@ static int write_fifo(struct imx_ep_struct *imx_ep, struct imx_request *req)
494 __func__, imx_ep->ep.name, req, 505 __func__, imx_ep->ep.name, req,
495 completed ? "completed" : "not completed"); 506 completed ? "completed" : "not completed");
496 if (!EP_NO(imx_ep)) 507 if (!EP_NO(imx_ep))
497 ep0_chg_stat(__func__, imx_ep->imx_usb, EP0_IDLE); 508 ep0_chg_stat(__func__,
509 imx_ep->imx_usb, EP0_IDLE);
498 } 510 }
499 } 511 }
500 512
@@ -539,10 +551,9 @@ static int handle_ep0(struct imx_ep_struct *imx_ep)
539 struct imx_request *req = NULL; 551 struct imx_request *req = NULL;
540 int ret = 0; 552 int ret = 0;
541 553
542 if (!list_empty(&imx_ep->queue)) 554 if (!list_empty(&imx_ep->queue)) {
543 req = list_entry(imx_ep->queue.next, struct imx_request, queue); 555 req = list_entry(imx_ep->queue.next, struct imx_request, queue);
544 556
545 if (req) {
546 switch (imx_ep->imx_usb->ep0state) { 557 switch (imx_ep->imx_usb->ep0state) {
547 558
548 case EP0_IN_DATA_PHASE: /* GET_DESCRIPTOR */ 559 case EP0_IN_DATA_PHASE: /* GET_DESCRIPTOR */
@@ -561,6 +572,10 @@ static int handle_ep0(struct imx_ep_struct *imx_ep)
561 } 572 }
562 } 573 }
563 574
575 else
576 D_ERR(imx_ep->imx_usb->dev, "<%s> no request on %s\n",
577 __func__, imx_ep->ep.name);
578
564 return ret; 579 return ret;
565} 580}
566 581
@@ -583,7 +598,8 @@ static void handle_ep0_devreq(struct imx_udc_struct *imx_usb)
583 "<%s> no setup packet received\n", __func__); 598 "<%s> no setup packet received\n", __func__);
584 goto stall; 599 goto stall;
585 } 600 }
586 u.word[i] = __raw_readl(imx_usb->base + USB_EP_FDAT(EP_NO(imx_ep))); 601 u.word[i] = __raw_readl(imx_usb->base
602 + USB_EP_FDAT(EP_NO(imx_ep)));
587 } 603 }
588 604
589 temp = imx_ep_empty(imx_ep); 605 temp = imx_ep_empty(imx_ep);
@@ -759,7 +775,7 @@ static int imx_ep_queue
759 */ 775 */
760 if (imx_usb->set_config && !EP_NO(imx_ep)) { 776 if (imx_usb->set_config && !EP_NO(imx_ep)) {
761 imx_usb->set_config = 0; 777 imx_usb->set_config = 0;
762 D_EPX(imx_usb->dev, 778 D_ERR(imx_usb->dev,
763 "<%s> gadget reply set config\n", __func__); 779 "<%s> gadget reply set config\n", __func__);
764 return 0; 780 return 0;
765 } 781 }
@@ -779,28 +795,29 @@ static int imx_ep_queue
779 return -ESHUTDOWN; 795 return -ESHUTDOWN;
780 } 796 }
781 797
782 local_irq_save(flags);
783
784 /* Debug */ 798 /* Debug */
785 D_REQ(imx_usb->dev, "<%s> ep%d %s request for [%d] bytes\n", 799 D_REQ(imx_usb->dev, "<%s> ep%d %s request for [%d] bytes\n",
786 __func__, EP_NO(imx_ep), 800 __func__, EP_NO(imx_ep),
787 ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state == EP0_IN_DATA_PHASE) 801 ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state
788 || (EP_NO(imx_ep) && EP_DIR(imx_ep))) ? "IN" : "OUT", usb_req->length); 802 == EP0_IN_DATA_PHASE)
803 || (EP_NO(imx_ep) && EP_DIR(imx_ep)))
804 ? "IN" : "OUT", usb_req->length);
789 dump_req(__func__, imx_ep, usb_req); 805 dump_req(__func__, imx_ep, usb_req);
790 806
791 if (imx_ep->stopped) { 807 if (imx_ep->stopped) {
792 usb_req->status = -ESHUTDOWN; 808 usb_req->status = -ESHUTDOWN;
793 ret = -ESHUTDOWN; 809 return -ESHUTDOWN;
794 goto out;
795 } 810 }
796 811
797 if (req->in_use) { 812 if (req->in_use) {
798 D_ERR(imx_usb->dev, 813 D_ERR(imx_usb->dev,
799 "<%s> refusing to queue req %p (already queued)\n", 814 "<%s> refusing to queue req %p (already queued)\n",
800 __func__, req); 815 __func__, req);
801 goto out; 816 return 0;
802 } 817 }
803 818
819 local_irq_save(flags);
820
804 usb_req->status = -EINPROGRESS; 821 usb_req->status = -EINPROGRESS;
805 usb_req->actual = 0; 822 usb_req->actual = 0;
806 823
@@ -810,7 +827,7 @@ static int imx_ep_queue
810 ret = handle_ep0(imx_ep); 827 ret = handle_ep0(imx_ep);
811 else 828 else
812 ret = handle_ep(imx_ep); 829 ret = handle_ep(imx_ep);
813out: 830
814 local_irq_restore(flags); 831 local_irq_restore(flags);
815 return ret; 832 return ret;
816} 833}
@@ -997,71 +1014,32 @@ static void udc_stop_activity(struct imx_udc_struct *imx_usb,
997 ******************************************************************************* 1014 *******************************************************************************
998 */ 1015 */
999 1016
1000static irqreturn_t imx_udc_irq(int irq, void *dev) 1017/*
1018 * Called when timer expires.
1019 * Timer is started when CFG_CHG is received.
1020 */
1021static void handle_config(unsigned long data)
1001{ 1022{
1002 struct imx_udc_struct *imx_usb = dev; 1023 struct imx_udc_struct *imx_usb = (void *)data;
1003 struct usb_ctrlrequest u; 1024 struct usb_ctrlrequest u;
1004 int temp, cfg, intf, alt; 1025 int temp, cfg, intf, alt;
1005 int intr = __raw_readl(imx_usb->base + USB_INTR);
1006 1026
1007 if (intr & (INTR_WAKEUP | INTR_SUSPEND | INTR_RESUME | INTR_RESET_START 1027 local_irq_disable();
1008 | INTR_RESET_STOP | INTR_CFG_CHG)) {
1009 dump_intr(__func__, intr, imx_usb->dev);
1010 dump_usb_stat(__func__, imx_usb);
1011 }
1012 1028
1013 if (!imx_usb->driver) { 1029 temp = __raw_readl(imx_usb->base + USB_STAT);
1014 /*imx_udc_disable(imx_usb);*/ 1030 cfg = (temp & STAT_CFG) >> 5;
1015 goto end_irq; 1031 intf = (temp & STAT_INTF) >> 3;
1016 } 1032 alt = temp & STAT_ALTSET;
1017 1033
1018 if (intr & INTR_WAKEUP) { 1034 D_REQ(imx_usb->dev,
1019 if (imx_usb->gadget.speed == USB_SPEED_UNKNOWN 1035 "<%s> orig config C=%d, I=%d, A=%d / "
1020 && imx_usb->driver && imx_usb->driver->resume) 1036 "req config C=%d, I=%d, A=%d\n",
1021 imx_usb->driver->resume(&imx_usb->gadget); 1037 __func__, imx_usb->cfg, imx_usb->intf, imx_usb->alt,
1022 imx_usb->set_config = 0; 1038 cfg, intf, alt);
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 1039
1041 if (intr & INTR_RESET_STOP) 1040 if (cfg == 1 || cfg == 2) {
1042 imx_usb->gadget.speed = USB_SPEED_FULL;
1043 1041
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) { 1042 if (imx_usb->cfg != cfg) {
1064 D_REQ(imx_usb->dev, "<%s> Change config start\n",__func__);
1065 u.bRequest = USB_REQ_SET_CONFIGURATION; 1043 u.bRequest = USB_REQ_SET_CONFIGURATION;
1066 u.bRequestType = USB_DIR_OUT | 1044 u.bRequestType = USB_DIR_OUT |
1067 USB_TYPE_STANDARD | 1045 USB_TYPE_STANDARD |
@@ -1070,14 +1048,10 @@ static irqreturn_t imx_udc_irq(int irq, void *dev)
1070 u.wIndex = 0; 1048 u.wIndex = 0;
1071 u.wLength = 0; 1049 u.wLength = 0;
1072 imx_usb->cfg = cfg; 1050 imx_usb->cfg = cfg;
1073 imx_usb->set_config = 1;
1074 imx_usb->driver->setup(&imx_usb->gadget, &u); 1051 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 1052
1078 } 1053 }
1079 if (imx_usb->intf != intf || imx_usb->alt != alt) { 1054 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; 1055 u.bRequest = USB_REQ_SET_INTERFACE;
1082 u.bRequestType = USB_DIR_OUT | 1056 u.bRequestType = USB_DIR_OUT |
1083 USB_TYPE_STANDARD | 1057 USB_TYPE_STANDARD |
@@ -1087,20 +1061,92 @@ static irqreturn_t imx_udc_irq(int irq, void *dev)
1087 u.wLength = 0; 1061 u.wLength = 0;
1088 imx_usb->intf = intf; 1062 imx_usb->intf = intf;
1089 imx_usb->alt = alt; 1063 imx_usb->alt = alt;
1090 imx_usb->set_config = 1;
1091 imx_usb->driver->setup(&imx_usb->gadget, &u); 1064 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 } 1065 }
1095 } 1066 }
1096 1067
1068 imx_usb->set_config = 0;
1069
1070 local_irq_enable();
1071}
1072
1073static irqreturn_t imx_udc_irq(int irq, void *dev)
1074{
1075 struct imx_udc_struct *imx_usb = dev;
1076 int intr = __raw_readl(imx_usb->base + USB_INTR);
1077 int temp;
1078
1079 if (intr & (INTR_WAKEUP | INTR_SUSPEND | INTR_RESUME | INTR_RESET_START
1080 | INTR_RESET_STOP | INTR_CFG_CHG)) {
1081 dump_intr(__func__, intr, imx_usb->dev);
1082 dump_usb_stat(__func__, imx_usb);
1083 }
1084
1085 if (!imx_usb->driver)
1086 goto end_irq;
1087
1097 if (intr & INTR_SOF) { 1088 if (intr & INTR_SOF) {
1089 /* Copy from Freescale BSP.
1090 We must enable SOF intr and set CMDOVER.
1091 Datasheet don't specifiy this action, but it
1092 is done in Freescale BSP, so just copy it.
1093 */
1098 if (imx_usb->ep0state == EP0_IDLE) { 1094 if (imx_usb->ep0state == EP0_IDLE) {
1099 temp = __raw_readl(imx_usb->base + USB_CTRL); 1095 temp = __raw_readl(imx_usb->base + USB_CTRL);
1100 __raw_writel(temp | CTRL_CMDOVER, imx_usb->base + USB_CTRL); 1096 __raw_writel(temp | CTRL_CMDOVER,
1097 imx_usb->base + USB_CTRL);
1101 } 1098 }
1102 } 1099 }
1103 1100
1101 if (intr & INTR_CFG_CHG) {
1102 /* A workaround of serious IMX UDC bug.
1103 Handling of CFG_CHG should be delayed for some time, because
1104 IMX does not NACK the host when CFG_CHG interrupt is pending.
1105 There is no time to handle current CFG_CHG
1106 if next CFG_CHG or SETUP packed is send immediately.
1107 We have to clear CFG_CHG, start the timer and
1108 NACK the host by setting CTRL_CMDOVER
1109 if it sends any SETUP packet.
1110 When timer expires, handler is called to handle configuration
1111 changes. While CFG_CHG is not handled (set_config=1),
1112 we must NACK the host to every SETUP packed.
1113 This delay prevents from going out of sync with host.
1114 */
1115 __raw_writel(INTR_CFG_CHG, imx_usb->base + USB_INTR);
1116 imx_usb->set_config = 1;
1117 mod_timer(&imx_usb->timer, jiffies + 5);
1118 goto end_irq;
1119 }
1120
1121 if (intr & INTR_WAKEUP) {
1122 if (imx_usb->gadget.speed == USB_SPEED_UNKNOWN
1123 && imx_usb->driver && imx_usb->driver->resume)
1124 imx_usb->driver->resume(&imx_usb->gadget);
1125 imx_usb->set_config = 0;
1126 del_timer(&imx_usb->timer);
1127 imx_usb->gadget.speed = USB_SPEED_FULL;
1128 }
1129
1130 if (intr & INTR_SUSPEND) {
1131 if (imx_usb->gadget.speed != USB_SPEED_UNKNOWN
1132 && imx_usb->driver && imx_usb->driver->suspend)
1133 imx_usb->driver->suspend(&imx_usb->gadget);
1134 imx_usb->set_config = 0;
1135 del_timer(&imx_usb->timer);
1136 imx_usb->gadget.speed = USB_SPEED_UNKNOWN;
1137 }
1138
1139 if (intr & INTR_RESET_START) {
1140 __raw_writel(intr, imx_usb->base + USB_INTR);
1141 udc_stop_activity(imx_usb, imx_usb->driver);
1142 imx_usb->set_config = 0;
1143 del_timer(&imx_usb->timer);
1144 imx_usb->gadget.speed = USB_SPEED_UNKNOWN;
1145 }
1146
1147 if (intr & INTR_RESET_STOP)
1148 imx_usb->gadget.speed = USB_SPEED_FULL;
1149
1104end_irq: 1150end_irq:
1105 __raw_writel(intr, imx_usb->base + USB_INTR); 1151 __raw_writel(intr, imx_usb->base + USB_INTR);
1106 return IRQ_HANDLED; 1152 return IRQ_HANDLED;
@@ -1109,6 +1155,7 @@ end_irq:
1109static irqreturn_t imx_udc_ctrl_irq(int irq, void *dev) 1155static irqreturn_t imx_udc_ctrl_irq(int irq, void *dev)
1110{ 1156{
1111 struct imx_udc_struct *imx_usb = dev; 1157 struct imx_udc_struct *imx_usb = dev;
1158 struct imx_ep_struct *imx_ep = &imx_usb->imx_ep[0];
1112 int intr = __raw_readl(imx_usb->base + USB_EP_INTR(0)); 1159 int intr = __raw_readl(imx_usb->base + USB_EP_INTR(0));
1113 1160
1114 dump_ep_intr(__func__, 0, intr, imx_usb->dev); 1161 dump_ep_intr(__func__, 0, intr, imx_usb->dev);
@@ -1118,16 +1165,15 @@ static irqreturn_t imx_udc_ctrl_irq(int irq, void *dev)
1118 return IRQ_HANDLED; 1165 return IRQ_HANDLED;
1119 } 1166 }
1120 1167
1121 /* DEVREQ IRQ has highest priority */ 1168 /* DEVREQ has highest priority */
1122 if (intr & (EPINTR_DEVREQ | EPINTR_MDEVREQ)) 1169 if (intr & (EPINTR_DEVREQ | EPINTR_MDEVREQ))
1123 handle_ep0_devreq(imx_usb); 1170 handle_ep0_devreq(imx_usb);
1124 /* Seem i.MX is missing EOF interrupt sometimes. 1171 /* Seem i.MX is missing EOF interrupt sometimes.
1125 * Therefore we monitor both EOF and FIFO_EMPTY interrups 1172 * Therefore we don't monitor EOF.
1126 * when transmiting, and both EOF and FIFO_FULL when 1173 * We call handle_ep0() only if a request is queued for ep0.
1127 * receiving data.
1128 */ 1174 */
1129 else if (intr & (EPINTR_EOF | EPINTR_FIFO_EMPTY | EPINTR_FIFO_FULL)) 1175 else if (!list_empty(&imx_ep->queue))
1130 handle_ep0(&imx_usb->imx_ep[0]); 1176 handle_ep0(imx_ep);
1131 1177
1132 __raw_writel(intr, imx_usb->base + USB_EP_INTR(0)); 1178 __raw_writel(intr, imx_usb->base + USB_EP_INTR(0));
1133 1179
@@ -1186,8 +1232,8 @@ static struct imx_udc_struct controller = {
1186 .ep0 = &controller.imx_ep[0].ep, 1232 .ep0 = &controller.imx_ep[0].ep,
1187 .name = driver_name, 1233 .name = driver_name,
1188 .dev = { 1234 .dev = {
1189 .bus_id = "gadget", 1235 .init_name = "gadget",
1190 }, 1236 },
1191 }, 1237 },
1192 1238
1193 .imx_ep[0] = { 1239 .imx_ep[0] = {
@@ -1318,6 +1364,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1318 1364
1319 udc_stop_activity(imx_usb, driver); 1365 udc_stop_activity(imx_usb, driver);
1320 imx_udc_disable(imx_usb); 1366 imx_udc_disable(imx_usb);
1367 del_timer(&imx_usb->timer);
1321 1368
1322 driver->unbind(&imx_usb->gadget); 1369 driver->unbind(&imx_usb->gadget);
1323 imx_usb->gadget.dev.driver = NULL; 1370 imx_usb->gadget.dev.driver = NULL;
@@ -1435,6 +1482,10 @@ static int __init imx_udc_probe(struct platform_device *pdev)
1435 usb_init_data(imx_usb); 1482 usb_init_data(imx_usb);
1436 imx_udc_init(imx_usb); 1483 imx_udc_init(imx_usb);
1437 1484
1485 init_timer(&imx_usb->timer);
1486 imx_usb->timer.function = handle_config;
1487 imx_usb->timer.data = (unsigned long)imx_usb;
1488
1438 return 0; 1489 return 0;
1439 1490
1440fail3: 1491fail3:
@@ -1457,6 +1508,7 @@ static int __exit imx_udc_remove(struct platform_device *pdev)
1457 int i; 1508 int i;
1458 1509
1459 imx_udc_disable(imx_usb); 1510 imx_udc_disable(imx_usb);
1511 del_timer(&imx_usb->timer);
1460 1512
1461 for (i = 0; i < IMX_USB_NB_EP + 1; i++) 1513 for (i = 0; i < IMX_USB_NB_EP + 1; i++)
1462 free_irq(imx_usb->usbd_int[i], imx_usb); 1514 free_irq(imx_usb->usbd_int[i], imx_usb);
diff --git a/drivers/usb/gadget/imx_udc.h b/drivers/usb/gadget/imx_udc.h
index 850076937d8d..b48ad59603d1 100644
--- a/drivers/usb/gadget/imx_udc.h
+++ b/drivers/usb/gadget/imx_udc.h
@@ -23,7 +23,8 @@
23/* Helper macros */ 23/* Helper macros */
24#define EP_NO(ep) ((ep->bEndpointAddress) & ~USB_DIR_IN) /* IN:1, OUT:0 */ 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) 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*/ 26#define irq_to_ep(irq) (((irq) >= USBD_INT0) || ((irq) <= USBD_INT6) \
27 ? ((irq) - USBD_INT0) : (USBD_INT6)) /*should not happen*/
27#define ep_to_irq(ep) (EP_NO((ep)) + USBD_INT0) 28#define ep_to_irq(ep) (EP_NO((ep)) + USBD_INT0)
28#define IMX_USB_NB_EP 6 29#define IMX_USB_NB_EP 6
29 30
@@ -58,6 +59,7 @@ struct imx_udc_struct {
58 struct device *dev; 59 struct device *dev;
59 struct imx_ep_struct imx_ep[IMX_USB_NB_EP]; 60 struct imx_ep_struct imx_ep[IMX_USB_NB_EP];
60 struct clk *clk; 61 struct clk *clk;
62 struct timer_list timer;
61 enum ep0_state ep0state; 63 enum ep0_state ep0state;
62 struct resource *res; 64 struct resource *res;
63 void __iomem *base; 65 void __iomem *base;
@@ -88,8 +90,8 @@ struct imx_udc_struct {
88#define USB_EP_FDAT3(x) (0x3F + (x*0x30)) /* USB FIFO data */ 90#define USB_EP_FDAT3(x) (0x3F + (x*0x30)) /* USB FIFO data */
89#define USB_EP_FSTAT(x) (0x40 + (x*0x30)) /* USB FIFO status */ 91#define USB_EP_FSTAT(x) (0x40 + (x*0x30)) /* USB FIFO status */
90#define USB_EP_FCTRL(x) (0x44 + (x*0x30)) /* USB FIFO control */ 92#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 */ 93#define USB_EP_LRFP(x) (0x48 + (x*0x30)) /* USB last rd f. pointer */
92#define USB_EP_LWFP(x) (0x4C + (x*0x30)) /* USB last write frame pointer */ 94#define USB_EP_LWFP(x) (0x4C + (x*0x30)) /* USB last wr f. pointer */
93#define USB_EP_FALRM(x) (0x50 + (x*0x30)) /* USB FIFO alarm */ 95#define USB_EP_FALRM(x) (0x50 + (x*0x30)) /* USB FIFO alarm */
94#define USB_EP_FRDP(x) (0x54 + (x*0x30)) /* USB FIFO read pointer */ 96#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 */ 97#define USB_EP_FWRP(x) (0x58 + (x*0x30)) /* USB FIFO write pointer */
@@ -170,7 +172,7 @@ struct imx_udc_struct {
170/* #define DEBUG_IRQ */ 172/* #define DEBUG_IRQ */
171/* #define DEBUG_EPIRQ */ 173/* #define DEBUG_EPIRQ */
172/* #define DEBUG_DUMP */ 174/* #define DEBUG_DUMP */
173#define DEBUG_ERR 175/* #define DEBUG_ERR */
174 176
175#ifdef DEBUG_REQ 177#ifdef DEBUG_REQ
176 #define D_REQ(dev, args...) dev_dbg(dev, ## args) 178 #define D_REQ(dev, args...) dev_dbg(dev, ## args)
@@ -228,7 +230,8 @@ struct imx_udc_struct {
228#endif /* DEBUG_IRQ */ 230#endif /* DEBUG_IRQ */
229 231
230#ifdef DEBUG_EPIRQ 232#ifdef DEBUG_EPIRQ
231 static void dump_ep_intr(const char *label, int nr, int irqreg, struct device *dev) 233 static void dump_ep_intr(const char *label, int nr, int irqreg,
234 struct device *dev)
232 { 235 {
233 dev_dbg(dev, "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n", label, nr, 236 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" : "", 237 (irqreg & EPINTR_FIFO_FULL) ? " full" : "",
@@ -246,7 +249,8 @@ struct imx_udc_struct {
246#endif /* DEBUG_IRQ */ 249#endif /* DEBUG_IRQ */
247 250
248#ifdef DEBUG_DUMP 251#ifdef DEBUG_DUMP
249 static void dump_usb_stat(const char *label, struct imx_udc_struct *imx_usb) 252 static void dump_usb_stat(const char *label,
253 struct imx_udc_struct *imx_usb)
250 { 254 {
251 int temp = __raw_readl(imx_usb->base + USB_STAT); 255 int temp = __raw_readl(imx_usb->base + USB_STAT);
252 256
@@ -259,12 +263,15 @@ struct imx_udc_struct {
259 (temp & STAT_ALTSET)); 263 (temp & STAT_ALTSET));
260 } 264 }
261 265
262 static void dump_ep_stat(const char *label, struct imx_ep_struct *imx_ep) 266 static void dump_ep_stat(const char *label,
267 struct imx_ep_struct *imx_ep)
263 { 268 {
264 int temp = __raw_readl(imx_ep->imx_usb->base + USB_EP_INTR(EP_NO(imx_ep))); 269 int temp = __raw_readl(imx_ep->imx_usb->base
270 + USB_EP_INTR(EP_NO(imx_ep)));
265 271
266 dev_dbg(imx_ep->imx_usb->dev, 272 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), 273 "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n",
274 label, EP_NO(imx_ep),
268 (temp & EPINTR_FIFO_FULL) ? " full" : "", 275 (temp & EPINTR_FIFO_FULL) ? " full" : "",
269 (temp & EPINTR_FIFO_EMPTY) ? " fempty" : "", 276 (temp & EPINTR_FIFO_EMPTY) ? " fempty" : "",
270 (temp & EPINTR_FIFO_ERROR) ? " ferr" : "", 277 (temp & EPINTR_FIFO_ERROR) ? " ferr" : "",
@@ -275,18 +282,22 @@ struct imx_udc_struct {
275 (temp & EPINTR_DEVREQ) ? " devreq" : "", 282 (temp & EPINTR_DEVREQ) ? " devreq" : "",
276 (temp & EPINTR_EOT) ? " eot" : ""); 283 (temp & EPINTR_EOT) ? " eot" : "");
277 284
278 temp = __raw_readl(imx_ep->imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); 285 temp = __raw_readl(imx_ep->imx_usb->base
286 + USB_EP_STAT(EP_NO(imx_ep)));
279 287
280 dev_dbg(imx_ep->imx_usb->dev, 288 dev_dbg(imx_ep->imx_usb->dev,
281 "<%s> EP%d_STAT=[%s%s bcount=%d]\n", label, EP_NO(imx_ep), 289 "<%s> EP%d_STAT=[%s%s bcount=%d]\n",
290 label, EP_NO(imx_ep),
282 (temp & EPSTAT_SIP) ? " sip" : "", 291 (temp & EPSTAT_SIP) ? " sip" : "",
283 (temp & EPSTAT_STALL) ? " stall" : "", 292 (temp & EPSTAT_STALL) ? " stall" : "",
284 (temp & EPSTAT_BCOUNT) >> 16); 293 (temp & EPSTAT_BCOUNT) >> 16);
285 294
286 temp = __raw_readl(imx_ep->imx_usb->base + USB_EP_FSTAT(EP_NO(imx_ep))); 295 temp = __raw_readl(imx_ep->imx_usb->base
296 + USB_EP_FSTAT(EP_NO(imx_ep)));
287 297
288 dev_dbg(imx_ep->imx_usb->dev, 298 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), 299 "<%s> EP%d_FSTAT=[%s%s%s%s%s%s%s]\n",
300 label, EP_NO(imx_ep),
290 (temp & FSTAT_ERR) ? " ferr" : "", 301 (temp & FSTAT_ERR) ? " ferr" : "",
291 (temp & FSTAT_UF) ? " funder" : "", 302 (temp & FSTAT_UF) ? " funder" : "",
292 (temp & FSTAT_OF) ? " fover" : "", 303 (temp & FSTAT_OF) ? " fover" : "",
@@ -296,19 +307,23 @@ struct imx_udc_struct {
296 (temp & FSTAT_EMPTY) ? " fempty" : ""); 307 (temp & FSTAT_EMPTY) ? " fempty" : "");
297 } 308 }
298 309
299 static void dump_req(const char *label, struct imx_ep_struct *imx_ep, struct usb_request *req) 310 static void dump_req(const char *label, struct imx_ep_struct *imx_ep,
311 struct usb_request *req)
300 { 312 {
301 int i; 313 int i;
302 314
303 if (!req || !req->buf) { 315 if (!req || !req->buf) {
304 dev_dbg(imx_ep->imx_usb->dev, "<%s> req or req buf is free\n", label); 316 dev_dbg(imx_ep->imx_usb->dev,
317 "<%s> req or req buf is free\n", label);
305 return; 318 return;
306 } 319 }
307 320
308 if ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state == EP0_IN_DATA_PHASE) 321 if ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state
322 == EP0_IN_DATA_PHASE)
309 || (EP_NO(imx_ep) && EP_DIR(imx_ep))) { 323 || (EP_NO(imx_ep) && EP_DIR(imx_ep))) {
310 324
311 dev_dbg(imx_ep->imx_usb->dev, "<%s> request dump <", label); 325 dev_dbg(imx_ep->imx_usb->dev,
326 "<%s> request dump <", label);
312 for (i = 0; i < req->length; i++) 327 for (i = 0; i < req->length; i++)
313 printk("%02x-", *((u8 *)req->buf + i)); 328 printk("%02x-", *((u8 *)req->buf + i));
314 printk(">\n"); 329 printk(">\n");
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 317b48fdbf01..d20937f28a19 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1334,7 +1334,7 @@ static void make_qualifier (struct dev_data *dev)
1334 1334
1335 qual.bLength = sizeof qual; 1335 qual.bLength = sizeof qual;
1336 qual.bDescriptorType = USB_DT_DEVICE_QUALIFIER; 1336 qual.bDescriptorType = USB_DT_DEVICE_QUALIFIER;
1337 qual.bcdUSB = __constant_cpu_to_le16 (0x0200); 1337 qual.bcdUSB = cpu_to_le16 (0x0200);
1338 1338
1339 desc = dev->dev; 1339 desc = dev->dev;
1340 qual.bDeviceClass = desc->bDeviceClass; 1340 qual.bDeviceClass = desc->bDeviceClass;
@@ -1908,7 +1908,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1908 || dev->dev->bNumConfigurations != 1) 1908 || dev->dev->bNumConfigurations != 1)
1909 goto fail; 1909 goto fail;
1910 dev->dev->bNumConfigurations = 1; 1910 dev->dev->bNumConfigurations = 1;
1911 dev->dev->bcdUSB = __constant_cpu_to_le16 (0x0200); 1911 dev->dev->bcdUSB = cpu_to_le16 (0x0200);
1912 1912
1913 /* triggers gadgetfs_bind(); then we can enumerate. */ 1913 /* triggers gadgetfs_bind(); then we can enumerate. */
1914 spin_unlock_irq (&dev->lock); 1914 spin_unlock_irq (&dev->lock);
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index d554b0895603..6cd3d54f5640 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -432,8 +432,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
432 device_add(&dev->gadget.dev); 432 device_add(&dev->gadget.dev);
433 retval = driver->bind(&dev->gadget); 433 retval = driver->bind(&dev->gadget);
434 if (retval) { 434 if (retval) {
435 printk("%s: bind to driver %s --> error %d\n", dev->gadget.name, 435 printk(KERN_WARNING "%s: bind to driver %s --> error %d\n",
436 driver->driver.name, retval); 436 dev->gadget.name, driver->driver.name, retval);
437 device_del(&dev->gadget.dev); 437 device_del(&dev->gadget.dev);
438 438
439 dev->driver = 0; 439 dev->driver = 0;
@@ -445,8 +445,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
445 * for set_configuration as well as eventual disconnect. 445 * for set_configuration as well as eventual disconnect.
446 * NOTE: this shouldn't power up until later. 446 * NOTE: this shouldn't power up until later.
447 */ 447 */
448 printk("%s: registered gadget driver '%s'\n", dev->gadget.name, 448 printk(KERN_WARNING "%s: registered gadget driver '%s'\n",
449 driver->driver.name); 449 dev->gadget.name, driver->driver.name);
450 450
451 udc_enable(dev); 451 udc_enable(dev);
452 452
@@ -581,7 +581,8 @@ static int read_fifo(struct lh7a40x_ep *ep, struct lh7a40x_request *req)
581 * discard the extra data. 581 * discard the extra data.
582 */ 582 */
583 if (req->req.status != -EOVERFLOW) 583 if (req->req.status != -EOVERFLOW)
584 printk("%s overflow %d\n", ep->ep.name, count); 584 printk(KERN_WARNING "%s overflow %d\n",
585 ep->ep.name, count);
585 req->req.status = -EOVERFLOW; 586 req->req.status = -EOVERFLOW;
586 } else { 587 } else {
587 *buf++ = byte; 588 *buf++ = byte;
@@ -831,7 +832,8 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr)
831 queue); 832 queue);
832 833
833 if (!req) { 834 if (!req) {
834 printk("%s: NULL REQ %d\n", 835 printk(KERN_WARNING
836 "%s: NULL REQ %d\n",
835 __func__, ep_idx); 837 __func__, ep_idx);
836 flush(ep); 838 flush(ep);
837 break; 839 break;
@@ -844,7 +846,7 @@ static void lh7a40x_out_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr)
844 846
845 } else { 847 } else {
846 /* Throw packet away.. */ 848 /* Throw packet away.. */
847 printk("%s: No descriptor?!?\n", __func__); 849 printk(KERN_WARNING "%s: No descriptor?!?\n", __func__);
848 flush(ep); 850 flush(ep);
849 } 851 }
850} 852}
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 12c6d83b218c..9498be87a724 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -142,8 +142,8 @@ static char *type_string (u8 bmAttributes)
142 142
143#include "net2280.h" 143#include "net2280.h"
144 144
145#define valid_bit __constant_cpu_to_le32 (1 << VALID_BIT) 145#define valid_bit cpu_to_le32 (1 << VALID_BIT)
146#define dma_done_ie __constant_cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE) 146#define dma_done_ie cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE)
147 147
148/*-------------------------------------------------------------------------*/ 148/*-------------------------------------------------------------------------*/
149 149
@@ -425,7 +425,7 @@ net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
425 return NULL; 425 return NULL;
426 } 426 }
427 td->dmacount = 0; /* not VALID */ 427 td->dmacount = 0; /* not VALID */
428 td->dmaaddr = __constant_cpu_to_le32 (DMA_ADDR_INVALID); 428 td->dmaaddr = cpu_to_le32 (DMA_ADDR_INVALID);
429 td->dmadesc = td->dmaaddr; 429 td->dmadesc = td->dmaaddr;
430 req->td = td; 430 req->td = td;
431 } 431 }
@@ -775,7 +775,7 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
775 fill_dma_desc (ep, req, 1); 775 fill_dma_desc (ep, req, 1);
776 776
777 if (!use_dma_chaining) 777 if (!use_dma_chaining)
778 req->td->dmacount |= __constant_cpu_to_le32 (1 << END_OF_CHAIN); 778 req->td->dmacount |= cpu_to_le32 (1 << END_OF_CHAIN);
779 779
780 start_queue (ep, tmp, req->td_dma); 780 start_queue (ep, tmp, req->td_dma);
781} 781}
@@ -2407,9 +2407,9 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
2407 2407
2408 if (readl (&e->regs->ep_rsp) 2408 if (readl (&e->regs->ep_rsp)
2409 & (1 << SET_ENDPOINT_HALT)) 2409 & (1 << SET_ENDPOINT_HALT))
2410 status = __constant_cpu_to_le32 (1); 2410 status = cpu_to_le32 (1);
2411 else 2411 else
2412 status = __constant_cpu_to_le32 (0); 2412 status = cpu_to_le32 (0);
2413 2413
2414 /* don't bother with a request object! */ 2414 /* don't bother with a request object! */
2415 writel (0, &dev->epregs [0].ep_irqenb); 2415 writel (0, &dev->epregs [0].ep_irqenb);
@@ -2667,7 +2667,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
2667 req = list_entry (ep->queue.next, 2667 req = list_entry (ep->queue.next,
2668 struct net2280_request, queue); 2668 struct net2280_request, queue);
2669 dmacount = req->td->dmacount; 2669 dmacount = req->td->dmacount;
2670 dmacount &= __constant_cpu_to_le32 ( 2670 dmacount &= cpu_to_le32 (
2671 (1 << VALID_BIT) 2671 (1 << VALID_BIT)
2672 | DMA_BYTE_COUNT_MASK); 2672 | DMA_BYTE_COUNT_MASK);
2673 if (dmacount && (dmacount & valid_bit) == 0) 2673 if (dmacount && (dmacount & valid_bit) == 0)
@@ -2881,7 +2881,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2881 goto done; 2881 goto done;
2882 } 2882 }
2883 td->dmacount = 0; /* not VALID */ 2883 td->dmacount = 0; /* not VALID */
2884 td->dmaaddr = __constant_cpu_to_le32 (DMA_ADDR_INVALID); 2884 td->dmaaddr = cpu_to_le32 (DMA_ADDR_INVALID);
2885 td->dmadesc = td->dmaaddr; 2885 td->dmadesc = td->dmaaddr;
2886 dev->ep [i].dummy = td; 2886 dev->ep [i].dummy = td;
2887 } 2887 }
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 5a3034fdfe47..29500154d00c 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -225,12 +225,12 @@ module_param(qlen, uint, S_IRUGO|S_IWUSR);
225static struct usb_device_descriptor device_desc = { 225static struct usb_device_descriptor device_desc = {
226 .bLength = sizeof device_desc, 226 .bLength = sizeof device_desc,
227 .bDescriptorType = USB_DT_DEVICE, 227 .bDescriptorType = USB_DT_DEVICE,
228 .bcdUSB = __constant_cpu_to_le16(0x0200), 228 .bcdUSB = cpu_to_le16(0x0200),
229 .bDeviceClass = USB_CLASS_PER_INTERFACE, 229 .bDeviceClass = USB_CLASS_PER_INTERFACE,
230 .bDeviceSubClass = 0, 230 .bDeviceSubClass = 0,
231 .bDeviceProtocol = 0, 231 .bDeviceProtocol = 0,
232 .idVendor = __constant_cpu_to_le16(PRINTER_VENDOR_NUM), 232 .idVendor = cpu_to_le16(PRINTER_VENDOR_NUM),
233 .idProduct = __constant_cpu_to_le16(PRINTER_PRODUCT_NUM), 233 .idProduct = cpu_to_le16(PRINTER_PRODUCT_NUM),
234 .iManufacturer = STRING_MANUFACTURER, 234 .iManufacturer = STRING_MANUFACTURER,
235 .iProduct = STRING_PRODUCT, 235 .iProduct = STRING_PRODUCT,
236 .iSerialNumber = STRING_SERIALNUM, 236 .iSerialNumber = STRING_SERIALNUM,
@@ -299,20 +299,20 @@ static struct usb_endpoint_descriptor hs_ep_in_desc = {
299 .bLength = USB_DT_ENDPOINT_SIZE, 299 .bLength = USB_DT_ENDPOINT_SIZE,
300 .bDescriptorType = USB_DT_ENDPOINT, 300 .bDescriptorType = USB_DT_ENDPOINT,
301 .bmAttributes = USB_ENDPOINT_XFER_BULK, 301 .bmAttributes = USB_ENDPOINT_XFER_BULK,
302 .wMaxPacketSize = __constant_cpu_to_le16(512) 302 .wMaxPacketSize = cpu_to_le16(512)
303}; 303};
304 304
305static struct usb_endpoint_descriptor hs_ep_out_desc = { 305static struct usb_endpoint_descriptor hs_ep_out_desc = {
306 .bLength = USB_DT_ENDPOINT_SIZE, 306 .bLength = USB_DT_ENDPOINT_SIZE,
307 .bDescriptorType = USB_DT_ENDPOINT, 307 .bDescriptorType = USB_DT_ENDPOINT,
308 .bmAttributes = USB_ENDPOINT_XFER_BULK, 308 .bmAttributes = USB_ENDPOINT_XFER_BULK,
309 .wMaxPacketSize = __constant_cpu_to_le16(512) 309 .wMaxPacketSize = cpu_to_le16(512)
310}; 310};
311 311
312static struct usb_qualifier_descriptor dev_qualifier = { 312static struct usb_qualifier_descriptor dev_qualifier = {
313 .bLength = sizeof dev_qualifier, 313 .bLength = sizeof dev_qualifier,
314 .bDescriptorType = USB_DT_DEVICE_QUALIFIER, 314 .bDescriptorType = USB_DT_DEVICE_QUALIFIER,
315 .bcdUSB = __constant_cpu_to_le16(0x0200), 315 .bcdUSB = cpu_to_le16(0x0200),
316 .bDeviceClass = USB_CLASS_PRINTER, 316 .bDeviceClass = USB_CLASS_PRINTER,
317 .bNumConfigurations = 1 317 .bNumConfigurations = 1
318}; 318};
@@ -1406,16 +1406,16 @@ printer_bind(struct usb_gadget *gadget)
1406 gadget->name); 1406 gadget->name);
1407 /* unrecognized, but safe unless bulk is REALLY quirky */ 1407 /* unrecognized, but safe unless bulk is REALLY quirky */
1408 device_desc.bcdDevice = 1408 device_desc.bcdDevice =
1409 __constant_cpu_to_le16(0xFFFF); 1409 cpu_to_le16(0xFFFF);
1410 } 1410 }
1411 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", 1411 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s",
1412 init_utsname()->sysname, init_utsname()->release, 1412 init_utsname()->sysname, init_utsname()->release,
1413 gadget->name); 1413 gadget->name);
1414 1414
1415 device_desc.idVendor = 1415 device_desc.idVendor =
1416 __constant_cpu_to_le16(PRINTER_VENDOR_NUM); 1416 cpu_to_le16(PRINTER_VENDOR_NUM);
1417 device_desc.idProduct = 1417 device_desc.idProduct =
1418 __constant_cpu_to_le16(PRINTER_PRODUCT_NUM); 1418 cpu_to_le16(PRINTER_PRODUCT_NUM);
1419 1419
1420 /* support optional vendor/distro customization */ 1420 /* support optional vendor/distro customization */
1421 if (idVendor) { 1421 if (idVendor) {
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 990f40f988d4..8cc676ecbb23 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -30,6 +30,7 @@
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/clk.h> 31#include <linux/clk.h>
32#include <linux/irq.h> 32#include <linux/irq.h>
33#include <linux/gpio.h>
33 34
34#include <asm/byteorder.h> 35#include <asm/byteorder.h>
35#include <mach/hardware.h> 36#include <mach/hardware.h>
@@ -278,7 +279,7 @@ static void pxa_init_debugfs(struct pxa_udc *udc)
278 goto err_queues; 279 goto err_queues;
279 eps = debugfs_create_file("epstate", 0400, root, udc, 280 eps = debugfs_create_file("epstate", 0400, root, udc,
280 &eps_dbg_fops); 281 &eps_dbg_fops);
281 if (!queues) 282 if (!eps)
282 goto err_eps; 283 goto err_eps;
283 284
284 udc->debugfs_root = root; 285 udc->debugfs_root = root;
@@ -747,13 +748,13 @@ static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status)
747} 748}
748 749
749/** 750/**
750 * ep_end_out_req - Ends control endpoint in request 751 * ep_end_out_req - Ends endpoint OUT request
751 * @ep: physical endpoint 752 * @ep: physical endpoint
752 * @req: pxa request 753 * @req: pxa request
753 * 754 *
754 * Context: ep->lock held 755 * Context: ep->lock held
755 * 756 *
756 * Ends endpoint in request (completes usb request). 757 * Ends endpoint OUT request (completes usb request).
757 */ 758 */
758static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) 759static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
759{ 760{
@@ -762,13 +763,13 @@ static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
762} 763}
763 764
764/** 765/**
765 * ep0_end_out_req - Ends control endpoint in request (ends data stage) 766 * ep0_end_out_req - Ends control endpoint OUT request (ends data stage)
766 * @ep: physical endpoint 767 * @ep: physical endpoint
767 * @req: pxa request 768 * @req: pxa request
768 * 769 *
769 * Context: ep->lock held 770 * Context: ep->lock held
770 * 771 *
771 * Ends control endpoint in request (completes usb request), and puts 772 * Ends control endpoint OUT request (completes usb request), and puts
772 * control endpoint into idle state 773 * control endpoint into idle state
773 */ 774 */
774static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) 775static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
@@ -779,13 +780,13 @@ static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
779} 780}
780 781
781/** 782/**
782 * ep_end_in_req - Ends endpoint out request 783 * ep_end_in_req - Ends endpoint IN request
783 * @ep: physical endpoint 784 * @ep: physical endpoint
784 * @req: pxa request 785 * @req: pxa request
785 * 786 *
786 * Context: ep->lock held 787 * Context: ep->lock held
787 * 788 *
788 * Ends endpoint out request (completes usb request). 789 * Ends endpoint IN request (completes usb request).
789 */ 790 */
790static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) 791static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
791{ 792{
@@ -794,20 +795,18 @@ static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
794} 795}
795 796
796/** 797/**
797 * ep0_end_in_req - Ends control endpoint out request (ends data stage) 798 * ep0_end_in_req - Ends control endpoint IN request (ends data stage)
798 * @ep: physical endpoint 799 * @ep: physical endpoint
799 * @req: pxa request 800 * @req: pxa request
800 * 801 *
801 * Context: ep->lock held 802 * Context: ep->lock held
802 * 803 *
803 * Ends control endpoint out request (completes usb request), and puts 804 * Ends control endpoint IN request (completes usb request), and puts
804 * control endpoint into status state 805 * control endpoint into status state
805 */ 806 */
806static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) 807static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
807{ 808{
808 struct pxa_udc *udc = ep->dev; 809 set_ep0state(ep->dev, IN_STATUS_STAGE);
809
810 set_ep0state(udc, IN_STATUS_STAGE);
811 ep_end_in_req(ep, req); 810 ep_end_in_req(ep, req);
812} 811}
813 812
@@ -1167,7 +1166,7 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1167 ep_end_in_req(ep, req); 1166 ep_end_in_req(ep, req);
1168 } else { 1167 } else {
1169 ep_err(ep, "got a request of %d bytes while" 1168 ep_err(ep, "got a request of %d bytes while"
1170 "in state WATI_ACK_SET_CONF_INTERF\n", 1169 "in state WAIT_ACK_SET_CONF_INTERF\n",
1171 length); 1170 length);
1172 ep_del_request(ep, req); 1171 ep_del_request(ep, req);
1173 rc = -EL2HLT; 1172 rc = -EL2HLT;
@@ -1213,30 +1212,26 @@ static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
1213 struct udc_usb_ep *udc_usb_ep; 1212 struct udc_usb_ep *udc_usb_ep;
1214 struct pxa27x_request *req; 1213 struct pxa27x_request *req;
1215 unsigned long flags; 1214 unsigned long flags;
1216 int rc; 1215 int rc = -EINVAL;
1217 1216
1218 if (!_ep) 1217 if (!_ep)
1219 return -EINVAL; 1218 return rc;
1220 udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); 1219 udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep);
1221 ep = udc_usb_ep->pxa_ep; 1220 ep = udc_usb_ep->pxa_ep;
1222 if (!ep || is_ep0(ep)) 1221 if (!ep || is_ep0(ep))
1223 return -EINVAL; 1222 return rc;
1224 1223
1225 spin_lock_irqsave(&ep->lock, flags); 1224 spin_lock_irqsave(&ep->lock, flags);
1226 1225
1227 /* make sure it's actually queued on this endpoint */ 1226 /* make sure it's actually queued on this endpoint */
1228 list_for_each_entry(req, &ep->queue, queue) { 1227 list_for_each_entry(req, &ep->queue, queue) {
1229 if (&req->req == _req) 1228 if (&req->req == _req) {
1229 req_done(ep, req, -ECONNRESET);
1230 rc = 0;
1230 break; 1231 break;
1232 }
1231 } 1233 }
1232 1234
1233 rc = -EINVAL;
1234 if (&req->req != _req)
1235 goto out;
1236
1237 rc = 0;
1238 req_done(ep, req, -ECONNRESET);
1239out:
1240 spin_unlock_irqrestore(&ep->lock, flags); 1235 spin_unlock_irqrestore(&ep->lock, flags);
1241 return rc; 1236 return rc;
1242} 1237}
@@ -1471,6 +1466,32 @@ static struct usb_ep_ops pxa_ep_ops = {
1471 .fifo_flush = pxa_ep_fifo_flush, 1466 .fifo_flush = pxa_ep_fifo_flush,
1472}; 1467};
1473 1468
1469/**
1470 * dplus_pullup - Connect or disconnect pullup resistor to D+ pin
1471 * @udc: udc device
1472 * @on: 0 if disconnect pullup resistor, 1 otherwise
1473 * Context: any
1474 *
1475 * Handle D+ pullup resistor, make the device visible to the usb bus, and
1476 * declare it as a full speed usb device
1477 */
1478static void dplus_pullup(struct pxa_udc *udc, int on)
1479{
1480 if (on) {
1481 if (gpio_is_valid(udc->mach->gpio_pullup))
1482 gpio_set_value(udc->mach->gpio_pullup,
1483 !udc->mach->gpio_pullup_inverted);
1484 if (udc->mach->udc_command)
1485 udc->mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
1486 } else {
1487 if (gpio_is_valid(udc->mach->gpio_pullup))
1488 gpio_set_value(udc->mach->gpio_pullup,
1489 udc->mach->gpio_pullup_inverted);
1490 if (udc->mach->udc_command)
1491 udc->mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
1492 }
1493 udc->pullup_on = on;
1494}
1474 1495
1475/** 1496/**
1476 * pxa_udc_get_frame - Returns usb frame number 1497 * pxa_udc_get_frame - Returns usb frame number
@@ -1500,21 +1521,145 @@ static int pxa_udc_wakeup(struct usb_gadget *_gadget)
1500 return 0; 1521 return 0;
1501} 1522}
1502 1523
1524static void udc_enable(struct pxa_udc *udc);
1525static void udc_disable(struct pxa_udc *udc);
1526
1527/**
1528 * should_enable_udc - Tells if UDC should be enabled
1529 * @udc: udc device
1530 * Context: any
1531 *
1532 * The UDC should be enabled if :
1533
1534 * - the pullup resistor is connected
1535 * - and a gadget driver is bound
1536 * - and vbus is sensed (or no vbus sense is available)
1537 *
1538 * Returns 1 if UDC should be enabled, 0 otherwise
1539 */
1540static int should_enable_udc(struct pxa_udc *udc)
1541{
1542 int put_on;
1543
1544 put_on = ((udc->pullup_on) && (udc->driver));
1545 put_on &= ((udc->vbus_sensed) || (!udc->transceiver));
1546 return put_on;
1547}
1548
1549/**
1550 * should_disable_udc - Tells if UDC should be disabled
1551 * @udc: udc device
1552 * Context: any
1553 *
1554 * The UDC should be disabled if :
1555 * - the pullup resistor is not connected
1556 * - or no gadget driver is bound
1557 * - or no vbus is sensed (when vbus sesing is available)
1558 *
1559 * Returns 1 if UDC should be disabled
1560 */
1561static int should_disable_udc(struct pxa_udc *udc)
1562{
1563 int put_off;
1564
1565 put_off = ((!udc->pullup_on) || (!udc->driver));
1566 put_off |= ((!udc->vbus_sensed) && (udc->transceiver));
1567 return put_off;
1568}
1569
1570/**
1571 * pxa_udc_pullup - Offer manual D+ pullup control
1572 * @_gadget: usb gadget using the control
1573 * @is_active: 0 if disconnect, else connect D+ pullup resistor
1574 * Context: !in_interrupt()
1575 *
1576 * Returns 0 if OK, -EOPNOTSUPP if udc driver doesn't handle D+ pullup
1577 */
1578static int pxa_udc_pullup(struct usb_gadget *_gadget, int is_active)
1579{
1580 struct pxa_udc *udc = to_gadget_udc(_gadget);
1581
1582 if (!gpio_is_valid(udc->mach->gpio_pullup) && !udc->mach->udc_command)
1583 return -EOPNOTSUPP;
1584
1585 dplus_pullup(udc, is_active);
1586
1587 if (should_enable_udc(udc))
1588 udc_enable(udc);
1589 if (should_disable_udc(udc))
1590 udc_disable(udc);
1591 return 0;
1592}
1593
1594static void udc_enable(struct pxa_udc *udc);
1595static void udc_disable(struct pxa_udc *udc);
1596
1597/**
1598 * pxa_udc_vbus_session - Called by external transceiver to enable/disable udc
1599 * @_gadget: usb gadget
1600 * @is_active: 0 if should disable the udc, 1 if should enable
1601 *
1602 * Enables the udc, and optionnaly activates D+ pullup resistor. Or disables the
1603 * udc, and deactivates D+ pullup resistor.
1604 *
1605 * Returns 0
1606 */
1607static int pxa_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
1608{
1609 struct pxa_udc *udc = to_gadget_udc(_gadget);
1610
1611 udc->vbus_sensed = is_active;
1612 if (should_enable_udc(udc))
1613 udc_enable(udc);
1614 if (should_disable_udc(udc))
1615 udc_disable(udc);
1616
1617 return 0;
1618}
1619
1620/**
1621 * pxa_udc_vbus_draw - Called by gadget driver after SET_CONFIGURATION completed
1622 * @_gadget: usb gadget
1623 * @mA: current drawn
1624 *
1625 * Context: !in_interrupt()
1626 *
1627 * Called after a configuration was chosen by a USB host, to inform how much
1628 * current can be drawn by the device from VBus line.
1629 *
1630 * Returns 0 or -EOPNOTSUPP if no transceiver is handling the udc
1631 */
1632static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
1633{
1634 struct pxa_udc *udc;
1635
1636 udc = to_gadget_udc(_gadget);
1637 if (udc->transceiver)
1638 return otg_set_power(udc->transceiver, mA);
1639 return -EOPNOTSUPP;
1640}
1641
1503static const struct usb_gadget_ops pxa_udc_ops = { 1642static const struct usb_gadget_ops pxa_udc_ops = {
1504 .get_frame = pxa_udc_get_frame, 1643 .get_frame = pxa_udc_get_frame,
1505 .wakeup = pxa_udc_wakeup, 1644 .wakeup = pxa_udc_wakeup,
1506 /* current versions must always be self-powered */ 1645 .pullup = pxa_udc_pullup,
1646 .vbus_session = pxa_udc_vbus_session,
1647 .vbus_draw = pxa_udc_vbus_draw,
1507}; 1648};
1508 1649
1509/** 1650/**
1510 * udc_disable - disable udc device controller 1651 * udc_disable - disable udc device controller
1511 * @udc: udc device 1652 * @udc: udc device
1653 * Context: any
1512 * 1654 *
1513 * Disables the udc device : disables clocks, udc interrupts, control endpoint 1655 * Disables the udc device : disables clocks, udc interrupts, control endpoint
1514 * interrupts. 1656 * interrupts.
1515 */ 1657 */
1516static void udc_disable(struct pxa_udc *udc) 1658static void udc_disable(struct pxa_udc *udc)
1517{ 1659{
1660 if (!udc->enabled)
1661 return;
1662
1518 udc_writel(udc, UDCICR0, 0); 1663 udc_writel(udc, UDCICR0, 0);
1519 udc_writel(udc, UDCICR1, 0); 1664 udc_writel(udc, UDCICR1, 0);
1520 1665
@@ -1523,8 +1668,8 @@ static void udc_disable(struct pxa_udc *udc)
1523 1668
1524 ep0_idle(udc); 1669 ep0_idle(udc);
1525 udc->gadget.speed = USB_SPEED_UNKNOWN; 1670 udc->gadget.speed = USB_SPEED_UNKNOWN;
1526 if (udc->mach->udc_command) 1671
1527 udc->mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); 1672 udc->enabled = 0;
1528} 1673}
1529 1674
1530/** 1675/**
@@ -1555,10 +1700,9 @@ static __init void udc_init_data(struct pxa_udc *dev)
1555 } 1700 }
1556 1701
1557 /* USB endpoints init */ 1702 /* USB endpoints init */
1558 for (i = 0; i < NR_USB_ENDPOINTS; i++) 1703 for (i = 1; i < NR_USB_ENDPOINTS; i++)
1559 if (i != 0) 1704 list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list,
1560 list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list, 1705 &dev->gadget.ep_list);
1561 &dev->gadget.ep_list);
1562} 1706}
1563 1707
1564/** 1708/**
@@ -1570,6 +1714,9 @@ static __init void udc_init_data(struct pxa_udc *dev)
1570 */ 1714 */
1571static void udc_enable(struct pxa_udc *udc) 1715static void udc_enable(struct pxa_udc *udc)
1572{ 1716{
1717 if (udc->enabled)
1718 return;
1719
1573 udc_writel(udc, UDCICR0, 0); 1720 udc_writel(udc, UDCICR0, 0);
1574 udc_writel(udc, UDCICR1, 0); 1721 udc_writel(udc, UDCICR1, 0);
1575 udc_clear_mask_UDCCR(udc, UDCCR_UDE); 1722 udc_clear_mask_UDCCR(udc, UDCCR_UDE);
@@ -1598,9 +1745,7 @@ static void udc_enable(struct pxa_udc *udc)
1598 /* enable ep0 irqs */ 1745 /* enable ep0 irqs */
1599 pio_irq_enable(&udc->pxa_ep[0]); 1746 pio_irq_enable(&udc->pxa_ep[0]);
1600 1747
1601 dev_info(udc->dev, "UDC connecting\n"); 1748 udc->enabled = 1;
1602 if (udc->mach->udc_command)
1603 udc->mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
1604} 1749}
1605 1750
1606/** 1751/**
@@ -1612,6 +1757,9 @@ static void udc_enable(struct pxa_udc *udc)
1612 * usb traffic follows until a disconnect is reported. Then a host may connect 1757 * usb traffic follows until a disconnect is reported. Then a host may connect
1613 * again, or the driver might get unbound. 1758 * again, or the driver might get unbound.
1614 * 1759 *
1760 * Note that the udc is not automatically enabled. Check function
1761 * should_enable_udc().
1762 *
1615 * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise 1763 * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise
1616 */ 1764 */
1617int usb_gadget_register_driver(struct usb_gadget_driver *driver) 1765int usb_gadget_register_driver(struct usb_gadget_driver *driver)
@@ -1630,6 +1778,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1630 /* first hook up the driver ... */ 1778 /* first hook up the driver ... */
1631 udc->driver = driver; 1779 udc->driver = driver;
1632 udc->gadget.dev.driver = &driver->driver; 1780 udc->gadget.dev.driver = &driver->driver;
1781 dplus_pullup(udc, 1);
1633 1782
1634 retval = device_add(&udc->gadget.dev); 1783 retval = device_add(&udc->gadget.dev);
1635 if (retval) { 1784 if (retval) {
@@ -1645,9 +1794,21 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1645 dev_dbg(udc->dev, "registered gadget driver '%s'\n", 1794 dev_dbg(udc->dev, "registered gadget driver '%s'\n",
1646 driver->driver.name); 1795 driver->driver.name);
1647 1796
1648 udc_enable(udc); 1797 if (udc->transceiver) {
1798 retval = otg_set_peripheral(udc->transceiver, &udc->gadget);
1799 if (retval) {
1800 dev_err(udc->dev, "can't bind to transceiver\n");
1801 goto transceiver_fail;
1802 }
1803 }
1804
1805 if (should_enable_udc(udc))
1806 udc_enable(udc);
1649 return 0; 1807 return 0;
1650 1808
1809transceiver_fail:
1810 if (driver->unbind)
1811 driver->unbind(&udc->gadget);
1651bind_fail: 1812bind_fail:
1652 device_del(&udc->gadget.dev); 1813 device_del(&udc->gadget.dev);
1653add_fail: 1814add_fail:
@@ -1699,14 +1860,17 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1699 1860
1700 stop_activity(udc, driver); 1861 stop_activity(udc, driver);
1701 udc_disable(udc); 1862 udc_disable(udc);
1863 dplus_pullup(udc, 0);
1702 1864
1703 driver->unbind(&udc->gadget); 1865 driver->unbind(&udc->gadget);
1704 udc->driver = NULL; 1866 udc->driver = NULL;
1705 1867
1706 device_del(&udc->gadget.dev); 1868 device_del(&udc->gadget.dev);
1707
1708 dev_info(udc->dev, "unregistered gadget driver '%s'\n", 1869 dev_info(udc->dev, "unregistered gadget driver '%s'\n",
1709 driver->driver.name); 1870 driver->driver.name);
1871
1872 if (udc->transceiver)
1873 return otg_set_peripheral(udc->transceiver, NULL);
1710 return 0; 1874 return 0;
1711} 1875}
1712EXPORT_SYMBOL(usb_gadget_unregister_driver); 1876EXPORT_SYMBOL(usb_gadget_unregister_driver);
@@ -1823,14 +1987,14 @@ static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq)
1823 struct pxa27x_request *req = NULL; 1987 struct pxa27x_request *req = NULL;
1824 int completed = 0; 1988 int completed = 0;
1825 1989
1990 if (!list_empty(&ep->queue))
1991 req = list_entry(ep->queue.next, struct pxa27x_request, queue);
1992
1826 udccsr0 = udc_ep_readl(ep, UDCCSR); 1993 udccsr0 = udc_ep_readl(ep, UDCCSR);
1827 ep_dbg(ep, "state=%s, req=%p, udccsr0=0x%03x, udcbcr=%d, irq_msk=%x\n", 1994 ep_dbg(ep, "state=%s, req=%p, udccsr0=0x%03x, udcbcr=%d, irq_msk=%x\n",
1828 EP0_STNAME(udc), req, udccsr0, udc_ep_readl(ep, UDCBCR), 1995 EP0_STNAME(udc), req, udccsr0, udc_ep_readl(ep, UDCBCR),
1829 (fifo_irq << 1 | opc_irq)); 1996 (fifo_irq << 1 | opc_irq));
1830 1997
1831 if (!list_empty(&ep->queue))
1832 req = list_entry(ep->queue.next, struct pxa27x_request, queue);
1833
1834 if (udccsr0 & UDCCSR0_SST) { 1998 if (udccsr0 & UDCCSR0_SST) {
1835 ep_dbg(ep, "clearing stall status\n"); 1999 ep_dbg(ep, "clearing stall status\n");
1836 nuke(ep, -EPIPE); 2000 nuke(ep, -EPIPE);
@@ -2212,7 +2376,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev)
2212{ 2376{
2213 struct resource *regs; 2377 struct resource *regs;
2214 struct pxa_udc *udc = &memory; 2378 struct pxa_udc *udc = &memory;
2215 int retval; 2379 int retval = 0, gpio;
2216 2380
2217 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2381 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2218 if (!regs) 2382 if (!regs)
@@ -2223,6 +2387,20 @@ static int __init pxa_udc_probe(struct platform_device *pdev)
2223 2387
2224 udc->dev = &pdev->dev; 2388 udc->dev = &pdev->dev;
2225 udc->mach = pdev->dev.platform_data; 2389 udc->mach = pdev->dev.platform_data;
2390 udc->transceiver = otg_get_transceiver();
2391
2392 gpio = udc->mach->gpio_pullup;
2393 if (gpio_is_valid(gpio)) {
2394 retval = gpio_request(gpio, "USB D+ pullup");
2395 if (retval == 0)
2396 gpio_direction_output(gpio,
2397 udc->mach->gpio_pullup_inverted);
2398 }
2399 if (retval) {
2400 dev_err(&pdev->dev, "Couldn't request gpio %d : %d\n",
2401 gpio, retval);
2402 return retval;
2403 }
2226 2404
2227 udc->clk = clk_get(&pdev->dev, NULL); 2405 udc->clk = clk_get(&pdev->dev, NULL);
2228 if (IS_ERR(udc->clk)) { 2406 if (IS_ERR(udc->clk)) {
@@ -2240,6 +2418,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev)
2240 device_initialize(&udc->gadget.dev); 2418 device_initialize(&udc->gadget.dev);
2241 udc->gadget.dev.parent = &pdev->dev; 2419 udc->gadget.dev.parent = &pdev->dev;
2242 udc->gadget.dev.dma_mask = NULL; 2420 udc->gadget.dev.dma_mask = NULL;
2421 udc->vbus_sensed = 0;
2243 2422
2244 the_controller = udc; 2423 the_controller = udc;
2245 platform_set_drvdata(pdev, udc); 2424 platform_set_drvdata(pdev, udc);
@@ -2273,14 +2452,21 @@ err_clk:
2273static int __exit pxa_udc_remove(struct platform_device *_dev) 2452static int __exit pxa_udc_remove(struct platform_device *_dev)
2274{ 2453{
2275 struct pxa_udc *udc = platform_get_drvdata(_dev); 2454 struct pxa_udc *udc = platform_get_drvdata(_dev);
2455 int gpio = udc->mach->gpio_pullup;
2276 2456
2277 usb_gadget_unregister_driver(udc->driver); 2457 usb_gadget_unregister_driver(udc->driver);
2278 free_irq(udc->irq, udc); 2458 free_irq(udc->irq, udc);
2279 pxa_cleanup_debugfs(udc); 2459 pxa_cleanup_debugfs(udc);
2460 if (gpio_is_valid(gpio))
2461 gpio_free(gpio);
2462
2463 otg_put_transceiver(udc->transceiver);
2280 2464
2465 udc->transceiver = NULL;
2281 platform_set_drvdata(_dev, NULL); 2466 platform_set_drvdata(_dev, NULL);
2282 the_controller = NULL; 2467 the_controller = NULL;
2283 clk_put(udc->clk); 2468 clk_put(udc->clk);
2469 iounmap(udc->regs);
2284 2470
2285 return 0; 2471 return 0;
2286} 2472}
@@ -2319,6 +2505,8 @@ static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state)
2319 } 2505 }
2320 2506
2321 udc_disable(udc); 2507 udc_disable(udc);
2508 udc->pullup_resume = udc->pullup_on;
2509 dplus_pullup(udc, 0);
2322 2510
2323 return 0; 2511 return 0;
2324} 2512}
@@ -2346,7 +2534,9 @@ static int pxa_udc_resume(struct platform_device *_dev)
2346 ep->udccsr_value, ep->udccr_value); 2534 ep->udccsr_value, ep->udccr_value);
2347 } 2535 }
2348 2536
2349 udc_enable(udc); 2537 dplus_pullup(udc, udc->pullup_resume);
2538 if (should_enable_udc(udc))
2539 udc_enable(udc);
2350 /* 2540 /*
2351 * We do not handle OTG yet. 2541 * We do not handle OTG yet.
2352 * 2542 *
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h
index 1d1b7936ee11..db58125331da 100644
--- a/drivers/usb/gadget/pxa27x_udc.h
+++ b/drivers/usb/gadget/pxa27x_udc.h
@@ -26,6 +26,7 @@
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/usb/otg.h>
29 30
30/* 31/*
31 * Register definitions 32 * Register definitions
@@ -421,10 +422,14 @@ struct udc_stats {
421 * @driver: bound gadget (zero, g_ether, g_file_storage, ...) 422 * @driver: bound gadget (zero, g_ether, g_file_storage, ...)
422 * @dev: device 423 * @dev: device
423 * @mach: machine info, used to activate specific GPIO 424 * @mach: machine info, used to activate specific GPIO
425 * @transceiver: external transceiver to handle vbus sense and D+ pullup
424 * @ep0state: control endpoint state machine state 426 * @ep0state: control endpoint state machine state
425 * @stats: statistics on udc usage 427 * @stats: statistics on udc usage
426 * @udc_usb_ep: array of usb endpoints offered by the gadget 428 * @udc_usb_ep: array of usb endpoints offered by the gadget
427 * @pxa_ep: array of pxa available endpoints 429 * @pxa_ep: array of pxa available endpoints
430 * @enabled: UDC was enabled by a previous udc_enable()
431 * @pullup_on: if pullup resistor connected to D+ pin
432 * @pullup_resume: if pullup resistor should be connected to D+ pin on resume
428 * @config: UDC active configuration 433 * @config: UDC active configuration
429 * @last_interface: UDC interface of the last SET_INTERFACE host request 434 * @last_interface: UDC interface of the last SET_INTERFACE host request
430 * @last_alternate: UDC altsetting of the last SET_INTERFACE host request 435 * @last_alternate: UDC altsetting of the last SET_INTERFACE host request
@@ -443,6 +448,7 @@ struct pxa_udc {
443 struct usb_gadget_driver *driver; 448 struct usb_gadget_driver *driver;
444 struct device *dev; 449 struct device *dev;
445 struct pxa2xx_udc_mach_info *mach; 450 struct pxa2xx_udc_mach_info *mach;
451 struct otg_transceiver *transceiver;
446 452
447 enum ep0_state ep0state; 453 enum ep0_state ep0state;
448 struct udc_stats stats; 454 struct udc_stats stats;
@@ -450,6 +456,10 @@ struct pxa_udc {
450 struct udc_usb_ep udc_usb_ep[NR_USB_ENDPOINTS]; 456 struct udc_usb_ep udc_usb_ep[NR_USB_ENDPOINTS];
451 struct pxa_ep pxa_ep[NR_PXA_ENDPOINTS]; 457 struct pxa_ep pxa_ep[NR_PXA_ENDPOINTS];
452 458
459 unsigned enabled:1;
460 unsigned pullup_on:1;
461 unsigned pullup_resume:1;
462 unsigned vbus_sensed:1;
453 unsigned config:2; 463 unsigned config:2;
454 unsigned last_interface:3; 464 unsigned last_interface:3;
455 unsigned last_alternate:3; 465 unsigned last_alternate:3;
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 37879af1c433..f46a60962dab 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -87,12 +87,12 @@ static struct usb_gadget_strings *dev_strings[] = {
87static struct usb_device_descriptor device_desc = { 87static struct usb_device_descriptor device_desc = {
88 .bLength = USB_DT_DEVICE_SIZE, 88 .bLength = USB_DT_DEVICE_SIZE,
89 .bDescriptorType = USB_DT_DEVICE, 89 .bDescriptorType = USB_DT_DEVICE,
90 .bcdUSB = __constant_cpu_to_le16(0x0200), 90 .bcdUSB = cpu_to_le16(0x0200),
91 /* .bDeviceClass = f(use_acm) */ 91 /* .bDeviceClass = f(use_acm) */
92 .bDeviceSubClass = 0, 92 .bDeviceSubClass = 0,
93 .bDeviceProtocol = 0, 93 .bDeviceProtocol = 0,
94 /* .bMaxPacketSize0 = f(hardware) */ 94 /* .bMaxPacketSize0 = f(hardware) */
95 .idVendor = __constant_cpu_to_le16(GS_VENDOR_ID), 95 .idVendor = cpu_to_le16(GS_VENDOR_ID),
96 /* .idProduct = f(use_acm) */ 96 /* .idProduct = f(use_acm) */
97 /* .bcdDevice = f(hardware) */ 97 /* .bcdDevice = f(hardware) */
98 /* .iManufacturer = DYNAMIC */ 98 /* .iManufacturer = DYNAMIC */
@@ -216,7 +216,7 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
216 pr_warning("gs_bind: controller '%s' not recognized\n", 216 pr_warning("gs_bind: controller '%s' not recognized\n",
217 gadget->name); 217 gadget->name);
218 device_desc.bcdDevice = 218 device_desc.bcdDevice =
219 __constant_cpu_to_le16(GS_VERSION_NUM | 0x0099); 219 cpu_to_le16(GS_VERSION_NUM | 0x0099);
220 } 220 }
221 221
222 if (gadget_is_otg(cdev->gadget)) { 222 if (gadget_is_otg(cdev->gadget)) {
@@ -255,19 +255,19 @@ static int __init init(void)
255 serial_config_driver.bConfigurationValue = 2; 255 serial_config_driver.bConfigurationValue = 2;
256 device_desc.bDeviceClass = USB_CLASS_COMM; 256 device_desc.bDeviceClass = USB_CLASS_COMM;
257 device_desc.idProduct = 257 device_desc.idProduct =
258 __constant_cpu_to_le16(GS_CDC_PRODUCT_ID); 258 cpu_to_le16(GS_CDC_PRODUCT_ID);
259 } else if (use_obex) { 259 } else if (use_obex) {
260 serial_config_driver.label = "CDC OBEX config"; 260 serial_config_driver.label = "CDC OBEX config";
261 serial_config_driver.bConfigurationValue = 3; 261 serial_config_driver.bConfigurationValue = 3;
262 device_desc.bDeviceClass = USB_CLASS_COMM; 262 device_desc.bDeviceClass = USB_CLASS_COMM;
263 device_desc.idProduct = 263 device_desc.idProduct =
264 __constant_cpu_to_le16(GS_CDC_OBEX_PRODUCT_ID); 264 cpu_to_le16(GS_CDC_OBEX_PRODUCT_ID);
265 } else { 265 } else {
266 serial_config_driver.label = "Generic Serial config"; 266 serial_config_driver.label = "Generic Serial config";
267 serial_config_driver.bConfigurationValue = 1; 267 serial_config_driver.bConfigurationValue = 1;
268 device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC; 268 device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC;
269 device_desc.idProduct = 269 device_desc.idProduct =
270 __constant_cpu_to_le16(GS_PRODUCT_ID); 270 cpu_to_le16(GS_PRODUCT_ID);
271 } 271 }
272 strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label; 272 strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label;
273 273
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index 53d59287f2bc..0a4d99ab40d8 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -1092,7 +1092,7 @@ int __init gserial_setup(struct usb_gadget *g, unsigned count)
1092 gs_tty_driver->init_termios.c_ispeed = 9600; 1092 gs_tty_driver->init_termios.c_ispeed = 9600;
1093 gs_tty_driver->init_termios.c_ospeed = 9600; 1093 gs_tty_driver->init_termios.c_ospeed = 9600;
1094 1094
1095 coding.dwDTERate = __constant_cpu_to_le32(9600); 1095 coding.dwDTERate = cpu_to_le32(9600);
1096 coding.bCharFormat = 8; 1096 coding.bCharFormat = 8;
1097 coding.bParityType = USB_CDC_NO_PARITY; 1097 coding.bParityType = USB_CDC_NO_PARITY;
1098 coding.bDataBits = USB_CDC_1_STOP_BITS; 1098 coding.bDataBits = USB_CDC_1_STOP_BITS;
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 361d9659ac48..2d772401b7ad 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -102,22 +102,32 @@ module_param(loopdefault, bool, S_IRUGO|S_IWUSR);
102#ifndef CONFIG_USB_ZERO_HNPTEST 102#ifndef CONFIG_USB_ZERO_HNPTEST
103#define DRIVER_VENDOR_NUM 0x0525 /* NetChip */ 103#define DRIVER_VENDOR_NUM 0x0525 /* NetChip */
104#define DRIVER_PRODUCT_NUM 0xa4a0 /* Linux-USB "Gadget Zero" */ 104#define DRIVER_PRODUCT_NUM 0xa4a0 /* Linux-USB "Gadget Zero" */
105#define DEFAULT_AUTORESUME 0
105#else 106#else
106#define DRIVER_VENDOR_NUM 0x1a0a /* OTG test device IDs */ 107#define DRIVER_VENDOR_NUM 0x1a0a /* OTG test device IDs */
107#define DRIVER_PRODUCT_NUM 0xbadd 108#define DRIVER_PRODUCT_NUM 0xbadd
109#define DEFAULT_AUTORESUME 5
108#endif 110#endif
109 111
112/* If the optional "autoresume" mode is enabled, it provides good
113 * functional coverage for the "USBCV" test harness from USB-IF.
114 * It's always set if OTG mode is enabled.
115 */
116unsigned autoresume = DEFAULT_AUTORESUME;
117module_param(autoresume, uint, S_IRUGO);
118MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup");
119
110/*-------------------------------------------------------------------------*/ 120/*-------------------------------------------------------------------------*/
111 121
112static struct usb_device_descriptor device_desc = { 122static struct usb_device_descriptor device_desc = {
113 .bLength = sizeof device_desc, 123 .bLength = sizeof device_desc,
114 .bDescriptorType = USB_DT_DEVICE, 124 .bDescriptorType = USB_DT_DEVICE,
115 125
116 .bcdUSB = __constant_cpu_to_le16(0x0200), 126 .bcdUSB = cpu_to_le16(0x0200),
117 .bDeviceClass = USB_CLASS_VENDOR_SPEC, 127 .bDeviceClass = USB_CLASS_VENDOR_SPEC,
118 128
119 .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_NUM), 129 .idVendor = cpu_to_le16(DRIVER_VENDOR_NUM),
120 .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_NUM), 130 .idProduct = cpu_to_le16(DRIVER_PRODUCT_NUM),
121 .bNumConfigurations = 2, 131 .bNumConfigurations = 2,
122}; 132};
123 133
@@ -212,6 +222,47 @@ void disable_endpoints(struct usb_composite_dev *cdev,
212 222
213/*-------------------------------------------------------------------------*/ 223/*-------------------------------------------------------------------------*/
214 224
225static struct timer_list autoresume_timer;
226
227static void zero_autoresume(unsigned long _c)
228{
229 struct usb_composite_dev *cdev = (void *)_c;
230 struct usb_gadget *g = cdev->gadget;
231
232 /* unconfigured devices can't issue wakeups */
233 if (!cdev->config)
234 return;
235
236 /* Normally the host would be woken up for something
237 * more significant than just a timer firing; likely
238 * because of some direct user request.
239 */
240 if (g->speed != USB_SPEED_UNKNOWN) {
241 int status = usb_gadget_wakeup(g);
242 INFO(cdev, "%s --> %d\n", __func__, status);
243 }
244}
245
246static void zero_suspend(struct usb_composite_dev *cdev)
247{
248 if (cdev->gadget->speed == USB_SPEED_UNKNOWN)
249 return;
250
251 if (autoresume) {
252 mod_timer(&autoresume_timer, jiffies + (HZ * autoresume));
253 DBG(cdev, "suspend, wakeup in %d seconds\n", autoresume);
254 } else
255 DBG(cdev, "%s\n", __func__);
256}
257
258static void zero_resume(struct usb_composite_dev *cdev)
259{
260 DBG(cdev, "%s\n", __func__);
261 del_timer(&autoresume_timer);
262}
263
264/*-------------------------------------------------------------------------*/
265
215static int __init zero_bind(struct usb_composite_dev *cdev) 266static int __init zero_bind(struct usb_composite_dev *cdev)
216{ 267{
217 int gcnum; 268 int gcnum;
@@ -239,17 +290,19 @@ static int __init zero_bind(struct usb_composite_dev *cdev)
239 strings_dev[STRING_SERIAL_IDX].id = id; 290 strings_dev[STRING_SERIAL_IDX].id = id;
240 device_desc.iSerialNumber = id; 291 device_desc.iSerialNumber = id;
241 292
293 setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev);
294
242 /* Register primary, then secondary configuration. Note that 295 /* Register primary, then secondary configuration. Note that
243 * SH3 only allows one config... 296 * SH3 only allows one config...
244 */ 297 */
245 if (loopdefault) { 298 if (loopdefault) {
246 loopback_add(cdev); 299 loopback_add(cdev, autoresume != 0);
247 if (!gadget_is_sh(gadget)) 300 if (!gadget_is_sh(gadget))
248 sourcesink_add(cdev); 301 sourcesink_add(cdev, autoresume != 0);
249 } else { 302 } else {
250 sourcesink_add(cdev); 303 sourcesink_add(cdev, autoresume != 0);
251 if (!gadget_is_sh(gadget)) 304 if (!gadget_is_sh(gadget))
252 loopback_add(cdev); 305 loopback_add(cdev, autoresume != 0);
253 } 306 }
254 307
255 gcnum = usb_gadget_controller_number(gadget); 308 gcnum = usb_gadget_controller_number(gadget);
@@ -265,7 +318,7 @@ static int __init zero_bind(struct usb_composite_dev *cdev)
265 */ 318 */
266 pr_warning("%s: controller '%s' not recognized\n", 319 pr_warning("%s: controller '%s' not recognized\n",
267 longname, gadget->name); 320 longname, gadget->name);
268 device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); 321 device_desc.bcdDevice = cpu_to_le16(0x9999);
269 } 322 }
270 323
271 324
@@ -278,11 +331,20 @@ static int __init zero_bind(struct usb_composite_dev *cdev)
278 return 0; 331 return 0;
279} 332}
280 333
334static int zero_unbind(struct usb_composite_dev *cdev)
335{
336 del_timer_sync(&autoresume_timer);
337 return 0;
338}
339
281static struct usb_composite_driver zero_driver = { 340static struct usb_composite_driver zero_driver = {
282 .name = "zero", 341 .name = "zero",
283 .dev = &device_desc, 342 .dev = &device_desc,
284 .strings = dev_strings, 343 .strings = dev_strings,
285 .bind = zero_bind, 344 .bind = zero_bind,
345 .unbind = zero_unbind,
346 .suspend = zero_suspend,
347 .resume = zero_resume,
286}; 348};
287 349
288MODULE_AUTHOR("David Brownell"); 350MODULE_AUTHOR("David Brownell");
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 2c63bfb1f8d9..845479f7c707 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -24,10 +24,7 @@ config USB_EHCI_HCD
24 The Enhanced Host Controller Interface (EHCI) is standard for USB 2.0 24 The Enhanced Host Controller Interface (EHCI) is standard for USB 2.0
25 "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware. 25 "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware.
26 If your USB host controller supports USB 2.0, you will likely want to 26 If your USB host controller supports USB 2.0, you will likely want to
27 configure this Host Controller Driver. At the time of this writing, 27 configure this Host Controller Driver.
28 the primary implementation of EHCI is a chip from NEC, widely available
29 in add-on PCI cards, but implementations are in the works from other
30 vendors including Intel and Philips. Motherboard support is appearing.
31 28
32 EHCI controllers are packaged with "companion" host controllers (OHCI 29 EHCI controllers are packaged with "companion" host controllers (OHCI
33 or UHCI) to handle USB 1.1 devices connected to root hub ports. Ports 30 or UHCI) to handle USB 1.1 devices connected to root hub ports. Ports
@@ -123,7 +120,7 @@ config USB_ISP116X_HCD
123 120
124config USB_ISP1760_HCD 121config USB_ISP1760_HCD
125 tristate "ISP 1760 HCD support" 122 tristate "ISP 1760 HCD support"
126 depends on USB && EXPERIMENTAL && (PCI || PPC_OF) 123 depends on USB && EXPERIMENTAL
127 ---help--- 124 ---help---
128 The ISP1760 chip is a USB 2.0 host controller. 125 The ISP1760 chip is a USB 2.0 host controller.
129 126
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index e551bb38852b..f2618d17710d 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -110,6 +110,42 @@ MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
110 110
111/*-------------------------------------------------------------------------*/ 111/*-------------------------------------------------------------------------*/
112 112
113static void
114timer_action(struct ehci_hcd *ehci, enum ehci_timer_action action)
115{
116 /* Don't override timeouts which shrink or (later) disable
117 * the async ring; just the I/O watchdog. Note that if a
118 * SHRINK were pending, OFF would never be requested.
119 */
120 if (timer_pending(&ehci->watchdog)
121 && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
122 & ehci->actions))
123 return;
124
125 if (!test_and_set_bit(action, &ehci->actions)) {
126 unsigned long t;
127
128 switch (action) {
129 case TIMER_IO_WATCHDOG:
130 t = EHCI_IO_JIFFIES;
131 break;
132 case TIMER_ASYNC_OFF:
133 t = EHCI_ASYNC_JIFFIES;
134 break;
135 /* case TIMER_ASYNC_SHRINK: */
136 default:
137 /* add a jiffie since we synch against the
138 * 8 KHz uframe counter.
139 */
140 t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
141 break;
142 }
143 mod_timer(&ehci->watchdog, t + jiffies);
144 }
145}
146
147/*-------------------------------------------------------------------------*/
148
113/* 149/*
114 * handshake - spin reading hc until handshake completes or fails 150 * handshake - spin reading hc until handshake completes or fails
115 * @ptr: address of hc register to be read 151 * @ptr: address of hc register to be read
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 3712b925b315..1976b1b3778c 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -333,12 +333,40 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
333 token = hc32_to_cpu(ehci, qtd->hw_token); 333 token = hc32_to_cpu(ehci, qtd->hw_token);
334 334
335 /* always clean up qtds the hc de-activated */ 335 /* always clean up qtds the hc de-activated */
336 retry_xacterr:
336 if ((token & QTD_STS_ACTIVE) == 0) { 337 if ((token & QTD_STS_ACTIVE) == 0) {
337 338
338 /* on STALL, error, and short reads this urb must 339 /* on STALL, error, and short reads this urb must
339 * complete and all its qtds must be recycled. 340 * complete and all its qtds must be recycled.
340 */ 341 */
341 if ((token & QTD_STS_HALT) != 0) { 342 if ((token & QTD_STS_HALT) != 0) {
343
344 /* retry transaction errors until we
345 * reach the software xacterr limit
346 */
347 if ((token & QTD_STS_XACT) &&
348 QTD_CERR(token) == 0 &&
349 --qh->xacterrs > 0 &&
350 !urb->unlinked) {
351 ehci_dbg(ehci,
352 "detected XactErr len %zu/%zu retry %d\n",
353 qtd->length - QTD_LENGTH(token), qtd->length,
354 QH_XACTERR_MAX - qh->xacterrs);
355
356 /* reset the token in the qtd and the
357 * qh overlay (which still contains
358 * the qtd) so that we pick up from
359 * where we left off
360 */
361 token &= ~QTD_STS_HALT;
362 token |= QTD_STS_ACTIVE |
363 (EHCI_TUNE_CERR << 10);
364 qtd->hw_token = cpu_to_hc32(ehci,
365 token);
366 wmb();
367 qh->hw_token = cpu_to_hc32(ehci, token);
368 goto retry_xacterr;
369 }
342 stopped = 1; 370 stopped = 1;
343 371
344 /* magic dummy for some short reads; qh won't advance. 372 /* magic dummy for some short reads; qh won't advance.
@@ -421,6 +449,9 @@ halt:
421 /* remove qtd; it's recycled after possible urb completion */ 449 /* remove qtd; it's recycled after possible urb completion */
422 list_del (&qtd->qtd_list); 450 list_del (&qtd->qtd_list);
423 last = qtd; 451 last = qtd;
452
453 /* reinit the xacterr counter for the next qtd */
454 qh->xacterrs = QH_XACTERR_MAX;
424 } 455 }
425 456
426 /* last urb's completion might still need calling */ 457 /* last urb's completion might still need calling */
@@ -862,6 +893,7 @@ static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
862 head->qh_next.qh = qh; 893 head->qh_next.qh = qh;
863 head->hw_next = dma; 894 head->hw_next = dma;
864 895
896 qh->xacterrs = QH_XACTERR_MAX;
865 qh->qh_state = QH_STATE_LINKED; 897 qh->qh_state = QH_STATE_LINKED;
866 /* qtd completions reported later by interrupt */ 898 /* qtd completions reported later by interrupt */
867} 899}
@@ -1095,7 +1127,8 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1095 prev->qh_next = qh->qh_next; 1127 prev->qh_next = qh->qh_next;
1096 wmb (); 1128 wmb ();
1097 1129
1098 if (unlikely (ehci_to_hcd(ehci)->state == HC_STATE_HALT)) { 1130 /* If the controller isn't running, we don't have to wait for it */
1131 if (unlikely(!HC_IS_RUNNING(ehci_to_hcd(ehci)->state))) {
1099 /* if (unlikely (qh->reclaim != 0)) 1132 /* if (unlikely (qh->reclaim != 0))
1100 * this will recurse, probably not much 1133 * this will recurse, probably not much
1101 */ 1134 */
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 07bcb931021b..ada5d2ba297b 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -563,7 +563,7 @@ static int qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh)
563 // and this qh is active in the current uframe 563 // and this qh is active in the current uframe
564 // (and overlay token SplitXstate is false?) 564 // (and overlay token SplitXstate is false?)
565 // THEN 565 // THEN
566 // qh->hw_info1 |= __constant_cpu_to_hc32(1 << 7 /* "ignore" */); 566 // qh->hw_info1 |= cpu_to_hc32(1 << 7 /* "ignore" */);
567 567
568 /* high bandwidth, or otherwise part of every microframe */ 568 /* high bandwidth, or otherwise part of every microframe */
569 if ((period = qh->period) == 0) 569 if ((period = qh->period) == 0)
@@ -1536,7 +1536,7 @@ itd_link_urb (
1536 struct ehci_itd, itd_list); 1536 struct ehci_itd, itd_list);
1537 list_move_tail (&itd->itd_list, &stream->td_list); 1537 list_move_tail (&itd->itd_list, &stream->td_list);
1538 itd->stream = iso_stream_get (stream); 1538 itd->stream = iso_stream_get (stream);
1539 itd->urb = usb_get_urb (urb); 1539 itd->urb = urb;
1540 itd_init (ehci, stream, itd); 1540 itd_init (ehci, stream, itd);
1541 } 1541 }
1542 1542
@@ -1645,7 +1645,7 @@ itd_complete (
1645 (void) disable_periodic(ehci); 1645 (void) disable_periodic(ehci);
1646 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 1646 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
1647 1647
1648 if (unlikely (list_empty (&stream->td_list))) { 1648 if (unlikely(list_is_singular(&stream->td_list))) {
1649 ehci_to_hcd(ehci)->self.bandwidth_allocated 1649 ehci_to_hcd(ehci)->self.bandwidth_allocated
1650 -= stream->bandwidth; 1650 -= stream->bandwidth;
1651 ehci_vdbg (ehci, 1651 ehci_vdbg (ehci,
@@ -1656,7 +1656,6 @@ itd_complete (
1656 iso_stream_put (ehci, stream); 1656 iso_stream_put (ehci, stream);
1657 1657
1658done: 1658done:
1659 usb_put_urb(urb);
1660 itd->urb = NULL; 1659 itd->urb = NULL;
1661 if (ehci->clock_frame != itd->frame || itd->index[7] != -1) { 1660 if (ehci->clock_frame != itd->frame || itd->index[7] != -1) {
1662 /* OK to recycle this ITD now. */ 1661 /* OK to recycle this ITD now. */
@@ -1949,7 +1948,7 @@ sitd_link_urb (
1949 struct ehci_sitd, sitd_list); 1948 struct ehci_sitd, sitd_list);
1950 list_move_tail (&sitd->sitd_list, &stream->td_list); 1949 list_move_tail (&sitd->sitd_list, &stream->td_list);
1951 sitd->stream = iso_stream_get (stream); 1950 sitd->stream = iso_stream_get (stream);
1952 sitd->urb = usb_get_urb (urb); 1951 sitd->urb = urb;
1953 1952
1954 sitd_patch(ehci, stream, sitd, sched, packet); 1953 sitd_patch(ehci, stream, sitd, sched, packet);
1955 sitd_link (ehci, (next_uframe >> 3) % ehci->periodic_size, 1954 sitd_link (ehci, (next_uframe >> 3) % ehci->periodic_size,
@@ -2034,7 +2033,7 @@ sitd_complete (
2034 (void) disable_periodic(ehci); 2033 (void) disable_periodic(ehci);
2035 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 2034 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
2036 2035
2037 if (list_empty (&stream->td_list)) { 2036 if (list_is_singular(&stream->td_list)) {
2038 ehci_to_hcd(ehci)->self.bandwidth_allocated 2037 ehci_to_hcd(ehci)->self.bandwidth_allocated
2039 -= stream->bandwidth; 2038 -= stream->bandwidth;
2040 ehci_vdbg (ehci, 2039 ehci_vdbg (ehci,
@@ -2045,7 +2044,6 @@ sitd_complete (
2045 iso_stream_put (ehci, stream); 2044 iso_stream_put (ehci, stream);
2046 /* OK to recycle this SITD now that its completion callback ran. */ 2045 /* OK to recycle this SITD now that its completion callback ran. */
2047done: 2046done:
2048 usb_put_urb(urb);
2049 sitd->urb = NULL; 2047 sitd->urb = NULL;
2050 sitd->stream = NULL; 2048 sitd->stream = NULL;
2051 list_move(&sitd->sitd_list, &stream->free_list); 2049 list_move(&sitd->sitd_list, &stream->free_list);
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 262b00c9b334..6cff195e1a36 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -190,40 +190,6 @@ timer_action_done (struct ehci_hcd *ehci, enum ehci_timer_action action)
190 clear_bit (action, &ehci->actions); 190 clear_bit (action, &ehci->actions);
191} 191}
192 192
193static inline void
194timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
195{
196 /* Don't override timeouts which shrink or (later) disable
197 * the async ring; just the I/O watchdog. Note that if a
198 * SHRINK were pending, OFF would never be requested.
199 */
200 if (timer_pending(&ehci->watchdog)
201 && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
202 & ehci->actions))
203 return;
204
205 if (!test_and_set_bit (action, &ehci->actions)) {
206 unsigned long t;
207
208 switch (action) {
209 case TIMER_IO_WATCHDOG:
210 t = EHCI_IO_JIFFIES;
211 break;
212 case TIMER_ASYNC_OFF:
213 t = EHCI_ASYNC_JIFFIES;
214 break;
215 // case TIMER_ASYNC_SHRINK:
216 default:
217 /* add a jiffie since we synch against the
218 * 8 KHz uframe counter.
219 */
220 t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
221 break;
222 }
223 mod_timer(&ehci->watchdog, t + jiffies);
224 }
225}
226
227static void free_cached_itd_list(struct ehci_hcd *ehci); 193static void free_cached_itd_list(struct ehci_hcd *ehci);
228 194
229/*-------------------------------------------------------------------------*/ 195/*-------------------------------------------------------------------------*/
@@ -287,7 +253,7 @@ struct ehci_qtd {
287 253
288/* 254/*
289 * Now the following defines are not converted using the 255 * Now the following defines are not converted using the
290 * __constant_cpu_to_le32() macro anymore, since we have to support 256 * cpu_to_le32() macro anymore, since we have to support
291 * "dynamic" switching between be and le support, so that the driver 257 * "dynamic" switching between be and le support, so that the driver
292 * can be used on one system with SoC EHCI controller using big-endian 258 * can be used on one system with SoC EHCI controller using big-endian
293 * descriptors as well as a normal little-endian PCI EHCI controller. 259 * descriptors as well as a normal little-endian PCI EHCI controller.
@@ -376,6 +342,9 @@ struct ehci_qh {
376#define QH_STATE_UNLINK_WAIT 4 /* LINKED and on reclaim q */ 342#define QH_STATE_UNLINK_WAIT 4 /* LINKED and on reclaim q */
377#define QH_STATE_COMPLETING 5 /* don't touch token.HALT */ 343#define QH_STATE_COMPLETING 5 /* don't touch token.HALT */
378 344
345 u8 xacterrs; /* XactErr retry counter */
346#define QH_XACTERR_MAX 32 /* XactErr retry limit */
347
379 /* periodic schedule info */ 348 /* periodic schedule info */
380 u8 usecs; /* intr bandwidth */ 349 u8 usecs; /* intr bandwidth */
381 u8 gap_uf; /* uframes split/csplit gap */ 350 u8 gap_uf; /* uframes split/csplit gap */
diff --git a/drivers/usb/host/fhci-dbg.c b/drivers/usb/host/fhci-dbg.c
index 34e14edf390b..ea8a4255c5da 100644
--- a/drivers/usb/host/fhci-dbg.c
+++ b/drivers/usb/host/fhci-dbg.c
@@ -108,7 +108,7 @@ void fhci_dfs_create(struct fhci_hcd *fhci)
108{ 108{
109 struct device *dev = fhci_to_hcd(fhci)->self.controller; 109 struct device *dev = fhci_to_hcd(fhci)->self.controller;
110 110
111 fhci->dfs_root = debugfs_create_dir(dev->bus_id, NULL); 111 fhci->dfs_root = debugfs_create_dir(dev_name(dev), NULL);
112 if (!fhci->dfs_root) { 112 if (!fhci->dfs_root) {
113 WARN_ON(1); 113 WARN_ON(1);
114 return; 114 return;
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index ba622cc8a9ba..0951818ef93b 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -583,7 +583,7 @@ static int __devinit of_fhci_probe(struct of_device *ofdev,
583 if (sprop && strcmp(sprop, "host")) 583 if (sprop && strcmp(sprop, "host"))
584 return -ENODEV; 584 return -ENODEV;
585 585
586 hcd = usb_create_hcd(&fhci_driver, dev, dev->bus_id); 586 hcd = usb_create_hcd(&fhci_driver, dev, dev_name(dev));
587 if (!hcd) { 587 if (!hcd) {
588 dev_err(dev, "could not create hcd\n"); 588 dev_err(dev, "could not create hcd\n");
589 return -ENOMEM; 589 return -ENOMEM;
@@ -650,7 +650,7 @@ static int __devinit of_fhci_probe(struct of_device *ofdev,
650 } 650 }
651 } 651 }
652 652
653 ret = gpio_request(gpio, dev->bus_id); 653 ret = gpio_request(gpio, dev_name(dev));
654 if (ret) { 654 if (ret) {
655 dev_err(dev, "failed to request gpio %d", i); 655 dev_err(dev, "failed to request gpio %d", i);
656 goto err_gpios; 656 goto err_gpios;
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
index 8582236e4cad..cbf30e515f29 100644
--- a/drivers/usb/host/hwa-hc.c
+++ b/drivers/usb/host/hwa-hc.c
@@ -464,8 +464,7 @@ static int __hwahc_dev_set_key(struct wusbhc *wusbhc, u8 port_idx, u32 tkid,
464 port_idx << 8 | iface_no, 464 port_idx << 8 | iface_no,
465 keyd, keyd_len, 1000 /* FIXME: arbitrary */); 465 keyd, keyd_len, 1000 /* FIXME: arbitrary */);
466 466
467 memset(keyd, 0, sizeof(*keyd)); /* clear keys etc. */ 467 kzfree(keyd); /* clear keys etc. */
468 kfree(keyd);
469 return result; 468 return result;
470} 469}
471 470
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 4dda31b26892..a2b305477afe 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -772,7 +772,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,
772 break; 772 break;
773 case PIPE_INTERRUPT: 773 case PIPE_INTERRUPT:
774 urb->interval = ep->period; 774 urb->interval = ep->period;
775 ep->length = min((int)ep->maxpacket, 775 ep->length = min_t(u32, ep->maxpacket,
776 urb->transfer_buffer_length); 776 urb->transfer_buffer_length);
777 777
778 /* urb submitted for already existing endpoint */ 778 /* urb submitted for already existing endpoint */
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h
index aa211bafcff9..12db961acdfb 100644
--- a/drivers/usb/host/isp116x.h
+++ b/drivers/usb/host/isp116x.h
@@ -563,7 +563,7 @@ static void urb_dbg(struct urb *urb, char *msg)
563*/ 563*/
564static inline void dump_ptd(struct ptd *ptd) 564static inline void dump_ptd(struct ptd *ptd)
565{ 565{
566 printk("td: %x %d%c%d %d,%d,%d %x %x%x%x\n", 566 printk(KERN_WARNING "td: %x %d%c%d %d,%d,%d %x %x%x%x\n",
567 PTD_GET_CC(ptd), PTD_GET_FA(ptd), 567 PTD_GET_CC(ptd), PTD_GET_FA(ptd),
568 PTD_DIR_STR(ptd), PTD_GET_EP(ptd), 568 PTD_DIR_STR(ptd), PTD_GET_EP(ptd),
569 PTD_GET_COUNT(ptd), PTD_GET_LEN(ptd), PTD_GET_MPS(ptd), 569 PTD_GET_COUNT(ptd), PTD_GET_LEN(ptd), PTD_GET_MPS(ptd),
@@ -576,7 +576,7 @@ static inline void dump_ptd_out_data(struct ptd *ptd, u8 * buf)
576 int k; 576 int k;
577 577
578 if (PTD_GET_DIR(ptd) != PTD_DIR_IN && PTD_GET_LEN(ptd)) { 578 if (PTD_GET_DIR(ptd) != PTD_DIR_IN && PTD_GET_LEN(ptd)) {
579 printk("-> "); 579 printk(KERN_WARNING "-> ");
580 for (k = 0; k < PTD_GET_LEN(ptd); ++k) 580 for (k = 0; k < PTD_GET_LEN(ptd); ++k)
581 printk("%02x ", ((u8 *) buf)[k]); 581 printk("%02x ", ((u8 *) buf)[k]);
582 printk("\n"); 582 printk("\n");
@@ -588,13 +588,13 @@ static inline void dump_ptd_in_data(struct ptd *ptd, u8 * buf)
588 int k; 588 int k;
589 589
590 if (PTD_GET_DIR(ptd) == PTD_DIR_IN && PTD_GET_COUNT(ptd)) { 590 if (PTD_GET_DIR(ptd) == PTD_DIR_IN && PTD_GET_COUNT(ptd)) {
591 printk("<- "); 591 printk(KERN_WARNING "<- ");
592 for (k = 0; k < PTD_GET_COUNT(ptd); ++k) 592 for (k = 0; k < PTD_GET_COUNT(ptd); ++k)
593 printk("%02x ", ((u8 *) buf)[k]); 593 printk("%02x ", ((u8 *) buf)[k]);
594 printk("\n"); 594 printk("\n");
595 } 595 }
596 if (PTD_GET_LAST(ptd)) 596 if (PTD_GET_LAST(ptd))
597 printk("-\n"); 597 printk(KERN_WARNING "-\n");
598} 598}
599 599
600#else 600#else
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index b899f1a59c26..cd07ea3f0c63 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -644,7 +644,7 @@ static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh,
644 644
645 if (urb->dev->speed != USB_SPEED_HIGH) { 645 if (urb->dev->speed != USB_SPEED_HIGH) {
646 /* split */ 646 /* split */
647 ptd->dw5 = __constant_cpu_to_le32(0x1c); 647 ptd->dw5 = cpu_to_le32(0x1c);
648 648
649 if (qh->period >= 32) 649 if (qh->period >= 32)
650 period = qh->period / 2; 650 period = qh->period / 2;
@@ -819,6 +819,13 @@ static void enqueue_an_ATL_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
819 u32 atl_regs, payload; 819 u32 atl_regs, payload;
820 u32 buffstatus; 820 u32 buffstatus;
821 821
822 /*
823 * When this function is called from the interrupt handler to enqueue
824 * a follow-up packet, the SKIP register gets written and read back
825 * almost immediately. With ISP1761, this register requires a delay of
826 * 195ns between a write and subsequent read (see section 15.1.1.3).
827 */
828 ndelay(195);
822 skip_map = isp1760_readl(hcd->regs + HC_ATL_PTD_SKIPMAP_REG); 829 skip_map = isp1760_readl(hcd->regs + HC_ATL_PTD_SKIPMAP_REG);
823 830
824 BUG_ON(!skip_map); 831 BUG_ON(!skip_map);
@@ -853,6 +860,13 @@ static void enqueue_an_INT_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
853 u32 int_regs, payload; 860 u32 int_regs, payload;
854 u32 buffstatus; 861 u32 buffstatus;
855 862
863 /*
864 * When this function is called from the interrupt handler to enqueue
865 * a follow-up packet, the SKIP register gets written and read back
866 * almost immediately. With ISP1761, this register requires a delay of
867 * 195ns between a write and subsequent read (see section 15.1.1.3).
868 */
869 ndelay(195);
856 skip_map = isp1760_readl(hcd->regs + HC_INT_PTD_SKIPMAP_REG); 870 skip_map = isp1760_readl(hcd->regs + HC_INT_PTD_SKIPMAP_REG);
857 871
858 BUG_ON(!skip_map); 872 BUG_ON(!skip_map);
@@ -1054,7 +1068,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd)
1054 priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs + 1068 priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs +
1055 atl_regs, sizeof(ptd)); 1069 atl_regs, sizeof(ptd));
1056 1070
1057 ptd.dw0 |= __constant_cpu_to_le32(PTD_VALID); 1071 ptd.dw0 |= cpu_to_le32(PTD_VALID);
1058 priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs + 1072 priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs +
1059 atl_regs, sizeof(ptd)); 1073 atl_regs, sizeof(ptd));
1060 1074
@@ -2235,9 +2249,10 @@ void deinit_kmem_cache(void)
2235 kmem_cache_destroy(qh_cachep); 2249 kmem_cache_destroy(qh_cachep);
2236} 2250}
2237 2251
2238struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq, 2252struct usb_hcd *isp1760_register(phys_addr_t res_start, resource_size_t res_len,
2239 u64 irqflags, struct device *dev, const char *busname, 2253 int irq, unsigned long irqflags,
2240 unsigned int devflags) 2254 struct device *dev, const char *busname,
2255 unsigned int devflags)
2241{ 2256{
2242 struct usb_hcd *hcd; 2257 struct usb_hcd *hcd;
2243 struct isp1760_hcd *priv; 2258 struct isp1760_hcd *priv;
diff --git a/drivers/usb/host/isp1760-hcd.h b/drivers/usb/host/isp1760-hcd.h
index a9daea587962..462f4943cb1b 100644
--- a/drivers/usb/host/isp1760-hcd.h
+++ b/drivers/usb/host/isp1760-hcd.h
@@ -2,9 +2,10 @@
2#define _ISP1760_HCD_H_ 2#define _ISP1760_HCD_H_
3 3
4/* exports for if */ 4/* exports for if */
5struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq, 5struct usb_hcd *isp1760_register(phys_addr_t res_start, resource_size_t res_len,
6 u64 irqflags, struct device *dev, const char *busname, 6 int irq, unsigned long irqflags,
7 unsigned int devflags); 7 struct device *dev, const char *busname,
8 unsigned int devflags);
8int init_kmem_once(void); 9int init_kmem_once(void);
9void deinit_kmem_cache(void); 10void deinit_kmem_cache(void);
10 11
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 4cf7ca428b33..3fa3a1702796 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/usb.h> 11#include <linux/usb.h>
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/platform_device.h>
13 14
14#include "../core/hcd.h" 15#include "../core/hcd.h"
15#include "isp1760-hcd.h" 16#include "isp1760-hcd.h"
@@ -300,39 +301,101 @@ static struct pci_driver isp1761_pci_driver = {
300}; 301};
301#endif 302#endif
302 303
304static int __devinit isp1760_plat_probe(struct platform_device *pdev)
305{
306 int ret = 0;
307 struct usb_hcd *hcd;
308 struct resource *mem_res;
309 struct resource *irq_res;
310 resource_size_t mem_size;
311 unsigned long irqflags = IRQF_SHARED | IRQF_DISABLED;
312
313 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
314 if (!mem_res) {
315 pr_warning("isp1760: Memory resource not available\n");
316 ret = -ENODEV;
317 goto out;
318 }
319 mem_size = resource_size(mem_res);
320 if (!request_mem_region(mem_res->start, mem_size, "isp1760")) {
321 pr_warning("isp1760: Cannot reserve the memory resource\n");
322 ret = -EBUSY;
323 goto out;
324 }
325
326 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
327 if (!irq_res) {
328 pr_warning("isp1760: IRQ resource not available\n");
329 return -ENODEV;
330 }
331 irqflags |= irq_res->flags & IRQF_TRIGGER_MASK;
332
333 hcd = isp1760_register(mem_res->start, mem_size, irq_res->start,
334 irqflags, &pdev->dev, dev_name(&pdev->dev), 0);
335 if (IS_ERR(hcd)) {
336 pr_warning("isp1760: Failed to register the HCD device\n");
337 ret = -ENODEV;
338 goto cleanup;
339 }
340
341 pr_info("ISP1760 USB device initialised\n");
342 return ret;
343
344cleanup:
345 release_mem_region(mem_res->start, mem_size);
346out:
347 return ret;
348}
349
350static int __devexit isp1760_plat_remove(struct platform_device *pdev)
351{
352 struct resource *mem_res;
353 resource_size_t mem_size;
354
355 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
356 mem_size = resource_size(mem_res);
357 release_mem_region(mem_res->start, mem_size);
358
359 return 0;
360}
361
362static struct platform_driver isp1760_plat_driver = {
363 .probe = isp1760_plat_probe,
364 .remove = isp1760_plat_remove,
365 .driver = {
366 .name = "isp1760",
367 },
368};
369
303static int __init isp1760_init(void) 370static int __init isp1760_init(void)
304{ 371{
305 int ret; 372 int ret, any_ret = -ENODEV;
306 373
307 init_kmem_once(); 374 init_kmem_once();
308 375
376 ret = platform_driver_register(&isp1760_plat_driver);
377 if (!ret)
378 any_ret = 0;
309#ifdef CONFIG_PPC_OF 379#ifdef CONFIG_PPC_OF
310 ret = of_register_platform_driver(&isp1760_of_driver); 380 ret = of_register_platform_driver(&isp1760_of_driver);
311 if (ret) { 381 if (!ret)
312 deinit_kmem_cache(); 382 any_ret = 0;
313 return ret;
314 }
315#endif 383#endif
316#ifdef CONFIG_PCI 384#ifdef CONFIG_PCI
317 ret = pci_register_driver(&isp1761_pci_driver); 385 ret = pci_register_driver(&isp1761_pci_driver);
318 if (ret) 386 if (!ret)
319 goto unreg_of; 387 any_ret = 0;
320#endif 388#endif
321 return ret;
322 389
323#ifdef CONFIG_PCI 390 if (any_ret)
324unreg_of: 391 deinit_kmem_cache();
325#endif 392 return any_ret;
326#ifdef CONFIG_PPC_OF
327 of_unregister_platform_driver(&isp1760_of_driver);
328#endif
329 deinit_kmem_cache();
330 return ret;
331} 393}
332module_init(isp1760_init); 394module_init(isp1760_init);
333 395
334static void __exit isp1760_exit(void) 396static void __exit isp1760_exit(void)
335{ 397{
398 platform_driver_unregister(&isp1760_plat_driver);
336#ifdef CONFIG_PPC_OF 399#ifdef CONFIG_PPC_OF
337 of_unregister_platform_driver(&isp1760_of_driver); 400 of_unregister_platform_driver(&isp1760_of_driver);
338#endif 401#endif
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 5cf5f1eca4f4..25db704f3a2a 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -997,7 +997,7 @@ MODULE_LICENSE ("GPL");
997#define SA1111_DRIVER ohci_hcd_sa1111_driver 997#define SA1111_DRIVER ohci_hcd_sa1111_driver
998#endif 998#endif
999 999
1000#ifdef CONFIG_ARCH_S3C2410 1000#if defined(CONFIG_ARCH_S3C2410) || defined(CONFIG_ARCH_S3C64XX)
1001#include "ohci-s3c2410.c" 1001#include "ohci-s3c2410.c"
1002#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver 1002#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver
1003#endif 1003#endif
@@ -1049,7 +1049,8 @@ MODULE_LICENSE ("GPL");
1049 1049
1050#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 1050#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
1051 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 1051 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
1052 defined(CONFIG_CPU_SUBTYPE_SH7763) 1052 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
1053 defined(CONFIG_CPU_SUBTYPE_SH7786)
1053#include "ohci-sh.c" 1054#include "ohci-sh.c"
1054#define PLATFORM_DRIVER ohci_hcd_sh_driver 1055#define PLATFORM_DRIVER ohci_hcd_sh_driver
1055#endif 1056#endif
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index f46af7a718d4..a68af2dd55ca 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -21,9 +21,7 @@
21 21
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24 24#include <plat/usb-control.h>
25#include <mach/hardware.h>
26#include <mach/usb-control.h>
27 25
28#define valid_port(idx) ((idx) == 1 || (idx) == 2) 26#define valid_port(idx) ((idx) == 1 || (idx) == 2)
29 27
@@ -372,7 +370,7 @@ static int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
372 370
373 usb_clk = clk_get(&dev->dev, "usb-bus-host"); 371 usb_clk = clk_get(&dev->dev, "usb-bus-host");
374 if (IS_ERR(usb_clk)) { 372 if (IS_ERR(usb_clk)) {
375 dev_err(&dev->dev, "cannot get usb-host clock\n"); 373 dev_err(&dev->dev, "cannot get usb-bus-host clock\n");
376 retval = -ENOENT; 374 retval = -ENOENT;
377 goto err_clk; 375 goto err_clk;
378 } 376 }
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 75548f7c716b..5ac489ee3dab 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -845,14 +845,14 @@ static inline void qh_update(struct oxu_hcd *oxu,
845 is_out = !(qtd->hw_token & cpu_to_le32(1 << 8)); 845 is_out = !(qtd->hw_token & cpu_to_le32(1 << 8));
846 epnum = (le32_to_cpup(&qh->hw_info1) >> 8) & 0x0f; 846 epnum = (le32_to_cpup(&qh->hw_info1) >> 8) & 0x0f;
847 if (unlikely(!usb_gettoggle(qh->dev, epnum, is_out))) { 847 if (unlikely(!usb_gettoggle(qh->dev, epnum, is_out))) {
848 qh->hw_token &= ~__constant_cpu_to_le32(QTD_TOGGLE); 848 qh->hw_token &= ~cpu_to_le32(QTD_TOGGLE);
849 usb_settoggle(qh->dev, epnum, is_out, 1); 849 usb_settoggle(qh->dev, epnum, is_out, 1);
850 } 850 }
851 } 851 }
852 852
853 /* HC must see latest qtd and qh data before we clear ACTIVE+HALT */ 853 /* HC must see latest qtd and qh data before we clear ACTIVE+HALT */
854 wmb(); 854 wmb();
855 qh->hw_token &= __constant_cpu_to_le32(QTD_TOGGLE | QTD_STS_PING); 855 qh->hw_token &= cpu_to_le32(QTD_TOGGLE | QTD_STS_PING);
856} 856}
857 857
858/* If it weren't for a common silicon quirk (writing the dummy into the qh 858/* If it weren't for a common silicon quirk (writing the dummy into the qh
@@ -937,7 +937,7 @@ __acquires(oxu->lock)
937 struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv; 937 struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv;
938 938
939 /* S-mask in a QH means it's an interrupt urb */ 939 /* S-mask in a QH means it's an interrupt urb */
940 if ((qh->hw_info2 & __constant_cpu_to_le32(QH_SMASK)) != 0) { 940 if ((qh->hw_info2 & cpu_to_le32(QH_SMASK)) != 0) {
941 941
942 /* ... update hc-wide periodic stats (for usbfs) */ 942 /* ... update hc-wide periodic stats (for usbfs) */
943 oxu_to_hcd(oxu)->self.bandwidth_int_reqs--; 943 oxu_to_hcd(oxu)->self.bandwidth_int_reqs--;
@@ -981,7 +981,7 @@ static void unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh);
981static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh); 981static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
982static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh); 982static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
983 983
984#define HALT_BIT __constant_cpu_to_le32(QTD_STS_HALT) 984#define HALT_BIT cpu_to_le32(QTD_STS_HALT)
985 985
986/* Process and free completed qtds for a qh, returning URBs to drivers. 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, 987 * Chases up to qh->hw_current. Returns number of completions called,
@@ -1160,7 +1160,7 @@ halt:
1160 /* should be rare for periodic transfers, 1160 /* should be rare for periodic transfers,
1161 * except maybe high bandwidth ... 1161 * except maybe high bandwidth ...
1162 */ 1162 */
1163 if ((__constant_cpu_to_le32(QH_SMASK) 1163 if ((cpu_to_le32(QH_SMASK)
1164 & qh->hw_info2) != 0) { 1164 & qh->hw_info2) != 0) {
1165 intr_deschedule(oxu, qh); 1165 intr_deschedule(oxu, qh);
1166 (void) qh_schedule(oxu, qh); 1166 (void) qh_schedule(oxu, qh);
@@ -1350,7 +1350,7 @@ static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu,
1350 } 1350 }
1351 1351
1352 /* by default, enable interrupt on urb completion */ 1352 /* by default, enable interrupt on urb completion */
1353 qtd->hw_token |= __constant_cpu_to_le32(QTD_IOC); 1353 qtd->hw_token |= cpu_to_le32(QTD_IOC);
1354 return head; 1354 return head;
1355 1355
1356cleanup: 1356cleanup:
@@ -1539,7 +1539,7 @@ static void qh_link_async(struct oxu_hcd *oxu, struct ehci_qh *qh)
1539 /* qtd completions reported later by interrupt */ 1539 /* qtd completions reported later by interrupt */
1540} 1540}
1541 1541
1542#define QH_ADDR_MASK __constant_cpu_to_le32(0x7f) 1542#define QH_ADDR_MASK cpu_to_le32(0x7f)
1543 1543
1544/* 1544/*
1545 * For control/bulk/interrupt, return QH with these TDs appended. 1545 * For control/bulk/interrupt, return QH with these TDs appended.
@@ -2012,7 +2012,7 @@ static void qh_unlink_periodic(struct oxu_hcd *oxu, struct ehci_qh *qh)
2012 * and this qh is active in the current uframe 2012 * and this qh is active in the current uframe
2013 * (and overlay token SplitXstate is false?) 2013 * (and overlay token SplitXstate is false?)
2014 * THEN 2014 * THEN
2015 * qh->hw_info1 |= __constant_cpu_to_le32(1 << 7 "ignore"); 2015 * qh->hw_info1 |= cpu_to_le32(1 << 7 "ignore");
2016 */ 2016 */
2017 2017
2018 /* high bandwidth, or otherwise part of every microframe */ 2018 /* high bandwidth, or otherwise part of every microframe */
@@ -2057,7 +2057,7 @@ static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh)
2057 * active high speed queues may need bigger delays... 2057 * active high speed queues may need bigger delays...
2058 */ 2058 */
2059 if (list_empty(&qh->qtd_list) 2059 if (list_empty(&qh->qtd_list)
2060 || (__constant_cpu_to_le32(QH_CMASK) & qh->hw_info2) != 0) 2060 || (cpu_to_le32(QH_CMASK) & qh->hw_info2) != 0)
2061 wait = 2; 2061 wait = 2;
2062 else 2062 else
2063 wait = 55; /* worst case: 3 * 1024 */ 2063 wait = 55; /* worst case: 3 * 1024 */
@@ -2183,10 +2183,10 @@ static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh)
2183 qh->start = frame; 2183 qh->start = frame;
2184 2184
2185 /* reset S-frame and (maybe) C-frame masks */ 2185 /* reset S-frame and (maybe) C-frame masks */
2186 qh->hw_info2 &= __constant_cpu_to_le32(~(QH_CMASK | QH_SMASK)); 2186 qh->hw_info2 &= cpu_to_le32(~(QH_CMASK | QH_SMASK));
2187 qh->hw_info2 |= qh->period 2187 qh->hw_info2 |= qh->period
2188 ? cpu_to_le32(1 << uframe) 2188 ? cpu_to_le32(1 << uframe)
2189 : __constant_cpu_to_le32(QH_SMASK); 2189 : cpu_to_le32(QH_SMASK);
2190 qh->hw_info2 |= c_mask; 2190 qh->hw_info2 |= c_mask;
2191 } else 2191 } else
2192 oxu_dbg(oxu, "reused qh %p schedule\n", qh); 2192 oxu_dbg(oxu, "reused qh %p schedule\n", qh);
@@ -2684,7 +2684,7 @@ static int oxu_reset(struct usb_hcd *hcd)
2684 oxu->urb_len = 0; 2684 oxu->urb_len = 0;
2685 2685
2686 /* FIMXE */ 2686 /* FIMXE */
2687 hcd->self.controller->dma_mask = 0UL; 2687 hcd->self.controller->dma_mask = NULL;
2688 2688
2689 if (oxu->is_otg) { 2689 if (oxu->is_otg) {
2690 oxu->caps = hcd->regs + OXU_OTG_CAP_OFFSET; 2690 oxu->caps = hcd->regs + OXU_OTG_CAP_OFFSET;
diff --git a/drivers/usb/host/oxu210hp.h b/drivers/usb/host/oxu210hp.h
index 8910e271cc7d..1c216ad9aad2 100644
--- a/drivers/usb/host/oxu210hp.h
+++ b/drivers/usb/host/oxu210hp.h
@@ -235,21 +235,21 @@ struct ehci_qtd {
235} __attribute__ ((aligned(32))); 235} __attribute__ ((aligned(32)));
236 236
237/* mask NakCnt+T in qh->hw_alt_next */ 237/* mask NakCnt+T in qh->hw_alt_next */
238#define QTD_MASK __constant_cpu_to_le32 (~0x1f) 238#define QTD_MASK cpu_to_le32 (~0x1f)
239 239
240#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1) 240#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1)
241 241
242/* Type tag from {qh, itd, sitd, fstn}->hw_next */ 242/* Type tag from {qh, itd, sitd, fstn}->hw_next */
243#define Q_NEXT_TYPE(dma) ((dma) & __constant_cpu_to_le32 (3 << 1)) 243#define Q_NEXT_TYPE(dma) ((dma) & cpu_to_le32 (3 << 1))
244 244
245/* values for that type tag */ 245/* values for that type tag */
246#define Q_TYPE_QH __constant_cpu_to_le32 (1 << 1) 246#define Q_TYPE_QH cpu_to_le32 (1 << 1)
247 247
248/* next async queue entry, or pointer to interrupt/periodic QH */ 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) 249#define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH)
250 250
251/* for periodic/async schedules and qtd lists, mark end of list */ 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 */ 252#define EHCI_LIST_END cpu_to_le32(1) /* "null pointer" to hw */
253 253
254/* 254/*
255 * Entries in periodic shadow table are pointers to one of four kinds 255 * Entries in periodic shadow table are pointers to one of four kinds
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 75b69847918e..033c2846ce59 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -234,7 +234,7 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
234 */ 234 */
235 hcc_params = readl(base + EHCI_HCC_PARAMS); 235 hcc_params = readl(base + EHCI_HCC_PARAMS);
236 offset = (hcc_params >> 8) & 0xff; 236 offset = (hcc_params >> 8) & 0xff;
237 while (offset && count--) { 237 while (offset && --count) {
238 u32 cap; 238 u32 cap;
239 int msec; 239 int msec;
240 240
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 319041205b57..f1626e58c141 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -660,9 +660,9 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
660 u16 array[R8A66597_MAX_NUM_PIPE], i = 0, min; 660 u16 array[R8A66597_MAX_NUM_PIPE], i = 0, min;
661 661
662 memset(array, 0, sizeof(array)); 662 memset(array, 0, sizeof(array));
663 switch (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 663 switch (usb_endpoint_type(ep)) {
664 case USB_ENDPOINT_XFER_BULK: 664 case USB_ENDPOINT_XFER_BULK:
665 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 665 if (usb_endpoint_dir_in(ep))
666 array[i++] = 4; 666 array[i++] = 4;
667 else { 667 else {
668 array[i++] = 3; 668 array[i++] = 3;
@@ -670,7 +670,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
670 } 670 }
671 break; 671 break;
672 case USB_ENDPOINT_XFER_INT: 672 case USB_ENDPOINT_XFER_INT:
673 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) { 673 if (usb_endpoint_dir_in(ep)) {
674 array[i++] = 6; 674 array[i++] = 6;
675 array[i++] = 7; 675 array[i++] = 7;
676 array[i++] = 8; 676 array[i++] = 8;
@@ -678,7 +678,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
678 array[i++] = 9; 678 array[i++] = 9;
679 break; 679 break;
680 case USB_ENDPOINT_XFER_ISOC: 680 case USB_ENDPOINT_XFER_ISOC:
681 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 681 if (usb_endpoint_dir_in(ep))
682 array[i++] = 2; 682 array[i++] = 2;
683 else 683 else
684 array[i++] = 1; 684 array[i++] = 1;
@@ -928,10 +928,9 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
928 928
929 info.pipenum = get_empty_pipenum(r8a66597, ep); 929 info.pipenum = get_empty_pipenum(r8a66597, ep);
930 info.address = get_urb_to_r8a66597_addr(r8a66597, urb); 930 info.address = get_urb_to_r8a66597_addr(r8a66597, urb);
931 info.epnum = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 931 info.epnum = usb_endpoint_num(ep);
932 info.maxpacket = le16_to_cpu(ep->wMaxPacketSize); 932 info.maxpacket = le16_to_cpu(ep->wMaxPacketSize);
933 info.type = get_r8a66597_type(ep->bmAttributes 933 info.type = get_r8a66597_type(usb_endpoint_type(ep));
934 & USB_ENDPOINT_XFERTYPE_MASK);
935 info.bufnum = get_bufnum(info.pipenum); 934 info.bufnum = get_bufnum(info.pipenum);
936 info.buf_bsize = get_buf_bsize(info.pipenum); 935 info.buf_bsize = get_buf_bsize(info.pipenum);
937 if (info.type == R8A66597_BULK) { 936 if (info.type == R8A66597_BULK) {
@@ -941,7 +940,7 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
941 info.interval = get_interval(urb, ep->bInterval); 940 info.interval = get_interval(urb, ep->bInterval);
942 info.timer_interval = get_timer_interval(urb, ep->bInterval); 941 info.timer_interval = get_timer_interval(urb, ep->bInterval);
943 } 942 }
944 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 943 if (usb_endpoint_dir_in(ep))
945 info.dir_in = 1; 944 info.dir_in = 1;
946 else 945 else
947 info.dir_in = 0; 946 info.dir_in = 0;
@@ -1014,6 +1013,9 @@ static void r8a66597_check_syssts(struct r8a66597 *r8a66597, int port,
1014 1013
1015 r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port)); 1014 r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port));
1016 r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); 1015 r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port));
1016
1017 if (r8a66597->bus_suspended)
1018 usb_hcd_resume_root_hub(r8a66597_to_hcd(r8a66597));
1017} 1019}
1018 1020
1019/* this function must be called with interrupt disabled */ 1021/* this function must be called with interrupt disabled */
@@ -1395,7 +1397,7 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum)
1395 (int)urb->iso_frame_desc[td->iso_cnt].length); 1397 (int)urb->iso_frame_desc[td->iso_cnt].length);
1396 } else { 1398 } else {
1397 buf = (u16 *)(urb->transfer_buffer + urb->actual_length); 1399 buf = (u16 *)(urb->transfer_buffer + urb->actual_length);
1398 size = min((int)bufsize, 1400 size = min_t(u32, bufsize,
1399 urb->transfer_buffer_length - urb->actual_length); 1401 urb->transfer_buffer_length - urb->actual_length);
1400 } 1402 }
1401 1403
@@ -1615,6 +1617,11 @@ static irqreturn_t r8a66597_irq(struct usb_hcd *hcd)
1615 r8a66597_bclr(r8a66597, DTCHE, INTENB2); 1617 r8a66597_bclr(r8a66597, DTCHE, INTENB2);
1616 r8a66597_usb_disconnect(r8a66597, 1); 1618 r8a66597_usb_disconnect(r8a66597, 1);
1617 } 1619 }
1620 if (mask2 & BCHG) {
1621 r8a66597_write(r8a66597, ~BCHG, INTSTS2);
1622 r8a66597_bclr(r8a66597, BCHGE, INTENB2);
1623 usb_hcd_resume_root_hub(r8a66597_to_hcd(r8a66597));
1624 }
1618 } 1625 }
1619 1626
1620 if (mask1) { 1627 if (mask1) {
@@ -1630,6 +1637,12 @@ static irqreturn_t r8a66597_irq(struct usb_hcd *hcd)
1630 r8a66597_bclr(r8a66597, DTCHE, INTENB1); 1637 r8a66597_bclr(r8a66597, DTCHE, INTENB1);
1631 r8a66597_usb_disconnect(r8a66597, 0); 1638 r8a66597_usb_disconnect(r8a66597, 0);
1632 } 1639 }
1640 if (mask1 & BCHG) {
1641 r8a66597_write(r8a66597, ~BCHG, INTSTS1);
1642 r8a66597_bclr(r8a66597, BCHGE, INTENB1);
1643 usb_hcd_resume_root_hub(r8a66597_to_hcd(r8a66597));
1644 }
1645
1633 if (mask1 & SIGN) { 1646 if (mask1 & SIGN) {
1634 r8a66597_write(r8a66597, ~SIGN, INTSTS1); 1647 r8a66597_write(r8a66597, ~SIGN, INTSTS1);
1635 status = get_urb_error(r8a66597, 0); 1648 status = get_urb_error(r8a66597, 0);
@@ -2141,7 +2154,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2141 2154
2142 switch (wValue) { 2155 switch (wValue) {
2143 case USB_PORT_FEAT_ENABLE: 2156 case USB_PORT_FEAT_ENABLE:
2144 rh->port &= (1 << USB_PORT_FEAT_POWER); 2157 rh->port &= ~(1 << USB_PORT_FEAT_POWER);
2145 break; 2158 break;
2146 case USB_PORT_FEAT_SUSPEND: 2159 case USB_PORT_FEAT_SUSPEND:
2147 break; 2160 break;
@@ -2213,6 +2226,68 @@ error:
2213 return ret; 2226 return ret;
2214} 2227}
2215 2228
2229#if defined(CONFIG_PM)
2230static int r8a66597_bus_suspend(struct usb_hcd *hcd)
2231{
2232 struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd);
2233 int port;
2234
2235 dbg("%s", __func__);
2236
2237 for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) {
2238 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
2239 unsigned long dvstctr_reg = get_dvstctr_reg(port);
2240
2241 if (!(rh->port & (1 << USB_PORT_FEAT_ENABLE)))
2242 continue;
2243
2244 dbg("suspend port = %d", port);
2245 r8a66597_bclr(r8a66597, UACT, dvstctr_reg); /* suspend */
2246 rh->port |= 1 << USB_PORT_FEAT_SUSPEND;
2247
2248 if (rh->dev->udev->do_remote_wakeup) {
2249 msleep(3); /* waiting last SOF */
2250 r8a66597_bset(r8a66597, RWUPE, dvstctr_reg);
2251 r8a66597_write(r8a66597, ~BCHG, get_intsts_reg(port));
2252 r8a66597_bset(r8a66597, BCHGE, get_intenb_reg(port));
2253 }
2254 }
2255
2256 r8a66597->bus_suspended = 1;
2257
2258 return 0;
2259}
2260
2261static int r8a66597_bus_resume(struct usb_hcd *hcd)
2262{
2263 struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd);
2264 int port;
2265
2266 dbg("%s", __func__);
2267
2268 for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) {
2269 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
2270 unsigned long dvstctr_reg = get_dvstctr_reg(port);
2271
2272 if (!(rh->port & (1 << USB_PORT_FEAT_SUSPEND)))
2273 continue;
2274
2275 dbg("resume port = %d", port);
2276 rh->port &= ~(1 << USB_PORT_FEAT_SUSPEND);
2277 rh->port |= 1 << USB_PORT_FEAT_C_SUSPEND;
2278 r8a66597_mdfy(r8a66597, RESUME, RESUME | UACT, dvstctr_reg);
2279 msleep(50);
2280 r8a66597_mdfy(r8a66597, UACT, RESUME | UACT, dvstctr_reg);
2281 }
2282
2283 return 0;
2284
2285}
2286#else
2287#define r8a66597_bus_suspend NULL
2288#define r8a66597_bus_resume NULL
2289#endif
2290
2216static struct hc_driver r8a66597_hc_driver = { 2291static struct hc_driver r8a66597_hc_driver = {
2217 .description = hcd_name, 2292 .description = hcd_name,
2218 .hcd_priv_size = sizeof(struct r8a66597), 2293 .hcd_priv_size = sizeof(struct r8a66597),
@@ -2243,16 +2318,39 @@ static struct hc_driver r8a66597_hc_driver = {
2243 */ 2318 */
2244 .hub_status_data = r8a66597_hub_status_data, 2319 .hub_status_data = r8a66597_hub_status_data,
2245 .hub_control = r8a66597_hub_control, 2320 .hub_control = r8a66597_hub_control,
2321 .bus_suspend = r8a66597_bus_suspend,
2322 .bus_resume = r8a66597_bus_resume,
2246}; 2323};
2247 2324
2248#if defined(CONFIG_PM) 2325#if defined(CONFIG_PM)
2249static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) 2326static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state)
2250{ 2327{
2328 struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev);
2329 int port;
2330
2331 dbg("%s", __func__);
2332
2333 disable_controller(r8a66597);
2334
2335 for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) {
2336 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
2337
2338 rh->port = 0x00000000;
2339 }
2340
2251 return 0; 2341 return 0;
2252} 2342}
2253 2343
2254static int r8a66597_resume(struct platform_device *pdev) 2344static int r8a66597_resume(struct platform_device *pdev)
2255{ 2345{
2346 struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev);
2347 struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597);
2348
2349 dbg("%s", __func__);
2350
2351 enable_controller(r8a66597);
2352 usb_root_hub_lost_power(hcd->self.root_hub);
2353
2256 return 0; 2354 return 0;
2257} 2355}
2258#else /* if defined(CONFIG_PM) */ 2356#else /* if defined(CONFIG_PM) */
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
index ecacde4d69b0..f49208f1bb74 100644
--- a/drivers/usb/host/r8a66597.h
+++ b/drivers/usb/host/r8a66597.h
@@ -504,6 +504,8 @@ struct r8a66597 {
504 504
505 struct list_head child_device; 505 struct list_head child_device;
506 unsigned long child_connect_map[4]; 506 unsigned long child_connect_map[4];
507
508 unsigned bus_suspended:1;
507}; 509};
508 510
509static inline struct r8a66597 *hcd_to_r8a66597(struct usb_hcd *hcd) 511static inline struct r8a66597 *hcd_to_r8a66597(struct usb_hcd *hcd)
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index e106e9d48d4a..a949259f18b9 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -230,7 +230,7 @@ static void in_packet(
230 writeb(usb_pipedevice(urb->pipe), data_reg); 230 writeb(usb_pipedevice(urb->pipe), data_reg);
231 231
232 sl811_write(sl811, bank + SL11H_HOSTCTLREG, control); 232 sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
233 ep->length = min((int)len, 233 ep->length = min_t(u32, len,
234 urb->transfer_buffer_length - urb->actual_length); 234 urb->transfer_buffer_length - urb->actual_length);
235 PACKET("IN%s/%d qh%p len%d\n", ep->nak_count ? "/retry" : "", 235 PACKET("IN%s/%d qh%p len%d\n", ep->nak_count ? "/retry" : "",
236 !!usb_gettoggle(urb->dev, ep->epnum, 0), ep, len); 236 !!usb_gettoggle(urb->dev, ep->epnum, 0), ep, len);
@@ -255,7 +255,7 @@ static void out_packet(
255 buf = urb->transfer_buffer + urb->actual_length; 255 buf = urb->transfer_buffer + urb->actual_length;
256 prefetch(buf); 256 prefetch(buf);
257 257
258 len = min((int)ep->maxpacket, 258 len = min_t(u32, ep->maxpacket,
259 urb->transfer_buffer_length - urb->actual_length); 259 urb->transfer_buffer_length - urb->actual_length);
260 260
261 if (!(control & SL11H_HCTLMASK_ISOCH) 261 if (!(control & SL11H_HCTLMASK_ISOCH)
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index 20cc58b97807..e52b954dda47 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -118,7 +118,9 @@ static int uhci_show_urbp(struct urb_priv *urbp, char *buf, int len, int space)
118 } 118 }
119 119
120 out += sprintf(out, "%s%s", ptype, (urbp->fsbr ? " FSBR" : "")); 120 out += sprintf(out, "%s%s", ptype, (urbp->fsbr ? " FSBR" : ""));
121 out += sprintf(out, " Actlen=%d", urbp->urb->actual_length); 121 out += sprintf(out, " Actlen=%d%s", urbp->urb->actual_length,
122 (urbp->qh->type == USB_ENDPOINT_XFER_CONTROL ?
123 "-8" : ""));
122 124
123 if (urbp->urb->unlinked) 125 if (urbp->urb->unlinked)
124 out += sprintf(out, " Unlinked=%d", urbp->urb->unlinked); 126 out += sprintf(out, " Unlinked=%d", urbp->urb->unlinked);
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index 7d01c5677f92..26bd1b2bcbfc 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -73,11 +73,11 @@
73#define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */ 73#define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */
74#define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */ 74#define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */
75 75
76#define UHCI_PTR_BITS __constant_cpu_to_le32(0x000F) 76#define UHCI_PTR_BITS cpu_to_le32(0x000F)
77#define UHCI_PTR_TERM __constant_cpu_to_le32(0x0001) 77#define UHCI_PTR_TERM cpu_to_le32(0x0001)
78#define UHCI_PTR_QH __constant_cpu_to_le32(0x0002) 78#define UHCI_PTR_QH cpu_to_le32(0x0002)
79#define UHCI_PTR_DEPTH __constant_cpu_to_le32(0x0004) 79#define UHCI_PTR_DEPTH cpu_to_le32(0x0004)
80#define UHCI_PTR_BREADTH __constant_cpu_to_le32(0x0000) 80#define UHCI_PTR_BREADTH cpu_to_le32(0x0000)
81 81
82#define UHCI_NUMFRAMES 1024 /* in the frame list [array] */ 82#define UHCI_NUMFRAMES 1024 /* in the frame list [array] */
83#define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */ 83#define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 5631d89c8730..3e5807d14ffb 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -402,7 +402,7 @@ static void uhci_fixup_toggles(struct uhci_qh *qh, int skip_first)
402 /* Otherwise all the toggles in the URB have to be switched */ 402 /* Otherwise all the toggles in the URB have to be switched */
403 } else { 403 } else {
404 list_for_each_entry(td, &urbp->td_list, list) { 404 list_for_each_entry(td, &urbp->td_list, list) {
405 td->token ^= __constant_cpu_to_le32( 405 td->token ^= cpu_to_le32(
406 TD_TOKEN_TOGGLE); 406 TD_TOKEN_TOGGLE);
407 toggle ^= 1; 407 toggle ^= 1;
408 } 408 }
@@ -883,7 +883,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb,
883 883
884 uhci_fill_td(td, 0, USB_PID_OUT | uhci_explen(0), 0); 884 uhci_fill_td(td, 0, USB_PID_OUT | uhci_explen(0), 0);
885 wmb(); 885 wmb();
886 qh->dummy_td->status |= __constant_cpu_to_le32(TD_CTRL_ACTIVE); 886 qh->dummy_td->status |= cpu_to_le32(TD_CTRL_ACTIVE);
887 qh->dummy_td = td; 887 qh->dummy_td = td;
888 888
889 /* Low-speed transfers get a different queue, and won't hog the bus. 889 /* Low-speed transfers get a different queue, and won't hog the bus.
@@ -899,8 +899,6 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb,
899 } 899 }
900 if (qh->state != QH_STATE_ACTIVE) 900 if (qh->state != QH_STATE_ACTIVE)
901 qh->skel = skel; 901 qh->skel = skel;
902
903 urb->actual_length = -8; /* Account for the SETUP packet */
904 return 0; 902 return 0;
905 903
906nomem: 904nomem:
@@ -1003,7 +1001,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
1003 * fast side but not enough to justify delaying an interrupt 1001 * fast side but not enough to justify delaying an interrupt
1004 * more than 2 or 3 URBs, so we will ignore the URB_NO_INTERRUPT 1002 * more than 2 or 3 URBs, so we will ignore the URB_NO_INTERRUPT
1005 * flag setting. */ 1003 * flag setting. */
1006 td->status |= __constant_cpu_to_le32(TD_CTRL_IOC); 1004 td->status |= cpu_to_le32(TD_CTRL_IOC);
1007 1005
1008 /* 1006 /*
1009 * Build the new dummy TD and activate the old one 1007 * Build the new dummy TD and activate the old one
@@ -1015,7 +1013,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
1015 1013
1016 uhci_fill_td(td, 0, USB_PID_OUT | uhci_explen(0), 0); 1014 uhci_fill_td(td, 0, USB_PID_OUT | uhci_explen(0), 0);
1017 wmb(); 1015 wmb();
1018 qh->dummy_td->status |= __constant_cpu_to_le32(TD_CTRL_ACTIVE); 1016 qh->dummy_td->status |= cpu_to_le32(TD_CTRL_ACTIVE);
1019 qh->dummy_td = td; 1017 qh->dummy_td = td;
1020 1018
1021 usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), 1019 usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
@@ -1317,7 +1315,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1317 } 1315 }
1318 1316
1319 /* Set the interrupt-on-completion flag on the last packet. */ 1317 /* Set the interrupt-on-completion flag on the last packet. */
1320 td->status |= __constant_cpu_to_le32(TD_CTRL_IOC); 1318 td->status |= cpu_to_le32(TD_CTRL_IOC);
1321 1319
1322 /* Add the TDs to the frame list */ 1320 /* Add the TDs to the frame list */
1323 frame = urb->start_frame; 1321 frame = urb->start_frame;
@@ -1494,11 +1492,10 @@ __acquires(uhci->lock)
1494 1492
1495 if (qh->type == USB_ENDPOINT_XFER_CONTROL) { 1493 if (qh->type == USB_ENDPOINT_XFER_CONTROL) {
1496 1494
1497 /* urb->actual_length < 0 means the setup transaction didn't 1495 /* Subtract off the length of the SETUP packet from
1498 * complete successfully. Either it failed or the URB was 1496 * urb->actual_length.
1499 * unlinked first. Regardless, don't confuse people with a 1497 */
1500 * negative length. */ 1498 urb->actual_length -= min_t(u32, 8, urb->actual_length);
1501 urb->actual_length = max(urb->actual_length, 0);
1502 } 1499 }
1503 1500
1504 /* When giving back the first URB in an Isochronous queue, 1501 /* When giving back the first URB in an Isochronous queue,
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index 878c77ca086e..eca355dccf65 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -188,7 +188,7 @@ static struct usb_endpoint_descriptor mdc800_ed [4] =
188 .bDescriptorType = 0, 188 .bDescriptorType = 0,
189 .bEndpointAddress = 0x01, 189 .bEndpointAddress = 0x01,
190 .bmAttributes = 0x02, 190 .bmAttributes = 0x02,
191 .wMaxPacketSize = __constant_cpu_to_le16(8), 191 .wMaxPacketSize = cpu_to_le16(8),
192 .bInterval = 0, 192 .bInterval = 0,
193 .bRefresh = 0, 193 .bRefresh = 0,
194 .bSynchAddress = 0, 194 .bSynchAddress = 0,
@@ -198,7 +198,7 @@ static struct usb_endpoint_descriptor mdc800_ed [4] =
198 .bDescriptorType = 0, 198 .bDescriptorType = 0,
199 .bEndpointAddress = 0x82, 199 .bEndpointAddress = 0x82,
200 .bmAttributes = 0x03, 200 .bmAttributes = 0x03,
201 .wMaxPacketSize = __constant_cpu_to_le16(8), 201 .wMaxPacketSize = cpu_to_le16(8),
202 .bInterval = 0, 202 .bInterval = 0,
203 .bRefresh = 0, 203 .bRefresh = 0,
204 .bSynchAddress = 0, 204 .bSynchAddress = 0,
@@ -208,7 +208,7 @@ static struct usb_endpoint_descriptor mdc800_ed [4] =
208 .bDescriptorType = 0, 208 .bDescriptorType = 0,
209 .bEndpointAddress = 0x03, 209 .bEndpointAddress = 0x03,
210 .bmAttributes = 0x02, 210 .bmAttributes = 0x02,
211 .wMaxPacketSize = __constant_cpu_to_le16(64), 211 .wMaxPacketSize = cpu_to_le16(64),
212 .bInterval = 0, 212 .bInterval = 0,
213 .bRefresh = 0, 213 .bRefresh = 0,
214 .bSynchAddress = 0, 214 .bSynchAddress = 0,
@@ -218,7 +218,7 @@ static struct usb_endpoint_descriptor mdc800_ed [4] =
218 .bDescriptorType = 0, 218 .bDescriptorType = 0,
219 .bEndpointAddress = 0x84, 219 .bEndpointAddress = 0x84,
220 .bmAttributes = 0x02, 220 .bmAttributes = 0x02,
221 .wMaxPacketSize = __constant_cpu_to_le16(64), 221 .wMaxPacketSize = cpu_to_le16(64),
222 .bInterval = 0, 222 .bInterval = 0,
223 .bRefresh = 0, 223 .bRefresh = 0,
224 .bSynchAddress = 0, 224 .bSynchAddress = 0,
@@ -499,6 +499,7 @@ static int mdc800_usb_probe (struct usb_interface *intf,
499 retval = usb_register_dev(intf, &mdc800_class); 499 retval = usb_register_dev(intf, &mdc800_class);
500 if (retval) { 500 if (retval) {
501 dev_err(&intf->dev, "Not able to get a minor for this device.\n"); 501 dev_err(&intf->dev, "Not able to get a minor for this device.\n");
502 mutex_unlock(&mdc800->io_lock);
502 return -ENODEV; 503 return -ENODEV;
503 } 504 }
504 505
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index e463db5d8188..a68d91a11bee 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -135,45 +135,6 @@ config USB_CYTHERM
135 To compile this driver as a module, choose M here: the 135 To compile this driver as a module, choose M here: the
136 module will be called cytherm. 136 module will be called cytherm.
137 137
138config USB_PHIDGET
139 tristate "USB Phidgets drivers"
140 depends on USB
141 help
142 Say Y here to enable the various drivers for devices from
143 Phidgets inc.
144
145config USB_PHIDGETKIT
146 tristate "USB PhidgetInterfaceKit support"
147 depends on USB_PHIDGET
148 help
149 Say Y here if you want to connect a PhidgetInterfaceKit USB device
150 from Phidgets Inc.
151
152 To compile this driver as a module, choose M here: the
153 module will be called phidgetkit.
154
155config USB_PHIDGETMOTORCONTROL
156 tristate "USB PhidgetMotorControl support"
157 depends on USB_PHIDGET
158 help
159 Say Y here if you want to connect a PhidgetMotorControl USB device
160 from Phidgets Inc.
161
162 To compile this driver as a module, choose M here: the
163 module will be called phidgetmotorcontrol.
164
165config USB_PHIDGETSERVO
166 tristate "USB PhidgetServo support"
167 depends on USB_PHIDGET
168 help
169 Say Y here if you want to connect an 1 or 4 Motor PhidgetServo
170 servo controller version 2.0 or 3.0.
171
172 Phidgets Inc. has a web page at <http://www.phidgets.com/>.
173
174 To compile this driver as a module, choose M here: the
175 module will be called phidgetservo.
176
177config USB_IDMOUSE 138config USB_IDMOUSE
178 tristate "Siemens ID USB Mouse Fingerprint sensor support" 139 tristate "Siemens ID USB Mouse Fingerprint sensor support"
179 depends on USB 140 depends on USB
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 1334f7bdd7be..0826aab8303f 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -18,10 +18,6 @@ obj-$(CONFIG_USB_LCD) += usblcd.o
18obj-$(CONFIG_USB_LD) += ldusb.o 18obj-$(CONFIG_USB_LD) += ldusb.o
19obj-$(CONFIG_USB_LED) += usbled.o 19obj-$(CONFIG_USB_LED) += usbled.o
20obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o 20obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
21obj-$(CONFIG_USB_PHIDGET) += phidget.o
22obj-$(CONFIG_USB_PHIDGETKIT) += phidgetkit.o
23obj-$(CONFIG_USB_PHIDGETMOTORCONTROL) += phidgetmotorcontrol.o
24obj-$(CONFIG_USB_PHIDGETSERVO) += phidgetservo.o
25obj-$(CONFIG_USB_RIO500) += rio500.o 21obj-$(CONFIG_USB_RIO500) += rio500.o
26obj-$(CONFIG_USB_TEST) += usbtest.o 22obj-$(CONFIG_USB_TEST) += usbtest.o
27obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o 23obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index 7b6922e08ed1..203526542013 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -376,7 +376,7 @@ static int adu_release(struct inode *inode, struct file *file)
376 if (dev->open_count <= 0) { 376 if (dev->open_count <= 0) {
377 dbg(1," %s : device not opened", __func__); 377 dbg(1," %s : device not opened", __func__);
378 retval = -ENODEV; 378 retval = -ENODEV;
379 goto exit; 379 goto unlock;
380 } 380 }
381 381
382 adu_release_internal(dev); 382 adu_release_internal(dev);
@@ -385,9 +385,9 @@ static int adu_release(struct inode *inode, struct file *file)
385 if (!dev->open_count) /* ... and we're the last user */ 385 if (!dev->open_count) /* ... and we're the last user */
386 adu_delete(dev); 386 adu_delete(dev);
387 } 387 }
388 388unlock:
389exit:
390 mutex_unlock(&adutux_mutex); 389 mutex_unlock(&adutux_mutex);
390exit:
391 dbg(2," %s : leave, return value %d", __func__, retval); 391 dbg(2," %s : leave, return value %d", __func__, retval);
392 return retval; 392 return retval;
393} 393}
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 79a7668ef264..9d0675ed0d4c 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -1568,7 +1568,7 @@ static int ftdi_elan_edset_input(struct usb_ftdi *ftdi, u8 ed_number,
1568 struct u132_target *target = &ftdi->target[ed]; 1568 struct u132_target *target = &ftdi->target[ed];
1569 struct u132_command *command = &ftdi->command[ 1569 struct u132_command *command = &ftdi->command[
1570 COMMAND_MASK & ftdi->command_next]; 1570 COMMAND_MASK & ftdi->command_next];
1571 int remaining_length = urb->transfer_buffer_length - 1571 u32 remaining_length = urb->transfer_buffer_length -
1572 urb->actual_length; 1572 urb->actual_length;
1573 command->header = 0x82 | (ed << 5); 1573 command->header = 0x82 | (ed << 5);
1574 if (remaining_length == 0) { 1574 if (remaining_length == 0) {
@@ -1702,7 +1702,7 @@ static int ftdi_elan_edset_output(struct usb_ftdi *ftdi, u8 ed_number,
1702 | (address << 0); 1702 | (address << 0);
1703 command->width = usb_maxpacket(urb->dev, urb->pipe, 1703 command->width = usb_maxpacket(urb->dev, urb->pipe,
1704 usb_pipeout(urb->pipe)); 1704 usb_pipeout(urb->pipe));
1705 command->follows = min(1024, 1705 command->follows = min_t(u32, 1024,
1706 urb->transfer_buffer_length - 1706 urb->transfer_buffer_length -
1707 urb->actual_length); 1707 urb->actual_length);
1708 command->value = 0; 1708 command->value = 0;
@@ -1766,7 +1766,7 @@ static int ftdi_elan_edset_single(struct usb_ftdi *ftdi, u8 ed_number,
1766 mutex_lock(&ftdi->u132_lock); 1766 mutex_lock(&ftdi->u132_lock);
1767 command_size = ftdi->command_next - ftdi->command_head; 1767 command_size = ftdi->command_next - ftdi->command_head;
1768 if (command_size < COMMAND_SIZE) { 1768 if (command_size < COMMAND_SIZE) {
1769 int remaining_length = urb->transfer_buffer_length - 1769 u32 remaining_length = urb->transfer_buffer_length -
1770 urb->actual_length; 1770 urb->actual_length;
1771 struct u132_target *target = &ftdi->target[ed]; 1771 struct u132_target *target = &ftdi->target[ed];
1772 struct u132_command *command = &ftdi->command[ 1772 struct u132_command *command = &ftdi->command[
diff --git a/drivers/usb/misc/phidget.c b/drivers/usb/misc/phidget.c
deleted file mode 100644
index 735ed33f4f7f..000000000000
--- a/drivers/usb/misc/phidget.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * USB Phidgets class
3 *
4 * Copyright (C) 2006 Sean Young <sean@mess.org>
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/module.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/device.h>
17
18struct class *phidget_class;
19
20static int __init init_phidget(void)
21{
22 phidget_class = class_create(THIS_MODULE, "phidget");
23
24 if (IS_ERR(phidget_class))
25 return PTR_ERR(phidget_class);
26
27 return 0;
28}
29
30static void __exit cleanup_phidget(void)
31{
32 class_destroy(phidget_class);
33}
34
35EXPORT_SYMBOL_GPL(phidget_class);
36
37module_init(init_phidget);
38module_exit(cleanup_phidget);
39
40MODULE_LICENSE("GPL");
41MODULE_AUTHOR("Sean Young <sean@mess.org>");
42MODULE_DESCRIPTION("Container module for phidget class");
43
diff --git a/drivers/usb/misc/phidget.h b/drivers/usb/misc/phidget.h
deleted file mode 100644
index c4011907d431..000000000000
--- a/drivers/usb/misc/phidget.h
+++ /dev/null
@@ -1,12 +0,0 @@
1/*
2 * USB Phidgets class
3 *
4 * Copyright (C) 2006 Sean Young <sean@mess.org>
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
12extern struct class *phidget_class;
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
deleted file mode 100644
index cc8e0a926f99..000000000000
--- a/drivers/usb/misc/phidgetkit.c
+++ /dev/null
@@ -1,740 +0,0 @@
1/*
2 * USB PhidgetInterfaceKit driver 1.0
3 *
4 * Copyright (C) 2004, 2006 Sean Young <sean@mess.org>
5 * Copyright (C) 2005 Daniel Saakes <daniel@saakes.net>
6 * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.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 is a driver for the USB PhidgetInterfaceKit.
14 */
15
16#include <linux/kernel.h>
17#include <linux/errno.h>
18#include <linux/init.h>
19#include <linux/slab.h>
20#include <linux/module.h>
21#include <linux/usb.h>
22
23#include "phidget.h"
24
25#define DRIVER_AUTHOR "Sean Young <sean@mess.org>"
26#define DRIVER_DESC "USB PhidgetInterfaceKit Driver"
27
28#define USB_VENDOR_ID_GLAB 0x06c2
29#define USB_DEVICE_ID_INTERFACEKIT004 0x0040
30#define USB_DEVICE_ID_INTERFACEKIT01616 0x0044
31#define USB_DEVICE_ID_INTERFACEKIT888 0x0045
32#define USB_DEVICE_ID_INTERFACEKIT047 0x0051
33#define USB_DEVICE_ID_INTERFACEKIT088 0x0053
34
35#define USB_VENDOR_ID_WISEGROUP 0x0925
36#define USB_DEVICE_ID_INTERFACEKIT884 0x8201
37
38#define MAX_INTERFACES 16
39
40#define URB_INT_SIZE 8
41
42struct driver_interfacekit {
43 int sensors;
44 int inputs;
45 int outputs;
46 int has_lcd;
47 int amnesiac;
48};
49
50#define ifkit(_sensors, _inputs, _outputs, _lcd, _amnesiac) \
51{ \
52 .sensors = _sensors, \
53 .inputs = _inputs, \
54 .outputs = _outputs, \
55 .has_lcd = _lcd, \
56 .amnesiac = _amnesiac \
57};
58
59static const struct driver_interfacekit ph_004 = ifkit(0, 0, 4, 0, 0);
60static const struct driver_interfacekit ph_888n = ifkit(8, 8, 8, 0, 1);
61static const struct driver_interfacekit ph_888o = ifkit(8, 8, 8, 0, 0);
62static const struct driver_interfacekit ph_047 = ifkit(0, 4, 7, 1, 0);
63static const struct driver_interfacekit ph_884 = ifkit(8, 8, 4, 0, 0);
64static const struct driver_interfacekit ph_088 = ifkit(0, 8, 8, 1, 0);
65static const struct driver_interfacekit ph_01616 = ifkit(0, 16, 16, 0, 0);
66
67static unsigned long device_no;
68
69struct interfacekit {
70 struct usb_device *udev;
71 struct usb_interface *intf;
72 struct driver_interfacekit *ifkit;
73 struct device *dev;
74 unsigned long outputs;
75 int dev_no;
76 u8 inputs[MAX_INTERFACES];
77 u16 sensors[MAX_INTERFACES];
78 u8 lcd_files_on;
79
80 struct urb *irq;
81 unsigned char *data;
82 dma_addr_t data_dma;
83
84 struct delayed_work do_notify;
85 struct delayed_work do_resubmit;
86 unsigned long input_events;
87 unsigned long sensor_events;
88};
89
90static struct usb_device_id id_table[] = {
91 {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT004),
92 .driver_info = (kernel_ulong_t)&ph_004},
93 {USB_DEVICE_VER(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT888, 0, 0x814),
94 .driver_info = (kernel_ulong_t)&ph_888o},
95 {USB_DEVICE_VER(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT888, 0x0815, 0xffff),
96 .driver_info = (kernel_ulong_t)&ph_888n},
97 {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT047),
98 .driver_info = (kernel_ulong_t)&ph_047},
99 {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT088),
100 .driver_info = (kernel_ulong_t)&ph_088},
101 {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT01616),
102 .driver_info = (kernel_ulong_t)&ph_01616},
103 {USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_INTERFACEKIT884),
104 .driver_info = (kernel_ulong_t)&ph_884},
105 {}
106};
107MODULE_DEVICE_TABLE(usb, id_table);
108
109static int set_outputs(struct interfacekit *kit)
110{
111 u8 *buffer;
112 int retval;
113
114 buffer = kzalloc(4, GFP_KERNEL);
115 if (!buffer) {
116 dev_err(&kit->udev->dev, "%s - out of memory\n", __func__);
117 return -ENOMEM;
118 }
119 buffer[0] = (u8)kit->outputs;
120 buffer[1] = (u8)(kit->outputs >> 8);
121
122 dev_dbg(&kit->udev->dev, "sending data: 0x%04x\n", (u16)kit->outputs);
123
124 retval = usb_control_msg(kit->udev,
125 usb_sndctrlpipe(kit->udev, 0),
126 0x09, 0x21, 0x0200, 0x0000, buffer, 4, 2000);
127
128 if (retval != 4)
129 dev_err(&kit->udev->dev, "usb_control_msg returned %d\n",
130 retval);
131 kfree(buffer);
132
133 if (kit->ifkit->amnesiac)
134 schedule_delayed_work(&kit->do_resubmit, HZ / 2);
135
136 return retval < 0 ? retval : 0;
137}
138
139static int change_string(struct interfacekit *kit, const char *display, unsigned char row)
140{
141 unsigned char *buffer;
142 unsigned char *form_buffer;
143 int retval = -ENOMEM;
144 int i,j, len, buf_ptr;
145
146 buffer = kmalloc(8, GFP_KERNEL);
147 form_buffer = kmalloc(30, GFP_KERNEL);
148 if ((!buffer) || (!form_buffer)) {
149 dev_err(&kit->udev->dev, "%s - out of memory\n", __func__);
150 goto exit;
151 }
152
153 len = strlen(display);
154 if (len > 20)
155 len = 20;
156
157 dev_dbg(&kit->udev->dev, "Setting LCD line %d to %s\n", row, display);
158
159 form_buffer[0] = row * 0x40 + 0x80;
160 form_buffer[1] = 0x02;
161 buf_ptr = 2;
162 for (i = 0; i<len; i++)
163 form_buffer[buf_ptr++] = display[i];
164
165 for (i = 0; i < (20 - len); i++)
166 form_buffer[buf_ptr++] = 0x20;
167 form_buffer[buf_ptr++] = 0x01;
168 form_buffer[buf_ptr++] = row * 0x40 + 0x80 + strlen(display);
169
170 for (i = 0; i < buf_ptr; i += 7) {
171 if ((buf_ptr - i) > 7)
172 len = 7;
173 else
174 len = (buf_ptr - i);
175 for (j = 0; j < len; j++)
176 buffer[j] = form_buffer[i + j];
177 buffer[7] = len;
178
179 retval = usb_control_msg(kit->udev,
180 usb_sndctrlpipe(kit->udev, 0),
181 0x09, 0x21, 0x0200, 0x0000, buffer, 8, 2000);
182 if (retval < 0)
183 goto exit;
184 }
185
186 retval = 0;
187exit:
188 kfree(buffer);
189 kfree(form_buffer);
190
191 return retval;
192}
193
194#define set_lcd_line(number) \
195static ssize_t lcd_line_##number(struct device *dev, \
196 struct device_attribute *attr, \
197 const char *buf, size_t count) \
198{ \
199 struct interfacekit *kit = dev_get_drvdata(dev); \
200 change_string(kit, buf, number - 1); \
201 return count; \
202}
203
204#define lcd_line_attr(number) \
205 __ATTR(lcd_line_##number, S_IWUGO, NULL, lcd_line_##number)
206
207set_lcd_line(1);
208set_lcd_line(2);
209
210static ssize_t set_backlight(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
211{
212 struct interfacekit *kit = dev_get_drvdata(dev);
213 int enabled;
214 unsigned char *buffer;
215 int retval = -ENOMEM;
216
217 buffer = kzalloc(8, GFP_KERNEL);
218 if (!buffer) {
219 dev_err(&kit->udev->dev, "%s - out of memory\n", __func__);
220 goto exit;
221 }
222
223 if (sscanf(buf, "%d", &enabled) < 1) {
224 retval = -EINVAL;
225 goto exit;
226 }
227 if (enabled)
228 buffer[0] = 0x01;
229 buffer[7] = 0x11;
230
231 dev_dbg(&kit->udev->dev, "Setting backlight to %s\n", enabled ? "on" : "off");
232
233 retval = usb_control_msg(kit->udev,
234 usb_sndctrlpipe(kit->udev, 0),
235 0x09, 0x21, 0x0200, 0x0000, buffer, 8, 2000);
236 if (retval < 0)
237 goto exit;
238
239 retval = count;
240exit:
241 kfree(buffer);
242 return retval;
243}
244
245static struct device_attribute dev_lcd_line_attrs[] = {
246 lcd_line_attr(1),
247 lcd_line_attr(2),
248 __ATTR(backlight, S_IWUGO, NULL, set_backlight)
249};
250
251static void remove_lcd_files(struct interfacekit *kit)
252{
253 int i;
254
255 if (kit->lcd_files_on) {
256 dev_dbg(&kit->udev->dev, "Removing lcd files\n");
257
258 for (i=0; i<ARRAY_SIZE(dev_lcd_line_attrs); i++)
259 device_remove_file(kit->dev, &dev_lcd_line_attrs[i]);
260 }
261}
262
263static ssize_t enable_lcd_files(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
264{
265 struct interfacekit *kit = dev_get_drvdata(dev);
266 int enable;
267 int i, rc;
268
269 if (kit->ifkit->has_lcd == 0)
270 return -ENODEV;
271
272 if (sscanf(buf, "%d", &enable) < 1)
273 return -EINVAL;
274
275 if (enable) {
276 if (!kit->lcd_files_on) {
277 dev_dbg(&kit->udev->dev, "Adding lcd files\n");
278 for (i=0; i<ARRAY_SIZE(dev_lcd_line_attrs); i++) {
279 rc = device_create_file(kit->dev,
280 &dev_lcd_line_attrs[i]);
281 if (rc)
282 goto out;
283 }
284 kit->lcd_files_on = 1;
285 }
286 } else {
287 if (kit->lcd_files_on) {
288 remove_lcd_files(kit);
289 kit->lcd_files_on = 0;
290 }
291 }
292
293 return count;
294out:
295 while (i-- > 0)
296 device_remove_file(kit->dev, &dev_lcd_line_attrs[i]);
297
298 return rc;
299}
300
301static DEVICE_ATTR(lcd, S_IWUGO, NULL, enable_lcd_files);
302
303static void interfacekit_irq(struct urb *urb)
304{
305 struct interfacekit *kit = urb->context;
306 unsigned char *buffer = kit->data;
307 int i, level, sensor;
308 int retval;
309 int status = urb->status;
310
311 switch (status) {
312 case 0: /* success */
313 break;
314 case -ECONNRESET: /* unlink */
315 case -ENOENT:
316 case -ESHUTDOWN:
317 return;
318 /* -EPIPE: should clear the halt */
319 default: /* error */
320 goto resubmit;
321 }
322
323 /* digital inputs */
324 if (kit->ifkit->inputs == 16) {
325 for (i=0; i < 8; i++) {
326 level = (buffer[0] >> i) & 1;
327 if (kit->inputs[i] != level) {
328 kit->inputs[i] = level;
329 set_bit(i, &kit->input_events);
330 }
331 level = (buffer[1] >> i) & 1;
332 if (kit->inputs[8 + i] != level) {
333 kit->inputs[8 + i] = level;
334 set_bit(8 + i, &kit->input_events);
335 }
336 }
337 }
338 else if (kit->ifkit->inputs == 8) {
339 for (i=0; i < 8; i++) {
340 level = (buffer[1] >> i) & 1;
341 if (kit->inputs[i] != level) {
342 kit->inputs[i] = level;
343 set_bit(i, &kit->input_events);
344 }
345 }
346 }
347
348 /* analog inputs */
349 if (kit->ifkit->sensors) {
350 sensor = (buffer[0] & 1) ? 4 : 0;
351
352 level = buffer[2] + (buffer[3] & 0x0f) * 256;
353 if (level != kit->sensors[sensor]) {
354 kit->sensors[sensor] = level;
355 set_bit(sensor, &kit->sensor_events);
356 }
357 sensor++;
358 level = buffer[4] + (buffer[3] & 0xf0) * 16;
359 if (level != kit->sensors[sensor]) {
360 kit->sensors[sensor] = level;
361 set_bit(sensor, &kit->sensor_events);
362 }
363 sensor++;
364 level = buffer[5] + (buffer[6] & 0x0f) * 256;
365 if (level != kit->sensors[sensor]) {
366 kit->sensors[sensor] = level;
367 set_bit(sensor, &kit->sensor_events);
368 }
369 sensor++;
370 level = buffer[7] + (buffer[6] & 0xf0) * 16;
371 if (level != kit->sensors[sensor]) {
372 kit->sensors[sensor] = level;
373 set_bit(sensor, &kit->sensor_events);
374 }
375 }
376
377 if (kit->input_events || kit->sensor_events)
378 schedule_delayed_work(&kit->do_notify, 0);
379
380resubmit:
381 retval = usb_submit_urb(urb, GFP_ATOMIC);
382 if (retval)
383 err("can't resubmit intr, %s-%s/interfacekit0, retval %d",
384 kit->udev->bus->bus_name,
385 kit->udev->devpath, retval);
386}
387
388static void do_notify(struct work_struct *work)
389{
390 struct interfacekit *kit =
391 container_of(work, struct interfacekit, do_notify.work);
392 int i;
393 char sysfs_file[8];
394
395 for (i=0; i<kit->ifkit->inputs; i++) {
396 if (test_and_clear_bit(i, &kit->input_events)) {
397 sprintf(sysfs_file, "input%d", i + 1);
398 sysfs_notify(&kit->dev->kobj, NULL, sysfs_file);
399 }
400 }
401
402 for (i=0; i<kit->ifkit->sensors; i++) {
403 if (test_and_clear_bit(i, &kit->sensor_events)) {
404 sprintf(sysfs_file, "sensor%d", i + 1);
405 sysfs_notify(&kit->dev->kobj, NULL, sysfs_file);
406 }
407 }
408}
409
410static void do_resubmit(struct work_struct *work)
411{
412 struct interfacekit *kit =
413 container_of(work, struct interfacekit, do_resubmit.work);
414 set_outputs(kit);
415}
416
417#define show_set_output(value) \
418static ssize_t set_output##value(struct device *dev, \
419 struct device_attribute *attr, \
420 const char *buf, size_t count) \
421{ \
422 struct interfacekit *kit = dev_get_drvdata(dev); \
423 int enable; \
424 int retval; \
425 \
426 if (sscanf(buf, "%d", &enable) < 1) \
427 return -EINVAL; \
428 \
429 if (enable) \
430 set_bit(value - 1, &kit->outputs); \
431 else \
432 clear_bit(value - 1, &kit->outputs); \
433 \
434 retval = set_outputs(kit); \
435 \
436 return retval ? retval : count; \
437} \
438 \
439static ssize_t show_output##value(struct device *dev, \
440 struct device_attribute *attr, \
441 char *buf) \
442{ \
443 struct interfacekit *kit = dev_get_drvdata(dev); \
444 \
445 return sprintf(buf, "%d\n", !!test_bit(value - 1, &kit->outputs));\
446}
447
448#define output_attr(value) \
449 __ATTR(output##value, S_IWUGO | S_IRUGO, \
450 show_output##value, set_output##value)
451
452show_set_output(1);
453show_set_output(2);
454show_set_output(3);
455show_set_output(4);
456show_set_output(5);
457show_set_output(6);
458show_set_output(7);
459show_set_output(8);
460show_set_output(9);
461show_set_output(10);
462show_set_output(11);
463show_set_output(12);
464show_set_output(13);
465show_set_output(14);
466show_set_output(15);
467show_set_output(16);
468
469static struct device_attribute dev_output_attrs[] = {
470 output_attr(1), output_attr(2), output_attr(3), output_attr(4),
471 output_attr(5), output_attr(6), output_attr(7), output_attr(8),
472 output_attr(9), output_attr(10), output_attr(11), output_attr(12),
473 output_attr(13), output_attr(14), output_attr(15), output_attr(16)
474};
475
476#define show_input(value) \
477static ssize_t show_input##value(struct device *dev, \
478 struct device_attribute *attr, char *buf) \
479{ \
480 struct interfacekit *kit = dev_get_drvdata(dev); \
481 \
482 return sprintf(buf, "%d\n", (int)kit->inputs[value - 1]); \
483}
484
485#define input_attr(value) \
486 __ATTR(input##value, S_IRUGO, show_input##value, NULL)
487
488show_input(1);
489show_input(2);
490show_input(3);
491show_input(4);
492show_input(5);
493show_input(6);
494show_input(7);
495show_input(8);
496show_input(9);
497show_input(10);
498show_input(11);
499show_input(12);
500show_input(13);
501show_input(14);
502show_input(15);
503show_input(16);
504
505static struct device_attribute dev_input_attrs[] = {
506 input_attr(1), input_attr(2), input_attr(3), input_attr(4),
507 input_attr(5), input_attr(6), input_attr(7), input_attr(8),
508 input_attr(9), input_attr(10), input_attr(11), input_attr(12),
509 input_attr(13), input_attr(14), input_attr(15), input_attr(16)
510};
511
512#define show_sensor(value) \
513static ssize_t show_sensor##value(struct device *dev, \
514 struct device_attribute *attr, \
515 char *buf) \
516{ \
517 struct interfacekit *kit = dev_get_drvdata(dev); \
518 \
519 return sprintf(buf, "%d\n", (int)kit->sensors[value - 1]); \
520}
521
522#define sensor_attr(value) \
523 __ATTR(sensor##value, S_IRUGO, show_sensor##value, NULL)
524
525show_sensor(1);
526show_sensor(2);
527show_sensor(3);
528show_sensor(4);
529show_sensor(5);
530show_sensor(6);
531show_sensor(7);
532show_sensor(8);
533
534static struct device_attribute dev_sensor_attrs[] = {
535 sensor_attr(1), sensor_attr(2), sensor_attr(3), sensor_attr(4),
536 sensor_attr(5), sensor_attr(6), sensor_attr(7), sensor_attr(8)
537};
538
539static int interfacekit_probe(struct usb_interface *intf, const struct usb_device_id *id)
540{
541 struct usb_device *dev = interface_to_usbdev(intf);
542 struct usb_host_interface *interface;
543 struct usb_endpoint_descriptor *endpoint;
544 struct interfacekit *kit;
545 struct driver_interfacekit *ifkit;
546 int pipe, maxp, rc = -ENOMEM;
547 int bit, value, i;
548
549 ifkit = (struct driver_interfacekit *)id->driver_info;
550 if (!ifkit)
551 return -ENODEV;
552
553 interface = intf->cur_altsetting;
554 if (interface->desc.bNumEndpoints != 1)
555 return -ENODEV;
556
557 endpoint = &interface->endpoint[0].desc;
558 if (!usb_endpoint_dir_in(endpoint))
559 return -ENODEV;
560 /*
561 * bmAttributes
562 */
563 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
564 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
565
566 kit = kzalloc(sizeof(*kit), GFP_KERNEL);
567 if (!kit)
568 goto out;
569
570 kit->dev_no = -1;
571 kit->ifkit = ifkit;
572 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &kit->data_dma);
573 if (!kit->data)
574 goto out;
575
576 kit->irq = usb_alloc_urb(0, GFP_KERNEL);
577 if (!kit->irq)
578 goto out;
579
580 kit->udev = usb_get_dev(dev);
581 kit->intf = intf;
582 INIT_DELAYED_WORK(&kit->do_notify, do_notify);
583 INIT_DELAYED_WORK(&kit->do_resubmit, do_resubmit);
584 usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data,
585 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
586 interfacekit_irq, kit, endpoint->bInterval);
587 kit->irq->transfer_dma = kit->data_dma;
588 kit->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
589
590 usb_set_intfdata(intf, kit);
591
592 do {
593 bit = find_first_zero_bit(&device_no, sizeof(device_no));
594 value = test_and_set_bit(bit, &device_no);
595 } while(value);
596 kit->dev_no = bit;
597
598 kit->dev = device_create(phidget_class, &kit->udev->dev, MKDEV(0, 0),
599 kit, "interfacekit%d", kit->dev_no);
600 if (IS_ERR(kit->dev)) {
601 rc = PTR_ERR(kit->dev);
602 kit->dev = NULL;
603 goto out;
604 }
605
606 if (usb_submit_urb(kit->irq, GFP_KERNEL)) {
607 rc = -EIO;
608 goto out;
609 }
610
611 for (i=0; i<ifkit->outputs; i++ ) {
612 rc = device_create_file(kit->dev, &dev_output_attrs[i]);
613 if (rc)
614 goto out2;
615 }
616
617 for (i=0; i<ifkit->inputs; i++ ) {
618 rc = device_create_file(kit->dev, &dev_input_attrs[i]);
619 if (rc)
620 goto out3;
621 }
622
623 for (i=0; i<ifkit->sensors; i++ ) {
624 rc = device_create_file(kit->dev, &dev_sensor_attrs[i]);
625 if (rc)
626 goto out4;
627 }
628
629 if (ifkit->has_lcd) {
630 rc = device_create_file(kit->dev, &dev_attr_lcd);
631 if (rc)
632 goto out4;
633
634 }
635
636 dev_info(&intf->dev, "USB PhidgetInterfaceKit %d/%d/%d attached\n",
637 ifkit->sensors, ifkit->inputs, ifkit->outputs);
638
639 return 0;
640
641out4:
642 while (i-- > 0)
643 device_remove_file(kit->dev, &dev_sensor_attrs[i]);
644
645 i = ifkit->inputs;
646out3:
647 while (i-- > 0)
648 device_remove_file(kit->dev, &dev_input_attrs[i]);
649
650 i = ifkit->outputs;
651out2:
652 while (i-- > 0)
653 device_remove_file(kit->dev, &dev_output_attrs[i]);
654out:
655 if (kit) {
656 usb_free_urb(kit->irq);
657 if (kit->data)
658 usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma);
659 if (kit->dev)
660 device_unregister(kit->dev);
661 if (kit->dev_no >= 0)
662 clear_bit(kit->dev_no, &device_no);
663
664 kfree(kit);
665 }
666
667 return rc;
668}
669
670static void interfacekit_disconnect(struct usb_interface *interface)
671{
672 struct interfacekit *kit;
673 int i;
674
675 kit = usb_get_intfdata(interface);
676 usb_set_intfdata(interface, NULL);
677 if (!kit)
678 return;
679
680 usb_kill_urb(kit->irq);
681 usb_free_urb(kit->irq);
682 usb_buffer_free(kit->udev, URB_INT_SIZE, kit->data, kit->data_dma);
683
684 cancel_delayed_work(&kit->do_notify);
685 cancel_delayed_work(&kit->do_resubmit);
686
687 for (i=0; i<kit->ifkit->outputs; i++)
688 device_remove_file(kit->dev, &dev_output_attrs[i]);
689
690 for (i=0; i<kit->ifkit->inputs; i++)
691 device_remove_file(kit->dev, &dev_input_attrs[i]);
692
693 for (i=0; i<kit->ifkit->sensors; i++)
694 device_remove_file(kit->dev, &dev_sensor_attrs[i]);
695
696 if (kit->ifkit->has_lcd) {
697 device_remove_file(kit->dev, &dev_attr_lcd);
698 remove_lcd_files(kit);
699 }
700
701 device_unregister(kit->dev);
702
703 dev_info(&interface->dev, "USB PhidgetInterfaceKit %d/%d/%d detached\n",
704 kit->ifkit->sensors, kit->ifkit->inputs, kit->ifkit->outputs);
705
706 usb_put_dev(kit->udev);
707 clear_bit(kit->dev_no, &device_no);
708
709 kfree(kit);
710}
711
712static struct usb_driver interfacekit_driver = {
713 .name = "phidgetkit",
714 .probe = interfacekit_probe,
715 .disconnect = interfacekit_disconnect,
716 .id_table = id_table
717};
718
719static int __init interfacekit_init(void)
720{
721 int retval = 0;
722
723 retval = usb_register(&interfacekit_driver);
724 if (retval)
725 err("usb_register failed. Error number %d", retval);
726
727 return retval;
728}
729
730static void __exit interfacekit_exit(void)
731{
732 usb_deregister(&interfacekit_driver);
733}
734
735module_init(interfacekit_init);
736module_exit(interfacekit_exit);
737
738MODULE_AUTHOR(DRIVER_AUTHOR);
739MODULE_DESCRIPTION(DRIVER_DESC);
740MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
deleted file mode 100644
index 38088b44349e..000000000000
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ /dev/null
@@ -1,465 +0,0 @@
1/*
2 * USB Phidget MotorControl driver
3 *
4 * Copyright (C) 2006 Sean Young <sean@mess.org>
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/errno.h>
14#include <linux/init.h>
15#include <linux/module.h>
16#include <linux/usb.h>
17
18#include "phidget.h"
19
20#define DRIVER_AUTHOR "Sean Young <sean@mess.org>"
21#define DRIVER_DESC "USB PhidgetMotorControl Driver"
22
23#define USB_VENDOR_ID_GLAB 0x06c2
24#define USB_DEVICE_ID_MOTORCONTROL 0x0058
25
26#define URB_INT_SIZE 8
27
28static unsigned long device_no;
29
30struct motorcontrol {
31 struct usb_device *udev;
32 struct usb_interface *intf;
33 struct device *dev;
34 int dev_no;
35 u8 inputs[4];
36 s8 desired_speed[2];
37 s8 speed[2];
38 s16 _current[2];
39 s8 acceleration[2];
40 struct urb *irq;
41 unsigned char *data;
42 dma_addr_t data_dma;
43
44 struct delayed_work do_notify;
45 unsigned long input_events;
46 unsigned long speed_events;
47 unsigned long exceed_events;
48};
49
50static struct usb_device_id id_table[] = {
51 { USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_MOTORCONTROL) },
52 {}
53};
54MODULE_DEVICE_TABLE(usb, id_table);
55
56static int set_motor(struct motorcontrol *mc, int motor)
57{
58 u8 *buffer;
59 int speed, speed2, acceleration;
60 int retval;
61
62 buffer = kzalloc(8, GFP_KERNEL);
63 if (!buffer) {
64 dev_err(&mc->intf->dev, "%s - out of memory\n", __func__);
65 return -ENOMEM;
66 }
67
68 acceleration = mc->acceleration[motor] * 10;
69 /* -127 <= speed <= 127 */
70 speed = (mc->desired_speed[motor] * 127) / 100;
71 /* -0x7300 <= speed2 <= 0x7300 */
72 speed2 = (mc->desired_speed[motor] * 230 * 128) / 100;
73
74 buffer[0] = motor;
75 buffer[1] = speed;
76 buffer[2] = acceleration >> 8;
77 buffer[3] = acceleration;
78 buffer[4] = speed2 >> 8;
79 buffer[5] = speed2;
80
81 retval = usb_control_msg(mc->udev,
82 usb_sndctrlpipe(mc->udev, 0),
83 0x09, 0x21, 0x0200, 0x0000, buffer, 8, 2000);
84
85 if (retval != 8)
86 dev_err(&mc->intf->dev, "usb_control_msg returned %d\n",
87 retval);
88 kfree(buffer);
89
90 return retval < 0 ? retval : 0;
91}
92
93static void motorcontrol_irq(struct urb *urb)
94{
95 struct motorcontrol *mc = urb->context;
96 unsigned char *buffer = mc->data;
97 int i, level;
98 int retval;
99 int status = urb->status;;
100
101 switch (status) {
102 case 0: /* success */
103 break;
104 case -ECONNRESET: /* unlink */
105 case -ENOENT:
106 case -ESHUTDOWN:
107 return;
108 /* -EPIPE: should clear the halt */
109 default: /* error */
110 goto resubmit;
111 }
112
113 /* digital inputs */
114 for (i=0; i<4; i++) {
115 level = (buffer[0] >> i) & 1;
116 if (mc->inputs[i] != level) {
117 mc->inputs[i] = level;
118 set_bit(i, &mc->input_events);
119 }
120 }
121
122 /* motor speed */
123 if (buffer[2] == 0) {
124 for (i=0; i<2; i++) {
125 level = ((s8)buffer[4+i]) * 100 / 127;
126 if (mc->speed[i] != level) {
127 mc->speed[i] = level;
128 set_bit(i, &mc->speed_events);
129 }
130 }
131 } else {
132 int index = buffer[3] & 1;
133
134 level = ((s8)buffer[4] << 8) | buffer[5];
135 level = level * 100 / 29440;
136 if (mc->speed[index] != level) {
137 mc->speed[index] = level;
138 set_bit(index, &mc->speed_events);
139 }
140
141 level = ((s8)buffer[6] << 8) | buffer[7];
142 mc->_current[index] = level * 100 / 1572;
143 }
144
145 if (buffer[1] & 1)
146 set_bit(0, &mc->exceed_events);
147
148 if (buffer[1] & 2)
149 set_bit(1, &mc->exceed_events);
150
151 if (mc->input_events || mc->exceed_events || mc->speed_events)
152 schedule_delayed_work(&mc->do_notify, 0);
153
154resubmit:
155 retval = usb_submit_urb(urb, GFP_ATOMIC);
156 if (retval)
157 dev_err(&mc->intf->dev,
158 "can't resubmit intr, %s-%s/motorcontrol0, retval %d\n",
159 mc->udev->bus->bus_name,
160 mc->udev->devpath, retval);
161}
162
163static void do_notify(struct work_struct *work)
164{
165 struct motorcontrol *mc =
166 container_of(work, struct motorcontrol, do_notify.work);
167 int i;
168 char sysfs_file[8];
169
170 for (i=0; i<4; i++) {
171 if (test_and_clear_bit(i, &mc->input_events)) {
172 sprintf(sysfs_file, "input%d", i);
173 sysfs_notify(&mc->dev->kobj, NULL, sysfs_file);
174 }
175 }
176
177 for (i=0; i<2; i++) {
178 if (test_and_clear_bit(i, &mc->speed_events)) {
179 sprintf(sysfs_file, "speed%d", i);
180 sysfs_notify(&mc->dev->kobj, NULL, sysfs_file);
181 }
182 }
183
184 for (i=0; i<2; i++) {
185 if (test_and_clear_bit(i, &mc->exceed_events))
186 dev_warn(&mc->intf->dev,
187 "motor #%d exceeds 1.5 Amp current limit\n", i);
188 }
189}
190
191#define show_set_speed(value) \
192static ssize_t set_speed##value(struct device *dev, \
193 struct device_attribute *attr, \
194 const char *buf, size_t count) \
195{ \
196 struct motorcontrol *mc = dev_get_drvdata(dev); \
197 int speed; \
198 int retval; \
199 \
200 if (sscanf(buf, "%d", &speed) < 1) \
201 return -EINVAL; \
202 \
203 if (speed < -100 || speed > 100) \
204 return -EINVAL; \
205 \
206 mc->desired_speed[value] = speed; \
207 \
208 retval = set_motor(mc, value); \
209 \
210 return retval ? retval : count; \
211} \
212 \
213static ssize_t show_speed##value(struct device *dev, \
214 struct device_attribute *attr, \
215 char *buf) \
216{ \
217 struct motorcontrol *mc = dev_get_drvdata(dev); \
218 \
219 return sprintf(buf, "%d\n", mc->speed[value]); \
220}
221
222#define speed_attr(value) \
223 __ATTR(speed##value, S_IWUGO | S_IRUGO, \
224 show_speed##value, set_speed##value)
225
226show_set_speed(0);
227show_set_speed(1);
228
229#define show_set_acceleration(value) \
230static ssize_t set_acceleration##value(struct device *dev, \
231 struct device_attribute *attr, \
232 const char *buf, size_t count) \
233{ \
234 struct motorcontrol *mc = dev_get_drvdata(dev); \
235 int acceleration; \
236 int retval; \
237 \
238 if (sscanf(buf, "%d", &acceleration) < 1) \
239 return -EINVAL; \
240 \
241 if (acceleration < 0 || acceleration > 100) \
242 return -EINVAL; \
243 \
244 mc->acceleration[value] = acceleration; \
245 \
246 retval = set_motor(mc, value); \
247 \
248 return retval ? retval : count; \
249} \
250 \
251static ssize_t show_acceleration##value(struct device *dev, \
252 struct device_attribute *attr, \
253 char *buf) \
254{ \
255 struct motorcontrol *mc = dev_get_drvdata(dev); \
256 \
257 return sprintf(buf, "%d\n", mc->acceleration[value]); \
258}
259
260#define acceleration_attr(value) \
261 __ATTR(acceleration##value, S_IWUGO | S_IRUGO, \
262 show_acceleration##value, set_acceleration##value)
263
264show_set_acceleration(0);
265show_set_acceleration(1);
266
267#define show_current(value) \
268static ssize_t show_current##value(struct device *dev, \
269 struct device_attribute *attr, \
270 char *buf) \
271{ \
272 struct motorcontrol *mc = dev_get_drvdata(dev); \
273 \
274 return sprintf(buf, "%dmA\n", (int)mc->_current[value]); \
275}
276
277#define current_attr(value) \
278 __ATTR(current##value, S_IRUGO, show_current##value, NULL)
279
280show_current(0);
281show_current(1);
282
283#define show_input(value) \
284static ssize_t show_input##value(struct device *dev, \
285 struct device_attribute *attr, \
286 char *buf) \
287{ \
288 struct motorcontrol *mc = dev_get_drvdata(dev); \
289 \
290 return sprintf(buf, "%d\n", (int)mc->inputs[value]); \
291}
292
293#define input_attr(value) \
294 __ATTR(input##value, S_IRUGO, show_input##value, NULL)
295
296show_input(0);
297show_input(1);
298show_input(2);
299show_input(3);
300
301static struct device_attribute dev_attrs[] = {
302 input_attr(0),
303 input_attr(1),
304 input_attr(2),
305 input_attr(3),
306 speed_attr(0),
307 speed_attr(1),
308 acceleration_attr(0),
309 acceleration_attr(1),
310 current_attr(0),
311 current_attr(1)
312};
313
314static int motorcontrol_probe(struct usb_interface *intf, const struct usb_device_id *id)
315{
316 struct usb_device *dev = interface_to_usbdev(intf);
317 struct usb_host_interface *interface;
318 struct usb_endpoint_descriptor *endpoint;
319 struct motorcontrol *mc;
320 int pipe, maxp, rc = -ENOMEM;
321 int bit, value, i;
322
323 interface = intf->cur_altsetting;
324 if (interface->desc.bNumEndpoints != 1)
325 return -ENODEV;
326
327 endpoint = &interface->endpoint[0].desc;
328 if (!usb_endpoint_dir_in(endpoint))
329 return -ENODEV;
330
331 /*
332 * bmAttributes
333 */
334 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
335 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
336
337 mc = kzalloc(sizeof(*mc), GFP_KERNEL);
338 if (!mc)
339 goto out;
340
341 mc->dev_no = -1;
342 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &mc->data_dma);
343 if (!mc->data)
344 goto out;
345
346 mc->irq = usb_alloc_urb(0, GFP_KERNEL);
347 if (!mc->irq)
348 goto out;
349
350 mc->udev = usb_get_dev(dev);
351 mc->intf = intf;
352 mc->acceleration[0] = mc->acceleration[1] = 10;
353 INIT_DELAYED_WORK(&mc->do_notify, do_notify);
354 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data,
355 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
356 motorcontrol_irq, mc, endpoint->bInterval);
357 mc->irq->transfer_dma = mc->data_dma;
358 mc->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
359
360 usb_set_intfdata(intf, mc);
361
362 do {
363 bit = find_first_zero_bit(&device_no, sizeof(device_no));
364 value = test_and_set_bit(bit, &device_no);
365 } while(value);
366 mc->dev_no = bit;
367
368 mc->dev = device_create(phidget_class, &mc->udev->dev, MKDEV(0, 0), mc,
369 "motorcontrol%d", mc->dev_no);
370 if (IS_ERR(mc->dev)) {
371 rc = PTR_ERR(mc->dev);
372 mc->dev = NULL;
373 goto out;
374 }
375
376 if (usb_submit_urb(mc->irq, GFP_KERNEL)) {
377 rc = -EIO;
378 goto out;
379 }
380
381 for (i=0; i<ARRAY_SIZE(dev_attrs); i++) {
382 rc = device_create_file(mc->dev, &dev_attrs[i]);
383 if (rc)
384 goto out2;
385 }
386
387 dev_info(&intf->dev, "USB PhidgetMotorControl attached\n");
388
389 return 0;
390out2:
391 while (i-- > 0)
392 device_remove_file(mc->dev, &dev_attrs[i]);
393out:
394 if (mc) {
395 usb_free_urb(mc->irq);
396 if (mc->data)
397 usb_buffer_free(dev, URB_INT_SIZE, mc->data, mc->data_dma);
398 if (mc->dev)
399 device_unregister(mc->dev);
400 if (mc->dev_no >= 0)
401 clear_bit(mc->dev_no, &device_no);
402
403 kfree(mc);
404 }
405
406 return rc;
407}
408
409static void motorcontrol_disconnect(struct usb_interface *interface)
410{
411 struct motorcontrol *mc;
412 int i;
413
414 mc = usb_get_intfdata(interface);
415 usb_set_intfdata(interface, NULL);
416 if (!mc)
417 return;
418
419 usb_kill_urb(mc->irq);
420 usb_free_urb(mc->irq);
421 usb_buffer_free(mc->udev, URB_INT_SIZE, mc->data, mc->data_dma);
422
423 cancel_delayed_work(&mc->do_notify);
424
425 for (i=0; i<ARRAY_SIZE(dev_attrs); i++)
426 device_remove_file(mc->dev, &dev_attrs[i]);
427
428 device_unregister(mc->dev);
429
430 usb_put_dev(mc->udev);
431 clear_bit(mc->dev_no, &device_no);
432 kfree(mc);
433
434 dev_info(&interface->dev, "USB PhidgetMotorControl detached\n");
435}
436
437static struct usb_driver motorcontrol_driver = {
438 .name = "phidgetmotorcontrol",
439 .probe = motorcontrol_probe,
440 .disconnect = motorcontrol_disconnect,
441 .id_table = id_table
442};
443
444static int __init motorcontrol_init(void)
445{
446 int retval = 0;
447
448 retval = usb_register(&motorcontrol_driver);
449 if (retval)
450 err("usb_register failed. Error number %d", retval);
451
452 return retval;
453}
454
455static void __exit motorcontrol_exit(void)
456{
457 usb_deregister(&motorcontrol_driver);
458}
459
460module_init(motorcontrol_init);
461module_exit(motorcontrol_exit);
462
463MODULE_AUTHOR(DRIVER_AUTHOR);
464MODULE_DESCRIPTION(DRIVER_DESC);
465MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
deleted file mode 100644
index bef6fe16364b..000000000000
--- a/drivers/usb/misc/phidgetservo.c
+++ /dev/null
@@ -1,375 +0,0 @@
1/*
2 * USB PhidgetServo driver 1.0
3 *
4 * Copyright (C) 2004, 2006 Sean Young <sean@mess.org>
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 is a driver for the USB PhidgetServo version 2.0 and 3.0 servo
12 * controllers available at: http://www.phidgets.com/
13 *
14 * Note that the driver takes input as: degrees.minutes
15 *
16 * CAUTION: Generally you should use 0 < degrees < 180 as anything else
17 * is probably beyond the range of your servo and may damage it.
18 */
19
20#include <linux/kernel.h>
21#include <linux/errno.h>
22#include <linux/init.h>
23#include <linux/slab.h>
24#include <linux/module.h>
25#include <linux/usb.h>
26
27#include "phidget.h"
28
29#define DRIVER_AUTHOR "Sean Young <sean@mess.org>"
30#define DRIVER_DESC "USB PhidgetServo Driver"
31
32#define VENDOR_ID_GLAB 0x06c2
33#define DEVICE_ID_GLAB_PHIDGETSERVO_QUAD 0x0038
34#define DEVICE_ID_GLAB_PHIDGETSERVO_UNI 0x0039
35
36#define VENDOR_ID_WISEGROUP 0x0925
37#define VENDOR_ID_WISEGROUP_PHIDGETSERVO_QUAD 0x8101
38#define VENDOR_ID_WISEGROUP_PHIDGETSERVO_UNI 0x8104
39
40#define SERVO_VERSION_30 0x01
41#define SERVO_COUNT_QUAD 0x02
42
43static struct usb_device_id id_table[] = {
44 {
45 USB_DEVICE(VENDOR_ID_GLAB, DEVICE_ID_GLAB_PHIDGETSERVO_QUAD),
46 .driver_info = SERVO_VERSION_30 | SERVO_COUNT_QUAD
47 },
48 {
49 USB_DEVICE(VENDOR_ID_GLAB, DEVICE_ID_GLAB_PHIDGETSERVO_UNI),
50 .driver_info = SERVO_VERSION_30
51 },
52 {
53 USB_DEVICE(VENDOR_ID_WISEGROUP,
54 VENDOR_ID_WISEGROUP_PHIDGETSERVO_QUAD),
55 .driver_info = SERVO_COUNT_QUAD
56 },
57 {
58 USB_DEVICE(VENDOR_ID_WISEGROUP,
59 VENDOR_ID_WISEGROUP_PHIDGETSERVO_UNI),
60 .driver_info = 0
61 },
62 {}
63};
64
65MODULE_DEVICE_TABLE(usb, id_table);
66
67static int unsigned long device_no;
68
69struct phidget_servo {
70 struct usb_device *udev;
71 struct device *dev;
72 int dev_no;
73 ulong type;
74 int pulse[4];
75 int degrees[4];
76 int minutes[4];
77};
78
79static int
80change_position_v30(struct phidget_servo *servo, int servo_no, int degrees,
81 int minutes)
82{
83 int retval;
84 unsigned char *buffer;
85
86 if (degrees < -23 || degrees > 362)
87 return -EINVAL;
88
89 buffer = kmalloc(6, GFP_KERNEL);
90 if (!buffer) {
91 dev_err(&servo->udev->dev, "%s - out of memory\n",
92 __func__);
93 return -ENOMEM;
94 }
95
96 /*
97 * pulse = 0 - 4095
98 * angle = 0 - 180 degrees
99 *
100 * pulse = angle * 10.6 + 243.8
101 */
102 servo->pulse[servo_no] = ((degrees*60 + minutes)*106 + 2438*60)/600;
103 servo->degrees[servo_no]= degrees;
104 servo->minutes[servo_no]= minutes;
105
106 /*
107 * The PhidgetServo v3.0 is controlled by sending 6 bytes,
108 * 4 * 12 bits for each servo.
109 *
110 * low = lower 8 bits pulse
111 * high = higher 4 bits pulse
112 *
113 * offset bits
114 * +---+-----------------+
115 * | 0 | low 0 |
116 * +---+--------+--------+
117 * | 1 | high 1 | high 0 |
118 * +---+--------+--------+
119 * | 2 | low 1 |
120 * +---+-----------------+
121 * | 3 | low 2 |
122 * +---+--------+--------+
123 * | 4 | high 3 | high 2 |
124 * +---+--------+--------+
125 * | 5 | low 3 |
126 * +---+-----------------+
127 */
128
129 buffer[0] = servo->pulse[0] & 0xff;
130 buffer[1] = (servo->pulse[0] >> 8 & 0x0f)
131 | (servo->pulse[1] >> 4 & 0xf0);
132 buffer[2] = servo->pulse[1] & 0xff;
133 buffer[3] = servo->pulse[2] & 0xff;
134 buffer[4] = (servo->pulse[2] >> 8 & 0x0f)
135 | (servo->pulse[3] >> 4 & 0xf0);
136 buffer[5] = servo->pulse[3] & 0xff;
137
138 dev_dbg(&servo->udev->dev,
139 "data: %02x %02x %02x %02x %02x %02x\n",
140 buffer[0], buffer[1], buffer[2],
141 buffer[3], buffer[4], buffer[5]);
142
143 retval = usb_control_msg(servo->udev,
144 usb_sndctrlpipe(servo->udev, 0),
145 0x09, 0x21, 0x0200, 0x0000, buffer, 6, 2000);
146
147 kfree(buffer);
148
149 return retval;
150}
151
152static int
153change_position_v20(struct phidget_servo *servo, int servo_no, int degrees,
154 int minutes)
155{
156 int retval;
157 unsigned char *buffer;
158
159 if (degrees < -23 || degrees > 278)
160 return -EINVAL;
161
162 buffer = kmalloc(2, GFP_KERNEL);
163 if (!buffer) {
164 dev_err(&servo->udev->dev, "%s - out of memory\n",
165 __func__);
166 return -ENOMEM;
167 }
168
169 /*
170 * angle = 0 - 180 degrees
171 * pulse = angle + 23
172 */
173 servo->pulse[servo_no]= degrees + 23;
174 servo->degrees[servo_no]= degrees;
175 servo->minutes[servo_no]= 0;
176
177 /*
178 * The PhidgetServo v2.0 is controlled by sending two bytes. The
179 * first byte is the servo number xor'ed with 2:
180 *
181 * servo 0 = 2
182 * servo 1 = 3
183 * servo 2 = 0
184 * servo 3 = 1
185 *
186 * The second byte is the position.
187 */
188
189 buffer[0] = servo_no ^ 2;
190 buffer[1] = servo->pulse[servo_no];
191
192 dev_dbg(&servo->udev->dev, "data: %02x %02x\n", buffer[0], buffer[1]);
193
194 retval = usb_control_msg(servo->udev,
195 usb_sndctrlpipe(servo->udev, 0),
196 0x09, 0x21, 0x0200, 0x0000, buffer, 2, 2000);
197
198 kfree(buffer);
199
200 return retval;
201}
202
203#define show_set(value) \
204static ssize_t set_servo##value (struct device *dev, \
205 struct device_attribute *attr, \
206 const char *buf, size_t count) \
207{ \
208 int degrees, minutes, retval; \
209 struct phidget_servo *servo = dev_get_drvdata(dev); \
210 \
211 minutes = 0; \
212 /* must at least convert degrees */ \
213 if (sscanf(buf, "%d.%d", &degrees, &minutes) < 1) { \
214 return -EINVAL; \
215 } \
216 \
217 if (minutes < 0 || minutes > 59) \
218 return -EINVAL; \
219 \
220 if (servo->type & SERVO_VERSION_30) \
221 retval = change_position_v30(servo, value, degrees, \
222 minutes); \
223 else \
224 retval = change_position_v20(servo, value, degrees, \
225 minutes); \
226 \
227 return retval < 0 ? retval : count; \
228} \
229 \
230static ssize_t show_servo##value (struct device *dev, \
231 struct device_attribute *attr, \
232 char *buf) \
233{ \
234 struct phidget_servo *servo = dev_get_drvdata(dev); \
235 \
236 return sprintf(buf, "%d.%02d\n", servo->degrees[value], \
237 servo->minutes[value]); \
238}
239
240#define servo_attr(value) \
241 __ATTR(servo##value, S_IWUGO | S_IRUGO, \
242 show_servo##value, set_servo##value)
243show_set(0);
244show_set(1);
245show_set(2);
246show_set(3);
247
248static struct device_attribute dev_attrs[] = {
249 servo_attr(0), servo_attr(1), servo_attr(2), servo_attr(3)
250};
251
252static int
253servo_probe(struct usb_interface *interface, const struct usb_device_id *id)
254{
255 struct usb_device *udev = interface_to_usbdev(interface);
256 struct phidget_servo *dev;
257 int bit, value, rc;
258 int servo_count, i;
259
260 dev = kzalloc(sizeof (struct phidget_servo), GFP_KERNEL);
261 if (dev == NULL) {
262 dev_err(&interface->dev, "%s - out of memory\n", __func__);
263 rc = -ENOMEM;
264 goto out;
265 }
266
267 dev->udev = usb_get_dev(udev);
268 dev->type = id->driver_info;
269 dev->dev_no = -1;
270 usb_set_intfdata(interface, dev);
271
272 do {
273 bit = find_first_zero_bit(&device_no, sizeof(device_no));
274 value = test_and_set_bit(bit, &device_no);
275 } while (value);
276 dev->dev_no = bit;
277
278 dev->dev = device_create(phidget_class, &dev->udev->dev, MKDEV(0, 0),
279 dev, "servo%d", dev->dev_no);
280 if (IS_ERR(dev->dev)) {
281 rc = PTR_ERR(dev->dev);
282 dev->dev = NULL;
283 goto out;
284 }
285
286 servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1;
287
288 for (i=0; i<servo_count; i++) {
289 rc = device_create_file(dev->dev, &dev_attrs[i]);
290 if (rc)
291 goto out2;
292 }
293
294 dev_info(&interface->dev, "USB %d-Motor PhidgetServo v%d.0 attached\n",
295 servo_count, dev->type & SERVO_VERSION_30 ? 3 : 2);
296
297 if (!(dev->type & SERVO_VERSION_30))
298 dev_info(&interface->dev,
299 "WARNING: v2.0 not tested! Please report if it works.\n");
300
301 return 0;
302out2:
303 while (i-- > 0)
304 device_remove_file(dev->dev, &dev_attrs[i]);
305out:
306 if (dev) {
307 if (dev->dev)
308 device_unregister(dev->dev);
309 if (dev->dev_no >= 0)
310 clear_bit(dev->dev_no, &device_no);
311
312 kfree(dev);
313 }
314
315 return rc;
316}
317
318static void
319servo_disconnect(struct usb_interface *interface)
320{
321 struct phidget_servo *dev;
322 int servo_count, i;
323
324 dev = usb_get_intfdata(interface);
325 usb_set_intfdata(interface, NULL);
326
327 if (!dev)
328 return;
329
330 servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1;
331
332 for (i=0; i<servo_count; i++)
333 device_remove_file(dev->dev, &dev_attrs[i]);
334
335 device_unregister(dev->dev);
336 usb_put_dev(dev->udev);
337
338 dev_info(&interface->dev, "USB %d-Motor PhidgetServo v%d.0 detached\n",
339 servo_count, dev->type & SERVO_VERSION_30 ? 3 : 2);
340
341 clear_bit(dev->dev_no, &device_no);
342 kfree(dev);
343}
344
345static struct usb_driver servo_driver = {
346 .name = "phidgetservo",
347 .probe = servo_probe,
348 .disconnect = servo_disconnect,
349 .id_table = id_table
350};
351
352static int __init
353phidget_servo_init(void)
354{
355 int retval;
356
357 retval = usb_register(&servo_driver);
358 if (retval)
359 err("usb_register failed. Error number %d", retval);
360
361 return retval;
362}
363
364static void __exit
365phidget_servo_exit(void)
366{
367 usb_deregister(&servo_driver);
368}
369
370module_init(phidget_servo_init);
371module_exit(phidget_servo_exit);
372
373MODULE_AUTHOR(DRIVER_AUTHOR);
374MODULE_DESCRIPTION(DRIVER_DESC);
375MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/vstusb.c b/drivers/usb/misc/vstusb.c
index 63dff9ba73c5..f26ea8dc1577 100644
--- a/drivers/usb/misc/vstusb.c
+++ b/drivers/usb/misc/vstusb.c
@@ -401,6 +401,7 @@ static ssize_t vstusb_write(struct file *file, const char __user *buffer,
401 } 401 }
402 402
403 if (copy_from_user(buf, buffer, count)) { 403 if (copy_from_user(buf, buffer, count)) {
404 mutex_unlock(&vstdev->lock);
404 dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__); 405 dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__);
405 retval = -EFAULT; 406 retval = -EFAULT;
406 goto exit; 407 goto exit;
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 4cf27c72423e..f8d9045d668a 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -37,10 +37,13 @@
37#define MON_IOCX_GET _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get) 37#define MON_IOCX_GET _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get)
38#define MON_IOCX_MFETCH _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch) 38#define MON_IOCX_MFETCH _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch)
39#define MON_IOCH_MFLUSH _IO(MON_IOC_MAGIC, 8) 39#define MON_IOCH_MFLUSH _IO(MON_IOC_MAGIC, 8)
40/* #9 was MON_IOCT_SETAPI */
41#define MON_IOCX_GETX _IOW(MON_IOC_MAGIC, 10, struct mon_bin_get)
40 42
41#ifdef CONFIG_COMPAT 43#ifdef CONFIG_COMPAT
42#define MON_IOCX_GET32 _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get32) 44#define MON_IOCX_GET32 _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get32)
43#define MON_IOCX_MFETCH32 _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch32) 45#define MON_IOCX_MFETCH32 _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch32)
46#define MON_IOCX_GETX32 _IOW(MON_IOC_MAGIC, 10, struct mon_bin_get32)
44#endif 47#endif
45 48
46/* 49/*
@@ -92,7 +95,29 @@ struct mon_bin_hdr {
92 int status; 95 int status;
93 unsigned int len_urb; /* Length of data (submitted or actual) */ 96 unsigned int len_urb; /* Length of data (submitted or actual) */
94 unsigned int len_cap; /* Delivered length */ 97 unsigned int len_cap; /* Delivered length */
95 unsigned char setup[SETUP_LEN]; /* Only for Control S-type */ 98 union {
99 unsigned char setup[SETUP_LEN]; /* Only for Control S-type */
100 struct iso_rec {
101 int error_count;
102 int numdesc;
103 } iso;
104 } s;
105 int interval;
106 int start_frame;
107 unsigned int xfer_flags;
108 unsigned int ndesc; /* Actual number of ISO descriptors */
109};
110
111/*
112 * ISO vector, packed into the head of data stream.
113 * This has to take 16 bytes to make sure that the end of buffer
114 * wrap is not happening in the middle of a descriptor.
115 */
116struct mon_bin_isodesc {
117 int iso_status;
118 unsigned int iso_off;
119 unsigned int iso_len;
120 u32 _pad;
96}; 121};
97 122
98/* per file statistic */ 123/* per file statistic */
@@ -102,7 +127,7 @@ struct mon_bin_stats {
102}; 127};
103 128
104struct mon_bin_get { 129struct mon_bin_get {
105 struct mon_bin_hdr __user *hdr; /* Only 48 bytes, not 64. */ 130 struct mon_bin_hdr __user *hdr; /* Can be 48 bytes or 64. */
106 void __user *data; 131 void __user *data;
107 size_t alloc; /* Length of data (can be zero) */ 132 size_t alloc; /* Length of data (can be zero) */
108}; 133};
@@ -131,6 +156,11 @@ struct mon_bin_mfetch32 {
131#define PKT_ALIGN 64 156#define PKT_ALIGN 64
132#define PKT_SIZE 64 157#define PKT_SIZE 64
133 158
159#define PKT_SZ_API0 48 /* API 0 (2.6.20) size */
160#define PKT_SZ_API1 64 /* API 1 size: extra fields */
161
162#define ISODESC_MAX 128 /* Same number as usbfs allows, 2048 bytes. */
163
134/* max number of USB bus supported */ 164/* max number of USB bus supported */
135#define MON_BIN_MAX_MINOR 128 165#define MON_BIN_MAX_MINOR 128
136 166
@@ -360,12 +390,8 @@ static inline char mon_bin_get_setup(unsigned char *setupb,
360 const struct urb *urb, char ev_type) 390 const struct urb *urb, char ev_type)
361{ 391{
362 392
363 if (!usb_endpoint_xfer_control(&urb->ep->desc) || ev_type != 'S')
364 return '-';
365
366 if (urb->setup_packet == NULL) 393 if (urb->setup_packet == NULL)
367 return 'Z'; 394 return 'Z';
368
369 memcpy(setupb, urb->setup_packet, SETUP_LEN); 395 memcpy(setupb, urb->setup_packet, SETUP_LEN);
370 return 0; 396 return 0;
371} 397}
@@ -387,6 +413,26 @@ static char mon_bin_get_data(const struct mon_reader_bin *rp,
387 return 0; 413 return 0;
388} 414}
389 415
416static void mon_bin_get_isodesc(const struct mon_reader_bin *rp,
417 unsigned int offset, struct urb *urb, char ev_type, unsigned int ndesc)
418{
419 struct mon_bin_isodesc *dp;
420 struct usb_iso_packet_descriptor *fp;
421
422 fp = urb->iso_frame_desc;
423 while (ndesc-- != 0) {
424 dp = (struct mon_bin_isodesc *)
425 (rp->b_vec[offset / CHUNK_SIZE].ptr + offset % CHUNK_SIZE);
426 dp->iso_status = fp->status;
427 dp->iso_off = fp->offset;
428 dp->iso_len = (ev_type == 'S') ? fp->length : fp->actual_length;
429 dp->_pad = 0;
430 if ((offset += sizeof(struct mon_bin_isodesc)) >= rp->b_size)
431 offset = 0;
432 fp++;
433 }
434}
435
390static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, 436static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
391 char ev_type, int status) 437 char ev_type, int status)
392{ 438{
@@ -396,6 +442,7 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
396 unsigned int urb_length; 442 unsigned int urb_length;
397 unsigned int offset; 443 unsigned int offset;
398 unsigned int length; 444 unsigned int length;
445 unsigned int ndesc, lendesc;
399 unsigned char dir; 446 unsigned char dir;
400 struct mon_bin_hdr *ep; 447 struct mon_bin_hdr *ep;
401 char data_tag = 0; 448 char data_tag = 0;
@@ -407,6 +454,19 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
407 /* 454 /*
408 * Find the maximum allowable length, then allocate space. 455 * Find the maximum allowable length, then allocate space.
409 */ 456 */
457 if (usb_endpoint_xfer_isoc(epd)) {
458 if (urb->number_of_packets < 0) {
459 ndesc = 0;
460 } else if (urb->number_of_packets >= ISODESC_MAX) {
461 ndesc = ISODESC_MAX;
462 } else {
463 ndesc = urb->number_of_packets;
464 }
465 } else {
466 ndesc = 0;
467 }
468 lendesc = ndesc*sizeof(struct mon_bin_isodesc);
469
410 urb_length = (ev_type == 'S') ? 470 urb_length = (ev_type == 'S') ?
411 urb->transfer_buffer_length : urb->actual_length; 471 urb->transfer_buffer_length : urb->actual_length;
412 length = urb_length; 472 length = urb_length;
@@ -429,10 +489,12 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
429 dir = 0; 489 dir = 0;
430 } 490 }
431 491
432 if (rp->mmap_active) 492 if (rp->mmap_active) {
433 offset = mon_buff_area_alloc_contiguous(rp, length + PKT_SIZE); 493 offset = mon_buff_area_alloc_contiguous(rp,
434 else 494 length + PKT_SIZE + lendesc);
435 offset = mon_buff_area_alloc(rp, length + PKT_SIZE); 495 } else {
496 offset = mon_buff_area_alloc(rp, length + PKT_SIZE + lendesc);
497 }
436 if (offset == ~0) { 498 if (offset == ~0) {
437 rp->cnt_lost++; 499 rp->cnt_lost++;
438 spin_unlock_irqrestore(&rp->b_lock, flags); 500 spin_unlock_irqrestore(&rp->b_lock, flags);
@@ -456,9 +518,31 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
456 ep->ts_usec = ts.tv_usec; 518 ep->ts_usec = ts.tv_usec;
457 ep->status = status; 519 ep->status = status;
458 ep->len_urb = urb_length; 520 ep->len_urb = urb_length;
459 ep->len_cap = length; 521 ep->len_cap = length + lendesc;
522 ep->xfer_flags = urb->transfer_flags;
523
524 if (usb_endpoint_xfer_int(epd)) {
525 ep->interval = urb->interval;
526 } else if (usb_endpoint_xfer_isoc(epd)) {
527 ep->interval = urb->interval;
528 ep->start_frame = urb->start_frame;
529 ep->s.iso.error_count = urb->error_count;
530 ep->s.iso.numdesc = urb->number_of_packets;
531 }
532
533 if (usb_endpoint_xfer_control(epd) && ev_type == 'S') {
534 ep->flag_setup = mon_bin_get_setup(ep->s.setup, urb, ev_type);
535 } else {
536 ep->flag_setup = '-';
537 }
538
539 if (ndesc != 0) {
540 ep->ndesc = ndesc;
541 mon_bin_get_isodesc(rp, offset, urb, ev_type, ndesc);
542 if ((offset += lendesc) >= rp->b_size)
543 offset -= rp->b_size;
544 }
460 545
461 ep->flag_setup = mon_bin_get_setup(ep->setup, urb, ev_type);
462 if (length != 0) { 546 if (length != 0) {
463 ep->flag_data = mon_bin_get_data(rp, offset, urb, length); 547 ep->flag_data = mon_bin_get_data(rp, offset, urb, length);
464 if (ep->flag_data != 0) { /* Yes, it's 0x00, not '0' */ 548 if (ep->flag_data != 0) { /* Yes, it's 0x00, not '0' */
@@ -592,7 +676,8 @@ err_alloc:
592 * Returns zero or error. 676 * Returns zero or error.
593 */ 677 */
594static int mon_bin_get_event(struct file *file, struct mon_reader_bin *rp, 678static int mon_bin_get_event(struct file *file, struct mon_reader_bin *rp,
595 struct mon_bin_hdr __user *hdr, void __user *data, unsigned int nbytes) 679 struct mon_bin_hdr __user *hdr, unsigned int hdrbytes,
680 void __user *data, unsigned int nbytes)
596{ 681{
597 unsigned long flags; 682 unsigned long flags;
598 struct mon_bin_hdr *ep; 683 struct mon_bin_hdr *ep;
@@ -609,7 +694,7 @@ static int mon_bin_get_event(struct file *file, struct mon_reader_bin *rp,
609 694
610 ep = MON_OFF2HDR(rp, rp->b_out); 695 ep = MON_OFF2HDR(rp, rp->b_out);
611 696
612 if (copy_to_user(hdr, ep, sizeof(struct mon_bin_hdr))) { 697 if (copy_to_user(hdr, ep, hdrbytes)) {
613 mutex_unlock(&rp->fetch_lock); 698 mutex_unlock(&rp->fetch_lock);
614 return -EFAULT; 699 return -EFAULT;
615 } 700 }
@@ -657,6 +742,7 @@ static ssize_t mon_bin_read(struct file *file, char __user *buf,
657 size_t nbytes, loff_t *ppos) 742 size_t nbytes, loff_t *ppos)
658{ 743{
659 struct mon_reader_bin *rp = file->private_data; 744 struct mon_reader_bin *rp = file->private_data;
745 unsigned int hdrbytes = PKT_SZ_API0;
660 unsigned long flags; 746 unsigned long flags;
661 struct mon_bin_hdr *ep; 747 struct mon_bin_hdr *ep;
662 unsigned int offset; 748 unsigned int offset;
@@ -674,8 +760,8 @@ static ssize_t mon_bin_read(struct file *file, char __user *buf,
674 760
675 ep = MON_OFF2HDR(rp, rp->b_out); 761 ep = MON_OFF2HDR(rp, rp->b_out);
676 762
677 if (rp->b_read < sizeof(struct mon_bin_hdr)) { 763 if (rp->b_read < hdrbytes) {
678 step_len = min(nbytes, sizeof(struct mon_bin_hdr) - rp->b_read); 764 step_len = min(nbytes, (size_t)(hdrbytes - rp->b_read));
679 ptr = ((char *)ep) + rp->b_read; 765 ptr = ((char *)ep) + rp->b_read;
680 if (step_len && copy_to_user(buf, ptr, step_len)) { 766 if (step_len && copy_to_user(buf, ptr, step_len)) {
681 mutex_unlock(&rp->fetch_lock); 767 mutex_unlock(&rp->fetch_lock);
@@ -687,13 +773,13 @@ static ssize_t mon_bin_read(struct file *file, char __user *buf,
687 done += step_len; 773 done += step_len;
688 } 774 }
689 775
690 if (rp->b_read >= sizeof(struct mon_bin_hdr)) { 776 if (rp->b_read >= hdrbytes) {
691 step_len = ep->len_cap; 777 step_len = ep->len_cap;
692 step_len -= rp->b_read - sizeof(struct mon_bin_hdr); 778 step_len -= rp->b_read - hdrbytes;
693 if (step_len > nbytes) 779 if (step_len > nbytes)
694 step_len = nbytes; 780 step_len = nbytes;
695 offset = rp->b_out + PKT_SIZE; 781 offset = rp->b_out + PKT_SIZE;
696 offset += rp->b_read - sizeof(struct mon_bin_hdr); 782 offset += rp->b_read - hdrbytes;
697 if (offset >= rp->b_size) 783 if (offset >= rp->b_size)
698 offset -= rp->b_size; 784 offset -= rp->b_size;
699 if (copy_from_buf(rp, offset, buf, step_len)) { 785 if (copy_from_buf(rp, offset, buf, step_len)) {
@@ -709,7 +795,7 @@ static ssize_t mon_bin_read(struct file *file, char __user *buf,
709 /* 795 /*
710 * Check if whole packet was read, and if so, jump to the next one. 796 * Check if whole packet was read, and if so, jump to the next one.
711 */ 797 */
712 if (rp->b_read >= sizeof(struct mon_bin_hdr) + ep->len_cap) { 798 if (rp->b_read >= hdrbytes + ep->len_cap) {
713 spin_lock_irqsave(&rp->b_lock, flags); 799 spin_lock_irqsave(&rp->b_lock, flags);
714 mon_buff_area_free(rp, PKT_SIZE + ep->len_cap); 800 mon_buff_area_free(rp, PKT_SIZE + ep->len_cap);
715 spin_unlock_irqrestore(&rp->b_lock, flags); 801 spin_unlock_irqrestore(&rp->b_lock, flags);
@@ -908,6 +994,7 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
908 break; 994 break;
909 995
910 case MON_IOCX_GET: 996 case MON_IOCX_GET:
997 case MON_IOCX_GETX:
911 { 998 {
912 struct mon_bin_get getb; 999 struct mon_bin_get getb;
913 1000
@@ -917,8 +1004,9 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
917 1004
918 if (getb.alloc > 0x10000000) /* Want to cast to u32 */ 1005 if (getb.alloc > 0x10000000) /* Want to cast to u32 */
919 return -EINVAL; 1006 return -EINVAL;
920 ret = mon_bin_get_event(file, rp, 1007 ret = mon_bin_get_event(file, rp, getb.hdr,
921 getb.hdr, getb.data, (unsigned int)getb.alloc); 1008 (cmd == MON_IOCX_GET)? PKT_SZ_API0: PKT_SZ_API1,
1009 getb.data, (unsigned int)getb.alloc);
922 } 1010 }
923 break; 1011 break;
924 1012
@@ -984,16 +1072,18 @@ static long mon_bin_compat_ioctl(struct file *file,
984 1072
985 switch (cmd) { 1073 switch (cmd) {
986 1074
987 case MON_IOCX_GET32: { 1075 case MON_IOCX_GET32:
1076 case MON_IOCX_GETX32:
1077 {
988 struct mon_bin_get32 getb; 1078 struct mon_bin_get32 getb;
989 1079
990 if (copy_from_user(&getb, (void __user *)arg, 1080 if (copy_from_user(&getb, (void __user *)arg,
991 sizeof(struct mon_bin_get32))) 1081 sizeof(struct mon_bin_get32)))
992 return -EFAULT; 1082 return -EFAULT;
993 1083
994 ret = mon_bin_get_event(file, rp, 1084 ret = mon_bin_get_event(file, rp, compat_ptr(getb.hdr32),
995 compat_ptr(getb.hdr32), compat_ptr(getb.data32), 1085 (cmd == MON_IOCX_GET32)? PKT_SZ_API0: PKT_SZ_API1,
996 getb.alloc32); 1086 compat_ptr(getb.data32), getb.alloc32);
997 if (ret < 0) 1087 if (ret < 0)
998 return ret; 1088 return ret;
999 } 1089 }
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 9985db08e7db..b66e8544d8b9 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -20,8 +20,8 @@ config USB_MUSB_HDRC
20 it's being used with, including the USB peripheral role, 20 it's being used with, including the USB peripheral role,
21 or the USB host role, or both. 21 or the USB host role, or both.
22 22
23 Texas Instruments parts using this IP include DaVinci 644x, 23 Texas Instruments familiies using this IP include DaVinci
24 OMAP 243x, OMAP 343x, and TUSB 6010. 24 (35x, 644x ...), OMAP 243x, OMAP 3, and TUSB 6010.
25 25
26 Analog Devices parts using this IP include Blackfin BF54x, 26 Analog Devices parts using this IP include Blackfin BF54x,
27 BF525 and BF527. 27 BF525 and BF527.
@@ -40,7 +40,7 @@ config USB_MUSB_SOC
40 default y if (BF54x && !BF544) 40 default y if (BF54x && !BF544)
41 default y if (BF52x && !BF522 && !BF523) 41 default y if (BF52x && !BF522 && !BF523)
42 42
43comment "DaVinci 644x USB support" 43comment "DaVinci 35x and 644x USB support"
44 depends on USB_MUSB_HDRC && ARCH_DAVINCI 44 depends on USB_MUSB_HDRC && ARCH_DAVINCI
45 45
46comment "OMAP 243x high speed USB support" 46comment "OMAP 243x high speed USB support"
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 2dc7606f319c..10d11ab113ab 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -48,6 +48,9 @@
48#include "cppi_dma.h" 48#include "cppi_dma.h"
49 49
50 50
51#define USB_PHY_CTRL IO_ADDRESS(USBPHY_CTL_PADDR)
52#define DM355_DEEPSLEEP IO_ADDRESS(DM355_DEEPSLEEP_PADDR)
53
51/* REVISIT (PM) we should be able to keep the PHY in low power mode most 54/* REVISIT (PM) we should be able to keep the PHY in low power mode most
52 * of the time (24 MHZ oscillator and PLL off, etc) by setting POWER.D0 55 * of the time (24 MHZ oscillator and PLL off, etc) by setting POWER.D0
53 * and, when in host mode, autosuspending idle root ports... PHYPLLON 56 * and, when in host mode, autosuspending idle root ports... PHYPLLON
@@ -56,20 +59,26 @@
56 59
57static inline void phy_on(void) 60static inline void phy_on(void)
58{ 61{
59 /* start the on-chip PHY and its PLL */ 62 u32 phy_ctrl = __raw_readl(USB_PHY_CTRL);
60 __raw_writel(USBPHY_SESNDEN | USBPHY_VBDTCTEN | USBPHY_PHYPLLON, 63
61 (void __force __iomem *) IO_ADDRESS(USBPHY_CTL_PADDR)); 64 /* power everything up; start the on-chip PHY and its PLL */
62 while ((__raw_readl((void __force __iomem *) 65 phy_ctrl &= ~(USBPHY_OSCPDWN | USBPHY_OTGPDWN | USBPHY_PHYPDWN);
63 IO_ADDRESS(USBPHY_CTL_PADDR)) 66 phy_ctrl |= USBPHY_SESNDEN | USBPHY_VBDTCTEN | USBPHY_PHYPLLON;
64 & USBPHY_PHYCLKGD) == 0) 67 __raw_writel(phy_ctrl, USB_PHY_CTRL);
68
69 /* wait for PLL to lock before proceeding */
70 while ((__raw_readl(USB_PHY_CTRL) & USBPHY_PHYCLKGD) == 0)
65 cpu_relax(); 71 cpu_relax();
66} 72}
67 73
68static inline void phy_off(void) 74static inline void phy_off(void)
69{ 75{
70 /* powerdown the on-chip PHY and its oscillator */ 76 u32 phy_ctrl = __raw_readl(USB_PHY_CTRL);
71 __raw_writel(USBPHY_OSCPDWN | USBPHY_PHYPDWN, (void __force __iomem *) 77
72 IO_ADDRESS(USBPHY_CTL_PADDR)); 78 /* powerdown the on-chip PHY, its PLL, and the OTG block */
79 phy_ctrl &= ~(USBPHY_SESNDEN | USBPHY_VBDTCTEN | USBPHY_PHYPLLON);
80 phy_ctrl |= USBPHY_OSCPDWN | USBPHY_OTGPDWN | USBPHY_PHYPDWN;
81 __raw_writel(phy_ctrl, USB_PHY_CTRL);
73} 82}
74 83
75static int dma_off = 1; 84static int dma_off = 1;
@@ -126,10 +135,6 @@ void musb_platform_disable(struct musb *musb)
126} 135}
127 136
128 137
129/* REVISIT it's not clear whether DaVinci can support full OTG. */
130
131static int vbus_state = -1;
132
133#ifdef CONFIG_USB_MUSB_HDRC_HCD 138#ifdef CONFIG_USB_MUSB_HDRC_HCD
134#define portstate(stmt) stmt 139#define portstate(stmt) stmt
135#else 140#else
@@ -137,10 +142,19 @@ static int vbus_state = -1;
137#endif 142#endif
138 143
139 144
140/* VBUS SWITCHING IS BOARD-SPECIFIC */ 145/*
146 * VBUS SWITCHING IS BOARD-SPECIFIC ... at least for the DM6446 EVM,
147 * which doesn't wire DRVVBUS to the FET that switches it. Unclear
148 * if that's a problem with the DM6446 chip or just with that board.
149 *
150 * In either case, the DM355 EVM automates DRVVBUS the normal way,
151 * when J10 is out, and TI documents it as handling OTG.
152 */
141 153
142#ifdef CONFIG_MACH_DAVINCI_EVM 154#ifdef CONFIG_MACH_DAVINCI_EVM
143 155
156static int vbus_state = -1;
157
144/* I2C operations are always synchronous, and require a task context. 158/* I2C operations are always synchronous, and require a task context.
145 * With unloaded systems, using the shared workqueue seems to suffice 159 * With unloaded systems, using the shared workqueue seems to suffice
146 * to satisfy the 100msec A_WAIT_VRISE timeout... 160 * to satisfy the 100msec A_WAIT_VRISE timeout...
@@ -150,12 +164,12 @@ static void evm_deferred_drvvbus(struct work_struct *ignored)
150 gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state); 164 gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state);
151 vbus_state = !vbus_state; 165 vbus_state = !vbus_state;
152} 166}
153static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus);
154 167
155#endif /* EVM */ 168#endif /* EVM */
156 169
157static void davinci_source_power(struct musb *musb, int is_on, int immediate) 170static void davinci_source_power(struct musb *musb, int is_on, int immediate)
158{ 171{
172#ifdef CONFIG_MACH_DAVINCI_EVM
159 if (is_on) 173 if (is_on)
160 is_on = 1; 174 is_on = 1;
161 175
@@ -163,16 +177,17 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate)
163 return; 177 return;
164 vbus_state = !is_on; /* 0/1 vs "-1 == unknown/init" */ 178 vbus_state = !is_on; /* 0/1 vs "-1 == unknown/init" */
165 179
166#ifdef CONFIG_MACH_DAVINCI_EVM
167 if (machine_is_davinci_evm()) { 180 if (machine_is_davinci_evm()) {
181 static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus);
182
168 if (immediate) 183 if (immediate)
169 gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state); 184 gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state);
170 else 185 else
171 schedule_work(&evm_vbus_work); 186 schedule_work(&evm_vbus_work);
172 } 187 }
173#endif
174 if (immediate) 188 if (immediate)
175 vbus_state = is_on; 189 vbus_state = is_on;
190#endif
176} 191}
177 192
178static void davinci_set_vbus(struct musb *musb, int is_on) 193static void davinci_set_vbus(struct musb *musb, int is_on)
@@ -391,6 +406,17 @@ int __init musb_platform_init(struct musb *musb)
391 musb->board_set_vbus = davinci_set_vbus; 406 musb->board_set_vbus = davinci_set_vbus;
392 davinci_source_power(musb, 0, 1); 407 davinci_source_power(musb, 0, 1);
393 408
409 /* dm355 EVM swaps D+/D- for signal integrity, and
410 * is clocked from the main 24 MHz crystal.
411 */
412 if (machine_is_davinci_dm355_evm()) {
413 u32 phy_ctrl = __raw_readl(USB_PHY_CTRL);
414
415 phy_ctrl &= ~(3 << 9);
416 phy_ctrl |= USBPHY_DATAPOL;
417 __raw_writel(phy_ctrl, USB_PHY_CTRL);
418 }
419
394 /* reset the controller */ 420 /* reset the controller */
395 musb_writel(tibase, DAVINCI_USB_CTRL_REG, 0x1); 421 musb_writel(tibase, DAVINCI_USB_CTRL_REG, 0x1);
396 422
@@ -401,8 +427,7 @@ int __init musb_platform_init(struct musb *musb)
401 427
402 /* NOTE: irqs are in mixed mode, not bypass to pure-musb */ 428 /* NOTE: irqs are in mixed mode, not bypass to pure-musb */
403 pr_debug("DaVinci OTG revision %08x phy %03x control %02x\n", 429 pr_debug("DaVinci OTG revision %08x phy %03x control %02x\n",
404 revision, __raw_readl((void __force __iomem *) 430 revision, __raw_readl(USB_PHY_CTRL),
405 IO_ADDRESS(USBPHY_CTL_PADDR)),
406 musb_readb(tibase, DAVINCI_USB_CTRL_REG)); 431 musb_readb(tibase, DAVINCI_USB_CTRL_REG));
407 432
408 musb->isr = davinci_interrupt; 433 musb->isr = davinci_interrupt;
diff --git a/drivers/usb/musb/davinci.h b/drivers/usb/musb/davinci.h
index 7fb6238e270f..046c84433cad 100644
--- a/drivers/usb/musb/davinci.h
+++ b/drivers/usb/musb/davinci.h
@@ -15,14 +15,21 @@
15 */ 15 */
16 16
17/* Integrated highspeed/otg PHY */ 17/* Integrated highspeed/otg PHY */
18#define USBPHY_CTL_PADDR (DAVINCI_SYSTEM_MODULE_BASE + 0x34) 18#define USBPHY_CTL_PADDR (DAVINCI_SYSTEM_MODULE_BASE + 0x34)
19#define USBPHY_PHYCLKGD (1 << 8) 19#define USBPHY_DATAPOL BIT(11) /* (dm355) switch D+/D- */
20#define USBPHY_SESNDEN (1 << 7) /* v(sess_end) comparator */ 20#define USBPHY_PHYCLKGD BIT(8)
21#define USBPHY_VBDTCTEN (1 << 6) /* v(bus) comparator */ 21#define USBPHY_SESNDEN BIT(7) /* v(sess_end) comparator */
22#define USBPHY_PHYPLLON (1 << 4) /* override pll suspend */ 22#define USBPHY_VBDTCTEN BIT(6) /* v(bus) comparator */
23#define USBPHY_CLKO1SEL (1 << 3) 23#define USBPHY_VBUSSENS BIT(5) /* (dm355,ro) is vbus > 0.5V */
24#define USBPHY_OSCPDWN (1 << 2) 24#define USBPHY_PHYPLLON BIT(4) /* override pll suspend */
25#define USBPHY_PHYPDWN (1 << 0) 25#define USBPHY_CLKO1SEL BIT(3)
26#define USBPHY_OSCPDWN BIT(2)
27#define USBPHY_OTGPDWN BIT(1)
28#define USBPHY_PHYPDWN BIT(0)
29
30#define DM355_DEEPSLEEP_PADDR (DAVINCI_SYSTEM_MODULE_BASE + 0x48)
31#define DRVVBUS_FORCE BIT(2)
32#define DRVVBUS_OVERRIDE BIT(1)
26 33
27/* For now include usb OTG module registers here */ 34/* For now include usb OTG module registers here */
28#define DAVINCI_USB_VERSION_REG 0x00 35#define DAVINCI_USB_VERSION_REG 0x00
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index af77e4659006..338cd1611ab3 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -769,7 +769,7 @@ static irqreturn_t musb_stage2_irq(struct musb *musb, u8 int_usb,
769 case OTG_STATE_A_SUSPEND: 769 case OTG_STATE_A_SUSPEND:
770 usb_hcd_resume_root_hub(musb_to_hcd(musb)); 770 usb_hcd_resume_root_hub(musb_to_hcd(musb));
771 musb_root_disconnect(musb); 771 musb_root_disconnect(musb);
772 if (musb->a_wait_bcon != 0) 772 if (musb->a_wait_bcon != 0 && is_otg_enabled(musb))
773 musb_platform_try_idle(musb, jiffies 773 musb_platform_try_idle(musb, jiffies
774 + msecs_to_jiffies(musb->a_wait_bcon)); 774 + msecs_to_jiffies(musb->a_wait_bcon));
775 break; 775 break;
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 630946a2d9fc..efb39b5e55b5 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -331,7 +331,6 @@ struct musb {
331 struct list_head control; /* of musb_qh */ 331 struct list_head control; /* of musb_qh */
332 struct list_head in_bulk; /* of musb_qh */ 332 struct list_head in_bulk; /* of musb_qh */
333 struct list_head out_bulk; /* of musb_qh */ 333 struct list_head out_bulk; /* of musb_qh */
334 struct musb_qh *periodic[32]; /* tree of interrupt+iso */
335#endif 334#endif
336 335
337 /* called with IRQs blocked; ON/nonzero implies starting a session, 336 /* called with IRQs blocked; ON/nonzero implies starting a session,
@@ -479,10 +478,11 @@ static inline void musb_configure_ep0(struct musb *musb)
479static inline int musb_read_fifosize(struct musb *musb, 478static inline int musb_read_fifosize(struct musb *musb,
480 struct musb_hw_ep *hw_ep, u8 epnum) 479 struct musb_hw_ep *hw_ep, u8 epnum)
481{ 480{
481 void *mbase = musb->mregs;
482 u8 reg = 0; 482 u8 reg = 0;
483 483
484 /* read from core using indexed model */ 484 /* read from core using indexed model */
485 reg = musb_readb(hw_ep->regs, 0x10 + MUSB_FIFOSIZE); 485 reg = musb_readb(mbase, MUSB_EP_OFFSET(epnum, MUSB_FIFOSIZE));
486 /* 0's returned when no more endpoints */ 486 /* 0's returned when no more endpoints */
487 if (!reg) 487 if (!reg)
488 return -ENODEV; 488 return -ENODEV;
@@ -509,6 +509,7 @@ static inline void musb_configure_ep0(struct musb *musb)
509{ 509{
510 musb->endpoints[0].max_packet_sz_tx = MUSB_EP0_FIFOSIZE; 510 musb->endpoints[0].max_packet_sz_tx = MUSB_EP0_FIFOSIZE;
511 musb->endpoints[0].max_packet_sz_rx = MUSB_EP0_FIFOSIZE; 511 musb->endpoints[0].max_packet_sz_rx = MUSB_EP0_FIFOSIZE;
512 musb->endpoints[0].is_shared_fifo = true;
512} 513}
513#endif /* CONFIG_BLACKFIN */ 514#endif /* CONFIG_BLACKFIN */
514 515
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 6dbbd0786a6a..499c431a6d62 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -64,11 +64,8 @@
64 * 64 *
65 * - DMA (Mentor/OMAP) ...has at least toggle update problems 65 * - DMA (Mentor/OMAP) ...has at least toggle update problems
66 * 66 *
67 * - Still no traffic scheduling code to make NAKing for bulk or control 67 * - [23-feb-2009] minimal traffic scheduling to avoid bulk RX packet
68 * transfers unable to starve other requests; or to make efficient use 68 * starvation ... nothing yet for TX, interrupt, or bulk.
69 * of hardware with periodic transfers. (Note that network drivers
70 * commonly post bulk reads that stay pending for a long time; these
71 * would make very visible trouble.)
72 * 69 *
73 * - Not tested with HNP, but some SRP paths seem to behave. 70 * - Not tested with HNP, but some SRP paths seem to behave.
74 * 71 *
@@ -88,11 +85,8 @@
88 * 85 *
89 * CONTROL transfers all go through ep0. BULK ones go through dedicated IN 86 * CONTROL transfers all go through ep0. BULK ones go through dedicated IN
90 * and OUT endpoints ... hardware is dedicated for those "async" queue(s). 87 * and OUT endpoints ... hardware is dedicated for those "async" queue(s).
91 *
92 * (Yes, bulk _could_ use more of the endpoints than that, and would even 88 * (Yes, bulk _could_ use more of the endpoints than that, and would even
93 * benefit from it ... one remote device may easily be NAKing while others 89 * benefit from it.)
94 * need to perform transfers in that same direction. The same thing could
95 * be done in software though, assuming dma cooperates.)
96 * 90 *
97 * INTERUPPT and ISOCHRONOUS transfers are scheduled to the other endpoints. 91 * INTERUPPT and ISOCHRONOUS transfers are scheduled to the other endpoints.
98 * So far that scheduling is both dumb and optimistic: the endpoint will be 92 * So far that scheduling is both dumb and optimistic: the endpoint will be
@@ -201,8 +195,9 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh)
201 len = urb->iso_frame_desc[0].length; 195 len = urb->iso_frame_desc[0].length;
202 break; 196 break;
203 default: /* bulk, interrupt */ 197 default: /* bulk, interrupt */
204 buf = urb->transfer_buffer; 198 /* actual_length may be nonzero on retry paths */
205 len = urb->transfer_buffer_length; 199 buf = urb->transfer_buffer + urb->actual_length;
200 len = urb->transfer_buffer_length - urb->actual_length;
206 } 201 }
207 202
208 DBG(4, "qh %p urb %p dev%d ep%d%s%s, hw_ep %d, %p/%d\n", 203 DBG(4, "qh %p urb %p dev%d ep%d%s%s, hw_ep %d, %p/%d\n",
@@ -395,7 +390,6 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
395 * de-allocated if it's tracked and allocated; 390 * de-allocated if it's tracked and allocated;
396 * and where we'd update the schedule tree... 391 * and where we'd update the schedule tree...
397 */ 392 */
398 musb->periodic[ep->epnum] = NULL;
399 kfree(qh); 393 kfree(qh);
400 qh = NULL; 394 qh = NULL;
401 break; 395 break;
@@ -1045,7 +1039,8 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb)
1045 1039
1046 /* NOTE: this code path would be a good place to PAUSE a 1040 /* NOTE: this code path would be a good place to PAUSE a
1047 * control transfer, if another one is queued, so that 1041 * control transfer, if another one is queued, so that
1048 * ep0 is more likely to stay busy. 1042 * ep0 is more likely to stay busy. That's already done
1043 * for bulk RX transfers.
1049 * 1044 *
1050 * if (qh->ring.next != &musb->control), then 1045 * if (qh->ring.next != &musb->control), then
1051 * we have a candidate... NAKing is *NOT* an error 1046 * we have a candidate... NAKing is *NOT* an error
@@ -1197,6 +1192,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
1197 /* NOTE: this code path would be a good place to PAUSE a 1192 /* NOTE: this code path would be a good place to PAUSE a
1198 * transfer, if there's some other (nonperiodic) tx urb 1193 * transfer, if there's some other (nonperiodic) tx urb
1199 * that could use this fifo. (dma complicates it...) 1194 * that could use this fifo. (dma complicates it...)
1195 * That's already done for bulk RX transfers.
1200 * 1196 *
1201 * if (bulk && qh->ring.next != &musb->out_bulk), then 1197 * if (bulk && qh->ring.next != &musb->out_bulk), then
1202 * we have a candidate... NAKing is *NOT* an error 1198 * we have a candidate... NAKing is *NOT* an error
@@ -1358,6 +1354,50 @@ finish:
1358 1354
1359#endif 1355#endif
1360 1356
1357/* Schedule next QH from musb->in_bulk and move the current qh to
1358 * the end; avoids starvation for other endpoints.
1359 */
1360static void musb_bulk_rx_nak_timeout(struct musb *musb, struct musb_hw_ep *ep)
1361{
1362 struct dma_channel *dma;
1363 struct urb *urb;
1364 void __iomem *mbase = musb->mregs;
1365 void __iomem *epio = ep->regs;
1366 struct musb_qh *cur_qh, *next_qh;
1367 u16 rx_csr;
1368
1369 musb_ep_select(mbase, ep->epnum);
1370 dma = is_dma_capable() ? ep->rx_channel : NULL;
1371
1372 /* clear nak timeout bit */
1373 rx_csr = musb_readw(epio, MUSB_RXCSR);
1374 rx_csr |= MUSB_RXCSR_H_WZC_BITS;
1375 rx_csr &= ~MUSB_RXCSR_DATAERROR;
1376 musb_writew(epio, MUSB_RXCSR, rx_csr);
1377
1378 cur_qh = first_qh(&musb->in_bulk);
1379 if (cur_qh) {
1380 urb = next_urb(cur_qh);
1381 if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) {
1382 dma->status = MUSB_DMA_STATUS_CORE_ABORT;
1383 musb->dma_controller->channel_abort(dma);
1384 urb->actual_length += dma->actual_len;
1385 dma->actual_len = 0L;
1386 }
1387 musb_save_toggle(ep, 1, urb);
1388
1389 /* move cur_qh to end of queue */
1390 list_move_tail(&cur_qh->ring, &musb->in_bulk);
1391
1392 /* get the next qh from musb->in_bulk */
1393 next_qh = first_qh(&musb->in_bulk);
1394
1395 /* set rx_reinit and schedule the next qh */
1396 ep->rx_reinit = 1;
1397 musb_start_urb(musb, 1, next_qh);
1398 }
1399}
1400
1361/* 1401/*
1362 * Service an RX interrupt for the given IN endpoint; docs cover bulk, iso, 1402 * Service an RX interrupt for the given IN endpoint; docs cover bulk, iso,
1363 * and high-bandwidth IN transfer cases. 1403 * and high-bandwidth IN transfer cases.
@@ -1421,18 +1461,26 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1421 } else if (rx_csr & MUSB_RXCSR_DATAERROR) { 1461 } else if (rx_csr & MUSB_RXCSR_DATAERROR) {
1422 1462
1423 if (USB_ENDPOINT_XFER_ISOC != qh->type) { 1463 if (USB_ENDPOINT_XFER_ISOC != qh->type) {
1424 /* NOTE this code path would be a good place to PAUSE a 1464 DBG(6, "RX end %d NAK timeout\n", epnum);
1425 * transfer, if there's some other (nonperiodic) rx urb 1465
1426 * that could use this fifo. (dma complicates it...) 1466 /* NOTE: NAKing is *NOT* an error, so we want to
1467 * continue. Except ... if there's a request for
1468 * another QH, use that instead of starving it.
1427 * 1469 *
1428 * if (bulk && qh->ring.next != &musb->in_bulk), then 1470 * Devices like Ethernet and serial adapters keep
1429 * we have a candidate... NAKing is *NOT* an error 1471 * reads posted at all times, which will starve
1472 * other devices without this logic.
1430 */ 1473 */
1431 DBG(6, "RX end %d NAK timeout\n", epnum); 1474 if (usb_pipebulk(urb->pipe)
1475 && qh->mux == 1
1476 && !list_is_singular(&musb->in_bulk)) {
1477 musb_bulk_rx_nak_timeout(musb, hw_ep);
1478 return;
1479 }
1432 musb_ep_select(mbase, epnum); 1480 musb_ep_select(mbase, epnum);
1433 musb_writew(epio, MUSB_RXCSR, 1481 rx_csr |= MUSB_RXCSR_H_WZC_BITS;
1434 MUSB_RXCSR_H_WZC_BITS 1482 rx_csr &= ~MUSB_RXCSR_DATAERROR;
1435 | MUSB_RXCSR_H_REQPKT); 1483 musb_writew(epio, MUSB_RXCSR, rx_csr);
1436 1484
1437 goto finish; 1485 goto finish;
1438 } else { 1486 } else {
@@ -1711,31 +1759,27 @@ static int musb_schedule(
1711 1759
1712 /* else, periodic transfers get muxed to other endpoints */ 1760 /* else, periodic transfers get muxed to other endpoints */
1713 1761
1714 /* FIXME this doesn't consider direction, so it can only 1762 /*
1715 * work for one half of the endpoint hardware, and assumes 1763 * We know this qh hasn't been scheduled, so all we need to do
1716 * the previous cases handled all non-shared endpoints...
1717 */
1718
1719 /* we know this qh hasn't been scheduled, so all we need to do
1720 * is choose which hardware endpoint to put it on ... 1764 * is choose which hardware endpoint to put it on ...
1721 * 1765 *
1722 * REVISIT what we really want here is a regular schedule tree 1766 * REVISIT what we really want here is a regular schedule tree
1723 * like e.g. OHCI uses, but for now musb->periodic is just an 1767 * like e.g. OHCI uses.
1724 * array of the _single_ logical endpoint associated with a
1725 * given physical one (identity mapping logical->physical).
1726 *
1727 * that simplistic approach makes TT scheduling a lot simpler;
1728 * there is none, and thus none of its complexity...
1729 */ 1768 */
1730 best_diff = 4096; 1769 best_diff = 4096;
1731 best_end = -1; 1770 best_end = -1;
1732 1771
1733 for (epnum = 1; epnum < musb->nr_endpoints; epnum++) { 1772 for (epnum = 1, hw_ep = musb->endpoints + 1;
1773 epnum < musb->nr_endpoints;
1774 epnum++, hw_ep++) {
1734 int diff; 1775 int diff;
1735 1776
1736 if (musb->periodic[epnum]) 1777 if (is_in || hw_ep->is_shared_fifo) {
1778 if (hw_ep->in_qh != NULL)
1779 continue;
1780 } else if (hw_ep->out_qh != NULL)
1737 continue; 1781 continue;
1738 hw_ep = &musb->endpoints[epnum]; 1782
1739 if (hw_ep == musb->bulk_ep) 1783 if (hw_ep == musb->bulk_ep)
1740 continue; 1784 continue;
1741 1785
@@ -1756,6 +1800,17 @@ static int musb_schedule(
1756 head = &musb->in_bulk; 1800 head = &musb->in_bulk;
1757 else 1801 else
1758 head = &musb->out_bulk; 1802 head = &musb->out_bulk;
1803
1804 /* Enable bulk RX NAK timeout scheme when bulk requests are
1805 * multiplexed. This scheme doen't work in high speed to full
1806 * speed scenario as NAK interrupts are not coming from a
1807 * full speed device connected to a high speed device.
1808 * NAK timeout interval is 8 (128 uframe or 16ms) for HS and
1809 * 4 (8 frame or 8ms) for FS device.
1810 */
1811 if (is_in && qh->dev)
1812 qh->intv_reg =
1813 (USB_SPEED_HIGH == qh->dev->speed) ? 8 : 4;
1759 goto success; 1814 goto success;
1760 } else if (best_end < 0) { 1815 } else if (best_end < 0) {
1761 return -ENOSPC; 1816 return -ENOSPC;
@@ -1764,7 +1819,6 @@ static int musb_schedule(
1764 idle = 1; 1819 idle = 1;
1765 qh->mux = 0; 1820 qh->mux = 0;
1766 hw_ep = musb->endpoints + best_end; 1821 hw_ep = musb->endpoints + best_end;
1767 musb->periodic[best_end] = qh;
1768 DBG(4, "qh %p periodic slot %d\n", qh, best_end); 1822 DBG(4, "qh %p periodic slot %d\n", qh, best_end);
1769success: 1823success:
1770 if (head) { 1824 if (head) {
@@ -1888,13 +1942,11 @@ static int musb_urb_enqueue(
1888 * 1942 *
1889 * The downside of disabling this is that transfer scheduling 1943 * The downside of disabling this is that transfer scheduling
1890 * gets VERY unfair for nonperiodic transfers; a misbehaving 1944 * gets VERY unfair for nonperiodic transfers; a misbehaving
1891 * peripheral could make that hurt. Or for reads, one that's 1945 * peripheral could make that hurt. That's perfectly normal
1892 * perfectly normal: network and other drivers keep reads 1946 * for reads from network or serial adapters ... so we have
1893 * posted at all times, having one pending for a week should 1947 * partial NAKlimit support for bulk RX.
1894 * be perfectly safe.
1895 * 1948 *
1896 * The upside of disabling it is avoidng transfer scheduling 1949 * The upside of disabling it is simpler transfer scheduling.
1897 * code to put this aside for while.
1898 */ 1950 */
1899 interval = 0; 1951 interval = 0;
1900 } 1952 }
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index e0e9ce584175..bf677acc83db 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -285,7 +285,7 @@ int musb_hub_control(
285 desc->bDescLength = 9; 285 desc->bDescLength = 9;
286 desc->bDescriptorType = 0x29; 286 desc->bDescriptorType = 0x29;
287 desc->bNbrPorts = 1; 287 desc->bNbrPorts = 1;
288 desc->wHubCharacteristics = __constant_cpu_to_le16( 288 desc->wHubCharacteristics = cpu_to_le16(
289 0x0001 /* per-port power switching */ 289 0x0001 /* per-port power switching */
290 | 0x0010 /* no overcurrent reporting */ 290 | 0x0010 /* no overcurrent reporting */
291 ); 291 );
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index ee55b449ffde..aa884d072f0b 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -43,7 +43,7 @@ config ISP1301_OMAP
43 43
44config TWL4030_USB 44config TWL4030_USB
45 tristate "TWL4030 USB Transceiver Driver" 45 tristate "TWL4030 USB Transceiver Driver"
46 depends on TWL4030_CORE 46 depends on TWL4030_CORE && REGULATOR_TWL4030
47 select USB_OTG_UTILS 47 select USB_OTG_UTILS
48 help 48 help
49 Enable this to support the USB OTG transceiver on TWL4030 49 Enable this to support the USB OTG transceiver on TWL4030
@@ -51,4 +51,12 @@ config TWL4030_USB
51 This transceiver supports high and full speed devices plus, 51 This transceiver supports high and full speed devices plus,
52 in host mode, low speed. 52 in host mode, low speed.
53 53
54config NOP_USB_XCEIV
55 tristate "NOP USB Transceiver Driver"
56 select USB_OTG_UTILS
57 help
58 this driver is to be used by all the usb transceiver which are either
59 built-in with usb ip or which are autonomous and doesn't require any
60 phy programming such as ISP1x04 etc.
61
54endif # USB || OTG 62endif # USB || OTG
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index d73c7cf5e2f7..208167856529 100644
--- a/drivers/usb/otg/Makefile
+++ b/drivers/usb/otg/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_OTG_UTILS) += otg.o
9obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o 9obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o
10obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 10obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
11obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o 11obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o
12obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o
12 13
13ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG 14ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG
14ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG 15ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c
index 63a6036f04be..1c26c94513e9 100644
--- a/drivers/usb/otg/gpio_vbus.c
+++ b/drivers/usb/otg/gpio_vbus.c
@@ -13,6 +13,7 @@
13#include <linux/gpio.h> 13#include <linux/gpio.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include <linux/workqueue.h>
16 17
17#include <linux/regulator/consumer.h> 18#include <linux/regulator/consumer.h>
18 19
@@ -34,6 +35,7 @@ struct gpio_vbus_data {
34 struct regulator *vbus_draw; 35 struct regulator *vbus_draw;
35 int vbus_draw_enabled; 36 int vbus_draw_enabled;
36 unsigned mA; 37 unsigned mA;
38 struct work_struct work;
37}; 39};
38 40
39 41
@@ -76,24 +78,26 @@ static void set_vbus_draw(struct gpio_vbus_data *gpio_vbus, unsigned mA)
76 gpio_vbus->mA = mA; 78 gpio_vbus->mA = mA;
77} 79}
78 80
79/* VBUS change IRQ handler */ 81static int is_vbus_powered(struct gpio_vbus_mach_info *pdata)
80static irqreturn_t gpio_vbus_irq(int irq, void *data)
81{ 82{
82 struct platform_device *pdev = data; 83 int vbus;
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 84
87 vbus = gpio_get_value(pdata->gpio_vbus); 85 vbus = gpio_get_value(pdata->gpio_vbus);
88 if (pdata->gpio_vbus_inverted) 86 if (pdata->gpio_vbus_inverted)
89 vbus = !vbus; 87 vbus = !vbus;
90 88
91 dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n", 89 return vbus;
92 vbus ? "supplied" : "inactive", 90}
93 gpio_vbus->otg.gadget ? gpio_vbus->otg.gadget->name : "none"); 91
92static void gpio_vbus_work(struct work_struct *work)
93{
94 struct gpio_vbus_data *gpio_vbus =
95 container_of(work, struct gpio_vbus_data, work);
96 struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data;
97 int gpio;
94 98
95 if (!gpio_vbus->otg.gadget) 99 if (!gpio_vbus->otg.gadget)
96 return IRQ_HANDLED; 100 return;
97 101
98 /* Peripheral controllers which manage the pullup themselves won't have 102 /* Peripheral controllers which manage the pullup themselves won't have
99 * gpio_pullup configured here. If it's configured here, we'll do what 103 * gpio_pullup configured here. If it's configured here, we'll do what
@@ -101,7 +105,7 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data)
101 * that may complicate usb_gadget_{,dis}connect() support. 105 * that may complicate usb_gadget_{,dis}connect() support.
102 */ 106 */
103 gpio = pdata->gpio_pullup; 107 gpio = pdata->gpio_pullup;
104 if (vbus) { 108 if (is_vbus_powered(pdata)) {
105 gpio_vbus->otg.state = OTG_STATE_B_PERIPHERAL; 109 gpio_vbus->otg.state = OTG_STATE_B_PERIPHERAL;
106 usb_gadget_vbus_connect(gpio_vbus->otg.gadget); 110 usb_gadget_vbus_connect(gpio_vbus->otg.gadget);
107 111
@@ -121,6 +125,21 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data)
121 usb_gadget_vbus_disconnect(gpio_vbus->otg.gadget); 125 usb_gadget_vbus_disconnect(gpio_vbus->otg.gadget);
122 gpio_vbus->otg.state = OTG_STATE_B_IDLE; 126 gpio_vbus->otg.state = OTG_STATE_B_IDLE;
123 } 127 }
128}
129
130/* VBUS change IRQ handler */
131static irqreturn_t gpio_vbus_irq(int irq, void *data)
132{
133 struct platform_device *pdev = data;
134 struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data;
135 struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev);
136
137 dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n",
138 is_vbus_powered(pdata) ? "supplied" : "inactive",
139 gpio_vbus->otg.gadget ? gpio_vbus->otg.gadget->name : "none");
140
141 if (gpio_vbus->otg.gadget)
142 schedule_work(&gpio_vbus->work);
124 143
125 return IRQ_HANDLED; 144 return IRQ_HANDLED;
126} 145}
@@ -257,6 +276,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
257 irq, err); 276 irq, err);
258 goto err_irq; 277 goto err_irq;
259 } 278 }
279 INIT_WORK(&gpio_vbus->work, gpio_vbus_work);
260 280
261 /* only active when a gadget is registered */ 281 /* only active when a gadget is registered */
262 err = otg_set_transceiver(&gpio_vbus->otg); 282 err = otg_set_transceiver(&gpio_vbus->otg);
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
new file mode 100644
index 000000000000..4b933f646f2e
--- /dev/null
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -0,0 +1,180 @@
1/*
2 * drivers/usb/otg/nop-usb-xceiv.c
3 *
4 * NOP USB transceiver for all USB transceiver which are either built-in
5 * into USB IP or which are mostly autonomous.
6 *
7 * Copyright (C) 2009 Texas Instruments Inc
8 * Author: Ajay Kumar Gupta <ajay.gupta@ti.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * Current status:
25 * this is to add "nop" transceiver for all those phy which is
26 * autonomous such as isp1504 etc.
27 */
28
29#include <linux/module.h>
30#include <linux/platform_device.h>
31#include <linux/dma-mapping.h>
32#include <linux/usb/otg.h>
33
34struct nop_usb_xceiv {
35 struct otg_transceiver otg;
36 struct device *dev;
37};
38
39static u64 nop_xceiv_dmamask = DMA_32BIT_MASK;
40
41static struct platform_device nop_xceiv_device = {
42 .name = "nop_usb_xceiv",
43 .id = -1,
44 .dev = {
45 .dma_mask = &nop_xceiv_dmamask,
46 .coherent_dma_mask = DMA_32BIT_MASK,
47 .platform_data = NULL,
48 },
49};
50
51void usb_nop_xceiv_register(void)
52{
53 if (platform_device_register(&nop_xceiv_device) < 0) {
54 printk(KERN_ERR "Unable to register usb nop transceiver\n");
55 return;
56 }
57}
58
59void usb_nop_xceiv_unregister(void)
60{
61 platform_device_unregister(&nop_xceiv_device);
62}
63
64static inline struct nop_usb_xceiv *xceiv_to_nop(struct otg_transceiver *x)
65{
66 return container_of(x, struct nop_usb_xceiv, otg);
67}
68
69static int nop_set_suspend(struct otg_transceiver *x, int suspend)
70{
71 return 0;
72}
73
74static int nop_set_peripheral(struct otg_transceiver *x,
75 struct usb_gadget *gadget)
76{
77 struct nop_usb_xceiv *nop;
78
79 if (!x)
80 return -ENODEV;
81
82 nop = xceiv_to_nop(x);
83
84 if (!gadget) {
85 nop->otg.gadget = NULL;
86 return -ENODEV;
87 }
88
89 nop->otg.gadget = gadget;
90 nop->otg.state = OTG_STATE_B_IDLE;
91 return 0;
92}
93
94static int nop_set_host(struct otg_transceiver *x, struct usb_bus *host)
95{
96 struct nop_usb_xceiv *nop;
97
98 if (!x)
99 return -ENODEV;
100
101 nop = xceiv_to_nop(x);
102
103 if (!host) {
104 nop->otg.host = NULL;
105 return -ENODEV;
106 }
107
108 nop->otg.host = host;
109 return 0;
110}
111
112static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
113{
114 struct nop_usb_xceiv *nop;
115 int err;
116
117 nop = kzalloc(sizeof *nop, GFP_KERNEL);
118 if (!nop)
119 return -ENOMEM;
120
121 nop->dev = &pdev->dev;
122 nop->otg.dev = nop->dev;
123 nop->otg.label = "nop-xceiv";
124 nop->otg.state = OTG_STATE_UNDEFINED;
125 nop->otg.set_host = nop_set_host;
126 nop->otg.set_peripheral = nop_set_peripheral;
127 nop->otg.set_suspend = nop_set_suspend;
128
129 err = otg_set_transceiver(&nop->otg);
130 if (err) {
131 dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
132 err);
133 goto exit;
134 }
135
136 platform_set_drvdata(pdev, nop);
137
138 return 0;
139exit:
140 kfree(nop);
141 return err;
142}
143
144static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev)
145{
146 struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);
147
148 otg_set_transceiver(NULL);
149
150 platform_set_drvdata(pdev, NULL);
151 kfree(nop);
152
153 return 0;
154}
155
156static struct platform_driver nop_usb_xceiv_driver = {
157 .probe = nop_usb_xceiv_probe,
158 .remove = __devexit_p(nop_usb_xceiv_remove),
159 .driver = {
160 .name = "nop_usb_xceiv",
161 .owner = THIS_MODULE,
162 },
163};
164
165static int __init nop_usb_xceiv_init(void)
166{
167 return platform_driver_register(&nop_usb_xceiv_driver);
168}
169subsys_initcall(nop_usb_xceiv_init);
170
171static void __exit nop_usb_xceiv_exit(void)
172{
173 platform_driver_unregister(&nop_usb_xceiv_driver);
174}
175module_exit(nop_usb_xceiv_exit);
176
177MODULE_ALIAS("platform:nop_usb_xceiv");
178MODULE_AUTHOR("Texas Instruments Inc");
179MODULE_DESCRIPTION("NOP USB Transceiver driver");
180MODULE_LICENSE("GPL");
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index 416e4410be02..d9478d0e1c8b 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -34,6 +34,8 @@
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/usb/otg.h> 35#include <linux/usb/otg.h>
36#include <linux/i2c/twl4030.h> 36#include <linux/i2c/twl4030.h>
37#include <linux/regulator/consumer.h>
38#include <linux/err.h>
37 39
38 40
39/* Register defines */ 41/* Register defines */
@@ -246,6 +248,11 @@ struct twl4030_usb {
246 struct otg_transceiver otg; 248 struct otg_transceiver otg;
247 struct device *dev; 249 struct device *dev;
248 250
251 /* TWL4030 internal USB regulator supplies */
252 struct regulator *usb1v5;
253 struct regulator *usb1v8;
254 struct regulator *usb3v1;
255
249 /* for vbus reporting with irqs disabled */ 256 /* for vbus reporting with irqs disabled */
250 spinlock_t lock; 257 spinlock_t lock;
251 258
@@ -434,6 +441,18 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on)
434 441
435 pwr = twl4030_usb_read(twl, PHY_PWR_CTRL); 442 pwr = twl4030_usb_read(twl, PHY_PWR_CTRL);
436 if (on) { 443 if (on) {
444 regulator_enable(twl->usb3v1);
445 regulator_enable(twl->usb1v8);
446 /*
447 * Disabling usb3v1 regulator (= writing 0 to VUSB3V1_DEV_GRP
448 * in twl4030) resets the VUSB_DEDICATED2 register. This reset
449 * enables VUSB3V1_SLEEP bit that remaps usb3v1 ACTIVE state to
450 * SLEEP. We work around this by clearing the bit after usv3v1
451 * is re-activated. This ensures that VUSB3V1 is really active.
452 */
453 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0,
454 VUSB_DEDICATED2);
455 regulator_enable(twl->usb1v5);
437 pwr &= ~PHY_PWR_PHYPWD; 456 pwr &= ~PHY_PWR_PHYPWD;
438 WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0); 457 WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0);
439 twl4030_usb_write(twl, PHY_CLK_CTRL, 458 twl4030_usb_write(twl, PHY_CLK_CTRL,
@@ -443,6 +462,9 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on)
443 } else { 462 } else {
444 pwr |= PHY_PWR_PHYPWD; 463 pwr |= PHY_PWR_PHYPWD;
445 WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0); 464 WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0);
465 regulator_disable(twl->usb1v5);
466 regulator_disable(twl->usb1v8);
467 regulator_disable(twl->usb3v1);
446 } 468 }
447} 469}
448 470
@@ -468,7 +490,7 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
468 twl->asleep = 0; 490 twl->asleep = 0;
469} 491}
470 492
471static void twl4030_usb_ldo_init(struct twl4030_usb *twl) 493static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
472{ 494{
473 /* Enable writing to power configuration registers */ 495 /* Enable writing to power configuration registers */
474 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0xC0, PROTECT_KEY); 496 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0xC0, PROTECT_KEY);
@@ -480,20 +502,45 @@ static void twl4030_usb_ldo_init(struct twl4030_usb *twl)
480 /* input to VUSB3V1 LDO is from VBAT, not VBUS */ 502 /* input to VUSB3V1 LDO is from VBAT, not VBUS */
481 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); 503 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1);
482 504
483 /* turn on 3.1V regulator */ 505 /* Initialize 3.1V regulator */
484 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x20, VUSB3V1_DEV_GRP); 506 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP);
507
508 twl->usb3v1 = regulator_get(twl->dev, "usb3v1");
509 if (IS_ERR(twl->usb3v1))
510 return -ENODEV;
511
485 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE); 512 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE);
486 513
487 /* turn on 1.5V regulator */ 514 /* Initialize 1.5V regulator */
488 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x20, VUSB1V5_DEV_GRP); 515 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP);
516
517 twl->usb1v5 = regulator_get(twl->dev, "usb1v5");
518 if (IS_ERR(twl->usb1v5))
519 goto fail1;
520
489 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE); 521 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE);
490 522
491 /* turn on 1.8V regulator */ 523 /* Initialize 1.8V regulator */
492 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x20, VUSB1V8_DEV_GRP); 524 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP);
525
526 twl->usb1v8 = regulator_get(twl->dev, "usb1v8");
527 if (IS_ERR(twl->usb1v8))
528 goto fail2;
529
493 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE); 530 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE);
494 531
495 /* disable access to power configuration registers */ 532 /* disable access to power configuration registers */
496 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, PROTECT_KEY); 533 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, PROTECT_KEY);
534
535 return 0;
536
537fail2:
538 regulator_put(twl->usb1v5);
539 twl->usb1v5 = NULL;
540fail1:
541 regulator_put(twl->usb3v1);
542 twl->usb3v1 = NULL;
543 return -ENODEV;
497} 544}
498 545
499static ssize_t twl4030_usb_vbus_show(struct device *dev, 546static ssize_t twl4030_usb_vbus_show(struct device *dev,
@@ -598,7 +645,7 @@ static int __init twl4030_usb_probe(struct platform_device *pdev)
598{ 645{
599 struct twl4030_usb_data *pdata = pdev->dev.platform_data; 646 struct twl4030_usb_data *pdata = pdev->dev.platform_data;
600 struct twl4030_usb *twl; 647 struct twl4030_usb *twl;
601 int status; 648 int status, err;
602 649
603 if (!pdata) { 650 if (!pdata) {
604 dev_dbg(&pdev->dev, "platform_data not available\n"); 651 dev_dbg(&pdev->dev, "platform_data not available\n");
@@ -622,7 +669,12 @@ static int __init twl4030_usb_probe(struct platform_device *pdev)
622 /* init spinlock for workqueue */ 669 /* init spinlock for workqueue */
623 spin_lock_init(&twl->lock); 670 spin_lock_init(&twl->lock);
624 671
625 twl4030_usb_ldo_init(twl); 672 err = twl4030_usb_ldo_init(twl);
673 if (err) {
674 dev_err(&pdev->dev, "ldo init failed\n");
675 kfree(twl);
676 return err;
677 }
626 otg_set_transceiver(&twl->otg); 678 otg_set_transceiver(&twl->otg);
627 679
628 platform_set_drvdata(pdev, twl); 680 platform_set_drvdata(pdev, twl);
@@ -688,6 +740,9 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev)
688 twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); 740 twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);
689 741
690 twl4030_phy_power(twl, 0); 742 twl4030_phy_power(twl, 0);
743 regulator_put(twl->usb1v5);
744 regulator_put(twl->usb1v8);
745 regulator_put(twl->usb3v1);
691 746
692 kfree(twl); 747 kfree(twl);
693 748
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index b361f05cafac..a65f9196b0a0 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -116,14 +116,14 @@ config USB_SERIAL_DIGI_ACCELEPORT
116 To compile this driver as a module, choose M here: the 116 To compile this driver as a module, choose M here: the
117 module will be called digi_acceleport. 117 module will be called digi_acceleport.
118 118
119config USB_SERIAL_CP2101 119config USB_SERIAL_CP210X
120 tristate "USB CP2101 UART Bridge Controller" 120 tristate "USB CP210x family of UART Bridge Controllers"
121 help 121 help
122 Say Y here if you want to use a CP2101/CP2102 based USB to RS232 122 Say Y here if you want to use a CP2101/CP2102/CP2103 based USB
123 converter. 123 to RS232 converters.
124 124
125 To compile this driver as a module, choose M here: the 125 To compile this driver as a module, choose M here: the
126 module will be called cp2101. 126 module will be called cp210x.
127 127
128config USB_SERIAL_CYPRESS_M8 128config USB_SERIAL_CYPRESS_M8
129 tristate "USB Cypress M8 USB Serial Driver" 129 tristate "USB Cypress M8 USB Serial Driver"
@@ -472,6 +472,15 @@ config USB_SERIAL_OTI6858
472 To compile this driver as a module, choose M here: the 472 To compile this driver as a module, choose M here: the
473 module will be called oti6858. 473 module will be called oti6858.
474 474
475config USB_SERIAL_QUALCOMM
476 tristate "USB Qualcomm Serial modem"
477 help
478 Say Y here if you have a Qualcomm USB modem device. These are
479 usually wireless cellular modems.
480
481 To compile this driver as a module, choose M here: the
482 module will be called qcserial.
483
475config USB_SERIAL_SPCP8X5 484config USB_SERIAL_SPCP8X5
476 tristate "USB SPCP8x5 USB To Serial Driver" 485 tristate "USB SPCP8x5 USB To Serial Driver"
477 help 486 help
@@ -515,6 +524,15 @@ config USB_SERIAL_SIERRAWIRELESS
515 To compile this driver as a module, choose M here: the 524 To compile this driver as a module, choose M here: the
516 module will be called sierra. 525 module will be called sierra.
517 526
527config USB_SERIAL_SYMBOL
528 tristate "USB Symbol Barcode driver (serial mode)"
529 help
530 Say Y here if you want to use a Symbol USB Barcode device
531 in serial emulation mode.
532
533 To compile this driver as a module, choose M here: the
534 module will be called symbolserial.
535
518config USB_SERIAL_TI 536config USB_SERIAL_TI
519 tristate "USB TI 3410/5052 Serial Driver" 537 tristate "USB TI 3410/5052 Serial Driver"
520 help 538 help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index b75be91eb8f1..66619beb6cc0 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o
15obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o 15obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o
16obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o 16obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
17obj-$(CONFIG_USB_SERIAL_CH341) += ch341.o 17obj-$(CONFIG_USB_SERIAL_CH341) += ch341.o
18obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o 18obj-$(CONFIG_USB_SERIAL_CP210X) += cp210x.o
19obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o 19obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o
20obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o 20obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o
21obj-$(CONFIG_USB_SERIAL_DEBUG) += usb_debug.o 21obj-$(CONFIG_USB_SERIAL_DEBUG) += usb_debug.o
@@ -45,10 +45,12 @@ obj-$(CONFIG_USB_SERIAL_OPTICON) += opticon.o
45obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 45obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
46obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o 46obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o
47obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 47obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
48obj-$(CONFIG_USB_SERIAL_QUALCOMM) += qcserial.o
48obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 49obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
49obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o 50obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o
50obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o 51obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o
51obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o 52obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o
53obj-$(CONFIG_USB_SERIAL_SYMBOL) += symbolserial.o
52obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o 54obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
53obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o 55obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o
54obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o 56obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index f61e3ca64305..ab4cc277aa65 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -1,5 +1,7 @@
1/* 1/*
2 * Copyright 2007, Frank A Kingswood <frank@kingswood-consulting.co.uk> 2 * Copyright 2007, Frank A Kingswood <frank@kingswood-consulting.co.uk>
3 * Copyright 2007, Werner Cornelius <werner@cornelius-consult.de>
4 * Copyright 2009, Boris Hajduk <boris@hajduk.org>
3 * 5 *
4 * ch341.c implements a serial port driver for the Winchiphead CH341. 6 * ch341.c implements a serial port driver for the Winchiphead CH341.
5 * 7 *
@@ -21,9 +23,39 @@
21#include <linux/usb/serial.h> 23#include <linux/usb/serial.h>
22#include <linux/serial.h> 24#include <linux/serial.h>
23 25
24#define DEFAULT_BAUD_RATE 2400 26#define DEFAULT_BAUD_RATE 9600
25#define DEFAULT_TIMEOUT 1000 27#define DEFAULT_TIMEOUT 1000
26 28
29/* flags for IO-Bits */
30#define CH341_BIT_RTS (1 << 6)
31#define CH341_BIT_DTR (1 << 5)
32
33/******************************/
34/* interrupt pipe definitions */
35/******************************/
36/* always 4 interrupt bytes */
37/* first irq byte normally 0x08 */
38/* second irq byte base 0x7d + below */
39/* third irq byte base 0x94 + below */
40/* fourth irq byte normally 0xee */
41
42/* second interrupt byte */
43#define CH341_MULT_STAT 0x04 /* multiple status since last interrupt event */
44
45/* status returned in third interrupt answer byte, inverted in data
46 from irq */
47#define CH341_BIT_CTS 0x01
48#define CH341_BIT_DSR 0x02
49#define CH341_BIT_RI 0x04
50#define CH341_BIT_DCD 0x08
51#define CH341_BITS_MODEM_STAT 0x0f /* all bits */
52
53/*******************************/
54/* baudrate calculation factor */
55/*******************************/
56#define CH341_BAUDBASE_FACTOR 1532620800
57#define CH341_BAUDBASE_DIVMAX 3
58
27static int debug; 59static int debug;
28 60
29static struct usb_device_id id_table [] = { 61static struct usb_device_id id_table [] = {
@@ -34,9 +66,12 @@ static struct usb_device_id id_table [] = {
34MODULE_DEVICE_TABLE(usb, id_table); 66MODULE_DEVICE_TABLE(usb, id_table);
35 67
36struct ch341_private { 68struct ch341_private {
37 unsigned baud_rate; 69 spinlock_t lock; /* access lock */
38 u8 dtr; 70 wait_queue_head_t delta_msr_wait; /* wait queue for modem status */
39 u8 rts; 71 unsigned baud_rate; /* set baud rate */
72 u8 line_control; /* set line control value RTS/DTR */
73 u8 line_status; /* active status of modem control inputs */
74 u8 multi_status_change; /* status changed multiple since last call */
40}; 75};
41 76
42static int ch341_control_out(struct usb_device *dev, u8 request, 77static int ch341_control_out(struct usb_device *dev, u8 request,
@@ -72,37 +107,28 @@ static int ch341_set_baudrate(struct usb_device *dev,
72{ 107{
73 short a, b; 108 short a, b;
74 int r; 109 int r;
110 unsigned long factor;
111 short divisor;
75 112
76 dbg("ch341_set_baudrate(%d)", priv->baud_rate); 113 dbg("ch341_set_baudrate(%d)", priv->baud_rate);
77 switch (priv->baud_rate) { 114
78 case 2400: 115 if (!priv->baud_rate)
79 a = 0xd901;
80 b = 0x0038;
81 break;
82 case 4800:
83 a = 0x6402;
84 b = 0x001f;
85 break;
86 case 9600:
87 a = 0xb202;
88 b = 0x0013;
89 break;
90 case 19200:
91 a = 0xd902;
92 b = 0x000d;
93 break;
94 case 38400:
95 a = 0x6403;
96 b = 0x000a;
97 break;
98 case 115200:
99 a = 0xcc03;
100 b = 0x0008;
101 break;
102 default:
103 return -EINVAL; 116 return -EINVAL;
117 factor = (CH341_BAUDBASE_FACTOR / priv->baud_rate);
118 divisor = CH341_BAUDBASE_DIVMAX;
119
120 while ((factor > 0xfff0) && divisor) {
121 factor >>= 3;
122 divisor--;
104 } 123 }
105 124
125 if (factor > 0xfff0)
126 return -EINVAL;
127
128 factor = 0x10000 - factor;
129 a = (factor & 0xff00) | divisor;
130 b = factor & 0xff;
131
106 r = ch341_control_out(dev, 0x9a, 0x1312, a); 132 r = ch341_control_out(dev, 0x9a, 0x1312, a);
107 if (!r) 133 if (!r)
108 r = ch341_control_out(dev, 0x9a, 0x0f2c, b); 134 r = ch341_control_out(dev, 0x9a, 0x0f2c, b);
@@ -110,19 +136,18 @@ static int ch341_set_baudrate(struct usb_device *dev,
110 return r; 136 return r;
111} 137}
112 138
113static int ch341_set_handshake(struct usb_device *dev, 139static int ch341_set_handshake(struct usb_device *dev, u8 control)
114 struct ch341_private *priv)
115{ 140{
116 dbg("ch341_set_handshake(%d,%d)", priv->dtr, priv->rts); 141 dbg("ch341_set_handshake(0x%02x)", control);
117 return ch341_control_out(dev, 0xa4, 142 return ch341_control_out(dev, 0xa4, ~control, 0);
118 ~((priv->dtr?1<<5:0)|(priv->rts?1<<6:0)), 0);
119} 143}
120 144
121static int ch341_get_status(struct usb_device *dev) 145static int ch341_get_status(struct usb_device *dev, struct ch341_private *priv)
122{ 146{
123 char *buffer; 147 char *buffer;
124 int r; 148 int r;
125 const unsigned size = 8; 149 const unsigned size = 8;
150 unsigned long flags;
126 151
127 dbg("ch341_get_status()"); 152 dbg("ch341_get_status()");
128 153
@@ -134,10 +159,15 @@ static int ch341_get_status(struct usb_device *dev)
134 if (r < 0) 159 if (r < 0)
135 goto out; 160 goto out;
136 161
137 /* Not having the datasheet for the CH341, we ignore the bytes returned 162 /* setup the private status if available */
138 * from the device. Return error if the device did not respond in time. 163 if (r == 2) {
139 */ 164 r = 0;
140 r = 0; 165 spin_lock_irqsave(&priv->lock, flags);
166 priv->line_status = (~(*buffer)) & CH341_BITS_MODEM_STAT;
167 priv->multi_status_change = 0;
168 spin_unlock_irqrestore(&priv->lock, flags);
169 } else
170 r = -EPROTO;
141 171
142out: kfree(buffer); 172out: kfree(buffer);
143 return r; 173 return r;
@@ -180,7 +210,7 @@ static int ch341_configure(struct usb_device *dev, struct ch341_private *priv)
180 goto out; 210 goto out;
181 211
182 /* expect 0xff 0xee */ 212 /* expect 0xff 0xee */
183 r = ch341_get_status(dev); 213 r = ch341_get_status(dev, priv);
184 if (r < 0) 214 if (r < 0)
185 goto out; 215 goto out;
186 216
@@ -192,12 +222,12 @@ static int ch341_configure(struct usb_device *dev, struct ch341_private *priv)
192 if (r < 0) 222 if (r < 0)
193 goto out; 223 goto out;
194 224
195 r = ch341_set_handshake(dev, priv); 225 r = ch341_set_handshake(dev, priv->line_control);
196 if (r < 0) 226 if (r < 0)
197 goto out; 227 goto out;
198 228
199 /* expect 0x9f 0xee */ 229 /* expect 0x9f 0xee */
200 r = ch341_get_status(dev); 230 r = ch341_get_status(dev, priv);
201 231
202out: kfree(buffer); 232out: kfree(buffer);
203 return r; 233 return r;
@@ -216,9 +246,10 @@ static int ch341_attach(struct usb_serial *serial)
216 if (!priv) 246 if (!priv)
217 return -ENOMEM; 247 return -ENOMEM;
218 248
249 spin_lock_init(&priv->lock);
250 init_waitqueue_head(&priv->delta_msr_wait);
219 priv->baud_rate = DEFAULT_BAUD_RATE; 251 priv->baud_rate = DEFAULT_BAUD_RATE;
220 priv->dtr = 1; 252 priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR;
221 priv->rts = 1;
222 253
223 r = ch341_configure(serial->dev, priv); 254 r = ch341_configure(serial->dev, priv);
224 if (r < 0) 255 if (r < 0)
@@ -231,6 +262,35 @@ error: kfree(priv);
231 return r; 262 return r;
232} 263}
233 264
265static void ch341_close(struct tty_struct *tty, struct usb_serial_port *port,
266 struct file *filp)
267{
268 struct ch341_private *priv = usb_get_serial_port_data(port);
269 unsigned long flags;
270 unsigned int c_cflag;
271
272 dbg("%s - port %d", __func__, port->number);
273
274 /* shutdown our urbs */
275 dbg("%s - shutting down urbs", __func__);
276 usb_kill_urb(port->write_urb);
277 usb_kill_urb(port->read_urb);
278 usb_kill_urb(port->interrupt_in_urb);
279
280 if (tty) {
281 c_cflag = tty->termios->c_cflag;
282 if (c_cflag & HUPCL) {
283 /* drop DTR and RTS */
284 spin_lock_irqsave(&priv->lock, flags);
285 priv->line_control = 0;
286 spin_unlock_irqrestore(&priv->lock, flags);
287 ch341_set_handshake(port->serial->dev, 0);
288 }
289 }
290 wake_up_interruptible(&priv->delta_msr_wait);
291}
292
293
234/* open this device, set default parameters */ 294/* open this device, set default parameters */
235static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port, 295static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port,
236 struct file *filp) 296 struct file *filp)
@@ -242,14 +302,13 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port,
242 dbg("ch341_open()"); 302 dbg("ch341_open()");
243 303
244 priv->baud_rate = DEFAULT_BAUD_RATE; 304 priv->baud_rate = DEFAULT_BAUD_RATE;
245 priv->dtr = 1; 305 priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR;
246 priv->rts = 1;
247 306
248 r = ch341_configure(serial->dev, priv); 307 r = ch341_configure(serial->dev, priv);
249 if (r) 308 if (r)
250 goto out; 309 goto out;
251 310
252 r = ch341_set_handshake(serial->dev, priv); 311 r = ch341_set_handshake(serial->dev, priv->line_control);
253 if (r) 312 if (r)
254 goto out; 313 goto out;
255 314
@@ -257,6 +316,16 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port,
257 if (r) 316 if (r)
258 goto out; 317 goto out;
259 318
319 dbg("%s - submitting interrupt urb", __func__);
320 port->interrupt_in_urb->dev = serial->dev;
321 r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
322 if (r) {
323 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
324 " error %d\n", __func__, r);
325 ch341_close(tty, port, NULL);
326 return -EPROTO;
327 }
328
260 r = usb_serial_generic_open(tty, port, filp); 329 r = usb_serial_generic_open(tty, port, filp);
261 330
262out: return r; 331out: return r;
@@ -270,46 +339,224 @@ static void ch341_set_termios(struct tty_struct *tty,
270{ 339{
271 struct ch341_private *priv = usb_get_serial_port_data(port); 340 struct ch341_private *priv = usb_get_serial_port_data(port);
272 unsigned baud_rate; 341 unsigned baud_rate;
342 unsigned long flags;
273 343
274 dbg("ch341_set_termios()"); 344 dbg("ch341_set_termios()");
275 345
346 if (!tty || !tty->termios)
347 return;
348
276 baud_rate = tty_get_baud_rate(tty); 349 baud_rate = tty_get_baud_rate(tty);
277 350
278 switch (baud_rate) { 351 priv->baud_rate = baud_rate;
279 case 2400: 352
280 case 4800: 353 if (baud_rate) {
281 case 9600: 354 spin_lock_irqsave(&priv->lock, flags);
282 case 19200: 355 priv->line_control |= (CH341_BIT_DTR | CH341_BIT_RTS);
283 case 38400: 356 spin_unlock_irqrestore(&priv->lock, flags);
284 case 115200: 357 ch341_set_baudrate(port->serial->dev, priv);
285 priv->baud_rate = baud_rate; 358 } else {
286 break; 359 spin_lock_irqsave(&priv->lock, flags);
287 default: 360 priv->line_control &= ~(CH341_BIT_DTR | CH341_BIT_RTS);
288 dbg("Rate %d not supported, using %d", 361 spin_unlock_irqrestore(&priv->lock, flags);
289 baud_rate, DEFAULT_BAUD_RATE);
290 priv->baud_rate = DEFAULT_BAUD_RATE;
291 } 362 }
292 363
293 ch341_set_baudrate(port->serial->dev, priv); 364 ch341_set_handshake(port->serial->dev, priv->line_control);
294 365
295 /* Unimplemented: 366 /* Unimplemented:
296 * (cflag & CSIZE) : data bits [5, 8] 367 * (cflag & CSIZE) : data bits [5, 8]
297 * (cflag & PARENB) : parity {NONE, EVEN, ODD} 368 * (cflag & PARENB) : parity {NONE, EVEN, ODD}
298 * (cflag & CSTOPB) : stop bits [1, 2] 369 * (cflag & CSTOPB) : stop bits [1, 2]
299 */ 370 */
371}
372
373static int ch341_tiocmset(struct tty_struct *tty, struct file *file,
374 unsigned int set, unsigned int clear)
375{
376 struct usb_serial_port *port = tty->driver_data;
377 struct ch341_private *priv = usb_get_serial_port_data(port);
378 unsigned long flags;
379 u8 control;
380
381 spin_lock_irqsave(&priv->lock, flags);
382 if (set & TIOCM_RTS)
383 priv->line_control |= CH341_BIT_RTS;
384 if (set & TIOCM_DTR)
385 priv->line_control |= CH341_BIT_DTR;
386 if (clear & TIOCM_RTS)
387 priv->line_control &= ~CH341_BIT_RTS;
388 if (clear & TIOCM_DTR)
389 priv->line_control &= ~CH341_BIT_DTR;
390 control = priv->line_control;
391 spin_unlock_irqrestore(&priv->lock, flags);
392
393 return ch341_set_handshake(port->serial->dev, control);
394}
395
396static void ch341_read_int_callback(struct urb *urb)
397{
398 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
399 unsigned char *data = urb->transfer_buffer;
400 unsigned int actual_length = urb->actual_length;
401 int status;
402
403 dbg("%s (%d)", __func__, port->number);
404
405 switch (urb->status) {
406 case 0:
407 /* success */
408 break;
409 case -ECONNRESET:
410 case -ENOENT:
411 case -ESHUTDOWN:
412 /* this urb is terminated, clean up */
413 dbg("%s - urb shutting down with status: %d", __func__,
414 urb->status);
415 return;
416 default:
417 dbg("%s - nonzero urb status received: %d", __func__,
418 urb->status);
419 goto exit;
420 }
300 421
301 /* Copy back the old hardware settings */ 422 usb_serial_debug_data(debug, &port->dev, __func__,
302 tty_termios_copy_hw(tty->termios, old_termios); 423 urb->actual_length, urb->transfer_buffer);
303 /* And re-encode with the new baud */ 424
304 tty_encode_baud_rate(tty, baud_rate, baud_rate); 425 if (actual_length >= 4) {
426 struct ch341_private *priv = usb_get_serial_port_data(port);
427 unsigned long flags;
428
429 spin_lock_irqsave(&priv->lock, flags);
430 priv->line_status = (~(data[2])) & CH341_BITS_MODEM_STAT;
431 if ((data[1] & CH341_MULT_STAT))
432 priv->multi_status_change = 1;
433 spin_unlock_irqrestore(&priv->lock, flags);
434 wake_up_interruptible(&priv->delta_msr_wait);
435 }
436
437exit:
438 status = usb_submit_urb(urb, GFP_ATOMIC);
439 if (status)
440 dev_err(&urb->dev->dev,
441 "%s - usb_submit_urb failed with result %d\n",
442 __func__, status);
443}
444
445static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
446{
447 struct ch341_private *priv = usb_get_serial_port_data(port);
448 unsigned long flags;
449 u8 prevstatus;
450 u8 status;
451 u8 changed;
452 u8 multi_change = 0;
453
454 spin_lock_irqsave(&priv->lock, flags);
455 prevstatus = priv->line_status;
456 priv->multi_status_change = 0;
457 spin_unlock_irqrestore(&priv->lock, flags);
458
459 while (!multi_change) {
460 interruptible_sleep_on(&priv->delta_msr_wait);
461 /* see if a signal did it */
462 if (signal_pending(current))
463 return -ERESTARTSYS;
464
465 spin_lock_irqsave(&priv->lock, flags);
466 status = priv->line_status;
467 multi_change = priv->multi_status_change;
468 spin_unlock_irqrestore(&priv->lock, flags);
469
470 changed = prevstatus ^ status;
471
472 if (((arg & TIOCM_RNG) && (changed & CH341_BIT_RI)) ||
473 ((arg & TIOCM_DSR) && (changed & CH341_BIT_DSR)) ||
474 ((arg & TIOCM_CD) && (changed & CH341_BIT_DCD)) ||
475 ((arg & TIOCM_CTS) && (changed & CH341_BIT_CTS))) {
476 return 0;
477 }
478 prevstatus = status;
479 }
480
481 return 0;
482}
483
484/*static int ch341_ioctl(struct usb_serial_port *port, struct file *file,*/
485static int ch341_ioctl(struct tty_struct *tty, struct file *file,
486 unsigned int cmd, unsigned long arg)
487{
488 struct usb_serial_port *port = tty->driver_data;
489 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
490
491 switch (cmd) {
492 case TIOCMIWAIT:
493 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
494 return wait_modem_info(port, arg);
495
496 default:
497 dbg("%s not supported = 0x%04x", __func__, cmd);
498 break;
499 }
500
501 return -ENOIOCTLCMD;
502}
503
504static int ch341_tiocmget(struct tty_struct *tty, struct file *file)
505{
506 struct usb_serial_port *port = tty->driver_data;
507 struct ch341_private *priv = usb_get_serial_port_data(port);
508 unsigned long flags;
509 u8 mcr;
510 u8 status;
511 unsigned int result;
512
513 dbg("%s (%d)", __func__, port->number);
514
515 spin_lock_irqsave(&priv->lock, flags);
516 mcr = priv->line_control;
517 status = priv->line_status;
518 spin_unlock_irqrestore(&priv->lock, flags);
519
520 result = ((mcr & CH341_BIT_DTR) ? TIOCM_DTR : 0)
521 | ((mcr & CH341_BIT_RTS) ? TIOCM_RTS : 0)
522 | ((status & CH341_BIT_CTS) ? TIOCM_CTS : 0)
523 | ((status & CH341_BIT_DSR) ? TIOCM_DSR : 0)
524 | ((status & CH341_BIT_RI) ? TIOCM_RI : 0)
525 | ((status & CH341_BIT_DCD) ? TIOCM_CD : 0);
526
527 dbg("%s - result = %x", __func__, result);
528
529 return result;
530}
531
532
533static int ch341_reset_resume(struct usb_interface *intf)
534{
535 struct usb_device *dev = interface_to_usbdev(intf);
536 struct usb_serial *serial = NULL;
537 struct ch341_private *priv;
538
539 serial = usb_get_intfdata(intf);
540 priv = usb_get_serial_port_data(serial->port[0]);
541
542 /*reconfigure ch341 serial port after bus-reset*/
543 ch341_configure(dev, priv);
544
545 usb_serial_resume(intf);
546
547 return 0;
305} 548}
306 549
307static struct usb_driver ch341_driver = { 550static struct usb_driver ch341_driver = {
308 .name = "ch341", 551 .name = "ch341",
309 .probe = usb_serial_probe, 552 .probe = usb_serial_probe,
310 .disconnect = usb_serial_disconnect, 553 .disconnect = usb_serial_disconnect,
554 .suspend = usb_serial_suspend,
555 .resume = usb_serial_resume,
556 .reset_resume = ch341_reset_resume,
311 .id_table = id_table, 557 .id_table = id_table,
312 .no_dynamic_id = 1, 558 .no_dynamic_id = 1,
559 .supports_autosuspend = 1,
313}; 560};
314 561
315static struct usb_serial_driver ch341_device = { 562static struct usb_serial_driver ch341_device = {
@@ -317,12 +564,17 @@ static struct usb_serial_driver ch341_device = {
317 .owner = THIS_MODULE, 564 .owner = THIS_MODULE,
318 .name = "ch341-uart", 565 .name = "ch341-uart",
319 }, 566 },
320 .id_table = id_table, 567 .id_table = id_table,
321 .usb_driver = &ch341_driver, 568 .usb_driver = &ch341_driver,
322 .num_ports = 1, 569 .num_ports = 1,
323 .open = ch341_open, 570 .open = ch341_open,
324 .set_termios = ch341_set_termios, 571 .close = ch341_close,
325 .attach = ch341_attach, 572 .ioctl = ch341_ioctl,
573 .set_termios = ch341_set_termios,
574 .tiocmget = ch341_tiocmget,
575 .tiocmset = ch341_tiocmset,
576 .read_int_callback = ch341_read_int_callback,
577 .attach = ch341_attach,
326}; 578};
327 579
328static int __init ch341_init(void) 580static int __init ch341_init(void)
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp210x.c
index 027f4b7dde86..e8d5133ce9c8 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp210x.c
@@ -11,10 +11,6 @@
11 * thanks to Karl Hiramoto karl@hiramoto.org. RTSCTS hardware flow 11 * thanks to Karl Hiramoto karl@hiramoto.org. RTSCTS hardware flow
12 * control thanks to Munir Nassar nassarmu@real-time.com 12 * control thanks to Munir Nassar nassarmu@real-time.com
13 * 13 *
14 * Outstanding Issues:
15 * Buffers are not flushed when the port is opened.
16 * Multiple calls to write() may fail with "Resource temporarily unavailable"
17 *
18 */ 14 */
19 15
20#include <linux/kernel.h> 16#include <linux/kernel.h>
@@ -31,7 +27,7 @@
31/* 27/*
32 * Version Information 28 * Version Information
33 */ 29 */
34#define DRIVER_VERSION "v0.07" 30#define DRIVER_VERSION "v0.08"
35#define DRIVER_DESC "Silicon Labs CP2101/CP2102 RS232 serial adaptor driver" 31#define DRIVER_DESC "Silicon Labs CP2101/CP2102 RS232 serial adaptor driver"
36 32
37/* 33/*
@@ -42,17 +38,21 @@ static int cp2101_open(struct tty_struct *, struct usb_serial_port *,
42static void cp2101_cleanup(struct usb_serial_port *); 38static void cp2101_cleanup(struct usb_serial_port *);
43static void cp2101_close(struct tty_struct *, struct usb_serial_port *, 39static void cp2101_close(struct tty_struct *, struct usb_serial_port *,
44 struct file*); 40 struct file*);
45static void cp2101_get_termios(struct tty_struct *); 41static void cp2101_get_termios(struct tty_struct *,
42 struct usb_serial_port *port);
43static void cp2101_get_termios_port(struct usb_serial_port *port,
44 unsigned int *cflagp, unsigned int *baudp);
46static void cp2101_set_termios(struct tty_struct *, struct usb_serial_port *, 45static void cp2101_set_termios(struct tty_struct *, struct usb_serial_port *,
47 struct ktermios*); 46 struct ktermios*);
48static int cp2101_tiocmget(struct tty_struct *, struct file *); 47static int cp2101_tiocmget(struct tty_struct *, struct file *);
49static int cp2101_tiocmset(struct tty_struct *, struct file *, 48static int cp2101_tiocmset(struct tty_struct *, struct file *,
50 unsigned int, unsigned int); 49 unsigned int, unsigned int);
50static int cp2101_tiocmset_port(struct usb_serial_port *port, struct file *,
51 unsigned int, unsigned int);
51static void cp2101_break_ctl(struct tty_struct *, int); 52static void cp2101_break_ctl(struct tty_struct *, int);
52static int cp2101_startup(struct usb_serial *); 53static int cp2101_startup(struct usb_serial *);
53static void cp2101_shutdown(struct usb_serial *); 54static void cp2101_shutdown(struct usb_serial *);
54 55
55
56static int debug; 56static int debug;
57 57
58static struct usb_device_id id_table [] = { 58static struct usb_device_id id_table [] = {
@@ -79,6 +79,7 @@ static struct usb_device_id id_table [] = {
79 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ 79 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */
80 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ 80 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */
81 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ 81 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
82 { USB_DEVICE(0x10C4, 0x819F) }, /* MJS USB Toslink Switcher */
82 { USB_DEVICE(0x10C4, 0x81A6) }, /* ThinkOptics WavIt */ 83 { USB_DEVICE(0x10C4, 0x81A6) }, /* ThinkOptics WavIt */
83 { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ 84 { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */
84 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ 85 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
@@ -90,6 +91,7 @@ static struct usb_device_id id_table [] = {
90 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ 91 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */
91 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ 92 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
92 { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */ 93 { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */
94 { USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */
93 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 95 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
94 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 96 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
95 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ 97 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
@@ -224,7 +226,7 @@ static int cp2101_get_config(struct usb_serial_port *port, u8 request,
224 kfree(buf); 226 kfree(buf);
225 227
226 if (result != size) { 228 if (result != size) {
227 dev_err(&port->dev, "%s - Unable to send config request, " 229 dbg("%s - Unable to send config request, "
228 "request=0x%x size=%d result=%d\n", 230 "request=0x%x size=%d result=%d\n",
229 __func__, request, size, result); 231 __func__, request, size, result);
230 return -EPROTO; 232 return -EPROTO;
@@ -275,7 +277,7 @@ static int cp2101_set_config(struct usb_serial_port *port, u8 request,
275 kfree(buf); 277 kfree(buf);
276 278
277 if ((size > 2 && result != size) || result < 0) { 279 if ((size > 2 && result != size) || result < 0) {
278 dev_err(&port->dev, "%s - Unable to send request, " 280 dbg("%s - Unable to send request, "
279 "request=0x%x size=%d result=%d\n", 281 "request=0x%x size=%d result=%d\n",
280 __func__, request, size, result); 282 __func__, request, size, result);
281 return -EPROTO; 283 return -EPROTO;
@@ -300,6 +302,47 @@ static inline int cp2101_set_config_single(struct usb_serial_port *port,
300 return cp2101_set_config(port, request, &data, 2); 302 return cp2101_set_config(port, request, &data, 2);
301} 303}
302 304
305/*
306 * cp2101_quantise_baudrate
307 * Quantises the baud rate as per AN205 Table 1
308 */
309static unsigned int cp2101_quantise_baudrate(unsigned int baud) {
310 if (baud <= 56) baud = 0;
311 else if (baud <= 300) baud = 300;
312 else if (baud <= 600) baud = 600;
313 else if (baud <= 1200) baud = 1200;
314 else if (baud <= 1800) baud = 1800;
315 else if (baud <= 2400) baud = 2400;
316 else if (baud <= 4000) baud = 4000;
317 else if (baud <= 4803) baud = 4800;
318 else if (baud <= 7207) baud = 7200;
319 else if (baud <= 9612) baud = 9600;
320 else if (baud <= 14428) baud = 14400;
321 else if (baud <= 16062) baud = 16000;
322 else if (baud <= 19250) baud = 19200;
323 else if (baud <= 28912) baud = 28800;
324 else if (baud <= 38601) baud = 38400;
325 else if (baud <= 51558) baud = 51200;
326 else if (baud <= 56280) baud = 56000;
327 else if (baud <= 58053) baud = 57600;
328 else if (baud <= 64111) baud = 64000;
329 else if (baud <= 77608) baud = 76800;
330 else if (baud <= 117028) baud = 115200;
331 else if (baud <= 129347) baud = 128000;
332 else if (baud <= 156868) baud = 153600;
333 else if (baud <= 237832) baud = 230400;
334 else if (baud <= 254234) baud = 250000;
335 else if (baud <= 273066) baud = 256000;
336 else if (baud <= 491520) baud = 460800;
337 else if (baud <= 567138) baud = 500000;
338 else if (baud <= 670254) baud = 576000;
339 else if (baud <= 1053257) baud = 921600;
340 else if (baud <= 1474560) baud = 1228800;
341 else if (baud <= 2457600) baud = 1843200;
342 else baud = 3686400;
343 return baud;
344}
345
303static int cp2101_open(struct tty_struct *tty, struct usb_serial_port *port, 346static int cp2101_open(struct tty_struct *tty, struct usb_serial_port *port,
304 struct file *filp) 347 struct file *filp)
305{ 348{
@@ -330,10 +373,12 @@ static int cp2101_open(struct tty_struct *tty, struct usb_serial_port *port,
330 } 373 }
331 374
332 /* Configure the termios structure */ 375 /* Configure the termios structure */
333 cp2101_get_termios(tty); 376 cp2101_get_termios(tty, port);
334 377
335 /* Set the DTR and RTS pins low */ 378 /* Set the DTR and RTS pins low */
336 cp2101_tiocmset(tty, NULL, TIOCM_DTR | TIOCM_RTS, 0); 379 cp2101_tiocmset_port(tty ? (struct usb_serial_port *) tty->driver_data
380 : port,
381 NULL, TIOCM_DTR | TIOCM_RTS, 0);
337 382
338 return 0; 383 return 0;
339} 384}
@@ -375,9 +420,31 @@ static void cp2101_close(struct tty_struct *tty, struct usb_serial_port *port,
375 * from the device, corrects any unsupported values, and configures the 420 * from the device, corrects any unsupported values, and configures the
376 * termios structure to reflect the state of the device 421 * termios structure to reflect the state of the device
377 */ 422 */
378static void cp2101_get_termios (struct tty_struct *tty) 423static void cp2101_get_termios(struct tty_struct *tty,
424 struct usb_serial_port *port)
425{
426 unsigned int baud;
427
428 if (tty) {
429 cp2101_get_termios_port(tty->driver_data,
430 &tty->termios->c_cflag, &baud);
431 tty_encode_baud_rate(tty, baud, baud);
432 }
433
434 else {
435 unsigned int cflag;
436 cflag = 0;
437 cp2101_get_termios_port(port, &cflag, &baud);
438 }
439}
440
441/*
442 * cp2101_get_termios_port
443 * This is the heart of cp2101_get_termios which always uses a &usb_serial_port.
444 */
445static void cp2101_get_termios_port(struct usb_serial_port *port,
446 unsigned int *cflagp, unsigned int *baudp)
379{ 447{
380 struct usb_serial_port *port = tty->driver_data;
381 unsigned int cflag, modem_ctl[4]; 448 unsigned int cflag, modem_ctl[4];
382 unsigned int baud; 449 unsigned int baud;
383 unsigned int bits; 450 unsigned int bits;
@@ -387,12 +454,12 @@ static void cp2101_get_termios (struct tty_struct *tty)
387 cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); 454 cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2);
388 /* Convert to baudrate */ 455 /* Convert to baudrate */
389 if (baud) 456 if (baud)
390 baud = BAUD_RATE_GEN_FREQ / baud; 457 baud = cp2101_quantise_baudrate((BAUD_RATE_GEN_FREQ + baud/2)/ baud);
391 458
392 dbg("%s - baud rate = %d", __func__, baud); 459 dbg("%s - baud rate = %d", __func__, baud);
460 *baudp = baud;
393 461
394 tty_encode_baud_rate(tty, baud, baud); 462 cflag = *cflagp;
395 cflag = tty->termios->c_cflag;
396 463
397 cp2101_get_config(port, CP2101_BITS, &bits, 2); 464 cp2101_get_config(port, CP2101_BITS, &bits, 2);
398 cflag &= ~CSIZE; 465 cflag &= ~CSIZE;
@@ -498,7 +565,7 @@ static void cp2101_get_termios (struct tty_struct *tty)
498 cflag &= ~CRTSCTS; 565 cflag &= ~CRTSCTS;
499 } 566 }
500 567
501 tty->termios->c_cflag = cflag; 568 *cflagp = cflag;
502} 569}
503 570
504static void cp2101_set_termios(struct tty_struct *tty, 571static void cp2101_set_termios(struct tty_struct *tty,
@@ -516,46 +583,16 @@ static void cp2101_set_termios(struct tty_struct *tty,
516 tty->termios->c_cflag &= ~CMSPAR; 583 tty->termios->c_cflag &= ~CMSPAR;
517 cflag = tty->termios->c_cflag; 584 cflag = tty->termios->c_cflag;
518 old_cflag = old_termios->c_cflag; 585 old_cflag = old_termios->c_cflag;
519 baud = tty_get_baud_rate(tty); 586 baud = cp2101_quantise_baudrate(tty_get_baud_rate(tty));
520 587
521 /* If the baud rate is to be updated*/ 588 /* If the baud rate is to be updated*/
522 if (baud != tty_termios_baud_rate(old_termios)) { 589 if (baud != tty_termios_baud_rate(old_termios) && baud != 0) {
523 switch (baud) { 590 dbg("%s - Setting baud rate to %d baud", __func__,
524 case 0: 591 baud);
525 case 600: 592 if (cp2101_set_config_single(port, CP2101_BAUDRATE,
526 case 1200: 593 ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) {
527 case 1800: 594 dbg("Baud rate requested not supported by device\n");
528 case 2400: 595 baud = tty_termios_baud_rate(old_termios);
529 case 4800:
530 case 7200:
531 case 9600:
532 case 14400:
533 case 19200:
534 case 28800:
535 case 38400:
536 case 55854:
537 case 57600:
538 case 115200:
539 case 127117:
540 case 230400:
541 case 460800:
542 case 921600:
543 case 3686400:
544 break;
545 default:
546 baud = 9600;
547 break;
548 }
549
550 if (baud) {
551 dbg("%s - Setting baud rate to %d baud", __func__,
552 baud);
553 if (cp2101_set_config_single(port, CP2101_BAUDRATE,
554 (BAUD_RATE_GEN_FREQ / baud))) {
555 dev_err(&port->dev, "Baud rate requested not "
556 "supported by device\n");
557 baud = tty_termios_baud_rate(old_termios);
558 }
559 } 596 }
560 } 597 }
561 /* Report back the resulting baud rate */ 598 /* Report back the resulting baud rate */
@@ -587,14 +624,14 @@ static void cp2101_set_termios(struct tty_struct *tty,
587 dbg("%s - data bits = 9", __func__); 624 dbg("%s - data bits = 9", __func__);
588 break;*/ 625 break;*/
589 default: 626 default:
590 dev_err(&port->dev, "cp2101 driver does not " 627 dbg("cp2101 driver does not "
591 "support the number of bits requested," 628 "support the number of bits requested,"
592 " using 8 bit mode\n"); 629 " using 8 bit mode\n");
593 bits |= BITS_DATA_8; 630 bits |= BITS_DATA_8;
594 break; 631 break;
595 } 632 }
596 if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) 633 if (cp2101_set_config(port, CP2101_BITS, &bits, 2))
597 dev_err(&port->dev, "Number of data bits requested " 634 dbg("Number of data bits requested "
598 "not supported by device\n"); 635 "not supported by device\n");
599 } 636 }
600 637
@@ -611,7 +648,7 @@ static void cp2101_set_termios(struct tty_struct *tty,
611 } 648 }
612 } 649 }
613 if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) 650 if (cp2101_set_config(port, CP2101_BITS, &bits, 2))
614 dev_err(&port->dev, "Parity mode not supported " 651 dbg("Parity mode not supported "
615 "by device\n"); 652 "by device\n");
616 } 653 }
617 654
@@ -626,7 +663,7 @@ static void cp2101_set_termios(struct tty_struct *tty,
626 dbg("%s - stop bits = 1", __func__); 663 dbg("%s - stop bits = 1", __func__);
627 } 664 }
628 if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) 665 if (cp2101_set_config(port, CP2101_BITS, &bits, 2))
629 dev_err(&port->dev, "Number of stop bits requested " 666 dbg("Number of stop bits requested "
630 "not supported by device\n"); 667 "not supported by device\n");
631 } 668 }
632 669
@@ -660,6 +697,12 @@ static int cp2101_tiocmset (struct tty_struct *tty, struct file *file,
660 unsigned int set, unsigned int clear) 697 unsigned int set, unsigned int clear)
661{ 698{
662 struct usb_serial_port *port = tty->driver_data; 699 struct usb_serial_port *port = tty->driver_data;
700 return cp2101_tiocmset_port(port, file, set, clear);
701}
702
703static int cp2101_tiocmset_port(struct usb_serial_port *port, struct file *file,
704 unsigned int set, unsigned int clear)
705{
663 unsigned int control = 0; 706 unsigned int control = 0;
664 707
665 dbg("%s - port %d", __func__, port->number); 708 dbg("%s - port %d", __func__, port->number);
@@ -684,7 +727,6 @@ static int cp2101_tiocmset (struct tty_struct *tty, struct file *file,
684 dbg("%s - control = 0x%.4x", __func__, control); 727 dbg("%s - control = 0x%.4x", __func__, control);
685 728
686 return cp2101_set_config(port, CP2101_CONTROL, &control, 2); 729 return cp2101_set_config(port, CP2101_CONTROL, &control, 2);
687
688} 730}
689 731
690static int cp2101_tiocmget (struct tty_struct *tty, struct file *file) 732static int cp2101_tiocmget (struct tty_struct *tty, struct file *file)
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index f92f4d773374..dcc87aaa8628 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -663,6 +663,11 @@ static struct usb_device_id id_table_combined [] = {
663 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) }, 663 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
664 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) }, 664 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) },
665 { USB_DEVICE(FTDI_VID, FTDI_NDI_HUC_PID) }, 665 { USB_DEVICE(FTDI_VID, FTDI_NDI_HUC_PID) },
666 { USB_DEVICE(ATMEL_VID, STK541_PID) },
667 { USB_DEVICE(DE_VID, STB_PID) },
668 { USB_DEVICE(DE_VID, WHT_PID) },
669 { USB_DEVICE(ADI_VID, ADI_GNICE_PID),
670 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
666 { }, /* Optional parameter entry */ 671 { }, /* Optional parameter entry */
667 { } /* Terminating entry */ 672 { } /* Terminating entry */
668}; 673};
@@ -1933,18 +1938,16 @@ static void ftdi_process_read(struct work_struct *work)
1933 /* Compare new line status to the old one, signal if different/ 1938 /* Compare new line status to the old one, signal if different/
1934 N.B. packet may be processed more than once, but differences 1939 N.B. packet may be processed more than once, but differences
1935 are only processed once. */ 1940 are only processed once. */
1936 if (priv != NULL) { 1941 char new_status = data[packet_offset + 0] &
1937 char new_status = data[packet_offset + 0] & 1942 FTDI_STATUS_B0_MASK;
1938 FTDI_STATUS_B0_MASK; 1943 if (new_status != priv->prev_status) {
1939 if (new_status != priv->prev_status) { 1944 priv->diff_status |=
1940 priv->diff_status |= 1945 new_status ^ priv->prev_status;
1941 new_status ^ priv->prev_status; 1946 wake_up_interruptible(&priv->delta_msr_wait);
1942 wake_up_interruptible(&priv->delta_msr_wait); 1947 priv->prev_status = new_status;
1943 priv->prev_status = new_status;
1944 }
1945 } 1948 }
1946 1949
1947 length = min(PKTSZ, urb->actual_length-packet_offset)-2; 1950 length = min_t(u32, PKTSZ, urb->actual_length-packet_offset)-2;
1948 if (length < 0) { 1951 if (length < 0) {
1949 dev_err(&port->dev, "%s - bad packet length: %d\n", 1952 dev_err(&port->dev, "%s - bad packet length: %d\n",
1950 __func__, length+2); 1953 __func__, length+2);
@@ -2289,11 +2292,8 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2289 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2292 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2290 0, 0, 2293 0, 0,
2291 buf, 1, WDR_TIMEOUT); 2294 buf, 1, WDR_TIMEOUT);
2292 if (ret < 0) { 2295 if (ret < 0)
2293 dbg("%s Could not get modem status of device - err: %d", __func__,
2294 ret);
2295 return ret; 2296 return ret;
2296 }
2297 break; 2297 break;
2298 case FT8U232AM: 2298 case FT8U232AM:
2299 case FT232BM: 2299 case FT232BM:
@@ -2308,15 +2308,11 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2308 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2308 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2309 0, priv->interface, 2309 0, priv->interface,
2310 buf, 2, WDR_TIMEOUT); 2310 buf, 2, WDR_TIMEOUT);
2311 if (ret < 0) { 2311 if (ret < 0)
2312 dbg("%s Could not get modem status of device - err: %d", __func__,
2313 ret);
2314 return ret; 2312 return ret;
2315 }
2316 break; 2313 break;
2317 default: 2314 default:
2318 return -EFAULT; 2315 return -EFAULT;
2319 break;
2320 } 2316 }
2321 2317
2322 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2318 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index e300c840f8ca..daaf63db0b50 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -893,6 +893,26 @@
893#define DIEBOLD_BCS_SE923_PID 0xfb99 893#define DIEBOLD_BCS_SE923_PID 0xfb99
894 894
895/* 895/*
896 * Atmel STK541
897 */
898#define ATMEL_VID 0x03eb /* Vendor ID */
899#define STK541_PID 0x2109 /* Zigbee Controller */
900
901/*
902 * Dresden Elektronic Sensor Terminal Board
903 */
904#define DE_VID 0x1cf1 /* Vendor ID */
905#define STB_PID 0x0001 /* Sensor Terminal Board */
906#define WHT_PID 0x0004 /* Wireless Handheld Terminal */
907
908/*
909 * Blackfin gnICE JTAG
910 * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice
911 */
912#define ADI_VID 0x0456
913#define ADI_GNICE_PID 0xF000
914
915/*
896 * BmRequestType: 1100 0000b 916 * BmRequestType: 1100 0000b
897 * bRequest: FTDI_E2_READ 917 * bRequest: FTDI_E2_READ
898 * wValue: 0 918 * wValue: 0
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 814909f1ee63..9d57cace3731 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -177,14 +177,6 @@ int usb_serial_generic_resume(struct usb_serial *serial)
177 struct usb_serial_port *port; 177 struct usb_serial_port *port;
178 int i, c = 0, r; 178 int i, c = 0, r;
179 179
180#ifdef CONFIG_PM
181 /*
182 * If this is an autoresume, don't submit URBs.
183 * They will be submitted in the open function instead.
184 */
185 if (serial->dev->auto_pm)
186 return 0;
187#endif
188 for (i = 0; i < serial->num_ports; i++) { 180 for (i = 0; i < serial->num_ports; i++) {
189 port = serial->port[i]; 181 port = serial->port[i];
190 if (port->port.count && port->read_urb) { 182 if (port->port.count && port->read_urb) {
@@ -196,6 +188,7 @@ int usb_serial_generic_resume(struct usb_serial *serial)
196 188
197 return c ? -EIO : 0; 189 return c ? -EIO : 0;
198} 190}
191EXPORT_SYMBOL_GPL(usb_serial_generic_resume);
199 192
200void usb_serial_generic_close(struct tty_struct *tty, 193void usb_serial_generic_close(struct tty_struct *tty,
201 struct usb_serial_port *port, struct file *filp) 194 struct usb_serial_port *port, struct file *filp)
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 132be74d2b89..ef92095b0732 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -78,6 +78,7 @@ static int ipaq_open(struct tty_struct *tty,
78 struct usb_serial_port *port, struct file *filp); 78 struct usb_serial_port *port, struct file *filp);
79static void ipaq_close(struct tty_struct *tty, 79static void ipaq_close(struct tty_struct *tty,
80 struct usb_serial_port *port, struct file *filp); 80 struct usb_serial_port *port, struct file *filp);
81static int ipaq_calc_num_ports(struct usb_serial *serial);
81static int ipaq_startup(struct usb_serial *serial); 82static int ipaq_startup(struct usb_serial *serial);
82static void ipaq_shutdown(struct usb_serial *serial); 83static void ipaq_shutdown(struct usb_serial *serial);
83static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, 84static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -572,15 +573,10 @@ static struct usb_serial_driver ipaq_device = {
572 .description = "PocketPC PDA", 573 .description = "PocketPC PDA",
573 .usb_driver = &ipaq_driver, 574 .usb_driver = &ipaq_driver,
574 .id_table = ipaq_id_table, 575 .id_table = ipaq_id_table,
575 /*
576 * some devices have an extra endpoint, which
577 * must be ignored as it would make the core
578 * create a second port which oopses when used
579 */
580 .num_ports = 1,
581 .open = ipaq_open, 576 .open = ipaq_open,
582 .close = ipaq_close, 577 .close = ipaq_close,
583 .attach = ipaq_startup, 578 .attach = ipaq_startup,
579 .calc_num_ports = ipaq_calc_num_ports,
584 .shutdown = ipaq_shutdown, 580 .shutdown = ipaq_shutdown,
585 .write = ipaq_write, 581 .write = ipaq_write,
586 .write_room = ipaq_write_room, 582 .write_room = ipaq_write_room,
@@ -956,14 +952,49 @@ static void ipaq_destroy_lists(struct usb_serial_port *port)
956} 952}
957 953
958 954
955static int ipaq_calc_num_ports(struct usb_serial *serial)
956{
957 /*
958 * some devices have 3 endpoints, the 3rd of which
959 * must be ignored as it would make the core
960 * create a second port which oopses when used
961 */
962 int ipaq_num_ports = 1;
963
964 dbg("%s - numberofendpoints: %d", __FUNCTION__,
965 (int)serial->interface->cur_altsetting->desc.bNumEndpoints);
966
967 /*
968 * a few devices have 4 endpoints, seemingly Yakuma devices,
969 * and we need the second pair, so let them have 2 ports
970 *
971 * TODO: can we drop port 1 ?
972 */
973 if (serial->interface->cur_altsetting->desc.bNumEndpoints > 3) {
974 ipaq_num_ports = 2;
975 }
976
977 return ipaq_num_ports;
978}
979
980
959static int ipaq_startup(struct usb_serial *serial) 981static int ipaq_startup(struct usb_serial *serial)
960{ 982{
961 dbg("%s", __func__); 983 dbg("%s", __func__);
962 if (serial->dev->actconfig->desc.bConfigurationValue != 1) { 984 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
985 /*
986 * FIXME: HP iPaq rx3715, possibly others, have 1 config that
987 * is labeled as 2
988 */
989
963 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", 990 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
964 serial->dev->actconfig->desc.bConfigurationValue); 991 serial->dev->actconfig->desc.bConfigurationValue);
965 return -ENODEV; 992 return -ENODEV;
966 } 993 }
994
995 dbg("%s - iPAQ module configured for %d ports",
996 __FUNCTION__, serial->num_ports);
997
967 return usb_reset_configuration(serial->dev); 998 return usb_reset_configuration(serial->dev);
968} 999}
969 1000
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 9878c0fb3859..00daa8f7759a 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1507,7 +1507,7 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
1507 } else { 1507 } else {
1508 dev_warn(&serial->interface->dev, 1508 dev_warn(&serial->interface->dev,
1509 "unsupported endpoint type %x\n", 1509 "unsupported endpoint type %x\n",
1510 ep_desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); 1510 usb_endpoint_type(ep_desc));
1511 usb_free_urb(urb); 1511 usb_free_urb(urb);
1512 return NULL; 1512 return NULL;
1513 } 1513 }
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index cea326f1f105..839583dc8b6a 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * Opticon USB barcode to serial driver 2 * Opticon USB barcode to serial driver
3 * 3 *
4 * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de> 4 * Copyright (C) 2008 - 2009 Greg Kroah-Hartman <gregkh@suse.de>
5 * Copyright (C) 2008 Novell Inc. 5 * Copyright (C) 2008 - 2009 Novell Inc.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 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 8 * modify it under the terms of the GNU General Public License version
@@ -14,6 +14,7 @@
14#include <linux/tty.h> 14#include <linux/tty.h>
15#include <linux/tty_driver.h> 15#include <linux/tty_driver.h>
16#include <linux/tty_flip.h> 16#include <linux/tty_flip.h>
17#include <linux/serial.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/usb.h> 19#include <linux/usb.h>
19#include <linux/usb/serial.h> 20#include <linux/usb/serial.h>
@@ -40,8 +41,12 @@ struct opticon_private {
40 bool throttled; 41 bool throttled;
41 bool actually_throttled; 42 bool actually_throttled;
42 bool rts; 43 bool rts;
44 int outstanding_urbs;
43}; 45};
44 46
47/* max number of write urbs in flight */
48#define URB_UPPER_LIMIT 4
49
45static void opticon_bulk_callback(struct urb *urb) 50static void opticon_bulk_callback(struct urb *urb)
46{ 51{
47 struct opticon_private *priv = urb->context; 52 struct opticon_private *priv = urb->context;
@@ -106,7 +111,6 @@ static void opticon_bulk_callback(struct urb *urb)
106 priv->rts = false; 111 priv->rts = false;
107 else 112 else
108 priv->rts = true; 113 priv->rts = true;
109 /* FIXME change the RTS level */
110 } else { 114 } else {
111 dev_dbg(&priv->udev->dev, 115 dev_dbg(&priv->udev->dev,
112 "Unknown data packet received from the device:" 116 "Unknown data packet received from the device:"
@@ -188,6 +192,120 @@ static void opticon_close(struct tty_struct *tty, struct usb_serial_port *port,
188 usb_kill_urb(priv->bulk_read_urb); 192 usb_kill_urb(priv->bulk_read_urb);
189} 193}
190 194
195static void opticon_write_bulk_callback(struct urb *urb)
196{
197 struct opticon_private *priv = urb->context;
198 int status = urb->status;
199 unsigned long flags;
200
201 /* free up the transfer buffer, as usb_free_urb() does not do this */
202 kfree(urb->transfer_buffer);
203
204 if (status)
205 dbg("%s - nonzero write bulk status received: %d",
206 __func__, status);
207
208 spin_lock_irqsave(&priv->lock, flags);
209 --priv->outstanding_urbs;
210 spin_unlock_irqrestore(&priv->lock, flags);
211
212 usb_serial_port_softint(priv->port);
213}
214
215static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
216 const unsigned char *buf, int count)
217{
218 struct opticon_private *priv = usb_get_serial_data(port->serial);
219 struct usb_serial *serial = port->serial;
220 struct urb *urb;
221 unsigned char *buffer;
222 unsigned long flags;
223 int status;
224
225 dbg("%s - port %d", __func__, port->number);
226
227 spin_lock_irqsave(&priv->lock, flags);
228 if (priv->outstanding_urbs > URB_UPPER_LIMIT) {
229 spin_unlock_irqrestore(&priv->lock, flags);
230 dbg("%s - write limit hit\n", __func__);
231 return 0;
232 }
233 priv->outstanding_urbs++;
234 spin_unlock_irqrestore(&priv->lock, flags);
235
236 buffer = kmalloc(count, GFP_ATOMIC);
237 if (!buffer) {
238 dev_err(&port->dev, "out of memory\n");
239 count = -ENOMEM;
240 goto error_no_buffer;
241 }
242
243 urb = usb_alloc_urb(0, GFP_ATOMIC);
244 if (!urb) {
245 dev_err(&port->dev, "no more free urbs\n");
246 count = -ENOMEM;
247 goto error_no_urb;
248 }
249
250 memcpy(buffer, buf, count);
251
252 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
253
254 usb_fill_bulk_urb(urb, serial->dev,
255 usb_sndbulkpipe(serial->dev,
256 port->bulk_out_endpointAddress),
257 buffer, count, opticon_write_bulk_callback, priv);
258
259 /* send it down the pipe */
260 status = usb_submit_urb(urb, GFP_ATOMIC);
261 if (status) {
262 dev_err(&port->dev,
263 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
264 __func__, status);
265 count = status;
266 goto error;
267 }
268
269 /* we are done with this urb, so let the host driver
270 * really free it when it is finished with it */
271 usb_free_urb(urb);
272
273 return count;
274error:
275 usb_free_urb(urb);
276error_no_urb:
277 kfree(buffer);
278error_no_buffer:
279 spin_lock_irqsave(&priv->lock, flags);
280 --priv->outstanding_urbs;
281 spin_unlock_irqrestore(&priv->lock, flags);
282 return count;
283}
284
285static int opticon_write_room(struct tty_struct *tty)
286{
287 struct usb_serial_port *port = tty->driver_data;
288 struct opticon_private *priv = usb_get_serial_data(port->serial);
289 unsigned long flags;
290
291 dbg("%s - port %d", __func__, port->number);
292
293 /*
294 * We really can take almost anything the user throws at us
295 * but let's pick a nice big number to tell the tty
296 * layer that we have lots of free space, unless we don't.
297 */
298 spin_lock_irqsave(&priv->lock, flags);
299 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) {
300 spin_unlock_irqrestore(&priv->lock, flags);
301 dbg("%s - write limit hit\n", __func__);
302 return 0;
303 }
304 spin_unlock_irqrestore(&priv->lock, flags);
305
306 return 2048;
307}
308
191static void opticon_throttle(struct tty_struct *tty) 309static void opticon_throttle(struct tty_struct *tty)
192{ 310{
193 struct usb_serial_port *port = tty->driver_data; 311 struct usb_serial_port *port = tty->driver_data;
@@ -223,6 +341,67 @@ static void opticon_unthrottle(struct tty_struct *tty)
223 __func__, result); 341 __func__, result);
224} 342}
225 343
344static int opticon_tiocmget(struct tty_struct *tty, struct file *file)
345{
346 struct usb_serial_port *port = tty->driver_data;
347 struct opticon_private *priv = usb_get_serial_data(port->serial);
348 unsigned long flags;
349 int result = 0;
350
351 dbg("%s - port %d", __func__, port->number);
352
353 spin_lock_irqsave(&priv->lock, flags);
354 if (priv->rts)
355 result = TIOCM_RTS;
356 spin_unlock_irqrestore(&priv->lock, flags);
357
358 dbg("%s - %x", __func__, result);
359 return result;
360}
361
362static int get_serial_info(struct opticon_private *priv,
363 struct serial_struct __user *serial)
364{
365 struct serial_struct tmp;
366
367 if (!serial)
368 return -EFAULT;
369
370 memset(&tmp, 0x00, sizeof(tmp));
371
372 /* fake emulate a 16550 uart to make userspace code happy */
373 tmp.type = PORT_16550A;
374 tmp.line = priv->serial->minor;
375 tmp.port = 0;
376 tmp.irq = 0;
377 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
378 tmp.xmit_fifo_size = 1024;
379 tmp.baud_base = 9600;
380 tmp.close_delay = 5*HZ;
381 tmp.closing_wait = 30*HZ;
382
383 if (copy_to_user(serial, &tmp, sizeof(*serial)))
384 return -EFAULT;
385 return 0;
386}
387
388static int opticon_ioctl(struct tty_struct *tty, struct file *file,
389 unsigned int cmd, unsigned long arg)
390{
391 struct usb_serial_port *port = tty->driver_data;
392 struct opticon_private *priv = usb_get_serial_data(port->serial);
393
394 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
395
396 switch (cmd) {
397 case TIOCGSERIAL:
398 return get_serial_info(priv,
399 (struct serial_struct __user *)arg);
400 }
401
402 return -ENOIOCTLCMD;
403}
404
226static int opticon_startup(struct usb_serial *serial) 405static int opticon_startup(struct usb_serial *serial)
227{ 406{
228 struct opticon_private *priv; 407 struct opticon_private *priv;
@@ -306,11 +485,37 @@ static void opticon_shutdown(struct usb_serial *serial)
306 usb_set_serial_data(serial, NULL); 485 usb_set_serial_data(serial, NULL);
307} 486}
308 487
488static int opticon_suspend(struct usb_interface *intf, pm_message_t message)
489{
490 struct usb_serial *serial = usb_get_intfdata(intf);
491 struct opticon_private *priv = usb_get_serial_data(serial);
492
493 usb_kill_urb(priv->bulk_read_urb);
494 return 0;
495}
496
497static int opticon_resume(struct usb_interface *intf)
498{
499 struct usb_serial *serial = usb_get_intfdata(intf);
500 struct opticon_private *priv = usb_get_serial_data(serial);
501 struct usb_serial_port *port = serial->port[0];
502 int result;
503
504 mutex_lock(&port->mutex);
505 if (port->port.count)
506 result = usb_submit_urb(priv->bulk_read_urb, GFP_NOIO);
507 else
508 result = 0;
509 mutex_unlock(&port->mutex);
510 return result;
511}
309 512
310static struct usb_driver opticon_driver = { 513static struct usb_driver opticon_driver = {
311 .name = "opticon", 514 .name = "opticon",
312 .probe = usb_serial_probe, 515 .probe = usb_serial_probe,
313 .disconnect = usb_serial_disconnect, 516 .disconnect = usb_serial_disconnect,
517 .suspend = opticon_suspend,
518 .resume = opticon_resume,
314 .id_table = id_table, 519 .id_table = id_table,
315 .no_dynamic_id = 1, 520 .no_dynamic_id = 1,
316}; 521};
@@ -326,9 +531,13 @@ static struct usb_serial_driver opticon_device = {
326 .attach = opticon_startup, 531 .attach = opticon_startup,
327 .open = opticon_open, 532 .open = opticon_open,
328 .close = opticon_close, 533 .close = opticon_close,
534 .write = opticon_write,
535 .write_room = opticon_write_room,
329 .shutdown = opticon_shutdown, 536 .shutdown = opticon_shutdown,
330 .throttle = opticon_throttle, 537 .throttle = opticon_throttle,
331 .unthrottle = opticon_unthrottle, 538 .unthrottle = opticon_unthrottle,
539 .ioctl = opticon_ioctl,
540 .tiocmget = opticon_tiocmget,
332}; 541};
333 542
334static int __init opticon_init(void) 543static int __init opticon_init(void)
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index b7c132bded7f..d560c0b54e6e 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -62,6 +62,8 @@ static int option_tiocmget(struct tty_struct *tty, struct file *file);
62static int option_tiocmset(struct tty_struct *tty, struct file *file, 62static int option_tiocmset(struct tty_struct *tty, struct file *file,
63 unsigned int set, unsigned int clear); 63 unsigned int set, unsigned int clear);
64static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *port); 64static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *port);
65static int option_suspend(struct usb_serial *serial, pm_message_t message);
66static int option_resume(struct usb_serial *serial);
65 67
66/* Vendor and product IDs */ 68/* Vendor and product IDs */
67#define OPTION_VENDOR_ID 0x0AF0 69#define OPTION_VENDOR_ID 0x0AF0
@@ -89,6 +91,7 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
89#define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041 91#define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041
90#define OPTION_PRODUCT_ETNA_MODEM_EX 0x7061 92#define OPTION_PRODUCT_ETNA_MODEM_EX 0x7061
91#define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100 93#define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100
94#define OPTION_PRODUCT_GTM380_MODEM 0x7201
92 95
93#define HUAWEI_VENDOR_ID 0x12D1 96#define HUAWEI_VENDOR_ID 0x12D1
94#define HUAWEI_PRODUCT_E600 0x1001 97#define HUAWEI_PRODUCT_E600 0x1001
@@ -197,6 +200,7 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
197/* OVATION PRODUCTS */ 200/* OVATION PRODUCTS */
198#define NOVATELWIRELESS_PRODUCT_MC727 0x4100 201#define NOVATELWIRELESS_PRODUCT_MC727 0x4100
199#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 202#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400
203#define NOVATELWIRELESS_PRODUCT_U727 0x5010
200 204
201/* FUTURE NOVATEL PRODUCTS */ 205/* FUTURE NOVATEL PRODUCTS */
202#define NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED 0X6000 206#define NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED 0X6000
@@ -288,15 +292,11 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
288 292
289/* ZTE PRODUCTS */ 293/* ZTE PRODUCTS */
290#define ZTE_VENDOR_ID 0x19d2 294#define ZTE_VENDOR_ID 0x19d2
295#define ZTE_PRODUCT_MF622 0x0001
291#define ZTE_PRODUCT_MF628 0x0015 296#define ZTE_PRODUCT_MF628 0x0015
292#define ZTE_PRODUCT_MF626 0x0031 297#define ZTE_PRODUCT_MF626 0x0031
293#define ZTE_PRODUCT_CDMA_TECH 0xfffe 298#define ZTE_PRODUCT_CDMA_TECH 0xfffe
294 299
295/* Ericsson products */
296#define ERICSSON_VENDOR_ID 0x0bdb
297#define ERICSSON_PRODUCT_F3507G_1 0x1900
298#define ERICSSON_PRODUCT_F3507G_2 0x1902
299
300#define BENQ_VENDOR_ID 0x04a5 300#define BENQ_VENDOR_ID 0x04a5
301#define BENQ_PRODUCT_H10 0x4068 301#define BENQ_PRODUCT_H10 0x4068
302 302
@@ -325,6 +325,7 @@ static struct usb_device_id option_ids[] = {
325 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) }, 325 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) },
326 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) }, 326 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) },
327 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, 327 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) },
328 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GTM380_MODEM) },
328 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q101) }, 329 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q101) },
329 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q111) }, 330 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q111) },
330 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) }, 331 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) },
@@ -415,6 +416,7 @@ static struct usb_device_id option_ids[] = {
415 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ 416 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */
416 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ 417 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */
417 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ 418 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */
419 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel MC727/U727/USB727 */
418 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED) }, /* Novatel EVDO product */ 420 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED) }, /* Novatel EVDO product */
419 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, /* Novatel HSPA product */ 421 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, /* Novatel HSPA product */
420 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, /* Novatel EVDO Embedded product */ 422 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, /* Novatel EVDO Embedded product */
@@ -442,7 +444,6 @@ static struct usb_device_id option_ids[] = {
442 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_CINGULAR) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 444 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_CINGULAR) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */
443 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_L) }, /* Dell Wireless HSDPA 5520 */ 445 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_L) }, /* Dell Wireless HSDPA 5520 */
444 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_I) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ 446 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_I) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */
445 { USB_DEVICE(DELL_VENDOR_ID, 0x8147) }, /* Dell Wireless 5530 Mobile Broadband (3G HSPA) Mini-Card */
446 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 447 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
447 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 448 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
448 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 449 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
@@ -510,11 +511,10 @@ static struct usb_device_id option_ids[] = {
510 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 511 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
511 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 512 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */
512 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, 513 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
514 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622) },
513 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF626) }, 515 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF626) },
514 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, 516 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) },
515 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, 517 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) },
516 { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G_1) },
517 { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G_2) },
518 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 518 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
519 { USB_DEVICE(0x1da5, 0x4515) }, /* BenQ H20 */ 519 { USB_DEVICE(0x1da5, 0x4515) }, /* BenQ H20 */
520 { } /* Terminating entry */ 520 { } /* Terminating entry */
@@ -525,6 +525,8 @@ static struct usb_driver option_driver = {
525 .name = "option", 525 .name = "option",
526 .probe = usb_serial_probe, 526 .probe = usb_serial_probe,
527 .disconnect = usb_serial_disconnect, 527 .disconnect = usb_serial_disconnect,
528 .suspend = usb_serial_suspend,
529 .resume = usb_serial_resume,
528 .id_table = option_ids, 530 .id_table = option_ids,
529 .no_dynamic_id = 1, 531 .no_dynamic_id = 1,
530}; 532};
@@ -553,6 +555,8 @@ static struct usb_serial_driver option_1port_device = {
553 .attach = option_startup, 555 .attach = option_startup,
554 .shutdown = option_shutdown, 556 .shutdown = option_shutdown,
555 .read_int_callback = option_instat_callback, 557 .read_int_callback = option_instat_callback,
558 .suspend = option_suspend,
559 .resume = option_resume,
556}; 560};
557 561
558static int debug; 562static int debug;
@@ -823,10 +827,10 @@ static void option_instat_callback(struct urb *urb)
823 req_pkt->bRequestType, req_pkt->bRequest); 827 req_pkt->bRequestType, req_pkt->bRequest);
824 } 828 }
825 } else 829 } else
826 dbg("%s: error %d", __func__, status); 830 err("%s: error %d", __func__, status);
827 831
828 /* Resubmit urb so we continue receiving IRQ data */ 832 /* Resubmit urb so we continue receiving IRQ data */
829 if (status != -ESHUTDOWN) { 833 if (status != -ESHUTDOWN && status != -ENOENT) {
830 urb->dev = serial->dev; 834 urb->dev = serial->dev;
831 err = usb_submit_urb(urb, GFP_ATOMIC); 835 err = usb_submit_urb(urb, GFP_ATOMIC);
832 if (err) 836 if (err)
@@ -845,7 +849,6 @@ static int option_write_room(struct tty_struct *tty)
845 849
846 portdata = usb_get_serial_port_data(port); 850 portdata = usb_get_serial_port_data(port);
847 851
848
849 for (i = 0; i < N_OUT_URB; i++) { 852 for (i = 0; i < N_OUT_URB; i++) {
850 this_urb = portdata->out_urbs[i]; 853 this_urb = portdata->out_urbs[i];
851 if (this_urb && !test_bit(i, &portdata->out_busy)) 854 if (this_urb && !test_bit(i, &portdata->out_busy))
@@ -1107,14 +1110,12 @@ bail_out_error:
1107 return 1; 1110 return 1;
1108} 1111}
1109 1112
1110static void option_shutdown(struct usb_serial *serial) 1113static void stop_read_write_urbs(struct usb_serial *serial)
1111{ 1114{
1112 int i, j; 1115 int i, j;
1113 struct usb_serial_port *port; 1116 struct usb_serial_port *port;
1114 struct option_port_private *portdata; 1117 struct option_port_private *portdata;
1115 1118
1116 dbg("%s", __func__);
1117
1118 /* Stop reading/writing urbs */ 1119 /* Stop reading/writing urbs */
1119 for (i = 0; i < serial->num_ports; ++i) { 1120 for (i = 0; i < serial->num_ports; ++i) {
1120 port = serial->port[i]; 1121 port = serial->port[i];
@@ -1124,6 +1125,17 @@ static void option_shutdown(struct usb_serial *serial)
1124 for (j = 0; j < N_OUT_URB; j++) 1125 for (j = 0; j < N_OUT_URB; j++)
1125 usb_kill_urb(portdata->out_urbs[j]); 1126 usb_kill_urb(portdata->out_urbs[j]);
1126 } 1127 }
1128}
1129
1130static void option_shutdown(struct usb_serial *serial)
1131{
1132 int i, j;
1133 struct usb_serial_port *port;
1134 struct option_port_private *portdata;
1135
1136 dbg("%s", __func__);
1137
1138 stop_read_write_urbs(serial);
1127 1139
1128 /* Now free them */ 1140 /* Now free them */
1129 for (i = 0; i < serial->num_ports; ++i) { 1141 for (i = 0; i < serial->num_ports; ++i) {
@@ -1154,6 +1166,66 @@ static void option_shutdown(struct usb_serial *serial)
1154 } 1166 }
1155} 1167}
1156 1168
1169static int option_suspend(struct usb_serial *serial, pm_message_t message)
1170{
1171 dbg("%s entered", __func__);
1172 stop_read_write_urbs(serial);
1173
1174 return 0;
1175}
1176
1177static int option_resume(struct usb_serial *serial)
1178{
1179 int err, i, j;
1180 struct usb_serial_port *port;
1181 struct urb *urb;
1182 struct option_port_private *portdata;
1183
1184 dbg("%s entered", __func__);
1185 /* get the interrupt URBs resubmitted unconditionally */
1186 for (i = 0; i < serial->num_ports; i++) {
1187 port = serial->port[i];
1188 if (!port->interrupt_in_urb) {
1189 dbg("%s: No interrupt URB for port %d\n", __func__, i);
1190 continue;
1191 }
1192 port->interrupt_in_urb->dev = serial->dev;
1193 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
1194 dbg("Submitted interrupt URB for port %d (result %d)", i, err);
1195 if (err < 0) {
1196 err("%s: Error %d for interrupt URB of port%d",
1197 __func__, err, i);
1198 return err;
1199 }
1200 }
1201
1202 for (i = 0; i < serial->num_ports; i++) {
1203 /* walk all ports */
1204 port = serial->port[i];
1205 portdata = usb_get_serial_port_data(port);
1206 mutex_lock(&port->mutex);
1207
1208 /* skip closed ports */
1209 if (!port->port.count) {
1210 mutex_unlock(&port->mutex);
1211 continue;
1212 }
1213
1214 for (j = 0; j < N_IN_URB; j++) {
1215 urb = portdata->in_urbs[j];
1216 err = usb_submit_urb(urb, GFP_NOIO);
1217 if (err < 0) {
1218 mutex_unlock(&port->mutex);
1219 err("%s: Error %d for bulk URB %d",
1220 __func__, err, i);
1221 return err;
1222 }
1223 }
1224 mutex_unlock(&port->mutex);
1225 }
1226 return 0;
1227}
1228
1157MODULE_AUTHOR(DRIVER_AUTHOR); 1229MODULE_AUTHOR(DRIVER_AUTHOR);
1158MODULE_DESCRIPTION(DRIVER_DESC); 1230MODULE_DESCRIPTION(DRIVER_DESC);
1159MODULE_VERSION(DRIVER_VERSION); 1231MODULE_VERSION(DRIVER_VERSION);
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
new file mode 100644
index 000000000000..e6d6b0c17fd9
--- /dev/null
+++ b/drivers/usb/serial/qcserial.c
@@ -0,0 +1,147 @@
1/*
2 * Qualcomm Serial USB driver
3 *
4 * Copyright (c) 2008 QUALCOMM Incorporated.
5 * Copyright (c) 2009 Greg Kroah-Hartman <gregkh@suse.de>
6 * Copyright (c) 2009 Novell Inc.
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
10 * 2 as published by the Free Software Foundation.
11 *
12 */
13
14#include <linux/tty.h>
15#include <linux/tty_flip.h>
16#include <linux/usb.h>
17#include <linux/usb/serial.h>
18
19#define DRIVER_AUTHOR "Qualcomm Inc"
20#define DRIVER_DESC "Qualcomm USB Serial driver"
21
22static int debug;
23
24static struct usb_device_id id_table[] = {
25 {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */
26 {USB_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
27 {USB_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
28 {USB_DEVICE(0x03f0, 0x201d)}, /* HP un2400 Gobi QDL Device */
29 { } /* Terminating entry */
30};
31MODULE_DEVICE_TABLE(usb, id_table);
32
33static struct usb_driver qcdriver = {
34 .name = "qcserial",
35 .probe = usb_serial_probe,
36 .disconnect = usb_serial_disconnect,
37 .id_table = id_table,
38 .suspend = usb_serial_suspend,
39 .resume = usb_serial_resume,
40 .supports_autosuspend = true,
41};
42
43static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
44{
45 int retval = -ENODEV;
46 __u8 nintf;
47 __u8 ifnum;
48
49 dbg("%s", __func__);
50
51 nintf = serial->dev->actconfig->desc.bNumInterfaces;
52 dbg("Num Interfaces = %d", nintf);
53 ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
54 dbg("This Interface = %d", ifnum);
55
56 switch (nintf) {
57 case 1:
58 /* QDL mode */
59 if (serial->interface->num_altsetting == 2) {
60 struct usb_host_interface *intf;
61
62 intf = &serial->interface->altsetting[1];
63 if (intf->desc.bNumEndpoints == 2) {
64 if (usb_endpoint_is_bulk_in(&intf->endpoint[0].desc) &&
65 usb_endpoint_is_bulk_out(&intf->endpoint[1].desc)) {
66 dbg("QDL port found");
67 retval = usb_set_interface(serial->dev, ifnum, 1);
68 if (retval < 0) {
69 dev_err(&serial->dev->dev,
70 "Could not set interface, error %d\n",
71 retval);
72 retval = -ENODEV;
73 }
74 return retval;
75 }
76 }
77 }
78 break;
79
80 case 4:
81 /* Composite mode */
82 if (ifnum == 2) {
83 dbg("Modem port found");
84 retval = usb_set_interface(serial->dev, ifnum, 0);
85 if (retval < 0) {
86 dev_err(&serial->dev->dev,
87 "Could not set interface, error %d\n",
88 retval);
89 retval = -ENODEV;
90 }
91 return retval;
92 }
93 break;
94
95 default:
96 dev_err(&serial->dev->dev,
97 "unknown number of interfaces: %d\n", nintf);
98 return -ENODEV;
99 }
100
101 return retval;
102}
103
104static struct usb_serial_driver qcdevice = {
105 .driver = {
106 .owner = THIS_MODULE,
107 .name = "qcserial",
108 },
109 .description = "Qualcomm USB modem",
110 .id_table = id_table,
111 .usb_driver = &qcdriver,
112 .num_ports = 1,
113 .probe = qcprobe,
114};
115
116static int __init qcinit(void)
117{
118 int retval;
119
120 retval = usb_serial_register(&qcdevice);
121 if (retval)
122 return retval;
123
124 retval = usb_register(&qcdriver);
125 if (retval) {
126 usb_serial_deregister(&qcdevice);
127 return retval;
128 }
129
130 return 0;
131}
132
133static void __exit qcexit(void)
134{
135 usb_deregister(&qcdriver);
136 usb_serial_deregister(&qcdevice);
137}
138
139module_init(qcinit);
140module_exit(qcexit);
141
142MODULE_AUTHOR(DRIVER_AUTHOR);
143MODULE_DESCRIPTION(DRIVER_DESC);
144MODULE_LICENSE("GPL v2");
145
146module_param(debug, bool, S_IRUGO | S_IWUSR);
147MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
new file mode 100644
index 000000000000..8b3cbc87adc7
--- /dev/null
+++ b/drivers/usb/serial/symbolserial.c
@@ -0,0 +1,399 @@
1/*
2 * Symbol USB barcode to serial driver
3 *
4 * Copyright (C) 2009 Greg Kroah-Hartman <gregkh@suse.de>
5 * Copyright (C) 2009 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(0x05e0, 0x0600) },
26 { },
27};
28MODULE_DEVICE_TABLE(usb, id_table);
29
30/* This structure holds all of the individual device information */
31struct symbol_private {
32 struct usb_device *udev;
33 struct usb_serial *serial;
34 struct usb_serial_port *port;
35 unsigned char *int_buffer;
36 struct urb *int_urb;
37 int buffer_size;
38 u8 bInterval;
39 u8 int_address;
40 spinlock_t lock; /* protects the following flags */
41 bool throttled;
42 bool actually_throttled;
43 bool rts;
44};
45
46static void symbol_int_callback(struct urb *urb)
47{
48 struct symbol_private *priv = urb->context;
49 unsigned char *data = urb->transfer_buffer;
50 struct usb_serial_port *port = priv->port;
51 int status = urb->status;
52 struct tty_struct *tty;
53 int result;
54 int available_room = 0;
55 int data_length;
56
57 dbg("%s - port %d", __func__, port->number);
58
59 switch (status) {
60 case 0:
61 /* success */
62 break;
63 case -ECONNRESET:
64 case -ENOENT:
65 case -ESHUTDOWN:
66 /* this urb is terminated, clean up */
67 dbg("%s - urb shutting down with status: %d",
68 __func__, status);
69 return;
70 default:
71 dbg("%s - nonzero urb status received: %d",
72 __func__, status);
73 goto exit;
74 }
75
76 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length,
77 data);
78
79 if (urb->actual_length > 1) {
80 data_length = urb->actual_length - 1;
81
82 /*
83 * Data from the device comes with a 1 byte header:
84 *
85 * <size of data>data...
86 * This is real data to be sent to the tty layer
87 * we pretty much just ignore the size and send everything
88 * else to the tty layer.
89 */
90 tty = tty_port_tty_get(&port->port);
91 if (tty) {
92 available_room = tty_buffer_request_room(tty,
93 data_length);
94 if (available_room) {
95 tty_insert_flip_string(tty, &data[1],
96 available_room);
97 tty_flip_buffer_push(tty);
98 }
99 tty_kref_put(tty);
100 }
101 } else {
102 dev_dbg(&priv->udev->dev,
103 "Improper ammount of data received from the device, "
104 "%d bytes", urb->actual_length);
105 }
106
107exit:
108 spin_lock(&priv->lock);
109
110 /* Continue trying to always read if we should */
111 if (!priv->throttled) {
112 usb_fill_int_urb(priv->int_urb, priv->udev,
113 usb_rcvintpipe(priv->udev,
114 priv->int_address),
115 priv->int_buffer, priv->buffer_size,
116 symbol_int_callback, priv, priv->bInterval);
117 result = usb_submit_urb(priv->int_urb, GFP_ATOMIC);
118 if (result)
119 dev_err(&port->dev,
120 "%s - failed resubmitting read urb, error %d\n",
121 __func__, result);
122 } else
123 priv->actually_throttled = true;
124 spin_unlock(&priv->lock);
125}
126
127static int symbol_open(struct tty_struct *tty, struct usb_serial_port *port,
128 struct file *filp)
129{
130 struct symbol_private *priv = usb_get_serial_data(port->serial);
131 unsigned long flags;
132 int result = 0;
133
134 dbg("%s - port %d", __func__, port->number);
135
136 spin_lock_irqsave(&priv->lock, flags);
137 priv->throttled = false;
138 priv->actually_throttled = false;
139 priv->port = port;
140 spin_unlock_irqrestore(&priv->lock, flags);
141
142 /*
143 * Force low_latency on so that our tty_push actually forces the data
144 * through, otherwise it is scheduled, and with high data rates (like
145 * with OHCI) data can get lost.
146 */
147 if (tty)
148 tty->low_latency = 1;
149
150 /* Start reading from the device */
151 usb_fill_int_urb(priv->int_urb, priv->udev,
152 usb_rcvintpipe(priv->udev, priv->int_address),
153 priv->int_buffer, priv->buffer_size,
154 symbol_int_callback, priv, priv->bInterval);
155 result = usb_submit_urb(priv->int_urb, GFP_KERNEL);
156 if (result)
157 dev_err(&port->dev,
158 "%s - failed resubmitting read urb, error %d\n",
159 __func__, result);
160 return result;
161}
162
163static void symbol_close(struct tty_struct *tty, struct usb_serial_port *port,
164 struct file *filp)
165{
166 struct symbol_private *priv = usb_get_serial_data(port->serial);
167
168 dbg("%s - port %d", __func__, port->number);
169
170 /* shutdown our urbs */
171 usb_kill_urb(priv->int_urb);
172}
173
174static void symbol_throttle(struct tty_struct *tty)
175{
176 struct usb_serial_port *port = tty->driver_data;
177 struct symbol_private *priv = usb_get_serial_data(port->serial);
178 unsigned long flags;
179
180 dbg("%s - port %d", __func__, port->number);
181 spin_lock_irqsave(&priv->lock, flags);
182 priv->throttled = true;
183 spin_unlock_irqrestore(&priv->lock, flags);
184}
185
186static void symbol_unthrottle(struct tty_struct *tty)
187{
188 struct usb_serial_port *port = tty->driver_data;
189 struct symbol_private *priv = usb_get_serial_data(port->serial);
190 unsigned long flags;
191 int result;
192
193 dbg("%s - port %d", __func__, port->number);
194
195 spin_lock_irqsave(&priv->lock, flags);
196 priv->throttled = false;
197 priv->actually_throttled = false;
198 spin_unlock_irqrestore(&priv->lock, flags);
199
200 priv->int_urb->dev = port->serial->dev;
201 result = usb_submit_urb(priv->int_urb, GFP_ATOMIC);
202 if (result)
203 dev_err(&port->dev,
204 "%s - failed submitting read urb, error %d\n",
205 __func__, result);
206}
207
208static int symbol_ioctl(struct tty_struct *tty, struct file *file,
209 unsigned int cmd, unsigned long arg)
210{
211 struct usb_serial_port *port = tty->driver_data;
212 struct device *dev = &port->dev;
213
214 /*
215 * Right now we need to figure out what commands
216 * most userspace tools want to see for this driver,
217 * so just log the things.
218 */
219 switch (cmd) {
220 case TIOCSERGETLSR:
221 dev_info(dev, "%s: TIOCSERGETLSR\n", __func__);
222 break;
223
224 case TIOCGSERIAL:
225 dev_info(dev, "%s: TIOCGSERIAL\n", __func__);
226 break;
227
228 case TIOCMIWAIT:
229 dev_info(dev, "%s: TIOCMIWAIT\n", __func__);
230 break;
231
232 case TIOCGICOUNT:
233 dev_info(dev, "%s: TIOCGICOUNT\n", __func__);
234 break;
235 default:
236 dev_info(dev, "%s: unknown (%d)\n", __func__, cmd);
237 }
238 return -ENOIOCTLCMD;
239}
240
241static int symbol_tiocmget(struct tty_struct *tty, struct file *file)
242{
243 struct usb_serial_port *port = tty->driver_data;
244 struct device *dev = &port->dev;
245
246 /* TODO */
247 /* probably just need to shadow whatever was sent to us here */
248 dev_info(dev, "%s\n", __func__);
249 return 0;
250}
251
252static int symbol_tiocmset(struct tty_struct *tty, struct file *file,
253 unsigned int set, unsigned int clear)
254{
255 struct usb_serial_port *port = tty->driver_data;
256 struct device *dev = &port->dev;
257
258 /* TODO */
259 /* probably just need to shadow whatever was sent to us here */
260 dev_info(dev, "%s\n", __func__);
261 return 0;
262}
263
264static int symbol_startup(struct usb_serial *serial)
265{
266 struct symbol_private *priv;
267 struct usb_host_interface *intf;
268 int i;
269 int retval = -ENOMEM;
270 bool int_in_found = false;
271
272 /* create our private serial structure */
273 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
274 if (priv == NULL) {
275 dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
276 return -ENOMEM;
277 }
278 spin_lock_init(&priv->lock);
279 priv->serial = serial;
280 priv->port = serial->port[0];
281 priv->udev = serial->dev;
282
283 /* find our interrupt endpoint */
284 intf = serial->interface->altsetting;
285 for (i = 0; i < intf->desc.bNumEndpoints; ++i) {
286 struct usb_endpoint_descriptor *endpoint;
287
288 endpoint = &intf->endpoint[i].desc;
289 if (!usb_endpoint_is_int_in(endpoint))
290 continue;
291
292 priv->int_urb = usb_alloc_urb(0, GFP_KERNEL);
293 if (!priv->int_urb) {
294 dev_err(&priv->udev->dev, "out of memory\n");
295 goto error;
296 }
297
298 priv->buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2;
299 priv->int_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
300 if (!priv->int_buffer) {
301 dev_err(&priv->udev->dev, "out of memory\n");
302 goto error;
303 }
304
305 priv->int_address = endpoint->bEndpointAddress;
306 priv->bInterval = endpoint->bInterval;
307
308 /* set up our int urb */
309 usb_fill_int_urb(priv->int_urb, priv->udev,
310 usb_rcvintpipe(priv->udev,
311 endpoint->bEndpointAddress),
312 priv->int_buffer, priv->buffer_size,
313 symbol_int_callback, priv, priv->bInterval);
314
315 int_in_found = true;
316 break;
317 }
318
319 if (!int_in_found) {
320 dev_err(&priv->udev->dev,
321 "Error - the proper endpoints were not found!\n");
322 goto error;
323 }
324
325 usb_set_serial_data(serial, priv);
326 return 0;
327
328error:
329 usb_free_urb(priv->int_urb);
330 kfree(priv->int_buffer);
331 kfree(priv);
332 return retval;
333}
334
335static void symbol_shutdown(struct usb_serial *serial)
336{
337 struct symbol_private *priv = usb_get_serial_data(serial);
338
339 dbg("%s", __func__);
340
341 usb_kill_urb(priv->int_urb);
342 usb_free_urb(priv->int_urb);
343 kfree(priv->int_buffer);
344 kfree(priv);
345 usb_set_serial_data(serial, NULL);
346}
347
348static struct usb_driver symbol_driver = {
349 .name = "symbol",
350 .probe = usb_serial_probe,
351 .disconnect = usb_serial_disconnect,
352 .id_table = id_table,
353 .no_dynamic_id = 1,
354};
355
356static struct usb_serial_driver symbol_device = {
357 .driver = {
358 .owner = THIS_MODULE,
359 .name = "symbol",
360 },
361 .id_table = id_table,
362 .usb_driver = &symbol_driver,
363 .num_ports = 1,
364 .attach = symbol_startup,
365 .open = symbol_open,
366 .close = symbol_close,
367 .shutdown = symbol_shutdown,
368 .throttle = symbol_throttle,
369 .unthrottle = symbol_unthrottle,
370 .ioctl = symbol_ioctl,
371 .tiocmget = symbol_tiocmget,
372 .tiocmset = symbol_tiocmset,
373};
374
375static int __init symbol_init(void)
376{
377 int retval;
378
379 retval = usb_serial_register(&symbol_device);
380 if (retval)
381 return retval;
382 retval = usb_register(&symbol_driver);
383 if (retval)
384 usb_serial_deregister(&symbol_device);
385 return retval;
386}
387
388static void __exit symbol_exit(void)
389{
390 usb_deregister(&symbol_driver);
391 usb_serial_deregister(&symbol_device);
392}
393
394module_init(symbol_init);
395module_exit(symbol_exit);
396MODULE_LICENSE("GPL");
397
398module_param(debug, bool, S_IRUGO | S_IWUSR);
399MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index cfcfd5ab06ce..742a5bc44be8 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -204,6 +204,11 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
204 goto bailout_kref_put; 204 goto bailout_kref_put;
205 } 205 }
206 206
207 if (port->serial->disconnected) {
208 retval = -ENODEV;
209 goto bailout_kref_put;
210 }
211
207 if (mutex_lock_interruptible(&port->mutex)) { 212 if (mutex_lock_interruptible(&port->mutex)) {
208 retval = -ERESTARTSYS; 213 retval = -ERESTARTSYS;
209 goto bailout_kref_put; 214 goto bailout_kref_put;
@@ -1067,6 +1072,8 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
1067 struct usb_serial_port *port; 1072 struct usb_serial_port *port;
1068 int i, r = 0; 1073 int i, r = 0;
1069 1074
1075 serial->suspending = 1;
1076
1070 for (i = 0; i < serial->num_ports; ++i) { 1077 for (i = 0; i < serial->num_ports; ++i) {
1071 port = serial->port[i]; 1078 port = serial->port[i];
1072 if (port) 1079 if (port)
@@ -1083,10 +1090,15 @@ EXPORT_SYMBOL(usb_serial_suspend);
1083int usb_serial_resume(struct usb_interface *intf) 1090int usb_serial_resume(struct usb_interface *intf)
1084{ 1091{
1085 struct usb_serial *serial = usb_get_intfdata(intf); 1092 struct usb_serial *serial = usb_get_intfdata(intf);
1093 int rv;
1086 1094
1095 serial->suspending = 0;
1087 if (serial->type->resume) 1096 if (serial->type->resume)
1088 return serial->type->resume(serial); 1097 rv = serial->type->resume(serial);
1089 return 0; 1098 else
1099 rv = usb_serial_generic_resume(serial);
1100
1101 return rv;
1090} 1102}
1091EXPORT_SYMBOL(usb_serial_resume); 1103EXPORT_SYMBOL(usb_serial_resume);
1092 1104
@@ -1222,7 +1234,6 @@ static void fixup_generic(struct usb_serial_driver *device)
1222 set_to_generic_if_null(device, read_bulk_callback); 1234 set_to_generic_if_null(device, read_bulk_callback);
1223 set_to_generic_if_null(device, write_bulk_callback); 1235 set_to_generic_if_null(device, write_bulk_callback);
1224 set_to_generic_if_null(device, shutdown); 1236 set_to_generic_if_null(device, shutdown);
1225 set_to_generic_if_null(device, resume);
1226} 1237}
1227 1238
1228int usb_serial_register(struct usb_serial_driver *driver) 1239int usb_serial_register(struct usb_serial_driver *driver)
@@ -1230,6 +1241,9 @@ int usb_serial_register(struct usb_serial_driver *driver)
1230 /* must be called with BKL held */ 1241 /* must be called with BKL held */
1231 int retval; 1242 int retval;
1232 1243
1244 if (usb_disabled())
1245 return -ENODEV;
1246
1233 fixup_generic(driver); 1247 fixup_generic(driver);
1234 1248
1235 if (!driver->description) 1249 if (!driver->description)
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index 9df6887b91f6..8a372bac0e43 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -2,8 +2,8 @@
2# USB Storage driver configuration 2# USB Storage driver configuration
3# 3#
4 4
5comment "NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;" 5comment "NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may"
6comment "see USB_STORAGE Help for more information" 6comment "also be needed; see USB_STORAGE Help for more info"
7 depends on USB 7 depends on USB
8 8
9config USB_STORAGE 9config USB_STORAGE
@@ -32,21 +32,25 @@ config USB_STORAGE_DEBUG
32 verbose debugging messages. 32 verbose debugging messages.
33 33
34config USB_STORAGE_DATAFAB 34config USB_STORAGE_DATAFAB
35 bool "Datafab Compact Flash Reader support" 35 tristate "Datafab Compact Flash Reader support"
36 depends on USB_STORAGE 36 depends on USB_STORAGE
37 help 37 help
38 Support for certain Datafab CompactFlash readers. 38 Support for certain Datafab CompactFlash readers.
39 Datafab has a web page at <http://www.datafabusa.com/>. 39 Datafab has a web page at <http://www.datafabusa.com/>.
40 40
41 If this driver is compiled as a module, it will be named ums-datafab.
42
41config USB_STORAGE_FREECOM 43config USB_STORAGE_FREECOM
42 bool "Freecom USB/ATAPI Bridge support" 44 tristate "Freecom USB/ATAPI Bridge support"
43 depends on USB_STORAGE 45 depends on USB_STORAGE
44 help 46 help
45 Support for the Freecom USB to IDE/ATAPI adaptor. 47 Support for the Freecom USB to IDE/ATAPI adaptor.
46 Freecom has a web page at <http://www.freecom.de/>. 48 Freecom has a web page at <http://www.freecom.de/>.
47 49
50 If this driver is compiled as a module, it will be named ums-freecom.
51
48config USB_STORAGE_ISD200 52config USB_STORAGE_ISD200
49 bool "ISD-200 USB/ATA Bridge support" 53 tristate "ISD-200 USB/ATA Bridge support"
50 depends on USB_STORAGE 54 depends on USB_STORAGE
51 ---help--- 55 ---help---
52 Say Y here if you want to use USB Mass Store devices based 56 Say Y here if you want to use USB Mass Store devices based
@@ -61,8 +65,10 @@ config USB_STORAGE_ISD200
61 - CyQ've CQ8060A CDRW drive 65 - CyQ've CQ8060A CDRW drive
62 - Planex eXtreme Drive RX-25HU USB-IDE cable (not model RX-25U) 66 - Planex eXtreme Drive RX-25HU USB-IDE cable (not model RX-25U)
63 67
68 If this driver is compiled as a module, it will be named ums-isd200.
69
64config USB_STORAGE_USBAT 70config USB_STORAGE_USBAT
65 bool "USBAT/USBAT02-based storage support" 71 tristate "USBAT/USBAT02-based storage support"
66 depends on USB_STORAGE 72 depends on USB_STORAGE
67 help 73 help
68 Say Y here to include additional code to support storage devices 74 Say Y here to include additional code to support storage devices
@@ -82,30 +88,38 @@ config USB_STORAGE_USBAT
82 - RCA LYRA MP3 portable 88 - RCA LYRA MP3 portable
83 - Sandisk ImageMate SDDR-05b 89 - Sandisk ImageMate SDDR-05b
84 90
91 If this driver is compiled as a module, it will be named ums-usbat.
92
85config USB_STORAGE_SDDR09 93config USB_STORAGE_SDDR09
86 bool "SanDisk SDDR-09 (and other SmartMedia, including DPCM) support" 94 tristate "SanDisk SDDR-09 (and other SmartMedia, including DPCM) support"
87 depends on USB_STORAGE 95 depends on USB_STORAGE
88 help 96 help
89 Say Y here to include additional code to support the Sandisk SDDR-09 97 Say Y here to include additional code to support the Sandisk SDDR-09
90 SmartMedia reader in the USB Mass Storage driver. 98 SmartMedia reader in the USB Mass Storage driver.
91 Also works for the Microtech Zio! CompactFlash/SmartMedia reader. 99 Also works for the Microtech Zio! CompactFlash/SmartMedia reader.
92 100
101 If this driver is compiled as a module, it will be named ums-sddr09.
102
93config USB_STORAGE_SDDR55 103config USB_STORAGE_SDDR55
94 bool "SanDisk SDDR-55 SmartMedia support" 104 tristate "SanDisk SDDR-55 SmartMedia support"
95 depends on USB_STORAGE 105 depends on USB_STORAGE
96 help 106 help
97 Say Y here to include additional code to support the Sandisk SDDR-55 107 Say Y here to include additional code to support the Sandisk SDDR-55
98 SmartMedia reader in the USB Mass Storage driver. 108 SmartMedia reader in the USB Mass Storage driver.
99 109
110 If this driver is compiled as a module, it will be named ums-sddr55.
111
100config USB_STORAGE_JUMPSHOT 112config USB_STORAGE_JUMPSHOT
101 bool "Lexar Jumpshot Compact Flash Reader" 113 tristate "Lexar Jumpshot Compact Flash Reader"
102 depends on USB_STORAGE 114 depends on USB_STORAGE
103 help 115 help
104 Say Y here to include additional code to support the Lexar Jumpshot 116 Say Y here to include additional code to support the Lexar Jumpshot
105 USB CompactFlash reader. 117 USB CompactFlash reader.
106 118
119 If this driver is compiled as a module, it will be named ums-jumpshot.
120
107config USB_STORAGE_ALAUDA 121config USB_STORAGE_ALAUDA
108 bool "Olympus MAUSB-10/Fuji DPC-R1 support" 122 tristate "Olympus MAUSB-10/Fuji DPC-R1 support"
109 depends on USB_STORAGE 123 depends on USB_STORAGE
110 help 124 help
111 Say Y here to include additional code to support the Olympus MAUSB-10 125 Say Y here to include additional code to support the Olympus MAUSB-10
@@ -114,8 +128,10 @@ config USB_STORAGE_ALAUDA
114 These devices are based on the Alauda chip and support both 128 These devices are based on the Alauda chip and support both
115 XD and SmartMedia cards. 129 XD and SmartMedia cards.
116 130
131 If this driver is compiled as a module, it will be named ums-alauda.
132
117config USB_STORAGE_ONETOUCH 133config USB_STORAGE_ONETOUCH
118 bool "Support OneTouch Button on Maxtor Hard Drives" 134 tristate "Support OneTouch Button on Maxtor Hard Drives"
119 depends on USB_STORAGE 135 depends on USB_STORAGE
120 depends on INPUT=y || INPUT=USB_STORAGE 136 depends on INPUT=y || INPUT=USB_STORAGE
121 help 137 help
@@ -127,8 +143,10 @@ config USB_STORAGE_ONETOUCH
127 this input in any keybinding software. (e.g. gnome's keyboard short- 143 this input in any keybinding software. (e.g. gnome's keyboard short-
128 cuts) 144 cuts)
129 145
146 If this driver is compiled as a module, it will be named ums-onetouch.
147
130config USB_STORAGE_KARMA 148config USB_STORAGE_KARMA
131 bool "Support for Rio Karma music player" 149 tristate "Support for Rio Karma music player"
132 depends on USB_STORAGE 150 depends on USB_STORAGE
133 help 151 help
134 Say Y here to include additional code to support the Rio Karma 152 Say Y here to include additional code to support the Rio Karma
@@ -139,8 +157,10 @@ config USB_STORAGE_KARMA
139 on the resulting scsi device node returns the Karma to normal 157 on the resulting scsi device node returns the Karma to normal
140 operation. 158 operation.
141 159
160 If this driver is compiled as a module, it will be named ums-karma.
161
142config USB_STORAGE_CYPRESS_ATACB 162config USB_STORAGE_CYPRESS_ATACB
143 bool "SAT emulation on Cypress USB/ATA Bridge with ATACB" 163 tristate "SAT emulation on Cypress USB/ATA Bridge with ATACB"
144 depends on USB_STORAGE 164 depends on USB_STORAGE
145 ---help--- 165 ---help---
146 Say Y here if you want to use SAT (ata pass through) on devices based 166 Say Y here if you want to use SAT (ata pass through) on devices based
@@ -150,6 +170,8 @@ config USB_STORAGE_CYPRESS_ATACB
150 If you say no here your device will still work with the standard usb 170 If you say no here your device will still work with the standard usb
151 mass storage class. 171 mass storage class.
152 172
173 If this driver is compiled as a module, it will be named ums-cypress.
174
153config USB_LIBUSUAL 175config USB_LIBUSUAL
154 bool "The shared table of common (or usual) storage devices" 176 bool "The shared table of common (or usual) storage devices"
155 depends on USB 177 depends on USB
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index b32069313390..5be54c019662 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -10,21 +10,36 @@ EXTRA_CFLAGS := -Idrivers/scsi
10obj-$(CONFIG_USB_STORAGE) += usb-storage.o 10obj-$(CONFIG_USB_STORAGE) += usb-storage.o
11 11
12usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG) += debug.o 12usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG) += debug.o
13usb-storage-obj-$(CONFIG_USB_STORAGE_USBAT) += shuttle_usbat.o
14usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR09) += sddr09.o
15usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR55) += sddr55.o
16usb-storage-obj-$(CONFIG_USB_STORAGE_FREECOM) += freecom.o
17usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200) += isd200.o
18usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o
19usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
20usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o
21usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
22usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o
23usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o
24 13
25usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ 14usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
26 initializers.o sierra_ms.o option_ms.o $(usb-storage-obj-y) 15 initializers.o sierra_ms.o option_ms.o $(usb-storage-obj-y)
27 16
28ifneq ($(CONFIG_USB_LIBUSUAL),) 17ifeq ($(CONFIG_USB_LIBUSUAL),)
29 obj-$(CONFIG_USB) += libusual.o 18 usb-storage-objs += usual-tables.o
19else
20 obj-$(CONFIG_USB) += libusual.o usual-tables.o
30endif 21endif
22
23obj-$(CONFIG_USB_STORAGE_ALAUDA) += ums-alauda.o
24obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.o
25obj-$(CONFIG_USB_STORAGE_DATAFAB) += ums-datafab.o
26obj-$(CONFIG_USB_STORAGE_FREECOM) += ums-freecom.o
27obj-$(CONFIG_USB_STORAGE_ISD200) += ums-isd200.o
28obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += ums-jumpshot.o
29obj-$(CONFIG_USB_STORAGE_KARMA) += ums-karma.o
30obj-$(CONFIG_USB_STORAGE_ONETOUCH) += ums-onetouch.o
31obj-$(CONFIG_USB_STORAGE_SDDR09) += ums-sddr09.o
32obj-$(CONFIG_USB_STORAGE_SDDR55) += ums-sddr55.o
33obj-$(CONFIG_USB_STORAGE_USBAT) += ums-usbat.o
34
35ums-alauda-objs := alauda.o
36ums-cypress-objs := cypress_atacb.o
37ums-datafab-objs := datafab.o
38ums-freecom-objs := freecom.o
39ums-isd200-objs := isd200.o
40ums-jumpshot-objs := jumpshot.o
41ums-karma-objs := karma.o
42ums-onetouch-objs := onetouch.o
43ums-sddr09-objs := sddr09.o
44ums-sddr55-objs := sddr55.o
45ums-usbat-objs := shuttle_usbat.o
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index 8d3711a7ff06..67edc65acb8e 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -31,6 +31,8 @@
31 * 675 Mass Ave, Cambridge, MA 02139, USA. 31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */ 32 */
33 33
34#include <linux/module.h>
35
34#include <scsi/scsi.h> 36#include <scsi/scsi.h>
35#include <scsi/scsi_cmnd.h> 37#include <scsi/scsi_cmnd.h>
36#include <scsi/scsi_device.h> 38#include <scsi/scsi_device.h>
@@ -39,7 +41,79 @@
39#include "transport.h" 41#include "transport.h"
40#include "protocol.h" 42#include "protocol.h"
41#include "debug.h" 43#include "debug.h"
42#include "alauda.h" 44
45MODULE_DESCRIPTION("Driver for Alauda-based card readers");
46MODULE_AUTHOR("Daniel Drake <dsd@gentoo.org>");
47MODULE_LICENSE("GPL");
48
49/*
50 * Status bytes
51 */
52#define ALAUDA_STATUS_ERROR 0x01
53#define ALAUDA_STATUS_READY 0x40
54
55/*
56 * Control opcodes (for request field)
57 */
58#define ALAUDA_GET_XD_MEDIA_STATUS 0x08
59#define ALAUDA_GET_SM_MEDIA_STATUS 0x98
60#define ALAUDA_ACK_XD_MEDIA_CHANGE 0x0a
61#define ALAUDA_ACK_SM_MEDIA_CHANGE 0x9a
62#define ALAUDA_GET_XD_MEDIA_SIG 0x86
63#define ALAUDA_GET_SM_MEDIA_SIG 0x96
64
65/*
66 * Bulk command identity (byte 0)
67 */
68#define ALAUDA_BULK_CMD 0x40
69
70/*
71 * Bulk opcodes (byte 1)
72 */
73#define ALAUDA_BULK_GET_REDU_DATA 0x85
74#define ALAUDA_BULK_READ_BLOCK 0x94
75#define ALAUDA_BULK_ERASE_BLOCK 0xa3
76#define ALAUDA_BULK_WRITE_BLOCK 0xb4
77#define ALAUDA_BULK_GET_STATUS2 0xb7
78#define ALAUDA_BULK_RESET_MEDIA 0xe0
79
80/*
81 * Port to operate on (byte 8)
82 */
83#define ALAUDA_PORT_XD 0x00
84#define ALAUDA_PORT_SM 0x01
85
86/*
87 * LBA and PBA are unsigned ints. Special values.
88 */
89#define UNDEF 0xffff
90#define SPARE 0xfffe
91#define UNUSABLE 0xfffd
92
93struct alauda_media_info {
94 unsigned long capacity; /* total media size in bytes */
95 unsigned int pagesize; /* page size in bytes */
96 unsigned int blocksize; /* number of pages per block */
97 unsigned int uzonesize; /* number of usable blocks per zone */
98 unsigned int zonesize; /* number of blocks per zone */
99 unsigned int blockmask; /* mask to get page from address */
100
101 unsigned char pageshift;
102 unsigned char blockshift;
103 unsigned char zoneshift;
104
105 u16 **lba_to_pba; /* logical to physical block map */
106 u16 **pba_to_lba; /* physical to logical block map */
107};
108
109struct alauda_info {
110 struct alauda_media_info port[2];
111 int wr_ep; /* endpoint to write data out of */
112
113 unsigned char sense_key;
114 unsigned long sense_asc; /* additional sense code */
115 unsigned long sense_ascq; /* additional sense code qualifier */
116};
43 117
44#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) 118#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
45#define LSB_of(s) ((s)&0xFF) 119#define LSB_of(s) ((s)&0xFF)
@@ -52,6 +126,48 @@
52#define PBA_HI(pba) (pba >> 3) 126#define PBA_HI(pba) (pba >> 3)
53#define PBA_ZONE(pba) (pba >> 11) 127#define PBA_ZONE(pba) (pba >> 11)
54 128
129static int init_alauda(struct us_data *us);
130
131
132/*
133 * The table of devices
134 */
135#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
136 vendorName, productName, useProtocol, useTransport, \
137 initFunction, flags) \
138{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
139 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
140
141struct usb_device_id alauda_usb_ids[] = {
142# include "unusual_alauda.h"
143 { } /* Terminating entry */
144};
145MODULE_DEVICE_TABLE(usb, alauda_usb_ids);
146
147#undef UNUSUAL_DEV
148
149/*
150 * The flags table
151 */
152#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
153 vendor_name, product_name, use_protocol, use_transport, \
154 init_function, Flags) \
155{ \
156 .vendorName = vendor_name, \
157 .productName = product_name, \
158 .useProtocol = use_protocol, \
159 .useTransport = use_transport, \
160 .initFunction = init_function, \
161}
162
163static struct us_unusual_dev alauda_unusual_dev_list[] = {
164# include "unusual_alauda.h"
165 { } /* Terminating entry */
166};
167
168#undef UNUSUAL_DEV
169
170
55/* 171/*
56 * Media handling 172 * Media handling
57 */ 173 */
@@ -307,7 +423,8 @@ static int alauda_init_media(struct us_data *us)
307 data[0], data[1], data[2], data[3]); 423 data[0], data[1], data[2], data[3]);
308 media_info = alauda_card_find_id(data[1]); 424 media_info = alauda_card_find_id(data[1]);
309 if (media_info == NULL) { 425 if (media_info == NULL) {
310 printk("alauda_init_media: Unrecognised media signature: " 426 printk(KERN_WARNING
427 "alauda_init_media: Unrecognised media signature: "
311 "%02X %02X %02X %02X\n", 428 "%02X %02X %02X %02X\n",
312 data[0], data[1], data[2], data[3]); 429 data[0], data[1], data[2], data[3]);
313 return USB_STOR_TRANSPORT_ERROR; 430 return USB_STOR_TRANSPORT_ERROR;
@@ -518,7 +635,8 @@ static int alauda_read_map(struct us_data *us, unsigned int zone)
518 635
519 /* check even parity */ 636 /* check even parity */
520 if (parity[data[6] ^ data[7]]) { 637 if (parity[data[6] ^ data[7]]) {
521 printk("alauda_read_map: Bad parity in LBA for block %d" 638 printk(KERN_WARNING
639 "alauda_read_map: Bad parity in LBA for block %d"
522 " (%02X %02X)\n", i, data[6], data[7]); 640 " (%02X %02X)\n", i, data[6], data[7]);
523 pba_to_lba[i] = UNUSABLE; 641 pba_to_lba[i] = UNUSABLE;
524 continue; 642 continue;
@@ -538,13 +656,16 @@ static int alauda_read_map(struct us_data *us, unsigned int zone)
538 */ 656 */
539 657
540 if (lba_offset >= uzonesize) { 658 if (lba_offset >= uzonesize) {
541 printk("alauda_read_map: Bad low LBA %d for block %d\n", 659 printk(KERN_WARNING
660 "alauda_read_map: Bad low LBA %d for block %d\n",
542 lba_real, blocknum); 661 lba_real, blocknum);
543 continue; 662 continue;
544 } 663 }
545 664
546 if (lba_to_pba[lba_offset] != UNDEF) { 665 if (lba_to_pba[lba_offset] != UNDEF) {
547 printk("alauda_read_map: LBA %d seen for PBA %d and %d\n", 666 printk(KERN_WARNING
667 "alauda_read_map: "
668 "LBA %d seen for PBA %d and %d\n",
548 lba_real, lba_to_pba[lba_offset], blocknum); 669 lba_real, lba_to_pba[lba_offset], blocknum);
549 continue; 670 continue;
550 } 671 }
@@ -712,13 +833,15 @@ static int alauda_write_lba(struct us_data *us, u16 lba,
712 if (pba == 1) { 833 if (pba == 1) {
713 /* Maybe it is impossible to write to PBA 1. 834 /* Maybe it is impossible to write to PBA 1.
714 Fake success, but don't do anything. */ 835 Fake success, but don't do anything. */
715 printk("alauda_write_lba: avoid writing to pba 1\n"); 836 printk(KERN_WARNING
837 "alauda_write_lba: avoid writing to pba 1\n");
716 return USB_STOR_TRANSPORT_GOOD; 838 return USB_STOR_TRANSPORT_GOOD;
717 } 839 }
718 840
719 new_pba = alauda_find_unused_pba(&MEDIA_INFO(us), zone); 841 new_pba = alauda_find_unused_pba(&MEDIA_INFO(us), zone);
720 if (!new_pba) { 842 if (!new_pba) {
721 printk("alauda_write_lba: Out of unused blocks\n"); 843 printk(KERN_WARNING
844 "alauda_write_lba: Out of unused blocks\n");
722 return USB_STOR_TRANSPORT_ERROR; 845 return USB_STOR_TRANSPORT_ERROR;
723 } 846 }
724 847
@@ -818,7 +941,7 @@ static int alauda_read_data(struct us_data *us, unsigned long address,
818 len = min(sectors, blocksize) * (pagesize + 64); 941 len = min(sectors, blocksize) * (pagesize + 64);
819 buffer = kmalloc(len, GFP_NOIO); 942 buffer = kmalloc(len, GFP_NOIO);
820 if (buffer == NULL) { 943 if (buffer == NULL) {
821 printk("alauda_read_data: Out of memory\n"); 944 printk(KERN_WARNING "alauda_read_data: Out of memory\n");
822 return USB_STOR_TRANSPORT_ERROR; 945 return USB_STOR_TRANSPORT_ERROR;
823 } 946 }
824 947
@@ -911,7 +1034,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address,
911 len = min(sectors, blocksize) * pagesize; 1034 len = min(sectors, blocksize) * pagesize;
912 buffer = kmalloc(len, GFP_NOIO); 1035 buffer = kmalloc(len, GFP_NOIO);
913 if (buffer == NULL) { 1036 if (buffer == NULL) {
914 printk("alauda_write_data: Out of memory\n"); 1037 printk(KERN_WARNING "alauda_write_data: Out of memory\n");
915 return USB_STOR_TRANSPORT_ERROR; 1038 return USB_STOR_TRANSPORT_ERROR;
916 } 1039 }
917 1040
@@ -921,7 +1044,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address,
921 */ 1044 */
922 blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO); 1045 blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO);
923 if (blockbuffer == NULL) { 1046 if (blockbuffer == NULL) {
924 printk("alauda_write_data: Out of memory\n"); 1047 printk(KERN_WARNING "alauda_write_data: Out of memory\n");
925 kfree(buffer); 1048 kfree(buffer);
926 return USB_STOR_TRANSPORT_ERROR; 1049 return USB_STOR_TRANSPORT_ERROR;
927 } 1050 }
@@ -991,7 +1114,7 @@ static void alauda_info_destructor(void *extra)
991/* 1114/*
992 * Initialize alauda_info struct and find the data-write endpoint 1115 * Initialize alauda_info struct and find the data-write endpoint
993 */ 1116 */
994int init_alauda(struct us_data *us) 1117static int init_alauda(struct us_data *us)
995{ 1118{
996 struct alauda_info *info; 1119 struct alauda_info *info;
997 struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting; 1120 struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting;
@@ -1013,7 +1136,7 @@ int init_alauda(struct us_data *us)
1013 return USB_STOR_TRANSPORT_GOOD; 1136 return USB_STOR_TRANSPORT_GOOD;
1014} 1137}
1015 1138
1016int alauda_transport(struct scsi_cmnd *srb, struct us_data *us) 1139static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
1017{ 1140{
1018 int rc; 1141 int rc;
1019 struct alauda_info *info = (struct alauda_info *) us->extra; 1142 struct alauda_info *info = (struct alauda_info *) us->extra;
@@ -1121,3 +1244,48 @@ int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
1121 return USB_STOR_TRANSPORT_FAILED; 1244 return USB_STOR_TRANSPORT_FAILED;
1122} 1245}
1123 1246
1247static int alauda_probe(struct usb_interface *intf,
1248 const struct usb_device_id *id)
1249{
1250 struct us_data *us;
1251 int result;
1252
1253 result = usb_stor_probe1(&us, intf, id,
1254 (id - alauda_usb_ids) + alauda_unusual_dev_list);
1255 if (result)
1256 return result;
1257
1258 us->transport_name = "Alauda Control/Bulk";
1259 us->transport = alauda_transport;
1260 us->transport_reset = usb_stor_Bulk_reset;
1261 us->max_lun = 1;
1262
1263 result = usb_stor_probe2(us);
1264 return result;
1265}
1266
1267static struct usb_driver alauda_driver = {
1268 .name = "ums-alauda",
1269 .probe = alauda_probe,
1270 .disconnect = usb_stor_disconnect,
1271 .suspend = usb_stor_suspend,
1272 .resume = usb_stor_resume,
1273 .reset_resume = usb_stor_reset_resume,
1274 .pre_reset = usb_stor_pre_reset,
1275 .post_reset = usb_stor_post_reset,
1276 .id_table = alauda_usb_ids,
1277 .soft_unbind = 1,
1278};
1279
1280static int __init alauda_init(void)
1281{
1282 return usb_register(&alauda_driver);
1283}
1284
1285static void __exit alauda_exit(void)
1286{
1287 usb_deregister(&alauda_driver);
1288}
1289
1290module_init(alauda_init);
1291module_exit(alauda_exit);
diff --git a/drivers/usb/storage/alauda.h b/drivers/usb/storage/alauda.h
deleted file mode 100644
index a700f87d0803..000000000000
--- a/drivers/usb/storage/alauda.h
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * Driver for Alauda-based card readers
3 *
4 * Current development and maintenance by:
5 * (c) 2005 Daniel Drake <dsd@gentoo.org>
6 *
7 * See alauda.c for more explanation.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
12 * 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. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#ifndef _USB_ALAUDA_H
25#define _USB_ALAUDA_H
26
27/*
28 * Status bytes
29 */
30#define ALAUDA_STATUS_ERROR 0x01
31#define ALAUDA_STATUS_READY 0x40
32
33/*
34 * Control opcodes (for request field)
35 */
36#define ALAUDA_GET_XD_MEDIA_STATUS 0x08
37#define ALAUDA_GET_SM_MEDIA_STATUS 0x98
38#define ALAUDA_ACK_XD_MEDIA_CHANGE 0x0a
39#define ALAUDA_ACK_SM_MEDIA_CHANGE 0x9a
40#define ALAUDA_GET_XD_MEDIA_SIG 0x86
41#define ALAUDA_GET_SM_MEDIA_SIG 0x96
42
43/*
44 * Bulk command identity (byte 0)
45 */
46#define ALAUDA_BULK_CMD 0x40
47
48/*
49 * Bulk opcodes (byte 1)
50 */
51#define ALAUDA_BULK_GET_REDU_DATA 0x85
52#define ALAUDA_BULK_READ_BLOCK 0x94
53#define ALAUDA_BULK_ERASE_BLOCK 0xa3
54#define ALAUDA_BULK_WRITE_BLOCK 0xb4
55#define ALAUDA_BULK_GET_STATUS2 0xb7
56#define ALAUDA_BULK_RESET_MEDIA 0xe0
57
58/*
59 * Port to operate on (byte 8)
60 */
61#define ALAUDA_PORT_XD 0x00
62#define ALAUDA_PORT_SM 0x01
63
64/*
65 * LBA and PBA are unsigned ints. Special values.
66 */
67#define UNDEF 0xffff
68#define SPARE 0xfffe
69#define UNUSABLE 0xfffd
70
71int init_alauda(struct us_data *us);
72int alauda_transport(struct scsi_cmnd *srb, struct us_data *us);
73
74struct alauda_media_info {
75 unsigned long capacity; /* total media size in bytes */
76 unsigned int pagesize; /* page size in bytes */
77 unsigned int blocksize; /* number of pages per block */
78 unsigned int uzonesize; /* number of usable blocks per zone */
79 unsigned int zonesize; /* number of blocks per zone */
80 unsigned int blockmask; /* mask to get page from address */
81
82 unsigned char pageshift;
83 unsigned char blockshift;
84 unsigned char zoneshift;
85
86 u16 **lba_to_pba; /* logical to physical block map */
87 u16 **pba_to_lba; /* physical to logical block map */
88};
89
90struct alauda_info {
91 struct alauda_media_info port[2];
92 int wr_ep; /* endpoint to write data out of */
93
94 unsigned char sense_key;
95 unsigned long sense_asc; /* additional sense code */
96 unsigned long sense_ascq; /* additional sense code qualifier */
97};
98
99#endif
100
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
index 898e67d30e56..c84471821183 100644
--- a/drivers/usb/storage/cypress_atacb.c
+++ b/drivers/usb/storage/cypress_atacb.c
@@ -19,6 +19,7 @@
19 * 675 Mass Ave, Cambridge, MA 02139, USA. 19 * 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/module.h>
22#include <scsi/scsi.h> 23#include <scsi/scsi.h>
23#include <scsi/scsi_cmnd.h> 24#include <scsi/scsi_cmnd.h>
24#include <scsi/scsi_eh.h> 25#include <scsi/scsi_eh.h>
@@ -29,6 +30,49 @@
29#include "scsiglue.h" 30#include "scsiglue.h"
30#include "debug.h" 31#include "debug.h"
31 32
33MODULE_DESCRIPTION("SAT support for Cypress USB/ATA bridges with ATACB");
34MODULE_AUTHOR("Matthieu Castet <castet.matthieu@free.fr>");
35MODULE_LICENSE("GPL");
36
37/*
38 * The table of devices
39 */
40#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
41 vendorName, productName, useProtocol, useTransport, \
42 initFunction, flags) \
43{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
44 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
45
46struct usb_device_id cypress_usb_ids[] = {
47# include "unusual_cypress.h"
48 { } /* Terminating entry */
49};
50MODULE_DEVICE_TABLE(usb, cypress_usb_ids);
51
52#undef UNUSUAL_DEV
53
54/*
55 * The flags table
56 */
57#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
58 vendor_name, product_name, use_protocol, use_transport, \
59 init_function, Flags) \
60{ \
61 .vendorName = vendor_name, \
62 .productName = product_name, \
63 .useProtocol = use_protocol, \
64 .useTransport = use_transport, \
65 .initFunction = init_function, \
66}
67
68static struct us_unusual_dev cypress_unusual_dev_list[] = {
69# include "unusual_cypress.h"
70 { } /* Terminating entry */
71};
72
73#undef UNUSUAL_DEV
74
75
32/* 76/*
33 * ATACB is a protocol used on cypress usb<->ata bridge to 77 * ATACB is a protocol used on cypress usb<->ata bridge to
34 * send raw ATA command over mass storage 78 * send raw ATA command over mass storage
@@ -36,7 +80,7 @@
36 * More info that be found on cy7c68310_8.pdf and cy7c68300c_8.pdf 80 * More info that be found on cy7c68310_8.pdf and cy7c68300c_8.pdf
37 * datasheet from cypress.com. 81 * datasheet from cypress.com.
38 */ 82 */
39void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) 83static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
40{ 84{
41 unsigned char save_cmnd[MAX_COMMAND_SIZE]; 85 unsigned char save_cmnd[MAX_COMMAND_SIZE];
42 86
@@ -133,19 +177,18 @@ void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
133 177
134 /* build the command for 178 /* build the command for
135 * reading the ATA registers */ 179 * reading the ATA registers */
136 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, 0); 180 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sizeof(regs));
137 srb->sdb.length = sizeof(regs); 181
138 sg_init_one(&ses.sense_sgl, regs, srb->sdb.length);
139 srb->sdb.table.sgl = &ses.sense_sgl;
140 srb->sc_data_direction = DMA_FROM_DEVICE;
141 srb->sdb.table.nents = 1;
142 /* we use the same command as before, but we set 182 /* we use the same command as before, but we set
143 * the read taskfile bit, for not executing atacb command, 183 * the read taskfile bit, for not executing atacb command,
144 * but reading register selected in srb->cmnd[4] 184 * but reading register selected in srb->cmnd[4]
145 */ 185 */
186 srb->cmd_len = 16;
187 srb->cmnd = ses.cmnd;
146 srb->cmnd[2] = 1; 188 srb->cmnd[2] = 1;
147 189
148 usb_stor_transparent_scsi_command(srb, us); 190 usb_stor_transparent_scsi_command(srb, us);
191 memcpy(regs, srb->sense_buffer, sizeof(regs));
149 tmp_result = srb->result; 192 tmp_result = srb->result;
150 scsi_eh_restore_cmnd(srb, &ses); 193 scsi_eh_restore_cmnd(srb, &ses);
151 /* we fail to get registers, report invalid command */ 194 /* we fail to get registers, report invalid command */
@@ -162,8 +205,8 @@ void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
162 205
163 /* XXX we should generate sk, asc, ascq from status and error 206 /* XXX we should generate sk, asc, ascq from status and error
164 * regs 207 * regs
165 * (see 11.1 Error translation ­ ATA device error to SCSI error map) 208 * (see 11.1 Error translation ATA device error to SCSI error
166 * and ata_to_sense_error from libata. 209 * map, and ata_to_sense_error from libata.)
167 */ 210 */
168 211
169 /* Sense data is current and format is descriptor. */ 212 /* Sense data is current and format is descriptor. */
@@ -198,3 +241,48 @@ end:
198 if (srb->cmnd[0] == ATA_12) 241 if (srb->cmnd[0] == ATA_12)
199 srb->cmd_len = 12; 242 srb->cmd_len = 12;
200} 243}
244
245
246static int cypress_probe(struct usb_interface *intf,
247 const struct usb_device_id *id)
248{
249 struct us_data *us;
250 int result;
251
252 result = usb_stor_probe1(&us, intf, id,
253 (id - cypress_usb_ids) + cypress_unusual_dev_list);
254 if (result)
255 return result;
256
257 us->protocol_name = "Transparent SCSI with Cypress ATACB";
258 us->proto_handler = cypress_atacb_passthrough;
259
260 result = usb_stor_probe2(us);
261 return result;
262}
263
264static struct usb_driver cypress_driver = {
265 .name = "ums-cypress",
266 .probe = cypress_probe,
267 .disconnect = usb_stor_disconnect,
268 .suspend = usb_stor_suspend,
269 .resume = usb_stor_resume,
270 .reset_resume = usb_stor_reset_resume,
271 .pre_reset = usb_stor_pre_reset,
272 .post_reset = usb_stor_post_reset,
273 .id_table = cypress_usb_ids,
274 .soft_unbind = 1,
275};
276
277static int __init cypress_init(void)
278{
279 return usb_register(&cypress_driver);
280}
281
282static void __exit cypress_exit(void)
283{
284 usb_deregister(&cypress_driver);
285}
286
287module_init(cypress_init);
288module_exit(cypress_exit);
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
index 17f1ae232919..2b6e565262c2 100644
--- a/drivers/usb/storage/datafab.c
+++ b/drivers/usb/storage/datafab.c
@@ -49,6 +49,7 @@
49 */ 49 */
50 50
51#include <linux/errno.h> 51#include <linux/errno.h>
52#include <linux/module.h>
52#include <linux/slab.h> 53#include <linux/slab.h>
53 54
54#include <scsi/scsi.h> 55#include <scsi/scsi.h>
@@ -58,12 +59,65 @@
58#include "transport.h" 59#include "transport.h"
59#include "protocol.h" 60#include "protocol.h"
60#include "debug.h" 61#include "debug.h"
61#include "datafab.h" 62
63MODULE_DESCRIPTION("Driver for Datafab USB Compact Flash reader");
64MODULE_AUTHOR("Jimmie Mayfield <mayfield+datafab@sackheads.org>");
65MODULE_LICENSE("GPL");
66
67struct datafab_info {
68 unsigned long sectors; /* total sector count */
69 unsigned long ssize; /* sector size in bytes */
70 signed char lun; /* used for dual-slot readers */
71
72 /* the following aren't used yet */
73 unsigned char sense_key;
74 unsigned long sense_asc; /* additional sense code */
75 unsigned long sense_ascq; /* additional sense code qualifier */
76};
62 77
63static int datafab_determine_lun(struct us_data *us, 78static int datafab_determine_lun(struct us_data *us,
64 struct datafab_info *info); 79 struct datafab_info *info);
65 80
66 81
82/*
83 * The table of devices
84 */
85#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
86 vendorName, productName, useProtocol, useTransport, \
87 initFunction, flags) \
88{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
89 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
90
91struct usb_device_id datafab_usb_ids[] = {
92# include "unusual_datafab.h"
93 { } /* Terminating entry */
94};
95MODULE_DEVICE_TABLE(usb, datafab_usb_ids);
96
97#undef UNUSUAL_DEV
98
99/*
100 * The flags table
101 */
102#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
103 vendor_name, product_name, use_protocol, use_transport, \
104 init_function, Flags) \
105{ \
106 .vendorName = vendor_name, \
107 .productName = product_name, \
108 .useProtocol = use_protocol, \
109 .useTransport = use_transport, \
110 .initFunction = init_function, \
111}
112
113static struct us_unusual_dev datafab_unusual_dev_list[] = {
114# include "unusual_datafab.h"
115 { } /* Terminating entry */
116};
117
118#undef UNUSUAL_DEV
119
120
67static inline int 121static inline int
68datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) { 122datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) {
69 if (len == 0) 123 if (len == 0)
@@ -500,7 +554,7 @@ static void datafab_info_destructor(void *extra)
500 554
501// Transport for the Datafab MDCFE-B 555// Transport for the Datafab MDCFE-B
502// 556//
503int datafab_transport(struct scsi_cmnd * srb, struct us_data *us) 557static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
504{ 558{
505 struct datafab_info *info; 559 struct datafab_info *info;
506 int rc; 560 int rc;
@@ -665,3 +719,49 @@ int datafab_transport(struct scsi_cmnd * srb, struct us_data *us)
665 info->sense_ascq = 0x00; 719 info->sense_ascq = 0x00;
666 return USB_STOR_TRANSPORT_FAILED; 720 return USB_STOR_TRANSPORT_FAILED;
667} 721}
722
723static int datafab_probe(struct usb_interface *intf,
724 const struct usb_device_id *id)
725{
726 struct us_data *us;
727 int result;
728
729 result = usb_stor_probe1(&us, intf, id,
730 (id - datafab_usb_ids) + datafab_unusual_dev_list);
731 if (result)
732 return result;
733
734 us->transport_name = "Datafab Bulk-Only";
735 us->transport = datafab_transport;
736 us->transport_reset = usb_stor_Bulk_reset;
737 us->max_lun = 1;
738
739 result = usb_stor_probe2(us);
740 return result;
741}
742
743static struct usb_driver datafab_driver = {
744 .name = "ums-datafab",
745 .probe = datafab_probe,
746 .disconnect = usb_stor_disconnect,
747 .suspend = usb_stor_suspend,
748 .resume = usb_stor_resume,
749 .reset_resume = usb_stor_reset_resume,
750 .pre_reset = usb_stor_pre_reset,
751 .post_reset = usb_stor_post_reset,
752 .id_table = datafab_usb_ids,
753 .soft_unbind = 1,
754};
755
756static int __init datafab_init(void)
757{
758 return usb_register(&datafab_driver);
759}
760
761static void __exit datafab_exit(void)
762{
763 usb_deregister(&datafab_driver);
764}
765
766module_init(datafab_init);
767module_exit(datafab_exit);
diff --git a/drivers/usb/storage/datafab.h b/drivers/usb/storage/datafab.h
deleted file mode 100644
index 32e3f271e582..000000000000
--- a/drivers/usb/storage/datafab.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/* Driver for Datafab MDCFE-B USB Compact Flash reader
2 * Header File
3 *
4 * Current development and maintenance by:
5 * (c) 2000 Jimmie Mayfield (mayfield+datafab@sackheads.org)
6 *
7 * See datafab.c for more explanation
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
12 * 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. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#ifndef _USB_DATAFAB_MDCFE_B_H
25#define _USB_DATAFAB_MDCFE_B_H
26
27extern int datafab_transport(struct scsi_cmnd *srb, struct us_data *us);
28
29struct datafab_info {
30 unsigned long sectors; // total sector count
31 unsigned long ssize; // sector size in bytes
32 signed char lun; // used for dual-slot readers
33
34 // the following aren't used yet
35 unsigned char sense_key;
36 unsigned long sense_asc; // additional sense code
37 unsigned long sense_ascq; // additional sense code qualifier
38};
39
40#endif
diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
index 73ac7262239e..54cc94277acb 100644
--- a/drivers/usb/storage/freecom.c
+++ b/drivers/usb/storage/freecom.c
@@ -26,6 +26,7 @@
26 * (http://www.freecom.de/) 26 * (http://www.freecom.de/)
27 */ 27 */
28 28
29#include <linux/module.h>
29#include <scsi/scsi.h> 30#include <scsi/scsi.h>
30#include <scsi/scsi_cmnd.h> 31#include <scsi/scsi_cmnd.h>
31 32
@@ -33,7 +34,10 @@
33#include "transport.h" 34#include "transport.h"
34#include "protocol.h" 35#include "protocol.h"
35#include "debug.h" 36#include "debug.h"
36#include "freecom.h" 37
38MODULE_DESCRIPTION("Driver for Freecom USB/IDE adaptor");
39MODULE_AUTHOR("David Brown <usb-storage@davidb.org>");
40MODULE_LICENSE("GPL");
37 41
38#ifdef CONFIG_USB_STORAGE_DEBUG 42#ifdef CONFIG_USB_STORAGE_DEBUG
39static void pdump (void *, int); 43static void pdump (void *, int);
@@ -103,6 +107,47 @@ struct freecom_status {
103#define FCM_PACKET_LENGTH 64 107#define FCM_PACKET_LENGTH 64
104#define FCM_STATUS_PACKET_LENGTH 4 108#define FCM_STATUS_PACKET_LENGTH 4
105 109
110static int init_freecom(struct us_data *us);
111
112
113/*
114 * The table of devices
115 */
116#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
117 vendorName, productName, useProtocol, useTransport, \
118 initFunction, flags) \
119{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
120 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
121
122struct usb_device_id freecom_usb_ids[] = {
123# include "unusual_freecom.h"
124 { } /* Terminating entry */
125};
126MODULE_DEVICE_TABLE(usb, freecom_usb_ids);
127
128#undef UNUSUAL_DEV
129
130/*
131 * The flags table
132 */
133#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
134 vendor_name, product_name, use_protocol, use_transport, \
135 init_function, Flags) \
136{ \
137 .vendorName = vendor_name, \
138 .productName = product_name, \
139 .useProtocol = use_protocol, \
140 .useTransport = use_transport, \
141 .initFunction = init_function, \
142}
143
144static struct us_unusual_dev freecom_unusual_dev_list[] = {
145# include "unusual_freecom.h"
146 { } /* Terminating entry */
147};
148
149#undef UNUSUAL_DEV
150
106static int 151static int
107freecom_readdata (struct scsi_cmnd *srb, struct us_data *us, 152freecom_readdata (struct scsi_cmnd *srb, struct us_data *us,
108 unsigned int ipipe, unsigned int opipe, int count) 153 unsigned int ipipe, unsigned int opipe, int count)
@@ -173,7 +218,7 @@ freecom_writedata (struct scsi_cmnd *srb, struct us_data *us,
173 * Transport for the Freecom USB/IDE adaptor. 218 * Transport for the Freecom USB/IDE adaptor.
174 * 219 *
175 */ 220 */
176int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) 221static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
177{ 222{
178 struct freecom_cb_wrap *fcb; 223 struct freecom_cb_wrap *fcb;
179 struct freecom_status *fst; 224 struct freecom_status *fst;
@@ -377,8 +422,7 @@ int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
377 return USB_STOR_TRANSPORT_GOOD; 422 return USB_STOR_TRANSPORT_GOOD;
378} 423}
379 424
380int 425static int init_freecom(struct us_data *us)
381freecom_init (struct us_data *us)
382{ 426{
383 int result; 427 int result;
384 char *buffer = us->iobuf; 428 char *buffer = us->iobuf;
@@ -417,7 +461,7 @@ freecom_init (struct us_data *us)
417 return USB_STOR_TRANSPORT_GOOD; 461 return USB_STOR_TRANSPORT_GOOD;
418} 462}
419 463
420int usb_stor_freecom_reset(struct us_data *us) 464static int usb_stor_freecom_reset(struct us_data *us)
421{ 465{
422 printk (KERN_CRIT "freecom reset called\n"); 466 printk (KERN_CRIT "freecom reset called\n");
423 467
@@ -479,3 +523,48 @@ static void pdump (void *ibuffer, int length)
479} 523}
480#endif 524#endif
481 525
526static int freecom_probe(struct usb_interface *intf,
527 const struct usb_device_id *id)
528{
529 struct us_data *us;
530 int result;
531
532 result = usb_stor_probe1(&us, intf, id,
533 (id - freecom_usb_ids) + freecom_unusual_dev_list);
534 if (result)
535 return result;
536
537 us->transport_name = "Freecom";
538 us->transport = freecom_transport;
539 us->transport_reset = usb_stor_freecom_reset;
540 us->max_lun = 0;
541
542 result = usb_stor_probe2(us);
543 return result;
544}
545
546static struct usb_driver freecom_driver = {
547 .name = "ums-freecom",
548 .probe = freecom_probe,
549 .disconnect = usb_stor_disconnect,
550 .suspend = usb_stor_suspend,
551 .resume = usb_stor_resume,
552 .reset_resume = usb_stor_reset_resume,
553 .pre_reset = usb_stor_pre_reset,
554 .post_reset = usb_stor_post_reset,
555 .id_table = freecom_usb_ids,
556 .soft_unbind = 1,
557};
558
559static int __init freecom_init(void)
560{
561 return usb_register(&freecom_driver);
562}
563
564static void __exit freecom_exit(void)
565{
566 usb_deregister(&freecom_driver);
567}
568
569module_init(freecom_init);
570module_exit(freecom_exit);
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 383abf2516a5..882c57b399f7 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -44,6 +44,7 @@
44 44
45#include <linux/jiffies.h> 45#include <linux/jiffies.h>
46#include <linux/errno.h> 46#include <linux/errno.h>
47#include <linux/module.h>
47#include <linux/slab.h> 48#include <linux/slab.h>
48#include <linux/hdreg.h> 49#include <linux/hdreg.h>
49#include <linux/scatterlist.h> 50#include <linux/scatterlist.h>
@@ -57,7 +58,53 @@
57#include "protocol.h" 58#include "protocol.h"
58#include "debug.h" 59#include "debug.h"
59#include "scsiglue.h" 60#include "scsiglue.h"
60#include "isd200.h" 61
62MODULE_DESCRIPTION("Driver for In-System Design, Inc. ISD200 ASIC");
63MODULE_AUTHOR("Björn Stenberg <bjorn@haxx.se>");
64MODULE_LICENSE("GPL");
65
66static int isd200_Initialization(struct us_data *us);
67
68
69/*
70 * The table of devices
71 */
72#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
73 vendorName, productName, useProtocol, useTransport, \
74 initFunction, flags) \
75{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
76 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
77
78struct usb_device_id isd200_usb_ids[] = {
79# include "unusual_isd200.h"
80 { } /* Terminating entry */
81};
82MODULE_DEVICE_TABLE(usb, isd200_usb_ids);
83
84#undef UNUSUAL_DEV
85#undef USUAL_DEV
86
87/*
88 * The flags table
89 */
90#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
91 vendor_name, product_name, use_protocol, use_transport, \
92 init_function, Flags) \
93{ \
94 .vendorName = vendor_name, \
95 .productName = product_name, \
96 .useProtocol = use_protocol, \
97 .useTransport = use_transport, \
98 .initFunction = init_function, \
99}
100
101static struct us_unusual_dev isd200_unusual_dev_list[] = {
102# include "unusual_isd200.h"
103 { } /* Terminating entry */
104};
105
106#undef UNUSUAL_DEV
107#undef USUAL_DEV
61 108
62 109
63/* Timeout defines (in Seconds) */ 110/* Timeout defines (in Seconds) */
@@ -1518,7 +1565,7 @@ static int isd200_init_info(struct us_data *us)
1518 * Initialization for the ISD200 1565 * Initialization for the ISD200
1519 */ 1566 */
1520 1567
1521int isd200_Initialization(struct us_data *us) 1568static int isd200_Initialization(struct us_data *us)
1522{ 1569{
1523 US_DEBUGP("ISD200 Initialization...\n"); 1570 US_DEBUGP("ISD200 Initialization...\n");
1524 1571
@@ -1549,7 +1596,7 @@ int isd200_Initialization(struct us_data *us)
1549 * 1596 *
1550 */ 1597 */
1551 1598
1552void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us) 1599static void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)
1553{ 1600{
1554 int sendToTransport = 1, orig_bufflen; 1601 int sendToTransport = 1, orig_bufflen;
1555 union ata_cdb ataCdb; 1602 union ata_cdb ataCdb;
@@ -1570,3 +1617,47 @@ void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)
1570 1617
1571 isd200_srb_set_bufflen(srb, orig_bufflen); 1618 isd200_srb_set_bufflen(srb, orig_bufflen);
1572} 1619}
1620
1621static int isd200_probe(struct usb_interface *intf,
1622 const struct usb_device_id *id)
1623{
1624 struct us_data *us;
1625 int result;
1626
1627 result = usb_stor_probe1(&us, intf, id,
1628 (id - isd200_usb_ids) + isd200_unusual_dev_list);
1629 if (result)
1630 return result;
1631
1632 us->protocol_name = "ISD200 ATA/ATAPI";
1633 us->proto_handler = isd200_ata_command;
1634
1635 result = usb_stor_probe2(us);
1636 return result;
1637}
1638
1639static struct usb_driver isd200_driver = {
1640 .name = "ums-isd200",
1641 .probe = isd200_probe,
1642 .disconnect = usb_stor_disconnect,
1643 .suspend = usb_stor_suspend,
1644 .resume = usb_stor_resume,
1645 .reset_resume = usb_stor_reset_resume,
1646 .pre_reset = usb_stor_pre_reset,
1647 .post_reset = usb_stor_post_reset,
1648 .id_table = isd200_usb_ids,
1649 .soft_unbind = 1,
1650};
1651
1652static int __init isd200_init(void)
1653{
1654 return usb_register(&isd200_driver);
1655}
1656
1657static void __exit isd200_exit(void)
1658{
1659 usb_deregister(&isd200_driver);
1660}
1661
1662module_init(isd200_init);
1663module_exit(isd200_exit);
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
index df67f13c9e73..1c69420e3acf 100644
--- a/drivers/usb/storage/jumpshot.c
+++ b/drivers/usb/storage/jumpshot.c
@@ -46,6 +46,7 @@
46 */ 46 */
47 47
48#include <linux/errno.h> 48#include <linux/errno.h>
49#include <linux/module.h>
49#include <linux/slab.h> 50#include <linux/slab.h>
50 51
51#include <scsi/scsi.h> 52#include <scsi/scsi.h>
@@ -55,9 +56,61 @@
55#include "transport.h" 56#include "transport.h"
56#include "protocol.h" 57#include "protocol.h"
57#include "debug.h" 58#include "debug.h"
58#include "jumpshot.h"
59 59
60 60
61MODULE_DESCRIPTION("Driver for Lexar \"Jumpshot\" Compact Flash reader");
62MODULE_AUTHOR("Jimmie Mayfield <mayfield+usb@sackheads.org>");
63MODULE_LICENSE("GPL");
64
65/*
66 * The table of devices
67 */
68#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
69 vendorName, productName, useProtocol, useTransport, \
70 initFunction, flags) \
71{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
72 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
73
74struct usb_device_id jumpshot_usb_ids[] = {
75# include "unusual_jumpshot.h"
76 { } /* Terminating entry */
77};
78MODULE_DEVICE_TABLE(usb, jumpshot_usb_ids);
79
80#undef UNUSUAL_DEV
81
82/*
83 * The flags table
84 */
85#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
86 vendor_name, product_name, use_protocol, use_transport, \
87 init_function, Flags) \
88{ \
89 .vendorName = vendor_name, \
90 .productName = product_name, \
91 .useProtocol = use_protocol, \
92 .useTransport = use_transport, \
93 .initFunction = init_function, \
94}
95
96static struct us_unusual_dev jumpshot_unusual_dev_list[] = {
97# include "unusual_jumpshot.h"
98 { } /* Terminating entry */
99};
100
101#undef UNUSUAL_DEV
102
103
104struct jumpshot_info {
105 unsigned long sectors; /* total sector count */
106 unsigned long ssize; /* sector size in bytes */
107
108 /* the following aren't used yet */
109 unsigned char sense_key;
110 unsigned long sense_asc; /* additional sense code */
111 unsigned long sense_ascq; /* additional sense code qualifier */
112};
113
61static inline int jumpshot_bulk_read(struct us_data *us, 114static inline int jumpshot_bulk_read(struct us_data *us,
62 unsigned char *data, 115 unsigned char *data,
63 unsigned int len) 116 unsigned int len)
@@ -429,7 +482,7 @@ static void jumpshot_info_destructor(void *extra)
429 482
430// Transport for the Lexar 'Jumpshot' 483// Transport for the Lexar 'Jumpshot'
431// 484//
432int jumpshot_transport(struct scsi_cmnd * srb, struct us_data *us) 485static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
433{ 486{
434 struct jumpshot_info *info; 487 struct jumpshot_info *info;
435 int rc; 488 int rc;
@@ -592,3 +645,49 @@ int jumpshot_transport(struct scsi_cmnd * srb, struct us_data *us)
592 info->sense_ascq = 0x00; 645 info->sense_ascq = 0x00;
593 return USB_STOR_TRANSPORT_FAILED; 646 return USB_STOR_TRANSPORT_FAILED;
594} 647}
648
649static int jumpshot_probe(struct usb_interface *intf,
650 const struct usb_device_id *id)
651{
652 struct us_data *us;
653 int result;
654
655 result = usb_stor_probe1(&us, intf, id,
656 (id - jumpshot_usb_ids) + jumpshot_unusual_dev_list);
657 if (result)
658 return result;
659
660 us->transport_name = "Lexar Jumpshot Control/Bulk";
661 us->transport = jumpshot_transport;
662 us->transport_reset = usb_stor_Bulk_reset;
663 us->max_lun = 1;
664
665 result = usb_stor_probe2(us);
666 return result;
667}
668
669static struct usb_driver jumpshot_driver = {
670 .name = "ums-jumpshot",
671 .probe = jumpshot_probe,
672 .disconnect = usb_stor_disconnect,
673 .suspend = usb_stor_suspend,
674 .resume = usb_stor_resume,
675 .reset_resume = usb_stor_reset_resume,
676 .pre_reset = usb_stor_pre_reset,
677 .post_reset = usb_stor_post_reset,
678 .id_table = jumpshot_usb_ids,
679 .soft_unbind = 1,
680};
681
682static int __init jumpshot_init(void)
683{
684 return usb_register(&jumpshot_driver);
685}
686
687static void __exit jumpshot_exit(void)
688{
689 usb_deregister(&jumpshot_driver);
690}
691
692module_init(jumpshot_init);
693module_exit(jumpshot_exit);
diff --git a/drivers/usb/storage/jumpshot.h b/drivers/usb/storage/jumpshot.h
deleted file mode 100644
index 19bac9d1558f..000000000000
--- a/drivers/usb/storage/jumpshot.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/* Driver for Lexar "Jumpshot" USB Compact Flash reader
2 * Header File
3 *
4 * Current development and maintenance by:
5 * (c) 2000 Jimmie Mayfield (mayfield+usb@sackheads.org)
6 *
7 * See jumpshot.c for more explanation
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
12 * 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. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#ifndef _USB_JUMPSHOT_H
25#define _USB_JUMPSHOT_H
26
27extern int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us);
28
29struct jumpshot_info {
30 unsigned long sectors; // total sector count
31 unsigned long ssize; // sector size in bytes
32
33 // the following aren't used yet
34 unsigned char sense_key;
35 unsigned long sense_asc; // additional sense code
36 unsigned long sense_ascq; // additional sense code qualifier
37};
38
39#endif
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
index 0d79ae5683f7..7953d93a7739 100644
--- a/drivers/usb/storage/karma.c
+++ b/drivers/usb/storage/karma.c
@@ -18,6 +18,8 @@
18 * 675 Mass Ave, Cambridge, MA 02139, USA. 18 * 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#include <linux/module.h>
22
21#include <scsi/scsi.h> 23#include <scsi/scsi.h>
22#include <scsi/scsi_cmnd.h> 24#include <scsi/scsi_cmnd.h>
23#include <scsi/scsi_device.h> 25#include <scsi/scsi_device.h>
@@ -25,7 +27,10 @@
25#include "usb.h" 27#include "usb.h"
26#include "transport.h" 28#include "transport.h"
27#include "debug.h" 29#include "debug.h"
28#include "karma.h" 30
31MODULE_DESCRIPTION("Driver for Rio Karma");
32MODULE_AUTHOR("Bob Copeland <me@bobcopeland.com>, Keith Bennett <keith@mcs.st-and.ac.uk>");
33MODULE_LICENSE("GPL");
29 34
30#define RIO_PREFIX "RIOP\x00" 35#define RIO_PREFIX "RIOP\x00"
31#define RIO_PREFIX_LEN 5 36#define RIO_PREFIX_LEN 5
@@ -36,13 +41,53 @@
36#define RIO_LEAVE_STORAGE 0x2 41#define RIO_LEAVE_STORAGE 0x2
37#define RIO_RESET 0xC 42#define RIO_RESET 0xC
38 43
39extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data *);
40
41struct karma_data { 44struct karma_data {
42 int in_storage; 45 int in_storage;
43 char *recv; 46 char *recv;
44}; 47};
45 48
49static int rio_karma_init(struct us_data *us);
50
51
52/*
53 * The table of devices
54 */
55#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
56 vendorName, productName, useProtocol, useTransport, \
57 initFunction, flags) \
58{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
59 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
60
61struct usb_device_id karma_usb_ids[] = {
62# include "unusual_karma.h"
63 { } /* Terminating entry */
64};
65MODULE_DEVICE_TABLE(usb, karma_usb_ids);
66
67#undef UNUSUAL_DEV
68
69/*
70 * The flags table
71 */
72#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
73 vendor_name, product_name, use_protocol, use_transport, \
74 init_function, Flags) \
75{ \
76 .vendorName = vendor_name, \
77 .productName = product_name, \
78 .useProtocol = use_protocol, \
79 .useTransport = use_transport, \
80 .initFunction = init_function, \
81}
82
83static struct us_unusual_dev karma_unusual_dev_list[] = {
84# include "unusual_karma.h"
85 { } /* Terminating entry */
86};
87
88#undef UNUSUAL_DEV
89
90
46/* 91/*
47 * Send commands to Rio Karma. 92 * Send commands to Rio Karma.
48 * 93 *
@@ -104,7 +149,7 @@ err:
104 * Trap START_STOP and READ_10 to leave/re-enter storage mode. 149 * Trap START_STOP and READ_10 to leave/re-enter storage mode.
105 * Everything else is propagated to the normal bulk layer. 150 * Everything else is propagated to the normal bulk layer.
106 */ 151 */
107int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us) 152static int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us)
108{ 153{
109 int ret; 154 int ret;
110 struct karma_data *data = (struct karma_data *) us->extra; 155 struct karma_data *data = (struct karma_data *) us->extra;
@@ -133,7 +178,7 @@ static void rio_karma_destructor(void *extra)
133 kfree(data->recv); 178 kfree(data->recv);
134} 179}
135 180
136int rio_karma_init(struct us_data *us) 181static int rio_karma_init(struct us_data *us)
137{ 182{
138 int ret = 0; 183 int ret = 0;
139 struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO); 184 struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO);
@@ -153,3 +198,48 @@ int rio_karma_init(struct us_data *us)
153out: 198out:
154 return ret; 199 return ret;
155} 200}
201
202static int karma_probe(struct usb_interface *intf,
203 const struct usb_device_id *id)
204{
205 struct us_data *us;
206 int result;
207
208 result = usb_stor_probe1(&us, intf, id,
209 (id - karma_usb_ids) + karma_unusual_dev_list);
210 if (result)
211 return result;
212
213 us->transport_name = "Rio Karma/Bulk";
214 us->transport = rio_karma_transport;
215 us->transport_reset = usb_stor_Bulk_reset;
216
217 result = usb_stor_probe2(us);
218 return result;
219}
220
221static struct usb_driver karma_driver = {
222 .name = "ums-karma",
223 .probe = karma_probe,
224 .disconnect = usb_stor_disconnect,
225 .suspend = usb_stor_suspend,
226 .resume = usb_stor_resume,
227 .reset_resume = usb_stor_reset_resume,
228 .pre_reset = usb_stor_pre_reset,
229 .post_reset = usb_stor_post_reset,
230 .id_table = karma_usb_ids,
231 .soft_unbind = 1,
232};
233
234static int __init karma_init(void)
235{
236 return usb_register(&karma_driver);
237}
238
239static void __exit karma_exit(void)
240{
241 usb_deregister(&karma_driver);
242}
243
244module_init(karma_init);
245module_exit(karma_exit);
diff --git a/drivers/usb/storage/karma.h b/drivers/usb/storage/karma.h
deleted file mode 100644
index 8a60972af8c5..000000000000
--- a/drivers/usb/storage/karma.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef _KARMA_USB_H
2#define _KARMA_USB_H
3
4extern int rio_karma_init(struct us_data *us);
5extern int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us);
6
7#endif
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c
index f970b27ba308..fe3ffe1459b2 100644
--- a/drivers/usb/storage/libusual.c
+++ b/drivers/usb/storage/libusual.c
@@ -38,37 +38,6 @@ static atomic_t total_threads = ATOMIC_INIT(0);
38static int usu_probe_thread(void *arg); 38static int usu_probe_thread(void *arg);
39 39
40/* 40/*
41 * The table.
42 */
43#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
44 vendorName, productName,useProtocol, useTransport, \
45 initFunction, flags) \
46{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \
47 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
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
55#define USUAL_DEV(useProto, useTrans, useType) \
56{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
57 .driver_info = ((useType)<<24) }
58
59struct usb_device_id storage_usb_ids [] = {
60# include "unusual_devs.h"
61 { } /* Terminating entry */
62};
63
64#undef USUAL_DEV
65#undef UNUSUAL_DEV
66#undef COMPLIANT_DEV
67
68MODULE_DEVICE_TABLE(usb, storage_usb_ids);
69EXPORT_SYMBOL_GPL(storage_usb_ids);
70
71/*
72 * @type: the module type as an integer 41 * @type: the module type as an integer
73 */ 42 */
74void usb_usual_set_present(int type) 43void usb_usual_set_present(int type)
@@ -167,7 +136,7 @@ static struct usb_driver usu_driver = {
167 .name = "libusual", 136 .name = "libusual",
168 .probe = usu_probe, 137 .probe = usu_probe,
169 .disconnect = usu_disconnect, 138 .disconnect = usu_disconnect,
170 .id_table = storage_usb_ids, 139 .id_table = usb_storage_usb_ids,
171}; 140};
172 141
173/* 142/*
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index c7bf8954b4e4..380233bd6a39 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -35,9 +35,16 @@
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/usb/input.h> 36#include <linux/usb/input.h>
37#include "usb.h" 37#include "usb.h"
38#include "onetouch.h"
39#include "debug.h" 38#include "debug.h"
40 39
40MODULE_DESCRIPTION("Maxtor USB OneTouch hard drive button driver");
41MODULE_AUTHOR("Nick Sillik <n.sillik@temple.edu>");
42MODULE_LICENSE("GPL");
43
44#define ONETOUCH_PKT_LEN 0x02
45#define ONETOUCH_BUTTON KEY_PROG1
46
47static int onetouch_connect_input(struct us_data *ss);
41static void onetouch_release_input(void *onetouch_); 48static void onetouch_release_input(void *onetouch_);
42 49
43struct usb_onetouch { 50struct usb_onetouch {
@@ -52,6 +59,46 @@ struct usb_onetouch {
52 unsigned int is_open:1; 59 unsigned int is_open:1;
53}; 60};
54 61
62
63/*
64 * The table of devices
65 */
66#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
67 vendorName, productName, useProtocol, useTransport, \
68 initFunction, flags) \
69{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
70 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
71
72struct usb_device_id onetouch_usb_ids[] = {
73# include "unusual_onetouch.h"
74 { } /* Terminating entry */
75};
76MODULE_DEVICE_TABLE(usb, onetouch_usb_ids);
77
78#undef UNUSUAL_DEV
79
80/*
81 * The flags table
82 */
83#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
84 vendor_name, product_name, use_protocol, use_transport, \
85 init_function, Flags) \
86{ \
87 .vendorName = vendor_name, \
88 .productName = product_name, \
89 .useProtocol = use_protocol, \
90 .useTransport = use_transport, \
91 .initFunction = init_function, \
92}
93
94static struct us_unusual_dev onetouch_unusual_dev_list[] = {
95# include "unusual_onetouch.h"
96 { } /* Terminating entry */
97};
98
99#undef UNUSUAL_DEV
100
101
55static void usb_onetouch_irq(struct urb *urb) 102static void usb_onetouch_irq(struct urb *urb)
56{ 103{
57 struct usb_onetouch *onetouch = urb->context; 104 struct usb_onetouch *onetouch = urb->context;
@@ -127,7 +174,7 @@ static void usb_onetouch_pm_hook(struct us_data *us, int action)
127} 174}
128#endif /* CONFIG_PM */ 175#endif /* CONFIG_PM */
129 176
130int onetouch_connect_input(struct us_data *ss) 177static int onetouch_connect_input(struct us_data *ss)
131{ 178{
132 struct usb_device *udev = ss->pusb_dev; 179 struct usb_device *udev = ss->pusb_dev;
133 struct usb_host_interface *interface; 180 struct usb_host_interface *interface;
@@ -236,3 +283,46 @@ static void onetouch_release_input(void *onetouch_)
236 onetouch->data, onetouch->data_dma); 283 onetouch->data, onetouch->data_dma);
237 } 284 }
238} 285}
286
287static int onetouch_probe(struct usb_interface *intf,
288 const struct usb_device_id *id)
289{
290 struct us_data *us;
291 int result;
292
293 result = usb_stor_probe1(&us, intf, id,
294 (id - onetouch_usb_ids) + onetouch_unusual_dev_list);
295 if (result)
296 return result;
297
298 /* Use default transport and protocol */
299
300 result = usb_stor_probe2(us);
301 return result;
302}
303
304static struct usb_driver onetouch_driver = {
305 .name = "ums-onetouch",
306 .probe = onetouch_probe,
307 .disconnect = usb_stor_disconnect,
308 .suspend = usb_stor_suspend,
309 .resume = usb_stor_resume,
310 .reset_resume = usb_stor_reset_resume,
311 .pre_reset = usb_stor_pre_reset,
312 .post_reset = usb_stor_post_reset,
313 .id_table = onetouch_usb_ids,
314 .soft_unbind = 1,
315};
316
317static int __init onetouch_init(void)
318{
319 return usb_register(&onetouch_driver);
320}
321
322static void __exit onetouch_exit(void)
323{
324 usb_deregister(&onetouch_driver);
325}
326
327module_init(onetouch_init);
328module_exit(onetouch_exit);
diff --git a/drivers/usb/storage/onetouch.h b/drivers/usb/storage/onetouch.h
deleted file mode 100644
index 41c7aa8f0446..000000000000
--- a/drivers/usb/storage/onetouch.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef _ONETOUCH_H_
2#define _ONETOUCH_H_
3
4#define ONETOUCH_PKT_LEN 0x02
5#define ONETOUCH_BUTTON KEY_PROG1
6
7int onetouch_connect_input(struct us_data *ss);
8
9#endif
diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c
index be441d84bc64..fc310f75eada 100644
--- a/drivers/usb/storage/protocol.c
+++ b/drivers/usb/storage/protocol.c
@@ -121,6 +121,7 @@ void usb_stor_transparent_scsi_command(struct scsi_cmnd *srb,
121 /* send the command to the transport layer */ 121 /* send the command to the transport layer */
122 usb_stor_invoke_transport(srb, us); 122 usb_stor_invoke_transport(srb, us);
123} 123}
124EXPORT_SYMBOL_GPL(usb_stor_transparent_scsi_command);
124 125
125/*********************************************************************** 126/***********************************************************************
126 * Scatter-gather transfer buffer access routines 127 * Scatter-gather transfer buffer access routines
@@ -199,6 +200,7 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
199 /* Return the amount actually transferred */ 200 /* Return the amount actually transferred */
200 return cnt; 201 return cnt;
201} 202}
203EXPORT_SYMBOL_GPL(usb_stor_access_xfer_buf);
202 204
203/* Store the contents of buffer into srb's transfer buffer and set the 205/* Store the contents of buffer into srb's transfer buffer and set the
204 * SCSI residue. 206 * SCSI residue.
@@ -215,3 +217,4 @@ void usb_stor_set_xfer_buf(unsigned char *buffer,
215 if (buflen < scsi_bufflen(srb)) 217 if (buflen < scsi_bufflen(srb))
216 scsi_set_resid(srb, scsi_bufflen(srb) - buflen); 218 scsi_set_resid(srb, scsi_bufflen(srb) - buflen);
217} 219}
220EXPORT_SYMBOL_GPL(usb_stor_set_xfer_buf);
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 727c506417cc..4ca3b5860643 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -135,6 +135,12 @@ static int slave_configure(struct scsi_device *sdev)
135 if (sdev->request_queue->max_sectors > max_sectors) 135 if (sdev->request_queue->max_sectors > max_sectors)
136 blk_queue_max_sectors(sdev->request_queue, 136 blk_queue_max_sectors(sdev->request_queue,
137 max_sectors); 137 max_sectors);
138 } else if (sdev->type == TYPE_TAPE) {
139 /* Tapes need much higher max_sector limits, so just
140 * raise it to the maximum possible (4 GB / 512) and
141 * let the queue segment size sort out the real limit.
142 */
143 blk_queue_max_sectors(sdev->request_queue, 0x7FFFFF);
138 } 144 }
139 145
140 /* Some USB host controllers can't do DMA; they have to use PIO. 146 /* Some USB host controllers can't do DMA; they have to use PIO.
@@ -563,4 +569,4 @@ unsigned char usb_stor_sense_invalidCDB[18] = {
563 [7] = 0x0a, /* additional length */ 569 [7] = 0x0a, /* additional length */
564 [12] = 0x24 /* Invalid Field in CDB */ 570 [12] = 0x24 /* Invalid Field in CDB */
565}; 571};
566 572EXPORT_SYMBOL_GPL(usb_stor_sense_invalidCDB);
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index 531ae5c5abf3..ab5f9f37575a 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -41,6 +41,7 @@
41 */ 41 */
42 42
43#include <linux/errno.h> 43#include <linux/errno.h>
44#include <linux/module.h>
44#include <linux/slab.h> 45#include <linux/slab.h>
45 46
46#include <scsi/scsi.h> 47#include <scsi/scsi.h>
@@ -51,7 +52,53 @@
51#include "transport.h" 52#include "transport.h"
52#include "protocol.h" 53#include "protocol.h"
53#include "debug.h" 54#include "debug.h"
54#include "sddr09.h" 55
56MODULE_DESCRIPTION("Driver for SanDisk SDDR-09 SmartMedia reader");
57MODULE_AUTHOR("Andries Brouwer <aeb@cwi.nl>, Robert Baruch <autophile@starband.net>");
58MODULE_LICENSE("GPL");
59
60static int usb_stor_sddr09_dpcm_init(struct us_data *us);
61static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us);
62static int usb_stor_sddr09_init(struct us_data *us);
63
64
65/*
66 * The table of devices
67 */
68#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
69 vendorName, productName, useProtocol, useTransport, \
70 initFunction, flags) \
71{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
72 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
73
74struct usb_device_id sddr09_usb_ids[] = {
75# include "unusual_sddr09.h"
76 { } /* Terminating entry */
77};
78MODULE_DEVICE_TABLE(usb, sddr09_usb_ids);
79
80#undef UNUSUAL_DEV
81
82/*
83 * The flags table
84 */
85#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
86 vendor_name, product_name, use_protocol, use_transport, \
87 init_function, Flags) \
88{ \
89 .vendorName = vendor_name, \
90 .productName = product_name, \
91 .useProtocol = use_protocol, \
92 .useTransport = use_transport, \
93 .initFunction = init_function, \
94}
95
96static struct us_unusual_dev sddr09_unusual_dev_list[] = {
97# include "unusual_sddr09.h"
98 { } /* Terminating entry */
99};
100
101#undef UNUSUAL_DEV
55 102
56 103
57#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) 104#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
@@ -723,7 +770,7 @@ sddr09_read_data(struct us_data *us,
723 len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; 770 len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
724 buffer = kmalloc(len, GFP_NOIO); 771 buffer = kmalloc(len, GFP_NOIO);
725 if (buffer == NULL) { 772 if (buffer == NULL) {
726 printk("sddr09_read_data: Out of memory\n"); 773 printk(KERN_WARNING "sddr09_read_data: Out of memory\n");
727 return -ENOMEM; 774 return -ENOMEM;
728 } 775 }
729 776
@@ -838,7 +885,8 @@ sddr09_write_lba(struct us_data *us, unsigned int lba,
838 if (pba == UNDEF) { 885 if (pba == UNDEF) {
839 pba = sddr09_find_unused_pba(info, lba); 886 pba = sddr09_find_unused_pba(info, lba);
840 if (!pba) { 887 if (!pba) {
841 printk("sddr09_write_lba: Out of unused blocks\n"); 888 printk(KERN_WARNING
889 "sddr09_write_lba: Out of unused blocks\n");
842 return -ENOSPC; 890 return -ENOSPC;
843 } 891 }
844 info->pba_to_lba[pba] = lba; 892 info->pba_to_lba[pba] = lba;
@@ -849,7 +897,7 @@ sddr09_write_lba(struct us_data *us, unsigned int lba,
849 if (pba == 1) { 897 if (pba == 1) {
850 /* Maybe it is impossible to write to PBA 1. 898 /* Maybe it is impossible to write to PBA 1.
851 Fake success, but don't do anything. */ 899 Fake success, but don't do anything. */
852 printk("sddr09: avoid writing to pba 1\n"); 900 printk(KERN_WARNING "sddr09: avoid writing to pba 1\n");
853 return 0; 901 return 0;
854 } 902 }
855 903
@@ -954,7 +1002,7 @@ sddr09_write_data(struct us_data *us,
954 blocklen = (pagelen << info->blockshift); 1002 blocklen = (pagelen << info->blockshift);
955 blockbuffer = kmalloc(blocklen, GFP_NOIO); 1003 blockbuffer = kmalloc(blocklen, GFP_NOIO);
956 if (!blockbuffer) { 1004 if (!blockbuffer) {
957 printk("sddr09_write_data: Out of memory\n"); 1005 printk(KERN_WARNING "sddr09_write_data: Out of memory\n");
958 return -ENOMEM; 1006 return -ENOMEM;
959 } 1007 }
960 1008
@@ -965,7 +1013,7 @@ sddr09_write_data(struct us_data *us,
965 len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; 1013 len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
966 buffer = kmalloc(len, GFP_NOIO); 1014 buffer = kmalloc(len, GFP_NOIO);
967 if (buffer == NULL) { 1015 if (buffer == NULL) {
968 printk("sddr09_write_data: Out of memory\n"); 1016 printk(KERN_WARNING "sddr09_write_data: Out of memory\n");
969 kfree(blockbuffer); 1017 kfree(blockbuffer);
970 return -ENOMEM; 1018 return -ENOMEM;
971 } 1019 }
@@ -1112,7 +1160,7 @@ sddr09_get_cardinfo(struct us_data *us, unsigned char flags) {
1112 1160
1113 if (result) { 1161 if (result) {
1114 US_DEBUGP("Result of read_deviceID is %d\n", result); 1162 US_DEBUGP("Result of read_deviceID is %d\n", result);
1115 printk("sddr09: could not read card info\n"); 1163 printk(KERN_WARNING "sddr09: could not read card info\n");
1116 return NULL; 1164 return NULL;
1117 } 1165 }
1118 1166
@@ -1153,7 +1201,7 @@ sddr09_get_cardinfo(struct us_data *us, unsigned char flags) {
1153 sprintf(blurbtxt + strlen(blurbtxt), 1201 sprintf(blurbtxt + strlen(blurbtxt),
1154 ", WP"); 1202 ", WP");
1155 1203
1156 printk("%s\n", blurbtxt); 1204 printk(KERN_WARNING "%s\n", blurbtxt);
1157 1205
1158 return cardinfo; 1206 return cardinfo;
1159} 1207}
@@ -1184,7 +1232,7 @@ sddr09_read_map(struct us_data *us) {
1184 alloc_len = (alloc_blocks << CONTROL_SHIFT); 1232 alloc_len = (alloc_blocks << CONTROL_SHIFT);
1185 buffer = kmalloc(alloc_len, GFP_NOIO); 1233 buffer = kmalloc(alloc_len, GFP_NOIO);
1186 if (buffer == NULL) { 1234 if (buffer == NULL) {
1187 printk("sddr09_read_map: out of memory\n"); 1235 printk(KERN_WARNING "sddr09_read_map: out of memory\n");
1188 result = -1; 1236 result = -1;
1189 goto done; 1237 goto done;
1190 } 1238 }
@@ -1198,7 +1246,7 @@ sddr09_read_map(struct us_data *us) {
1198 info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO); 1246 info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
1199 1247
1200 if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { 1248 if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {
1201 printk("sddr09_read_map: out of memory\n"); 1249 printk(KERN_WARNING "sddr09_read_map: out of memory\n");
1202 result = -1; 1250 result = -1;
1203 goto done; 1251 goto done;
1204 } 1252 }
@@ -1238,7 +1286,8 @@ sddr09_read_map(struct us_data *us) {
1238 if (ptr[j] != 0) 1286 if (ptr[j] != 0)
1239 goto nonz; 1287 goto nonz;
1240 info->pba_to_lba[i] = UNUSABLE; 1288 info->pba_to_lba[i] = UNUSABLE;
1241 printk("sddr09: PBA %d has no logical mapping\n", i); 1289 printk(KERN_WARNING "sddr09: PBA %d has no logical mapping\n",
1290 i);
1242 continue; 1291 continue;
1243 1292
1244 nonz: 1293 nonz:
@@ -1251,7 +1300,8 @@ sddr09_read_map(struct us_data *us) {
1251 nonff: 1300 nonff:
1252 /* normal PBAs start with six FFs */ 1301 /* normal PBAs start with six FFs */
1253 if (j < 6) { 1302 if (j < 6) {
1254 printk("sddr09: PBA %d has no logical mapping: " 1303 printk(KERN_WARNING
1304 "sddr09: PBA %d has no logical mapping: "
1255 "reserved area = %02X%02X%02X%02X " 1305 "reserved area = %02X%02X%02X%02X "
1256 "data status %02X block status %02X\n", 1306 "data status %02X block status %02X\n",
1257 i, ptr[0], ptr[1], ptr[2], ptr[3], 1307 i, ptr[0], ptr[1], ptr[2], ptr[3],
@@ -1261,7 +1311,8 @@ sddr09_read_map(struct us_data *us) {
1261 } 1311 }
1262 1312
1263 if ((ptr[6] >> 4) != 0x01) { 1313 if ((ptr[6] >> 4) != 0x01) {
1264 printk("sddr09: PBA %d has invalid address field " 1314 printk(KERN_WARNING
1315 "sddr09: PBA %d has invalid address field "
1265 "%02X%02X/%02X%02X\n", 1316 "%02X%02X/%02X%02X\n",
1266 i, ptr[6], ptr[7], ptr[11], ptr[12]); 1317 i, ptr[6], ptr[7], ptr[11], ptr[12]);
1267 info->pba_to_lba[i] = UNUSABLE; 1318 info->pba_to_lba[i] = UNUSABLE;
@@ -1270,7 +1321,8 @@ sddr09_read_map(struct us_data *us) {
1270 1321
1271 /* check even parity */ 1322 /* check even parity */
1272 if (parity[ptr[6] ^ ptr[7]]) { 1323 if (parity[ptr[6] ^ ptr[7]]) {
1273 printk("sddr09: Bad parity in LBA for block %d" 1324 printk(KERN_WARNING
1325 "sddr09: Bad parity in LBA for block %d"
1274 " (%02X %02X)\n", i, ptr[6], ptr[7]); 1326 " (%02X %02X)\n", i, ptr[6], ptr[7]);
1275 info->pba_to_lba[i] = UNUSABLE; 1327 info->pba_to_lba[i] = UNUSABLE;
1276 continue; 1328 continue;
@@ -1289,7 +1341,8 @@ sddr09_read_map(struct us_data *us) {
1289 */ 1341 */
1290 1342
1291 if (lba >= 1000) { 1343 if (lba >= 1000) {
1292 printk("sddr09: Bad low LBA %d for block %d\n", 1344 printk(KERN_WARNING
1345 "sddr09: Bad low LBA %d for block %d\n",
1293 lba, i); 1346 lba, i);
1294 goto possibly_erase; 1347 goto possibly_erase;
1295 } 1348 }
@@ -1297,7 +1350,8 @@ sddr09_read_map(struct us_data *us) {
1297 lba += 1000*(i/0x400); 1350 lba += 1000*(i/0x400);
1298 1351
1299 if (info->lba_to_pba[lba] != UNDEF) { 1352 if (info->lba_to_pba[lba] != UNDEF) {
1300 printk("sddr09: LBA %d seen for PBA %d and %d\n", 1353 printk(KERN_WARNING
1354 "sddr09: LBA %d seen for PBA %d and %d\n",
1301 lba, info->lba_to_pba[lba], i); 1355 lba, info->lba_to_pba[lba], i);
1302 goto possibly_erase; 1356 goto possibly_erase;
1303 } 1357 }
@@ -1399,7 +1453,7 @@ sddr09_common_init(struct us_data *us) {
1399 * unusual devices list but called from here then LUN 0 of the combo reader 1453 * unusual devices list but called from here then LUN 0 of the combo reader
1400 * is not recognized. But I do not know what precisely these calls do. 1454 * is not recognized. But I do not know what precisely these calls do.
1401 */ 1455 */
1402int 1456static int
1403usb_stor_sddr09_dpcm_init(struct us_data *us) { 1457usb_stor_sddr09_dpcm_init(struct us_data *us) {
1404 int result; 1458 int result;
1405 unsigned char *data = us->iobuf; 1459 unsigned char *data = us->iobuf;
@@ -1449,7 +1503,7 @@ usb_stor_sddr09_dpcm_init(struct us_data *us) {
1449/* 1503/*
1450 * Transport for the Microtech DPCM-USB 1504 * Transport for the Microtech DPCM-USB
1451 */ 1505 */
1452int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us) 1506static int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
1453{ 1507{
1454 int ret; 1508 int ret;
1455 1509
@@ -1491,7 +1545,7 @@ int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
1491/* 1545/*
1492 * Transport for the Sandisk SDDR-09 1546 * Transport for the Sandisk SDDR-09
1493 */ 1547 */
1494int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) 1548static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1495{ 1549{
1496 static unsigned char sensekey = 0, sensecode = 0; 1550 static unsigned char sensekey = 0, sensecode = 0;
1497 static unsigned char havefakesense = 0; 1551 static unsigned char havefakesense = 0;
@@ -1690,7 +1744,60 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1690/* 1744/*
1691 * Initialization routine for the sddr09 subdriver 1745 * Initialization routine for the sddr09 subdriver
1692 */ 1746 */
1693int 1747static int
1694usb_stor_sddr09_init(struct us_data *us) { 1748usb_stor_sddr09_init(struct us_data *us) {
1695 return sddr09_common_init(us); 1749 return sddr09_common_init(us);
1696} 1750}
1751
1752static int sddr09_probe(struct usb_interface *intf,
1753 const struct usb_device_id *id)
1754{
1755 struct us_data *us;
1756 int result;
1757
1758 result = usb_stor_probe1(&us, intf, id,
1759 (id - sddr09_usb_ids) + sddr09_unusual_dev_list);
1760 if (result)
1761 return result;
1762
1763 if (us->protocol == US_PR_DPCM_USB) {
1764 us->transport_name = "Control/Bulk-EUSB/SDDR09";
1765 us->transport = dpcm_transport;
1766 us->transport_reset = usb_stor_CB_reset;
1767 us->max_lun = 1;
1768 } else {
1769 us->transport_name = "EUSB/SDDR09";
1770 us->transport = sddr09_transport;
1771 us->transport_reset = usb_stor_CB_reset;
1772 us->max_lun = 0;
1773 }
1774
1775 result = usb_stor_probe2(us);
1776 return result;
1777}
1778
1779static struct usb_driver sddr09_driver = {
1780 .name = "ums-sddr09",
1781 .probe = sddr09_probe,
1782 .disconnect = usb_stor_disconnect,
1783 .suspend = usb_stor_suspend,
1784 .resume = usb_stor_resume,
1785 .reset_resume = usb_stor_reset_resume,
1786 .pre_reset = usb_stor_pre_reset,
1787 .post_reset = usb_stor_post_reset,
1788 .id_table = sddr09_usb_ids,
1789 .soft_unbind = 1,
1790};
1791
1792static int __init sddr09_init(void)
1793{
1794 return usb_register(&sddr09_driver);
1795}
1796
1797static void __exit sddr09_exit(void)
1798{
1799 usb_deregister(&sddr09_driver);
1800}
1801
1802module_init(sddr09_init);
1803module_exit(sddr09_exit);
diff --git a/drivers/usb/storage/sddr09.h b/drivers/usb/storage/sddr09.h
deleted file mode 100644
index b701172e12e3..000000000000
--- a/drivers/usb/storage/sddr09.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/* Driver for SanDisk SDDR-09 SmartMedia reader
2 * Header File
3 *
4 * Current development and maintenance by:
5 * (c) 2000 Robert Baruch (autophile@dol.net)
6 * (c) 2002 Andries Brouwer (aeb@cwi.nl)
7 *
8 * See sddr09.c for more explanation
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, or (at your option) any
13 * later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#ifndef _USB_SHUTTLE_EUSB_SDDR09_H
26#define _USB_SHUTTLE_EUSB_SDDR09_H
27
28/* Sandisk SDDR-09 stuff */
29
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 */
34
35extern int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us);
36extern int usb_stor_sddr09_dpcm_init(struct us_data *us);
37
38#endif
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
index 0d8df7577899..44dfed7754ed 100644
--- a/drivers/usb/storage/sddr55.c
+++ b/drivers/usb/storage/sddr55.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/jiffies.h> 25#include <linux/jiffies.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/module.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28 29
29#include <scsi/scsi.h> 30#include <scsi/scsi.h>
@@ -33,7 +34,48 @@
33#include "transport.h" 34#include "transport.h"
34#include "protocol.h" 35#include "protocol.h"
35#include "debug.h" 36#include "debug.h"
36#include "sddr55.h" 37
38MODULE_DESCRIPTION("Driver for SanDisk SDDR-55 SmartMedia reader");
39MODULE_AUTHOR("Simon Munton");
40MODULE_LICENSE("GPL");
41
42/*
43 * The table of devices
44 */
45#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
46 vendorName, productName, useProtocol, useTransport, \
47 initFunction, flags) \
48{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
49 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
50
51struct usb_device_id sddr55_usb_ids[] = {
52# include "unusual_sddr55.h"
53 { } /* Terminating entry */
54};
55MODULE_DEVICE_TABLE(usb, sddr55_usb_ids);
56
57#undef UNUSUAL_DEV
58
59/*
60 * The flags table
61 */
62#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
63 vendor_name, product_name, use_protocol, use_transport, \
64 init_function, Flags) \
65{ \
66 .vendorName = vendor_name, \
67 .productName = product_name, \
68 .useProtocol = use_protocol, \
69 .useTransport = use_transport, \
70 .initFunction = init_function, \
71}
72
73static struct us_unusual_dev sddr55_unusual_dev_list[] = {
74# include "unusual_sddr55.h"
75 { } /* Terminating entry */
76};
77
78#undef UNUSUAL_DEV
37 79
38 80
39#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) 81#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
@@ -513,7 +555,8 @@ static int sddr55_read_deviceID(struct us_data *us,
513} 555}
514 556
515 557
516int sddr55_reset(struct us_data *us) { 558static int sddr55_reset(struct us_data *us)
559{
517 return 0; 560 return 0;
518} 561}
519 562
@@ -703,7 +746,9 @@ static int sddr55_read_map(struct us_data *us) {
703 746
704 if (info->lba_to_pba[lba + zone * 1000] != NOT_ALLOCATED && 747 if (info->lba_to_pba[lba + zone * 1000] != NOT_ALLOCATED &&
705 !info->force_read_only) { 748 !info->force_read_only) {
706 printk("sddr55: map inconsistency at LBA %04X\n", lba + zone * 1000); 749 printk(KERN_WARNING
750 "sddr55: map inconsistency at LBA %04X\n",
751 lba + zone * 1000);
707 info->force_read_only = 1; 752 info->force_read_only = 1;
708 } 753 }
709 754
@@ -732,7 +777,7 @@ static void sddr55_card_info_destructor(void *extra) {
732/* 777/*
733 * Transport for the Sandisk SDDR-55 778 * Transport for the Sandisk SDDR-55
734 */ 779 */
735int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) 780static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
736{ 781{
737 int result; 782 int result;
738 static unsigned char inquiry_response[8] = { 783 static unsigned char inquiry_response[8] = {
@@ -929,3 +974,49 @@ int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
929 return USB_STOR_TRANSPORT_FAILED; // FIXME: sense buffer? 974 return USB_STOR_TRANSPORT_FAILED; // FIXME: sense buffer?
930} 975}
931 976
977
978static int sddr55_probe(struct usb_interface *intf,
979 const struct usb_device_id *id)
980{
981 struct us_data *us;
982 int result;
983
984 result = usb_stor_probe1(&us, intf, id,
985 (id - sddr55_usb_ids) + sddr55_unusual_dev_list);
986 if (result)
987 return result;
988
989 us->transport_name = "SDDR55";
990 us->transport = sddr55_transport;
991 us->transport_reset = sddr55_reset;
992 us->max_lun = 0;
993
994 result = usb_stor_probe2(us);
995 return result;
996}
997
998static struct usb_driver sddr55_driver = {
999 .name = "ums-sddr55",
1000 .probe = sddr55_probe,
1001 .disconnect = usb_stor_disconnect,
1002 .suspend = usb_stor_suspend,
1003 .resume = usb_stor_resume,
1004 .reset_resume = usb_stor_reset_resume,
1005 .pre_reset = usb_stor_pre_reset,
1006 .post_reset = usb_stor_post_reset,
1007 .id_table = sddr55_usb_ids,
1008 .soft_unbind = 1,
1009};
1010
1011static int __init sddr55_init(void)
1012{
1013 return usb_register(&sddr55_driver);
1014}
1015
1016static void __exit sddr55_exit(void)
1017{
1018 usb_deregister(&sddr55_driver);
1019}
1020
1021module_init(sddr55_init);
1022module_exit(sddr55_exit);
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index ae6d64810d2a..b62a28814ebe 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <linux/errno.h> 44#include <linux/errno.h>
45#include <linux/module.h>
45#include <linux/slab.h> 46#include <linux/slab.h>
46#include <linux/cdrom.h> 47#include <linux/cdrom.h>
47 48
@@ -52,7 +53,100 @@
52#include "transport.h" 53#include "transport.h"
53#include "protocol.h" 54#include "protocol.h"
54#include "debug.h" 55#include "debug.h"
55#include "shuttle_usbat.h" 56
57MODULE_DESCRIPTION("Driver for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable");
58MODULE_AUTHOR("Daniel Drake <dsd@gentoo.org>, Robert Baruch <autophile@starband.net>");
59MODULE_LICENSE("GPL");
60
61/* Supported device types */
62#define USBAT_DEV_HP8200 0x01
63#define USBAT_DEV_FLASH 0x02
64
65#define USBAT_EPP_PORT 0x10
66#define USBAT_EPP_REGISTER 0x30
67#define USBAT_ATA 0x40
68#define USBAT_ISA 0x50
69
70/* Commands (need to be logically OR'd with an access type */
71#define USBAT_CMD_READ_REG 0x00
72#define USBAT_CMD_WRITE_REG 0x01
73#define USBAT_CMD_READ_BLOCK 0x02
74#define USBAT_CMD_WRITE_BLOCK 0x03
75#define USBAT_CMD_COND_READ_BLOCK 0x04
76#define USBAT_CMD_COND_WRITE_BLOCK 0x05
77#define USBAT_CMD_WRITE_REGS 0x07
78
79/* Commands (these don't need an access type) */
80#define USBAT_CMD_EXEC_CMD 0x80
81#define USBAT_CMD_SET_FEAT 0x81
82#define USBAT_CMD_UIO 0x82
83
84/* Methods of accessing UIO register */
85#define USBAT_UIO_READ 1
86#define USBAT_UIO_WRITE 0
87
88/* Qualifier bits */
89#define USBAT_QUAL_FCQ 0x20 /* full compare */
90#define USBAT_QUAL_ALQ 0x10 /* auto load subcount */
91
92/* USBAT Flash Media status types */
93#define USBAT_FLASH_MEDIA_NONE 0
94#define USBAT_FLASH_MEDIA_CF 1
95
96/* USBAT Flash Media change types */
97#define USBAT_FLASH_MEDIA_SAME 0
98#define USBAT_FLASH_MEDIA_CHANGED 1
99
100/* USBAT ATA registers */
101#define USBAT_ATA_DATA 0x10 /* read/write data (R/W) */
102#define USBAT_ATA_FEATURES 0x11 /* set features (W) */
103#define USBAT_ATA_ERROR 0x11 /* error (R) */
104#define USBAT_ATA_SECCNT 0x12 /* sector count (R/W) */
105#define USBAT_ATA_SECNUM 0x13 /* sector number (R/W) */
106#define USBAT_ATA_LBA_ME 0x14 /* cylinder low (R/W) */
107#define USBAT_ATA_LBA_HI 0x15 /* cylinder high (R/W) */
108#define USBAT_ATA_DEVICE 0x16 /* head/device selection (R/W) */
109#define USBAT_ATA_STATUS 0x17 /* device status (R) */
110#define USBAT_ATA_CMD 0x17 /* device command (W) */
111#define USBAT_ATA_ALTSTATUS 0x0E /* status (no clear IRQ) (R) */
112
113/* USBAT User I/O Data registers */
114#define USBAT_UIO_EPAD 0x80 /* Enable Peripheral Control Signals */
115#define USBAT_UIO_CDT 0x40 /* Card Detect (Read Only) */
116 /* CDT = ACKD & !UI1 & !UI0 */
117#define USBAT_UIO_1 0x20 /* I/O 1 */
118#define USBAT_UIO_0 0x10 /* I/O 0 */
119#define USBAT_UIO_EPP_ATA 0x08 /* 1=EPP mode, 0=ATA mode */
120#define USBAT_UIO_UI1 0x04 /* Input 1 */
121#define USBAT_UIO_UI0 0x02 /* Input 0 */
122#define USBAT_UIO_INTR_ACK 0x01 /* Interrupt (ATA/ISA)/Acknowledge (EPP) */
123
124/* USBAT User I/O Enable registers */
125#define USBAT_UIO_DRVRST 0x80 /* Reset Peripheral */
126#define USBAT_UIO_ACKD 0x40 /* Enable Card Detect */
127#define USBAT_UIO_OE1 0x20 /* I/O 1 set=output/clr=input */
128 /* If ACKD=1, set OE1 to 1 also. */
129#define USBAT_UIO_OE0 0x10 /* I/O 0 set=output/clr=input */
130#define USBAT_UIO_ADPRST 0x01 /* Reset SCM chip */
131
132/* USBAT Features */
133#define USBAT_FEAT_ETEN 0x80 /* External trigger enable */
134#define USBAT_FEAT_U1 0x08
135#define USBAT_FEAT_U0 0x04
136#define USBAT_FEAT_ET1 0x02
137#define USBAT_FEAT_ET2 0x01
138
139struct usbat_info {
140 int devicetype;
141
142 /* Used for Flash readers only */
143 unsigned long sectors; /* total sector count */
144 unsigned long ssize; /* sector size in bytes */
145
146 unsigned char sense_key;
147 unsigned long sense_asc; /* additional sense code */
148 unsigned long sense_ascq; /* additional sense code qualifier */
149};
56 150
57#define short_pack(LSB,MSB) ( ((u16)(LSB)) | ( ((u16)(MSB))<<8 ) ) 151#define short_pack(LSB,MSB) ( ((u16)(LSB)) | ( ((u16)(MSB))<<8 ) )
58#define LSB_of(s) ((s)&0xFF) 152#define LSB_of(s) ((s)&0xFF)
@@ -63,6 +157,48 @@ static int transferred = 0;
63static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us); 157static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us);
64static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us); 158static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us);
65 159
160static int init_usbat_cd(struct us_data *us);
161static int init_usbat_flash(struct us_data *us);
162
163
164/*
165 * The table of devices
166 */
167#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
168 vendorName, productName, useProtocol, useTransport, \
169 initFunction, flags) \
170{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
171 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
172
173struct usb_device_id usbat_usb_ids[] = {
174# include "unusual_usbat.h"
175 { } /* Terminating entry */
176};
177MODULE_DEVICE_TABLE(usb, usbat_usb_ids);
178
179#undef UNUSUAL_DEV
180
181/*
182 * The flags table
183 */
184#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
185 vendor_name, product_name, use_protocol, use_transport, \
186 init_function, Flags) \
187{ \
188 .vendorName = vendor_name, \
189 .productName = product_name, \
190 .useProtocol = use_protocol, \
191 .useTransport = use_transport, \
192 .initFunction = init_function, \
193}
194
195static struct us_unusual_dev usbat_unusual_dev_list[] = {
196# include "unusual_usbat.h"
197 { } /* Terminating entry */
198};
199
200#undef UNUSUAL_DEV
201
66/* 202/*
67 * Convenience function to produce an ATA read/write sectors command 203 * Convenience function to produce an ATA read/write sectors command
68 * Use cmd=0x20 for read, cmd=0x30 for write 204 * Use cmd=0x20 for read, cmd=0x30 for write
@@ -1684,37 +1820,61 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1684 return USB_STOR_TRANSPORT_FAILED; 1820 return USB_STOR_TRANSPORT_FAILED;
1685} 1821}
1686 1822
1687int init_usbat_cd(struct us_data *us) 1823static int init_usbat_cd(struct us_data *us)
1688{ 1824{
1689 return init_usbat(us, USBAT_DEV_HP8200); 1825 return init_usbat(us, USBAT_DEV_HP8200);
1690} 1826}
1691 1827
1692 1828static int init_usbat_flash(struct us_data *us)
1693int init_usbat_flash(struct us_data *us)
1694{ 1829{
1695 return init_usbat(us, USBAT_DEV_FLASH); 1830 return init_usbat(us, USBAT_DEV_FLASH);
1696} 1831}
1697 1832
1698int init_usbat_probe(struct us_data *us) 1833static int usbat_probe(struct usb_interface *intf,
1834 const struct usb_device_id *id)
1699{ 1835{
1700 return init_usbat(us, 0); 1836 struct us_data *us;
1837 int result;
1838
1839 result = usb_stor_probe1(&us, intf, id,
1840 (id - usbat_usb_ids) + usbat_unusual_dev_list);
1841 if (result)
1842 return result;
1843
1844 /* The actual transport will be determined later by the
1845 * initialization routine; this is just a placeholder.
1846 */
1847 us->transport_name = "Shuttle USBAT";
1848 us->transport = usbat_flash_transport;
1849 us->transport_reset = usb_stor_CB_reset;
1850 us->max_lun = 1;
1851
1852 result = usb_stor_probe2(us);
1853 return result;
1701} 1854}
1702 1855
1703/* 1856static struct usb_driver usbat_driver = {
1704 * Default transport function. Attempts to detect which transport function 1857 .name = "ums-usbat",
1705 * should be called, makes it the new default, and calls it. 1858 .probe = usbat_probe,
1706 * 1859 .disconnect = usb_stor_disconnect,
1707 * This function should never be called. Our usbat_init() function detects the 1860 .suspend = usb_stor_suspend,
1708 * device type and changes the us->transport ptr to the transport function 1861 .resume = usb_stor_resume,
1709 * relevant to the device. 1862 .reset_resume = usb_stor_reset_resume,
1710 * However, we'll support this impossible(?) case anyway. 1863 .pre_reset = usb_stor_pre_reset,
1711 */ 1864 .post_reset = usb_stor_post_reset,
1712int usbat_transport(struct scsi_cmnd *srb, struct us_data *us) 1865 .id_table = usbat_usb_ids,
1866 .soft_unbind = 1,
1867};
1868
1869static int __init usbat_init(void)
1713{ 1870{
1714 struct usbat_info *info = (struct usbat_info*) (us->extra); 1871 return usb_register(&usbat_driver);
1715 1872}
1716 if (usbat_set_transport(us, info, 0))
1717 return USB_STOR_TRANSPORT_ERROR;
1718 1873
1719 return us->transport(srb, us); 1874static void __exit usbat_exit(void)
1875{
1876 usb_deregister(&usbat_driver);
1720} 1877}
1878
1879module_init(usbat_init);
1880module_exit(usbat_exit);
diff --git a/drivers/usb/storage/shuttle_usbat.h b/drivers/usb/storage/shuttle_usbat.h
deleted file mode 100644
index d8bfc43e9044..000000000000
--- a/drivers/usb/storage/shuttle_usbat.h
+++ /dev/null
@@ -1,123 +0,0 @@
1/* Driver for SCM Microsystems USB-ATAPI cable
2 * Header File
3 *
4 * Current development and maintenance by:
5 * (c) 2000 Robert Baruch (autophile@dol.net)
6 * (c) 2004, 2005 Daniel Drake <dsd@gentoo.org>
7 *
8 * See shuttle_usbat.c for more explanation
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, or (at your option) any
13 * later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#ifndef _USB_SHUTTLE_USBAT_H
26#define _USB_SHUTTLE_USBAT_H
27
28/* Supported device types */
29#define USBAT_DEV_HP8200 0x01
30#define USBAT_DEV_FLASH 0x02
31
32#define USBAT_EPP_PORT 0x10
33#define USBAT_EPP_REGISTER 0x30
34#define USBAT_ATA 0x40
35#define USBAT_ISA 0x50
36
37/* Commands (need to be logically OR'd with an access type */
38#define USBAT_CMD_READ_REG 0x00
39#define USBAT_CMD_WRITE_REG 0x01
40#define USBAT_CMD_READ_BLOCK 0x02
41#define USBAT_CMD_WRITE_BLOCK 0x03
42#define USBAT_CMD_COND_READ_BLOCK 0x04
43#define USBAT_CMD_COND_WRITE_BLOCK 0x05
44#define USBAT_CMD_WRITE_REGS 0x07
45
46/* Commands (these don't need an access type) */
47#define USBAT_CMD_EXEC_CMD 0x80
48#define USBAT_CMD_SET_FEAT 0x81
49#define USBAT_CMD_UIO 0x82
50
51/* Methods of accessing UIO register */
52#define USBAT_UIO_READ 1
53#define USBAT_UIO_WRITE 0
54
55/* Qualifier bits */
56#define USBAT_QUAL_FCQ 0x20 /* full compare */
57#define USBAT_QUAL_ALQ 0x10 /* auto load subcount */
58
59/* USBAT Flash Media status types */
60#define USBAT_FLASH_MEDIA_NONE 0
61#define USBAT_FLASH_MEDIA_CF 1
62
63/* USBAT Flash Media change types */
64#define USBAT_FLASH_MEDIA_SAME 0
65#define USBAT_FLASH_MEDIA_CHANGED 1
66
67/* USBAT ATA registers */
68#define USBAT_ATA_DATA 0x10 /* read/write data (R/W) */
69#define USBAT_ATA_FEATURES 0x11 /* set features (W) */
70#define USBAT_ATA_ERROR 0x11 /* error (R) */
71#define USBAT_ATA_SECCNT 0x12 /* sector count (R/W) */
72#define USBAT_ATA_SECNUM 0x13 /* sector number (R/W) */
73#define USBAT_ATA_LBA_ME 0x14 /* cylinder low (R/W) */
74#define USBAT_ATA_LBA_HI 0x15 /* cylinder high (R/W) */
75#define USBAT_ATA_DEVICE 0x16 /* head/device selection (R/W) */
76#define USBAT_ATA_STATUS 0x17 /* device status (R) */
77#define USBAT_ATA_CMD 0x17 /* device command (W) */
78#define USBAT_ATA_ALTSTATUS 0x0E /* status (no clear IRQ) (R) */
79
80/* USBAT User I/O Data registers */
81#define USBAT_UIO_EPAD 0x80 /* Enable Peripheral Control Signals */
82#define USBAT_UIO_CDT 0x40 /* Card Detect (Read Only) */
83 /* CDT = ACKD & !UI1 & !UI0 */
84#define USBAT_UIO_1 0x20 /* I/O 1 */
85#define USBAT_UIO_0 0x10 /* I/O 0 */
86#define USBAT_UIO_EPP_ATA 0x08 /* 1=EPP mode, 0=ATA mode */
87#define USBAT_UIO_UI1 0x04 /* Input 1 */
88#define USBAT_UIO_UI0 0x02 /* Input 0 */
89#define USBAT_UIO_INTR_ACK 0x01 /* Interrupt (ATA/ISA)/Acknowledge (EPP) */
90
91/* USBAT User I/O Enable registers */
92#define USBAT_UIO_DRVRST 0x80 /* Reset Peripheral */
93#define USBAT_UIO_ACKD 0x40 /* Enable Card Detect */
94#define USBAT_UIO_OE1 0x20 /* I/O 1 set=output/clr=input */
95 /* If ACKD=1, set OE1 to 1 also. */
96#define USBAT_UIO_OE0 0x10 /* I/O 0 set=output/clr=input */
97#define USBAT_UIO_ADPRST 0x01 /* Reset SCM chip */
98
99/* USBAT Features */
100#define USBAT_FEAT_ETEN 0x80 /* External trigger enable */
101#define USBAT_FEAT_U1 0x08
102#define USBAT_FEAT_U0 0x04
103#define USBAT_FEAT_ET1 0x02
104#define USBAT_FEAT_ET2 0x01
105
106extern int usbat_transport(struct scsi_cmnd *srb, struct us_data *us);
107extern int init_usbat_cd(struct us_data *us);
108extern int init_usbat_flash(struct us_data *us);
109extern int init_usbat_probe(struct us_data *us);
110
111struct usbat_info {
112 int devicetype;
113
114 /* Used for Flash readers only */
115 unsigned long sectors; /* total sector count */
116 unsigned long ssize; /* sector size in bytes */
117
118 unsigned char sense_key;
119 unsigned long sense_asc; /* additional sense code */
120 unsigned long sense_ascq; /* additional sense code qualifier */
121};
122
123#endif
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index fb65d221cedf..d48c8553539d 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -220,6 +220,7 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
220 status = us->current_urb->actual_length; 220 status = us->current_urb->actual_length;
221 return status; 221 return status;
222} 222}
223EXPORT_SYMBOL_GPL(usb_stor_control_msg);
223 224
224/* This is a version of usb_clear_halt() that allows early termination and 225/* This is a version of usb_clear_halt() that allows early termination and
225 * doesn't read the status from the device -- this is because some devices 226 * doesn't read the status from the device -- this is because some devices
@@ -254,6 +255,7 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
254 US_DEBUGP("%s: result = %d\n", __func__, result); 255 US_DEBUGP("%s: result = %d\n", __func__, result);
255 return result; 256 return result;
256} 257}
258EXPORT_SYMBOL_GPL(usb_stor_clear_halt);
257 259
258 260
259/* 261/*
@@ -352,6 +354,7 @@ int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
352 return interpret_urb_result(us, pipe, size, result, 354 return interpret_urb_result(us, pipe, size, result,
353 us->current_urb->actual_length); 355 us->current_urb->actual_length);
354} 356}
357EXPORT_SYMBOL_GPL(usb_stor_ctrl_transfer);
355 358
356/* 359/*
357 * Receive one interrupt buffer, without timeouts, but allowing early 360 * Receive one interrupt buffer, without timeouts, but allowing early
@@ -407,6 +410,7 @@ int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
407 return interpret_urb_result(us, pipe, length, result, 410 return interpret_urb_result(us, pipe, length, result,
408 us->current_urb->actual_length); 411 us->current_urb->actual_length);
409} 412}
413EXPORT_SYMBOL_GPL(usb_stor_bulk_transfer_buf);
410 414
411/* 415/*
412 * Transfer a scatter-gather list via bulk transfer 416 * Transfer a scatter-gather list via bulk transfer
@@ -474,6 +478,7 @@ int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
474 scsi_set_resid(srb, scsi_bufflen(srb) - partial); 478 scsi_set_resid(srb, scsi_bufflen(srb) - partial);
475 return result; 479 return result;
476} 480}
481EXPORT_SYMBOL_GPL(usb_stor_bulk_srb);
477 482
478/* 483/*
479 * Transfer an entire SCSI command's worth of data payload over the bulk 484 * Transfer an entire SCSI command's worth of data payload over the bulk
@@ -509,6 +514,7 @@ int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,
509 *residual = length_left; 514 *residual = length_left;
510 return result; 515 return result;
511} 516}
517EXPORT_SYMBOL_GPL(usb_stor_bulk_transfer_sg);
512 518
513/*********************************************************************** 519/***********************************************************************
514 * Transport routines 520 * Transport routines
@@ -940,6 +946,7 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
940 usb_stor_clear_halt(us, pipe); 946 usb_stor_clear_halt(us, pipe);
941 return USB_STOR_TRANSPORT_FAILED; 947 return USB_STOR_TRANSPORT_FAILED;
942} 948}
949EXPORT_SYMBOL_GPL(usb_stor_CB_transport);
943 950
944/* 951/*
945 * Bulk only transport 952 * Bulk only transport
@@ -1156,6 +1163,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1156 /* we should never get here, but if we do, we're in trouble */ 1163 /* we should never get here, but if we do, we're in trouble */
1157 return USB_STOR_TRANSPORT_ERROR; 1164 return USB_STOR_TRANSPORT_ERROR;
1158} 1165}
1166EXPORT_SYMBOL_GPL(usb_stor_Bulk_transport);
1159 1167
1160/*********************************************************************** 1168/***********************************************************************
1161 * Reset routines 1169 * Reset routines
@@ -1230,6 +1238,7 @@ int usb_stor_CB_reset(struct us_data *us)
1230 USB_TYPE_CLASS | USB_RECIP_INTERFACE, 1238 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
1231 0, us->ifnum, us->iobuf, CB_RESET_CMD_SIZE); 1239 0, us->ifnum, us->iobuf, CB_RESET_CMD_SIZE);
1232} 1240}
1241EXPORT_SYMBOL_GPL(usb_stor_CB_reset);
1233 1242
1234/* This issues a Bulk-only Reset to the device in question, including 1243/* This issues a Bulk-only Reset to the device in question, including
1235 * clearing the subsequent endpoint halts that may occur. 1244 * clearing the subsequent endpoint halts that may occur.
@@ -1242,6 +1251,7 @@ int usb_stor_Bulk_reset(struct us_data *us)
1242 USB_TYPE_CLASS | USB_RECIP_INTERFACE, 1251 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
1243 0, us->ifnum, NULL, 0); 1252 0, us->ifnum, NULL, 0);
1244} 1253}
1254EXPORT_SYMBOL_GPL(usb_stor_Bulk_reset);
1245 1255
1246/* Issue a USB port reset to the device. The caller must not hold 1256/* Issue a USB port reset to the device. The caller must not hold
1247 * us->dev_mutex. 1257 * us->dev_mutex.
diff --git a/drivers/usb/storage/freecom.h b/drivers/usb/storage/unusual_alauda.h
index 20d0fe6ba0c8..8c412f885dd2 100644
--- a/drivers/usb/storage/freecom.h
+++ b/drivers/usb/storage/unusual_alauda.h
@@ -1,13 +1,4 @@
1/* Driver for Freecom USB/IDE adaptor 1/* Unusual Devices File for the Alauda-based card readers
2 *
3 * Freecom v0.1:
4 *
5 * First release
6 *
7 * Current development and maintenance by:
8 * (c) 2000 David Brown <usb-storage@davidb.org>
9 *
10 * See freecom.c for more explanation
11 * 2 *
12 * This program is free software; you can redistribute it and/or modify it 3 * 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 4 * under the terms of the GNU General Public License as published by the
@@ -24,11 +15,17 @@
24 * 675 Mass Ave, Cambridge, MA 02139, USA. 15 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 16 */
26 17
27#ifndef _FREECOM_USB_H 18#if defined(CONFIG_USB_STORAGE_ALAUDA) || \
28#define _FREECOM_USB_H 19 defined(CONFIG_USB_STORAGE_ALAUDA_MODULE)
20
21UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102,
22 "Fujifilm",
23 "DPC-R1 (Alauda)",
24 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0),
29 25
30extern int freecom_transport(struct scsi_cmnd *srb, struct us_data *us); 26UNUSUAL_DEV( 0x07b4, 0x010a, 0x0102, 0x0102,
31extern int usb_stor_freecom_reset(struct us_data *us); 27 "Olympus",
32extern int freecom_init (struct us_data *us); 28 "MAUSB-10 (Alauda)",
29 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0),
33 30
34#endif 31#endif /* defined(CONFIG_USB_STORAGE_ALAUDA) || ... */
diff --git a/drivers/usb/storage/unusual_cypress.h b/drivers/usb/storage/unusual_cypress.h
new file mode 100644
index 000000000000..44be6d75dab6
--- /dev/null
+++ b/drivers/usb/storage/unusual_cypress.h
@@ -0,0 +1,34 @@
1/* Unusual Devices File for devices based on the Cypress USB/ATA bridge
2 * with support for ATACB
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#if defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || \
20 defined(CONFIG_USB_STORAGE_CYPRESS_ATACB_MODULE)
21
22/* CY7C68300 : support atacb */
23UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
24 "Cypress",
25 "Cypress AT2LP",
26 US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0),
27
28/* CY7C68310 : support atacb and atacb2 */
29UNUSUAL_DEV( 0x04b4, 0x6831, 0x0000, 0x9999,
30 "Cypress",
31 "Cypress ISD-300LP",
32 US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0),
33
34#endif /* defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || ... */
diff --git a/drivers/usb/storage/unusual_datafab.h b/drivers/usb/storage/unusual_datafab.h
new file mode 100644
index 000000000000..c9298ce9f223
--- /dev/null
+++ b/drivers/usb/storage/unusual_datafab.h
@@ -0,0 +1,98 @@
1/* Unusual Devices File for the Datafab USB Compact Flash reader
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2, or (at your option) any
6 * later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#if defined(CONFIG_USB_STORAGE_DATAFAB) || \
19 defined(CONFIG_USB_STORAGE_DATAFAB_MODULE)
20
21UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015,
22 "Datafab",
23 "MDCFE-B USB CF Reader",
24 US_SC_SCSI, US_PR_DATAFAB, NULL,
25 0),
26
27/*
28 * The following Datafab-based devices may or may not work
29 * using the current driver...the 0xffff is arbitrary since I
30 * don't know what device versions exist for these guys.
31 *
32 * The 0xa003 and 0xa004 devices in particular I'm curious about.
33 * I'm told they exist but so far nobody has come forward to say that
34 * they work with this driver. Given the success we've had getting
35 * other Datafab-based cards operational with this driver, I've decided
36 * to leave these two devices in the list.
37 */
38UNUSUAL_DEV( 0x07c4, 0xa001, 0x0000, 0xffff,
39 "SIIG/Datafab",
40 "SIIG/Datafab Memory Stick+CF Reader/Writer",
41 US_SC_SCSI, US_PR_DATAFAB, NULL,
42 0),
43
44/* Reported by Josef Reisinger <josef.reisinger@netcologne.de> */
45UNUSUAL_DEV( 0x07c4, 0xa002, 0x0000, 0xffff,
46 "Datafab/Unknown",
47 "MD2/MD3 Disk enclosure",
48 US_SC_SCSI, US_PR_DATAFAB, NULL,
49 US_FL_SINGLE_LUN),
50
51UNUSUAL_DEV( 0x07c4, 0xa003, 0x0000, 0xffff,
52 "Datafab/Unknown",
53 "Datafab-based Reader",
54 US_SC_SCSI, US_PR_DATAFAB, NULL,
55 0),
56
57UNUSUAL_DEV( 0x07c4, 0xa004, 0x0000, 0xffff,
58 "Datafab/Unknown",
59 "Datafab-based Reader",
60 US_SC_SCSI, US_PR_DATAFAB, NULL,
61 0),
62
63UNUSUAL_DEV( 0x07c4, 0xa005, 0x0000, 0xffff,
64 "PNY/Datafab",
65 "PNY/Datafab CF+SM Reader",
66 US_SC_SCSI, US_PR_DATAFAB, NULL,
67 0),
68
69UNUSUAL_DEV( 0x07c4, 0xa006, 0x0000, 0xffff,
70 "Simple Tech/Datafab",
71 "Simple Tech/Datafab CF+SM Reader",
72 US_SC_SCSI, US_PR_DATAFAB, NULL,
73 0),
74
75/* Submitted by Olaf Hering <olh@suse.de> */
76UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
77 "Datafab Systems, Inc.",
78 "USB to CF + SM Combo (LC1)",
79 US_SC_SCSI, US_PR_DATAFAB, NULL,
80 0),
81
82/* Reported by Felix Moeller <felix@derklecks.de>
83 * in Germany this is sold by Hama with the productnumber 46952
84 * as "DualSlot CompactFlash(TM) & MStick Drive USB"
85 */
86UNUSUAL_DEV( 0x07c4, 0xa10b, 0x0000, 0xffff,
87 "DataFab Systems Inc.",
88 "USB CF+MS",
89 US_SC_SCSI, US_PR_DATAFAB, NULL,
90 0),
91
92UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
93 "Acomdata",
94 "CF",
95 US_SC_SCSI, US_PR_DATAFAB, NULL,
96 US_FL_SINGLE_LUN),
97
98#endif /* defined(CONFIG_USB_STORAGE_DATAFAB) || ... */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 6f59c8e510ea..1c1f643e8a78 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -53,6 +53,11 @@
53 * as opposed to devices that do something strangely or wrongly. 53 * as opposed to devices that do something strangely or wrongly.
54 */ 54 */
55 55
56#if !defined(CONFIG_USB_STORAGE_SDDR09) && \
57 !defined(CONFIG_USB_STORAGE_SDDR09_MODULE)
58#define NO_SDDR09
59#endif
60
56/* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr> 61/* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr>
57 */ 62 */
58UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100, 63UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
@@ -80,18 +85,6 @@ UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200,
80 "CD-Writer+", 85 "CD-Writer+",
81 US_SC_8070, US_PR_CB, NULL, 0), 86 US_SC_8070, US_PR_CB, NULL, 0),
82 87
83#ifdef CONFIG_USB_STORAGE_USBAT
84UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001,
85 "HP",
86 "CD-Writer+ 8200e",
87 US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
88
89UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001,
90 "HP",
91 "CD-Writer+ CD-4e",
92 US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
93#endif
94
95/* Reported by Ben Efros <ben@pc-doctor.com> */ 88/* Reported by Ben Efros <ben@pc-doctor.com> */
96UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000, 89UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000,
97 "HP", 90 "HP",
@@ -226,7 +219,7 @@ UNUSUAL_DEV( 0x0421, 0x047c, 0x0370, 0x0610,
226 US_FL_MAX_SECTORS_64 ), 219 US_FL_MAX_SECTORS_64 ),
227 220
228/* Reported by Manuel Osdoba <manuel.osdoba@tu-ilmenau.de> */ 221/* Reported by Manuel Osdoba <manuel.osdoba@tu-ilmenau.de> */
229UNUSUAL_DEV( 0x0421, 0x0492, 0x0452, 0x0452, 222UNUSUAL_DEV( 0x0421, 0x0492, 0x0452, 0x9999,
230 "Nokia", 223 "Nokia",
231 "Nokia 6233", 224 "Nokia 6233",
232 US_SC_DEVICE, US_PR_DEVICE, NULL, 225 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -246,12 +239,7 @@ UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
246 US_SC_DEVICE, US_PR_DEVICE, NULL, 239 US_SC_DEVICE, US_PR_DEVICE, NULL,
247 US_FL_SINGLE_LUN ), 240 US_FL_SINGLE_LUN ),
248 241
249#ifdef CONFIG_USB_STORAGE_SDDR09 242#ifdef NO_SDDR09
250UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
251 "Microtech",
252 "CameraMate (DPCM_USB)",
253 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ),
254#else
255UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100, 243UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
256 "Microtech", 244 "Microtech",
257 "CameraMate", 245 "CameraMate",
@@ -288,13 +276,6 @@ UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100,
288 US_SC_DEVICE, US_PR_DEVICE, NULL, 276 US_SC_DEVICE, US_PR_DEVICE, NULL,
289 US_FL_NOT_LOCKABLE ), 277 US_FL_NOT_LOCKABLE ),
290 278
291#ifdef CONFIG_USB_STORAGE_KARMA
292UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101,
293 "Rio",
294 "Rio Karma",
295 US_SC_SCSI, US_PR_KARMA, rio_karma_init, 0),
296#endif
297
298/* Reported by Tamas Kerecsen <kerecsen@bigfoot.com> 279/* Reported by Tamas Kerecsen <kerecsen@bigfoot.com>
299 * Obviously the PROM has not been customized by the VAR; 280 * Obviously the PROM has not been customized by the VAR;
300 * the Vendor and Product string descriptors are: 281 * the Vendor and Product string descriptors are:
@@ -375,22 +356,6 @@ UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110,
375 US_SC_DEVICE, US_PR_CB, NULL, 356 US_SC_DEVICE, US_PR_CB, NULL,
376 US_FL_MAX_SECTORS_MIN), 357 US_FL_MAX_SECTORS_MIN),
377 358
378#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
379/* CY7C68300 : support atacb */
380UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
381 "Cypress",
382 "Cypress AT2LP",
383 US_SC_CYP_ATACB, US_PR_DEVICE, NULL,
384 0),
385
386/* CY7C68310 : support atacb and atacb2 */
387UNUSUAL_DEV( 0x04b4, 0x6831, 0x0000, 0x9999,
388 "Cypress",
389 "Cypress ISD-300LP",
390 US_SC_CYP_ATACB, US_PR_DEVICE, NULL,
391 0),
392#endif
393
394/* Reported by Simon Levitt <simon@whattf.com> 359/* Reported by Simon Levitt <simon@whattf.com>
395 * This entry needs Sub and Proto fields */ 360 * This entry needs Sub and Proto fields */
396UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, 361UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100,
@@ -467,20 +432,7 @@ UNUSUAL_DEV( 0x04e6, 0x0002, 0x0100, 0x0100,
467 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init, 432 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init,
468 US_FL_SCM_MULT_TARG ), 433 US_FL_SCM_MULT_TARG ),
469 434
470#ifdef CONFIG_USB_STORAGE_SDDR09 435#ifdef NO_SDDR09
471UNUSUAL_DEV( 0x04e6, 0x0003, 0x0000, 0x9999,
472 "Sandisk",
473 "ImageMate SDDR09",
474 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
475 0),
476
477/* This entry is from Andries.Brouwer@cwi.nl */
478UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
479 "SCM Microsystems",
480 "eUSB SmartMedia / CompactFlash Adapter",
481 US_SC_SCSI, US_PR_DPCM_USB, usb_stor_sddr09_dpcm_init,
482 0),
483#else
484UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208, 436UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
485 "SCM Microsystems", 437 "SCM Microsystems",
486 "eUSB CompactFlash Adapter", 438 "eUSB CompactFlash Adapter",
@@ -535,14 +487,6 @@ UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200,
535 "CD-RW Device", 487 "CD-RW Device",
536 US_SC_8020, US_PR_CB, NULL, 0), 488 US_SC_8020, US_PR_CB, NULL, 0),
537 489
538#ifdef CONFIG_USB_STORAGE_USBAT
539UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
540 "Shuttle/SCM",
541 "USBAT-02",
542 US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
543 US_FL_SINGLE_LUN),
544#endif
545
546/* Reported by Dmitry Khlystov <adminimus@gmail.com> */ 490/* Reported by Dmitry Khlystov <adminimus@gmail.com> */
547UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220, 491UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
548 "Samsung", 492 "Samsung",
@@ -645,14 +589,6 @@ UNUSUAL_DEV( 0x054c, 0x0025, 0x0100, 0x0100,
645 US_SC_DEVICE, US_PR_DEVICE, NULL, 589 US_SC_DEVICE, US_PR_DEVICE, NULL,
646 US_FL_SINGLE_LUN ), 590 US_FL_SINGLE_LUN ),
647 591
648#ifdef CONFIG_USB_STORAGE_ISD200
649UNUSUAL_DEV( 0x054c, 0x002b, 0x0100, 0x0110,
650 "Sony",
651 "Portable USB Harddrive V2",
652 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
653 0 ),
654#endif
655
656/* Submitted by Olaf Hering, <olh@suse.de> SuSE Bugzilla #49049 */ 592/* Submitted by Olaf Hering, <olh@suse.de> SuSE Bugzilla #49049 */
657UNUSUAL_DEV( 0x054c, 0x002c, 0x0501, 0x2000, 593UNUSUAL_DEV( 0x054c, 0x002c, 0x0501, 0x2000,
658 "Sony", 594 "Sony",
@@ -749,13 +685,6 @@ UNUSUAL_DEV( 0x057b, 0x0022, 0x0000, 0x9999,
749 "Silicon Media R/W", 685 "Silicon Media R/W",
750 US_SC_DEVICE, US_PR_DEVICE, NULL, 0), 686 US_SC_DEVICE, US_PR_DEVICE, NULL, 0),
751 687
752#ifdef CONFIG_USB_STORAGE_ALAUDA
753UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102,
754 "Fujifilm",
755 "DPC-R1 (Alauda)",
756 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ),
757#endif
758
759/* Reported by RTE <raszilki@yandex.ru> */ 688/* Reported by RTE <raszilki@yandex.ru> */
760UNUSUAL_DEV( 0x058f, 0x6387, 0x0141, 0x0141, 689UNUSUAL_DEV( 0x058f, 0x6387, 0x0141, 0x0141,
761 "JetFlash", 690 "JetFlash",
@@ -798,32 +727,6 @@ UNUSUAL_DEV( 0x05ab, 0x0060, 0x1104, 0x1110,
798 US_SC_SCSI, US_PR_BULK, NULL, 727 US_SC_SCSI, US_PR_BULK, NULL,
799 US_FL_NEED_OVERRIDE ), 728 US_FL_NEED_OVERRIDE ),
800 729
801#ifdef CONFIG_USB_STORAGE_ISD200
802UNUSUAL_DEV( 0x05ab, 0x0031, 0x0100, 0x0110,
803 "In-System",
804 "USB/IDE Bridge (ATA/ATAPI)",
805 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
806 0 ),
807
808UNUSUAL_DEV( 0x05ab, 0x0301, 0x0100, 0x0110,
809 "In-System",
810 "Portable USB Harddrive V2",
811 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
812 0 ),
813
814UNUSUAL_DEV( 0x05ab, 0x0351, 0x0100, 0x0110,
815 "In-System",
816 "Portable USB Harddrive V2",
817 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
818 0 ),
819
820UNUSUAL_DEV( 0x05ab, 0x5701, 0x0100, 0x0110,
821 "In-System",
822 "USB Storage Adapter V2",
823 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
824 0 ),
825#endif
826
827/* Submitted by Sven Anderson <sven-linux@anderson.de> 730/* Submitted by Sven Anderson <sven-linux@anderson.de>
828 * There are at least four ProductIDs used for iPods, so I added 0x1202 and 731 * There are at least four ProductIDs used for iPods, so I added 0x1202 and
829 * 0x1204. They just need the US_FL_FIX_CAPACITY. As the bcdDevice appears 732 * 0x1204. They just need the US_FL_FIX_CAPACITY. As the bcdDevice appears
@@ -877,14 +780,6 @@ UNUSUAL_DEV( 0x05c6, 0x1000, 0x0000, 0x9999,
877 US_SC_DEVICE, US_PR_DEVICE, option_ms_init, 780 US_SC_DEVICE, US_PR_DEVICE, option_ms_init,
878 0), 781 0),
879 782
880#ifdef CONFIG_USB_STORAGE_JUMPSHOT
881UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001,
882 "Lexar",
883 "Jumpshot USB CF Reader",
884 US_SC_SCSI, US_PR_JUMPSHOT, NULL,
885 US_FL_NEED_OVERRIDE ),
886#endif
887
888/* Reported by Blake Matheny <bmatheny@purdue.edu> */ 783/* Reported by Blake Matheny <bmatheny@purdue.edu> */
889UNUSUAL_DEV( 0x05dc, 0xb002, 0x0000, 0x0113, 784UNUSUAL_DEV( 0x05dc, 0xb002, 0x0000, 0x0113,
890 "Lexar", 785 "Lexar",
@@ -935,14 +830,6 @@ UNUSUAL_DEV( 0x0644, 0x0000, 0x0100, 0x0100,
935 "Floppy Drive", 830 "Floppy Drive",
936 US_SC_UFI, US_PR_CB, NULL, 0 ), 831 US_SC_UFI, US_PR_CB, NULL, 0 ),
937 832
938#ifdef CONFIG_USB_STORAGE_SDDR09
939UNUSUAL_DEV( 0x066b, 0x0105, 0x0100, 0x0100,
940 "Olympus",
941 "Camedia MAUSB-2",
942 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
943 0),
944#endif
945
946/* Reported by Darsen Lu <darsen@micro.ee.nthu.edu.tw> */ 833/* Reported by Darsen Lu <darsen@micro.ee.nthu.edu.tw> */
947UNUSUAL_DEV( 0x066f, 0x8000, 0x0001, 0x0001, 834UNUSUAL_DEV( 0x066f, 0x8000, 0x0001, 0x0001,
948 "SigmaTel", 835 "SigmaTel",
@@ -951,7 +838,9 @@ UNUSUAL_DEV( 0x066f, 0x8000, 0x0001, 0x0001,
951 US_FL_FIX_CAPACITY ), 838 US_FL_FIX_CAPACITY ),
952 839
953/* Reported by Richard -=[]=- <micro_flyer@hotmail.com> */ 840/* Reported by Richard -=[]=- <micro_flyer@hotmail.com> */
954UNUSUAL_DEV( 0x067b, 0x2507, 0x0100, 0x0100, 841/* Change to bcdDeviceMin (0x0100 to 0x0001) reported by
842 * Thomas Bartosik <tbartdev@gmx-topmail.de> */
843UNUSUAL_DEV( 0x067b, 0x2507, 0x0001, 0x0100,
955 "Prolific Technology Inc.", 844 "Prolific Technology Inc.",
956 "Mass Storage Device", 845 "Mass Storage Device",
957 US_SC_DEVICE, US_PR_DEVICE, NULL, 846 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -1041,35 +930,12 @@ UNUSUAL_DEV( 0x0781, 0x0002, 0x0009, 0x0009,
1041 US_SC_DEVICE, US_PR_DEVICE, NULL, 930 US_SC_DEVICE, US_PR_DEVICE, NULL,
1042 US_FL_FIX_CAPACITY ), 931 US_FL_FIX_CAPACITY ),
1043 932
1044#ifdef CONFIG_USB_STORAGE_USBAT
1045UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005,
1046 "Sandisk",
1047 "ImageMate SDDR-05b",
1048 US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
1049 US_FL_SINGLE_LUN ),
1050#endif
1051
1052UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100, 933UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100,
1053 "Sandisk", 934 "Sandisk",
1054 "ImageMate SDDR-12", 935 "ImageMate SDDR-12",
1055 US_SC_SCSI, US_PR_CB, NULL, 936 US_SC_SCSI, US_PR_CB, NULL,
1056 US_FL_SINGLE_LUN ), 937 US_FL_SINGLE_LUN ),
1057 938
1058#ifdef CONFIG_USB_STORAGE_SDDR09
1059UNUSUAL_DEV( 0x0781, 0x0200, 0x0000, 0x9999,
1060 "Sandisk",
1061 "ImageMate SDDR-09",
1062 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
1063 0),
1064#endif
1065
1066#ifdef CONFIG_USB_STORAGE_FREECOM
1067UNUSUAL_DEV( 0x07ab, 0xfc01, 0x0000, 0x9999,
1068 "Freecom",
1069 "USB-IDE",
1070 US_SC_QIC, US_PR_FREECOM, freecom_init, 0),
1071#endif
1072
1073/* Reported by Eero Volotinen <eero@ping-viini.org> */ 939/* Reported by Eero Volotinen <eero@ping-viini.org> */
1074UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0000, 0x9999, 940UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0000, 0x9999,
1075 "Freecom Technologies", 941 "Freecom Technologies",
@@ -1089,12 +955,7 @@ UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100,
1089 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init, 955 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init,
1090 US_FL_SCM_MULT_TARG ), 956 US_FL_SCM_MULT_TARG ),
1091 957
1092#ifdef CONFIG_USB_STORAGE_SDDR09 958#ifdef NO_SDDR09
1093UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
1094 "Microtech",
1095 "CameraMate (DPCM_USB)",
1096 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ),
1097#else
1098UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100, 959UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
1099 "Microtech", 960 "Microtech",
1100 "CameraMate", 961 "CameraMate",
@@ -1102,108 +963,6 @@ UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
1102 US_FL_SINGLE_LUN ), 963 US_FL_SINGLE_LUN ),
1103#endif 964#endif
1104 965
1105#ifdef CONFIG_USB_STORAGE_ALAUDA
1106UNUSUAL_DEV( 0x07b4, 0x010a, 0x0102, 0x0102,
1107 "Olympus",
1108 "MAUSB-10 (Alauda)",
1109 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ),
1110#endif
1111
1112#ifdef CONFIG_USB_STORAGE_DATAFAB
1113UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015,
1114 "Datafab",
1115 "MDCFE-B USB CF Reader",
1116 US_SC_SCSI, US_PR_DATAFAB, NULL,
1117 0 ),
1118
1119/*
1120 * The following Datafab-based devices may or may not work
1121 * using the current driver...the 0xffff is arbitrary since I
1122 * don't know what device versions exist for these guys.
1123 *
1124 * The 0xa003 and 0xa004 devices in particular I'm curious about.
1125 * I'm told they exist but so far nobody has come forward to say that
1126 * they work with this driver. Given the success we've had getting
1127 * other Datafab-based cards operational with this driver, I've decided
1128 * to leave these two devices in the list.
1129 */
1130UNUSUAL_DEV( 0x07c4, 0xa001, 0x0000, 0xffff,
1131 "SIIG/Datafab",
1132 "SIIG/Datafab Memory Stick+CF Reader/Writer",
1133 US_SC_SCSI, US_PR_DATAFAB, NULL,
1134 0 ),
1135
1136/* Reported by Josef Reisinger <josef.reisinger@netcologne.de> */
1137UNUSUAL_DEV( 0x07c4, 0xa002, 0x0000, 0xffff,
1138 "Datafab/Unknown",
1139 "MD2/MD3 Disk enclosure",
1140 US_SC_SCSI, US_PR_DATAFAB, NULL,
1141 US_FL_SINGLE_LUN ),
1142
1143UNUSUAL_DEV( 0x07c4, 0xa003, 0x0000, 0xffff,
1144 "Datafab/Unknown",
1145 "Datafab-based Reader",
1146 US_SC_SCSI, US_PR_DATAFAB, NULL,
1147 0 ),
1148
1149UNUSUAL_DEV( 0x07c4, 0xa004, 0x0000, 0xffff,
1150 "Datafab/Unknown",
1151 "Datafab-based Reader",
1152 US_SC_SCSI, US_PR_DATAFAB, NULL,
1153 0 ),
1154
1155UNUSUAL_DEV( 0x07c4, 0xa005, 0x0000, 0xffff,
1156 "PNY/Datafab",
1157 "PNY/Datafab CF+SM Reader",
1158 US_SC_SCSI, US_PR_DATAFAB, NULL,
1159 0 ),
1160
1161UNUSUAL_DEV( 0x07c4, 0xa006, 0x0000, 0xffff,
1162 "Simple Tech/Datafab",
1163 "Simple Tech/Datafab CF+SM Reader",
1164 US_SC_SCSI, US_PR_DATAFAB, NULL,
1165 0 ),
1166#endif
1167
1168#ifdef CONFIG_USB_STORAGE_SDDR55
1169/* Contributed by Peter Waechtler */
1170UNUSUAL_DEV( 0x07c4, 0xa103, 0x0000, 0x9999,
1171 "Datafab",
1172 "MDSM-B reader",
1173 US_SC_SCSI, US_PR_SDDR55, NULL,
1174 US_FL_FIX_INQUIRY ),
1175#endif
1176
1177#ifdef CONFIG_USB_STORAGE_DATAFAB
1178/* Submitted by Olaf Hering <olh@suse.de> */
1179UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
1180 "Datafab Systems, Inc.",
1181 "USB to CF + SM Combo (LC1)",
1182 US_SC_SCSI, US_PR_DATAFAB, NULL,
1183 0 ),
1184#endif
1185#ifdef CONFIG_USB_STORAGE_SDDR55
1186/* SM part - aeb <Andries.Brouwer@cwi.nl> */
1187UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
1188 "Datafab Systems, Inc.",
1189 "USB to CF + SM Combo (LC1)",
1190 US_SC_SCSI, US_PR_SDDR55, NULL,
1191 US_FL_SINGLE_LUN ),
1192#endif
1193
1194#ifdef CONFIG_USB_STORAGE_DATAFAB
1195/* Reported by Felix Moeller <felix@derklecks.de>
1196 * in Germany this is sold by Hama with the productnumber 46952
1197 * as "DualSlot CompactFlash(TM) & MStick Drive USB"
1198 */
1199UNUSUAL_DEV( 0x07c4, 0xa10b, 0x0000, 0xffff,
1200 "DataFab Systems Inc.",
1201 "USB CF+MS",
1202 US_SC_SCSI, US_PR_DATAFAB, NULL,
1203 0 ),
1204
1205#endif
1206
1207/* Datafab KECF-USB / Sagatek DCS-CF / Simpletech Flashlink UCF-100 966/* Datafab KECF-USB / Sagatek DCS-CF / Simpletech Flashlink UCF-100
1208 * Only revision 1.13 tested (same for all of the above devices, 967 * Only revision 1.13 tested (same for all of the above devices,
1209 * based on the Datafab DF-UG-07 chip). Needed for US_FL_FIX_INQUIRY. 968 * based on the Datafab DF-UG-07 chip). Needed for US_FL_FIX_INQUIRY.
@@ -1390,6 +1149,16 @@ UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
1390 US_SC_DEVICE, US_PR_DEVICE, NULL, 1149 US_SC_DEVICE, US_PR_DEVICE, NULL,
1391 0 ), 1150 0 ),
1392 1151
1152/* Reported by Jan Dumon <j.dumon@option.com>
1153 * This device (wrongly) has a vendor-specific device descriptor.
1154 * The entry is needed so usb-storage can bind to it's mass-storage
1155 * interface as an interface driver */
1156UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000,
1157 "Option",
1158 "GI 0431 SD-Card",
1159 US_SC_DEVICE, US_PR_DEVICE, NULL,
1160 0 ),
1161
1393/* Reported by Ben Efros <ben@pc-doctor.com> */ 1162/* Reported by Ben Efros <ben@pc-doctor.com> */
1394UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000, 1163UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000,
1395 "Seagate", 1164 "Seagate",
@@ -1397,29 +1166,6 @@ UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000,
1397 US_SC_DEVICE, US_PR_DEVICE, NULL, 1166 US_SC_DEVICE, US_PR_DEVICE, NULL,
1398 US_FL_SANE_SENSE ), 1167 US_FL_SANE_SENSE ),
1399 1168
1400#ifdef CONFIG_USB_STORAGE_ISD200
1401UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
1402 "ATI",
1403 "USB Cable 205",
1404 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
1405 0 ),
1406#endif
1407
1408#ifdef CONFIG_USB_STORAGE_DATAFAB
1409UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
1410 "Acomdata",
1411 "CF",
1412 US_SC_SCSI, US_PR_DATAFAB, NULL,
1413 US_FL_SINGLE_LUN ),
1414#endif
1415#ifdef CONFIG_USB_STORAGE_SDDR55
1416UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
1417 "Acomdata",
1418 "SM",
1419 US_SC_SCSI, US_PR_SDDR55, NULL,
1420 US_FL_SINGLE_LUN ),
1421#endif
1422
1423UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999, 1169UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999,
1424 "Maxtor", 1170 "Maxtor",
1425 "USB to SATA", 1171 "USB to SATA",
@@ -1436,23 +1182,6 @@ UNUSUAL_DEV( 0x0c45, 0x1060, 0x0100, 0x0100,
1436 US_SC_DEVICE, US_PR_DEVICE, NULL, 1182 US_SC_DEVICE, US_PR_DEVICE, NULL,
1437 US_FL_SINGLE_LUN ), 1183 US_FL_SINGLE_LUN ),
1438 1184
1439/* Submitted by: Nick Sillik <n.sillik@temple.edu>
1440 * Needed for OneTouch extension to usb-storage
1441 *
1442 */
1443#ifdef CONFIG_USB_STORAGE_ONETOUCH
1444 UNUSUAL_DEV( 0x0d49, 0x7000, 0x0000, 0x9999,
1445 "Maxtor",
1446 "OneTouch External Harddrive",
1447 US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
1448 0),
1449 UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999,
1450 "Maxtor",
1451 "OneTouch External Harddrive",
1452 US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
1453 0),
1454#endif
1455
1456/* Submitted by Joris Struyve <joris@struyve.be> */ 1185/* Submitted by Joris Struyve <joris@struyve.be> */
1457UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff, 1186UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
1458 "Medion", 1187 "Medion",
@@ -2105,14 +1834,6 @@ UNUSUAL_DEV( 0x4146, 0xba01, 0x0100, 0x0100,
2105 "Micro Mini 1GB", 1834 "Micro Mini 1GB",
2106 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), 1835 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
2107 1836
2108#ifdef CONFIG_USB_STORAGE_SDDR55
2109UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999,
2110 "Sandisk",
2111 "ImageMate SDDR55",
2112 US_SC_SCSI, US_PR_SDDR55, NULL,
2113 US_FL_SINGLE_LUN),
2114#endif
2115
2116/* Reported by Andrew Simmons <andrew.simmons@gmail.com> */ 1837/* Reported by Andrew Simmons <andrew.simmons@gmail.com> */
2117UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001, 1838UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001,
2118 "DataStor", 1839 "DataStor",
diff --git a/drivers/usb/storage/cypress_atacb.h b/drivers/usb/storage/unusual_freecom.h
index fbada898d56b..375867942391 100644
--- a/drivers/usb/storage/cypress_atacb.h
+++ b/drivers/usb/storage/unusual_freecom.h
@@ -1,8 +1,4 @@
1/* 1/* Unusual Devices File for the Freecom USB/IDE adaptor
2 * Support for emulating SAT (ata pass through) on devices based
3 * on the Cypress USB/ATA bridge supporting ATACB.
4 *
5 * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr)
6 * 2 *
7 * This program is free software; you can redistribute it and/or modify it 3 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the 4 * under the terms of the GNU General Public License as published by the
@@ -19,7 +15,12 @@
19 * 675 Mass Ave, Cambridge, MA 02139, USA. 15 * 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 16 */
21 17
22#ifndef _CYPRESS_ATACB_H_ 18#if defined(CONFIG_USB_STORAGE_FREECOM) || \
23#define _CYPRESS_ATACB_H_ 19 defined(CONFIG_USB_STORAGE_FREECOM_MODULE)
24extern void cypress_atacb_passthrough(struct scsi_cmnd*, struct us_data*); 20
25#endif 21UNUSUAL_DEV( 0x07ab, 0xfc01, 0x0000, 0x9999,
22 "Freecom",
23 "USB-IDE",
24 US_SC_QIC, US_PR_FREECOM, init_freecom, 0),
25
26#endif /* defined(CONFIG_USB_STORAGE_FREECOM) || ... */
diff --git a/drivers/usb/storage/unusual_isd200.h b/drivers/usb/storage/unusual_isd200.h
new file mode 100644
index 000000000000..0d99dde3382a
--- /dev/null
+++ b/drivers/usb/storage/unusual_isd200.h
@@ -0,0 +1,57 @@
1/* Unusual Devices File for In-System Design, Inc. ISD200 ASIC
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2, or (at your option) any
6 * later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#if defined(CONFIG_USB_STORAGE_ISD200) || \
19 defined(CONFIG_USB_STORAGE_ISD200_MODULE)
20
21UNUSUAL_DEV( 0x054c, 0x002b, 0x0100, 0x0110,
22 "Sony",
23 "Portable USB Harddrive V2",
24 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
25 0),
26
27UNUSUAL_DEV( 0x05ab, 0x0031, 0x0100, 0x0110,
28 "In-System",
29 "USB/IDE Bridge (ATA/ATAPI)",
30 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
31 0),
32
33UNUSUAL_DEV( 0x05ab, 0x0301, 0x0100, 0x0110,
34 "In-System",
35 "Portable USB Harddrive V2",
36 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
37 0),
38
39UNUSUAL_DEV( 0x05ab, 0x0351, 0x0100, 0x0110,
40 "In-System",
41 "Portable USB Harddrive V2",
42 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
43 0),
44
45UNUSUAL_DEV( 0x05ab, 0x5701, 0x0100, 0x0110,
46 "In-System",
47 "USB Storage Adapter V2",
48 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
49 0),
50
51UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
52 "ATI",
53 "USB Cable 205",
54 US_SC_ISD200, US_PR_BULK, isd200_Initialization,
55 0),
56
57#endif /* defined(CONFIG_USB_STORAGE_ISD200) || ... */
diff --git a/drivers/usb/storage/sddr55.h b/drivers/usb/storage/unusual_jumpshot.h
index a815a0470c84..2e549b1c2c62 100644
--- a/drivers/usb/storage/sddr55.h
+++ b/drivers/usb/storage/unusual_jumpshot.h
@@ -1,10 +1,4 @@
1/* Driver for SanDisk SDDR-55 SmartMedia reader 1/* Unusual Devices File for the Lexar "Jumpshot" Compact Flash reader
2 * Header File
3 *
4 * Current development and maintenance by:
5 * (c) 2002 Simon Munton
6 *
7 * See sddr55.c for more explanation
8 * 2 *
9 * This program is free software; you can redistribute it and/or modify it 3 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the 4 * under the terms of the GNU General Public License as published by the
@@ -21,12 +15,13 @@
21 * 675 Mass Ave, Cambridge, MA 02139, USA. 15 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 16 */
23 17
24#ifndef _USB_SHUTTLE_EUSB_SDDR55_H 18#if defined(CONFIG_USB_STORAGE_JUMPSHOT) || \
25#define _USB_SHUTTLE_EUSB_SDDR55_H 19 defined(CONFIG_USB_STORAGE_JUMPSHOT_MODULE)
26
27/* Sandisk SDDR-55 stuff */
28 20
29extern int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us); 21UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001,
30extern int sddr55_reset(struct us_data *us); 22 "Lexar",
23 "Jumpshot USB CF Reader",
24 US_SC_SCSI, US_PR_JUMPSHOT, NULL,
25 US_FL_NEED_OVERRIDE),
31 26
32#endif 27#endif /* defined(CONFIG_USB_STORAGE_JUMPSHOT) || ... */
diff --git a/drivers/usb/storage/isd200.h b/drivers/usb/storage/unusual_karma.h
index 0a35f4fa78f8..12ae3a03e802 100644
--- a/drivers/usb/storage/isd200.h
+++ b/drivers/usb/storage/unusual_karma.h
@@ -1,11 +1,4 @@
1/* Header File for In-System Design, Inc. ISD200 ASIC 1/* Unusual Devices File for the Rio Karma
2 *
3 * First release
4 *
5 * Current development and maintenance by:
6 * (c) 2000 In-System Design, Inc. (support@in-system.com)
7 *
8 * See isd200.c for more information.
9 * 2 *
10 * This program is free software; you can redistribute it and/or modify it 3 * 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 4 * under the terms of the GNU General Public License as published by the
@@ -22,10 +15,12 @@
22 * 675 Mass Ave, Cambridge, MA 02139, USA. 15 * 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 16 */
24 17
25#ifndef _USB_ISD200_H 18#if defined(CONFIG_USB_STORAGE_KARMA) || \
26#define _USB_ISD200_H 19 defined(CONFIG_USB_STORAGE_KARMA_MODULE)
27 20
28extern void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us); 21UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101,
29extern int isd200_Initialization(struct us_data *us); 22 "Rio",
23 "Rio Karma",
24 US_SC_SCSI, US_PR_KARMA, rio_karma_init, 0),
30 25
31#endif 26#endif /* defined(CONFIG_USB_STORAGE_KARMA) || ... */
diff --git a/drivers/usb/storage/unusual_onetouch.h b/drivers/usb/storage/unusual_onetouch.h
new file mode 100644
index 000000000000..bd9306b637df
--- /dev/null
+++ b/drivers/usb/storage/unusual_onetouch.h
@@ -0,0 +1,36 @@
1/* Unusual Devices File for the Maxtor OneTouch USB hard drive's button
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2, or (at your option) any
6 * later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#if defined(CONFIG_USB_STORAGE_ONETOUCH) || \
19 defined(CONFIG_USB_STORAGE_ONETOUCH_MODULE)
20
21/* Submitted by: Nick Sillik <n.sillik@temple.edu>
22 * Needed for OneTouch extension to usb-storage
23 */
24UNUSUAL_DEV( 0x0d49, 0x7000, 0x0000, 0x9999,
25 "Maxtor",
26 "OneTouch External Harddrive",
27 US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
28 0),
29
30UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999,
31 "Maxtor",
32 "OneTouch External Harddrive",
33 US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
34 0),
35
36#endif /* defined(CONFIG_USB_STORAGE_ONETOUCH) || ... */
diff --git a/drivers/usb/storage/unusual_sddr09.h b/drivers/usb/storage/unusual_sddr09.h
new file mode 100644
index 000000000000..50cab511a4d7
--- /dev/null
+++ b/drivers/usb/storage/unusual_sddr09.h
@@ -0,0 +1,56 @@
1/* Unusual Devices File for SanDisk SDDR-09 SmartMedia reader
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2, or (at your option) any
6 * later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#if defined(CONFIG_USB_STORAGE_SDDR09) || \
19 defined(CONFIG_USB_STORAGE_SDDR09_MODULE)
20
21UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
22 "Microtech",
23 "CameraMate (DPCM_USB)",
24 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0),
25
26UNUSUAL_DEV( 0x04e6, 0x0003, 0x0000, 0x9999,
27 "Sandisk",
28 "ImageMate SDDR09",
29 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
30 0),
31
32/* This entry is from Andries.Brouwer@cwi.nl */
33UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
34 "SCM Microsystems",
35 "eUSB SmartMedia / CompactFlash Adapter",
36 US_SC_SCSI, US_PR_DPCM_USB, usb_stor_sddr09_dpcm_init,
37 0),
38
39UNUSUAL_DEV( 0x066b, 0x0105, 0x0100, 0x0100,
40 "Olympus",
41 "Camedia MAUSB-2",
42 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
43 0),
44
45UNUSUAL_DEV( 0x0781, 0x0200, 0x0000, 0x9999,
46 "Sandisk",
47 "ImageMate SDDR-09",
48 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
49 0),
50
51UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
52 "Microtech",
53 "CameraMate (DPCM_USB)",
54 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0),
55
56#endif /* defined(CONFIG_USB_STORAGE_SDDR09) || ... */
diff --git a/drivers/usb/storage/unusual_sddr55.h b/drivers/usb/storage/unusual_sddr55.h
new file mode 100644
index 000000000000..ae81ef7a1cfd
--- /dev/null
+++ b/drivers/usb/storage/unusual_sddr55.h
@@ -0,0 +1,44 @@
1/* Unusual Devices File for SanDisk SDDR-55 SmartMedia reader
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2, or (at your option) any
6 * later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#if defined(CONFIG_USB_STORAGE_SDDR55) || \
19 defined(CONFIG_USB_STORAGE_SDDR55_MODULE)
20
21/* Contributed by Peter Waechtler */
22UNUSUAL_DEV( 0x07c4, 0xa103, 0x0000, 0x9999,
23 "Datafab",
24 "MDSM-B reader",
25 US_SC_SCSI, US_PR_SDDR55, NULL,
26 US_FL_FIX_INQUIRY),
27
28/* SM part - aeb <Andries.Brouwer@cwi.nl> */
29UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
30 "Datafab Systems, Inc.",
31 "USB to CF + SM Combo (LC1)",
32 US_SC_SCSI, US_PR_SDDR55, NULL, 0),
33
34UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
35 "Acomdata",
36 "SM",
37 US_SC_SCSI, US_PR_SDDR55, NULL, 0),
38
39UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999,
40 "Sandisk",
41 "ImageMate SDDR55",
42 US_SC_SCSI, US_PR_SDDR55, NULL, 0),
43
44#endif /* defined(CONFIG_USB_STORAGE_SDDR55) || ... */
diff --git a/drivers/usb/storage/unusual_usbat.h b/drivers/usb/storage/unusual_usbat.h
new file mode 100644
index 000000000000..80e869f10180
--- /dev/null
+++ b/drivers/usb/storage/unusual_usbat.h
@@ -0,0 +1,43 @@
1/* Unusual Devices File for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2, or (at your option) any
6 * later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#if defined(CONFIG_USB_STORAGE_USBAT) || \
19 defined(CONFIG_USB_STORAGE_USBAT_MODULE)
20
21UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001,
22 "HP",
23 "CD-Writer+ 8200e",
24 US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
25
26UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001,
27 "HP",
28 "CD-Writer+ CD-4e",
29 US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
30
31UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
32 "Shuttle/SCM",
33 "USBAT-02",
34 US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
35 US_FL_SINGLE_LUN),
36
37UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005,
38 "Sandisk",
39 "ImageMate SDDR-05b",
40 US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
41 US_FL_SINGLE_LUN),
42
43#endif /* defined(CONFIG_USB_STORAGE_USBAT) || ... */
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 4becf495ca2d..8060b85fe1a3 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Developed with the assistance of: 6 * Developed with the assistance of:
7 * (c) 2000 David L. Brown, Jr. (usb-storage@davidb.org) 7 * (c) 2000 David L. Brown, Jr. (usb-storage@davidb.org)
8 * (c) 2003 Alan Stern (stern@rowland.harvard.edu) 8 * (c) 2003-2009 Alan Stern (stern@rowland.harvard.edu)
9 * 9 *
10 * Initial work by: 10 * Initial work by:
11 * (c) 1999 Michael Gee (michael@linuxspecific.com) 11 * (c) 1999 Michael Gee (michael@linuxspecific.com)
@@ -66,39 +66,6 @@
66#include "debug.h" 66#include "debug.h"
67#include "initializers.h" 67#include "initializers.h"
68 68
69#ifdef CONFIG_USB_STORAGE_USBAT
70#include "shuttle_usbat.h"
71#endif
72#ifdef CONFIG_USB_STORAGE_SDDR09
73#include "sddr09.h"
74#endif
75#ifdef CONFIG_USB_STORAGE_SDDR55
76#include "sddr55.h"
77#endif
78#ifdef CONFIG_USB_STORAGE_FREECOM
79#include "freecom.h"
80#endif
81#ifdef CONFIG_USB_STORAGE_ISD200
82#include "isd200.h"
83#endif
84#ifdef CONFIG_USB_STORAGE_DATAFAB
85#include "datafab.h"
86#endif
87#ifdef CONFIG_USB_STORAGE_JUMPSHOT
88#include "jumpshot.h"
89#endif
90#ifdef CONFIG_USB_STORAGE_ONETOUCH
91#include "onetouch.h"
92#endif
93#ifdef CONFIG_USB_STORAGE_ALAUDA
94#include "alauda.h"
95#endif
96#ifdef CONFIG_USB_STORAGE_KARMA
97#include "karma.h"
98#endif
99#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
100#include "cypress_atacb.h"
101#endif
102#include "sierra_ms.h" 69#include "sierra_ms.h"
103#include "option_ms.h" 70#include "option_ms.h"
104 71
@@ -118,36 +85,8 @@ MODULE_PARM_DESC(quirks, "supplemental list of device IDs and their quirks");
118 85
119/* 86/*
120 * The entries in this table correspond, line for line, 87 * The entries in this table correspond, line for line,
121 * with the entries of us_unusual_dev_list[]. 88 * with the entries in usb_storage_usb_ids[], defined in usual-tables.c.
122 */ 89 */
123#ifndef CONFIG_USB_LIBUSUAL
124
125#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
126 vendorName, productName,useProtocol, useTransport, \
127 initFunction, flags) \
128{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \
129 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
130
131#define COMPLIANT_DEV UNUSUAL_DEV
132
133#define USUAL_DEV(useProto, useTrans, useType) \
134{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
135 .driver_info = (USB_US_TYPE_STOR<<24) }
136
137static struct usb_device_id storage_usb_ids [] = {
138
139# include "unusual_devs.h"
140#undef UNUSUAL_DEV
141#undef COMPLIANT_DEV
142#undef USUAL_DEV
143 /* Terminating entry */
144 { }
145};
146
147MODULE_DEVICE_TABLE (usb, storage_usb_ids);
148#endif /* CONFIG_USB_LIBUSUAL */
149
150/* This is the list of devices we recognize, along with their flag data */
151 90
152/* The vendor name should be kept at eight characters or less, and 91/* The vendor name should be kept at eight characters or less, and
153 * the product name should be kept at 16 characters or less. If a device 92 * the product name should be kept at 16 characters or less. If a device
@@ -179,18 +118,17 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
179 118
180static struct us_unusual_dev us_unusual_dev_list[] = { 119static struct us_unusual_dev us_unusual_dev_list[] = {
181# include "unusual_devs.h" 120# include "unusual_devs.h"
182# undef UNUSUAL_DEV 121 { } /* Terminating entry */
183# undef COMPLIANT_DEV
184# undef USUAL_DEV
185
186 /* Terminating entry */
187 { NULL }
188}; 122};
189 123
124#undef UNUSUAL_DEV
125#undef COMPLIANT_DEV
126#undef USUAL_DEV
127
190 128
191#ifdef CONFIG_PM /* Minimal support for suspend and resume */ 129#ifdef CONFIG_PM /* Minimal support for suspend and resume */
192 130
193static int storage_suspend(struct usb_interface *iface, pm_message_t message) 131int usb_stor_suspend(struct usb_interface *iface, pm_message_t message)
194{ 132{
195 struct us_data *us = usb_get_intfdata(iface); 133 struct us_data *us = usb_get_intfdata(iface);
196 134
@@ -207,8 +145,9 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message)
207 mutex_unlock(&us->dev_mutex); 145 mutex_unlock(&us->dev_mutex);
208 return 0; 146 return 0;
209} 147}
148EXPORT_SYMBOL_GPL(usb_stor_suspend);
210 149
211static int storage_resume(struct usb_interface *iface) 150int usb_stor_resume(struct usb_interface *iface)
212{ 151{
213 struct us_data *us = usb_get_intfdata(iface); 152 struct us_data *us = usb_get_intfdata(iface);
214 153
@@ -221,8 +160,9 @@ static int storage_resume(struct usb_interface *iface)
221 mutex_unlock(&us->dev_mutex); 160 mutex_unlock(&us->dev_mutex);
222 return 0; 161 return 0;
223} 162}
163EXPORT_SYMBOL_GPL(usb_stor_resume);
224 164
225static int storage_reset_resume(struct usb_interface *iface) 165int usb_stor_reset_resume(struct usb_interface *iface)
226{ 166{
227 struct us_data *us = usb_get_intfdata(iface); 167 struct us_data *us = usb_get_intfdata(iface);
228 168
@@ -235,6 +175,7 @@ static int storage_reset_resume(struct usb_interface *iface)
235 * the device */ 175 * the device */
236 return 0; 176 return 0;
237} 177}
178EXPORT_SYMBOL_GPL(usb_stor_reset_resume);
238 179
239#endif /* CONFIG_PM */ 180#endif /* CONFIG_PM */
240 181
@@ -243,7 +184,7 @@ static int storage_reset_resume(struct usb_interface *iface)
243 * a USB port reset, whether from this driver or a different one. 184 * a USB port reset, whether from this driver or a different one.
244 */ 185 */
245 186
246static int storage_pre_reset(struct usb_interface *iface) 187int usb_stor_pre_reset(struct usb_interface *iface)
247{ 188{
248 struct us_data *us = usb_get_intfdata(iface); 189 struct us_data *us = usb_get_intfdata(iface);
249 190
@@ -253,8 +194,9 @@ static int storage_pre_reset(struct usb_interface *iface)
253 mutex_lock(&us->dev_mutex); 194 mutex_lock(&us->dev_mutex);
254 return 0; 195 return 0;
255} 196}
197EXPORT_SYMBOL_GPL(usb_stor_pre_reset);
256 198
257static int storage_post_reset(struct usb_interface *iface) 199int usb_stor_post_reset(struct usb_interface *iface)
258{ 200{
259 struct us_data *us = usb_get_intfdata(iface); 201 struct us_data *us = usb_get_intfdata(iface);
260 202
@@ -269,6 +211,7 @@ static int storage_post_reset(struct usb_interface *iface)
269 mutex_unlock(&us->dev_mutex); 211 mutex_unlock(&us->dev_mutex);
270 return 0; 212 return 0;
271} 213}
214EXPORT_SYMBOL_GPL(usb_stor_post_reset);
272 215
273/* 216/*
274 * fill_inquiry_response takes an unsigned char array (which must 217 * fill_inquiry_response takes an unsigned char array (which must
@@ -311,6 +254,7 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data,
311 254
312 usb_stor_set_xfer_buf(data, data_len, us->srb); 255 usb_stor_set_xfer_buf(data, data_len, us->srb);
313} 256}
257EXPORT_SYMBOL_GPL(fill_inquiry_response);
314 258
315static int usb_stor_control_thread(void * __us) 259static int usb_stor_control_thread(void * __us)
316{ 260{
@@ -551,20 +495,13 @@ static void adjust_quirks(struct us_data *us)
551 vid, pid, f); 495 vid, pid, f);
552} 496}
553 497
554/* Find an unusual_dev descriptor (always succeeds in the current code) */
555static struct us_unusual_dev *find_unusual(const struct usb_device_id *id)
556{
557 const int id_index = id - storage_usb_ids;
558 return &us_unusual_dev_list[id_index];
559}
560
561/* Get the unusual_devs entries and the string descriptors */ 498/* Get the unusual_devs entries and the string descriptors */
562static int get_device_info(struct us_data *us, const struct usb_device_id *id) 499static int get_device_info(struct us_data *us, const struct usb_device_id *id,
500 struct us_unusual_dev *unusual_dev)
563{ 501{
564 struct usb_device *dev = us->pusb_dev; 502 struct usb_device *dev = us->pusb_dev;
565 struct usb_interface_descriptor *idesc = 503 struct usb_interface_descriptor *idesc =
566 &us->pusb_intf->cur_altsetting->desc; 504 &us->pusb_intf->cur_altsetting->desc;
567 struct us_unusual_dev *unusual_dev = find_unusual(id);
568 505
569 /* Store the entries */ 506 /* Store the entries */
570 us->unusual_dev = unusual_dev; 507 us->unusual_dev = unusual_dev;
@@ -629,7 +566,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
629} 566}
630 567
631/* Get the transport settings */ 568/* Get the transport settings */
632static int get_transport(struct us_data *us) 569static void get_transport(struct us_data *us)
633{ 570{
634 switch (us->protocol) { 571 switch (us->protocol) {
635 case US_PR_CB: 572 case US_PR_CB:
@@ -651,100 +588,11 @@ static int get_transport(struct us_data *us)
651 us->transport = usb_stor_Bulk_transport; 588 us->transport = usb_stor_Bulk_transport;
652 us->transport_reset = usb_stor_Bulk_reset; 589 us->transport_reset = usb_stor_Bulk_reset;
653 break; 590 break;
654
655#ifdef CONFIG_USB_STORAGE_USBAT
656 case US_PR_USBAT:
657 us->transport_name = "Shuttle USBAT";
658 us->transport = usbat_transport;
659 us->transport_reset = usb_stor_CB_reset;
660 us->max_lun = 1;
661 break;
662#endif
663
664#ifdef CONFIG_USB_STORAGE_SDDR09
665 case US_PR_EUSB_SDDR09:
666 us->transport_name = "EUSB/SDDR09";
667 us->transport = sddr09_transport;
668 us->transport_reset = usb_stor_CB_reset;
669 us->max_lun = 0;
670 break;
671#endif
672
673#ifdef CONFIG_USB_STORAGE_SDDR55
674 case US_PR_SDDR55:
675 us->transport_name = "SDDR55";
676 us->transport = sddr55_transport;
677 us->transport_reset = sddr55_reset;
678 us->max_lun = 0;
679 break;
680#endif
681
682#ifdef CONFIG_USB_STORAGE_DPCM
683 case US_PR_DPCM_USB:
684 us->transport_name = "Control/Bulk-EUSB/SDDR09";
685 us->transport = dpcm_transport;
686 us->transport_reset = usb_stor_CB_reset;
687 us->max_lun = 1;
688 break;
689#endif
690
691#ifdef CONFIG_USB_STORAGE_FREECOM
692 case US_PR_FREECOM:
693 us->transport_name = "Freecom";
694 us->transport = freecom_transport;
695 us->transport_reset = usb_stor_freecom_reset;
696 us->max_lun = 0;
697 break;
698#endif
699
700#ifdef CONFIG_USB_STORAGE_DATAFAB
701 case US_PR_DATAFAB:
702 us->transport_name = "Datafab Bulk-Only";
703 us->transport = datafab_transport;
704 us->transport_reset = usb_stor_Bulk_reset;
705 us->max_lun = 1;
706 break;
707#endif
708
709#ifdef CONFIG_USB_STORAGE_JUMPSHOT
710 case US_PR_JUMPSHOT:
711 us->transport_name = "Lexar Jumpshot Control/Bulk";
712 us->transport = jumpshot_transport;
713 us->transport_reset = usb_stor_Bulk_reset;
714 us->max_lun = 1;
715 break;
716#endif
717
718#ifdef CONFIG_USB_STORAGE_ALAUDA
719 case US_PR_ALAUDA:
720 us->transport_name = "Alauda Control/Bulk";
721 us->transport = alauda_transport;
722 us->transport_reset = usb_stor_Bulk_reset;
723 us->max_lun = 1;
724 break;
725#endif
726
727#ifdef CONFIG_USB_STORAGE_KARMA
728 case US_PR_KARMA:
729 us->transport_name = "Rio Karma/Bulk";
730 us->transport = rio_karma_transport;
731 us->transport_reset = usb_stor_Bulk_reset;
732 break;
733#endif
734
735 default:
736 return -EIO;
737 } 591 }
738 US_DEBUGP("Transport: %s\n", us->transport_name);
739
740 /* fix for single-lun devices */
741 if (us->fflags & US_FL_SINGLE_LUN)
742 us->max_lun = 0;
743 return 0;
744} 592}
745 593
746/* Get the protocol settings */ 594/* Get the protocol settings */
747static int get_protocol(struct us_data *us) 595static void get_protocol(struct us_data *us)
748{ 596{
749 switch (us->subclass) { 597 switch (us->subclass) {
750 case US_SC_RBC: 598 case US_SC_RBC:
@@ -779,26 +627,7 @@ static int get_protocol(struct us_data *us)
779 us->protocol_name = "Uniform Floppy Interface (UFI)"; 627 us->protocol_name = "Uniform Floppy Interface (UFI)";
780 us->proto_handler = usb_stor_ufi_command; 628 us->proto_handler = usb_stor_ufi_command;
781 break; 629 break;
782
783#ifdef CONFIG_USB_STORAGE_ISD200
784 case US_SC_ISD200:
785 us->protocol_name = "ISD200 ATA/ATAPI";
786 us->proto_handler = isd200_ata_command;
787 break;
788#endif
789
790#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
791 case US_SC_CYP_ATACB:
792 us->protocol_name = "Transparent SCSI with Cypress ATACB";
793 us->proto_handler = cypress_atacb_passthrough;
794 break;
795#endif
796
797 default:
798 return -EIO;
799 } 630 }
800 US_DEBUGP("Protocol: %s\n", us->protocol_name);
801 return 0;
802} 631}
803 632
804/* Get the pipe settings */ 633/* Get the pipe settings */
@@ -846,12 +675,12 @@ static int get_pipes(struct us_data *us)
846 us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0); 675 us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0);
847 us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0); 676 us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0);
848 us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, 677 us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev,
849 ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 678 usb_endpoint_num(ep_out));
850 us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, 679 us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev,
851 ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 680 usb_endpoint_num(ep_in));
852 if (ep_int) { 681 if (ep_int) {
853 us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, 682 us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev,
854 ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 683 usb_endpoint_num(ep_int));
855 us->ep_bInterval = ep_int->bInterval; 684 us->ep_bInterval = ep_int->bInterval;
856 } 685 }
857 return 0; 686 return 0;
@@ -1012,17 +841,15 @@ static int usb_stor_scan_thread(void * __us)
1012} 841}
1013 842
1014 843
1015/* Probe to see if we can drive a newly-connected USB device */ 844/* First part of general USB mass-storage probing */
1016static int storage_probe(struct usb_interface *intf, 845int usb_stor_probe1(struct us_data **pus,
1017 const struct usb_device_id *id) 846 struct usb_interface *intf,
847 const struct usb_device_id *id,
848 struct us_unusual_dev *unusual_dev)
1018{ 849{
1019 struct Scsi_Host *host; 850 struct Scsi_Host *host;
1020 struct us_data *us; 851 struct us_data *us;
1021 int result; 852 int result;
1022 struct task_struct *th;
1023
1024 if (usb_usual_check_type(id, USB_US_TYPE_STOR))
1025 return -ENXIO;
1026 853
1027 US_DEBUGP("USB Mass Storage device detected\n"); 854 US_DEBUGP("USB Mass Storage device detected\n");
1028 855
@@ -1041,7 +868,7 @@ static int storage_probe(struct usb_interface *intf,
1041 * Allow 16-byte CDBs and thus > 2TB 868 * Allow 16-byte CDBs and thus > 2TB
1042 */ 869 */
1043 host->max_cmd_len = 16; 870 host->max_cmd_len = 16;
1044 us = host_to_us(host); 871 *pus = us = host_to_us(host);
1045 memset(us, 0, sizeof(struct us_data)); 872 memset(us, 0, sizeof(struct us_data));
1046 mutex_init(&(us->dev_mutex)); 873 mutex_init(&(us->dev_mutex));
1047 init_completion(&us->cmnd_ready); 874 init_completion(&us->cmnd_ready);
@@ -1054,24 +881,46 @@ static int storage_probe(struct usb_interface *intf,
1054 if (result) 881 if (result)
1055 goto BadDevice; 882 goto BadDevice;
1056 883
1057 /* 884 /* Get the unusual_devs entries and the descriptors */
1058 * Get the unusual_devs entries and the descriptors 885 result = get_device_info(us, id, unusual_dev);
1059 *
1060 * id_index is calculated in the declaration to be the index number
1061 * of the match from the usb_device_id table, so we can find the
1062 * corresponding entry in the private table.
1063 */
1064 result = get_device_info(us, id);
1065 if (result) 886 if (result)
1066 goto BadDevice; 887 goto BadDevice;
1067 888
1068 /* Get the transport, protocol, and pipe settings */ 889 /* Get standard transport and protocol settings */
1069 result = get_transport(us); 890 get_transport(us);
1070 if (result) 891 get_protocol(us);
1071 goto BadDevice; 892
1072 result = get_protocol(us); 893 /* Give the caller a chance to fill in specialized transport
1073 if (result) 894 * or protocol settings.
895 */
896 return 0;
897
898BadDevice:
899 US_DEBUGP("storage_probe() failed\n");
900 release_everything(us);
901 return result;
902}
903EXPORT_SYMBOL_GPL(usb_stor_probe1);
904
905/* Second part of general USB mass-storage probing */
906int usb_stor_probe2(struct us_data *us)
907{
908 struct task_struct *th;
909 int result;
910
911 /* Make sure the transport and protocol have both been set */
912 if (!us->transport || !us->proto_handler) {
913 result = -ENXIO;
1074 goto BadDevice; 914 goto BadDevice;
915 }
916 US_DEBUGP("Transport: %s\n", us->transport_name);
917 US_DEBUGP("Protocol: %s\n", us->protocol_name);
918
919 /* fix for single-lun devices */
920 if (us->fflags & US_FL_SINGLE_LUN)
921 us->max_lun = 0;
922
923 /* Find the endpoints and calculate pipe values */
1075 result = get_pipes(us); 924 result = get_pipes(us);
1076 if (result) 925 if (result)
1077 goto BadDevice; 926 goto BadDevice;
@@ -1080,7 +929,7 @@ static int storage_probe(struct usb_interface *intf,
1080 result = usb_stor_acquire_resources(us); 929 result = usb_stor_acquire_resources(us);
1081 if (result) 930 if (result)
1082 goto BadDevice; 931 goto BadDevice;
1083 result = scsi_add_host(host, &intf->dev); 932 result = scsi_add_host(us_to_host(us), &us->pusb_intf->dev);
1084 if (result) { 933 if (result) {
1085 printk(KERN_WARNING USB_STORAGE 934 printk(KERN_WARNING USB_STORAGE
1086 "Unable to add the scsi host\n"); 935 "Unable to add the scsi host\n");
@@ -1108,9 +957,10 @@ BadDevice:
1108 release_everything(us); 957 release_everything(us);
1109 return result; 958 return result;
1110} 959}
960EXPORT_SYMBOL_GPL(usb_stor_probe2);
1111 961
1112/* Handle a disconnect event from the USB core */ 962/* Handle a USB mass-storage disconnect */
1113static void storage_disconnect(struct usb_interface *intf) 963void usb_stor_disconnect(struct usb_interface *intf)
1114{ 964{
1115 struct us_data *us = usb_get_intfdata(intf); 965 struct us_data *us = usb_get_intfdata(intf);
1116 966
@@ -1118,6 +968,42 @@ static void storage_disconnect(struct usb_interface *intf)
1118 quiesce_and_remove_host(us); 968 quiesce_and_remove_host(us);
1119 release_everything(us); 969 release_everything(us);
1120} 970}
971EXPORT_SYMBOL_GPL(usb_stor_disconnect);
972
973/* The main probe routine for standard devices */
974static int storage_probe(struct usb_interface *intf,
975 const struct usb_device_id *id)
976{
977 struct us_data *us;
978 int result;
979
980 /*
981 * If libusual is configured, let it decide whether a standard
982 * device should be handled by usb-storage or by ub.
983 * If the device isn't standard (is handled by a subdriver
984 * module) then don't accept it.
985 */
986 if (usb_usual_check_type(id, USB_US_TYPE_STOR) ||
987 usb_usual_ignore_device(intf))
988 return -ENXIO;
989
990 /*
991 * Call the general probe procedures.
992 *
993 * The unusual_dev_list array is parallel to the usb_storage_usb_ids
994 * table, so we use the index of the id entry to find the
995 * corresponding unusual_devs entry.
996 */
997 result = usb_stor_probe1(&us, intf, id,
998 (id - usb_storage_usb_ids) + us_unusual_dev_list);
999 if (result)
1000 return result;
1001
1002 /* No special transport or protocol settings in the main module */
1003
1004 result = usb_stor_probe2(us);
1005 return result;
1006}
1121 1007
1122/*********************************************************************** 1008/***********************************************************************
1123 * Initialization and registration 1009 * Initialization and registration
@@ -1126,15 +1012,13 @@ static void storage_disconnect(struct usb_interface *intf)
1126static struct usb_driver usb_storage_driver = { 1012static struct usb_driver usb_storage_driver = {
1127 .name = "usb-storage", 1013 .name = "usb-storage",
1128 .probe = storage_probe, 1014 .probe = storage_probe,
1129 .disconnect = storage_disconnect, 1015 .disconnect = usb_stor_disconnect,
1130#ifdef CONFIG_PM 1016 .suspend = usb_stor_suspend,
1131 .suspend = storage_suspend, 1017 .resume = usb_stor_resume,
1132 .resume = storage_resume, 1018 .reset_resume = usb_stor_reset_resume,
1133 .reset_resume = storage_reset_resume, 1019 .pre_reset = usb_stor_pre_reset,
1134#endif 1020 .post_reset = usb_stor_post_reset,
1135 .pre_reset = storage_pre_reset, 1021 .id_table = usb_storage_usb_ids,
1136 .post_reset = storage_post_reset,
1137 .id_table = storage_usb_ids,
1138 .soft_unbind = 1, 1022 .soft_unbind = 1,
1139}; 1023};
1140 1024
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 65e674e4be99..2609efb2bd7e 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -177,4 +177,25 @@ extern void fill_inquiry_response(struct us_data *us,
177#define scsi_unlock(host) spin_unlock_irq(host->host_lock) 177#define scsi_unlock(host) spin_unlock_irq(host->host_lock)
178#define scsi_lock(host) spin_lock_irq(host->host_lock) 178#define scsi_lock(host) spin_lock_irq(host->host_lock)
179 179
180/* General routines provided by the usb-storage standard core */
181#ifdef CONFIG_PM
182extern int usb_stor_suspend(struct usb_interface *iface, pm_message_t message);
183extern int usb_stor_resume(struct usb_interface *iface);
184extern int usb_stor_reset_resume(struct usb_interface *iface);
185#else
186#define usb_stor_suspend NULL
187#define usb_stor_resume NULL
188#define usb_stor_reset_resume NULL
189#endif
190
191extern int usb_stor_pre_reset(struct usb_interface *iface);
192extern int usb_stor_post_reset(struct usb_interface *iface);
193
194extern int usb_stor_probe1(struct us_data **pus,
195 struct usb_interface *intf,
196 const struct usb_device_id *id,
197 struct us_unusual_dev *unusual_dev);
198extern int usb_stor_probe2(struct us_data *us);
199extern void usb_stor_disconnect(struct usb_interface *intf);
200
180#endif 201#endif
diff --git a/drivers/usb/storage/usual-tables.c b/drivers/usb/storage/usual-tables.c
new file mode 100644
index 000000000000..468bde7d1971
--- /dev/null
+++ b/drivers/usb/storage/usual-tables.c
@@ -0,0 +1,116 @@
1/* Driver for USB Mass Storage devices
2 * Usual Tables File for usb-storage and libusual
3 *
4 * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu)
5 *
6 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
7 * information about this driver.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
12 * 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. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/usb.h>
27#include <linux/usb_usual.h>
28
29
30/*
31 * The table of devices
32 */
33#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
34 vendorName, productName, useProtocol, useTransport, \
35 initFunction, flags) \
36{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
37 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
38
39#define COMPLIANT_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
40 vendorName, productName, useProtocol, useTransport, \
41 initFunction, flags) \
42{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
43 .driver_info = (flags) }
44
45#define USUAL_DEV(useProto, useTrans, useType) \
46{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
47 .driver_info = ((useType)<<24) }
48
49struct usb_device_id usb_storage_usb_ids[] = {
50# include "unusual_devs.h"
51 { } /* Terminating entry */
52};
53EXPORT_SYMBOL_GPL(usb_storage_usb_ids);
54
55MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
56
57#undef UNUSUAL_DEV
58#undef COMPLIANT_DEV
59#undef USUAL_DEV
60
61
62/*
63 * The table of devices to ignore
64 */
65struct ignore_entry {
66 u16 vid, pid, bcdmin, bcdmax;
67};
68
69#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
70 vendorName, productName, useProtocol, useTransport, \
71 initFunction, flags) \
72{ \
73 .vid = id_vendor, \
74 .pid = id_product, \
75 .bcdmin = bcdDeviceMin, \
76 .bcdmax = bcdDeviceMax, \
77}
78
79static struct ignore_entry ignore_ids[] = {
80# include "unusual_alauda.h"
81# include "unusual_cypress.h"
82# include "unusual_datafab.h"
83# include "unusual_freecom.h"
84# include "unusual_isd200.h"
85# include "unusual_jumpshot.h"
86# include "unusual_karma.h"
87# include "unusual_onetouch.h"
88# include "unusual_sddr09.h"
89# include "unusual_sddr55.h"
90# include "unusual_usbat.h"
91 { } /* Terminating entry */
92};
93
94#undef UNUSUAL_DEV
95
96
97/* Return an error if a device is in the ignore_ids list */
98int usb_usual_ignore_device(struct usb_interface *intf)
99{
100 struct usb_device *udev;
101 unsigned vid, pid, bcd;
102 struct ignore_entry *p;
103
104 udev = interface_to_usbdev(intf);
105 vid = le16_to_cpu(udev->descriptor.idVendor);
106 pid = le16_to_cpu(udev->descriptor.idProduct);
107 bcd = le16_to_cpu(udev->descriptor.bcdDevice);
108
109 for (p = ignore_ids; p->vid; ++p) {
110 if (p->vid == vid && p->pid == pid &&
111 p->bcdmin <= bcd && p->bcdmax >= bcd)
112 return -ENXIO;
113 }
114 return 0;
115}
116EXPORT_SYMBOL_GPL(usb_usual_ignore_device);
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index be76084c8d7e..60ba631e99c2 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -410,7 +410,9 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
410 } 410 }
411 411
412 /* let the user know what node this device is now attached to */ 412 /* let the user know what node this device is now attached to */
413 info("USB Skeleton device now attached to USBSkel-%d", interface->minor); 413 dev_info(&interface->dev,
414 "USB Skeleton device now attached to USBSkel-%d",
415 interface->minor);
414 return 0; 416 return 0;
415 417
416error: 418error:
@@ -441,7 +443,7 @@ static void skel_disconnect(struct usb_interface *interface)
441 /* decrement our usage count */ 443 /* decrement our usage count */
442 kref_put(&dev->kref, skel_delete); 444 kref_put(&dev->kref, skel_delete);
443 445
444 info("USB Skeleton #%d now disconnected", minor); 446 dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor);
445} 447}
446 448
447static void skel_draw_down(struct usb_skel *dev) 449static void skel_draw_down(struct usb_skel *dev)
diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c
index 1335cbe1191d..25eae405f622 100644
--- a/drivers/usb/wusbcore/cbaf.c
+++ b/drivers/usb/wusbcore/cbaf.c
@@ -638,8 +638,7 @@ static void cbaf_disconnect(struct usb_interface *iface)
638 usb_put_intf(iface); 638 usb_put_intf(iface);
639 kfree(cbaf->buffer); 639 kfree(cbaf->buffer);
640 /* paranoia: clean up crypto keys */ 640 /* paranoia: clean up crypto keys */
641 memset(cbaf, 0, sizeof(*cbaf)); 641 kzfree(cbaf);
642 kfree(cbaf);
643} 642}
644 643
645static struct usb_device_id cbaf_id_table[] = { 644static struct usb_device_id cbaf_id_table[] = {
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c
index 8e18141bb2e0..f0aac0cf315a 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -889,6 +889,8 @@ static void wusb_dev_add_ncb(struct usb_device *usb_dev)
889 if (usb_dev->wusb == 0 || usb_dev->devnum == 1) 889 if (usb_dev->wusb == 0 || usb_dev->devnum == 1)
890 return; /* skip non wusb and wusb RHs */ 890 return; /* skip non wusb and wusb RHs */
891 891
892 usb_set_device_state(usb_dev, USB_STATE_UNAUTHENTICATED);
893
892 wusbhc = wusbhc_get_by_usb_dev(usb_dev); 894 wusbhc = wusbhc_get_by_usb_dev(usb_dev);
893 if (wusbhc == NULL) 895 if (wusbhc == NULL)
894 goto error_nodev; 896 goto error_nodev;
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
index f4aa28eca70d..8118db7f1d8d 100644
--- a/drivers/usb/wusbcore/security.c
+++ b/drivers/usb/wusbcore/security.c
@@ -312,6 +312,7 @@ int wusb_dev_update_address(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
312 result = wusb_set_dev_addr(wusbhc, wusb_dev, 0); 312 result = wusb_set_dev_addr(wusbhc, wusb_dev, 0);
313 if (result < 0) 313 if (result < 0)
314 goto error_addr0; 314 goto error_addr0;
315 usb_set_device_state(usb_dev, USB_STATE_DEFAULT);
315 usb_ep0_reinit(usb_dev); 316 usb_ep0_reinit(usb_dev);
316 317
317 /* Set new (authenticated) address. */ 318 /* Set new (authenticated) address. */
@@ -327,6 +328,7 @@ int wusb_dev_update_address(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
327 result = wusb_set_dev_addr(wusbhc, wusb_dev, new_address); 328 result = wusb_set_dev_addr(wusbhc, wusb_dev, new_address);
328 if (result < 0) 329 if (result < 0)
329 goto error_addr; 330 goto error_addr;
331 usb_set_device_state(usb_dev, USB_STATE_ADDRESS);
330 usb_ep0_reinit(usb_dev); 332 usb_ep0_reinit(usb_dev);
331 usb_dev->authenticated = 1; 333 usb_dev->authenticated = 1;
332error_addr: 334error_addr:
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index 238a96aee3a1..613a5fc490d3 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -921,8 +921,10 @@ static void wa_urb_enqueue_b(struct wa_xfer *xfer)
921 result = -ENODEV; 921 result = -ENODEV;
922 /* FIXME: segmentation broken -- kills DWA */ 922 /* FIXME: segmentation broken -- kills DWA */
923 mutex_lock(&wusbhc->mutex); /* get a WUSB dev */ 923 mutex_lock(&wusbhc->mutex); /* get a WUSB dev */
924 if (urb->dev == NULL) 924 if (urb->dev == NULL) {
925 mutex_unlock(&wusbhc->mutex);
925 goto error_dev_gone; 926 goto error_dev_gone;
927 }
926 wusb_dev = __wusb_dev_get_by_usb_dev(wusbhc, urb->dev); 928 wusb_dev = __wusb_dev_get_by_usb_dev(wusbhc, urb->dev);
927 if (wusb_dev == NULL) { 929 if (wusb_dev == NULL) {
928 mutex_unlock(&wusbhc->mutex); 930 mutex_unlock(&wusbhc->mutex);
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index 2181ce4d7ebd..35e8eb02b9e9 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1853,13 +1853,14 @@ static void aty128_bl_exit(struct backlight_device *bd)
1853 * Initialisation 1853 * Initialisation
1854 */ 1854 */
1855 1855
1856#ifdef CONFIG_PPC_PMAC 1856#ifdef CONFIG_PPC_PMAC__disabled
1857static void aty128_early_resume(void *data) 1857static void aty128_early_resume(void *data)
1858{ 1858{
1859 struct aty128fb_par *par = data; 1859 struct aty128fb_par *par = data;
1860 1860
1861 if (try_acquire_console_sem()) 1861 if (try_acquire_console_sem())
1862 return; 1862 return;
1863 pci_restore_state(par->pdev);
1863 aty128_do_resume(par->pdev); 1864 aty128_do_resume(par->pdev);
1864 release_console_sem(); 1865 release_console_sem();
1865} 1866}
@@ -1907,7 +1908,14 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
1907 /* Indicate sleep capability */ 1908 /* Indicate sleep capability */
1908 if (par->chip_gen == rage_M3) { 1909 if (par->chip_gen == rage_M3) {
1909 pmac_call_feature(PMAC_FTR_DEVICE_CAN_WAKE, NULL, 0, 1); 1910 pmac_call_feature(PMAC_FTR_DEVICE_CAN_WAKE, NULL, 0, 1);
1911#if 0 /* Disable the early video resume hack for now as it's causing problems, among
1912 * others we now rely on the PCI core restoring the config space for us, which
1913 * isn't the case with that hack, and that code path causes various things to
1914 * be called with interrupts off while they shouldn't. I'm leaving the code in
1915 * as it can be useful for debugging purposes
1916 */
1910 pmac_set_early_video_resume(aty128_early_resume, par); 1917 pmac_set_early_video_resume(aty128_early_resume, par);
1918#endif
1911 } 1919 }
1912 1920
1913 /* Find default mode */ 1921 /* Find default mode */
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index ca5f0dc28546..c6d7cc76516f 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2507,6 +2507,25 @@ static void radeon_reinitialize_QW(struct radeonfb_info *rinfo)
2507 2507
2508#endif /* CONFIG_PPC_OF */ 2508#endif /* CONFIG_PPC_OF */
2509 2509
2510static void radeonfb_whack_power_state(struct radeonfb_info *rinfo, pci_power_t state)
2511{
2512 u16 pwr_cmd;
2513
2514 for (;;) {
2515 pci_read_config_word(rinfo->pdev,
2516 rinfo->pm_reg+PCI_PM_CTRL,
2517 &pwr_cmd);
2518 if (pwr_cmd & 2)
2519 break;
2520 pwr_cmd = (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | 2;
2521 pci_write_config_word(rinfo->pdev,
2522 rinfo->pm_reg+PCI_PM_CTRL,
2523 pwr_cmd);
2524 msleep(500);
2525 }
2526 rinfo->pdev->current_state = state;
2527}
2528
2510static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend) 2529static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
2511{ 2530{
2512 u32 tmp; 2531 u32 tmp;
@@ -2558,6 +2577,11 @@ static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
2558 /* Switch PCI power management to D2. */ 2577 /* Switch PCI power management to D2. */
2559 pci_disable_device(rinfo->pdev); 2578 pci_disable_device(rinfo->pdev);
2560 pci_save_state(rinfo->pdev); 2579 pci_save_state(rinfo->pdev);
2580 /* The chip seems to need us to whack the PM register
2581 * repeatedly until it sticks. We do that -prior- to
2582 * calling pci_set_power_state()
2583 */
2584 radeonfb_whack_power_state(rinfo, PCI_D2);
2561 pci_set_power_state(rinfo->pdev, PCI_D2); 2585 pci_set_power_state(rinfo->pdev, PCI_D2);
2562 } else { 2586 } else {
2563 printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n", 2587 printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n",
@@ -2762,12 +2786,13 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2762 return rc; 2786 return rc;
2763} 2787}
2764 2788
2765#ifdef CONFIG_PPC_OF 2789#ifdef CONFIG_PPC_OF__disabled
2766static void radeonfb_early_resume(void *data) 2790static void radeonfb_early_resume(void *data)
2767{ 2791{
2768 struct radeonfb_info *rinfo = data; 2792 struct radeonfb_info *rinfo = data;
2769 2793
2770 rinfo->no_schedule = 1; 2794 rinfo->no_schedule = 1;
2795 pci_restore_state(rinfo->pdev);
2771 radeonfb_pci_resume(rinfo->pdev); 2796 radeonfb_pci_resume(rinfo->pdev);
2772 rinfo->no_schedule = 0; 2797 rinfo->no_schedule = 0;
2773} 2798}
@@ -2834,7 +2859,14 @@ void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk, int ignore_devlis
2834 */ 2859 */
2835 if (rinfo->pm_mode != radeon_pm_none) { 2860 if (rinfo->pm_mode != radeon_pm_none) {
2836 pmac_call_feature(PMAC_FTR_DEVICE_CAN_WAKE, rinfo->of_node, 0, 1); 2861 pmac_call_feature(PMAC_FTR_DEVICE_CAN_WAKE, rinfo->of_node, 0, 1);
2862#if 0 /* Disable the early video resume hack for now as it's causing problems, among
2863 * others we now rely on the PCI core restoring the config space for us, which
2864 * isn't the case with that hack, and that code path causes various things to
2865 * be called with interrupts off while they shouldn't. I'm leaving the code in
2866 * as it can be useful for debugging purposes
2867 */
2837 pmac_set_early_video_resume(radeonfb_early_resume, rinfo); 2868 pmac_set_early_video_resume(radeonfb_early_resume, rinfo);
2869#endif
2838 } 2870 }
2839 2871
2840#if 0 2872#if 0
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index 62bd4441b5e0..378f27745a1d 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -457,7 +457,7 @@ static struct fb_ops au1100fb_ops =
457 457
458/* AU1100 LCD controller device driver */ 458/* AU1100 LCD controller device driver */
459 459
460static int __init au1100fb_drv_probe(struct device *dev) 460static int __init au1100fb_drv_probe(struct platform_device *dev)
461{ 461{
462 struct au1100fb_device *fbdev = NULL; 462 struct au1100fb_device *fbdev = NULL;
463 struct resource *regs_res; 463 struct resource *regs_res;
@@ -475,7 +475,7 @@ static int __init au1100fb_drv_probe(struct device *dev)
475 475
476 fbdev->panel = &known_lcd_panels[drv_info.panel_idx]; 476 fbdev->panel = &known_lcd_panels[drv_info.panel_idx];
477 477
478 dev_set_drvdata(dev, (void*)fbdev); 478 platform_set_drvdata(dev, (void *)fbdev);
479 479
480 /* Allocate region for our registers and map them */ 480 /* Allocate region for our registers and map them */
481 if (!(regs_res = platform_get_resource(to_platform_device(dev), 481 if (!(regs_res = platform_get_resource(to_platform_device(dev),
@@ -583,19 +583,19 @@ failed:
583 fb_dealloc_cmap(&fbdev->info.cmap); 583 fb_dealloc_cmap(&fbdev->info.cmap);
584 } 584 }
585 kfree(fbdev); 585 kfree(fbdev);
586 dev_set_drvdata(dev, NULL); 586 platform_set_drvdata(dev, NULL);
587 587
588 return 0; 588 return 0;
589} 589}
590 590
591int au1100fb_drv_remove(struct device *dev) 591int au1100fb_drv_remove(struct platform_device *dev)
592{ 592{
593 struct au1100fb_device *fbdev = NULL; 593 struct au1100fb_device *fbdev = NULL;
594 594
595 if (!dev) 595 if (!dev)
596 return -ENODEV; 596 return -ENODEV;
597 597
598 fbdev = (struct au1100fb_device*) dev_get_drvdata(dev); 598 fbdev = (struct au1100fb_device *) platform_get_drvdata(dev);
599 599
600#if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO) 600#if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO)
601 au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info); 601 au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info);
@@ -620,9 +620,9 @@ int au1100fb_drv_remove(struct device *dev)
620static u32 sys_clksrc; 620static u32 sys_clksrc;
621static struct au1100fb_regs fbregs; 621static struct au1100fb_regs fbregs;
622 622
623int au1100fb_drv_suspend(struct device *dev, pm_message_t state) 623int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state)
624{ 624{
625 struct au1100fb_device *fbdev = dev_get_drvdata(dev); 625 struct au1100fb_device *fbdev = platform_get_drvdata(dev);
626 626
627 if (!fbdev) 627 if (!fbdev)
628 return 0; 628 return 0;
@@ -641,9 +641,9 @@ int au1100fb_drv_suspend(struct device *dev, pm_message_t state)
641 return 0; 641 return 0;
642} 642}
643 643
644int au1100fb_drv_resume(struct device *dev) 644int au1100fb_drv_resume(struct platform_device *dev)
645{ 645{
646 struct au1100fb_device *fbdev = dev_get_drvdata(dev); 646 struct au1100fb_device *fbdev = platform_get_drvdata(dev);
647 647
648 if (!fbdev) 648 if (!fbdev)
649 return 0; 649 return 0;
@@ -663,10 +663,11 @@ int au1100fb_drv_resume(struct device *dev)
663#define au1100fb_drv_resume NULL 663#define au1100fb_drv_resume NULL
664#endif 664#endif
665 665
666static struct device_driver au1100fb_driver = { 666static struct platform_driver au1100fb_driver = {
667 .name = "au1100-lcd", 667 .driver = {
668 .bus = &platform_bus_type, 668 .name = "au1100-lcd",
669 669 .owner = THIS_MODULE,
670 },
670 .probe = au1100fb_drv_probe, 671 .probe = au1100fb_drv_probe,
671 .remove = au1100fb_drv_remove, 672 .remove = au1100fb_drv_remove,
672 .suspend = au1100fb_drv_suspend, 673 .suspend = au1100fb_drv_suspend,
@@ -753,12 +754,12 @@ int __init au1100fb_init(void)
753 return ret; 754 return ret;
754 } 755 }
755 756
756 return driver_register(&au1100fb_driver); 757 return platform_driver_register(&au1100fb_driver);
757} 758}
758 759
759void __exit au1100fb_cleanup(void) 760void __exit au1100fb_cleanup(void)
760{ 761{
761 driver_unregister(&au1100fb_driver); 762 platform_driver_unregister(&au1100fb_driver);
762 763
763 kfree(drv_info.opt_mode); 764 kfree(drv_info.opt_mode);
764} 765}
diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index 03e57ef88378..0d96f1d2d4c5 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -1622,7 +1622,7 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev)
1622 1622
1623/* AU1200 LCD controller device driver */ 1623/* AU1200 LCD controller device driver */
1624 1624
1625static int au1200fb_drv_probe(struct device *dev) 1625static int au1200fb_drv_probe(struct platform_device *dev)
1626{ 1626{
1627 struct au1200fb_device *fbdev; 1627 struct au1200fb_device *fbdev;
1628 unsigned long page; 1628 unsigned long page;
@@ -1645,7 +1645,7 @@ static int au1200fb_drv_probe(struct device *dev)
1645 /* Allocate the framebuffer to the maximum screen size */ 1645 /* Allocate the framebuffer to the maximum screen size */
1646 fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) / 8; 1646 fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) / 8;
1647 1647
1648 fbdev->fb_mem = dma_alloc_noncoherent(dev, 1648 fbdev->fb_mem = dma_alloc_noncoherent(&dev->dev,
1649 PAGE_ALIGN(fbdev->fb_len), 1649 PAGE_ALIGN(fbdev->fb_len),
1650 &fbdev->fb_phys, GFP_KERNEL); 1650 &fbdev->fb_phys, GFP_KERNEL);
1651 if (!fbdev->fb_mem) { 1651 if (!fbdev->fb_mem) {
@@ -1715,7 +1715,7 @@ failed:
1715 return ret; 1715 return ret;
1716} 1716}
1717 1717
1718static int au1200fb_drv_remove(struct device *dev) 1718static int au1200fb_drv_remove(struct platform_device *dev)
1719{ 1719{
1720 struct au1200fb_device *fbdev; 1720 struct au1200fb_device *fbdev;
1721 int plane; 1721 int plane;
@@ -1733,7 +1733,8 @@ static int au1200fb_drv_remove(struct device *dev)
1733 /* Clean up all probe data */ 1733 /* Clean up all probe data */
1734 unregister_framebuffer(&fbdev->fb_info); 1734 unregister_framebuffer(&fbdev->fb_info);
1735 if (fbdev->fb_mem) 1735 if (fbdev->fb_mem)
1736 dma_free_noncoherent(dev, PAGE_ALIGN(fbdev->fb_len), 1736 dma_free_noncoherent(&dev->dev,
1737 PAGE_ALIGN(fbdev->fb_len),
1737 fbdev->fb_mem, fbdev->fb_phys); 1738 fbdev->fb_mem, fbdev->fb_phys);
1738 if (fbdev->fb_info.cmap.len != 0) 1739 if (fbdev->fb_info.cmap.len != 0)
1739 fb_dealloc_cmap(&fbdev->fb_info.cmap); 1740 fb_dealloc_cmap(&fbdev->fb_info.cmap);
@@ -1747,22 +1748,24 @@ static int au1200fb_drv_remove(struct device *dev)
1747} 1748}
1748 1749
1749#ifdef CONFIG_PM 1750#ifdef CONFIG_PM
1750static int au1200fb_drv_suspend(struct device *dev, u32 state, u32 level) 1751static int au1200fb_drv_suspend(struct platform_device *dev, u32 state)
1751{ 1752{
1752 /* TODO */ 1753 /* TODO */
1753 return 0; 1754 return 0;
1754} 1755}
1755 1756
1756static int au1200fb_drv_resume(struct device *dev, u32 level) 1757static int au1200fb_drv_resume(struct platform_device *dev)
1757{ 1758{
1758 /* TODO */ 1759 /* TODO */
1759 return 0; 1760 return 0;
1760} 1761}
1761#endif /* CONFIG_PM */ 1762#endif /* CONFIG_PM */
1762 1763
1763static struct device_driver au1200fb_driver = { 1764static struct platform_driver au1200fb_driver = {
1764 .name = "au1200-lcd", 1765 .driver = {
1765 .bus = &platform_bus_type, 1766 .name = "au1200-lcd",
1767 .owner = THIS_MODULE,
1768 },
1766 .probe = au1200fb_drv_probe, 1769 .probe = au1200fb_drv_probe,
1767 .remove = au1200fb_drv_remove, 1770 .remove = au1200fb_drv_remove,
1768#ifdef CONFIG_PM 1771#ifdef CONFIG_PM
@@ -1906,12 +1909,12 @@ static int __init au1200fb_init(void)
1906 printk(KERN_INFO "Power management device entry for the au1200fb loaded.\n"); 1909 printk(KERN_INFO "Power management device entry for the au1200fb loaded.\n");
1907 #endif 1910 #endif
1908 1911
1909 return driver_register(&au1200fb_driver); 1912 return platform_driver_register(&au1200fb_driver);
1910} 1913}
1911 1914
1912static void __exit au1200fb_cleanup(void) 1915static void __exit au1200fb_cleanup(void)
1913{ 1916{
1914 driver_unregister(&au1200fb_driver); 1917 platform_driver_unregister(&au1200fb_driver);
1915} 1918}
1916 1919
1917module_init(au1200fb_init); 1920module_init(au1200fb_init);
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index a24e680d2b9c..2e940199fc89 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -993,6 +993,7 @@ static int i810_check_params(struct fb_var_screeninfo *var,
993 struct i810fb_par *par = info->par; 993 struct i810fb_par *par = info->par;
994 int line_length, vidmem, mode_valid = 0, retval = 0; 994 int line_length, vidmem, mode_valid = 0, retval = 0;
995 u32 vyres = var->yres_virtual, vxres = var->xres_virtual; 995 u32 vyres = var->yres_virtual, vxres = var->xres_virtual;
996
996 /* 997 /*
997 * Memory limit 998 * Memory limit
998 */ 999 */
@@ -1002,12 +1003,12 @@ static int i810_check_params(struct fb_var_screeninfo *var,
1002 if (vidmem > par->fb.size) { 1003 if (vidmem > par->fb.size) {
1003 vyres = par->fb.size/line_length; 1004 vyres = par->fb.size/line_length;
1004 if (vyres < var->yres) { 1005 if (vyres < var->yres) {
1005 vyres = yres; 1006 vyres = info->var.yres;
1006 vxres = par->fb.size/vyres; 1007 vxres = par->fb.size/vyres;
1007 vxres /= var->bits_per_pixel >> 3; 1008 vxres /= var->bits_per_pixel >> 3;
1008 line_length = get_line_length(par, vxres, 1009 line_length = get_line_length(par, vxres,
1009 var->bits_per_pixel); 1010 var->bits_per_pixel);
1010 vidmem = line_length * yres; 1011 vidmem = line_length * info->var.yres;
1011 if (vxres < var->xres) { 1012 if (vxres < var->xres) {
1012 printk("i810fb: required video memory, " 1013 printk("i810fb: required video memory, "
1013 "%d bytes, for %dx%d-%d (virtual) " 1014 "%d bytes, for %dx%d-%d (virtual) "
diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
index 3c14e43b82fe..de93ff3fc1ad 100644
--- a/drivers/video/logo/logo_linux_clut224.ppm
+++ b/drivers/video/logo/logo_linux_clut224.ppm
@@ -1,1604 +1,2828 @@
1P3 1P3
2# Standard 224-color Linux logo 2145 113
380 80
4255 3255
5 0 0 0 0 0 0 0 0 0 0 0 0 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 0 0 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0 0 0 0 70 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 0 0 0 0 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10 0 0 0 0 0 0 0 0 0 0 0 0 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12 0 0 0 0 0 0 0 0 0 0 0 0 110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
13 0 0 0 0 0 0 0 0 0 0 0 0 120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
14 6 6 6 6 6 6 10 10 10 10 10 10 130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
15 10 10 10 6 6 6 6 6 6 6 6 6 140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16 0 0 0 0 0 0 0 0 0 0 0 0 150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17 0 0 0 0 0 0 0 0 0 0 0 0 160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18 0 0 0 0 0 0 0 0 0 0 0 0 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19 0 0 0 0 0 0 0 0 0 0 0 0 180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20 0 0 0 0 0 0 0 0 0 0 0 0 190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21 0 0 0 0 0 0 0 0 0 0 0 0 200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22 0 0 0 0 0 0 0 0 0 0 0 0 210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23 0 0 0 0 0 0 0 0 0 0 0 0 220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24 0 0 0 0 0 0 0 0 0 0 0 0 230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25 0 0 0 0 0 0 0 0 0 0 0 0 240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26 0 0 0 0 0 0 0 0 0 0 0 0 250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27 0 0 0 0 0 0 0 0 0 0 0 0 260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28 0 0 0 0 0 0 0 0 0 0 0 0 270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
29 0 0 0 0 0 0 0 0 0 0 0 0 280 0 0
30 0 0 0 0 0 0 0 0 0 0 0 0 290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31 0 0 0 0 0 0 0 0 0 0 0 0 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
32 0 0 0 0 0 0 0 0 0 0 0 0 310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
33 0 0 0 6 6 6 10 10 10 14 14 14 320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
34 22 22 22 26 26 26 30 30 30 34 34 34 330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
35 30 30 30 30 30 30 26 26 26 18 18 18 340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
36 14 14 14 10 10 10 6 6 6 0 0 0 350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
37 0 0 0 0 0 0 0 0 0 0 0 0 360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
38 0 0 0 0 0 0 0 0 0 0 0 0 370 0 0 0 0 0 0 0 0 0 0 0 3 4 4 6 7 7
39 0 0 0 0 0 0 0 0 0 0 0 0 388 10 10 8 10 10 6 8 8 6 7 7 3 4 4 2 2 2
40 0 0 0 0 0 0 0 0 0 0 0 0 390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
41 0 0 0 0 0 0 0 0 0 0 0 0 400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
42 0 0 0 0 0 0 0 0 0 0 0 0 410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
43 0 0 0 0 0 0 0 0 0 0 0 0 420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
44 0 0 0 0 0 0 0 0 0 0 0 0 430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
45 0 0 0 0 0 0 0 0 0 0 0 0 440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46 0 0 0 0 0 1 0 0 1 0 0 0 450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47 0 0 0 0 0 0 0 0 0 0 0 0 460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
48 0 0 0 0 0 0 0 0 0 0 0 0 470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49 0 0 0 0 0 0 0 0 0 0 0 0 480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50 0 0 0 0 0 0 0 0 0 0 0 0 490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
51 0 0 0 0 0 0 0 0 0 0 0 0 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52 0 0 0 0 0 0 0 0 0 0 0 0 510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
53 6 6 6 14 14 14 26 26 26 42 42 42 520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
54 54 54 54 66 66 66 78 78 78 78 78 78 530 0 0
55 78 78 78 74 74 74 66 66 66 54 54 54 540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
56 42 42 42 26 26 26 18 18 18 10 10 10 550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
57 6 6 6 0 0 0 0 0 0 0 0 0 560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
58 0 0 0 0 0 0 0 0 0 0 0 0 570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
59 0 0 0 0 0 0 0 0 0 0 0 0 580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
60 0 0 0 0 0 0 0 0 0 0 0 0 590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
61 0 0 0 0 0 0 0 0 0 0 0 0 600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
62 0 0 0 0 0 0 0 0 0 0 0 0 610 0 0 0 0 0 0 0 0 0 0 0 4 5 5 17 18 17
63 0 0 0 0 0 0 0 0 0 0 0 0 6227 29 28 35 37 36 40 43 41 43 45 43 40 43 41 37 39 37
64 0 0 0 0 0 0 0 0 0 0 0 0 6332 34 33 27 30 29 23 25 24 17 21 21 15 18 18 12 15 15
65 0 0 0 0 0 0 0 0 0 0 0 0 6411 13 13 8 10 10 6 7 7 3 4 4 1 1 1 0 0 0
66 0 0 1 0 0 0 0 0 0 0 0 0 650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
67 0 0 0 0 0 0 0 0 0 0 0 0 660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
68 0 0 0 0 0 0 0 0 0 0 0 0 670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
69 0 0 0 0 0 0 0 0 0 0 0 0 680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
70 0 0 0 0 0 0 0 0 0 0 0 0 690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
71 0 0 0 0 0 0 0 0 0 0 0 0 700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
72 0 0 0 0 0 0 0 0 0 10 10 10 710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
73 22 22 22 42 42 42 66 66 66 86 86 86 720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
74 66 66 66 38 38 38 38 38 38 22 22 22 730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
75 26 26 26 34 34 34 54 54 54 66 66 66 740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
76 86 86 86 70 70 70 46 46 46 26 26 26 750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
77 14 14 14 6 6 6 0 0 0 0 0 0 760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
78 0 0 0 0 0 0 0 0 0 0 0 0 770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
79 0 0 0 0 0 0 0 0 0 0 0 0 780 0 0
80 0 0 0 0 0 0 0 0 0 0 0 0 790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
81 0 0 0 0 0 0 0 0 0 0 0 0 800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
82 0 0 0 0 0 0 0 0 0 0 0 0 810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
83 0 0 0 0 0 0 0 0 0 0 0 0 820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
84 0 0 0 0 0 0 0 0 0 0 0 0 830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
85 0 0 0 0 0 0 0 0 0 0 0 0 840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
86 0 0 1 0 0 1 0 0 1 0 0 0 850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
87 0 0 0 0 0 0 0 0 0 0 0 0 860 0 0 13 13 13 32 34 33 49 51 48 60 60 56 58 59 55
88 0 0 0 0 0 0 0 0 0 0 0 0 8755 57 54 55 56 53 49 51 48 43 45 43 39 40 39 33 37 35
89 0 0 0 0 0 0 0 0 0 0 0 0 8828 31 30 23 27 26 20 23 23 17 20 20 14 17 17 13 16 16
90 0 0 0 0 0 0 0 0 0 0 0 0 8911 14 14 10 13 13 10 12 12 9 11 11 8 10 10 6 7 7
91 0 0 0 0 0 0 0 0 0 0 0 0 902 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
92 0 0 0 0 0 0 10 10 10 26 26 26 910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
93 50 50 50 82 82 82 58 58 58 6 6 6 920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
94 2 2 6 2 2 6 2 2 6 2 2 6 930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
95 2 2 6 2 2 6 2 2 6 2 2 6 940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
96 6 6 6 54 54 54 86 86 86 66 66 66 950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
97 38 38 38 18 18 18 6 6 6 0 0 0 960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
98 0 0 0 0 0 0 0 0 0 0 0 0 970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
99 0 0 0 0 0 0 0 0 0 0 0 0 980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
100 0 0 0 0 0 0 0 0 0 0 0 0 990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
101 0 0 0 0 0 0 0 0 0 0 0 0 1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
102 0 0 0 0 0 0 0 0 0 0 0 0 1010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
103 0 0 0 0 0 0 0 0 0 0 0 0 1020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
104 0 0 0 0 0 0 0 0 0 0 0 0 1030 0 0
105 0 0 0 0 0 0 0 0 0 0 0 0 1040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
106 0 0 0 0 0 0 0 0 0 0 0 0 1050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
107 0 0 0 0 0 0 0 0 0 0 0 0 1060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
108 0 0 0 0 0 0 0 0 0 0 0 0 1070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
109 0 0 0 0 0 0 0 0 0 0 0 0 1080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
110 0 0 0 0 0 0 0 0 0 0 0 0 1090 0 0 0 0 0 0 0 0 0 0 0 6 7 7 12 15 15
111 0 0 0 0 0 0 0 0 0 0 0 0 11012 15 15 8 9 9 2 3 3 0 0 0 1 1 1 25 27 26
112 0 0 0 6 6 6 22 22 22 50 50 50 11155 56 53 68 70 65 65 66 61 65 66 61 63 64 60 63 64 60
113 78 78 78 34 34 34 2 2 6 2 2 6 11258 59 55 51 52 50 47 48 46 41 42 42 35 37 36 30 32 31
114 2 2 6 2 2 6 2 2 6 2 2 6 11326 28 27 20 24 24 18 22 22 16 19 19 14 17 17 13 16 16
115 2 2 6 2 2 6 2 2 6 2 2 6 11412 15 15 11 14 14 10 13 13 10 12 12 9 11 11 8 10 10
116 2 2 6 2 2 6 6 6 6 70 70 70 1158 9 9 6 8 8 3 3 3 0 0 0 0 0 0 0 0 0
117 78 78 78 46 46 46 22 22 22 6 6 6 1160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
118 0 0 0 0 0 0 0 0 0 0 0 0 1170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
119 0 0 0 0 0 0 0 0 0 0 0 0 1180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
120 0 0 0 0 0 0 0 0 0 0 0 0 1190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
121 0 0 0 0 0 0 0 0 0 0 0 0 1200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
122 0 0 0 0 0 0 0 0 0 0 0 0 1210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
123 0 0 0 0 0 0 0 0 0 0 0 0 1220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
124 0 0 0 0 0 0 0 0 0 0 0 0 1230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
125 0 0 0 0 0 0 0 0 0 0 0 0 1240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
126 0 0 1 0 0 1 0 0 1 0 0 0 1250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
127 0 0 0 0 0 0 0 0 0 0 0 0 1260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
128 0 0 0 0 0 0 0 0 0 0 0 0 1270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
129 0 0 0 0 0 0 0 0 0 0 0 0 1280 0 0
130 0 0 0 0 0 0 0 0 0 0 0 0 1290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
131 0 0 0 0 0 0 0 0 0 0 0 0 1300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
132 6 6 6 18 18 18 42 42 42 82 82 82 1310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
133 26 26 26 2 2 6 2 2 6 2 2 6 1320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
134 2 2 6 2 2 6 2 2 6 2 2 6 1330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
135 2 2 6 2 2 6 2 2 6 14 14 14 1340 0 0 0 0 0 0 0 0 6 7 7 20 24 24 23 27 26
136 46 46 46 34 34 34 6 6 6 2 2 6 13523 27 26 18 22 22 11 13 13 23 24 24 61 63 57 72 73 67
137 42 42 42 78 78 78 42 42 42 18 18 18 13672 73 67 68 70 65 68 70 65 68 70 65 63 64 60 58 59 55
138 6 6 6 0 0 0 0 0 0 0 0 0 13755 56 53 47 48 46 41 42 42 35 37 36 30 32 31 26 28 27
139 0 0 0 0 0 0 0 0 0 0 0 0 13820 24 24 18 22 22 16 20 20 15 19 19 14 17 17 13 16 16
140 0 0 0 0 0 0 0 0 0 0 0 0 13912 15 15 12 15 15 11 14 14 10 13 13 10 12 12 9 11 11
141 0 0 0 0 0 0 0 0 0 0 0 0 1408 10 10 8 9 9 7 9 9 6 7 7 1 2 2 0 0 0
142 0 0 0 0 0 0 0 0 0 0 0 0 1410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
143 0 0 0 0 0 0 0 0 0 0 0 0 1420 0 0 0 0 0 1 1 1 4 5 5 5 6 5 4 5 5
144 0 0 0 0 0 0 0 0 0 0 0 0 1430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
145 0 0 0 0 0 0 0 0 0 0 0 0 1440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
146 0 0 1 0 0 0 0 0 1 0 0 0 1450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
147 0 0 0 0 0 0 0 0 0 0 0 0 1460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
148 0 0 0 0 0 0 0 0 0 0 0 0 1470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
149 0 0 0 0 0 0 0 0 0 0 0 0 1480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
150 0 0 0 0 0 0 0 0 0 0 0 0 1490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
151 0 0 0 0 0 0 0 0 0 0 0 0 1500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
152 10 10 10 30 30 30 66 66 66 58 58 58 1510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
153 2 2 6 2 2 6 2 2 6 2 2 6 1520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
154 2 2 6 2 2 6 2 2 6 2 2 6 1530 0 0
155 2 2 6 2 2 6 2 2 6 26 26 26 1540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
156 86 86 86 101 101 101 46 46 46 10 10 10 1550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
157 2 2 6 58 58 58 70 70 70 34 34 34 1560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
158 10 10 10 0 0 0 0 0 0 0 0 0 1570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
159 0 0 0 0 0 0 0 0 0 0 0 0 1580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
160 0 0 0 0 0 0 0 0 0 0 0 0 1590 0 0 0 0 0 0 0 0 15 19 19 40 41 39 53 55 47
161 0 0 0 0 0 0 0 0 0 0 0 0 16033 36 34 27 30 29 51 52 50 72 73 67 72 73 67 72 73 67
162 0 0 0 0 0 0 0 0 0 0 0 0 16172 73 67 68 70 65 68 70 65 63 64 60 58 59 55 51 52 50
163 0 0 0 0 0 0 0 0 0 0 0 0 16247 48 46 40 43 41 33 37 35 30 32 31 26 28 27 20 24 24
164 0 0 0 0 0 0 0 0 0 0 0 0 16318 22 22 17 21 21 16 19 19 14 18 18 14 17 17 13 17 17
165 0 0 0 0 0 0 0 0 0 0 0 0 16413 16 16 12 15 15 12 15 15 11 14 14 10 13 13 10 12 12
166 0 0 1 0 0 1 0 0 1 0 0 0 1659 11 11 8 10 10 8 9 9 7 9 9 6 8 8 3 4 4
167 0 0 0 0 0 0 0 0 0 0 0 0 1660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
168 0 0 0 0 0 0 0 0 0 0 0 0 1672 2 2 6 8 8 10 12 12 10 12 12 10 12 12 10 12 12
169 0 0 0 0 0 0 0 0 0 0 0 0 1686 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
170 0 0 0 0 0 0 0 0 0 0 0 0 1690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
171 0 0 0 0 0 0 0 0 0 0 0 0 1700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
172 14 14 14 42 42 42 86 86 86 10 10 10 1710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
173 2 2 6 2 2 6 2 2 6 2 2 6 1720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
174 2 2 6 2 2 6 2 2 6 2 2 6 1730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
175 2 2 6 2 2 6 2 2 6 30 30 30 1740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
176 94 94 94 94 94 94 58 58 58 26 26 26 1750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
177 2 2 6 6 6 6 78 78 78 54 54 54 1760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
178 22 22 22 6 6 6 0 0 0 0 0 0 1770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
179 0 0 0 0 0 0 0 0 0 0 0 0 1780 0 0
180 0 0 0 0 0 0 0 0 0 0 0 0 1790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
181 0 0 0 0 0 0 0 0 0 0 0 0 1800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
182 0 0 0 0 0 0 0 0 0 0 0 0 1810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
183 0 0 0 0 0 0 0 0 0 0 0 0 1820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
184 0 0 0 0 0 0 0 0 0 0 0 0 1830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
185 0 0 0 0 0 0 0 0 0 0 0 0 1840 0 0 0 0 0 0 0 0 20 23 23 71 71 57 131 127 93
186 0 0 0 0 0 0 0 0 0 0 0 0 185115 113 82 63 64 60 72 73 67 72 73 67 72 73 67 72 73 67
187 0 0 0 0 0 0 0 0 0 0 0 0 18668 70 65 65 66 61 61 63 57 55 57 54 49 51 48 43 45 43
188 0 0 0 0 0 0 0 0 0 0 0 0 18739 40 39 33 36 34 28 31 30 23 27 26 20 24 24 20 23 23
189 0 0 0 0 0 0 0 0 0 0 0 0 18817 21 21 16 20 20 15 19 19 15 18 18 14 18 18 14 17 17
190 0 0 0 0 0 0 0 0 0 0 0 0 18913 17 17 13 16 16 12 15 15 12 15 15 11 14 14 10 13 13
191 0 0 0 0 0 0 0 0 0 6 6 6 19010 12 12 9 11 11 8 10 10 7 9 9 7 9 9 6 8 8
192 22 22 22 62 62 62 62 62 62 2 2 6 1914 5 5 0 0 0 0 0 0 0 0 0 1 1 1 6 7 7
193 2 2 6 2 2 6 2 2 6 2 2 6 19210 12 12 10 12 12 10 12 12 10 12 12 10 12 12 10 12 12
194 2 2 6 2 2 6 2 2 6 2 2 6 19310 12 12 3 4 4 0 0 0 0 0 0 0 0 0 0 0 0
195 2 2 6 2 2 6 2 2 6 26 26 26 1940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
196 54 54 54 38 38 38 18 18 18 10 10 10 1950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
197 2 2 6 2 2 6 34 34 34 82 82 82 1960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
198 38 38 38 14 14 14 0 0 0 0 0 0 1970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
199 0 0 0 0 0 0 0 0 0 0 0 0 1980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
200 0 0 0 0 0 0 0 0 0 0 0 0 1990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
201 0 0 0 0 0 0 0 0 0 0 0 0 2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
202 0 0 0 0 0 0 0 0 0 0 0 0 2010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
203 0 0 0 0 0 0 0 0 0 0 0 0 2020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
204 0 0 0 0 0 0 0 0 0 0 0 0 2030 0 0
205 0 0 0 0 0 0 0 0 0 0 0 0 2040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
206 0 0 0 0 0 1 0 0 1 0 0 0 2050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
207 0 0 0 0 0 0 0 0 0 0 0 0 2060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
208 0 0 0 0 0 0 0 0 0 0 0 0 2070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
209 0 0 0 0 0 0 0 0 0 0 0 0 2080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
210 0 0 0 0 0 0 0 0 0 0 0 0 2090 0 0 0 0 0 0 0 0 18 22 22 71 71 57 144 139 99
211 0 0 0 0 0 0 0 0 0 6 6 6 21084 83 72 68 70 65 72 73 67 72 73 67 68 70 65 65 66 61
212 30 30 30 78 78 78 30 30 30 2 2 6 21163 64 60 55 57 54 51 52 50 47 48 46 40 43 41 35 37 36
213 2 2 6 2 2 6 2 2 6 2 2 6 21230 32 31 27 29 28 23 27 26 20 24 24 18 22 22 17 21 21
214 2 2 6 2 2 6 2 2 6 2 2 6 21316 20 20 15 19 19 15 19 19 15 19 19 15 18 18 14 18 18
215 2 2 6 2 2 6 2 2 6 10 10 10 21414 17 17 13 17 17 13 16 16 12 15 15 12 15 15 11 14 14
216 10 10 10 2 2 6 2 2 6 2 2 6 21510 13 13 9 12 12 9 11 11 8 10 10 7 9 9 6 8 8
217 2 2 6 2 2 6 2 2 6 78 78 78 2166 8 8 3 4 4 0 0 0 2 2 2 8 10 10 10 12 12
218 50 50 50 18 18 18 6 6 6 0 0 0 21710 12 12 10 12 12 11 13 13 36 38 35 61 61 53 48 49 45
219 0 0 0 0 0 0 0 0 0 0 0 0 21810 12 12 7 9 9 0 0 0 0 0 0 0 0 0 0 0 0
220 0 0 0 0 0 0 0 0 0 0 0 0 2190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
221 0 0 0 0 0 0 0 0 0 0 0 0 2200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
222 0 0 0 0 0 0 0 0 0 0 0 0 2210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
223 0 0 0 0 0 0 0 0 0 0 0 0 2220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
224 0 0 0 0 0 0 0 0 0 0 0 0 2230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
225 0 0 0 0 0 0 0 0 0 0 0 0 2240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
226 0 0 1 0 0 0 0 0 0 0 0 0 2250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
227 0 0 0 0 0 0 0 0 0 0 0 0 2260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
228 0 0 0 0 0 0 0 0 0 0 0 0 2270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
229 0 0 0 0 0 0 0 0 0 0 0 0 2280 0 0
230 0 0 0 0 0 0 0 0 0 0 0 0 2290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
231 0 0 0 0 0 0 0 0 0 10 10 10 2300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
232 38 38 38 86 86 86 14 14 14 2 2 6 2310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
233 2 2 6 2 2 6 2 2 6 2 2 6 2320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
234 2 2 6 2 2 6 2 2 6 2 2 6 2330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
235 2 2 6 2 2 6 2 2 6 2 2 6 2340 0 0 0 0 0 0 0 0 15 19 19 61 61 53 84 83 72
236 2 2 6 2 2 6 2 2 6 2 2 6 23568 70 65 72 73 67 68 70 65 68 70 65 63 64 60 58 59 55
237 2 2 6 2 2 6 2 2 6 54 54 54 23651 52 50 47 48 46 41 42 42 37 39 37 32 35 33 28 31 30
238 66 66 66 26 26 26 6 6 6 0 0 0 23723 27 26 20 24 24 20 23 23 18 22 22 17 21 21 17 21 21
239 0 0 0 0 0 0 0 0 0 0 0 0 23817 21 21 17 21 21 17 20 20 16 20 20 16 20 20 16 19 19
240 0 0 0 0 0 0 0 0 0 0 0 0 23915 18 18 14 18 18 13 17 17 13 16 16 12 15 15 12 15 15
241 0 0 0 0 0 0 0 0 0 0 0 0 24011 14 14 10 13 13 9 12 12 9 11 11 8 10 10 7 9 9
242 0 0 0 0 0 0 0 0 0 0 0 0 2416 8 8 6 8 8 5 6 5 9 11 11 10 12 12 10 12 12
243 0 0 0 0 0 0 0 0 0 0 0 0 24219 20 18 82 81 62 149 145 103 160 154 106 142 137 94 96 95 69
244 0 0 0 0 0 0 0 0 0 0 0 0 24310 12 12 10 12 12 1 1 1 0 0 0 0 0 0 0 0 0
245 0 0 0 0 0 0 0 0 0 0 0 0 2440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
246 0 0 0 0 0 1 0 0 1 0 0 0 2450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
247 0 0 0 0 0 0 0 0 0 0 0 0 2460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
248 0 0 0 0 0 0 0 0 0 0 0 0 2470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
249 0 0 0 0 0 0 0 0 0 0 0 0 2480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
250 0 0 0 0 0 0 0 0 0 0 0 0 2490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
251 0 0 0 0 0 0 0 0 0 14 14 14 2500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
252 42 42 42 82 82 82 2 2 6 2 2 6 2510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
253 2 2 6 6 6 6 10 10 10 2 2 6 2520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
254 2 2 6 2 2 6 2 2 6 2 2 6 2530 0 0
255 2 2 6 2 2 6 2 2 6 6 6 6 2540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
256 14 14 14 10 10 10 2 2 6 2 2 6 2550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
257 2 2 6 2 2 6 2 2 6 18 18 18 2560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
258 82 82 82 34 34 34 10 10 10 0 0 0 2570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
259 0 0 0 0 0 0 0 0 0 0 0 0 2580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
260 0 0 0 0 0 0 0 0 0 0 0 0 2590 0 0 0 0 0 0 0 0 10 12 12 44 46 43 68 70 65
261 0 0 0 0 0 0 0 0 0 0 0 0 26072 73 67 68 70 65 68 70 65 63 64 60 55 57 54 49 51 48
262 0 0 0 0 0 0 0 0 0 0 0 0 26143 45 43 39 40 39 33 37 35 30 32 31 26 28 27 23 27 26
263 0 0 0 0 0 0 0 0 0 0 0 0 26220 24 24 18 22 22 18 22 22 18 22 22 18 22 22 20 23 23
264 0 0 0 0 0 0 0 0 0 0 0 0 26320 24 24 23 25 24 23 25 24 22 24 23 20 23 23 18 22 22
265 0 0 0 0 0 0 0 0 0 0 0 0 26417 20 20 15 19 19 15 18 18 14 17 17 13 16 16 12 15 15
266 0 0 1 0 0 0 0 0 0 0 0 0 26511 14 14 11 13 13 10 12 12 9 11 11 8 10 10 8 9 9
267 0 0 0 0 0 0 0 0 0 0 0 0 2667 9 9 7 9 9 10 12 12 10 12 12 10 12 12 71 71 57
268 0 0 0 0 0 0 0 0 0 0 0 0 267164 159 111 186 182 128 186 182 128 171 165 117 151 147 98 96 95 69
269 0 0 0 0 0 0 0 0 0 0 0 0 26810 12 12 10 12 12 3 3 3 0 0 0 0 0 0 0 0 0
270 0 0 0 0 0 0 0 0 0 0 0 0 2690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
271 0 0 0 0 0 0 0 0 0 14 14 14 2700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
272 46 46 46 86 86 86 2 2 6 2 2 6 2710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
273 6 6 6 6 6 6 22 22 22 34 34 34 2720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
274 6 6 6 2 2 6 2 2 6 2 2 6 2730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
275 2 2 6 2 2 6 18 18 18 34 34 34 2740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
276 10 10 10 50 50 50 22 22 22 2 2 6 2750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
277 2 2 6 2 2 6 2 2 6 10 10 10 2760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
278 86 86 86 42 42 42 14 14 14 0 0 0 2770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
279 0 0 0 0 0 0 0 0 0 0 0 0 2780 0 0
280 0 0 0 0 0 0 0 0 0 0 0 0 2790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
281 0 0 0 0 0 0 0 0 0 0 0 0 2800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
282 0 0 0 0 0 0 0 0 0 0 0 0 2810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
283 0 0 0 0 0 0 0 0 0 0 0 0 2820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
284 0 0 0 0 0 0 0 0 0 0 0 0 2830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
285 0 0 0 0 0 0 0 0 0 0 0 0 2840 0 0 0 0 0 0 0 0 8 10 10 63 64 60 68 70 65
286 0 0 1 0 0 1 0 0 1 0 0 0 28572 73 67 68 70 65 63 64 60 55 57 54 47 48 46 40 43 41
287 0 0 0 0 0 0 0 0 0 0 0 0 28633 37 35 30 32 31 27 29 28 23 27 26 20 24 24 20 23 23
288 0 0 0 0 0 0 0 0 0 0 0 0 28718 22 22 18 22 22 20 23 22 21 25 23 23 27 26 27 29 28
289 0 0 0 0 0 0 0 0 0 0 0 0 28828 31 30 31 33 31 31 33 31 31 33 31 28 31 30 26 28 27
290 0 0 0 0 0 0 0 0 0 0 0 0 28923 25 24 20 23 22 16 20 20 15 18 18 14 17 17 13 16 16
291 0 0 0 0 0 0 0 0 0 14 14 14 29012 15 15 11 14 14 10 13 13 10 12 12 9 11 11 8 10 10
292 46 46 46 86 86 86 2 2 6 2 2 6 29110 12 12 10 13 13 10 12 12 12 14 14 96 95 69 165 161 109
293 38 38 38 116 116 116 94 94 94 22 22 22 292186 182 128 192 187 134 192 187 134 176 171 126 160 154 106 103 101 77
294 22 22 22 2 2 6 2 2 6 2 2 6 29310 12 12 10 12 12 5 6 5 0 0 0 0 0 0 0 0 0
295 14 14 14 86 86 86 138 138 138 162 162 162 2940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
296154 154 154 38 38 38 26 26 26 6 6 6 2950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
297 2 2 6 2 2 6 2 2 6 2 2 6 2960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
298 86 86 86 46 46 46 14 14 14 0 0 0 2970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
299 0 0 0 0 0 0 0 0 0 0 0 0 2980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
300 0 0 0 0 0 0 0 0 0 0 0 0 2990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
301 0 0 0 0 0 0 0 0 0 0 0 0 3000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
302 0 0 0 0 0 0 0 0 0 0 0 0 3010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
303 0 0 0 0 0 0 0 0 0 0 0 0 3020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
304 0 0 0 0 0 0 0 0 0 0 0 0 3030 0 0
305 0 0 0 0 0 0 0 0 0 0 0 0 3040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
306 0 0 0 0 0 0 0 0 0 0 0 0 3050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
307 0 0 0 0 0 0 0 0 0 0 0 0 3060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
308 0 0 0 0 0 0 0 0 0 0 0 0 3070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
309 0 0 0 0 0 0 0 0 0 0 0 0 3080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
310 0 0 0 0 0 0 0 0 0 0 0 0 3090 0 0 0 0 0 0 0 0 35 37 36 68 70 65 72 73 67
311 0 0 0 0 0 0 0 0 0 14 14 14 31068 70 65 65 66 61 58 59 55 49 51 48 40 43 41 33 37 35
312 46 46 46 86 86 86 2 2 6 14 14 14 31128 31 30 23 27 26 20 24 24 20 23 23 18 22 22 18 22 22
313134 134 134 198 198 198 195 195 195 116 116 116 31218 22 22 20 23 23 23 27 26 27 30 29 32 35 33 37 39 37
314 10 10 10 2 2 6 2 2 6 6 6 6 31340 43 41 44 46 43 46 47 43 44 46 43 40 43 41 36 38 35
315101 98 89 187 187 187 210 210 210 218 218 218 31431 33 31 27 29 28 22 24 23 17 21 21 15 18 18 14 17 17
316214 214 214 134 134 134 14 14 14 6 6 6 31513 16 16 12 15 15 11 14 14 11 14 14 11 13 13 13 16 16
317 2 2 6 2 2 6 2 2 6 2 2 6 31613 16 16 11 14 14 10 12 12 79 78 62 142 137 94 164 159 111
318 86 86 86 50 50 50 18 18 18 6 6 6 317178 174 128 192 187 134 192 187 134 176 171 126 160 154 106 96 95 69
319 0 0 0 0 0 0 0 0 0 0 0 0 31810 12 12 10 12 12 6 7 7 0 0 0 0 0 0 0 0 0
320 0 0 0 0 0 0 0 0 0 0 0 0 3190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
321 0 0 0 0 0 0 0 0 0 0 0 0 3200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
322 0 0 0 0 0 0 0 0 0 0 0 0 3210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
323 0 0 0 0 0 0 0 0 0 0 0 0 3220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
324 0 0 0 0 0 0 0 0 0 0 0 0 3230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
325 0 0 0 0 0 0 0 0 1 0 0 0 3240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
326 0 0 1 0 0 1 0 0 1 0 0 0 3250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
327 0 0 0 0 0 0 0 0 0 0 0 0 3260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
328 0 0 0 0 0 0 0 0 0 0 0 0 3270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
329 0 0 0 0 0 0 0 0 0 0 0 0 3280 0 0
330 0 0 0 0 0 0 0 0 0 0 0 0 3290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
331 0 0 0 0 0 0 0 0 0 14 14 14 3300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
332 46 46 46 86 86 86 2 2 6 54 54 54 3310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
333218 218 218 195 195 195 226 226 226 246 246 246 3320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
334 58 58 58 2 2 6 2 2 6 30 30 30 3330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
335210 210 210 253 253 253 174 174 174 123 123 123 3340 0 0 0 0 0 0 0 0 55 57 54 68 70 65 72 73 67
336221 221 221 234 234 234 74 74 74 2 2 6 33568 70 65 63 64 60 55 56 53 43 45 43 35 37 36 28 31 30
337 2 2 6 2 2 6 2 2 6 2 2 6 33623 27 26 20 24 24 18 22 22 17 21 21 17 21 21 17 21 21
338 70 70 70 58 58 58 22 22 22 6 6 6 33720 24 24 25 27 26 31 33 31 38 39 37 46 47 43 53 55 47
339 0 0 0 0 0 0 0 0 0 0 0 0 33861 61 53 66 65 55 66 65 55 66 65 55 61 61 53 53 55 47
340 0 0 0 0 0 0 0 0 0 0 0 0 33946 47 43 37 39 37 30 33 30 24 26 24 17 21 21 15 18 18
341 0 0 0 0 0 0 0 0 0 0 0 0 34013 17 17 12 15 15 12 15 15 13 16 16 14 18 18 14 18 18
342 0 0 0 0 0 0 0 0 0 0 0 0 34114 17 17 12 15 15 30 31 28 118 116 76 134 131 96 160 154 106
343 0 0 0 0 0 0 0 0 0 0 0 0 342174 170 121 178 174 128 178 174 128 171 165 117 151 147 98 96 95 69
344 0 0 0 0 0 0 0 0 0 0 0 0 34310 12 12 10 12 12 6 8 8 0 0 0 0 0 0 0 0 0
345 0 0 0 0 0 0 0 0 0 0 0 0 3440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
346 0 0 0 0 0 0 0 0 0 0 0 0 3450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
347 0 0 0 0 0 0 0 0 0 0 0 0 3460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
348 0 0 0 0 0 0 0 0 0 0 0 0 3470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
349 0 0 0 0 0 0 0 0 0 0 0 0 3480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
350 0 0 0 0 0 0 0 0 0 0 0 0 3490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
351 0 0 0 0 0 0 0 0 0 14 14 14 3500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
352 46 46 46 82 82 82 2 2 6 106 106 106 3510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
353170 170 170 26 26 26 86 86 86 226 226 226 3520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
354123 123 123 10 10 10 14 14 14 46 46 46 3530 0 0
355231 231 231 190 190 190 6 6 6 70 70 70 3540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
356 90 90 90 238 238 238 158 158 158 2 2 6 3550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
357 2 2 6 2 2 6 2 2 6 2 2 6 3560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
358 70 70 70 58 58 58 22 22 22 6 6 6 3570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
359 0 0 0 0 0 0 0 0 0 0 0 0 3580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
360 0 0 0 0 0 0 0 0 0 0 0 0 3590 0 0 0 0 0 0 0 0 63 64 60 68 70 65 68 70 65
361 0 0 0 0 0 0 0 0 0 0 0 0 36065 66 61 58 59 55 49 51 48 39 40 39 30 32 31 23 27 26
362 0 0 0 0 0 0 0 0 0 0 0 0 36120 24 24 18 22 22 17 21 21 16 20 20 17 21 21 20 23 23
363 0 0 0 0 0 0 0 0 0 0 0 0 36225 27 26 32 35 33 43 44 41 53 55 47 66 65 55 75 75 61
364 0 0 0 0 0 0 0 0 0 0 0 0 36382 81 62 84 83 72 87 86 72 87 86 72 82 81 62 75 75 61
365 0 0 0 0 0 0 0 0 1 0 0 0 36466 65 55 53 55 47 40 41 39 31 33 31 23 25 24 17 20 20
366 0 0 1 0 0 1 0 0 1 0 0 0 36514 18 18 13 16 16 12 15 15 12 15 15 13 17 17 14 18 18
367 0 0 0 0 0 0 0 0 0 0 0 0 36614 18 18 13 16 16 46 47 43 96 95 69 125 122 87 142 137 94
368 0 0 0 0 0 0 0 0 0 0 0 0 367160 154 106 165 161 109 164 159 111 155 149 109 142 137 94 75 75 61
369 0 0 0 0 0 0 0 0 0 0 0 0 36810 12 12 10 12 12 6 8 8 0 0 0 0 0 0 0 0 0
370 0 0 0 0 0 0 0 0 0 0 0 0 3690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
371 0 0 0 0 0 0 0 0 0 14 14 14 3700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
372 42 42 42 86 86 86 6 6 6 116 116 116 3710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
373106 106 106 6 6 6 70 70 70 149 149 149 3720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
374128 128 128 18 18 18 38 38 38 54 54 54 3730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
375221 221 221 106 106 106 2 2 6 14 14 14 3740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
376 46 46 46 190 190 190 198 198 198 2 2 6 3750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
377 2 2 6 2 2 6 2 2 6 2 2 6 3760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
378 74 74 74 62 62 62 22 22 22 6 6 6 3770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
379 0 0 0 0 0 0 0 0 0 0 0 0 3780 0 0
380 0 0 0 0 0 0 0 0 0 0 0 0 3790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
381 0 0 0 0 0 0 0 0 0 0 0 0 3800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
382 0 0 0 0 0 0 0 0 0 0 0 0 3810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
383 0 0 0 0 0 0 0 0 0 0 0 0 3820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
384 0 0 0 0 0 0 0 0 0 0 0 0 3830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
385 0 0 0 0 0 0 0 0 1 0 0 0 3840 0 0 0 0 0 0 0 0 60 60 56 68 70 65 68 70 65
386 0 0 1 0 0 0 0 0 1 0 0 0 38563 64 60 55 57 54 46 47 45 35 37 36 27 30 29 23 25 24
387 0 0 0 0 0 0 0 0 0 0 0 0 38618 22 22 17 21 21 16 20 20 17 21 21 18 22 22 23 27 26
388 0 0 0 0 0 0 0 0 0 0 0 0 38731 33 31 43 44 41 55 56 53 71 71 57 84 83 72 92 91 72
389 0 0 0 0 0 0 0 0 0 0 0 0 388103 101 77 92 91 72 82 81 62 82 81 62 87 86 72 92 91 72
390 0 0 0 0 0 0 0 0 0 0 0 0 38984 83 72 71 71 57 55 56 53 43 44 41 30 33 30 22 24 23
391 0 0 0 0 0 0 0 0 0 14 14 14 39016 19 19 14 17 17 12 15 15 12 15 15 13 16 16 14 18 18
392 42 42 42 94 94 94 14 14 14 101 101 101 39114 18 18 14 17 17 43 44 41 82 81 62 118 116 76 125 122 87
393128 128 128 2 2 6 18 18 18 116 116 116 392142 137 94 144 139 99 144 139 99 134 131 96 118 116 76 53 55 47
394118 98 46 121 92 8 121 92 8 98 78 10 39310 12 12 10 12 12 6 8 8 0 0 0 0 0 0 0 0 0
395162 162 162 106 106 106 2 2 6 2 2 6 3940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
396 2 2 6 195 195 195 195 195 195 6 6 6 3950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
397 2 2 6 2 2 6 2 2 6 2 2 6 3960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
398 74 74 74 62 62 62 22 22 22 6 6 6 3970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
399 0 0 0 0 0 0 0 0 0 0 0 0 3980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
400 0 0 0 0 0 0 0 0 0 0 0 0 3990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
401 0 0 0 0 0 0 0 0 0 0 0 0 4000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
402 0 0 0 0 0 0 0 0 0 0 0 0 4010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
403 0 0 0 0 0 0 0 0 0 0 0 0 4020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
404 0 0 0 0 0 0 0 0 0 0 0 0 4030 0 0
405 0 0 0 0 0 0 0 0 1 0 0 1 4040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
406 0 0 1 0 0 0 0 0 1 0 0 0 4050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
407 0 0 0 0 0 0 0 0 0 0 0 0 4060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
408 0 0 0 0 0 0 0 0 0 0 0 0 4070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
409 0 0 0 0 0 0 0 0 0 0 0 0 4080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
410 0 0 0 0 0 0 0 0 0 0 0 0 4090 0 0 0 0 0 0 0 0 47 48 46 63 64 60 63 64 60
411 0 0 0 0 0 0 0 0 0 10 10 10 41055 57 54 49 51 48 40 43 41 32 34 33 26 28 27 20 24 24
412 38 38 38 90 90 90 14 14 14 58 58 58 41118 22 22 16 20 20 16 20 20 17 21 21 20 24 24 28 31 30
413210 210 210 26 26 26 54 38 6 154 114 10 41240 41 39 53 55 47 75 75 61 90 89 73 87 86 72 48 49 45
414226 170 11 236 186 11 225 175 15 184 144 12 41314 14 13 2 2 2 1 2 2 1 1 1 1 1 1 2 2 2
415215 174 15 175 146 61 37 26 9 2 2 6 41419 20 18 43 44 41 66 65 55 53 55 47 38 39 37 26 28 27
416 70 70 70 246 246 246 138 138 138 2 2 6 41518 22 22 14 18 18 13 16 16 12 15 15 12 15 15 13 17 17
417 2 2 6 2 2 6 2 2 6 2 2 6 41614 18 18 14 18 18 30 31 28 66 65 55 96 95 69 103 101 77
418 70 70 70 66 66 66 26 26 26 6 6 6 417118 116 76 118 116 76 118 116 76 118 116 76 103 101 77 36 38 35
419 0 0 0 0 0 0 0 0 0 0 0 0 41810 12 12 10 12 12 6 7 7 0 0 0 0 0 0 0 0 0
420 0 0 0 0 0 0 0 0 0 0 0 0 4190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
421 0 0 0 0 0 0 0 0 0 0 0 0 4200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
422 0 0 0 0 0 0 0 0 0 0 0 0 4210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
423 0 0 0 0 0 0 0 0 0 0 0 0 4220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
424 0 0 0 0 0 0 0 0 0 0 0 0 4230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
425 0 0 0 0 0 0 0 0 0 0 0 0 4240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
426 0 0 0 0 0 0 0 0 0 0 0 0 4250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
427 0 0 0 0 0 0 0 0 0 0 0 0 4260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
428 0 0 0 0 0 0 0 0 0 0 0 0 4270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
429 0 0 0 0 0 0 0 0 0 0 0 0 4280 0 0
430 0 0 0 0 0 0 0 0 0 0 0 0 4290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
431 0 0 0 0 0 0 0 0 0 10 10 10 4300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
432 38 38 38 86 86 86 14 14 14 10 10 10 4310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
433195 195 195 188 164 115 192 133 9 225 175 15 4320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
434239 182 13 234 190 10 232 195 16 232 200 30 4330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
435245 207 45 241 208 19 232 195 16 184 144 12 4340 0 0 0 0 0 0 0 0 28 31 30 55 57 54 51 52 50
436218 194 134 211 206 186 42 42 42 2 2 6 43549 51 48 41 42 42 35 37 36 28 31 30 23 27 26 20 23 23
437 2 2 6 2 2 6 2 2 6 2 2 6 43617 21 21 16 20 20 16 20 20 18 22 22 23 27 26 33 36 34
438 50 50 50 74 74 74 30 30 30 6 6 6 43748 49 45 71 71 57 82 81 62 43 44 41 8 9 9 6 7 7
439 0 0 0 0 0 0 0 0 0 0 0 0 4386 7 7 6 7 7 6 7 7 5 6 5 4 5 5 3 4 4
440 0 0 0 0 0 0 0 0 0 0 0 0 4392 3 3 1 2 2 4 5 4 36 38 35 48 49 45 32 35 33
441 0 0 0 0 0 0 0 0 0 0 0 0 44021 25 23 16 19 19 13 17 17 12 15 15 12 15 15 13 16 16
442 0 0 0 0 0 0 0 0 0 0 0 0 44114 18 18 14 18 18 16 18 16 36 38 35 61 61 53 82 81 62
443 0 0 0 0 0 0 0 0 0 0 0 0 44296 95 69 96 95 69 96 95 69 96 95 69 79 78 62 19 20 18
444 0 0 0 0 0 0 0 0 0 0 0 0 44310 12 12 10 12 12 4 5 5 0 0 0 0 0 0 0 0 0
445 0 0 0 0 0 0 0 0 0 0 0 0 4440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
446 0 0 0 0 0 0 0 0 0 0 0 0 4450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
447 0 0 0 0 0 0 0 0 0 0 0 0 4460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
448 0 0 0 0 0 0 0 0 0 0 0 0 4470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
449 0 0 0 0 0 0 0 0 0 0 0 0 4480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
450 0 0 0 0 0 0 0 0 0 0 0 0 4490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
451 0 0 0 0 0 0 0 0 0 10 10 10 4500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
452 34 34 34 86 86 86 14 14 14 2 2 6 4510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
453121 87 25 192 133 9 219 162 10 239 182 13 4520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
454236 186 11 232 195 16 241 208 19 244 214 54 4530 0 0
455246 218 60 246 218 38 246 215 20 241 208 19 4540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
456241 208 19 226 184 13 121 87 25 2 2 6 4550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
457 2 2 6 2 2 6 2 2 6 2 2 6 4560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
458 50 50 50 82 82 82 34 34 34 10 10 10 4570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
459 0 0 0 0 0 0 0 0 0 0 0 0 4580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
460 0 0 0 0 0 0 0 0 0 0 0 0 4590 0 0 0 0 0 0 0 0 13 13 13 46 47 45 43 45 43
461 0 0 0 0 0 0 0 0 0 0 0 0 46040 43 41 35 37 36 30 32 31 23 27 26 20 24 24 18 22 22
462 0 0 0 0 0 0 0 0 0 0 0 0 46117 21 21 16 20 20 17 21 21 20 23 23 27 30 29 40 41 39
463 0 0 0 0 0 0 0 0 0 0 0 0 46261 61 53 53 55 47 16 17 16 9 11 11 10 12 12 10 12 12
464 0 0 0 0 0 0 0 0 0 0 0 0 46310 12 12 10 12 12 10 12 12 9 11 11 8 10 10 8 9 9
465 0 0 0 0 0 0 0 0 0 0 0 0 4646 8 8 5 6 5 4 5 5 2 3 3 19 20 18 38 39 37
466 0 0 0 0 0 0 0 0 0 0 0 0 46526 28 27 17 21 21 14 17 17 13 16 16 12 15 15 12 15 15
467 0 0 0 0 0 0 0 0 0 0 0 0 46613 17 17 14 18 18 12 15 15 13 12 7 30 31 28 46 47 43
468 0 0 0 0 0 0 0 0 0 0 0 0 46753 55 47 66 65 55 66 65 55 53 55 47 36 38 35 10 12 12
469 0 0 0 0 0 0 0 0 0 0 0 0 46810 12 12 10 12 12 2 3 3 0 0 0 0 0 0 0 0 0
470 0 0 0 0 0 0 0 0 0 0 0 0 4690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
471 0 0 0 0 0 0 0 0 0 10 10 10 4700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
472 34 34 34 82 82 82 30 30 30 61 42 6 4710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
473180 123 7 206 145 10 230 174 11 239 182 13 4720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
474234 190 10 238 202 15 241 208 19 246 218 74 4730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
475246 218 38 246 215 20 246 215 20 246 215 20 4740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
476226 184 13 215 174 15 184 144 12 6 6 6 4750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
477 2 2 6 2 2 6 2 2 6 2 2 6 4760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
478 26 26 26 94 94 94 42 42 42 14 14 14 4770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
479 0 0 0 0 0 0 0 0 0 0 0 0 4780 0 0
480 0 0 0 0 0 0 0 0 0 0 0 0 4790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
481 0 0 0 0 0 0 0 0 0 0 0 0 4800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
482 0 0 0 0 0 0 0 0 0 0 0 0 4810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
483 0 0 0 0 0 0 0 0 0 0 0 0 4820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
484 0 0 0 0 0 0 0 0 0 0 0 0 4830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
485 0 0 0 0 0 0 0 0 0 0 0 0 4840 0 0 0 0 0 0 0 0 1 1 1 33 37 35 35 37 36
486 0 0 0 0 0 0 0 0 0 0 0 0 48532 35 33 28 31 30 23 27 26 20 24 24 18 22 22 17 21 21
487 0 0 0 0 0 0 0 0 0 0 0 0 48616 20 20 16 20 20 17 21 21 21 25 23 31 33 31 44 46 43
488 0 0 0 0 0 0 0 0 0 0 0 0 48731 33 31 11 13 13 12 14 14 12 15 15 13 16 16 14 17 17
489 0 0 0 0 0 0 0 0 0 0 0 0 48814 17 17 14 17 17 14 17 17 13 16 16 12 15 15 12 14 14
490 0 0 0 0 0 0 0 0 0 0 0 0 48911 13 13 9 11 11 8 10 10 6 8 8 4 5 5 17 18 17
491 0 0 0 0 0 0 0 0 0 10 10 10 49030 33 30 20 23 22 15 18 18 13 16 16 12 15 15 12 14 14
492 30 30 30 78 78 78 50 50 50 104 69 6 49113 16 16 14 17 17 14 18 18 11 12 11 7 7 5 16 17 12
493192 133 9 216 158 10 236 178 12 236 186 11 49221 22 20 30 31 28 25 27 25 21 22 20 14 14 13 10 12 12
494232 195 16 241 208 19 244 214 54 245 215 43 49310 12 12 9 11 11 0 0 0 0 0 0 0 0 0 0 0 0
495246 215 20 246 215 20 241 208 19 198 155 10 4940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
496200 144 11 216 158 10 156 118 10 2 2 6 4950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
497 2 2 6 2 2 6 2 2 6 2 2 6 4960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
498 6 6 6 90 90 90 54 54 54 18 18 18 4970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
499 6 6 6 0 0 0 0 0 0 0 0 0 4980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
500 0 0 0 0 0 0 0 0 0 0 0 0 4990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
501 0 0 0 0 0 0 0 0 0 0 0 0 5000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
502 0 0 0 0 0 0 0 0 0 0 0 0 5010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
503 0 0 0 0 0 0 0 0 0 0 0 0 5020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
504 0 0 0 0 0 0 0 0 0 0 0 0 5030 0 0
505 0 0 0 0 0 0 0 0 0 0 0 0 5040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
506 0 0 0 0 0 0 0 0 0 0 0 0 5050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
507 0 0 0 0 0 0 0 0 0 0 0 0 5060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
508 0 0 0 0 0 0 0 0 0 0 0 0 5070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
509 0 0 0 0 0 0 0 0 0 0 0 0 5080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
510 0 0 0 0 0 0 0 0 0 0 0 0 5090 0 0 0 0 0 0 0 0 0 0 0 18 22 22 27 30 29
511 0 0 0 0 0 0 0 0 0 10 10 10 51027 29 28 40 41 39 53 55 47 53 55 47 53 55 47 46 47 43
512 30 30 30 78 78 78 46 46 46 22 22 22 51125 27 25 16 20 20 17 21 21 23 25 24 31 33 31 20 20 20
513137 92 6 210 162 10 239 182 13 238 190 10 51212 15 15 14 17 17 15 19 19 16 20 20 17 21 21 18 22 22
514238 202 15 241 208 19 246 215 20 246 215 20 51318 22 22 18 22 22 18 22 22 17 21 21 17 21 21 16 19 19
515241 208 19 203 166 17 185 133 11 210 150 10 51415 18 18 13 16 16 12 15 15 10 12 12 8 10 10 6 8 8
516216 158 10 210 150 10 102 78 10 2 2 6 51521 22 21 22 24 23 15 19 19 13 17 17 13 16 16 12 15 15
517 6 6 6 54 54 54 14 14 14 2 2 6 51612 15 15 13 17 17 14 18 18 14 18 18 13 15 14 10 9 6
518 2 2 6 62 62 62 74 74 74 30 30 30 5177 7 5 7 7 5 7 7 5 9 11 11 10 12 12 10 12 12
519 10 10 10 0 0 0 0 0 0 0 0 0 51810 12 12 6 7 7 0 0 0 0 0 0 0 0 0 0 0 0
520 0 0 0 0 0 0 0 0 0 0 0 0 5190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
521 0 0 0 0 0 0 0 0 0 0 0 0 5200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
522 0 0 0 0 0 0 0 0 0 0 0 0 5210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
523 0 0 0 0 0 0 0 0 0 0 0 0 5220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
524 0 0 0 0 0 0 0 0 0 0 0 0 5230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
525 0 0 0 0 0 0 0 0 0 0 0 0 5240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
526 0 0 0 0 0 0 0 0 0 0 0 0 5250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
527 0 0 0 0 0 0 0 0 0 0 0 0 5260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
528 0 0 0 0 0 0 0 0 0 0 0 0 5270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
529 0 0 0 0 0 0 0 0 0 0 0 0 5280 0 0
530 0 0 0 0 0 0 0 0 0 0 0 0 5290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
531 0 0 0 0 0 0 0 0 0 10 10 10 5300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
532 34 34 34 78 78 78 50 50 50 6 6 6 5310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
533 94 70 30 139 102 15 190 146 13 226 184 13 5320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
534232 200 30 232 195 16 215 174 15 190 146 13 5330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
535168 122 10 192 133 9 210 150 10 213 154 11 5340 0 0 0 0 0 0 0 0 0 0 0 16 17 12 82 81 62
536202 150 34 182 157 106 101 98 89 2 2 6 535118 116 76 118 116 76 161 156 96 161 156 96 161 156 96 118 116 76
537 2 2 6 78 78 78 116 116 116 58 58 58 536118 116 76 96 95 69 53 55 47 22 24 23 14 17 17 13 16 16
538 2 2 6 22 22 22 90 90 90 46 46 46 53715 19 19 17 21 21 18 22 22 20 24 24 20 24 24 23 27 26
539 18 18 18 6 6 6 0 0 0 0 0 0 53823 27 26 23 27 26 23 27 26 23 27 26 23 27 26 20 24 24
540 0 0 0 0 0 0 0 0 0 0 0 0 53920 23 23 17 21 21 16 19 19 14 17 17 12 15 15 10 12 12
541 0 0 0 0 0 0 0 0 0 0 0 0 5409 11 11 20 23 22 16 19 19 14 17 17 13 16 16 12 15 15
542 0 0 0 0 0 0 0 0 0 0 0 0 54111 14 14 13 16 16 14 17 17 14 18 18 14 17 17 12 15 15
543 0 0 0 0 0 0 0 0 0 0 0 0 54210 12 12 10 12 12 10 12 12 10 12 12 10 12 12 10 12 12
544 0 0 0 0 0 0 0 0 0 0 0 0 5439 11 11 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
545 0 0 0 0 0 0 0 0 0 0 0 0 5440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
546 0 0 0 0 0 0 0 0 0 0 0 0 5450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
547 0 0 0 0 0 0 0 0 0 0 0 0 5460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
548 0 0 0 0 0 0 0 0 0 0 0 0 5470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
549 0 0 0 0 0 0 0 0 0 0 0 0 5480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
550 0 0 0 0 0 0 0 0 0 0 0 0 5490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
551 0 0 0 0 0 0 0 0 0 10 10 10 5500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
552 38 38 38 86 86 86 50 50 50 6 6 6 5510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
553128 128 128 174 154 114 156 107 11 168 122 10 5520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
554198 155 10 184 144 12 197 138 11 200 144 11 5530 0 0
555206 145 10 206 145 10 197 138 11 188 164 115 5540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
556195 195 195 198 198 198 174 174 174 14 14 14 5550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
557 2 2 6 22 22 22 116 116 116 116 116 116 5560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
558 22 22 22 2 2 6 74 74 74 70 70 70 5570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
559 30 30 30 10 10 10 0 0 0 0 0 0 5580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
560 0 0 0 0 0 0 0 0 0 0 0 0 5590 0 0 0 0 0 0 0 0 0 0 0 53 55 47 161 156 96
561 0 0 0 0 0 0 0 0 0 0 0 0 560161 156 96 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
562 0 0 0 0 0 0 0 0 0 0 0 0 561230 229 82 161 156 96 118 116 76 96 95 69 21 22 20 16 19 19
563 0 0 0 0 0 0 0 0 0 0 0 0 56218 22 22 20 24 24 23 27 26 23 27 26 26 28 27 27 30 29
564 0 0 0 0 0 0 0 0 0 0 0 0 56327 30 29 18 22 22 12 14 14 8 10 10 9 11 11 17 21 21
565 0 0 0 0 0 0 0 0 0 0 0 0 56423 27 26 23 27 26 20 24 24 18 22 22 16 20 20 14 17 17
566 0 0 0 0 0 0 0 0 0 0 0 0 56512 14 14 14 17 17 16 20 20 14 17 17 13 17 17 13 16 16
567 0 0 0 0 0 0 0 0 0 0 0 0 56612 15 15 12 15 15 13 17 17 14 18 18 14 17 17 13 16 16
568 0 0 0 0 0 0 0 0 0 0 0 0 56711 13 13 10 12 12 10 12 12 10 12 12 10 12 12 10 12 12
569 0 0 0 0 0 0 0 0 0 0 0 0 5684 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
570 0 0 0 0 0 0 0 0 0 0 0 0 5690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
571 0 0 0 0 0 0 6 6 6 18 18 18 5700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
572 50 50 50 101 101 101 26 26 26 10 10 10 5710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
573138 138 138 190 190 190 174 154 114 156 107 11 5720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
574197 138 11 200 144 11 197 138 11 192 133 9 5730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
575180 123 7 190 142 34 190 178 144 187 187 187 5740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
576202 202 202 221 221 221 214 214 214 66 66 66 5750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
577 2 2 6 2 2 6 50 50 50 62 62 62 5760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
578 6 6 6 2 2 6 10 10 10 90 90 90 5770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
579 50 50 50 18 18 18 6 6 6 0 0 0 5780 0 0
580 0 0 0 0 0 0 0 0 0 0 0 0 5790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
581 0 0 0 0 0 0 0 0 0 0 0 0 5800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
582 0 0 0 0 0 0 0 0 0 0 0 0 5810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
583 0 0 0 0 0 0 0 0 0 0 0 0 5820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
584 0 0 0 0 0 0 0 0 0 0 0 0 5830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
585 0 0 0 0 0 0 0 0 0 0 0 0 5840 0 0 0 0 0 0 0 0 13 12 7 118 116 76 230 229 82
586 0 0 0 0 0 0 0 0 0 0 0 0 585230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
587 0 0 0 0 0 0 0 0 0 0 0 0 586230 229 82 230 229 82 230 229 82 161 156 96 118 116 76 30 31 28
588 0 0 0 0 0 0 0 0 0 0 0 0 58720 24 24 23 27 26 27 30 29 28 31 30 30 32 31 23 27 26
589 0 0 0 0 0 0 0 0 0 0 0 0 58816 19 19 17 21 21 12 15 15 9 11 11 10 12 12 9 11 11
590 0 0 0 0 0 0 0 0 0 0 0 0 58920 24 24 28 31 30 26 28 27 23 27 26 20 24 24 17 21 21
591 0 0 0 0 0 0 10 10 10 34 34 34 59015 19 19 13 16 16 16 19 19 14 18 18 14 17 17 13 16 16
592 74 74 74 74 74 74 2 2 6 6 6 6 59112 15 15 11 14 14 13 16 16 14 17 17 14 18 18 14 17 17
593144 144 144 198 198 198 190 190 190 178 166 146 59212 15 15 10 12 12 10 12 12 10 12 12 10 12 12 8 9 9
594154 121 60 156 107 11 156 107 11 168 124 44 5930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
595174 154 114 187 187 187 190 190 190 210 210 210 5940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
596246 246 246 253 253 253 253 253 253 182 182 182 5950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
597 6 6 6 2 2 6 2 2 6 2 2 6 5960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
598 2 2 6 2 2 6 2 2 6 62 62 62 5970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
599 74 74 74 34 34 34 14 14 14 0 0 0 5980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
600 0 0 0 0 0 0 0 0 0 0 0 0 5990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
601 0 0 0 0 0 0 0 0 0 0 0 0 6000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
602 0 0 0 0 0 0 0 0 0 0 0 0 6010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
603 0 0 0 0 0 0 0 0 0 0 0 0 6020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
604 0 0 0 0 0 0 0 0 0 0 0 0 6030 0 0
605 0 0 0 0 0 0 0 0 0 0 0 0 6040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
606 0 0 0 0 0 0 0 0 0 0 0 0 6050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
607 0 0 0 0 0 0 0 0 0 0 0 0 6060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
608 0 0 0 0 0 0 0 0 0 0 0 0 6070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
609 0 0 0 0 0 0 0 0 0 0 0 0 6080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
610 0 0 0 0 0 0 0 0 0 0 0 0 6090 0 0 0 0 0 0 0 0 82 81 62 161 156 96 230 229 82
611 0 0 0 10 10 10 22 22 22 54 54 54 610230 229 82 233 233 100 230 229 82 230 229 82 230 229 82 230 229 82
612 94 94 94 18 18 18 2 2 6 46 46 46 611230 229 82 230 229 82 230 229 82 230 229 82 161 156 96 118 116 76
613234 234 234 221 221 221 190 190 190 190 190 190 61227 29 28 27 30 29 30 32 31 30 32 31 23 27 26 20 24 24
614190 190 190 187 187 187 187 187 187 190 190 190 61326 28 27 17 21 21 6 7 7 72 73 67 145 141 105 15 15 15
615190 190 190 195 195 195 214 214 214 242 242 242 61414 17 17 33 37 35 30 32 31 28 31 30 26 28 27 23 27 26
616253 253 253 253 253 253 253 253 253 253 253 253 61520 23 23 16 20 20 15 19 19 14 18 18 14 17 17 13 16 16
617 82 82 82 2 2 6 2 2 6 2 2 6 61612 15 15 11 14 14 12 15 15 13 17 17 14 18 18 14 17 17
618 2 2 6 2 2 6 2 2 6 14 14 14 61713 16 16 11 13 13 10 12 12 10 12 12 9 11 11 1 1 1
619 86 86 86 54 54 54 22 22 22 6 6 6 6180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
620 0 0 0 0 0 0 0 0 0 0 0 0 6190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
621 0 0 0 0 0 0 0 0 0 0 0 0 6200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
622 0 0 0 0 0 0 0 0 0 0 0 0 6210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
623 0 0 0 0 0 0 0 0 0 0 0 0 6220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
624 0 0 0 0 0 0 0 0 0 0 0 0 6230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
625 0 0 0 0 0 0 0 0 0 0 0 0 6240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
626 0 0 0 0 0 0 0 0 0 0 0 0 6250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
627 0 0 0 0 0 0 0 0 0 0 0 0 6260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
628 0 0 0 0 0 0 0 0 0 0 0 0 6270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
629 0 0 0 0 0 0 0 0 0 0 0 0 6280 0 0
630 0 0 0 0 0 0 0 0 0 0 0 0 6290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
631 6 6 6 18 18 18 46 46 46 90 90 90 6300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
632 46 46 46 18 18 18 6 6 6 182 182 182 6310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
633253 253 253 246 246 246 206 206 206 190 190 190 6320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
634190 190 190 190 190 190 190 190 190 190 190 190 6330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
635206 206 206 231 231 231 250 250 250 253 253 253 6340 0 0 0 0 0 16 17 12 161 156 96 230 229 82 230 229 82
636253 253 253 253 253 253 253 253 253 253 253 253 635243 242 120 235 234 117 230 229 82 230 229 82 230 229 82 230 229 82
637202 202 202 14 14 14 2 2 6 2 2 6 636230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 161 156 96
638 2 2 6 2 2 6 2 2 6 2 2 6 63782 81 62 28 31 30 28 31 30 27 30 29 28 31 30 30 32 31
639 42 42 42 86 86 86 42 42 42 18 18 18 63833 37 35 13 16 16 3 3 3 105 104 92 210 208 158 12 14 14
640 6 6 6 0 0 0 0 0 0 0 0 0 63917 21 21 33 37 35 33 37 35 32 35 33 30 32 31 27 30 29
641 0 0 0 0 0 0 0 0 0 0 0 0 64023 27 26 20 23 23 17 20 20 15 18 18 14 18 18 13 17 17
642 0 0 0 0 0 0 0 0 0 0 0 0 64113 16 16 12 15 15 11 14 14 13 16 16 14 17 17 14 18 18
643 0 0 0 0 0 0 0 0 0 0 0 0 64213 17 17 12 15 15 10 12 12 10 12 12 3 4 4 0 0 0
644 0 0 0 0 0 0 0 0 0 0 0 0 6430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
645 0 0 0 0 0 0 0 0 0 0 0 0 6440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
646 0 0 0 0 0 0 0 0 0 0 0 0 6450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
647 0 0 0 0 0 0 0 0 0 0 0 0 6460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
648 0 0 0 0 0 0 0 0 0 0 0 0 6470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
649 0 0 0 0 0 0 0 0 0 0 0 0 6480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
650 0 0 0 0 0 0 0 0 0 6 6 6 6490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
651 14 14 14 38 38 38 74 74 74 66 66 66 6500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
652 2 2 6 6 6 6 90 90 90 250 250 250 6510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
653253 253 253 253 253 253 238 238 238 198 198 198 6520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
654190 190 190 190 190 190 195 195 195 221 221 221 6530 0 0
655246 246 246 253 253 253 253 253 253 253 253 253 6540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
656253 253 253 253 253 253 253 253 253 253 253 253 6550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
657253 253 253 82 82 82 2 2 6 2 2 6 6560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
658 2 2 6 2 2 6 2 2 6 2 2 6 6570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
659 2 2 6 78 78 78 70 70 70 34 34 34 6580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
660 14 14 14 6 6 6 0 0 0 0 0 0 6590 0 0 0 0 0 96 95 69 230 229 82 230 229 82 244 244 132
661 0 0 0 0 0 0 0 0 0 0 0 0 660241 241 143 243 242 120 230 229 82 230 229 82 230 229 82 230 229 82
662 0 0 0 0 0 0 0 0 0 0 0 0 661230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
663 0 0 0 0 0 0 0 0 0 0 0 0 662161 156 96 46 47 43 32 35 33 33 37 35 33 37 35 33 37 35
664 0 0 0 0 0 0 0 0 0 0 0 0 66340 43 41 23 27 26 1 1 1 2 2 2 24 26 24 14 17 17
665 0 0 0 0 0 0 0 0 0 0 0 0 66423 27 26 33 37 35 33 37 35 33 37 35 33 37 35 30 32 31
666 0 0 0 0 0 0 0 0 0 0 0 0 66527 30 29 23 27 26 20 23 23 15 18 18 14 18 18 14 17 17
667 0 0 0 0 0 0 0 0 0 0 0 0 66613 16 16 12 15 15 11 14 14 12 15 15 13 17 17 14 17 17
668 0 0 0 0 0 0 0 0 0 0 0 0 66714 17 17 13 16 16 11 13 13 6 8 8 0 0 0 0 0 0
669 0 0 0 0 0 0 0 0 0 0 0 0 6680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
670 0 0 0 0 0 0 0 0 0 14 14 14 6690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
671 34 34 34 66 66 66 78 78 78 6 6 6 6700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
672 2 2 6 18 18 18 218 218 218 253 253 253 6710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
673253 253 253 253 253 253 253 253 253 246 246 246 6720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
674226 226 226 231 231 231 246 246 246 253 253 253 6730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
675253 253 253 253 253 253 253 253 253 253 253 253 6740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
676253 253 253 253 253 253 253 253 253 253 253 253 6750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
677253 253 253 178 178 178 2 2 6 2 2 6 6760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
678 2 2 6 2 2 6 2 2 6 2 2 6 6770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
679 2 2 6 18 18 18 90 90 90 62 62 62 6780 0 0
680 30 30 30 10 10 10 0 0 0 0 0 0 6790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
681 0 0 0 0 0 0 0 0 0 0 0 0 6800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
682 0 0 0 0 0 0 0 0 0 0 0 0 6810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
683 0 0 0 0 0 0 0 0 0 0 0 0 6820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
684 0 0 0 0 0 0 0 0 0 0 0 0 6830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
685 0 0 0 0 0 0 0 0 0 0 0 0 6840 0 0 16 17 12 161 156 96 230 229 82 235 234 117 239 239 170
686 0 0 0 0 0 0 0 0 0 0 0 0 685239 239 170 236 236 101 230 229 82 230 229 82 230 229 82 230 229 82
687 0 0 0 0 0 0 0 0 0 0 0 0 686230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
688 0 0 0 0 0 0 0 0 0 0 0 0 687230 229 82 118 116 76 33 37 35 33 37 35 37 39 37 37 39 37
689 0 0 0 0 0 0 0 0 0 0 0 0 68843 45 43 49 51 48 20 24 24 8 10 10 17 20 20 35 37 36
690 0 0 0 0 0 0 10 10 10 26 26 26 68933 37 35 40 43 41 37 39 37 35 37 36 33 37 35 33 37 35
691 58 58 58 90 90 90 18 18 18 2 2 6 69030 32 31 27 30 29 23 27 26 15 19 19 14 18 18 14 17 17
692 2 2 6 110 110 110 253 253 253 253 253 253 69113 17 17 13 16 16 12 15 15 11 14 14 13 16 16 14 17 17
693253 253 253 253 253 253 253 253 253 253 253 253 69214 17 17 13 17 17 11 14 14 4 5 5 0 0 0 0 0 0
694250 250 250 253 253 253 253 253 253 253 253 253 6930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
695253 253 253 253 253 253 253 253 253 253 253 253 6940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
696253 253 253 253 253 253 253 253 253 253 253 253 6950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
697253 253 253 231 231 231 18 18 18 2 2 6 6960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
698 2 2 6 2 2 6 2 2 6 2 2 6 6970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
699 2 2 6 2 2 6 18 18 18 94 94 94 6980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
700 54 54 54 26 26 26 10 10 10 0 0 0 6990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
701 0 0 0 0 0 0 0 0 0 0 0 0 7000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
702 0 0 0 0 0 0 0 0 0 0 0 0 7010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
703 0 0 0 0 0 0 0 0 0 0 0 0 7020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
704 0 0 0 0 0 0 0 0 0 0 0 0 7030 0 0
705 0 0 0 0 0 0 0 0 0 0 0 0 7040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
706 0 0 0 0 0 0 0 0 0 0 0 0 7050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
707 0 0 0 0 0 0 0 0 0 0 0 0 7060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
708 0 0 0 0 0 0 0 0 0 0 0 0 7070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
709 0 0 0 0 0 0 0 0 0 0 0 0 7080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
710 0 0 0 6 6 6 22 22 22 50 50 50 7090 0 0 96 95 69 230 229 82 230 229 82 239 239 170 251 251 187
711 90 90 90 26 26 26 2 2 6 2 2 6 710241 241 143 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
712 14 14 14 195 195 195 250 250 250 253 253 253 711230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
713253 253 253 253 253 253 253 253 253 253 253 253 712230 229 82 161 156 96 36 38 35 33 37 35 33 37 35 33 37 35
714253 253 253 253 253 253 253 253 253 253 253 253 71337 39 37 47 48 46 55 57 54 55 57 54 49 51 48 43 45 43
715253 253 253 253 253 253 253 253 253 253 253 253 71443 45 43 43 45 43 40 43 41 40 43 41 37 39 37 33 37 35
716253 253 253 253 253 253 253 253 253 253 253 253 71533 37 35 28 31 30 26 28 27 16 20 20 15 18 18 14 18 18
717250 250 250 242 242 242 54 54 54 2 2 6 71614 17 17 13 16 16 12 15 15 11 14 14 12 15 15 13 17 17
718 2 2 6 2 2 6 2 2 6 2 2 6 71714 17 17 14 17 17 8 10 10 5 7 7 0 0 0 0 0 0
719 2 2 6 2 2 6 2 2 6 38 38 38 7180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
720 86 86 86 50 50 50 22 22 22 6 6 6 7190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
721 0 0 0 0 0 0 0 0 0 0 0 0 7200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
722 0 0 0 0 0 0 0 0 0 0 0 0 7210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
723 0 0 0 0 0 0 0 0 0 0 0 0 7220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
724 0 0 0 0 0 0 0 0 0 0 0 0 7230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
725 0 0 0 0 0 0 0 0 0 0 0 0 7240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
726 0 0 0 0 0 0 0 0 0 0 0 0 7250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
727 0 0 0 0 0 0 0 0 0 0 0 0 7260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
728 0 0 0 0 0 0 0 0 0 0 0 0 7270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
729 0 0 0 0 0 0 0 0 0 0 0 0 7280 0 0
730 6 6 6 14 14 14 38 38 38 82 82 82 7290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
731 34 34 34 2 2 6 2 2 6 2 2 6 7300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
732 42 42 42 195 195 195 246 246 246 253 253 253 7310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
733253 253 253 253 253 253 253 253 253 250 250 250 7320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
734242 242 242 242 242 242 250 250 250 253 253 253 7330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
735253 253 253 253 253 253 253 253 253 253 253 253 73416 17 12 230 229 82 230 229 82 243 242 120 251 251 187 251 251 187
736253 253 253 250 250 250 246 246 246 238 238 238 735246 246 123 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
737226 226 226 231 231 231 101 101 101 6 6 6 736230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
738 2 2 6 2 2 6 2 2 6 2 2 6 737230 229 82 230 229 82 66 65 55 30 32 31 32 35 33 33 37 35
739 2 2 6 2 2 6 2 2 6 2 2 6 73833 37 35 37 39 37 40 43 41 47 48 46 49 51 48 51 52 50
740 38 38 38 82 82 82 42 42 42 14 14 14 73955 57 54 55 57 54 51 52 50 47 48 46 43 45 43 39 40 39
741 6 6 6 0 0 0 0 0 0 0 0 0 74033 37 35 30 32 31 26 28 27 17 21 21 15 19 19 14 18 18
742 0 0 0 0 0 0 0 0 0 0 0 0 74114 17 17 13 16 16 12 15 15 12 14 14 11 14 14 13 16 16
743 0 0 0 0 0 0 0 0 0 0 0 0 74214 17 17 12 15 15 7 9 9 6 8 8 1 1 1 0 0 0
744 0 0 0 0 0 0 0 0 0 0 0 0 7430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
745 0 0 0 0 0 0 0 0 0 0 0 0 7440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
746 0 0 0 0 0 0 0 0 0 0 0 0 7450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
747 0 0 0 0 0 0 0 0 0 0 0 0 7460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
748 0 0 0 0 0 0 0 0 0 0 0 0 7470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
749 0 0 0 0 0 0 0 0 0 0 0 0 7480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
750 10 10 10 26 26 26 62 62 62 66 66 66 7490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
751 2 2 6 2 2 6 2 2 6 6 6 6 7500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
752 70 70 70 170 170 170 206 206 206 234 234 234 7510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
753246 246 246 250 250 250 250 250 250 238 238 238 7520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
754226 226 226 231 231 231 238 238 238 250 250 250 7530 0 0
755250 250 250 250 250 250 246 246 246 231 231 231 7540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
756214 214 214 206 206 206 202 202 202 202 202 202 7550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
757198 198 198 202 202 202 182 182 182 18 18 18 7560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
758 2 2 6 2 2 6 2 2 6 2 2 6 7570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
759 2 2 6 2 2 6 2 2 6 2 2 6 7580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
760 2 2 6 62 62 62 66 66 66 30 30 30 75996 95 69 230 229 82 230 229 82 239 239 170 251 251 187 239 239 170
761 10 10 10 0 0 0 0 0 0 0 0 0 760230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
762 0 0 0 0 0 0 0 0 0 0 0 0 761230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
763 0 0 0 0 0 0 0 0 0 0 0 0 762230 229 82 230 229 82 96 95 69 27 30 29 28 31 30 30 32 31
764 0 0 0 0 0 0 0 0 0 0 0 0 76333 37 35 40 43 41 46 47 45 55 57 54 63 64 60 72 73 67
765 0 0 0 0 0 0 0 0 0 0 0 0 76472 73 67 72 73 67 72 73 67 65 66 61 55 57 54 47 48 46
766 0 0 0 0 0 0 0 0 0 0 0 0 76539 40 39 32 35 33 27 30 29 17 21 21 15 19 19 15 18 18
767 0 0 0 0 0 0 0 0 0 0 0 0 76614 18 18 13 17 17 13 16 16 12 15 15 11 14 14 12 14 14
768 0 0 0 0 0 0 0 0 0 0 0 0 76713 16 16 9 11 11 7 9 9 9 11 11 66 65 55 115 113 82
769 0 0 0 0 0 0 0 0 0 0 0 0 76821 22 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
770 14 14 14 42 42 42 82 82 82 18 18 18 7690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
771 2 2 6 2 2 6 2 2 6 10 10 10 7700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
772 94 94 94 182 182 182 218 218 218 242 242 242 7710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
773250 250 250 253 253 253 253 253 253 250 250 250 7720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
774234 234 234 253 253 253 253 253 253 253 253 253 7730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
775253 253 253 253 253 253 253 253 253 246 246 246 7740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
776238 238 238 226 226 226 210 210 210 202 202 202 7750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
777195 195 195 195 195 195 210 210 210 158 158 158 7760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
778 6 6 6 14 14 14 50 50 50 14 14 14 7770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
779 2 2 6 2 2 6 2 2 6 2 2 6 7780 0 0
780 2 2 6 6 6 6 86 86 86 46 46 46 7790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
781 18 18 18 6 6 6 0 0 0 0 0 0 7800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
782 0 0 0 0 0 0 0 0 0 0 0 0 7810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
783 0 0 0 0 0 0 0 0 0 0 0 0 7820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
784 0 0 0 0 0 0 0 0 0 0 0 0 7830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 12 7
785 0 0 0 0 0 0 0 0 0 0 0 0 784230 229 82 230 229 82 236 236 101 251 251 187 251 251 187 246 246 123
786 0 0 0 0 0 0 0 0 0 0 0 0 785230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
787 0 0 0 0 0 0 0 0 0 0 0 0 786230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
788 0 0 0 0 0 0 0 0 0 0 0 0 787230 229 82 230 229 82 118 116 76 23 27 26 26 28 27 32 35 33
789 0 0 0 0 0 0 0 0 0 6 6 6 78851 52 50 90 89 73 110 109 94 145 141 105 168 163 120 177 172 135
790 22 22 22 54 54 54 70 70 70 2 2 6 789177 172 135 188 184 146 188 184 146 181 176 137 194 191 148 188 184 146
791 2 2 6 10 10 10 2 2 6 22 22 22 790184 179 149 188 184 146 188 184 146 156 151 111 177 172 135 181 176 137
792166 166 166 231 231 231 250 250 250 253 253 253 791177 172 135 168 163 120 168 163 120 158 153 112 156 151 111 158 153 112
793253 253 253 253 253 253 253 253 253 250 250 250 792156 151 111 158 153 112 177 172 135 188 184 146 188 184 146 194 189 146
794242 242 242 253 253 253 253 253 253 253 253 253 79336 38 35 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
795253 253 253 253 253 253 253 253 253 253 253 253 7940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
796253 253 253 253 253 253 253 253 253 246 246 246 7950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
797231 231 231 206 206 206 198 198 198 226 226 226 7960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
798 94 94 94 2 2 6 6 6 6 38 38 38 7970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
799 30 30 30 2 2 6 2 2 6 2 2 6 7980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
800 2 2 6 2 2 6 62 62 62 66 66 66 7990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
801 26 26 26 10 10 10 0 0 0 0 0 0 8000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
802 0 0 0 0 0 0 0 0 0 0 0 0 8010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
803 0 0 0 0 0 0 0 0 0 0 0 0 8020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
804 0 0 0 0 0 0 0 0 0 0 0 0 8030 0 0
805 0 0 0 0 0 0 0 0 0 0 0 0 8040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
806 0 0 0 0 0 0 0 0 0 0 0 0 8050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
807 0 0 0 0 0 0 0 0 0 0 0 0 8060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
808 0 0 0 0 0 0 0 0 0 0 0 0 8070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
809 0 0 0 0 0 0 0 0 0 10 10 10 8080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 82 81 62
810 30 30 30 74 74 74 50 50 50 2 2 6 809230 229 82 230 229 82 244 244 132 251 251 187 244 244 132 230 229 82
811 26 26 26 26 26 26 2 2 6 106 106 106 810230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
812238 238 238 253 253 253 253 253 253 253 253 253 811230 229 82 230 229 82 230 229 82 230 229 82 161 156 96 82 81 62
813253 253 253 253 253 253 253 253 253 253 253 253 81296 95 69 230 229 82 181 178 103 110 109 94 156 151 111 188 184 146
814253 253 253 253 253 253 253 253 253 253 253 253 813188 184 146 197 193 154 188 184 146 184 181 136 188 184 146 168 163 120
815253 253 253 253 253 253 253 253 253 253 253 253 814168 163 120 178 174 128 156 151 111 158 153 112 174 170 121 156 151 111
816253 253 253 253 253 253 253 253 253 253 253 253 815156 151 111 158 153 112 156 151 111 168 163 120 178 174 128 181 176 137
817253 253 253 246 246 246 218 218 218 202 202 202 816176 171 126 178 174 128 184 181 136 176 171 126 178 174 128 184 181 136
818210 210 210 14 14 14 2 2 6 2 2 6 817176 171 126 178 174 128 184 181 136 164 159 111 155 149 109 96 95 69
819 30 30 30 22 22 22 2 2 6 2 2 6 8181 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
820 2 2 6 2 2 6 18 18 18 86 86 86 8190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
821 42 42 42 14 14 14 0 0 0 0 0 0 8200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
822 0 0 0 0 0 0 0 0 0 0 0 0 8210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
823 0 0 0 0 0 0 0 0 0 0 0 0 8220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
824 0 0 0 0 0 0 0 0 0 0 0 0 8230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
825 0 0 0 0 0 0 0 0 0 0 0 0 8240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
826 0 0 0 0 0 0 0 0 0 0 0 0 8250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
827 0 0 0 0 0 0 0 0 0 0 0 0 8260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
828 0 0 0 0 0 0 0 0 0 0 0 0 8270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
829 0 0 0 0 0 0 0 0 0 14 14 14 8280 0 0
830 42 42 42 90 90 90 22 22 22 2 2 6 8290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
831 42 42 42 2 2 6 18 18 18 218 218 218 8300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
832253 253 253 253 253 253 253 253 253 253 253 253 8310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
833253 253 253 253 253 253 253 253 253 253 253 253 8320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
834253 253 253 253 253 253 253 253 253 253 253 253 8330 0 0 0 0 0 0 0 0 0 0 0 2 2 1 161 156 96
835253 253 253 253 253 253 253 253 253 253 253 253 834230 229 82 230 229 82 244 244 132 244 244 132 236 236 101 230 229 82
836253 253 253 253 253 253 253 253 253 253 253 253 835230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
837253 253 253 253 253 253 250 250 250 221 221 221 836230 229 82 230 229 82 230 229 82 230 229 82 46 47 43 82 81 62
838218 218 218 101 101 101 2 2 6 14 14 14 837158 153 112 197 193 154 194 189 146 184 181 136 188 184 146 168 163 120
839 18 18 18 38 38 38 10 10 10 2 2 6 838156 151 111 137 133 100 131 127 93 137 133 100 137 133 100 158 153 112
840 2 2 6 2 2 6 2 2 6 78 78 78 839121 119 87 137 133 100 156 151 111 145 141 105 99 98 80 84 83 72
841 58 58 58 22 22 22 6 6 6 0 0 0 84063 64 60 52 53 49 40 43 41 33 36 34 36 38 35 36 38 35
842 0 0 0 0 0 0 0 0 0 0 0 0 84138 39 37 43 44 41 43 44 41 46 47 43 48 49 45 48 49 45
843 0 0 0 0 0 0 0 0 0 0 0 0 84246 47 43 36 38 35 30 31 28 19 20 18 6 7 7 0 0 0
844 0 0 0 0 0 0 0 0 0 0 0 0 8430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
845 0 0 0 0 0 0 0 0 0 0 0 0 8440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
846 0 0 0 0 0 0 0 0 0 0 0 0 8450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
847 0 0 0 0 0 0 0 0 0 0 0 0 8460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
848 0 0 0 0 0 0 0 0 0 0 0 0 8470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
849 0 0 0 0 0 0 6 6 6 18 18 18 8480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
850 54 54 54 82 82 82 2 2 6 26 26 26 8490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
851 22 22 22 2 2 6 123 123 123 253 253 253 8500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
852253 253 253 253 253 253 253 253 253 253 253 253 8510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
853253 253 253 253 253 253 253 253 253 253 253 253 8520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
854253 253 253 253 253 253 253 253 253 253 253 253 8530 0 0
855253 253 253 253 253 253 253 253 253 253 253 253 8540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
856253 253 253 253 253 253 253 253 253 253 253 253 8550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
857253 253 253 253 253 253 253 253 253 250 250 250 8560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
858238 238 238 198 198 198 6 6 6 38 38 38 8570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
859 58 58 58 26 26 26 38 38 38 2 2 6 8580 0 0 0 0 0 0 0 0 0 0 0 36 38 35 230 229 82
860 2 2 6 2 2 6 2 2 6 46 46 46 859230 229 82 230 229 82 246 246 123 236 236 101 230 229 82 230 229 82
861 78 78 78 30 30 30 10 10 10 0 0 0 860230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
862 0 0 0 0 0 0 0 0 0 0 0 0 861230 229 82 230 229 82 230 229 82 230 229 82 53 55 47 121 119 87
863 0 0 0 0 0 0 0 0 0 0 0 0 862176 171 126 171 165 117 161 156 96 82 81 62 53 55 47 33 37 35
864 0 0 0 0 0 0 0 0 0 0 0 0 86339 40 39 63 64 60 99 98 80 121 119 87 137 133 100 177 172 135
865 0 0 0 0 0 0 0 0 0 0 0 0 864176 171 126 184 181 136 131 127 93 131 127 93 110 109 94 84 83 72
866 0 0 0 0 0 0 0 0 0 0 0 0 86551 52 50 39 40 39 27 29 28 18 22 22 16 19 19 15 19 19
867 0 0 0 0 0 0 0 0 0 0 0 0 86615 19 19 14 18 18 14 17 17 13 16 16 12 15 15 11 14 14
868 0 0 0 0 0 0 0 0 0 0 0 0 86710 13 13 9 12 12 9 11 11 8 9 9 7 9 9 1 1 1
869 0 0 0 0 0 0 10 10 10 30 30 30 8680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
870 74 74 74 58 58 58 2 2 6 42 42 42 8690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
871 2 2 6 22 22 22 231 231 231 253 253 253 8700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
872253 253 253 253 253 253 253 253 253 253 253 253 8710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
873253 253 253 253 253 253 253 253 253 250 250 250 8720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
874253 253 253 253 253 253 253 253 253 253 253 253 8730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
875253 253 253 253 253 253 253 253 253 253 253 253 8740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
876253 253 253 253 253 253 253 253 253 253 253 253 8750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
877253 253 253 253 253 253 253 253 253 253 253 253 8760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
878253 253 253 246 246 246 46 46 46 38 38 38 8770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
879 42 42 42 14 14 14 38 38 38 14 14 14 8780 0 0
880 2 2 6 2 2 6 2 2 6 6 6 6 8790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
881 86 86 86 46 46 46 14 14 14 0 0 0 8800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
882 0 0 0 0 0 0 0 0 0 0 0 0 8810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
883 0 0 0 0 0 0 0 0 0 0 0 0 8820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
884 0 0 0 0 0 0 0 0 0 0 0 0 8830 0 0 0 0 0 0 0 0 0 0 0 118 116 76 230 229 82
885 0 0 0 0 0 0 0 0 0 0 0 0 884230 229 82 230 229 82 236 236 101 230 229 82 230 229 82 230 229 82
886 0 0 0 0 0 0 0 0 0 0 0 0 885230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
887 0 0 0 0 0 0 0 0 0 0 0 0 886230 229 82 230 229 82 230 229 82 230 229 82 96 95 69 71 71 57
888 0 0 0 0 0 0 0 0 0 0 0 0 88736 38 35 118 116 76 118 116 76 12 15 15 15 18 18 20 24 24
889 0 0 0 6 6 6 14 14 14 42 42 42 88833 37 35 55 56 53 84 83 72 110 109 94 145 141 105 110 109 94
890 90 90 90 18 18 18 18 18 18 26 26 26 889168 163 120 121 119 87 156 151 111 131 127 93 87 86 72 61 63 57
891 2 2 6 116 116 116 253 253 253 253 253 253 89047 48 46 28 31 30 18 22 22 15 19 19 15 18 18 15 19 19
892253 253 253 253 253 253 253 253 253 253 253 253 89115 19 19 14 18 18 14 17 17 13 17 17 13 16 16 12 15 15
893253 253 253 253 253 253 250 250 250 238 238 238 89211 13 13 10 12 12 9 11 11 8 10 10 7 9 9 3 3 3
894253 253 253 253 253 253 253 253 253 253 253 253 8930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
895253 253 253 253 253 253 253 253 253 253 253 253 8940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
896253 253 253 253 253 253 253 253 253 253 253 253 8950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
897253 253 253 253 253 253 253 253 253 253 253 253 8960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
898253 253 253 253 253 253 94 94 94 6 6 6 8970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
899 2 2 6 2 2 6 10 10 10 34 34 34 8980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
900 2 2 6 2 2 6 2 2 6 2 2 6 8990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
901 74 74 74 58 58 58 22 22 22 6 6 6 9000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
902 0 0 0 0 0 0 0 0 0 0 0 0 9010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
903 0 0 0 0 0 0 0 0 0 0 0 0 9020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
904 0 0 0 0 0 0 0 0 0 0 0 0 9030 0 0
905 0 0 0 0 0 0 0 0 0 0 0 0 9040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
906 0 0 0 0 0 0 0 0 0 0 0 0 9050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
907 0 0 0 0 0 0 0 0 0 0 0 0 9060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
908 0 0 0 0 0 0 0 0 0 0 0 0 9070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
909 0 0 0 10 10 10 26 26 26 66 66 66 9080 0 0 0 0 0 0 0 0 1 1 0 230 229 82 230 229 82
910 82 82 82 2 2 6 38 38 38 6 6 6 909230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
911 14 14 14 210 210 210 253 253 253 253 253 253 910230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
912253 253 253 253 253 253 253 253 253 253 253 253 911230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 161 156 96
913253 253 253 253 253 253 246 246 246 242 242 242 912161 156 96 230 229 82 118 116 76 11 14 14 14 17 17 18 22 22
914253 253 253 253 253 253 253 253 253 253 253 253 91327 30 29 40 43 41 60 60 56 84 83 72 105 104 92 110 109 94
915253 253 253 253 253 253 253 253 253 253 253 253 914110 109 94 110 109 94 99 98 80 90 89 73 68 70 65 47 48 46
916253 253 253 253 253 253 253 253 253 253 253 253 91532 34 33 23 25 24 20 23 23 17 21 21 15 19 19 14 17 17
917253 253 253 253 253 253 253 253 253 253 253 253 91615 19 19 15 18 18 14 18 18 13 17 17 13 16 16 12 15 15
918253 253 253 253 253 253 144 144 144 2 2 6 91711 14 14 10 12 12 9 11 11 8 10 10 7 9 9 4 5 5
919 2 2 6 2 2 6 2 2 6 46 46 46 9180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
920 2 2 6 2 2 6 2 2 6 2 2 6 9190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
921 42 42 42 74 74 74 30 30 30 10 10 10 9200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
922 0 0 0 0 0 0 0 0 0 0 0 0 9210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
923 0 0 0 0 0 0 0 0 0 0 0 0 9220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
924 0 0 0 0 0 0 0 0 0 0 0 0 9230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
925 0 0 0 0 0 0 0 0 0 0 0 0 9240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
926 0 0 0 0 0 0 0 0 0 0 0 0 9250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
927 0 0 0 0 0 0 0 0 0 0 0 0 9260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
928 0 0 0 0 0 0 0 0 0 0 0 0 9270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
929 6 6 6 14 14 14 42 42 42 90 90 90 9280 0 0
930 26 26 26 6 6 6 42 42 42 2 2 6 9290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
931 74 74 74 250 250 250 253 253 253 253 253 253 9300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
932253 253 253 253 253 253 253 253 253 253 253 253 9310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
933253 253 253 253 253 253 242 242 242 242 242 242 9320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
934253 253 253 253 253 253 253 253 253 253 253 253 9330 0 0 0 0 0 0 0 0 16 17 12 230 229 82 230 229 82
935253 253 253 253 253 253 253 253 253 253 253 253 934230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
936253 253 253 253 253 253 253 253 253 253 253 253 935230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
937253 253 253 253 253 253 253 253 253 253 253 253 936230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
938253 253 253 253 253 253 182 182 182 2 2 6 937230 229 82 161 156 96 118 116 76 11 13 13 13 16 16 15 19 19
939 2 2 6 2 2 6 2 2 6 46 46 46 93820 24 24 30 32 31 40 43 41 51 52 50 63 64 60 72 73 67
940 2 2 6 2 2 6 2 2 6 2 2 6 93965 66 61 65 66 61 65 66 61 55 57 54 46 47 45 33 37 35
941 10 10 10 86 86 86 38 38 38 10 10 10 94027 29 28 20 24 24 17 21 21 16 20 20 16 20 20 15 19 19
942 0 0 0 0 0 0 0 0 0 0 0 0 94115 19 19 15 19 19 14 18 18 14 17 17 13 16 16 12 15 15
943 0 0 0 0 0 0 0 0 0 0 0 0 94211 14 14 10 13 13 9 12 12 8 10 10 7 9 9 6 7 7
944 0 0 0 0 0 0 0 0 0 0 0 0 9430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
945 0 0 0 0 0 0 0 0 0 0 0 0 9440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
946 0 0 0 0 0 0 0 0 0 0 0 0 9450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
947 0 0 0 0 0 0 0 0 0 0 0 0 9460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
948 0 0 0 0 0 0 0 0 0 0 0 0 9470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
949 10 10 10 26 26 26 66 66 66 82 82 82 9480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
950 2 2 6 22 22 22 18 18 18 2 2 6 9490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
951149 149 149 253 253 253 253 253 253 253 253 253 9500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
952253 253 253 253 253 253 253 253 253 253 253 253 9510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
953253 253 253 253 253 253 234 234 234 242 242 242 9520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
954253 253 253 253 253 253 253 253 253 253 253 253 9530 0 0
955253 253 253 253 253 253 253 253 253 253 253 253 9540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
956253 253 253 253 253 253 253 253 253 253 253 253 9550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
957253 253 253 253 253 253 253 253 253 253 253 253 9560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
958253 253 253 253 253 253 206 206 206 2 2 6 9570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
959 2 2 6 2 2 6 2 2 6 38 38 38 9580 0 0 0 0 0 0 0 0 53 55 47 230 229 82 230 229 82
960 2 2 6 2 2 6 2 2 6 2 2 6 959230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
961 6 6 6 86 86 86 46 46 46 14 14 14 960230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
962 0 0 0 0 0 0 0 0 0 0 0 0 961230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
963 0 0 0 0 0 0 0 0 0 0 0 0 962161 156 96 118 116 76 53 55 47 10 13 13 12 15 15 14 17 17
964 0 0 0 0 0 0 0 0 0 0 0 0 96317 20 20 20 24 24 27 29 28 32 34 33 37 39 37 40 43 41
965 0 0 0 0 0 0 0 0 0 0 0 0 96443 45 43 41 42 42 35 37 36 30 32 31 28 31 30 23 27 26
966 0 0 0 0 0 0 0 0 0 0 0 0 96520 23 23 17 21 21 16 20 20 16 20 20 16 20 20 16 19 19
967 0 0 0 0 0 0 0 0 0 0 0 0 96615 19 19 15 19 19 14 18 18 14 17 17 13 16 16 12 15 15
968 0 0 0 0 0 0 0 0 0 6 6 6 96711 14 14 10 13 13 9 12 12 9 11 11 8 10 10 10 12 12
969 18 18 18 46 46 46 86 86 86 18 18 18 9681 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
970 2 2 6 34 34 34 10 10 10 6 6 6 9690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
971210 210 210 253 253 253 253 253 253 253 253 253 9700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
972253 253 253 253 253 253 253 253 253 253 253 253 9710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
973253 253 253 253 253 253 234 234 234 242 242 242 9720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
974253 253 253 253 253 253 253 253 253 253 253 253 9730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
975253 253 253 253 253 253 253 253 253 253 253 253 9740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
976253 253 253 253 253 253 253 253 253 253 253 253 9750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
977253 253 253 253 253 253 253 253 253 253 253 253 9760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
978253 253 253 253 253 253 221 221 221 6 6 6 9770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
979 2 2 6 2 2 6 6 6 6 30 30 30 9780 0 0
980 2 2 6 2 2 6 2 2 6 2 2 6 9790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
981 2 2 6 82 82 82 54 54 54 18 18 18 9800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
982 6 6 6 0 0 0 0 0 0 0 0 0 9810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
983 0 0 0 0 0 0 0 0 0 0 0 0 9820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
984 0 0 0 0 0 0 0 0 0 0 0 0 9830 0 0 0 0 0 0 0 0 82 81 62 230 229 82 230 229 82
985 0 0 0 0 0 0 0 0 0 0 0 0 984230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
986 0 0 0 0 0 0 0 0 0 0 0 0 985230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
987 0 0 0 0 0 0 0 0 0 0 0 0 986230 229 82 230 229 82 230 229 82 230 229 82 161 156 96 161 156 96
988 0 0 0 0 0 0 0 0 0 10 10 10 987118 116 76 82 81 62 13 14 12 10 13 13 12 15 15 13 17 17
989 26 26 26 66 66 66 62 62 62 2 2 6 98815 19 19 16 20 20 20 23 23 20 24 24 23 27 26 26 28 27
990 2 2 6 38 38 38 10 10 10 26 26 26 98926 28 27 26 28 27 23 27 26 18 22 22 20 23 23 17 21 21
991238 238 238 253 253 253 253 253 253 253 253 253 99017 21 21 16 20 20 16 20 20 16 20 20 16 20 20 16 19 19
992253 253 253 253 253 253 253 253 253 253 253 253 99115 19 19 15 19 19 15 18 18 14 17 17 13 17 17 13 16 16
993253 253 253 253 253 253 231 231 231 238 238 238 99212 15 15 12 14 14 12 14 14 12 14 14 12 14 14 23 24 24
994253 253 253 253 253 253 253 253 253 253 253 253 9936 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
995253 253 253 253 253 253 253 253 253 253 253 253 9940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
996253 253 253 253 253 253 253 253 253 253 253 253 9950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
997253 253 253 253 253 253 253 253 253 253 253 253 9960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
998253 253 253 253 253 253 231 231 231 6 6 6 9970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
999 2 2 6 2 2 6 10 10 10 30 30 30 9980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1000 2 2 6 2 2 6 2 2 6 2 2 6 9990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1001 2 2 6 66 66 66 58 58 58 22 22 22 10000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1002 6 6 6 0 0 0 0 0 0 0 0 0 10010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1003 0 0 0 0 0 0 0 0 0 0 0 0 10020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1004 0 0 0 0 0 0 0 0 0 0 0 0 10030 0 0
1005 0 0 0 0 0 0 0 0 0 0 0 0 10040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1006 0 0 0 0 0 0 0 0 0 0 0 0 10050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1007 0 0 0 0 0 0 0 0 0 0 0 0 10060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1008 0 0 0 0 0 0 0 0 0 10 10 10 10070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1009 38 38 38 78 78 78 6 6 6 2 2 6 10080 0 0 0 0 0 0 0 0 118 116 76 230 229 82 230 229 82
1010 2 2 6 46 46 46 14 14 14 42 42 42 1009230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
1011246 246 246 253 253 253 253 253 253 253 253 253 1010230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
1012253 253 253 253 253 253 253 253 253 253 253 253 1011230 229 82 230 229 82 230 229 82 161 156 96 161 156 96 118 116 76
1013253 253 253 253 253 253 231 231 231 242 242 242 101271 71 57 13 14 12 9 12 12 10 13 13 12 15 15 13 17 17
1014253 253 253 253 253 253 253 253 253 253 253 253 101315 18 18 15 19 19 16 20 20 17 21 21 17 21 21 18 22 22
1015253 253 253 253 253 253 253 253 253 253 253 253 101418 22 22 18 22 22 17 21 21 16 19 19 15 18 18 14 18 18
1016253 253 253 253 253 253 253 253 253 253 253 253 101516 19 19 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1017253 253 253 253 253 253 253 253 253 253 253 253 101615 19 19 15 19 19 15 18 18 14 18 18 16 20 20 23 25 24
1018253 253 253 253 253 253 234 234 234 10 10 10 101717 21 21 25 27 26 47 48 46 47 48 46 51 52 50 72 73 67
1019 2 2 6 2 2 6 22 22 22 14 14 14 101833 36 34 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1020 2 2 6 2 2 6 2 2 6 2 2 6 10190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1021 2 2 6 66 66 66 62 62 62 22 22 22 10200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1022 6 6 6 0 0 0 0 0 0 0 0 0 10210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1023 0 0 0 0 0 0 0 0 0 0 0 0 10220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1024 0 0 0 0 0 0 0 0 0 0 0 0 10230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1025 0 0 0 0 0 0 0 0 0 0 0 0 10240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1026 0 0 0 0 0 0 0 0 0 0 0 0 10250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1027 0 0 0 0 0 0 0 0 0 0 0 0 10260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1028 0 0 0 0 0 0 6 6 6 18 18 18 10270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1029 50 50 50 74 74 74 2 2 6 2 2 6 10280 0 0
1030 14 14 14 70 70 70 34 34 34 62 62 62 10290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1031250 250 250 253 253 253 253 253 253 253 253 253 10300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1032253 253 253 253 253 253 253 253 253 253 253 253 10310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1033253 253 253 253 253 253 231 231 231 246 246 246 10320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1034253 253 253 253 253 253 253 253 253 253 253 253 10330 0 0 0 0 0 0 0 0 118 116 76 230 229 82 230 229 82
1035253 253 253 253 253 253 253 253 253 253 253 253 1034230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
1036253 253 253 253 253 253 253 253 253 253 253 253 1035230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
1037253 253 253 253 253 253 253 253 253 253 253 253 1036230 229 82 230 229 82 161 156 96 118 116 76 118 116 76 46 47 43
1038253 253 253 253 253 253 234 234 234 14 14 14 10379 11 11 9 11 11 10 12 12 11 13 13 12 15 15 14 17 17
1039 2 2 6 2 2 6 30 30 30 2 2 6 103815 18 18 15 19 19 16 20 20 16 20 20 16 20 20 16 20 20
1040 2 2 6 2 2 6 2 2 6 2 2 6 103916 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1041 2 2 6 66 66 66 62 62 62 22 22 22 104015 19 19 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1042 6 6 6 0 0 0 0 0 0 0 0 0 104115 19 19 16 20 20 20 24 24 55 56 53 32 34 33 84 83 72
1043 0 0 0 0 0 0 0 0 0 0 0 0 104290 89 73 110 109 94 110 109 94 105 104 92 110 109 94 110 109 94
1044 0 0 0 0 0 0 0 0 0 0 0 0 104372 73 67 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1045 0 0 0 0 0 0 0 0 0 0 0 0 10440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1046 0 0 0 0 0 0 0 0 0 0 0 0 10450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1047 0 0 0 0 0 0 0 0 0 0 0 0 10460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1048 0 0 0 0 0 0 6 6 6 18 18 18 10470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1049 54 54 54 62 62 62 2 2 6 2 2 6 10480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1050 2 2 6 30 30 30 46 46 46 70 70 70 10490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1051250 250 250 253 253 253 253 253 253 253 253 253 10500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1052253 253 253 253 253 253 253 253 253 253 253 253 10510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1053253 253 253 253 253 253 231 231 231 246 246 246 10520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1054253 253 253 253 253 253 253 253 253 253 253 253 10530 0 0
1055253 253 253 253 253 253 253 253 253 253 253 253 10540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1056253 253 253 253 253 253 253 253 253 253 253 253 10550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1057253 253 253 253 253 253 253 253 253 253 253 253 10560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1058253 253 253 253 253 253 226 226 226 10 10 10 10570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1059 2 2 6 6 6 6 30 30 30 2 2 6 10580 0 0 0 0 0 0 0 0 96 95 69 230 229 82 230 229 82
1060 2 2 6 2 2 6 2 2 6 2 2 6 1059230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
1061 2 2 6 66 66 66 58 58 58 22 22 22 1060230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
1062 6 6 6 0 0 0 0 0 0 0 0 0 1061230 229 82 161 156 96 118 116 76 82 81 62 16 17 12 9 11 11
1063 0 0 0 0 0 0 0 0 0 0 0 0 10629 11 11 9 12 12 10 13 13 12 14 14 13 16 16 14 18 18
1064 0 0 0 0 0 0 0 0 0 0 0 0 106315 19 19 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1065 0 0 0 0 0 0 0 0 0 0 0 0 106416 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1066 0 0 0 0 0 0 0 0 0 0 0 0 106516 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1067 0 0 0 0 0 0 0 0 0 0 0 0 106616 19 19 33 36 34 99 98 80 156 151 111 145 141 105 184 179 149
1068 0 0 0 0 0 0 6 6 6 22 22 22 1067168 163 120 184 179 149 177 172 135 156 151 111 145 141 105 110 109 94
1069 58 58 58 62 62 62 2 2 6 2 2 6 106890 89 73 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0
1070 2 2 6 2 2 6 30 30 30 78 78 78 10690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1071250 250 250 253 253 253 253 253 253 253 253 253 10700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1072253 253 253 253 253 253 253 253 253 253 253 253 10710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1073253 253 253 253 253 253 231 231 231 246 246 246 10720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1074253 253 253 253 253 253 253 253 253 253 253 253 10730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1075253 253 253 253 253 253 253 253 253 253 253 253 10740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1076253 253 253 253 253 253 253 253 253 253 253 253 10750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1077253 253 253 253 253 253 253 253 253 253 253 253 10760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1078253 253 253 253 253 253 206 206 206 2 2 6 10770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1079 22 22 22 34 34 34 18 14 6 22 22 22 10780 0 0
1080 26 26 26 18 18 18 6 6 6 2 2 6 10790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1081 2 2 6 82 82 82 54 54 54 18 18 18 10800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1082 6 6 6 0 0 0 0 0 0 0 0 0 10810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1083 0 0 0 0 0 0 0 0 0 0 0 0 10820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1084 0 0 0 0 0 0 0 0 0 0 0 0 10830 0 0 0 0 0 0 0 0 71 71 57 230 229 82 230 229 82
1085 0 0 0 0 0 0 0 0 0 0 0 0 1084230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 230 229 82
1086 0 0 0 0 0 0 0 0 0 0 0 0 1085230 229 82 161 156 96 230 229 82 230 229 82 230 229 82 161 156 96
1087 0 0 0 0 0 0 0 0 0 0 0 0 1086118 116 76 82 81 62 30 31 28 9 11 11 9 11 11 9 11 11
1088 0 0 0 0 0 0 6 6 6 26 26 26 108710 12 12 10 13 13 11 14 14 13 16 16 14 17 17 15 18 18
1089 62 62 62 106 106 106 74 54 14 185 133 11 108815 19 19 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1090210 162 10 121 92 8 6 6 6 62 62 62 108916 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1091238 238 238 253 253 253 253 253 253 253 253 253 109016 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1092253 253 253 253 253 253 253 253 253 253 253 253 109118 22 22 58 59 55 137 133 100 197 193 154 214 212 158 210 208 158
1093253 253 253 253 253 253 231 231 231 246 246 246 1092197 193 154 184 179 149 184 179 149 137 133 100 110 109 94 99 98 80
1094253 253 253 253 253 253 253 253 253 253 253 253 109384 83 72 10 10 9 0 0 0 0 0 0 0 0 0 0 0 0
1095253 253 253 253 253 253 253 253 253 253 253 253 10940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1096253 253 253 253 253 253 253 253 253 253 253 253 10950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1097253 253 253 253 253 253 253 253 253 253 253 253 10960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1098253 253 253 253 253 253 158 158 158 18 18 18 10970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1099 14 14 14 2 2 6 2 2 6 2 2 6 10980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1100 6 6 6 18 18 18 66 66 66 38 38 38 10990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1101 6 6 6 94 94 94 50 50 50 18 18 18 11000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1102 6 6 6 0 0 0 0 0 0 0 0 0 11010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1103 0 0 0 0 0 0 0 0 0 0 0 0 11020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1104 0 0 0 0 0 0 0 0 0 0 0 0 11030 0 0
1105 0 0 0 0 0 0 0 0 0 0 0 0 11040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1106 0 0 0 0 0 0 0 0 0 0 0 0 11050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1107 0 0 0 0 0 0 0 0 0 6 6 6 11060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1108 10 10 10 10 10 10 18 18 18 38 38 38 11070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1109 78 78 78 142 134 106 216 158 10 242 186 14 11080 0 0 0 0 0 0 0 0 16 17 12 230 229 82 230 229 82
1110246 190 14 246 190 14 156 118 10 10 10 10 1109230 229 82 230 229 82 230 229 82 230 229 82 230 229 82 161 156 96
1111 90 90 90 238 238 238 253 253 253 253 253 253 1110161 156 96 161 156 96 161 156 96 161 156 96 118 116 76 71 71 57
1112253 253 253 253 253 253 253 253 253 253 253 253 111121 22 20 12 14 14 11 13 13 10 12 12 10 12 12 10 13 13
1113253 253 253 253 253 253 231 231 231 250 250 250 111211 13 13 12 15 15 13 16 16 14 17 17 14 18 18 15 19 19
1114253 253 253 253 253 253 253 253 253 253 253 253 111316 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1115253 253 253 253 253 253 253 253 253 253 253 253 111416 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1116253 253 253 253 253 253 253 253 253 253 253 253 111516 20 20 16 20 20 16 20 20 16 20 20 16 20 20 17 21 21
1117253 253 253 253 253 253 253 253 253 246 230 190 111623 27 26 84 83 72 184 179 149 251 251 187 210 208 158 184 179 149
1118238 204 91 238 204 91 181 142 44 37 26 9 1117184 179 149 156 151 111 110 109 94 84 83 72 63 64 60 51 52 50
1119 2 2 6 2 2 6 2 2 6 2 2 6 111818 22 22 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0
1120 2 2 6 2 2 6 38 38 38 46 46 46 11190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1121 26 26 26 106 106 106 54 54 54 18 18 18 11200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1122 6 6 6 0 0 0 0 0 0 0 0 0 11210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1123 0 0 0 0 0 0 0 0 0 0 0 0 11220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1124 0 0 0 0 0 0 0 0 0 0 0 0 11230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1125 0 0 0 0 0 0 0 0 0 0 0 0 11240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1126 0 0 0 0 0 0 0 0 0 0 0 0 11250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1127 0 0 0 6 6 6 14 14 14 22 22 22 11260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1128 30 30 30 38 38 38 50 50 50 70 70 70 11270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1129106 106 106 190 142 34 226 170 11 242 186 14 11280 0 0
1130246 190 14 246 190 14 246 190 14 154 114 10 11290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1131 6 6 6 74 74 74 226 226 226 253 253 253 11300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1132253 253 253 253 253 253 253 253 253 253 253 253 11310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1133253 253 253 253 253 253 231 231 231 250 250 250 11320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1134253 253 253 253 253 253 253 253 253 253 253 253 11330 0 0 0 0 0 0 0 0 0 0 0 118 116 76 230 229 82
1135253 253 253 253 253 253 253 253 253 253 253 253 1134230 229 82 230 229 82 230 229 82 230 229 82 161 156 96 161 156 96
1136253 253 253 253 253 253 253 253 253 253 253 253 1135161 156 96 161 156 96 118 116 76 53 55 47 20 23 22 16 19 19
1137253 253 253 253 253 253 253 253 253 228 184 62 113613 16 16 12 15 15 12 14 14 11 14 14 11 14 14 11 14 14
1138241 196 14 241 208 19 232 195 16 38 30 10 113712 15 15 13 16 16 14 17 17 15 19 19 16 20 20 17 21 21
1139 2 2 6 2 2 6 2 2 6 2 2 6 113823 27 26 18 22 22 20 24 24 23 27 26 30 32 31 17 21 21
1140 2 2 6 6 6 6 30 30 30 26 26 26 113916 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1141203 166 17 154 142 90 66 66 66 26 26 26 114016 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1142 6 6 6 0 0 0 0 0 0 0 0 0 114123 27 26 33 37 35 137 133 100 156 151 111 158 153 112 105 104 92
1143 0 0 0 0 0 0 0 0 0 0 0 0 1142105 104 92 68 70 65 39 40 39 18 22 22 12 14 14 12 15 15
1144 0 0 0 0 0 0 0 0 0 0 0 0 11439 11 11 4 5 5 0 0 0 0 0 0 0 0 0 0 0 0
1145 0 0 0 0 0 0 0 0 0 0 0 0 11440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1146 0 0 0 0 0 0 0 0 0 0 0 0 11450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1147 6 6 6 18 18 18 38 38 38 58 58 58 11460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1148 78 78 78 86 86 86 101 101 101 123 123 123 11470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1149175 146 61 210 150 10 234 174 13 246 186 14 11480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1150246 190 14 246 190 14 246 190 14 238 190 10 11490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1151102 78 10 2 2 6 46 46 46 198 198 198 11500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1152253 253 253 253 253 253 253 253 253 253 253 253 11510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1153253 253 253 253 253 253 234 234 234 242 242 242 11520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1154253 253 253 253 253 253 253 253 253 253 253 253 11530 0 0
1155253 253 253 253 253 253 253 253 253 253 253 253 11540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1156253 253 253 253 253 253 253 253 253 253 253 253 11550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1157253 253 253 253 253 253 253 253 253 224 178 62 11560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1158242 186 14 241 196 14 210 166 10 22 18 6 11570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1159 2 2 6 2 2 6 2 2 6 2 2 6 11580 0 0 0 0 0 0 0 0 0 0 0 16 17 12 230 229 82
1160 2 2 6 2 2 6 6 6 6 121 92 8 1159230 229 82 230 229 82 230 229 82 161 156 96 118 116 76 118 116 76
1161238 202 15 232 195 16 82 82 82 34 34 34 1160118 116 76 66 65 55 43 45 43 32 34 33 25 27 26 20 23 22
1162 10 10 10 0 0 0 0 0 0 0 0 0 116117 20 20 15 18 18 14 17 17 15 18 18 13 16 16 14 17 17
1163 0 0 0 0 0 0 0 0 0 0 0 0 116214 18 18 16 20 20 32 34 33 55 57 54 58 59 55 72 73 67
1164 0 0 0 0 0 0 0 0 0 0 0 0 1163105 104 92 55 57 54 65 66 61 63 64 60 40 43 41 33 37 35
1165 0 0 0 0 0 0 0 0 0 0 0 0 116441 42 42 20 24 24 16 20 20 16 20 20 16 20 20 16 20 20
1166 0 0 0 0 0 0 0 0 0 0 0 0 116516 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1167 14 14 14 38 38 38 70 70 70 154 122 46 116617 21 21 26 28 27 30 32 31 35 37 36 68 70 65 39 40 39
1168190 142 34 200 144 11 197 138 11 197 138 11 116723 27 26 15 18 18 13 16 16 11 14 14 9 12 12 8 10 10
1169213 154 11 226 170 11 242 186 14 246 190 14 11687 9 9 6 7 7 0 0 0 0 0 0 0 0 0 0 0 0
1170246 190 14 246 190 14 246 190 14 246 190 14 11690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1171225 175 15 46 32 6 2 2 6 22 22 22 11700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1172158 158 158 250 250 250 253 253 253 253 253 253 11710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1173253 253 253 253 253 253 253 253 253 253 253 253 11720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1174253 253 253 253 253 253 253 253 253 253 253 253 11730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1175253 253 253 253 253 253 253 253 253 253 253 253 11740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1176253 253 253 253 253 253 253 253 253 253 253 253 11750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1177253 253 253 250 250 250 242 242 242 224 178 62 11760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1178239 182 13 236 186 11 213 154 11 46 32 6 11770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1179 2 2 6 2 2 6 2 2 6 2 2 6 11780 0 0
1180 2 2 6 2 2 6 61 42 6 225 175 15 11790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1181238 190 10 236 186 11 112 100 78 42 42 42 11800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1182 14 14 14 0 0 0 0 0 0 0 0 0 11810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1183 0 0 0 0 0 0 0 0 0 0 0 0 11820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1184 0 0 0 0 0 0 0 0 0 0 0 0 11830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 38 35
1185 0 0 0 0 0 0 0 0 0 0 0 0 1184230 229 82 230 229 82 230 229 82 96 95 69 30 31 28 49 51 48
1186 0 0 0 0 0 0 0 0 0 6 6 6 118590 89 73 68 70 65 55 57 54 47 48 46 47 48 46 43 45 43
1187 22 22 22 54 54 54 154 122 46 213 154 11 118632 34 33 43 45 43 43 45 43 23 27 26 25 27 26 40 43 41
1188226 170 11 230 174 11 226 170 11 226 170 11 118740 43 41 90 89 73 110 109 94 145 141 105 156 151 111 156 151 111
1189236 178 12 242 186 14 246 190 14 246 190 14 1188184 179 149 184 179 149 177 172 135 184 179 149 137 133 100 84 83 72
1190246 190 14 246 190 14 246 190 14 246 190 14 1189105 104 92 63 64 60 49 51 48 47 48 46 28 31 30 18 22 22
1191241 196 14 184 144 12 10 10 10 2 2 6 119016 20 20 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1192 6 6 6 116 116 116 242 242 242 253 253 253 119116 20 20 15 19 19 15 19 19 15 19 19 18 22 22 15 19 19
1193253 253 253 253 253 253 253 253 253 253 253 253 119213 16 16 12 15 15 11 14 14 10 13 13 9 12 12 9 11 11
1194253 253 253 253 253 253 253 253 253 253 253 253 11938 10 10 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0
1195253 253 253 253 253 253 253 253 253 253 253 253 11940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1196253 253 253 253 253 253 253 253 253 253 253 253 11950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1197253 253 253 231 231 231 198 198 198 214 170 54 11960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1198236 178 12 236 178 12 210 150 10 137 92 6 11970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1199 18 14 6 2 2 6 2 2 6 2 2 6 11980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1200 6 6 6 70 47 6 200 144 11 236 178 12 11990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1201239 182 13 239 182 13 124 112 88 58 58 58 12000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1202 22 22 22 6 6 6 0 0 0 0 0 0 12010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1203 0 0 0 0 0 0 0 0 0 0 0 0 12020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1204 0 0 0 0 0 0 0 0 0 0 0 0 12030 0 0
1205 0 0 0 0 0 0 0 0 0 0 0 0 12040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1206 0 0 0 0 0 0 0 0 0 10 10 10 12050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1207 30 30 30 70 70 70 180 133 36 226 170 11 12060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1208239 182 13 242 186 14 242 186 14 246 186 14 12070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1209246 190 14 246 190 14 246 190 14 246 190 14 12080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1210246 190 14 246 190 14 246 190 14 246 190 14 120930 31 28 230 229 82 71 71 57 2 2 1 0 0 0 58 59 55
1211246 190 14 232 195 16 98 70 6 2 2 6 1210105 104 92 84 83 72 65 66 61 84 83 72 110 109 94 110 109 94
1212 2 2 6 2 2 6 66 66 66 221 221 221 1211145 141 105 105 104 92 110 109 94 110 109 94 84 83 72 110 109 94
1213253 253 253 253 253 253 253 253 253 253 253 253 1212158 153 112 197 193 154 197 193 154 239 239 170 251 251 187 251 251 187
1214253 253 253 253 253 253 253 253 253 253 253 253 1213251 251 187 251 251 187 251 251 187 251 251 187 210 208 158 197 193 154
1215253 253 253 253 253 253 253 253 253 253 253 253 1214197 193 154 184 179 149 145 141 105 137 133 100 105 104 92 47 48 46
1216253 253 253 253 253 253 253 253 253 253 253 253 121520 23 23 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1217253 253 253 206 206 206 198 198 198 214 166 58 121616 20 20 16 19 19 15 19 19 15 19 19 14 18 18 14 17 17
1218230 174 11 230 174 11 216 158 10 192 133 9 121713 17 17 13 16 16 12 14 14 12 14 14 13 13 13 13 13 13
1219163 110 8 116 81 8 102 78 10 116 81 8 121813 13 13 12 12 12 10 10 9 6 7 7 2 2 2 0 0 0
1220167 114 7 197 138 11 226 170 11 239 182 13 12190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1221242 186 14 242 186 14 162 146 94 78 78 78 12200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1222 34 34 34 14 14 14 6 6 6 0 0 0 12210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1223 0 0 0 0 0 0 0 0 0 0 0 0 12220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1224 0 0 0 0 0 0 0 0 0 0 0 0 12230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1225 0 0 0 0 0 0 0 0 0 0 0 0 12240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1226 0 0 0 0 0 0 0 0 0 6 6 6 12250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1227 30 30 30 78 78 78 190 142 34 226 170 11 12260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1228239 182 13 246 190 14 246 190 14 246 190 14 12270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1229246 190 14 246 190 14 246 190 14 246 190 14 12280 0 0
1230246 190 14 246 190 14 246 190 14 246 190 14 12290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1231246 190 14 241 196 14 203 166 17 22 18 6 12300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1232 2 2 6 2 2 6 2 2 6 38 38 38 12310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1233218 218 218 253 253 253 253 253 253 253 253 253 12320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1234253 253 253 253 253 253 253 253 253 253 253 253 12330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1235253 253 253 253 253 253 253 253 253 253 253 253 12340 0 0 0 0 0 1 1 0 0 0 0 0 0 0 65 66 61
1236253 253 253 253 253 253 253 253 253 253 253 253 1235105 104 92 84 83 72 84 83 72 110 109 94 184 179 149 210 208 158
1237250 250 250 206 206 206 198 198 198 202 162 69 1236210 208 158 210 208 158 214 212 158 197 193 154 214 212 158 210 208 158
1238226 170 11 236 178 12 224 166 10 210 150 10 1237251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
1239200 144 11 197 138 11 192 133 9 197 138 11 1238251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
1240210 150 10 226 170 11 242 186 14 246 190 14 1239251 251 187 251 251 187 239 239 170 251 251 187 184 179 149 84 83 72
1241246 190 14 246 186 14 225 175 15 124 112 88 124026 28 27 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1242 62 62 62 30 30 30 14 14 14 6 6 6 124116 20 20 16 20 20 15 19 19 15 19 19 15 18 18 14 18 18
1243 0 0 0 0 0 0 0 0 0 0 0 0 124213 17 17 13 16 16 15 15 15 14 14 13 14 14 13 14 14 13
1244 0 0 0 0 0 0 0 0 0 0 0 0 124313 13 13 13 13 13 12 12 12 12 12 12 12 12 12 3 4 4
1245 0 0 0 0 0 0 0 0 0 0 0 0 12440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1246 0 0 0 0 0 0 0 0 0 10 10 10 12450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1247 30 30 30 78 78 78 174 135 50 224 166 10 12460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1248239 182 13 246 190 14 246 190 14 246 190 14 12470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1249246 190 14 246 190 14 246 190 14 246 190 14 12480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1250246 190 14 246 190 14 246 190 14 246 190 14 12490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1251246 190 14 246 190 14 241 196 14 139 102 15 12500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1252 2 2 6 2 2 6 2 2 6 2 2 6 12510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1253 78 78 78 250 250 250 253 253 253 253 253 253 12520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1254253 253 253 253 253 253 253 253 253 253 253 253 12530 0 0
1255253 253 253 253 253 253 253 253 253 253 253 253 12540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1256253 253 253 253 253 253 253 253 253 253 253 253 12550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1257250 250 250 214 214 214 198 198 198 190 150 46 12560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1258219 162 10 236 178 12 234 174 13 224 166 10 12570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1259216 158 10 213 154 11 213 154 11 216 158 10 12580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1260226 170 11 239 182 13 246 190 14 246 190 14 12590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 72 73 67
1261246 190 14 246 190 14 242 186 14 206 162 42 1260105 104 92 99 98 80 84 83 72 99 98 80 177 172 135 197 193 154
1262101 101 101 58 58 58 30 30 30 14 14 14 1261251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
1263 6 6 6 0 0 0 0 0 0 0 0 0 1262251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
1264 0 0 0 0 0 0 0 0 0 0 0 0 1263251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
1265 0 0 0 0 0 0 0 0 0 0 0 0 1264251 251 187 251 251 187 251 251 187 214 212 158 197 193 154 99 98 80
1266 0 0 0 0 0 0 0 0 0 10 10 10 126523 27 26 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1267 30 30 30 74 74 74 174 135 50 216 158 10 126616 20 20 16 20 20 15 19 19 15 19 19 15 18 18 14 18 18
1268236 178 12 246 190 14 246 190 14 246 190 14 126714 17 17 16 16 16 16 16 16 16 16 16 15 15 15 14 14 13
1269246 190 14 246 190 14 246 190 14 246 190 14 126814 14 13 13 13 13 13 13 13 12 12 12 12 12 12 12 12 12
1270246 190 14 246 190 14 246 190 14 246 190 14 12693 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1271246 190 14 246 190 14 241 196 14 226 184 13 12700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1272 61 42 6 2 2 6 2 2 6 2 2 6 12710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1273 22 22 22 238 238 238 253 253 253 253 253 253 12720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1274253 253 253 253 253 253 253 253 253 253 253 253 12730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1275253 253 253 253 253 253 253 253 253 253 253 253 12740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1276253 253 253 253 253 253 253 253 253 253 253 253 12750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1277253 253 253 226 226 226 187 187 187 180 133 36 12760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1278216 158 10 236 178 12 239 182 13 236 178 12 12770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1279230 174 11 226 170 11 226 170 11 230 174 11 12780 0 0
1280236 178 12 242 186 14 246 190 14 246 190 14 12790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1281246 190 14 246 190 14 246 186 14 239 182 13 12800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1282206 162 42 106 106 106 66 66 66 34 34 34 12810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1283 14 14 14 6 6 6 0 0 0 0 0 0 12820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1284 0 0 0 0 0 0 0 0 0 0 0 0 12830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1285 0 0 0 0 0 0 0 0 0 0 0 0 12840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 84 83 72
1286 0 0 0 0 0 0 0 0 0 6 6 6 1285110 109 94 99 98 80 72 73 67 63 64 60 99 98 80 177 172 135
1287 26 26 26 70 70 70 163 133 67 213 154 11 1286184 179 149 210 208 158 251 251 187 251 251 187 251 251 187 251 251 187
1288236 178 12 246 190 14 246 190 14 246 190 14 1287251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
1289246 190 14 246 190 14 246 190 14 246 190 14 1288251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
1290246 190 14 246 190 14 246 190 14 246 190 14 1289251 251 187 210 208 158 184 179 149 177 172 135 110 109 94 33 37 35
1291246 190 14 246 190 14 246 190 14 241 196 14 129017 21 21 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1292190 146 13 18 14 6 2 2 6 2 2 6 129116 20 20 16 20 20 15 19 19 15 19 19 15 19 19 14 18 18
1293 46 46 46 246 246 246 253 253 253 253 253 253 129215 18 18 18 19 18 18 19 18 17 17 17 16 16 16 15 15 15
1294253 253 253 253 253 253 253 253 253 253 253 253 129314 14 13 13 13 13 13 13 13 12 12 12 12 12 12 12 12 12
1295253 253 253 253 253 253 253 253 253 253 253 253 129410 10 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1296253 253 253 253 253 253 253 253 253 253 253 253 12950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1297253 253 253 221 221 221 86 86 86 156 107 11 12960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1298216 158 10 236 178 12 242 186 14 246 186 14 12970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1299242 186 14 239 182 13 239 182 13 242 186 14 12980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1300242 186 14 246 186 14 246 190 14 246 190 14 12990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1301246 190 14 246 190 14 246 190 14 246 190 14 13000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1302242 186 14 225 175 15 142 122 72 66 66 66 13010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1303 30 30 30 10 10 10 0 0 0 0 0 0 13020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1304 0 0 0 0 0 0 0 0 0 0 0 0 13030 0 0
1305 0 0 0 0 0 0 0 0 0 0 0 0 13040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1306 0 0 0 0 0 0 0 0 0 6 6 6 13050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1307 26 26 26 70 70 70 163 133 67 210 150 10 13060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1308236 178 12 246 190 14 246 190 14 246 190 14 13070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1309246 190 14 246 190 14 246 190 14 246 190 14 13080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1310246 190 14 246 190 14 246 190 14 246 190 14 13090 0 0 0 0 0 0 0 0 0 0 0 2 2 2 105 104 92
1311246 190 14 246 190 14 246 190 14 246 190 14 1310108 107 93 99 98 80 72 73 67 63 64 60 51 52 50 87 86 72
1312232 195 16 121 92 8 34 34 34 106 106 106 1311105 104 92 110 109 94 108 107 93 156 151 111 184 179 149 184 179 149
1313221 221 221 253 253 253 253 253 253 253 253 253 1312197 193 154 197 193 154 197 193 154 184 179 149 184 179 149 177 172 135
1314253 253 253 253 253 253 253 253 253 253 253 253 1313197 193 154 156 151 111 177 172 135 184 179 149 168 163 120 137 133 100
1315253 253 253 253 253 253 253 253 253 253 253 253 1314145 141 105 110 109 94 99 98 80 47 48 46 55 57 54 15 19 19
1316253 253 253 253 253 253 253 253 253 253 253 253 131516 19 19 16 20 20 16 20 20 16 20 20 16 20 20 16 20 20
1317242 242 242 82 82 82 18 14 6 163 110 8 131617 20 20 17 21 21 16 20 20 16 19 19 15 19 19 16 19 19
1318216 158 10 236 178 12 242 186 14 246 190 14 131720 20 20 21 22 21 20 20 20 19 20 19 18 19 18 16 16 16
1319246 190 14 246 190 14 246 190 14 246 190 14 131815 15 15 14 14 13 13 13 13 13 13 13 12 12 12 12 12 12
1320246 190 14 246 190 14 246 190 14 246 190 14 131912 12 12 4 5 5 0 0 0 0 0 0 0 0 0 0 0 0
1321246 190 14 246 190 14 246 190 14 246 190 14 13200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1322246 190 14 246 190 14 242 186 14 163 133 67 13210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1323 46 46 46 18 18 18 6 6 6 0 0 0 13220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1324 0 0 0 0 0 0 0 0 0 0 0 0 13230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1325 0 0 0 0 0 0 0 0 0 0 0 0 13240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1326 0 0 0 0 0 0 0 0 0 10 10 10 13250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1327 30 30 30 78 78 78 163 133 67 210 150 10 13260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1328236 178 12 246 186 14 246 190 14 246 190 14 13270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1329246 190 14 246 190 14 246 190 14 246 190 14 13280 0 0
1330246 190 14 246 190 14 246 190 14 246 190 14 13290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1331246 190 14 246 190 14 246 190 14 246 190 14 13300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1332241 196 14 215 174 15 190 178 144 253 253 253 13310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1333253 253 253 253 253 253 253 253 253 253 253 253 13320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1334253 253 253 253 253 253 253 253 253 253 253 253 13330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1335253 253 253 253 253 253 253 253 253 253 253 253 13340 0 0 0 0 0 0 0 0 0 0 0 58 59 55 110 109 94
1336253 253 253 253 253 253 253 253 253 218 218 218 1335105 104 92 90 89 73 72 73 67 55 57 54 43 45 43 39 40 39
1337 58 58 58 2 2 6 22 18 6 167 114 7 133643 45 43 46 47 45 43 45 43 68 70 65 65 66 61 63 64 60
1338216 158 10 236 178 12 246 186 14 246 190 14 1337108 107 93 72 73 67 105 104 92 90 89 73 72 73 67 40 43 41
1339246 190 14 246 190 14 246 190 14 246 190 14 133872 73 67 68 70 65 68 70 65 58 59 55 63 64 60 49 51 48
1340246 190 14 246 190 14 246 190 14 246 190 14 133943 45 43 33 36 34 27 30 29 20 24 24 16 20 20 15 19 19
1341246 190 14 246 190 14 246 190 14 246 190 14 134015 19 19 15 19 19 15 19 19 16 19 19 16 20 20 16 20 20
1342246 190 14 246 186 14 242 186 14 190 150 46 134117 21 21 20 24 24 20 23 22 17 21 21 17 20 20 20 20 20
1343 54 54 54 22 22 22 6 6 6 0 0 0 134221 22 21 21 22 21 21 22 21 21 22 21 20 20 20 18 19 18
1344 0 0 0 0 0 0 0 0 0 0 0 0 134316 16 16 15 15 15 13 13 13 13 13 13 12 12 12 12 12 12
1345 0 0 0 0 0 0 0 0 0 0 0 0 134412 12 12 10 10 9 0 0 0 0 0 0 0 0 0 0 0 0
1346 0 0 0 0 0 0 0 0 0 14 14 14 13450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1347 38 38 38 86 86 86 180 133 36 213 154 11 13460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1348236 178 12 246 186 14 246 190 14 246 190 14 13470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1349246 190 14 246 190 14 246 190 14 246 190 14 13480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1350246 190 14 246 190 14 246 190 14 246 190 14 13490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1351246 190 14 246 190 14 246 190 14 246 190 14 13500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1352246 190 14 232 195 16 190 146 13 214 214 214 13510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1353253 253 253 253 253 253 253 253 253 253 253 253 13520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1354253 253 253 253 253 253 253 253 253 253 253 253 13530 0 0
1355253 253 253 253 253 253 253 253 253 253 253 253 13540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1356253 253 253 250 250 250 170 170 170 26 26 26 13550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1357 2 2 6 2 2 6 37 26 9 163 110 8 13560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1358219 162 10 239 182 13 246 186 14 246 190 14 13570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1359246 190 14 246 190 14 246 190 14 246 190 14 13580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1360246 190 14 246 190 14 246 190 14 246 190 14 13590 0 0 0 0 0 0 0 0 21 22 21 110 109 94 110 109 94
1361246 190 14 246 190 14 246 190 14 246 190 14 1360105 104 92 84 83 72 68 70 65 51 52 50 41 42 42 33 37 35
1362246 186 14 236 178 12 224 166 10 142 122 72 136128 31 30 23 27 26 20 23 23 18 22 22 17 20 20 25 27 26
1363 46 46 46 18 18 18 6 6 6 0 0 0 136226 28 27 27 30 29 25 27 26 20 23 23 23 27 26 30 32 31
1364 0 0 0 0 0 0 0 0 0 0 0 0 136320 24 24 17 21 21 18 22 22 15 19 19 26 28 27 20 23 23
1365 0 0 0 0 0 0 0 0 0 0 0 0 136414 18 18 15 19 19 15 18 18 15 19 19 15 19 19 15 19 19
1366 0 0 0 0 0 0 6 6 6 18 18 18 136515 19 19 15 19 19 15 19 19 15 19 19 15 19 19 16 19 19
1367 50 50 50 109 106 95 192 133 9 224 166 10 136616 20 20 22 24 23 24 26 24 22 24 23 20 23 22 22 24 23
1368242 186 14 246 190 14 246 190 14 246 190 14 136724 26 24 24 26 24 23 24 24 22 24 23 21 22 21 19 20 19
1369246 190 14 246 190 14 246 190 14 246 190 14 136817 17 17 15 15 15 14 14 13 13 13 13 12 12 12 12 12 12
1370246 190 14 246 190 14 246 190 14 246 190 14 136912 12 12 12 12 12 2 2 2 0 0 0 0 0 0 0 0 0
1371246 190 14 246 190 14 246 190 14 246 190 14 13700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1372242 186 14 226 184 13 210 162 10 142 110 46 13710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1373226 226 226 253 253 253 253 253 253 253 253 253 13720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1374253 253 253 253 253 253 253 253 253 253 253 253 13730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1375253 253 253 253 253 253 253 253 253 253 253 253 13740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1376198 198 198 66 66 66 2 2 6 2 2 6 13750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1377 2 2 6 2 2 6 50 34 6 156 107 11 13760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1378219 162 10 239 182 13 246 186 14 246 190 14 13770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1379246 190 14 246 190 14 246 190 14 246 190 14 13780 0 0
1380246 190 14 246 190 14 246 190 14 246 190 14 13790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1381246 190 14 246 190 14 246 190 14 242 186 14 13800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1382234 174 13 213 154 11 154 122 46 66 66 66 13810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1383 30 30 30 10 10 10 0 0 0 0 0 0 13820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1384 0 0 0 0 0 0 0 0 0 0 0 0 13830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1385 0 0 0 0 0 0 0 0 0 0 0 0 13840 0 0 0 0 0 2 2 2 99 98 80 110 109 94 108 107 93
1386 0 0 0 0 0 0 6 6 6 22 22 22 1385105 104 92 84 83 72 63 64 60 49 51 48 39 40 39 32 34 33
1387 58 58 58 154 121 60 206 145 10 234 174 13 138627 30 29 23 25 24 20 23 23 17 20 20 15 19 19 14 18 18
1388242 186 14 246 186 14 246 190 14 246 190 14 138714 17 17 13 17 17 13 17 17 13 17 17 13 17 17 13 17 17
1389246 190 14 246 190 14 246 190 14 246 190 14 138814 17 17 14 17 17 14 17 17 14 17 17 14 17 17 14 17 17
1390246 190 14 246 190 14 246 190 14 246 190 14 138914 18 18 14 18 18 14 18 18 14 18 18 15 18 18 15 19 19
1391246 190 14 246 190 14 246 190 14 246 190 14 139015 19 19 15 19 19 15 19 19 15 19 19 15 19 19 15 19 19
1392246 186 14 236 178 12 210 162 10 163 110 8 139115 19 19 17 21 21 27 29 28 26 28 27 25 27 26 25 27 26
1393 61 42 6 138 138 138 218 218 218 250 250 250 139227 29 28 27 29 28 26 28 27 24 26 24 21 22 21 20 20 20
1394253 253 253 253 253 253 253 253 253 250 250 250 139318 19 18 16 16 16 14 14 13 13 13 13 12 12 12 12 12 12
1395242 242 242 210 210 210 144 144 144 66 66 66 139412 12 12 12 12 12 4 5 5 0 0 0 0 0 0 0 0 0
1396 6 6 6 2 2 6 2 2 6 2 2 6 13950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1397 2 2 6 2 2 6 61 42 6 163 110 8 13960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1398216 158 10 236 178 12 246 190 14 246 190 14 13970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1399246 190 14 246 190 14 246 190 14 246 190 14 13980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1400246 190 14 246 190 14 246 190 14 246 190 14 13990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1401246 190 14 239 182 13 230 174 11 216 158 10 14000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1402190 142 34 124 112 88 70 70 70 38 38 38 14010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1403 18 18 18 6 6 6 0 0 0 0 0 0 14020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1404 0 0 0 0 0 0 0 0 0 0 0 0 14030 0 0
1405 0 0 0 0 0 0 0 0 0 0 0 0 14040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1406 0 0 0 0 0 0 6 6 6 22 22 22 14050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1407 62 62 62 168 124 44 206 145 10 224 166 10 14060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1408236 178 12 239 182 13 242 186 14 242 186 14 14070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1409246 186 14 246 190 14 246 190 14 246 190 14 14080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1410246 190 14 246 190 14 246 190 14 246 190 14 14090 0 0 0 0 0 51 52 50 110 109 94 110 109 94 105 104 92
1411246 190 14 246 190 14 246 190 14 246 190 14 141090 89 73 72 73 67 55 57 54 43 45 43 35 37 36 30 32 31
1412246 190 14 236 178 12 216 158 10 175 118 6 141126 28 27 20 24 24 17 21 21 16 19 19 15 18 18 14 17 17
1413 80 54 7 2 2 6 6 6 6 30 30 30 141213 16 16 13 16 16 13 16 16 13 16 16 13 16 16 13 16 16
1414 54 54 54 62 62 62 50 50 50 38 38 38 141313 16 16 13 16 16 13 16 16 13 17 17 13 17 17 14 17 17
1415 14 14 14 2 2 6 2 2 6 2 2 6 141414 17 17 14 17 17 14 17 17 14 18 18 14 18 18 14 18 18
1416 2 2 6 2 2 6 2 2 6 2 2 6 141515 18 18 15 18 18 15 19 19 15 19 19 15 19 19 15 19 19
1417 2 2 6 6 6 6 80 54 7 167 114 7 141615 19 19 15 19 19 27 29 28 32 34 33 28 31 30 27 29 28
1418213 154 11 236 178 12 246 190 14 246 190 14 141730 32 31 30 32 31 30 31 28 26 28 27 23 24 24 21 22 21
1419246 190 14 246 190 14 246 190 14 246 190 14 141819 20 19 16 16 16 14 14 13 13 13 13 12 12 12 12 12 12
1420246 190 14 242 186 14 239 182 13 239 182 13 141912 12 12 12 12 12 6 7 7 0 0 0 0 0 0 0 0 0
1421230 174 11 210 150 10 174 135 50 124 112 88 14200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1422 82 82 82 54 54 54 34 34 34 18 18 18 14210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1423 6 6 6 0 0 0 0 0 0 0 0 0 14220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1424 0 0 0 0 0 0 0 0 0 0 0 0 14230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1425 0 0 0 0 0 0 0 0 0 0 0 0 14240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1426 0 0 0 0 0 0 6 6 6 18 18 18 14250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1427 50 50 50 158 118 36 192 133 9 200 144 11 14260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1428216 158 10 219 162 10 224 166 10 226 170 11 14270 0 0 0 0 0 0 0 0 3 3 3 0 0 0 0 0 0
1429230 174 11 236 178 12 239 182 13 239 182 13 14280 0 0
1430242 186 14 246 186 14 246 190 14 246 190 14 14290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1431246 190 14 246 190 14 246 190 14 246 190 14 14300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1432246 186 14 230 174 11 210 150 10 163 110 8 14310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1433104 69 6 10 10 10 2 2 6 2 2 6 14320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1434 2 2 6 2 2 6 2 2 6 2 2 6 14330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1435 2 2 6 2 2 6 2 2 6 2 2 6 14340 0 0 10 10 9 108 107 93 110 109 94 108 107 93 99 98 80
1436 2 2 6 2 2 6 2 2 6 2 2 6 143584 83 72 63 64 60 49 51 48 40 43 41 33 36 34 27 30 29
1437 2 2 6 6 6 6 91 60 6 167 114 7 143623 27 26 18 22 22 17 20 20 15 18 18 14 17 17 13 16 16
1438206 145 10 230 174 11 242 186 14 246 190 14 143713 16 16 13 16 16 12 15 15 12 15 15 12 15 15 12 15 15
1439246 190 14 246 190 14 246 186 14 242 186 14 143813 16 16 13 16 16 13 16 16 13 16 16 13 16 16 13 16 16
1440239 182 13 230 174 11 224 166 10 213 154 11 143913 17 17 13 17 17 14 17 17 14 17 17 14 17 17 14 18 18
1441180 133 36 124 112 88 86 86 86 58 58 58 144014 18 18 14 18 18 15 18 18 15 18 18 15 19 19 15 19 19
1442 38 38 38 22 22 22 10 10 10 6 6 6 144115 19 19 15 19 19 17 21 21 33 36 34 32 34 33 31 33 31
1443 0 0 0 0 0 0 0 0 0 0 0 0 144233 36 34 33 36 34 31 33 31 27 29 28 25 27 26 21 22 21
1444 0 0 0 0 0 0 0 0 0 0 0 0 144319 20 19 17 17 17 15 15 15 13 13 13 12 12 12 12 12 12
1445 0 0 0 0 0 0 0 0 0 0 0 0 144412 12 12 12 12 12 8 8 7 0 0 0 0 0 0 0 0 0
1446 0 0 0 0 0 0 0 0 0 14 14 14 14450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1447 34 34 34 70 70 70 138 110 50 158 118 36 14460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1448167 114 7 180 123 7 192 133 9 197 138 11 14470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1449200 144 11 206 145 10 213 154 11 219 162 10 14480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1450224 166 10 230 174 11 239 182 13 242 186 14 14490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1451246 186 14 246 186 14 246 186 14 246 186 14 14500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1452239 182 13 216 158 10 185 133 11 152 99 6 14510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1453104 69 6 18 14 6 2 2 6 2 2 6 14520 0 0 0 0 0 63 64 60 137 133 100 43 45 43 0 0 0
1454 2 2 6 2 2 6 2 2 6 2 2 6 14530 0 0
1455 2 2 6 2 2 6 2 2 6 2 2 6 14540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1456 2 2 6 2 2 6 2 2 6 2 2 6 14550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1457 2 2 6 6 6 6 80 54 7 152 99 6 14560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1458192 133 9 219 162 10 236 178 12 239 182 13 14570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1459246 186 14 242 186 14 239 182 13 236 178 12 14580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1460224 166 10 206 145 10 192 133 9 154 121 60 14590 0 0 68 70 65 110 109 94 110 109 94 105 104 92 84 83 72
1461 94 94 94 62 62 62 42 42 42 22 22 22 146068 70 65 55 57 54 43 45 43 35 37 36 30 32 31 26 28 27
1462 14 14 14 6 6 6 0 0 0 0 0 0 146120 24 24 17 21 21 16 19 19 14 17 17 13 16 16 12 15 15
1463 0 0 0 0 0 0 0 0 0 0 0 0 146212 15 15 12 15 15 12 15 15 12 15 15 12 15 15 12 15 15
1464 0 0 0 0 0 0 0 0 0 0 0 0 146312 15 15 12 15 15 12 15 15 12 15 15 12 15 15 13 16 16
1465 0 0 0 0 0 0 0 0 0 0 0 0 146413 16 16 13 16 16 13 16 16 13 17 17 13 17 17 14 17 17
1466 0 0 0 0 0 0 0 0 0 6 6 6 146514 17 17 14 17 17 14 18 18 14 18 18 14 18 18 15 18 18
1467 18 18 18 34 34 34 58 58 58 78 78 78 146615 19 19 15 19 19 15 19 19 20 24 24 32 34 33 35 37 36
1468101 98 89 124 112 88 142 110 46 156 107 11 146737 39 37 35 37 36 33 36 34 30 32 31 26 28 27 22 24 23
1469163 110 8 167 114 7 175 118 6 180 123 7 146820 20 20 17 17 17 15 15 15 13 13 13 12 12 12 12 12 12
1470185 133 11 197 138 11 210 150 10 219 162 10 146912 12 12 12 12 12 8 8 7 0 0 0 0 0 0 0 0 0
1471226 170 11 236 178 12 236 178 12 234 174 13 14700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1472219 162 10 197 138 11 163 110 8 130 83 6 14710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1473 91 60 6 10 10 10 2 2 6 2 2 6 14720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1474 18 18 18 38 38 38 38 38 38 38 38 38 14730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1475 38 38 38 38 38 38 38 38 38 38 38 38 14740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1476 38 38 38 38 38 38 26 26 26 2 2 6 14750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1477 2 2 6 6 6 6 70 47 6 137 92 6 14760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1478175 118 6 200 144 11 219 162 10 230 174 11 14771 1 1 99 98 80 184 179 149 184 179 149 68 70 65 0 0 0
1479234 174 13 230 174 11 219 162 10 210 150 10 14780 0 0
1480192 133 9 163 110 8 124 112 88 82 82 82 14790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1481 50 50 50 30 30 30 14 14 14 6 6 6 14800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1482 0 0 0 0 0 0 0 0 0 0 0 0 14810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1483 0 0 0 0 0 0 0 0 0 0 0 0 14820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1484 0 0 0 0 0 0 0 0 0 0 0 0 14830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1485 0 0 0 0 0 0 0 0 0 0 0 0 148415 15 15 110 109 94 110 109 94 108 107 93 99 98 80 72 73 67
1486 0 0 0 0 0 0 0 0 0 0 0 0 148561 63 57 49 51 48 39 40 39 33 36 34 27 30 29 23 25 24
1487 6 6 6 14 14 14 22 22 22 34 34 34 148618 22 22 16 19 19 14 17 17 13 16 16 12 15 15 12 15 15
1488 42 42 42 58 58 58 74 74 74 86 86 86 148711 14 14 11 14 14 11 14 14 11 14 14 11 14 14 11 14 14
1489101 98 89 122 102 70 130 98 46 121 87 25 148811 14 14 11 14 14 12 14 14 12 15 15 12 15 15 12 15 15
1490137 92 6 152 99 6 163 110 8 180 123 7 148912 15 15 13 16 16 13 16 16 13 16 16 13 16 16 13 16 16
1491185 133 11 197 138 11 206 145 10 200 144 11 149013 17 17 14 17 17 14 17 17 14 17 17 14 18 18 14 18 18
1492180 123 7 156 107 11 130 83 6 104 69 6 149114 18 18 15 18 18 15 19 19 15 19 19 30 32 31 38 39 37
1493 50 34 6 54 54 54 110 110 110 101 98 89 149239 40 39 39 40 39 35 37 36 31 33 31 27 29 28 22 24 23
1494 86 86 86 82 82 82 78 78 78 78 78 78 149320 20 20 17 17 17 15 15 15 13 13 13 12 12 12 12 12 12
1495 78 78 78 78 78 78 78 78 78 78 78 78 149412 12 12 12 12 12 8 8 7 0 0 0 0 0 0 0 0 0
1496 78 78 78 82 82 82 86 86 86 94 94 94 14950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1497106 106 106 101 101 101 86 66 34 124 80 6 14960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1498156 107 11 180 123 7 192 133 9 200 144 11 14970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1499206 145 10 200 144 11 192 133 9 175 118 6 14980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1500139 102 15 109 106 95 70 70 70 42 42 42 14990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1501 22 22 22 10 10 10 0 0 0 0 0 0 15000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1502 0 0 0 0 0 0 0 0 0 0 0 0 15010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3
1503 0 0 0 0 0 0 0 0 0 0 0 0 1502110 109 94 197 193 154 210 208 158 184 179 149 68 70 65 0 0 0
1504 0 0 0 0 0 0 0 0 0 0 0 0 15030 0 0
1505 0 0 0 0 0 0 0 0 0 0 0 0 15040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1506 0 0 0 0 0 0 0 0 0 0 0 0 15050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1507 0 0 0 0 0 0 6 6 6 10 10 10 15060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1508 14 14 14 22 22 22 30 30 30 38 38 38 15070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1509 50 50 50 62 62 62 74 74 74 90 90 90 15080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1510101 98 89 112 100 78 121 87 25 124 80 6 150968 70 65 110 109 94 110 109 94 105 104 92 84 83 72 65 66 61
1511137 92 6 152 99 6 152 99 6 152 99 6 151051 52 50 43 45 43 35 37 36 30 32 31 25 27 26 20 23 23
1512138 86 6 124 80 6 98 70 6 86 66 30 151117 20 20 15 18 18 13 16 16 12 15 15 12 15 15 11 14 14
1513101 98 89 82 82 82 58 58 58 46 46 46 151211 14 14 11 14 14 11 13 13 11 13 13 11 13 13 11 13 13
1514 38 38 38 34 34 34 34 34 34 34 34 34 151311 14 14 11 14 14 11 14 14 11 14 14 11 14 14 11 14 14
1515 34 34 34 34 34 34 34 34 34 34 34 34 151412 15 15 12 15 15 12 15 15 12 15 15 13 16 16 13 16 16
1516 34 34 34 34 34 34 38 38 38 42 42 42 151513 16 16 13 16 16 13 17 17 13 17 17 14 17 17 14 17 17
1517 54 54 54 82 82 82 94 86 76 91 60 6 151614 18 18 14 18 18 14 18 18 16 19 19 37 39 37 41 42 42
1518134 86 6 156 107 11 167 114 7 175 118 6 151741 42 42 41 42 42 38 39 37 32 34 33 27 29 28 23 24 24
1519175 118 6 167 114 7 152 99 6 121 87 25 151821 22 21 17 17 17 15 15 15 13 13 13 12 12 12 12 12 12
1520101 98 89 62 62 62 34 34 34 18 18 18 151912 12 12 12 12 12 8 8 7 0 0 0 0 0 0 0 0 0
1521 6 6 6 0 0 0 0 0 0 0 0 0 15200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1522 0 0 0 0 0 0 0 0 0 0 0 0 15210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1523 0 0 0 0 0 0 0 0 0 0 0 0 15220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1524 0 0 0 0 0 0 0 0 0 0 0 0 15230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1525 0 0 0 0 0 0 0 0 0 0 0 0 15240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1526 0 0 0 0 0 0 0 0 0 0 0 0 15250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1527 0 0 0 0 0 0 0 0 0 0 0 0 15260 0 0 0 0 0 0 0 0 0 0 0 11 11 11 137 133 100
1528 0 0 0 6 6 6 6 6 6 10 10 10 1527197 193 154 251 251 187 239 239 170 184 179 149 31 33 31 0 0 0
1529 18 18 18 22 22 22 30 30 30 42 42 42 15280 0 0
1530 50 50 50 66 66 66 86 86 86 101 98 89 15290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1531106 86 58 98 70 6 104 69 6 104 69 6 15300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1532104 69 6 91 60 6 82 62 34 90 90 90 15310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1533 62 62 62 38 38 38 22 22 22 14 14 14 15320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1534 10 10 10 10 10 10 10 10 10 10 10 10 15330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 12 12
1535 10 10 10 10 10 10 6 6 6 10 10 10 1534110 109 94 110 109 94 105 104 92 90 89 73 72 73 67 58 59 55
1536 10 10 10 10 10 10 10 10 10 14 14 14 153546 47 45 37 39 37 31 33 31 26 28 27 20 24 24 17 21 21
1537 22 22 22 42 42 42 70 70 70 89 81 66 153615 18 18 13 16 16 12 15 15 12 14 14 11 13 13 11 13 13
1538 80 54 7 104 69 6 124 80 6 137 92 6 153710 13 13 10 13 13 10 13 13 10 13 13 10 13 13 10 13 13
1539134 86 6 116 81 8 100 82 52 86 86 86 153810 13 13 10 13 13 11 13 13 11 13 13 11 14 14 11 14 14
1540 58 58 58 30 30 30 14 14 14 6 6 6 153911 14 14 11 14 14 12 14 14 12 15 15 12 15 15 12 15 15
1541 0 0 0 0 0 0 0 0 0 0 0 0 154013 16 16 13 16 16 13 16 16 13 16 16 13 17 17 13 17 17
1542 0 0 0 0 0 0 0 0 0 0 0 0 154114 17 17 14 17 17 14 18 18 23 27 26 41 42 42 41 42 42
1543 0 0 0 0 0 0 0 0 0 0 0 0 154243 45 43 41 42 42 39 40 39 33 36 34 27 29 28 23 24 24
1544 0 0 0 0 0 0 0 0 0 0 0 0 154321 22 21 17 17 17 15 15 15 13 13 13 12 12 12 12 12 12
1545 0 0 0 0 0 0 0 0 0 0 0 0 154412 12 12 12 12 12 6 7 7 0 0 0 0 0 0 0 0 0
1546 0 0 0 0 0 0 0 0 0 0 0 0 15450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1547 0 0 0 0 0 0 0 0 0 0 0 0 15460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1548 0 0 0 0 0 0 0 0 0 0 0 0 15470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1549 0 0 0 6 6 6 10 10 10 14 14 14 15480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1550 18 18 18 26 26 26 38 38 38 54 54 54 15490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1551 70 70 70 86 86 86 94 86 76 89 81 66 15500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1552 89 81 66 86 86 86 74 74 74 50 50 50 15510 0 0 0 0 0 0 0 0 27 29 28 168 163 120 210 208 158
1553 30 30 30 14 14 14 6 6 6 0 0 0 1552251 251 187 251 251 187 210 208 158 137 133 100 1 1 1 0 0 0
1554 0 0 0 0 0 0 0 0 0 0 0 0 15530 0 0
1555 0 0 0 0 0 0 0 0 0 0 0 0 15540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1556 0 0 0 0 0 0 0 0 0 0 0 0 15550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1557 6 6 6 18 18 18 34 34 34 58 58 58 15560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1558 82 82 82 89 81 66 89 81 66 89 81 66 15570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1559 94 86 66 94 86 76 74 74 74 50 50 50 15580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60 60 56
1560 26 26 26 14 14 14 6 6 6 0 0 0 1559110 109 94 105 104 92 105 104 92 84 83 72 65 66 61 51 52 50
1561 0 0 0 0 0 0 0 0 0 0 0 0 156040 43 41 33 36 34 27 30 29 23 25 24 18 22 22 16 19 19
1562 0 0 0 0 0 0 0 0 0 0 0 0 156114 17 17 12 15 15 11 14 14 11 14 14 10 13 13 10 13 13
1563 0 0 0 0 0 0 0 0 0 0 0 0 156210 13 13 10 12 12 10 12 12 10 12 12 10 12 12 10 12 12
1564 0 0 0 0 0 0 0 0 0 0 0 0 156310 12 12 10 12 12 10 13 13 10 13 13 10 13 13 11 13 13
1565 0 0 0 0 0 0 0 0 0 0 0 0 156411 13 13 11 14 14 11 14 14 11 14 14 11 14 14 12 15 15
1566 0 0 0 0 0 0 0 0 0 0 0 0 156512 15 15 12 15 15 12 15 15 13 16 16 13 16 16 13 16 16
1567 0 0 0 0 0 0 0 0 0 0 0 0 156613 17 17 13 17 17 14 17 17 32 34 33 43 45 43 43 45 43
1568 0 0 0 0 0 0 0 0 0 0 0 0 156743 45 43 43 45 43 39 40 39 33 36 34 27 29 28 23 24 24
1569 0 0 0 0 0 0 0 0 0 0 0 0 156821 22 21 17 17 17 15 15 15 13 13 13 12 12 12 12 12 12
1570 6 6 6 6 6 6 14 14 14 18 18 18 156912 12 12 12 12 12 6 7 7 0 0 0 0 0 0 0 0 0
1571 30 30 30 38 38 38 46 46 46 54 54 54 15700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1572 50 50 50 42 42 42 30 30 30 18 18 18 15710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1573 10 10 10 0 0 0 0 0 0 0 0 0 15720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1574 0 0 0 0 0 0 0 0 0 0 0 0 15730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1575 0 0 0 0 0 0 0 0 0 0 0 0 15740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1576 0 0 0 0 0 0 0 0 0 0 0 0 15750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1577 0 0 0 6 6 6 14 14 14 26 26 26 15760 0 0 1 1 1 68 70 65 184 179 149 210 208 158 251 251 187
1578 38 38 38 50 50 50 58 58 58 58 58 58 1577251 251 187 214 212 158 184 179 149 37 39 37 0 0 0 0 0 0
1579 54 54 54 42 42 42 30 30 30 18 18 18 15780 0 0
1580 10 10 10 0 0 0 0 0 0 0 0 0 15790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1581 0 0 0 0 0 0 0 0 0 0 0 0 15800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1582 0 0 0 0 0 0 0 0 0 0 0 0 15810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1583 0 0 0 0 0 0 0 0 0 0 0 0 15820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1584 0 0 0 0 0 0 0 0 0 0 0 0 15830 0 0 0 0 0 0 0 0 0 0 0 6 7 7 105 104 92
1585 0 0 0 0 0 0 0 0 0 0 0 0 1584105 104 92 105 104 92 99 98 80 72 73 67 58 59 55 46 47 45
1586 0 0 0 0 0 0 0 0 0 0 0 0 158535 37 36 30 32 31 25 27 26 20 23 23 16 19 19 14 17 17
1587 0 0 0 0 0 0 0 0 0 0 0 0 158612 15 15 12 14 14 11 13 13 10 13 13 10 12 12 10 12 12
1588 0 0 0 0 0 0 0 0 0 0 0 0 158710 12 12 10 12 12 9 12 12 9 12 12 9 12 12 9 12 12
1589 0 0 0 0 0 0 0 0 0 0 0 0 158810 12 12 10 12 12 10 12 12 10 12 12 10 12 12 10 13 13
1590 0 0 0 0 0 0 0 0 0 6 6 6 158910 13 13 10 13 13 11 13 13 11 13 13 11 14 14 11 14 14
1591 6 6 6 10 10 10 14 14 14 18 18 18 159011 14 14 12 15 15 12 15 15 12 15 15 12 15 15 13 16 16
1592 18 18 18 14 14 14 10 10 10 6 6 6 159113 16 16 13 16 16 17 20 20 41 42 42 46 47 45 46 47 45
1593 0 0 0 0 0 0 0 0 0 0 0 0 159246 47 45 43 45 43 40 41 39 33 36 34 27 29 28 23 24 24
1594 0 0 0 0 0 0 0 0 0 0 0 0 159320 20 20 17 17 17 15 15 15 13 13 13 12 12 12 12 12 12
1595 0 0 0 0 0 0 0 0 0 0 0 0 159412 12 12 12 12 12 4 5 5 0 0 0 0 0 0 0 0 0
1596 0 0 0 0 0 0 0 0 0 0 0 0 15950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1597 0 0 0 0 0 0 0 0 0 6 6 6 15960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1598 14 14 14 18 18 18 22 22 22 22 22 22 15970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1599 18 18 18 14 14 14 10 10 10 6 6 6 15980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1600 0 0 0 0 0 0 0 0 0 0 0 0 15990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1601 0 0 0 0 0 0 0 0 0 0 0 0 16000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1602 0 0 0 0 0 0 0 0 0 0 0 0 160115 15 15 110 109 94 197 193 154 214 212 158 251 251 187 251 251 187
1603 0 0 0 0 0 0 0 0 0 0 0 0 1602239 239 170 184 179 149 84 83 72 0 0 0 0 0 0 0 0 0
1604 0 0 0 0 0 0 0 0 0 0 0 0 16030 0 0
16040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16080 0 0 0 0 0 0 0 0 0 0 0 47 48 46 105 104 92
1609105 104 92 99 98 80 84 83 72 68 70 65 51 52 50 40 43 41
161032 34 33 27 29 28 22 24 23 17 21 21 15 18 18 13 16 16
161112 15 15 11 13 13 10 13 13 10 12 12 9 12 12 9 12 12
16129 12 12 9 12 12 9 11 11 9 11 11 9 11 11 9 11 11
16139 12 12 9 12 12 9 12 12 9 12 12 10 12 12 10 12 12
161410 12 12 10 12 12 10 13 13 10 13 13 10 13 13 11 13 13
161511 14 14 11 14 14 11 14 14 12 14 14 12 15 15 12 15 15
161612 15 15 13 16 16 28 31 30 43 45 43 47 48 46 47 48 46
161747 48 46 43 45 43 40 41 39 33 36 34 27 29 28 22 24 23
161820 20 20 17 17 17 15 15 15 13 13 13 12 12 12 12 12 12
161912 12 12 12 12 12 3 4 4 0 0 0 0 0 0 0 0 0
16200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16250 0 0 0 0 0 0 0 0 0 0 0 1 1 1 60 60 56
1626177 172 135 197 193 154 251 251 187 251 251 187 251 251 187 251 251 187
1627184 179 149 110 109 94 3 4 4 0 0 0 0 0 0 0 0 0
16280 0 0
16290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16330 0 0 0 0 0 0 0 0 1 1 1 99 98 80 105 104 92
163499 98 80 87 86 72 84 83 72 63 64 60 46 47 45 35 37 36
163530 32 31 25 27 26 18 22 22 16 19 19 14 17 17 12 15 15
163611 14 14 10 13 13 9 12 12 9 12 12 9 11 11 9 11 11
16379 11 11 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
16389 11 11 9 11 11 9 11 11 9 11 11 9 12 12 9 12 12
16399 12 12 10 12 12 10 12 12 10 12 12 10 13 13 10 13 13
164010 13 13 11 13 13 11 14 14 11 14 14 11 14 14 12 15 15
164112 15 15 14 17 17 41 42 42 47 48 46 49 51 48 51 52 50
164247 48 46 43 45 43 40 41 39 33 36 34 27 29 28 22 24 23
164319 20 19 16 16 16 14 14 13 13 13 13 12 12 12 12 12 12
164412 12 12 12 12 12 2 2 2 0 0 0 0 0 0 0 0 0
16450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16500 0 0 0 0 0 0 0 0 23 24 24 137 133 100 184 179 149
1651210 208 158 251 251 187 251 251 187 251 251 187 251 251 187 184 179 149
1652110 109 94 13 13 13 0 0 0 0 0 0 0 0 0 0 0 0
16530 0 0
16540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16580 0 0 0 0 0 0 0 0 30 32 31 105 104 92 99 98 80
165984 83 72 84 83 72 72 73 67 55 57 54 41 42 42 32 34 33
166027 29 28 20 24 24 17 20 20 14 17 17 13 16 16 12 14 14
166110 13 13 10 12 12 9 11 11 9 11 11 9 11 11 9 11 11
16629 11 11 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
16639 11 11 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
16649 11 11 9 12 12 9 12 12 10 12 12 10 12 12 10 12 12
166510 13 13 10 13 13 10 13 13 11 13 13 11 14 14 11 14 14
166611 14 14 27 29 28 55 56 53 72 73 67 51 52 50 51 52 50
166749 51 48 43 45 43 39 40 39 32 34 33 26 28 27 21 22 21
166819 20 19 16 16 16 18 19 17 13 13 13 12 12 12 12 12 12
166912 12 12 12 12 12 1 1 1 0 0 0 0 0 0 0 0 0
16700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16750 0 0 8 8 7 84 83 72 184 179 149 197 193 154 251 251 187
1676251 251 187 251 251 187 251 251 187 251 251 187 184 179 149 145 141 105
167719 20 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16780 0 0
16790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16820 0 0 14 14 13 0 0 0 0 0 0 0 0 0 0 0 0
16830 0 0 0 0 0 0 0 0 72 73 67 105 104 92 84 83 72
168472 73 67 84 83 72 68 70 65 49 51 48 39 40 39 30 32 31
168525 27 26 18 22 22 15 18 18 13 16 16 12 15 15 11 13 13
168610 12 12 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
16879 11 11 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
16889 11 11 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
16899 11 11 9 11 11 9 11 11 9 12 12 9 12 12 9 12 12
169010 12 12 10 12 12 10 12 12 10 13 13 10 13 13 11 13 13
169113 16 16 41 42 42 99 98 80 158 153 112 65 66 61 51 52 50
169249 51 48 43 45 43 39 40 39 31 33 31 25 27 26 21 22 21
169321 22 21 68 70 65 55 56 53 13 13 13 12 12 12 12 12 12
169412 12 12 11 11 11 0 0 0 0 0 0 0 0 0 0 0 0
16950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3
170063 64 60 158 153 112 184 179 149 210 208 158 251 251 187 251 251 187
1701251 251 187 251 251 187 251 251 187 184 179 149 137 133 100 27 29 28
17020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17030 0 0
17040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
170721 22 21 110 109 94 5 6 5 0 0 0 0 0 0 0 0 0
17080 0 0 0 0 0 13 13 13 105 104 92 90 89 73 72 73 67
170968 70 65 84 83 72 63 64 60 46 47 45 35 37 36 27 29 28
171022 24 23 17 20 20 14 17 17 12 15 15 11 14 14 10 12 12
171110 12 12 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
17129 11 11 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
17138 10 10 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
17149 11 11 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
17159 12 12 9 12 12 10 12 12 10 12 12 10 13 13 10 13 13
171630 32 31 47 48 46 177 172 135 210 208 158 137 133 100 55 56 53
171749 51 48 43 45 43 38 39 37 31 33 31 25 27 26 22 24 23
1718110 109 94 184 179 149 63 64 60 13 13 13 12 12 12 12 12 12
171912 12 12 8 9 9 0 0 0 1 1 1 0 0 0 0 0 0
17200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17240 0 0 0 0 0 0 0 0 0 0 0 21 22 21 105 104 92
1725184 179 149 210 208 158 251 251 187 251 251 187 251 251 187 251 251 187
1726251 251 187 251 251 187 184 179 149 145 141 105 23 24 24 0 0 0
17270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17280 0 0
17290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
173268 70 65 184 179 149 105 104 92 0 0 0 0 0 0 0 0 0
17330 0 0 0 0 0 51 52 50 99 98 80 84 83 72 63 64 60
173468 70 65 72 73 67 55 57 54 41 42 42 32 34 33 25 27 26
173520 23 23 16 19 19 13 16 16 12 14 14 10 13 13 10 12 12
17369 11 11 9 11 11 9 11 11 9 11 11 9 11 11 8 10 10
17378 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
17388 10 10 8 10 10 8 10 10 8 10 10 9 11 11 9 11 11
17399 11 11 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
17409 11 11 9 11 11 9 12 12 9 12 12 10 12 12 17 20 20
174146 47 45 72 73 67 210 208 158 251 251 187 210 208 158 63 64 60
174249 51 48 43 45 43 37 39 37 30 32 31 24 26 24 105 104 92
1743210 208 158 197 193 154 47 48 46 13 13 13 12 12 12 12 12 12
174412 12 12 6 7 7 33 36 34 48 49 45 0 0 0 0 0 0
17450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17490 0 0 0 0 0 8 8 7 23 24 24 55 56 53 110 109 94
1750210 208 158 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
1751251 251 187 184 179 149 110 109 94 20 20 20 0 0 0 0 0 0
17520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17530 0 0
17540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1757110 109 94 251 251 187 210 208 158 47 48 46 0 0 0 0 0 0
17580 0 0 1 1 1 90 89 73 90 89 73 72 73 67 55 56 53
175972 73 67 68 70 65 51 52 50 37 39 37 28 31 30 23 25 24
176017 21 21 15 18 18 12 15 15 11 14 14 10 13 13 9 12 12
17619 11 11 9 11 11 9 11 11 8 10 10 8 10 10 8 10 10
17628 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
17638 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
17648 10 10 9 11 11 9 11 11 9 11 11 9 11 11 9 11 11
17659 11 11 9 11 11 9 11 11 9 12 12 13 16 16 41 42 42
176649 51 48 110 109 94 251 251 187 251 251 187 251 251 187 105 104 92
176749 51 48 43 45 43 35 37 36 30 31 28 47 48 46 197 193 154
1768251 251 187 197 193 154 31 33 31 12 12 12 12 12 12 12 12 12
176912 12 12 51 52 50 184 179 149 72 73 67 0 0 0 0 0 0
17700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2
177411 11 11 21 22 21 30 32 31 40 41 39 60 60 56 145 141 105
1775251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 214 212 158
1776184 179 149 110 109 94 13 13 13 0 0 0 0 0 0 0 0 0
17770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17780 0 0
17790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17800 0 0 0 0 0 4 5 4 61 61 53 48 49 45 3 4 3
17810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1782156 151 111 251 251 187 251 251 187 184 179 149 11 11 11 0 0 0
17830 0 0 26 28 27 99 98 80 84 83 72 60 60 56 43 45 43
178472 73 67 65 66 61 49 51 48 35 37 36 27 29 28 20 24 24
178517 20 20 14 17 17 12 15 15 11 13 13 10 12 12 9 11 11
17869 11 11 9 11 11 8 10 10 8 10 10 8 10 10 8 10 10
17878 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
17888 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
17898 10 10 8 10 10 8 10 10 8 10 10 9 11 11 9 11 11
17909 11 11 9 11 11 9 11 11 11 13 13 37 39 37 47 48 46
179151 52 50 184 179 149 251 251 187 251 251 187 251 251 187 145 141 105
179247 48 46 41 42 42 35 37 36 27 29 28 137 133 100 251 251 187
1793251 251 187 197 193 154 19 20 19 12 12 12 12 12 12 12 12 12
179427 29 28 184 179 149 214 212 158 63 64 60 0 0 0 0 0 0
17950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17980 0 0 0 0 0 1 1 1 6 7 7 16 16 16 24 26 24
179930 32 31 38 39 37 47 48 46 55 57 54 68 70 65 110 109 94
1800197 193 154 251 251 187 251 251 187 251 251 187 210 208 158 184 179 149
1801105 104 92 8 8 7 0 0 0 0 0 0 0 0 0 0 0 0
18020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18030 0 0
18040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18050 0 0 0 0 0 0 0 0 65 66 61 184 179 149 156 151 111
180630 32 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1807168 163 120 251 251 187 251 251 187 251 251 187 110 109 94 0 0 0
18080 0 0 60 60 56 84 83 72 68 70 65 51 52 50 38 39 37
180984 83 72 63 64 60 43 45 43 33 36 34 25 27 26 20 23 22
181015 18 18 13 16 16 12 14 14 10 13 13 9 12 12 9 11 11
18119 11 11 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18128 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18138 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18148 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18159 11 11 9 11 11 10 12 12 33 36 34 46 47 45 51 52 50
181672 73 67 210 208 158 251 251 187 251 251 187 251 251 187 177 172 135
181747 48 46 41 42 42 35 37 36 37 39 37 184 179 149 251 251 187
1818251 251 187 197 193 154 13 13 13 12 12 12 12 12 12 12 12 12
1819110 109 94 251 251 187 251 251 187 37 39 37 0 0 0 0 0 0
18200 0 0 21 22 20 2 2 1 0 0 0 0 0 0 0 0 0
18210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18234 5 5 12 12 12 21 22 21 25 27 26 30 32 31 38 39 37
182446 47 45 55 56 53 60 60 56 65 66 61 68 70 65 105 104 92
1825110 109 94 197 193 154 210 208 158 197 193 154 184 179 149 84 83 72
18262 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18280 0 0
18290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18300 0 0 0 0 0 0 0 0 13 13 13 184 179 149 251 251 187
1831197 193 154 43 44 41 0 0 0 0 0 0 0 0 0 0 0 0
1832145 141 105 251 251 187 251 251 187 251 251 187 214 212 158 43 45 43
18332 2 2 84 83 72 72 73 67 58 59 55 41 42 42 38 39 37
183472 73 67 58 59 55 41 42 42 31 33 31 25 27 26 18 22 22
183514 17 17 12 15 15 12 14 14 10 12 12 9 12 12 9 11 11
18369 11 11 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18378 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18388 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18398 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18408 10 10 9 12 12 31 33 31 43 45 43 49 51 48 55 56 53
1841110 109 94 251 251 187 251 251 187 251 251 187 251 251 187 168 163 120
184247 48 46 41 42 42 33 36 34 63 64 60 197 193 154 251 251 187
1843251 251 187 184 179 149 13 13 13 12 12 12 12 12 12 16 16 16
1844197 193 154 251 251 187 239 239 170 20 20 20 0 0 0 2 2 1
1845108 107 93 110 109 94 0 0 0 0 0 0 0 0 0 0 0 0
18460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18470 0 0 0 0 0 1 1 1 4 5 5 11 11 11 18 19 18
184822 24 23 26 28 27 32 34 33 39 40 39 46 47 45 51 52 50
184955 57 54 60 60 56 63 64 60 63 64 60 63 64 60 58 59 55
185063 64 60 99 98 80 145 141 105 137 133 100 43 45 43 0 0 0
18510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18530 0 0
18540 0 0 0 0 0 0 0 0 3 4 3 0 0 0 0 0 0
18550 0 0 0 0 0 0 0 0 0 0 0 110 109 94 251 251 187
1856251 251 187 184 179 149 25 27 26 0 0 0 0 0 0 0 0 0
185799 98 80 251 251 187 251 251 187 251 251 187 251 251 187 156 151 111
185825 27 26 84 83 72 65 66 61 47 48 46 32 34 33 39 40 39
185972 73 67 55 57 54 40 41 39 30 32 31 23 25 24 18 22 22
186014 17 17 12 15 15 11 13 13 10 12 12 9 11 11 9 11 11
18619 11 11 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18628 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18638 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18648 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18659 11 11 28 31 30 41 42 42 47 48 46 55 56 53 58 59 55
1866137 133 100 251 251 187 251 251 187 251 251 187 210 208 158 137 133 100
186747 48 46 40 41 39 32 34 33 75 75 61 184 179 149 239 239 170
1868251 251 187 177 172 135 13 13 13 12 12 12 12 12 12 43 44 41
1869197 193 154 251 251 187 210 208 158 10 10 9 0 0 0 84 83 72
1870251 251 187 84 83 72 0 0 0 0 0 0 0 0 0 0 0 0
18710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
18726 7 7 11 11 11 17 17 17 20 20 20 23 24 24 27 29 28
187332 34 33 38 39 37 43 45 43 47 48 46 51 52 50 55 56 53
187458 59 55 58 59 55 55 57 54 55 56 53 47 48 46 41 42 42
187535 37 36 31 33 31 47 48 46 14 14 13 0 0 0 0 0 0
18760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18780 0 0
18790 0 0 0 0 0 0 0 0 66 65 55 99 98 80 20 20 20
18800 0 0 0 0 0 0 0 0 0 0 0 43 45 43 214 212 158
1881251 251 187 251 251 187 145 141 105 3 3 3 0 0 0 0 0 0
188248 49 45 184 179 149 239 239 170 251 251 187 239 239 170 177 172 135
188384 83 72 72 73 67 55 56 53 39 40 39 26 28 27 39 40 39
188468 70 65 51 52 50 39 40 39 28 31 30 22 24 23 17 20 20
188514 17 17 12 14 14 10 13 13 9 11 11 9 11 11 9 11 11
18868 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18878 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18888 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
18898 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
189027 29 28 40 41 39 46 47 45 51 52 50 55 57 54 63 64 60
1891131 127 93 197 193 154 210 208 158 197 193 154 168 163 120 96 95 69
189247 48 46 40 41 39 32 34 33 71 71 57 145 141 105 184 179 149
1893184 179 149 131 127 93 13 13 13 12 12 12 12 12 12 48 49 45
1894168 163 120 184 179 149 156 151 111 6 7 7 14 14 13 177 172 135
1895239 239 170 40 41 39 0 0 0 0 0 0 0 0 0 0 0 0
18960 0 0 0 0 0 3 3 3 6 7 7 11 11 11 16 16 16
189718 19 18 21 22 21 23 24 24 27 29 28 32 34 33 37 39 37
189841 42 42 43 45 43 47 48 46 51 52 50 51 52 50 51 52 50
189951 52 50 49 51 48 46 47 45 40 41 39 32 34 33 25 27 26
190020 20 20 14 14 13 2 2 2 0 0 0 0 0 0 0 0 0
19010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19030 0 0
19040 0 0 0 0 0 0 0 0 33 36 34 197 193 154 184 179 149
190541 42 42 0 0 0 0 0 0 0 0 0 3 3 3 184 179 149
1906251 251 187 251 251 187 184 179 149 48 49 45 0 0 0 0 0 0
190716 17 12 121 119 87 177 172 135 194 189 146 188 184 146 145 141 105
190882 81 62 63 64 60 46 47 45 31 33 31 21 22 21 35 37 36
190968 70 65 51 52 50 37 39 37 27 30 29 22 24 23 17 20 20
191013 16 16 12 14 14 10 13 13 9 11 11 8 10 10 8 10 10
19118 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19128 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19138 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19148 10 10 8 10 10 8 10 10 8 10 10 8 10 10 25 27 26
191538 39 37 43 45 43 51 52 50 55 56 53 60 60 56 63 64 60
191692 91 72 158 153 112 176 171 126 171 165 117 149 143 98 82 81 62
191744 46 43 38 39 37 30 32 31 71 71 57 131 127 93 160 154 106
1918149 143 98 82 81 62 13 13 13 12 12 12 12 12 12 46 47 43
1919121 119 87 134 131 96 96 95 69 7 7 6 38 39 37 131 127 93
1920145 141 105 12 13 12 0 0 0 1 1 1 3 3 3 6 7 7
192110 10 9 12 12 12 14 14 13 16 16 16 18 19 18 21 22 21
192222 24 23 26 28 27 30 31 28 33 36 34 37 39 37 40 41 39
192341 42 42 43 45 43 46 47 45 46 47 45 46 47 45 43 45 43
192441 42 42 37 39 37 31 33 31 26 28 27 21 22 21 16 16 16
19256 7 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19280 0 0
19290 0 0 0 0 0 0 0 0 0 0 0 177 172 135 251 251 187
1930197 193 154 27 29 28 0 0 0 0 0 0 0 0 0 110 109 94
1931239 239 170 239 239 170 184 179 149 87 86 72 2 2 1 0 0 0
19321 1 1 82 81 62 142 137 94 165 161 109 165 161 109 131 127 93
193375 75 61 55 56 53 37 39 37 25 27 26 19 20 19 32 34 33
193465 66 61 49 51 48 35 37 36 27 29 28 20 23 23 16 19 19
193513 16 16 13 13 13 10 12 12 9 11 11 8 10 10 8 10 10
19368 9 9 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19378 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19388 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19398 10 10 8 10 10 8 10 10 8 10 10 22 24 23 35 37 36
194041 42 42 47 48 46 55 56 53 58 59 55 63 64 60 65 66 61
194171 71 57 131 127 93 160 154 106 160 154 106 142 137 94 82 81 62
194246 47 43 40 41 39 33 36 34 66 65 55 125 122 87 149 143 98
1943142 137 94 82 81 62 17 17 17 18 19 17 14 14 13 46 47 43
1944118 116 76 125 122 87 96 95 69 16 17 12 71 71 57 103 101 77
194582 81 62 11 11 11 11 11 11 13 13 13 14 14 13 14 14 13
194615 15 15 16 16 16 17 17 17 19 20 19 21 22 21 23 24 24
194726 28 27 27 29 28 31 33 31 33 36 34 35 37 36 38 39 37
194839 40 39 39 40 39 38 39 37 37 39 37 35 37 36 31 33 31
194927 29 28 24 26 24 21 22 21 17 17 17 12 12 12 2 2 2
19500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19530 0 0
19540 0 0 0 0 0 0 0 0 0 0 0 68 70 65 251 251 187
1955251 251 187 156 151 111 2 2 1 0 0 0 0 0 0 43 44 41
1956177 172 135 184 179 149 158 153 112 103 101 77 19 20 18 0 0 0
19570 0 0 46 47 43 131 127 93 160 154 106 160 154 106 131 127 93
195871 71 57 43 45 43 30 32 31 21 22 21 16 16 16 26 28 27
195963 64 60 47 48 46 35 37 36 26 28 27 20 23 23 16 19 19
196013 16 16 13 13 13 10 12 12 9 11 11 8 10 10 8 10 10
19617 9 9 7 9 9 8 9 9 8 10 10 8 10 10 8 10 10
19628 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19638 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19648 10 10 8 10 10 8 10 10 20 20 20 33 36 34 40 41 39
196546 47 45 51 52 50 55 57 54 60 60 56 63 64 60 65 66 61
196666 65 55 118 116 76 151 147 98 165 161 109 151 147 98 121 119 87
196796 95 69 96 95 69 96 95 69 103 101 77 142 137 94 151 147 98
1968142 137 94 103 101 77 82 81 62 82 81 62 82 81 62 96 95 69
1969131 127 93 142 137 94 103 101 77 46 47 43 96 95 69 118 116 76
197071 71 57 14 14 13 14 14 13 15 15 15 15 15 15 16 16 16
197116 16 16 17 17 17 18 19 18 20 20 20 21 22 21 23 24 24
197225 27 26 27 29 28 30 31 28 30 32 31 31 33 31 31 33 31
197331 33 31 31 33 31 30 31 28 27 29 28 25 27 26 22 24 23
197420 20 20 16 16 16 13 13 13 6 7 7 0 0 0 0 0 0
19750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19780 0 0
197958 59 55 68 70 65 8 8 7 0 0 0 10 10 9 210 208 158
1980251 251 187 184 179 149 38 39 37 0 0 0 0 0 0 8 8 7
1981103 101 77 149 143 98 149 143 98 118 116 76 40 41 39 25 27 25
198253 55 47 82 81 62 144 139 99 165 161 109 165 161 109 142 137 94
198371 71 57 35 37 36 24 26 24 18 19 18 15 15 15 22 24 23
198463 64 60 46 47 45 33 36 34 26 28 27 20 23 22 17 18 17
198512 15 15 11 13 13 10 12 12 9 11 11 8 10 10 8 10 10
19867 9 9 7 9 9 7 9 9 7 9 9 8 9 9 8 10 10
19878 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19888 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
19898 10 10 8 10 10 16 16 16 30 31 28 35 37 36 41 42 42
199047 48 46 55 56 53 58 59 55 63 64 60 65 66 61 65 66 61
199161 61 53 103 101 77 151 147 98 171 165 117 171 165 117 168 163 120
1992158 153 112 158 153 112 155 149 109 151 147 98 151 147 98 160 154 106
1993151 147 98 149 143 98 142 137 94 149 143 98 149 143 98 149 143 98
1994155 149 109 151 147 98 131 127 93 103 101 77 125 122 87 118 116 76
199571 71 57 16 16 16 16 16 16 16 16 16 17 17 17 17 17 17
199617 17 17 17 17 17 18 19 18 19 20 19 20 20 20 21 22 21
199723 24 24 24 26 24 25 27 26 26 28 27 26 28 27 26 28 27
199825 27 26 24 26 24 22 24 23 21 22 21 19 20 19 16 16 16
199914 14 13 8 8 7 1 1 1 0 0 0 0 0 0 0 0 0
20000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20030 0 0
200420 20 20 184 179 149 168 163 120 21 22 21 0 0 0 105 104 92
2005177 172 135 145 141 105 71 71 57 0 0 0 0 0 0 0 0 0
200666 65 55 131 127 93 151 147 98 142 137 94 118 116 76 121 119 87
2007145 141 105 158 153 112 176 171 126 178 174 128 176 171 126 149 145 103
200896 95 69 31 33 31 21 22 21 16 16 16 14 14 13 18 19 18
200960 60 56 46 47 45 33 36 34 25 27 26 21 22 21 15 18 18
201012 15 15 11 13 13 9 11 11 8 10 10 8 10 10 8 9 9
20117 9 9 7 9 9 7 9 9 7 9 9 7 9 9 8 9 9
20128 9 9 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
20138 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
20148 10 10 10 12 12 26 28 27 31 33 31 38 39 37 43 45 43
201551 52 50 55 56 53 60 60 56 63 64 60 65 66 61 68 70 65
201663 64 60 96 95 69 158 153 112 178 174 128 188 184 146 194 189 146
2017194 189 146 188 184 146 184 181 136 176 171 126 171 165 117 173 167 111
2018173 167 111 165 161 109 171 165 117 174 170 121 176 171 126 178 174 128
2019178 174 128 174 170 121 160 154 106 149 143 98 149 143 98 125 122 87
202071 71 57 16 16 16 16 16 16 17 17 17 17 17 17 17 17 17
202117 17 17 17 17 17 17 17 17 18 19 18 19 20 19 20 20 20
202221 22 21 21 22 21 21 22 21 22 24 23 21 22 21 21 22 21
202321 22 21 19 20 19 18 19 18 16 16 16 14 14 13 11 11 11
20243 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20280 0 0
20290 0 0 105 104 92 197 193 154 110 109 94 9 9 8 36 38 35
2030121 119 87 131 127 93 96 95 69 18 19 17 30 31 28 66 65 55
203196 95 69 142 137 94 160 154 106 160 154 106 160 154 106 168 163 120
2032184 181 136 194 191 148 197 193 154 197 193 154 194 189 146 168 163 120
2033125 122 87 46 47 43 18 19 18 15 15 15 13 13 13 14 14 13
203455 57 54 43 45 43 32 34 33 25 27 26 18 22 22 17 17 17
203512 14 14 10 12 12 9 11 11 8 10 10 8 9 9 7 9 9
20366 8 8 7 9 9 7 9 9 7 9 9 7 9 9 7 9 9
20377 9 9 8 9 9 8 9 9 8 10 10 8 10 10 8 10 10
20388 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
20398 10 10 32 34 33 41 42 42 35 37 36 39 40 39 37 39 37
204035 37 36 55 57 54 60 60 56 63 64 60 65 66 61 65 66 61
204161 63 57 115 113 82 168 163 120 194 191 148 204 201 155 210 208 158
2042210 208 158 210 208 158 197 193 154 194 189 146 186 182 128 176 171 126
2043174 170 121 176 171 126 186 182 128 190 186 136 194 191 148 197 193 154
2044197 193 154 188 184 146 181 176 137 174 170 121 165 161 109 142 137 94
204582 81 62 24 26 24 16 16 16 16 16 16 16 16 16 16 16 16
204617 17 17 17 17 17 17 17 17 17 17 17 18 19 18 19 20 19
204719 20 19 19 20 19 20 20 20 19 20 19 19 20 19 18 19 18
204817 17 17 15 15 15 13 13 13 12 12 12 6 7 7 0 0 0
20490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20530 0 0
20540 0 0 17 18 17 137 133 100 115 113 82 53 55 47 19 20 18
2055103 101 77 144 139 99 137 133 100 115 113 82 137 133 100 156 151 111
2056158 153 112 164 159 111 171 165 117 174 170 121 178 174 128 194 189 146
2057204 201 155 214 212 158 214 212 158 214 212 158 210 208 158 188 184 146
2058158 153 112 87 86 72 17 17 17 13 13 13 13 13 13 15 15 15
205955 56 53 43 45 43 32 34 33 24 26 24 17 20 20 16 16 16
206012 14 14 10 12 12 8 10 10 8 10 10 7 9 9 6 8 8
20616 8 8 6 8 8 6 8 8 7 9 9 7 9 9 7 9 9
20627 9 9 7 9 9 7 9 9 7 9 9 8 9 9 8 10 10
20638 10 10 8 10 10 8 10 10 8 10 10 8 10 10 8 10 10
20648 10 10 110 109 94 84 83 72 49 51 48 26 28 27 8 10 10
20658 9 9 51 52 50 58 59 55 63 64 60 63 64 60 63 64 60
206666 65 55 134 131 96 181 176 137 210 208 158 214 212 158 239 239 170
2067239 239 170 224 223 159 210 208 158 204 201 155 194 189 146 186 182 128
2068186 182 128 184 181 136 194 189 146 204 201 155 210 208 158 210 208 158
2069210 208 158 210 208 158 197 193 154 190 186 136 176 171 126 155 149 109
2070118 116 76 36 38 35 15 15 15 16 16 16 16 16 16 16 16 16
207116 16 16 16 16 16 16 16 16 16 16 16 16 16 16 17 17 17
207217 17 17 17 17 17 17 17 17 16 16 16 16 16 16 15 15 15
207313 13 13 12 12 12 8 8 7 2 2 2 0 0 0 0 0 0
20740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20780 0 0
20790 0 0 0 0 0 53 55 47 103 101 77 96 95 69 53 55 47
2080103 101 77 158 153 112 177 172 135 184 179 149 188 184 146 197 193 154
2081194 189 146 190 186 136 184 181 136 184 181 136 194 189 146 210 208 158
2082214 212 158 239 239 170 251 251 187 251 251 187 224 223 159 204 201 155
2083177 172 135 121 119 87 30 31 28 13 13 13 12 12 12 39 40 39
208460 60 56 43 45 43 32 34 33 23 25 24 18 19 18 13 16 16
208513 13 13 9 11 11 8 10 10 8 9 9 6 8 8 6 8 8
20866 8 8 6 8 8 6 8 8 6 8 8 6 8 8 7 9 9
20877 9 9 7 9 9 7 9 9 7 9 9 7 9 9 7 9 9
20887 9 9 8 9 9 8 9 9 8 10 10 8 10 10 8 10 10
208914 17 17 197 193 154 158 153 112 55 57 54 7 9 9 7 9 9
20908 10 10 51 52 50 58 59 55 60 60 56 63 64 60 63 64 60
209171 71 57 155 149 109 194 191 148 214 212 158 251 251 187 251 251 187
2092251 251 187 251 251 187 239 239 170 210 208 158 197 193 154 190 186 136
2093190 186 136 194 189 146 204 201 155 210 208 158 224 223 159 239 239 170
2094239 239 170 224 223 159 210 208 158 204 201 155 190 186 136 164 159 111
2095125 122 87 40 41 39 15 15 15 15 15 15 15 15 15 15 15 15
209616 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
209716 16 16 16 16 16 15 15 15 14 14 13 13 13 13 12 12 12
20988 9 9 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0
20990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21030 0 0
21040 0 0 0 0 0 21 22 20 96 95 69 125 122 87 121 119 87
2105144 139 99 177 172 135 197 193 154 210 208 158 214 212 158 214 212 158
2106210 208 158 204 201 155 194 191 148 194 189 146 204 201 155 214 212 158
2107239 239 170 251 251 187 251 251 187 251 251 187 251 251 187 214 212 158
2108188 184 146 145 141 105 53 55 47 12 12 12 15 15 15 63 64 60
210963 64 60 41 42 42 31 33 31 23 24 24 17 18 17 12 15 15
211011 13 13 9 11 11 8 9 9 7 9 9 6 8 8 6 8 8
21116 7 7 6 7 7 6 8 8 6 8 8 6 8 8 6 8 8
21126 8 8 7 9 9 7 9 9 7 9 9 7 9 9 7 9 9
21137 9 9 7 9 9 7 9 9 7 9 9 7 9 9 8 8 7
211443 45 43 251 251 187 156 151 111 8 10 10 7 9 9 7 9 9
211521 22 21 51 52 50 55 56 53 55 57 54 58 59 55 58 59 55
211675 75 61 158 153 112 197 193 154 224 223 159 251 251 187 251 251 187
2117251 251 187 251 251 187 251 251 187 214 212 158 204 201 155 194 189 146
2118190 186 136 197 193 154 210 208 158 224 223 159 251 251 187 251 251 187
2119251 251 187 251 251 187 239 239 170 210 208 158 197 193 154 176 171 126
2120125 122 87 36 38 35 14 14 13 14 14 13 15 15 15 15 15 15
212115 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
212215 15 15 14 14 13 13 13 13 12 12 12 10 10 9 3 4 4
21230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21280 0 0
21290 0 0 0 0 0 7 7 5 71 71 57 131 127 93 158 153 112
2130177 172 135 197 193 154 214 212 158 239 239 170 251 251 187 251 251 187
2131238 237 168 210 208 158 204 201 155 197 193 154 204 201 155 214 212 158
2132251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 214 212 158
2133197 193 154 156 151 111 66 65 55 12 12 12 37 39 37 58 59 55
213458 59 55 41 42 42 31 33 31 22 24 23 17 17 17 12 14 14
213510 12 12 8 10 10 6 8 8 6 8 8 6 7 7 6 7 7
21366 7 7 5 7 7 6 7 7 6 7 7 6 8 8 6 8 8
21376 8 8 6 8 8 6 8 8 7 9 9 7 9 9 7 9 9
21387 9 9 6 8 8 6 8 8 6 8 8 6 8 8 6 8 8
213961 63 57 197 193 154 16 19 19 6 8 8 6 8 8 8 9 9
214041 42 42 47 48 46 51 52 50 51 52 50 55 56 53 55 56 53
214171 71 57 158 153 112 197 193 154 224 223 159 251 251 187 251 251 187
2142251 251 187 251 251 187 239 239 170 214 212 158 204 201 155 194 189 146
2143190 186 136 197 193 154 210 208 158 239 239 170 251 251 187 251 251 187
2144251 251 187 251 251 187 251 251 187 224 223 159 204 201 155 177 172 135
2145121 119 87 30 31 28 13 13 13 14 14 13 14 14 13 14 14 13
214614 14 13 14 14 13 15 15 15 15 15 15 14 14 13 13 13 13
214712 12 12 12 12 12 10 10 9 4 5 5 0 0 0 0 0 0
21480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21530 0 0
21540 0 0 0 0 0 0 0 0 48 49 45 131 127 93 174 170 121
2155194 189 146 210 208 158 239 239 170 251 251 187 251 251 187 251 251 187
2156251 251 187 214 212 158 204 201 155 197 193 154 204 201 155 210 208 158
2157239 239 170 251 251 187 251 251 187 251 251 187 239 239 170 214 212 158
2158194 191 148 156 151 111 71 71 57 19 20 19 51 52 50 51 52 50
215951 52 50 41 42 42 30 32 31 21 22 21 17 17 17 13 13 13
21609 11 11 8 9 9 6 8 8 6 7 7 6 7 7 5 7 7
21615 6 5 5 6 5 5 7 7 5 7 7 6 7 7 6 7 7
21626 8 8 6 8 8 6 8 8 6 7 7 6 7 7 6 7 7
21636 7 7 6 8 8 6 8 8 6 8 8 6 8 8 6 8 8
216455 56 53 43 45 43 6 8 8 6 8 8 6 8 8 47 48 46
216560 60 56 47 48 46 46 47 45 47 48 46 38 39 37 10 12 12
216666 65 55 145 141 105 197 193 154 214 212 158 251 251 187 251 251 187
2167251 251 187 251 251 187 224 223 159 210 208 158 194 191 148 184 181 136
2168184 181 136 194 189 146 204 201 155 224 223 159 251 251 187 251 251 187
2169251 251 187 251 251 187 251 251 187 239 239 170 210 208 158 181 176 137
2170115 113 82 21 22 20 13 13 13 13 13 13 13 13 13 13 13 13
217114 14 13 13 13 13 13 13 13 13 13 13 12 12 12 11 11 11
217210 10 9 6 7 7 1 1 1 0 0 0 0 0 0 0 0 0
21730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21780 0 0
21790 0 0 0 0 0 2 2 1 66 65 55 144 139 99 178 174 128
2180204 201 155 214 212 158 251 251 187 251 251 187 251 251 187 251 251 187
2181251 251 187 214 212 158 204 201 155 194 191 148 197 193 154 204 201 155
2182214 212 158 239 239 170 239 239 170 239 239 170 214 212 158 210 208 158
2183184 181 136 149 145 103 66 65 55 41 42 42 47 48 46 46 47 45
218443 45 43 39 40 39 28 31 30 21 22 21 16 16 16 10 12 12
21858 10 10 6 8 8 6 7 7 6 7 7 5 6 5 5 6 5
21865 6 5 5 6 5 5 6 5 5 6 5 5 7 7 5 7 7
21876 7 7 6 7 7 6 7 7 5 7 7 5 7 7 5 7 7
21885 7 7 6 7 7 6 7 7 6 7 7 6 7 7 6 8 8
21896 8 8 6 8 8 6 7 7 6 7 7 46 47 45 156 151 111
2190105 104 92 58 59 55 43 45 43 32 34 33 6 8 8 6 8 8
219149 51 48 125 122 87 181 176 137 204 201 155 214 212 158 239 239 170
2192239 239 170 214 212 158 210 208 158 197 193 154 181 176 137 176 171 126
2193176 171 126 184 181 136 197 193 154 210 208 158 239 239 170 251 251 187
2194251 251 187 251 251 187 251 251 187 251 251 187 210 208 158 177 172 135
219599 98 80 13 13 13 12 12 12 12 12 12 13 13 13 12 12 12
219612 12 12 12 12 12 11 11 11 11 11 11 8 9 9 4 5 5
21971 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22030 0 0
22040 0 0 0 0 0 1 1 0 61 61 53 142 137 94 181 176 137
2205204 201 155 224 223 159 251 251 187 251 251 187 251 251 187 251 251 187
2206251 251 187 214 212 158 197 193 154 190 186 136 184 181 136 188 184 146
2207197 193 154 204 201 155 210 208 158 210 208 158 204 201 155 194 189 146
2208176 171 126 134 131 96 66 65 55 43 45 43 41 42 42 39 40 39
220935 37 36 33 36 34 27 29 28 20 20 20 15 15 15 9 11 11
22108 9 9 6 7 7 5 6 5 5 6 5 4 5 5 4 5 5
22114 5 5 4 5 5 4 5 5 4 5 5 5 6 5 4 5 5
22124 5 5 5 6 5 4 5 5 5 6 5 5 6 5 5 6 5
22135 7 7 5 7 7 5 7 7 5 7 7 5 7 7 5 7 7
22146 7 7 6 7 7 6 7 7 28 31 30 184 179 149 184 179 149
2215145 141 105 84 83 72 27 29 28 5 7 7 5 6 5 16 16 16
221643 44 41 96 95 69 158 153 112 188 184 146 204 201 155 210 208 158
2217204 201 155 197 193 154 184 179 149 177 172 135 168 163 120 164 159 111
2218164 159 111 174 170 121 184 181 136 197 193 154 214 212 158 251 251 187
2219251 251 187 251 251 187 251 251 187 251 251 187 210 208 158 177 172 135
222071 71 57 11 11 11 12 12 12 11 11 11 11 11 11 11 11 11
222110 10 9 10 10 9 8 8 7 3 4 4 0 0 0 0 0 0
22220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22280 0 0
22290 0 0 0 0 0 0 0 0 31 33 31 121 119 87 176 171 126
2230197 193 154 214 212 158 251 251 187 251 251 187 251 251 187 251 251 187
2231239 239 170 210 208 158 194 189 146 178 174 128 174 170 121 176 171 126
2232177 172 135 181 176 137 184 179 149 184 179 149 181 176 137 178 174 128
2233158 153 112 121 119 87 53 55 47 37 39 37 33 36 34 30 32 31
223427 29 28 25 27 26 24 26 24 19 20 19 13 13 13 8 10 10
22356 8 8 6 7 7 5 6 5 4 5 5 4 5 5 4 5 5
22364 5 5 4 5 5 4 5 5 3 4 4 3 4 4 4 5 5
22374 5 5 4 5 5 4 5 5 4 5 5 4 5 5 4 5 5
22385 6 5 5 6 5 5 6 5 5 6 5 5 6 5 5 6 5
22395 6 5 5 6 5 12 14 14 145 141 105 184 179 149 177 172 135
224090 89 73 21 22 21 5 6 5 5 6 5 4 5 5 37 39 37
224138 39 37 61 61 53 134 131 96 168 163 120 184 181 136 188 184 146
2242184 179 149 177 172 135 168 163 120 164 159 111 155 149 109 151 147 98
2243151 147 98 164 159 111 176 171 126 184 179 149 210 208 158 239 239 170
2244251 251 187 251 251 187 251 251 187 239 239 170 210 208 158 158 153 112
224546 47 43 10 10 9 10 10 9 10 10 9 8 9 9 8 9 9
22466 7 7 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0
22470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22530 0 0
22540 0 0 0 0 0 0 0 0 13 12 7 82 81 62 158 153 112
2255188 184 146 210 208 158 239 239 170 251 251 187 251 251 187 251 251 187
2256224 223 159 204 201 155 184 181 136 171 165 117 164 159 111 160 154 106
2257158 153 112 164 159 111 168 163 120 168 163 120 168 163 120 164 159 111
2258142 137 94 96 95 69 43 44 41 27 29 28 26 28 27 23 24 24
225921 22 21 18 19 18 17 17 17 18 19 18 13 13 13 8 8 7
22606 7 7 5 6 5 4 5 5 3 4 4 3 4 4 3 4 4
22613 4 4 3 4 4 3 3 3 3 3 3 3 4 4 3 4 4
22623 4 4 3 4 4 4 5 5 4 5 5 4 5 5 4 5 5
22634 5 5 4 5 5 4 5 5 4 5 5 4 5 5 4 5 5
22644 5 5 4 5 5 4 5 5 4 5 5 4 5 5 4 5 5
22654 5 5 4 5 5 4 5 5 4 5 5 31 33 31 65 66 61
226637 39 37 38 39 37 96 95 69 144 139 99 168 163 120 174 170 121
2267168 163 120 164 159 111 155 149 109 149 145 103 149 143 98 142 137 94
2268149 143 98 151 147 98 164 159 111 177 172 135 197 193 154 210 208 158
2269251 251 187 251 251 187 251 251 187 239 239 170 197 193 154 137 133 100
227024 26 24 8 9 9 8 9 9 8 8 7 6 7 7 2 2 2
22710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22780 0 0
22790 0 0 0 0 0 0 0 0 0 0 0 46 47 43 125 122 87
2280176 171 126 197 193 154 210 208 158 239 239 170 251 251 187 239 239 170
2281214 212 158 197 193 154 181 176 137 164 159 111 151 147 98 149 143 98
2282149 143 98 149 143 98 149 145 103 155 149 109 160 154 106 149 143 98
2283118 116 76 82 81 62 30 31 28 21 22 21 19 20 19 17 17 17
228414 14 13 12 12 12 10 10 9 12 12 12 10 12 12 6 8 8
22854 5 5 3 4 4 3 4 4 3 4 4 3 3 3 3 3 3
22863 3 3 3 3 3 3 3 3 3 3 3 2 3 3 2 3 3
22873 4 4 3 4 4 3 4 4 3 4 4 3 4 4 4 5 5
22884 5 5 3 4 4 3 4 4 3 4 4 3 4 4 3 4 4
22894 5 5 4 5 5 4 5 5 4 5 5 4 5 5 4 5 5
22904 5 5 3 4 4 3 4 4 23 24 24 110 109 94 72 73 67
229139 40 39 22 24 23 46 47 43 103 101 77 142 137 94 155 149 109
2292160 154 106 155 149 109 149 143 98 142 137 94 142 137 94 142 137 94
2293142 137 94 149 143 98 155 149 109 176 171 126 184 179 149 210 208 158
2294239 239 170 251 251 187 251 251 187 214 212 158 184 179 149 105 104 92
229510 10 9 6 7 7 3 4 4 1 1 1 0 0 0 0 0 0
22960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23030 0 0
23040 0 0 0 0 0 0 0 0 0 0 0 12 12 9 82 81 62
2305149 145 103 181 176 137 197 193 154 210 208 158 214 212 158 214 212 158
2306210 208 158 197 193 154 177 172 135 158 153 112 149 143 98 142 137 94
2307142 137 94 142 137 94 149 143 98 151 147 98 151 147 98 131 127 93
2308103 101 77 71 71 57 22 24 23 15 15 15 13 13 13 11 11 11
23098 9 9 6 7 7 6 7 7 4 5 5 8 9 9 6 7 7
23104 5 5 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2
23112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3
23122 3 3 2 3 3 2 3 3 3 4 4 3 4 4 3 4 4
23133 4 4 3 4 4 3 3 3 3 4 4 3 4 4 3 4 4
23143 4 4 3 4 4 3 4 4 3 4 4 3 4 4 3 4 4
23153 4 4 3 4 4 21 22 21 145 141 105 145 141 105 72 73 67
231617 18 17 3 4 4 21 22 20 66 65 55 118 116 76 142 137 94
2317149 143 98 151 147 98 149 143 98 142 137 94 142 137 94 142 137 94
2318142 137 94 149 143 98 155 149 109 168 163 120 184 179 149 210 208 158
2319239 239 170 251 251 187 251 251 187 210 208 158 177 172 135 71 71 57
23203 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23280 0 0
23290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 38 35
2330115 113 82 158 153 112 181 176 137 197 193 154 204 201 155 210 208 158
2331204 201 155 188 184 146 177 172 135 164 159 111 149 145 103 142 137 94
2332142 137 94 142 137 94 149 143 98 151 147 98 149 143 98 125 122 87
233396 95 69 61 61 53 16 17 12 8 9 9 8 8 7 6 7 7
23344 5 5 3 4 4 3 3 3 3 3 3 3 3 3 5 6 5
23353 4 4 2 3 3 2 2 2 2 2 2 2 2 2 2 2 2
23362 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2
23372 2 2 2 2 2 2 3 3 2 3 3 2 3 3 2 3 3
23383 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
23393 3 3 2 3 3 2 3 3 3 4 4 3 4 4 3 4 4
23403 4 4 3 4 4 3 4 4 8 9 9 8 8 7 3 3 3
23413 3 3 3 3 3 9 9 8 36 38 35 82 81 62 118 116 76
2342142 137 94 151 147 98 151 147 98 151 147 98 149 143 98 149 143 98
2343149 143 98 151 147 98 160 154 106 176 171 126 188 184 146 210 208 158
2344239 239 170 251 251 187 239 239 170 210 208 158 156 151 111 31 33 31
23450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23530 0 0
23540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 5
235566 65 55 125 122 87 158 153 112 181 176 137 194 189 146 197 193 154
2356197 193 154 184 179 149 177 172 135 168 163 120 156 151 111 151 147 98
2357151 147 98 151 147 98 151 147 98 161 156 96 149 143 98 118 116 76
235882 81 62 53 55 47 12 12 9 4 5 5 3 4 4 3 3 3
23593 3 3 3 3 3 2 2 2 2 2 2 1 1 1 1 2 2
23603 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
23611 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 2
23621 2 2 1 2 2 1 2 2 2 2 2 2 2 2 2 3 3
23632 3 3 2 3 3 2 3 3 2 3 3 2 2 2 2 2 2
23642 3 3 2 3 3 2 3 3 2 3 3 2 3 3 2 3 3
23652 3 3 2 3 3 2 3 3 2 3 3 2 3 3 3 3 3
23663 3 3 3 3 3 72 73 67 61 61 53 53 55 47 96 95 69
2367131 127 93 151 147 98 161 156 96 161 156 96 151 147 98 151 147 98
2368161 156 96 160 154 106 164 159 111 177 172 135 197 193 154 210 208 158
2369239 239 170 251 251 187 224 223 159 197 193 154 131 127 93 9 9 8
23700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23780 0 0
23790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
238024 26 24 82 81 62 131 127 93 164 159 111 178 174 128 188 184 146
2381188 184 146 188 184 146 181 176 137 176 171 126 168 163 120 164 159 111
2382160 154 106 160 154 106 160 154 106 160 154 106 151 147 98 125 122 87
238382 81 62 61 61 53 12 12 9 3 3 3 3 3 3 2 2 2
23842 2 2 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0
23850 0 0 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1
23861 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
23871 1 1 1 1 1 1 2 2 1 2 2 1 2 2 1 2 2
23881 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
23892 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
23902 3 3 2 3 3 2 3 3 2 3 3 2 3 3 2 3 3
23912 3 3 30 32 31 72 73 67 31 33 31 36 38 35 82 81 62
2392118 116 76 149 143 98 161 156 96 161 156 96 161 156 96 160 154 106
2393165 161 109 165 161 109 176 171 126 188 184 146 204 201 155 214 212 158
2394239 239 170 239 239 170 214 212 158 184 179 149 82 81 62 0 0 0
23950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24030 0 0
24040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24052 2 2 43 44 41 96 95 69 131 127 93 160 154 106 176 171 126
2406184 181 136 184 181 136 184 181 136 181 176 137 178 174 128 174 170 121
2407171 165 117 173 167 111 173 167 111 173 167 111 160 154 106 131 127 93
240896 95 69 66 65 55 16 17 12 2 2 2 1 1 1 1 1 1
24091 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
24100 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
24111 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24121 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24131 2 2 1 2 2 1 2 2 1 2 2 1 2 2 2 2 2
24142 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
24152 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
24162 2 2 2 2 2 2 2 2 10 9 6 30 31 28 71 71 57
2417118 116 76 149 143 98 165 161 109 165 161 109 165 161 109 173 167 111
2418173 167 111 176 171 126 184 181 136 197 193 154 210 208 158 224 223 159
2419251 251 187 239 239 170 210 208 158 168 163 120 40 41 39 0 0 0
24200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24280 0 0
24290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24300 0 0 13 12 7 61 61 53 96 95 69 131 127 93 160 154 106
2431176 171 126 184 181 136 184 181 136 188 184 146 184 181 136 184 181 136
2432184 181 136 186 182 128 186 182 128 178 174 128 174 170 121 149 145 103
2433118 116 76 82 81 62 21 22 20 1 1 1 1 1 1 0 0 0
24340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24350 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1
24361 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24371 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24381 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2
24391 2 2 1 2 2 1 2 2 1 2 2 1 2 2 2 2 2
24402 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
24412 2 2 2 2 2 2 2 2 3 3 3 30 31 28 66 65 55
2442118 116 76 149 143 98 165 161 109 173 167 111 173 167 111 174 170 121
2443186 182 128 190 186 136 197 193 154 210 208 158 224 223 159 251 251 187
2444251 251 187 239 239 170 197 193 154 137 133 100 12 12 9 0 0 0
24450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24530 0 0
24540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24550 0 0 0 0 0 30 31 28 71 71 57 103 101 77 134 131 96
2456164 159 111 176 171 126 184 181 136 188 184 146 194 189 146 197 193 154
2457197 193 154 197 193 154 194 191 148 194 189 146 190 186 136 176 171 126
2458145 141 105 103 101 77 40 41 39 0 0 0 0 0 0 0 0 0
24590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24611 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24621 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24631 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24641 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 2
24651 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
24661 2 2 1 2 2 1 2 2 1 2 2 30 31 28 71 71 57
2467118 116 76 160 154 106 173 167 111 178 174 128 186 182 128 190 186 136
2468194 191 148 204 201 155 210 208 158 224 223 159 251 251 187 251 251 187
2469251 251 187 214 212 158 184 179 149 84 83 72 0 0 0 0 0 0
24700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24780 0 0
24790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24800 0 0 0 0 0 5 5 3 43 44 41 82 81 62 103 101 77
2481142 137 94 165 161 109 178 174 128 190 186 136 197 193 154 204 201 155
2482210 208 158 210 208 158 210 208 158 210 208 158 210 208 158 197 193 154
2483177 172 135 145 141 105 79 78 62 5 4 3 0 0 0 0 0 0
24840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24860 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
24871 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24881 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24891 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24901 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24911 1 1 1 1 1 1 2 2 1 2 2 30 31 28 82 81 62
2492142 137 94 165 161 109 178 174 128 190 186 136 194 191 148 204 201 155
2493210 208 158 214 212 158 239 239 170 251 251 187 251 251 187 251 251 187
2494251 251 187 210 208 158 168 163 120 36 38 35 0 0 0 0 0 0
24950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25030 0 0
25040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25050 0 0 0 0 0 0 0 0 16 17 12 53 55 47 82 81 62
2506118 116 76 151 147 98 171 165 117 184 181 136 194 191 148 210 208 158
2507214 212 158 224 223 159 239 239 170 239 239 170 224 223 159 214 212 158
2508197 193 154 176 171 126 115 113 82 24 26 24 0 0 0 0 0 0
25090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25110 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1
25121 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25131 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25141 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25151 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25161 1 1 1 1 1 1 1 1 1 1 1 40 41 39 103 101 77
2517151 147 98 176 171 126 190 186 136 197 193 154 210 208 158 214 212 158
2518239 239 170 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
2519239 239 170 197 193 154 110 109 94 3 4 3 0 0 0 0 0 0
25200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25280 0 0
25290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25300 0 0 0 0 0 0 0 0 0 0 0 30 31 28 66 65 55
253196 95 69 125 122 87 160 154 106 178 174 128 194 189 146 204 201 155
2532214 212 158 239 239 170 251 251 187 251 251 187 251 251 187 239 239 170
2533210 208 158 188 184 146 149 145 103 61 61 53 0 0 0 0 0 0
25340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25370 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25381 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25391 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25401 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25411 1 1 1 1 1 1 1 1 1 1 1 61 61 53 131 127 93
2542164 159 111 184 181 136 197 193 154 210 208 158 224 223 159 251 251 187
2543251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 251 251 187
2544210 208 158 168 163 120 43 44 41 0 0 0 0 0 0 0 0 0
25450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25530 0 0
25540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25550 0 0 0 0 0 0 0 0 0 0 0 4 3 2 36 38 35
255671 71 57 96 95 69 142 137 94 165 161 109 184 181 136 197 193 154
2557210 208 158 239 239 170 251 251 187 251 251 187 251 251 187 251 251 187
2558214 212 158 197 193 154 168 163 120 103 101 77 7 7 5 0 0 0
25590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
25631 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25641 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25651 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25661 1 1 0 0 0 0 0 0 0 0 0 82 81 62 142 137 94
2567174 170 121 194 189 146 210 208 158 224 223 159 251 251 187 251 251 187
2568251 251 187 251 251 187 251 251 187 251 251 187 251 251 187 224 223 159
2569184 179 149 99 98 80 3 3 3 0 0 0 0 0 0 0 0 0
25700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25780 0 0
25790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 5
258143 44 41 82 81 62 118 116 76 142 137 94 171 165 117 190 186 136
2582204 201 155 224 223 159 251 251 187 251 251 187 251 251 187 251 251 187
2583214 212 158 197 193 154 174 170 121 125 122 87 30 31 28 0 0 0
25840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
25891 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
25900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25910 0 0 0 0 0 0 0 0 3 4 3 82 81 62 149 143 98
2592176 171 126 194 191 148 210 208 158 239 239 170 251 251 187 251 251 187
2593251 251 187 251 251 187 251 251 187 251 251 187 239 239 170 204 201 155
2594145 141 105 30 31 28 0 0 0 0 0 0 0 0 0 0 0 0
25950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26030 0 0
26040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
260610 9 6 46 47 43 82 81 62 118 116 76 149 143 98 174 170 121
2607194 189 146 210 208 158 224 223 159 251 251 187 251 251 187 224 223 159
2608210 208 158 194 191 148 174 170 121 134 131 96 53 55 47 0 0 0
26090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26160 0 0 0 0 0 0 0 0 7 7 5 96 95 69 149 143 98
2617176 171 126 194 191 148 210 208 158 239 239 170 251 251 187 251 251 187
2618251 251 187 251 251 187 251 251 187 239 239 170 210 208 158 177 172 135
261975 75 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26280 0 0
26290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26310 0 0 10 9 6 46 47 43 82 81 62 118 116 76 149 143 98
2632176 171 126 194 191 148 210 208 158 214 212 158 214 212 158 210 208 158
2633197 193 154 184 181 136 164 159 111 131 127 93 53 55 47 0 0 0
26340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26410 0 0 0 0 0 0 0 0 7 7 5 96 95 69 149 143 98
2642174 170 121 194 189 146 204 201 155 214 212 158 239 239 170 251 251 187
2643251 251 187 251 251 187 239 239 170 210 208 158 184 179 149 110 109 94
264412 12 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26530 0 0
26540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26560 0 0 0 0 0 10 9 6 43 44 41 82 81 62 115 113 82
2657144 139 99 168 163 120 188 184 146 197 193 154 197 193 154 194 189 146
2658184 181 136 174 170 121 151 147 98 118 116 76 36 38 35 0 0 0
26590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26660 0 0 0 0 0 0 0 0 4 3 2 82 81 62 142 137 94
2667171 165 117 186 182 128 194 191 148 210 208 158 214 212 158 224 223 159
2668239 239 170 224 223 159 210 208 158 184 179 149 137 133 100 36 38 35
26690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26780 0 0
26790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26810 0 0 0 0 0 0 0 0 7 7 5 36 38 35 71 71 57
2682103 101 77 131 127 93 155 149 109 168 163 120 168 163 120 168 163 120
2683164 159 111 149 143 98 125 122 87 82 81 62 13 12 7 0 0 0
26840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26910 0 0 0 0 0 0 0 0 0 0 0 61 61 53 125 122 87
2692160 154 106 174 170 121 184 181 136 194 189 146 204 201 155 210 208 158
2693210 208 158 204 201 155 184 179 149 145 141 105 61 61 53 0 0 0
26940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27030 0 0
27040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27060 0 0 0 0 0 0 0 0 0 0 0 3 3 2 30 31 28
270761 61 53 82 81 62 103 101 77 121 119 87 125 122 87 125 122 87
2708118 116 76 103 101 77 79 78 62 24 26 24 0 0 0 0 0 0
27090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27160 0 0 0 0 0 0 0 0 0 0 0 25 27 25 96 95 69
2717142 137 94 160 154 106 171 165 117 178 174 128 184 181 136 184 181 136
2718181 176 137 177 172 135 145 141 105 75 75 61 5 5 3 0 0 0
27190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27280 0 0
27290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
273216 17 12 40 41 39 61 61 53 71 71 57 71 71 57 71 71 57
273366 65 55 43 44 41 12 12 9 0 0 0 0 0 0 0 0 0
27340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27410 0 0 0 0 0 0 0 0 0 0 0 1 1 1 46 47 43
274296 95 69 125 122 87 142 137 94 149 145 103 155 149 109 155 149 109
2743145 141 105 121 119 87 66 65 55 7 7 5 0 0 0 0 0 0
27440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27530 0 0
27540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27570 0 0 1 1 1 16 17 12 24 26 24 25 27 25 19 20 18
27587 7 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 1
276725 27 25 61 61 53 82 81 62 96 95 69 96 95 69 82 81 62
276861 61 53 25 27 25 2 2 1 0 0 0 0 0 0 0 0 0
27690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27780 0 0
27790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27920 0 0 0 0 0 5 6 5 13 12 7 10 9 6 3 4 3
27930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28030 0 0
28040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28280 0 0
diff --git a/drivers/video/logo/logo_linux_vga16.ppm b/drivers/video/logo/logo_linux_vga16.ppm
index 1850c15e6feb..12ac3a5454c0 100644
--- a/drivers/video/logo/logo_linux_vga16.ppm
+++ b/drivers/video/logo/logo_linux_vga16.ppm
@@ -1,1604 +1,2739 @@
1P3 1P3
2# Standard 16-color Linux logo 2142 114
380 80
4255 3255
5 0 0 0 0 0 0 0 0 0 0 0 0 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 0 0 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0 0 0 0 70 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 0 0 0 0 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10 0 0 0 0 0 0 0 0 0 0 0 0 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12 0 0 0 0 0 0 0 0 0 0 0 0 110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
13 0 0 0 0 0 0 0 0 0 0 0 0 120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
14 0 0 0 0 0 0 0 0 0 0 0 0 130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
15 0 0 0 0 0 0 0 0 0 0 0 0 140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16 0 0 0 0 0 0 0 0 0 0 0 0 150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17 0 0 0 0 0 0 0 0 0 0 0 0 160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18 0 0 0 0 0 0 0 0 0 0 0 0 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19 0 0 0 0 0 0 0 0 0 0 0 0 180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20 0 0 0 0 0 0 0 0 0 0 0 0 190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21 0 0 0 0 0 0 0 0 0 0 0 0 200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22 0 0 0 0 0 0 0 0 0 0 0 0 210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23 0 0 0 0 0 0 0 0 0 0 0 0 220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24 0 0 0 0 0 0 0 0 0 0 0 0 230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25 0 0 0 0 0 0 0 0 0 0 0 0 240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26 0 0 0 0 0 0 0 0 0 0 0 0 250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27 0 0 0 0 0 0 0 0 0 0 0 0 260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28 0 0 0 0 0 0 0 0 0 0 0 0 270 0 0 0 0 0 0 0 0 0 0 0
29 0 0 0 0 0 0 0 0 0 0 0 0 280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
30 0 0 0 0 0 0 0 0 0 0 0 0 290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31 0 0 0 0 0 0 0 0 0 0 0 0 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
32 0 0 0 0 0 0 0 0 0 0 0 0 310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
33 0 0 0 0 0 0 0 0 0 0 0 0 320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
34 0 0 0 0 0 0 0 0 0 0 0 0 330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
35 0 0 0 0 0 0 0 0 0 0 0 0 340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
36 0 0 0 0 0 0 0 0 0 0 0 0 350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
37 0 0 0 0 0 0 0 0 0 0 0 0 360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
38 0 0 0 0 0 0 0 0 0 0 0 0 370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
39 0 0 0 0 0 0 0 0 0 0 0 0 380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
40 0 0 0 0 0 0 0 0 0 0 0 0 390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
41 0 0 0 0 0 0 0 0 0 0 0 0 400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
42 0 0 0 0 0 0 0 0 0 0 0 0 410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
43 0 0 0 0 0 0 0 0 0 0 0 0 420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
44 0 0 0 0 0 0 0 0 0 0 0 0 430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
45 0 0 0 0 0 0 0 0 0 0 0 0 440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46 0 0 0 0 0 0 0 0 0 0 0 0 450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47 0 0 0 0 0 0 0 0 0 0 0 0 460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
48 0 0 0 0 0 0 0 0 0 0 0 0 470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49 0 0 0 0 0 0 0 0 0 0 0 0 480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50 0 0 0 0 0 0 0 0 0 0 0 0 490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
51 0 0 0 0 0 0 0 0 0 0 0 0 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52 0 0 0 0 0 0 0 0 0 0 0 0 510 0 0 0 0 0 0 0 0 0 0 0
53 0 0 0 0 0 0 0 0 0 0 0 0 520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
54 85 85 85 85 85 85 85 85 85 85 85 85 530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
55 85 85 85 85 85 85 85 85 85 0 0 0 540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
56 0 0 0 0 0 0 0 0 0 0 0 0 550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
57 0 0 0 0 0 0 0 0 0 0 0 0 560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
58 0 0 0 0 0 0 0 0 0 0 0 0 570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
59 0 0 0 0 0 0 0 0 0 0 0 0 580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
60 0 0 0 0 0 0 0 0 0 0 0 0 590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
61 0 0 0 0 0 0 0 0 0 0 0 0 600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
62 0 0 0 0 0 0 0 0 0 0 0 0 610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
63 0 0 0 0 0 0 0 0 0 0 0 0 620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
64 0 0 0 0 0 0 0 0 0 0 0 0 630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
65 0 0 0 0 0 0 0 0 0 0 0 0 640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
66 0 0 0 0 0 0 0 0 0 0 0 0 650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
67 0 0 0 0 0 0 0 0 0 0 0 0 660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
68 0 0 0 0 0 0 0 0 0 0 0 0 670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
69 0 0 0 0 0 0 0 0 0 0 0 0 680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
70 0 0 0 0 0 0 0 0 0 0 0 0 690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
71 0 0 0 0 0 0 0 0 0 0 0 0 700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
72 0 0 0 0 0 0 0 0 0 0 0 0 710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
73 0 0 0 0 0 0 85 85 85 85 85 85 720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
74 85 85 85 0 0 0 0 0 0 0 0 0 730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
75 0 0 0 0 0 0 0 0 0 85 85 85 740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
76 85 85 85 85 85 85 0 0 0 0 0 0 750 0 0 0 0 0 0 0 0 0 0 0
77 0 0 0 0 0 0 0 0 0 0 0 0 760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
78 0 0 0 0 0 0 0 0 0 0 0 0 770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
79 0 0 0 0 0 0 0 0 0 0 0 0 780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
80 0 0 0 0 0 0 0 0 0 0 0 0 790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
81 0 0 0 0 0 0 0 0 0 0 0 0 800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
82 0 0 0 0 0 0 0 0 0 0 0 0 810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
83 0 0 0 0 0 0 0 0 0 0 0 0 820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
84 0 0 0 0 0 0 0 0 0 0 0 0 830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
85 0 0 0 0 0 0 0 0 0 0 0 0 840 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
86 0 0 0 0 0 0 0 0 0 0 0 0 8585 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
87 0 0 0 0 0 0 0 0 0 0 0 0 860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
88 0 0 0 0 0 0 0 0 0 0 0 0 870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
89 0 0 0 0 0 0 0 0 0 0 0 0 880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
90 0 0 0 0 0 0 0 0 0 0 0 0 890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
91 0 0 0 0 0 0 0 0 0 0 0 0 900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
92 0 0 0 0 0 0 0 0 0 0 0 0 910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
93 0 0 0 85 85 85 0 0 0 0 0 0 920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
94 0 0 0 0 0 0 0 0 0 0 0 0 930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
95 0 0 0 0 0 0 0 0 0 0 0 0 940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
96 0 0 0 0 0 0 85 85 85 85 85 85 950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
97 0 0 0 0 0 0 0 0 0 0 0 0 960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
98 0 0 0 0 0 0 0 0 0 0 0 0 970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
99 0 0 0 0 0 0 0 0 0 0 0 0 980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
100 0 0 0 0 0 0 0 0 0 0 0 0 990 0 0 0 0 0 0 0 0 0 0 0
101 0 0 0 0 0 0 0 0 0 0 0 0 1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
102 0 0 0 0 0 0 0 0 0 0 0 0 1010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
103 0 0 0 0 0 0 0 0 0 0 0 0 1020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
104 0 0 0 0 0 0 0 0 0 0 0 0 1030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
105 0 0 0 0 0 0 0 0 0 0 0 0 1040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
106 0 0 0 0 0 0 0 0 0 0 0 0 1050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
107 0 0 0 0 0 0 0 0 0 0 0 0 1060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
108 0 0 0 0 0 0 0 0 0 0 0 0 1070 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
109 0 0 0 0 0 0 0 0 0 0 0 0 10885 85 85 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
110 0 0 0 0 0 0 0 0 0 0 0 0 1090 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
111 0 0 0 0 0 0 0 0 0 0 0 0 1100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
112 0 0 0 0 0 0 0 0 0 0 0 0 1110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
113 85 85 85 0 0 0 0 0 0 0 0 0 1120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
114 0 0 0 0 0 0 0 0 0 0 0 0 1130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
115 0 0 0 0 0 0 0 0 0 0 0 0 1140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
116 0 0 0 0 0 0 0 0 0 85 85 85 1150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
117 85 85 85 0 0 0 0 0 0 0 0 0 1160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
118 0 0 0 0 0 0 0 0 0 0 0 0 1170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
119 0 0 0 0 0 0 0 0 0 0 0 0 1180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
120 0 0 0 0 0 0 0 0 0 0 0 0 1190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
121 0 0 0 0 0 0 0 0 0 0 0 0 1200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
122 0 0 0 0 0 0 0 0 0 0 0 0 1210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
123 0 0 0 0 0 0 0 0 0 0 0 0 1220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
124 0 0 0 0 0 0 0 0 0 0 0 0 1230 0 0 0 0 0 0 0 0 0 0 0
125 0 0 0 0 0 0 0 0 0 0 0 0 1240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
126 0 0 0 0 0 0 0 0 0 0 0 0 1250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
127 0 0 0 0 0 0 0 0 0 0 0 0 1260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
128 0 0 0 0 0 0 0 0 0 0 0 0 1270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
129 0 0 0 0 0 0 0 0 0 0 0 0 1280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
130 0 0 0 0 0 0 0 0 0 0 0 0 1290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
131 0 0 0 0 0 0 0 0 0 0 0 0 1300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
132 0 0 0 0 0 0 0 0 0 85 85 85 13185 85 85 85 85 85 85 85 85 0 0 0 85 85 85 85 85 85
133 0 0 0 0 0 0 0 0 0 0 0 0 1320 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
134 0 0 0 0 0 0 0 0 0 0 0 0 13385 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
135 0 0 0 0 0 0 0 0 0 0 0 0 1340 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
136 0 0 0 0 0 0 0 0 0 0 0 0 1350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
137 85 85 85 85 85 85 0 0 0 0 0 0 1360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
138 0 0 0 0 0 0 0 0 0 0 0 0 1370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
139 0 0 0 0 0 0 0 0 0 0 0 0 1380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
140 0 0 0 0 0 0 0 0 0 0 0 0 1390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
141 0 0 0 0 0 0 0 0 0 0 0 0 1400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
142 0 0 0 0 0 0 0 0 0 0 0 0 1410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
143 0 0 0 0 0 0 0 0 0 0 0 0 1420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
144 0 0 0 0 0 0 0 0 0 0 0 0 1430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
145 0 0 0 0 0 0 0 0 0 0 0 0 1440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
146 0 0 0 0 0 0 0 0 0 0 0 0 1450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
147 0 0 0 0 0 0 0 0 0 0 0 0 1460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
148 0 0 0 0 0 0 0 0 0 0 0 0 1470 0 0 0 0 0 0 0 0 0 0 0
149 0 0 0 0 0 0 0 0 0 0 0 0 1480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
150 0 0 0 0 0 0 0 0 0 0 0 0 1490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
151 0 0 0 0 0 0 0 0 0 0 0 0 1500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
152 0 0 0 0 0 0 0 0 0 85 85 85 1510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
153 0 0 0 0 0 0 0 0 0 0 0 0 1520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
154 0 0 0 0 0 0 0 0 0 0 0 0 1530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
155 0 0 0 0 0 0 0 0 0 0 0 0 1540 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
156 85 85 85 170 170 170 0 0 0 0 0 0 15585 85 85 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
157 0 0 0 85 85 85 0 0 0 0 0 0 15685 85 85 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
158 0 0 0 0 0 0 0 0 0 0 0 0 1570 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
159 0 0 0 0 0 0 0 0 0 0 0 0 1580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
160 0 0 0 0 0 0 0 0 0 0 0 0 1590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
161 0 0 0 0 0 0 0 0 0 0 0 0 1600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
162 0 0 0 0 0 0 0 0 0 0 0 0 1610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
163 0 0 0 0 0 0 0 0 0 0 0 0 1620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
164 0 0 0 0 0 0 0 0 0 0 0 0 1630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
165 0 0 0 0 0 0 0 0 0 0 0 0 1640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
166 0 0 0 0 0 0 0 0 0 0 0 0 1650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
167 0 0 0 0 0 0 0 0 0 0 0 0 1660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
168 0 0 0 0 0 0 0 0 0 0 0 0 1670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
169 0 0 0 0 0 0 0 0 0 0 0 0 1680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
170 0 0 0 0 0 0 0 0 0 0 0 0 1690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
171 0 0 0 0 0 0 0 0 0 0 0 0 1700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
172 0 0 0 0 0 0 85 85 85 0 0 0 1710 0 0 0 0 0 0 0 0 0 0 0
173 0 0 0 0 0 0 0 0 0 0 0 0 1720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
174 0 0 0 0 0 0 0 0 0 0 0 0 1730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
175 0 0 0 0 0 0 0 0 0 0 0 0 1740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
176170 170 170 170 170 170 85 85 85 0 0 0 1750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
177 0 0 0 0 0 0 85 85 85 0 0 0 1760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
178 0 0 0 0 0 0 0 0 0 0 0 0 1770 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
179 0 0 0 0 0 0 0 0 0 0 0 0 17885 85 85 0 0 0 85 85 85 85 85 85 85 85 85 85 85 85
180 0 0 0 0 0 0 0 0 0 0 0 0 1790 0 0 85 85 85 85 85 85 0 0 0 85 85 85 85 85 85
181 0 0 0 0 0 0 0 0 0 0 0 0 1800 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
182 0 0 0 0 0 0 0 0 0 0 0 0 1810 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
183 0 0 0 0 0 0 0 0 0 0 0 0 18285 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
184 0 0 0 0 0 0 0 0 0 0 0 0 1830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
185 0 0 0 0 0 0 0 0 0 0 0 0 1840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
186 0 0 0 0 0 0 0 0 0 0 0 0 1850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
187 0 0 0 0 0 0 0 0 0 0 0 0 1860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
188 0 0 0 0 0 0 0 0 0 0 0 0 1870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
189 0 0 0 0 0 0 0 0 0 0 0 0 1880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
190 0 0 0 0 0 0 0 0 0 0 0 0 1890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
191 0 0 0 0 0 0 0 0 0 0 0 0 1900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
192 0 0 0 0 0 0 85 85 85 0 0 0 1910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
193 0 0 0 0 0 0 0 0 0 0 0 0 1920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
194 0 0 0 0 0 0 0 0 0 0 0 0 1930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
195 0 0 0 0 0 0 0 0 0 0 0 0 1940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
196 0 0 0 85 85 85 0 0 0 0 0 0 1950 0 0 0 0 0 0 0 0 0 0 0
197 0 0 0 0 0 0 0 0 0 85 85 85 1960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
198 0 0 0 0 0 0 0 0 0 0 0 0 1970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
199 0 0 0 0 0 0 0 0 0 0 0 0 1980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
200 0 0 0 0 0 0 0 0 0 0 0 0 1990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
201 0 0 0 0 0 0 0 0 0 0 0 0 2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
202 0 0 0 0 0 0 0 0 0 0 0 0 2010 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
203 0 0 0 0 0 0 0 0 0 0 0 0 20285 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
204 0 0 0 0 0 0 0 0 0 0 0 0 20385 85 85 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
205 0 0 0 0 0 0 0 0 0 0 0 0 2040 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
206 0 0 0 0 0 0 0 0 0 0 0 0 2050 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
207 0 0 0 0 0 0 0 0 0 0 0 0 2060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
208 0 0 0 0 0 0 0 0 0 0 0 0 2070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
209 0 0 0 0 0 0 0 0 0 0 0 0 2080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
210 0 0 0 0 0 0 0 0 0 0 0 0 2090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
211 0 0 0 0 0 0 0 0 0 0 0 0 2100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
212 0 0 0 0 0 0 85 85 85 0 0 0 2110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
213 0 0 0 0 0 0 0 0 0 0 0 0 2120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
214 0 0 0 0 0 0 0 0 0 0 0 0 2130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
215 0 0 0 0 0 0 0 0 0 0 0 0 2140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
216 0 0 0 0 0 0 0 0 0 0 0 0 2150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
217 0 0 0 0 0 0 0 0 0 85 85 85 2160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
218 0 0 0 0 0 0 0 0 0 0 0 0 2170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
219 0 0 0 0 0 0 0 0 0 0 0 0 2180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
220 0 0 0 0 0 0 0 0 0 0 0 0 2190 0 0 0 0 0 0 0 0 0 0 0
221 0 0 0 0 0 0 0 0 0 0 0 0 2200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
222 0 0 0 0 0 0 0 0 0 0 0 0 2210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
223 0 0 0 0 0 0 0 0 0 0 0 0 2220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
224 0 0 0 0 0 0 0 0 0 0 0 0 2230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
225 0 0 0 0 0 0 0 0 0 0 0 0 2240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
226 0 0 0 0 0 0 0 0 0 0 0 0 2250 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
227 0 0 0 0 0 0 0 0 0 0 0 0 22685 85 85 85 85 85 85 85 85 85 85 85 0 0 0 85 85 85
228 0 0 0 0 0 0 0 0 0 0 0 0 2270 0 0 85 85 85 85 85 85 0 0 0 85 85 85 0 0 0
229 0 0 0 0 0 0 0 0 0 0 0 0 22885 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
230 0 0 0 0 0 0 0 0 0 0 0 0 2290 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
231 0 0 0 0 0 0 0 0 0 0 0 0 23085 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
232 0 0 0 85 85 85 0 0 0 0 0 0 23185 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
233 0 0 0 0 0 0 0 0 0 0 0 0 2320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
234 0 0 0 0 0 0 0 0 0 0 0 0 2330 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
235 0 0 0 0 0 0 0 0 0 0 0 0 2340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
236 0 0 0 0 0 0 0 0 0 0 0 0 2350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
237 0 0 0 0 0 0 0 0 0 85 85 85 2360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
238 0 0 0 0 0 0 0 0 0 0 0 0 2370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
239 0 0 0 0 0 0 0 0 0 0 0 0 2380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
240 0 0 0 0 0 0 0 0 0 0 0 0 2390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
241 0 0 0 0 0 0 0 0 0 0 0 0 2400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
242 0 0 0 0 0 0 0 0 0 0 0 0 2410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
243 0 0 0 0 0 0 0 0 0 0 0 0 2420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
244 0 0 0 0 0 0 0 0 0 0 0 0 2430 0 0 0 0 0 0 0 0 0 0 0
245 0 0 0 0 0 0 0 0 0 0 0 0 2440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
246 0 0 0 0 0 0 0 0 0 0 0 0 2450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
247 0 0 0 0 0 0 0 0 0 0 0 0 2460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
248 0 0 0 0 0 0 0 0 0 0 0 0 2470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
249 0 0 0 0 0 0 0 0 0 0 0 0 2480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
250 0 0 0 0 0 0 0 0 0 0 0 0 2490 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
251 0 0 0 0 0 0 0 0 0 0 0 0 25085 85 85 0 0 0 85 85 85 85 85 85 85 85 85 85 85 85
252 0 0 0 85 85 85 0 0 0 0 0 0 2510 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
253 0 0 0 0 0 0 0 0 0 0 0 0 2520 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
254 0 0 0 0 0 0 0 0 0 0 0 0 2530 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
255 0 0 0 0 0 0 0 0 0 0 0 0 2540 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
256 0 0 0 0 0 0 0 0 0 0 0 0 2550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
257 0 0 0 0 0 0 0 0 0 0 0 0 2560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
258 85 85 85 0 0 0 0 0 0 0 0 0 2570 0 0 85 85 85 170 170 170 170 85 0 170 170 170 85 85 85
259 0 0 0 0 0 0 0 0 0 0 0 0 2580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
260 0 0 0 0 0 0 0 0 0 0 0 0 2590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
261 0 0 0 0 0 0 0 0 0 0 0 0 2600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
262 0 0 0 0 0 0 0 0 0 0 0 0 2610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
263 0 0 0 0 0 0 0 0 0 0 0 0 2620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
264 0 0 0 0 0 0 0 0 0 0 0 0 2630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
265 0 0 0 0 0 0 0 0 0 0 0 0 2640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
266 0 0 0 0 0 0 0 0 0 0 0 0 2650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
267 0 0 0 0 0 0 0 0 0 0 0 0 2660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
268 0 0 0 0 0 0 0 0 0 0 0 0 2670 0 0 0 0 0 0 0 0 0 0 0
269 0 0 0 0 0 0 0 0 0 0 0 0 2680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
270 0 0 0 0 0 0 0 0 0 0 0 0 2690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
271 0 0 0 0 0 0 0 0 0 0 0 0 2700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
272 0 0 0 85 85 85 0 0 0 0 0 0 2710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
273 0 0 0 0 0 0 0 0 0 0 0 0 2720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
274 0 0 0 0 0 0 0 0 0 0 0 0 2730 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
275 0 0 0 0 0 0 0 0 0 0 0 0 27485 85 85 85 85 85 85 85 85 85 85 85 0 0 0 85 85 85
276 0 0 0 0 0 0 0 0 0 0 0 0 2750 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
277 0 0 0 0 0 0 0 0 0 0 0 0 27685 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
278 85 85 85 0 0 0 0 0 0 0 0 0 27785 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
279 0 0 0 0 0 0 0 0 0 0 0 0 27885 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
280 0 0 0 0 0 0 0 0 0 0 0 0 2790 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
281 0 0 0 0 0 0 0 0 0 0 0 0 2800 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
282 0 0 0 0 0 0 0 0 0 0 0 0 281170 170 170 255 255 85 170 170 170 170 170 170 170 170 170 85 85 85
283 0 0 0 0 0 0 0 0 0 0 0 0 2820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
284 0 0 0 0 0 0 0 0 0 0 0 0 2830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
285 0 0 0 0 0 0 0 0 0 0 0 0 2840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
286 0 0 0 0 0 0 0 0 0 0 0 0 2850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
287 0 0 0 0 0 0 0 0 0 0 0 0 2860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
288 0 0 0 0 0 0 0 0 0 0 0 0 2870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
289 0 0 0 0 0 0 0 0 0 0 0 0 2880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
290 0 0 0 0 0 0 0 0 0 0 0 0 2890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
291 0 0 0 0 0 0 0 0 0 0 0 0 2900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
292 0 0 0 85 85 85 0 0 0 0 0 0 2910 0 0 0 0 0 0 0 0 0 0 0
293 0 0 0 85 85 85 170 170 170 0 0 0 2920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
294 0 0 0 0 0 0 0 0 0 0 0 0 2930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
295 0 0 0 0 0 0 170 170 170 170 170 170 2940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
296170 170 170 0 0 0 0 0 0 0 0 0 2950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
297 0 0 0 0 0 0 0 0 0 0 0 0 2960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
298 85 85 85 0 0 0 0 0 0 0 0 0 2970 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
299 0 0 0 0 0 0 0 0 0 0 0 0 29885 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
300 0 0 0 0 0 0 0 0 0 0 0 0 29985 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
301 0 0 0 0 0 0 0 0 0 0 0 0 3000 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
302 0 0 0 0 0 0 0 0 0 0 0 0 3010 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
303 0 0 0 0 0 0 0 0 0 0 0 0 3020 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
304 0 0 0 0 0 0 0 0 0 0 0 0 3030 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
305 0 0 0 0 0 0 0 0 0 0 0 0 3040 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
306 0 0 0 0 0 0 0 0 0 0 0 0 305255 255 85 170 170 170 170 170 170 170 85 0 85 255 85 170 85 0
307 0 0 0 0 0 0 0 0 0 0 0 0 3060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
308 0 0 0 0 0 0 0 0 0 0 0 0 3070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
309 0 0 0 0 0 0 0 0 0 0 0 0 3080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
310 0 0 0 0 0 0 0 0 0 0 0 0 3090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
311 0 0 0 0 0 0 0 0 0 0 0 0 3100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
312 0 0 0 85 85 85 0 0 0 0 0 0 3110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
313 85 85 85 170 170 170 170 170 170 170 170 170 3120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
314 0 0 0 0 0 0 0 0 0 0 0 0 3130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
315 0 0 0 170 170 170 255 255 255 255 255 255 3140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
316255 255 255 170 170 170 0 0 0 0 0 0 3150 0 0 0 0 0 0 0 0 0 0 0
317 0 0 0 0 0 0 0 0 0 0 0 0 3160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
318 85 85 85 0 0 0 0 0 0 0 0 0 3170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
319 0 0 0 0 0 0 0 0 0 0 0 0 3180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
320 0 0 0 0 0 0 0 0 0 0 0 0 3190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
321 0 0 0 0 0 0 0 0 0 0 0 0 3200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
322 0 0 0 0 0 0 0 0 0 0 0 0 3210 0 0 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
323 0 0 0 0 0 0 0 0 0 0 0 0 32285 85 85 85 85 85 85 85 85 85 85 85 0 0 0 85 85 85
324 0 0 0 0 0 0 0 0 0 0 0 0 3230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
325 0 0 0 0 0 0 0 0 0 0 0 0 3240 0 0 85 85 85 0 0 0 0 0 0 85 85 85 85 85 85
326 0 0 0 0 0 0 0 0 0 0 0 0 3250 0 0 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
327 0 0 0 0 0 0 0 0 0 0 0 0 3260 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
328 0 0 0 0 0 0 0 0 0 0 0 0 3270 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
329 0 0 0 0 0 0 0 0 0 0 0 0 32885 85 85 0 0 0 0 0 0 85 85 85 170 170 170 170 85 0
330 0 0 0 0 0 0 0 0 0 0 0 0 329170 170 170 170 170 170 255 255 85 170 170 170 170 170 170 85 85 85
331 0 0 0 0 0 0 0 0 0 0 0 0 3300 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
332 0 0 0 85 85 85 0 0 0 85 85 85 3310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
333170 170 170 170 170 170 255 255 255 255 255 255 3320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
334 0 0 0 0 0 0 0 0 0 0 0 0 3330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
335170 170 170 255 255 255 170 170 170 170 170 170 3340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
336255 255 255 170 170 170 0 0 0 0 0 0 3350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
337 0 0 0 0 0 0 0 0 0 0 0 0 3360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
338 85 85 85 0 0 0 0 0 0 0 0 0 3370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
339 0 0 0 0 0 0 0 0 0 0 0 0 3380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
340 0 0 0 0 0 0 0 0 0 0 0 0 3390 0 0 0 0 0 0 0 0 0 0 0
341 0 0 0 0 0 0 0 0 0 0 0 0 3400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
342 0 0 0 0 0 0 0 0 0 0 0 0 3410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
343 0 0 0 0 0 0 0 0 0 0 0 0 3420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
344 0 0 0 0 0 0 0 0 0 0 0 0 3430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
345 0 0 0 0 0 0 0 0 0 0 0 0 3440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
346 0 0 0 0 0 0 0 0 0 0 0 0 3450 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
347 0 0 0 0 0 0 0 0 0 0 0 0 3460 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
348 0 0 0 0 0 0 0 0 0 0 0 0 34785 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
349 0 0 0 0 0 0 0 0 0 0 0 0 3480 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
350 0 0 0 0 0 0 0 0 0 0 0 0 34985 85 85 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
351 0 0 0 0 0 0 0 0 0 0 0 0 35085 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
352 0 0 0 85 85 85 0 0 0 85 85 85 3510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
353170 170 170 0 0 0 0 0 0 255 255 255 3520 0 0 0 0 0 85 85 85 85 85 85 170 85 0 170 170 170
354 85 85 85 0 0 0 0 0 0 0 0 0 353170 170 170 170 85 0 170 170 170 170 170 170 170 85 0 85 85 85
355255 255 255 170 170 170 0 0 0 85 85 85 3540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
356170 170 170 255 255 255 170 170 170 0 0 0 3550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
357 0 0 0 0 0 0 0 0 0 0 0 0 3560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
358 85 85 85 0 0 0 0 0 0 0 0 0 3570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
359 0 0 0 0 0 0 0 0 0 0 0 0 3580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
360 0 0 0 0 0 0 0 0 0 0 0 0 3590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
361 0 0 0 0 0 0 0 0 0 0 0 0 3600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
362 0 0 0 0 0 0 0 0 0 0 0 0 3610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
363 0 0 0 0 0 0 0 0 0 0 0 0 3620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
364 0 0 0 0 0 0 0 0 0 0 0 0 3630 0 0 0 0 0 0 0 0 0 0 0
365 0 0 0 0 0 0 0 0 0 0 0 0 3640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
366 0 0 0 0 0 0 0 0 0 0 0 0 3650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
367 0 0 0 0 0 0 0 0 0 0 0 0 3660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
368 0 0 0 0 0 0 0 0 0 0 0 0 3670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
369 0 0 0 0 0 0 0 0 0 0 0 0 3680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
370 0 0 0 0 0 0 0 0 0 0 0 0 3690 0 0 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
371 0 0 0 0 0 0 0 0 0 0 0 0 37085 85 85 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
372 0 0 0 85 85 85 0 0 0 85 85 85 3710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
373 85 85 85 0 0 0 0 0 0 170 170 170 37285 85 85 0 0 0 85 85 85 0 0 0 85 85 85 85 85 85
374 85 85 85 0 0 0 0 0 0 0 0 0 37385 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
375255 255 255 85 85 85 0 0 0 0 0 0 37485 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
376 85 85 85 255 255 255 170 170 170 0 0 0 37585 85 85 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
377 0 0 0 0 0 0 0 0 0 0 0 0 3760 0 0 0 0 0 85 85 85 85 85 85 85 85 85 85 255 85
378 85 85 85 0 0 0 0 0 0 0 0 0 377255 85 85 85 255 85 170 170 170 170 85 0 170 170 170 85 85 85
379 0 0 0 0 0 0 0 0 0 0 0 0 3780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
380 0 0 0 0 0 0 0 0 0 0 0 0 3790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
381 0 0 0 0 0 0 0 0 0 0 0 0 3800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
382 0 0 0 0 0 0 0 0 0 0 0 0 3810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
383 0 0 0 0 0 0 0 0 0 0 0 0 3820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
384 0 0 0 0 0 0 0 0 0 0 0 0 3830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
385 0 0 0 0 0 0 0 0 0 0 0 0 3840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
386 0 0 0 0 0 0 0 0 0 0 0 0 3850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
387 0 0 0 0 0 0 0 0 0 0 0 0 3860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
388 0 0 0 0 0 0 0 0 0 0 0 0 3870 0 0 0 0 0 0 0 0 0 0 0
389 0 0 0 0 0 0 0 0 0 0 0 0 3880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
390 0 0 0 0 0 0 0 0 0 0 0 0 3890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
391 0 0 0 0 0 0 0 0 0 0 0 0 3900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
392 0 0 0 85 85 85 0 0 0 85 85 85 3910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
393170 170 170 0 0 0 0 0 0 170 170 170 3920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
394 85 85 85 85 85 85 85 85 85 85 85 85 3930 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
395255 255 255 85 85 85 0 0 0 0 0 0 3940 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
396 85 85 85 255 255 255 170 170 170 0 0 0 3950 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
397 0 0 0 0 0 0 0 0 0 0 0 0 3960 0 0 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
398 85 85 85 0 0 0 0 0 0 0 0 0 39785 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
399 0 0 0 0 0 0 0 0 0 0 0 0 39885 85 85 85 85 85 85 85 85 0 0 0 85 85 85 0 0 0
400 0 0 0 0 0 0 0 0 0 0 0 0 3990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
401 0 0 0 0 0 0 0 0 0 0 0 0 4000 0 0 0 0 0 85 85 85 170 85 0 85 85 85 85 85 85
402 0 0 0 0 0 0 0 0 0 0 0 0 401170 170 170 170 85 0 170 170 170 85 85 85 170 85 0 85 85 85
403 0 0 0 0 0 0 0 0 0 0 0 0 4020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
404 0 0 0 0 0 0 0 0 0 0 0 0 4030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
405 0 0 0 0 0 0 0 0 0 0 0 0 4040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
406 0 0 0 0 0 0 0 0 0 0 0 0 4050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
407 0 0 0 0 0 0 0 0 0 0 0 0 4060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
408 0 0 0 0 0 0 0 0 0 0 0 0 4070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
409 0 0 0 0 0 0 0 0 0 0 0 0 4080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
410 0 0 0 0 0 0 0 0 0 0 0 0 4090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
411 0 0 0 0 0 0 0 0 0 0 0 0 4100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
412 0 0 0 85 85 85 0 0 0 0 0 0 4110 0 0 0 0 0 0 0 0 0 0 0
413255 255 255 0 0 0 0 0 0 170 85 0 4120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
414255 255 85 170 85 0 255 255 85 170 85 0 4130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
415255 255 85 170 85 0 0 0 0 0 0 0 4140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
416 85 85 85 255 255 255 0 0 0 0 0 0 4150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
417 0 0 0 0 0 0 0 0 0 0 0 0 4160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
418 85 85 85 0 0 0 0 0 0 0 0 0 4170 0 0 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
419 0 0 0 0 0 0 0 0 0 0 0 0 41885 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
420 0 0 0 0 0 0 0 0 0 0 0 0 4190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
421 0 0 0 0 0 0 0 0 0 0 0 0 4200 0 0 85 85 85 0 0 0 85 85 85 85 85 85 0 0 0
422 0 0 0 0 0 0 0 0 0 0 0 0 4210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
423 0 0 0 0 0 0 0 0 0 0 0 0 4220 0 0 0 0 0 85 85 85 85 85 85 0 0 0 85 85 85
424 0 0 0 0 0 0 0 0 0 0 0 0 4230 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
425 0 0 0 0 0 0 0 0 0 0 0 0 42485 85 85 0 0 0 0 0 0 85 85 85 85 85 85 170 85 0
426 0 0 0 0 0 0 0 0 0 0 0 0 42585 85 85 85 85 85 170 85 0 85 255 85 85 85 85 85 85 85
427 0 0 0 0 0 0 0 0 0 0 0 0 4260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
428 0 0 0 0 0 0 0 0 0 0 0 0 4270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
429 0 0 0 0 0 0 0 0 0 0 0 0 4280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
430 0 0 0 0 0 0 0 0 0 0 0 0 4290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
431 0 0 0 0 0 0 0 0 0 0 0 0 4300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
432 0 0 0 85 85 85 0 0 0 0 0 0 4310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
433170 170 170 170 170 170 170 85 0 255 255 85 4320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
434170 85 0 255 255 85 170 85 0 255 255 85 4330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
435170 85 0 255 255 85 170 85 0 255 255 85 4340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
436170 170 170 170 170 170 0 0 0 0 0 0 4350 0 0 0 0 0 0 0 0 0 0 0
437 0 0 0 0 0 0 0 0 0 0 0 0 4360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
438 85 85 85 0 0 0 0 0 0 0 0 0 4370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
439 0 0 0 0 0 0 0 0 0 0 0 0 4380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
440 0 0 0 0 0 0 0 0 0 0 0 0 4390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
441 0 0 0 0 0 0 0 0 0 0 0 0 4400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
442 0 0 0 0 0 0 0 0 0 0 0 0 4410 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
443 0 0 0 0 0 0 0 0 0 0 0 0 44285 85 85 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
444 0 0 0 0 0 0 0 0 0 0 0 0 4430 0 0 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
445 0 0 0 0 0 0 0 0 0 0 0 0 4440 0 0 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
446 0 0 0 0 0 0 0 0 0 0 0 0 4450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
447 0 0 0 0 0 0 0 0 0 0 0 0 4460 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
448 0 0 0 0 0 0 0 0 0 0 0 0 4470 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
449 0 0 0 0 0 0 0 0 0 0 0 0 4480 0 0 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
450 0 0 0 0 0 0 0 0 0 0 0 0 44985 85 85 85 85 85 85 85 85 85 85 85 170 85 0 0 0 0
451 0 0 0 0 0 0 0 0 0 0 0 0 4500 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
452 0 0 0 85 85 85 0 0 0 0 0 0 4510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
453 0 0 0 170 85 0 255 255 85 170 85 0 4520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
454255 255 85 170 85 0 255 255 85 170 85 0 4530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
455255 255 85 170 85 0 255 255 85 170 85 0 4540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
456255 255 85 170 85 0 0 0 0 0 0 0 4550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
457 0 0 0 0 0 0 0 0 0 0 0 0 4560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
458 85 85 85 0 0 0 0 0 0 0 0 0 4570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
459 0 0 0 0 0 0 0 0 0 0 0 0 4580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
460 0 0 0 0 0 0 0 0 0 0 0 0 4590 0 0 0 0 0 0 0 0 0 0 0
461 0 0 0 0 0 0 0 0 0 0 0 0 4600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
462 0 0 0 0 0 0 0 0 0 0 0 0 4610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
463 0 0 0 0 0 0 0 0 0 0 0 0 4620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
464 0 0 0 0 0 0 0 0 0 0 0 0 4630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
465 0 0 0 0 0 0 0 0 0 0 0 0 4640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
466 0 0 0 0 0 0 0 0 0 0 0 0 4650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
467 0 0 0 0 0 0 0 0 0 0 0 0 4660 0 0 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
468 0 0 0 0 0 0 0 0 0 0 0 0 4670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
469 0 0 0 0 0 0 0 0 0 0 0 0 46885 85 85 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
470 0 0 0 0 0 0 0 0 0 0 0 0 4690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
471 0 0 0 0 0 0 0 0 0 0 0 0 4700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
472 0 0 0 85 85 85 0 0 0 0 0 0 47185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
473170 85 0 255 255 85 170 85 0 255 255 85 4720 0 0 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
474170 85 0 255 255 85 170 85 0 255 255 85 47385 85 85 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
475170 85 0 255 255 85 170 85 0 255 255 85 4740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
476170 85 0 255 255 85 170 85 0 0 0 0 4750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
477 0 0 0 0 0 0 0 0 0 0 0 0 4760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
478 0 0 0 85 85 85 0 0 0 0 0 0 4770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
479 0 0 0 0 0 0 0 0 0 0 0 0 4780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
480 0 0 0 0 0 0 0 0 0 0 0 0 4790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
481 0 0 0 0 0 0 0 0 0 0 0 0 4800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
482 0 0 0 0 0 0 0 0 0 0 0 0 4810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
483 0 0 0 0 0 0 0 0 0 0 0 0 4820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
484 0 0 0 0 0 0 0 0 0 0 0 0 4830 0 0 0 0 0 0 0 0 0 0 0
485 0 0 0 0 0 0 0 0 0 0 0 0 4840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
486 0 0 0 0 0 0 0 0 0 0 0 0 4850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
487 0 0 0 0 0 0 0 0 0 0 0 0 4860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
488 0 0 0 0 0 0 0 0 0 0 0 0 4870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
489 0 0 0 0 0 0 0 0 0 0 0 0 4880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
490 0 0 0 0 0 0 0 0 0 0 0 0 4890 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
491 0 0 0 0 0 0 0 0 0 0 0 0 4900 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
492 0 0 0 85 85 85 85 85 85 0 0 0 4910 0 0 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
493255 255 85 170 85 0 255 255 85 170 85 0 4920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
494255 255 85 170 85 0 255 255 85 170 85 0 4930 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
495255 255 85 170 85 0 255 255 85 170 85 0 4940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
496255 255 85 170 85 0 170 85 0 0 0 0 4950 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
497 0 0 0 0 0 0 0 0 0 0 0 0 4960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
498 0 0 0 85 85 85 0 0 0 0 0 0 4970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
499 0 0 0 0 0 0 0 0 0 0 0 0 4980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
500 0 0 0 0 0 0 0 0 0 0 0 0 4990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
501 0 0 0 0 0 0 0 0 0 0 0 0 5000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
502 0 0 0 0 0 0 0 0 0 0 0 0 5010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
503 0 0 0 0 0 0 0 0 0 0 0 0 5020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
504 0 0 0 0 0 0 0 0 0 0 0 0 5030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
505 0 0 0 0 0 0 0 0 0 0 0 0 5040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
506 0 0 0 0 0 0 0 0 0 0 0 0 5050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
507 0 0 0 0 0 0 0 0 0 0 0 0 5060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
508 0 0 0 0 0 0 0 0 0 0 0 0 5070 0 0 0 0 0 0 0 0 0 0 0
509 0 0 0 0 0 0 0 0 0 0 0 0 5080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
510 0 0 0 0 0 0 0 0 0 0 0 0 5090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
511 0 0 0 0 0 0 0 0 0 0 0 0 5100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
512 0 0 0 85 85 85 85 85 85 0 0 0 5110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
513170 85 0 255 255 85 170 85 0 255 255 85 5120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
514170 85 0 255 255 85 170 85 0 255 255 85 5130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
515170 85 0 255 255 85 170 85 0 170 85 0 5140 0 0 85 85 85 0 0 0 0 170 0 85 85 85 0 0 0
516170 85 0 170 85 0 85 85 85 0 0 0 51585 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
517 0 0 0 85 85 85 0 0 0 0 0 0 5160 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
518 0 0 0 0 0 0 85 85 85 0 0 0 5170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
519 0 0 0 0 0 0 0 0 0 0 0 0 5180 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
520 0 0 0 0 0 0 0 0 0 0 0 0 5190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
521 0 0 0 0 0 0 0 0 0 0 0 0 5200 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
522 0 0 0 0 0 0 0 0 0 0 0 0 5210 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
523 0 0 0 0 0 0 0 0 0 0 0 0 5220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
524 0 0 0 0 0 0 0 0 0 0 0 0 5230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
525 0 0 0 0 0 0 0 0 0 0 0 0 5240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
526 0 0 0 0 0 0 0 0 0 0 0 0 5250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
527 0 0 0 0 0 0 0 0 0 0 0 0 5260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
528 0 0 0 0 0 0 0 0 0 0 0 0 5270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
529 0 0 0 0 0 0 0 0 0 0 0 0 5280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
530 0 0 0 0 0 0 0 0 0 0 0 0 5290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
531 0 0 0 0 0 0 0 0 0 0 0 0 5300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
532 0 0 0 85 85 85 85 85 85 0 0 0 5310 0 0 0 0 0 0 0 0 0 0 0
533 85 85 85 170 85 0 255 255 85 170 85 0 5320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
534255 255 85 170 85 0 255 255 85 170 85 0 5330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
535170 85 0 170 85 0 170 85 0 170 85 0 5340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
536170 85 0 170 85 0 85 85 85 0 0 0 5350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
537 0 0 0 85 85 85 170 170 170 85 85 85 5360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
538 0 0 0 0 0 0 85 85 85 0 0 0 5370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
539 0 0 0 0 0 0 0 0 0 0 0 0 538170 85 0 85 255 85 170 85 0 170 85 0 170 85 0 85 255 85
540 0 0 0 0 0 0 0 0 0 0 0 0 539170 85 0 170 85 0 0 170 0 0 0 0 0 0 0 0 0 0
541 0 0 0 0 0 0 0 0 0 0 0 0 54085 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
542 0 0 0 0 0 0 0 0 0 0 0 0 5410 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
543 0 0 0 0 0 0 0 0 0 0 0 0 5420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
544 0 0 0 0 0 0 0 0 0 0 0 0 54385 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
545 0 0 0 0 0 0 0 0 0 0 0 0 5440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
546 0 0 0 0 0 0 0 0 0 0 0 0 54585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
547 0 0 0 0 0 0 0 0 0 0 0 0 5460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
548 0 0 0 0 0 0 0 0 0 0 0 0 5470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
549 0 0 0 0 0 0 0 0 0 0 0 0 5480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
550 0 0 0 0 0 0 0 0 0 0 0 0 5490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
551 0 0 0 0 0 0 0 0 0 0 0 0 5500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
552 0 0 0 85 85 85 85 85 85 0 0 0 5510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
553 85 85 85 170 85 0 170 85 0 170 85 0 5520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
554170 85 0 170 85 0 170 85 0 170 85 0 5530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
555170 85 0 170 85 0 170 85 0 170 85 0 5540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
556170 170 170 170 170 170 170 170 170 0 0 0 5550 0 0 0 0 0 0 0 0 0 0 0
557 0 0 0 0 0 0 170 170 170 170 170 170 5560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
558 0 0 0 0 0 0 0 0 0 85 85 85 5570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
559 0 0 0 0 0 0 0 0 0 0 0 0 5580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
560 0 0 0 0 0 0 0 0 0 0 0 0 5590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
561 0 0 0 0 0 0 0 0 0 0 0 0 5600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
562 0 0 0 0 0 0 0 0 0 0 0 0 5610 0 0 0 0 0 0 0 0 0 0 0 0 170 0 170 85 0
563 0 0 0 0 0 0 0 0 0 0 0 0 562255 255 85 170 85 0 255 255 85 255 255 85 255 255 85 170 85 0
564 0 0 0 0 0 0 0 0 0 0 0 0 563255 255 85 85 255 85 170 85 0 170 85 0 85 85 85 0 0 0
565 0 0 0 0 0 0 0 0 0 0 0 0 5640 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
566 0 0 0 0 0 0 0 0 0 0 0 0 56585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
567 0 0 0 0 0 0 0 0 0 0 0 0 5660 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
568 0 0 0 0 0 0 0 0 0 0 0 0 5670 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
569 0 0 0 0 0 0 0 0 0 0 0 0 56885 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
570 0 0 0 0 0 0 0 0 0 0 0 0 5690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
571 0 0 0 0 0 0 0 0 0 0 0 0 5700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
572 0 0 0 85 85 85 0 0 0 0 0 0 5710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
573 85 85 85 170 170 170 170 85 0 170 85 0 5720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
574170 85 0 170 85 0 170 85 0 170 85 0 5730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
575170 85 0 170 85 0 170 170 170 170 170 170 5740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
576170 170 170 170 170 170 170 170 170 85 85 85 5750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
577 0 0 0 0 0 0 85 85 85 85 85 85 5760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
578 0 0 0 0 0 0 0 0 0 85 85 85 5770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
579 0 0 0 0 0 0 0 0 0 0 0 0 5780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
580 0 0 0 0 0 0 0 0 0 0 0 0 5790 0 0 0 0 0 0 0 0 0 0 0
581 0 0 0 0 0 0 0 0 0 0 0 0 5800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
582 0 0 0 0 0 0 0 0 0 0 0 0 5810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
583 0 0 0 0 0 0 0 0 0 0 0 0 5820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
584 0 0 0 0 0 0 0 0 0 0 0 0 5830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
585 0 0 0 0 0 0 0 0 0 0 0 0 5840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
586 0 0 0 0 0 0 0 0 0 0 0 0 5850 0 0 0 0 0 0 0 0 0 0 0 170 85 0 255 255 85
587 0 0 0 0 0 0 0 0 0 0 0 0 58685 255 85 255 255 85 255 255 85 170 85 0 255 255 85 255 255 85
588 0 0 0 0 0 0 0 0 0 0 0 0 587255 255 85 170 85 0 255 255 85 85 255 85 170 85 0 0 0 0
589 0 0 0 0 0 0 0 0 0 0 0 0 58885 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
590 0 0 0 0 0 0 0 0 0 0 0 0 5890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
591 0 0 0 0 0 0 0 0 0 0 0 0 5900 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
592 0 0 0 85 85 85 0 0 0 0 0 0 5910 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
593 85 85 85 170 170 170 170 170 170 170 85 0 5920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
594170 85 0 170 85 0 170 85 0 170 85 0 5930 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
595170 170 170 170 170 170 170 170 170 170 170 170 5940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
596255 255 255 255 255 255 255 255 255 170 170 170 5950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
597 0 0 0 0 0 0 0 0 0 0 0 0 5960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
598 0 0 0 0 0 0 0 0 0 85 85 85 5970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
599 0 0 0 0 0 0 0 0 0 0 0 0 5980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
600 0 0 0 0 0 0 0 0 0 0 0 0 5990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
601 0 0 0 0 0 0 0 0 0 0 0 0 6000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
602 0 0 0 0 0 0 0 0 0 0 0 0 6010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
603 0 0 0 0 0 0 0 0 0 0 0 0 6020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
604 0 0 0 0 0 0 0 0 0 0 0 0 6030 0 0 0 0 0 0 0 0 0 0 0
605 0 0 0 0 0 0 0 0 0 0 0 0 6040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
606 0 0 0 0 0 0 0 0 0 0 0 0 6050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
607 0 0 0 0 0 0 0 0 0 0 0 0 6060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
608 0 0 0 0 0 0 0 0 0 0 0 0 6070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
609 0 0 0 0 0 0 0 0 0 0 0 0 6080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
610 0 0 0 0 0 0 0 0 0 0 0 0 6090 0 0 0 0 0 0 0 0 85 85 85 255 255 85 170 85 0
611 0 0 0 0 0 0 0 0 0 0 0 0 610255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 170 85 0
612 85 85 85 0 0 0 0 0 0 85 85 85 611255 255 85 255 255 85 255 255 85 255 255 85 170 85 0 85 255 85
613255 255 255 255 255 255 170 170 170 170 170 170 6120 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
614170 170 170 170 170 170 170 170 170 170 170 170 6130 0 0 85 85 85 0 0 0 85 85 85 170 170 170 0 0 0
615170 170 170 170 170 170 255 255 255 255 255 255 6140 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
616255 255 255 255 255 255 255 255 255 255 255 255 61585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
617 85 85 85 0 0 0 0 0 0 0 0 0 6160 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
618 0 0 0 0 0 0 0 0 0 0 0 0 6170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
619 85 85 85 0 0 0 0 0 0 0 0 0 6180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
620 0 0 0 0 0 0 0 0 0 0 0 0 6190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
621 0 0 0 0 0 0 0 0 0 0 0 0 6200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
622 0 0 0 0 0 0 0 0 0 0 0 0 6210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
623 0 0 0 0 0 0 0 0 0 0 0 0 6220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
624 0 0 0 0 0 0 0 0 0 0 0 0 6230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
625 0 0 0 0 0 0 0 0 0 0 0 0 6240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
626 0 0 0 0 0 0 0 0 0 0 0 0 6250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
627 0 0 0 0 0 0 0 0 0 0 0 0 6260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
628 0 0 0 0 0 0 0 0 0 0 0 0 6270 0 0 0 0 0 0 0 0 0 0 0
629 0 0 0 0 0 0 0 0 0 0 0 0 6280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
630 0 0 0 0 0 0 0 0 0 0 0 0 6290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
631 0 0 0 0 0 0 0 0 0 0 0 0 6300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
632 85 85 85 0 0 0 0 0 0 170 170 170 6310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
633255 255 255 255 255 255 170 170 170 170 170 170 6320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
634170 170 170 170 170 170 170 170 170 170 170 170 6330 0 0 0 0 0 0 0 0 170 85 0 255 255 85 255 255 85
635170 170 170 255 255 255 255 255 255 255 255 255 634255 255 85 255 255 85 170 85 0 255 255 85 85 255 85 255 255 85
636255 255 255 255 255 255 255 255 255 255 255 255 635255 255 85 170 85 0 255 255 85 170 85 0 255 255 85 170 85 0
637170 170 170 0 0 0 0 0 0 0 0 0 636170 85 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
638 0 0 0 0 0 0 0 0 0 0 0 0 63785 85 85 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
639 85 85 85 0 0 0 0 0 0 0 0 0 63885 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
640 0 0 0 0 0 0 0 0 0 0 0 0 6390 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
641 0 0 0 0 0 0 0 0 0 0 0 0 6400 0 0 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
642 0 0 0 0 0 0 0 0 0 0 0 0 6410 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
643 0 0 0 0 0 0 0 0 0 0 0 0 6420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
644 0 0 0 0 0 0 0 0 0 0 0 0 6430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
645 0 0 0 0 0 0 0 0 0 0 0 0 6440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
646 0 0 0 0 0 0 0 0 0 0 0 0 6450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
647 0 0 0 0 0 0 0 0 0 0 0 0 6460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
648 0 0 0 0 0 0 0 0 0 0 0 0 6470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
649 0 0 0 0 0 0 0 0 0 0 0 0 6480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
650 0 0 0 0 0 0 0 0 0 0 0 0 6490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
651 0 0 0 0 0 0 0 0 0 85 85 85 6500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
652 0 0 0 0 0 0 85 85 85 255 255 255 6510 0 0 0 0 0 0 0 0 0 0 0
653255 255 255 255 255 255 255 255 255 170 170 170 6520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
654170 170 170 170 170 170 170 170 170 170 170 170 6530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
655255 255 255 255 255 255 255 255 255 255 255 255 6540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
656255 255 255 255 255 255 255 255 255 255 255 255 6550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
657255 255 255 0 0 0 0 0 0 0 0 0 6560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
658 0 0 0 0 0 0 0 0 0 0 0 0 6570 0 0 0 0 0 170 85 0 255 255 85 85 255 85 255 255 85
659 0 0 0 85 85 85 0 0 0 0 0 0 658170 170 170 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
660 0 0 0 0 0 0 0 0 0 0 0 0 659255 255 85 255 255 85 85 255 85 255 255 85 255 255 85 255 255 85
661 0 0 0 0 0 0 0 0 0 0 0 0 66085 255 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
662 0 0 0 0 0 0 0 0 0 0 0 0 66185 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
663 0 0 0 0 0 0 0 0 0 0 0 0 6620 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
664 0 0 0 0 0 0 0 0 0 0 0 0 66385 85 85 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
665 0 0 0 0 0 0 0 0 0 0 0 0 6640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
666 0 0 0 0 0 0 0 0 0 0 0 0 6650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
667 0 0 0 0 0 0 0 0 0 0 0 0 6660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
668 0 0 0 0 0 0 0 0 0 0 0 0 6670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
669 0 0 0 0 0 0 0 0 0 0 0 0 6680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
670 0 0 0 0 0 0 0 0 0 0 0 0 6690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
671 0 0 0 0 0 0 85 85 85 0 0 0 6700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
672 0 0 0 85 85 85 170 170 170 255 255 255 6710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
673255 255 255 255 255 255 255 255 255 255 255 255 6720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
674255 255 255 255 255 255 255 255 255 255 255 255 6730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
675255 255 255 255 255 255 255 255 255 255 255 255 6740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
676255 255 255 255 255 255 255 255 255 255 255 255 6750 0 0 0 0 0 0 0 0 0 0 0
677255 255 255 85 85 85 0 0 0 0 0 0 6760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
678 0 0 0 0 0 0 0 0 0 0 0 0 6770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
679 0 0 0 0 0 0 85 85 85 0 0 0 6780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
680 0 0 0 0 0 0 0 0 0 0 0 0 6790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
681 0 0 0 0 0 0 0 0 0 0 0 0 6800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
682 0 0 0 0 0 0 0 0 0 0 0 0 6810 0 0 0 0 0 170 85 0 255 255 85 255 255 85 255 255 85
683 0 0 0 0 0 0 0 0 0 0 0 0 682255 255 255 255 255 85 255 255 85 170 85 0 255 255 85 170 85 0
684 0 0 0 0 0 0 0 0 0 0 0 0 683255 255 85 255 255 85 255 255 85 255 255 85 170 85 0 255 255 85
685 0 0 0 0 0 0 0 0 0 0 0 0 684170 85 0 170 85 0 0 170 0 0 0 0 85 85 85 0 0 0
686 0 0 0 0 0 0 0 0 0 0 0 0 68585 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
687 0 0 0 0 0 0 0 0 0 0 0 0 6860 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
688 0 0 0 0 0 0 0 0 0 0 0 0 6870 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
689 0 0 0 0 0 0 0 0 0 0 0 0 6880 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
690 0 0 0 0 0 0 0 0 0 0 0 0 6890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
691 0 0 0 85 85 85 0 0 0 0 0 0 6900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
692 0 0 0 85 85 85 255 255 255 255 255 255 6910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
693255 255 255 255 255 255 255 255 255 255 255 255 6920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
694255 255 255 255 255 255 255 255 255 255 255 255 6930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
695255 255 255 255 255 255 255 255 255 255 255 255 6940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
696255 255 255 255 255 255 255 255 255 255 255 255 6950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
697255 255 255 170 170 170 0 0 0 0 0 0 6960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
698 0 0 0 0 0 0 0 0 0 0 0 0 6970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
699 0 0 0 0 0 0 0 0 0 85 85 85 6980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
700 0 0 0 0 0 0 0 0 0 0 0 0 6990 0 0 0 0 0 0 0 0 0 0 0
701 0 0 0 0 0 0 0 0 0 0 0 0 7000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
702 0 0 0 0 0 0 0 0 0 0 0 0 7010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
703 0 0 0 0 0 0 0 0 0 0 0 0 7020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
704 0 0 0 0 0 0 0 0 0 0 0 0 7030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
705 0 0 0 0 0 0 0 0 0 0 0 0 7040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
706 0 0 0 0 0 0 0 0 0 0 0 0 7050 0 0 170 85 0 85 255 85 255 255 85 170 170 170 255 255 255
707 0 0 0 0 0 0 0 0 0 0 0 0 706255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
708 0 0 0 0 0 0 0 0 0 0 0 0 707255 255 85 255 255 85 170 85 0 255 255 85 85 255 85 255 255 85
709 0 0 0 0 0 0 0 0 0 0 0 0 708255 255 85 85 255 85 0 0 0 85 85 85 0 0 0 85 85 85
710 0 0 0 0 0 0 0 0 0 0 0 0 7090 0 0 85 85 85 0 0 0 85 85 85 85 85 85 0 0 0
711 0 0 0 85 85 85 0 0 0 0 0 0 71085 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
712 0 0 0 85 85 85 255 255 255 255 255 255 71185 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
713255 255 255 255 255 255 255 255 255 255 255 255 71285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
714255 255 255 255 255 255 255 255 255 255 255 255 7130 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
715255 255 255 255 255 255 255 255 255 255 255 255 7140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
716255 255 255 255 255 255 255 255 255 255 255 255 7150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
717255 255 255 255 255 255 0 0 0 0 0 0 7160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
718 0 0 0 0 0 0 0 0 0 0 0 0 7170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
719 0 0 0 0 0 0 0 0 0 0 0 0 7180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
720 85 85 85 0 0 0 0 0 0 0 0 0 7190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
721 0 0 0 0 0 0 0 0 0 0 0 0 7200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
722 0 0 0 0 0 0 0 0 0 0 0 0 7210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
723 0 0 0 0 0 0 0 0 0 0 0 0 7220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
724 0 0 0 0 0 0 0 0 0 0 0 0 7230 0 0 0 0 0 0 0 0 0 0 0
725 0 0 0 0 0 0 0 0 0 0 0 0 7240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
726 0 0 0 0 0 0 0 0 0 0 0 0 7250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
727 0 0 0 0 0 0 0 0 0 0 0 0 7260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
728 0 0 0 0 0 0 0 0 0 0 0 0 7270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
729 0 0 0 0 0 0 0 0 0 0 0 0 7280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
730 0 0 0 0 0 0 0 0 0 0 0 0 7290 0 0 255 255 85 255 255 85 255 255 85 255 255 255 255 255 85
731 85 85 85 0 0 0 0 0 0 0 0 0 730255 255 85 255 255 85 85 255 85 255 255 85 255 255 85 85 255 85
732 85 85 85 170 170 170 255 255 255 255 255 255 731255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 170 85 0
733255 255 255 255 255 255 255 255 255 255 255 255 732255 255 85 170 85 0 85 85 85 0 0 0 0 0 0 85 85 85
734255 255 255 255 255 255 255 255 255 255 255 255 7330 0 0 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
735255 255 255 255 255 255 255 255 255 255 255 255 73485 85 85 0 0 0 85 85 85 85 85 85 0 0 0 85 85 85
736255 255 255 255 255 255 255 255 255 255 255 255 7350 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
737255 255 255 255 255 255 85 85 85 0 0 0 7360 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
738 0 0 0 0 0 0 0 0 0 0 0 0 73785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
739 0 0 0 0 0 0 0 0 0 0 0 0 7380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
740 0 0 0 85 85 85 0 0 0 0 0 0 7390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
741 0 0 0 0 0 0 0 0 0 0 0 0 7400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
742 0 0 0 0 0 0 0 0 0 0 0 0 7410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
743 0 0 0 0 0 0 0 0 0 0 0 0 7420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
744 0 0 0 0 0 0 0 0 0 0 0 0 7430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
745 0 0 0 0 0 0 0 0 0 0 0 0 7440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
746 0 0 0 0 0 0 0 0 0 0 0 0 7450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
747 0 0 0 0 0 0 0 0 0 0 0 0 7460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
748 0 0 0 0 0 0 0 0 0 0 0 0 7470 0 0 0 0 0 0 0 0 0 0 0
749 0 0 0 0 0 0 0 0 0 0 0 0 7480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
750 0 0 0 0 0 0 0 0 0 85 85 85 7490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
751 0 0 0 0 0 0 0 0 0 0 0 0 7500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
752 85 85 85 170 170 170 170 170 170 170 170 170 7510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
753255 255 255 255 255 255 255 255 255 170 170 170 7520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
754170 170 170 170 170 170 255 255 255 255 255 255 753170 85 0 170 85 0 255 255 85 255 255 85 255 255 255 170 170 170
755255 255 255 255 255 255 255 255 255 255 255 255 754255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
756170 170 170 170 170 170 170 170 170 170 170 170 755170 85 0 255 255 85 255 255 85 170 85 0 255 255 85 255 255 85
757170 170 170 170 170 170 170 170 170 85 85 85 756255 255 85 85 255 85 170 85 0 85 85 85 0 0 0 0 0 0
758 0 0 0 0 0 0 0 0 0 0 0 0 75785 85 85 0 0 0 85 85 85 0 0 0 85 85 85 85 85 85
759 0 0 0 0 0 0 0 0 0 0 0 0 75885 85 85 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
760 0 0 0 85 85 85 0 0 0 0 0 0 75985 85 85 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
761 0 0 0 0 0 0 0 0 0 0 0 0 7600 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
762 0 0 0 0 0 0 0 0 0 0 0 0 7610 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
763 0 0 0 0 0 0 0 0 0 0 0 0 7620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
764 0 0 0 0 0 0 0 0 0 0 0 0 7630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
765 0 0 0 0 0 0 0 0 0 0 0 0 7640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
766 0 0 0 0 0 0 0 0 0 0 0 0 7650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
767 0 0 0 0 0 0 0 0 0 0 0 0 7660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
768 0 0 0 0 0 0 0 0 0 0 0 0 7670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
769 0 0 0 0 0 0 0 0 0 0 0 0 7680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
770 0 0 0 0 0 0 0 0 0 85 85 85 7690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
771 0 0 0 0 0 0 0 0 0 0 0 0 7700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
772170 170 170 170 170 170 170 170 170 255 255 255 7710 0 0 0 0 0 0 0 0 0 0 0
773255 255 255 255 255 255 255 255 255 255 255 255 7720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
774170 170 170 255 255 255 255 255 255 255 255 255 7730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
775255 255 255 255 255 255 255 255 255 255 255 255 7740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
776255 255 255 255 255 255 170 170 170 170 170 170 7750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
777170 170 170 170 170 170 170 170 170 85 85 85 7760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
778 0 0 0 0 0 0 85 85 85 0 0 0 777255 255 85 85 255 85 255 255 85 170 170 170 255 255 255 255 255 85
779 0 0 0 0 0 0 0 0 0 0 0 0 778255 255 85 255 255 85 170 85 0 255 255 85 255 255 85 255 255 85
780 0 0 0 0 0 0 85 85 85 0 0 0 779255 255 85 255 255 85 255 255 85 255 255 85 85 255 85 170 85 0
781 0 0 0 0 0 0 0 0 0 0 0 0 780255 255 85 170 85 0 170 85 0 0 0 0 85 85 85 0 0 0
782 0 0 0 0 0 0 0 0 0 0 0 0 78185 85 85 85 85 85 85 85 85 170 170 170 170 170 170 170 170 170
783 0 0 0 0 0 0 0 0 0 0 0 0 78285 255 85 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
784 0 0 0 0 0 0 0 0 0 0 0 0 783170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
785 0 0 0 0 0 0 0 0 0 0 0 0 784170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
786 0 0 0 0 0 0 0 0 0 0 0 0 785170 170 170 170 170 170 170 170 170 170 170 170 255 255 85 170 170 170
787 0 0 0 0 0 0 0 0 0 0 0 0 78685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
788 0 0 0 0 0 0 0 0 0 0 0 0 7870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
789 0 0 0 0 0 0 0 0 0 0 0 0 7880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
790 0 0 0 0 0 0 85 85 85 0 0 0 7890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
791 0 0 0 0 0 0 0 0 0 0 0 0 7900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
792170 170 170 255 255 255 255 255 255 255 255 255 7910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
793255 255 255 255 255 255 255 255 255 255 255 255 7920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
794255 255 255 255 255 255 255 255 255 255 255 255 7930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
795255 255 255 255 255 255 255 255 255 255 255 255 7940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
796255 255 255 255 255 255 255 255 255 255 255 255 7950 0 0 0 0 0 0 0 0 0 0 0
797255 255 255 170 170 170 170 170 170 170 170 170 7960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
798 0 0 0 0 0 0 0 0 0 85 85 85 7970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
799 85 85 85 0 0 0 0 0 0 0 0 0 7980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
800 0 0 0 0 0 0 85 85 85 0 0 0 7990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
801 0 0 0 0 0 0 0 0 0 0 0 0 8000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 0
802 0 0 0 0 0 0 0 0 0 0 0 0 801170 85 0 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
803 0 0 0 0 0 0 0 0 0 0 0 0 802255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
804 0 0 0 0 0 0 0 0 0 0 0 0 803255 255 85 255 255 85 85 255 85 255 255 85 170 85 0 170 85 0
805 0 0 0 0 0 0 0 0 0 0 0 0 804170 85 0 85 255 85 255 255 85 85 85 85 170 170 170 170 170 170
806 0 0 0 0 0 0 0 0 0 0 0 0 805170 170 170 170 170 170 170 170 170 85 255 85 170 170 170 170 170 170
807 0 0 0 0 0 0 0 0 0 0 0 0 80685 85 85 170 170 170 170 170 170 170 85 0 170 170 170 170 170 170
808 0 0 0 0 0 0 0 0 0 0 0 0 80785 255 85 170 170 170 170 85 0 170 170 170 85 255 85 255 85 85
809 0 0 0 0 0 0 0 0 0 0 0 0 80885 255 85 170 170 170 255 255 85 85 85 85 255 255 85 170 170 170
810 0 0 0 0 0 0 85 85 85 0 0 0 80985 255 85 170 170 170 255 255 85 170 170 170 170 170 170 85 85 85
811 85 85 85 0 0 0 0 0 0 85 85 85 8100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
812255 255 255 255 255 255 255 255 255 255 255 255 8110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
813255 255 255 255 255 255 255 255 255 255 255 255 8120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
814255 255 255 255 255 255 255 255 255 255 255 255 8130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
815255 255 255 255 255 255 255 255 255 255 255 255 8140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
816255 255 255 255 255 255 255 255 255 255 255 255 8150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
817255 255 255 255 255 255 170 170 170 170 170 170 8160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
818 85 85 85 0 0 0 0 0 0 0 0 0 8170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
819 0 0 0 85 85 85 0 0 0 0 0 0 8180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
820 0 0 0 0 0 0 0 0 0 85 85 85 8190 0 0 0 0 0 0 0 0 0 0 0
821 0 0 0 0 0 0 0 0 0 0 0 0 8200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
822 0 0 0 0 0 0 0 0 0 0 0 0 8210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
823 0 0 0 0 0 0 0 0 0 0 0 0 8220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
824 0 0 0 0 0 0 0 0 0 0 0 0 8230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
825 0 0 0 0 0 0 0 0 0 0 0 0 8240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 85
826 0 0 0 0 0 0 0 0 0 0 0 0 825255 255 85 255 255 85 255 255 85 255 255 255 255 255 85 255 255 85
827 0 0 0 0 0 0 0 0 0 0 0 0 826255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 170 85 0
828 0 0 0 0 0 0 0 0 0 0 0 0 827255 255 85 255 255 85 255 255 85 170 85 0 0 170 0 85 85 85
829 0 0 0 0 0 0 0 0 0 0 0 0 828170 170 170 170 170 170 255 255 85 170 170 170 170 170 170 85 255 85
830 0 0 0 85 85 85 0 0 0 0 0 0 829255 85 85 85 255 85 85 85 85 255 85 85 85 85 85 170 170 170
831 85 85 85 0 0 0 0 0 0 170 170 170 830170 85 0 170 170 170 85 85 85 85 255 85 85 85 85 85 85 85
832255 255 255 255 255 255 255 255 255 255 255 255 83185 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
833255 255 255 255 255 255 255 255 255 255 255 255 8320 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
834255 255 255 255 255 255 255 255 255 255 255 255 833170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
835255 255 255 255 255 255 255 255 255 255 255 255 8340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
836255 255 255 255 255 255 255 255 255 255 255 255 8350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
837255 255 255 255 255 255 255 255 255 255 255 255 8360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
838170 170 170 85 85 85 0 0 0 0 0 0 8370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
839 0 0 0 85 85 85 85 85 85 0 0 0 8380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
840 0 0 0 0 0 0 0 0 0 85 85 85 8390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
841 0 0 0 0 0 0 0 0 0 0 0 0 8400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
842 0 0 0 0 0 0 0 0 0 0 0 0 8410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
843 0 0 0 0 0 0 0 0 0 0 0 0 8420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
844 0 0 0 0 0 0 0 0 0 0 0 0 8430 0 0 0 0 0 0 0 0 0 0 0
845 0 0 0 0 0 0 0 0 0 0 0 0 8440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
846 0 0 0 0 0 0 0 0 0 0 0 0 8450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
847 0 0 0 0 0 0 0 0 0 0 0 0 8460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
848 0 0 0 0 0 0 0 0 0 0 0 0 8470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
849 0 0 0 0 0 0 0 0 0 0 0 0 8480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 85
850 0 0 0 85 85 85 0 0 0 85 85 85 849170 85 0 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
851 0 0 0 0 0 0 85 85 85 255 255 255 850255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
852255 255 255 255 255 255 255 255 255 255 255 255 851255 255 85 255 255 85 170 85 0 255 255 85 85 85 85 85 85 85
853255 255 255 255 255 255 255 255 255 255 255 255 852255 255 85 170 170 170 85 85 85 85 85 85 0 0 0 85 85 85
854255 255 255 255 255 255 255 255 255 255 255 255 8530 0 0 85 85 85 85 85 85 170 170 170 170 85 0 170 170 170
855255 255 255 255 255 255 255 255 255 255 255 255 854170 170 170 255 255 85 170 170 170 85 85 85 85 85 85 85 85 85
856255 255 255 255 255 255 255 255 255 255 255 255 8550 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
857255 255 255 255 255 255 255 255 255 255 255 255 85685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
858255 255 255 170 170 170 0 0 0 85 85 85 8570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
859 85 85 85 0 0 0 85 85 85 0 0 0 8580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
860 0 0 0 0 0 0 0 0 0 85 85 85 8590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
861 0 0 0 0 0 0 0 0 0 0 0 0 8600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
862 0 0 0 0 0 0 0 0 0 0 0 0 8610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
863 0 0 0 0 0 0 0 0 0 0 0 0 8620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
864 0 0 0 0 0 0 0 0 0 0 0 0 8630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
865 0 0 0 0 0 0 0 0 0 0 0 0 8640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
866 0 0 0 0 0 0 0 0 0 0 0 0 8650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
867 0 0 0 0 0 0 0 0 0 0 0 0 8660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
868 0 0 0 0 0 0 0 0 0 0 0 0 8670 0 0 0 0 0 0 0 0 0 0 0
869 0 0 0 0 0 0 0 0 0 0 0 0 8680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
870 0 0 0 85 85 85 0 0 0 85 85 85 8690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
871 0 0 0 85 85 85 170 170 170 255 255 255 8700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
872255 255 255 255 255 255 255 255 255 255 255 255 8710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
873255 255 255 255 255 255 255 255 255 255 255 255 8720 0 0 0 0 0 0 0 0 0 0 0 170 85 0 255 255 85
874255 255 255 255 255 255 255 255 255 255 255 255 873255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
875255 255 255 255 255 255 255 255 255 255 255 255 874255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
876255 255 255 255 255 255 255 255 255 255 255 255 875255 255 85 255 255 85 255 255 85 170 85 0 170 85 0 0 170 0
877255 255 255 255 255 255 255 255 255 255 255 255 8760 0 0 170 85 0 170 85 0 0 170 0 0 0 0 0 0 0
878255 255 255 170 170 170 0 0 0 85 85 85 87785 85 85 0 0 0 85 85 85 85 85 85 170 170 170 85 85 85
879 85 85 85 0 0 0 85 85 85 0 0 0 878170 170 170 85 85 85 85 85 85 170 170 170 170 85 0 85 85 85
880 0 0 0 0 0 0 0 0 0 0 0 0 87985 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
881 85 85 85 0 0 0 0 0 0 0 0 0 8800 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
882 0 0 0 0 0 0 0 0 0 0 0 0 88185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
883 0 0 0 0 0 0 0 0 0 0 0 0 8820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
884 0 0 0 0 0 0 0 0 0 0 0 0 8830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
885 0 0 0 0 0 0 0 0 0 0 0 0 8840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
886 0 0 0 0 0 0 0 0 0 0 0 0 8850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
887 0 0 0 0 0 0 0 0 0 0 0 0 8860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
888 0 0 0 0 0 0 0 0 0 0 0 0 8870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
889 0 0 0 0 0 0 0 0 0 0 0 0 8880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
890 85 85 85 0 0 0 0 0 0 85 85 85 8890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
891 0 0 0 170 170 170 255 255 255 255 255 255 8900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
892255 255 255 255 255 255 255 255 255 255 255 255 8910 0 0 0 0 0 0 0 0 0 0 0
893255 255 255 255 255 255 255 255 255 255 255 255 8920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
894255 255 255 255 255 255 255 255 255 255 255 255 8930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
895255 255 255 255 255 255 255 255 255 255 255 255 8940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
896255 255 255 255 255 255 255 255 255 255 255 255 8950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
897255 255 255 255 255 255 255 255 255 255 255 255 8960 0 0 0 0 0 0 0 0 0 0 0 255 255 85 170 85 0
898255 255 255 255 255 255 85 85 85 0 0 0 897255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 170 85 0
899 0 0 0 0 0 0 0 0 0 85 85 85 898255 255 85 255 255 85 255 255 85 170 85 0 255 255 85 255 255 85
900 0 0 0 0 0 0 0 0 0 0 0 0 899170 85 0 255 255 85 85 255 85 255 255 85 255 255 85 170 85 0
901 85 85 85 0 0 0 0 0 0 0 0 0 900170 85 0 255 255 85 170 85 0 0 0 0 0 0 0 0 0 0
902 0 0 0 0 0 0 0 0 0 0 0 0 9010 0 0 0 0 0 85 85 85 85 85 85 85 85 85 85 85 85
903 0 0 0 0 0 0 0 0 0 0 0 0 90285 85 85 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
904 0 0 0 0 0 0 0 0 0 0 0 0 9030 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
905 0 0 0 0 0 0 0 0 0 0 0 0 90485 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
906 0 0 0 0 0 0 0 0 0 0 0 0 9050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
907 0 0 0 0 0 0 0 0 0 0 0 0 9060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
908 0 0 0 0 0 0 0 0 0 0 0 0 9070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
909 0 0 0 0 0 0 0 0 0 0 0 0 9080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
910 85 85 85 0 0 0 85 85 85 0 0 0 9090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
911 0 0 0 255 255 255 255 255 255 255 255 255 9100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
912255 255 255 255 255 255 255 255 255 255 255 255 9110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
913255 255 255 255 255 255 255 255 255 255 255 255 9120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
914255 255 255 255 255 255 255 255 255 255 255 255 9130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
915255 255 255 255 255 255 255 255 255 255 255 255 9140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
916255 255 255 255 255 255 255 255 255 255 255 255 9150 0 0 0 0 0 0 0 0 0 0 0
917255 255 255 255 255 255 255 255 255 255 255 255 9160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
918255 255 255 255 255 255 170 170 170 0 0 0 9170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
919 0 0 0 0 0 0 0 0 0 85 85 85 9180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
920 0 0 0 0 0 0 0 0 0 0 0 0 9190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
921 85 85 85 0 0 0 0 0 0 0 0 0 9200 0 0 0 0 0 0 0 0 0 0 0 255 255 85 255 255 85
922 0 0 0 0 0 0 0 0 0 0 0 0 921255 255 85 255 255 85 170 85 0 255 255 85 255 255 85 255 255 85
923 0 0 0 0 0 0 0 0 0 0 0 0 922255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
924 0 0 0 0 0 0 0 0 0 0 0 0 923255 255 85 255 255 85 255 255 85 170 85 0 255 255 85 255 255 85
925 0 0 0 0 0 0 0 0 0 0 0 0 92485 255 85 170 85 0 0 170 0 85 85 85 0 0 0 85 85 85
926 0 0 0 0 0 0 0 0 0 0 0 0 9250 0 0 85 85 85 0 0 0 85 85 85 85 85 85 85 85 85
927 0 0 0 0 0 0 0 0 0 0 0 0 92685 85 85 85 85 85 85 85 85 85 85 85 0 0 0 85 85 85
928 0 0 0 0 0 0 0 0 0 0 0 0 9270 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
929 0 0 0 0 0 0 0 0 0 85 85 85 9280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
930 0 0 0 0 0 0 85 85 85 0 0 0 9290 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
931 85 85 85 255 255 255 255 255 255 255 255 255 9300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
932255 255 255 255 255 255 255 255 255 255 255 255 9310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
933255 255 255 255 255 255 255 255 255 255 255 255 9320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
934255 255 255 255 255 255 255 255 255 255 255 255 9330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
935255 255 255 255 255 255 255 255 255 255 255 255 9340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
936255 255 255 255 255 255 255 255 255 255 255 255 9350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
937255 255 255 255 255 255 255 255 255 255 255 255 9360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
938255 255 255 255 255 255 170 170 170 0 0 0 9370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
939 0 0 0 0 0 0 0 0 0 85 85 85 9380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
940 0 0 0 0 0 0 0 0 0 0 0 0 9390 0 0 0 0 0 0 0 0 0 0 0
941 85 85 85 0 0 0 0 0 0 0 0 0 9400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
942 0 0 0 0 0 0 0 0 0 0 0 0 9410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
943 0 0 0 0 0 0 0 0 0 0 0 0 9420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
944 0 0 0 0 0 0 0 0 0 0 0 0 9430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
945 0 0 0 0 0 0 0 0 0 0 0 0 9440 0 0 0 0 0 0 0 0 0 170 0 170 85 0 255 255 85
946 0 0 0 0 0 0 0 0 0 0 0 0 94585 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
947 0 0 0 0 0 0 0 0 0 0 0 0 946255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
948 0 0 0 0 0 0 0 0 0 0 0 0 947170 85 0 255 255 85 85 255 85 255 255 85 255 255 85 170 85 0
949 0 0 0 0 0 0 0 0 0 85 85 85 94885 255 85 170 85 0 170 85 0 0 0 0 0 0 0 0 0 0
950 0 0 0 85 85 85 0 0 0 0 0 0 9490 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
951170 170 170 255 255 255 255 255 255 255 255 255 9500 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
952255 255 255 255 255 255 255 255 255 255 255 255 9510 0 0 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
953255 255 255 255 255 255 255 255 255 255 255 255 9520 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
954255 255 255 255 255 255 255 255 255 255 255 255 9530 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
955255 255 255 255 255 255 255 255 255 255 255 255 9540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
956255 255 255 255 255 255 255 255 255 255 255 255 9550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
957255 255 255 255 255 255 255 255 255 255 255 255 9560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
958255 255 255 255 255 255 170 170 170 0 0 0 9570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
959 0 0 0 0 0 0 0 0 0 85 85 85 9580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
960 0 0 0 0 0 0 0 0 0 0 0 0 9590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
961 0 0 0 85 85 85 0 0 0 0 0 0 9600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
962 0 0 0 0 0 0 0 0 0 0 0 0 9610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
963 0 0 0 0 0 0 0 0 0 0 0 0 9620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
964 0 0 0 0 0 0 0 0 0 0 0 0 9630 0 0 0 0 0 0 0 0 0 0 0
965 0 0 0 0 0 0 0 0 0 0 0 0 9640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
966 0 0 0 0 0 0 0 0 0 0 0 0 9650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
967 0 0 0 0 0 0 0 0 0 0 0 0 9660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
968 0 0 0 0 0 0 0 0 0 0 0 0 9670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
969 0 0 0 0 0 0 85 85 85 0 0 0 9680 0 0 0 0 0 0 0 0 170 85 0 255 255 85 255 255 85
970 0 0 0 85 85 85 0 0 0 0 0 0 969255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
971255 255 255 255 255 255 255 255 255 255 255 255 970255 255 85 170 85 0 255 255 85 85 255 85 255 255 85 170 85 0
972255 255 255 255 255 255 255 255 255 255 255 255 971255 255 85 255 255 85 170 85 0 255 255 85 170 85 0 85 255 85
973255 255 255 255 255 255 170 170 170 255 255 255 972170 85 0 170 85 0 0 0 0 0 0 0 0 0 0 85 85 85
974255 255 255 255 255 255 255 255 255 255 255 255 9730 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
975255 255 255 255 255 255 255 255 255 255 255 255 9740 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
976255 255 255 255 255 255 255 255 255 255 255 255 9750 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
977255 255 255 255 255 255 255 255 255 255 255 255 9760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
978255 255 255 255 255 255 255 255 255 0 0 0 97785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
979 0 0 0 0 0 0 0 0 0 85 85 85 9780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
980 0 0 0 0 0 0 0 0 0 0 0 0 9790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
981 0 0 0 85 85 85 0 0 0 0 0 0 9800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
982 0 0 0 0 0 0 0 0 0 0 0 0 9810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
983 0 0 0 0 0 0 0 0 0 0 0 0 9820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
984 0 0 0 0 0 0 0 0 0 0 0 0 9830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
985 0 0 0 0 0 0 0 0 0 0 0 0 9840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
986 0 0 0 0 0 0 0 0 0 0 0 0 9850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
987 0 0 0 0 0 0 0 0 0 0 0 0 9860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
988 0 0 0 0 0 0 0 0 0 0 0 0 9870 0 0 0 0 0 0 0 0 0 0 0
989 0 0 0 85 85 85 0 0 0 0 0 0 9880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
990 0 0 0 85 85 85 0 0 0 0 0 0 9890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
991255 255 255 255 255 255 255 255 255 255 255 255 9900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
992255 255 255 255 255 255 255 255 255 255 255 255 9910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
993255 255 255 255 255 255 170 170 170 255 255 255 9920 0 0 0 0 0 0 0 0 85 85 85 255 255 85 170 85 0
994255 255 255 255 255 255 255 255 255 255 255 255 993255 255 85 170 85 0 255 255 85 170 85 0 255 255 85 85 255 85
995255 255 255 255 255 255 255 255 255 255 255 255 994255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
996255 255 255 255 255 255 255 255 255 255 255 255 995255 255 85 170 85 0 255 255 85 85 255 85 170 85 0 170 85 0
997255 255 255 255 255 255 255 255 255 255 255 255 9960 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
998255 255 255 255 255 255 255 255 255 0 0 0 9970 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
999 0 0 0 0 0 0 0 0 0 85 85 85 9980 0 0 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
1000 0 0 0 0 0 0 0 0 0 0 0 0 9990 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1001 0 0 0 85 85 85 0 0 0 0 0 0 10000 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
1002 0 0 0 0 0 0 0 0 0 0 0 0 10010 0 0 0 0 0 85 85 85 85 85 85 85 85 85 85 85 85
1003 0 0 0 0 0 0 0 0 0 0 0 0 100285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1004 0 0 0 0 0 0 0 0 0 0 0 0 10030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1005 0 0 0 0 0 0 0 0 0 0 0 0 10040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1006 0 0 0 0 0 0 0 0 0 0 0 0 10050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1007 0 0 0 0 0 0 0 0 0 0 0 0 10060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1008 0 0 0 0 0 0 0 0 0 0 0 0 10070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1009 0 0 0 85 85 85 0 0 0 0 0 0 10080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1010 0 0 0 85 85 85 0 0 0 85 85 85 10090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1011255 255 255 255 255 255 255 255 255 255 255 255 10100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1012255 255 255 255 255 255 255 255 255 255 255 255 10110 0 0 0 0 0 0 0 0 0 0 0
1013255 255 255 255 255 255 170 170 170 255 255 255 10120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1014255 255 255 255 255 255 255 255 255 255 255 255 10130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1015255 255 255 255 255 255 255 255 255 255 255 255 10140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1016255 255 255 255 255 255 255 255 255 255 255 255 10150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1017255 255 255 255 255 255 255 255 255 255 255 255 10160 0 0 0 0 0 0 0 0 170 85 0 255 255 85 255 255 85
1018255 255 255 255 255 255 255 255 255 0 0 0 1017255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1019 0 0 0 0 0 0 0 0 0 85 85 85 1018255 255 85 255 255 85 170 85 0 255 255 85 170 85 0 85 255 85
1020 0 0 0 0 0 0 0 0 0 0 0 0 1019255 255 85 85 255 85 170 85 0 170 85 0 85 255 85 170 85 0
1021 0 0 0 85 85 85 0 0 0 0 0 0 10200 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1022 0 0 0 0 0 0 0 0 0 0 0 0 10210 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1023 0 0 0 0 0 0 0 0 0 0 0 0 102285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1024 0 0 0 0 0 0 0 0 0 0 0 0 10230 0 0 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
1025 0 0 0 0 0 0 0 0 0 0 0 0 10240 0 0 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
1026 0 0 0 0 0 0 0 0 0 0 0 0 102585 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
1027 0 0 0 0 0 0 0 0 0 0 0 0 102685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1028 0 0 0 0 0 0 0 0 0 0 0 0 10270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1029 0 0 0 85 85 85 0 0 0 0 0 0 10280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1030 0 0 0 85 85 85 0 0 0 85 85 85 10290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1031255 255 255 255 255 255 255 255 255 255 255 255 10300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1032255 255 255 255 255 255 255 255 255 255 255 255 10310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1033255 255 255 255 255 255 170 170 170 255 255 255 10320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1034255 255 255 255 255 255 255 255 255 255 255 255 10330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1035255 255 255 255 255 255 255 255 255 255 255 255 10340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1036255 255 255 255 255 255 255 255 255 255 255 255 10350 0 0 0 0 0 0 0 0 0 0 0
1037255 255 255 255 255 255 255 255 255 255 255 255 10360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1038255 255 255 255 255 255 255 255 255 0 0 0 10370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1039 0 0 0 0 0 0 0 0 0 85 85 85 10380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1040 0 0 0 0 0 0 0 0 0 0 0 0 10390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1041 0 0 0 85 85 85 0 0 0 0 0 0 10400 0 0 0 0 0 0 0 0 85 85 85 255 255 85 85 255 85
1042 0 0 0 0 0 0 0 0 0 0 0 0 1041255 255 85 255 255 85 85 255 85 255 255 85 255 255 85 255 255 85
1043 0 0 0 0 0 0 0 0 0 0 0 0 1042255 255 85 170 85 0 255 255 85 85 255 85 255 255 85 255 255 85
1044 0 0 0 0 0 0 0 0 0 0 0 0 1043170 85 0 170 85 0 85 255 85 170 85 0 0 0 0 0 0 0
1045 0 0 0 0 0 0 0 0 0 0 0 0 10440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1046 0 0 0 0 0 0 0 0 0 0 0 0 10450 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1047 0 0 0 0 0 0 0 0 0 0 0 0 10460 0 0 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
1048 0 0 0 0 0 0 0 0 0 0 0 0 10470 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1049 0 0 0 85 85 85 0 0 0 0 0 0 10480 0 0 85 85 85 85 85 85 170 170 170 170 170 170 170 170 170
1050 0 0 0 0 0 0 85 85 85 85 85 85 1049170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 85 85 85
1051255 255 255 255 255 255 255 255 255 255 255 255 105085 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1052255 255 255 255 255 255 255 255 255 255 255 255 10510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1053255 255 255 255 255 255 170 170 170 255 255 255 10520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1054255 255 255 255 255 255 255 255 255 255 255 255 10530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1055255 255 255 255 255 255 255 255 255 255 255 255 10540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1056255 255 255 255 255 255 255 255 255 255 255 255 10550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1057255 255 255 255 255 255 255 255 255 255 255 255 10560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1058255 255 255 255 255 255 255 255 255 0 0 0 10570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1059 0 0 0 0 0 0 0 0 0 85 85 85 10580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1060 0 0 0 0 0 0 0 0 0 0 0 0 10590 0 0 0 0 0 0 0 0 0 0 0
1061 0 0 0 85 85 85 0 0 0 0 0 0 10600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1062 0 0 0 0 0 0 0 0 0 0 0 0 10610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1063 0 0 0 0 0 0 0 0 0 0 0 0 10620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1064 0 0 0 0 0 0 0 0 0 0 0 0 10630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1065 0 0 0 0 0 0 0 0 0 0 0 0 10640 0 0 0 0 0 0 0 0 85 85 85 255 255 85 255 255 85
1066 0 0 0 0 0 0 0 0 0 0 0 0 1065170 85 0 255 255 85 255 255 85 170 85 0 255 255 85 170 85 0
1067 0 0 0 0 0 0 0 0 0 0 0 0 1066255 255 85 85 255 85 170 85 0 255 255 85 170 85 0 85 255 85
1068 0 0 0 0 0 0 0 0 0 0 0 0 1067170 85 0 170 85 0 0 0 0 0 0 0 0 0 0 0 0 0
1069 0 0 0 85 85 85 0 0 0 0 0 0 10680 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
1070 0 0 0 0 0 0 0 0 0 85 85 85 106985 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1071255 255 255 255 255 255 255 255 255 255 255 255 10700 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1072255 255 255 255 255 255 255 255 255 255 255 255 10710 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1073255 255 255 255 255 255 170 170 170 255 255 255 107285 85 85 0 0 0 170 170 170 170 170 170 170 170 170 170 170 170
1074255 255 255 255 255 255 255 255 255 255 255 255 1073170 170 170 170 170 170 170 170 170 85 85 85 85 85 85 85 85 85
1075255 255 255 255 255 255 255 255 255 255 255 255 107485 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1076255 255 255 255 255 255 255 255 255 255 255 255 10750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1077255 255 255 255 255 255 255 255 255 255 255 255 10760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1078255 255 255 255 255 255 255 255 255 0 0 0 10770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1079 85 85 85 85 85 85 85 85 85 85 85 85 10780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1080 85 85 85 0 0 0 0 0 0 0 0 0 10790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1081 0 0 0 85 85 85 0 0 0 0 0 0 10800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1082 0 0 0 0 0 0 0 0 0 0 0 0 10810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1083 0 0 0 0 0 0 0 0 0 0 0 0 10820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1084 0 0 0 0 0 0 0 0 0 0 0 0 10830 0 0 0 0 0 0 0 0 0 0 0
1085 0 0 0 0 0 0 0 0 0 0 0 0 10840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1086 0 0 0 0 0 0 0 0 0 0 0 0 10850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1087 0 0 0 0 0 0 0 0 0 0 0 0 10860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1088 0 0 0 0 0 0 0 0 0 0 0 0 10870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1089 0 0 0 85 85 85 0 0 0 170 85 0 10880 0 0 0 0 0 0 0 0 0 0 0 170 85 0 255 255 85
1090255 255 85 170 85 0 0 0 0 0 0 0 1089255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 85 255 85
1091 85 85 85 255 255 255 255 255 255 255 255 255 1090170 85 0 255 255 85 170 85 0 85 255 85 170 85 0 170 85 0
1092255 255 255 255 255 255 255 255 255 255 255 255 10910 170 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1093255 255 255 255 255 255 170 170 170 255 255 255 10920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1094255 255 255 255 255 255 255 255 255 255 255 255 10930 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1095255 255 255 255 255 255 255 255 255 255 255 255 10940 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1096255 255 255 255 255 255 255 255 255 255 255 255 10950 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
1097255 255 255 255 255 255 255 255 255 255 255 255 10960 0 0 85 85 85 170 170 170 170 170 170 255 255 255 170 170 170
1098255 255 255 255 255 255 255 255 255 85 85 85 1097170 170 170 170 170 170 85 85 85 85 85 85 85 85 85 85 85 85
1099 0 0 0 0 0 0 0 0 0 0 0 0 10980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1100 0 0 0 85 85 85 85 85 85 0 0 0 10990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1101 0 0 0 85 85 85 0 0 0 0 0 0 11000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1102 0 0 0 0 0 0 0 0 0 0 0 0 11010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1103 0 0 0 0 0 0 0 0 0 0 0 0 11020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1104 0 0 0 0 0 0 0 0 0 0 0 0 11030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1105 0 0 0 0 0 0 0 0 0 0 0 0 11040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1106 0 0 0 0 0 0 0 0 0 0 0 0 11050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1107 0 0 0 0 0 0 0 0 0 0 0 0 11060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1108 0 0 0 0 0 0 0 0 0 0 0 0 11070 0 0 0 0 0 0 0 0 0 0 0
1109 0 0 0 0 0 0 170 85 0 255 255 85 11080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1110170 85 0 255 255 85 170 85 0 0 0 0 11090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1111 0 0 0 85 85 85 255 255 255 255 255 255 11100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1112255 255 255 255 255 255 255 255 255 255 255 255 11110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1113255 255 255 255 255 255 170 170 170 255 255 255 11120 0 0 0 0 0 0 0 0 0 0 0 85 255 85 255 255 85
1114255 255 255 255 255 255 255 255 255 255 255 255 1113170 85 0 255 255 85 255 255 85 170 85 0 85 255 85 170 85 0
1115255 255 255 255 255 255 255 255 255 255 255 255 1114255 255 85 170 85 0 0 170 0 170 85 0 0 0 0 0 0 0
1116255 255 255 255 255 255 255 255 255 255 255 255 11150 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1117255 255 255 255 255 255 255 255 255 255 255 255 11160 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
1118255 255 85 170 85 0 255 255 85 0 0 0 111785 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1119 0 0 0 0 0 0 0 0 0 0 0 0 11180 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1120 0 0 0 0 0 0 85 85 85 85 85 85 111985 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1121 85 85 85 0 0 0 0 0 0 0 0 0 112085 85 85 0 0 0 170 170 170 170 170 170 170 170 170 85 85 85
1122 0 0 0 0 0 0 0 0 0 0 0 0 112185 85 85 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
1123 0 0 0 0 0 0 0 0 0 0 0 0 11220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1124 0 0 0 0 0 0 0 0 0 0 0 0 11230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1125 0 0 0 0 0 0 0 0 0 0 0 0 11240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1126 0 0 0 0 0 0 0 0 0 0 0 0 11250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1127 0 0 0 0 0 0 0 0 0 0 0 0 11260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1128 0 0 0 0 0 0 0 0 0 0 0 0 11270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1129 0 0 0 170 85 0 255 255 85 170 85 0 11280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1130255 255 85 170 85 0 255 255 85 170 85 0 11290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1131 0 0 0 0 0 0 85 85 85 255 255 255 11300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1132255 255 255 255 255 255 255 255 255 255 255 255 11310 0 0 0 0 0 0 0 0 0 0 0
1133255 255 255 255 255 255 255 255 255 255 255 255 11320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1134255 255 255 255 255 255 255 255 255 255 255 255 11330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1135255 255 255 255 255 255 255 255 255 255 255 255 11340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1136255 255 255 255 255 255 255 255 255 255 255 255 11350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1137255 255 255 255 255 255 255 255 255 255 255 85 11360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 85
1138170 85 0 255 255 85 170 85 0 0 0 0 1137255 255 85 255 255 85 255 255 85 255 255 85 170 85 0 170 85 0
1139 0 0 0 0 0 0 0 0 0 0 0 0 11380 170 0 85 85 85 85 85 85 0 0 0 0 0 0 85 85 85
1140 0 0 0 0 0 0 0 0 0 0 0 0 11390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1141170 85 0 0 0 0 0 0 0 0 0 0 11400 0 0 0 0 0 85 85 85 0 0 0 85 85 85 85 85 85
1142 0 0 0 0 0 0 0 0 0 0 0 0 114185 85 85 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
1143 0 0 0 0 0 0 0 0 0 0 0 0 114285 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1144 0 0 0 0 0 0 0 0 0 0 0 0 11430 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1145 0 0 0 0 0 0 0 0 0 0 0 0 11440 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1146 0 0 0 0 0 0 0 0 0 0 0 0 114585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1147 0 0 0 0 0 0 0 0 0 0 0 0 11460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1148 0 0 0 0 0 0 0 0 0 0 0 0 11470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1149170 85 0 255 255 85 170 85 0 255 255 85 11480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1150170 85 0 255 255 85 170 85 0 255 255 85 11490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1151170 85 0 0 0 0 0 0 0 85 85 85 11500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1152255 255 255 255 255 255 255 255 255 255 255 255 11510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1153255 255 255 255 255 255 255 255 255 255 255 255 11520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1154255 255 255 255 255 255 255 255 255 255 255 255 11530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1155255 255 255 255 255 255 255 255 255 255 255 255 11540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1156255 255 255 255 255 255 255 255 255 255 255 255 11550 0 0 0 0 0 0 0 0 0 0 0
1157255 255 255 255 255 255 255 255 255 170 85 0 11560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1158255 255 85 170 85 0 255 255 85 0 0 0 11570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1159 0 0 0 0 0 0 0 0 0 0 0 0 11580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1160 0 0 0 0 0 0 0 0 0 170 85 0 11590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1161255 255 85 170 85 0 0 0 0 0 0 0 11600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1162 0 0 0 0 0 0 0 0 0 0 0 0 1161255 255 85 255 255 85 170 85 0 0 170 0 85 85 85 85 85 85
1163 0 0 0 0 0 0 0 0 0 0 0 0 116285 85 85 85 85 85 0 0 0 85 85 85 85 85 85 0 0 0
1164 0 0 0 0 0 0 0 0 0 0 0 0 116385 85 85 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
1165 0 0 0 0 0 0 0 0 0 0 0 0 116485 85 85 85 85 85 85 85 85 170 170 170 170 170 170 85 85 85
1166 0 0 0 0 0 0 0 0 0 0 0 0 1165170 170 170 170 170 170 170 170 170 170 170 170 85 85 85 85 85 85
1167 0 0 0 0 0 0 0 0 0 170 85 0 116685 85 85 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
1168255 255 85 170 85 0 255 255 85 170 85 0 116785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1169255 255 85 170 85 0 255 255 85 170 85 0 116885 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1170255 255 85 170 85 0 255 255 85 170 85 0 11690 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1171255 255 85 0 0 0 0 0 0 0 0 0 117085 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1172 85 85 85 255 255 255 255 255 255 255 255 255 11710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1173255 255 255 255 255 255 255 255 255 255 255 255 11720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1174255 255 255 255 255 255 255 255 255 255 255 255 11730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1175255 255 255 255 255 255 255 255 255 255 255 255 11740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1176255 255 255 255 255 255 255 255 255 255 255 255 11750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1177255 255 255 255 255 255 255 255 255 255 255 85 11760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1178170 85 0 255 255 85 170 85 0 0 0 0 11770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1179 0 0 0 0 0 0 0 0 0 0 0 0 11780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1180 0 0 0 0 0 0 0 0 0 255 255 85 11790 0 0 0 0 0 0 0 0 0 0 0
1181170 85 0 255 255 85 0 0 0 0 0 0 11800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1182 0 0 0 0 0 0 0 0 0 0 0 0 11810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1183 0 0 0 0 0 0 0 0 0 0 0 0 11820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1184 0 0 0 0 0 0 0 0 0 0 0 0 11830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1185 0 0 0 0 0 0 0 0 0 0 0 0 11840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1186 0 0 0 0 0 0 0 0 0 0 0 0 11850 0 0 170 85 0 85 85 85 0 0 0 0 0 0 0 0 0
1187 0 0 0 0 0 0 170 85 0 255 255 85 118685 85 85 85 85 85 85 85 85 85 85 85 170 170 170 85 85 85
1188170 85 0 255 255 85 170 85 0 255 255 85 118785 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
1189170 85 0 255 255 85 170 85 0 255 255 85 1188170 170 170 170 170 170 170 170 170 170 170 170 255 255 255 255 255 255
1190170 85 0 255 255 85 170 85 0 255 255 85 1189255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 170 170 170
1191170 85 0 255 255 85 0 0 0 0 0 0 1190170 170 170 170 170 170 170 170 170 85 85 85 85 85 85 85 85 85
1192 0 0 0 85 85 85 255 255 255 255 255 255 11910 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1193255 255 255 255 255 255 255 255 255 255 255 255 11920 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1194255 255 255 255 255 255 255 255 255 255 255 255 11930 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1195255 255 255 255 255 255 255 255 255 255 255 255 11940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1196255 255 255 255 255 255 255 255 255 255 255 255 11950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1197255 255 255 255 255 255 170 170 170 170 85 0 11960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1198255 255 85 170 85 0 255 255 85 170 85 0 11970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1199 0 0 0 0 0 0 0 0 0 0 0 0 11980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1200 0 0 0 0 0 0 255 255 85 170 85 0 11990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1201255 255 85 170 85 0 0 0 0 0 0 0 12000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1202 0 0 0 0 0 0 0 0 0 0 0 0 12010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1203 0 0 0 0 0 0 0 0 0 0 0 0 12020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1204 0 0 0 0 0 0 0 0 0 0 0 0 12030 0 0 0 0 0 0 0 0 0 0 0
1205 0 0 0 0 0 0 0 0 0 0 0 0 12040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1206 0 0 0 0 0 0 0 0 0 0 0 0 12050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1207 0 0 0 0 0 0 255 255 85 170 85 0 12060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1208255 255 85 170 85 0 255 255 85 170 85 0 12070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1209255 255 85 170 85 0 255 255 85 170 85 0 12080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1210255 255 85 170 85 0 255 255 85 170 85 0 12090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1211255 255 85 170 85 0 255 255 85 0 0 0 121085 85 85 85 85 85 85 85 85 85 85 85 170 170 170 170 170 170
1212 0 0 0 0 0 0 85 85 85 255 255 255 1211255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 170 170 170
1213255 255 255 255 255 255 255 255 255 255 255 255 1212255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
1214255 255 255 255 255 255 255 255 255 255 255 255 1213255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
1215255 255 255 255 255 255 255 255 255 255 255 255 1214255 255 255 255 255 255 170 170 170 255 255 255 170 170 170 85 85 85
1216255 255 255 255 255 255 255 255 255 255 255 255 12150 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1217255 255 255 170 170 170 170 170 170 255 255 85 121685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1218170 85 0 255 255 85 170 85 0 255 255 85 121785 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1219170 85 0 255 255 85 170 85 0 255 255 85 12180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1220170 85 0 255 255 85 170 85 0 255 255 85 12190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1221170 85 0 255 255 85 0 0 0 0 0 0 12200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1222 0 0 0 0 0 0 0 0 0 0 0 0 12210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1223 0 0 0 0 0 0 0 0 0 0 0 0 12220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1224 0 0 0 0 0 0 0 0 0 0 0 0 12230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1225 0 0 0 0 0 0 0 0 0 0 0 0 12240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1226 0 0 0 0 0 0 0 0 0 0 0 0 12250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1227 0 0 0 0 0 0 170 85 0 255 255 85 12260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1228170 85 0 255 255 85 170 85 0 255 255 85 12270 0 0 0 0 0 0 0 0 0 0 0
1229170 85 0 255 255 85 170 85 0 255 255 85 12280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1230170 85 0 255 255 85 170 85 0 255 255 85 12290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1231170 85 0 255 255 85 170 85 0 0 0 0 12300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1232 0 0 0 0 0 0 0 0 0 85 85 85 12310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1233255 255 255 255 255 255 255 255 255 255 255 255 12320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1234255 255 255 255 255 255 255 255 255 255 255 255 12330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1235255 255 255 255 255 255 255 255 255 255 255 255 123485 85 85 85 85 85 85 85 85 85 85 85 170 170 170 170 170 170
1236255 255 255 255 255 255 255 255 255 255 255 255 1235255 255 255 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
1237255 255 255 170 170 170 170 170 170 170 85 0 1236255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 170 170
1238255 255 85 170 85 0 255 255 85 170 85 0 1237255 255 255 255 255 255 170 170 170 255 255 255 255 255 255 255 255 255
1239255 255 85 170 85 0 255 255 85 170 85 0 1238255 255 255 255 255 255 255 255 255 255 255 255 170 170 170 85 85 85
1240255 255 85 170 85 0 255 255 85 170 85 0 12390 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1241255 255 85 170 85 0 255 255 85 0 0 0 12400 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1242 0 0 0 0 0 0 0 0 0 0 0 0 12410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1243 0 0 0 0 0 0 0 0 0 0 0 0 124285 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1244 0 0 0 0 0 0 0 0 0 0 0 0 12430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1245 0 0 0 0 0 0 0 0 0 0 0 0 12440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1246 0 0 0 0 0 0 0 0 0 0 0 0 12450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1247 0 0 0 0 0 0 255 255 85 170 85 0 12460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1248255 255 85 170 85 0 255 255 85 170 85 0 12470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1249255 255 85 170 85 0 255 255 85 170 85 0 12480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1250255 255 85 170 85 0 255 255 85 170 85 0 12490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1251255 255 85 170 85 0 255 255 85 170 85 0 12500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1252 0 0 0 0 0 0 0 0 0 0 0 0 12510 0 0 0 0 0 0 0 0 0 0 0
1253 0 0 0 255 255 255 255 255 255 255 255 255 12520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1254255 255 255 255 255 255 255 255 255 255 255 255 12530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1255255 255 255 255 255 255 255 255 255 255 255 255 12540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1256255 255 255 255 255 255 255 255 255 255 255 255 12550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1257255 255 255 170 170 170 170 170 170 255 255 85 12560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1258170 85 0 255 255 85 170 85 0 255 255 85 12570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1259170 85 0 255 255 85 170 85 0 255 255 85 125885 85 85 85 85 85 85 85 85 85 85 85 85 85 85 170 170 170
1260170 85 0 255 255 85 170 85 0 255 255 85 1259170 170 170 170 170 170 255 255 255 170 170 170 255 255 255 170 170 170
1261170 85 0 255 255 85 170 85 0 255 255 85 1260255 255 255 170 170 170 255 255 255 170 170 170 255 255 255 255 255 255
1262 0 0 0 0 0 0 0 0 0 0 0 0 1261255 255 255 170 170 170 255 255 255 170 170 170 255 255 255 170 170 170
1263 0 0 0 0 0 0 0 0 0 0 0 0 1262170 170 170 170 170 170 170 170 170 170 170 170 85 85 85 85 85 85
1264 0 0 0 0 0 0 0 0 0 0 0 0 12630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1265 0 0 0 0 0 0 0 0 0 0 0 0 126485 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1266 0 0 0 0 0 0 0 0 0 0 0 0 126585 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1267 0 0 0 0 0 0 170 85 0 255 255 85 12660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1268170 85 0 255 255 85 170 85 0 255 255 85 12670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1269170 85 0 255 255 85 170 85 0 255 255 85 12680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1270170 85 0 255 255 85 170 85 0 255 255 85 12690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1271170 85 0 255 255 85 170 85 0 255 255 85 12700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1272170 85 0 0 0 0 0 0 0 0 0 0 12710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1273 0 0 0 255 255 255 255 255 255 255 255 255 12720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1274255 255 255 255 255 255 255 255 255 255 255 255 12730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1275255 255 255 255 255 255 255 255 255 255 255 255 12740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1276255 255 255 255 255 255 255 255 255 255 255 255 12750 0 0 0 0 0 0 0 0 0 0 0
1277255 255 255 170 170 170 170 170 170 170 85 0 12760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1278255 255 85 170 85 0 255 255 85 170 85 0 12770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1279255 255 85 170 85 0 255 255 85 170 85 0 12780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1280255 255 85 170 85 0 255 255 85 170 85 0 12790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1281255 255 85 170 85 0 255 255 85 170 85 0 12800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1282255 255 85 0 0 0 0 0 0 0 0 0 12810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1283 0 0 0 0 0 0 0 0 0 0 0 0 128285 85 85 85 85 85 85 85 85 0 0 0 85 85 85 85 85 85
1284 0 0 0 0 0 0 0 0 0 0 0 0 128385 85 85 85 85 85 85 85 85 170 170 170 170 170 170 170 170 170
1285 0 0 0 0 0 0 0 0 0 0 0 0 1284170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1286 0 0 0 0 0 0 0 0 0 0 0 0 1285170 170 170 170 170 170 170 170 170 170 170 170 85 85 85 170 170 170
1287 0 0 0 0 0 0 255 255 85 170 85 0 1286170 170 170 170 170 170 85 85 85 0 0 0 85 85 85 0 0 0
1288255 255 85 170 85 0 255 255 85 170 85 0 12870 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1289255 255 85 170 85 0 255 255 85 170 85 0 12880 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
1290255 255 85 170 85 0 255 255 85 170 85 0 12890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1291255 255 85 170 85 0 255 255 85 170 85 0 12900 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1292255 255 85 0 0 0 0 0 0 0 0 0 12910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1293 85 85 85 255 255 255 255 255 255 255 255 255 12920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1294255 255 255 255 255 255 255 255 255 255 255 255 12930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1295255 255 255 255 255 255 255 255 255 255 255 255 12940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1296255 255 255 255 255 255 255 255 255 255 255 255 12950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1297255 255 255 170 170 170 85 85 85 255 255 85 12960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1298170 85 0 255 255 85 170 85 0 255 255 85 12970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1299170 85 0 255 255 85 170 85 0 255 255 85 12980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1300170 85 0 255 255 85 170 85 0 255 255 85 12990 0 0 0 0 0 0 0 0 0 0 0
1301170 85 0 255 255 85 170 85 0 255 255 85 13000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1302170 85 0 255 255 85 0 0 0 0 0 0 13010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1303 0 0 0 0 0 0 0 0 0 0 0 0 13020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1304 0 0 0 0 0 0 0 0 0 0 0 0 13030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1305 0 0 0 0 0 0 0 0 0 0 0 0 13040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1306 0 0 0 0 0 0 0 0 0 0 0 0 13050 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
1307 0 0 0 0 0 0 170 85 0 255 255 85 1306170 170 170 85 85 85 85 85 85 85 85 85 0 0 0 85 85 85
1308170 85 0 255 255 85 170 85 0 255 255 85 13070 0 0 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
1309170 85 0 255 255 85 170 85 0 255 255 85 130885 85 85 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
1310170 85 0 255 255 85 170 85 0 255 255 85 130985 85 85 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
1311170 85 0 255 255 85 170 85 0 255 255 85 13100 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1312170 85 0 255 255 85 85 85 85 85 85 85 131185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1313255 255 255 255 255 255 255 255 255 255 255 255 13120 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1314255 255 255 255 255 255 255 255 255 255 255 255 131385 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1315255 255 255 255 255 255 255 255 255 255 255 255 13140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1316255 255 255 255 255 255 255 255 255 255 255 255 13150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1317170 170 170 85 85 85 85 85 85 170 85 0 13160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1318255 255 85 170 85 0 255 255 85 170 85 0 13170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1319255 255 85 170 85 0 255 255 85 170 85 0 13180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1320255 255 85 170 85 0 255 255 85 170 85 0 13190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1321255 255 85 170 85 0 255 255 85 170 85 0 13200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1322255 255 85 170 85 0 255 255 85 170 85 0 13210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1323 0 0 0 0 0 0 0 0 0 0 0 0 13220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1324 0 0 0 0 0 0 0 0 0 0 0 0 13230 0 0 0 0 0 0 0 0 0 0 0
1325 0 0 0 0 0 0 0 0 0 0 0 0 13240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1326 0 0 0 0 0 0 0 0 0 0 0 0 13250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1327 0 0 0 0 0 0 255 255 85 170 85 0 13260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1328255 255 85 170 85 0 255 255 85 170 85 0 13270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1329255 255 85 170 85 0 255 255 85 170 85 0 13280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1330255 255 85 170 85 0 255 255 85 170 85 0 13290 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
1331255 255 85 170 85 0 255 255 85 170 85 0 133085 85 85 85 85 85 85 85 85 0 0 0 85 85 85 0 0 0
1332255 255 85 170 85 0 255 255 85 255 255 255 133185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1333255 255 255 255 255 255 255 255 255 255 255 255 133285 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1334255 255 255 255 255 255 255 255 255 255 255 255 13330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1335255 255 255 255 255 255 255 255 255 255 255 255 133485 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1336255 255 255 255 255 255 255 255 255 170 170 170 13350 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1337 85 85 85 0 0 0 0 0 0 170 85 0 13360 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
1338170 85 0 255 255 85 170 85 0 255 255 85 13370 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1339170 85 0 255 255 85 170 85 0 255 255 85 133885 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1340170 85 0 255 255 85 170 85 0 255 255 85 13390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1341170 85 0 255 255 85 170 85 0 255 255 85 13400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1342170 85 0 255 255 85 170 85 0 255 255 85 13410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1343 0 0 0 0 0 0 0 0 0 0 0 0 13420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1344 0 0 0 0 0 0 0 0 0 0 0 0 13430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1345 0 0 0 0 0 0 0 0 0 0 0 0 13440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1346 0 0 0 0 0 0 0 0 0 0 0 0 13450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1347 0 0 0 0 0 0 170 85 0 255 255 85 13460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1348170 85 0 255 255 85 170 85 0 255 255 85 13470 0 0 0 0 0 0 0 0 0 0 0
1349170 85 0 255 255 85 170 85 0 255 255 85 13480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1350170 85 0 255 255 85 170 85 0 255 255 85 13490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1351170 85 0 255 255 85 170 85 0 255 255 85 13500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1352170 85 0 255 255 85 170 85 0 255 255 85 13510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1353255 255 255 255 255 255 255 255 255 255 255 255 13520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1354255 255 255 255 255 255 255 255 255 255 255 255 13530 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
1355255 255 255 255 255 255 255 255 255 255 255 255 135485 85 85 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
1356255 255 255 255 255 255 170 170 170 85 85 85 13550 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1357 0 0 0 0 0 0 0 0 0 170 85 0 13560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1358255 255 85 170 85 0 255 255 85 170 85 0 13570 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1359255 255 85 170 85 0 255 255 85 170 85 0 13580 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1360255 255 85 170 85 0 255 255 85 170 85 0 135985 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1361255 255 85 170 85 0 255 255 85 170 85 0 13600 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1362255 255 85 170 85 0 255 255 85 0 0 0 136185 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1363 0 0 0 0 0 0 0 0 0 0 0 0 13620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1364 0 0 0 0 0 0 0 0 0 0 0 0 13630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1365 0 0 0 0 0 0 0 0 0 0 0 0 13640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1366 0 0 0 0 0 0 0 0 0 0 0 0 13650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1367 0 0 0 0 0 0 255 255 85 170 85 0 13660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1368255 255 85 170 85 0 255 255 85 170 85 0 13670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1369255 255 85 170 85 0 255 255 85 170 85 0 13680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1370255 255 85 170 85 0 255 255 85 170 85 0 13690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1371255 255 85 170 85 0 255 255 85 170 85 0 13700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1372255 255 85 170 85 0 255 255 85 170 85 0 13710 0 0 0 0 0 0 0 0 0 0 0
1373170 170 170 255 255 255 255 255 255 255 255 255 13720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1374255 255 255 255 255 255 255 255 255 255 255 255 13730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1375255 255 255 255 255 255 255 255 255 255 255 255 13740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1376170 170 170 85 85 85 85 85 85 0 0 0 13750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1377 0 0 0 0 0 0 0 0 0 170 85 0 13760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1378170 85 0 255 255 85 170 85 0 255 255 85 13770 0 0 0 0 0 85 85 85 85 85 85 170 170 170 85 85 85
1379170 85 0 255 255 85 170 85 0 255 255 85 137885 85 85 85 85 85 85 85 85 0 0 0 85 85 85 0 0 0
1380170 85 0 255 255 85 170 85 0 255 255 85 137985 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1381170 85 0 255 255 85 170 85 0 255 255 85 13800 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
1382170 85 0 255 255 85 0 0 0 0 0 0 13810 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1383 0 0 0 0 0 0 0 0 0 0 0 0 138285 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1384 0 0 0 0 0 0 0 0 0 0 0 0 13830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1385 0 0 0 0 0 0 0 0 0 0 0 0 138485 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1386 0 0 0 0 0 0 0 0 0 0 0 0 138585 85 85 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
1387 0 0 0 255 255 85 170 85 0 255 255 85 13860 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1388170 85 0 255 255 85 170 85 0 255 255 85 13870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1389170 85 0 255 255 85 170 85 0 255 255 85 13880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1390170 85 0 255 255 85 170 85 0 255 255 85 13890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1391170 85 0 255 255 85 170 85 0 255 255 85 13900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1392170 85 0 255 255 85 170 85 0 170 85 0 13910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1393170 85 0 170 170 170 255 255 255 255 255 255 13920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1394255 255 255 255 255 255 255 255 255 255 255 255 13930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1395255 255 255 255 255 255 170 170 170 85 85 85 13940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1396 85 85 85 0 0 0 0 0 0 0 0 0 13950 0 0 0 0 0 0 0 0 0 0 0
1397 0 0 0 0 0 0 85 85 85 170 85 0 13960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1398255 255 85 170 85 0 255 255 85 170 85 0 13970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1399255 255 85 170 85 0 255 255 85 170 85 0 13980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1400255 255 85 170 85 0 255 255 85 170 85 0 13990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1401255 255 85 170 85 0 255 255 85 170 85 0 14000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1402255 255 85 0 0 0 0 0 0 0 0 0 14010 0 0 0 0 0 85 85 85 85 85 85 85 85 85 85 85 85
1403 0 0 0 0 0 0 0 0 0 0 0 0 140285 85 85 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
1404 0 0 0 0 0 0 0 0 0 0 0 0 14030 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1405 0 0 0 0 0 0 0 0 0 0 0 0 14040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1406 0 0 0 0 0 0 0 0 0 0 0 0 14050 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1407 0 0 0 170 85 0 255 255 85 170 85 0 14060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1408255 255 85 170 85 0 255 255 85 170 85 0 140785 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1409255 255 85 170 85 0 255 255 85 170 85 0 14080 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1410255 255 85 170 85 0 255 255 85 170 85 0 14090 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1411255 255 85 170 85 0 255 255 85 170 85 0 141085 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1412255 255 85 170 85 0 255 255 85 170 85 0 141185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1413170 85 0 0 0 0 0 0 0 0 0 0 14120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1414 0 0 0 0 0 0 0 0 0 0 0 0 14130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1415 0 0 0 0 0 0 0 0 0 0 0 0 14140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1416 0 0 0 0 0 0 0 0 0 0 0 0 14150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1417 0 0 0 0 0 0 85 85 85 170 85 0 14160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1418170 85 0 255 255 85 170 85 0 255 255 85 14170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1419170 85 0 255 255 85 170 85 0 255 255 85 14180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1420170 85 0 255 255 85 170 85 0 255 255 85 14190 0 0 0 0 0 85 85 85 85 85 85
1421170 85 0 170 85 0 170 85 0 0 0 0 14200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1422 0 0 0 0 0 0 0 0 0 0 0 0 14210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1423 0 0 0 0 0 0 0 0 0 0 0 0 14220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1424 0 0 0 0 0 0 0 0 0 0 0 0 14230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1425 0 0 0 0 0 0 0 0 0 0 0 0 14240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1426 0 0 0 0 0 0 0 0 0 0 0 0 14250 0 0 85 85 85 85 85 85 170 170 170 85 85 85 85 85 85
1427 0 0 0 255 255 85 170 85 0 255 255 85 142685 85 85 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
1428170 85 0 255 255 85 170 85 0 255 255 85 142785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1429170 85 0 255 255 85 170 85 0 255 255 85 142885 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1430170 85 0 255 255 85 170 85 0 255 255 85 142985 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1431170 85 0 255 255 85 170 85 0 255 255 85 143085 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1432170 85 0 255 255 85 170 85 0 170 85 0 14310 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1433170 85 0 0 0 0 0 0 0 0 0 0 143285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1434 0 0 0 0 0 0 0 0 0 0 0 0 143385 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1435 0 0 0 0 0 0 0 0 0 0 0 0 14340 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1436 0 0 0 0 0 0 0 0 0 0 0 0 14350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1437 0 0 0 0 0 0 85 85 85 170 85 0 14360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1438255 255 85 170 85 0 255 255 85 170 85 0 14370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1439255 255 85 170 85 0 255 255 85 170 85 0 14380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1440255 255 85 170 85 0 255 255 85 170 85 0 14390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1441170 85 0 0 0 0 0 0 0 0 0 0 14400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1442 0 0 0 0 0 0 0 0 0 0 0 0 14410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1443 0 0 0 0 0 0 0 0 0 0 0 0 14420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1444 0 0 0 0 0 0 0 0 0 0 0 0 14430 0 0 85 85 85 170 170 170 170 170 170
1445 0 0 0 0 0 0 0 0 0 0 0 0 14440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1446 0 0 0 0 0 0 0 0 0 0 0 0 14450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1447 0 0 0 0 0 0 255 255 85 170 85 0 14460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1448255 255 85 170 85 0 255 255 85 170 85 0 14470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1449255 255 85 170 85 0 255 255 85 170 85 0 14480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1450255 255 85 170 85 0 255 255 85 170 85 0 14490 0 0 85 85 85 170 170 170 85 85 85 85 85 85 85 85 85
1451255 255 85 170 85 0 255 255 85 170 85 0 145085 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1452255 255 85 170 85 0 255 255 85 170 85 0 14510 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1453170 85 0 0 0 0 0 0 0 0 0 0 14520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1454 0 0 0 0 0 0 0 0 0 0 0 0 14530 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1455 0 0 0 0 0 0 0 0 0 0 0 0 14540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1456 0 0 0 0 0 0 0 0 0 0 0 0 14550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1457 0 0 0 0 0 0 85 85 85 170 85 0 14560 0 0 0 0 0 85 85 85 0 0 0 85 85 85 85 85 85
1458170 85 0 255 255 85 170 85 0 255 255 85 14570 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
1459170 85 0 255 255 85 170 85 0 255 255 85 145885 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1460170 85 0 170 85 0 170 85 0 170 85 0 14590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1461 0 0 0 0 0 0 0 0 0 0 0 0 14600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1462 0 0 0 0 0 0 0 0 0 0 0 0 14610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1463 0 0 0 0 0 0 0 0 0 0 0 0 14620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1464 0 0 0 0 0 0 0 0 0 0 0 0 14630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1465 0 0 0 0 0 0 0 0 0 0 0 0 14640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1466 0 0 0 0 0 0 0 0 0 0 0 0 14650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1467 0 0 0 0 0 0 0 0 0 0 0 0 14660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1468 0 0 0 0 0 0 170 85 0 170 85 0 146785 85 85 170 170 170 255 255 255 170 170 170
1469170 85 0 170 85 0 170 85 0 170 85 0 14680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1470170 85 0 255 255 85 170 85 0 255 255 85 14690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1471170 85 0 255 255 85 170 85 0 255 255 85 14700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1472170 85 0 255 255 85 170 85 0 170 85 0 14710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1473170 85 0 0 0 0 0 0 0 0 0 0 14720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1474 85 85 85 85 85 85 85 85 85 85 85 85 147385 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
1475 85 85 85 85 85 85 85 85 85 85 85 85 147485 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1476 85 85 85 85 85 85 85 85 85 0 0 0 14750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1477 0 0 0 0 0 0 0 0 0 170 85 0 14760 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1478170 85 0 170 85 0 255 255 85 170 85 0 14770 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1479255 255 85 170 85 0 255 255 85 170 85 0 14780 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
1480170 85 0 170 85 0 0 0 0 0 0 0 14790 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
1481 0 0 0 0 0 0 0 0 0 0 0 0 148085 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1482 0 0 0 0 0 0 0 0 0 0 0 0 148185 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1483 0 0 0 0 0 0 0 0 0 0 0 0 14820 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1484 0 0 0 0 0 0 0 0 0 0 0 0 14830 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1485 0 0 0 0 0 0 0 0 0 0 0 0 14840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1486 0 0 0 0 0 0 0 0 0 0 0 0 14850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1487 0 0 0 0 0 0 0 0 0 0 0 0 14860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1488 0 0 0 0 0 0 0 0 0 0 0 0 14870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1489 0 0 0 0 0 0 170 85 0 170 85 0 14880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1490170 85 0 170 85 0 170 85 0 170 85 0 14890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1491170 85 0 170 85 0 255 255 85 170 85 0 14900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 170 170
1492255 255 85 170 85 0 170 85 0 170 85 0 1491170 170 170 255 255 255 170 170 170 170 170 170
1493 85 85 85 85 85 85 85 85 85 85 85 85 14920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1494 0 0 0 0 0 0 0 0 0 0 0 0 14930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1495 0 0 0 0 0 0 0 0 0 0 0 0 14940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1496 0 0 0 0 0 0 0 0 0 85 85 85 14950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1497 85 85 85 85 85 85 85 85 85 170 85 0 14960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1498170 85 0 170 85 0 170 85 0 255 255 85 149785 85 85 170 170 170 85 85 85 85 85 85 85 85 85 0 0 0
1499170 85 0 255 255 85 170 85 0 170 85 0 149885 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1500170 85 0 0 0 0 0 0 0 0 0 0 149985 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1501 0 0 0 0 0 0 0 0 0 0 0 0 15000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1502 0 0 0 0 0 0 0 0 0 0 0 0 15010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1503 0 0 0 0 0 0 0 0 0 0 0 0 15020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1504 0 0 0 0 0 0 0 0 0 0 0 0 15030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1505 0 0 0 0 0 0 0 0 0 0 0 0 15040 0 0 0 0 0 85 85 85 0 0 0 85 85 85 85 85 85
1506 0 0 0 0 0 0 0 0 0 0 0 0 15050 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
1507 0 0 0 0 0 0 0 0 0 0 0 0 15060 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1508 0 0 0 0 0 0 0 0 0 0 0 0 15070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1509 0 0 0 0 0 0 0 0 0 0 0 0 15080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1510 0 0 0 0 0 0 0 0 0 170 85 0 15090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1511170 85 0 170 85 0 170 85 0 170 85 0 15100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1512170 85 0 170 85 0 170 85 0 170 85 0 15110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1513 0 0 0 0 0 0 0 0 0 0 0 0 15120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1514 0 0 0 0 0 0 0 0 0 0 0 0 15130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1515 0 0 0 0 0 0 0 0 0 0 0 0 15140 0 0 0 0 0 0 0 0 0 0 0 170 170 170 170 170 170
1516 0 0 0 0 0 0 0 0 0 0 0 0 1515255 255 255 255 255 255 170 170 170 170 170 170
1517 0 0 0 0 0 0 0 0 0 170 85 0 15160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1518170 85 0 170 85 0 170 85 0 170 85 0 15170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1519170 85 0 170 85 0 170 85 0 170 85 0 15180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1520 0 0 0 0 0 0 0 0 0 0 0 0 15190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1521 0 0 0 0 0 0 0 0 0 0 0 0 15200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1522 0 0 0 0 0 0 0 0 0 0 0 0 152185 85 85 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
1523 0 0 0 0 0 0 0 0 0 0 0 0 152285 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1524 0 0 0 0 0 0 0 0 0 0 0 0 15230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1525 0 0 0 0 0 0 0 0 0 0 0 0 152485 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1526 0 0 0 0 0 0 0 0 0 0 0 0 15250 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1527 0 0 0 0 0 0 0 0 0 0 0 0 152685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1528 0 0 0 0 0 0 0 0 0 0 0 0 15270 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1529 0 0 0 0 0 0 0 0 0 0 0 0 15280 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1530 0 0 0 0 0 0 0 0 0 0 0 0 152985 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1531 0 0 0 170 85 0 170 85 0 170 85 0 15300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1532170 85 0 170 85 0 170 85 0 0 0 0 153185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1533 0 0 0 0 0 0 0 0 0 0 0 0 15320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1534 0 0 0 0 0 0 0 0 0 0 0 0 15330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1535 0 0 0 0 0 0 0 0 0 0 0 0 15340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1536 0 0 0 0 0 0 0 0 0 0 0 0 15350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1537 0 0 0 0 0 0 0 0 0 0 0 0 15360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1538170 85 0 170 85 0 170 85 0 170 85 0 15370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1539170 85 0 170 85 0 170 85 0 0 0 0 15380 0 0 0 0 0 85 85 85 170 170 170 170 170 170 255 255 255
1540 0 0 0 0 0 0 0 0 0 0 0 0 1539255 255 255 170 170 170 170 170 170 0 0 0
1541 0 0 0 0 0 0 0 0 0 0 0 0 15400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1542 0 0 0 0 0 0 0 0 0 0 0 0 15410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1543 0 0 0 0 0 0 0 0 0 0 0 0 15420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1544 0 0 0 0 0 0 0 0 0 0 0 0 15430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1545 0 0 0 0 0 0 0 0 0 0 0 0 15440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1546 0 0 0 0 0 0 0 0 0 0 0 0 1545170 170 170 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
1547 0 0 0 0 0 0 0 0 0 0 0 0 15460 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1548 0 0 0 0 0 0 0 0 0 0 0 0 154785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1549 0 0 0 0 0 0 0 0 0 0 0 0 15480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1550 0 0 0 0 0 0 0 0 0 0 0 0 154985 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1551 0 0 0 0 0 0 0 0 0 0 0 0 15500 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1552 0 0 0 0 0 0 0 0 0 0 0 0 15510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1553 0 0 0 0 0 0 0 0 0 0 0 0 15520 0 0 85 85 85 0 0 0 0 0 0 85 85 85 85 85 85
1554 0 0 0 0 0 0 0 0 0 0 0 0 15530 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
1555 0 0 0 0 0 0 0 0 0 0 0 0 155485 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1556 0 0 0 0 0 0 0 0 0 0 0 0 15550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1557 0 0 0 0 0 0 0 0 0 0 0 0 15560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1558 0 0 0 0 0 0 0 0 0 0 0 0 15570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1559 0 0 0 0 0 0 0 0 0 0 0 0 15580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1560 0 0 0 0 0 0 0 0 0 0 0 0 15590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1561 0 0 0 0 0 0 0 0 0 0 0 0 15600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1562 0 0 0 0 0 0 0 0 0 0 0 0 15610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1563 0 0 0 0 0 0 0 0 0 0 0 0 15620 0 0 85 85 85 170 170 170 255 255 255 255 255 255 255 255 255
1564 0 0 0 0 0 0 0 0 0 0 0 0 1563170 170 170 170 170 170 85 85 85 0 0 0
1565 0 0 0 0 0 0 0 0 0 0 0 0 15640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1566 0 0 0 0 0 0 0 0 0 0 0 0 15650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1567 0 0 0 0 0 0 0 0 0 0 0 0 15660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1568 0 0 0 0 0 0 0 0 0 0 0 0 15670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1569 0 0 0 0 0 0 0 0 0 0 0 0 15680 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
1570 0 0 0 0 0 0 0 0 0 0 0 0 156985 85 85 85 85 85 85 85 85 85 85 85 0 0 0 85 85 85
1571 0 0 0 0 0 0 0 0 0 0 0 0 15700 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1572 0 0 0 0 0 0 0 0 0 0 0 0 15710 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1573 0 0 0 0 0 0 0 0 0 0 0 0 15720 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1574 0 0 0 0 0 0 0 0 0 0 0 0 15730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1575 0 0 0 0 0 0 0 0 0 0 0 0 15740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1576 0 0 0 0 0 0 0 0 0 0 0 0 15750 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
1577 0 0 0 0 0 0 0 0 0 0 0 0 15760 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1578 0 0 0 0 0 0 0 0 0 0 0 0 157785 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1579 0 0 0 0 0 0 0 0 0 0 0 0 15780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1580 0 0 0 0 0 0 0 0 0 0 0 0 15790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1581 0 0 0 0 0 0 0 0 0 0 0 0 15800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1582 0 0 0 0 0 0 0 0 0 0 0 0 15810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1583 0 0 0 0 0 0 0 0 0 0 0 0 15820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1584 0 0 0 0 0 0 0 0 0 0 0 0 15830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1585 0 0 0 0 0 0 0 0 0 0 0 0 15840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1586 0 0 0 0 0 0 0 0 0 0 0 0 15850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1587 0 0 0 0 0 0 0 0 0 0 0 0 1586170 170 170 170 170 170 255 255 255 255 255 255 255 255 255 170 170 170
1588 0 0 0 0 0 0 0 0 0 0 0 0 1587170 170 170 170 170 170 0 0 0 0 0 0
1589 0 0 0 0 0 0 0 0 0 0 0 0 15880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1590 0 0 0 0 0 0 0 0 0 0 0 0 15890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1591 0 0 0 0 0 0 0 0 0 0 0 0 15900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1592 0 0 0 0 0 0 0 0 0 0 0 0 15910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1593 0 0 0 0 0 0 0 0 0 0 0 0 15920 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
1594 0 0 0 0 0 0 0 0 0 0 0 0 159385 85 85 85 85 85 85 85 85 85 85 85 0 0 0 85 85 85
1595 0 0 0 0 0 0 0 0 0 0 0 0 15940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1596 0 0 0 0 0 0 0 0 0 0 0 0 15950 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1597 0 0 0 0 0 0 0 0 0 0 0 0 15960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1598 0 0 0 0 0 0 0 0 0 0 0 0 15970 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1599 0 0 0 0 0 0 0 0 0 0 0 0 15980 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1600 0 0 0 0 0 0 0 0 0 0 0 0 15990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1601 0 0 0 0 0 0 0 0 0 0 0 0 16000 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1602 0 0 0 0 0 0 0 0 0 0 0 0 160185 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
1603 0 0 0 0 0 0 0 0 0 0 0 0 16020 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
1604 0 0 0 0 0 0 0 0 0 0 0 0 16030 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
16040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16090 0 0 0 0 0 0 0 0 0 0 0 170 170 170 170 170 170
1610170 170 170 255 255 255 255 255 255 255 255 255 170 170 170 170 170 170
1611170 170 170 0 0 0 0 0 0 0 0 0
16120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16160 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
161785 85 85 85 85 85 85 85 85 0 0 0 85 85 85 0 0 0
161885 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
16190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
162085 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
162185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
162285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
16230 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
16240 0 0 0 0 0 85 85 85 85 85 85 85 85 85 85 85 85
16250 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
16260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16330 0 0 0 0 0 85 85 85 170 170 170 170 170 170 170 170 170
1634255 255 255 255 255 255 255 255 255 255 255 255 170 170 170 170 170 170
16350 0 0 0 0 0 0 0 0 0 0 0
16360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16400 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
164185 85 85 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
16420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16430 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
16440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16480 0 0 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
164985 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
165085 85 85 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
16510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
165785 85 85 170 170 170 170 170 170 255 255 255 255 255 255 255 255 255
1658255 255 255 255 255 255 170 170 170 170 170 170 85 85 85 0 0 0
16590 0 0 0 0 0 0 0 0 0 0 0
16600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16630 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
16640 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
166585 85 85 85 85 85 85 85 85 0 0 0 85 85 85 0 0 0
166685 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
16670 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
16680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16690 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
16700 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
167185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
167285 85 85 0 0 0 170 170 170 255 255 255 85 85 85 85 85 85
167385 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
167485 85 85 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
167585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1681170 170 170 170 170 170 255 255 255 170 170 170 255 255 255 255 255 255
1682255 255 255 255 255 255 170 170 170 170 170 170 85 85 85 0 0 0
16830 0 0 0 0 0 0 0 0 0 0 0
16840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
168785 85 85 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
16880 0 0 0 0 0 85 85 85 85 85 85 85 85 85 85 85 85
168985 85 85 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
16900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16920 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
16930 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
16940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16950 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
16960 0 0 85 85 85 170 170 170 255 255 255 170 170 170 85 85 85
16970 0 0 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
1698255 255 255 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
16990 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
17000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17040 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
1705255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
1706170 170 170 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
17070 0 0 0 0 0 0 0 0 0 0 0
17080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
171185 85 85 255 255 255 170 170 170 85 85 85 0 0 0 0 0 0
17120 0 0 0 0 0 85 85 85 85 85 85 85 85 85 0 0 0
171385 85 85 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
17140 0 0 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
17150 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
17160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
171885 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
17190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
172085 85 85 85 85 85 255 255 255 255 255 255 255 255 255 85 85 85
172185 85 85 0 0 0 85 85 85 0 0 0 85 85 85 170 170 170
1722255 255 255 170 170 170 0 0 0 0 0 0 85 85 85 0 0 0
17230 0 0 85 85 85 170 170 170 85 85 85 0 0 0 0 0 0
17240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17280 0 0 0 0 0 85 85 85 0 0 0 85 85 85 170 170 170
1729170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 170 170 170
1730170 170 170 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
17310 0 0 0 0 0 0 0 0 0 0 0
17320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17330 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
17340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1735170 170 170 255 255 255 255 255 255 170 170 170 0 0 0 0 0 0
17360 0 0 0 0 0 85 85 85 85 85 85 85 85 85 0 0 0
173785 85 85 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
17380 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
17390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
17400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17410 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
17420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17430 0 0 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
174485 85 85 170 170 170 255 255 255 255 255 255 255 255 255 85 85 85
174585 85 85 0 0 0 85 85 85 0 0 0 85 85 85 255 255 255
1746255 255 255 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
174785 85 85 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
17480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
175285 85 85 0 0 0 85 85 85 85 85 85 85 85 85 85 85 85
1753170 170 170 255 255 255 255 255 255 255 255 255 170 170 170 170 170 170
175485 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17550 0 0 0 0 0 0 0 0 0 0 0
17560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17570 0 0 0 0 0 0 0 0 85 85 85 170 170 170 170 170 170
17580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1759170 170 170 255 255 255 255 255 255 255 255 255 85 85 85 0 0 0
17600 0 0 85 85 85 85 85 85 85 85 85 85 85 85 0 0 0
176185 85 85 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
17620 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
17630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17640 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
176585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17660 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
17670 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
176885 85 85 170 170 170 255 255 255 255 255 255 255 255 255 170 170 170
17690 0 0 85 85 85 0 0 0 85 85 85 170 170 170 255 255 255
1770255 255 255 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
177185 85 85 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
17720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17750 0 0 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
17760 0 0 85 85 85 85 85 85 0 0 0 85 85 85 85 85 85
1777170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 85 85 85
17780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17790 0 0 0 0 0 0 0 0 0 0 0
17800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17810 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
1782170 170 170 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
178385 85 85 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
17840 0 0 85 85 85 85 85 85 0 0 0 85 85 85 0 0 0
178585 85 85 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
17860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
17870 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
17880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
17910 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
179285 85 85 255 255 255 255 255 255 255 255 255 170 170 170 170 170 170
179385 85 85 0 0 0 0 0 0 85 85 85 170 170 170 255 255 255
1794255 255 255 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
1795170 170 170 255 255 255 170 170 170 0 0 0 0 0 0 0 0 0
179685 85 85 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
17970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17990 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
180085 85 85 85 85 85 0 0 0 85 85 85 85 85 85 0 0 0
180185 85 85 85 85 85 170 170 170 85 85 85 85 85 85 0 0 0
18020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18030 0 0 0 0 0 0 0 0 0 0 0
18040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18050 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
1806255 255 255 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
180785 85 85 170 170 170 255 255 255 255 255 255 255 255 255 170 170 170
18080 0 0 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
180985 85 85 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
18100 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
18110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
18120 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
18130 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
181485 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18150 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
1816170 170 170 170 170 170 255 255 255 170 170 170 255 255 255 85 85 85
18170 0 0 85 85 85 0 0 0 85 85 85 170 170 170 255 255 255
1818170 170 170 170 170 170 0 0 0 0 0 0 0 0 0 85 85 85
1819170 170 170 255 255 255 255 255 255 0 0 0 0 0 0 85 85 85
1820255 255 255 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
18210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18220 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
182385 85 85 0 0 0 85 85 85 0 0 0 85 85 85 85 85 85
182485 85 85 0 0 0 85 85 85 85 85 85 0 0 0 85 85 85
18250 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
18260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18270 0 0 0 0 0 0 0 0 0 0 0
18280 0 0 0 0 0 0 0 0 85 85 85 85 85 85 0 0 0
18290 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 255
1830255 255 255 255 255 255 170 170 170 0 0 0 0 0 0 0 0 0
183185 85 85 170 170 170 255 255 255 170 170 170 170 170 170 170 170 170
183285 85 85 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
183385 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
18340 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
18350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
18370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18380 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
183985 85 85 0 0 0 85 85 85 0 0 0 85 85 85 85 85 85
184085 85 85 170 170 170 255 255 255 170 170 170 170 170 170 85 85 85
184185 85 85 0 0 0 85 85 85 85 85 85 85 85 85 170 170 170
1842170 170 170 85 85 85 85 85 85 0 0 0 0 0 0 85 85 85
1843170 170 170 170 170 170 85 85 85 0 0 0 0 0 0 170 170 170
1844170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18460 0 0 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
18470 0 0 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
18480 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
184985 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18510 0 0 0 0 0 0 0 0 0 0 0
18520 0 0 0 0 0 0 0 0 0 0 0 170 170 170 170 170 170
185385 85 85 0 0 0 0 0 0 0 0 0 0 0 0 170 170 170
1854255 255 255 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
18550 0 0 85 85 85 170 170 170 170 170 170 255 255 85 85 85 85
185685 85 85 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
185785 85 85 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
18580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18590 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
18600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18610 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
18620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
186385 85 85 0 0 0 85 85 85 85 85 85 0 0 0 85 85 85
186485 85 85 170 170 170 170 170 170 170 170 170 170 85 0 85 85 85
18650 0 0 85 85 85 0 0 0 85 85 85 170 170 170 170 85 0
1866170 170 170 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1867170 85 0 170 170 170 85 85 85 0 0 0 85 85 85 85 85 85
1868170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
18700 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
187185 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
187285 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
18730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18750 0 0 0 0 0 0 0 0 0 0 0
18760 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
1877170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1878255 255 255 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
18790 0 0 85 85 85 170 85 0 170 170 170 170 170 170 85 85 85
188085 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
188185 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
18820 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
18830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
18840 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
18850 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
18860 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
188785 85 85 0 0 0 85 85 85 0 0 0 85 85 85 85 85 85
188885 85 85 170 85 0 85 255 85 170 85 0 170 170 170 85 85 85
188985 85 85 0 0 0 0 0 0 85 85 85 170 85 0 85 255 85
1890170 85 0 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
189185 85 85 85 85 85 170 85 0 0 0 0 85 85 85 85 85 85
189285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18930 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
18940 0 0 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
18950 0 0 85 85 85 0 0 0 85 85 85 0 0 0 85 85 85
18960 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
18970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18990 0 0 0 0 0 0 0 0 0 0 0
19000 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 255
1901255 255 255 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
1902170 170 170 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
19030 0 0 0 0 0 170 170 170 170 85 0 170 170 170 170 85 0
190485 85 85 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
190585 85 85 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
19060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
190785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
191085 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
191185 85 85 0 0 0 85 85 85 85 85 85 85 85 85 0 0 0
191285 85 85 85 85 85 255 85 85 170 170 170 85 255 85 170 85 0
191385 85 85 85 85 85 170 85 0 85 85 85 170 170 170 85 85 85
1914170 170 170 170 85 0 85 85 85 85 85 85 85 85 85 85 85 85
1915170 85 0 85 255 85 85 85 85 85 85 85 85 85 85 170 85 0
191685 85 85 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
19170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
191885 85 85 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
19190 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
19200 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
19210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19230 0 0 0 0 0 0 0 0 0 0 0
192485 85 85 85 85 85 0 0 0 0 0 0 0 0 0 170 170 170
1925255 255 255 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
192685 85 85 170 85 0 170 170 170 170 85 0 85 85 85 0 0 0
192785 85 85 85 85 85 85 255 85 170 170 170 170 170 170 170 85 0
192885 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
192985 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
193085 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19310 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
19320 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
19330 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
19340 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
19350 0 0 85 85 85 85 85 85 0 0 0 85 85 85 85 85 85
193685 85 85 85 85 85 85 255 85 255 85 85 170 170 170 170 170 170
1937170 170 170 85 255 85 170 170 170 170 85 0 170 170 170 170 85 0
1938170 170 170 85 85 85 85 255 85 170 85 0 170 170 170 170 85 0
1939170 170 170 170 170 170 170 85 0 85 85 85 85 85 85 85 255 85
194085 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19410 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
19420 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
19430 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
19440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19470 0 0 0 0 0 0 0 0 0 0 0
19480 0 0 170 170 170 170 170 170 0 0 0 0 0 0 85 85 85
1949170 170 170 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
195085 85 85 85 85 85 255 255 85 85 85 85 85 85 85 85 85 85
195185 255 85 255 85 85 170 170 170 170 85 0 170 170 170 85 255 85
195285 85 85 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
195385 85 85 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
19540 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
19550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19560 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
19570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19580 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
195985 85 85 0 0 0 85 85 85 85 85 85 85 85 85 0 0 0
196085 85 85 85 85 85 170 85 0 170 170 170 170 170 170 255 255 85
1961170 170 170 255 85 85 170 170 170 170 170 170 255 255 85 170 170 170
196285 255 85 170 170 170 255 85 85 170 170 170 170 170 170 170 170 170
1963170 170 170 170 170 170 170 170 170 170 85 0 170 170 170 170 85 0
196485 85 85 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
19650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
196685 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
19670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19710 0 0 0 0 0 0 0 0 0 0 0
19720 0 0 85 85 85 170 170 170 85 85 85 0 0 0 85 85 85
197385 85 85 170 85 0 85 85 85 0 0 0 85 85 85 85 85 85
197485 85 85 170 85 0 170 170 170 170 170 170 255 255 85 170 170 170
1975170 170 170 170 170 170 255 255 85 170 170 170 170 170 170 255 85 85
197685 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
197785 85 85 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
197885 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19810 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
198285 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
198385 85 85 85 85 85 0 0 0 85 85 85 85 85 85 85 85 85
198485 85 85 85 85 85 170 170 170 255 255 85 170 170 170 170 170 170
1985170 170 170 255 255 85 170 170 170 170 170 170 170 170 170 170 85 0
1986170 170 170 255 255 85 170 170 170 255 255 85 170 170 170 255 255 85
1987170 170 170 255 255 85 170 170 170 170 170 170 85 255 85 170 85 0
198885 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19890 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
19900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
19910 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
19920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19950 0 0 0 0 0 0 0 0 0 0 0
19960 0 0 0 0 0 170 170 170 85 85 85 85 85 85 0 0 0
199785 85 85 85 85 85 170 170 170 85 85 85 170 170 170 170 85 0
1998170 170 170 85 255 85 170 170 170 170 85 0 170 170 170 170 170 170
1999255 255 85 170 170 170 170 170 170 255 255 255 255 255 85 170 170 170
2000255 255 85 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
200185 85 85 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
20020 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
20030 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
20040 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
200585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20060 0 0 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
20070 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
200885 85 85 170 85 0 170 170 170 170 170 170 170 170 170 255 255 255
2009170 170 170 255 255 255 255 255 85 170 170 170 255 255 85 170 170 170
2010255 255 85 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
2011170 170 170 170 170 170 170 170 170 255 85 85 170 170 170 170 170 170
201285 85 85 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
20130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20140 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
20150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20190 0 0 0 0 0 0 0 0 0 0 0
20200 0 0 0 0 0 85 85 85 85 85 85 170 85 0 85 85 85
202185 85 85 255 255 85 170 170 170 170 170 170 170 170 170 170 170 170
2022255 255 85 170 170 170 170 170 170 255 255 85 170 170 170 170 170 170
2023170 170 170 255 255 255 255 255 255 170 170 170 255 255 255 170 170 170
2024170 170 170 85 85 85 85 85 85 0 0 0 0 0 0 85 85 85
20250 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
20260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
203085 85 85 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
20310 0 0 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
203285 85 85 85 255 85 170 170 170 255 255 85 255 255 255 255 255 255
2033255 255 255 170 170 170 255 255 255 170 170 170 170 170 170 170 170 170
2034170 170 170 170 170 170 255 255 85 170 170 170 255 255 85 255 255 255
2035255 255 85 255 255 255 255 255 85 170 170 170 170 170 170 170 85 0
2036170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
203785 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
20380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20430 0 0 0 0 0 0 0 0 0 0 0
20440 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
204585 85 85 170 170 170 255 255 85 170 170 170 255 255 85 170 170 170
2046170 170 170 255 255 85 170 170 170 170 170 170 170 170 170 255 255 85
2047255 255 255 255 255 255 255 255 85 255 255 255 255 255 255 170 170 170
2048255 255 85 85 85 85 85 85 85 0 0 0 0 0 0 85 85 85
204985 85 85 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
20500 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
20510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20520 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
20530 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
205485 85 85 170 170 170 170 170 170 0 0 0 0 0 0 0 0 0
205585 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
205685 85 85 170 170 170 170 170 170 170 170 170 255 255 255 170 170 170
2057255 255 255 255 255 255 255 255 255 170 170 170 170 170 170 255 255 85
2058170 170 170 255 255 85 170 170 170 255 255 255 170 170 170 255 255 255
2059255 255 255 255 255 255 170 170 170 255 255 85 170 170 170 255 255 85
206085 85 85 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
20610 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
20620 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
20630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20670 0 0 0 0 0 0 0 0 0 0 0
20680 0 0 0 0 0 0 0 0 85 85 85 170 85 0 170 170 170
2069255 255 85 170 170 170 170 170 170 255 255 255 255 255 255 255 255 255
2070170 170 170 170 170 170 170 170 170 255 255 85 170 170 170 170 170 170
2071255 255 255 170 170 170 255 255 255 255 255 255 170 170 170 255 255 255
2072170 170 170 170 170 170 85 85 85 0 0 0 85 85 85 0 0 0
207385 85 85 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
20740 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
20750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
20770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
207885 85 85 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
20790 0 0 85 85 85 0 0 0 85 85 85 85 85 85 0 0 0
208085 85 85 170 85 0 255 255 255 170 170 170 255 255 255 255 255 255
2081255 255 85 255 255 255 170 170 170 255 255 85 170 170 170 170 170 170
2082170 170 170 170 170 170 170 170 170 255 255 85 255 255 255 255 255 255
2083170 170 170 255 255 255 255 255 255 170 170 170 170 170 170 170 170 170
208485 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20850 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
20860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20910 0 0 0 0 0 0 0 0 0 0 0
20920 0 0 0 0 0 0 0 0 85 85 85 85 255 85 170 170 170
2093170 170 170 255 255 85 170 170 170 255 255 255 170 170 170 255 255 255
2094255 255 255 255 255 255 255 255 85 170 170 170 170 170 170 255 255 255
2095170 170 170 255 255 255 255 255 255 170 170 170 255 255 255 255 255 85
2096170 170 170 170 85 0 85 85 85 0 0 0 0 0 0 85 85 85
20970 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
20980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20990 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
21000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
210285 85 85 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
210385 85 85 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
210485 85 85 170 170 170 170 170 170 255 255 85 170 170 170 255 255 255
2105255 255 255 170 170 170 255 255 255 170 170 170 170 170 170 255 255 85
2106170 170 170 255 255 85 170 170 170 255 255 255 170 170 170 255 255 255
2107255 255 255 255 255 255 255 255 255 255 255 255 170 170 170 255 255 85
210885 85 85 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
21090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
21100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21150 0 0 0 0 0 0 0 0 0 0 0
21160 0 0 0 0 0 0 0 0 85 85 85 170 85 0 170 170 170
2117170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
2118170 170 170 170 170 170 170 170 170 170 170 170 255 255 85 170 170 170
2119255 255 85 255 255 255 170 170 170 255 255 255 170 170 170 170 170 170
2120170 170 170 170 170 170 85 85 85 0 0 0 85 85 85 85 85 85
21210 0 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
21220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
212385 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21260 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
212785 85 85 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
212885 85 85 85 85 85 170 170 170 170 170 170 255 255 255 170 170 170
2129255 255 255 170 170 170 255 255 85 170 170 170 170 170 170 170 170 170
2130255 85 85 170 170 170 170 170 170 170 170 170 255 255 255 255 255 255
2131170 170 170 255 255 255 255 255 255 170 170 170 255 255 255 170 170 170
213285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21330 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
21340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21390 0 0 0 0 0 0 0 0 0 0 0
21400 0 0 0 0 0 0 0 0 85 85 85 85 85 85 170 170 170
2141255 255 85 170 170 170 255 255 255 170 170 170 255 255 255 255 255 255
2142255 255 85 255 255 255 170 170 170 255 255 85 170 170 170 170 170 170
2143170 170 170 170 170 170 255 255 85 170 170 170 170 170 170 255 255 85
2144170 170 170 170 85 0 85 85 85 0 0 0 85 85 85 0 0 0
21450 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
214685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21480 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
21490 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
21500 0 0 0 0 0 0 0 0 0 0 0 170 170 170 170 170 170
2151170 170 170 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
21520 0 0 85 85 85 170 170 170 255 255 85 170 170 170 170 170 170
2153255 255 85 170 170 170 170 170 170 170 170 170 170 170 170 255 85 85
215485 255 85 170 170 170 170 170 170 170 170 170 255 255 85 170 170 170
2155255 255 255 255 255 255 255 255 255 255 255 85 170 170 170 170 170 170
215685 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
21570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21630 0 0 0 0 0 0 0 0 0 0 0
21640 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 85
2165170 170 170 170 170 170 255 255 255 255 255 255 255 255 255 170 170 170
2166255 255 255 170 170 170 170 170 170 170 170 170 170 170 170 255 85 85
2167170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
2168170 170 170 85 85 85 85 85 85 0 0 0 85 85 85 0 0 0
216985 85 85 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
21700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
217285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21740 0 0 0 0 0 0 0 0 170 170 170 170 170 170 170 170 170
217585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
21760 0 0 85 85 85 170 85 0 170 170 170 170 170 170 170 170 170
2177170 170 170 170 170 170 170 170 170 170 85 0 170 170 170 85 255 85
2178255 85 85 170 170 170 255 255 85 170 170 170 170 170 170 255 255 255
2179255 255 255 170 170 170 255 255 255 255 255 255 170 170 170 170 170 170
21800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21870 0 0 0 0 0 0 0 0 0 0 0
21880 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
2189170 170 170 255 255 85 170 170 170 255 255 85 255 255 255 255 255 255
2190170 170 170 170 170 170 255 255 85 170 170 170 255 85 85 85 255 85
2191170 170 170 170 85 0 170 170 170 170 170 170 255 255 85 170 170 170
2192170 85 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
21930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21940 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
21950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
22000 0 0 85 85 85 85 85 85 85 85 85 170 170 170 255 255 85
2201170 170 170 170 85 0 170 170 170 170 170 170 170 85 0 85 85 85
2202170 170 170 170 85 0 85 85 85 170 170 170 170 170 170 170 170 170
2203170 170 170 255 255 255 255 255 255 255 255 85 170 170 170 170 170 170
22040 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
22050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22110 0 0 0 0 0 0 0 0 0 0 0
22120 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 85 0
2213170 170 170 170 170 170 255 255 255 170 170 170 255 255 255 170 170 170
2214255 255 255 170 170 170 170 170 170 170 85 0 170 170 170 85 85 85
2215170 170 170 170 170 170 170 85 0 170 170 170 170 85 0 85 85 85
221685 255 85 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
22170 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
22180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
222185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22230 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
222485 85 85 0 0 0 85 85 85 170 85 0 85 85 85 170 170 170
2225170 85 0 170 170 170 85 255 85 170 85 0 170 170 170 85 85 85
2226170 85 0 170 170 170 170 170 170 255 255 85 170 170 170 255 255 255
2227255 255 85 255 255 255 170 170 170 170 170 170 170 170 170 170 85 0
22280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22350 0 0 0 0 0 0 0 0 0 0 0
22360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
2237170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 255 255 85
2238170 170 170 255 255 85 170 170 170 170 170 170 85 255 85 170 170 170
2239170 85 0 170 85 0 170 170 170 85 255 85 85 85 85 170 170 170
2240170 85 0 85 85 85 0 0 0 85 85 85 0 0 0 0 0 0
22410 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
22420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22460 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
22470 0 0 0 0 0 0 0 0 85 85 85 170 170 170 85 85 85
22480 0 0 0 0 0 0 0 0 85 85 85 170 85 0 85 85 85
2249170 170 170 170 85 0 170 170 170 85 85 85 170 170 170 170 85 0
2250170 170 170 85 255 85 170 85 0 170 170 170 170 170 170 170 170 170
2251255 255 255 170 170 170 255 255 255 255 255 255 170 170 170 85 85 85
22520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22590 0 0 0 0 0 0 0 0 0 0 0
22600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2261170 85 0 170 170 170 255 255 85 170 170 170 255 255 255 170 170 170
2262170 170 170 170 170 170 170 170 170 170 85 0 170 170 170 170 85 0
2263170 170 170 85 255 85 170 85 0 170 170 170 170 85 0 85 85 85
226485 85 85 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
22650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22670 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
22680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22710 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
22720 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
227385 255 85 170 170 170 170 85 0 170 170 170 170 85 0 85 255 85
2274170 170 170 170 85 0 170 170 170 170 170 170 170 170 170 255 255 85
2275170 170 170 255 255 255 170 170 170 170 170 170 170 170 170 0 0 0
22760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22830 0 0 0 0 0 0 0 0 0 0 0
22840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
228585 85 85 170 85 0 85 85 85 170 170 170 255 255 85 170 170 170
2286170 170 170 255 255 85 170 170 170 170 170 170 170 170 170 170 85 0
2287170 170 170 85 85 85 170 170 170 170 85 0 170 170 170 85 85 85
2288170 85 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
22890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22960 0 0 0 0 0 85 85 85 0 0 0 85 85 85 170 85 0
229785 85 85 255 85 85 85 255 85 170 85 0 170 170 170 170 170 170
2298170 85 0 170 170 170 85 85 85 255 255 85 170 170 170 170 170 170
2299255 255 255 170 170 170 255 255 255 255 255 85 85 85 85 0 0 0
23000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23070 0 0 0 0 0 0 0 0 0 0 0
23080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23090 0 0 85 85 85 170 170 170 170 85 0 170 170 170 170 170 170
2310170 170 170 170 170 170 170 170 170 255 255 85 85 85 85 170 170 170
231185 255 85 255 85 85 170 170 170 85 255 85 255 85 85 85 255 85
231285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23200 0 0 0 0 0 85 85 85 85 85 85 0 0 0 85 85 85
232185 85 85 85 255 85 255 85 85 170 170 170 85 255 85 170 85 0
2322170 170 170 170 170 170 255 255 85 170 170 170 170 170 170 255 255 255
2323170 170 170 255 255 255 170 170 170 170 170 170 85 85 85 0 0 0
23240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23310 0 0 0 0 0 0 0 0 0 0 0
23320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23330 0 0 0 0 0 85 85 85 170 170 170 85 85 85 255 255 85
2334170 170 170 255 255 85 170 170 170 170 170 170 170 170 170 255 255 85
233585 85 85 255 255 85 170 170 170 170 85 0 170 170 170 85 85 85
2336170 85 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
23370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
2345170 170 170 170 85 0 170 170 170 170 85 0 170 170 170 170 170 170
2346170 85 0 170 170 170 170 170 170 170 170 170 255 255 85 170 170 170
2347255 255 85 255 255 255 170 170 170 170 170 170 85 85 85 0 0 0
23480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23550 0 0 0 0 0 0 0 0 0 0 0
23560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23570 0 0 0 0 0 85 85 85 170 85 0 85 85 85 170 170 170
2358170 85 0 170 170 170 170 170 170 255 255 85 170 170 170 170 170 170
2359170 170 170 170 170 170 170 170 170 255 255 85 170 170 170 170 85 0
236085 85 85 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
23610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23680 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
2369170 85 0 85 255 85 170 170 170 170 170 170 255 255 85 170 170 170
2370255 255 85 170 170 170 170 170 170 170 170 170 255 255 255 255 255 255
2371255 255 255 170 170 170 255 255 85 85 85 85 0 0 0 0 0 0
23720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23790 0 0 0 0 0 0 0 0 0 0 0
23800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23810 0 0 0 0 0 0 0 0 85 85 85 85 85 85 170 85 0
2382170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 255 255 85
2383170 170 170 255 255 85 170 170 170 170 170 170 170 170 170 170 170 170
2384170 170 170 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
23850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
239385 85 85 170 85 0 170 170 170 170 85 0 170 170 170 170 170 170
2394170 170 170 255 255 85 170 170 170 255 255 85 170 170 170 255 255 255
2395170 170 170 255 255 255 170 170 170 85 85 85 0 0 0 0 0 0
23960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
23990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24030 0 0 0 0 0 0 0 0 0 0 0
24040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24050 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
2406170 85 0 170 170 170 170 85 0 255 255 85 170 170 170 170 170 170
2407170 170 170 170 170 170 255 255 85 170 170 170 255 255 85 170 170 170
2408255 255 85 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
24090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24160 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
241785 85 85 170 170 170 255 255 85 170 170 170 255 255 85 170 170 170
2418170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
2419170 170 170 170 170 170 170 170 170 0 0 0 0 0 0 0 0 0
24200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24270 0 0 0 0 0 0 0 0 0 0 0
24280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24290 0 0 0 0 0 0 0 0 0 0 0 0 170 0 85 85 85
2430170 85 0 85 255 85 170 170 170 170 170 170 170 170 170 255 255 85
2431255 255 255 170 170 170 255 255 255 170 170 170 255 255 255 170 170 170
2432170 170 170 255 255 85 85 85 85 0 0 0 0 0 0 0 0 0
24330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
2441170 85 0 170 170 170 170 170 170 170 170 170 170 170 170 255 255 85
2442170 170 170 255 255 255 170 170 170 255 255 255 170 170 170 255 255 255
2443255 255 255 255 255 85 85 85 85 0 0 0 0 0 0 0 0 0
24440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24510 0 0 0 0 0 0 0 0 0 0 0
24520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
245485 85 85 170 85 0 170 170 170 170 170 170 255 255 85 170 170 170
2455170 170 170 255 255 255 255 255 255 255 255 255 170 170 170 255 255 255
2456170 170 170 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
24570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24640 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 255 85
2465170 170 170 255 255 85 170 170 170 255 255 85 255 255 255 255 255 255
2466255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 170 170
2467170 170 170 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
24680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24750 0 0 0 0 0 0 0 0 0 0 0
24760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
247885 85 85 85 85 85 85 85 85 170 85 0 170 170 170 170 170 170
2479255 255 85 170 170 170 255 255 255 255 255 85 255 255 255 255 255 255
2480170 170 170 255 255 85 170 170 170 85 85 85 0 0 0 0 0 0
24810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24880 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 85 0
2489170 170 170 170 170 170 170 170 170 255 255 255 170 170 170 255 255 255
2490170 170 170 255 255 255 170 170 170 255 255 255 255 255 85 255 255 255
2491170 170 170 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
24920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24990 0 0 0 0 0 0 0 0 0 0 0
25000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
250285 85 85 170 85 0 85 85 85 170 170 170 170 170 170 170 170 170
2503170 170 170 255 255 255 170 170 170 255 255 255 255 255 255 170 170 170
2504255 255 85 170 170 170 170 170 170 170 85 0 85 85 85 0 0 0
25050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25120 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
2513255 255 85 170 170 170 255 255 85 170 170 170 255 255 255 255 255 255
2514255 255 255 255 255 255 255 255 255 255 255 255 170 170 170 170 170 170
2515170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25230 0 0 0 0 0 0 0 0 0 0 0
25240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25260 0 0 85 85 85 85 85 85 85 85 85 170 85 0 170 170 170
2527255 255 85 170 170 170 255 255 85 255 255 255 170 170 170 255 255 255
2528170 170 170 170 170 170 170 170 170 170 170 170 0 0 0 0 0 0
25290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25360 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
2537170 85 0 170 170 170 255 255 255 170 170 170 255 255 255 170 170 170
2538255 255 255 255 255 255 170 170 170 255 255 255 255 255 85 170 170 170
253985 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25470 0 0 0 0 0 0 0 0 0 0 0
25480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25500 0 0 0 0 0 85 85 85 170 85 0 85 85 85 170 170 170
2551170 170 170 170 170 170 170 170 170 170 170 170 255 255 85 170 170 170
2552255 255 85 170 170 170 170 85 0 85 255 85 85 85 85 0 0 0
25530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25600 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 85 0
2561170 170 170 170 170 170 255 255 85 170 170 170 255 255 255 255 255 255
2562255 255 85 255 255 255 170 170 170 255 255 255 170 170 170 85 85 85
25630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25710 0 0 0 0 0 0 0 0 0 0 0
25720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25740 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
2575170 85 0 170 170 170 170 170 170 255 255 85 170 170 170 170 170 170
2576170 170 170 170 170 170 170 170 170 170 85 0 0 0 0 0 0 0
25770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25840 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
2585255 255 85 170 170 170 170 170 170 170 170 170 255 255 85 170 170 170
2586255 255 255 170 170 170 255 255 85 170 170 170 85 85 85 85 85 85
25870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25950 0 0 0 0 0 0 0 0 0 0 0
25960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25980 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
259985 85 85 170 85 0 170 170 170 170 170 170 170 170 170 170 170 170
2600170 85 0 170 170 170 170 85 0 85 85 85 0 0 0 0 0 0
26010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26080 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
2609170 170 170 170 170 170 255 255 85 170 170 170 170 170 170 170 170 170
2610170 170 170 255 255 255 170 170 170 170 170 170 85 85 85 0 0 0
26110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26190 0 0 0 0 0 0 0 0 0 0 0
26200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
262385 85 85 85 85 85 85 85 85 170 85 0 85 85 85 170 85 0
262485 85 85 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
26250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 85 0
263385 85 85 170 85 0 170 170 170 170 170 170 170 170 170 255 255 85
2634170 170 170 170 170 170 170 85 0 85 85 85 0 0 0 0 0 0
26350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26430 0 0 0 0 0 0 0 0 0 0 0
26440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26470 0 0 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
264885 85 85 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
26490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
265785 85 85 85 255 85 170 85 0 170 170 170 170 85 0 170 170 170
265885 85 85 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
26590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26670 0 0 0 0 0 0 0 0 0 0 0
26680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26810 0 0 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
268285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26910 0 0 0 0 0 0 0 0 0 0 0
26920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27150 0 0 0 0 0 0 0 0 0 0 0
27160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27390 0 0 0 0 0 0 0 0 0 0 0
diff --git a/drivers/video/pmag-ba-fb.c b/drivers/video/pmag-ba-fb.c
index 3a3f80f65219..0573ec685a57 100644
--- a/drivers/video/pmag-ba-fb.c
+++ b/drivers/video/pmag-ba-fb.c
@@ -151,7 +151,7 @@ static int __init pmagbafb_probe(struct device *dev)
151 151
152 info = framebuffer_alloc(sizeof(struct pmagbafb_par), dev); 152 info = framebuffer_alloc(sizeof(struct pmagbafb_par), dev);
153 if (!info) { 153 if (!info) {
154 printk(KERN_ERR "%s: Cannot allocate memory\n", dev->bus_id); 154 printk(KERN_ERR "%s: Cannot allocate memory\n", dev_name(dev));
155 return -ENOMEM; 155 return -ENOMEM;
156 } 156 }
157 157
@@ -160,7 +160,7 @@ static int __init pmagbafb_probe(struct device *dev)
160 160
161 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 161 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
162 printk(KERN_ERR "%s: Cannot allocate color map\n", 162 printk(KERN_ERR "%s: Cannot allocate color map\n",
163 dev->bus_id); 163 dev_name(dev));
164 err = -ENOMEM; 164 err = -ENOMEM;
165 goto err_alloc; 165 goto err_alloc;
166 } 166 }
@@ -173,8 +173,9 @@ static int __init pmagbafb_probe(struct device *dev)
173 /* Request the I/O MEM resource. */ 173 /* Request the I/O MEM resource. */
174 start = tdev->resource.start; 174 start = tdev->resource.start;
175 len = tdev->resource.end - start + 1; 175 len = tdev->resource.end - start + 1;
176 if (!request_mem_region(start, len, dev->bus_id)) { 176 if (!request_mem_region(start, len, dev_name(dev))) {
177 printk(KERN_ERR "%s: Cannot reserve FB region\n", dev->bus_id); 177 printk(KERN_ERR "%s: Cannot reserve FB region\n",
178 dev_name(dev));
178 err = -EBUSY; 179 err = -EBUSY;
179 goto err_cmap; 180 goto err_cmap;
180 } 181 }
@@ -183,7 +184,7 @@ static int __init pmagbafb_probe(struct device *dev)
183 info->fix.mmio_start = start; 184 info->fix.mmio_start = start;
184 par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); 185 par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len);
185 if (!par->mmio) { 186 if (!par->mmio) {
186 printk(KERN_ERR "%s: Cannot map MMIO\n", dev->bus_id); 187 printk(KERN_ERR "%s: Cannot map MMIO\n", dev_name(dev));
187 err = -ENOMEM; 188 err = -ENOMEM;
188 goto err_resource; 189 goto err_resource;
189 } 190 }
@@ -194,7 +195,7 @@ static int __init pmagbafb_probe(struct device *dev)
194 info->screen_base = ioremap_nocache(info->fix.smem_start, 195 info->screen_base = ioremap_nocache(info->fix.smem_start,
195 info->fix.smem_len); 196 info->fix.smem_len);
196 if (!info->screen_base) { 197 if (!info->screen_base) {
197 printk(KERN_ERR "%s: Cannot map FB\n", dev->bus_id); 198 printk(KERN_ERR "%s: Cannot map FB\n", dev_name(dev));
198 err = -ENOMEM; 199 err = -ENOMEM;
199 goto err_mmio_map; 200 goto err_mmio_map;
200 } 201 }
@@ -205,14 +206,14 @@ static int __init pmagbafb_probe(struct device *dev)
205 err = register_framebuffer(info); 206 err = register_framebuffer(info);
206 if (err < 0) { 207 if (err < 0) {
207 printk(KERN_ERR "%s: Cannot register framebuffer\n", 208 printk(KERN_ERR "%s: Cannot register framebuffer\n",
208 dev->bus_id); 209 dev_name(dev));
209 goto err_smem_map; 210 goto err_smem_map;
210 } 211 }
211 212
212 get_device(dev); 213 get_device(dev);
213 214
214 pr_info("fb%d: %s frame buffer device at %s\n", 215 pr_info("fb%d: %s frame buffer device at %s\n",
215 info->node, info->fix.id, dev->bus_id); 216 info->node, info->fix.id, dev_name(dev));
216 217
217 return 0; 218 return 0;
218 219
diff --git a/drivers/video/pmagb-b-fb.c b/drivers/video/pmagb-b-fb.c
index 9b80597241b0..98748723af9f 100644
--- a/drivers/video/pmagb-b-fb.c
+++ b/drivers/video/pmagb-b-fb.c
@@ -258,7 +258,7 @@ static int __init pmagbbfb_probe(struct device *dev)
258 258
259 info = framebuffer_alloc(sizeof(struct pmagbbfb_par), dev); 259 info = framebuffer_alloc(sizeof(struct pmagbbfb_par), dev);
260 if (!info) { 260 if (!info) {
261 printk(KERN_ERR "%s: Cannot allocate memory\n", dev->bus_id); 261 printk(KERN_ERR "%s: Cannot allocate memory\n", dev_name(dev));
262 return -ENOMEM; 262 return -ENOMEM;
263 } 263 }
264 264
@@ -267,7 +267,7 @@ static int __init pmagbbfb_probe(struct device *dev)
267 267
268 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 268 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
269 printk(KERN_ERR "%s: Cannot allocate color map\n", 269 printk(KERN_ERR "%s: Cannot allocate color map\n",
270 dev->bus_id); 270 dev_name(dev));
271 err = -ENOMEM; 271 err = -ENOMEM;
272 goto err_alloc; 272 goto err_alloc;
273 } 273 }
@@ -280,8 +280,9 @@ static int __init pmagbbfb_probe(struct device *dev)
280 /* Request the I/O MEM resource. */ 280 /* Request the I/O MEM resource. */
281 start = tdev->resource.start; 281 start = tdev->resource.start;
282 len = tdev->resource.end - start + 1; 282 len = tdev->resource.end - start + 1;
283 if (!request_mem_region(start, len, dev->bus_id)) { 283 if (!request_mem_region(start, len, dev_name(dev))) {
284 printk(KERN_ERR "%s: Cannot reserve FB region\n", dev->bus_id); 284 printk(KERN_ERR "%s: Cannot reserve FB region\n",
285 dev_name(dev));
285 err = -EBUSY; 286 err = -EBUSY;
286 goto err_cmap; 287 goto err_cmap;
287 } 288 }
@@ -290,7 +291,7 @@ static int __init pmagbbfb_probe(struct device *dev)
290 info->fix.mmio_start = start; 291 info->fix.mmio_start = start;
291 par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); 292 par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len);
292 if (!par->mmio) { 293 if (!par->mmio) {
293 printk(KERN_ERR "%s: Cannot map MMIO\n", dev->bus_id); 294 printk(KERN_ERR "%s: Cannot map MMIO\n", dev_name(dev));
294 err = -ENOMEM; 295 err = -ENOMEM;
295 goto err_resource; 296 goto err_resource;
296 } 297 }
@@ -301,7 +302,7 @@ static int __init pmagbbfb_probe(struct device *dev)
301 info->fix.smem_start = start + PMAGB_B_FBMEM; 302 info->fix.smem_start = start + PMAGB_B_FBMEM;
302 par->smem = ioremap_nocache(info->fix.smem_start, info->fix.smem_len); 303 par->smem = ioremap_nocache(info->fix.smem_start, info->fix.smem_len);
303 if (!par->smem) { 304 if (!par->smem) {
304 printk(KERN_ERR "%s: Cannot map FB\n", dev->bus_id); 305 printk(KERN_ERR "%s: Cannot map FB\n", dev_name(dev));
305 err = -ENOMEM; 306 err = -ENOMEM;
306 goto err_mmio_map; 307 goto err_mmio_map;
307 } 308 }
@@ -316,7 +317,7 @@ static int __init pmagbbfb_probe(struct device *dev)
316 err = register_framebuffer(info); 317 err = register_framebuffer(info);
317 if (err < 0) { 318 if (err < 0) {
318 printk(KERN_ERR "%s: Cannot register framebuffer\n", 319 printk(KERN_ERR "%s: Cannot register framebuffer\n",
319 dev->bus_id); 320 dev_name(dev));
320 goto err_smem_map; 321 goto err_smem_map;
321 } 322 }
322 323
@@ -328,7 +329,7 @@ static int __init pmagbbfb_probe(struct device *dev)
328 par->osc1 / 1000, par->osc1 % 1000); 329 par->osc1 / 1000, par->osc1 % 1000);
329 330
330 pr_info("fb%d: %s frame buffer device at %s\n", 331 pr_info("fb%d: %s frame buffer device at %s\n",
331 info->node, info->fix.id, dev->bus_id); 332 info->node, info->fix.id, dev_name(dev));
332 pr_info("fb%d: Osc0: %s, Osc1: %s, Osc%u selected\n", 333 pr_info("fb%d: Osc0: %s, Osc1: %s, Osc%u selected\n",
333 info->node, freq0, par->osc1 ? freq1 : "disabled", 334 info->node, freq0, par->osc1 ? freq1 : "disabled",
334 par->osc1 != 0); 335 par->osc1 != 0);
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 87f826e4c958..e00c1dff55de 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -1213,7 +1213,7 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
1213 dev->core.driver_data = info; 1213 dev->core.driver_data = info;
1214 1214
1215 dev_info(info->device, "%s %s, using %u KiB of video memory\n", 1215 dev_info(info->device, "%s %s, using %u KiB of video memory\n",
1216 dev_driver_string(info->dev), info->dev->bus_id, 1216 dev_driver_string(info->dev), dev_name(info->dev),
1217 info->fix.smem_len >> 10); 1217 info->fix.smem_len >> 10);
1218 1218
1219 task = kthread_run(ps3fbd, info, DEVICE_NAME); 1219 task = kthread_run(ps3fbd, info, DEVICE_NAME);
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 0a0fd48a8566..53f8f1100e81 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -61,7 +61,7 @@
61#include <mach-dreamcast/mach/sysasic.h> 61#include <mach-dreamcast/mach/sysasic.h>
62#endif 62#endif
63 63
64#ifdef CONFIG_SH_DMA 64#ifdef CONFIG_PVR2_DMA
65#include <linux/pagemap.h> 65#include <linux/pagemap.h>
66#include <mach/dma.h> 66#include <mach/dma.h>
67#include <asm/dma.h> 67#include <asm/dma.h>
@@ -188,7 +188,7 @@ static unsigned int is_blanked = 0; /* Is the screen blanked? */
188static unsigned long pvr2fb_map; 188static unsigned long pvr2fb_map;
189#endif 189#endif
190 190
191#ifdef CONFIG_SH_DMA 191#ifdef CONFIG_PVR2_DMA
192static unsigned int shdma = PVR2_CASCADE_CHAN; 192static unsigned int shdma = PVR2_CASCADE_CHAN;
193static unsigned int pvr2dma = ONCHIP_NR_DMA_CHANNELS; 193static unsigned int pvr2dma = ONCHIP_NR_DMA_CHANNELS;
194#endif 194#endif
@@ -207,7 +207,7 @@ static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id);
207static int pvr2_init_cable(void); 207static int pvr2_init_cable(void);
208static int pvr2_get_param(const struct pvr2_params *p, const char *s, 208static int pvr2_get_param(const struct pvr2_params *p, const char *s,
209 int val, int size); 209 int val, int size);
210#ifdef CONFIG_SH_DMA 210#ifdef CONFIG_PVR2_DMA
211static ssize_t pvr2fb_write(struct fb_info *info, const char *buf, 211static ssize_t pvr2fb_write(struct fb_info *info, const char *buf,
212 size_t count, loff_t *ppos); 212 size_t count, loff_t *ppos);
213#endif 213#endif
@@ -218,7 +218,7 @@ static struct fb_ops pvr2fb_ops = {
218 .fb_blank = pvr2fb_blank, 218 .fb_blank = pvr2fb_blank,
219 .fb_check_var = pvr2fb_check_var, 219 .fb_check_var = pvr2fb_check_var,
220 .fb_set_par = pvr2fb_set_par, 220 .fb_set_par = pvr2fb_set_par,
221#ifdef CONFIG_SH_DMA 221#ifdef CONFIG_PVR2_DMA
222 .fb_write = pvr2fb_write, 222 .fb_write = pvr2fb_write,
223#endif 223#endif
224 .fb_fillrect = cfb_fillrect, 224 .fb_fillrect = cfb_fillrect,
@@ -671,7 +671,7 @@ static int pvr2_init_cable(void)
671 return cable_type; 671 return cable_type;
672} 672}
673 673
674#ifdef CONFIG_SH_DMA 674#ifdef CONFIG_PVR2_DMA
675static ssize_t pvr2fb_write(struct fb_info *info, const char *buf, 675static ssize_t pvr2fb_write(struct fb_info *info, const char *buf,
676 size_t count, loff_t *ppos) 676 size_t count, loff_t *ppos)
677{ 677{
@@ -743,7 +743,7 @@ out_unmap:
743 743
744 return ret; 744 return ret;
745} 745}
746#endif /* CONFIG_SH_DMA */ 746#endif /* CONFIG_PVR2_DMA */
747 747
748/** 748/**
749 * pvr2fb_common_init 749 * pvr2fb_common_init
@@ -893,7 +893,7 @@ static int __init pvr2fb_dc_init(void)
893 return -EBUSY; 893 return -EBUSY;
894 } 894 }
895 895
896#ifdef CONFIG_SH_DMA 896#ifdef CONFIG_PVR2_DMA
897 if (request_dma(pvr2dma, "pvr2") != 0) { 897 if (request_dma(pvr2dma, "pvr2") != 0) {
898 free_irq(HW_EVENT_VSYNC, 0); 898 free_irq(HW_EVENT_VSYNC, 0);
899 return -EBUSY; 899 return -EBUSY;
@@ -915,7 +915,7 @@ static void __exit pvr2fb_dc_exit(void)
915 } 915 }
916 916
917 free_irq(HW_EVENT_VSYNC, 0); 917 free_irq(HW_EVENT_VSYNC, 0);
918#ifdef CONFIG_SH_DMA 918#ifdef CONFIG_PVR2_DMA
919 free_dma(pvr2dma); 919 free_dma(pvr2dma);
920#endif 920#endif
921} 921}
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index 0e2b8fd24df1..92ea0ab44ce2 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -33,6 +33,8 @@ struct sh_mobile_lcdc_chan {
33 struct fb_info info; 33 struct fb_info info;
34 dma_addr_t dma_handle; 34 dma_addr_t dma_handle;
35 struct fb_deferred_io defio; 35 struct fb_deferred_io defio;
36 unsigned long frame_end;
37 wait_queue_head_t frame_end_wait;
36}; 38};
37 39
38struct sh_mobile_lcdc_priv { 40struct sh_mobile_lcdc_priv {
@@ -226,7 +228,10 @@ static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info)
226static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data) 228static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data)
227{ 229{
228 struct sh_mobile_lcdc_priv *priv = data; 230 struct sh_mobile_lcdc_priv *priv = data;
231 struct sh_mobile_lcdc_chan *ch;
229 unsigned long tmp; 232 unsigned long tmp;
233 int is_sub;
234 int k;
230 235
231 /* acknowledge interrupt */ 236 /* acknowledge interrupt */
232 tmp = lcdc_read(priv, _LDINTR); 237 tmp = lcdc_read(priv, _LDINTR);
@@ -234,8 +239,24 @@ static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data)
234 tmp |= 0x000000ff ^ LDINTR_FS; /* status in low 8 */ 239 tmp |= 0x000000ff ^ LDINTR_FS; /* status in low 8 */
235 lcdc_write(priv, _LDINTR, tmp); 240 lcdc_write(priv, _LDINTR, tmp);
236 241
237 /* disable clocks */ 242 /* figure out if this interrupt is for main or sub lcd */
238 sh_mobile_lcdc_clk_off(priv); 243 is_sub = (lcdc_read(priv, _LDSR) & (1 << 10)) ? 1 : 0;
244
245 /* wake up channel and disable clocks*/
246 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
247 ch = &priv->ch[k];
248
249 if (!ch->enabled)
250 continue;
251
252 if (is_sub == lcdc_chan_is_sublcd(ch)) {
253 ch->frame_end = 1;
254 wake_up(&ch->frame_end_wait);
255
256 sh_mobile_lcdc_clk_off(priv);
257 }
258 }
259
239 return IRQ_HANDLED; 260 return IRQ_HANDLED;
240} 261}
241 262
@@ -446,22 +467,29 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
446{ 467{
447 struct sh_mobile_lcdc_chan *ch; 468 struct sh_mobile_lcdc_chan *ch;
448 struct sh_mobile_lcdc_board_cfg *board_cfg; 469 struct sh_mobile_lcdc_board_cfg *board_cfg;
449 unsigned long tmp;
450 int k; 470 int k;
451 471
452 /* tell the board code to disable the panel */ 472 /* clean up deferred io and ask board code to disable panel */
453 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { 473 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
454 ch = &priv->ch[k]; 474 ch = &priv->ch[k];
455 board_cfg = &ch->cfg.board_cfg;
456 if (board_cfg->display_off)
457 board_cfg->display_off(board_cfg->board_data);
458 475
459 /* cleanup deferred io if SYS bus */ 476 /* deferred io mode:
460 tmp = ch->cfg.sys_bus_cfg.deferred_io_msec; 477 * flush frame, and wait for frame end interrupt
461 if (ch->ldmt1r_value & (1 << 12) && tmp) { 478 * clean up deferred io and enable clock
479 */
480 if (ch->info.fbdefio) {
481 ch->frame_end = 0;
482 schedule_delayed_work(&ch->info.deferred_work, 0);
483 wait_event(ch->frame_end_wait, ch->frame_end);
462 fb_deferred_io_cleanup(&ch->info); 484 fb_deferred_io_cleanup(&ch->info);
463 ch->info.fbdefio = NULL; 485 ch->info.fbdefio = NULL;
486 sh_mobile_lcdc_clk_on(priv);
464 } 487 }
488
489 board_cfg = &ch->cfg.board_cfg;
490 if (board_cfg->display_off)
491 board_cfg->display_off(board_cfg->board_data);
492
465 } 493 }
466 494
467 /* stop the lcdc */ 495 /* stop the lcdc */
@@ -654,6 +682,26 @@ static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp)
654 return 0; 682 return 0;
655} 683}
656 684
685static int sh_mobile_lcdc_suspend(struct device *dev)
686{
687 struct platform_device *pdev = to_platform_device(dev);
688
689 sh_mobile_lcdc_stop(platform_get_drvdata(pdev));
690 return 0;
691}
692
693static int sh_mobile_lcdc_resume(struct device *dev)
694{
695 struct platform_device *pdev = to_platform_device(dev);
696
697 return sh_mobile_lcdc_start(platform_get_drvdata(pdev));
698}
699
700static struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = {
701 .suspend = sh_mobile_lcdc_suspend,
702 .resume = sh_mobile_lcdc_resume,
703};
704
657static int sh_mobile_lcdc_remove(struct platform_device *pdev); 705static int sh_mobile_lcdc_remove(struct platform_device *pdev);
658 706
659static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) 707static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
@@ -689,7 +737,7 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
689 } 737 }
690 738
691 error = request_irq(i, sh_mobile_lcdc_irq, IRQF_DISABLED, 739 error = request_irq(i, sh_mobile_lcdc_irq, IRQF_DISABLED,
692 pdev->dev.bus_id, priv); 740 dev_name(&pdev->dev), priv);
693 if (error) { 741 if (error) {
694 dev_err(&pdev->dev, "unable to request irq\n"); 742 dev_err(&pdev->dev, "unable to request irq\n");
695 goto err1; 743 goto err1;
@@ -709,6 +757,7 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
709 dev_err(&pdev->dev, "unsupported interface type\n"); 757 dev_err(&pdev->dev, "unsupported interface type\n");
710 goto err1; 758 goto err1;
711 } 759 }
760 init_waitqueue_head(&priv->ch[i].frame_end_wait);
712 761
713 switch (pdata->ch[i].chan) { 762 switch (pdata->ch[i].chan) {
714 case LCDC_CHAN_MAINLCD: 763 case LCDC_CHAN_MAINLCD:
@@ -862,6 +911,7 @@ static struct platform_driver sh_mobile_lcdc_driver = {
862 .driver = { 911 .driver = {
863 .name = "sh_mobile_lcdc_fb", 912 .name = "sh_mobile_lcdc_fb",
864 .owner = THIS_MODULE, 913 .owner = THIS_MODULE,
914 .pm = &sh_mobile_lcdc_dev_pm_ops,
865 }, 915 },
866 .probe = sh_mobile_lcdc_probe, 916 .probe = sh_mobile_lcdc_probe,
867 .remove = sh_mobile_lcdc_remove, 917 .remove = sh_mobile_lcdc_remove,
diff --git a/drivers/video/tmiofb.c b/drivers/video/tmiofb.c
index 7baf2dd12d50..a1eb0862255b 100644
--- a/drivers/video/tmiofb.c
+++ b/drivers/video/tmiofb.c
@@ -751,7 +751,7 @@ static int __devinit tmiofb_probe(struct platform_device *dev)
751 } 751 }
752 752
753 retval = request_irq(irq, &tmiofb_irq, IRQF_DISABLED, 753 retval = request_irq(irq, &tmiofb_irq, IRQF_DISABLED,
754 dev->dev.bus_id, info); 754 dev_name(&dev->dev), info);
755 755
756 if (retval) 756 if (retval)
757 goto err_request_irq; 757 goto err_request_irq;
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index 9e1138a75e8b..a411702413d6 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -39,7 +39,7 @@ static u8 w1_gpio_read_bit(void *data)
39{ 39{
40 struct w1_gpio_platform_data *pdata = data; 40 struct w1_gpio_platform_data *pdata = data;
41 41
42 return gpio_get_value(pdata->pin); 42 return gpio_get_value(pdata->pin) ? 1 : 0;
43} 43}
44 44
45static int __init w1_gpio_probe(struct platform_device *pdev) 45static int __init w1_gpio_probe(struct platform_device *pdev)
diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c
index f0c2b7a1a175..734d9806a872 100644
--- a/drivers/watchdog/gef_wdt.c
+++ b/drivers/watchdog/gef_wdt.c
@@ -269,7 +269,7 @@ static int __devinit gef_wdt_probe(struct of_device *dev,
269 bus_clk = 133; /* in MHz */ 269 bus_clk = 133; /* in MHz */
270 270
271 freq = fsl_get_sys_freq(); 271 freq = fsl_get_sys_freq();
272 if (freq > 0) 272 if (freq != -1)
273 bus_clk = freq; 273 bus_clk = freq;
274 274
275 /* Map devices registers into memory */ 275 /* Map devices registers into memory */
diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c
index 0b798fdaa378..74c92d384112 100644
--- a/drivers/watchdog/ks8695_wdt.c
+++ b/drivers/watchdog/ks8695_wdt.c
@@ -21,6 +21,7 @@
21#include <linux/watchdog.h> 21#include <linux/watchdog.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/uaccess.h> 23#include <linux/uaccess.h>
24#include <mach/timex.h>
24#include <mach/regs-timer.h> 25#include <mach/regs-timer.h>
25 26
26#define WDT_DEFAULT_TIME 5 /* seconds */ 27#define WDT_DEFAULT_TIME 5 /* seconds */
diff --git a/drivers/watchdog/orion5x_wdt.c b/drivers/watchdog/orion5x_wdt.c
index 14a339f58b6a..b64ae1a17832 100644
--- a/drivers/watchdog/orion5x_wdt.c
+++ b/drivers/watchdog/orion5x_wdt.c
@@ -29,6 +29,7 @@
29#define WDT_EN 0x0010 29#define WDT_EN 0x0010
30#define WDT_VAL (TIMER_VIRT_BASE + 0x0024) 30#define WDT_VAL (TIMER_VIRT_BASE + 0x0024)
31 31
32#define ORION5X_TCLK 166666667
32#define WDT_MAX_DURATION (0xffffffff / ORION5X_TCLK) 33#define WDT_MAX_DURATION (0xffffffff / ORION5X_TCLK)
33#define WDT_IN_USE 0 34#define WDT_IN_USE 0
34#define WDT_OK_TO_CLOSE 1 35#define WDT_OK_TO_CLOSE 1
diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c
index 57027f4653ce..f3553fa40b17 100644
--- a/drivers/watchdog/rc32434_wdt.c
+++ b/drivers/watchdog/rc32434_wdt.c
@@ -34,104 +34,89 @@
34#include <asm/time.h> 34#include <asm/time.h>
35#include <asm/mach-rc32434/integ.h> 35#include <asm/mach-rc32434/integ.h>
36 36
37#define MAX_TIMEOUT 20 37#define VERSION "0.4"
38#define RC32434_WDT_INTERVAL (15 * HZ)
39
40#define VERSION "0.2"
41 38
42static struct { 39static struct {
43 struct completion stop;
44 int running;
45 struct timer_list timer;
46 int queue;
47 int default_ticks;
48 unsigned long inuse; 40 unsigned long inuse;
49} rc32434_wdt_device; 41} rc32434_wdt_device;
50 42
51static struct integ __iomem *wdt_reg; 43static struct integ __iomem *wdt_reg;
52static int ticks = 100 * HZ;
53 44
54static int expect_close; 45static int expect_close;
55static int timeout; 46
47/* Board internal clock speed in Hz,
48 * the watchdog timer ticks at. */
49extern unsigned int idt_cpu_freq;
50
51/* translate wtcompare value to seconds and vice versa */
52#define WTCOMP2SEC(x) (x / idt_cpu_freq)
53#define SEC2WTCOMP(x) (x * idt_cpu_freq)
54
55/* Use a default timeout of 20s. This should be
56 * safe for CPU clock speeds up to 400MHz, as
57 * ((2 ^ 32) - 1) / (400MHz / 2) = 21s. */
58#define WATCHDOG_TIMEOUT 20
59
60static int timeout = WATCHDOG_TIMEOUT;
56 61
57static int nowayout = WATCHDOG_NOWAYOUT; 62static int nowayout = WATCHDOG_NOWAYOUT;
58module_param(nowayout, int, 0); 63module_param(nowayout, int, 0);
59MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 64MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
60 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 65 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
61 66
67/* apply or and nand masks to data read from addr and write back */
68#define SET_BITS(addr, or, nand) \
69 writel((readl(&addr) | or) & ~nand, &addr)
62 70
63static void rc32434_wdt_start(void) 71static void rc32434_wdt_start(void)
64{ 72{
65 u32 val; 73 u32 or, nand;
66
67 if (!rc32434_wdt_device.inuse) {
68 writel(0, &wdt_reg->wtcount);
69 74
70 val = RC32434_ERR_WRE; 75 /* zero the counter before enabling */
71 writel(readl(&wdt_reg->errcs) | val, &wdt_reg->errcs); 76 writel(0, &wdt_reg->wtcount);
72 77
73 val = RC32434_WTC_EN; 78 /* don't generate a non-maskable interrupt,
74 writel(readl(&wdt_reg->wtc) | val, &wdt_reg->wtc); 79 * do a warm reset instead */
75 } 80 nand = 1 << RC32434_ERR_WNE;
76 rc32434_wdt_device.running++; 81 or = 1 << RC32434_ERR_WRE;
77}
78 82
79static void rc32434_wdt_stop(void) 83 /* reset the ERRCS timeout bit in case it's set */
80{ 84 nand |= 1 << RC32434_ERR_WTO;
81 u32 val;
82 85
83 if (rc32434_wdt_device.running) { 86 SET_BITS(wdt_reg->errcs, or, nand);
84 87
85 val = ~RC32434_WTC_EN; 88 /* reset WTC timeout bit and enable WDT */
86 writel(readl(&wdt_reg->wtc) & val, &wdt_reg->wtc); 89 nand = 1 << RC32434_WTC_TO;
90 or = 1 << RC32434_WTC_EN;
87 91
88 val = ~RC32434_ERR_WRE; 92 SET_BITS(wdt_reg->wtc, or, nand);
89 writel(readl(&wdt_reg->errcs) & val, &wdt_reg->errcs); 93}
90 94
91 rc32434_wdt_device.running = 0; 95static void rc32434_wdt_stop(void)
92 } 96{
97 /* Disable WDT */
98 SET_BITS(wdt_reg->wtc, 0, 1 << RC32434_WTC_EN);
93} 99}
94 100
95static void rc32434_wdt_set(int new_timeout) 101static int rc32434_wdt_set(int new_timeout)
96{ 102{
97 u32 cmp = new_timeout * HZ; 103 int max_to = WTCOMP2SEC((u32)-1);
98 u32 state, val;
99 104
105 if (new_timeout < 0 || new_timeout > max_to) {
106 printk(KERN_ERR KBUILD_MODNAME
107 ": timeout value must be between 0 and %d",
108 max_to);
109 return -EINVAL;
110 }
100 timeout = new_timeout; 111 timeout = new_timeout;
101 /* 112 writel(SEC2WTCOMP(timeout), &wdt_reg->wtcompare);
102 * store and disable WTC
103 */
104 state = (u32)(readl(&wdt_reg->wtc) & RC32434_WTC_EN);
105 val = ~RC32434_WTC_EN;
106 writel(readl(&wdt_reg->wtc) & val, &wdt_reg->wtc);
107
108 writel(0, &wdt_reg->wtcount);
109 writel(cmp, &wdt_reg->wtcompare);
110
111 /*
112 * restore WTC
113 */
114
115 writel(readl(&wdt_reg->wtc) | state, &wdt_reg);
116}
117 113
118static void rc32434_wdt_reset(void) 114 return 0;
119{
120 ticks = rc32434_wdt_device.default_ticks;
121} 115}
122 116
123static void rc32434_wdt_update(unsigned long unused) 117static void rc32434_wdt_ping(void)
124{ 118{
125 if (rc32434_wdt_device.running)
126 ticks--;
127
128 writel(0, &wdt_reg->wtcount); 119 writel(0, &wdt_reg->wtcount);
129
130 if (rc32434_wdt_device.queue && ticks)
131 mod_timer(&rc32434_wdt_device.timer,
132 jiffies + RC32434_WDT_INTERVAL);
133 else
134 complete(&rc32434_wdt_device.stop);
135} 120}
136 121
137static int rc32434_wdt_open(struct inode *inode, struct file *file) 122static int rc32434_wdt_open(struct inode *inode, struct file *file)
@@ -142,19 +127,23 @@ static int rc32434_wdt_open(struct inode *inode, struct file *file)
142 if (nowayout) 127 if (nowayout)
143 __module_get(THIS_MODULE); 128 __module_get(THIS_MODULE);
144 129
130 rc32434_wdt_start();
131 rc32434_wdt_ping();
132
145 return nonseekable_open(inode, file); 133 return nonseekable_open(inode, file);
146} 134}
147 135
148static int rc32434_wdt_release(struct inode *inode, struct file *file) 136static int rc32434_wdt_release(struct inode *inode, struct file *file)
149{ 137{
150 if (expect_close && nowayout == 0) { 138 if (expect_close == 42) {
151 rc32434_wdt_stop(); 139 rc32434_wdt_stop();
152 printk(KERN_INFO KBUILD_MODNAME ": disabling watchdog timer\n"); 140 printk(KERN_INFO KBUILD_MODNAME ": disabling watchdog timer\n");
153 module_put(THIS_MODULE); 141 module_put(THIS_MODULE);
154 } else 142 } else {
155 printk(KERN_CRIT KBUILD_MODNAME 143 printk(KERN_CRIT KBUILD_MODNAME
156 ": device closed unexpectedly. WDT will not stop !\n"); 144 ": device closed unexpectedly. WDT will not stop !\n");
157 145 rc32434_wdt_ping();
146 }
158 clear_bit(0, &rc32434_wdt_device.inuse); 147 clear_bit(0, &rc32434_wdt_device.inuse);
159 return 0; 148 return 0;
160} 149}
@@ -174,10 +163,10 @@ static ssize_t rc32434_wdt_write(struct file *file, const char *data,
174 if (get_user(c, data + i)) 163 if (get_user(c, data + i))
175 return -EFAULT; 164 return -EFAULT;
176 if (c == 'V') 165 if (c == 'V')
177 expect_close = 1; 166 expect_close = 42;
178 } 167 }
179 } 168 }
180 rc32434_wdt_update(0); 169 rc32434_wdt_ping();
181 return len; 170 return len;
182 } 171 }
183 return 0; 172 return 0;
@@ -197,11 +186,11 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
197 }; 186 };
198 switch (cmd) { 187 switch (cmd) {
199 case WDIOC_KEEPALIVE: 188 case WDIOC_KEEPALIVE:
200 rc32434_wdt_reset(); 189 rc32434_wdt_ping();
201 break; 190 break;
202 case WDIOC_GETSTATUS: 191 case WDIOC_GETSTATUS:
203 case WDIOC_GETBOOTSTATUS: 192 case WDIOC_GETBOOTSTATUS:
204 value = readl(&wdt_reg->wtcount); 193 value = 0;
205 if (copy_to_user(argp, &value, sizeof(int))) 194 if (copy_to_user(argp, &value, sizeof(int)))
206 return -EFAULT; 195 return -EFAULT;
207 break; 196 break;
@@ -218,6 +207,7 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
218 break; 207 break;
219 case WDIOS_DISABLECARD: 208 case WDIOS_DISABLECARD:
220 rc32434_wdt_stop(); 209 rc32434_wdt_stop();
210 break;
221 default: 211 default:
222 return -EINVAL; 212 return -EINVAL;
223 } 213 }
@@ -225,11 +215,9 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
225 case WDIOC_SETTIMEOUT: 215 case WDIOC_SETTIMEOUT:
226 if (copy_from_user(&new_timeout, argp, sizeof(int))) 216 if (copy_from_user(&new_timeout, argp, sizeof(int)))
227 return -EFAULT; 217 return -EFAULT;
228 if (new_timeout < 1) 218 if (rc32434_wdt_set(new_timeout))
229 return -EINVAL; 219 return -EINVAL;
230 if (new_timeout > MAX_TIMEOUT) 220 /* Fall through */
231 return -EINVAL;
232 rc32434_wdt_set(new_timeout);
233 case WDIOC_GETTIMEOUT: 221 case WDIOC_GETTIMEOUT:
234 return copy_to_user(argp, &timeout, sizeof(int)); 222 return copy_to_user(argp, &timeout, sizeof(int));
235 default: 223 default:
@@ -254,15 +242,15 @@ static struct miscdevice rc32434_wdt_miscdev = {
254 .fops = &rc32434_wdt_fops, 242 .fops = &rc32434_wdt_fops,
255}; 243};
256 244
257static char banner[] = KERN_INFO KBUILD_MODNAME 245static char banner[] __devinitdata = KERN_INFO KBUILD_MODNAME
258 ": Watchdog Timer version " VERSION ", timer margin: %d sec\n"; 246 ": Watchdog Timer version " VERSION ", timer margin: %d sec\n";
259 247
260static int rc32434_wdt_probe(struct platform_device *pdev) 248static int __devinit rc32434_wdt_probe(struct platform_device *pdev)
261{ 249{
262 int ret; 250 int ret;
263 struct resource *r; 251 struct resource *r;
264 252
265 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb500_wdt_res"); 253 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb532_wdt_res");
266 if (!r) { 254 if (!r) {
267 printk(KERN_ERR KBUILD_MODNAME 255 printk(KERN_ERR KBUILD_MODNAME
268 "failed to retrieve resources\n"); 256 "failed to retrieve resources\n");
@@ -277,24 +265,12 @@ static int rc32434_wdt_probe(struct platform_device *pdev)
277 } 265 }
278 266
279 ret = misc_register(&rc32434_wdt_miscdev); 267 ret = misc_register(&rc32434_wdt_miscdev);
280
281 if (ret < 0) { 268 if (ret < 0) {
282 printk(KERN_ERR KBUILD_MODNAME 269 printk(KERN_ERR KBUILD_MODNAME
283 "failed to register watchdog device\n"); 270 "failed to register watchdog device\n");
284 goto unmap; 271 goto unmap;
285 } 272 }
286 273
287 init_completion(&rc32434_wdt_device.stop);
288 rc32434_wdt_device.queue = 0;
289
290 clear_bit(0, &rc32434_wdt_device.inuse);
291
292 setup_timer(&rc32434_wdt_device.timer, rc32434_wdt_update, 0L);
293
294 rc32434_wdt_device.default_ticks = ticks;
295
296 rc32434_wdt_start();
297
298 printk(banner, timeout); 274 printk(banner, timeout);
299 275
300 return 0; 276 return 0;
@@ -304,23 +280,17 @@ unmap:
304 return ret; 280 return ret;
305} 281}
306 282
307static int rc32434_wdt_remove(struct platform_device *pdev) 283static int __devexit rc32434_wdt_remove(struct platform_device *pdev)
308{ 284{
309 if (rc32434_wdt_device.queue) {
310 rc32434_wdt_device.queue = 0;
311 wait_for_completion(&rc32434_wdt_device.stop);
312 }
313 misc_deregister(&rc32434_wdt_miscdev); 285 misc_deregister(&rc32434_wdt_miscdev);
314
315 iounmap(wdt_reg); 286 iounmap(wdt_reg);
316
317 return 0; 287 return 0;
318} 288}
319 289
320static struct platform_driver rc32434_wdt = { 290static struct platform_driver rc32434_wdt = {
321 .probe = rc32434_wdt_probe, 291 .probe = rc32434_wdt_probe,
322 .remove = rc32434_wdt_remove, 292 .remove = __devexit_p(rc32434_wdt_remove),
323 .driver = { 293 .driver = {
324 .name = "rc32434_wdt", 294 .name = "rc32434_wdt",
325 } 295 }
326}; 296};
diff --git a/drivers/watchdog/rm9k_wdt.c b/drivers/watchdog/rm9k_wdt.c
index f1ae3729a19e..cce1982a1b58 100644
--- a/drivers/watchdog/rm9k_wdt.c
+++ b/drivers/watchdog/rm9k_wdt.c
@@ -59,8 +59,8 @@ static long wdt_gpi_ioctl(struct file *, unsigned int, unsigned long);
59static int wdt_gpi_notify(struct notifier_block *, unsigned long, void *); 59static int wdt_gpi_notify(struct notifier_block *, unsigned long, void *);
60static const struct resource *wdt_gpi_get_resource(struct platform_device *, 60static const struct resource *wdt_gpi_get_resource(struct platform_device *,
61 const char *, unsigned int); 61 const char *, unsigned int);
62static int __init wdt_gpi_probe(struct device *); 62static int __init wdt_gpi_probe(struct platform_device *);
63static int __exit wdt_gpi_remove(struct device *); 63static int __exit wdt_gpi_remove(struct platform_device *);
64 64
65 65
66static const char wdt_gpi_name[] = "wdt_gpi"; 66static const char wdt_gpi_name[] = "wdt_gpi";
@@ -346,10 +346,9 @@ static const struct resource *wdt_gpi_get_resource(struct platform_device *pdv,
346} 346}
347 347
348/* No hotplugging on the platform bus - use __init */ 348/* No hotplugging on the platform bus - use __init */
349static int __init wdt_gpi_probe(struct device *dev) 349static int __init wdt_gpi_probe(struct platform_device *pdv)
350{ 350{
351 int res; 351 int res;
352 struct platform_device * const pdv = to_platform_device(dev);
353 const struct resource 352 const struct resource
354 * const rr = wdt_gpi_get_resource(pdv, WDT_RESOURCE_REGS, 353 * const rr = wdt_gpi_get_resource(pdv, WDT_RESOURCE_REGS,
355 IORESOURCE_MEM), 354 IORESOURCE_MEM),
@@ -374,7 +373,7 @@ static int __init wdt_gpi_probe(struct device *dev)
374 return res; 373 return res;
375} 374}
376 375
377static int __exit wdt_gpi_remove(struct device *dev) 376static int __exit wdt_gpi_remove(struct platform_device *dev)
378{ 377{
379 int res; 378 int res;
380 379
@@ -387,15 +386,13 @@ static int __exit wdt_gpi_remove(struct device *dev)
387 386
388 387
389/* Device driver init & exit */ 388/* Device driver init & exit */
390static struct device_driver wdt_gpi_driver = { 389static struct platform_driver wgt_gpi_driver = {
391 .name = (char *) wdt_gpi_name, 390 .driver = {
392 .bus = &platform_bus_type, 391 .name = wdt_gpi_name,
393 .owner = THIS_MODULE, 392 .owner = THIS_MODULE,
393 },
394 .probe = wdt_gpi_probe, 394 .probe = wdt_gpi_probe,
395 .remove = __exit_p(wdt_gpi_remove), 395 .remove = __devexit_p(wdt_gpi_remove),
396 .shutdown = NULL,
397 .suspend = NULL,
398 .resume = NULL,
399}; 396};
400 397
401static int __init wdt_gpi_init_module(void) 398static int __init wdt_gpi_init_module(void)
@@ -403,12 +400,12 @@ static int __init wdt_gpi_init_module(void)
403 atomic_set(&opencnt, 1); 400 atomic_set(&opencnt, 1);
404 if (timeout > MAX_TIMEOUT_SECONDS) 401 if (timeout > MAX_TIMEOUT_SECONDS)
405 timeout = MAX_TIMEOUT_SECONDS; 402 timeout = MAX_TIMEOUT_SECONDS;
406 return driver_register(&wdt_gpi_driver); 403 return platform_driver_register(&wdt_gpi_driver);
407} 404}
408 405
409static void __exit wdt_gpi_cleanup_module(void) 406static void __exit wdt_gpi_cleanup_module(void)
410{ 407{
411 driver_unregister(&wdt_gpi_driver); 408 platform_driver_unregister(&wdt_gpi_driver);
412} 409}
413 410
414module_init(wdt_gpi_init_module); 411module_init(wdt_gpi_init_module);
diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c
index a1585d6f6486..d45fb34e2d23 100644
--- a/drivers/zorro/zorro.c
+++ b/drivers/zorro/zorro.c
@@ -140,7 +140,7 @@ static int __init zorro_init(void)
140 140
141 /* Initialize the Zorro bus */ 141 /* Initialize the Zorro bus */
142 INIT_LIST_HEAD(&zorro_bus.devices); 142 INIT_LIST_HEAD(&zorro_bus.devices);
143 strcpy(zorro_bus.dev.bus_id, "zorro"); 143 dev_set_name(&zorro_bus.dev, "zorro");
144 error = device_register(&zorro_bus.dev); 144 error = device_register(&zorro_bus.dev);
145 if (error) { 145 if (error) {
146 pr_err("Zorro: Error registering zorro_bus\n"); 146 pr_err("Zorro: Error registering zorro_bus\n");
@@ -167,7 +167,7 @@ static int __init zorro_init(void)
167 if (request_resource(zorro_find_parent_resource(z), &z->resource)) 167 if (request_resource(zorro_find_parent_resource(z), &z->resource))
168 pr_err("Zorro: Address space collision on device %s %pR\n", 168 pr_err("Zorro: Address space collision on device %s %pR\n",
169 z->name, &z->resource); 169 z->name, &z->resource);
170 sprintf(z->dev.bus_id, "%02x", i); 170 dev_set_name(&z->dev, "%02x", i);
171 z->dev.parent = &zorro_bus.dev; 171 z->dev.parent = &zorro_bus.dev;
172 z->dev.bus = &zorro_bus_type; 172 z->dev.bus = &zorro_bus_type;
173 error = device_register(&z->dev); 173 error = device_register(&z->dev);