aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2010-04-08 13:34:54 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-04-08 13:34:54 -0400
commit0f2df9eac70423838a1f8d410fd3899ddd88317b (patch)
tree0617f723320d83eca5cef9c964c001014e74213f /drivers
parent8c11e4ab09ffb975a89802dde0e9aa52a53b8aa5 (diff)
parent1144601118507f8b3b676a9a392584d216d3f2cc (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6 into merge
Conflicts: Documentation/feature-removal-schedule.txt drivers/net/wireless/ath/ath5k/phy.c drivers/net/wireless/iwlwifi/iwl-4965.c drivers/net/wireless/iwlwifi/iwl-agn.c drivers/net/wireless/iwlwifi/iwl-core.c drivers/net/wireless/iwlwifi/iwl-core.h drivers/net/wireless/iwlwifi/iwl-tx.c
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/acpica/accommon.h2
-rw-r--r--drivers/acpi/acpica/acconfig.h2
-rw-r--r--drivers/acpi/acpica/acdebug.h2
-rw-r--r--drivers/acpi/acpica/acdispat.h2
-rw-r--r--drivers/acpi/acpica/acevents.h5
-rw-r--r--drivers/acpi/acpica/acglobal.h2
-rw-r--r--drivers/acpi/acpica/achware.h2
-rw-r--r--drivers/acpi/acpica/acinterp.h44
-rw-r--r--drivers/acpi/acpica/aclocal.h6
-rw-r--r--drivers/acpi/acpica/acmacros.h14
-rw-r--r--drivers/acpi/acpica/acnamesp.h18
-rw-r--r--drivers/acpi/acpica/acobject.h4
-rw-r--r--drivers/acpi/acpica/acopcode.h2
-rw-r--r--drivers/acpi/acpica/acparser.h2
-rw-r--r--drivers/acpi/acpica/acpredef.h2
-rw-r--r--drivers/acpi/acpica/acresrc.h2
-rw-r--r--drivers/acpi/acpica/acstruct.h2
-rw-r--r--drivers/acpi/acpica/actables.h2
-rw-r--r--drivers/acpi/acpica/acutils.h22
-rw-r--r--drivers/acpi/acpica/amlcode.h2
-rw-r--r--drivers/acpi/acpica/amlresrc.h2
-rw-r--r--drivers/acpi/acpica/dsfield.c12
-rw-r--r--drivers/acpi/acpica/dsinit.c2
-rw-r--r--drivers/acpi/acpica/dsmethod.c2
-rw-r--r--drivers/acpi/acpica/dsmthdat.c2
-rw-r--r--drivers/acpi/acpica/dsobject.c4
-rw-r--r--drivers/acpi/acpica/dsopcode.c2
-rw-r--r--drivers/acpi/acpica/dsutils.c2
-rw-r--r--drivers/acpi/acpica/dswexec.c2
-rw-r--r--drivers/acpi/acpica/dswload.c2
-rw-r--r--drivers/acpi/acpica/dswscope.c2
-rw-r--r--drivers/acpi/acpica/dswstate.c2
-rw-r--r--drivers/acpi/acpica/evevent.c2
-rw-r--r--drivers/acpi/acpica/evgpe.c2
-rw-r--r--drivers/acpi/acpica/evgpeblk.c2
-rw-r--r--drivers/acpi/acpica/evmisc.c2
-rw-r--r--drivers/acpi/acpica/evregion.c7
-rw-r--r--drivers/acpi/acpica/evrgnini.c4
-rw-r--r--drivers/acpi/acpica/evsci.c2
-rw-r--r--drivers/acpi/acpica/evxface.c2
-rw-r--r--drivers/acpi/acpica/evxfevnt.c2
-rw-r--r--drivers/acpi/acpica/evxfregn.c2
-rw-r--r--drivers/acpi/acpica/exconfig.c17
-rw-r--r--drivers/acpi/acpica/exconvrt.c21
-rw-r--r--drivers/acpi/acpica/excreate.c2
-rw-r--r--drivers/acpi/acpica/exdump.c2
-rw-r--r--drivers/acpi/acpica/exfield.c9
-rw-r--r--drivers/acpi/acpica/exfldio.c59
-rw-r--r--drivers/acpi/acpica/exmisc.c12
-rw-r--r--drivers/acpi/acpica/exmutex.c2
-rw-r--r--drivers/acpi/acpica/exnames.c2
-rw-r--r--drivers/acpi/acpica/exoparg1.c16
-rw-r--r--drivers/acpi/acpica/exoparg2.c6
-rw-r--r--drivers/acpi/acpica/exoparg3.c4
-rw-r--r--drivers/acpi/acpica/exoparg6.c10
-rw-r--r--drivers/acpi/acpica/exprep.c2
-rw-r--r--drivers/acpi/acpica/exregion.c35
-rw-r--r--drivers/acpi/acpica/exresnte.c2
-rw-r--r--drivers/acpi/acpica/exresolv.c2
-rw-r--r--drivers/acpi/acpica/exresop.c2
-rw-r--r--drivers/acpi/acpica/exstore.c2
-rw-r--r--drivers/acpi/acpica/exstoren.c2
-rw-r--r--drivers/acpi/acpica/exstorob.c2
-rw-r--r--drivers/acpi/acpica/exsystem.c4
-rw-r--r--drivers/acpi/acpica/exutils.c24
-rw-r--r--drivers/acpi/acpica/hwacpi.c2
-rw-r--r--drivers/acpi/acpica/hwgpe.c8
-rw-r--r--drivers/acpi/acpica/hwregs.c2
-rw-r--r--drivers/acpi/acpica/hwsleep.c2
-rw-r--r--drivers/acpi/acpica/hwtimer.c4
-rw-r--r--drivers/acpi/acpica/hwvalid.c2
-rw-r--r--drivers/acpi/acpica/hwxface.c2
-rw-r--r--drivers/acpi/acpica/nsaccess.c2
-rw-r--r--drivers/acpi/acpica/nsalloc.c2
-rw-r--r--drivers/acpi/acpica/nsdump.c2
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c2
-rw-r--r--drivers/acpi/acpica/nseval.c2
-rw-r--r--drivers/acpi/acpica/nsinit.c2
-rw-r--r--drivers/acpi/acpica/nsload.c2
-rw-r--r--drivers/acpi/acpica/nsnames.c2
-rw-r--r--drivers/acpi/acpica/nsobject.c2
-rw-r--r--drivers/acpi/acpica/nsparse.c2
-rw-r--r--drivers/acpi/acpica/nspredef.c53
-rw-r--r--drivers/acpi/acpica/nsrepair.c175
-rw-r--r--drivers/acpi/acpica/nsrepair2.c110
-rw-r--r--drivers/acpi/acpica/nssearch.c2
-rw-r--r--drivers/acpi/acpica/nsutils.c2
-rw-r--r--drivers/acpi/acpica/nswalk.c2
-rw-r--r--drivers/acpi/acpica/nsxfeval.c54
-rw-r--r--drivers/acpi/acpica/nsxfname.c2
-rw-r--r--drivers/acpi/acpica/nsxfobj.c2
-rw-r--r--drivers/acpi/acpica/psargs.c4
-rw-r--r--drivers/acpi/acpica/psloop.c2
-rw-r--r--drivers/acpi/acpica/psopcode.c2
-rw-r--r--drivers/acpi/acpica/psparse.c2
-rw-r--r--drivers/acpi/acpica/psscope.c2
-rw-r--r--drivers/acpi/acpica/pstree.c2
-rw-r--r--drivers/acpi/acpica/psutils.c2
-rw-r--r--drivers/acpi/acpica/pswalk.c2
-rw-r--r--drivers/acpi/acpica/psxface.c2
-rw-r--r--drivers/acpi/acpica/rsaddr.c2
-rw-r--r--drivers/acpi/acpica/rscalc.c2
-rw-r--r--drivers/acpi/acpica/rscreate.c4
-rw-r--r--drivers/acpi/acpica/rsdump.c2
-rw-r--r--drivers/acpi/acpica/rsinfo.c2
-rw-r--r--drivers/acpi/acpica/rsio.c2
-rw-r--r--drivers/acpi/acpica/rsirq.c2
-rw-r--r--drivers/acpi/acpica/rslist.c2
-rw-r--r--drivers/acpi/acpica/rsmemory.c2
-rw-r--r--drivers/acpi/acpica/rsmisc.c2
-rw-r--r--drivers/acpi/acpica/rsutils.c2
-rw-r--r--drivers/acpi/acpica/rsxface.c2
-rw-r--r--drivers/acpi/acpica/tbfadt.c2
-rw-r--r--drivers/acpi/acpica/tbfind.c2
-rw-r--r--drivers/acpi/acpica/tbinstal.c2
-rw-r--r--drivers/acpi/acpica/tbutils.c2
-rw-r--r--drivers/acpi/acpica/tbxface.c2
-rw-r--r--drivers/acpi/acpica/tbxfroot.c2
-rw-r--r--drivers/acpi/acpica/utalloc.c2
-rw-r--r--drivers/acpi/acpica/utcopy.c2
-rw-r--r--drivers/acpi/acpica/utdebug.c5
-rw-r--r--drivers/acpi/acpica/utdelete.c2
-rw-r--r--drivers/acpi/acpica/uteval.c4
-rw-r--r--drivers/acpi/acpica/utglobal.c4
-rw-r--r--drivers/acpi/acpica/utids.c2
-rw-r--r--drivers/acpi/acpica/utinit.c2
-rw-r--r--drivers/acpi/acpica/utlock.c2
-rw-r--r--drivers/acpi/acpica/utmath.c27
-rw-r--r--drivers/acpi/acpica/utmisc.c16
-rw-r--r--drivers/acpi/acpica/utmutex.c18
-rw-r--r--drivers/acpi/acpica/utobject.c2
-rw-r--r--drivers/acpi/acpica/utresrc.c2
-rw-r--r--drivers/acpi/acpica/utstate.c2
-rw-r--r--drivers/acpi/acpica/utxface.c2
-rw-r--r--drivers/acpi/battery.c4
-rw-r--r--drivers/acpi/ec.c4
-rw-r--r--drivers/acpi/glue.c4
-rw-r--r--drivers/acpi/osl.c4
-rw-r--r--drivers/acpi/power_meter.c30
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/acpi/processor_throttling.c24
-rw-r--r--drivers/acpi/utils.c16
-rw-r--r--drivers/acpi/video.c2
-rw-r--r--drivers/ata/Kconfig4
-rw-r--r--drivers/ata/ahci.c235
-rw-r--r--drivers/ata/ata_generic.c2
-rw-r--r--drivers/ata/ata_piix.c28
-rw-r--r--drivers/ata/libata-acpi.c4
-rw-r--r--drivers/ata/libata-core.c17
-rw-r--r--drivers/ata/libata-scsi.c2
-rw-r--r--drivers/ata/libata-sff.c50
-rw-r--r--drivers/ata/pata_acpi.c2
-rw-r--r--drivers/ata/pata_ali.c10
-rw-r--r--drivers/ata/pata_amd.c2
-rw-r--r--drivers/ata/pata_artop.c2
-rw-r--r--drivers/ata/pata_at91.c4
-rw-r--r--drivers/ata/pata_atiixp.c14
-rw-r--r--drivers/ata/pata_cmd640.c2
-rw-r--r--drivers/ata/pata_cmd64x.c27
-rw-r--r--drivers/ata/pata_cs5530.c2
-rw-r--r--drivers/ata/pata_cs5535.c4
-rw-r--r--drivers/ata/pata_cs5536.c2
-rw-r--r--drivers/ata/pata_cypress.c12
-rw-r--r--drivers/ata/pata_efar.c22
-rw-r--r--drivers/ata/pata_hpt366.c23
-rw-r--r--drivers/ata/pata_hpt37x.c189
-rw-r--r--drivers/ata/pata_hpt3x2n.c120
-rw-r--r--drivers/ata/pata_it8213.c2
-rw-r--r--drivers/ata/pata_it821x.c2
-rw-r--r--drivers/ata/pata_jmicron.c2
-rw-r--r--drivers/ata/pata_marvell.c4
-rw-r--r--drivers/ata/pata_netcell.c2
-rw-r--r--drivers/ata/pata_ns87410.c2
-rw-r--r--drivers/ata/pata_ns87415.c2
-rw-r--r--drivers/ata/pata_oldpiix.c2
-rw-r--r--drivers/ata/pata_opti.c2
-rw-r--r--drivers/ata/pata_optidma.c2
-rw-r--r--drivers/ata/pata_pcmcia.c2
-rw-r--r--drivers/ata/pata_pdc202xx_old.c17
-rw-r--r--drivers/ata/pata_piccolo.c2
-rw-r--r--drivers/ata/pata_radisys.c2
-rw-r--r--drivers/ata/pata_rz1000.c2
-rw-r--r--drivers/ata/pata_sc1200.c2
-rw-r--r--drivers/ata/pata_serverworks.c7
-rw-r--r--drivers/ata/pata_sil680.c2
-rw-r--r--drivers/ata/pata_sis.c2
-rw-r--r--drivers/ata/pata_sl82c105.c2
-rw-r--r--drivers/ata/pata_triflex.c2
-rw-r--r--drivers/ata/pata_via.c210
-rw-r--r--drivers/ata/sata_nv.c2
-rw-r--r--drivers/ata/sata_via.c23
-rw-r--r--drivers/block/DAC960.c6
-rw-r--r--drivers/block/brd.c2
-rw-r--r--drivers/block/cciss.c218
-rw-r--r--drivers/block/cciss.h21
-rw-r--r--drivers/block/cciss_cmd.h164
-rw-r--r--drivers/block/cciss_scsi.c145
-rw-r--r--drivers/block/cciss_scsi.h18
-rw-r--r--drivers/block/cpqarray.c5
-rw-r--r--drivers/block/drbd/drbd_nl.c5
-rw-r--r--drivers/block/floppy.c2
-rw-r--r--drivers/block/hd.c2
-rw-r--r--drivers/block/mg_disk.c2
-rw-r--r--drivers/block/paride/pd.c2
-rw-r--r--drivers/block/paride/pf.c3
-rw-r--r--drivers/block/pktcdvd.c97
-rw-r--r--drivers/block/ps3disk.c5
-rw-r--r--drivers/block/ps3vram.c7
-rw-r--r--drivers/block/sunvdc.c5
-rw-r--r--drivers/block/sx8.c5
-rw-r--r--drivers/block/ub.c7
-rw-r--r--drivers/block/viodasd.c5
-rw-r--r--drivers/block/virtio_blk.c2
-rw-r--r--drivers/block/xd.c2
-rw-r--r--drivers/block/xen-blkfront.c7
-rw-r--r--drivers/block/xsysace.c2
-rw-r--r--drivers/cdrom/gdrom.c2
-rw-r--r--drivers/cdrom/viocd.c5
-rw-r--r--drivers/char/hw_random/Kconfig2
-rw-r--r--drivers/char/keyboard.c29
-rw-r--r--drivers/char/nvram.c3
-rw-r--r--drivers/clocksource/sh_cmt.c35
-rw-r--r--drivers/firewire/sbp2.c2
-rw-r--r--drivers/i2c/busses/i2c-pnx.c285
-rw-r--r--drivers/ide/ide-acpi.c8
-rw-r--r--drivers/ide/ide-disk.c2
-rw-r--r--drivers/ide/ide-floppy.c4
-rw-r--r--drivers/ide/ide-probe.c5
-rw-r--r--drivers/ieee1394/sbp2.c2
-rw-r--r--drivers/input/evdev.c2
-rw-r--r--drivers/input/gameport/emu10k1-gp.c2
-rw-r--r--drivers/input/gameport/fm801-gp.c2
-rw-r--r--drivers/input/gameport/gameport.c98
-rw-r--r--drivers/input/gameport/ns558.c2
-rw-r--r--drivers/input/input-compat.h2
-rw-r--r--drivers/input/input.c90
-rw-r--r--drivers/input/joydev.c34
-rw-r--r--drivers/input/joystick/Kconfig1
-rw-r--r--drivers/input/joystick/gamecon.c664
-rw-r--r--drivers/input/joystick/xpad.c253
-rw-r--r--drivers/input/keyboard/Kconfig33
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/adp5588-keys.c6
-rw-r--r--drivers/input/keyboard/atkbd.c309
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c40
-rw-r--r--drivers/input/keyboard/gpio_keys.c318
-rw-r--r--drivers/input/keyboard/imx_keypad.c594
-rw-r--r--drivers/input/keyboard/qt2160.c2
-rw-r--r--drivers/input/keyboard/sh_keysc.c145
-rw-r--r--drivers/input/misc/apanel.c2
-rw-r--r--drivers/input/misc/atlas_btns.c2
-rw-r--r--drivers/input/misc/rotary_encoder.c14
-rw-r--r--drivers/input/misc/uinput.c4
-rw-r--r--drivers/input/misc/winbond-cir.c213
-rw-r--r--drivers/input/mouse/hgpk.c4
-rw-r--r--drivers/input/serio/pcips2.c2
-rw-r--r--drivers/input/serio/serio.c131
-rw-r--r--drivers/input/serio/xilinx_ps2.c6
-rw-r--r--drivers/input/tablet/gtco.c2
-rw-r--r--drivers/input/tablet/wacom.h5
-rw-r--r--drivers/input/tablet/wacom_sys.c70
-rw-r--r--drivers/input/tablet/wacom_wac.c408
-rw-r--r--drivers/input/tablet/wacom_wac.h17
-rw-r--r--drivers/input/touchscreen/Kconfig6
-rw-r--r--drivers/input/touchscreen/ads7846.c28
-rw-r--r--drivers/input/touchscreen/elo.c225
-rw-r--r--drivers/input/touchscreen/mainstone-wm97xx.c3
-rw-r--r--drivers/input/touchscreen/s3c2410_ts.c31
-rw-r--r--drivers/input/touchscreen/tsc2007.c2
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c317
-rw-r--r--drivers/input/touchscreen/zylonite-wm97xx.c3
-rw-r--r--drivers/input/xen-kbdfront.c2
-rw-r--r--drivers/macintosh/Kconfig7
-rw-r--r--drivers/macintosh/mac_hid.c266
-rw-r--r--drivers/md/linear.c2
-rw-r--r--drivers/md/multipath.c4
-rw-r--r--drivers/md/raid0.c4
-rw-r--r--drivers/md/raid1.c4
-rw-r--r--drivers/md/raid10.c4
-rw-r--r--drivers/md/raid5.c2
-rw-r--r--drivers/memstick/core/mspro_block.c5
-rw-r--r--drivers/message/i2o/i2o_block.c5
-rw-r--r--drivers/mfd/Kconfig2
-rw-r--r--drivers/mfd/twl-core.c18
-rw-r--r--drivers/mmc/card/queue.c10
-rw-r--r--drivers/mmc/host/mmci.c41
-rw-r--r--drivers/mmc/host/omap_hsmmc.c400
-rw-r--r--drivers/mtd/maps/Kconfig9
-rw-r--r--drivers/mtd/maps/Makefile1
-rw-r--r--drivers/mtd/maps/omap_nor.c188
-rw-r--r--drivers/mtd/nand/omap2.c35
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/arm/ks8695net.c2
-rw-r--r--drivers/net/benet/be.h5
-rw-r--r--drivers/net/benet/be_cmds.c6
-rw-r--r--drivers/net/benet/be_hw.h5
-rw-r--r--drivers/net/benet/be_main.c25
-rw-r--r--drivers/net/can/bfin_can.c3
-rw-r--r--drivers/net/can/usb/ems_usb.c4
-rw-r--r--drivers/net/cassini.c2
-rw-r--r--drivers/net/cpmac.c14
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c1
-rw-r--r--drivers/net/davinci_emac.c57
-rw-r--r--drivers/net/e1000e/defines.h2
-rw-r--r--drivers/net/e1000e/ich8lan.c10
-rw-r--r--drivers/net/gianfar.c5
-rw-r--r--drivers/net/irda/irda-usb.c4
-rw-r--r--drivers/net/qlcnic/qlcnic.h13
-rw-r--r--drivers/net/qlcnic/qlcnic_ethtool.c17
-rw-r--r--drivers/net/qlcnic/qlcnic_hw.c32
-rw-r--r--drivers/net/qlcnic/qlcnic_init.c156
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c5
-rw-r--r--drivers/net/r8169.c4
-rw-r--r--drivers/net/s2io.c6
-rw-r--r--drivers/net/smc911x.h4
-rw-r--r--drivers/net/smc91x.h14
-rw-r--r--drivers/net/typhoon.c6
-rw-r--r--drivers/net/usb/pegasus.h6
-rw-r--r--drivers/net/wireless/ath/ar9170/usb.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c44
-rw-r--r--drivers/net/wireless/ath/ath5k/reg.h1
-rw-r--r--drivers/net/wireless/ath/ath5k/reset.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c21
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c19
-rw-r--r--drivers/net/wireless/ipw2x00/libipw.h2
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_module.c37
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c55
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c49
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c50
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c4
-rw-r--r--drivers/net/wireless/libertas/cfg.c8
-rw-r--r--drivers/net/wireless/libertas/dev.h1
-rw-r--r--drivers/net/wireless/mwl8k.c1
-rw-r--r--drivers/net/wireless/p54/p54usb.c1
-rw-r--r--drivers/net/wireless/rndis_wlan.c66
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c5
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00soc.h2
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_debugfs.c3
-rw-r--r--drivers/pci/pci-acpi.c2
-rw-r--r--drivers/pci/setup-bus.c12
-rw-r--r--drivers/platform/x86/toshiba_bluetooth.c4
-rw-r--r--drivers/platform/x86/wmi.c4
-rw-r--r--drivers/rtc/rtc-pl031.c365
-rw-r--r--drivers/s390/block/dasd.c5
-rw-r--r--drivers/s390/char/tape_block.c5
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.c4
-rw-r--r--drivers/scsi/ipr.c2
-rw-r--r--drivers/scsi/pmcraid.c2
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_lib.c6
-rw-r--r--drivers/scsi/scsi_scan.c2
-rw-r--r--drivers/scsi/sg.c6
-rw-r--r--drivers/scsi/st.c3
-rw-r--r--drivers/serial/amba-pl011.c19
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/spi/amba-pl022.c18
-rw-r--r--drivers/spi/omap2_mcspi.c2
-rw-r--r--drivers/staging/hv/blkvsc_drv.c5
-rw-r--r--drivers/staging/phison/phison.c2
-rw-r--r--drivers/usb/Kconfig2
-rw-r--r--drivers/usb/gadget/f_audio.c6
-rw-r--r--drivers/usb/gadget/gmidi.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c2
-rw-r--r--drivers/usb/musb/Kconfig6
-rw-r--r--drivers/usb/musb/musb_core.c2
-rw-r--r--drivers/usb/musb/musb_core.h2
-rw-r--r--drivers/usb/storage/scsiglue.c6
-rw-r--r--drivers/video/omap/lcd_ams_delta.c93
-rw-r--r--drivers/video/omap/omapfb_main.c7
-rw-r--r--drivers/video/omap2/displays/Kconfig18
-rw-r--r--drivers/video/omap2/displays/Makefile3
-rw-r--r--drivers/video/omap2/displays/panel-generic.c56
-rw-r--r--drivers/video/omap2/displays/panel-sharp-lq043t1dg01.c159
-rw-r--r--drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c77
-rw-r--r--drivers/video/omap2/displays/panel-taal.c253
-rw-r--r--drivers/video/omap2/displays/panel-toppoly-tdo35s.c154
-rw-r--r--drivers/video/omap2/displays/panel-tpo-td043mtea1.c528
-rw-r--r--drivers/video/omap2/dss/Kconfig26
-rw-r--r--drivers/video/omap2/dss/core.c117
-rw-r--r--drivers/video/omap2/dss/dispc.c42
-rw-r--r--drivers/video/omap2/dss/display.c119
-rw-r--r--drivers/video/omap2/dss/dpi.c144
-rw-r--r--drivers/video/omap2/dss/dsi.c1031
-rw-r--r--drivers/video/omap2/dss/dss.c42
-rw-r--r--drivers/video/omap2/dss/dss.h23
-rw-r--r--drivers/video/omap2/dss/manager.c48
-rw-r--r--drivers/video/omap2/dss/overlay.c2
-rw-r--r--drivers/video/omap2/dss/rfbi.c321
-rw-r--r--drivers/video/omap2/dss/sdi.c115
-rw-r--r--drivers/video/omap2/dss/venc.c296
-rw-r--r--drivers/video/omap2/omapfb/Kconfig11
-rw-r--r--drivers/video/omap2/omapfb/omapfb-ioctl.c68
-rw-r--r--drivers/video/omap2/omapfb/omapfb-main.c133
-rw-r--r--drivers/video/omap2/omapfb/omapfb.h9
-rw-r--r--drivers/video/sunxvr500.c1
-rw-r--r--drivers/virtio/virtio_pci.c3
-rw-r--r--drivers/w1/masters/Kconfig2
-rw-r--r--drivers/watchdog/Kconfig2
-rw-r--r--drivers/watchdog/pnx4008_wdt.c39
406 files changed, 8369 insertions, 5347 deletions
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
index 3b20786cbb0d..3e50c74ed4a1 100644
--- a/drivers/acpi/acpica/accommon.h
+++ b/drivers/acpi/acpica/accommon.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
index a4471e3d3853..33181ad350d5 100644
--- a/drivers/acpi/acpica/acconfig.h
+++ b/drivers/acpi/acpica/acconfig.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index a4fb001d96f1..48faf3eba9fb 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index 6291904be01e..894a0ff2a946 100644
--- a/drivers/acpi/acpica/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 4ced54f7a5d9..3e6ba99e4053 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -133,8 +133,7 @@ acpi_status acpi_ev_initialize_op_regions(void);
133acpi_status 133acpi_status
134acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, 134acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
135 u32 function, 135 u32 function,
136 u32 region_offset, 136 u32 region_offset, u32 bit_width, u64 *value);
137 u32 bit_width, acpi_integer * value);
138 137
139acpi_status 138acpi_status
140acpi_ev_attach_region(union acpi_operand_object *handler_obj, 139acpi_ev_attach_region(union acpi_operand_object *handler_obj,
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 29ba66d5a790..f8dd8f250ac4 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 36192f142fbb..5900f135dc6d 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index 5db9f2916f7c..6df3f8428168 100644
--- a/drivers/acpi/acpica/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -129,18 +129,17 @@ acpi_ex_common_buffer_setup(union acpi_operand_object *obj_desc,
129 129
130acpi_status 130acpi_status
131acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, 131acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
132 acpi_integer mask, 132 u64 mask,
133 acpi_integer field_value, 133 u64 field_value, u32 field_datum_byte_offset);
134 u32 field_datum_byte_offset);
135 134
136void 135void
137acpi_ex_get_buffer_datum(acpi_integer * datum, 136acpi_ex_get_buffer_datum(u64 *datum,
138 void *buffer, 137 void *buffer,
139 u32 buffer_length, 138 u32 buffer_length,
140 u32 byte_granularity, u32 buffer_offset); 139 u32 byte_granularity, u32 buffer_offset);
141 140
142void 141void
143acpi_ex_set_buffer_datum(acpi_integer merged_datum, 142acpi_ex_set_buffer_datum(u64 merged_datum,
144 void *buffer, 143 void *buffer,
145 u32 buffer_length, 144 u32 buffer_length,
146 u32 byte_granularity, u32 buffer_offset); 145 u32 byte_granularity, u32 buffer_offset);
@@ -168,8 +167,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
168 167
169acpi_status 168acpi_status
170acpi_ex_access_region(union acpi_operand_object *obj_desc, 169acpi_ex_access_region(union acpi_operand_object *obj_desc,
171 u32 field_datum_byte_offset, 170 u32 field_datum_byte_offset, u64 *value, u32 read_write);
172 acpi_integer * value, u32 read_write);
173 171
174/* 172/*
175 * exmisc - misc support routines 173 * exmisc - misc support routines
@@ -193,16 +191,14 @@ acpi_ex_do_concatenate(union acpi_operand_object *obj_desc,
193 191
194acpi_status 192acpi_status
195acpi_ex_do_logical_numeric_op(u16 opcode, 193acpi_ex_do_logical_numeric_op(u16 opcode,
196 acpi_integer integer0, 194 u64 integer0, u64 integer1, u8 *logical_result);
197 acpi_integer integer1, u8 * logical_result);
198 195
199acpi_status 196acpi_status
200acpi_ex_do_logical_op(u16 opcode, 197acpi_ex_do_logical_op(u16 opcode,
201 union acpi_operand_object *operand0, 198 union acpi_operand_object *operand0,
202 union acpi_operand_object *operand1, u8 * logical_result); 199 union acpi_operand_object *operand1, u8 *logical_result);
203 200
204acpi_integer 201u64 acpi_ex_do_math_op(u16 opcode, u64 operand0, u64 operand1);
205acpi_ex_do_math_op(u16 opcode, acpi_integer operand0, acpi_integer operand1);
206 202
207acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state); 203acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state);
208 204
@@ -278,7 +274,7 @@ acpi_status
278acpi_ex_system_do_notify_op(union acpi_operand_object *value, 274acpi_ex_system_do_notify_op(union acpi_operand_object *value,
279 union acpi_operand_object *obj_desc); 275 union acpi_operand_object *obj_desc);
280 276
281acpi_status acpi_ex_system_do_suspend(acpi_integer time); 277acpi_status acpi_ex_system_do_suspend(u64 time);
282 278
283acpi_status acpi_ex_system_do_stall(u32 time); 279acpi_status acpi_ex_system_do_stall(u32 time);
284 280
@@ -461,9 +457,9 @@ void acpi_ex_acquire_global_lock(u32 rule);
461 457
462void acpi_ex_release_global_lock(u32 rule); 458void acpi_ex_release_global_lock(u32 rule);
463 459
464void acpi_ex_eisa_id_to_string(char *dest, acpi_integer compressed_id); 460void acpi_ex_eisa_id_to_string(char *dest, u64 compressed_id);
465 461
466void acpi_ex_integer_to_string(char *dest, acpi_integer value); 462void acpi_ex_integer_to_string(char *dest, u64 value);
467 463
468/* 464/*
469 * exregion - default op_region handlers 465 * exregion - default op_region handlers
@@ -472,7 +468,7 @@ acpi_status
472acpi_ex_system_memory_space_handler(u32 function, 468acpi_ex_system_memory_space_handler(u32 function,
473 acpi_physical_address address, 469 acpi_physical_address address,
474 u32 bit_width, 470 u32 bit_width,
475 acpi_integer * value, 471 u64 *value,
476 void *handler_context, 472 void *handler_context,
477 void *region_context); 473 void *region_context);
478 474
@@ -480,35 +476,35 @@ acpi_status
480acpi_ex_system_io_space_handler(u32 function, 476acpi_ex_system_io_space_handler(u32 function,
481 acpi_physical_address address, 477 acpi_physical_address address,
482 u32 bit_width, 478 u32 bit_width,
483 acpi_integer * value, 479 u64 *value,
484 void *handler_context, void *region_context); 480 void *handler_context, void *region_context);
485 481
486acpi_status 482acpi_status
487acpi_ex_pci_config_space_handler(u32 function, 483acpi_ex_pci_config_space_handler(u32 function,
488 acpi_physical_address address, 484 acpi_physical_address address,
489 u32 bit_width, 485 u32 bit_width,
490 acpi_integer * value, 486 u64 *value,
491 void *handler_context, void *region_context); 487 void *handler_context, void *region_context);
492 488
493acpi_status 489acpi_status
494acpi_ex_cmos_space_handler(u32 function, 490acpi_ex_cmos_space_handler(u32 function,
495 acpi_physical_address address, 491 acpi_physical_address address,
496 u32 bit_width, 492 u32 bit_width,
497 acpi_integer * value, 493 u64 *value,
498 void *handler_context, void *region_context); 494 void *handler_context, void *region_context);
499 495
500acpi_status 496acpi_status
501acpi_ex_pci_bar_space_handler(u32 function, 497acpi_ex_pci_bar_space_handler(u32 function,
502 acpi_physical_address address, 498 acpi_physical_address address,
503 u32 bit_width, 499 u32 bit_width,
504 acpi_integer * value, 500 u64 *value,
505 void *handler_context, void *region_context); 501 void *handler_context, void *region_context);
506 502
507acpi_status 503acpi_status
508acpi_ex_embedded_controller_space_handler(u32 function, 504acpi_ex_embedded_controller_space_handler(u32 function,
509 acpi_physical_address address, 505 acpi_physical_address address,
510 u32 bit_width, 506 u32 bit_width,
511 acpi_integer * value, 507 u64 *value,
512 void *handler_context, 508 void *handler_context,
513 void *region_context); 509 void *region_context);
514 510
@@ -516,14 +512,14 @@ acpi_status
516acpi_ex_sm_bus_space_handler(u32 function, 512acpi_ex_sm_bus_space_handler(u32 function,
517 acpi_physical_address address, 513 acpi_physical_address address,
518 u32 bit_width, 514 u32 bit_width,
519 acpi_integer * value, 515 u64 *value,
520 void *handler_context, void *region_context); 516 void *handler_context, void *region_context);
521 517
522acpi_status 518acpi_status
523acpi_ex_data_table_space_handler(u32 function, 519acpi_ex_data_table_space_handler(u32 function,
524 acpi_physical_address address, 520 acpi_physical_address address,
525 u32 bit_width, 521 u32 bit_width,
526 acpi_integer * value, 522 u64 *value,
527 void *handler_context, void *region_context); 523 void *handler_context, void *region_context);
528 524
529#endif /* __INTERP_H__ */ 525#endif /* __INTERP_H__ */
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 13cb80caacde..24b8faa5c395 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -374,6 +374,7 @@ union acpi_predefined_info {
374struct acpi_predefined_data { 374struct acpi_predefined_data {
375 char *pathname; 375 char *pathname;
376 const union acpi_predefined_info *predefined; 376 const union acpi_predefined_info *predefined;
377 union acpi_operand_object *parent_package;
377 u32 flags; 378 u32 flags;
378 u8 node_flags; 379 u8 node_flags;
379}; 380};
@@ -651,8 +652,7 @@ struct acpi_opcode_info {
651}; 652};
652 653
653union acpi_parse_value { 654union acpi_parse_value {
654 acpi_integer integer; /* Integer constant (Up to 64 bits) */ 655 u64 integer; /* Integer constant (Up to 64 bits) */
655 struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */
656 u32 size; /* bytelist or field size */ 656 u32 size; /* bytelist or field size */
657 char *string; /* NULL terminated string */ 657 char *string; /* NULL terminated string */
658 u8 *buffer; /* buffer or string */ 658 u8 *buffer; /* buffer or string */
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 7d9ba6e57554..9894929a2abb 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -272,8 +272,8 @@
272 * MASK_BITS_ABOVE creates a mask starting AT the position and above 272 * MASK_BITS_ABOVE creates a mask starting AT the position and above
273 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position 273 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
274 */ 274 */
275#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position)))) 275#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((u32) (position))))
276#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position))) 276#define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((u32) (position)))
277 277
278/* Bitfields within ACPI registers */ 278/* Bitfields within ACPI registers */
279 279
@@ -414,16 +414,16 @@
414 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \ 414 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \
415 return (_s); }) 415 return (_s); })
416#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ 416#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
417 register acpi_integer _s = (s); \ 417 register u64 _s = (s); \
418 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ 418 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \
419 return (_s); }) 419 return (_s); })
420#define return_UINT8(s) ACPI_DO_WHILE0 ({ \ 420#define return_UINT8(s) ACPI_DO_WHILE0 ({ \
421 register u8 _s = (u8) (s); \ 421 register u8 _s = (u8) (s); \
422 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \ 422 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \
423 return (_s); }) 423 return (_s); })
424#define return_UINT32(s) ACPI_DO_WHILE0 ({ \ 424#define return_UINT32(s) ACPI_DO_WHILE0 ({ \
425 register u32 _s = (u32) (s); \ 425 register u32 _s = (u32) (s); \
426 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \ 426 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \
427 return (_s); }) 427 return (_s); })
428#else /* Use original less-safe macros */ 428#else /* Use original less-safe macros */
429 429
@@ -434,7 +434,7 @@
434 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \ 434 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \
435 return((s)); }) 435 return((s)); })
436#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ 436#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
437 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) (s)); \ 437 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) (s)); \
438 return((s)); }) 438 return((s)); })
439#define return_UINT8(s) return_VALUE(s) 439#define return_UINT8(s) return_VALUE(s)
440#define return_UINT32(s) return_VALUE(s) 440#define return_UINT32(s) return_VALUE(s)
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index 61edb156e8d0..258159cfcdfa 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -286,6 +286,17 @@ acpi_status
286acpi_ns_repair_package_list(struct acpi_predefined_data *data, 286acpi_ns_repair_package_list(struct acpi_predefined_data *data,
287 union acpi_operand_object **obj_desc_ptr); 287 union acpi_operand_object **obj_desc_ptr);
288 288
289acpi_status
290acpi_ns_repair_null_element(struct acpi_predefined_data *data,
291 u32 expected_btypes,
292 u32 package_index,
293 union acpi_operand_object **return_object_ptr);
294
295void
296acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
297 u8 package_type,
298 union acpi_operand_object *obj_desc);
299
289/* 300/*
290 * nsrepair2 - Return object repair for specific 301 * nsrepair2 - Return object repair for specific
291 * predefined methods/objects 302 * predefined methods/objects
@@ -296,11 +307,6 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data,
296 acpi_status validate_status, 307 acpi_status validate_status,
297 union acpi_operand_object **return_object_ptr); 308 union acpi_operand_object **return_object_ptr);
298 309
299void
300acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
301 u8 package_type,
302 union acpi_operand_object *obj_desc);
303
304/* 310/*
305 * nssearch - Namespace searching and entry 311 * nssearch - Namespace searching and entry
306 */ 312 */
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index 07f6e2ea2ee5..cde18ea82656 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -111,7 +111,7 @@ ACPI_OBJECT_COMMON_HEADER};
111 111
112struct acpi_object_integer { 112struct acpi_object_integer {
113 ACPI_OBJECT_COMMON_HEADER u8 fill[3]; /* Prevent warning on some compilers */ 113 ACPI_OBJECT_COMMON_HEADER u8 fill[3]; /* Prevent warning on some compilers */
114 acpi_integer value; 114 u64 value;
115}; 115};
116 116
117/* 117/*
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index dfdf63327885..8c15ff43f42b 100644
--- a/drivers/acpi/acpica/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
index 22881e8ce229..d0bb0fd3e57a 100644
--- a/drivers/acpi/acpica/acparser.h
+++ b/drivers/acpi/acpica/acparser.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 57bdaf6ffab1..97116082cb6c 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
index eef5bd7a59fa..528bcbaf4ce7 100644
--- a/drivers/acpi/acpica/acresrc.h
+++ b/drivers/acpi/acpica/acresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 7980a26bad35..161bc0e3d70a 100644
--- a/drivers/acpi/acpica/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 01c76b8ea7ba..8ff3b741df28 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 3a451a21a3f9..35df755251ce 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -134,7 +134,7 @@ char *acpi_ut_get_region_name(u8 space_id);
134 134
135char *acpi_ut_get_event_name(u32 event_id); 135char *acpi_ut_get_event_name(u32 event_id);
136 136
137char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position); 137char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
138 138
139u8 acpi_ut_valid_object_type(acpi_object_type type); 139u8 acpi_ut_valid_object_type(acpi_object_type type);
140 140
@@ -279,8 +279,7 @@ acpi_ut_status_exit(u32 line_number,
279void 279void
280acpi_ut_value_exit(u32 line_number, 280acpi_ut_value_exit(u32 line_number,
281 const char *function_name, 281 const char *function_name,
282 const char *module_name, 282 const char *module_name, u32 component_id, u64 value);
283 u32 component_id, acpi_integer value);
284 283
285void 284void
286acpi_ut_ptr_exit(u32 line_number, 285acpi_ut_ptr_exit(u32 line_number,
@@ -324,7 +323,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
324acpi_status 323acpi_status
325acpi_ut_evaluate_numeric_object(char *object_name, 324acpi_ut_evaluate_numeric_object(char *object_name,
326 struct acpi_namespace_node *device_node, 325 struct acpi_namespace_node *device_node,
327 acpi_integer *value); 326 u64 *value);
328 327
329acpi_status 328acpi_status
330acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 *status_flags); 329acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 *status_flags);
@@ -437,14 +436,12 @@ void acpi_ut_delete_generic_state(union acpi_generic_state *state);
437 * utmath 436 * utmath
438 */ 437 */
439acpi_status 438acpi_status
440acpi_ut_divide(acpi_integer in_dividend, 439acpi_ut_divide(u64 in_dividend,
441 acpi_integer in_divisor, 440 u64 in_divisor, u64 *out_quotient, u64 *out_remainder);
442 acpi_integer * out_quotient, acpi_integer * out_remainder);
443 441
444acpi_status 442acpi_status
445acpi_ut_short_divide(acpi_integer in_dividend, 443acpi_ut_short_divide(u64 in_dividend,
446 u32 divisor, 444 u32 divisor, u64 *out_quotient, u32 *out_remainder);
447 acpi_integer * out_quotient, u32 * out_remainder);
448 445
449/* 446/*
450 * utmisc 447 * utmisc
@@ -474,8 +471,7 @@ acpi_name acpi_ut_repair_name(char *name);
474 471
475u8 acpi_ut_valid_acpi_char(char character, u32 position); 472u8 acpi_ut_valid_acpi_char(char character, u32 position);
476 473
477acpi_status 474acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer);
478acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
479 475
480void ACPI_INTERNAL_VAR_XFACE 476void ACPI_INTERNAL_VAR_XFACE
481acpi_ut_predefined_warning(const char *module_name, 477acpi_ut_predefined_warning(const char *module_name,
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index 4940249f2524..1f484ba228fc 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 10 * Copyright (C) 2000 - 2010, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
index 7b070e42b7c5..0e5798fcbb19 100644
--- a/drivers/acpi/acpica/amlresrc.h
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index 54a225e56a64..bb13817e0c31 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -220,7 +220,7 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
220 union acpi_parse_object *arg) 220 union acpi_parse_object *arg)
221{ 221{
222 acpi_status status; 222 acpi_status status;
223 acpi_integer position; 223 u64 position;
224 224
225 ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info); 225 ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info);
226 226
@@ -240,8 +240,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
240 switch (arg->common.aml_opcode) { 240 switch (arg->common.aml_opcode) {
241 case AML_INT_RESERVEDFIELD_OP: 241 case AML_INT_RESERVEDFIELD_OP:
242 242
243 position = (acpi_integer) info->field_bit_position 243 position = (u64) info->field_bit_position
244 + (acpi_integer) arg->common.value.size; 244 + (u64) arg->common.value.size;
245 245
246 if (position > ACPI_UINT32_MAX) { 246 if (position > ACPI_UINT32_MAX) {
247 ACPI_ERROR((AE_INFO, 247 ACPI_ERROR((AE_INFO,
@@ -305,8 +305,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
305 305
306 /* Keep track of bit position for the next field */ 306 /* Keep track of bit position for the next field */
307 307
308 position = (acpi_integer) info->field_bit_position 308 position = (u64) info->field_bit_position
309 + (acpi_integer) arg->common.value.size; 309 + (u64) arg->common.value.size;
310 310
311 if (position > ACPI_UINT32_MAX) { 311 if (position > ACPI_UINT32_MAX) {
312 ACPI_ERROR((AE_INFO, 312 ACPI_ERROR((AE_INFO,
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index f23fa0be6fc2..abe140318a74 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index e786f9fd767f..721039233aa7 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index 0ba19f84ad82..cc343b959540 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 9bc1ba076347..891e08bf560b 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -684,7 +684,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
684 684
685 case AML_ONES_OP: 685 case AML_ONES_OP:
686 686
687 obj_desc->integer.value = ACPI_INTEGER_MAX; 687 obj_desc->integer.value = ACPI_UINT64_MAX;
688 688
689 /* Truncate value if we are executing from a 32-bit ACPI table */ 689 /* Truncate value if we are executing from a 32-bit ACPI table */
690 690
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index b79978f7bc71..bf980cadb1e8 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index dfa104102926..306c62ab2e88 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c
index f0280856dc0e..6b76c486d784 100644
--- a/drivers/acpi/acpica/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index b40513dd6a6a..140a9d002959 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswscope.c b/drivers/acpi/acpica/dswscope.c
index 908645e72f03..d1e701709dac 100644
--- a/drivers/acpi/acpica/dswscope.c
+++ b/drivers/acpi/acpica/dswscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c
index e46c821cf572..050df8164165 100644
--- a/drivers/acpi/acpica/dswstate.c
+++ b/drivers/acpi/acpica/dswstate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index cd55c774e882..c1e6f472d435 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 0b453467a5a0..837de669743a 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 3d4c4aca11cd..fef721917eaf 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 8f0fac6c4366..9a3cb7045a32 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 5336d911fbf0..98fd210e87b2 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -329,7 +329,7 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
329 * region_offset - Where in the region to read or write 329 * region_offset - Where in the region to read or write
330 * bit_width - Field width in bits (8, 16, 32, or 64) 330 * bit_width - Field width in bits (8, 16, 32, or 64)
331 * Value - Pointer to in or out value, must be 331 * Value - Pointer to in or out value, must be
332 * full 64-bit acpi_integer 332 * a full 64-bit integer
333 * 333 *
334 * RETURN: Status 334 * RETURN: Status
335 * 335 *
@@ -341,8 +341,7 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
341acpi_status 341acpi_status
342acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, 342acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
343 u32 function, 343 u32 function,
344 u32 region_offset, 344 u32 region_offset, u32 bit_width, u64 *value)
345 u32 bit_width, acpi_integer * value)
346{ 345{
347 acpi_status status; 346 acpi_status status;
348 acpi_adr_space_handler handler; 347 acpi_adr_space_handler handler;
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index ff168052a332..2e3b0334072f 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -168,7 +168,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
168 void *handler_context, void **region_context) 168 void *handler_context, void **region_context)
169{ 169{
170 acpi_status status = AE_OK; 170 acpi_status status = AE_OK;
171 acpi_integer pci_value; 171 u64 pci_value;
172 struct acpi_pci_id *pci_id = *region_context; 172 struct acpi_pci_id *pci_id = *region_context;
173 union acpi_operand_object *handler_obj; 173 union acpi_operand_object *handler_obj;
174 struct acpi_namespace_node *parent_node; 174 struct acpi_namespace_node *parent_node;
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c
index 567b356c85af..8dfbaa96e422 100644
--- a/drivers/acpi/acpica/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 474e2cab603d..b40757955f9b 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 124c157215bf..5ff32c78ea2d 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index c98aa7c2d67c..541cbc1544d5 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 46adfa541cbc..7e8b3bedc376 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -284,7 +284,7 @@ static acpi_status
284acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer) 284acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
285{ 285{
286 acpi_status status; 286 acpi_status status;
287 acpi_integer value; 287 u64 value;
288 u32 region_offset = 0; 288 u32 region_offset = 0;
289 u32 i; 289 u32 i;
290 290
@@ -490,7 +490,11 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
490 490
491 status = acpi_tb_add_table(&table_desc, &table_index); 491 status = acpi_tb_add_table(&table_desc, &table_index);
492 if (ACPI_FAILURE(status)) { 492 if (ACPI_FAILURE(status)) {
493 goto cleanup; 493
494 /* Delete allocated table buffer */
495
496 acpi_tb_delete_table(&table_desc);
497 return_ACPI_STATUS(status);
494 } 498 }
495 499
496 /* 500 /*
@@ -533,13 +537,6 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
533 acpi_gbl_table_handler_context); 537 acpi_gbl_table_handler_context);
534 } 538 }
535 539
536 cleanup:
537 if (ACPI_FAILURE(status)) {
538
539 /* Delete allocated table buffer */
540
541 acpi_tb_delete_table(&table_desc);
542 }
543 return_ACPI_STATUS(status); 540 return_ACPI_STATUS(status);
544} 541}
545 542
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 51d5f224f9fa..bda7aed0404b 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,8 +51,7 @@ ACPI_MODULE_NAME("exconvrt")
51 51
52/* Local prototypes */ 52/* Local prototypes */
53static u32 53static u32
54acpi_ex_convert_to_ascii(acpi_integer integer, 54acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 max_length);
55 u16 base, u8 * string, u8 max_length);
56 55
57/******************************************************************************* 56/*******************************************************************************
58 * 57 *
@@ -75,7 +74,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
75{ 74{
76 union acpi_operand_object *return_desc; 75 union acpi_operand_object *return_desc;
77 u8 *pointer; 76 u8 *pointer;
78 acpi_integer result; 77 u64 result;
79 u32 i; 78 u32 i;
80 u32 count; 79 u32 count;
81 acpi_status status; 80 acpi_status status;
@@ -155,7 +154,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
155 * Little endian is used, meaning that the first byte of the buffer 154 * Little endian is used, meaning that the first byte of the buffer
156 * is the LSB of the integer 155 * is the LSB of the integer
157 */ 156 */
158 result |= (((acpi_integer) pointer[i]) << (i * 8)); 157 result |= (((u64) pointer[i]) << (i * 8));
159 } 158 }
160 break; 159 break;
161 160
@@ -285,10 +284,9 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
285 ******************************************************************************/ 284 ******************************************************************************/
286 285
287static u32 286static u32
288acpi_ex_convert_to_ascii(acpi_integer integer, 287acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
289 u16 base, u8 * string, u8 data_width)
290{ 288{
291 acpi_integer digit; 289 u64 digit;
292 u32 i; 290 u32 i;
293 u32 j; 291 u32 j;
294 u32 k = 0; 292 u32 k = 0;
@@ -531,10 +529,9 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
531 * (separated by commas or spaces) 529 * (separated by commas or spaces)
532 */ 530 */
533 for (i = 0; i < obj_desc->buffer.length; i++) { 531 for (i = 0; i < obj_desc->buffer.length; i++) {
534 new_buf += acpi_ex_convert_to_ascii((acpi_integer) 532 new_buf += acpi_ex_convert_to_ascii((u64) obj_desc->
535 obj_desc->buffer. 533 buffer.pointer[i],
536 pointer[i], base, 534 base, new_buf, 1);
537 new_buf, 1);
538 *new_buf++ = separator; /* each separated by a comma or space */ 535 *new_buf++ = separator; /* each separated by a comma or space */
539 } 536 }
540 537
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index 02b25d233d99..0aa57d938698 100644
--- a/drivers/acpi/acpica/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index de3446372ddc..d39d438ba1e3 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index 1588a2d660e7..6c79fecbee42 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -130,7 +130,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
130 /* Call the region handler for the read */ 130 /* Call the region handler for the read */
131 131
132 status = acpi_ex_access_region(obj_desc, 0, 132 status = acpi_ex_access_region(obj_desc, 0,
133 ACPI_CAST_PTR(acpi_integer, 133 ACPI_CAST_PTR(u64,
134 buffer_desc-> 134 buffer_desc->
135 buffer.pointer), 135 buffer.pointer),
136 function); 136 function);
@@ -141,7 +141,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
141 /* 141 /*
142 * Allocate a buffer for the contents of the field. 142 * Allocate a buffer for the contents of the field.
143 * 143 *
144 * If the field is larger than the size of an acpi_integer, create 144 * If the field is larger than the current integer width, create
145 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows 145 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
146 * the use of arithmetic operators on the returned value if the 146 * the use of arithmetic operators on the returned value if the
147 * field size is equal or smaller than an Integer. 147 * field size is equal or smaller than an Integer.
@@ -306,8 +306,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
306 * same buffer) 306 * same buffer)
307 */ 307 */
308 status = acpi_ex_access_region(obj_desc, 0, 308 status = acpi_ex_access_region(obj_desc, 0,
309 (acpi_integer *) buffer, 309 (u64 *) buffer, function);
310 function);
311 acpi_ex_release_global_lock(obj_desc->common_field.field_flags); 310 acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
312 311
313 *result_desc = buffer_desc; 312 *result_desc = buffer_desc;
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index d7b3b418fb45..f68a216168be 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -55,11 +55,10 @@ ACPI_MODULE_NAME("exfldio")
55static acpi_status 55static acpi_status
56acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, 56acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
57 u32 field_datum_byte_offset, 57 u32 field_datum_byte_offset,
58 acpi_integer * value, u32 read_write); 58 u64 *value, u32 read_write);
59 59
60static u8 60static u8
61acpi_ex_register_overflow(union acpi_operand_object *obj_desc, 61acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value);
62 acpi_integer value);
63 62
64static acpi_status 63static acpi_status
65acpi_ex_setup_region(union acpi_operand_object *obj_desc, 64acpi_ex_setup_region(union acpi_operand_object *obj_desc,
@@ -212,7 +211,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
212 * field_datum_byte_offset - Byte offset of this datum within the 211 * field_datum_byte_offset - Byte offset of this datum within the
213 * parent field 212 * parent field
214 * Value - Where to store value (must at least 213 * Value - Where to store value (must at least
215 * the size of acpi_integer) 214 * 64 bits)
216 * Function - Read or Write flag plus other region- 215 * Function - Read or Write flag plus other region-
217 * dependent flags 216 * dependent flags
218 * 217 *
@@ -224,8 +223,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
224 223
225acpi_status 224acpi_status
226acpi_ex_access_region(union acpi_operand_object *obj_desc, 225acpi_ex_access_region(union acpi_operand_object *obj_desc,
227 u32 field_datum_byte_offset, 226 u32 field_datum_byte_offset, u64 *value, u32 function)
228 acpi_integer * value, u32 function)
229{ 227{
230 acpi_status status; 228 acpi_status status;
231 union acpi_operand_object *rgn_desc; 229 union acpi_operand_object *rgn_desc;
@@ -317,8 +315,7 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
317 ******************************************************************************/ 315 ******************************************************************************/
318 316
319static u8 317static u8
320acpi_ex_register_overflow(union acpi_operand_object *obj_desc, 318acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)
321 acpi_integer value)
322{ 319{
323 320
324 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) { 321 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
@@ -329,7 +326,7 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
329 return (FALSE); 326 return (FALSE);
330 } 327 }
331 328
332 if (value >= ((acpi_integer) 1 << obj_desc->common_field.bit_length)) { 329 if (value >= ((u64) 1 << obj_desc->common_field.bit_length)) {
333 /* 330 /*
334 * The Value is larger than the maximum value that can fit into 331 * The Value is larger than the maximum value that can fit into
335 * the register. 332 * the register.
@@ -362,11 +359,10 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
362 359
363static acpi_status 360static acpi_status
364acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, 361acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
365 u32 field_datum_byte_offset, 362 u32 field_datum_byte_offset, u64 *value, u32 read_write)
366 acpi_integer * value, u32 read_write)
367{ 363{
368 acpi_status status; 364 acpi_status status;
369 acpi_integer local_value; 365 u64 local_value;
370 366
371 ACPI_FUNCTION_TRACE_U32(ex_field_datum_io, field_datum_byte_offset); 367 ACPI_FUNCTION_TRACE_U32(ex_field_datum_io, field_datum_byte_offset);
372 368
@@ -439,8 +435,8 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
439 * the register 435 * the register
440 */ 436 */
441 if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj, 437 if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj,
442 (acpi_integer) obj_desc-> 438 (u64) obj_desc->bank_field.
443 bank_field.value)) { 439 value)) {
444 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT); 440 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
445 } 441 }
446 442
@@ -481,8 +477,8 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
481 * the register 477 * the register
482 */ 478 */
483 if (acpi_ex_register_overflow(obj_desc->index_field.index_obj, 479 if (acpi_ex_register_overflow(obj_desc->index_field.index_obj,
484 (acpi_integer) obj_desc-> 480 (u64) obj_desc->index_field.
485 index_field.value)) { 481 value)) {
486 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT); 482 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
487 } 483 }
488 484
@@ -512,7 +508,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
512 status = 508 status =
513 acpi_ex_extract_from_field(obj_desc->index_field. 509 acpi_ex_extract_from_field(obj_desc->index_field.
514 data_obj, value, 510 data_obj, value,
515 sizeof(acpi_integer)); 511 sizeof(u64));
516 } else { 512 } else {
517 /* Write the datum to the data_register */ 513 /* Write the datum to the data_register */
518 514
@@ -523,7 +519,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
523 status = 519 status =
524 acpi_ex_insert_into_field(obj_desc->index_field. 520 acpi_ex_insert_into_field(obj_desc->index_field.
525 data_obj, value, 521 data_obj, value,
526 sizeof(acpi_integer)); 522 sizeof(u64));
527 } 523 }
528 break; 524 break;
529 525
@@ -571,13 +567,12 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
571 567
572acpi_status 568acpi_status
573acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, 569acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
574 acpi_integer mask, 570 u64 mask,
575 acpi_integer field_value, 571 u64 field_value, u32 field_datum_byte_offset)
576 u32 field_datum_byte_offset)
577{ 572{
578 acpi_status status = AE_OK; 573 acpi_status status = AE_OK;
579 acpi_integer merged_value; 574 u64 merged_value;
580 acpi_integer current_value; 575 u64 current_value;
581 576
582 ACPI_FUNCTION_TRACE_U32(ex_write_with_update_rule, mask); 577 ACPI_FUNCTION_TRACE_U32(ex_write_with_update_rule, mask);
583 578
@@ -587,7 +582,7 @@ acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
587 582
588 /* If the mask is all ones, we don't need to worry about the update rule */ 583 /* If the mask is all ones, we don't need to worry about the update rule */
589 584
590 if (mask != ACPI_INTEGER_MAX) { 585 if (mask != ACPI_UINT64_MAX) {
591 586
592 /* Decode the update rule */ 587 /* Decode the update rule */
593 588
@@ -678,8 +673,8 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
678 void *buffer, u32 buffer_length) 673 void *buffer, u32 buffer_length)
679{ 674{
680 acpi_status status; 675 acpi_status status;
681 acpi_integer raw_datum; 676 u64 raw_datum;
682 acpi_integer merged_datum; 677 u64 merged_datum;
683 u32 field_offset = 0; 678 u32 field_offset = 0;
684 u32 buffer_offset = 0; 679 u32 buffer_offset = 0;
685 u32 buffer_tail_bits; 680 u32 buffer_tail_bits;
@@ -804,10 +799,10 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
804 void *buffer, u32 buffer_length) 799 void *buffer, u32 buffer_length)
805{ 800{
806 acpi_status status; 801 acpi_status status;
807 acpi_integer mask; 802 u64 mask;
808 acpi_integer width_mask; 803 u64 width_mask;
809 acpi_integer merged_datum; 804 u64 merged_datum;
810 acpi_integer raw_datum = 0; 805 u64 raw_datum = 0;
811 u32 field_offset = 0; 806 u32 field_offset = 0;
812 u32 buffer_offset = 0; 807 u32 buffer_offset = 0;
813 u32 buffer_tail_bits; 808 u32 buffer_tail_bits;
@@ -855,7 +850,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
855 * shift operator 850 * shift operator
856 */ 851 */
857 if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) { 852 if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) {
858 width_mask = ACPI_INTEGER_MAX; 853 width_mask = ACPI_UINT64_MAX;
859 } else { 854 } else {
860 width_mask = 855 width_mask =
861 ACPI_MASK_BITS_ABOVE(obj_desc->common_field. 856 ACPI_MASK_BITS_ABOVE(obj_desc->common_field.
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c
index 998eac329937..c5bb1eeed2df 100644
--- a/drivers/acpi/acpica/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -409,8 +409,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
409 * 409 *
410 ******************************************************************************/ 410 ******************************************************************************/
411 411
412acpi_integer 412u64 acpi_ex_do_math_op(u16 opcode, u64 integer0, u64 integer1)
413acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1)
414{ 413{
415 414
416 ACPI_FUNCTION_ENTRY(); 415 ACPI_FUNCTION_ENTRY();
@@ -498,8 +497,7 @@ acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1)
498 497
499acpi_status 498acpi_status
500acpi_ex_do_logical_numeric_op(u16 opcode, 499acpi_ex_do_logical_numeric_op(u16 opcode,
501 acpi_integer integer0, 500 u64 integer0, u64 integer1, u8 *logical_result)
502 acpi_integer integer1, u8 * logical_result)
503{ 501{
504 acpi_status status = AE_OK; 502 acpi_status status = AE_OK;
505 u8 local_result = FALSE; 503 u8 local_result = FALSE;
@@ -564,8 +562,8 @@ acpi_ex_do_logical_op(u16 opcode,
564 union acpi_operand_object *operand1, u8 * logical_result) 562 union acpi_operand_object *operand1, u8 * logical_result)
565{ 563{
566 union acpi_operand_object *local_operand1 = operand1; 564 union acpi_operand_object *local_operand1 = operand1;
567 acpi_integer integer0; 565 u64 integer0;
568 acpi_integer integer1; 566 u64 integer1;
569 u32 length0; 567 u32 length0;
570 u32 length1; 568 u32 length1;
571 acpi_status status = AE_OK; 569 acpi_status status = AE_OK;
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index 3c456bd575d0..cc8a10268f68 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c
index ffdae122d94a..679f308c5a89 100644
--- a/drivers/acpi/acpica/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index 752fe48b2d20..99adbab5acbf 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -261,8 +261,8 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
261 union acpi_operand_object *return_desc2 = NULL; 261 union acpi_operand_object *return_desc2 = NULL;
262 u32 temp32; 262 u32 temp32;
263 u32 i; 263 u32 i;
264 acpi_integer power_of_ten; 264 u64 power_of_ten;
265 acpi_integer digit; 265 u64 digit;
266 266
267 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_1R, 267 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_1R,
268 acpi_ps_get_opcode_name(walk_state->opcode)); 268 acpi_ps_get_opcode_name(walk_state->opcode));
@@ -362,7 +362,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
362 /* Sum the digit into the result with the current power of 10 */ 362 /* Sum the digit into the result with the current power of 10 */
363 363
364 return_desc->integer.value += 364 return_desc->integer.value +=
365 (((acpi_integer) temp32) * power_of_ten); 365 (((u64) temp32) * power_of_ten);
366 366
367 /* Shift to next BCD digit */ 367 /* Shift to next BCD digit */
368 368
@@ -392,7 +392,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
392 * remainder from above 392 * remainder from above
393 */ 393 */
394 return_desc->integer.value |= 394 return_desc->integer.value |=
395 (((acpi_integer) temp32) << ACPI_MUL_4(i)); 395 (((u64) temp32) << ACPI_MUL_4(i));
396 } 396 }
397 397
398 /* Overflow if there is any data left in Digit */ 398 /* Overflow if there is any data left in Digit */
@@ -439,7 +439,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
439 439
440 /* The object exists in the namespace, return TRUE */ 440 /* The object exists in the namespace, return TRUE */
441 441
442 return_desc->integer.value = ACPI_INTEGER_MAX; 442 return_desc->integer.value = ACPI_UINT64_MAX;
443 goto cleanup; 443 goto cleanup;
444 444
445 default: 445 default:
@@ -589,7 +589,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
589 union acpi_operand_object *return_desc = NULL; 589 union acpi_operand_object *return_desc = NULL;
590 acpi_status status = AE_OK; 590 acpi_status status = AE_OK;
591 u32 type; 591 u32 type;
592 acpi_integer value; 592 u64 value;
593 593
594 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_1R, 594 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_1R,
595 acpi_ps_get_opcode_name(walk_state->opcode)); 595 acpi_ps_get_opcode_name(walk_state->opcode));
@@ -610,7 +610,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
610 * return_desc->Integer.Value is initially == 0 (FALSE) from above. 610 * return_desc->Integer.Value is initially == 0 (FALSE) from above.
611 */ 611 */
612 if (!operand[0]->integer.value) { 612 if (!operand[0]->integer.value) {
613 return_desc->integer.value = ACPI_INTEGER_MAX; 613 return_desc->integer.value = ACPI_UINT64_MAX;
614 } 614 }
615 break; 615 break;
616 616
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index 85d95c92dfd3..22841bbbe63c 100644
--- a/drivers/acpi/acpica/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -282,7 +282,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
282{ 282{
283 union acpi_operand_object **operand = &walk_state->operands[0]; 283 union acpi_operand_object **operand = &walk_state->operands[0];
284 union acpi_operand_object *return_desc = NULL; 284 union acpi_operand_object *return_desc = NULL;
285 acpi_integer index; 285 u64 index;
286 acpi_status status = AE_OK; 286 acpi_status status = AE_OK;
287 acpi_size length; 287 acpi_size length;
288 288
@@ -584,7 +584,7 @@ acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state)
584 * Default is FALSE (zero) 584 * Default is FALSE (zero)
585 */ 585 */
586 if (logical_result) { 586 if (logical_result) {
587 return_desc->integer.value = ACPI_INTEGER_MAX; 587 return_desc->integer.value = ACPI_UINT64_MAX;
588 } 588 }
589 589
590 cleanup: 590 cleanup:
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index 253f9e122584..8bb1012ef44e 100644
--- a/drivers/acpi/acpica/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -148,7 +148,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
148 union acpi_operand_object *return_desc = NULL; 148 union acpi_operand_object *return_desc = NULL;
149 char *buffer = NULL; 149 char *buffer = NULL;
150 acpi_status status = AE_OK; 150 acpi_status status = AE_OK;
151 acpi_integer index; 151 u64 index;
152 acpi_size length; 152 acpi_size length;
153 153
154 ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_1T_1R, 154 ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_1T_1R,
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index 295542e6bd51..f256b6a25f2e 100644
--- a/drivers/acpi/acpica/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -218,7 +218,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
218 union acpi_operand_object **operand = &walk_state->operands[0]; 218 union acpi_operand_object **operand = &walk_state->operands[0];
219 union acpi_operand_object *return_desc = NULL; 219 union acpi_operand_object *return_desc = NULL;
220 acpi_status status = AE_OK; 220 acpi_status status = AE_OK;
221 acpi_integer index; 221 u64 index;
222 union acpi_operand_object *this_element; 222 union acpi_operand_object *this_element;
223 223
224 ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R, 224 ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R,
@@ -253,9 +253,9 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
253 } 253 }
254 254
255 /* Create an integer for the return value */ 255 /* Create an integer for the return value */
256 /* Default return value is ACPI_INTEGER_MAX if no match found */ 256 /* Default return value is ACPI_UINT64_MAX if no match found */
257 257
258 return_desc = acpi_ut_create_integer_object(ACPI_INTEGER_MAX); 258 return_desc = acpi_ut_create_integer_object(ACPI_UINT64_MAX);
259 if (!return_desc) { 259 if (!return_desc) {
260 status = AE_NO_MEMORY; 260 status = AE_NO_MEMORY;
261 goto cleanup; 261 goto cleanup;
@@ -270,7 +270,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
270 * 270 *
271 * Upon finding a match, the loop will terminate via "break" at 271 * Upon finding a match, the loop will terminate via "break" at
272 * the bottom. If it terminates "normally", match_value will be 272 * the bottom. If it terminates "normally", match_value will be
273 * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no 273 * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
274 * match was found. 274 * match was found.
275 */ 275 */
276 for (; index < operand[0]->package.count; index++) { 276 for (; index < operand[0]->package.count; index++) {
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index 52fec07064f0..edf62bf5b266 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 2bd83ac57c3a..486b2e5661b6 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,7 @@ acpi_status
70acpi_ex_system_memory_space_handler(u32 function, 70acpi_ex_system_memory_space_handler(u32 function,
71 acpi_physical_address address, 71 acpi_physical_address address,
72 u32 bit_width, 72 u32 bit_width,
73 acpi_integer * value, 73 u64 *value,
74 void *handler_context, void *region_context) 74 void *handler_context, void *region_context)
75{ 75{
76 acpi_status status = AE_OK; 76 acpi_status status = AE_OK;
@@ -115,8 +115,7 @@ acpi_ex_system_memory_space_handler(u32 function,
115 * Hardware does not support non-aligned data transfers, we must verify 115 * Hardware does not support non-aligned data transfers, we must verify
116 * the request. 116 * the request.
117 */ 117 */
118 (void)acpi_ut_short_divide((acpi_integer) address, length, NULL, 118 (void)acpi_ut_short_divide((u64) address, length, NULL, &remainder);
119 &remainder);
120 if (remainder != 0) { 119 if (remainder != 0) {
121 return_ACPI_STATUS(AE_AML_ALIGNMENT); 120 return_ACPI_STATUS(AE_AML_ALIGNMENT);
122 } 121 }
@@ -128,10 +127,9 @@ acpi_ex_system_memory_space_handler(u32 function,
128 * 2) Address beyond the current mapping? 127 * 2) Address beyond the current mapping?
129 */ 128 */
130 if ((address < mem_info->mapped_physical_address) || 129 if ((address < mem_info->mapped_physical_address) ||
131 (((acpi_integer) address + length) > ((acpi_integer) 130 (((u64) address + length) > ((u64)
132 mem_info-> 131 mem_info->mapped_physical_address +
133 mapped_physical_address + 132 mem_info->mapped_length))) {
134 mem_info->mapped_length))) {
135 /* 133 /*
136 * The request cannot be resolved by the current memory mapping; 134 * The request cannot be resolved by the current memory mapping;
137 * Delete the existing mapping and create a new one. 135 * Delete the existing mapping and create a new one.
@@ -193,8 +191,7 @@ acpi_ex_system_memory_space_handler(u32 function,
193 * access 191 * access
194 */ 192 */
195 logical_addr_ptr = mem_info->mapped_logical_address + 193 logical_addr_ptr = mem_info->mapped_logical_address +
196 ((acpi_integer) address - 194 ((u64) address - (u64) mem_info->mapped_physical_address);
197 (acpi_integer) mem_info->mapped_physical_address);
198 195
199 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 196 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
200 "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", 197 "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n",
@@ -215,19 +212,19 @@ acpi_ex_system_memory_space_handler(u32 function,
215 *value = 0; 212 *value = 0;
216 switch (bit_width) { 213 switch (bit_width) {
217 case 8: 214 case 8:
218 *value = (acpi_integer) ACPI_GET8(logical_addr_ptr); 215 *value = (u64) ACPI_GET8(logical_addr_ptr);
219 break; 216 break;
220 217
221 case 16: 218 case 16:
222 *value = (acpi_integer) ACPI_GET16(logical_addr_ptr); 219 *value = (u64) ACPI_GET16(logical_addr_ptr);
223 break; 220 break;
224 221
225 case 32: 222 case 32:
226 *value = (acpi_integer) ACPI_GET32(logical_addr_ptr); 223 *value = (u64) ACPI_GET32(logical_addr_ptr);
227 break; 224 break;
228 225
229 case 64: 226 case 64:
230 *value = (acpi_integer) ACPI_GET64(logical_addr_ptr); 227 *value = (u64) ACPI_GET64(logical_addr_ptr);
231 break; 228 break;
232 229
233 default: 230 default:
@@ -291,7 +288,7 @@ acpi_status
291acpi_ex_system_io_space_handler(u32 function, 288acpi_ex_system_io_space_handler(u32 function,
292 acpi_physical_address address, 289 acpi_physical_address address,
293 u32 bit_width, 290 u32 bit_width,
294 acpi_integer * value, 291 u64 *value,
295 void *handler_context, void *region_context) 292 void *handler_context, void *region_context)
296{ 293{
297 acpi_status status = AE_OK; 294 acpi_status status = AE_OK;
@@ -350,7 +347,7 @@ acpi_status
350acpi_ex_pci_config_space_handler(u32 function, 347acpi_ex_pci_config_space_handler(u32 function,
351 acpi_physical_address address, 348 acpi_physical_address address,
352 u32 bit_width, 349 u32 bit_width,
353 acpi_integer * value, 350 u64 *value,
354 void *handler_context, void *region_context) 351 void *handler_context, void *region_context)
355{ 352{
356 acpi_status status = AE_OK; 353 acpi_status status = AE_OK;
@@ -425,7 +422,7 @@ acpi_status
425acpi_ex_cmos_space_handler(u32 function, 422acpi_ex_cmos_space_handler(u32 function,
426 acpi_physical_address address, 423 acpi_physical_address address,
427 u32 bit_width, 424 u32 bit_width,
428 acpi_integer * value, 425 u64 *value,
429 void *handler_context, void *region_context) 426 void *handler_context, void *region_context)
430{ 427{
431 acpi_status status = AE_OK; 428 acpi_status status = AE_OK;
@@ -457,7 +454,7 @@ acpi_status
457acpi_ex_pci_bar_space_handler(u32 function, 454acpi_ex_pci_bar_space_handler(u32 function,
458 acpi_physical_address address, 455 acpi_physical_address address,
459 u32 bit_width, 456 u32 bit_width,
460 acpi_integer * value, 457 u64 *value,
461 void *handler_context, void *region_context) 458 void *handler_context, void *region_context)
462{ 459{
463 acpi_status status = AE_OK; 460 acpi_status status = AE_OK;
@@ -489,7 +486,7 @@ acpi_status
489acpi_ex_data_table_space_handler(u32 function, 486acpi_ex_data_table_space_handler(u32 function,
490 acpi_physical_address address, 487 acpi_physical_address address,
491 u32 bit_width, 488 u32 bit_width,
492 acpi_integer * value, 489 u64 *value,
493 void *handler_context, void *region_context) 490 void *handler_context, void *region_context)
494{ 491{
495 ACPI_FUNCTION_TRACE(ex_data_table_space_handler); 492 ACPI_FUNCTION_TRACE(ex_data_table_space_handler);
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 607958ff467c..fdc1b27999ef 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index c93b54ce7f78..fdd6a7079b97 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c
index 5c729a9e9131..c5ecd615f145 100644
--- a/drivers/acpi/acpica/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index 6efd07a4f779..702b9ecfd44b 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c
index 608e838d537e..d4af684620ca 100644
--- a/drivers/acpi/acpica/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 10 * Copyright (C) 2000 - 2010, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c
index 257706e7734f..e972b667b09b 100644
--- a/drivers/acpi/acpica/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exsystem.c b/drivers/acpi/acpica/exsystem.c
index 3d00b9357233..e11b6cb42a57 100644
--- a/drivers/acpi/acpica/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -193,7 +193,7 @@ acpi_status acpi_ex_system_do_stall(u32 how_long)
193 * 193 *
194 ******************************************************************************/ 194 ******************************************************************************/
195 195
196acpi_status acpi_ex_system_do_suspend(acpi_integer how_long) 196acpi_status acpi_ex_system_do_suspend(u64 how_long)
197{ 197{
198 ACPI_FUNCTION_ENTRY(); 198 ACPI_FUNCTION_ENTRY();
199 199
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index 7d41f99f7052..74c24d517f81 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -67,7 +67,7 @@
67ACPI_MODULE_NAME("exutils") 67ACPI_MODULE_NAME("exutils")
68 68
69/* Local prototypes */ 69/* Local prototypes */
70static u32 acpi_ex_digits_needed(acpi_integer value, u32 base); 70static u32 acpi_ex_digits_needed(u64 value, u32 base);
71 71
72#ifndef ACPI_NO_METHOD_EXECUTION 72#ifndef ACPI_NO_METHOD_EXECUTION
73/******************************************************************************* 73/*******************************************************************************
@@ -230,7 +230,7 @@ void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
230 * We are running a method that exists in a 32-bit ACPI table. 230 * We are running a method that exists in a 32-bit ACPI table.
231 * Truncate the value to 32 bits by zeroing out the upper 32-bit field 231 * Truncate the value to 32 bits by zeroing out the upper 32-bit field
232 */ 232 */
233 obj_desc->integer.value &= (acpi_integer) ACPI_UINT32_MAX; 233 obj_desc->integer.value &= (u64) ACPI_UINT32_MAX;
234 } 234 }
235} 235}
236 236
@@ -327,14 +327,14 @@ void acpi_ex_release_global_lock(u32 field_flags)
327 * 327 *
328 ******************************************************************************/ 328 ******************************************************************************/
329 329
330static u32 acpi_ex_digits_needed(acpi_integer value, u32 base) 330static u32 acpi_ex_digits_needed(u64 value, u32 base)
331{ 331{
332 u32 num_digits; 332 u32 num_digits;
333 acpi_integer current_value; 333 u64 current_value;
334 334
335 ACPI_FUNCTION_TRACE(ex_digits_needed); 335 ACPI_FUNCTION_TRACE(ex_digits_needed);
336 336
337 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ 337 /* u64 is unsigned, so we don't worry about a '-' prefix */
338 338
339 if (value == 0) { 339 if (value == 0) {
340 return_UINT32(1); 340 return_UINT32(1);
@@ -370,7 +370,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
370 * 370 *
371 ******************************************************************************/ 371 ******************************************************************************/
372 372
373void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id) 373void acpi_ex_eisa_id_to_string(char *out_string, u64 compressed_id)
374{ 374{
375 u32 swapped_id; 375 u32 swapped_id;
376 376
@@ -394,10 +394,10 @@ void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id)
394 (char)(0x40 + (((unsigned long)swapped_id >> 26) & 0x1F)); 394 (char)(0x40 + (((unsigned long)swapped_id >> 26) & 0x1F));
395 out_string[1] = (char)(0x40 + ((swapped_id >> 21) & 0x1F)); 395 out_string[1] = (char)(0x40 + ((swapped_id >> 21) & 0x1F));
396 out_string[2] = (char)(0x40 + ((swapped_id >> 16) & 0x1F)); 396 out_string[2] = (char)(0x40 + ((swapped_id >> 16) & 0x1F));
397 out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 12); 397 out_string[3] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 12);
398 out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 8); 398 out_string[4] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 8);
399 out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 4); 399 out_string[5] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 4);
400 out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 0); 400 out_string[6] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 0);
401 out_string[7] = 0; 401 out_string[7] = 0;
402} 402}
403 403
@@ -418,7 +418,7 @@ void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id)
418 * 418 *
419 ******************************************************************************/ 419 ******************************************************************************/
420 420
421void acpi_ex_integer_to_string(char *out_string, acpi_integer value) 421void acpi_ex_integer_to_string(char *out_string, u64 value)
422{ 422{
423 u32 count; 423 u32 count;
424 u32 digits_needed; 424 u32 digits_needed;
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index 9af361a191e7..679a112a7d26 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index c28c41b3180b..bd72319a38f0 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -224,7 +224,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
224 224
225 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address); 225 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
226 if (ACPI_FAILURE(status)) { 226 if (ACPI_FAILURE(status)) {
227 goto unlock_and_exit; 227 return (status);
228 } 228 }
229 229
230 if (register_bit & in_byte) { 230 if (register_bit & in_byte) {
@@ -234,9 +234,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
234 /* Set return value */ 234 /* Set return value */
235 235
236 (*event_status) = local_event_status; 236 (*event_status) = local_event_status;
237 237 return (AE_OK);
238 unlock_and_exit:
239 return (status);
240} 238}
241 239
242/****************************************************************************** 240/******************************************************************************
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 15c9ed2be853..ec7fc227b33f 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -7,7 +7,7 @@
7 ******************************************************************************/ 7 ******************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 10 * Copyright (C) 2000 - 2010, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index cc22f9a585b0..5e6d4dbb8024 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index 6b282e85d039..1ef8e0bb250b 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -140,7 +140,7 @@ acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
140{ 140{
141 acpi_status status; 141 acpi_status status;
142 u32 delta_ticks; 142 u32 delta_ticks;
143 acpi_integer quotient; 143 u64 quotient;
144 144
145 ACPI_FUNCTION_TRACE(acpi_get_timer_duration); 145 ACPI_FUNCTION_TRACE(acpi_get_timer_duration);
146 146
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
index ec33f270c5b7..e26c17d4b716 100644
--- a/drivers/acpi/acpica/hwvalid.c
+++ b/drivers/acpi/acpica/hwvalid.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2009, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 647c7b6e6756..50cc3be77724 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index d622ba770000..aa2b80132d0a 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index 8a58a1b85aa0..982269c1fa48 100644
--- a/drivers/acpi/acpica/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index e37836e27e29..0689d36638d9 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 36be7f0e97ec..d2a97921e249 100644
--- a/drivers/acpi/acpica/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index af9fe9103734..f52829cc294b 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 4f8abac231d2..9bd6f050f299 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index a7234e60e985..df18be94fefe 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index 8f9a4875ce26..959372451635 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
index 60f3af08d28c..41a9213dd5af 100644
--- a/drivers/acpi/acpica/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index 662a4bd5b621..27cda52c76bc 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index d34fa59548f7..7096bcda0c72 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -231,6 +231,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
231 * Note: Package may have been newly created by call above. 231 * Note: Package may have been newly created by call above.
232 */ 232 */
233 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) { 233 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) {
234 data->parent_package = *return_object_ptr;
234 status = acpi_ns_check_package(data, return_object_ptr); 235 status = acpi_ns_check_package(data, return_object_ptr);
235 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
236 goto exit; 237 goto exit;
@@ -710,6 +711,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
710 for (i = 0; i < count; i++) { 711 for (i = 0; i < count; i++) {
711 sub_package = *elements; 712 sub_package = *elements;
712 sub_elements = sub_package->package.elements; 713 sub_elements = sub_package->package.elements;
714 data->parent_package = sub_package;
713 715
714 /* Each sub-object must be of type Package */ 716 /* Each sub-object must be of type Package */
715 717
@@ -721,6 +723,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
721 723
722 /* Examine the different types of expected sub-packages */ 724 /* Examine the different types of expected sub-packages */
723 725
726 data->parent_package = sub_package;
724 switch (package->ret_info.type) { 727 switch (package->ret_info.type) {
725 case ACPI_PTYPE2: 728 case ACPI_PTYPE2:
726 case ACPI_PTYPE2_PKG_COUNT: 729 case ACPI_PTYPE2_PKG_COUNT:
@@ -800,7 +803,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
800 803
801 /* 804 /*
802 * First element is the (Integer) count of elements, including 805 * First element is the (Integer) count of elements, including
803 * the count field. 806 * the count field (the ACPI name is num_elements)
804 */ 807 */
805 status = acpi_ns_check_object_type(data, sub_elements, 808 status = acpi_ns_check_object_type(data, sub_elements,
806 ACPI_RTYPE_INTEGER, 809 ACPI_RTYPE_INTEGER,
@@ -822,6 +825,16 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
822 expected_count = package->ret_info.count1; 825 expected_count = package->ret_info.count1;
823 goto package_too_small; 826 goto package_too_small;
824 } 827 }
828 if (expected_count == 0) {
829 /*
830 * Either the num_entries element was originally zero or it was
831 * a NULL element and repaired to an Integer of value zero.
832 * In either case, repair it by setting num_entries to be the
833 * actual size of the subpackage.
834 */
835 expected_count = sub_package->package.count;
836 (*sub_elements)->integer.value = expected_count;
837 }
825 838
826 /* Check the type of each sub-package element */ 839 /* Check the type of each sub-package element */
827 840
@@ -945,10 +958,18 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
945 char type_buffer[48]; /* Room for 5 types */ 958 char type_buffer[48]; /* Room for 5 types */
946 959
947 /* 960 /*
948 * If we get a NULL return_object here, it is a NULL package element, 961 * If we get a NULL return_object here, it is a NULL package element.
949 * and this is always an error. 962 * Since all extraneous NULL package elements were removed earlier by a
963 * call to acpi_ns_remove_null_elements, this is an unexpected NULL element.
964 * We will attempt to repair it.
950 */ 965 */
951 if (!return_object) { 966 if (!return_object) {
967 status = acpi_ns_repair_null_element(data, expected_btypes,
968 package_index,
969 return_object_ptr);
970 if (ACPI_SUCCESS(status)) {
971 return (AE_OK); /* Repair was successful */
972 }
952 goto type_error_exit; 973 goto type_error_exit;
953 } 974 }
954 975
@@ -1000,27 +1021,25 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
1000 1021
1001 /* Is the object one of the expected types? */ 1022 /* Is the object one of the expected types? */
1002 1023
1003 if (!(return_btype & expected_btypes)) { 1024 if (return_btype & expected_btypes) {
1004 1025
1005 /* Type mismatch -- attempt repair of the returned object */ 1026 /* For reference objects, check that the reference type is correct */
1006 1027
1007 status = acpi_ns_repair_object(data, expected_btypes, 1028 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
1008 package_index, 1029 status = acpi_ns_check_reference(data, return_object);
1009 return_object_ptr);
1010 if (ACPI_SUCCESS(status)) {
1011 return (AE_OK); /* Repair was successful */
1012 } 1030 }
1013 goto type_error_exit; 1031
1032 return (status);
1014 } 1033 }
1015 1034
1016 /* For reference objects, check that the reference type is correct */ 1035 /* Type mismatch -- attempt repair of the returned object */
1017 1036
1018 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { 1037 status = acpi_ns_repair_object(data, expected_btypes,
1019 status = acpi_ns_check_reference(data, return_object); 1038 package_index, return_object_ptr);
1039 if (ACPI_SUCCESS(status)) {
1040 return (AE_OK); /* Repair was successful */
1020 } 1041 }
1021 1042
1022 return (status);
1023
1024 type_error_exit: 1043 type_error_exit:
1025 1044
1026 /* Create a string with all expected types for this predefined object */ 1045 /* Create a string with all expected types for this predefined object */
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index 4fd1bdb056b2..d4be37751be4 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2009, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@
45#include "accommon.h" 45#include "accommon.h"
46#include "acnamesp.h" 46#include "acnamesp.h"
47#include "acinterp.h" 47#include "acinterp.h"
48#include "acpredef.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsrepair") 51ACPI_MODULE_NAME("nsrepair")
@@ -71,6 +72,12 @@ ACPI_MODULE_NAME("nsrepair")
71 * Buffer -> Package of Integers 72 * Buffer -> Package of Integers
72 * Package -> Package of one Package 73 * Package -> Package of one Package
73 * 74 *
75 * Additional possible repairs:
76 *
77 * Optional/unnecessary NULL package elements removed
78 * Required package elements that are NULL replaced by Integer/String/Buffer
79 * Incorrect standalone package wrapped with required outer package
80 *
74 ******************************************************************************/ 81 ******************************************************************************/
75/* Local prototypes */ 82/* Local prototypes */
76static acpi_status 83static acpi_status
@@ -506,6 +513,172 @@ acpi_ns_convert_to_package(union acpi_operand_object *original_object,
506 513
507/******************************************************************************* 514/*******************************************************************************
508 * 515 *
516 * FUNCTION: acpi_ns_repair_null_element
517 *
518 * PARAMETERS: Data - Pointer to validation data structure
519 * expected_btypes - Object types expected
520 * package_index - Index of object within parent package (if
521 * applicable - ACPI_NOT_PACKAGE_ELEMENT
522 * otherwise)
523 * return_object_ptr - Pointer to the object returned from the
524 * evaluation of a method or object
525 *
526 * RETURN: Status. AE_OK if repair was successful.
527 *
528 * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
529 *
530 ******************************************************************************/
531
532acpi_status
533acpi_ns_repair_null_element(struct acpi_predefined_data *data,
534 u32 expected_btypes,
535 u32 package_index,
536 union acpi_operand_object **return_object_ptr)
537{
538 union acpi_operand_object *return_object = *return_object_ptr;
539 union acpi_operand_object *new_object;
540
541 ACPI_FUNCTION_NAME(ns_repair_null_element);
542
543 /* No repair needed if return object is non-NULL */
544
545 if (return_object) {
546 return (AE_OK);
547 }
548
549 /*
550 * Attempt to repair a NULL element of a Package object. This applies to
551 * predefined names that return a fixed-length package and each element
552 * is required. It does not apply to variable-length packages where NULL
553 * elements are allowed, especially at the end of the package.
554 */
555 if (expected_btypes & ACPI_RTYPE_INTEGER) {
556
557 /* Need an Integer - create a zero-value integer */
558
559 new_object = acpi_ut_create_integer_object(0);
560 } else if (expected_btypes & ACPI_RTYPE_STRING) {
561
562 /* Need a String - create a NULL string */
563
564 new_object = acpi_ut_create_string_object(0);
565 } else if (expected_btypes & ACPI_RTYPE_BUFFER) {
566
567 /* Need a Buffer - create a zero-length buffer */
568
569 new_object = acpi_ut_create_buffer_object(0);
570 } else {
571 /* Error for all other expected types */
572
573 return (AE_AML_OPERAND_TYPE);
574 }
575
576 if (!new_object) {
577 return (AE_NO_MEMORY);
578 }
579
580 /* Set the reference count according to the parent Package object */
581
582 new_object->common.reference_count =
583 data->parent_package->common.reference_count;
584
585 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
586 "%s: Converted NULL package element to expected %s at index %u\n",
587 data->pathname,
588 acpi_ut_get_object_type_name(new_object),
589 package_index));
590
591 *return_object_ptr = new_object;
592 data->flags |= ACPI_OBJECT_REPAIRED;
593 return (AE_OK);
594}
595
596/******************************************************************************
597 *
598 * FUNCTION: acpi_ns_remove_null_elements
599 *
600 * PARAMETERS: Data - Pointer to validation data structure
601 * package_type - An acpi_return_package_types value
602 * obj_desc - A Package object
603 *
604 * RETURN: None.
605 *
606 * DESCRIPTION: Remove all NULL package elements from packages that contain
607 * a variable number of sub-packages. For these types of
608 * packages, NULL elements can be safely removed.
609 *
610 *****************************************************************************/
611
612void
613acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
614 u8 package_type,
615 union acpi_operand_object *obj_desc)
616{
617 union acpi_operand_object **source;
618 union acpi_operand_object **dest;
619 u32 count;
620 u32 new_count;
621 u32 i;
622
623 ACPI_FUNCTION_NAME(ns_remove_null_elements);
624
625 /*
626 * PTYPE1 packages contain no subpackages.
627 * PTYPE2 packages contain a variable number of sub-packages. We can
628 * safely remove all NULL elements from the PTYPE2 packages.
629 */
630 switch (package_type) {
631 case ACPI_PTYPE1_FIXED:
632 case ACPI_PTYPE1_VAR:
633 case ACPI_PTYPE1_OPTION:
634 return;
635
636 case ACPI_PTYPE2:
637 case ACPI_PTYPE2_COUNT:
638 case ACPI_PTYPE2_PKG_COUNT:
639 case ACPI_PTYPE2_FIXED:
640 case ACPI_PTYPE2_MIN:
641 case ACPI_PTYPE2_REV_FIXED:
642 break;
643
644 default:
645 return;
646 }
647
648 count = obj_desc->package.count;
649 new_count = count;
650
651 source = obj_desc->package.elements;
652 dest = source;
653
654 /* Examine all elements of the package object, remove nulls */
655
656 for (i = 0; i < count; i++) {
657 if (!*source) {
658 new_count--;
659 } else {
660 *dest = *source;
661 dest++;
662 }
663 source++;
664 }
665
666 /* Update parent package if any null elements were removed */
667
668 if (new_count < count) {
669 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
670 "%s: Found and removed %u NULL elements\n",
671 data->pathname, (count - new_count)));
672
673 /* NULL terminate list and update the package count */
674
675 *dest = NULL;
676 obj_desc->package.count = new_count;
677 }
678}
679
680/*******************************************************************************
681 *
509 * FUNCTION: acpi_ns_repair_package_list 682 * FUNCTION: acpi_ns_repair_package_list
510 * 683 *
511 * PARAMETERS: Data - Pointer to validation data structure 684 * PARAMETERS: Data - Pointer to validation data structure
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index f13691c1cca5..61bd0f6755d2 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2009, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,6 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "acnamesp.h" 47#include "acnamesp.h"
48#include "acpredef.h"
49 48
50#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
51ACPI_MODULE_NAME("nsrepair2") 50ACPI_MODULE_NAME("nsrepair2")
@@ -93,7 +92,7 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
93 u32 sort_index, 92 u32 sort_index,
94 u8 sort_direction, char *sort_key_name); 93 u8 sort_direction, char *sort_key_name);
95 94
96static acpi_status 95static void
97acpi_ns_sort_list(union acpi_operand_object **elements, 96acpi_ns_sort_list(union acpi_operand_object **elements,
98 u32 count, u32 index, u8 sort_direction); 97 u32 count, u32 index, u8 sort_direction);
99 98
@@ -443,7 +442,6 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
443 union acpi_operand_object *obj_desc; 442 union acpi_operand_object *obj_desc;
444 u32 i; 443 u32 i;
445 u32 previous_value; 444 u32 previous_value;
446 acpi_status status;
447 445
448 ACPI_FUNCTION_NAME(ns_check_sorted_list); 446 ACPI_FUNCTION_NAME(ns_check_sorted_list);
449 447
@@ -494,19 +492,15 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
494 492
495 /* 493 /*
496 * The list must be sorted in the specified order. If we detect a 494 * The list must be sorted in the specified order. If we detect a
497 * discrepancy, issue a warning and sort the entire list 495 * discrepancy, sort the entire list.
498 */ 496 */
499 if (((sort_direction == ACPI_SORT_ASCENDING) && 497 if (((sort_direction == ACPI_SORT_ASCENDING) &&
500 (obj_desc->integer.value < previous_value)) || 498 (obj_desc->integer.value < previous_value)) ||
501 ((sort_direction == ACPI_SORT_DESCENDING) && 499 ((sort_direction == ACPI_SORT_DESCENDING) &&
502 (obj_desc->integer.value > previous_value))) { 500 (obj_desc->integer.value > previous_value))) {
503 status = 501 acpi_ns_sort_list(return_object->package.elements,
504 acpi_ns_sort_list(return_object->package.elements, 502 outer_element_count, sort_index,
505 outer_element_count, sort_index, 503 sort_direction);
506 sort_direction);
507 if (ACPI_FAILURE(status)) {
508 return (status);
509 }
510 504
511 data->flags |= ACPI_OBJECT_REPAIRED; 505 data->flags |= ACPI_OBJECT_REPAIRED;
512 506
@@ -525,89 +519,6 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
525 519
526/****************************************************************************** 520/******************************************************************************
527 * 521 *
528 * FUNCTION: acpi_ns_remove_null_elements
529 *
530 * PARAMETERS: Data - Pointer to validation data structure
531 * package_type - An acpi_return_package_types value
532 * obj_desc - A Package object
533 *
534 * RETURN: None.
535 *
536 * DESCRIPTION: Remove all NULL package elements from packages that contain
537 * a variable number of sub-packages.
538 *
539 *****************************************************************************/
540
541void
542acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
543 u8 package_type,
544 union acpi_operand_object *obj_desc)
545{
546 union acpi_operand_object **source;
547 union acpi_operand_object **dest;
548 u32 count;
549 u32 new_count;
550 u32 i;
551
552 ACPI_FUNCTION_NAME(ns_remove_null_elements);
553
554 /*
555 * PTYPE1 packages contain no subpackages.
556 * PTYPE2 packages contain a variable number of sub-packages. We can
557 * safely remove all NULL elements from the PTYPE2 packages.
558 */
559 switch (package_type) {
560 case ACPI_PTYPE1_FIXED:
561 case ACPI_PTYPE1_VAR:
562 case ACPI_PTYPE1_OPTION:
563 return;
564
565 case ACPI_PTYPE2:
566 case ACPI_PTYPE2_COUNT:
567 case ACPI_PTYPE2_PKG_COUNT:
568 case ACPI_PTYPE2_FIXED:
569 case ACPI_PTYPE2_MIN:
570 case ACPI_PTYPE2_REV_FIXED:
571 break;
572
573 default:
574 return;
575 }
576
577 count = obj_desc->package.count;
578 new_count = count;
579
580 source = obj_desc->package.elements;
581 dest = source;
582
583 /* Examine all elements of the package object, remove nulls */
584
585 for (i = 0; i < count; i++) {
586 if (!*source) {
587 new_count--;
588 } else {
589 *dest = *source;
590 dest++;
591 }
592 source++;
593 }
594
595 /* Update parent package if any null elements were removed */
596
597 if (new_count < count) {
598 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
599 "%s: Found and removed %u NULL elements\n",
600 data->pathname, (count - new_count)));
601
602 /* NULL terminate list and update the package count */
603
604 *dest = NULL;
605 obj_desc->package.count = new_count;
606 }
607}
608
609/******************************************************************************
610 *
611 * FUNCTION: acpi_ns_sort_list 522 * FUNCTION: acpi_ns_sort_list
612 * 523 *
613 * PARAMETERS: Elements - Package object element list 524 * PARAMETERS: Elements - Package object element list
@@ -615,15 +526,16 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
615 * Index - Sort by which package element 526 * Index - Sort by which package element
616 * sort_direction - Ascending or Descending sort 527 * sort_direction - Ascending or Descending sort
617 * 528 *
618 * RETURN: Status 529 * RETURN: None
619 * 530 *
620 * DESCRIPTION: Sort the objects that are in a package element list. 531 * DESCRIPTION: Sort the objects that are in a package element list.
621 * 532 *
622 * NOTE: Assumes that all NULL elements have been removed from the package. 533 * NOTE: Assumes that all NULL elements have been removed from the package,
534 * and that all elements have been verified to be of type Integer.
623 * 535 *
624 *****************************************************************************/ 536 *****************************************************************************/
625 537
626static acpi_status 538static void
627acpi_ns_sort_list(union acpi_operand_object **elements, 539acpi_ns_sort_list(union acpi_operand_object **elements,
628 u32 count, u32 index, u8 sort_direction) 540 u32 count, u32 index, u8 sort_direction)
629{ 541{
@@ -652,6 +564,4 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
652 } 564 }
653 } 565 }
654 } 566 }
655
656 return (AE_OK);
657} 567}
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index 7e865639a928..08f8b3f5ccaa 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index 47d91e668a1b..24d05a87a2a3 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index d7e6b52b4482..00e79fb26029 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index f0c0892bc7e5..ebef8a7fd707 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -562,25 +562,20 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
562 return (AE_BAD_PARAMETER); 562 return (AE_BAD_PARAMETER);
563 } 563 }
564 564
565 /* Run _STA to determine if device is present */ 565 /*
566 566 * First, filter based on the device HID and CID.
567 status = acpi_ut_execute_STA(node, &flags); 567 *
568 if (ACPI_FAILURE(status)) { 568 * 01/2010: For this case where a specific HID is requested, we don't
569 return (AE_CTRL_DEPTH); 569 * want to run _STA until we have an actual HID match. Thus, we will
570 } 570 * not unnecessarily execute _STA on devices for which the caller
571 571 * doesn't care about. Previously, _STA was executed unconditionally
572 if (!(flags & ACPI_STA_DEVICE_PRESENT) && 572 * on all devices found here.
573 !(flags & ACPI_STA_DEVICE_FUNCTIONING)) { 573 *
574 /* 574 * A side-effect of this change is that now we will continue to search
575 * Don't examine the children of the device only when the 575 * for a matching HID even under device trees where the parent device
576 * device is neither present nor functional. See ACPI spec, 576 * would have returned a _STA that indicates it is not present or
577 * description of _STA for more information. 577 * not functioning (thus aborting the search on that branch).
578 */ 578 */
579 return (AE_CTRL_DEPTH);
580 }
581
582 /* Filter based on device HID & CID */
583
584 if (info->hid != NULL) { 579 if (info->hid != NULL) {
585 status = acpi_ut_execute_HID(node, &hid); 580 status = acpi_ut_execute_HID(node, &hid);
586 if (status == AE_NOT_FOUND) { 581 if (status == AE_NOT_FOUND) {
@@ -620,6 +615,25 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
620 } 615 }
621 } 616 }
622 617
618 /* Run _STA to determine if device is present */
619
620 status = acpi_ut_execute_STA(node, &flags);
621 if (ACPI_FAILURE(status)) {
622 return (AE_CTRL_DEPTH);
623 }
624
625 if (!(flags & ACPI_STA_DEVICE_PRESENT) &&
626 !(flags & ACPI_STA_DEVICE_FUNCTIONING)) {
627 /*
628 * Don't examine the children of the device only when the
629 * device is neither present nor functional. See ACPI spec,
630 * description of _STA for more information.
631 */
632 return (AE_CTRL_DEPTH);
633 }
634
635 /* We have a valid device, invoke the user function */
636
623 status = info->user_function(obj_handle, nesting_level, info->context, 637 status = info->user_function(obj_handle, nesting_level, info->context,
624 return_value); 638 return_value);
625 return (status); 639 return (status);
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index e611dd961b20..b01e45a415e3 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index 0cc6ba01a495..eafef24ea448 100644
--- a/drivers/acpi/acpica/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index b161f3544b51..00493e108a01 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -403,7 +403,7 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
403 /* Get 1 byte from the AML stream */ 403 /* Get 1 byte from the AML stream */
404 404
405 opcode = AML_BYTE_OP; 405 opcode = AML_BYTE_OP;
406 arg->common.value.integer = (acpi_integer) * aml; 406 arg->common.value.integer = (u64) *aml;
407 length = 1; 407 length = 1;
408 break; 408 break;
409 409
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index 0988e4a8901d..59aabaeab1d3 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c
index 3bc3a60194d6..2b0c3be2b1b8 100644
--- a/drivers/acpi/acpica/psopcode.c
+++ b/drivers/acpi/acpica/psopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c
index 4df8f139026c..8d81542194d4 100644
--- a/drivers/acpi/acpica/psparse.c
+++ b/drivers/acpi/acpica/psparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psscope.c b/drivers/acpi/acpica/psscope.c
index 2feca5ca9581..40e2b279ea12 100644
--- a/drivers/acpi/acpica/psscope.c
+++ b/drivers/acpi/acpica/psscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pstree.c b/drivers/acpi/acpica/pstree.c
index 4d3389118ec3..d4b970c3630b 100644
--- a/drivers/acpi/acpica/pstree.c
+++ b/drivers/acpi/acpica/pstree.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psutils.c b/drivers/acpi/acpica/psutils.c
index e636e078ad3d..fe29eee5adb1 100644
--- a/drivers/acpi/acpica/psutils.c
+++ b/drivers/acpi/acpica/psutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pswalk.c b/drivers/acpi/acpica/pswalk.c
index 78b8b791f2ae..8abb9629443d 100644
--- a/drivers/acpi/acpica/pswalk.c
+++ b/drivers/acpi/acpica/pswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c
index d0c1b91eb8ca..6064dd4e94c2 100644
--- a/drivers/acpi/acpica/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsaddr.c b/drivers/acpi/acpica/rsaddr.c
index 1e437bfd8db5..226c806ae986 100644
--- a/drivers/acpi/acpica/rsaddr.c
+++ b/drivers/acpi/acpica/rsaddr.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 3c4dcc3d1069..d6ebf7ec622d 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index a3c23d686d5f..f2ee3b548609 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -182,7 +182,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
182 182
183 /* 183 /*
184 * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a 184 * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
185 * package that in turn contains an acpi_integer Address, a u8 Pin, 185 * package that in turn contains an u64 Address, a u8 Pin,
186 * a Name, and a u8 source_index. 186 * a Name, and a u8 source_index.
187 */ 187 */
188 top_object_list = package_object->package.elements; 188 top_object_list = package_object->package.elements;
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index 3f0ca5a12d34..f859b0386fe4 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index 77b25fdb459c..1fd868b964fd 100644
--- a/drivers/acpi/acpica/rsinfo.c
+++ b/drivers/acpi/acpica/rsinfo.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsio.c b/drivers/acpi/acpica/rsio.c
index 35a49aa95609..33bff17c0bbc 100644
--- a/drivers/acpi/acpica/rsio.c
+++ b/drivers/acpi/acpica/rsio.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsirq.c b/drivers/acpi/acpica/rsirq.c
index 2e0256983aa6..545da40d7fa7 100644
--- a/drivers/acpi/acpica/rsirq.c
+++ b/drivers/acpi/acpica/rsirq.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c
index 1b1dbc69f087..fd057c72d252 100644
--- a/drivers/acpi/acpica/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmemory.c b/drivers/acpi/acpica/rsmemory.c
index ddc76cebdc92..887b8ba8c432 100644
--- a/drivers/acpi/acpica/rsmemory.c
+++ b/drivers/acpi/acpica/rsmemory.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index 5bc49a553284..07de352fa443 100644
--- a/drivers/acpi/acpica/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c
index bc03d5966829..22cfcfbd9fff 100644
--- a/drivers/acpi/acpica/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index f27feb4772f6..9f6a6e7e1c8e 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index c016335fb759..f43fbe0fc3fc 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 1054dfd49207..e252180ce61c 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 63e82329a9e8..7ec02b0f69e0 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 1f15497f00d1..02723a9fb10c 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index a88f02bd6c94..5217a6159a31 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index 85ea834199e2..dda6e8c497d3 100644
--- a/drivers/acpi/acpica/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c
index 7580f6b3069e..3d706b8fd449 100644
--- a/drivers/acpi/acpica/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index f857c5efb79f..97ec3621e71d 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index 527d729f6815..983510640059 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -460,8 +460,7 @@ ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
460void 460void
461acpi_ut_value_exit(u32 line_number, 461acpi_ut_value_exit(u32 line_number,
462 const char *function_name, 462 const char *function_name,
463 const char *module_name, 463 const char *module_name, u32 component_id, u64 value)
464 u32 component_id, acpi_integer value)
465{ 464{
466 465
467 acpi_debug_print(ACPI_LV_FUNCTIONS, 466 acpi_debug_print(ACPI_LV_FUNCTIONS,
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
index 96e26e70c63d..16b51c69606a 100644
--- a/drivers/acpi/acpica/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index 5d54e36ab453..7f5e734ce7f7 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -348,7 +348,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
348acpi_status 348acpi_status
349acpi_ut_evaluate_numeric_object(char *object_name, 349acpi_ut_evaluate_numeric_object(char *object_name,
350 struct acpi_namespace_node *device_node, 350 struct acpi_namespace_node *device_node,
351 acpi_integer *value) 351 u64 *value)
352{ 352{
353 union acpi_operand_object *obj_desc; 353 union acpi_operand_object *obj_desc;
354 acpi_status status; 354 acpi_status status;
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 3f2c68f4e959..eda3e656c4af 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -234,7 +234,7 @@ static const char acpi_gbl_hex_to_ascii[] = {
234 * 234 *
235 ******************************************************************************/ 235 ******************************************************************************/
236 236
237char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position) 237char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
238{ 238{
239 239
240 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); 240 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c
index 52eaae404554..1397fadd0d4b 100644
--- a/drivers/acpi/acpica/utids.c
+++ b/drivers/acpi/acpica/utids.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2009, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index 9d0919ebf7b0..a39c93dac719 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utlock.c b/drivers/acpi/acpica/utlock.c
index 25e03120686d..b081cd46a15f 100644
--- a/drivers/acpi/acpica/utlock.c
+++ b/drivers/acpi/acpica/utlock.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2009, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmath.c b/drivers/acpi/acpica/utmath.c
index c9f682d640ef..35059a14eb72 100644
--- a/drivers/acpi/acpica/utmath.c
+++ b/drivers/acpi/acpica/utmath.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -70,9 +70,8 @@ ACPI_MODULE_NAME("utmath")
70 * 70 *
71 ******************************************************************************/ 71 ******************************************************************************/
72acpi_status 72acpi_status
73acpi_ut_short_divide(acpi_integer dividend, 73acpi_ut_short_divide(u64 dividend,
74 u32 divisor, 74 u32 divisor, u64 *out_quotient, u32 *out_remainder)
75 acpi_integer * out_quotient, u32 * out_remainder)
76{ 75{
77 union uint64_overlay dividend_ovl; 76 union uint64_overlay dividend_ovl;
78 union uint64_overlay quotient; 77 union uint64_overlay quotient;
@@ -126,9 +125,8 @@ acpi_ut_short_divide(acpi_integer dividend,
126 ******************************************************************************/ 125 ******************************************************************************/
127 126
128acpi_status 127acpi_status
129acpi_ut_divide(acpi_integer in_dividend, 128acpi_ut_divide(u64 in_dividend,
130 acpi_integer in_divisor, 129 u64 in_divisor, u64 *out_quotient, u64 *out_remainder)
131 acpi_integer * out_quotient, acpi_integer * out_remainder)
132{ 130{
133 union uint64_overlay dividend; 131 union uint64_overlay dividend;
134 union uint64_overlay divisor; 132 union uint64_overlay divisor;
@@ -199,9 +197,8 @@ acpi_ut_divide(acpi_integer in_dividend,
199 * The 64-bit remainder must be generated. 197 * The 64-bit remainder must be generated.
200 */ 198 */
201 partial1 = quotient.part.lo * divisor.part.hi; 199 partial1 = quotient.part.lo * divisor.part.hi;
202 partial2.full = 200 partial2.full = (u64) quotient.part.lo * divisor.part.lo;
203 (acpi_integer) quotient.part.lo * divisor.part.lo; 201 partial3.full = (u64) partial2.part.hi + partial1;
204 partial3.full = (acpi_integer) partial2.part.hi + partial1;
205 202
206 remainder.part.hi = partial3.part.lo; 203 remainder.part.hi = partial3.part.lo;
207 remainder.part.lo = partial2.part.lo; 204 remainder.part.lo = partial2.part.lo;
@@ -257,9 +254,8 @@ acpi_ut_divide(acpi_integer in_dividend,
257 * 254 *
258 ******************************************************************************/ 255 ******************************************************************************/
259acpi_status 256acpi_status
260acpi_ut_short_divide(acpi_integer in_dividend, 257acpi_ut_short_divide(u64 in_dividend,
261 u32 divisor, 258 u32 divisor, u64 *out_quotient, u32 *out_remainder)
262 acpi_integer * out_quotient, u32 * out_remainder)
263{ 259{
264 260
265 ACPI_FUNCTION_TRACE(ut_short_divide); 261 ACPI_FUNCTION_TRACE(ut_short_divide);
@@ -284,9 +280,8 @@ acpi_ut_short_divide(acpi_integer in_dividend,
284} 280}
285 281
286acpi_status 282acpi_status
287acpi_ut_divide(acpi_integer in_dividend, 283acpi_ut_divide(u64 in_dividend,
288 acpi_integer in_divisor, 284 u64 in_divisor, u64 *out_quotient, u64 *out_remainder)
289 acpi_integer * out_quotient, acpi_integer * out_remainder)
290{ 285{
291 ACPI_FUNCTION_TRACE(ut_divide); 286 ACPI_FUNCTION_TRACE(ut_divide);
292 287
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 6c6a5137b728..32982e2ac384 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -724,13 +724,12 @@ acpi_name acpi_ut_repair_name(char *name)
724 * 724 *
725 ******************************************************************************/ 725 ******************************************************************************/
726 726
727acpi_status 727acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer)
728acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
729{ 728{
730 u32 this_digit = 0; 729 u32 this_digit = 0;
731 acpi_integer return_value = 0; 730 u64 return_value = 0;
732 acpi_integer quotient; 731 u64 quotient;
733 acpi_integer dividend; 732 u64 dividend;
734 u32 to_integer_op = (base == ACPI_ANY_BASE); 733 u32 to_integer_op = (base == ACPI_ANY_BASE);
735 u32 mode32 = (acpi_gbl_integer_byte_width == 4); 734 u32 mode32 = (acpi_gbl_integer_byte_width == 4);
736 u8 valid_digits = 0; 735 u8 valid_digits = 0;
@@ -844,9 +843,8 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
844 843
845 /* Divide the digit into the correct position */ 844 /* Divide the digit into the correct position */
846 845
847 (void) 846 (void)acpi_ut_short_divide((dividend - (u64) this_digit),
848 acpi_ut_short_divide((dividend - (acpi_integer) this_digit), 847 base, &quotient, NULL);
849 base, &quotient, NULL);
850 848
851 if (return_value > quotient) { 849 if (return_value > quotient) {
852 if (to_integer_op) { 850 if (to_integer_op) {
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 80bb65154117..55d014ed6d55 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,7 @@ ACPI_MODULE_NAME("utmutex")
50/* Local prototypes */ 50/* Local prototypes */
51static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id); 51static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id);
52 52
53static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id); 53static void acpi_ut_delete_mutex(acpi_mutex_handle mutex_id);
54 54
55/******************************************************************************* 55/*******************************************************************************
56 * 56 *
@@ -114,7 +114,7 @@ void acpi_ut_mutex_terminate(void)
114 /* Delete each predefined mutex object */ 114 /* Delete each predefined mutex object */
115 115
116 for (i = 0; i < ACPI_NUM_MUTEX; i++) { 116 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
117 (void)acpi_ut_delete_mutex(i); 117 acpi_ut_delete_mutex(i);
118 } 118 }
119 119
120 /* Delete the spinlocks */ 120 /* Delete the spinlocks */
@@ -146,10 +146,6 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
146 146
147 ACPI_FUNCTION_TRACE_U32(ut_create_mutex, mutex_id); 147 ACPI_FUNCTION_TRACE_U32(ut_create_mutex, mutex_id);
148 148
149 if (mutex_id > ACPI_MAX_MUTEX) {
150 return_ACPI_STATUS(AE_BAD_PARAMETER);
151 }
152
153 if (!acpi_gbl_mutex_info[mutex_id].mutex) { 149 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
154 status = 150 status =
155 acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex); 151 acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex);
@@ -173,21 +169,15 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
173 * 169 *
174 ******************************************************************************/ 170 ******************************************************************************/
175 171
176static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id) 172static void acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
177{ 173{
178 174
179 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id); 175 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id);
180 176
181 if (mutex_id > ACPI_MAX_MUTEX) {
182 return_ACPI_STATUS(AE_BAD_PARAMETER);
183 }
184
185 acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex); 177 acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
186 178
187 acpi_gbl_mutex_info[mutex_id].mutex = NULL; 179 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
188 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 180 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
189
190 return_ACPI_STATUS(AE_OK);
191} 181}
192 182
193/******************************************************************************* 183/*******************************************************************************
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index 42e658b543f1..3356f0cb0745 100644
--- a/drivers/acpi/acpica/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index 91b7c00236f4..7965919000b1 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utstate.c b/drivers/acpi/acpica/utstate.c
index 0440c958f5a4..d35d109b8da2 100644
--- a/drivers/acpi/acpica/utstate.c
+++ b/drivers/acpi/acpica/utstate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index b1f5f680bc78..db9d8ca57987 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index cada73ffdfa7..58d2c91ba62b 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -324,8 +324,8 @@ static int extract_package(struct acpi_battery *battery,
324 strncpy(ptr, element->string.pointer, 32); 324 strncpy(ptr, element->string.pointer, 32);
325 else if (element->type == ACPI_TYPE_INTEGER) { 325 else if (element->type == ACPI_TYPE_INTEGER) {
326 strncpy(ptr, (u8 *)&element->integer.value, 326 strncpy(ptr, (u8 *)&element->integer.value,
327 sizeof(acpi_integer)); 327 sizeof(u64));
328 ptr[sizeof(acpi_integer)] = 0; 328 ptr[sizeof(u64)] = 0;
329 } else 329 } else
330 *ptr = 0; /* don't have value */ 330 *ptr = 0; /* don't have value */
331 } else { 331 } else {
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 27e0b92b2e39..d7a6bbbb834c 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -597,7 +597,7 @@ static u32 acpi_ec_gpe_handler(void *data)
597 597
598static acpi_status 598static acpi_status
599acpi_ec_space_handler(u32 function, acpi_physical_address address, 599acpi_ec_space_handler(u32 function, acpi_physical_address address,
600 u32 bits, acpi_integer *value, 600 u32 bits, u64 *value,
601 void *handler_context, void *region_context) 601 void *handler_context, void *region_context)
602{ 602{
603 struct acpi_ec *ec = handler_context; 603 struct acpi_ec *ec = handler_context;
@@ -628,7 +628,7 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
628 ++address; 628 ++address;
629 if (function == ACPI_READ) { 629 if (function == ACPI_READ) {
630 result = acpi_ec_read(ec, address, &temp); 630 result = acpi_ec_read(ec, address, &temp);
631 (*value) |= ((acpi_integer)temp) << i; 631 (*value) |= ((u64)temp) << i;
632 } else { 632 } else {
633 temp = 0xff & ((*value) >> i); 633 temp = 0xff & ((*value) >> i);
634 result = acpi_ec_write(ec, address, temp); 634 result = acpi_ec_write(ec, address, temp);
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 4c8fcff662cf..6d5b64b7d526 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -87,7 +87,7 @@ static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
87/* Get device's handler per its address under its parent */ 87/* Get device's handler per its address under its parent */
88struct acpi_find_child { 88struct acpi_find_child {
89 acpi_handle handle; 89 acpi_handle handle;
90 acpi_integer address; 90 u64 address;
91}; 91};
92 92
93static acpi_status 93static acpi_status
@@ -106,7 +106,7 @@ do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
106 return AE_OK; 106 return AE_OK;
107} 107}
108 108
109acpi_handle acpi_get_child(acpi_handle parent, acpi_integer address) 109acpi_handle acpi_get_child(acpi_handle parent, u64 address)
110{ 110{
111 struct acpi_find_child find = { NULL, address }; 111 struct acpi_find_child find = { NULL, address };
112 112
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 02e8464e480f..8e6d8665f0ae 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -436,7 +436,7 @@ acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
436 * Running in interpreter thread context, safe to sleep 436 * Running in interpreter thread context, safe to sleep
437 */ 437 */
438 438
439void acpi_os_sleep(acpi_integer ms) 439void acpi_os_sleep(u64 ms)
440{ 440{
441 schedule_timeout_interruptible(msecs_to_jiffies(ms)); 441 schedule_timeout_interruptible(msecs_to_jiffies(ms));
442} 442}
@@ -603,7 +603,7 @@ acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
603 603
604acpi_status 604acpi_status
605acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, 605acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
606 acpi_integer value, u32 width) 606 u64 value, u32 width)
607{ 607{
608 int result, size; 608 int result, size;
609 609
diff --git a/drivers/acpi/power_meter.c b/drivers/acpi/power_meter.c
index dc4ffadf8122..834c5af0de4b 100644
--- a/drivers/acpi/power_meter.c
+++ b/drivers/acpi/power_meter.c
@@ -71,17 +71,17 @@ static const struct acpi_device_id power_meter_ids[] = {
71MODULE_DEVICE_TABLE(acpi, power_meter_ids); 71MODULE_DEVICE_TABLE(acpi, power_meter_ids);
72 72
73struct acpi_power_meter_capabilities { 73struct acpi_power_meter_capabilities {
74 acpi_integer flags; 74 u64 flags;
75 acpi_integer units; 75 u64 units;
76 acpi_integer type; 76 u64 type;
77 acpi_integer accuracy; 77 u64 accuracy;
78 acpi_integer sampling_time; 78 u64 sampling_time;
79 acpi_integer min_avg_interval; 79 u64 min_avg_interval;
80 acpi_integer max_avg_interval; 80 u64 max_avg_interval;
81 acpi_integer hysteresis; 81 u64 hysteresis;
82 acpi_integer configurable_cap; 82 u64 configurable_cap;
83 acpi_integer min_cap; 83 u64 min_cap;
84 acpi_integer max_cap; 84 u64 max_cap;
85}; 85};
86 86
87struct acpi_power_meter_resource { 87struct acpi_power_meter_resource {
@@ -93,9 +93,9 @@ struct acpi_power_meter_resource {
93 acpi_string model_number; 93 acpi_string model_number;
94 acpi_string serial_number; 94 acpi_string serial_number;
95 acpi_string oem_info; 95 acpi_string oem_info;
96 acpi_integer power; 96 u64 power;
97 acpi_integer cap; 97 u64 cap;
98 acpi_integer avg_interval; 98 u64 avg_interval;
99 int sensors_valid; 99 int sensors_valid;
100 unsigned long sensors_last_updated; 100 unsigned long sensors_last_updated;
101 struct sensor_device_attribute sensors[NUM_SENSORS]; 101 struct sensor_device_attribute sensors[NUM_SENSORS];
@@ -402,7 +402,7 @@ static ssize_t show_val(struct device *dev,
402 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 402 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
403 struct acpi_device *acpi_dev = to_acpi_device(dev); 403 struct acpi_device *acpi_dev = to_acpi_device(dev);
404 struct acpi_power_meter_resource *resource = acpi_dev->driver_data; 404 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
405 acpi_integer val = 0; 405 u64 val = 0;
406 406
407 switch (attr->index) { 407 switch (attr->index) {
408 case 0: 408 case 0:
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index cc978a8c00b7..37dfce749398 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -360,7 +360,7 @@ static int acpi_processor_get_power_info_default(struct acpi_processor *pr)
360static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) 360static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
361{ 361{
362 acpi_status status = 0; 362 acpi_status status = 0;
363 acpi_integer count; 363 u64 count;
364 int current_count; 364 int current_count;
365 int i; 365 int i;
366 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 366 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1c5d7a8b2fdf..7ded7542fc9d 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -660,7 +660,7 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
660 660
661#ifdef CONFIG_X86 661#ifdef CONFIG_X86
662static int acpi_throttling_rdmsr(struct acpi_processor *pr, 662static int acpi_throttling_rdmsr(struct acpi_processor *pr,
663 acpi_integer * value) 663 u64 *value)
664{ 664{
665 struct cpuinfo_x86 *c; 665 struct cpuinfo_x86 *c;
666 u64 msr_high, msr_low; 666 u64 msr_high, msr_low;
@@ -681,13 +681,13 @@ static int acpi_throttling_rdmsr(struct acpi_processor *pr,
681 rdmsr_safe(MSR_IA32_THERM_CONTROL, 681 rdmsr_safe(MSR_IA32_THERM_CONTROL,
682 (u32 *)&msr_low , (u32 *) &msr_high); 682 (u32 *)&msr_low , (u32 *) &msr_high);
683 msr = (msr_high << 32) | msr_low; 683 msr = (msr_high << 32) | msr_low;
684 *value = (acpi_integer) msr; 684 *value = (u64) msr;
685 ret = 0; 685 ret = 0;
686 } 686 }
687 return ret; 687 return ret;
688} 688}
689 689
690static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) 690static int acpi_throttling_wrmsr(struct acpi_processor *pr, u64 value)
691{ 691{
692 struct cpuinfo_x86 *c; 692 struct cpuinfo_x86 *c;
693 unsigned int cpu; 693 unsigned int cpu;
@@ -711,14 +711,14 @@ static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
711} 711}
712#else 712#else
713static int acpi_throttling_rdmsr(struct acpi_processor *pr, 713static int acpi_throttling_rdmsr(struct acpi_processor *pr,
714 acpi_integer * value) 714 u64 *value)
715{ 715{
716 printk(KERN_ERR PREFIX 716 printk(KERN_ERR PREFIX
717 "HARDWARE addr space,NOT supported yet\n"); 717 "HARDWARE addr space,NOT supported yet\n");
718 return -1; 718 return -1;
719} 719}
720 720
721static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) 721static int acpi_throttling_wrmsr(struct acpi_processor *pr, u64 value)
722{ 722{
723 printk(KERN_ERR PREFIX 723 printk(KERN_ERR PREFIX
724 "HARDWARE addr space,NOT supported yet\n"); 724 "HARDWARE addr space,NOT supported yet\n");
@@ -727,7 +727,7 @@ static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
727#endif 727#endif
728 728
729static int acpi_read_throttling_status(struct acpi_processor *pr, 729static int acpi_read_throttling_status(struct acpi_processor *pr,
730 acpi_integer *value) 730 u64 *value)
731{ 731{
732 u32 bit_width, bit_offset; 732 u32 bit_width, bit_offset;
733 u64 ptc_value; 733 u64 ptc_value;
@@ -746,7 +746,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
746 address, (u32 *) &ptc_value, 746 address, (u32 *) &ptc_value,
747 (u32) (bit_width + bit_offset)); 747 (u32) (bit_width + bit_offset));
748 ptc_mask = (1 << bit_width) - 1; 748 ptc_mask = (1 << bit_width) - 1;
749 *value = (acpi_integer) ((ptc_value >> bit_offset) & ptc_mask); 749 *value = (u64) ((ptc_value >> bit_offset) & ptc_mask);
750 ret = 0; 750 ret = 0;
751 break; 751 break;
752 case ACPI_ADR_SPACE_FIXED_HARDWARE: 752 case ACPI_ADR_SPACE_FIXED_HARDWARE:
@@ -760,7 +760,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
760} 760}
761 761
762static int acpi_write_throttling_state(struct acpi_processor *pr, 762static int acpi_write_throttling_state(struct acpi_processor *pr,
763 acpi_integer value) 763 u64 value)
764{ 764{
765 u32 bit_width, bit_offset; 765 u32 bit_width, bit_offset;
766 u64 ptc_value; 766 u64 ptc_value;
@@ -793,7 +793,7 @@ static int acpi_write_throttling_state(struct acpi_processor *pr,
793} 793}
794 794
795static int acpi_get_throttling_state(struct acpi_processor *pr, 795static int acpi_get_throttling_state(struct acpi_processor *pr,
796 acpi_integer value) 796 u64 value)
797{ 797{
798 int i; 798 int i;
799 799
@@ -808,7 +808,7 @@ static int acpi_get_throttling_state(struct acpi_processor *pr,
808} 808}
809 809
810static int acpi_get_throttling_value(struct acpi_processor *pr, 810static int acpi_get_throttling_value(struct acpi_processor *pr,
811 int state, acpi_integer *value) 811 int state, u64 *value)
812{ 812{
813 int ret = -1; 813 int ret = -1;
814 814
@@ -826,7 +826,7 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
826{ 826{
827 int state = 0; 827 int state = 0;
828 int ret; 828 int ret;
829 acpi_integer value; 829 u64 value;
830 830
831 if (!pr) 831 if (!pr)
832 return -EINVAL; 832 return -EINVAL;
@@ -993,7 +993,7 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
993 int state, bool force) 993 int state, bool force)
994{ 994{
995 int ret; 995 int ret;
996 acpi_integer value; 996 u64 value;
997 997
998 if (!pr) 998 if (!pr)
999 return -EINVAL; 999 return -EINVAL;
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 811fec10462b..11882dbe2094 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -107,12 +107,12 @@ acpi_extract_package(union acpi_object *package,
107 case ACPI_TYPE_INTEGER: 107 case ACPI_TYPE_INTEGER:
108 switch (format_string[i]) { 108 switch (format_string[i]) {
109 case 'N': 109 case 'N':
110 size_required += sizeof(acpi_integer); 110 size_required += sizeof(u64);
111 tail_offset += sizeof(acpi_integer); 111 tail_offset += sizeof(u64);
112 break; 112 break;
113 case 'S': 113 case 'S':
114 size_required += 114 size_required +=
115 sizeof(char *) + sizeof(acpi_integer) + 115 sizeof(char *) + sizeof(u64) +
116 sizeof(char); 116 sizeof(char);
117 tail_offset += sizeof(char *); 117 tail_offset += sizeof(char *);
118 break; 118 break;
@@ -193,17 +193,17 @@ acpi_extract_package(union acpi_object *package,
193 case ACPI_TYPE_INTEGER: 193 case ACPI_TYPE_INTEGER:
194 switch (format_string[i]) { 194 switch (format_string[i]) {
195 case 'N': 195 case 'N':
196 *((acpi_integer *) head) = 196 *((u64 *) head) =
197 element->integer.value; 197 element->integer.value;
198 head += sizeof(acpi_integer); 198 head += sizeof(u64);
199 break; 199 break;
200 case 'S': 200 case 'S':
201 pointer = (u8 **) head; 201 pointer = (u8 **) head;
202 *pointer = tail; 202 *pointer = tail;
203 *((acpi_integer *) tail) = 203 *((u64 *) tail) =
204 element->integer.value; 204 element->integer.value;
205 head += sizeof(acpi_integer *); 205 head += sizeof(u64 *);
206 tail += sizeof(acpi_integer); 206 tail += sizeof(u64);
207 /* NULL terminate string */ 207 /* NULL terminate string */
208 *tail = (char)0; 208 *tail = (char)0;
209 tail += sizeof(char); 209 tail += sizeof(char);
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index b765790b32be..6e9b49149fce 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -759,7 +759,7 @@ acpi_video_bus_POST_options(struct acpi_video_bus *video,
759static int 759static int
760acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) 760acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
761{ 761{
762 acpi_integer status = 0; 762 u64 status = 0;
763 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 763 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
764 struct acpi_object_list args = { 1, &arg0 }; 764 struct acpi_object_list args = { 1, &arg0 };
765 765
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 56c6374a3989..01c52c415bdc 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -446,9 +446,9 @@ config PATA_JMICRON
446 446
447config PATA_LEGACY 447config PATA_LEGACY
448 tristate "Legacy ISA PATA support (Experimental)" 448 tristate "Legacy ISA PATA support (Experimental)"
449 depends on ISA && EXPERIMENTAL 449 depends on (ISA || PCI) && EXPERIMENTAL
450 help 450 help
451 This option enables support for ISA/VLB bus legacy PATA 451 This option enables support for ISA/VLB/PCI bus legacy PATA
452 ports and allows them to be accessed via the new ATA layer. 452 ports and allows them to be accessed via the new ATA layer.
453 453
454 If unsure, say N. 454 If unsure, say N.
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index a6a736a7dbf2..6bd930b93bcc 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -93,6 +93,9 @@ enum {
93 AHCI_CMD_TBL_AR_SZ = AHCI_CMD_TBL_SZ * AHCI_MAX_CMDS, 93 AHCI_CMD_TBL_AR_SZ = AHCI_CMD_TBL_SZ * AHCI_MAX_CMDS,
94 AHCI_PORT_PRIV_DMA_SZ = AHCI_CMD_SLOT_SZ + AHCI_CMD_TBL_AR_SZ + 94 AHCI_PORT_PRIV_DMA_SZ = AHCI_CMD_SLOT_SZ + AHCI_CMD_TBL_AR_SZ +
95 AHCI_RX_FIS_SZ, 95 AHCI_RX_FIS_SZ,
96 AHCI_PORT_PRIV_FBS_DMA_SZ = AHCI_CMD_SLOT_SZ +
97 AHCI_CMD_TBL_AR_SZ +
98 (AHCI_RX_FIS_SZ * 16),
96 AHCI_IRQ_ON_SG = (1 << 31), 99 AHCI_IRQ_ON_SG = (1 << 31),
97 AHCI_CMD_ATAPI = (1 << 5), 100 AHCI_CMD_ATAPI = (1 << 5),
98 AHCI_CMD_WRITE = (1 << 6), 101 AHCI_CMD_WRITE = (1 << 6),
@@ -170,6 +173,7 @@ enum {
170 PORT_SCR_ERR = 0x30, /* SATA phy register: SError */ 173 PORT_SCR_ERR = 0x30, /* SATA phy register: SError */
171 PORT_SCR_ACT = 0x34, /* SATA phy register: SActive */ 174 PORT_SCR_ACT = 0x34, /* SATA phy register: SActive */
172 PORT_SCR_NTF = 0x3c, /* SATA phy register: SNotification */ 175 PORT_SCR_NTF = 0x3c, /* SATA phy register: SNotification */
176 PORT_FBS = 0x40, /* FIS-based Switching */
173 177
174 /* PORT_IRQ_{STAT,MASK} bits */ 178 /* PORT_IRQ_{STAT,MASK} bits */
175 PORT_IRQ_COLD_PRES = (1 << 31), /* cold presence detect */ 179 PORT_IRQ_COLD_PRES = (1 << 31), /* cold presence detect */
@@ -208,6 +212,7 @@ enum {
208 PORT_CMD_ASP = (1 << 27), /* Aggressive Slumber/Partial */ 212 PORT_CMD_ASP = (1 << 27), /* Aggressive Slumber/Partial */
209 PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */ 213 PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */
210 PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */ 214 PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */
215 PORT_CMD_FBSCP = (1 << 22), /* FBS Capable Port */
211 PORT_CMD_PMP = (1 << 17), /* PMP attached */ 216 PORT_CMD_PMP = (1 << 17), /* PMP attached */
212 PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ 217 PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */
213 PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */ 218 PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */
@@ -222,6 +227,14 @@ enum {
222 PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */ 227 PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */
223 PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */ 228 PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */
224 229
230 PORT_FBS_DWE_OFFSET = 16, /* FBS device with error offset */
231 PORT_FBS_ADO_OFFSET = 12, /* FBS active dev optimization offset */
232 PORT_FBS_DEV_OFFSET = 8, /* FBS device to issue offset */
233 PORT_FBS_DEV_MASK = (0xf << PORT_FBS_DEV_OFFSET), /* FBS.DEV */
234 PORT_FBS_SDE = (1 << 2), /* FBS single device error */
235 PORT_FBS_DEC = (1 << 1), /* FBS device error clear */
236 PORT_FBS_EN = (1 << 0), /* Enable FBS */
237
225 /* hpriv->flags bits */ 238 /* hpriv->flags bits */
226 AHCI_HFLAG_NO_NCQ = (1 << 0), 239 AHCI_HFLAG_NO_NCQ = (1 << 0),
227 AHCI_HFLAG_IGN_IRQ_IF_ERR = (1 << 1), /* ignore IRQ_IF_ERR */ 240 AHCI_HFLAG_IGN_IRQ_IF_ERR = (1 << 1), /* ignore IRQ_IF_ERR */
@@ -304,6 +317,9 @@ struct ahci_port_priv {
304 unsigned int ncq_saw_dmas:1; 317 unsigned int ncq_saw_dmas:1;
305 unsigned int ncq_saw_sdb:1; 318 unsigned int ncq_saw_sdb:1;
306 u32 intr_mask; /* interrupts to enable */ 319 u32 intr_mask; /* interrupts to enable */
320 bool fbs_supported; /* set iff FBS is supported */
321 bool fbs_enabled; /* set iff FBS is enabled */
322 int fbs_last_dev; /* save FBS.DEV of last FIS */
307 /* enclosure management info per PM slot */ 323 /* enclosure management info per PM slot */
308 struct ahci_em_priv em_priv[EM_MAX_SLOTS]; 324 struct ahci_em_priv em_priv[EM_MAX_SLOTS];
309}; 325};
@@ -315,9 +331,12 @@ static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc);
315static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc); 331static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc);
316static int ahci_port_start(struct ata_port *ap); 332static int ahci_port_start(struct ata_port *ap);
317static void ahci_port_stop(struct ata_port *ap); 333static void ahci_port_stop(struct ata_port *ap);
334static int ahci_pmp_qc_defer(struct ata_queued_cmd *qc);
318static void ahci_qc_prep(struct ata_queued_cmd *qc); 335static void ahci_qc_prep(struct ata_queued_cmd *qc);
319static void ahci_freeze(struct ata_port *ap); 336static void ahci_freeze(struct ata_port *ap);
320static void ahci_thaw(struct ata_port *ap); 337static void ahci_thaw(struct ata_port *ap);
338static void ahci_enable_fbs(struct ata_port *ap);
339static void ahci_disable_fbs(struct ata_port *ap);
321static void ahci_pmp_attach(struct ata_port *ap); 340static void ahci_pmp_attach(struct ata_port *ap);
322static void ahci_pmp_detach(struct ata_port *ap); 341static void ahci_pmp_detach(struct ata_port *ap);
323static int ahci_softreset(struct ata_link *link, unsigned int *class, 342static int ahci_softreset(struct ata_link *link, unsigned int *class,
@@ -356,10 +375,10 @@ static ssize_t ahci_show_host_version(struct device *dev,
356static ssize_t ahci_show_port_cmd(struct device *dev, 375static ssize_t ahci_show_port_cmd(struct device *dev,
357 struct device_attribute *attr, char *buf); 376 struct device_attribute *attr, char *buf);
358 377
359DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL); 378static DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
360DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL); 379static DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL);
361DEVICE_ATTR(ahci_host_version, S_IRUGO, ahci_show_host_version, NULL); 380static DEVICE_ATTR(ahci_host_version, S_IRUGO, ahci_show_host_version, NULL);
362DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL); 381static DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL);
363 382
364static struct device_attribute *ahci_shost_attrs[] = { 383static struct device_attribute *ahci_shost_attrs[] = {
365 &dev_attr_link_power_management_policy, 384 &dev_attr_link_power_management_policy,
@@ -390,7 +409,7 @@ static struct scsi_host_template ahci_sht = {
390static struct ata_port_operations ahci_ops = { 409static struct ata_port_operations ahci_ops = {
391 .inherits = &sata_pmp_port_ops, 410 .inherits = &sata_pmp_port_ops,
392 411
393 .qc_defer = sata_pmp_qc_defer_cmd_switch, 412 .qc_defer = ahci_pmp_qc_defer,
394 .qc_prep = ahci_qc_prep, 413 .qc_prep = ahci_qc_prep,
395 .qc_issue = ahci_qc_issue, 414 .qc_issue = ahci_qc_issue,
396 .qc_fill_rtf = ahci_qc_fill_rtf, 415 .qc_fill_rtf = ahci_qc_fill_rtf,
@@ -570,6 +589,12 @@ static const struct pci_device_id ahci_pci_tbl[] = {
570 { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */ 589 { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */
571 { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */ 590 { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */
572 { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */ 591 { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */
592 { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */
593 { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */
594 { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
595 { PCI_VDEVICE(INTEL, 0x1c05), board_ahci }, /* CPT RAID */
596 { PCI_VDEVICE(INTEL, 0x1c06), board_ahci }, /* CPT RAID */
597 { PCI_VDEVICE(INTEL, 0x1c07), board_ahci }, /* CPT RAID */
573 598
574 /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 599 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
575 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 600 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
@@ -2045,6 +2070,17 @@ static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl)
2045 return si; 2070 return si;
2046} 2071}
2047 2072
2073static int ahci_pmp_qc_defer(struct ata_queued_cmd *qc)
2074{
2075 struct ata_port *ap = qc->ap;
2076 struct ahci_port_priv *pp = ap->private_data;
2077
2078 if (!sata_pmp_attached(ap) || pp->fbs_enabled)
2079 return ata_std_qc_defer(qc);
2080 else
2081 return sata_pmp_qc_defer_cmd_switch(qc);
2082}
2083
2048static void ahci_qc_prep(struct ata_queued_cmd *qc) 2084static void ahci_qc_prep(struct ata_queued_cmd *qc)
2049{ 2085{
2050 struct ata_port *ap = qc->ap; 2086 struct ata_port *ap = qc->ap;
@@ -2083,6 +2119,31 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
2083 ahci_fill_cmd_slot(pp, qc->tag, opts); 2119 ahci_fill_cmd_slot(pp, qc->tag, opts);
2084} 2120}
2085 2121
2122static void ahci_fbs_dec_intr(struct ata_port *ap)
2123{
2124 struct ahci_port_priv *pp = ap->private_data;
2125 void __iomem *port_mmio = ahci_port_base(ap);
2126 u32 fbs = readl(port_mmio + PORT_FBS);
2127 int retries = 3;
2128
2129 DPRINTK("ENTER\n");
2130 BUG_ON(!pp->fbs_enabled);
2131
2132 /* time to wait for DEC is not specified by AHCI spec,
2133 * add a retry loop for safety.
2134 */
2135 writel(fbs | PORT_FBS_DEC, port_mmio + PORT_FBS);
2136 fbs = readl(port_mmio + PORT_FBS);
2137 while ((fbs & PORT_FBS_DEC) && retries--) {
2138 udelay(1);
2139 fbs = readl(port_mmio + PORT_FBS);
2140 }
2141
2142 if (fbs & PORT_FBS_DEC)
2143 dev_printk(KERN_ERR, ap->host->dev,
2144 "failed to clear device error\n");
2145}
2146
2086static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) 2147static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
2087{ 2148{
2088 struct ahci_host_priv *hpriv = ap->host->private_data; 2149 struct ahci_host_priv *hpriv = ap->host->private_data;
@@ -2091,12 +2152,26 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
2091 struct ata_link *link = NULL; 2152 struct ata_link *link = NULL;
2092 struct ata_queued_cmd *active_qc; 2153 struct ata_queued_cmd *active_qc;
2093 struct ata_eh_info *active_ehi; 2154 struct ata_eh_info *active_ehi;
2155 bool fbs_need_dec = false;
2094 u32 serror; 2156 u32 serror;
2095 2157
2096 /* determine active link */ 2158 /* determine active link with error */
2097 ata_for_each_link(link, ap, EDGE) 2159 if (pp->fbs_enabled) {
2098 if (ata_link_active(link)) 2160 void __iomem *port_mmio = ahci_port_base(ap);
2099 break; 2161 u32 fbs = readl(port_mmio + PORT_FBS);
2162 int pmp = fbs >> PORT_FBS_DWE_OFFSET;
2163
2164 if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links) &&
2165 ata_link_online(&ap->pmp_link[pmp])) {
2166 link = &ap->pmp_link[pmp];
2167 fbs_need_dec = true;
2168 }
2169
2170 } else
2171 ata_for_each_link(link, ap, EDGE)
2172 if (ata_link_active(link))
2173 break;
2174
2100 if (!link) 2175 if (!link)
2101 link = &ap->link; 2176 link = &ap->link;
2102 2177
@@ -2153,8 +2228,13 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
2153 } 2228 }
2154 2229
2155 if (irq_stat & PORT_IRQ_IF_ERR) { 2230 if (irq_stat & PORT_IRQ_IF_ERR) {
2156 host_ehi->err_mask |= AC_ERR_ATA_BUS; 2231 if (fbs_need_dec)
2157 host_ehi->action |= ATA_EH_RESET; 2232 active_ehi->err_mask |= AC_ERR_DEV;
2233 else {
2234 host_ehi->err_mask |= AC_ERR_ATA_BUS;
2235 host_ehi->action |= ATA_EH_RESET;
2236 }
2237
2158 ata_ehi_push_desc(host_ehi, "interface fatal error"); 2238 ata_ehi_push_desc(host_ehi, "interface fatal error");
2159 } 2239 }
2160 2240
@@ -2169,7 +2249,10 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
2169 2249
2170 if (irq_stat & PORT_IRQ_FREEZE) 2250 if (irq_stat & PORT_IRQ_FREEZE)
2171 ata_port_freeze(ap); 2251 ata_port_freeze(ap);
2172 else 2252 else if (fbs_need_dec) {
2253 ata_link_abort(link);
2254 ahci_fbs_dec_intr(ap);
2255 } else
2173 ata_port_abort(ap); 2256 ata_port_abort(ap);
2174} 2257}
2175 2258
@@ -2222,12 +2305,19 @@ static void ahci_port_intr(struct ata_port *ap)
2222 /* If the 'N' bit in word 0 of the FIS is set, 2305 /* If the 'N' bit in word 0 of the FIS is set,
2223 * we just received asynchronous notification. 2306 * we just received asynchronous notification.
2224 * Tell libata about it. 2307 * Tell libata about it.
2308 *
2309 * Lack of SNotification should not appear in
2310 * ahci 1.2, so the workaround is unnecessary
2311 * when FBS is enabled.
2225 */ 2312 */
2226 const __le32 *f = pp->rx_fis + RX_FIS_SDB; 2313 if (pp->fbs_enabled)
2227 u32 f0 = le32_to_cpu(f[0]); 2314 WARN_ON_ONCE(1);
2228 2315 else {
2229 if (f0 & (1 << 15)) 2316 const __le32 *f = pp->rx_fis + RX_FIS_SDB;
2230 sata_async_notification(ap); 2317 u32 f0 = le32_to_cpu(f[0]);
2318 if (f0 & (1 << 15))
2319 sata_async_notification(ap);
2320 }
2231 } 2321 }
2232 } 2322 }
2233 2323
@@ -2321,6 +2411,15 @@ static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
2321 2411
2322 if (qc->tf.protocol == ATA_PROT_NCQ) 2412 if (qc->tf.protocol == ATA_PROT_NCQ)
2323 writel(1 << qc->tag, port_mmio + PORT_SCR_ACT); 2413 writel(1 << qc->tag, port_mmio + PORT_SCR_ACT);
2414
2415 if (pp->fbs_enabled && pp->fbs_last_dev != qc->dev->link->pmp) {
2416 u32 fbs = readl(port_mmio + PORT_FBS);
2417 fbs &= ~(PORT_FBS_DEV_MASK | PORT_FBS_DEC);
2418 fbs |= qc->dev->link->pmp << PORT_FBS_DEV_OFFSET;
2419 writel(fbs, port_mmio + PORT_FBS);
2420 pp->fbs_last_dev = qc->dev->link->pmp;
2421 }
2422
2324 writel(1 << qc->tag, port_mmio + PORT_CMD_ISSUE); 2423 writel(1 << qc->tag, port_mmio + PORT_CMD_ISSUE);
2325 2424
2326 ahci_sw_activity(qc->dev->link); 2425 ahci_sw_activity(qc->dev->link);
@@ -2333,6 +2432,9 @@ static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
2333 struct ahci_port_priv *pp = qc->ap->private_data; 2432 struct ahci_port_priv *pp = qc->ap->private_data;
2334 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; 2433 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
2335 2434
2435 if (pp->fbs_enabled)
2436 d2h_fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ;
2437
2336 ata_tf_from_fis(d2h_fis, &qc->result_tf); 2438 ata_tf_from_fis(d2h_fis, &qc->result_tf);
2337 return true; 2439 return true;
2338} 2440}
@@ -2381,6 +2483,71 @@ static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
2381 ahci_kick_engine(ap); 2483 ahci_kick_engine(ap);
2382} 2484}
2383 2485
2486static void ahci_enable_fbs(struct ata_port *ap)
2487{
2488 struct ahci_port_priv *pp = ap->private_data;
2489 void __iomem *port_mmio = ahci_port_base(ap);
2490 u32 fbs;
2491 int rc;
2492
2493 if (!pp->fbs_supported)
2494 return;
2495
2496 fbs = readl(port_mmio + PORT_FBS);
2497 if (fbs & PORT_FBS_EN) {
2498 pp->fbs_enabled = true;
2499 pp->fbs_last_dev = -1; /* initialization */
2500 return;
2501 }
2502
2503 rc = ahci_stop_engine(ap);
2504 if (rc)
2505 return;
2506
2507 writel(fbs | PORT_FBS_EN, port_mmio + PORT_FBS);
2508 fbs = readl(port_mmio + PORT_FBS);
2509 if (fbs & PORT_FBS_EN) {
2510 dev_printk(KERN_INFO, ap->host->dev, "FBS is enabled.\n");
2511 pp->fbs_enabled = true;
2512 pp->fbs_last_dev = -1; /* initialization */
2513 } else
2514 dev_printk(KERN_ERR, ap->host->dev, "Failed to enable FBS\n");
2515
2516 ahci_start_engine(ap);
2517}
2518
2519static void ahci_disable_fbs(struct ata_port *ap)
2520{
2521 struct ahci_port_priv *pp = ap->private_data;
2522 void __iomem *port_mmio = ahci_port_base(ap);
2523 u32 fbs;
2524 int rc;
2525
2526 if (!pp->fbs_supported)
2527 return;
2528
2529 fbs = readl(port_mmio + PORT_FBS);
2530 if ((fbs & PORT_FBS_EN) == 0) {
2531 pp->fbs_enabled = false;
2532 return;
2533 }
2534
2535 rc = ahci_stop_engine(ap);
2536 if (rc)
2537 return;
2538
2539 writel(fbs & ~PORT_FBS_EN, port_mmio + PORT_FBS);
2540 fbs = readl(port_mmio + PORT_FBS);
2541 if (fbs & PORT_FBS_EN)
2542 dev_printk(KERN_ERR, ap->host->dev, "Failed to disable FBS\n");
2543 else {
2544 dev_printk(KERN_INFO, ap->host->dev, "FBS is disabled.\n");
2545 pp->fbs_enabled = false;
2546 }
2547
2548 ahci_start_engine(ap);
2549}
2550
2384static void ahci_pmp_attach(struct ata_port *ap) 2551static void ahci_pmp_attach(struct ata_port *ap)
2385{ 2552{
2386 void __iomem *port_mmio = ahci_port_base(ap); 2553 void __iomem *port_mmio = ahci_port_base(ap);
@@ -2391,6 +2558,8 @@ static void ahci_pmp_attach(struct ata_port *ap)
2391 cmd |= PORT_CMD_PMP; 2558 cmd |= PORT_CMD_PMP;
2392 writel(cmd, port_mmio + PORT_CMD); 2559 writel(cmd, port_mmio + PORT_CMD);
2393 2560
2561 ahci_enable_fbs(ap);
2562
2394 pp->intr_mask |= PORT_IRQ_BAD_PMP; 2563 pp->intr_mask |= PORT_IRQ_BAD_PMP;
2395 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); 2564 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
2396} 2565}
@@ -2401,6 +2570,8 @@ static void ahci_pmp_detach(struct ata_port *ap)
2401 struct ahci_port_priv *pp = ap->private_data; 2570 struct ahci_port_priv *pp = ap->private_data;
2402 u32 cmd; 2571 u32 cmd;
2403 2572
2573 ahci_disable_fbs(ap);
2574
2404 cmd = readl(port_mmio + PORT_CMD); 2575 cmd = readl(port_mmio + PORT_CMD);
2405 cmd &= ~PORT_CMD_PMP; 2576 cmd &= ~PORT_CMD_PMP;
2406 writel(cmd, port_mmio + PORT_CMD); 2577 writel(cmd, port_mmio + PORT_CMD);
@@ -2492,20 +2663,40 @@ static int ahci_pci_device_resume(struct pci_dev *pdev)
2492 2663
2493static int ahci_port_start(struct ata_port *ap) 2664static int ahci_port_start(struct ata_port *ap)
2494{ 2665{
2666 struct ahci_host_priv *hpriv = ap->host->private_data;
2495 struct device *dev = ap->host->dev; 2667 struct device *dev = ap->host->dev;
2496 struct ahci_port_priv *pp; 2668 struct ahci_port_priv *pp;
2497 void *mem; 2669 void *mem;
2498 dma_addr_t mem_dma; 2670 dma_addr_t mem_dma;
2671 size_t dma_sz, rx_fis_sz;
2499 2672
2500 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); 2673 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
2501 if (!pp) 2674 if (!pp)
2502 return -ENOMEM; 2675 return -ENOMEM;
2503 2676
2504 mem = dmam_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, 2677 /* check FBS capability */
2505 GFP_KERNEL); 2678 if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) {
2679 void __iomem *port_mmio = ahci_port_base(ap);
2680 u32 cmd = readl(port_mmio + PORT_CMD);
2681 if (cmd & PORT_CMD_FBSCP)
2682 pp->fbs_supported = true;
2683 else
2684 dev_printk(KERN_WARNING, dev,
2685 "The port is not capable of FBS\n");
2686 }
2687
2688 if (pp->fbs_supported) {
2689 dma_sz = AHCI_PORT_PRIV_FBS_DMA_SZ;
2690 rx_fis_sz = AHCI_RX_FIS_SZ * 16;
2691 } else {
2692 dma_sz = AHCI_PORT_PRIV_DMA_SZ;
2693 rx_fis_sz = AHCI_RX_FIS_SZ;
2694 }
2695
2696 mem = dmam_alloc_coherent(dev, dma_sz, &mem_dma, GFP_KERNEL);
2506 if (!mem) 2697 if (!mem)
2507 return -ENOMEM; 2698 return -ENOMEM;
2508 memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ); 2699 memset(mem, 0, dma_sz);
2509 2700
2510 /* 2701 /*
2511 * First item in chunk of DMA memory: 32-slot command table, 2702 * First item in chunk of DMA memory: 32-slot command table,
@@ -2523,8 +2714,8 @@ static int ahci_port_start(struct ata_port *ap)
2523 pp->rx_fis = mem; 2714 pp->rx_fis = mem;
2524 pp->rx_fis_dma = mem_dma; 2715 pp->rx_fis_dma = mem_dma;
2525 2716
2526 mem += AHCI_RX_FIS_SZ; 2717 mem += rx_fis_sz;
2527 mem_dma += AHCI_RX_FIS_SZ; 2718 mem_dma += rx_fis_sz;
2528 2719
2529 /* 2720 /*
2530 * Third item: data area for storing a single command 2721 * Third item: data area for storing a single command
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 12e26c3c68e3..33fb614f9784 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -155,7 +155,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
155 return rc; 155 return rc;
156 pcim_pin_device(dev); 156 pcim_pin_device(dev);
157 } 157 }
158 return ata_pci_sff_init_one(dev, ppi, &generic_sht, NULL); 158 return ata_pci_sff_init_one(dev, ppi, &generic_sht, NULL, 0);
159} 159}
160 160
161static struct pci_device_id ata_generic[] = { 161static struct pci_device_id ata_generic[] = {
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 6f3f2257d0f0..c33806654e46 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -173,6 +173,7 @@ static int piix_sidpr_scr_read(struct ata_link *link,
173 unsigned int reg, u32 *val); 173 unsigned int reg, u32 *val);
174static int piix_sidpr_scr_write(struct ata_link *link, 174static int piix_sidpr_scr_write(struct ata_link *link,
175 unsigned int reg, u32 val); 175 unsigned int reg, u32 val);
176static bool piix_irq_check(struct ata_port *ap);
176#ifdef CONFIG_PM 177#ifdef CONFIG_PM
177static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); 178static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
178static int piix_pci_device_resume(struct pci_dev *pdev); 179static int piix_pci_device_resume(struct pci_dev *pdev);
@@ -291,6 +292,14 @@ static const struct pci_device_id piix_pci_tbl[] = {
291 { 0x8086, 0x3b2d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, 292 { 0x8086, 0x3b2d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
292 /* SATA Controller IDE (PCH) */ 293 /* SATA Controller IDE (PCH) */
293 { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 294 { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
295 /* SATA Controller IDE (CPT) */
296 { 0x8086, 0x1c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
297 /* SATA Controller IDE (CPT) */
298 { 0x8086, 0x1c01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
299 /* SATA Controller IDE (CPT) */
300 { 0x8086, 0x1c08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
301 /* SATA Controller IDE (CPT) */
302 { 0x8086, 0x1c09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
294 { } /* terminate list */ 303 { } /* terminate list */
295}; 304};
296 305
@@ -309,8 +318,13 @@ static struct scsi_host_template piix_sht = {
309 ATA_BMDMA_SHT(DRV_NAME), 318 ATA_BMDMA_SHT(DRV_NAME),
310}; 319};
311 320
312static struct ata_port_operations piix_pata_ops = { 321static struct ata_port_operations piix_sata_ops = {
313 .inherits = &ata_bmdma32_port_ops, 322 .inherits = &ata_bmdma32_port_ops,
323 .sff_irq_check = piix_irq_check,
324};
325
326static struct ata_port_operations piix_pata_ops = {
327 .inherits = &piix_sata_ops,
314 .cable_detect = ata_cable_40wire, 328 .cable_detect = ata_cable_40wire,
315 .set_piomode = piix_set_piomode, 329 .set_piomode = piix_set_piomode,
316 .set_dmamode = piix_set_dmamode, 330 .set_dmamode = piix_set_dmamode,
@@ -328,10 +342,6 @@ static struct ata_port_operations ich_pata_ops = {
328 .set_dmamode = ich_set_dmamode, 342 .set_dmamode = ich_set_dmamode,
329}; 343};
330 344
331static struct ata_port_operations piix_sata_ops = {
332 .inherits = &ata_bmdma32_port_ops,
333};
334
335static struct ata_port_operations piix_sidpr_sata_ops = { 345static struct ata_port_operations piix_sidpr_sata_ops = {
336 .inherits = &piix_sata_ops, 346 .inherits = &piix_sata_ops,
337 .hardreset = sata_std_hardreset, 347 .hardreset = sata_std_hardreset,
@@ -962,6 +972,14 @@ static int piix_sidpr_scr_write(struct ata_link *link,
962 return 0; 972 return 0;
963} 973}
964 974
975static bool piix_irq_check(struct ata_port *ap)
976{
977 if (unlikely(!ap->ioaddr.bmdma_addr))
978 return false;
979
980 return ap->ops->bmdma_status(ap) & ATA_DMA_INTR;
981}
982
965#ifdef CONFIG_PM 983#ifdef CONFIG_PM
966static int piix_broken_suspend(void) 984static int piix_broken_suspend(void)
967{ 985{
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 1245838ac13d..292fdbc0431a 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -64,7 +64,7 @@ void ata_acpi_associate_sata_port(struct ata_port *ap)
64 WARN_ON(!(ap->flags & ATA_FLAG_ACPI_SATA)); 64 WARN_ON(!(ap->flags & ATA_FLAG_ACPI_SATA));
65 65
66 if (!sata_pmp_attached(ap)) { 66 if (!sata_pmp_attached(ap)) {
67 acpi_integer adr = SATA_ADR(ap->port_no, NO_PORT_MULT); 67 u64 adr = SATA_ADR(ap->port_no, NO_PORT_MULT);
68 68
69 ap->link.device->acpi_handle = 69 ap->link.device->acpi_handle =
70 acpi_get_child(ap->host->acpi_handle, adr); 70 acpi_get_child(ap->host->acpi_handle, adr);
@@ -74,7 +74,7 @@ void ata_acpi_associate_sata_port(struct ata_port *ap)
74 ap->link.device->acpi_handle = NULL; 74 ap->link.device->acpi_handle = NULL;
75 75
76 ata_for_each_link(link, ap, EDGE) { 76 ata_for_each_link(link, ap, EDGE) {
77 acpi_integer adr = SATA_ADR(ap->port_no, link->pmp); 77 u64 adr = SATA_ADR(ap->port_no, link->pmp);
78 78
79 link->device->acpi_handle = 79 link->device->acpi_handle =
80 acpi_get_child(ap->host->acpi_handle, adr); 80 acpi_get_child(ap->host->acpi_handle, adr);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 6728328f3bea..9c77b0d1a9d0 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3211,6 +3211,7 @@ const struct ata_timing *ata_timing_find_mode(u8 xfer_mode)
3211int ata_timing_compute(struct ata_device *adev, unsigned short speed, 3211int ata_timing_compute(struct ata_device *adev, unsigned short speed,
3212 struct ata_timing *t, int T, int UT) 3212 struct ata_timing *t, int T, int UT)
3213{ 3213{
3214 const u16 *id = adev->id;
3214 const struct ata_timing *s; 3215 const struct ata_timing *s;
3215 struct ata_timing p; 3216 struct ata_timing p;
3216 3217
@@ -3228,14 +3229,18 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
3228 * PIO/MW_DMA cycle timing. 3229 * PIO/MW_DMA cycle timing.
3229 */ 3230 */
3230 3231
3231 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */ 3232 if (id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */
3232 memset(&p, 0, sizeof(p)); 3233 memset(&p, 0, sizeof(p));
3234
3233 if (speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) { 3235 if (speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) {
3234 if (speed <= XFER_PIO_2) p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO]; 3236 if (speed <= XFER_PIO_2)
3235 else p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO_IORDY]; 3237 p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO];
3236 } else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) { 3238 else if ((speed <= XFER_PIO_4) ||
3237 p.cycle = adev->id[ATA_ID_EIDE_DMA_MIN]; 3239 (speed == XFER_PIO_5 && !ata_id_is_cfa(id)))
3238 } 3240 p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO_IORDY];
3241 } else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2)
3242 p.cycle = id[ATA_ID_EIDE_DMA_MIN];
3243
3239 ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B); 3244 ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B);
3240 } 3245 }
3241 3246
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index d096fbcbc771..bea003a24d27 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1097,7 +1097,7 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
1097 dev->flags |= ATA_DFLAG_NO_UNLOAD; 1097 dev->flags |= ATA_DFLAG_NO_UNLOAD;
1098 1098
1099 /* configure max sectors */ 1099 /* configure max sectors */
1100 blk_queue_max_sectors(sdev->request_queue, dev->max_sectors); 1100 blk_queue_max_hw_sectors(sdev->request_queue, dev->max_sectors);
1101 1101
1102 if (dev->class == ATA_DEV_ATAPI) { 1102 if (dev->class == ATA_DEV_ATAPI) {
1103 struct request_queue *q = sdev->request_queue; 1103 struct request_queue *q = sdev->request_queue;
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 730ef3c384ca..02441fd57e9e 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1763,24 +1763,50 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
1763{ 1763{
1764 struct ata_host *host = dev_instance; 1764 struct ata_host *host = dev_instance;
1765 unsigned int i; 1765 unsigned int i;
1766 unsigned int handled = 0; 1766 unsigned int handled = 0, polling = 0;
1767 unsigned long flags; 1767 unsigned long flags;
1768 1768
1769 /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ 1769 /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */
1770 spin_lock_irqsave(&host->lock, flags); 1770 spin_lock_irqsave(&host->lock, flags);
1771 1771
1772 for (i = 0; i < host->n_ports; i++) { 1772 for (i = 0; i < host->n_ports; i++) {
1773 struct ata_port *ap; 1773 struct ata_port *ap = host->ports[i];
1774 struct ata_queued_cmd *qc;
1774 1775
1775 ap = host->ports[i]; 1776 if (unlikely(ap->flags & ATA_FLAG_DISABLED))
1776 if (ap && 1777 continue;
1777 !(ap->flags & ATA_FLAG_DISABLED)) {
1778 struct ata_queued_cmd *qc;
1779 1778
1780 qc = ata_qc_from_tag(ap, ap->link.active_tag); 1779 qc = ata_qc_from_tag(ap, ap->link.active_tag);
1781 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) && 1780 if (qc) {
1782 (qc->flags & ATA_QCFLAG_ACTIVE)) 1781 if (!(qc->tf.flags & ATA_TFLAG_POLLING))
1783 handled |= ata_sff_host_intr(ap, qc); 1782 handled |= ata_sff_host_intr(ap, qc);
1783 else
1784 polling |= 1 << i;
1785 }
1786 }
1787
1788 /*
1789 * If no port was expecting IRQ but the controller is actually
1790 * asserting IRQ line, nobody cared will ensue. Check IRQ
1791 * pending status if available and clear spurious IRQ.
1792 */
1793 if (!handled) {
1794 for (i = 0; i < host->n_ports; i++) {
1795 struct ata_port *ap = host->ports[i];
1796
1797 if (polling & (1 << i))
1798 continue;
1799
1800 if (!ap->ops->sff_irq_check ||
1801 !ap->ops->sff_irq_check(ap))
1802 continue;
1803
1804 if (printk_ratelimit())
1805 ata_port_printk(ap, KERN_INFO,
1806 "clearing spurious IRQ\n");
1807
1808 ap->ops->sff_check_status(ap);
1809 ap->ops->sff_irq_clear(ap);
1784 } 1810 }
1785 } 1811 }
1786 1812
@@ -3011,6 +3037,7 @@ EXPORT_SYMBOL_GPL(ata_pci_sff_activate_host);
3011 * @ppi: array of port_info, must be enough for two ports 3037 * @ppi: array of port_info, must be enough for two ports
3012 * @sht: scsi_host_template to use when registering the host 3038 * @sht: scsi_host_template to use when registering the host
3013 * @host_priv: host private_data 3039 * @host_priv: host private_data
3040 * @hflag: host flags
3014 * 3041 *
3015 * This is a helper function which can be called from a driver's 3042 * This is a helper function which can be called from a driver's
3016 * xxx_init_one() probe function if the hardware uses traditional 3043 * xxx_init_one() probe function if the hardware uses traditional
@@ -3031,8 +3058,8 @@ EXPORT_SYMBOL_GPL(ata_pci_sff_activate_host);
3031 * Zero on success, negative on errno-based value on error. 3058 * Zero on success, negative on errno-based value on error.
3032 */ 3059 */
3033int ata_pci_sff_init_one(struct pci_dev *pdev, 3060int ata_pci_sff_init_one(struct pci_dev *pdev,
3034 const struct ata_port_info * const *ppi, 3061 const struct ata_port_info * const *ppi,
3035 struct scsi_host_template *sht, void *host_priv) 3062 struct scsi_host_template *sht, void *host_priv, int hflag)
3036{ 3063{
3037 struct device *dev = &pdev->dev; 3064 struct device *dev = &pdev->dev;
3038 const struct ata_port_info *pi = NULL; 3065 const struct ata_port_info *pi = NULL;
@@ -3067,6 +3094,7 @@ int ata_pci_sff_init_one(struct pci_dev *pdev,
3067 if (rc) 3094 if (rc)
3068 goto out; 3095 goto out;
3069 host->private_data = host_priv; 3096 host->private_data = host_priv;
3097 host->flags |= hflag;
3070 3098
3071 pci_set_master(pdev); 3099 pci_set_master(pdev);
3072 rc = ata_pci_sff_activate_host(host, ata_sff_interrupt, sht); 3100 rc = ata_pci_sff_activate_host(host, ata_sff_interrupt, sht);
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index d8f35fe44421..294f3020a78a 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -259,7 +259,7 @@ static int pacpi_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
259 return rc; 259 return rc;
260 pcim_pin_device(pdev); 260 pcim_pin_device(pdev);
261 } 261 }
262 return ata_pci_sff_init_one(pdev, ppi, &pacpi_sht, NULL); 262 return ata_pci_sff_init_one(pdev, ppi, &pacpi_sht, NULL, 0);
263} 263}
264 264
265static const struct pci_device_id pacpi_pci_tbl[] = { 265static const struct pci_device_id pacpi_pci_tbl[] = {
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 9434114b2ca8..dc61b72f751c 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -159,8 +159,7 @@ static void ali_fifo_control(struct ata_port *ap, struct ata_device *adev, int o
159 * ali_program_modes - load mode registers 159 * ali_program_modes - load mode registers
160 * @ap: ALi channel to load 160 * @ap: ALi channel to load
161 * @adev: Device the timing is for 161 * @adev: Device the timing is for
162 * @cmd: Command timing 162 * @t: timing data
163 * @data: Data timing
164 * @ultra: UDMA timing or zero for off 163 * @ultra: UDMA timing or zero for off
165 * 164 *
166 * Loads the timing registers for cmd/data and disable UDMA if 165 * Loads the timing registers for cmd/data and disable UDMA if
@@ -202,8 +201,7 @@ static void ali_program_modes(struct ata_port *ap, struct ata_device *adev, stru
202 * @ap: ATA interface 201 * @ap: ATA interface
203 * @adev: ATA device 202 * @adev: ATA device
204 * 203 *
205 * Program the ALi registers for PIO mode. FIXME: add timings for 204 * Program the ALi registers for PIO mode.
206 * PIO5.
207 */ 205 */
208 206
209static void ali_set_piomode(struct ata_port *ap, struct ata_device *adev) 207static void ali_set_piomode(struct ata_port *ap, struct ata_device *adev)
@@ -237,7 +235,7 @@ static void ali_set_piomode(struct ata_port *ap, struct ata_device *adev)
237 * @ap: ATA interface 235 * @ap: ATA interface
238 * @adev: ATA device 236 * @adev: ATA device
239 * 237 *
240 * FIXME: MWDMA timings 238 * Program the ALi registers for DMA mode.
241 */ 239 */
242 240
243static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev) 241static void ali_set_dmamode(struct ata_port *ap, struct ata_device *adev)
@@ -585,7 +583,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
585 ppi[0] = &info_20_udma; 583 ppi[0] = &info_20_udma;
586 } 584 }
587 585
588 return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL); 586 return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL, 0);
589} 587}
590 588
591#ifdef CONFIG_PM 589#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 567f3f72774e..d95eca9c547e 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -574,7 +574,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
574 } 574 }
575 575
576 /* And fire it up */ 576 /* And fire it up */
577 return ata_pci_sff_init_one(pdev, ppi, &amd_sht, hpriv); 577 return ata_pci_sff_init_one(pdev, ppi, &amd_sht, hpriv, 0);
578} 578}
579 579
580#ifdef CONFIG_PM 580#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index d332cfdb0f30..4d066d6c30fa 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -421,7 +421,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
421 421
422 BUG_ON(ppi[0] == NULL); 422 BUG_ON(ppi[0] == NULL);
423 423
424 return ata_pci_sff_init_one(pdev, ppi, &artop_sht, NULL); 424 return ata_pci_sff_init_one(pdev, ppi, &artop_sht, NULL, 0);
425} 425}
426 426
427static const struct pci_device_id artop_pci_tbl[] = { 427static const struct pci_device_id artop_pci_tbl[] = {
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index 41c94b1ae493..376dd380b43c 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -153,8 +153,8 @@ static void pata_at91_set_piomode(struct ata_port *ap, struct ata_device *adev)
153 /* Compute ATA timing and set it to SMC */ 153 /* Compute ATA timing and set it to SMC */
154 ret = ata_timing_compute(adev, adev->pio_mode, &timing, 1000, 0); 154 ret = ata_timing_compute(adev, adev->pio_mode, &timing, 1000, 0);
155 if (ret) { 155 if (ret) {
156 dev_warn(ap->dev, "Failed to compute ATA timing %d, \ 156 dev_warn(ap->dev, "Failed to compute ATA timing %d, "
157 set PIO_0 timing\n", ret); 157 "set PIO_0 timing\n", ret);
158 set_smc_timing(ap->dev, info, &initial_timing); 158 set_smc_timing(ap->dev, info, &initial_timing);
159 } else { 159 } else {
160 set_smc_timing(ap->dev, info, &timing); 160 set_smc_timing(ap->dev, info, &timing);
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index ae4454d4e955..cbaf2eddac6b 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * pata_atiixp.c - ATI PATA for new ATA layer 2 * pata_atiixp.c - ATI PATA for new ATA layer
3 * (C) 2005 Red Hat Inc 3 * (C) 2005 Red Hat Inc
4 * (C) 2009 Bartlomiej Zolnierkiewicz 4 * (C) 2009-2010 Bartlomiej Zolnierkiewicz
5 * 5 *
6 * Based on 6 * Based on
7 * 7 *
@@ -46,6 +46,8 @@ static int atiixp_cable_detect(struct ata_port *ap)
46 return ATA_CBL_PATA40; 46 return ATA_CBL_PATA40;
47} 47}
48 48
49static DEFINE_SPINLOCK(atiixp_lock);
50
49/** 51/**
50 * atiixp_set_pio_timing - set initial PIO mode data 52 * atiixp_set_pio_timing - set initial PIO mode data
51 * @ap: ATA interface 53 * @ap: ATA interface
@@ -88,7 +90,10 @@ static void atiixp_set_pio_timing(struct ata_port *ap, struct ata_device *adev,
88 90
89static void atiixp_set_piomode(struct ata_port *ap, struct ata_device *adev) 91static void atiixp_set_piomode(struct ata_port *ap, struct ata_device *adev)
90{ 92{
93 unsigned long flags;
94 spin_lock_irqsave(&atiixp_lock, flags);
91 atiixp_set_pio_timing(ap, adev, adev->pio_mode - XFER_PIO_0); 95 atiixp_set_pio_timing(ap, adev, adev->pio_mode - XFER_PIO_0);
96 spin_unlock_irqrestore(&atiixp_lock, flags);
92} 97}
93 98
94/** 99/**
@@ -108,6 +113,9 @@ static void atiixp_set_dmamode(struct ata_port *ap, struct ata_device *adev)
108 int dma = adev->dma_mode; 113 int dma = adev->dma_mode;
109 int dn = 2 * ap->port_no + adev->devno; 114 int dn = 2 * ap->port_no + adev->devno;
110 int wanted_pio; 115 int wanted_pio;
116 unsigned long flags;
117
118 spin_lock_irqsave(&atiixp_lock, flags);
111 119
112 if (adev->dma_mode >= XFER_UDMA_0) { 120 if (adev->dma_mode >= XFER_UDMA_0) {
113 u16 udma_mode_data; 121 u16 udma_mode_data;
@@ -145,6 +153,7 @@ static void atiixp_set_dmamode(struct ata_port *ap, struct ata_device *adev)
145 153
146 if (adev->pio_mode != wanted_pio) 154 if (adev->pio_mode != wanted_pio)
147 atiixp_set_pio_timing(ap, adev, wanted_pio); 155 atiixp_set_pio_timing(ap, adev, wanted_pio);
156 spin_unlock_irqrestore(&atiixp_lock, flags);
148} 157}
149 158
150/** 159/**
@@ -237,7 +246,8 @@ static int atiixp_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
237 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[i])) 246 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[i]))
238 ppi[i] = &ata_dummy_port_info; 247 ppi[i] = &ata_dummy_port_info;
239 248
240 return ata_pci_sff_init_one(pdev, ppi, &atiixp_sht, NULL); 249 return ata_pci_sff_init_one(pdev, ppi, &atiixp_sht, NULL,
250 ATA_HOST_PARALLEL_SCAN);
241} 251}
242 252
243static const struct pci_device_id atiixp[] = { 253static const struct pci_device_id atiixp[] = {
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c
index 5acf9fa9b39f..6cd5d5dd9e3b 100644
--- a/drivers/ata/pata_cmd640.c
+++ b/drivers/ata/pata_cmd640.c
@@ -223,7 +223,7 @@ static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
223 223
224 cmd640_hardware_init(pdev); 224 cmd640_hardware_init(pdev);
225 225
226 return ata_pci_sff_init_one(pdev, ppi, &cmd640_sht, NULL); 226 return ata_pci_sff_init_one(pdev, ppi, &cmd640_sht, NULL, 0);
227} 227}
228 228
229#ifdef CONFIG_PM 229#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index 0efb1f58f255..4c81a71b8877 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -2,6 +2,7 @@
2 * pata_cmd64x.c - CMD64x PATA for new ATA layer 2 * pata_cmd64x.c - CMD64x PATA for new ATA layer
3 * (C) 2005 Red Hat Inc 3 * (C) 2005 Red Hat Inc
4 * Alan Cox <alan@lxorguk.ukuu.org.uk> 4 * Alan Cox <alan@lxorguk.ukuu.org.uk>
5 * (C) 2009-2010 Bartlomiej Zolnierkiewicz
5 * 6 *
6 * Based upon 7 * Based upon
7 * linux/drivers/ide/pci/cmd64x.c Version 1.30 Sept 10, 2002 8 * linux/drivers/ide/pci/cmd64x.c Version 1.30 Sept 10, 2002
@@ -39,11 +40,7 @@
39 40
40enum { 41enum {
41 CFR = 0x50, 42 CFR = 0x50,
42 CFR_INTR_CH0 = 0x02, 43 CFR_INTR_CH0 = 0x04,
43 CNTRL = 0x51,
44 CNTRL_DIS_RA0 = 0x40,
45 CNTRL_DIS_RA1 = 0x80,
46 CNTRL_ENA_2ND = 0x08,
47 CMDTIM = 0x52, 44 CMDTIM = 0x52,
48 ARTTIM0 = 0x53, 45 ARTTIM0 = 0x53,
49 DRWTIM0 = 0x54, 46 DRWTIM0 = 0x54,
@@ -53,9 +50,6 @@ enum {
53 ARTTIM23_DIS_RA2 = 0x04, 50 ARTTIM23_DIS_RA2 = 0x04,
54 ARTTIM23_DIS_RA3 = 0x08, 51 ARTTIM23_DIS_RA3 = 0x08,
55 ARTTIM23_INTR_CH1 = 0x10, 52 ARTTIM23_INTR_CH1 = 0x10,
56 ARTTIM2 = 0x57,
57 ARTTIM3 = 0x57,
58 DRWTIM23 = 0x58,
59 DRWTIM2 = 0x58, 53 DRWTIM2 = 0x58,
60 BRST = 0x59, 54 BRST = 0x59,
61 DRWTIM3 = 0x5b, 55 DRWTIM3 = 0x5b,
@@ -63,14 +57,11 @@ enum {
63 MRDMODE = 0x71, 57 MRDMODE = 0x71,
64 MRDMODE_INTR_CH0 = 0x04, 58 MRDMODE_INTR_CH0 = 0x04,
65 MRDMODE_INTR_CH1 = 0x08, 59 MRDMODE_INTR_CH1 = 0x08,
66 MRDMODE_BLK_CH0 = 0x10,
67 MRDMODE_BLK_CH1 = 0x20,
68 BMIDESR0 = 0x72, 60 BMIDESR0 = 0x72,
69 UDIDETCR0 = 0x73, 61 UDIDETCR0 = 0x73,
70 DTPR0 = 0x74, 62 DTPR0 = 0x74,
71 BMIDECR1 = 0x78, 63 BMIDECR1 = 0x78,
72 BMIDECSR = 0x79, 64 BMIDECSR = 0x79,
73 BMIDESR1 = 0x7A,
74 UDIDETCR1 = 0x7B, 65 UDIDETCR1 = 0x7B,
75 DTPR1 = 0x7C 66 DTPR1 = 0x7C
76}; 67};
@@ -130,8 +121,14 @@ static void cmd64x_set_timing(struct ata_port *ap, struct ata_device *adev, u8 m
130 121
131 if (pair) { 122 if (pair) {
132 struct ata_timing tp; 123 struct ata_timing tp;
124
133 ata_timing_compute(pair, pair->pio_mode, &tp, T, 0); 125 ata_timing_compute(pair, pair->pio_mode, &tp, T, 0);
134 ata_timing_merge(&t, &tp, &t, ATA_TIMING_SETUP); 126 ata_timing_merge(&t, &tp, &t, ATA_TIMING_SETUP);
127 if (pair->dma_mode) {
128 ata_timing_compute(pair, pair->dma_mode,
129 &tp, T, 0);
130 ata_timing_merge(&tp, &t, &t, ATA_TIMING_SETUP);
131 }
135 } 132 }
136 } 133 }
137 134
@@ -147,7 +144,9 @@ static void cmd64x_set_timing(struct ata_port *ap, struct ata_device *adev, u8 m
147 /* Now convert the clocks into values we can actually stuff into 144 /* Now convert the clocks into values we can actually stuff into
148 the chip */ 145 the chip */
149 146
150 if (t.recover > 1) 147 if (t.recover == 16)
148 t.recover = 0;
149 else if (t.recover > 1)
151 t.recover--; 150 t.recover--;
152 else 151 else
153 t.recover = 15; 152 t.recover = 15;
@@ -245,7 +244,7 @@ static void cmd648_bmdma_stop(struct ata_queued_cmd *qc)
245 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 244 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
246 u8 dma_intr; 245 u8 dma_intr;
247 int dma_mask = ap->port_no ? ARTTIM23_INTR_CH1 : CFR_INTR_CH0; 246 int dma_mask = ap->port_no ? ARTTIM23_INTR_CH1 : CFR_INTR_CH0;
248 int dma_reg = ap->port_no ? ARTTIM2 : CFR; 247 int dma_reg = ap->port_no ? ARTTIM23 : CFR;
249 248
250 ata_bmdma_stop(qc); 249 ata_bmdma_stop(qc);
251 250
@@ -368,7 +367,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
368 pci_write_config_byte(pdev, UDIDETCR0, 0xF0); 367 pci_write_config_byte(pdev, UDIDETCR0, 0xF0);
369#endif 368#endif
370 369
371 return ata_pci_sff_init_one(pdev, ppi, &cmd64x_sht, NULL); 370 return ata_pci_sff_init_one(pdev, ppi, &cmd64x_sht, NULL, 0);
372} 371}
373 372
374#ifdef CONFIG_PM 373#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index c974b05e4129..738ad2e14a97 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -324,7 +324,7 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
324 ppi[1] = &info_palmax_secondary; 324 ppi[1] = &info_palmax_secondary;
325 325
326 /* Now kick off ATA set up */ 326 /* Now kick off ATA set up */
327 return ata_pci_sff_init_one(pdev, ppi, &cs5530_sht, NULL); 327 return ata_pci_sff_init_one(pdev, ppi, &cs5530_sht, NULL, 0);
328} 328}
329 329
330#ifdef CONFIG_PM 330#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index 71cef9a962d4..a02e6459fdcc 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -100,7 +100,7 @@ static int cs5535_cable_detect(struct ata_port *ap)
100static void cs5535_set_piomode(struct ata_port *ap, struct ata_device *adev) 100static void cs5535_set_piomode(struct ata_port *ap, struct ata_device *adev)
101{ 101{
102 static const u16 pio_timings[5] = { 102 static const u16 pio_timings[5] = {
103 0xF7F4, 0x53F3, 0x13F1, 0x5131, 0x1131 103 0xF7F4, 0xF173, 0x8141, 0x5131, 0x1131
104 }; 104 };
105 static const u16 pio_cmd_timings[5] = { 105 static const u16 pio_cmd_timings[5] = {
106 0xF7F4, 0x53F3, 0x13F1, 0x5131, 0x1131 106 0xF7F4, 0x53F3, 0x13F1, 0x5131, 0x1131
@@ -198,7 +198,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
198 rdmsr(ATAC_CH0D1_PIO, timings, dummy); 198 rdmsr(ATAC_CH0D1_PIO, timings, dummy);
199 if (CS5535_BAD_PIO(timings)) 199 if (CS5535_BAD_PIO(timings))
200 wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0); 200 wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0);
201 return ata_pci_sff_init_one(dev, ppi, &cs5535_sht, NULL); 201 return ata_pci_sff_init_one(dev, ppi, &cs5535_sht, NULL, 0);
202} 202}
203 203
204static const struct pci_device_id cs5535[] = { 204static const struct pci_device_id cs5535[] = {
diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c
index ffee3978ec83..914ae3506ff5 100644
--- a/drivers/ata/pata_cs5536.c
+++ b/drivers/ata/pata_cs5536.c
@@ -260,7 +260,7 @@ static int cs5536_init_one(struct pci_dev *dev, const struct pci_device_id *id)
260 return -ENODEV; 260 return -ENODEV;
261 } 261 }
262 262
263 return ata_pci_sff_init_one(dev, ppi, &cs5536_sht, NULL); 263 return ata_pci_sff_init_one(dev, ppi, &cs5536_sht, NULL, 0);
264} 264}
265 265
266static const struct pci_device_id cs5536[] = { 266static const struct pci_device_id cs5536[] = {
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c
index 8fb040bf7361..0fcc096b8dac 100644
--- a/drivers/ata/pata_cypress.c
+++ b/drivers/ata/pata_cypress.c
@@ -62,14 +62,16 @@ static void cy82c693_set_piomode(struct ata_port *ap, struct ata_device *adev)
62 return; 62 return;
63 } 63 }
64 64
65 time_16 = clamp_val(t.recover, 0, 15) | (clamp_val(t.active, 0, 15) << 4); 65 time_16 = clamp_val(t.recover - 1, 0, 15) |
66 time_8 = clamp_val(t.act8b, 0, 15) | (clamp_val(t.rec8b, 0, 15) << 4); 66 (clamp_val(t.active - 1, 0, 15) << 4);
67 time_8 = clamp_val(t.act8b - 1, 0, 15) |
68 (clamp_val(t.rec8b - 1, 0, 15) << 4);
67 69
68 if (adev->devno == 0) { 70 if (adev->devno == 0) {
69 pci_read_config_dword(pdev, CY82_IDE_ADDRSETUP, &addr); 71 pci_read_config_dword(pdev, CY82_IDE_ADDRSETUP, &addr);
70 72
71 addr &= ~0x0F; /* Mask bits */ 73 addr &= ~0x0F; /* Mask bits */
72 addr |= clamp_val(t.setup, 0, 15); 74 addr |= clamp_val(t.setup - 1, 0, 15);
73 75
74 pci_write_config_dword(pdev, CY82_IDE_ADDRSETUP, addr); 76 pci_write_config_dword(pdev, CY82_IDE_ADDRSETUP, addr);
75 pci_write_config_byte(pdev, CY82_IDE_MASTER_IOR, time_16); 77 pci_write_config_byte(pdev, CY82_IDE_MASTER_IOR, time_16);
@@ -79,7 +81,7 @@ static void cy82c693_set_piomode(struct ata_port *ap, struct ata_device *adev)
79 pci_read_config_dword(pdev, CY82_IDE_ADDRSETUP, &addr); 81 pci_read_config_dword(pdev, CY82_IDE_ADDRSETUP, &addr);
80 82
81 addr &= ~0xF0; /* Mask bits */ 83 addr &= ~0xF0; /* Mask bits */
82 addr |= (clamp_val(t.setup, 0, 15) << 4); 84 addr |= (clamp_val(t.setup - 1, 0, 15) << 4);
83 85
84 pci_write_config_dword(pdev, CY82_IDE_ADDRSETUP, addr); 86 pci_write_config_dword(pdev, CY82_IDE_ADDRSETUP, addr);
85 pci_write_config_byte(pdev, CY82_IDE_SLAVE_IOR, time_16); 87 pci_write_config_byte(pdev, CY82_IDE_SLAVE_IOR, time_16);
@@ -136,7 +138,7 @@ static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *i
136 if (PCI_FUNC(pdev->devfn) != 1) 138 if (PCI_FUNC(pdev->devfn) != 1)
137 return -ENODEV; 139 return -ENODEV;
138 140
139 return ata_pci_sff_init_one(pdev, ppi, &cy82c693_sht, NULL); 141 return ata_pci_sff_init_one(pdev, ppi, &cy82c693_sht, NULL, 0);
140} 142}
141 143
142static const struct pci_device_id cy82c693[] = { 144static const struct pci_device_id cy82c693[] = {
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
index b2e71e6473ed..3bac0e079691 100644
--- a/drivers/ata/pata_efar.c
+++ b/drivers/ata/pata_efar.c
@@ -2,7 +2,7 @@
2 * pata_efar.c - EFAR PIIX clone controller driver 2 * pata_efar.c - EFAR PIIX clone controller driver
3 * 3 *
4 * (C) 2005 Red Hat 4 * (C) 2005 Red Hat
5 * (C) 2009 Bartlomiej Zolnierkiewicz 5 * (C) 2009-2010 Bartlomiej Zolnierkiewicz
6 * 6 *
7 * Some parts based on ata_piix.c by Jeff Garzik and others. 7 * Some parts based on ata_piix.c by Jeff Garzik and others.
8 * 8 *
@@ -68,6 +68,8 @@ static int efar_cable_detect(struct ata_port *ap)
68 return ATA_CBL_PATA80; 68 return ATA_CBL_PATA80;
69} 69}
70 70
71static DEFINE_SPINLOCK(efar_lock);
72
71/** 73/**
72 * efar_set_piomode - Initialize host controller PATA PIO timings 74 * efar_set_piomode - Initialize host controller PATA PIO timings
73 * @ap: Port whose timings we are configuring 75 * @ap: Port whose timings we are configuring
@@ -84,7 +86,9 @@ static void efar_set_piomode (struct ata_port *ap, struct ata_device *adev)
84 unsigned int pio = adev->pio_mode - XFER_PIO_0; 86 unsigned int pio = adev->pio_mode - XFER_PIO_0;
85 struct pci_dev *dev = to_pci_dev(ap->host->dev); 87 struct pci_dev *dev = to_pci_dev(ap->host->dev);
86 unsigned int idetm_port= ap->port_no ? 0x42 : 0x40; 88 unsigned int idetm_port= ap->port_no ? 0x42 : 0x40;
89 unsigned long flags;
87 u16 idetm_data; 90 u16 idetm_data;
91 u8 udma_enable;
88 int control = 0; 92 int control = 0;
89 93
90 /* 94 /*
@@ -107,6 +111,8 @@ static void efar_set_piomode (struct ata_port *ap, struct ata_device *adev)
107 if (adev->class == ATA_DEV_ATA) 111 if (adev->class == ATA_DEV_ATA)
108 control |= 4; /* PPE */ 112 control |= 4; /* PPE */
109 113
114 spin_lock_irqsave(&efar_lock, flags);
115
110 pci_read_config_word(dev, idetm_port, &idetm_data); 116 pci_read_config_word(dev, idetm_port, &idetm_data);
111 117
112 /* Set PPE, IE, and TIME as appropriate */ 118 /* Set PPE, IE, and TIME as appropriate */
@@ -131,6 +137,11 @@ static void efar_set_piomode (struct ata_port *ap, struct ata_device *adev)
131 137
132 idetm_data |= 0x4000; /* Ensure SITRE is set */ 138 idetm_data |= 0x4000; /* Ensure SITRE is set */
133 pci_write_config_word(dev, idetm_port, idetm_data); 139 pci_write_config_word(dev, idetm_port, idetm_data);
140
141 pci_read_config_byte(dev, 0x48, &udma_enable);
142 udma_enable &= ~(1 << (2 * ap->port_no + adev->devno));
143 pci_write_config_byte(dev, 0x48, udma_enable);
144 spin_unlock_irqrestore(&efar_lock, flags);
134} 145}
135 146
136/** 147/**
@@ -151,6 +162,7 @@ static void efar_set_dmamode (struct ata_port *ap, struct ata_device *adev)
151 u16 master_data; 162 u16 master_data;
152 u8 speed = adev->dma_mode; 163 u8 speed = adev->dma_mode;
153 int devid = adev->devno + 2 * ap->port_no; 164 int devid = adev->devno + 2 * ap->port_no;
165 unsigned long flags;
154 u8 udma_enable; 166 u8 udma_enable;
155 167
156 static const /* ISP RTC */ 168 static const /* ISP RTC */
@@ -160,6 +172,8 @@ static void efar_set_dmamode (struct ata_port *ap, struct ata_device *adev)
160 { 2, 1 }, 172 { 2, 1 },
161 { 2, 3 }, }; 173 { 2, 3 }, };
162 174
175 spin_lock_irqsave(&efar_lock, flags);
176
163 pci_read_config_word(dev, master_port, &master_data); 177 pci_read_config_word(dev, master_port, &master_data);
164 pci_read_config_byte(dev, 0x48, &udma_enable); 178 pci_read_config_byte(dev, 0x48, &udma_enable);
165 179
@@ -217,6 +231,7 @@ static void efar_set_dmamode (struct ata_port *ap, struct ata_device *adev)
217 pci_write_config_word(dev, master_port, master_data); 231 pci_write_config_word(dev, master_port, master_data);
218 } 232 }
219 pci_write_config_byte(dev, 0x48, udma_enable); 233 pci_write_config_byte(dev, 0x48, udma_enable);
234 spin_unlock_irqrestore(&efar_lock, flags);
220} 235}
221 236
222static struct scsi_host_template efar_sht = { 237static struct scsi_host_template efar_sht = {
@@ -256,13 +271,14 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
256 .udma_mask = ATA_UDMA4, 271 .udma_mask = ATA_UDMA4,
257 .port_ops = &efar_ops, 272 .port_ops = &efar_ops,
258 }; 273 };
259 const struct ata_port_info *ppi[] = { &info, NULL }; 274 const struct ata_port_info *ppi[] = { &info, &info };
260 275
261 if (!printed_version++) 276 if (!printed_version++)
262 dev_printk(KERN_DEBUG, &pdev->dev, 277 dev_printk(KERN_DEBUG, &pdev->dev,
263 "version " DRV_VERSION "\n"); 278 "version " DRV_VERSION "\n");
264 279
265 return ata_pci_sff_init_one(pdev, ppi, &efar_sht, NULL); 280 return ata_pci_sff_init_one(pdev, ppi, &efar_sht, NULL,
281 ATA_HOST_PARALLEL_SCAN);
266} 282}
267 283
268static const struct pci_device_id efar_pci_tbl[] = { 284static const struct pci_device_id efar_pci_tbl[] = {
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index 0bd48e8f21bd..af49bfb57247 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -11,9 +11,7 @@
11 * 11 *
12 * 12 *
13 * TODO 13 * TODO
14 * Maybe PLL mode 14 * Look into engine reset on timeout errors. Should not be required.
15 * Look into engine reset on timeout errors. Should not be
16 * required.
17 */ 15 */
18 16
19 17
@@ -27,7 +25,7 @@
27#include <linux/libata.h> 25#include <linux/libata.h>
28 26
29#define DRV_NAME "pata_hpt366" 27#define DRV_NAME "pata_hpt366"
30#define DRV_VERSION "0.6.7" 28#define DRV_VERSION "0.6.8"
31 29
32struct hpt_clock { 30struct hpt_clock {
33 u8 xfer_mode; 31 u8 xfer_mode;
@@ -207,17 +205,8 @@ static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev,
207{ 205{
208 struct hpt_clock *clocks = ap->host->private_data; 206 struct hpt_clock *clocks = ap->host->private_data;
209 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 207 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
210 u32 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 208 u32 addr = 0x40 + 4 * adev->devno;
211 u32 addr2 = 0x51 + 4 * ap->port_no;
212 u32 mask, reg; 209 u32 mask, reg;
213 u8 fast;
214
215 /* Fast interrupt prediction disable, hold off interrupt disable */
216 pci_read_config_byte(pdev, addr2, &fast);
217 if (fast & 0x80) {
218 fast &= ~0x80;
219 pci_write_config_byte(pdev, addr2, fast);
220 }
221 210
222 /* determine timing mask and find matching clock entry */ 211 /* determine timing mask and find matching clock entry */
223 if (mode < XFER_MW_DMA_0) 212 if (mode < XFER_MW_DMA_0)
@@ -240,9 +229,9 @@ static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev,
240 * on-chip PIO FIFO/buffer (and PIO MST mode as well) to avoid 229 * on-chip PIO FIFO/buffer (and PIO MST mode as well) to avoid
241 * problems handling I/O errors later. 230 * problems handling I/O errors later.
242 */ 231 */
243 pci_read_config_dword(pdev, addr1, &reg); 232 pci_read_config_dword(pdev, addr, &reg);
244 reg = ((reg & ~mask) | (clocks->timing & mask)) & ~0xc0000000; 233 reg = ((reg & ~mask) | (clocks->timing & mask)) & ~0xc0000000;
245 pci_write_config_dword(pdev, addr1, reg); 234 pci_write_config_dword(pdev, addr, reg);
246} 235}
247 236
248/** 237/**
@@ -372,7 +361,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
372 break; 361 break;
373 } 362 }
374 /* Now kick off ATA set up */ 363 /* Now kick off ATA set up */
375 return ata_pci_sff_init_one(dev, ppi, &hpt36x_sht, hpriv); 364 return ata_pci_sff_init_one(dev, ppi, &hpt36x_sht, hpriv, 0);
376} 365}
377 366
378#ifdef CONFIG_PM 367#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 4224cfccedef..8839307a64cf 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -24,7 +24,7 @@
24#include <linux/libata.h> 24#include <linux/libata.h>
25 25
26#define DRV_NAME "pata_hpt37x" 26#define DRV_NAME "pata_hpt37x"
27#define DRV_VERSION "0.6.14" 27#define DRV_VERSION "0.6.15"
28 28
29struct hpt_clock { 29struct hpt_clock {
30 u8 xfer_speed; 30 u8 xfer_speed;
@@ -39,25 +39,24 @@ struct hpt_chip {
39 39
40/* key for bus clock timings 40/* key for bus clock timings
41 * bit 41 * bit
42 * 0:3 data_high_time. inactive time of DIOW_/DIOR_ for PIO and MW 42 * 0:3 data_high_time. Inactive time of DIOW_/DIOR_ for PIO and MW DMA.
43 * DMA. cycles = value + 1 43 * cycles = value + 1
44 * 4:8 data_low_time. active time of DIOW_/DIOR_ for PIO and MW 44 * 4:8 data_low_time. Active time of DIOW_/DIOR_ for PIO and MW DMA.
45 * DMA. cycles = value + 1 45 * cycles = value + 1
46 * 9:12 cmd_high_time. inactive time of DIOW_/DIOR_ during task file 46 * 9:12 cmd_high_time. Inactive time of DIOW_/DIOR_ during task file
47 * register access. 47 * register access.
48 * 13:17 cmd_low_time. active time of DIOW_/DIOR_ during task file 48 * 13:17 cmd_low_time. Active time of DIOW_/DIOR_ during task file
49 * register access. 49 * register access.
50 * 18:21 udma_cycle_time. clock freq and clock cycles for UDMA xfer. 50 * 18:20 udma_cycle_time. Clock cycles for UDMA xfer.
51 * during task file register access. 51 * 21 CLK frequency for UDMA: 0=ATA clock, 1=dual ATA clock.
52 * 22:24 pre_high_time. time to initialize 1st cycle for PIO and MW DMA 52 * 22:24 pre_high_time. Time to initialize 1st cycle for PIO and MW DMA xfer.
53 * xfer. 53 * 25:27 cmd_pre_high_time. Time to initialize 1st PIO cycle for task file
54 * 25:27 cmd_pre_high_time. time to initialize 1st PIO cycle for task
55 * register access. 54 * register access.
56 * 28 UDMA enable 55 * 28 UDMA enable.
57 * 29 DMA enable 56 * 29 DMA enable.
58 * 30 PIO_MST enable. if set, the chip is in bus master mode during 57 * 30 PIO_MST enable. If set, the chip is in bus master mode during
59 * PIO. 58 * PIO xfer.
60 * 31 FIFO enable. 59 * 31 FIFO enable. Only for PIO.
61 */ 60 */
62 61
63static struct hpt_clock hpt37x_timings_33[] = { 62static struct hpt_clock hpt37x_timings_33[] = {
@@ -384,20 +383,12 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline)
384 return ata_sff_prereset(link, deadline); 383 return ata_sff_prereset(link, deadline);
385} 384}
386 385
387/** 386static void hpt370_set_mode(struct ata_port *ap, struct ata_device *adev,
388 * hpt370_set_piomode - PIO setup 387 u8 mode)
389 * @ap: ATA interface
390 * @adev: device on the interface
391 *
392 * Perform PIO mode setup.
393 */
394
395static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev)
396{ 388{
397 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 389 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
398 u32 addr1, addr2; 390 u32 addr1, addr2;
399 u32 reg; 391 u32 reg, timing, mask;
400 u32 mode;
401 u8 fast; 392 u8 fast;
402 393
403 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 394 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
@@ -409,11 +400,31 @@ static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev)
409 fast |= 0x01; 400 fast |= 0x01;
410 pci_write_config_byte(pdev, addr2, fast); 401 pci_write_config_byte(pdev, addr2, fast);
411 402
403 /* Determine timing mask and find matching mode entry */
404 if (mode < XFER_MW_DMA_0)
405 mask = 0xcfc3ffff;
406 else if (mode < XFER_UDMA_0)
407 mask = 0x31c001ff;
408 else
409 mask = 0x303c0000;
410
411 timing = hpt37x_find_mode(ap, mode);
412
412 pci_read_config_dword(pdev, addr1, &reg); 413 pci_read_config_dword(pdev, addr1, &reg);
413 mode = hpt37x_find_mode(ap, adev->pio_mode); 414 reg = (reg & ~mask) | (timing & mask);
414 mode &= 0xCFC3FFFF; /* Leave DMA bits alone */ 415 pci_write_config_dword(pdev, addr1, reg);
415 reg &= ~0xCFC3FFFF; /* Strip timing bits */ 416}
416 pci_write_config_dword(pdev, addr1, reg | mode); 417/**
418 * hpt370_set_piomode - PIO setup
419 * @ap: ATA interface
420 * @adev: device on the interface
421 *
422 * Perform PIO mode setup.
423 */
424
425static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev)
426{
427 hpt370_set_mode(ap, adev, adev->pio_mode);
417} 428}
418 429
419/** 430/**
@@ -421,33 +432,12 @@ static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev)
421 * @ap: ATA interface 432 * @ap: ATA interface
422 * @adev: Device being configured 433 * @adev: Device being configured
423 * 434 *
424 * Set up the channel for MWDMA or UDMA modes. Much the same as with 435 * Set up the channel for MWDMA or UDMA modes.
425 * PIO, load the mode number and then set MWDMA or UDMA flag.
426 */ 436 */
427 437
428static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev) 438static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev)
429{ 439{
430 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 440 hpt370_set_mode(ap, adev, adev->dma_mode);
431 u32 addr1, addr2;
432 u32 reg, mode, mask;
433 u8 fast;
434
435 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
436 addr2 = 0x51 + 4 * ap->port_no;
437
438 /* Fast interrupt prediction disable, hold off interrupt disable */
439 pci_read_config_byte(pdev, addr2, &fast);
440 fast &= ~0x02;
441 fast |= 0x01;
442 pci_write_config_byte(pdev, addr2, fast);
443
444 mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000;
445
446 pci_read_config_dword(pdev, addr1, &reg);
447 mode = hpt37x_find_mode(ap, adev->dma_mode);
448 mode &= mask;
449 reg &= ~mask;
450 pci_write_config_dword(pdev, addr1, reg | mode);
451} 441}
452 442
453/** 443/**
@@ -461,24 +451,25 @@ static void hpt370_bmdma_stop(struct ata_queued_cmd *qc)
461{ 451{
462 struct ata_port *ap = qc->ap; 452 struct ata_port *ap = qc->ap;
463 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 453 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
464 u8 dma_stat = ioread8(ap->ioaddr.bmdma_addr + 2);
465 u8 dma_cmd;
466 void __iomem *bmdma = ap->ioaddr.bmdma_addr; 454 void __iomem *bmdma = ap->ioaddr.bmdma_addr;
455 u8 dma_stat = ioread8(bmdma + ATA_DMA_STATUS);
456 u8 dma_cmd;
467 457
468 if (dma_stat & 0x01) { 458 if (dma_stat & ATA_DMA_ACTIVE) {
469 udelay(20); 459 udelay(20);
470 dma_stat = ioread8(bmdma + 2); 460 dma_stat = ioread8(bmdma + ATA_DMA_STATUS);
471 } 461 }
472 if (dma_stat & 0x01) { 462 if (dma_stat & ATA_DMA_ACTIVE) {
473 /* Clear the engine */ 463 /* Clear the engine */
474 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 464 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
475 udelay(10); 465 udelay(10);
476 /* Stop DMA */ 466 /* Stop DMA */
477 dma_cmd = ioread8(bmdma ); 467 dma_cmd = ioread8(bmdma + ATA_DMA_CMD);
478 iowrite8(dma_cmd & 0xFE, bmdma); 468 iowrite8(dma_cmd & ~ATA_DMA_START, bmdma + ATA_DMA_CMD);
479 /* Clear Error */ 469 /* Clear Error */
480 dma_stat = ioread8(bmdma + 2); 470 dma_stat = ioread8(bmdma + ATA_DMA_STATUS);
481 iowrite8(dma_stat | 0x06 , bmdma + 2); 471 iowrite8(dma_stat | ATA_DMA_INTR | ATA_DMA_ERR,
472 bmdma + ATA_DMA_STATUS);
482 /* Clear the engine */ 473 /* Clear the engine */
483 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 474 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
484 udelay(10); 475 udelay(10);
@@ -486,20 +477,12 @@ static void hpt370_bmdma_stop(struct ata_queued_cmd *qc)
486 ata_bmdma_stop(qc); 477 ata_bmdma_stop(qc);
487} 478}
488 479
489/** 480static void hpt372_set_mode(struct ata_port *ap, struct ata_device *adev,
490 * hpt372_set_piomode - PIO setup 481 u8 mode)
491 * @ap: ATA interface
492 * @adev: device on the interface
493 *
494 * Perform PIO mode setup.
495 */
496
497static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev)
498{ 482{
499 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 483 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
500 u32 addr1, addr2; 484 u32 addr1, addr2;
501 u32 reg; 485 u32 reg, timing, mask;
502 u32 mode;
503 u8 fast; 486 u8 fast;
504 487
505 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 488 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
@@ -510,13 +493,32 @@ static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev)
510 fast &= ~0x07; 493 fast &= ~0x07;
511 pci_write_config_byte(pdev, addr2, fast); 494 pci_write_config_byte(pdev, addr2, fast);
512 495
496 /* Determine timing mask and find matching mode entry */
497 if (mode < XFER_MW_DMA_0)
498 mask = 0xcfc3ffff;
499 else if (mode < XFER_UDMA_0)
500 mask = 0x31c001ff;
501 else
502 mask = 0x303c0000;
503
504 timing = hpt37x_find_mode(ap, mode);
505
513 pci_read_config_dword(pdev, addr1, &reg); 506 pci_read_config_dword(pdev, addr1, &reg);
514 mode = hpt37x_find_mode(ap, adev->pio_mode); 507 reg = (reg & ~mask) | (timing & mask);
508 pci_write_config_dword(pdev, addr1, reg);
509}
510
511/**
512 * hpt372_set_piomode - PIO setup
513 * @ap: ATA interface
514 * @adev: device on the interface
515 *
516 * Perform PIO mode setup.
517 */
515 518
516 printk("Find mode for %d reports %X\n", adev->pio_mode, mode); 519static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev)
517 mode &= 0xCFC3FFFF; /* Leave DMA bits alone */ 520{
518 reg &= ~0xCFC3FFFF; /* Strip timing bits */ 521 hpt372_set_mode(ap, adev, adev->pio_mode);
519 pci_write_config_dword(pdev, addr1, reg | mode);
520} 522}
521 523
522/** 524/**
@@ -524,33 +526,12 @@ static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev)
524 * @ap: ATA interface 526 * @ap: ATA interface
525 * @adev: Device being configured 527 * @adev: Device being configured
526 * 528 *
527 * Set up the channel for MWDMA or UDMA modes. Much the same as with 529 * Set up the channel for MWDMA or UDMA modes.
528 * PIO, load the mode number and then set MWDMA or UDMA flag.
529 */ 530 */
530 531
531static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev) 532static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev)
532{ 533{
533 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 534 hpt372_set_mode(ap, adev, adev->dma_mode);
534 u32 addr1, addr2;
535 u32 reg, mode, mask;
536 u8 fast;
537
538 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
539 addr2 = 0x51 + 4 * ap->port_no;
540
541 /* Fast interrupt prediction disable, hold off interrupt disable */
542 pci_read_config_byte(pdev, addr2, &fast);
543 fast &= ~0x07;
544 pci_write_config_byte(pdev, addr2, fast);
545
546 mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000;
547
548 pci_read_config_dword(pdev, addr1, &reg);
549 mode = hpt37x_find_mode(ap, adev->dma_mode);
550 printk("Find mode for DMA %d reports %X\n", adev->dma_mode, mode);
551 mode &= mask;
552 reg &= ~mask;
553 pci_write_config_dword(pdev, addr1, reg | mode);
554} 535}
555 536
556/** 537/**
@@ -1006,7 +987,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1006 } 987 }
1007 988
1008 /* Now kick off ATA set up */ 989 /* Now kick off ATA set up */
1009 return ata_pci_sff_init_one(dev, ppi, &hpt37x_sht, private_data); 990 return ata_pci_sff_init_one(dev, ppi, &hpt37x_sht, private_data, 0);
1010} 991}
1011 992
1012static const struct pci_device_id hpt37x[] = { 993static const struct pci_device_id hpt37x[] = {
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index dd26bc73bd9a..01457b266f3d 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_hpt3x2n" 27#define DRV_NAME "pata_hpt3x2n"
28#define DRV_VERSION "0.3.8" 28#define DRV_VERSION "0.3.10"
29 29
30enum { 30enum {
31 HPT_PCI_FAST = (1 << 31), 31 HPT_PCI_FAST = (1 << 31),
@@ -45,25 +45,24 @@ struct hpt_chip {
45 45
46/* key for bus clock timings 46/* key for bus clock timings
47 * bit 47 * bit
48 * 0:3 data_high_time. inactive time of DIOW_/DIOR_ for PIO and MW 48 * 0:3 data_high_time. Inactive time of DIOW_/DIOR_ for PIO and MW DMA.
49 * DMA. cycles = value + 1 49 * cycles = value + 1
50 * 4:8 data_low_time. active time of DIOW_/DIOR_ for PIO and MW 50 * 4:8 data_low_time. Active time of DIOW_/DIOR_ for PIO and MW DMA.
51 * DMA. cycles = value + 1 51 * cycles = value + 1
52 * 9:12 cmd_high_time. inactive time of DIOW_/DIOR_ during task file 52 * 9:12 cmd_high_time. Inactive time of DIOW_/DIOR_ during task file
53 * register access. 53 * register access.
54 * 13:17 cmd_low_time. active time of DIOW_/DIOR_ during task file 54 * 13:17 cmd_low_time. Active time of DIOW_/DIOR_ during task file
55 * register access. 55 * register access.
56 * 18:21 udma_cycle_time. clock freq and clock cycles for UDMA xfer. 56 * 18:20 udma_cycle_time. Clock cycles for UDMA xfer.
57 * during task file register access. 57 * 21 CLK frequency for UDMA: 0=ATA clock, 1=dual ATA clock.
58 * 22:24 pre_high_time. time to initialize 1st cycle for PIO and MW DMA 58 * 22:24 pre_high_time. Time to initialize 1st cycle for PIO and MW DMA xfer.
59 * xfer. 59 * 25:27 cmd_pre_high_time. Time to initialize 1st PIO cycle for task file
60 * 25:27 cmd_pre_high_time. time to initialize 1st PIO cycle for task
61 * register access. 60 * register access.
62 * 28 UDMA enable 61 * 28 UDMA enable.
63 * 29 DMA enable 62 * 29 DMA enable.
64 * 30 PIO_MST enable. if set, the chip is in bus master mode during 63 * 30 PIO_MST enable. If set, the chip is in bus master mode during
65 * PIO. 64 * PIO xfer.
66 * 31 FIFO enable. 65 * 31 FIFO enable. Only for PIO.
67 */ 66 */
68 67
69/* 66MHz DPLL clocks */ 68/* 66MHz DPLL clocks */
@@ -161,20 +160,12 @@ static int hpt3x2n_pre_reset(struct ata_link *link, unsigned long deadline)
161 return ata_sff_prereset(link, deadline); 160 return ata_sff_prereset(link, deadline);
162} 161}
163 162
164/** 163static void hpt3x2n_set_mode(struct ata_port *ap, struct ata_device *adev,
165 * hpt3x2n_set_piomode - PIO setup 164 u8 mode)
166 * @ap: ATA interface
167 * @adev: device on the interface
168 *
169 * Perform PIO mode setup.
170 */
171
172static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev)
173{ 165{
174 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 166 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
175 u32 addr1, addr2; 167 u32 addr1, addr2;
176 u32 reg; 168 u32 reg, timing, mask;
177 u32 mode;
178 u8 fast; 169 u8 fast;
179 170
180 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 171 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
@@ -185,11 +176,32 @@ static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev)
185 fast &= ~0x07; 176 fast &= ~0x07;
186 pci_write_config_byte(pdev, addr2, fast); 177 pci_write_config_byte(pdev, addr2, fast);
187 178
179 /* Determine timing mask and find matching mode entry */
180 if (mode < XFER_MW_DMA_0)
181 mask = 0xcfc3ffff;
182 else if (mode < XFER_UDMA_0)
183 mask = 0x31c001ff;
184 else
185 mask = 0x303c0000;
186
187 timing = hpt3x2n_find_mode(ap, mode);
188
188 pci_read_config_dword(pdev, addr1, &reg); 189 pci_read_config_dword(pdev, addr1, &reg);
189 mode = hpt3x2n_find_mode(ap, adev->pio_mode); 190 reg = (reg & ~mask) | (timing & mask);
190 mode &= 0xCFC3FFFF; /* Leave DMA bits alone */ 191 pci_write_config_dword(pdev, addr1, reg);
191 reg &= ~0xCFC3FFFF; /* Strip timing bits */ 192}
192 pci_write_config_dword(pdev, addr1, reg | mode); 193
194/**
195 * hpt3x2n_set_piomode - PIO setup
196 * @ap: ATA interface
197 * @adev: device on the interface
198 *
199 * Perform PIO mode setup.
200 */
201
202static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev)
203{
204 hpt3x2n_set_mode(ap, adev, adev->pio_mode);
193} 205}
194 206
195/** 207/**
@@ -197,32 +209,12 @@ static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev)
197 * @ap: ATA interface 209 * @ap: ATA interface
198 * @adev: Device being configured 210 * @adev: Device being configured
199 * 211 *
200 * Set up the channel for MWDMA or UDMA modes. Much the same as with 212 * Set up the channel for MWDMA or UDMA modes.
201 * PIO, load the mode number and then set MWDMA or UDMA flag.
202 */ 213 */
203 214
204static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev) 215static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev)
205{ 216{
206 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 217 hpt3x2n_set_mode(ap, adev, adev->dma_mode);
207 u32 addr1, addr2;
208 u32 reg, mode, mask;
209 u8 fast;
210
211 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
212 addr2 = 0x51 + 4 * ap->port_no;
213
214 /* Fast interrupt prediction disable, hold off interrupt disable */
215 pci_read_config_byte(pdev, addr2, &fast);
216 fast &= ~0x07;
217 pci_write_config_byte(pdev, addr2, fast);
218
219 mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000;
220
221 pci_read_config_dword(pdev, addr1, &reg);
222 mode = hpt3x2n_find_mode(ap, adev->dma_mode);
223 mode &= mask;
224 reg &= ~mask;
225 pci_write_config_dword(pdev, addr1, reg | mode);
226} 218}
227 219
228/** 220/**
@@ -544,19 +536,19 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
544 pci_mhz); 536 pci_mhz);
545 /* Set our private data up. We only need a few flags so we use 537 /* Set our private data up. We only need a few flags so we use
546 it directly */ 538 it directly */
547 if (pci_mhz > 60) { 539 if (pci_mhz > 60)
548 hpriv = (void *)(PCI66 | USE_DPLL); 540 hpriv = (void *)(PCI66 | USE_DPLL);
549 /* 541
550 * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in 542 /*
551 * the MISC. register to stretch the UltraDMA Tss timing. 543 * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in
552 * NOTE: This register is only writeable via I/O space. 544 * the MISC. register to stretch the UltraDMA Tss timing.
553 */ 545 * NOTE: This register is only writeable via I/O space.
554 if (dev->device == PCI_DEVICE_ID_TTI_HPT371) 546 */
555 outb(inb(iobase + 0x9c) | 0x04, iobase + 0x9c); 547 if (dev->device == PCI_DEVICE_ID_TTI_HPT371)
556 } 548 outb(inb(iobase + 0x9c) | 0x04, iobase + 0x9c);
557 549
558 /* Now kick off ATA set up */ 550 /* Now kick off ATA set up */
559 return ata_pci_sff_init_one(dev, ppi, &hpt3x2n_sht, hpriv); 551 return ata_pci_sff_init_one(dev, ppi, &hpt3x2n_sht, hpriv, 0);
560} 552}
561 553
562static const struct pci_device_id hpt3x2n[] = { 554static const struct pci_device_id hpt3x2n[] = {
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c
index 8f3325adceb3..f971f0de88e6 100644
--- a/drivers/ata/pata_it8213.c
+++ b/drivers/ata/pata_it8213.c
@@ -273,7 +273,7 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en
273 dev_printk(KERN_DEBUG, &pdev->dev, 273 dev_printk(KERN_DEBUG, &pdev->dev,
274 "version " DRV_VERSION "\n"); 274 "version " DRV_VERSION "\n");
275 275
276 return ata_pci_sff_init_one(pdev, ppi, &it8213_sht, NULL); 276 return ata_pci_sff_init_one(pdev, ppi, &it8213_sht, NULL, 0);
277} 277}
278 278
279static const struct pci_device_id it8213_pci_tbl[] = { 279static const struct pci_device_id it8213_pci_tbl[] = {
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index edc5c1fed150..9bde1cb5f981 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -932,7 +932,7 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
932 else 932 else
933 ppi[0] = &info_smart; 933 ppi[0] = &info_smart;
934 } 934 }
935 return ata_pci_sff_init_one(pdev, ppi, &it821x_sht, NULL); 935 return ata_pci_sff_init_one(pdev, ppi, &it821x_sht, NULL, 0);
936} 936}
937 937
938#ifdef CONFIG_PM 938#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 3a1474ac8838..565e01e6ac7c 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -144,7 +144,7 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i
144 }; 144 };
145 const struct ata_port_info *ppi[] = { &info, NULL }; 145 const struct ata_port_info *ppi[] = { &info, NULL };
146 146
147 return ata_pci_sff_init_one(pdev, ppi, &jmicron_sht, NULL); 147 return ata_pci_sff_init_one(pdev, ppi, &jmicron_sht, NULL, 0);
148} 148}
149 149
150static const struct pci_device_id jmicron_pci_tbl[] = { 150static const struct pci_device_id jmicron_pci_tbl[] = {
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index 950da39cae3d..e8ca02e5a71d 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -147,13 +147,13 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
147 if (pdev->device == 0x6101) 147 if (pdev->device == 0x6101)
148 ppi[1] = &ata_dummy_port_info; 148 ppi[1] = &ata_dummy_port_info;
149 149
150#if defined(CONFIG_AHCI) || defined(CONFIG_AHCI_MODULE) 150#if defined(CONFIG_SATA_AHCI) || defined(CONFIG_SATA_AHCI_MODULE)
151 if (!marvell_pata_active(pdev)) { 151 if (!marvell_pata_active(pdev)) {
152 printk(KERN_INFO DRV_NAME ": PATA port not active, deferring to AHCI driver.\n"); 152 printk(KERN_INFO DRV_NAME ": PATA port not active, deferring to AHCI driver.\n");
153 return -ENODEV; 153 return -ENODEV;
154 } 154 }
155#endif 155#endif
156 return ata_pci_sff_init_one(pdev, ppi, &marvell_sht, NULL); 156 return ata_pci_sff_init_one(pdev, ppi, &marvell_sht, NULL, 0);
157} 157}
158 158
159static const struct pci_device_id marvell_pci_tbl[] = { 159static const struct pci_device_id marvell_pci_tbl[] = {
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c
index f0d52f72f5bb..94f979a7f4f7 100644
--- a/drivers/ata/pata_netcell.c
+++ b/drivers/ata/pata_netcell.c
@@ -82,7 +82,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e
82 ata_pci_bmdma_clear_simplex(pdev); 82 ata_pci_bmdma_clear_simplex(pdev);
83 83
84 /* And let the library code do the work */ 84 /* And let the library code do the work */
85 return ata_pci_sff_init_one(pdev, port_info, &netcell_sht, NULL); 85 return ata_pci_sff_init_one(pdev, port_info, &netcell_sht, NULL, 0);
86} 86}
87 87
88static const struct pci_device_id netcell_pci_tbl[] = { 88static const struct pci_device_id netcell_pci_tbl[] = {
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
index ca53fac06717..2110863bb3db 100644
--- a/drivers/ata/pata_ns87410.c
+++ b/drivers/ata/pata_ns87410.c
@@ -148,7 +148,7 @@ static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id)
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 };
151 return ata_pci_sff_init_one(dev, ppi, &ns87410_sht, NULL); 151 return ata_pci_sff_init_one(dev, ppi, &ns87410_sht, NULL, 0);
152} 152}
153 153
154static const struct pci_device_id ns87410[] = { 154static const struct pci_device_id ns87410[] = {
diff --git a/drivers/ata/pata_ns87415.c b/drivers/ata/pata_ns87415.c
index 061aa1c41a48..830431f036a1 100644
--- a/drivers/ata/pata_ns87415.c
+++ b/drivers/ata/pata_ns87415.c
@@ -380,7 +380,7 @@ static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *e
380 380
381 ns87415_fixup(pdev); 381 ns87415_fixup(pdev);
382 382
383 return ata_pci_sff_init_one(pdev, ppi, &ns87415_sht, NULL); 383 return ata_pci_sff_init_one(pdev, ppi, &ns87415_sht, NULL, 0);
384} 384}
385 385
386static const struct pci_device_id ns87415_pci_tbl[] = { 386static const struct pci_device_id ns87415_pci_tbl[] = {
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
index 9a8687db6b2d..5f6aba7eb0dd 100644
--- a/drivers/ata/pata_oldpiix.c
+++ b/drivers/ata/pata_oldpiix.c
@@ -248,7 +248,7 @@ static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *e
248 dev_printk(KERN_DEBUG, &pdev->dev, 248 dev_printk(KERN_DEBUG, &pdev->dev,
249 "version " DRV_VERSION "\n"); 249 "version " DRV_VERSION "\n");
250 250
251 return ata_pci_sff_init_one(pdev, ppi, &oldpiix_sht, NULL); 251 return ata_pci_sff_init_one(pdev, ppi, &oldpiix_sht, NULL, 0);
252} 252}
253 253
254static const struct pci_device_id oldpiix_pci_tbl[] = { 254static const struct pci_device_id oldpiix_pci_tbl[] = {
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
index 99eddda2d2e5..00c5a02a94fc 100644
--- a/drivers/ata/pata_opti.c
+++ b/drivers/ata/pata_opti.c
@@ -172,7 +172,7 @@ static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id)
172 if (!printed_version++) 172 if (!printed_version++)
173 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); 173 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
174 174
175 return ata_pci_sff_init_one(dev, ppi, &opti_sht, NULL); 175 return ata_pci_sff_init_one(dev, ppi, &opti_sht, NULL, 0);
176} 176}
177 177
178static const struct pci_device_id opti[] = { 178static const struct pci_device_id opti[] = {
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index 86885a445f97..76b7d12b1e8d 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -429,7 +429,7 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
429 if (optiplus_with_udma(dev)) 429 if (optiplus_with_udma(dev))
430 ppi[0] = &info_82c700_udma; 430 ppi[0] = &info_82c700_udma;
431 431
432 return ata_pci_sff_init_one(dev, ppi, &optidma_sht, NULL); 432 return ata_pci_sff_init_one(dev, ppi, &optidma_sht, NULL, 0);
433} 433}
434 434
435static const struct pci_device_id optidma[] = { 435static const struct pci_device_id optidma[] = {
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 1b392c9e8531..36103531feeb 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -136,7 +136,7 @@ static unsigned int ata_data_xfer_8bit(struct ata_device *dev,
136 * 136 *
137 */ 137 */
138 138
139void pcmcia_8bit_drain_fifo(struct ata_queued_cmd *qc) 139static void pcmcia_8bit_drain_fifo(struct ata_queued_cmd *qc)
140{ 140{
141 int count; 141 int count;
142 struct ata_port *ap; 142 struct ata_port *ap;
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
index 2f3c9bed63d9..9ac0897cf8b0 100644
--- a/drivers/ata/pata_pdc202xx_old.c
+++ b/drivers/ata/pata_pdc202xx_old.c
@@ -2,7 +2,7 @@
2 * pata_pdc202xx_old.c - Promise PDC202xx PATA for new ATA layer 2 * pata_pdc202xx_old.c - Promise PDC202xx PATA for new ATA layer
3 * (C) 2005 Red Hat Inc 3 * (C) 2005 Red Hat Inc
4 * Alan Cox <alan@lxorguk.ukuu.org.uk> 4 * Alan Cox <alan@lxorguk.ukuu.org.uk>
5 * (C) 2007,2009 Bartlomiej Zolnierkiewicz 5 * (C) 2007,2009,2010 Bartlomiej Zolnierkiewicz
6 * 6 *
7 * Based in part on linux/drivers/ide/pci/pdc202xx_old.c 7 * Based in part on linux/drivers/ide/pci/pdc202xx_old.c
8 * 8 *
@@ -35,6 +35,15 @@ static int pdc2026x_cable_detect(struct ata_port *ap)
35 return ATA_CBL_PATA80; 35 return ATA_CBL_PATA80;
36} 36}
37 37
38static void pdc202xx_exec_command(struct ata_port *ap,
39 const struct ata_taskfile *tf)
40{
41 DPRINTK("ata%u: cmd 0x%X\n", ap->print_id, tf->command);
42
43 iowrite8(tf->command, ap->ioaddr.command_addr);
44 ndelay(400);
45}
46
38/** 47/**
39 * pdc202xx_configure_piomode - set chip PIO timing 48 * pdc202xx_configure_piomode - set chip PIO timing
40 * @ap: ATA interface 49 * @ap: ATA interface
@@ -271,6 +280,8 @@ static struct ata_port_operations pdc2024x_port_ops = {
271 .cable_detect = ata_cable_40wire, 280 .cable_detect = ata_cable_40wire,
272 .set_piomode = pdc202xx_set_piomode, 281 .set_piomode = pdc202xx_set_piomode,
273 .set_dmamode = pdc202xx_set_dmamode, 282 .set_dmamode = pdc202xx_set_dmamode,
283
284 .sff_exec_command = pdc202xx_exec_command,
274}; 285};
275 286
276static struct ata_port_operations pdc2026x_port_ops = { 287static struct ata_port_operations pdc2026x_port_ops = {
@@ -284,6 +295,8 @@ static struct ata_port_operations pdc2026x_port_ops = {
284 .dev_config = pdc2026x_dev_config, 295 .dev_config = pdc2026x_dev_config,
285 296
286 .port_start = pdc2026x_port_start, 297 .port_start = pdc2026x_port_start,
298
299 .sff_exec_command = pdc202xx_exec_command,
287}; 300};
288 301
289static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) 302static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id)
@@ -324,7 +337,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id
324 return -ENODEV; 337 return -ENODEV;
325 } 338 }
326 } 339 }
327 return ata_pci_sff_init_one(dev, ppi, &pdc202xx_sht, NULL); 340 return ata_pci_sff_init_one(dev, ppi, &pdc202xx_sht, NULL, 0);
328} 341}
329 342
330static const struct pci_device_id pdc202xx[] = { 343static const struct pci_device_id pdc202xx[] = {
diff --git a/drivers/ata/pata_piccolo.c b/drivers/ata/pata_piccolo.c
index bfe0180f3efa..981615414849 100644
--- a/drivers/ata/pata_piccolo.c
+++ b/drivers/ata/pata_piccolo.c
@@ -95,7 +95,7 @@ static int ata_tosh_init_one(struct pci_dev *dev, const struct pci_device_id *id
95 }; 95 };
96 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; 96 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
97 /* Just one port for the moment */ 97 /* Just one port for the moment */
98 return ata_pci_sff_init_one(dev, ppi, &tosh_sht, NULL); 98 return ata_pci_sff_init_one(dev, ppi, &tosh_sht, NULL, 0);
99} 99}
100 100
101static struct pci_device_id ata_tosh[] = { 101static struct pci_device_id ata_tosh[] = {
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c
index 4fd25e737d9a..fc9602229acb 100644
--- a/drivers/ata/pata_radisys.c
+++ b/drivers/ata/pata_radisys.c
@@ -227,7 +227,7 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e
227 dev_printk(KERN_DEBUG, &pdev->dev, 227 dev_printk(KERN_DEBUG, &pdev->dev,
228 "version " DRV_VERSION "\n"); 228 "version " DRV_VERSION "\n");
229 229
230 return ata_pci_sff_init_one(pdev, ppi, &radisys_sht, NULL); 230 return ata_pci_sff_init_one(pdev, ppi, &radisys_sht, NULL, 0);
231} 231}
232 232
233static const struct pci_device_id radisys_pci_tbl[] = { 233static const struct pci_device_id radisys_pci_tbl[] = {
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 2932998fc4c6..4a454a88aa9d 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -95,7 +95,7 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
95 printk_once(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 95 printk_once(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
96 96
97 if (rz1000_fifo_disable(pdev) == 0) 97 if (rz1000_fifo_disable(pdev) == 0)
98 return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL); 98 return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL, 0);
99 99
100 printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); 100 printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n");
101 /* Not safe to use so skip */ 101 /* Not safe to use so skip */
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c
index 3bbed8322ecf..dfecc6f964b0 100644
--- a/drivers/ata/pata_sc1200.c
+++ b/drivers/ata/pata_sc1200.c
@@ -237,7 +237,7 @@ static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
237 }; 237 };
238 const struct ata_port_info *ppi[] = { &info, NULL }; 238 const struct ata_port_info *ppi[] = { &info, NULL };
239 239
240 return ata_pci_sff_init_one(dev, ppi, &sc1200_sht, NULL); 240 return ata_pci_sff_init_one(dev, ppi, &sc1200_sht, NULL, 0);
241} 241}
242 242
243static const struct pci_device_id sc1200[] = { 243static const struct pci_device_id sc1200[] = {
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index beaed12d50e4..9524d54035f7 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * pata_serverworks.c - Serverworks PATA for new ATA layer 2 * pata_serverworks.c - Serverworks PATA for new ATA layer
3 * (C) 2005 Red Hat Inc 3 * (C) 2005 Red Hat Inc
4 * (C) 2010 Bartlomiej Zolnierkiewicz
4 * 5 *
5 * based upon 6 * based upon
6 * 7 *
@@ -253,7 +254,7 @@ static void serverworks_set_piomode(struct ata_port *ap, struct ata_device *adev
253 if (serverworks_is_csb(pdev)) { 254 if (serverworks_is_csb(pdev)) {
254 pci_read_config_word(pdev, 0x4A, &csb5_pio); 255 pci_read_config_word(pdev, 0x4A, &csb5_pio);
255 csb5_pio &= ~(0x0F << devbits); 256 csb5_pio &= ~(0x0F << devbits);
256 pci_write_config_byte(pdev, 0x4A, csb5_pio | (pio << devbits)); 257 pci_write_config_word(pdev, 0x4A, csb5_pio | (pio << devbits));
257 } 258 }
258} 259}
259 260
@@ -327,7 +328,7 @@ static int serverworks_fixup_osb4(struct pci_dev *pdev)
327 pci_dev_put(isa_dev); 328 pci_dev_put(isa_dev);
328 return 0; 329 return 0;
329 } 330 }
330 printk(KERN_WARNING "ata_serverworks: Unable to find bridge.\n"); 331 printk(KERN_WARNING DRV_NAME ": Unable to find bridge.\n");
331 return -ENODEV; 332 return -ENODEV;
332} 333}
333 334
@@ -459,7 +460,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
459 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) 460 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)
460 ata_pci_bmdma_clear_simplex(pdev); 461 ata_pci_bmdma_clear_simplex(pdev);
461 462
462 return ata_pci_sff_init_one(pdev, ppi, &serverworks_sht, NULL); 463 return ata_pci_sff_init_one(pdev, ppi, &serverworks_sht, NULL, 0);
463} 464}
464 465
465#ifdef CONFIG_PM 466#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index a2ace48a4610..c6c589c23ffc 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -356,7 +356,7 @@ static int __devinit sil680_init_one(struct pci_dev *pdev,
356 IRQF_SHARED, &sil680_sht); 356 IRQF_SHARED, &sil680_sht);
357 357
358use_ioports: 358use_ioports:
359 return ata_pci_sff_init_one(pdev, ppi, &sil680_sht, NULL); 359 return ata_pci_sff_init_one(pdev, ppi, &sil680_sht, NULL, 0);
360} 360}
361 361
362#ifdef CONFIG_PM 362#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index 5c30d56dec84..b6708032f321 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -826,7 +826,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
826 826
827 sis_fixup(pdev, chipset); 827 sis_fixup(pdev, chipset);
828 828
829 return ata_pci_sff_init_one(pdev, ppi, &sis_sht, chipset); 829 return ata_pci_sff_init_one(pdev, ppi, &sis_sht, chipset, 0);
830} 830}
831 831
832#ifdef CONFIG_PM 832#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index 29f733c32066..733b042a7469 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -316,7 +316,7 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id
316 val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; 316 val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16;
317 pci_write_config_dword(dev, 0x40, val); 317 pci_write_config_dword(dev, 0x40, val);
318 318
319 return ata_pci_sff_init_one(dev, ppi, &sl82c105_sht, NULL); 319 return ata_pci_sff_init_one(dev, ppi, &sl82c105_sht, NULL, 0);
320} 320}
321 321
322static const struct pci_device_id sl82c105[] = { 322static const struct pci_device_id sl82c105[] = {
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index f1f13ff222fd..48f50600ed2a 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -201,7 +201,7 @@ static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id)
201 if (!printed_version++) 201 if (!printed_version++)
202 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); 202 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
203 203
204 return ata_pci_sff_init_one(dev, ppi, &triflex_sht, NULL); 204 return ata_pci_sff_init_one(dev, ppi, &triflex_sht, NULL, 0);
205} 205}
206 206
207static const struct pci_device_id triflex[] = { 207static const struct pci_device_id triflex[] = {
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 0d97890af681..3059ec017de3 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -22,6 +22,7 @@
22 * VIA VT8233c - UDMA100 22 * VIA VT8233c - UDMA100
23 * VIA VT8235 - UDMA133 23 * VIA VT8235 - UDMA133
24 * VIA VT8237 - UDMA133 24 * VIA VT8237 - UDMA133
25 * VIA VT8237A - UDMA133
25 * VIA VT8237S - UDMA133 26 * VIA VT8237S - UDMA133
26 * VIA VT8251 - UDMA133 27 * VIA VT8251 - UDMA133
27 * 28 *
@@ -64,26 +65,15 @@
64#define DRV_NAME "pata_via" 65#define DRV_NAME "pata_via"
65#define DRV_VERSION "0.3.4" 66#define DRV_VERSION "0.3.4"
66 67
67/*
68 * The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx
69 * driver.
70 */
71
72enum { 68enum {
73 VIA_UDMA = 0x007, 69 VIA_BAD_PREQ = 0x01, /* Crashes if PREQ# till DDACK# set */
74 VIA_UDMA_NONE = 0x000, 70 VIA_BAD_CLK66 = 0x02, /* 66 MHz clock doesn't work correctly */
75 VIA_UDMA_33 = 0x001, 71 VIA_SET_FIFO = 0x04, /* Needs to have FIFO split set */
76 VIA_UDMA_66 = 0x002, 72 VIA_NO_UNMASK = 0x08, /* Doesn't work with IRQ unmasking on */
77 VIA_UDMA_100 = 0x003, 73 VIA_BAD_ID = 0x10, /* Has wrong vendor ID (0x1107) */
78 VIA_UDMA_133 = 0x004, 74 VIA_BAD_AST = 0x20, /* Don't touch Address Setup Timing */
79 VIA_BAD_PREQ = 0x010, /* Crashes if PREQ# till DDACK# set */ 75 VIA_NO_ENABLES = 0x40, /* Has no enablebits */
80 VIA_BAD_CLK66 = 0x020, /* 66 MHz clock doesn't work correctly */ 76 VIA_SATA_PATA = 0x80, /* SATA/PATA combined configuration */
81 VIA_SET_FIFO = 0x040, /* Needs to have FIFO split set */
82 VIA_NO_UNMASK = 0x080, /* Doesn't work with IRQ unmasking on */
83 VIA_BAD_ID = 0x100, /* Has wrong vendor ID (0x1107) */
84 VIA_BAD_AST = 0x200, /* Don't touch Address Setup Timing */
85 VIA_NO_ENABLES = 0x400, /* Has no enablebits */
86 VIA_SATA_PATA = 0x800, /* SATA/PATA combined configuration */
87}; 77};
88 78
89enum { 79enum {
@@ -99,40 +89,37 @@ static const struct via_isa_bridge {
99 u16 id; 89 u16 id;
100 u8 rev_min; 90 u8 rev_min;
101 u8 rev_max; 91 u8 rev_max;
102 u16 flags; 92 u8 udma_mask;
93 u8 flags;
103} via_isa_bridges[] = { 94} via_isa_bridges[] = {
104 { "vx855", PCI_DEVICE_ID_VIA_VX855, 0x00, 0x2f, 95 { "vx855", PCI_DEVICE_ID_VIA_VX855, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST | VIA_SATA_PATA },
105 VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA }, 96 { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST | VIA_SATA_PATA },
106 { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, VIA_UDMA_133 | 97 { "vt8261", PCI_DEVICE_ID_VIA_8261, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
107 VIA_BAD_AST | VIA_SATA_PATA }, 98 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
108 { "vt8261", PCI_DEVICE_ID_VIA_8261, 0x00, 0x2f, 99 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
109 VIA_UDMA_133 | VIA_BAD_AST }, 100 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST | VIA_SATA_PATA },
110 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 101 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST | VIA_NO_ENABLES },
111 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 102 { "vt6415", PCI_DEVICE_ID_VIA_6415, 0x00, 0xff, ATA_UDMA6, VIA_BAD_AST | VIA_NO_ENABLES },
112 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA }, 103 { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
113 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES }, 104 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
114 { "vt6415", PCI_DEVICE_ID_VIA_6415, 0x00, 0xff, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES }, 105 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
115 { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 106 { "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
116 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 107 { "vt8233c", PCI_DEVICE_ID_VIA_8233C_0, 0x00, 0x2f, ATA_UDMA5, },
117 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 108 { "vt8233", PCI_DEVICE_ID_VIA_8233_0, 0x00, 0x2f, ATA_UDMA5, },
118 { "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 109 { "vt8231", PCI_DEVICE_ID_VIA_8231, 0x00, 0x2f, ATA_UDMA5, },
119 { "vt8233c", PCI_DEVICE_ID_VIA_8233C_0, 0x00, 0x2f, VIA_UDMA_100 }, 110 { "vt82c686b", PCI_DEVICE_ID_VIA_82C686, 0x40, 0x4f, ATA_UDMA5, },
120 { "vt8233", PCI_DEVICE_ID_VIA_8233_0, 0x00, 0x2f, VIA_UDMA_100 }, 111 { "vt82c686a", PCI_DEVICE_ID_VIA_82C686, 0x10, 0x2f, ATA_UDMA4, },
121 { "vt8231", PCI_DEVICE_ID_VIA_8231, 0x00, 0x2f, VIA_UDMA_100 }, 112 { "vt82c686", PCI_DEVICE_ID_VIA_82C686, 0x00, 0x0f, ATA_UDMA2, VIA_BAD_CLK66 },
122 { "vt82c686b", PCI_DEVICE_ID_VIA_82C686, 0x40, 0x4f, VIA_UDMA_100 }, 113 { "vt82c596b", PCI_DEVICE_ID_VIA_82C596, 0x10, 0x2f, ATA_UDMA4, },
123 { "vt82c686a", PCI_DEVICE_ID_VIA_82C686, 0x10, 0x2f, VIA_UDMA_66 }, 114 { "vt82c596a", PCI_DEVICE_ID_VIA_82C596, 0x00, 0x0f, ATA_UDMA2, VIA_BAD_CLK66 },
124 { "vt82c686", PCI_DEVICE_ID_VIA_82C686, 0x00, 0x0f, VIA_UDMA_33 | VIA_BAD_CLK66 }, 115 { "vt82c586b", PCI_DEVICE_ID_VIA_82C586_0, 0x47, 0x4f, ATA_UDMA2, VIA_SET_FIFO },
125 { "vt82c596b", PCI_DEVICE_ID_VIA_82C596, 0x10, 0x2f, VIA_UDMA_66 }, 116 { "vt82c586b", PCI_DEVICE_ID_VIA_82C586_0, 0x40, 0x46, ATA_UDMA2, VIA_SET_FIFO | VIA_BAD_PREQ },
126 { "vt82c596a", PCI_DEVICE_ID_VIA_82C596, 0x00, 0x0f, VIA_UDMA_33 | VIA_BAD_CLK66 }, 117 { "vt82c586b", PCI_DEVICE_ID_VIA_82C586_0, 0x30, 0x3f, ATA_UDMA2, VIA_SET_FIFO },
127 { "vt82c586b", PCI_DEVICE_ID_VIA_82C586_0, 0x47, 0x4f, VIA_UDMA_33 | VIA_SET_FIFO }, 118 { "vt82c586a", PCI_DEVICE_ID_VIA_82C586_0, 0x20, 0x2f, ATA_UDMA2, VIA_SET_FIFO },
128 { "vt82c586b", PCI_DEVICE_ID_VIA_82C586_0, 0x40, 0x46, VIA_UDMA_33 | VIA_SET_FIFO | VIA_BAD_PREQ }, 119 { "vt82c586", PCI_DEVICE_ID_VIA_82C586_0, 0x00, 0x0f, 0x00, VIA_SET_FIFO },
129 { "vt82c586b", PCI_DEVICE_ID_VIA_82C586_0, 0x30, 0x3f, VIA_UDMA_33 | VIA_SET_FIFO }, 120 { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, 0x00, VIA_SET_FIFO | VIA_NO_UNMASK },
130 { "vt82c586a", PCI_DEVICE_ID_VIA_82C586_0, 0x20, 0x2f, VIA_UDMA_33 | VIA_SET_FIFO }, 121 { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, 0x00, VIA_SET_FIFO | VIA_NO_UNMASK | VIA_BAD_ID },
131 { "vt82c586", PCI_DEVICE_ID_VIA_82C586_0, 0x00, 0x0f, VIA_UDMA_NONE | VIA_SET_FIFO }, 122 { "vtxxxx", PCI_DEVICE_ID_VIA_ANON, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
132 { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, VIA_UDMA_NONE | VIA_SET_FIFO | VIA_NO_UNMASK },
133 { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, VIA_UDMA_NONE | VIA_SET_FIFO | VIA_NO_UNMASK | VIA_BAD_ID },
134 { "vtxxxx", PCI_DEVICE_ID_VIA_ANON, 0x00, 0x2f,
135 VIA_UDMA_133 | VIA_BAD_AST },
136 { NULL } 123 { NULL }
137}; 124};
138 125
@@ -191,10 +178,10 @@ static int via_cable_detect(struct ata_port *ap) {
191 return ATA_CBL_SATA; 178 return ATA_CBL_SATA;
192 179
193 /* Early chips are 40 wire */ 180 /* Early chips are 40 wire */
194 if ((config->flags & VIA_UDMA) < VIA_UDMA_66) 181 if (config->udma_mask < ATA_UDMA4)
195 return ATA_CBL_PATA40; 182 return ATA_CBL_PATA40;
196 /* UDMA 66 chips have only drive side logic */ 183 /* UDMA 66 chips have only drive side logic */
197 else if ((config->flags & VIA_UDMA) < VIA_UDMA_100) 184 else if (config->udma_mask < ATA_UDMA5)
198 return ATA_CBL_PATA_UNK; 185 return ATA_CBL_PATA_UNK;
199 /* UDMA 100 or later */ 186 /* UDMA 100 or later */
200 pci_read_config_dword(pdev, 0x50, &ata66); 187 pci_read_config_dword(pdev, 0x50, &ata66);
@@ -229,11 +216,10 @@ static int via_pre_reset(struct ata_link *link, unsigned long deadline)
229 216
230 217
231/** 218/**
232 * via_do_set_mode - set initial PIO mode data 219 * via_do_set_mode - set transfer mode data
233 * @ap: ATA interface 220 * @ap: ATA interface
234 * @adev: ATA device 221 * @adev: ATA device
235 * @mode: ATA mode being programmed 222 * @mode: ATA mode being programmed
236 * @tdiv: Clocks per PCI clock
237 * @set_ast: Set to program address setup 223 * @set_ast: Set to program address setup
238 * @udma_type: UDMA mode/format of registers 224 * @udma_type: UDMA mode/format of registers
239 * 225 *
@@ -244,17 +230,27 @@ static int via_pre_reset(struct ata_link *link, unsigned long deadline)
244 * on the two channels. 230 * on the two channels.
245 */ 231 */
246 232
247static void via_do_set_mode(struct ata_port *ap, struct ata_device *adev, int mode, int tdiv, int set_ast, int udma_type) 233static void via_do_set_mode(struct ata_port *ap, struct ata_device *adev,
234 int mode, int set_ast, int udma_type)
248{ 235{
249 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 236 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
250 struct ata_device *peer = ata_dev_pair(adev); 237 struct ata_device *peer = ata_dev_pair(adev);
251 struct ata_timing t, p; 238 struct ata_timing t, p;
252 static int via_clock = 33333; /* Bus clock in kHZ - ought to be tunable one day */ 239 static int via_clock = 33333; /* Bus clock in kHZ */
253 unsigned long T = 1000000000 / via_clock; 240 unsigned long T = 1000000000 / via_clock;
254 unsigned long UT = T/tdiv; 241 unsigned long UT = T;
255 int ut; 242 int ut;
256 int offset = 3 - (2*ap->port_no) - adev->devno; 243 int offset = 3 - (2*ap->port_no) - adev->devno;
257 244
245 switch (udma_type) {
246 case ATA_UDMA4:
247 UT = T / 2; break;
248 case ATA_UDMA5:
249 UT = T / 3; break;
250 case ATA_UDMA6:
251 UT = T / 4; break;
252 }
253
258 /* Calculate the timing values we require */ 254 /* Calculate the timing values we require */
259 ata_timing_compute(adev, mode, &t, T, UT); 255 ata_timing_compute(adev, mode, &t, T, UT);
260 256
@@ -273,7 +269,7 @@ static void via_do_set_mode(struct ata_port *ap, struct ata_device *adev, int mo
273 269
274 pci_read_config_byte(pdev, 0x4C, &setup); 270 pci_read_config_byte(pdev, 0x4C, &setup);
275 setup &= ~(3 << shift); 271 setup &= ~(3 << shift);
276 setup |= clamp_val(t.setup, 1, 4) << shift; /* 1,4 or 1,4 - 1 FIXME */ 272 setup |= (clamp_val(t.setup, 1, 4) - 1) << shift;
277 pci_write_config_byte(pdev, 0x4C, setup); 273 pci_write_config_byte(pdev, 0x4C, setup);
278 } 274 }
279 275
@@ -284,22 +280,20 @@ static void via_do_set_mode(struct ata_port *ap, struct ata_device *adev, int mo
284 ((clamp_val(t.active, 1, 16) - 1) << 4) | (clamp_val(t.recover, 1, 16) - 1)); 280 ((clamp_val(t.active, 1, 16) - 1) << 4) | (clamp_val(t.recover, 1, 16) - 1));
285 281
286 /* Load the UDMA bits according to type */ 282 /* Load the UDMA bits according to type */
287 switch(udma_type) { 283 switch (udma_type) {
288 default: 284 case ATA_UDMA2:
289 /* BUG() ? */ 285 default:
290 /* fall through */ 286 ut = t.udma ? (0xe0 | (clamp_val(t.udma, 2, 5) - 2)) : 0x03;
291 case 33: 287 break;
292 ut = t.udma ? (0xe0 | (clamp_val(t.udma, 2, 5) - 2)) : 0x03; 288 case ATA_UDMA4:
293 break; 289 ut = t.udma ? (0xe8 | (clamp_val(t.udma, 2, 9) - 2)) : 0x0f;
294 case 66: 290 break;
295 ut = t.udma ? (0xe8 | (clamp_val(t.udma, 2, 9) - 2)) : 0x0f; 291 case ATA_UDMA5:
296 break; 292 ut = t.udma ? (0xe0 | (clamp_val(t.udma, 2, 9) - 2)) : 0x07;
297 case 100: 293 break;
298 ut = t.udma ? (0xe0 | (clamp_val(t.udma, 2, 9) - 2)) : 0x07; 294 case ATA_UDMA6:
299 break; 295 ut = t.udma ? (0xe0 | (clamp_val(t.udma, 2, 9) - 2)) : 0x07;
300 case 133: 296 break;
301 ut = t.udma ? (0xe0 | (clamp_val(t.udma, 2, 9) - 2)) : 0x07;
302 break;
303 } 297 }
304 298
305 /* Set UDMA unless device is not UDMA capable */ 299 /* Set UDMA unless device is not UDMA capable */
@@ -325,22 +319,16 @@ static void via_set_piomode(struct ata_port *ap, struct ata_device *adev)
325{ 319{
326 const struct via_isa_bridge *config = ap->host->private_data; 320 const struct via_isa_bridge *config = ap->host->private_data;
327 int set_ast = (config->flags & VIA_BAD_AST) ? 0 : 1; 321 int set_ast = (config->flags & VIA_BAD_AST) ? 0 : 1;
328 int mode = config->flags & VIA_UDMA;
329 static u8 tclock[5] = { 1, 1, 2, 3, 4 };
330 static u8 udma[5] = { 0, 33, 66, 100, 133 };
331 322
332 via_do_set_mode(ap, adev, adev->pio_mode, tclock[mode], set_ast, udma[mode]); 323 via_do_set_mode(ap, adev, adev->pio_mode, set_ast, config->udma_mask);
333} 324}
334 325
335static void via_set_dmamode(struct ata_port *ap, struct ata_device *adev) 326static void via_set_dmamode(struct ata_port *ap, struct ata_device *adev)
336{ 327{
337 const struct via_isa_bridge *config = ap->host->private_data; 328 const struct via_isa_bridge *config = ap->host->private_data;
338 int set_ast = (config->flags & VIA_BAD_AST) ? 0 : 1; 329 int set_ast = (config->flags & VIA_BAD_AST) ? 0 : 1;
339 int mode = config->flags & VIA_UDMA;
340 static u8 tclock[5] = { 1, 1, 2, 3, 4 };
341 static u8 udma[5] = { 0, 33, 66, 100, 133 };
342 330
343 via_do_set_mode(ap, adev, adev->dma_mode, tclock[mode], set_ast, udma[mode]); 331 via_do_set_mode(ap, adev, adev->dma_mode, set_ast, config->udma_mask);
344} 332}
345 333
346/** 334/**
@@ -604,33 +592,29 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
604 via_config_fifo(pdev, config->flags); 592 via_config_fifo(pdev, config->flags);
605 593
606 /* Clock set up */ 594 /* Clock set up */
607 switch(config->flags & VIA_UDMA) { 595 switch (config->udma_mask) {
608 case VIA_UDMA_NONE: 596 case 0x00:
609 if (config->flags & VIA_NO_UNMASK) 597 if (config->flags & VIA_NO_UNMASK)
610 ppi[0] = &via_mwdma_info_borked; 598 ppi[0] = &via_mwdma_info_borked;
611 else 599 else
612 ppi[0] = &via_mwdma_info; 600 ppi[0] = &via_mwdma_info;
613 break; 601 break;
614 case VIA_UDMA_33: 602 case ATA_UDMA2:
615 ppi[0] = &via_udma33_info; 603 ppi[0] = &via_udma33_info;
616 break; 604 break;
617 case VIA_UDMA_66: 605 case ATA_UDMA4:
618 ppi[0] = &via_udma66_info; 606 ppi[0] = &via_udma66_info;
619 /* The 66 MHz devices require we enable the clock */ 607 break;
620 pci_read_config_dword(pdev, 0x50, &timing); 608 case ATA_UDMA5:
621 timing |= 0x80008; 609 ppi[0] = &via_udma100_info;
622 pci_write_config_dword(pdev, 0x50, timing); 610 break;
623 break; 611 case ATA_UDMA6:
624 case VIA_UDMA_100: 612 ppi[0] = &via_udma133_info;
625 ppi[0] = &via_udma100_info; 613 break;
626 break; 614 default:
627 case VIA_UDMA_133: 615 WARN_ON(1);
628 ppi[0] = &via_udma133_info; 616 return -ENODEV;
629 break; 617 }
630 default:
631 WARN_ON(1);
632 return -ENODEV;
633 }
634 618
635 if (config->flags & VIA_BAD_CLK66) { 619 if (config->flags & VIA_BAD_CLK66) {
636 /* Disable the 66MHz clock on problem devices */ 620 /* Disable the 66MHz clock on problem devices */
@@ -640,7 +624,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
640 } 624 }
641 625
642 /* We have established the device type, now fire it up */ 626 /* We have established the device type, now fire it up */
643 return ata_pci_sff_init_one(pdev, ppi, &via_sht, (void *)config); 627 return ata_pci_sff_init_one(pdev, ppi, &via_sht, (void *)config, 0);
644} 628}
645 629
646#ifdef CONFIG_PM 630#ifdef CONFIG_PM
@@ -667,7 +651,7 @@ static int via_reinit_one(struct pci_dev *pdev)
667 651
668 via_config_fifo(pdev, config->flags); 652 via_config_fifo(pdev, config->flags);
669 653
670 if ((config->flags & VIA_UDMA) == VIA_UDMA_66) { 654 if (config->udma_mask == ATA_UDMA4) {
671 /* The 66 MHz devices require we enable the clock */ 655 /* The 66 MHz devices require we enable the clock */
672 pci_read_config_dword(pdev, 0x50, &timing); 656 pci_read_config_dword(pdev, 0x50, &timing);
673 timing |= 0x80008; 657 timing |= 0x80008;
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 0c82d335c55d..684fe04dbbb7 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -772,7 +772,7 @@ static int nv_adma_slave_config(struct scsi_device *sdev)
772 } 772 }
773 773
774 blk_queue_segment_boundary(sdev->request_queue, segment_boundary); 774 blk_queue_segment_boundary(sdev->request_queue, segment_boundary);
775 blk_queue_max_hw_segments(sdev->request_queue, sg_tablesize); 775 blk_queue_max_segments(sdev->request_queue, sg_tablesize);
776 ata_port_printk(ap, KERN_INFO, 776 ata_port_printk(ap, KERN_INFO,
777 "DMA mask 0x%llX, segment boundary 0x%lX, hw segs %hu\n", 777 "DMA mask 0x%llX, segment boundary 0x%lX, hw segs %hu\n",
778 (unsigned long long)*ap->host->dev->dma_mask, 778 (unsigned long long)*ap->host->dev->dma_mask,
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 02efd9a83d26..08f65492cc81 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -40,11 +40,13 @@
40#include <linux/blkdev.h> 40#include <linux/blkdev.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/device.h> 42#include <linux/device.h>
43#include <scsi/scsi.h>
44#include <scsi/scsi_cmnd.h>
43#include <scsi/scsi_host.h> 45#include <scsi/scsi_host.h>
44#include <linux/libata.h> 46#include <linux/libata.h>
45 47
46#define DRV_NAME "sata_via" 48#define DRV_NAME "sata_via"
47#define DRV_VERSION "2.4" 49#define DRV_VERSION "2.6"
48 50
49/* 51/*
50 * vt8251 is different from other sata controllers of VIA. It has two 52 * vt8251 is different from other sata controllers of VIA. It has two
@@ -80,6 +82,7 @@ static int vt8251_scr_write(struct ata_link *link, unsigned int scr, u32 val);
80static void svia_tf_load(struct ata_port *ap, const struct ata_taskfile *tf); 82static void svia_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
81static void svia_noop_freeze(struct ata_port *ap); 83static void svia_noop_freeze(struct ata_port *ap);
82static int vt6420_prereset(struct ata_link *link, unsigned long deadline); 84static int vt6420_prereset(struct ata_link *link, unsigned long deadline);
85static void vt6420_bmdma_start(struct ata_queued_cmd *qc);
83static int vt6421_pata_cable_detect(struct ata_port *ap); 86static int vt6421_pata_cable_detect(struct ata_port *ap);
84static void vt6421_set_pio_mode(struct ata_port *ap, struct ata_device *adev); 87static void vt6421_set_pio_mode(struct ata_port *ap, struct ata_device *adev);
85static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev); 88static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev);
@@ -121,6 +124,7 @@ static struct ata_port_operations vt6420_sata_ops = {
121 .inherits = &svia_base_ops, 124 .inherits = &svia_base_ops,
122 .freeze = svia_noop_freeze, 125 .freeze = svia_noop_freeze,
123 .prereset = vt6420_prereset, 126 .prereset = vt6420_prereset,
127 .bmdma_start = vt6420_bmdma_start,
124}; 128};
125 129
126static struct ata_port_operations vt6421_pata_ops = { 130static struct ata_port_operations vt6421_pata_ops = {
@@ -377,6 +381,17 @@ static int vt6420_prereset(struct ata_link *link, unsigned long deadline)
377 return 0; 381 return 0;
378} 382}
379 383
384static void vt6420_bmdma_start(struct ata_queued_cmd *qc)
385{
386 struct ata_port *ap = qc->ap;
387 if ((qc->tf.command == ATA_CMD_PACKET) &&
388 (qc->scsicmd->sc_data_direction == DMA_TO_DEVICE)) {
389 /* Prevents corruption on some ATAPI burners */
390 ata_sff_pause(ap);
391 }
392 ata_bmdma_start(qc);
393}
394
380static int vt6421_pata_cable_detect(struct ata_port *ap) 395static int vt6421_pata_cable_detect(struct ata_port *ap)
381{ 396{
382 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 397 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -392,14 +407,16 @@ static void vt6421_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
392{ 407{
393 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 408 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
394 static const u8 pio_bits[] = { 0xA8, 0x65, 0x65, 0x31, 0x20 }; 409 static const u8 pio_bits[] = { 0xA8, 0x65, 0x65, 0x31, 0x20 };
395 pci_write_config_byte(pdev, PATA_PIO_TIMING, pio_bits[adev->pio_mode - XFER_PIO_0]); 410 pci_write_config_byte(pdev, PATA_PIO_TIMING - adev->devno,
411 pio_bits[adev->pio_mode - XFER_PIO_0]);
396} 412}
397 413
398static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev) 414static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev)
399{ 415{
400 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 416 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
401 static const u8 udma_bits[] = { 0xEE, 0xE8, 0xE6, 0xE4, 0xE2, 0xE1, 0xE0, 0xE0 }; 417 static const u8 udma_bits[] = { 0xEE, 0xE8, 0xE6, 0xE4, 0xE2, 0xE1, 0xE0, 0xE0 };
402 pci_write_config_byte(pdev, PATA_UDMA_TIMING, udma_bits[adev->dma_mode - XFER_UDMA_0]); 418 pci_write_config_byte(pdev, PATA_UDMA_TIMING - adev->devno,
419 udma_bits[adev->dma_mode - XFER_UDMA_0]);
403} 420}
404 421
405static const unsigned int svia_bar_sizes[] = { 422static const unsigned int svia_bar_sizes[] = {
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index ce1fa923c414..459f1bc25a7b 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -2534,8 +2534,8 @@ static bool DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
2534 blk_queue_bounce_limit(RequestQueue, Controller->BounceBufferLimit); 2534 blk_queue_bounce_limit(RequestQueue, Controller->BounceBufferLimit);
2535 RequestQueue->queuedata = Controller; 2535 RequestQueue->queuedata = Controller;
2536 blk_queue_max_hw_segments(RequestQueue, Controller->DriverScatterGatherLimit); 2536 blk_queue_max_hw_segments(RequestQueue, Controller->DriverScatterGatherLimit);
2537 blk_queue_max_phys_segments(RequestQueue, Controller->DriverScatterGatherLimit); 2537 blk_queue_max_segments(RequestQueue, Controller->DriverScatterGatherLimit);
2538 blk_queue_max_sectors(RequestQueue, Controller->MaxBlocksPerCommand); 2538 blk_queue_max_hw_sectors(RequestQueue, Controller->MaxBlocksPerCommand);
2539 disk->queue = RequestQueue; 2539 disk->queue = RequestQueue;
2540 sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n); 2540 sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n);
2541 disk->major = MajorNumber; 2541 disk->major = MajorNumber;
@@ -7134,7 +7134,7 @@ static struct DAC960_privdata DAC960_P_privdata = {
7134 .MemoryWindowSize = DAC960_PD_RegisterWindowSize, 7134 .MemoryWindowSize = DAC960_PD_RegisterWindowSize,
7135}; 7135};
7136 7136
7137static struct pci_device_id DAC960_id_table[] = { 7137static const struct pci_device_id DAC960_id_table[] = {
7138 { 7138 {
7139 .vendor = PCI_VENDOR_ID_MYLEX, 7139 .vendor = PCI_VENDOR_ID_MYLEX,
7140 .device = PCI_DEVICE_ID_MYLEX_DAC960_GEM, 7140 .device = PCI_DEVICE_ID_MYLEX_DAC960_GEM,
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 4f688434daf1..c6ddeacb77fd 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -434,7 +434,7 @@ static struct brd_device *brd_alloc(int i)
434 goto out_free_dev; 434 goto out_free_dev;
435 blk_queue_make_request(brd->brd_queue, brd_make_request); 435 blk_queue_make_request(brd->brd_queue, brd_make_request);
436 blk_queue_ordered(brd->brd_queue, QUEUE_ORDERED_TAG, NULL); 436 blk_queue_ordered(brd->brd_queue, QUEUE_ORDERED_TAG, NULL);
437 blk_queue_max_sectors(brd->brd_queue, 1024); 437 blk_queue_max_hw_sectors(brd->brd_queue, 1024);
438 blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY); 438 blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY);
439 439
440 disk = brd->brd_disk = alloc_disk(1 << part_shift); 440 disk = brd->brd_disk = alloc_disk(1 << part_shift);
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 9291614ac6b7..9e3af307aae1 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -257,6 +257,79 @@ static inline void removeQ(CommandList_struct *c)
257 hlist_del_init(&c->list); 257 hlist_del_init(&c->list);
258} 258}
259 259
260static void cciss_free_sg_chain_blocks(SGDescriptor_struct **cmd_sg_list,
261 int nr_cmds)
262{
263 int i;
264
265 if (!cmd_sg_list)
266 return;
267 for (i = 0; i < nr_cmds; i++) {
268 kfree(cmd_sg_list[i]);
269 cmd_sg_list[i] = NULL;
270 }
271 kfree(cmd_sg_list);
272}
273
274static SGDescriptor_struct **cciss_allocate_sg_chain_blocks(
275 ctlr_info_t *h, int chainsize, int nr_cmds)
276{
277 int j;
278 SGDescriptor_struct **cmd_sg_list;
279
280 if (chainsize <= 0)
281 return NULL;
282
283 cmd_sg_list = kmalloc(sizeof(*cmd_sg_list) * nr_cmds, GFP_KERNEL);
284 if (!cmd_sg_list)
285 return NULL;
286
287 /* Build up chain blocks for each command */
288 for (j = 0; j < nr_cmds; j++) {
289 /* Need a block of chainsized s/g elements. */
290 cmd_sg_list[j] = kmalloc((chainsize *
291 sizeof(*cmd_sg_list[j])), GFP_KERNEL);
292 if (!cmd_sg_list[j]) {
293 dev_err(&h->pdev->dev, "Cannot get memory "
294 "for s/g chains.\n");
295 goto clean;
296 }
297 }
298 return cmd_sg_list;
299clean:
300 cciss_free_sg_chain_blocks(cmd_sg_list, nr_cmds);
301 return NULL;
302}
303
304static void cciss_unmap_sg_chain_block(ctlr_info_t *h, CommandList_struct *c)
305{
306 SGDescriptor_struct *chain_sg;
307 u64bit temp64;
308
309 if (c->Header.SGTotal <= h->max_cmd_sgentries)
310 return;
311
312 chain_sg = &c->SG[h->max_cmd_sgentries - 1];
313 temp64.val32.lower = chain_sg->Addr.lower;
314 temp64.val32.upper = chain_sg->Addr.upper;
315 pci_unmap_single(h->pdev, temp64.val, chain_sg->Len, PCI_DMA_TODEVICE);
316}
317
318static void cciss_map_sg_chain_block(ctlr_info_t *h, CommandList_struct *c,
319 SGDescriptor_struct *chain_block, int len)
320{
321 SGDescriptor_struct *chain_sg;
322 u64bit temp64;
323
324 chain_sg = &c->SG[h->max_cmd_sgentries - 1];
325 chain_sg->Ext = CCISS_SG_CHAIN;
326 chain_sg->Len = len;
327 temp64.val = pci_map_single(h->pdev, chain_block, len,
328 PCI_DMA_TODEVICE);
329 chain_sg->Addr.lower = temp64.val32.lower;
330 chain_sg->Addr.upper = temp64.val32.upper;
331}
332
260#include "cciss_scsi.c" /* For SCSI tape support */ 333#include "cciss_scsi.c" /* For SCSI tape support */
261 334
262static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG", 335static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG",
@@ -1344,26 +1417,27 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
1344 kfree(buff); 1417 kfree(buff);
1345 return -ENOMEM; 1418 return -ENOMEM;
1346 } 1419 }
1347 // Fill in the command type 1420 /* Fill in the command type */
1348 c->cmd_type = CMD_IOCTL_PEND; 1421 c->cmd_type = CMD_IOCTL_PEND;
1349 // Fill in Command Header 1422 /* Fill in Command Header */
1350 c->Header.ReplyQueue = 0; // unused in simple mode 1423 c->Header.ReplyQueue = 0; /* unused in simple mode */
1351 if (iocommand.buf_size > 0) // buffer to fill 1424 if (iocommand.buf_size > 0) /* buffer to fill */
1352 { 1425 {
1353 c->Header.SGList = 1; 1426 c->Header.SGList = 1;
1354 c->Header.SGTotal = 1; 1427 c->Header.SGTotal = 1;
1355 } else // no buffers to fill 1428 } else /* no buffers to fill */
1356 { 1429 {
1357 c->Header.SGList = 0; 1430 c->Header.SGList = 0;
1358 c->Header.SGTotal = 0; 1431 c->Header.SGTotal = 0;
1359 } 1432 }
1360 c->Header.LUN = iocommand.LUN_info; 1433 c->Header.LUN = iocommand.LUN_info;
1361 c->Header.Tag.lower = c->busaddr; // use the kernel address the cmd block for tag 1434 /* use the kernel address the cmd block for tag */
1435 c->Header.Tag.lower = c->busaddr;
1362 1436
1363 // Fill in Request block 1437 /* Fill in Request block */
1364 c->Request = iocommand.Request; 1438 c->Request = iocommand.Request;
1365 1439
1366 // Fill in the scatter gather information 1440 /* Fill in the scatter gather information */
1367 if (iocommand.buf_size > 0) { 1441 if (iocommand.buf_size > 0) {
1368 temp64.val = pci_map_single(host->pdev, buff, 1442 temp64.val = pci_map_single(host->pdev, buff,
1369 iocommand.buf_size, 1443 iocommand.buf_size,
@@ -1371,7 +1445,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
1371 c->SG[0].Addr.lower = temp64.val32.lower; 1445 c->SG[0].Addr.lower = temp64.val32.lower;
1372 c->SG[0].Addr.upper = temp64.val32.upper; 1446 c->SG[0].Addr.upper = temp64.val32.upper;
1373 c->SG[0].Len = iocommand.buf_size; 1447 c->SG[0].Len = iocommand.buf_size;
1374 c->SG[0].Ext = 0; // we are not chaining 1448 c->SG[0].Ext = 0; /* we are not chaining */
1375 } 1449 }
1376 c->waiting = &wait; 1450 c->waiting = &wait;
1377 1451
@@ -1670,14 +1744,9 @@ static void cciss_softirq_done(struct request *rq)
1670 /* unmap the DMA mapping for all the scatter gather elements */ 1744 /* unmap the DMA mapping for all the scatter gather elements */
1671 for (i = 0; i < cmd->Header.SGList; i++) { 1745 for (i = 0; i < cmd->Header.SGList; i++) {
1672 if (curr_sg[sg_index].Ext == CCISS_SG_CHAIN) { 1746 if (curr_sg[sg_index].Ext == CCISS_SG_CHAIN) {
1673 temp64.val32.lower = cmd->SG[i].Addr.lower; 1747 cciss_unmap_sg_chain_block(h, cmd);
1674 temp64.val32.upper = cmd->SG[i].Addr.upper;
1675 pci_dma_sync_single_for_cpu(h->pdev, temp64.val,
1676 cmd->SG[i].Len, ddir);
1677 pci_unmap_single(h->pdev, temp64.val,
1678 cmd->SG[i].Len, ddir);
1679 /* Point to the next block */ 1748 /* Point to the next block */
1680 curr_sg = h->cmd_sg_list[cmd->cmdindex]->sgchain; 1749 curr_sg = h->cmd_sg_list[cmd->cmdindex];
1681 sg_index = 0; 1750 sg_index = 0;
1682 } 1751 }
1683 temp64.val32.lower = curr_sg[sg_index].Addr.lower; 1752 temp64.val32.lower = curr_sg[sg_index].Addr.lower;
@@ -1796,12 +1865,9 @@ static int cciss_add_disk(ctlr_info_t *h, struct gendisk *disk,
1796 blk_queue_bounce_limit(disk->queue, h->pdev->dma_mask); 1865 blk_queue_bounce_limit(disk->queue, h->pdev->dma_mask);
1797 1866
1798 /* This is a hardware imposed limit. */ 1867 /* This is a hardware imposed limit. */
1799 blk_queue_max_hw_segments(disk->queue, h->maxsgentries); 1868 blk_queue_max_segments(disk->queue, h->maxsgentries);
1800
1801 /* This is a limit in the driver and could be eliminated. */
1802 blk_queue_max_phys_segments(disk->queue, h->maxsgentries);
1803 1869
1804 blk_queue_max_sectors(disk->queue, h->cciss_max_sectors); 1870 blk_queue_max_hw_sectors(disk->queue, h->cciss_max_sectors);
1805 1871
1806 blk_queue_softirq_done(disk->queue, cciss_softirq_done); 1872 blk_queue_softirq_done(disk->queue, cciss_softirq_done);
1807 1873
@@ -2425,7 +2491,7 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff,
2425 c->Request.Type.Direction = XFER_READ; 2491 c->Request.Type.Direction = XFER_READ;
2426 c->Request.Timeout = 0; 2492 c->Request.Timeout = 0;
2427 c->Request.CDB[0] = cmd; 2493 c->Request.CDB[0] = cmd;
2428 c->Request.CDB[6] = (size >> 24) & 0xFF; //MSB 2494 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */
2429 c->Request.CDB[7] = (size >> 16) & 0xFF; 2495 c->Request.CDB[7] = (size >> 16) & 0xFF;
2430 c->Request.CDB[8] = (size >> 8) & 0xFF; 2496 c->Request.CDB[8] = (size >> 8) & 0xFF;
2431 c->Request.CDB[9] = size & 0xFF; 2497 c->Request.CDB[9] = size & 0xFF;
@@ -2694,7 +2760,7 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
2694 "cciss: reading geometry failed, volume " 2760 "cciss: reading geometry failed, volume "
2695 "does not support reading geometry\n"); 2761 "does not support reading geometry\n");
2696 drv->heads = 255; 2762 drv->heads = 255;
2697 drv->sectors = 32; // Sectors per track 2763 drv->sectors = 32; /* Sectors per track */
2698 drv->cylinders = total_size + 1; 2764 drv->cylinders = total_size + 1;
2699 drv->raid_level = RAID_UNKNOWN; 2765 drv->raid_level = RAID_UNKNOWN;
2700 } else { 2766 } else {
@@ -3082,7 +3148,6 @@ static void do_cciss_request(struct request_queue *q)
3082 SGDescriptor_struct *curr_sg; 3148 SGDescriptor_struct *curr_sg;
3083 drive_info_struct *drv; 3149 drive_info_struct *drv;
3084 int i, dir; 3150 int i, dir;
3085 int nseg = 0;
3086 int sg_index = 0; 3151 int sg_index = 0;
3087 int chained = 0; 3152 int chained = 0;
3088 3153
@@ -3112,19 +3177,19 @@ static void do_cciss_request(struct request_queue *q)
3112 3177
3113 /* fill in the request */ 3178 /* fill in the request */
3114 drv = creq->rq_disk->private_data; 3179 drv = creq->rq_disk->private_data;
3115 c->Header.ReplyQueue = 0; // unused in simple mode 3180 c->Header.ReplyQueue = 0; /* unused in simple mode */
3116 /* got command from pool, so use the command block index instead */ 3181 /* got command from pool, so use the command block index instead */
3117 /* for direct lookups. */ 3182 /* for direct lookups. */
3118 /* The first 2 bits are reserved for controller error reporting. */ 3183 /* The first 2 bits are reserved for controller error reporting. */
3119 c->Header.Tag.lower = (c->cmdindex << 3); 3184 c->Header.Tag.lower = (c->cmdindex << 3);
3120 c->Header.Tag.lower |= 0x04; /* flag for direct lookup. */ 3185 c->Header.Tag.lower |= 0x04; /* flag for direct lookup. */
3121 memcpy(&c->Header.LUN, drv->LunID, sizeof(drv->LunID)); 3186 memcpy(&c->Header.LUN, drv->LunID, sizeof(drv->LunID));
3122 c->Request.CDBLen = 10; // 12 byte commands not in FW yet; 3187 c->Request.CDBLen = 10; /* 12 byte commands not in FW yet; */
3123 c->Request.Type.Type = TYPE_CMD; // It is a command. 3188 c->Request.Type.Type = TYPE_CMD; /* It is a command. */
3124 c->Request.Type.Attribute = ATTR_SIMPLE; 3189 c->Request.Type.Attribute = ATTR_SIMPLE;
3125 c->Request.Type.Direction = 3190 c->Request.Type.Direction =
3126 (rq_data_dir(creq) == READ) ? XFER_READ : XFER_WRITE; 3191 (rq_data_dir(creq) == READ) ? XFER_READ : XFER_WRITE;
3127 c->Request.Timeout = 0; // Don't time out 3192 c->Request.Timeout = 0; /* Don't time out */
3128 c->Request.CDB[0] = 3193 c->Request.CDB[0] =
3129 (rq_data_dir(creq) == READ) ? h->cciss_read : h->cciss_write; 3194 (rq_data_dir(creq) == READ) ? h->cciss_read : h->cciss_write;
3130 start_blk = blk_rq_pos(creq); 3195 start_blk = blk_rq_pos(creq);
@@ -3149,13 +3214,8 @@ static void do_cciss_request(struct request_queue *q)
3149 for (i = 0; i < seg; i++) { 3214 for (i = 0; i < seg; i++) {
3150 if (((sg_index+1) == (h->max_cmd_sgentries)) && 3215 if (((sg_index+1) == (h->max_cmd_sgentries)) &&
3151 !chained && ((seg - i) > 1)) { 3216 !chained && ((seg - i) > 1)) {
3152 nseg = seg - i;
3153 curr_sg[sg_index].Len = (nseg) *
3154 sizeof(SGDescriptor_struct);
3155 curr_sg[sg_index].Ext = CCISS_SG_CHAIN;
3156
3157 /* Point to next chain block. */ 3217 /* Point to next chain block. */
3158 curr_sg = h->cmd_sg_list[c->cmdindex]->sgchain; 3218 curr_sg = h->cmd_sg_list[c->cmdindex];
3159 sg_index = 0; 3219 sg_index = 0;
3160 chained = 1; 3220 chained = 1;
3161 } 3221 }
@@ -3166,31 +3226,12 @@ static void do_cciss_request(struct request_queue *q)
3166 curr_sg[sg_index].Addr.lower = temp64.val32.lower; 3226 curr_sg[sg_index].Addr.lower = temp64.val32.lower;
3167 curr_sg[sg_index].Addr.upper = temp64.val32.upper; 3227 curr_sg[sg_index].Addr.upper = temp64.val32.upper;
3168 curr_sg[sg_index].Ext = 0; /* we are not chaining */ 3228 curr_sg[sg_index].Ext = 0; /* we are not chaining */
3169
3170 ++sg_index; 3229 ++sg_index;
3171 } 3230 }
3172 3231 if (chained)
3173 if (chained) { 3232 cciss_map_sg_chain_block(h, c, h->cmd_sg_list[c->cmdindex],
3174 int len; 3233 (seg - (h->max_cmd_sgentries - 1)) *
3175 curr_sg = c->SG; 3234 sizeof(SGDescriptor_struct));
3176 sg_index = h->max_cmd_sgentries - 1;
3177 len = curr_sg[sg_index].Len;
3178 /* Setup pointer to next chain block.
3179 * Fill out last element in current chain
3180 * block with address of next chain block.
3181 */
3182 temp64.val = pci_map_single(h->pdev,
3183 h->cmd_sg_list[c->cmdindex]->sgchain,
3184 len, dir);
3185
3186 h->cmd_sg_list[c->cmdindex]->sg_chain_dma = temp64.val;
3187 curr_sg[sg_index].Addr.lower = temp64.val32.lower;
3188 curr_sg[sg_index].Addr.upper = temp64.val32.upper;
3189
3190 pci_dma_sync_single_for_device(h->pdev,
3191 h->cmd_sg_list[c->cmdindex]->sg_chain_dma,
3192 len, dir);
3193 }
3194 3235
3195 /* track how many SG entries we are using */ 3236 /* track how many SG entries we are using */
3196 if (seg > h->maxSG) 3237 if (seg > h->maxSG)
@@ -3209,11 +3250,11 @@ static void do_cciss_request(struct request_queue *q)
3209 if (likely(blk_fs_request(creq))) { 3250 if (likely(blk_fs_request(creq))) {
3210 if(h->cciss_read == CCISS_READ_10) { 3251 if(h->cciss_read == CCISS_READ_10) {
3211 c->Request.CDB[1] = 0; 3252 c->Request.CDB[1] = 0;
3212 c->Request.CDB[2] = (start_blk >> 24) & 0xff; //MSB 3253 c->Request.CDB[2] = (start_blk >> 24) & 0xff; /* MSB */
3213 c->Request.CDB[3] = (start_blk >> 16) & 0xff; 3254 c->Request.CDB[3] = (start_blk >> 16) & 0xff;
3214 c->Request.CDB[4] = (start_blk >> 8) & 0xff; 3255 c->Request.CDB[4] = (start_blk >> 8) & 0xff;
3215 c->Request.CDB[5] = start_blk & 0xff; 3256 c->Request.CDB[5] = start_blk & 0xff;
3216 c->Request.CDB[6] = 0; // (sect >> 24) & 0xff; MSB 3257 c->Request.CDB[6] = 0; /* (sect >> 24) & 0xff; MSB */
3217 c->Request.CDB[7] = (blk_rq_sectors(creq) >> 8) & 0xff; 3258 c->Request.CDB[7] = (blk_rq_sectors(creq) >> 8) & 0xff;
3218 c->Request.CDB[8] = blk_rq_sectors(creq) & 0xff; 3259 c->Request.CDB[8] = blk_rq_sectors(creq) & 0xff;
3219 c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0; 3260 c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0;
@@ -3222,7 +3263,7 @@ static void do_cciss_request(struct request_queue *q)
3222 3263
3223 c->Request.CDBLen = 16; 3264 c->Request.CDBLen = 16;
3224 c->Request.CDB[1]= 0; 3265 c->Request.CDB[1]= 0;
3225 c->Request.CDB[2]= (upper32 >> 24) & 0xff; //MSB 3266 c->Request.CDB[2]= (upper32 >> 24) & 0xff; /* MSB */
3226 c->Request.CDB[3]= (upper32 >> 16) & 0xff; 3267 c->Request.CDB[3]= (upper32 >> 16) & 0xff;
3227 c->Request.CDB[4]= (upper32 >> 8) & 0xff; 3268 c->Request.CDB[4]= (upper32 >> 8) & 0xff;
3228 c->Request.CDB[5]= upper32 & 0xff; 3269 c->Request.CDB[5]= upper32 & 0xff;
@@ -4240,37 +4281,10 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
4240 goto clean4; 4281 goto clean4;
4241 } 4282 }
4242 } 4283 }
4243 hba[i]->cmd_sg_list = kmalloc(sizeof(struct Cmd_sg_list *) * 4284 hba[i]->cmd_sg_list = cciss_allocate_sg_chain_blocks(hba[i],
4244 hba[i]->nr_cmds, 4285 hba[i]->chainsize, hba[i]->nr_cmds);
4245 GFP_KERNEL); 4286 if (!hba[i]->cmd_sg_list && hba[i]->chainsize > 0)
4246 if (!hba[i]->cmd_sg_list) {
4247 printk(KERN_ERR "cciss%d: Cannot get memory for "
4248 "s/g chaining.\n", i);
4249 goto clean4; 4287 goto clean4;
4250 }
4251 /* Build up chain blocks for each command */
4252 if (hba[i]->chainsize > 0) {
4253 for (j = 0; j < hba[i]->nr_cmds; j++) {
4254 hba[i]->cmd_sg_list[j] =
4255 kmalloc(sizeof(struct Cmd_sg_list),
4256 GFP_KERNEL);
4257 if (!hba[i]->cmd_sg_list[j]) {
4258 printk(KERN_ERR "cciss%d: Cannot get memory "
4259 "for chain block.\n", i);
4260 goto clean4;
4261 }
4262 /* Need a block of chainsized s/g elements. */
4263 hba[i]->cmd_sg_list[j]->sgchain =
4264 kmalloc((hba[i]->chainsize *
4265 sizeof(SGDescriptor_struct)),
4266 GFP_KERNEL);
4267 if (!hba[i]->cmd_sg_list[j]->sgchain) {
4268 printk(KERN_ERR "cciss%d: Cannot get memory "
4269 "for s/g chains\n", i);
4270 goto clean4;
4271 }
4272 }
4273 }
4274 4288
4275 spin_lock_init(&hba[i]->lock); 4289 spin_lock_init(&hba[i]->lock);
4276 4290
@@ -4329,16 +4343,7 @@ clean4:
4329 for (k = 0; k < hba[i]->nr_cmds; k++) 4343 for (k = 0; k < hba[i]->nr_cmds; k++)
4330 kfree(hba[i]->scatter_list[k]); 4344 kfree(hba[i]->scatter_list[k]);
4331 kfree(hba[i]->scatter_list); 4345 kfree(hba[i]->scatter_list);
4332 /* Only free up extra s/g lists if controller supports them */ 4346 cciss_free_sg_chain_blocks(hba[i]->cmd_sg_list, hba[i]->nr_cmds);
4333 if (hba[i]->chainsize > 0) {
4334 for (j = 0; j < hba[i]->nr_cmds; j++) {
4335 if (hba[i]->cmd_sg_list[j]) {
4336 kfree(hba[i]->cmd_sg_list[j]->sgchain);
4337 kfree(hba[i]->cmd_sg_list[j]);
4338 }
4339 }
4340 kfree(hba[i]->cmd_sg_list);
4341 }
4342 if (hba[i]->cmd_pool) 4347 if (hba[i]->cmd_pool)
4343 pci_free_consistent(hba[i]->pdev, 4348 pci_free_consistent(hba[i]->pdev,
4344 hba[i]->nr_cmds * sizeof(CommandList_struct), 4349 hba[i]->nr_cmds * sizeof(CommandList_struct),
@@ -4456,16 +4461,7 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
4456 for (j = 0; j < hba[i]->nr_cmds; j++) 4461 for (j = 0; j < hba[i]->nr_cmds; j++)
4457 kfree(hba[i]->scatter_list[j]); 4462 kfree(hba[i]->scatter_list[j]);
4458 kfree(hba[i]->scatter_list); 4463 kfree(hba[i]->scatter_list);
4459 /* Only free up extra s/g lists if controller supports them */ 4464 cciss_free_sg_chain_blocks(hba[i]->cmd_sg_list, hba[i]->nr_cmds);
4460 if (hba[i]->chainsize > 0) {
4461 for (j = 0; j < hba[i]->nr_cmds; j++) {
4462 if (hba[i]->cmd_sg_list[j]) {
4463 kfree(hba[i]->cmd_sg_list[j]->sgchain);
4464 kfree(hba[i]->cmd_sg_list[j]);
4465 }
4466 }
4467 kfree(hba[i]->cmd_sg_list);
4468 }
4469 /* 4465 /*
4470 * Deliberately omit pci_disable_device(): it does something nasty to 4466 * Deliberately omit pci_disable_device(): it does something nasty to
4471 * Smart Array controllers that pci_enable_device does not undo 4467 * Smart Array controllers that pci_enable_device does not undo
@@ -4498,7 +4494,7 @@ static int __init cciss_init(void)
4498 * boundary. Given that we use pci_alloc_consistent() to allocate an 4494 * boundary. Given that we use pci_alloc_consistent() to allocate an
4499 * array of them, the size must be a multiple of 8 bytes. 4495 * array of them, the size must be a multiple of 8 bytes.
4500 */ 4496 */
4501 BUILD_BUG_ON(sizeof(CommandList_struct) % 8); 4497 BUILD_BUG_ON(sizeof(CommandList_struct) % COMMANDLIST_ALIGNMENT);
4502 4498
4503 printk(KERN_INFO DRIVER_NAME "\n"); 4499 printk(KERN_INFO DRIVER_NAME "\n");
4504 4500
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index 1d95db254069..c5d411174db0 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -55,18 +55,12 @@ typedef struct _drive_info_struct
55 char device_initialized; /* indicates whether dev is initialized */ 55 char device_initialized; /* indicates whether dev is initialized */
56} drive_info_struct; 56} drive_info_struct;
57 57
58struct Cmd_sg_list {
59 SGDescriptor_struct *sgchain;
60 dma_addr_t sg_chain_dma;
61 int chain_block_size;
62};
63
64struct ctlr_info 58struct ctlr_info
65{ 59{
66 int ctlr; 60 int ctlr;
67 char devname[8]; 61 char devname[8];
68 char *product_name; 62 char *product_name;
69 char firm_ver[4]; // Firmware version 63 char firm_ver[4]; /* Firmware version */
70 struct pci_dev *pdev; 64 struct pci_dev *pdev;
71 __u32 board_id; 65 __u32 board_id;
72 void __iomem *vaddr; 66 void __iomem *vaddr;
@@ -89,7 +83,7 @@ struct ctlr_info
89 int maxsgentries; 83 int maxsgentries;
90 int chainsize; 84 int chainsize;
91 int max_cmd_sgentries; 85 int max_cmd_sgentries;
92 struct Cmd_sg_list **cmd_sg_list; 86 SGDescriptor_struct **cmd_sg_list;
93 87
94# define DOORBELL_INT 0 88# define DOORBELL_INT 0
95# define PERF_MODE_INT 1 89# define PERF_MODE_INT 1
@@ -103,7 +97,7 @@ struct ctlr_info
103 BYTE cciss_write; 97 BYTE cciss_write;
104 BYTE cciss_read_capacity; 98 BYTE cciss_read_capacity;
105 99
106 // information about each logical volume 100 /* information about each logical volume */
107 drive_info_struct *drv[CISS_MAX_LUN]; 101 drive_info_struct *drv[CISS_MAX_LUN];
108 102
109 struct access_method access; 103 struct access_method access;
@@ -116,7 +110,7 @@ struct ctlr_info
116 unsigned int maxSG; 110 unsigned int maxSG;
117 spinlock_t lock; 111 spinlock_t lock;
118 112
119 //* pointers to command and error info pool */ 113 /* pointers to command and error info pool */
120 CommandList_struct *cmd_pool; 114 CommandList_struct *cmd_pool;
121 dma_addr_t cmd_pool_dhandle; 115 dma_addr_t cmd_pool_dhandle;
122 ErrorInfo_struct *errinfo_pool; 116 ErrorInfo_struct *errinfo_pool;
@@ -134,12 +128,10 @@ struct ctlr_info
134 */ 128 */
135 int next_to_run; 129 int next_to_run;
136 130
137 // Disk structures we need to pass back 131 /* Disk structures we need to pass back */
138 struct gendisk *gendisk[CISS_MAX_LUN]; 132 struct gendisk *gendisk[CISS_MAX_LUN];
139#ifdef CONFIG_CISS_SCSI_TAPE 133#ifdef CONFIG_CISS_SCSI_TAPE
140 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ 134 struct cciss_scsi_adapter_data_t *scsi_ctlr;
141 /* list of block side commands the scsi error handling sucked up */
142 /* and saved for later processing */
143#endif 135#endif
144 unsigned char alive; 136 unsigned char alive;
145 struct list_head scan_list; 137 struct list_head scan_list;
@@ -315,4 +307,3 @@ struct board_type {
315#define CCISS_LOCK(i) (&hba[i]->lock) 307#define CCISS_LOCK(i) (&hba[i]->lock)
316 308
317#endif /* CCISS_H */ 309#endif /* CCISS_H */
318
diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h
index 6afa700890ff..e624ff959cb6 100644
--- a/drivers/block/cciss_cmd.h
+++ b/drivers/block/cciss_cmd.h
@@ -1,31 +1,16 @@
1#ifndef CCISS_CMD_H 1#ifndef CCISS_CMD_H
2#define CCISS_CMD_H 2#define CCISS_CMD_H
3//########################################################################### 3
4//DEFINES 4#include <linux/cciss_defs.h>
5//########################################################################### 5
6/* DEFINES */
6#define CISS_VERSION "1.00" 7#define CISS_VERSION "1.00"
7 8
8//general boundary definitions 9/* general boundary definitions */
9#define SENSEINFOBYTES 32//note that this value may vary between host implementations
10#define MAXSGENTRIES 32 10#define MAXSGENTRIES 32
11#define CCISS_SG_CHAIN 0x80000000 11#define CCISS_SG_CHAIN 0x80000000
12#define MAXREPLYQS 256 12#define MAXREPLYQS 256
13 13
14//Command Status value
15#define CMD_SUCCESS 0x0000
16#define CMD_TARGET_STATUS 0x0001
17#define CMD_DATA_UNDERRUN 0x0002
18#define CMD_DATA_OVERRUN 0x0003
19#define CMD_INVALID 0x0004
20#define CMD_PROTOCOL_ERR 0x0005
21#define CMD_HARDWARE_ERR 0x0006
22#define CMD_CONNECTION_LOST 0x0007
23#define CMD_ABORTED 0x0008
24#define CMD_ABORT_FAILED 0x0009
25#define CMD_UNSOLICITED_ABORT 0x000A
26#define CMD_TIMEOUT 0x000B
27#define CMD_UNABORTABLE 0x000C
28
29/* Unit Attentions ASC's as defined for the MSA2012sa */ 14/* Unit Attentions ASC's as defined for the MSA2012sa */
30#define POWER_OR_RESET 0x29 15#define POWER_OR_RESET 0x29
31#define STATE_CHANGED 0x2a 16#define STATE_CHANGED 0x2a
@@ -49,30 +34,13 @@
49#define ASYM_ACCESS_CHANGED 0x06 34#define ASYM_ACCESS_CHANGED 0x06
50#define LUN_CAPACITY_CHANGED 0x09 35#define LUN_CAPACITY_CHANGED 0x09
51 36
52//transfer direction 37/* config space register offsets */
53#define XFER_NONE 0x00
54#define XFER_WRITE 0x01
55#define XFER_READ 0x02
56#define XFER_RSVD 0x03
57
58//task attribute
59#define ATTR_UNTAGGED 0x00
60#define ATTR_SIMPLE 0x04
61#define ATTR_HEADOFQUEUE 0x05
62#define ATTR_ORDERED 0x06
63#define ATTR_ACA 0x07
64
65//cdb type
66#define TYPE_CMD 0x00
67#define TYPE_MSG 0x01
68
69//config space register offsets
70#define CFG_VENDORID 0x00 38#define CFG_VENDORID 0x00
71#define CFG_DEVICEID 0x02 39#define CFG_DEVICEID 0x02
72#define CFG_I2OBAR 0x10 40#define CFG_I2OBAR 0x10
73#define CFG_MEM1BAR 0x14 41#define CFG_MEM1BAR 0x14
74 42
75//i2o space register offsets 43/* i2o space register offsets */
76#define I2O_IBDB_SET 0x20 44#define I2O_IBDB_SET 0x20
77#define I2O_IBDB_CLEAR 0x70 45#define I2O_IBDB_CLEAR 0x70
78#define I2O_INT_STATUS 0x30 46#define I2O_INT_STATUS 0x30
@@ -81,7 +49,7 @@
81#define I2O_OBPOST_Q 0x44 49#define I2O_OBPOST_Q 0x44
82#define I2O_DMA1_CFG 0x214 50#define I2O_DMA1_CFG 0x214
83 51
84//Configuration Table 52/* Configuration Table */
85#define CFGTBL_ChangeReq 0x00000001l 53#define CFGTBL_ChangeReq 0x00000001l
86#define CFGTBL_AccCmds 0x00000001l 54#define CFGTBL_AccCmds 0x00000001l
87 55
@@ -103,24 +71,17 @@ typedef union _u64bit
103 __u64 val; 71 __u64 val;
104} u64bit; 72} u64bit;
105 73
106// Type defs used in the following structs 74/* Type defs used in the following structs */
107#define BYTE __u8
108#define WORD __u16
109#define HWORD __u16
110#define DWORD __u32
111#define QWORD vals32 75#define QWORD vals32
112 76
113//########################################################################### 77/* STRUCTURES */
114//STRUCTURES
115//###########################################################################
116#define CISS_MAX_LUN 1024
117#define CISS_MAX_PHYS_LUN 1024 78#define CISS_MAX_PHYS_LUN 1024
118// SCSI-3 Cmmands 79/* SCSI-3 Cmmands */
119 80
120#pragma pack(1) 81#pragma pack(1)
121 82
122#define CISS_INQUIRY 0x12 83#define CISS_INQUIRY 0x12
123//Date returned 84/* Date returned */
124typedef struct _InquiryData_struct 85typedef struct _InquiryData_struct
125{ 86{
126 BYTE data_byte[36]; 87 BYTE data_byte[36];
@@ -128,7 +89,7 @@ typedef struct _InquiryData_struct
128 89
129#define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */ 90#define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */
130#define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */ 91#define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */
131// Data returned 92/* Data returned */
132typedef struct _ReportLUNdata_struct 93typedef struct _ReportLUNdata_struct
133{ 94{
134 BYTE LUNListLength[4]; 95 BYTE LUNListLength[4];
@@ -139,8 +100,8 @@ typedef struct _ReportLUNdata_struct
139#define CCISS_READ_CAPACITY 0x25 /* Read Capacity */ 100#define CCISS_READ_CAPACITY 0x25 /* Read Capacity */
140typedef struct _ReadCapdata_struct 101typedef struct _ReadCapdata_struct
141{ 102{
142 BYTE total_size[4]; // Total size in blocks 103 BYTE total_size[4]; /* Total size in blocks */
143 BYTE block_size[4]; // Size of blocks in bytes 104 BYTE block_size[4]; /* Size of blocks in bytes */
144} ReadCapdata_struct; 105} ReadCapdata_struct;
145 106
146#define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */ 107#define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */
@@ -172,52 +133,13 @@ typedef struct _ReadCapdata_struct_16
172#define CDB_LEN10 10 133#define CDB_LEN10 10
173#define CDB_LEN16 16 134#define CDB_LEN16 16
174 135
175// BMIC commands 136/* BMIC commands */
176#define BMIC_READ 0x26 137#define BMIC_READ 0x26
177#define BMIC_WRITE 0x27 138#define BMIC_WRITE 0x27
178#define BMIC_CACHE_FLUSH 0xc2 139#define BMIC_CACHE_FLUSH 0xc2
179#define CCISS_CACHE_FLUSH 0x01 //C2 was already being used by CCISS 140#define CCISS_CACHE_FLUSH 0x01 /* C2 was already being used by CCISS */
180
181//Command List Structure
182typedef union _SCSI3Addr_struct {
183 struct {
184 BYTE Dev;
185 BYTE Bus:6;
186 BYTE Mode:2; // b00
187 } PeripDev;
188 struct {
189 BYTE DevLSB;
190 BYTE DevMSB:6;
191 BYTE Mode:2; // b01
192 } LogDev;
193 struct {
194 BYTE Dev:5;
195 BYTE Bus:3;
196 BYTE Targ:6;
197 BYTE Mode:2; // b10
198 } LogUnit;
199} SCSI3Addr_struct;
200
201typedef struct _PhysDevAddr_struct {
202 DWORD TargetId:24;
203 DWORD Bus:6;
204 DWORD Mode:2;
205 SCSI3Addr_struct Target[2]; //2 level target device addr
206} PhysDevAddr_struct;
207
208typedef struct _LogDevAddr_struct {
209 DWORD VolId:30;
210 DWORD Mode:2;
211 BYTE reserved[4];
212} LogDevAddr_struct;
213
214typedef union _LUNAddr_struct {
215 BYTE LunAddrBytes[8];
216 SCSI3Addr_struct SCSI3Lun[4];
217 PhysDevAddr_struct PhysDev;
218 LogDevAddr_struct LogDev;
219} LUNAddr_struct;
220 141
142/* Command List Structure */
221#define CTLR_LUNID "\0\0\0\0\0\0\0\0" 143#define CTLR_LUNID "\0\0\0\0\0\0\0\0"
222 144
223typedef struct _CommandListHeader_struct { 145typedef struct _CommandListHeader_struct {
@@ -227,16 +149,6 @@ typedef struct _CommandListHeader_struct {
227 QWORD Tag; 149 QWORD Tag;
228 LUNAddr_struct LUN; 150 LUNAddr_struct LUN;
229} CommandListHeader_struct; 151} CommandListHeader_struct;
230typedef struct _RequestBlock_struct {
231 BYTE CDBLen;
232 struct {
233 BYTE Type:3;
234 BYTE Attribute:3;
235 BYTE Direction:2;
236 } Type;
237 HWORD Timeout;
238 BYTE CDB[16];
239} RequestBlock_struct;
240typedef struct _ErrDescriptor_struct { 152typedef struct _ErrDescriptor_struct {
241 QWORD Addr; 153 QWORD Addr;
242 DWORD Len; 154 DWORD Len;
@@ -247,28 +159,6 @@ typedef struct _SGDescriptor_struct {
247 DWORD Ext; 159 DWORD Ext;
248} SGDescriptor_struct; 160} SGDescriptor_struct;
249 161
250typedef union _MoreErrInfo_struct{
251 struct {
252 BYTE Reserved[3];
253 BYTE Type;
254 DWORD ErrorInfo;
255 }Common_Info;
256 struct{
257 BYTE Reserved[2];
258 BYTE offense_size;//size of offending entry
259 BYTE offense_num; //byte # of offense 0-base
260 DWORD offense_value;
261 }Invalid_Cmd;
262}MoreErrInfo_struct;
263typedef struct _ErrorInfo_struct {
264 BYTE ScsiStatus;
265 BYTE SenseLen;
266 HWORD CommandStatus;
267 DWORD ResidualCnt;
268 MoreErrInfo_struct MoreErrInfo;
269 BYTE SenseInfo[SENSEINFOBYTES];
270} ErrorInfo_struct;
271
272/* Command types */ 162/* Command types */
273#define CMD_RWREQ 0x00 163#define CMD_RWREQ 0x00
274#define CMD_IOCTL_PEND 0x01 164#define CMD_IOCTL_PEND 0x01
@@ -277,10 +167,18 @@ typedef struct _ErrorInfo_struct {
277#define CMD_MSG_TIMEOUT 0x05 167#define CMD_MSG_TIMEOUT 0x05
278#define CMD_MSG_STALE 0xff 168#define CMD_MSG_STALE 0xff
279 169
280/* This structure needs to be divisible by 8 for new 170/* This structure needs to be divisible by COMMANDLIST_ALIGNMENT
281 * indexing method. 171 * because low bits of the address are used to to indicate that
172 * whether the tag contains an index or an address. PAD_32 and
173 * PAD_64 can be adjusted independently as needed for 32-bit
174 * and 64-bits systems.
282 */ 175 */
283#define PADSIZE (sizeof(long) - 4) 176#define COMMANDLIST_ALIGNMENT (8)
177#define IS_64_BIT ((sizeof(long) - 4)/4)
178#define IS_32_BIT (!IS_64_BIT)
179#define PAD_32 (0)
180#define PAD_64 (4)
181#define PADSIZE (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64)
284typedef struct _CommandList_struct { 182typedef struct _CommandList_struct {
285 CommandListHeader_struct Header; 183 CommandListHeader_struct Header;
286 RequestBlock_struct Request; 184 RequestBlock_struct Request;
@@ -300,7 +198,7 @@ typedef struct _CommandList_struct {
300 char pad[PADSIZE]; 198 char pad[PADSIZE];
301} CommandList_struct; 199} CommandList_struct;
302 200
303//Configuration Table Structure 201/* Configuration Table Structure */
304typedef struct _HostWrite_struct { 202typedef struct _HostWrite_struct {
305 DWORD TransportRequest; 203 DWORD TransportRequest;
306 DWORD Reserved; 204 DWORD Reserved;
@@ -326,4 +224,4 @@ typedef struct _CfgTable_struct {
326 DWORD MaxPhysicalDrivesPerLogicalUnit; 224 DWORD MaxPhysicalDrivesPerLogicalUnit;
327} CfgTable_struct; 225} CfgTable_struct;
328#pragma pack() 226#pragma pack()
329#endif // CCISS_CMD_H 227#endif /* CCISS_CMD_H */
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 5d0e46dc3632..e1d0e2cfec72 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -84,7 +84,6 @@ static struct scsi_host_template cciss_driver_template = {
84 .queuecommand = cciss_scsi_queue_command, 84 .queuecommand = cciss_scsi_queue_command,
85 .can_queue = SCSI_CCISS_CAN_QUEUE, 85 .can_queue = SCSI_CCISS_CAN_QUEUE,
86 .this_id = 7, 86 .this_id = 7,
87 .sg_tablesize = MAXSGENTRIES,
88 .cmd_per_lun = 1, 87 .cmd_per_lun = 1,
89 .use_clustering = DISABLE_CLUSTERING, 88 .use_clustering = DISABLE_CLUSTERING,
90 /* Can't have eh_bus_reset_handler or eh_host_reset_handler for cciss */ 89 /* Can't have eh_bus_reset_handler or eh_host_reset_handler for cciss */
@@ -93,11 +92,16 @@ static struct scsi_host_template cciss_driver_template = {
93}; 92};
94 93
95#pragma pack(1) 94#pragma pack(1)
95
96#define SCSI_PAD_32 0
97#define SCSI_PAD_64 0
98
96struct cciss_scsi_cmd_stack_elem_t { 99struct cciss_scsi_cmd_stack_elem_t {
97 CommandList_struct cmd; 100 CommandList_struct cmd;
98 ErrorInfo_struct Err; 101 ErrorInfo_struct Err;
99 __u32 busaddr; 102 __u32 busaddr;
100 __u32 pad; 103 int cmdindex;
104 u8 pad[IS_32_BIT * SCSI_PAD_32 + IS_64_BIT * SCSI_PAD_64];
101}; 105};
102 106
103#pragma pack() 107#pragma pack()
@@ -118,16 +122,15 @@ struct cciss_scsi_cmd_stack_t {
118struct cciss_scsi_adapter_data_t { 122struct cciss_scsi_adapter_data_t {
119 struct Scsi_Host *scsi_host; 123 struct Scsi_Host *scsi_host;
120 struct cciss_scsi_cmd_stack_t cmd_stack; 124 struct cciss_scsi_cmd_stack_t cmd_stack;
125 SGDescriptor_struct **cmd_sg_list;
121 int registered; 126 int registered;
122 spinlock_t lock; // to protect ccissscsi[ctlr]; 127 spinlock_t lock; // to protect ccissscsi[ctlr];
123}; 128};
124 129
125#define CPQ_TAPE_LOCK(ctlr, flags) spin_lock_irqsave( \ 130#define CPQ_TAPE_LOCK(ctlr, flags) spin_lock_irqsave( \
126 &(((struct cciss_scsi_adapter_data_t *) \ 131 &hba[ctlr]->scsi_ctlr->lock, flags);
127 hba[ctlr]->scsi_ctlr)->lock), flags);
128#define CPQ_TAPE_UNLOCK(ctlr, flags) spin_unlock_irqrestore( \ 132#define CPQ_TAPE_UNLOCK(ctlr, flags) spin_unlock_irqrestore( \
129 &(((struct cciss_scsi_adapter_data_t *) \ 133 &hba[ctlr]->scsi_ctlr->lock, flags);
130 hba[ctlr]->scsi_ctlr)->lock), flags);
131 134
132static CommandList_struct * 135static CommandList_struct *
133scsi_cmd_alloc(ctlr_info_t *h) 136scsi_cmd_alloc(ctlr_info_t *h)
@@ -143,7 +146,7 @@ scsi_cmd_alloc(ctlr_info_t *h)
143 struct cciss_scsi_cmd_stack_t *stk; 146 struct cciss_scsi_cmd_stack_t *stk;
144 u64bit temp64; 147 u64bit temp64;
145 148
146 sa = (struct cciss_scsi_adapter_data_t *) h->scsi_ctlr; 149 sa = h->scsi_ctlr;
147 stk = &sa->cmd_stack; 150 stk = &sa->cmd_stack;
148 151
149 if (stk->top < 0) 152 if (stk->top < 0)
@@ -154,6 +157,7 @@ scsi_cmd_alloc(ctlr_info_t *h)
154 memset(&c->Err, 0, sizeof(c->Err)); 157 memset(&c->Err, 0, sizeof(c->Err));
155 /* set physical addr of cmd and addr of scsi parameters */ 158 /* set physical addr of cmd and addr of scsi parameters */
156 c->cmd.busaddr = c->busaddr; 159 c->cmd.busaddr = c->busaddr;
160 c->cmd.cmdindex = c->cmdindex;
157 /* (__u32) (stk->cmd_pool_handle + 161 /* (__u32) (stk->cmd_pool_handle +
158 (sizeof(struct cciss_scsi_cmd_stack_elem_t)*stk->top)); */ 162 (sizeof(struct cciss_scsi_cmd_stack_elem_t)*stk->top)); */
159 163
@@ -182,7 +186,7 @@ scsi_cmd_free(ctlr_info_t *h, CommandList_struct *cmd)
182 struct cciss_scsi_adapter_data_t *sa; 186 struct cciss_scsi_adapter_data_t *sa;
183 struct cciss_scsi_cmd_stack_t *stk; 187 struct cciss_scsi_cmd_stack_t *stk;
184 188
185 sa = (struct cciss_scsi_adapter_data_t *) h->scsi_ctlr; 189 sa = h->scsi_ctlr;
186 stk = &sa->cmd_stack; 190 stk = &sa->cmd_stack;
187 if (stk->top >= CMD_STACK_SIZE) { 191 if (stk->top >= CMD_STACK_SIZE) {
188 printk("cciss: scsi_cmd_free called too many times.\n"); 192 printk("cciss: scsi_cmd_free called too many times.\n");
@@ -199,24 +203,31 @@ scsi_cmd_stack_setup(int ctlr, struct cciss_scsi_adapter_data_t *sa)
199 struct cciss_scsi_cmd_stack_t *stk; 203 struct cciss_scsi_cmd_stack_t *stk;
200 size_t size; 204 size_t size;
201 205
206 sa->cmd_sg_list = cciss_allocate_sg_chain_blocks(hba[ctlr],
207 hba[ctlr]->chainsize, CMD_STACK_SIZE);
208 if (!sa->cmd_sg_list && hba[ctlr]->chainsize > 0)
209 return -ENOMEM;
210
202 stk = &sa->cmd_stack; 211 stk = &sa->cmd_stack;
203 size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE; 212 size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE;
204 213
205 // pci_alloc_consistent guarantees 32-bit DMA address will 214 /* Check alignment, see cciss_cmd.h near CommandList_struct def. */
206 // be used 215 BUILD_BUG_ON((sizeof(*stk->pool) % COMMANDLIST_ALIGNMENT) != 0);
207 216 /* pci_alloc_consistent guarantees 32-bit DMA address will be used */
208 stk->pool = (struct cciss_scsi_cmd_stack_elem_t *) 217 stk->pool = (struct cciss_scsi_cmd_stack_elem_t *)
209 pci_alloc_consistent(hba[ctlr]->pdev, size, &stk->cmd_pool_handle); 218 pci_alloc_consistent(hba[ctlr]->pdev, size, &stk->cmd_pool_handle);
210 219
211 if (stk->pool == NULL) { 220 if (stk->pool == NULL) {
212 printk("stk->pool is null\n"); 221 cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE);
213 return -1; 222 sa->cmd_sg_list = NULL;
223 return -ENOMEM;
214 } 224 }
215 225
216 for (i=0; i<CMD_STACK_SIZE; i++) { 226 for (i=0; i<CMD_STACK_SIZE; i++) {
217 stk->elem[i] = &stk->pool[i]; 227 stk->elem[i] = &stk->pool[i];
218 stk->elem[i]->busaddr = (__u32) (stk->cmd_pool_handle + 228 stk->elem[i]->busaddr = (__u32) (stk->cmd_pool_handle +
219 (sizeof(struct cciss_scsi_cmd_stack_elem_t) * i)); 229 (sizeof(struct cciss_scsi_cmd_stack_elem_t) * i));
230 stk->elem[i]->cmdindex = i;
220 } 231 }
221 stk->top = CMD_STACK_SIZE-1; 232 stk->top = CMD_STACK_SIZE-1;
222 return 0; 233 return 0;
@@ -229,7 +240,7 @@ scsi_cmd_stack_free(int ctlr)
229 struct cciss_scsi_cmd_stack_t *stk; 240 struct cciss_scsi_cmd_stack_t *stk;
230 size_t size; 241 size_t size;
231 242
232 sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr; 243 sa = hba[ctlr]->scsi_ctlr;
233 stk = &sa->cmd_stack; 244 stk = &sa->cmd_stack;
234 if (stk->top != CMD_STACK_SIZE-1) { 245 if (stk->top != CMD_STACK_SIZE-1) {
235 printk( "cciss: %d scsi commands are still outstanding.\n", 246 printk( "cciss: %d scsi commands are still outstanding.\n",
@@ -241,6 +252,7 @@ scsi_cmd_stack_free(int ctlr)
241 252
242 pci_free_consistent(hba[ctlr]->pdev, size, stk->pool, stk->cmd_pool_handle); 253 pci_free_consistent(hba[ctlr]->pdev, size, stk->pool, stk->cmd_pool_handle);
243 stk->pool = NULL; 254 stk->pool = NULL;
255 cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE);
244} 256}
245 257
246#if 0 258#if 0
@@ -530,8 +542,7 @@ adjust_cciss_scsi_table(int ctlr, int hostno,
530 CPQ_TAPE_LOCK(ctlr, flags); 542 CPQ_TAPE_LOCK(ctlr, flags);
531 543
532 if (hostno != -1) /* if it's not the first time... */ 544 if (hostno != -1) /* if it's not the first time... */
533 sh = ((struct cciss_scsi_adapter_data_t *) 545 sh = hba[ctlr]->scsi_ctlr->scsi_host;
534 hba[ctlr]->scsi_ctlr)->scsi_host;
535 546
536 /* find any devices in ccissscsi[] that are not in 547 /* find any devices in ccissscsi[] that are not in
537 sd[] and remove them from ccissscsi[] */ 548 sd[] and remove them from ccissscsi[] */
@@ -702,7 +713,7 @@ cciss_scsi_setup(int cntl_num)
702 kfree(shba); 713 kfree(shba);
703 shba = NULL; 714 shba = NULL;
704 } 715 }
705 hba[cntl_num]->scsi_ctlr = (void *) shba; 716 hba[cntl_num]->scsi_ctlr = shba;
706 return; 717 return;
707} 718}
708 719
@@ -725,6 +736,8 @@ complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag)
725 ctlr = hba[cp->ctlr]; 736 ctlr = hba[cp->ctlr];
726 737
727 scsi_dma_unmap(cmd); 738 scsi_dma_unmap(cmd);
739 if (cp->Header.SGTotal > ctlr->max_cmd_sgentries)
740 cciss_unmap_sg_chain_block(ctlr, cp);
728 741
729 cmd->result = (DID_OK << 16); /* host byte */ 742 cmd->result = (DID_OK << 16); /* host byte */
730 cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */ 743 cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */
@@ -847,9 +860,10 @@ cciss_scsi_detect(int ctlr)
847 sh->io_port = 0; // good enough? FIXME, 860 sh->io_port = 0; // good enough? FIXME,
848 sh->n_io_port = 0; // I don't think we use these two... 861 sh->n_io_port = 0; // I don't think we use these two...
849 sh->this_id = SELF_SCSI_ID; 862 sh->this_id = SELF_SCSI_ID;
863 sh->sg_tablesize = hba[ctlr]->maxsgentries;
850 864
851 ((struct cciss_scsi_adapter_data_t *) 865 ((struct cciss_scsi_adapter_data_t *)
852 hba[ctlr]->scsi_ctlr)->scsi_host = (void *) sh; 866 hba[ctlr]->scsi_ctlr)->scsi_host = sh;
853 sh->hostdata[0] = (unsigned long) hba[ctlr]; 867 sh->hostdata[0] = (unsigned long) hba[ctlr];
854 sh->irq = hba[ctlr]->intr[SIMPLE_MODE_INT]; 868 sh->irq = hba[ctlr]->intr[SIMPLE_MODE_INT];
855 sh->unique_id = sh->irq; 869 sh->unique_id = sh->irq;
@@ -1364,34 +1378,54 @@ cciss_scsi_proc_info(struct Scsi_Host *sh,
1364 dma mapping and fills in the scatter gather entries of the 1378 dma mapping and fills in the scatter gather entries of the
1365 cciss command, cp. */ 1379 cciss command, cp. */
1366 1380
1367static void 1381static void cciss_scatter_gather(ctlr_info_t *h, CommandList_struct *cp,
1368cciss_scatter_gather(struct pci_dev *pdev, 1382 struct scsi_cmnd *cmd)
1369 CommandList_struct *cp,
1370 struct scsi_cmnd *cmd)
1371{ 1383{
1372 unsigned int len; 1384 unsigned int len;
1373 struct scatterlist *sg; 1385 struct scatterlist *sg;
1374 __u64 addr64; 1386 __u64 addr64;
1375 int use_sg, i; 1387 int request_nsgs, i, chained, sg_index;
1376 1388 struct cciss_scsi_adapter_data_t *sa = h->scsi_ctlr;
1377 BUG_ON(scsi_sg_count(cmd) > MAXSGENTRIES); 1389 SGDescriptor_struct *curr_sg;
1378 1390
1379 use_sg = scsi_dma_map(cmd); 1391 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries);
1380 if (use_sg) { /* not too many addrs? */ 1392
1381 scsi_for_each_sg(cmd, sg, use_sg, i) { 1393 chained = 0;
1394 sg_index = 0;
1395 curr_sg = cp->SG;
1396 request_nsgs = scsi_dma_map(cmd);
1397 if (request_nsgs) {
1398 scsi_for_each_sg(cmd, sg, request_nsgs, i) {
1399 if (sg_index + 1 == h->max_cmd_sgentries &&
1400 !chained && request_nsgs - i > 1) {
1401 chained = 1;
1402 sg_index = 0;
1403 curr_sg = sa->cmd_sg_list[cp->cmdindex];
1404 }
1382 addr64 = (__u64) sg_dma_address(sg); 1405 addr64 = (__u64) sg_dma_address(sg);
1383 len = sg_dma_len(sg); 1406 len = sg_dma_len(sg);
1384 cp->SG[i].Addr.lower = 1407 curr_sg[sg_index].Addr.lower =
1385 (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF); 1408 (__u32) (addr64 & 0x0FFFFFFFFULL);
1386 cp->SG[i].Addr.upper = 1409 curr_sg[sg_index].Addr.upper =
1387 (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF); 1410 (__u32) ((addr64 >> 32) & 0x0FFFFFFFFULL);
1388 cp->SG[i].Len = len; 1411 curr_sg[sg_index].Len = len;
1389 cp->SG[i].Ext = 0; // we are not chaining 1412 curr_sg[sg_index].Ext = 0;
1413 ++sg_index;
1390 } 1414 }
1415 if (chained)
1416 cciss_map_sg_chain_block(h, cp,
1417 sa->cmd_sg_list[cp->cmdindex],
1418 (request_nsgs - (h->max_cmd_sgentries - 1)) *
1419 sizeof(SGDescriptor_struct));
1391 } 1420 }
1392 1421 /* track how many SG entries we are using */
1393 cp->Header.SGList = (__u8) use_sg; /* no. SGs contig in this cmd */ 1422 if (request_nsgs > h->maxSG)
1394 cp->Header.SGTotal = (__u16) use_sg; /* total sgs in this cmd list */ 1423 h->maxSG = request_nsgs;
1424 cp->Header.SGTotal = (__u8) request_nsgs + chained;
1425 if (request_nsgs > h->max_cmd_sgentries)
1426 cp->Header.SGList = h->max_cmd_sgentries;
1427 else
1428 cp->Header.SGList = cp->Header.SGTotal;
1395 return; 1429 return;
1396} 1430}
1397 1431
@@ -1399,7 +1433,7 @@ cciss_scatter_gather(struct pci_dev *pdev,
1399static int 1433static int
1400cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) 1434cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
1401{ 1435{
1402 ctlr_info_t **c; 1436 ctlr_info_t *c;
1403 int ctlr, rc; 1437 int ctlr, rc;
1404 unsigned char scsi3addr[8]; 1438 unsigned char scsi3addr[8];
1405 CommandList_struct *cp; 1439 CommandList_struct *cp;
@@ -1407,8 +1441,8 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd
1407 1441
1408 // Get the ptr to our adapter structure (hba[i]) out of cmd->host. 1442 // Get the ptr to our adapter structure (hba[i]) out of cmd->host.
1409 // We violate cmd->host privacy here. (Is there another way?) 1443 // We violate cmd->host privacy here. (Is there another way?)
1410 c = (ctlr_info_t **) &cmd->device->host->hostdata[0]; 1444 c = (ctlr_info_t *) cmd->device->host->hostdata[0];
1411 ctlr = (*c)->ctlr; 1445 ctlr = c->ctlr;
1412 1446
1413 rc = lookup_scsi3addr(ctlr, cmd->device->channel, cmd->device->id, 1447 rc = lookup_scsi3addr(ctlr, cmd->device->channel, cmd->device->id,
1414 cmd->device->lun, scsi3addr); 1448 cmd->device->lun, scsi3addr);
@@ -1431,7 +1465,7 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd
1431 see what the device thinks of it. */ 1465 see what the device thinks of it. */
1432 1466
1433 spin_lock_irqsave(CCISS_LOCK(ctlr), flags); 1467 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1434 cp = scsi_cmd_alloc(*c); 1468 cp = scsi_cmd_alloc(c);
1435 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); 1469 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1436 if (cp == NULL) { /* trouble... */ 1470 if (cp == NULL) { /* trouble... */
1437 printk("scsi_cmd_alloc returned NULL!\n"); 1471 printk("scsi_cmd_alloc returned NULL!\n");
@@ -1489,15 +1523,14 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd
1489 BUG(); 1523 BUG();
1490 break; 1524 break;
1491 } 1525 }
1492 1526 cciss_scatter_gather(c, cp, cmd);
1493 cciss_scatter_gather((*c)->pdev, cp, cmd); // Fill the SG list
1494 1527
1495 /* Put the request on the tail of the request queue */ 1528 /* Put the request on the tail of the request queue */
1496 1529
1497 spin_lock_irqsave(CCISS_LOCK(ctlr), flags); 1530 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1498 addQ(&(*c)->reqQ, cp); 1531 addQ(&c->reqQ, cp);
1499 (*c)->Qdepth++; 1532 c->Qdepth++;
1500 start_io(*c); 1533 start_io(c);
1501 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); 1534 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1502 1535
1503 /* the cmd'll come back via intr handler in complete_scsi_command() */ 1536 /* the cmd'll come back via intr handler in complete_scsi_command() */
@@ -1514,7 +1547,7 @@ cciss_unregister_scsi(int ctlr)
1514 /* we are being forcibly unloaded, and may not refuse. */ 1547 /* we are being forcibly unloaded, and may not refuse. */
1515 1548
1516 spin_lock_irqsave(CCISS_LOCK(ctlr), flags); 1549 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1517 sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr; 1550 sa = hba[ctlr]->scsi_ctlr;
1518 stk = &sa->cmd_stack; 1551 stk = &sa->cmd_stack;
1519 1552
1520 /* if we weren't ever actually registered, don't unregister */ 1553 /* if we weren't ever actually registered, don't unregister */
@@ -1541,7 +1574,7 @@ cciss_engage_scsi(int ctlr)
1541 unsigned long flags; 1574 unsigned long flags;
1542 1575
1543 spin_lock_irqsave(CCISS_LOCK(ctlr), flags); 1576 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1544 sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr; 1577 sa = hba[ctlr]->scsi_ctlr;
1545 stk = &sa->cmd_stack; 1578 stk = &sa->cmd_stack;
1546 1579
1547 if (sa->registered) { 1580 if (sa->registered) {
@@ -1654,14 +1687,14 @@ static int cciss_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
1654 int rc; 1687 int rc;
1655 CommandList_struct *cmd_in_trouble; 1688 CommandList_struct *cmd_in_trouble;
1656 unsigned char lunaddr[8]; 1689 unsigned char lunaddr[8];
1657 ctlr_info_t **c; 1690 ctlr_info_t *c;
1658 int ctlr; 1691 int ctlr;
1659 1692
1660 /* find the controller to which the command to be aborted was sent */ 1693 /* find the controller to which the command to be aborted was sent */
1661 c = (ctlr_info_t **) &scsicmd->device->host->hostdata[0]; 1694 c = (ctlr_info_t *) scsicmd->device->host->hostdata[0];
1662 if (c == NULL) /* paranoia */ 1695 if (c == NULL) /* paranoia */
1663 return FAILED; 1696 return FAILED;
1664 ctlr = (*c)->ctlr; 1697 ctlr = c->ctlr;
1665 printk(KERN_WARNING "cciss%d: resetting tape drive or medium changer.\n", ctlr); 1698 printk(KERN_WARNING "cciss%d: resetting tape drive or medium changer.\n", ctlr);
1666 /* find the command that's giving us trouble */ 1699 /* find the command that's giving us trouble */
1667 cmd_in_trouble = (CommandList_struct *) scsicmd->host_scribble; 1700 cmd_in_trouble = (CommandList_struct *) scsicmd->host_scribble;
@@ -1671,7 +1704,7 @@ static int cciss_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
1671 /* send a reset to the SCSI LUN which the command was sent to */ 1704 /* send a reset to the SCSI LUN which the command was sent to */
1672 rc = sendcmd_withirq(CCISS_RESET_MSG, ctlr, NULL, 0, 0, lunaddr, 1705 rc = sendcmd_withirq(CCISS_RESET_MSG, ctlr, NULL, 0, 0, lunaddr,
1673 TYPE_MSG); 1706 TYPE_MSG);
1674 if (rc == 0 && wait_for_device_to_become_ready(*c, lunaddr) == 0) 1707 if (rc == 0 && wait_for_device_to_become_ready(c, lunaddr) == 0)
1675 return SUCCESS; 1708 return SUCCESS;
1676 printk(KERN_WARNING "cciss%d: resetting device failed.\n", ctlr); 1709 printk(KERN_WARNING "cciss%d: resetting device failed.\n", ctlr);
1677 return FAILED; 1710 return FAILED;
@@ -1682,14 +1715,14 @@ static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd)
1682 int rc; 1715 int rc;
1683 CommandList_struct *cmd_to_abort; 1716 CommandList_struct *cmd_to_abort;
1684 unsigned char lunaddr[8]; 1717 unsigned char lunaddr[8];
1685 ctlr_info_t **c; 1718 ctlr_info_t *c;
1686 int ctlr; 1719 int ctlr;
1687 1720
1688 /* find the controller to which the command to be aborted was sent */ 1721 /* find the controller to which the command to be aborted was sent */
1689 c = (ctlr_info_t **) &scsicmd->device->host->hostdata[0]; 1722 c = (ctlr_info_t *) scsicmd->device->host->hostdata[0];
1690 if (c == NULL) /* paranoia */ 1723 if (c == NULL) /* paranoia */
1691 return FAILED; 1724 return FAILED;
1692 ctlr = (*c)->ctlr; 1725 ctlr = c->ctlr;
1693 printk(KERN_WARNING "cciss%d: aborting tardy SCSI cmd\n", ctlr); 1726 printk(KERN_WARNING "cciss%d: aborting tardy SCSI cmd\n", ctlr);
1694 1727
1695 /* find the command to be aborted */ 1728 /* find the command to be aborted */
diff --git a/drivers/block/cciss_scsi.h b/drivers/block/cciss_scsi.h
index 7b750245ae76..6d5822fe851a 100644
--- a/drivers/block/cciss_scsi.h
+++ b/drivers/block/cciss_scsi.h
@@ -25,16 +25,16 @@
25 25
26#include <scsi/scsicam.h> /* possibly irrelevant, since we don't show disks */ 26#include <scsi/scsicam.h> /* possibly irrelevant, since we don't show disks */
27 27
28 // the scsi id of the adapter... 28 /* the scsi id of the adapter... */
29#define SELF_SCSI_ID 15 29#define SELF_SCSI_ID 15
30 // 15 is somewhat arbitrary, since the scsi-2 bus 30 /* 15 is somewhat arbitrary, since the scsi-2 bus
31 // that's presented by the driver to the OS is 31 that's presented by the driver to the OS is
32 // fabricated. The "real" scsi-3 bus the 32 fabricated. The "real" scsi-3 bus the
33 // hardware presents is fabricated too. 33 hardware presents is fabricated too.
34 // The actual, honest-to-goodness physical 34 The actual, honest-to-goodness physical
35 // bus that the devices are attached to is not 35 bus that the devices are attached to is not
36 // addressible natively, and may in fact turn 36 addressible natively, and may in fact turn
37 // out to be not scsi at all. 37 out to be not scsi at all. */
38 38
39#define SCSI_CCISS_CAN_QUEUE 2 39#define SCSI_CCISS_CAN_QUEUE 2
40 40
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 6422651ec364..91d11631cec9 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -448,11 +448,8 @@ static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev)
448 blk_queue_bounce_limit(q, hba[i]->pci_dev->dma_mask); 448 blk_queue_bounce_limit(q, hba[i]->pci_dev->dma_mask);
449 449
450 /* This is a hardware imposed limit. */ 450 /* This is a hardware imposed limit. */
451 blk_queue_max_hw_segments(q, SG_MAX); 451 blk_queue_max_segments(q, SG_MAX);
452 452
453 /* This is a driver limit and could be eliminated. */
454 blk_queue_max_phys_segments(q, SG_MAX);
455
456 init_timer(&hba[i]->timer); 453 init_timer(&hba[i]->timer);
457 hba[i]->timer.expires = jiffies + IDA_TIMER; 454 hba[i]->timer.expires = jiffies + IDA_TIMER;
458 hba[i]->timer.data = (unsigned long)hba[i]; 455 hba[i]->timer.data = (unsigned long)hba[i];
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 1292e0620663..4df3b40b1057 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -709,9 +709,8 @@ void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int max_seg_s) __mu
709 709
710 max_seg_s = min(queue_max_sectors(b) * queue_logical_block_size(b), max_seg_s); 710 max_seg_s = min(queue_max_sectors(b) * queue_logical_block_size(b), max_seg_s);
711 711
712 blk_queue_max_sectors(q, max_seg_s >> 9); 712 blk_queue_max_hw_sectors(q, max_seg_s >> 9);
713 blk_queue_max_phys_segments(q, max_segments ? max_segments : MAX_PHYS_SEGMENTS); 713 blk_queue_max_segments(q, max_segments ? max_segments : BLK_MAX_SEGMENTS);
714 blk_queue_max_hw_segments(q, max_segments ? max_segments : MAX_HW_SEGMENTS);
715 blk_queue_max_segment_size(q, max_seg_s); 714 blk_queue_max_segment_size(q, max_seg_s);
716 blk_queue_logical_block_size(q, 512); 715 blk_queue_logical_block_size(q, 512);
717 blk_queue_segment_boundary(q, PAGE_SIZE-1); 716 blk_queue_segment_boundary(q, PAGE_SIZE-1);
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 3266b4f65daa..b9b117059b62 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4234,7 +4234,7 @@ static int __init floppy_init(void)
4234 err = -ENOMEM; 4234 err = -ENOMEM;
4235 goto out_unreg_driver; 4235 goto out_unreg_driver;
4236 } 4236 }
4237 blk_queue_max_sectors(floppy_queue, 64); 4237 blk_queue_max_hw_sectors(floppy_queue, 64);
4238 4238
4239 blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, 4239 blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE,
4240 floppy_find, NULL, NULL); 4240 floppy_find, NULL, NULL);
diff --git a/drivers/block/hd.c b/drivers/block/hd.c
index d5cdce08ffd2..5116c65c07cb 100644
--- a/drivers/block/hd.c
+++ b/drivers/block/hd.c
@@ -719,7 +719,7 @@ static int __init hd_init(void)
719 return -ENOMEM; 719 return -ENOMEM;
720 } 720 }
721 721
722 blk_queue_max_sectors(hd_queue, 255); 722 blk_queue_max_hw_sectors(hd_queue, 255);
723 init_timer(&device_timer); 723 init_timer(&device_timer);
724 device_timer.function = hd_times_out; 724 device_timer.function = hd_times_out;
725 blk_queue_logical_block_size(hd_queue, 512); 725 blk_queue_logical_block_size(hd_queue, 512);
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index 02b2583df7fc..5416c9a606e4 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -980,7 +980,7 @@ static int mg_probe(struct platform_device *plat_dev)
980 __func__, __LINE__); 980 __func__, __LINE__);
981 goto probe_err_6; 981 goto probe_err_6;
982 } 982 }
983 blk_queue_max_sectors(host->breq, MG_MAX_SECTS); 983 blk_queue_max_hw_sectors(host->breq, MG_MAX_SECTS);
984 blk_queue_logical_block_size(host->breq, MG_SECTOR_SIZE); 984 blk_queue_logical_block_size(host->breq, MG_SECTOR_SIZE);
985 985
986 init_timer(&host->timer); 986 init_timer(&host->timer);
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 569e39e8f114..e712cd51af15 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -906,7 +906,7 @@ static int __init pd_init(void)
906 if (!pd_queue) 906 if (!pd_queue)
907 goto out1; 907 goto out1;
908 908
909 blk_queue_max_sectors(pd_queue, cluster); 909 blk_queue_max_hw_sectors(pd_queue, cluster);
910 910
911 if (register_blkdev(major, name)) 911 if (register_blkdev(major, name))
912 goto out2; 912 goto out2;
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index ea54ea393553..ddb4f9abd480 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -956,8 +956,7 @@ static int __init pf_init(void)
956 return -ENOMEM; 956 return -ENOMEM;
957 } 957 }
958 958
959 blk_queue_max_phys_segments(pf_queue, cluster); 959 blk_queue_max_segments(pf_queue, cluster);
960 blk_queue_max_hw_segments(pf_queue, cluster);
961 960
962 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) { 961 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) {
963 struct gendisk *disk = pf->disk; 962 struct gendisk *disk = pf->disk;
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 68b5957f107c..b72935b8f203 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -569,6 +569,7 @@ static struct packet_data *pkt_alloc_packet_data(int frames)
569 } 569 }
570 570
571 spin_lock_init(&pkt->lock); 571 spin_lock_init(&pkt->lock);
572 bio_list_init(&pkt->orig_bios);
572 573
573 for (i = 0; i < frames; i++) { 574 for (i = 0; i < frames; i++) {
574 struct bio *bio = pkt_bio_alloc(1); 575 struct bio *bio = pkt_bio_alloc(1);
@@ -721,43 +722,6 @@ static void pkt_rbtree_insert(struct pktcdvd_device *pd, struct pkt_rb_node *nod
721} 722}
722 723
723/* 724/*
724 * Add a bio to a single linked list defined by its head and tail pointers.
725 */
726static void pkt_add_list_last(struct bio *bio, struct bio **list_head, struct bio **list_tail)
727{
728 bio->bi_next = NULL;
729 if (*list_tail) {
730 BUG_ON((*list_head) == NULL);
731 (*list_tail)->bi_next = bio;
732 (*list_tail) = bio;
733 } else {
734 BUG_ON((*list_head) != NULL);
735 (*list_head) = bio;
736 (*list_tail) = bio;
737 }
738}
739
740/*
741 * Remove and return the first bio from a single linked list defined by its
742 * head and tail pointers.
743 */
744static inline struct bio *pkt_get_list_first(struct bio **list_head, struct bio **list_tail)
745{
746 struct bio *bio;
747
748 if (*list_head == NULL)
749 return NULL;
750
751 bio = *list_head;
752 *list_head = bio->bi_next;
753 if (*list_head == NULL)
754 *list_tail = NULL;
755
756 bio->bi_next = NULL;
757 return bio;
758}
759
760/*
761 * Send a packet_command to the underlying block device and 725 * Send a packet_command to the underlying block device and
762 * wait for completion. 726 * wait for completion.
763 */ 727 */
@@ -876,13 +840,10 @@ static noinline_for_stack int pkt_set_speed(struct pktcdvd_device *pd,
876static void pkt_queue_bio(struct pktcdvd_device *pd, struct bio *bio) 840static void pkt_queue_bio(struct pktcdvd_device *pd, struct bio *bio)
877{ 841{
878 spin_lock(&pd->iosched.lock); 842 spin_lock(&pd->iosched.lock);
879 if (bio_data_dir(bio) == READ) { 843 if (bio_data_dir(bio) == READ)
880 pkt_add_list_last(bio, &pd->iosched.read_queue, 844 bio_list_add(&pd->iosched.read_queue, bio);
881 &pd->iosched.read_queue_tail); 845 else
882 } else { 846 bio_list_add(&pd->iosched.write_queue, bio);
883 pkt_add_list_last(bio, &pd->iosched.write_queue,
884 &pd->iosched.write_queue_tail);
885 }
886 spin_unlock(&pd->iosched.lock); 847 spin_unlock(&pd->iosched.lock);
887 848
888 atomic_set(&pd->iosched.attention, 1); 849 atomic_set(&pd->iosched.attention, 1);
@@ -917,8 +878,8 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
917 int reads_queued, writes_queued; 878 int reads_queued, writes_queued;
918 879
919 spin_lock(&pd->iosched.lock); 880 spin_lock(&pd->iosched.lock);
920 reads_queued = (pd->iosched.read_queue != NULL); 881 reads_queued = !bio_list_empty(&pd->iosched.read_queue);
921 writes_queued = (pd->iosched.write_queue != NULL); 882 writes_queued = !bio_list_empty(&pd->iosched.write_queue);
922 spin_unlock(&pd->iosched.lock); 883 spin_unlock(&pd->iosched.lock);
923 884
924 if (!reads_queued && !writes_queued) 885 if (!reads_queued && !writes_queued)
@@ -927,7 +888,7 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
927 if (pd->iosched.writing) { 888 if (pd->iosched.writing) {
928 int need_write_seek = 1; 889 int need_write_seek = 1;
929 spin_lock(&pd->iosched.lock); 890 spin_lock(&pd->iosched.lock);
930 bio = pd->iosched.write_queue; 891 bio = bio_list_peek(&pd->iosched.write_queue);
931 spin_unlock(&pd->iosched.lock); 892 spin_unlock(&pd->iosched.lock);
932 if (bio && (bio->bi_sector == pd->iosched.last_write)) 893 if (bio && (bio->bi_sector == pd->iosched.last_write))
933 need_write_seek = 0; 894 need_write_seek = 0;
@@ -950,13 +911,10 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
950 } 911 }
951 912
952 spin_lock(&pd->iosched.lock); 913 spin_lock(&pd->iosched.lock);
953 if (pd->iosched.writing) { 914 if (pd->iosched.writing)
954 bio = pkt_get_list_first(&pd->iosched.write_queue, 915 bio = bio_list_pop(&pd->iosched.write_queue);
955 &pd->iosched.write_queue_tail); 916 else
956 } else { 917 bio = bio_list_pop(&pd->iosched.read_queue);
957 bio = pkt_get_list_first(&pd->iosched.read_queue,
958 &pd->iosched.read_queue_tail);
959 }
960 spin_unlock(&pd->iosched.lock); 918 spin_unlock(&pd->iosched.lock);
961 919
962 if (!bio) 920 if (!bio)
@@ -992,14 +950,14 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
992static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q) 950static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q)
993{ 951{
994 if ((pd->settings.size << 9) / CD_FRAMESIZE 952 if ((pd->settings.size << 9) / CD_FRAMESIZE
995 <= queue_max_phys_segments(q)) { 953 <= queue_max_segments(q)) {
996 /* 954 /*
997 * The cdrom device can handle one segment/frame 955 * The cdrom device can handle one segment/frame
998 */ 956 */
999 clear_bit(PACKET_MERGE_SEGS, &pd->flags); 957 clear_bit(PACKET_MERGE_SEGS, &pd->flags);
1000 return 0; 958 return 0;
1001 } else if ((pd->settings.size << 9) / PAGE_SIZE 959 } else if ((pd->settings.size << 9) / PAGE_SIZE
1002 <= queue_max_phys_segments(q)) { 960 <= queue_max_segments(q)) {
1003 /* 961 /*
1004 * We can handle this case at the expense of some extra memory 962 * We can handle this case at the expense of some extra memory
1005 * copies during write operations 963 * copies during write operations
@@ -1114,7 +1072,7 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
1114 int f; 1072 int f;
1115 char written[PACKET_MAX_SIZE]; 1073 char written[PACKET_MAX_SIZE];
1116 1074
1117 BUG_ON(!pkt->orig_bios); 1075 BUG_ON(bio_list_empty(&pkt->orig_bios));
1118 1076
1119 atomic_set(&pkt->io_wait, 0); 1077 atomic_set(&pkt->io_wait, 0);
1120 atomic_set(&pkt->io_errors, 0); 1078 atomic_set(&pkt->io_errors, 0);
@@ -1124,7 +1082,7 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
1124 */ 1082 */
1125 memset(written, 0, sizeof(written)); 1083 memset(written, 0, sizeof(written));
1126 spin_lock(&pkt->lock); 1084 spin_lock(&pkt->lock);
1127 for (bio = pkt->orig_bios; bio; bio = bio->bi_next) { 1085 bio_list_for_each(bio, &pkt->orig_bios) {
1128 int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9); 1086 int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9);
1129 int num_frames = bio->bi_size / CD_FRAMESIZE; 1087 int num_frames = bio->bi_size / CD_FRAMESIZE;
1130 pd->stats.secs_w += num_frames * (CD_FRAMESIZE >> 9); 1088 pd->stats.secs_w += num_frames * (CD_FRAMESIZE >> 9);
@@ -1363,7 +1321,7 @@ try_next_bio:
1363 break; 1321 break;
1364 pkt_rbtree_erase(pd, node); 1322 pkt_rbtree_erase(pd, node);
1365 spin_lock(&pkt->lock); 1323 spin_lock(&pkt->lock);
1366 pkt_add_list_last(bio, &pkt->orig_bios, &pkt->orig_bios_tail); 1324 bio_list_add(&pkt->orig_bios, bio);
1367 pkt->write_size += bio->bi_size / CD_FRAMESIZE; 1325 pkt->write_size += bio->bi_size / CD_FRAMESIZE;
1368 spin_unlock(&pkt->lock); 1326 spin_unlock(&pkt->lock);
1369 } 1327 }
@@ -1409,7 +1367,7 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
1409 */ 1367 */
1410 frames_write = 0; 1368 frames_write = 0;
1411 spin_lock(&pkt->lock); 1369 spin_lock(&pkt->lock);
1412 for (bio = pkt->orig_bios; bio; bio = bio->bi_next) { 1370 bio_list_for_each(bio, &pkt->orig_bios) {
1413 int segment = bio->bi_idx; 1371 int segment = bio->bi_idx;
1414 int src_offs = 0; 1372 int src_offs = 0;
1415 int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9); 1373 int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9);
@@ -1472,20 +1430,14 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
1472 1430
1473static void pkt_finish_packet(struct packet_data *pkt, int uptodate) 1431static void pkt_finish_packet(struct packet_data *pkt, int uptodate)
1474{ 1432{
1475 struct bio *bio, *next; 1433 struct bio *bio;
1476 1434
1477 if (!uptodate) 1435 if (!uptodate)
1478 pkt->cache_valid = 0; 1436 pkt->cache_valid = 0;
1479 1437
1480 /* Finish all bios corresponding to this packet */ 1438 /* Finish all bios corresponding to this packet */
1481 bio = pkt->orig_bios; 1439 while ((bio = bio_list_pop(&pkt->orig_bios)))
1482 while (bio) {
1483 next = bio->bi_next;
1484 bio->bi_next = NULL;
1485 bio_endio(bio, uptodate ? 0 : -EIO); 1440 bio_endio(bio, uptodate ? 0 : -EIO);
1486 bio = next;
1487 }
1488 pkt->orig_bios = pkt->orig_bios_tail = NULL;
1489} 1441}
1490 1442
1491static void pkt_run_state_machine(struct pktcdvd_device *pd, struct packet_data *pkt) 1443static void pkt_run_state_machine(struct pktcdvd_device *pd, struct packet_data *pkt)
@@ -2360,7 +2312,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
2360 * even if the size is a multiple of the packet size. 2312 * even if the size is a multiple of the packet size.
2361 */ 2313 */
2362 spin_lock_irq(q->queue_lock); 2314 spin_lock_irq(q->queue_lock);
2363 blk_queue_max_sectors(q, pd->settings.size); 2315 blk_queue_max_hw_sectors(q, pd->settings.size);
2364 spin_unlock_irq(q->queue_lock); 2316 spin_unlock_irq(q->queue_lock);
2365 set_bit(PACKET_WRITABLE, &pd->flags); 2317 set_bit(PACKET_WRITABLE, &pd->flags);
2366 } else { 2318 } else {
@@ -2567,8 +2519,7 @@ static int pkt_make_request(struct request_queue *q, struct bio *bio)
2567 spin_lock(&pkt->lock); 2519 spin_lock(&pkt->lock);
2568 if ((pkt->state == PACKET_WAITING_STATE) || 2520 if ((pkt->state == PACKET_WAITING_STATE) ||
2569 (pkt->state == PACKET_READ_WAIT_STATE)) { 2521 (pkt->state == PACKET_READ_WAIT_STATE)) {
2570 pkt_add_list_last(bio, &pkt->orig_bios, 2522 bio_list_add(&pkt->orig_bios, bio);
2571 &pkt->orig_bios_tail);
2572 pkt->write_size += bio->bi_size / CD_FRAMESIZE; 2523 pkt->write_size += bio->bi_size / CD_FRAMESIZE;
2573 if ((pkt->write_size >= pkt->frames) && 2524 if ((pkt->write_size >= pkt->frames) &&
2574 (pkt->state == PACKET_WAITING_STATE)) { 2525 (pkt->state == PACKET_WAITING_STATE)) {
@@ -2662,7 +2613,7 @@ static void pkt_init_queue(struct pktcdvd_device *pd)
2662 2613
2663 blk_queue_make_request(q, pkt_make_request); 2614 blk_queue_make_request(q, pkt_make_request);
2664 blk_queue_logical_block_size(q, CD_FRAMESIZE); 2615 blk_queue_logical_block_size(q, CD_FRAMESIZE);
2665 blk_queue_max_sectors(q, PACKET_MAX_SECTORS); 2616 blk_queue_max_hw_sectors(q, PACKET_MAX_SECTORS);
2666 blk_queue_merge_bvec(q, pkt_merge_bvec); 2617 blk_queue_merge_bvec(q, pkt_merge_bvec);
2667 q->queuedata = pd; 2618 q->queuedata = pd;
2668} 2619}
@@ -2898,6 +2849,8 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
2898 2849
2899 spin_lock_init(&pd->lock); 2850 spin_lock_init(&pd->lock);
2900 spin_lock_init(&pd->iosched.lock); 2851 spin_lock_init(&pd->iosched.lock);
2852 bio_list_init(&pd->iosched.read_queue);
2853 bio_list_init(&pd->iosched.write_queue);
2901 sprintf(pd->name, DRIVER_NAME"%d", idx); 2854 sprintf(pd->name, DRIVER_NAME"%d", idx);
2902 init_waitqueue_head(&pd->wqueue); 2855 init_waitqueue_head(&pd->wqueue);
2903 pd->bio_queue = RB_ROOT; 2856 pd->bio_queue = RB_ROOT;
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index 03a130dca8ab..bc95469d33c1 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -474,7 +474,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)
474 474
475 blk_queue_bounce_limit(queue, BLK_BOUNCE_HIGH); 475 blk_queue_bounce_limit(queue, BLK_BOUNCE_HIGH);
476 476
477 blk_queue_max_sectors(queue, dev->bounce_size >> 9); 477 blk_queue_max_hw_sectors(queue, dev->bounce_size >> 9);
478 blk_queue_segment_boundary(queue, -1UL); 478 blk_queue_segment_boundary(queue, -1UL);
479 blk_queue_dma_alignment(queue, dev->blk_size-1); 479 blk_queue_dma_alignment(queue, dev->blk_size-1);
480 blk_queue_logical_block_size(queue, dev->blk_size); 480 blk_queue_logical_block_size(queue, dev->blk_size);
@@ -482,8 +482,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)
482 blk_queue_ordered(queue, QUEUE_ORDERED_DRAIN_FLUSH, 482 blk_queue_ordered(queue, QUEUE_ORDERED_DRAIN_FLUSH,
483 ps3disk_prepare_flush); 483 ps3disk_prepare_flush);
484 484
485 blk_queue_max_phys_segments(queue, -1); 485 blk_queue_max_segments(queue, -1);
486 blk_queue_max_hw_segments(queue, -1);
487 blk_queue_max_segment_size(queue, dev->bounce_size); 486 blk_queue_max_segment_size(queue, dev->bounce_size);
488 487
489 gendisk = alloc_disk(PS3DISK_MINORS); 488 gendisk = alloc_disk(PS3DISK_MINORS);
diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
index 1fb6c3135fc8..e44608229972 100644
--- a/drivers/block/ps3vram.c
+++ b/drivers/block/ps3vram.c
@@ -751,10 +751,9 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
751 priv->queue = queue; 751 priv->queue = queue;
752 queue->queuedata = dev; 752 queue->queuedata = dev;
753 blk_queue_make_request(queue, ps3vram_make_request); 753 blk_queue_make_request(queue, ps3vram_make_request);
754 blk_queue_max_phys_segments(queue, MAX_PHYS_SEGMENTS); 754 blk_queue_max_segments(queue, BLK_MAX_SEGMENTS);
755 blk_queue_max_hw_segments(queue, MAX_HW_SEGMENTS); 755 blk_queue_max_segment_size(queue, BLK_MAX_SEGMENT_SIZE);
756 blk_queue_max_segment_size(queue, MAX_SEGMENT_SIZE); 756 blk_queue_max_hw_sectors(queue, BLK_SAFE_MAX_SECTORS);
757 blk_queue_max_sectors(queue, SAFE_MAX_SECTORS);
758 757
759 gendisk = alloc_disk(1); 758 gendisk = alloc_disk(1);
760 if (!gendisk) { 759 if (!gendisk) {
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 411f064760b4..48e8fee9f2d4 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -691,9 +691,8 @@ static int probe_disk(struct vdc_port *port)
691 691
692 port->disk = g; 692 port->disk = g;
693 693
694 blk_queue_max_hw_segments(q, port->ring_cookies); 694 blk_queue_max_segments(q, port->ring_cookies);
695 blk_queue_max_phys_segments(q, port->ring_cookies); 695 blk_queue_max_hw_sectors(q, port->max_xfer_size);
696 blk_queue_max_sectors(q, port->max_xfer_size);
697 g->major = vdc_major; 696 g->major = vdc_major;
698 g->first_minor = port->vio.vdev->dev_no << PARTITION_SHIFT; 697 g->first_minor = port->vio.vdev->dev_no << PARTITION_SHIFT;
699 strcpy(g->disk_name, port->disk_name); 698 strcpy(g->disk_name, port->disk_name);
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index a7c4184f4a63..b70f0fca9a42 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -409,7 +409,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
409static void carm_remove_one (struct pci_dev *pdev); 409static void carm_remove_one (struct pci_dev *pdev);
410static int carm_bdev_getgeo(struct block_device *bdev, struct hd_geometry *geo); 410static int carm_bdev_getgeo(struct block_device *bdev, struct hd_geometry *geo);
411 411
412static struct pci_device_id carm_pci_tbl[] = { 412static const struct pci_device_id carm_pci_tbl[] = {
413 { PCI_VENDOR_ID_PROMISE, 0x8000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, 413 { PCI_VENDOR_ID_PROMISE, 0x8000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
414 { PCI_VENDOR_ID_PROMISE, 0x8002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, 414 { PCI_VENDOR_ID_PROMISE, 0x8002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
415 { } /* terminate list */ 415 { } /* terminate list */
@@ -1518,8 +1518,7 @@ static int carm_init_disks(struct carm_host *host)
1518 break; 1518 break;
1519 } 1519 }
1520 disk->queue = q; 1520 disk->queue = q;
1521 blk_queue_max_hw_segments(q, CARM_MAX_REQ_SG); 1521 blk_queue_max_segments(q, CARM_MAX_REQ_SG);
1522 blk_queue_max_phys_segments(q, CARM_MAX_REQ_SG);
1523 blk_queue_segment_boundary(q, CARM_SG_BOUNDARY); 1522 blk_queue_segment_boundary(q, CARM_SG_BOUNDARY);
1524 1523
1525 q->queuedata = port; 1524 q->queuedata = port;
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index c739b203fe91..2e889838e819 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -393,7 +393,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum);
393#define ub_usb_ids usb_storage_usb_ids 393#define ub_usb_ids usb_storage_usb_ids
394#else 394#else
395 395
396static struct usb_device_id ub_usb_ids[] = { 396static const struct usb_device_id ub_usb_ids[] = {
397 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) }, 397 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) },
398 { } 398 { }
399}; 399};
@@ -2320,10 +2320,9 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum)
2320 disk->queue = q; 2320 disk->queue = q;
2321 2321
2322 blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); 2322 blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
2323 blk_queue_max_hw_segments(q, UB_MAX_REQ_SG); 2323 blk_queue_max_segments(q, UB_MAX_REQ_SG);
2324 blk_queue_max_phys_segments(q, UB_MAX_REQ_SG);
2325 blk_queue_segment_boundary(q, 0xffffffff); /* Dubious. */ 2324 blk_queue_segment_boundary(q, 0xffffffff); /* Dubious. */
2326 blk_queue_max_sectors(q, UB_MAX_SECTORS); 2325 blk_queue_max_hw_sectors(q, UB_MAX_SECTORS);
2327 blk_queue_logical_block_size(q, lun->capacity.bsize); 2326 blk_queue_logical_block_size(q, lun->capacity.bsize);
2328 2327
2329 lun->disk = disk; 2328 lun->disk = disk;
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index 1b3def1e8591..788d93882ab9 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -462,9 +462,8 @@ retry:
462 } 462 }
463 463
464 d->disk = g; 464 d->disk = g;
465 blk_queue_max_hw_segments(q, VIOMAXBLOCKDMA); 465 blk_queue_max_segments(q, VIOMAXBLOCKDMA);
466 blk_queue_max_phys_segments(q, VIOMAXBLOCKDMA); 466 blk_queue_max_hw_sectors(q, VIODASD_MAXSECTORS);
467 blk_queue_max_sectors(q, VIODASD_MAXSECTORS);
468 g->major = VIODASD_MAJOR; 467 g->major = VIODASD_MAJOR;
469 g->first_minor = dev_no << PARTITION_SHIFT; 468 g->first_minor = dev_no << PARTITION_SHIFT;
470 if (dev_no >= 26) 469 if (dev_no >= 26)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 7eff828b2117..3c64af05fa82 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -435,7 +435,7 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
435 kfree(vblk); 435 kfree(vblk);
436} 436}
437 437
438static struct virtio_device_id id_table[] = { 438static const struct virtio_device_id id_table[] = {
439 { VIRTIO_ID_BLOCK, VIRTIO_DEV_ANY_ID }, 439 { VIRTIO_ID_BLOCK, VIRTIO_DEV_ANY_ID },
440 { 0 }, 440 { 0 },
441}; 441};
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index d1fd032e7514..1a325fb05c92 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -242,7 +242,7 @@ static int __init xd_init(void)
242 } 242 }
243 243
244 /* xd_maxsectors depends on controller - so set after detection */ 244 /* xd_maxsectors depends on controller - so set after detection */
245 blk_queue_max_sectors(xd_queue, xd_maxsectors); 245 blk_queue_max_hw_sectors(xd_queue, xd_maxsectors);
246 246
247 for (i = 0; i < xd_drives; i++) 247 for (i = 0; i < xd_drives; i++)
248 add_disk(xd_gendisk[i]); 248 add_disk(xd_gendisk[i]);
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 05a31e55d278..9c09694b2520 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -346,15 +346,14 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
346 346
347 /* Hard sector size and max sectors impersonate the equiv. hardware. */ 347 /* Hard sector size and max sectors impersonate the equiv. hardware. */
348 blk_queue_logical_block_size(rq, sector_size); 348 blk_queue_logical_block_size(rq, sector_size);
349 blk_queue_max_sectors(rq, 512); 349 blk_queue_max_hw_sectors(rq, 512);
350 350
351 /* Each segment in a request is up to an aligned page in size. */ 351 /* Each segment in a request is up to an aligned page in size. */
352 blk_queue_segment_boundary(rq, PAGE_SIZE - 1); 352 blk_queue_segment_boundary(rq, PAGE_SIZE - 1);
353 blk_queue_max_segment_size(rq, PAGE_SIZE); 353 blk_queue_max_segment_size(rq, PAGE_SIZE);
354 354
355 /* Ensure a merged request will fit in a single I/O ring slot. */ 355 /* Ensure a merged request will fit in a single I/O ring slot. */
356 blk_queue_max_phys_segments(rq, BLKIF_MAX_SEGMENTS_PER_REQUEST); 356 blk_queue_max_segments(rq, BLKIF_MAX_SEGMENTS_PER_REQUEST);
357 blk_queue_max_hw_segments(rq, BLKIF_MAX_SEGMENTS_PER_REQUEST);
358 357
359 /* Make sure buffer addresses are sector-aligned. */ 358 /* Make sure buffer addresses are sector-aligned. */
360 blk_queue_dma_alignment(rq, 511); 359 blk_queue_dma_alignment(rq, 511);
@@ -1050,7 +1049,7 @@ static const struct block_device_operations xlvbd_block_fops =
1050}; 1049};
1051 1050
1052 1051
1053static struct xenbus_device_id blkfront_ids[] = { 1052static const struct xenbus_device_id blkfront_ids[] = {
1054 { "vbd" }, 1053 { "vbd" },
1055 { "" } 1054 { "" }
1056}; 1055};
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index e5c5415eb45e..e1c95e208a66 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -1227,7 +1227,7 @@ static int __devexit ace_of_remove(struct of_device *op)
1227} 1227}
1228 1228
1229/* Match table for of_platform binding */ 1229/* Match table for of_platform binding */
1230static struct of_device_id ace_of_match[] __devinitdata = { 1230static const struct of_device_id ace_of_match[] __devinitconst = {
1231 { .compatible = "xlnx,opb-sysace-1.00.b", }, 1231 { .compatible = "xlnx,opb-sysace-1.00.b", },
1232 { .compatible = "xlnx,opb-sysace-1.00.c", }, 1232 { .compatible = "xlnx,opb-sysace-1.00.c", },
1233 { .compatible = "xlnx,xps-sysace-1.00.a", }, 1233 { .compatible = "xlnx,xps-sysace-1.00.a", },
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index e789e6c9a422..03c71f7698cb 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -741,7 +741,7 @@ static int __devinit probe_gdrom_setupqueue(void)
741{ 741{
742 blk_queue_logical_block_size(gd.gdrom_rq, GDROM_HARD_SECTOR); 742 blk_queue_logical_block_size(gd.gdrom_rq, GDROM_HARD_SECTOR);
743 /* using DMA so memory will need to be contiguous */ 743 /* using DMA so memory will need to be contiguous */
744 blk_queue_max_hw_segments(gd.gdrom_rq, 1); 744 blk_queue_max_segments(gd.gdrom_rq, 1);
745 /* set a large max size to get most from DMA */ 745 /* set a large max size to get most from DMA */
746 blk_queue_max_segment_size(gd.gdrom_rq, 0x40000); 746 blk_queue_max_segment_size(gd.gdrom_rq, 0x40000);
747 gd.disk->queue = gd.gdrom_rq; 747 gd.disk->queue = gd.gdrom_rq;
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index 57ca69e0ac55..cc435be0bc13 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -616,9 +616,8 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
616 gendisk->first_minor = deviceno; 616 gendisk->first_minor = deviceno;
617 strncpy(gendisk->disk_name, c->name, 617 strncpy(gendisk->disk_name, c->name,
618 sizeof(gendisk->disk_name)); 618 sizeof(gendisk->disk_name));
619 blk_queue_max_hw_segments(q, 1); 619 blk_queue_max_segments(q, 1);
620 blk_queue_max_phys_segments(q, 1); 620 blk_queue_max_hw_sectors(q, 4096 / 512);
621 blk_queue_max_sectors(q, 4096 / 512);
622 gendisk->queue = q; 621 gendisk->queue = q;
623 gendisk->fops = &viocd_fops; 622 gendisk->fops = &viocd_fops;
624 gendisk->flags = GENHD_FL_CD|GENHD_FL_REMOVABLE; 623 gendisk->flags = GENHD_FL_CD|GENHD_FL_REMOVABLE;
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 6ea1014697d1..d31483c54883 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -114,7 +114,7 @@ config HW_RANDOM_IXP4XX
114 114
115config HW_RANDOM_OMAP 115config HW_RANDOM_OMAP
116 tristate "OMAP Random Number Generator support" 116 tristate "OMAP Random Number Generator support"
117 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX) 117 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP2)
118 default HW_RANDOM 118 default HW_RANDOM
119 ---help--- 119 ---help---
120 This driver provides kernel-side support for the Random Number 120 This driver provides kernel-side support for the Random Number
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index f706b1dffdb3..ada25bb8941e 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1185,11 +1185,6 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1185 1185
1186 rep = (down == 2); 1186 rep = (down == 2);
1187 1187
1188#ifdef CONFIG_MAC_EMUMOUSEBTN
1189 if (mac_hid_mouse_emulate_buttons(1, keycode, down))
1190 return;
1191#endif /* CONFIG_MAC_EMUMOUSEBTN */
1192
1193 if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw) 1188 if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw)
1194 if (emulate_raw(vc, keycode, !down << 7)) 1189 if (emulate_raw(vc, keycode, !down << 7))
1195 if (keycode < BTN_MISC && printk_ratelimit()) 1190 if (keycode < BTN_MISC && printk_ratelimit())
@@ -1328,6 +1323,21 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type,
1328 schedule_console_callback(); 1323 schedule_console_callback();
1329} 1324}
1330 1325
1326static bool kbd_match(struct input_handler *handler, struct input_dev *dev)
1327{
1328 int i;
1329
1330 if (test_bit(EV_SND, dev->evbit))
1331 return true;
1332
1333 if (test_bit(EV_KEY, dev->evbit))
1334 for (i = KEY_RESERVED; i < BTN_MISC; i++)
1335 if (test_bit(i, dev->keybit))
1336 return true;
1337
1338 return false;
1339}
1340
1331/* 1341/*
1332 * When a keyboard (or other input device) is found, the kbd_connect 1342 * When a keyboard (or other input device) is found, the kbd_connect
1333 * function is called. The function then looks at the device, and if it 1343 * function is called. The function then looks at the device, and if it
@@ -1339,14 +1349,6 @@ static int kbd_connect(struct input_handler *handler, struct input_dev *dev,
1339{ 1349{
1340 struct input_handle *handle; 1350 struct input_handle *handle;
1341 int error; 1351 int error;
1342 int i;
1343
1344 for (i = KEY_RESERVED; i < BTN_MISC; i++)
1345 if (test_bit(i, dev->keybit))
1346 break;
1347
1348 if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit))
1349 return -ENODEV;
1350 1352
1351 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); 1353 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
1352 if (!handle) 1354 if (!handle)
@@ -1412,6 +1414,7 @@ MODULE_DEVICE_TABLE(input, kbd_ids);
1412 1414
1413static struct input_handler kbd_handler = { 1415static struct input_handler kbd_handler = {
1414 .event = kbd_event, 1416 .event = kbd_event,
1417 .match = kbd_match,
1415 .connect = kbd_connect, 1418 .connect = kbd_connect,
1416 .disconnect = kbd_disconnect, 1419 .disconnect = kbd_disconnect,
1417 .start = kbd_start, 1420 .start = kbd_start,
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index fdbcc9fd6d31..5eb83c3ca20d 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -336,14 +336,12 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
336 336
337static int nvram_open(struct inode *inode, struct file *file) 337static int nvram_open(struct inode *inode, struct file *file)
338{ 338{
339 lock_kernel();
340 spin_lock(&nvram_state_lock); 339 spin_lock(&nvram_state_lock);
341 340
342 if ((nvram_open_cnt && (file->f_flags & O_EXCL)) || 341 if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
343 (nvram_open_mode & NVRAM_EXCL) || 342 (nvram_open_mode & NVRAM_EXCL) ||
344 ((file->f_mode & FMODE_WRITE) && (nvram_open_mode & NVRAM_WRITE))) { 343 ((file->f_mode & FMODE_WRITE) && (nvram_open_mode & NVRAM_WRITE))) {
345 spin_unlock(&nvram_state_lock); 344 spin_unlock(&nvram_state_lock);
346 unlock_kernel();
347 return -EBUSY; 345 return -EBUSY;
348 } 346 }
349 347
@@ -354,7 +352,6 @@ static int nvram_open(struct inode *inode, struct file *file)
354 nvram_open_cnt++; 352 nvram_open_cnt++;
355 353
356 spin_unlock(&nvram_state_lock); 354 spin_unlock(&nvram_state_lock);
357 unlock_kernel();
358 355
359 return 0; 356 return 0;
360} 357}
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 6fe4f7701188..578595c4425d 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -40,7 +40,6 @@ struct sh_cmt_priv {
40 struct platform_device *pdev; 40 struct platform_device *pdev;
41 41
42 unsigned long flags; 42 unsigned long flags;
43 unsigned long flags_suspend;
44 unsigned long match_value; 43 unsigned long match_value;
45 unsigned long next_match_value; 44 unsigned long next_match_value;
46 unsigned long max_match_value; 45 unsigned long max_match_value;
@@ -432,6 +431,11 @@ static void sh_cmt_clocksource_disable(struct clocksource *cs)
432 sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE); 431 sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE);
433} 432}
434 433
434static void sh_cmt_clocksource_resume(struct clocksource *cs)
435{
436 sh_cmt_start(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE);
437}
438
435static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, 439static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
436 char *name, unsigned long rating) 440 char *name, unsigned long rating)
437{ 441{
@@ -442,6 +446,8 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
442 cs->read = sh_cmt_clocksource_read; 446 cs->read = sh_cmt_clocksource_read;
443 cs->enable = sh_cmt_clocksource_enable; 447 cs->enable = sh_cmt_clocksource_enable;
444 cs->disable = sh_cmt_clocksource_disable; 448 cs->disable = sh_cmt_clocksource_disable;
449 cs->suspend = sh_cmt_clocksource_disable;
450 cs->resume = sh_cmt_clocksource_resume;
445 cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); 451 cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
446 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; 452 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
447 pr_info("sh_cmt: %s used as clock source\n", cs->name); 453 pr_info("sh_cmt: %s used as clock source\n", cs->name);
@@ -674,38 +680,11 @@ static int __devexit sh_cmt_remove(struct platform_device *pdev)
674 return -EBUSY; /* cannot unregister clockevent and clocksource */ 680 return -EBUSY; /* cannot unregister clockevent and clocksource */
675} 681}
676 682
677static int sh_cmt_suspend(struct device *dev)
678{
679 struct platform_device *pdev = to_platform_device(dev);
680 struct sh_cmt_priv *p = platform_get_drvdata(pdev);
681
682 /* save flag state and stop CMT channel */
683 p->flags_suspend = p->flags;
684 sh_cmt_stop(p, p->flags);
685 return 0;
686}
687
688static int sh_cmt_resume(struct device *dev)
689{
690 struct platform_device *pdev = to_platform_device(dev);
691 struct sh_cmt_priv *p = platform_get_drvdata(pdev);
692
693 /* start CMT channel from saved state */
694 sh_cmt_start(p, p->flags_suspend);
695 return 0;
696}
697
698static struct dev_pm_ops sh_cmt_dev_pm_ops = {
699 .suspend = sh_cmt_suspend,
700 .resume = sh_cmt_resume,
701};
702
703static struct platform_driver sh_cmt_device_driver = { 683static struct platform_driver sh_cmt_device_driver = {
704 .probe = sh_cmt_probe, 684 .probe = sh_cmt_probe,
705 .remove = __devexit_p(sh_cmt_remove), 685 .remove = __devexit_p(sh_cmt_remove),
706 .driver = { 686 .driver = {
707 .name = "sh_cmt", 687 .name = "sh_cmt",
708 .pm = &sh_cmt_dev_pm_ops,
709 } 688 }
710}; 689};
711 690
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index d485cdd8cbac..70fef40cd22f 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1571,7 +1571,7 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
1571 sdev->start_stop_pwr_cond = 1; 1571 sdev->start_stop_pwr_cond = 1;
1572 1572
1573 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) 1573 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
1574 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512); 1574 blk_queue_max_hw_sectors(sdev->request_queue, 128 * 1024 / 512);
1575 1575
1576 blk_queue_max_segment_size(sdev->request_queue, SBP2_MAX_SEG_SIZE); 1576 blk_queue_max_segment_size(sdev->request_queue, SBP2_MAX_SEG_SIZE);
1577 1577
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 5d1c2603a130..2b0bd0b042d6 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -20,15 +20,15 @@
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/i2c-pnx.h> 21#include <linux/i2c-pnx.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/err.h>
24#include <linux/clk.h>
25
23#include <mach/hardware.h> 26#include <mach/hardware.h>
24#include <mach/i2c.h> 27#include <mach/i2c.h>
25#include <asm/irq.h>
26#include <asm/uaccess.h>
27 28
28#define I2C_PNX_TIMEOUT 10 /* msec */ 29#define I2C_PNX_TIMEOUT 10 /* msec */
29#define I2C_PNX_SPEED_KHZ 100 30#define I2C_PNX_SPEED_KHZ 100
30#define I2C_PNX_REGION_SIZE 0x100 31#define I2C_PNX_REGION_SIZE 0x100
31#define PNX_DEFAULT_FREQ 13 /* MHz */
32 32
33static inline int wait_timeout(long timeout, struct i2c_pnx_algo_data *data) 33static inline int wait_timeout(long timeout, struct i2c_pnx_algo_data *data)
34{ 34{
@@ -50,22 +50,21 @@ static inline int wait_reset(long timeout, struct i2c_pnx_algo_data *data)
50 return (timeout <= 0); 50 return (timeout <= 0);
51} 51}
52 52
53static inline void i2c_pnx_arm_timer(struct i2c_adapter *adap) 53static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data)
54{ 54{
55 struct i2c_pnx_algo_data *data = adap->algo_data; 55 struct timer_list *timer = &alg_data->mif.timer;
56 struct timer_list *timer = &data->mif.timer; 56 unsigned long expires = msecs_to_jiffies(I2C_PNX_TIMEOUT);
57 int expires = I2C_PNX_TIMEOUT / (1000 / HZ);
58 57
59 if (expires <= 1) 58 if (expires <= 1)
60 expires = 2; 59 expires = 2;
61 60
62 del_timer_sync(timer); 61 del_timer_sync(timer);
63 62
64 dev_dbg(&adap->dev, "Timer armed at %lu plus %u jiffies.\n", 63 dev_dbg(&alg_data->adapter.dev, "Timer armed at %lu plus %lu jiffies.\n",
65 jiffies, expires); 64 jiffies, expires);
66 65
67 timer->expires = jiffies + expires; 66 timer->expires = jiffies + expires;
68 timer->data = (unsigned long)adap; 67 timer->data = (unsigned long)&alg_data;
69 68
70 add_timer(timer); 69 add_timer(timer);
71} 70}
@@ -77,34 +76,34 @@ static inline void i2c_pnx_arm_timer(struct i2c_adapter *adap)
77 * 76 *
78 * Generate a START signal in the desired mode. 77 * Generate a START signal in the desired mode.
79 */ 78 */
80static int i2c_pnx_start(unsigned char slave_addr, struct i2c_adapter *adap) 79static int i2c_pnx_start(unsigned char slave_addr,
80 struct i2c_pnx_algo_data *alg_data)
81{ 81{
82 struct i2c_pnx_algo_data *alg_data = adap->algo_data; 82 dev_dbg(&alg_data->adapter.dev, "%s(): addr 0x%x mode %d\n", __func__,
83
84 dev_dbg(&adap->dev, "%s(): addr 0x%x mode %d\n", __func__,
85 slave_addr, alg_data->mif.mode); 83 slave_addr, alg_data->mif.mode);
86 84
87 /* Check for 7 bit slave addresses only */ 85 /* Check for 7 bit slave addresses only */
88 if (slave_addr & ~0x7f) { 86 if (slave_addr & ~0x7f) {
89 dev_err(&adap->dev, "%s: Invalid slave address %x. " 87 dev_err(&alg_data->adapter.dev,
90 "Only 7-bit addresses are supported\n", 88 "%s: Invalid slave address %x. Only 7-bit addresses are supported\n",
91 adap->name, slave_addr); 89 alg_data->adapter.name, slave_addr);
92 return -EINVAL; 90 return -EINVAL;
93 } 91 }
94 92
95 /* First, make sure bus is idle */ 93 /* First, make sure bus is idle */
96 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) { 94 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) {
97 /* Somebody else is monopolizing the bus */ 95 /* Somebody else is monopolizing the bus */
98 dev_err(&adap->dev, "%s: Bus busy. Slave addr = %02x, " 96 dev_err(&alg_data->adapter.dev,
99 "cntrl = %x, stat = %x\n", 97 "%s: Bus busy. Slave addr = %02x, cntrl = %x, stat = %x\n",
100 adap->name, slave_addr, 98 alg_data->adapter.name, slave_addr,
101 ioread32(I2C_REG_CTL(alg_data)), 99 ioread32(I2C_REG_CTL(alg_data)),
102 ioread32(I2C_REG_STS(alg_data))); 100 ioread32(I2C_REG_STS(alg_data)));
103 return -EBUSY; 101 return -EBUSY;
104 } else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) { 102 } else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) {
105 /* Sorry, we lost the bus */ 103 /* Sorry, we lost the bus */
106 dev_err(&adap->dev, "%s: Arbitration failure. " 104 dev_err(&alg_data->adapter.dev,
107 "Slave addr = %02x\n", adap->name, slave_addr); 105 "%s: Arbitration failure. Slave addr = %02x\n",
106 alg_data->adapter.name, slave_addr);
108 return -EIO; 107 return -EIO;
109 } 108 }
110 109
@@ -115,14 +114,14 @@ static int i2c_pnx_start(unsigned char slave_addr, struct i2c_adapter *adap)
115 iowrite32(ioread32(I2C_REG_STS(alg_data)) | mstatus_tdi | mstatus_afi, 114 iowrite32(ioread32(I2C_REG_STS(alg_data)) | mstatus_tdi | mstatus_afi,
116 I2C_REG_STS(alg_data)); 115 I2C_REG_STS(alg_data));
117 116
118 dev_dbg(&adap->dev, "%s(): sending %#x\n", __func__, 117 dev_dbg(&alg_data->adapter.dev, "%s(): sending %#x\n", __func__,
119 (slave_addr << 1) | start_bit | alg_data->mif.mode); 118 (slave_addr << 1) | start_bit | alg_data->mif.mode);
120 119
121 /* Write the slave address, START bit and R/W bit */ 120 /* Write the slave address, START bit and R/W bit */
122 iowrite32((slave_addr << 1) | start_bit | alg_data->mif.mode, 121 iowrite32((slave_addr << 1) | start_bit | alg_data->mif.mode,
123 I2C_REG_TX(alg_data)); 122 I2C_REG_TX(alg_data));
124 123
125 dev_dbg(&adap->dev, "%s(): exit\n", __func__); 124 dev_dbg(&alg_data->adapter.dev, "%s(): exit\n", __func__);
126 125
127 return 0; 126 return 0;
128} 127}
@@ -133,13 +132,12 @@ static int i2c_pnx_start(unsigned char slave_addr, struct i2c_adapter *adap)
133 * 132 *
134 * Generate a STOP signal to terminate the master transaction. 133 * Generate a STOP signal to terminate the master transaction.
135 */ 134 */
136static void i2c_pnx_stop(struct i2c_adapter *adap) 135static void i2c_pnx_stop(struct i2c_pnx_algo_data *alg_data)
137{ 136{
138 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
139 /* Only 1 msec max timeout due to interrupt context */ 137 /* Only 1 msec max timeout due to interrupt context */
140 long timeout = 1000; 138 long timeout = 1000;
141 139
142 dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n", 140 dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n",
143 __func__, ioread32(I2C_REG_STS(alg_data))); 141 __func__, ioread32(I2C_REG_STS(alg_data)));
144 142
145 /* Write a STOP bit to TX FIFO */ 143 /* Write a STOP bit to TX FIFO */
@@ -153,7 +151,7 @@ static void i2c_pnx_stop(struct i2c_adapter *adap)
153 timeout--; 151 timeout--;
154 } 152 }
155 153
156 dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n", 154 dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n",
157 __func__, ioread32(I2C_REG_STS(alg_data))); 155 __func__, ioread32(I2C_REG_STS(alg_data)));
158} 156}
159 157
@@ -163,12 +161,11 @@ static void i2c_pnx_stop(struct i2c_adapter *adap)
163 * 161 *
164 * Sends one byte of data to the slave 162 * Sends one byte of data to the slave
165 */ 163 */
166static int i2c_pnx_master_xmit(struct i2c_adapter *adap) 164static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
167{ 165{
168 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
169 u32 val; 166 u32 val;
170 167
171 dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n", 168 dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n",
172 __func__, ioread32(I2C_REG_STS(alg_data))); 169 __func__, ioread32(I2C_REG_STS(alg_data)));
173 170
174 if (alg_data->mif.len > 0) { 171 if (alg_data->mif.len > 0) {
@@ -184,15 +181,15 @@ static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
184 alg_data->mif.len--; 181 alg_data->mif.len--;
185 iowrite32(val, I2C_REG_TX(alg_data)); 182 iowrite32(val, I2C_REG_TX(alg_data));
186 183
187 dev_dbg(&adap->dev, "%s(): xmit %#x [%d]\n", __func__, 184 dev_dbg(&alg_data->adapter.dev, "%s(): xmit %#x [%d]\n",
188 val, alg_data->mif.len + 1); 185 __func__, val, alg_data->mif.len + 1);
189 186
190 if (alg_data->mif.len == 0) { 187 if (alg_data->mif.len == 0) {
191 if (alg_data->last) { 188 if (alg_data->last) {
192 /* Wait until the STOP is seen. */ 189 /* Wait until the STOP is seen. */
193 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) 190 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
194 dev_err(&adap->dev, "The bus is still " 191 dev_err(&alg_data->adapter.dev,
195 "active after timeout\n"); 192 "The bus is still active after timeout\n");
196 } 193 }
197 /* Disable master interrupts */ 194 /* Disable master interrupts */
198 iowrite32(ioread32(I2C_REG_CTL(alg_data)) & 195 iowrite32(ioread32(I2C_REG_CTL(alg_data)) &
@@ -201,14 +198,15 @@ static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
201 198
202 del_timer_sync(&alg_data->mif.timer); 199 del_timer_sync(&alg_data->mif.timer);
203 200
204 dev_dbg(&adap->dev, "%s(): Waking up xfer routine.\n", 201 dev_dbg(&alg_data->adapter.dev,
202 "%s(): Waking up xfer routine.\n",
205 __func__); 203 __func__);
206 204
207 complete(&alg_data->mif.complete); 205 complete(&alg_data->mif.complete);
208 } 206 }
209 } else if (alg_data->mif.len == 0) { 207 } else if (alg_data->mif.len == 0) {
210 /* zero-sized transfer */ 208 /* zero-sized transfer */
211 i2c_pnx_stop(adap); 209 i2c_pnx_stop(alg_data);
212 210
213 /* Disable master interrupts. */ 211 /* Disable master interrupts. */
214 iowrite32(ioread32(I2C_REG_CTL(alg_data)) & 212 iowrite32(ioread32(I2C_REG_CTL(alg_data)) &
@@ -217,13 +215,14 @@ static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
217 215
218 /* Stop timer. */ 216 /* Stop timer. */
219 del_timer_sync(&alg_data->mif.timer); 217 del_timer_sync(&alg_data->mif.timer);
220 dev_dbg(&adap->dev, "%s(): Waking up xfer routine after " 218 dev_dbg(&alg_data->adapter.dev,
221 "zero-xfer.\n", __func__); 219 "%s(): Waking up xfer routine after zero-xfer.\n",
220 __func__);
222 221
223 complete(&alg_data->mif.complete); 222 complete(&alg_data->mif.complete);
224 } 223 }
225 224
226 dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n", 225 dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n",
227 __func__, ioread32(I2C_REG_STS(alg_data))); 226 __func__, ioread32(I2C_REG_STS(alg_data)));
228 227
229 return 0; 228 return 0;
@@ -235,21 +234,21 @@ static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
235 * 234 *
236 * Reads one byte data from the slave 235 * Reads one byte data from the slave
237 */ 236 */
238static int i2c_pnx_master_rcv(struct i2c_adapter *adap) 237static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data)
239{ 238{
240 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
241 unsigned int val = 0; 239 unsigned int val = 0;
242 u32 ctl = 0; 240 u32 ctl = 0;
243 241
244 dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n", 242 dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n",
245 __func__, ioread32(I2C_REG_STS(alg_data))); 243 __func__, ioread32(I2C_REG_STS(alg_data)));
246 244
247 /* Check, whether there is already data, 245 /* Check, whether there is already data,
248 * or we didn't 'ask' for it yet. 246 * or we didn't 'ask' for it yet.
249 */ 247 */
250 if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) { 248 if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) {
251 dev_dbg(&adap->dev, "%s(): Write dummy data to fill " 249 dev_dbg(&alg_data->adapter.dev,
252 "Rx-fifo...\n", __func__); 250 "%s(): Write dummy data to fill Rx-fifo...\n",
251 __func__);
253 252
254 if (alg_data->mif.len == 1) { 253 if (alg_data->mif.len == 1) {
255 /* Last byte, do not acknowledge next rcv. */ 254 /* Last byte, do not acknowledge next rcv. */
@@ -281,16 +280,16 @@ static int i2c_pnx_master_rcv(struct i2c_adapter *adap)
281 if (alg_data->mif.len > 0) { 280 if (alg_data->mif.len > 0) {
282 val = ioread32(I2C_REG_RX(alg_data)); 281 val = ioread32(I2C_REG_RX(alg_data));
283 *alg_data->mif.buf++ = (u8) (val & 0xff); 282 *alg_data->mif.buf++ = (u8) (val & 0xff);
284 dev_dbg(&adap->dev, "%s(): rcv 0x%x [%d]\n", __func__, val, 283 dev_dbg(&alg_data->adapter.dev, "%s(): rcv 0x%x [%d]\n",
285 alg_data->mif.len); 284 __func__, val, alg_data->mif.len);
286 285
287 alg_data->mif.len--; 286 alg_data->mif.len--;
288 if (alg_data->mif.len == 0) { 287 if (alg_data->mif.len == 0) {
289 if (alg_data->last) 288 if (alg_data->last)
290 /* Wait until the STOP is seen. */ 289 /* Wait until the STOP is seen. */
291 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) 290 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
292 dev_err(&adap->dev, "The bus is still " 291 dev_err(&alg_data->adapter.dev,
293 "active after timeout\n"); 292 "The bus is still active after timeout\n");
294 293
295 /* Disable master interrupts */ 294 /* Disable master interrupts */
296 ctl = ioread32(I2C_REG_CTL(alg_data)); 295 ctl = ioread32(I2C_REG_CTL(alg_data));
@@ -304,7 +303,7 @@ static int i2c_pnx_master_rcv(struct i2c_adapter *adap)
304 } 303 }
305 } 304 }
306 305
307 dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n", 306 dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n",
308 __func__, ioread32(I2C_REG_STS(alg_data))); 307 __func__, ioread32(I2C_REG_STS(alg_data)));
309 308
310 return 0; 309 return 0;
@@ -312,11 +311,11 @@ static int i2c_pnx_master_rcv(struct i2c_adapter *adap)
312 311
313static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id) 312static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
314{ 313{
314 struct i2c_pnx_algo_data *alg_data = dev_id;
315 u32 stat, ctl; 315 u32 stat, ctl;
316 struct i2c_adapter *adap = dev_id;
317 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
318 316
319 dev_dbg(&adap->dev, "%s(): mstat = %x mctrl = %x, mode = %d\n", 317 dev_dbg(&alg_data->adapter.dev,
318 "%s(): mstat = %x mctrl = %x, mode = %d\n",
320 __func__, 319 __func__,
321 ioread32(I2C_REG_STS(alg_data)), 320 ioread32(I2C_REG_STS(alg_data)),
322 ioread32(I2C_REG_CTL(alg_data)), 321 ioread32(I2C_REG_CTL(alg_data)),
@@ -339,10 +338,10 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
339 complete(&alg_data->mif.complete); 338 complete(&alg_data->mif.complete);
340 } else if (stat & mstatus_nai) { 339 } else if (stat & mstatus_nai) {
341 /* Slave did not acknowledge, generate a STOP */ 340 /* Slave did not acknowledge, generate a STOP */
342 dev_dbg(&adap->dev, "%s(): " 341 dev_dbg(&alg_data->adapter.dev,
343 "Slave did not acknowledge, generating a STOP.\n", 342 "%s(): Slave did not acknowledge, generating a STOP.\n",
344 __func__); 343 __func__);
345 i2c_pnx_stop(adap); 344 i2c_pnx_stop(alg_data);
346 345
347 /* Disable master interrupts. */ 346 /* Disable master interrupts. */
348 ctl = ioread32(I2C_REG_CTL(alg_data)); 347 ctl = ioread32(I2C_REG_CTL(alg_data));
@@ -368,9 +367,9 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
368 */ 367 */
369 if ((stat & mstatus_drmi) || !(stat & mstatus_rfe)) { 368 if ((stat & mstatus_drmi) || !(stat & mstatus_rfe)) {
370 if (alg_data->mif.mode == I2C_SMBUS_WRITE) { 369 if (alg_data->mif.mode == I2C_SMBUS_WRITE) {
371 i2c_pnx_master_xmit(adap); 370 i2c_pnx_master_xmit(alg_data);
372 } else if (alg_data->mif.mode == I2C_SMBUS_READ) { 371 } else if (alg_data->mif.mode == I2C_SMBUS_READ) {
373 i2c_pnx_master_rcv(adap); 372 i2c_pnx_master_rcv(alg_data);
374 } 373 }
375 } 374 }
376 } 375 }
@@ -379,7 +378,8 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
379 stat = ioread32(I2C_REG_STS(alg_data)); 378 stat = ioread32(I2C_REG_STS(alg_data));
380 iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data)); 379 iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data));
381 380
382 dev_dbg(&adap->dev, "%s(): exiting, stat = %x ctrl = %x.\n", 381 dev_dbg(&alg_data->adapter.dev,
382 "%s(): exiting, stat = %x ctrl = %x.\n",
383 __func__, ioread32(I2C_REG_STS(alg_data)), 383 __func__, ioread32(I2C_REG_STS(alg_data)),
384 ioread32(I2C_REG_CTL(alg_data))); 384 ioread32(I2C_REG_CTL(alg_data)));
385 385
@@ -388,14 +388,13 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
388 388
389static void i2c_pnx_timeout(unsigned long data) 389static void i2c_pnx_timeout(unsigned long data)
390{ 390{
391 struct i2c_adapter *adap = (struct i2c_adapter *)data; 391 struct i2c_pnx_algo_data *alg_data = (struct i2c_pnx_algo_data *)data;
392 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
393 u32 ctl; 392 u32 ctl;
394 393
395 dev_err(&adap->dev, "Master timed out. stat = %04x, cntrl = %04x. " 394 dev_err(&alg_data->adapter.dev,
396 "Resetting master...\n", 395 "Master timed out. stat = %04x, cntrl = %04x. Resetting master...\n",
397 ioread32(I2C_REG_STS(alg_data)), 396 ioread32(I2C_REG_STS(alg_data)),
398 ioread32(I2C_REG_CTL(alg_data))); 397 ioread32(I2C_REG_CTL(alg_data)));
399 398
400 /* Reset master and disable interrupts */ 399 /* Reset master and disable interrupts */
401 ctl = ioread32(I2C_REG_CTL(alg_data)); 400 ctl = ioread32(I2C_REG_CTL(alg_data));
@@ -409,15 +408,14 @@ static void i2c_pnx_timeout(unsigned long data)
409 complete(&alg_data->mif.complete); 408 complete(&alg_data->mif.complete);
410} 409}
411 410
412static inline void bus_reset_if_active(struct i2c_adapter *adap) 411static inline void bus_reset_if_active(struct i2c_pnx_algo_data *alg_data)
413{ 412{
414 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
415 u32 stat; 413 u32 stat;
416 414
417 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) { 415 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) {
418 dev_err(&adap->dev, 416 dev_err(&alg_data->adapter.dev,
419 "%s: Bus is still active after xfer. Reset it...\n", 417 "%s: Bus is still active after xfer. Reset it...\n",
420 adap->name); 418 alg_data->adapter.name);
421 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset, 419 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
422 I2C_REG_CTL(alg_data)); 420 I2C_REG_CTL(alg_data));
423 wait_reset(I2C_PNX_TIMEOUT, alg_data); 421 wait_reset(I2C_PNX_TIMEOUT, alg_data);
@@ -451,10 +449,11 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
451 struct i2c_pnx_algo_data *alg_data = adap->algo_data; 449 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
452 u32 stat = ioread32(I2C_REG_STS(alg_data)); 450 u32 stat = ioread32(I2C_REG_STS(alg_data));
453 451
454 dev_dbg(&adap->dev, "%s(): entering: %d messages, stat = %04x.\n", 452 dev_dbg(&alg_data->adapter.dev,
453 "%s(): entering: %d messages, stat = %04x.\n",
455 __func__, num, ioread32(I2C_REG_STS(alg_data))); 454 __func__, num, ioread32(I2C_REG_STS(alg_data)));
456 455
457 bus_reset_if_active(adap); 456 bus_reset_if_active(alg_data);
458 457
459 /* Process transactions in a loop. */ 458 /* Process transactions in a loop. */
460 for (i = 0; rc >= 0 && i < num; i++) { 459 for (i = 0; rc >= 0 && i < num; i++) {
@@ -464,9 +463,9 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
464 addr = pmsg->addr; 463 addr = pmsg->addr;
465 464
466 if (pmsg->flags & I2C_M_TEN) { 465 if (pmsg->flags & I2C_M_TEN) {
467 dev_err(&adap->dev, 466 dev_err(&alg_data->adapter.dev,
468 "%s: 10 bits addr not supported!\n", 467 "%s: 10 bits addr not supported!\n",
469 adap->name); 468 alg_data->adapter.name);
470 rc = -EINVAL; 469 rc = -EINVAL;
471 break; 470 break;
472 } 471 }
@@ -478,11 +477,10 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
478 alg_data->mif.ret = 0; 477 alg_data->mif.ret = 0;
479 alg_data->last = (i == num - 1); 478 alg_data->last = (i == num - 1);
480 479
481 dev_dbg(&adap->dev, "%s(): mode %d, %d bytes\n", __func__, 480 dev_dbg(&alg_data->adapter.dev, "%s(): mode %d, %d bytes\n",
482 alg_data->mif.mode, 481 __func__, alg_data->mif.mode, alg_data->mif.len);
483 alg_data->mif.len);
484 482
485 i2c_pnx_arm_timer(adap); 483 i2c_pnx_arm_timer(alg_data);
486 484
487 /* initialize the completion var */ 485 /* initialize the completion var */
488 init_completion(&alg_data->mif.complete); 486 init_completion(&alg_data->mif.complete);
@@ -493,7 +491,7 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
493 I2C_REG_CTL(alg_data)); 491 I2C_REG_CTL(alg_data));
494 492
495 /* Put start-code and slave-address on the bus. */ 493 /* Put start-code and slave-address on the bus. */
496 rc = i2c_pnx_start(addr, adap); 494 rc = i2c_pnx_start(addr, alg_data);
497 if (rc < 0) 495 if (rc < 0)
498 break; 496 break;
499 497
@@ -502,31 +500,32 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
502 500
503 if (!(rc = alg_data->mif.ret)) 501 if (!(rc = alg_data->mif.ret))
504 completed++; 502 completed++;
505 dev_dbg(&adap->dev, "%s(): Complete, return code = %d.\n", 503 dev_dbg(&alg_data->adapter.dev,
504 "%s(): Complete, return code = %d.\n",
506 __func__, rc); 505 __func__, rc);
507 506
508 /* Clear TDI and AFI bits in case they are set. */ 507 /* Clear TDI and AFI bits in case they are set. */
509 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_tdi) { 508 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_tdi) {
510 dev_dbg(&adap->dev, 509 dev_dbg(&alg_data->adapter.dev,
511 "%s: TDI still set... clearing now.\n", 510 "%s: TDI still set... clearing now.\n",
512 adap->name); 511 alg_data->adapter.name);
513 iowrite32(stat, I2C_REG_STS(alg_data)); 512 iowrite32(stat, I2C_REG_STS(alg_data));
514 } 513 }
515 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_afi) { 514 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_afi) {
516 dev_dbg(&adap->dev, 515 dev_dbg(&alg_data->adapter.dev,
517 "%s: AFI still set... clearing now.\n", 516 "%s: AFI still set... clearing now.\n",
518 adap->name); 517 alg_data->adapter.name);
519 iowrite32(stat, I2C_REG_STS(alg_data)); 518 iowrite32(stat, I2C_REG_STS(alg_data));
520 } 519 }
521 } 520 }
522 521
523 bus_reset_if_active(adap); 522 bus_reset_if_active(alg_data);
524 523
525 /* Cleanup to be sure... */ 524 /* Cleanup to be sure... */
526 alg_data->mif.buf = NULL; 525 alg_data->mif.buf = NULL;
527 alg_data->mif.len = 0; 526 alg_data->mif.len = 0;
528 527
529 dev_dbg(&adap->dev, "%s(): exiting, stat = %x\n", 528 dev_dbg(&alg_data->adapter.dev, "%s(): exiting, stat = %x\n",
530 __func__, ioread32(I2C_REG_STS(alg_data))); 529 __func__, ioread32(I2C_REG_STS(alg_data)));
531 530
532 if (completed != num) 531 if (completed != num)
@@ -545,69 +544,92 @@ static struct i2c_algorithm pnx_algorithm = {
545 .functionality = i2c_pnx_func, 544 .functionality = i2c_pnx_func,
546}; 545};
547 546
547#ifdef CONFIG_PM
548static int i2c_pnx_controller_suspend(struct platform_device *pdev, 548static int i2c_pnx_controller_suspend(struct platform_device *pdev,
549 pm_message_t state) 549 pm_message_t state)
550{ 550{
551 struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); 551 struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
552 return i2c_pnx->suspend(pdev, state); 552
553 /* FIXME: shouldn't this be clk_disable? */
554 clk_enable(alg_data->clk);
555
556 return 0;
553} 557}
554 558
555static int i2c_pnx_controller_resume(struct platform_device *pdev) 559static int i2c_pnx_controller_resume(struct platform_device *pdev)
556{ 560{
557 struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); 561 struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
558 return i2c_pnx->resume(pdev); 562
563 return clk_enable(alg_data->clk);
559} 564}
565#else
566#define i2c_pnx_controller_suspend NULL
567#define i2c_pnx_controller_resume NULL
568#endif
560 569
561static int __devinit i2c_pnx_probe(struct platform_device *pdev) 570static int __devinit i2c_pnx_probe(struct platform_device *pdev)
562{ 571{
563 unsigned long tmp; 572 unsigned long tmp;
564 int ret = 0; 573 int ret = 0;
565 struct i2c_pnx_algo_data *alg_data; 574 struct i2c_pnx_algo_data *alg_data;
566 int freq_mhz; 575 unsigned long freq;
567 struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data; 576 struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data;
568 577
569 if (!i2c_pnx || !i2c_pnx->adapter) { 578 if (!i2c_pnx || !i2c_pnx->name) {
570 dev_err(&pdev->dev, "%s: no platform data supplied\n", 579 dev_err(&pdev->dev, "%s: no platform data supplied\n",
571 __func__); 580 __func__);
572 ret = -EINVAL; 581 ret = -EINVAL;
573 goto out; 582 goto out;
574 } 583 }
575 584
576 platform_set_drvdata(pdev, i2c_pnx); 585 alg_data = kzalloc(sizeof(*alg_data), GFP_KERNEL);
577 586 if (!alg_data) {
578 if (i2c_pnx->calculate_input_freq) 587 ret = -ENOMEM;
579 freq_mhz = i2c_pnx->calculate_input_freq(pdev); 588 goto err_kzalloc;
580 else {
581 freq_mhz = PNX_DEFAULT_FREQ;
582 dev_info(&pdev->dev, "Setting bus frequency to default value: "
583 "%d MHz\n", freq_mhz);
584 } 589 }
585 590
586 i2c_pnx->adapter->algo = &pnx_algorithm; 591 platform_set_drvdata(pdev, alg_data);
592
593 strlcpy(alg_data->adapter.name, i2c_pnx->name,
594 sizeof(alg_data->adapter.name));
595 alg_data->adapter.dev.parent = &pdev->dev;
596 alg_data->adapter.algo = &pnx_algorithm;
597 alg_data->adapter.algo_data = alg_data;
598 alg_data->adapter.nr = pdev->id;
599 alg_data->i2c_pnx = i2c_pnx;
600
601 alg_data->clk = clk_get(&pdev->dev, NULL);
602 if (IS_ERR(alg_data->clk)) {
603 ret = PTR_ERR(alg_data->clk);
604 goto out_drvdata;
605 }
587 606
588 alg_data = i2c_pnx->adapter->algo_data;
589 init_timer(&alg_data->mif.timer); 607 init_timer(&alg_data->mif.timer);
590 alg_data->mif.timer.function = i2c_pnx_timeout; 608 alg_data->mif.timer.function = i2c_pnx_timeout;
591 alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; 609 alg_data->mif.timer.data = (unsigned long)alg_data;
592 610
593 /* Register I/O resource */ 611 /* Register I/O resource */
594 if (!request_mem_region(alg_data->base, I2C_PNX_REGION_SIZE, 612 if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE,
595 pdev->name)) { 613 pdev->name)) {
596 dev_err(&pdev->dev, 614 dev_err(&pdev->dev,
597 "I/O region 0x%08x for I2C already in use.\n", 615 "I/O region 0x%08x for I2C already in use.\n",
598 alg_data->base); 616 i2c_pnx->base);
599 ret = -ENODEV; 617 ret = -ENODEV;
600 goto out_drvdata; 618 goto out_clkget;
601 } 619 }
602 620
603 if (!(alg_data->ioaddr = 621 alg_data->ioaddr = ioremap(i2c_pnx->base, I2C_PNX_REGION_SIZE);
604 (u32)ioremap(alg_data->base, I2C_PNX_REGION_SIZE))) { 622 if (!alg_data->ioaddr) {
605 dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n"); 623 dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n");
606 ret = -ENOMEM; 624 ret = -ENOMEM;
607 goto out_release; 625 goto out_release;
608 } 626 }
609 627
610 i2c_pnx->set_clock_run(pdev); 628 ret = clk_enable(alg_data->clk);
629 if (ret)
630 goto out_unmap;
631
632 freq = clk_get_rate(alg_data->clk);
611 633
612 /* 634 /*
613 * Clock Divisor High This value is the number of system clocks 635 * Clock Divisor High This value is the number of system clocks
@@ -620,45 +642,47 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
620 * the deglitching filter length. 642 * the deglitching filter length.
621 */ 643 */
622 644
623 tmp = ((freq_mhz * 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2; 645 tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2;
624 iowrite32(tmp, I2C_REG_CKH(alg_data)); 646 iowrite32(tmp, I2C_REG_CKH(alg_data));
625 iowrite32(tmp, I2C_REG_CKL(alg_data)); 647 iowrite32(tmp, I2C_REG_CKL(alg_data));
626 648
627 iowrite32(mcntrl_reset, I2C_REG_CTL(alg_data)); 649 iowrite32(mcntrl_reset, I2C_REG_CTL(alg_data));
628 if (wait_reset(I2C_PNX_TIMEOUT, alg_data)) { 650 if (wait_reset(I2C_PNX_TIMEOUT, alg_data)) {
629 ret = -ENODEV; 651 ret = -ENODEV;
630 goto out_unmap; 652 goto out_clock;
631 } 653 }
632 init_completion(&alg_data->mif.complete); 654 init_completion(&alg_data->mif.complete);
633 655
634 ret = request_irq(alg_data->irq, i2c_pnx_interrupt, 656 ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt,
635 0, pdev->name, i2c_pnx->adapter); 657 0, pdev->name, alg_data);
636 if (ret) 658 if (ret)
637 goto out_clock; 659 goto out_clock;
638 660
639 /* Register this adapter with the I2C subsystem */ 661 /* Register this adapter with the I2C subsystem */
640 i2c_pnx->adapter->dev.parent = &pdev->dev; 662 ret = i2c_add_numbered_adapter(&alg_data->adapter);
641 i2c_pnx->adapter->nr = pdev->id;
642 ret = i2c_add_numbered_adapter(i2c_pnx->adapter);
643 if (ret < 0) { 663 if (ret < 0) {
644 dev_err(&pdev->dev, "I2C: Failed to add bus\n"); 664 dev_err(&pdev->dev, "I2C: Failed to add bus\n");
645 goto out_irq; 665 goto out_irq;
646 } 666 }
647 667
648 dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", 668 dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n",
649 i2c_pnx->adapter->name, alg_data->base, alg_data->irq); 669 alg_data->adapter.name, i2c_pnx->base, i2c_pnx->irq);
650 670
651 return 0; 671 return 0;
652 672
653out_irq: 673out_irq:
654 free_irq(alg_data->irq, i2c_pnx->adapter); 674 free_irq(i2c_pnx->irq, alg_data);
655out_clock: 675out_clock:
656 i2c_pnx->set_clock_stop(pdev); 676 clk_disable(alg_data->clk);
657out_unmap: 677out_unmap:
658 iounmap((void *)alg_data->ioaddr); 678 iounmap(alg_data->ioaddr);
659out_release: 679out_release:
660 release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); 680 release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);
681out_clkget:
682 clk_put(alg_data->clk);
661out_drvdata: 683out_drvdata:
684 kfree(alg_data);
685err_kzalloc:
662 platform_set_drvdata(pdev, NULL); 686 platform_set_drvdata(pdev, NULL);
663out: 687out:
664 return ret; 688 return ret;
@@ -666,15 +690,16 @@ out:
666 690
667static int __devexit i2c_pnx_remove(struct platform_device *pdev) 691static int __devexit i2c_pnx_remove(struct platform_device *pdev)
668{ 692{
669 struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); 693 struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
670 struct i2c_adapter *adap = i2c_pnx->adapter; 694 struct i2c_pnx_data *i2c_pnx = alg_data->i2c_pnx;
671 struct i2c_pnx_algo_data *alg_data = adap->algo_data; 695
672 696 free_irq(i2c_pnx->irq, alg_data);
673 free_irq(alg_data->irq, i2c_pnx->adapter); 697 i2c_del_adapter(&alg_data->adapter);
674 i2c_del_adapter(adap); 698 clk_disable(alg_data->clk);
675 i2c_pnx->set_clock_stop(pdev); 699 iounmap(alg_data->ioaddr);
676 iounmap((void *)alg_data->ioaddr); 700 release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);
677 release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); 701 clk_put(alg_data->clk);
702 kfree(alg_data);
678 platform_set_drvdata(pdev, NULL); 703 platform_set_drvdata(pdev, NULL);
679 704
680 return 0; 705 return 0;
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index c0cf45a11b93..5cb01e5c323c 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -108,11 +108,11 @@ bool ide_port_acpi(ide_hwif_t *hwif)
108 * Returns 0 on success, <0 on error. 108 * Returns 0 on success, <0 on error.
109 */ 109 */
110static int ide_get_dev_handle(struct device *dev, acpi_handle *handle, 110static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
111 acpi_integer *pcidevfn) 111 u64 *pcidevfn)
112{ 112{
113 struct pci_dev *pdev = to_pci_dev(dev); 113 struct pci_dev *pdev = to_pci_dev(dev);
114 unsigned int bus, devnum, func; 114 unsigned int bus, devnum, func;
115 acpi_integer addr; 115 u64 addr;
116 acpi_handle dev_handle; 116 acpi_handle dev_handle;
117 acpi_status status; 117 acpi_status status;
118 struct acpi_device_info *dinfo = NULL; 118 struct acpi_device_info *dinfo = NULL;
@@ -122,7 +122,7 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
122 devnum = PCI_SLOT(pdev->devfn); 122 devnum = PCI_SLOT(pdev->devfn);
123 func = PCI_FUNC(pdev->devfn); 123 func = PCI_FUNC(pdev->devfn);
124 /* ACPI _ADR encoding for PCI bus: */ 124 /* ACPI _ADR encoding for PCI bus: */
125 addr = (acpi_integer)(devnum << 16 | func); 125 addr = (u64)(devnum << 16 | func);
126 126
127 DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func); 127 DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func);
128 128
@@ -169,7 +169,7 @@ static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif)
169{ 169{
170 struct device *dev = hwif->gendev.parent; 170 struct device *dev = hwif->gendev.parent;
171 acpi_handle uninitialized_var(dev_handle); 171 acpi_handle uninitialized_var(dev_handle);
172 acpi_integer pcidevfn; 172 u64 pcidevfn;
173 acpi_handle chan_handle; 173 acpi_handle chan_handle;
174 int err; 174 int err;
175 175
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 7f878017b736..3b128dce9c3a 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -679,7 +679,7 @@ static void ide_disk_setup(ide_drive_t *drive)
679 if (max_s > hwif->rqsize) 679 if (max_s > hwif->rqsize)
680 max_s = hwif->rqsize; 680 max_s = hwif->rqsize;
681 681
682 blk_queue_max_sectors(q, max_s); 682 blk_queue_max_hw_sectors(q, max_s);
683 } 683 }
684 684
685 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, 685 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name,
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index fefbdfc8db06..efd907623469 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -486,7 +486,7 @@ static void ide_floppy_setup(ide_drive_t *drive)
486 drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE; 486 drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE;
487 /* This value will be visible in the /proc/ide/hdx/settings */ 487 /* This value will be visible in the /proc/ide/hdx/settings */
488 drive->pc_delay = IDEFLOPPY_PC_DELAY; 488 drive->pc_delay = IDEFLOPPY_PC_DELAY;
489 blk_queue_max_sectors(drive->queue, 64); 489 blk_queue_max_hw_sectors(drive->queue, 64);
490 } 490 }
491 491
492 /* 492 /*
@@ -494,7 +494,7 @@ static void ide_floppy_setup(ide_drive_t *drive)
494 * nasty clicking noises without it, so please don't remove this. 494 * nasty clicking noises without it, so please don't remove this.
495 */ 495 */
496 if (strncmp((char *)&id[ATA_ID_PROD], "IOMEGA Clik!", 11) == 0) { 496 if (strncmp((char *)&id[ATA_ID_PROD], "IOMEGA Clik!", 11) == 0) {
497 blk_queue_max_sectors(drive->queue, 64); 497 blk_queue_max_hw_sectors(drive->queue, 64);
498 drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; 498 drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE;
499 /* IOMEGA Clik! drives do not support lock/unlock commands */ 499 /* IOMEGA Clik! drives do not support lock/unlock commands */
500 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; 500 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 4d76ba473097..f8c1ae6ad74c 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -774,7 +774,7 @@ static int ide_init_queue(ide_drive_t *drive)
774 774
775 if (hwif->rqsize < max_sectors) 775 if (hwif->rqsize < max_sectors)
776 max_sectors = hwif->rqsize; 776 max_sectors = hwif->rqsize;
777 blk_queue_max_sectors(q, max_sectors); 777 blk_queue_max_hw_sectors(q, max_sectors);
778 778
779#ifdef CONFIG_PCI 779#ifdef CONFIG_PCI
780 /* When we have an IOMMU, we may have a problem where pci_map_sg() 780 /* When we have an IOMMU, we may have a problem where pci_map_sg()
@@ -790,8 +790,7 @@ static int ide_init_queue(ide_drive_t *drive)
790 max_sg_entries >>= 1; 790 max_sg_entries >>= 1;
791#endif /* CONFIG_PCI */ 791#endif /* CONFIG_PCI */
792 792
793 blk_queue_max_hw_segments(q, max_sg_entries); 793 blk_queue_max_segments(q, max_sg_entries);
794 blk_queue_max_phys_segments(q, max_sg_entries);
795 794
796 /* assign drive queue */ 795 /* assign drive queue */
797 drive->queue = q; 796 drive->queue = q;
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index f199896c4113..c88696a6cf8a 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -2020,7 +2020,7 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
2020 if (lu->workarounds & SBP2_WORKAROUND_POWER_CONDITION) 2020 if (lu->workarounds & SBP2_WORKAROUND_POWER_CONDITION)
2021 sdev->start_stop_pwr_cond = 1; 2021 sdev->start_stop_pwr_cond = 1;
2022 if (lu->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) 2022 if (lu->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
2023 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512); 2023 blk_queue_max_hw_sectors(sdev->request_queue, 128 * 1024 / 512);
2024 2024
2025 blk_queue_max_segment_size(sdev->request_queue, SBP2_MAX_SEG_SIZE); 2025 blk_queue_max_segment_size(sdev->request_queue, SBP2_MAX_SEG_SIZE);
2026 return 0; 2026 return 0;
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 258c639571b5..9f9816baeb97 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -278,6 +278,8 @@ static int evdev_open(struct inode *inode, struct file *file)
278 goto err_free_client; 278 goto err_free_client;
279 279
280 file->private_data = client; 280 file->private_data = client;
281 nonseekable_open(inode, file);
282
281 return 0; 283 return 0;
282 284
283 err_free_client: 285 err_free_client:
diff --git a/drivers/input/gameport/emu10k1-gp.c b/drivers/input/gameport/emu10k1-gp.c
index b04930f7ea7d..7392992da424 100644
--- a/drivers/input/gameport/emu10k1-gp.c
+++ b/drivers/input/gameport/emu10k1-gp.c
@@ -46,7 +46,7 @@ struct emu {
46 int size; 46 int size;
47}; 47};
48 48
49static struct pci_device_id emu_tbl[] = { 49static const struct pci_device_id emu_tbl[] = {
50 50
51 { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */ 51 { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */
52 { 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */ 52 { 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */
diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
index 8a1810f88b9e..14d3f3e208a2 100644
--- a/drivers/input/gameport/fm801-gp.c
+++ b/drivers/input/gameport/fm801-gp.c
@@ -140,7 +140,7 @@ static void __devexit fm801_gp_remove(struct pci_dev *pci)
140 } 140 }
141} 141}
142 142
143static struct pci_device_id fm801_gp_id_table[] = { 143static const struct pci_device_id fm801_gp_id_table[] = {
144 { PCI_VENDOR_ID_FORTEMEDIA, PCI_DEVICE_ID_FM801_GP, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 144 { PCI_VENDOR_ID_FORTEMEDIA, PCI_DEVICE_ID_FM801_GP, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
145 { 0 } 145 { 0 }
146}; 146};
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index ac11be08585e..7e18bcf05a66 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -11,6 +11,8 @@
11 * the Free Software Foundation. 11 * the Free Software Foundation.
12 */ 12 */
13 13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
14#include <linux/stddef.h> 16#include <linux/stddef.h>
15#include <linux/module.h> 17#include <linux/module.h>
16#include <linux/ioport.h> 18#include <linux/ioport.h>
@@ -190,9 +192,8 @@ static int gameport_bind_driver(struct gameport *gameport, struct gameport_drive
190 192
191 error = device_bind_driver(&gameport->dev); 193 error = device_bind_driver(&gameport->dev);
192 if (error) { 194 if (error) {
193 printk(KERN_WARNING 195 dev_warn(&gameport->dev,
194 "gameport: device_bind_driver() failed " 196 "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
195 "for %s (%s) and %s, error: %d\n",
196 gameport->phys, gameport->name, 197 gameport->phys, gameport->name,
197 drv->description, error); 198 drv->description, error);
198 drv->disconnect(gameport); 199 drv->disconnect(gameport);
@@ -209,9 +210,9 @@ static void gameport_find_driver(struct gameport *gameport)
209 210
210 error = device_attach(&gameport->dev); 211 error = device_attach(&gameport->dev);
211 if (error < 0) 212 if (error < 0)
212 printk(KERN_WARNING 213 dev_warn(&gameport->dev,
213 "gameport: device_attach() failed for %s (%s), error: %d\n", 214 "device_attach() failed for %s (%s), error: %d\n",
214 gameport->phys, gameport->name, error); 215 gameport->phys, gameport->name, error);
215} 216}
216 217
217 218
@@ -262,17 +263,14 @@ static int gameport_queue_event(void *object, struct module *owner,
262 263
263 event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC); 264 event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC);
264 if (!event) { 265 if (!event) {
265 printk(KERN_ERR 266 pr_err("Not enough memory to queue event %d\n", event_type);
266 "gameport: Not enough memory to queue event %d\n",
267 event_type);
268 retval = -ENOMEM; 267 retval = -ENOMEM;
269 goto out; 268 goto out;
270 } 269 }
271 270
272 if (!try_module_get(owner)) { 271 if (!try_module_get(owner)) {
273 printk(KERN_WARNING 272 pr_warning("Can't get module reference, dropping event %d\n",
274 "gameport: Can't get module reference, dropping event %d\n", 273 event_type);
275 event_type);
276 kfree(event); 274 kfree(event);
277 retval = -EINVAL; 275 retval = -EINVAL;
278 goto out; 276 goto out;
@@ -298,14 +296,12 @@ static void gameport_free_event(struct gameport_event *event)
298 296
299static void gameport_remove_duplicate_events(struct gameport_event *event) 297static void gameport_remove_duplicate_events(struct gameport_event *event)
300{ 298{
301 struct list_head *node, *next; 299 struct gameport_event *e, *next;
302 struct gameport_event *e;
303 unsigned long flags; 300 unsigned long flags;
304 301
305 spin_lock_irqsave(&gameport_event_lock, flags); 302 spin_lock_irqsave(&gameport_event_lock, flags);
306 303
307 list_for_each_safe(node, next, &gameport_event_list) { 304 list_for_each_entry_safe(e, next, &gameport_event_list, node) {
308 e = list_entry(node, struct gameport_event, node);
309 if (event->object == e->object) { 305 if (event->object == e->object) {
310 /* 306 /*
311 * If this event is of different type we should not 307 * If this event is of different type we should not
@@ -315,7 +311,7 @@ static void gameport_remove_duplicate_events(struct gameport_event *event)
315 if (event->type != e->type) 311 if (event->type != e->type)
316 break; 312 break;
317 313
318 list_del_init(node); 314 list_del_init(&e->node);
319 gameport_free_event(e); 315 gameport_free_event(e);
320 } 316 }
321 } 317 }
@@ -325,23 +321,18 @@ static void gameport_remove_duplicate_events(struct gameport_event *event)
325 321
326static struct gameport_event *gameport_get_event(void) 322static struct gameport_event *gameport_get_event(void)
327{ 323{
328 struct gameport_event *event; 324 struct gameport_event *event = NULL;
329 struct list_head *node;
330 unsigned long flags; 325 unsigned long flags;
331 326
332 spin_lock_irqsave(&gameport_event_lock, flags); 327 spin_lock_irqsave(&gameport_event_lock, flags);
333 328
334 if (list_empty(&gameport_event_list)) { 329 if (!list_empty(&gameport_event_list)) {
335 spin_unlock_irqrestore(&gameport_event_lock, flags); 330 event = list_first_entry(&gameport_event_list,
336 return NULL; 331 struct gameport_event, node);
332 list_del_init(&event->node);
337 } 333 }
338 334
339 node = gameport_event_list.next;
340 event = list_entry(node, struct gameport_event, node);
341 list_del_init(node);
342
343 spin_unlock_irqrestore(&gameport_event_lock, flags); 335 spin_unlock_irqrestore(&gameport_event_lock, flags);
344
345 return event; 336 return event;
346} 337}
347 338
@@ -360,16 +351,14 @@ static void gameport_handle_event(void)
360 if ((event = gameport_get_event())) { 351 if ((event = gameport_get_event())) {
361 352
362 switch (event->type) { 353 switch (event->type) {
363 case GAMEPORT_REGISTER_PORT:
364 gameport_add_port(event->object);
365 break;
366 354
367 case GAMEPORT_ATTACH_DRIVER: 355 case GAMEPORT_REGISTER_PORT:
368 gameport_attach_driver(event->object); 356 gameport_add_port(event->object);
369 break; 357 break;
370 358
371 default: 359 case GAMEPORT_ATTACH_DRIVER:
372 break; 360 gameport_attach_driver(event->object);
361 break;
373 } 362 }
374 363
375 gameport_remove_duplicate_events(event); 364 gameport_remove_duplicate_events(event);
@@ -385,16 +374,14 @@ static void gameport_handle_event(void)
385 */ 374 */
386static void gameport_remove_pending_events(void *object) 375static void gameport_remove_pending_events(void *object)
387{ 376{
388 struct list_head *node, *next; 377 struct gameport_event *event, *next;
389 struct gameport_event *event;
390 unsigned long flags; 378 unsigned long flags;
391 379
392 spin_lock_irqsave(&gameport_event_lock, flags); 380 spin_lock_irqsave(&gameport_event_lock, flags);
393 381
394 list_for_each_safe(node, next, &gameport_event_list) { 382 list_for_each_entry_safe(event, next, &gameport_event_list, node) {
395 event = list_entry(node, struct gameport_event, node);
396 if (event->object == object) { 383 if (event->object == object) {
397 list_del_init(node); 384 list_del_init(&event->node);
398 gameport_free_event(event); 385 gameport_free_event(event);
399 } 386 }
400 } 387 }
@@ -441,7 +428,6 @@ static int gameport_thread(void *nothing)
441 kthread_should_stop() || !list_empty(&gameport_event_list)); 428 kthread_should_stop() || !list_empty(&gameport_event_list));
442 } while (!kthread_should_stop()); 429 } while (!kthread_should_stop());
443 430
444 printk(KERN_DEBUG "gameport: kgameportd exiting\n");
445 return 0; 431 return 0;
446} 432}
447 433
@@ -453,6 +439,7 @@ static int gameport_thread(void *nothing)
453static ssize_t gameport_show_description(struct device *dev, struct device_attribute *attr, char *buf) 439static ssize_t gameport_show_description(struct device *dev, struct device_attribute *attr, char *buf)
454{ 440{
455 struct gameport *gameport = to_gameport_port(dev); 441 struct gameport *gameport = to_gameport_port(dev);
442
456 return sprintf(buf, "%s\n", gameport->name); 443 return sprintf(buf, "%s\n", gameport->name);
457} 444}
458 445
@@ -521,7 +508,8 @@ static void gameport_init_port(struct gameport *gameport)
521 508
522 mutex_init(&gameport->drv_mutex); 509 mutex_init(&gameport->drv_mutex);
523 device_initialize(&gameport->dev); 510 device_initialize(&gameport->dev);
524 dev_set_name(&gameport->dev, "gameport%lu", (unsigned long)atomic_inc_return(&gameport_no) - 1); 511 dev_set_name(&gameport->dev, "gameport%lu",
512 (unsigned long)atomic_inc_return(&gameport_no) - 1);
525 gameport->dev.bus = &gameport_bus; 513 gameport->dev.bus = &gameport_bus;
526 gameport->dev.release = gameport_release_port; 514 gameport->dev.release = gameport_release_port;
527 if (gameport->parent) 515 if (gameport->parent)
@@ -550,19 +538,17 @@ static void gameport_add_port(struct gameport *gameport)
550 list_add_tail(&gameport->node, &gameport_list); 538 list_add_tail(&gameport->node, &gameport_list);
551 539
552 if (gameport->io) 540 if (gameport->io)
553 printk(KERN_INFO "gameport: %s is %s, io %#x, speed %dkHz\n", 541 dev_info(&gameport->dev, "%s is %s, io %#x, speed %dkHz\n",
554 gameport->name, gameport->phys, gameport->io, gameport->speed); 542 gameport->name, gameport->phys, gameport->io, gameport->speed);
555 else 543 else
556 printk(KERN_INFO "gameport: %s is %s, speed %dkHz\n", 544 dev_info(&gameport->dev, "%s is %s, speed %dkHz\n",
557 gameport->name, gameport->phys, gameport->speed); 545 gameport->name, gameport->phys, gameport->speed);
558 546
559 error = device_add(&gameport->dev); 547 error = device_add(&gameport->dev);
560 if (error) 548 if (error)
561 printk(KERN_ERR 549 dev_err(&gameport->dev,
562 "gameport: device_add() failed for %s (%s), error: %d\n", 550 "device_add() failed for %s (%s), error: %d\n",
563 gameport->phys, gameport->name, error); 551 gameport->phys, gameport->name, error);
564 else
565 gameport->registered = 1;
566} 552}
567 553
568/* 554/*
@@ -584,10 +570,8 @@ static void gameport_destroy_port(struct gameport *gameport)
584 gameport->parent = NULL; 570 gameport->parent = NULL;
585 } 571 }
586 572
587 if (gameport->registered) { 573 if (device_is_registered(&gameport->dev))
588 device_del(&gameport->dev); 574 device_del(&gameport->dev);
589 gameport->registered = 0;
590 }
591 575
592 list_del_init(&gameport->node); 576 list_del_init(&gameport->node);
593 577
@@ -705,8 +689,7 @@ static void gameport_attach_driver(struct gameport_driver *drv)
705 689
706 error = driver_attach(&drv->driver); 690 error = driver_attach(&drv->driver);
707 if (error) 691 if (error)
708 printk(KERN_ERR 692 pr_err("driver_attach() failed for %s, error: %d\n",
709 "gameport: driver_attach() failed for %s, error: %d\n",
710 drv->driver.name, error); 693 drv->driver.name, error);
711} 694}
712 695
@@ -727,8 +710,7 @@ int __gameport_register_driver(struct gameport_driver *drv, struct module *owner
727 710
728 error = driver_register(&drv->driver); 711 error = driver_register(&drv->driver);
729 if (error) { 712 if (error) {
730 printk(KERN_ERR 713 pr_err("driver_register() failed for %s, error: %d\n",
731 "gameport: driver_register() failed for %s, error: %d\n",
732 drv->driver.name, error); 714 drv->driver.name, error);
733 return error; 715 return error;
734 } 716 }
@@ -828,7 +810,7 @@ static int __init gameport_init(void)
828 810
829 error = bus_register(&gameport_bus); 811 error = bus_register(&gameport_bus);
830 if (error) { 812 if (error) {
831 printk(KERN_ERR "gameport: failed to register gameport bus, error: %d\n", error); 813 pr_err("failed to register gameport bus, error: %d\n", error);
832 return error; 814 return error;
833 } 815 }
834 816
@@ -836,7 +818,7 @@ static int __init gameport_init(void)
836 if (IS_ERR(gameport_task)) { 818 if (IS_ERR(gameport_task)) {
837 bus_unregister(&gameport_bus); 819 bus_unregister(&gameport_bus);
838 error = PTR_ERR(gameport_task); 820 error = PTR_ERR(gameport_task);
839 printk(KERN_ERR "gameport: Failed to start kgameportd, error: %d\n", error); 821 pr_err("Failed to start kgameportd, error: %d\n", error);
840 return error; 822 return error;
841 } 823 }
842 824
diff --git a/drivers/input/gameport/ns558.c b/drivers/input/gameport/ns558.c
index db556b71ddda..7c217848613e 100644
--- a/drivers/input/gameport/ns558.c
+++ b/drivers/input/gameport/ns558.c
@@ -166,7 +166,7 @@ static int ns558_isa_probe(int io)
166 166
167#ifdef CONFIG_PNP 167#ifdef CONFIG_PNP
168 168
169static struct pnp_device_id pnp_devids[] = { 169static const struct pnp_device_id pnp_devids[] = {
170 { .id = "@P@0001", .driver_data = 0 }, /* ALS 100 */ 170 { .id = "@P@0001", .driver_data = 0 }, /* ALS 100 */
171 { .id = "@P@0020", .driver_data = 0 }, /* ALS 200 */ 171 { .id = "@P@0020", .driver_data = 0 }, /* ALS 200 */
172 { .id = "@P@1001", .driver_data = 0 }, /* ALS 100+ */ 172 { .id = "@P@1001", .driver_data = 0 }, /* ALS 100+ */
diff --git a/drivers/input/input-compat.h b/drivers/input/input-compat.h
index 47cd9eaee66a..4d8ea32e8a00 100644
--- a/drivers/input/input-compat.h
+++ b/drivers/input/input-compat.h
@@ -21,8 +21,6 @@
21 you why the ifdefs are needed? Think about it again. -AK */ 21 you why the ifdefs are needed? Think about it again. -AK */
22#ifdef CONFIG_X86_64 22#ifdef CONFIG_X86_64
23# define INPUT_COMPAT_TEST is_compat_task() 23# define INPUT_COMPAT_TEST is_compat_task()
24#elif defined(CONFIG_IA64)
25# define INPUT_COMPAT_TEST IS_IA32_PROCESS(task_pt_regs(current))
26#elif defined(CONFIG_S390) 24#elif defined(CONFIG_S390)
27# define INPUT_COMPAT_TEST test_thread_flag(TIF_31BIT) 25# define INPUT_COMPAT_TEST test_thread_flag(TIF_31BIT)
28#elif defined(CONFIG_MIPS) 26#elif defined(CONFIG_MIPS)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 86cb2d2196ff..41168d5f8c17 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -87,12 +87,14 @@ static int input_defuzz_abs_event(int value, int old_val, int fuzz)
87} 87}
88 88
89/* 89/*
90 * Pass event through all open handles. This function is called with 90 * Pass event first through all filters and then, if event has not been
91 * filtered out, through all open handles. This function is called with
91 * dev->event_lock held and interrupts disabled. 92 * dev->event_lock held and interrupts disabled.
92 */ 93 */
93static void input_pass_event(struct input_dev *dev, 94static void input_pass_event(struct input_dev *dev,
94 unsigned int type, unsigned int code, int value) 95 unsigned int type, unsigned int code, int value)
95{ 96{
97 struct input_handler *handler;
96 struct input_handle *handle; 98 struct input_handle *handle;
97 99
98 rcu_read_lock(); 100 rcu_read_lock();
@@ -100,11 +102,25 @@ static void input_pass_event(struct input_dev *dev,
100 handle = rcu_dereference(dev->grab); 102 handle = rcu_dereference(dev->grab);
101 if (handle) 103 if (handle)
102 handle->handler->event(handle, type, code, value); 104 handle->handler->event(handle, type, code, value);
103 else 105 else {
104 list_for_each_entry_rcu(handle, &dev->h_list, d_node) 106 bool filtered = false;
105 if (handle->open) 107
106 handle->handler->event(handle, 108 list_for_each_entry_rcu(handle, &dev->h_list, d_node) {
107 type, code, value); 109 if (!handle->open)
110 continue;
111
112 handler = handle->handler;
113 if (!handler->filter) {
114 if (filtered)
115 break;
116
117 handler->event(handle, type, code, value);
118
119 } else if (handler->filter(handle, type, code, value))
120 filtered = true;
121 }
122 }
123
108 rcu_read_unlock(); 124 rcu_read_unlock();
109} 125}
110 126
@@ -615,12 +631,12 @@ static int input_default_setkeycode(struct input_dev *dev,
615 } 631 }
616 } 632 }
617 633
618 clear_bit(old_keycode, dev->keybit); 634 __clear_bit(old_keycode, dev->keybit);
619 set_bit(keycode, dev->keybit); 635 __set_bit(keycode, dev->keybit);
620 636
621 for (i = 0; i < dev->keycodemax; i++) { 637 for (i = 0; i < dev->keycodemax; i++) {
622 if (input_fetch_keycode(dev, i) == old_keycode) { 638 if (input_fetch_keycode(dev, i) == old_keycode) {
623 set_bit(old_keycode, dev->keybit); 639 __set_bit(old_keycode, dev->keybit);
624 break; /* Setting the bit twice is useless, so break */ 640 break; /* Setting the bit twice is useless, so break */
625 } 641 }
626 } 642 }
@@ -678,6 +694,9 @@ int input_set_keycode(struct input_dev *dev, int scancode, int keycode)
678 if (retval) 694 if (retval)
679 goto out; 695 goto out;
680 696
697 /* Make sure KEY_RESERVED did not get enabled. */
698 __clear_bit(KEY_RESERVED, dev->keybit);
699
681 /* 700 /*
682 * Simulate keyup event if keycode is not present 701 * Simulate keyup event if keycode is not present
683 * in the keymap anymore 702 * in the keymap anymore
@@ -705,12 +724,13 @@ EXPORT_SYMBOL(input_set_keycode);
705 if (i != BITS_TO_LONGS(max)) \ 724 if (i != BITS_TO_LONGS(max)) \
706 continue; 725 continue;
707 726
708static const struct input_device_id *input_match_device(const struct input_device_id *id, 727static const struct input_device_id *input_match_device(struct input_handler *handler,
709 struct input_dev *dev) 728 struct input_dev *dev)
710{ 729{
730 const struct input_device_id *id;
711 int i; 731 int i;
712 732
713 for (; id->flags || id->driver_info; id++) { 733 for (id = handler->id_table; id->flags || id->driver_info; id++) {
714 734
715 if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) 735 if (id->flags & INPUT_DEVICE_ID_MATCH_BUS)
716 if (id->bustype != dev->id.bustype) 736 if (id->bustype != dev->id.bustype)
@@ -738,7 +758,8 @@ static const struct input_device_id *input_match_device(const struct input_devic
738 MATCH_BIT(ffbit, FF_MAX); 758 MATCH_BIT(ffbit, FF_MAX);
739 MATCH_BIT(swbit, SW_MAX); 759 MATCH_BIT(swbit, SW_MAX);
740 760
741 return id; 761 if (!handler->match || handler->match(handler, dev))
762 return id;
742 } 763 }
743 764
744 return NULL; 765 return NULL;
@@ -749,10 +770,7 @@ static int input_attach_handler(struct input_dev *dev, struct input_handler *han
749 const struct input_device_id *id; 770 const struct input_device_id *id;
750 int error; 771 int error;
751 772
752 if (handler->blacklist && input_match_device(handler->blacklist, dev)) 773 id = input_match_device(handler, dev);
753 return -ENODEV;
754
755 id = input_match_device(handler->id_table, dev);
756 if (!id) 774 if (!id)
757 return -ENODEV; 775 return -ENODEV;
758 776
@@ -988,6 +1006,8 @@ static int input_handlers_seq_show(struct seq_file *seq, void *v)
988 union input_seq_state *state = (union input_seq_state *)&seq->private; 1006 union input_seq_state *state = (union input_seq_state *)&seq->private;
989 1007
990 seq_printf(seq, "N: Number=%u Name=%s", state->pos, handler->name); 1008 seq_printf(seq, "N: Number=%u Name=%s", state->pos, handler->name);
1009 if (handler->filter)
1010 seq_puts(seq, " (filter)");
991 if (handler->fops) 1011 if (handler->fops)
992 seq_printf(seq, " Minor=%d", handler->minor); 1012 seq_printf(seq, " Minor=%d", handler->minor);
993 seq_putc(seq, '\n'); 1013 seq_putc(seq, '\n');
@@ -1551,6 +1571,25 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
1551} 1571}
1552EXPORT_SYMBOL(input_set_capability); 1572EXPORT_SYMBOL(input_set_capability);
1553 1573
1574#define INPUT_CLEANSE_BITMASK(dev, type, bits) \
1575 do { \
1576 if (!test_bit(EV_##type, dev->evbit)) \
1577 memset(dev->bits##bit, 0, \
1578 sizeof(dev->bits##bit)); \
1579 } while (0)
1580
1581static void input_cleanse_bitmasks(struct input_dev *dev)
1582{
1583 INPUT_CLEANSE_BITMASK(dev, KEY, key);
1584 INPUT_CLEANSE_BITMASK(dev, REL, rel);
1585 INPUT_CLEANSE_BITMASK(dev, ABS, abs);
1586 INPUT_CLEANSE_BITMASK(dev, MSC, msc);
1587 INPUT_CLEANSE_BITMASK(dev, LED, led);
1588 INPUT_CLEANSE_BITMASK(dev, SND, snd);
1589 INPUT_CLEANSE_BITMASK(dev, FF, ff);
1590 INPUT_CLEANSE_BITMASK(dev, SW, sw);
1591}
1592
1554/** 1593/**
1555 * input_register_device - register device with input core 1594 * input_register_device - register device with input core
1556 * @dev: device to be registered 1595 * @dev: device to be registered
@@ -1570,13 +1609,19 @@ int input_register_device(struct input_dev *dev)
1570 const char *path; 1609 const char *path;
1571 int error; 1610 int error;
1572 1611
1612 /* Every input device generates EV_SYN/SYN_REPORT events. */
1573 __set_bit(EV_SYN, dev->evbit); 1613 __set_bit(EV_SYN, dev->evbit);
1574 1614
1615 /* KEY_RESERVED is not supposed to be transmitted to userspace. */
1616 __clear_bit(KEY_RESERVED, dev->keybit);
1617
1618 /* Make sure that bitmasks not mentioned in dev->evbit are clean. */
1619 input_cleanse_bitmasks(dev);
1620
1575 /* 1621 /*
1576 * If delay and period are pre-set by the driver, then autorepeating 1622 * If delay and period are pre-set by the driver, then autorepeating
1577 * is handled by the driver itself and we don't do it in input.c. 1623 * is handled by the driver itself and we don't do it in input.c.
1578 */ 1624 */
1579
1580 init_timer(&dev->timer); 1625 init_timer(&dev->timer);
1581 if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) { 1626 if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) {
1582 dev->timer.data = (long) dev; 1627 dev->timer.data = (long) dev;
@@ -1776,7 +1821,16 @@ int input_register_handle(struct input_handle *handle)
1776 error = mutex_lock_interruptible(&dev->mutex); 1821 error = mutex_lock_interruptible(&dev->mutex);
1777 if (error) 1822 if (error)
1778 return error; 1823 return error;
1779 list_add_tail_rcu(&handle->d_node, &dev->h_list); 1824
1825 /*
1826 * Filters go to the head of the list, normal handlers
1827 * to the tail.
1828 */
1829 if (handler->filter)
1830 list_add_rcu(&handle->d_node, &dev->h_list);
1831 else
1832 list_add_tail_rcu(&handle->d_node, &dev->h_list);
1833
1780 mutex_unlock(&dev->mutex); 1834 mutex_unlock(&dev->mutex);
1781 1835
1782 /* 1836 /*
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index b1bd6dd32286..c52bec4d0530 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -286,6 +286,8 @@ static int joydev_open(struct inode *inode, struct file *file)
286 goto err_free_client; 286 goto err_free_client;
287 287
288 file->private_data = client; 288 file->private_data = client;
289 nonseekable_open(inode, file);
290
289 return 0; 291 return 0;
290 292
291 err_free_client: 293 err_free_client:
@@ -775,6 +777,20 @@ static void joydev_cleanup(struct joydev *joydev)
775 input_close_device(handle); 777 input_close_device(handle);
776} 778}
777 779
780
781static bool joydev_match(struct input_handler *handler, struct input_dev *dev)
782{
783 /* Avoid touchpads and touchscreens */
784 if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit))
785 return false;
786
787 /* Avoid tablets, digitisers and similar devices */
788 if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_DIGI, dev->keybit))
789 return false;
790
791 return true;
792}
793
778static int joydev_connect(struct input_handler *handler, struct input_dev *dev, 794static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
779 const struct input_device_id *id) 795 const struct input_device_id *id)
780{ 796{
@@ -894,22 +910,6 @@ static void joydev_disconnect(struct input_handle *handle)
894 put_device(&joydev->dev); 910 put_device(&joydev->dev);
895} 911}
896 912
897static const struct input_device_id joydev_blacklist[] = {
898 {
899 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
900 INPUT_DEVICE_ID_MATCH_KEYBIT,
901 .evbit = { BIT_MASK(EV_KEY) },
902 .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
903 }, /* Avoid itouchpads and touchscreens */
904 {
905 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
906 INPUT_DEVICE_ID_MATCH_KEYBIT,
907 .evbit = { BIT_MASK(EV_KEY) },
908 .keybit = { [BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_DIGI) },
909 }, /* Avoid tablets, digitisers and similar devices */
910 { } /* Terminating entry */
911};
912
913static const struct input_device_id joydev_ids[] = { 913static const struct input_device_id joydev_ids[] = {
914 { 914 {
915 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | 915 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
@@ -936,13 +936,13 @@ MODULE_DEVICE_TABLE(input, joydev_ids);
936 936
937static struct input_handler joydev_handler = { 937static struct input_handler joydev_handler = {
938 .event = joydev_event, 938 .event = joydev_event,
939 .match = joydev_match,
939 .connect = joydev_connect, 940 .connect = joydev_connect,
940 .disconnect = joydev_disconnect, 941 .disconnect = joydev_disconnect,
941 .fops = &joydev_fops, 942 .fops = &joydev_fops,
942 .minor = JOYDEV_MINOR_BASE, 943 .minor = JOYDEV_MINOR_BASE,
943 .name = "joydev", 944 .name = "joydev",
944 .id_table = joydev_ids, 945 .id_table = joydev_ids,
945 .blacklist = joydev_blacklist,
946}; 946};
947 947
948static int __init joydev_init(void) 948static int __init joydev_init(void)
diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
index b11419590cfe..5b596165b571 100644
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@ -221,6 +221,7 @@ config JOYSTICK_DB9
221config JOYSTICK_GAMECON 221config JOYSTICK_GAMECON
222 tristate "Multisystem, NES, SNES, N64, PSX joysticks and gamepads" 222 tristate "Multisystem, NES, SNES, N64, PSX joysticks and gamepads"
223 depends on PARPORT 223 depends on PARPORT
224 select INPUT_FF_MEMLESS
224 ---help--- 225 ---help---
225 Say Y here if you have a Nintendo Entertainment System gamepad, 226 Say Y here if you have a Nintendo Entertainment System gamepad,
226 Super Nintendo Entertainment System gamepad, Nintendo 64 gamepad, 227 Super Nintendo Entertainment System gamepad, Nintendo 64 gamepad,
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 07a32aff5a31..ae998d99a5ae 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -30,6 +30,8 @@
30 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 30 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
31 */ 31 */
32 32
33#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34
33#include <linux/kernel.h> 35#include <linux/kernel.h>
34#include <linux/delay.h> 36#include <linux/delay.h>
35#include <linux/module.h> 37#include <linux/module.h>
@@ -61,48 +63,73 @@ MODULE_PARM_DESC(map3, "Describes third set of devices");
61 63
62/* see also gs_psx_delay parameter in PSX support section */ 64/* see also gs_psx_delay parameter in PSX support section */
63 65
64#define GC_SNES 1 66enum gc_type {
65#define GC_NES 2 67 GC_NONE = 0,
66#define GC_NES4 3 68 GC_SNES,
67#define GC_MULTI 4 69 GC_NES,
68#define GC_MULTI2 5 70 GC_NES4,
69#define GC_N64 6 71 GC_MULTI,
70#define GC_PSX 7 72 GC_MULTI2,
71#define GC_DDR 8 73 GC_N64,
72#define GC_SNESMOUSE 9 74 GC_PSX,
73 75 GC_DDR,
74#define GC_MAX 9 76 GC_SNESMOUSE,
77 GC_MAX
78};
75 79
76#define GC_REFRESH_TIME HZ/100 80#define GC_REFRESH_TIME HZ/100
77 81
82struct gc_pad {
83 struct input_dev *dev;
84 enum gc_type type;
85 char phys[32];
86};
87
78struct gc { 88struct gc {
79 struct pardevice *pd; 89 struct pardevice *pd;
90 struct gc_pad pads[GC_MAX_DEVICES];
80 struct input_dev *dev[GC_MAX_DEVICES]; 91 struct input_dev *dev[GC_MAX_DEVICES];
81 struct timer_list timer; 92 struct timer_list timer;
82 unsigned char pads[GC_MAX + 1]; 93 int pad_count[GC_MAX];
83 int used; 94 int used;
84 struct mutex mutex; 95 struct mutex mutex;
85 char phys[GC_MAX_DEVICES][32]; 96};
97
98struct gc_subdev {
99 unsigned int idx;
86}; 100};
87 101
88static struct gc *gc_base[3]; 102static struct gc *gc_base[3];
89 103
90static int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 }; 104static const int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 };
105
106static const char *gc_names[] = {
107 NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick",
108 "Multisystem 2-button joystick", "N64 controller", "PSX controller",
109 "PSX DDR controller", "SNES mouse"
110};
91 111
92static char *gc_names[] = { NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick",
93 "Multisystem 2-button joystick", "N64 controller", "PSX controller",
94 "PSX DDR controller", "SNES mouse" };
95/* 112/*
96 * N64 support. 113 * N64 support.
97 */ 114 */
98 115
99static unsigned char gc_n64_bytes[] = { 0, 1, 13, 15, 14, 12, 10, 11, 2, 3 }; 116static const unsigned char gc_n64_bytes[] = { 0, 1, 13, 15, 14, 12, 10, 11, 2, 3 };
100static short gc_n64_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TRIGGER, BTN_START }; 117static const short gc_n64_btn[] = {
118 BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z,
119 BTN_TL, BTN_TR, BTN_TRIGGER, BTN_START
120};
101 121
102#define GC_N64_LENGTH 32 /* N64 bit length, not including stop bit */ 122#define GC_N64_LENGTH 32 /* N64 bit length, not including stop bit */
103#define GC_N64_REQUEST_LENGTH 37 /* transmit request sequence is 9 bits long */ 123#define GC_N64_STOP_LENGTH 5 /* Length of encoded stop bit */
124#define GC_N64_CMD_00 0x11111111UL
125#define GC_N64_CMD_01 0xd1111111UL
126#define GC_N64_CMD_03 0xdd111111UL
127#define GC_N64_CMD_1b 0xdd1dd111UL
128#define GC_N64_CMD_c0 0x111111ddUL
129#define GC_N64_CMD_80 0x1111111dUL
130#define GC_N64_STOP_BIT 0x1d /* Encoded stop bit */
131#define GC_N64_REQUEST_DATA GC_N64_CMD_01 /* the request data command */
104#define GC_N64_DELAY 133 /* delay between transmit request, and response ready (us) */ 132#define GC_N64_DELAY 133 /* delay between transmit request, and response ready (us) */
105#define GC_N64_REQUEST 0x1dd1111111ULL /* the request data command (encoded for 000000011) */
106#define GC_N64_DWS 3 /* delay between write segments (required for sound playback because of ISA DMA) */ 133#define GC_N64_DWS 3 /* delay between write segments (required for sound playback because of ISA DMA) */
107 /* GC_N64_DWS > 24 is known to fail */ 134 /* GC_N64_DWS > 24 is known to fail */
108#define GC_N64_POWER_W 0xe2 /* power during write (transmit request) */ 135#define GC_N64_POWER_W 0xe2 /* power during write (transmit request) */
@@ -114,8 +141,40 @@ static short gc_n64_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL,
114#define GC_N64_CLOCK 0x02 /* clock bits for read */ 141#define GC_N64_CLOCK 0x02 /* clock bits for read */
115 142
116/* 143/*
144 * Used for rumble code.
145 */
146
147/* Send encoded command */
148static void gc_n64_send_command(struct gc *gc, unsigned long cmd,
149 unsigned char target)
150{
151 struct parport *port = gc->pd->port;
152 int i;
153
154 for (i = 0; i < GC_N64_LENGTH; i++) {
155 unsigned char data = (cmd >> i) & 1 ? target : 0;
156 parport_write_data(port, GC_N64_POWER_W | data);
157 udelay(GC_N64_DWS);
158 }
159}
160
161/* Send stop bit */
162static void gc_n64_send_stop_bit(struct gc *gc, unsigned char target)
163{
164 struct parport *port = gc->pd->port;
165 int i;
166
167 for (i = 0; i < GC_N64_STOP_LENGTH; i++) {
168 unsigned char data = (GC_N64_STOP_BIT >> i) & 1 ? target : 0;
169 parport_write_data(port, GC_N64_POWER_W | data);
170 udelay(GC_N64_DWS);
171 }
172}
173
174/*
117 * gc_n64_read_packet() reads an N64 packet. 175 * gc_n64_read_packet() reads an N64 packet.
118 * Each pad uses one bit per byte. So all pads connected to this port are read in parallel. 176 * Each pad uses one bit per byte. So all pads connected to this port
177 * are read in parallel.
119 */ 178 */
120 179
121static void gc_n64_read_packet(struct gc *gc, unsigned char *data) 180static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
@@ -128,14 +187,13 @@ static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
128 */ 187 */
129 188
130 local_irq_save(flags); 189 local_irq_save(flags);
131 for (i = 0; i < GC_N64_REQUEST_LENGTH; i++) { 190 gc_n64_send_command(gc, GC_N64_REQUEST_DATA, GC_N64_OUT);
132 parport_write_data(gc->pd->port, GC_N64_POWER_W | ((GC_N64_REQUEST >> i) & 1 ? GC_N64_OUT : 0)); 191 gc_n64_send_stop_bit(gc, GC_N64_OUT);
133 udelay(GC_N64_DWS);
134 }
135 local_irq_restore(flags); 192 local_irq_restore(flags);
136 193
137/* 194/*
138 * Wait for the pad response to be loaded into the 33-bit register of the adapter 195 * Wait for the pad response to be loaded into the 33-bit register
196 * of the adapter.
139 */ 197 */
140 198
141 udelay(GC_N64_DELAY); 199 udelay(GC_N64_DELAY);
@@ -146,13 +204,15 @@ static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
146 204
147 for (i = 0; i < GC_N64_LENGTH; i++) { 205 for (i = 0; i < GC_N64_LENGTH; i++) {
148 parport_write_data(gc->pd->port, GC_N64_POWER_R); 206 parport_write_data(gc->pd->port, GC_N64_POWER_R);
207 udelay(2);
149 data[i] = parport_read_status(gc->pd->port); 208 data[i] = parport_read_status(gc->pd->port);
150 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK); 209 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK);
151 } 210 }
152 211
153/* 212/*
154 * We must wait 200 ms here for the controller to reinitialize before the next read request. 213 * We must wait 200 ms here for the controller to reinitialize before
155 * No worries as long as gc_read is polled less frequently than this. 214 * the next read request. No worries as long as gc_read is polled less
215 * frequently than this.
156 */ 216 */
157 217
158} 218}
@@ -160,45 +220,112 @@ static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
160static void gc_n64_process_packet(struct gc *gc) 220static void gc_n64_process_packet(struct gc *gc)
161{ 221{
162 unsigned char data[GC_N64_LENGTH]; 222 unsigned char data[GC_N64_LENGTH];
163 signed char axes[2];
164 struct input_dev *dev; 223 struct input_dev *dev;
165 int i, j, s; 224 int i, j, s;
225 signed char x, y;
166 226
167 gc_n64_read_packet(gc, data); 227 gc_n64_read_packet(gc, data);
168 228
169 for (i = 0; i < GC_MAX_DEVICES; i++) { 229 for (i = 0; i < GC_MAX_DEVICES; i++) {
170 230
171 dev = gc->dev[i]; 231 if (gc->pads[i].type != GC_N64)
172 if (!dev)
173 continue; 232 continue;
174 233
234 dev = gc->pads[i].dev;
175 s = gc_status_bit[i]; 235 s = gc_status_bit[i];
176 236
177 if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) { 237 if (s & ~(data[8] | data[9])) {
178 238
179 axes[0] = axes[1] = 0; 239 x = y = 0;
180 240
181 for (j = 0; j < 8; j++) { 241 for (j = 0; j < 8; j++) {
182 if (data[23 - j] & s) 242 if (data[23 - j] & s)
183 axes[0] |= 1 << j; 243 x |= 1 << j;
184 if (data[31 - j] & s) 244 if (data[31 - j] & s)
185 axes[1] |= 1 << j; 245 y |= 1 << j;
186 } 246 }
187 247
188 input_report_abs(dev, ABS_X, axes[0]); 248 input_report_abs(dev, ABS_X, x);
189 input_report_abs(dev, ABS_Y, -axes[1]); 249 input_report_abs(dev, ABS_Y, -y);
190 250
191 input_report_abs(dev, ABS_HAT0X, !(s & data[6]) - !(s & data[7])); 251 input_report_abs(dev, ABS_HAT0X,
192 input_report_abs(dev, ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); 252 !(s & data[6]) - !(s & data[7]));
253 input_report_abs(dev, ABS_HAT0Y,
254 !(s & data[4]) - !(s & data[5]));
193 255
194 for (j = 0; j < 10; j++) 256 for (j = 0; j < 10; j++)
195 input_report_key(dev, gc_n64_btn[j], s & data[gc_n64_bytes[j]]); 257 input_report_key(dev, gc_n64_btn[j],
258 s & data[gc_n64_bytes[j]]);
196 259
197 input_sync(dev); 260 input_sync(dev);
198 } 261 }
199 } 262 }
200} 263}
201 264
265static int gc_n64_play_effect(struct input_dev *dev, void *data,
266 struct ff_effect *effect)
267{
268 int i;
269 unsigned long flags;
270 struct gc *gc = input_get_drvdata(dev);
271 struct gc_subdev *sdev = data;
272 unsigned char target = 1 << sdev->idx; /* select desired pin */
273
274 if (effect->type == FF_RUMBLE) {
275 struct ff_rumble_effect *rumble = &effect->u.rumble;
276 unsigned int cmd =
277 rumble->strong_magnitude || rumble->weak_magnitude ?
278 GC_N64_CMD_01 : GC_N64_CMD_00;
279
280 local_irq_save(flags);
281
282 /* Init Rumble - 0x03, 0x80, 0x01, (34)0x80 */
283 gc_n64_send_command(gc, GC_N64_CMD_03, target);
284 gc_n64_send_command(gc, GC_N64_CMD_80, target);
285 gc_n64_send_command(gc, GC_N64_CMD_01, target);
286 for (i = 0; i < 32; i++)
287 gc_n64_send_command(gc, GC_N64_CMD_80, target);
288 gc_n64_send_stop_bit(gc, target);
289
290 udelay(GC_N64_DELAY);
291
292 /* Now start or stop it - 0x03, 0xc0, 0zx1b, (32)0x01/0x00 */
293 gc_n64_send_command(gc, GC_N64_CMD_03, target);
294 gc_n64_send_command(gc, GC_N64_CMD_c0, target);
295 gc_n64_send_command(gc, GC_N64_CMD_1b, target);
296 for (i = 0; i < 32; i++)
297 gc_n64_send_command(gc, cmd, target);
298 gc_n64_send_stop_bit(gc, target);
299
300 local_irq_restore(flags);
301
302 }
303
304 return 0;
305}
306
307static int __init gc_n64_init_ff(struct input_dev *dev, int i)
308{
309 struct gc_subdev *sdev;
310 int err;
311
312 sdev = kmalloc(sizeof(*sdev), GFP_KERNEL);
313 if (!sdev)
314 return -ENOMEM;
315
316 sdev->idx = i;
317
318 input_set_capability(dev, EV_FF, FF_RUMBLE);
319
320 err = input_ff_create_memless(dev, sdev, gc_n64_play_effect);
321 if (err) {
322 kfree(sdev);
323 return err;
324 }
325
326 return 0;
327}
328
202/* 329/*
203 * NES/SNES support. 330 * NES/SNES support.
204 */ 331 */
@@ -214,9 +341,11 @@ static void gc_n64_process_packet(struct gc *gc)
214#define GC_NES_CLOCK 0x01 341#define GC_NES_CLOCK 0x01
215#define GC_NES_LATCH 0x02 342#define GC_NES_LATCH 0x02
216 343
217static unsigned char gc_nes_bytes[] = { 0, 1, 2, 3 }; 344static const unsigned char gc_nes_bytes[] = { 0, 1, 2, 3 };
218static unsigned char gc_snes_bytes[] = { 8, 0, 2, 3, 9, 1, 10, 11 }; 345static const unsigned char gc_snes_bytes[] = { 8, 0, 2, 3, 9, 1, 10, 11 };
219static short gc_snes_btn[] = { BTN_A, BTN_B, BTN_SELECT, BTN_START, BTN_X, BTN_Y, BTN_TL, BTN_TR }; 346static const short gc_snes_btn[] = {
347 BTN_A, BTN_B, BTN_SELECT, BTN_START, BTN_X, BTN_Y, BTN_TL, BTN_TR
348};
220 349
221/* 350/*
222 * gc_nes_read_packet() reads a NES/SNES packet. 351 * gc_nes_read_packet() reads a NES/SNES packet.
@@ -244,40 +373,51 @@ static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data)
244static void gc_nes_process_packet(struct gc *gc) 373static void gc_nes_process_packet(struct gc *gc)
245{ 374{
246 unsigned char data[GC_SNESMOUSE_LENGTH]; 375 unsigned char data[GC_SNESMOUSE_LENGTH];
376 struct gc_pad *pad;
247 struct input_dev *dev; 377 struct input_dev *dev;
248 int i, j, s, len; 378 int i, j, s, len;
249 char x_rel, y_rel; 379 char x_rel, y_rel;
250 380
251 len = gc->pads[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : 381 len = gc->pad_count[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH :
252 (gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); 382 (gc->pad_count[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH);
253 383
254 gc_nes_read_packet(gc, len, data); 384 gc_nes_read_packet(gc, len, data);
255 385
256 for (i = 0; i < GC_MAX_DEVICES; i++) { 386 for (i = 0; i < GC_MAX_DEVICES; i++) {
257 387
388 pad = &gc->pads[i];
258 dev = gc->dev[i]; 389 dev = gc->dev[i];
259 if (!dev)
260 continue;
261
262 s = gc_status_bit[i]; 390 s = gc_status_bit[i];
263 391
264 if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { 392 switch (pad->type) {
393
394 case GC_NES:
395
265 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7])); 396 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7]));
266 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5])); 397 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5]));
267 }
268 398
269 if (s & gc->pads[GC_NES])
270 for (j = 0; j < 4; j++) 399 for (j = 0; j < 4; j++)
271 input_report_key(dev, gc_snes_btn[j], s & data[gc_nes_bytes[j]]); 400 input_report_key(dev, gc_snes_btn[j],
401 s & data[gc_nes_bytes[j]]);
402 input_sync(dev);
403 break;
404
405 case GC_SNES:
406
407 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7]));
408 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5]));
272 409
273 if (s & gc->pads[GC_SNES])
274 for (j = 0; j < 8; j++) 410 for (j = 0; j < 8; j++)
275 input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); 411 input_report_key(dev, gc_snes_btn[j],
412 s & data[gc_snes_bytes[j]]);
413 input_sync(dev);
414 break;
276 415
277 if (s & gc->pads[GC_SNESMOUSE]) { 416 case GC_SNESMOUSE:
278 /* 417 /*
279 * The 4 unused bits from SNES controllers appear to be ID bits 418 * The 4 unused bits from SNES controllers appear
280 * so use them to make sure iwe are dealing with a mouse. 419 * to be ID bits so use them to make sure we are
420 * dealing with a mouse.
281 * gamepad is connected. This is important since 421 * gamepad is connected. This is important since
282 * my SNES gamepad sends 1's for bits 16-31, which 422 * my SNES gamepad sends 1's for bits 16-31, which
283 * cause the mouse pointer to quickly move to the 423 * cause the mouse pointer to quickly move to the
@@ -310,9 +450,14 @@ static void gc_nes_process_packet(struct gc *gc)
310 y_rel = -y_rel; 450 y_rel = -y_rel;
311 input_report_rel(dev, REL_Y, y_rel); 451 input_report_rel(dev, REL_Y, y_rel);
312 } 452 }
453
454 input_sync(dev);
313 } 455 }
456 break;
457
458 default:
459 break;
314 } 460 }
315 input_sync(dev);
316 } 461 }
317} 462}
318 463
@@ -340,29 +485,35 @@ static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data)
340static void gc_multi_process_packet(struct gc *gc) 485static void gc_multi_process_packet(struct gc *gc)
341{ 486{
342 unsigned char data[GC_MULTI2_LENGTH]; 487 unsigned char data[GC_MULTI2_LENGTH];
488 int data_len = gc->pad_count[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH;
489 struct gc_pad *pad;
343 struct input_dev *dev; 490 struct input_dev *dev;
344 int i, s; 491 int i, s;
345 492
346 gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data); 493 gc_multi_read_packet(gc, data_len, data);
347 494
348 for (i = 0; i < GC_MAX_DEVICES; i++) { 495 for (i = 0; i < GC_MAX_DEVICES; i++) {
349 496 pad = &gc->pads[i];
350 dev = gc->dev[i]; 497 dev = pad->dev;
351 if (!dev)
352 continue;
353
354 s = gc_status_bit[i]; 498 s = gc_status_bit[i];
355 499
356 if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { 500 switch (pad->type) {
357 input_report_abs(dev, ABS_X, !(s & data[2]) - !(s & data[3])); 501 case GC_MULTI2:
358 input_report_abs(dev, ABS_Y, !(s & data[0]) - !(s & data[1]));
359 input_report_key(dev, BTN_TRIGGER, s & data[4]);
360 }
361
362 if (s & gc->pads[GC_MULTI2])
363 input_report_key(dev, BTN_THUMB, s & data[5]); 502 input_report_key(dev, BTN_THUMB, s & data[5]);
503 /* fall through */
364 504
365 input_sync(dev); 505 case GC_MULTI:
506 input_report_abs(dev, ABS_X,
507 !(s & data[2]) - !(s & data[3]));
508 input_report_abs(dev, ABS_Y,
509 !(s & data[0]) - !(s & data[1]));
510 input_report_key(dev, BTN_TRIGGER, s & data[4]);
511 input_sync(dev);
512 break;
513
514 default:
515 break;
516 }
366 } 517 }
367} 518}
368 519
@@ -398,30 +549,41 @@ static int gc_psx_delay = GC_PSX_DELAY;
398module_param_named(psx_delay, gc_psx_delay, uint, 0); 549module_param_named(psx_delay, gc_psx_delay, uint, 0);
399MODULE_PARM_DESC(psx_delay, "Delay when accessing Sony PSX controller (usecs)"); 550MODULE_PARM_DESC(psx_delay, "Delay when accessing Sony PSX controller (usecs)");
400 551
401static short gc_psx_abs[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_HAT0X, ABS_HAT0Y }; 552static const short gc_psx_abs[] = {
402static short gc_psx_btn[] = { BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_A, BTN_B, BTN_X, BTN_Y, 553 ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_HAT0X, ABS_HAT0Y
403 BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR }; 554};
404static short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 }; 555static const short gc_psx_btn[] = {
556 BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_A, BTN_B, BTN_X, BTN_Y,
557 BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR
558};
559static const short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 };
405 560
406/* 561/*
407 * gc_psx_command() writes 8bit command and reads 8bit data from 562 * gc_psx_command() writes 8bit command and reads 8bit data from
408 * the psx pad. 563 * the psx pad.
409 */ 564 */
410 565
411static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_MAX_DEVICES]) 566static void gc_psx_command(struct gc *gc, int b, unsigned char *data)
412{ 567{
568 struct parport *port = gc->pd->port;
413 int i, j, cmd, read; 569 int i, j, cmd, read;
414 570
415 for (i = 0; i < GC_MAX_DEVICES; i++) 571 memset(data, 0, GC_MAX_DEVICES);
416 data[i] = 0;
417 572
418 for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) { 573 for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) {
419 cmd = (b & 1) ? GC_PSX_COMMAND : 0; 574 cmd = (b & 1) ? GC_PSX_COMMAND : 0;
420 parport_write_data(gc->pd->port, cmd | GC_PSX_POWER); 575 parport_write_data(port, cmd | GC_PSX_POWER);
421 udelay(gc_psx_delay); 576 udelay(gc_psx_delay);
422 read = parport_read_status(gc->pd->port) ^ 0x80; 577
423 for (j = 0; j < GC_MAX_DEVICES; j++) 578 read = parport_read_status(port) ^ 0x80;
424 data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0; 579
580 for (j = 0; j < GC_MAX_DEVICES; j++) {
581 struct gc_pad *pad = &gc->pads[i];
582
583 if (pad->type == GC_PSX || pad->type == GC_DDR)
584 data[j] |= (read & gc_status_bit[j]) ? (1 << i) : 0;
585 }
586
425 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); 587 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER);
426 udelay(gc_psx_delay); 588 udelay(gc_psx_delay);
427 } 589 }
@@ -432,31 +594,40 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_MAX_DEVIC
432 * device identifier code. 594 * device identifier code.
433 */ 595 */
434 596
435static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES], 597static void gc_psx_read_packet(struct gc *gc,
598 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES],
436 unsigned char id[GC_MAX_DEVICES]) 599 unsigned char id[GC_MAX_DEVICES])
437{ 600{
438 int i, j, max_len = 0; 601 int i, j, max_len = 0;
439 unsigned long flags; 602 unsigned long flags;
440 unsigned char data2[GC_MAX_DEVICES]; 603 unsigned char data2[GC_MAX_DEVICES];
441 604
442 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); /* Select pad */ 605 /* Select pad */
606 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER);
443 udelay(gc_psx_delay); 607 udelay(gc_psx_delay);
444 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); /* Deselect, begin command */ 608 /* Deselect, begin command */
609 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER);
445 udelay(gc_psx_delay); 610 udelay(gc_psx_delay);
446 611
447 local_irq_save(flags); 612 local_irq_save(flags);
448 613
449 gc_psx_command(gc, 0x01, data2); /* Access pad */ 614 gc_psx_command(gc, 0x01, data2); /* Access pad */
450 gc_psx_command(gc, 0x42, id); /* Get device ids */ 615 gc_psx_command(gc, 0x42, id); /* Get device ids */
451 gc_psx_command(gc, 0, data2); /* Dump status */ 616 gc_psx_command(gc, 0, data2); /* Dump status */
617
618 /* Find the longest pad */
619 for (i = 0; i < GC_MAX_DEVICES; i++) {
620 struct gc_pad *pad = &gc->pads[i];
452 621
453 for (i =0; i < GC_MAX_DEVICES; i++) /* Find the longest pad */ 622 if ((pad->type == GC_PSX || pad->type == GC_DDR) &&
454 if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) 623 GC_PSX_LEN(id[i]) > max_len &&
455 && (GC_PSX_LEN(id[i]) > max_len) 624 GC_PSX_LEN(id[i]) <= GC_PSX_BYTES) {
456 && (GC_PSX_LEN(id[i]) <= GC_PSX_BYTES))
457 max_len = GC_PSX_LEN(id[i]); 625 max_len = GC_PSX_LEN(id[i]);
626 }
627 }
458 628
459 for (i = 0; i < max_len; i++) { /* Read in all the data */ 629 /* Read in all the data */
630 for (i = 0; i < max_len; i++) {
460 gc_psx_command(gc, 0, data2); 631 gc_psx_command(gc, 0, data2);
461 for (j = 0; j < GC_MAX_DEVICES; j++) 632 for (j = 0; j < GC_MAX_DEVICES; j++)
462 data[j][i] = data2[j]; 633 data[j][i] = data2[j];
@@ -466,86 +637,104 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES]
466 637
467 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); 638 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER);
468 639
469 for(i = 0; i < GC_MAX_DEVICES; i++) /* Set id's to the real value */ 640 /* Set id's to the real value */
641 for (i = 0; i < GC_MAX_DEVICES; i++)
470 id[i] = GC_PSX_ID(id[i]); 642 id[i] = GC_PSX_ID(id[i]);
471} 643}
472 644
473static void gc_psx_process_packet(struct gc *gc) 645static void gc_psx_report_one(struct gc_pad *pad, unsigned char psx_type,
646 unsigned char *data)
474{ 647{
475 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES]; 648 struct input_dev *dev = pad->dev;
476 unsigned char id[GC_MAX_DEVICES]; 649 int i;
477 struct input_dev *dev;
478 int i, j;
479 650
480 gc_psx_read_packet(gc, data, id); 651 switch (psx_type) {
481 652
482 for (i = 0; i < GC_MAX_DEVICES; i++) { 653 case GC_PSX_RUMBLE:
483 654
484 dev = gc->dev[i]; 655 input_report_key(dev, BTN_THUMBL, ~data[0] & 0x04);
485 if (!dev) 656 input_report_key(dev, BTN_THUMBR, ~data[0] & 0x02);
486 continue;
487 657
488 switch (id[i]) { 658 case GC_PSX_NEGCON:
659 case GC_PSX_ANALOG:
489 660
490 case GC_PSX_RUMBLE: 661 if (pad->type == GC_DDR) {
662 for (i = 0; i < 4; i++)
663 input_report_key(dev, gc_psx_ddr_btn[i],
664 ~data[0] & (0x10 << i));
665 } else {
666 for (i = 0; i < 4; i++)
667 input_report_abs(dev, gc_psx_abs[i + 2],
668 data[i + 2]);
491 669
492 input_report_key(dev, BTN_THUMBL, ~data[i][0] & 0x04); 670 input_report_abs(dev, ABS_X,
493 input_report_key(dev, BTN_THUMBR, ~data[i][0] & 0x02); 671 !!(data[0] & 0x80) * 128 + !(data[0] & 0x20) * 127);
672 input_report_abs(dev, ABS_Y,
673 !!(data[0] & 0x10) * 128 + !(data[0] & 0x40) * 127);
674 }
494 675
495 case GC_PSX_NEGCON: 676 for (i = 0; i < 8; i++)
496 case GC_PSX_ANALOG: 677 input_report_key(dev, gc_psx_btn[i], ~data[1] & (1 << i));
497 678
498 if (gc->pads[GC_DDR] & gc_status_bit[i]) { 679 input_report_key(dev, BTN_START, ~data[0] & 0x08);
499 for(j = 0; j < 4; j++) 680 input_report_key(dev, BTN_SELECT, ~data[0] & 0x01);
500 input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j));
501 } else {
502 for (j = 0; j < 4; j++)
503 input_report_abs(dev, gc_psx_abs[j + 2], data[i][j + 2]);
504 681
505 input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); 682 input_sync(dev);
506 input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128);
507 }
508 683
509 for (j = 0; j < 8; j++) 684 break;
510 input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j));
511 685
512 input_report_key(dev, BTN_START, ~data[i][0] & 0x08); 686 case GC_PSX_NORMAL:
513 input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01);
514 687
515 input_sync(dev); 688 if (pad->type == GC_DDR) {
689 for (i = 0; i < 4; i++)
690 input_report_key(dev, gc_psx_ddr_btn[i],
691 ~data[0] & (0x10 << i));
692 } else {
693 input_report_abs(dev, ABS_X,
694 !!(data[0] & 0x80) * 128 + !(data[0] & 0x20) * 127);
695 input_report_abs(dev, ABS_Y,
696 !!(data[0] & 0x10) * 128 + !(data[0] & 0x40) * 127);
516 697
517 break; 698 /*
518 699 * For some reason if the extra axes are left unset
519 case GC_PSX_NORMAL: 700 * they drift.
520 if (gc->pads[GC_DDR] & gc_status_bit[i]) { 701 * for (i = 0; i < 4; i++)
521 for(j = 0; j < 4; j++) 702 input_report_abs(dev, gc_psx_abs[i + 2], 128);
522 input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j)); 703 * This needs to be debugged properly,
523 } else { 704 * maybe fuzz processing needs to be done
524 input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); 705 * in input_sync()
525 input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128); 706 * --vojtech
526 707 */
527 /* for some reason if the extra axes are left unset they drift */ 708 }
528 /* for (j = 0; j < 4; j++)
529 input_report_abs(dev, gc_psx_abs[j + 2], 128);
530 * This needs to be debugged properly,
531 * maybe fuzz processing needs to be done in input_sync()
532 * --vojtech
533 */
534 }
535 709
536 for (j = 0; j < 8; j++) 710 for (i = 0; i < 8; i++)
537 input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j)); 711 input_report_key(dev, gc_psx_btn[i], ~data[1] & (1 << i));
538 712
539 input_report_key(dev, BTN_START, ~data[i][0] & 0x08); 713 input_report_key(dev, BTN_START, ~data[0] & 0x08);
540 input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01); 714 input_report_key(dev, BTN_SELECT, ~data[0] & 0x01);
541 715
542 input_sync(dev); 716 input_sync(dev);
543 717
544 break; 718 break;
545 719
546 case 0: /* not a pad, ignore */ 720 default: /* not a pad, ignore */
547 break; 721 break;
548 } 722 }
723}
724
725static void gc_psx_process_packet(struct gc *gc)
726{
727 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES];
728 unsigned char id[GC_MAX_DEVICES];
729 struct gc_pad *pad;
730 int i;
731
732 gc_psx_read_packet(gc, data, id);
733
734 for (i = 0; i < GC_MAX_DEVICES; i++) {
735 pad = &gc->pads[i];
736 if (pad->type == GC_PSX || pad->type == GC_DDR)
737 gc_psx_report_one(pad, id[i], data[i]);
549 } 738 }
550} 739}
551 740
@@ -561,28 +750,31 @@ static void gc_timer(unsigned long private)
561 * N64 pads - must be read first, any read confuses them for 200 us 750 * N64 pads - must be read first, any read confuses them for 200 us
562 */ 751 */
563 752
564 if (gc->pads[GC_N64]) 753 if (gc->pad_count[GC_N64])
565 gc_n64_process_packet(gc); 754 gc_n64_process_packet(gc);
566 755
567/* 756/*
568 * NES and SNES pads or mouse 757 * NES and SNES pads or mouse
569 */ 758 */
570 759
571 if (gc->pads[GC_NES] || gc->pads[GC_SNES] || gc->pads[GC_SNESMOUSE]) 760 if (gc->pad_count[GC_NES] ||
761 gc->pad_count[GC_SNES] ||
762 gc->pad_count[GC_SNESMOUSE]) {
572 gc_nes_process_packet(gc); 763 gc_nes_process_packet(gc);
764 }
573 765
574/* 766/*
575 * Multi and Multi2 joysticks 767 * Multi and Multi2 joysticks
576 */ 768 */
577 769
578 if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2]) 770 if (gc->pad_count[GC_MULTI] || gc->pad_count[GC_MULTI2])
579 gc_multi_process_packet(gc); 771 gc_multi_process_packet(gc);
580 772
581/* 773/*
582 * PSX controllers 774 * PSX controllers
583 */ 775 */
584 776
585 if (gc->pads[GC_PSX] || gc->pads[GC_DDR]) 777 if (gc->pad_count[GC_PSX] || gc->pad_count[GC_DDR])
586 gc_psx_process_packet(gc); 778 gc_psx_process_packet(gc);
587 779
588 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); 780 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
@@ -622,25 +814,29 @@ static void gc_close(struct input_dev *dev)
622 814
623static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) 815static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
624{ 816{
817 struct gc_pad *pad = &gc->pads[idx];
625 struct input_dev *input_dev; 818 struct input_dev *input_dev;
626 int i; 819 int i;
627 820 int err;
628 if (!pad_type)
629 return 0;
630 821
631 if (pad_type < 1 || pad_type > GC_MAX) { 822 if (pad_type < 1 || pad_type > GC_MAX) {
632 printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", pad_type); 823 pr_err("Pad type %d unknown\n", pad_type);
633 return -EINVAL; 824 return -EINVAL;
634 } 825 }
635 826
636 gc->dev[idx] = input_dev = input_allocate_device(); 827 pad->dev = input_dev = input_allocate_device();
637 if (!input_dev) { 828 if (!input_dev) {
638 printk(KERN_ERR "gamecon.c: Not enough memory for input device\n"); 829 pr_err("Not enough memory for input device\n");
639 return -ENOMEM; 830 return -ENOMEM;
640 } 831 }
641 832
833 pad->type = pad_type;
834
835 snprintf(pad->phys, sizeof(pad->phys),
836 "%s/input%d", gc->pd->port->name, idx);
837
642 input_dev->name = gc_names[pad_type]; 838 input_dev->name = gc_names[pad_type];
643 input_dev->phys = gc->phys[idx]; 839 input_dev->phys = pad->phys;
644 input_dev->id.bustype = BUS_PARPORT; 840 input_dev->id.bustype = BUS_PARPORT;
645 input_dev->id.vendor = 0x0001; 841 input_dev->id.vendor = 0x0001;
646 input_dev->id.product = pad_type; 842 input_dev->id.product = pad_type;
@@ -659,61 +855,76 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
659 } else 855 } else
660 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 856 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
661 857
662 gc->pads[0] |= gc_status_bit[idx]; 858 gc->pad_count[pad_type]++;
663 gc->pads[pad_type] |= gc_status_bit[idx];
664 859
665 switch (pad_type) { 860 switch (pad_type) {
666 861
667 case GC_N64: 862 case GC_N64:
668 for (i = 0; i < 10; i++) 863 for (i = 0; i < 10; i++)
669 set_bit(gc_n64_btn[i], input_dev->keybit); 864 __set_bit(gc_n64_btn[i], input_dev->keybit);
670
671 for (i = 0; i < 2; i++) {
672 input_set_abs_params(input_dev, ABS_X + i, -127, 126, 0, 2);
673 input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0);
674 }
675
676 break;
677
678 case GC_SNESMOUSE:
679 set_bit(BTN_LEFT, input_dev->keybit);
680 set_bit(BTN_RIGHT, input_dev->keybit);
681 set_bit(REL_X, input_dev->relbit);
682 set_bit(REL_Y, input_dev->relbit);
683 break;
684
685 case GC_SNES:
686 for (i = 4; i < 8; i++)
687 set_bit(gc_snes_btn[i], input_dev->keybit);
688 case GC_NES:
689 for (i = 0; i < 4; i++)
690 set_bit(gc_snes_btn[i], input_dev->keybit);
691 break;
692
693 case GC_MULTI2:
694 set_bit(BTN_THUMB, input_dev->keybit);
695 case GC_MULTI:
696 set_bit(BTN_TRIGGER, input_dev->keybit);
697 break;
698
699 case GC_PSX:
700 for (i = 0; i < 6; i++)
701 input_set_abs_params(input_dev, gc_psx_abs[i], 4, 252, 0, 2);
702 for (i = 0; i < 12; i++)
703 set_bit(gc_psx_btn[i], input_dev->keybit);
704 865
705 break; 866 for (i = 0; i < 2; i++) {
867 input_set_abs_params(input_dev, ABS_X + i, -127, 126, 0, 2);
868 input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0);
869 }
706 870
707 case GC_DDR: 871 err = gc_n64_init_ff(input_dev, idx);
708 for (i = 0; i < 4; i++) 872 if (err) {
709 set_bit(gc_psx_ddr_btn[i], input_dev->keybit); 873 pr_warning("Failed to initiate rumble for N64 device %d\n", idx);
710 for (i = 0; i < 12; i++) 874 goto err_free_dev;
711 set_bit(gc_psx_btn[i], input_dev->keybit); 875 }
712 876
713 break; 877 break;
878
879 case GC_SNESMOUSE:
880 __set_bit(BTN_LEFT, input_dev->keybit);
881 __set_bit(BTN_RIGHT, input_dev->keybit);
882 __set_bit(REL_X, input_dev->relbit);
883 __set_bit(REL_Y, input_dev->relbit);
884 break;
885
886 case GC_SNES:
887 for (i = 4; i < 8; i++)
888 __set_bit(gc_snes_btn[i], input_dev->keybit);
889 case GC_NES:
890 for (i = 0; i < 4; i++)
891 __set_bit(gc_snes_btn[i], input_dev->keybit);
892 break;
893
894 case GC_MULTI2:
895 __set_bit(BTN_THUMB, input_dev->keybit);
896 case GC_MULTI:
897 __set_bit(BTN_TRIGGER, input_dev->keybit);
898 break;
899
900 case GC_PSX:
901 for (i = 0; i < 6; i++)
902 input_set_abs_params(input_dev,
903 gc_psx_abs[i], 4, 252, 0, 2);
904 for (i = 0; i < 12; i++)
905 __set_bit(gc_psx_btn[i], input_dev->keybit);
906
907 break;
908
909 case GC_DDR:
910 for (i = 0; i < 4; i++)
911 __set_bit(gc_psx_ddr_btn[i], input_dev->keybit);
912 for (i = 0; i < 12; i++)
913 __set_bit(gc_psx_btn[i], input_dev->keybit);
914
915 break;
714 } 916 }
715 917
918 err = input_register_device(pad->dev);
919 if (err)
920 goto err_free_dev;
921
716 return 0; 922 return 0;
923
924err_free_dev:
925 input_free_device(pad->dev);
926 pad->dev = NULL;
927 return err;
717} 928}
718 929
719static struct gc __init *gc_probe(int parport, int *pads, int n_pads) 930static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
@@ -722,52 +933,47 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
722 struct parport *pp; 933 struct parport *pp;
723 struct pardevice *pd; 934 struct pardevice *pd;
724 int i; 935 int i;
936 int count = 0;
725 int err; 937 int err;
726 938
727 pp = parport_find_number(parport); 939 pp = parport_find_number(parport);
728 if (!pp) { 940 if (!pp) {
729 printk(KERN_ERR "gamecon.c: no such parport\n"); 941 pr_err("no such parport %d\n", parport);
730 err = -EINVAL; 942 err = -EINVAL;
731 goto err_out; 943 goto err_out;
732 } 944 }
733 945
734 pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 946 pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
735 if (!pd) { 947 if (!pd) {
736 printk(KERN_ERR "gamecon.c: parport busy already - lp.o loaded?\n"); 948 pr_err("parport busy already - lp.o loaded?\n");
737 err = -EBUSY; 949 err = -EBUSY;
738 goto err_put_pp; 950 goto err_put_pp;
739 } 951 }
740 952
741 gc = kzalloc(sizeof(struct gc), GFP_KERNEL); 953 gc = kzalloc(sizeof(struct gc), GFP_KERNEL);
742 if (!gc) { 954 if (!gc) {
743 printk(KERN_ERR "gamecon.c: Not enough memory\n"); 955 pr_err("Not enough memory\n");
744 err = -ENOMEM; 956 err = -ENOMEM;
745 goto err_unreg_pardev; 957 goto err_unreg_pardev;
746 } 958 }
747 959
748 mutex_init(&gc->mutex); 960 mutex_init(&gc->mutex);
749 gc->pd = pd; 961 gc->pd = pd;
750 init_timer(&gc->timer); 962 setup_timer(&gc->timer, gc_timer, (long) gc);
751 gc->timer.data = (long) gc;
752 gc->timer.function = gc_timer;
753 963
754 for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) { 964 for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) {
755 if (!pads[i]) 965 if (!pads[i])
756 continue; 966 continue;
757 967
758 snprintf(gc->phys[i], sizeof(gc->phys[i]),
759 "%s/input%d", gc->pd->port->name, i);
760 err = gc_setup_pad(gc, i, pads[i]); 968 err = gc_setup_pad(gc, i, pads[i]);
761 if (err) 969 if (err)
762 goto err_unreg_devs; 970 goto err_unreg_devs;
763 971
764 err = input_register_device(gc->dev[i]); 972 count++;
765 if (err)
766 goto err_free_dev;
767 } 973 }
768 974
769 if (!gc->pads[0]) { 975 if (count == 0) {
770 printk(KERN_ERR "gamecon.c: No valid devices specified\n"); 976 pr_err("No valid devices specified\n");
771 err = -EINVAL; 977 err = -EINVAL;
772 goto err_free_gc; 978 goto err_free_gc;
773 } 979 }
@@ -775,12 +981,10 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
775 parport_put_port(pp); 981 parport_put_port(pp);
776 return gc; 982 return gc;
777 983
778 err_free_dev:
779 input_free_device(gc->dev[i]);
780 err_unreg_devs: 984 err_unreg_devs:
781 while (--i >= 0) 985 while (--i >= 0)
782 if (gc->dev[i]) 986 if (gc->pads[i].dev)
783 input_unregister_device(gc->dev[i]); 987 input_unregister_device(gc->pads[i].dev);
784 err_free_gc: 988 err_free_gc:
785 kfree(gc); 989 kfree(gc);
786 err_unreg_pardev: 990 err_unreg_pardev:
@@ -796,8 +1000,8 @@ static void gc_remove(struct gc *gc)
796 int i; 1000 int i;
797 1001
798 for (i = 0; i < GC_MAX_DEVICES; i++) 1002 for (i = 0; i < GC_MAX_DEVICES; i++)
799 if (gc->dev[i]) 1003 if (gc->pads[i].dev)
800 input_unregister_device(gc->dev[i]); 1004 input_unregister_device(gc->pads[i].dev);
801 parport_unregister_device(gc->pd); 1005 parport_unregister_device(gc->pd);
802 kfree(gc); 1006 kfree(gc);
803} 1007}
@@ -813,7 +1017,7 @@ static int __init gc_init(void)
813 continue; 1017 continue;
814 1018
815 if (gc_cfg[i].nargs < 2) { 1019 if (gc_cfg[i].nargs < 2) {
816 printk(KERN_ERR "gamecon.c: at least one device must be specified\n"); 1020 pr_err("at least one device must be specified\n");
817 err = -EINVAL; 1021 err = -EINVAL;
818 break; 1022 break;
819 } 1023 }
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 8a28fb7846dc..9b3353b404da 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -86,9 +86,8 @@
86 86
87/* xbox d-pads should map to buttons, as is required for DDR pads 87/* xbox d-pads should map to buttons, as is required for DDR pads
88 but we map them to axes when possible to simplify things */ 88 but we map them to axes when possible to simplify things */
89#define MAP_DPAD_TO_BUTTONS 0 89#define MAP_DPAD_TO_BUTTONS (1 << 0)
90#define MAP_DPAD_TO_AXES 1 90#define MAP_TRIGGERS_TO_BUTTONS (1 << 1)
91#define MAP_DPAD_UNKNOWN 2
92 91
93#define XTYPE_XBOX 0 92#define XTYPE_XBOX 0
94#define XTYPE_XBOX360 1 93#define XTYPE_XBOX360 1
@@ -99,57 +98,61 @@ static int dpad_to_buttons;
99module_param(dpad_to_buttons, bool, S_IRUGO); 98module_param(dpad_to_buttons, bool, S_IRUGO);
100MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads"); 99MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
101 100
101static int triggers_to_buttons;
102module_param(triggers_to_buttons, bool, S_IRUGO);
103MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes for unknown pads");
104
102static const struct xpad_device { 105static const struct xpad_device {
103 u16 idVendor; 106 u16 idVendor;
104 u16 idProduct; 107 u16 idProduct;
105 char *name; 108 char *name;
106 u8 dpad_mapping; 109 u8 mapping;
107 u8 xtype; 110 u8 xtype;
108} xpad_device[] = { 111} xpad_device[] = {
109 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 112 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
110 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 113 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
111 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 114 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
112 { 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 115 { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
113 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 116 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
114 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 117 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
115 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 118 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
116 { 0x046d, 0xc242, "Logitech Chillstream Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 119 { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
117 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 120 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
118 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 121 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
119 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 122 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
120 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 123 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
121 { 0x0738, 0x4516, "Mad Catz Control Pad", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 124 { 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX },
122 { 0x0738, 0x4522, "Mad Catz LumiCON", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 125 { 0x0738, 0x4522, "Mad Catz LumiCON", 0, XTYPE_XBOX },
123 { 0x0738, 0x4526, "Mad Catz Control Pad Pro", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 126 { 0x0738, 0x4526, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX },
124 { 0x0738, 0x4536, "Mad Catz MicroCON", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 127 { 0x0738, 0x4536, "Mad Catz MicroCON", 0, XTYPE_XBOX },
125 { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 128 { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
126 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 129 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX },
127 { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 130 { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
128 { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 131 { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
129 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 132 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
130 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 133 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
131 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 134 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
132 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 135 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
133 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 136 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
134 { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 137 { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX },
135 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 138 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX },
136 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 139 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX },
137 { 0x0e6f, 0x0005, "Eclipse wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 140 { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX },
138 { 0x0e6f, 0x0006, "Edge wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 141 { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
139 { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 142 { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
140 { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 143 { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX },
141 { 0x0f30, 0x0202, "Joytech Advanced Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 144 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
142 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 145 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
143 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 146 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
144 { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 147 { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
145 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 148 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
146 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 149 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
147 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 150 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
148 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 151 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
149 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 152 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
150 { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 153 { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
151 { 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 154 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
152 { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN, XTYPE_UNKNOWN } 155 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
153}; 156};
154 157
155/* buttons shared with xbox and xbox360 */ 158/* buttons shared with xbox and xbox360 */
@@ -165,13 +168,20 @@ static const signed short xpad_btn[] = {
165 -1 /* terminating entry */ 168 -1 /* terminating entry */
166}; 169};
167 170
168/* only used if MAP_DPAD_TO_BUTTONS */ 171/* used when dpad is mapped to nuttons */
169static const signed short xpad_btn_pad[] = { 172static const signed short xpad_btn_pad[] = {
170 BTN_LEFT, BTN_RIGHT, /* d-pad left, right */ 173 BTN_LEFT, BTN_RIGHT, /* d-pad left, right */
171 BTN_0, BTN_1, /* d-pad up, down (XXX names??) */ 174 BTN_0, BTN_1, /* d-pad up, down (XXX names??) */
172 -1 /* terminating entry */ 175 -1 /* terminating entry */
173}; 176};
174 177
178/* used when triggers are mapped to buttons */
179static const signed short xpad_btn_triggers[] = {
180 BTN_TL2, BTN_TR2, /* triggers left/right */
181 -1
182};
183
184
175static const signed short xpad360_btn[] = { /* buttons for x360 controller */ 185static const signed short xpad360_btn[] = { /* buttons for x360 controller */
176 BTN_TL, BTN_TR, /* Button LB/RB */ 186 BTN_TL, BTN_TR, /* Button LB/RB */
177 BTN_MODE, /* The big X button */ 187 BTN_MODE, /* The big X button */
@@ -181,16 +191,21 @@ static const signed short xpad360_btn[] = { /* buttons for x360 controller */
181static const signed short xpad_abs[] = { 191static const signed short xpad_abs[] = {
182 ABS_X, ABS_Y, /* left stick */ 192 ABS_X, ABS_Y, /* left stick */
183 ABS_RX, ABS_RY, /* right stick */ 193 ABS_RX, ABS_RY, /* right stick */
184 ABS_Z, ABS_RZ, /* triggers left/right */
185 -1 /* terminating entry */ 194 -1 /* terminating entry */
186}; 195};
187 196
188/* only used if MAP_DPAD_TO_AXES */ 197/* used when dpad is mapped to axes */
189static const signed short xpad_abs_pad[] = { 198static const signed short xpad_abs_pad[] = {
190 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */ 199 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
191 -1 /* terminating entry */ 200 -1 /* terminating entry */
192}; 201};
193 202
203/* used when triggers are mapped to axes */
204static const signed short xpad_abs_triggers[] = {
205 ABS_Z, ABS_RZ, /* triggers left/right */
206 -1
207};
208
194/* Xbox 360 has a vendor-specific class, so we cannot match it with only 209/* Xbox 360 has a vendor-specific class, so we cannot match it with only
195 * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we 210 * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we
196 * match against vendor id as well. Wired Xbox 360 devices have protocol 1, 211 * match against vendor id as well. Wired Xbox 360 devices have protocol 1,
@@ -246,7 +261,7 @@ struct usb_xpad {
246 261
247 char phys[64]; /* physical device path */ 262 char phys[64]; /* physical device path */
248 263
249 int dpad_mapping; /* map d-pad to buttons or to axes */ 264 int mapping; /* map d-pad to buttons or to axes */
250 int xtype; /* type of xbox device */ 265 int xtype; /* type of xbox device */
251}; 266};
252 267
@@ -277,20 +292,25 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
277 ~(__s16) le16_to_cpup((__le16 *)(data + 18))); 292 ~(__s16) le16_to_cpup((__le16 *)(data + 18)));
278 293
279 /* triggers left/right */ 294 /* triggers left/right */
280 input_report_abs(dev, ABS_Z, data[10]); 295 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
281 input_report_abs(dev, ABS_RZ, data[11]); 296 input_report_key(dev, BTN_TL2, data[10]);
297 input_report_key(dev, BTN_TR2, data[11]);
298 } else {
299 input_report_abs(dev, ABS_Z, data[10]);
300 input_report_abs(dev, ABS_RZ, data[11]);
301 }
282 302
283 /* digital pad */ 303 /* digital pad */
284 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) { 304 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
285 input_report_abs(dev, ABS_HAT0X,
286 !!(data[2] & 0x08) - !!(data[2] & 0x04));
287 input_report_abs(dev, ABS_HAT0Y,
288 !!(data[2] & 0x02) - !!(data[2] & 0x01));
289 } else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ {
290 input_report_key(dev, BTN_LEFT, data[2] & 0x04); 305 input_report_key(dev, BTN_LEFT, data[2] & 0x04);
291 input_report_key(dev, BTN_RIGHT, data[2] & 0x08); 306 input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
292 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ 307 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */
293 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ 308 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */
309 } else {
310 input_report_abs(dev, ABS_HAT0X,
311 !!(data[2] & 0x08) - !!(data[2] & 0x04));
312 input_report_abs(dev, ABS_HAT0Y,
313 !!(data[2] & 0x02) - !!(data[2] & 0x01));
294 } 314 }
295 315
296 /* start/back buttons and stick press left/right */ 316 /* start/back buttons and stick press left/right */
@@ -328,17 +348,17 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
328 struct input_dev *dev = xpad->dev; 348 struct input_dev *dev = xpad->dev;
329 349
330 /* digital pad */ 350 /* digital pad */
331 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) { 351 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
332 input_report_abs(dev, ABS_HAT0X,
333 !!(data[2] & 0x08) - !!(data[2] & 0x04));
334 input_report_abs(dev, ABS_HAT0Y,
335 !!(data[2] & 0x02) - !!(data[2] & 0x01));
336 } else if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS) {
337 /* dpad as buttons (right, left, down, up) */ 352 /* dpad as buttons (right, left, down, up) */
338 input_report_key(dev, BTN_LEFT, data[2] & 0x04); 353 input_report_key(dev, BTN_LEFT, data[2] & 0x04);
339 input_report_key(dev, BTN_RIGHT, data[2] & 0x08); 354 input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
340 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ 355 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */
341 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ 356 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */
357 } else {
358 input_report_abs(dev, ABS_HAT0X,
359 !!(data[2] & 0x08) - !!(data[2] & 0x04));
360 input_report_abs(dev, ABS_HAT0Y,
361 !!(data[2] & 0x02) - !!(data[2] & 0x01));
342 } 362 }
343 363
344 /* start/back buttons */ 364 /* start/back buttons */
@@ -371,8 +391,13 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
371 ~(__s16) le16_to_cpup((__le16 *)(data + 12))); 391 ~(__s16) le16_to_cpup((__le16 *)(data + 12)));
372 392
373 /* triggers left/right */ 393 /* triggers left/right */
374 input_report_abs(dev, ABS_Z, data[4]); 394 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
375 input_report_abs(dev, ABS_RZ, data[5]); 395 input_report_key(dev, BTN_TL2, data[4]);
396 input_report_key(dev, BTN_TR2, data[5]);
397 } else {
398 input_report_abs(dev, ABS_Z, data[4]);
399 input_report_abs(dev, ABS_RZ, data[5]);
400 }
376 401
377 input_sync(dev); 402 input_sync(dev);
378} 403}
@@ -505,7 +530,7 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
505 struct usb_endpoint_descriptor *ep_irq_out; 530 struct usb_endpoint_descriptor *ep_irq_out;
506 int error = -ENOMEM; 531 int error = -ENOMEM;
507 532
508 if (xpad->xtype != XTYPE_XBOX360) 533 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX)
509 return 0; 534 return 0;
510 535
511 xpad->odata = usb_buffer_alloc(xpad->udev, XPAD_PKT_LEN, 536 xpad->odata = usb_buffer_alloc(xpad->udev, XPAD_PKT_LEN,
@@ -535,13 +560,13 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
535 560
536static void xpad_stop_output(struct usb_xpad *xpad) 561static void xpad_stop_output(struct usb_xpad *xpad)
537{ 562{
538 if (xpad->xtype == XTYPE_XBOX360) 563 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX)
539 usb_kill_urb(xpad->irq_out); 564 usb_kill_urb(xpad->irq_out);
540} 565}
541 566
542static void xpad_deinit_output(struct usb_xpad *xpad) 567static void xpad_deinit_output(struct usb_xpad *xpad)
543{ 568{
544 if (xpad->xtype == XTYPE_XBOX360) { 569 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX) {
545 usb_free_urb(xpad->irq_out); 570 usb_free_urb(xpad->irq_out);
546 usb_buffer_free(xpad->udev, XPAD_PKT_LEN, 571 usb_buffer_free(xpad->udev, XPAD_PKT_LEN,
547 xpad->odata, xpad->odata_dma); 572 xpad->odata, xpad->odata_dma);
@@ -554,24 +579,45 @@ static void xpad_stop_output(struct usb_xpad *xpad) {}
554#endif 579#endif
555 580
556#ifdef CONFIG_JOYSTICK_XPAD_FF 581#ifdef CONFIG_JOYSTICK_XPAD_FF
557static int xpad_play_effect(struct input_dev *dev, void *data, 582static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect)
558 struct ff_effect *effect)
559{ 583{
560 struct usb_xpad *xpad = input_get_drvdata(dev); 584 struct usb_xpad *xpad = input_get_drvdata(dev);
561 585
562 if (effect->type == FF_RUMBLE) { 586 if (effect->type == FF_RUMBLE) {
563 __u16 strong = effect->u.rumble.strong_magnitude; 587 __u16 strong = effect->u.rumble.strong_magnitude;
564 __u16 weak = effect->u.rumble.weak_magnitude; 588 __u16 weak = effect->u.rumble.weak_magnitude;
565 xpad->odata[0] = 0x00; 589
566 xpad->odata[1] = 0x08; 590 switch (xpad->xtype) {
567 xpad->odata[2] = 0x00; 591
568 xpad->odata[3] = strong / 256; 592 case XTYPE_XBOX:
569 xpad->odata[4] = weak / 256; 593 xpad->odata[0] = 0x00;
570 xpad->odata[5] = 0x00; 594 xpad->odata[1] = 0x06;
571 xpad->odata[6] = 0x00; 595 xpad->odata[2] = 0x00;
572 xpad->odata[7] = 0x00; 596 xpad->odata[3] = strong / 256; /* left actuator */
573 xpad->irq_out->transfer_buffer_length = 8; 597 xpad->odata[4] = 0x00;
574 usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 598 xpad->odata[5] = weak / 256; /* right actuator */
599 xpad->irq_out->transfer_buffer_length = 6;
600
601 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
602
603 case XTYPE_XBOX360:
604 xpad->odata[0] = 0x00;
605 xpad->odata[1] = 0x08;
606 xpad->odata[2] = 0x00;
607 xpad->odata[3] = strong / 256; /* left actuator? */
608 xpad->odata[4] = weak / 256; /* right actuator? */
609 xpad->odata[5] = 0x00;
610 xpad->odata[6] = 0x00;
611 xpad->odata[7] = 0x00;
612 xpad->irq_out->transfer_buffer_length = 8;
613
614 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
615
616 default:
617 dbg("%s - rumble command sent to unsupported xpad type: %d",
618 __func__, xpad->xtype);
619 return -1;
620 }
575 } 621 }
576 622
577 return 0; 623 return 0;
@@ -579,7 +625,7 @@ static int xpad_play_effect(struct input_dev *dev, void *data,
579 625
580static int xpad_init_ff(struct usb_xpad *xpad) 626static int xpad_init_ff(struct usb_xpad *xpad)
581{ 627{
582 if (xpad->xtype != XTYPE_XBOX360) 628 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX)
583 return 0; 629 return 0;
584 630
585 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); 631 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE);
@@ -712,11 +758,11 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
712 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); 758 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128);
713 break; 759 break;
714 case ABS_Z: 760 case ABS_Z:
715 case ABS_RZ: /* the triggers */ 761 case ABS_RZ: /* the triggers (if mapped to axes) */
716 input_set_abs_params(input_dev, abs, 0, 255, 0, 0); 762 input_set_abs_params(input_dev, abs, 0, 255, 0, 0);
717 break; 763 break;
718 case ABS_HAT0X: 764 case ABS_HAT0X:
719 case ABS_HAT0Y: /* the d-pad (only if MAP_DPAD_TO_AXES) */ 765 case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
720 input_set_abs_params(input_dev, abs, -1, 1, 0, 0); 766 input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
721 break; 767 break;
722 } 768 }
@@ -752,10 +798,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
752 goto fail2; 798 goto fail2;
753 799
754 xpad->udev = udev; 800 xpad->udev = udev;
755 xpad->dpad_mapping = xpad_device[i].dpad_mapping; 801 xpad->mapping = xpad_device[i].mapping;
756 xpad->xtype = xpad_device[i].xtype; 802 xpad->xtype = xpad_device[i].xtype;
757 if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN) 803
758 xpad->dpad_mapping = !dpad_to_buttons;
759 if (xpad->xtype == XTYPE_UNKNOWN) { 804 if (xpad->xtype == XTYPE_UNKNOWN) {
760 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { 805 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
761 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) 806 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)
@@ -764,7 +809,13 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
764 xpad->xtype = XTYPE_XBOX360; 809 xpad->xtype = XTYPE_XBOX360;
765 } else 810 } else
766 xpad->xtype = XTYPE_XBOX; 811 xpad->xtype = XTYPE_XBOX;
812
813 if (dpad_to_buttons)
814 xpad->mapping |= MAP_DPAD_TO_BUTTONS;
815 if (triggers_to_buttons)
816 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS;
767 } 817 }
818
768 xpad->dev = input_dev; 819 xpad->dev = input_dev;
769 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); 820 usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
770 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); 821 strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
@@ -781,25 +832,37 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
781 832
782 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 833 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
783 834
784 /* set up buttons */ 835 /* set up standard buttons and axes */
785 for (i = 0; xpad_common_btn[i] >= 0; i++) 836 for (i = 0; xpad_common_btn[i] >= 0; i++)
786 set_bit(xpad_common_btn[i], input_dev->keybit); 837 __set_bit(xpad_common_btn[i], input_dev->keybit);
787 if ((xpad->xtype == XTYPE_XBOX360) || (xpad->xtype == XTYPE_XBOX360W))
788 for (i = 0; xpad360_btn[i] >= 0; i++)
789 set_bit(xpad360_btn[i], input_dev->keybit);
790 else
791 for (i = 0; xpad_btn[i] >= 0; i++)
792 set_bit(xpad_btn[i], input_dev->keybit);
793 if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS)
794 for (i = 0; xpad_btn_pad[i] >= 0; i++)
795 set_bit(xpad_btn_pad[i], input_dev->keybit);
796 838
797 /* set up axes */
798 for (i = 0; xpad_abs[i] >= 0; i++) 839 for (i = 0; xpad_abs[i] >= 0; i++)
799 xpad_set_up_abs(input_dev, xpad_abs[i]); 840 xpad_set_up_abs(input_dev, xpad_abs[i]);
800 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) 841
842 /* Now set up model-specific ones */
843 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {
844 for (i = 0; xpad360_btn[i] >= 0; i++)
845 __set_bit(xpad360_btn[i], input_dev->keybit);
846 } else {
847 for (i = 0; xpad_btn[i] >= 0; i++)
848 __set_bit(xpad_btn[i], input_dev->keybit);
849 }
850
851 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
852 for (i = 0; xpad_btn_pad[i] >= 0; i++)
853 __set_bit(xpad_btn_pad[i], input_dev->keybit);
854 } else {
801 for (i = 0; xpad_abs_pad[i] >= 0; i++) 855 for (i = 0; xpad_abs_pad[i] >= 0; i++)
802 xpad_set_up_abs(input_dev, xpad_abs_pad[i]); 856 xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
857 }
858
859 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
860 for (i = 0; xpad_btn_triggers[i] >= 0; i++)
861 __set_bit(xpad_btn_triggers[i], input_dev->keybit);
862 } else {
863 for (i = 0; xpad_abs_triggers[i] >= 0; i++)
864 xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
865 }
803 866
804 error = xpad_init_output(intf, xpad); 867 error = xpad_init_output(intf, xpad);
805 if (error) 868 if (error)
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 02c836e11813..64c102355f53 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -35,10 +35,10 @@ config KEYBOARD_ADP5520
35 be called adp5520-keys. 35 be called adp5520-keys.
36 36
37config KEYBOARD_ADP5588 37config KEYBOARD_ADP5588
38 tristate "ADP5588 I2C QWERTY Keypad and IO Expander" 38 tristate "ADP5588/87 I2C QWERTY Keypad and IO Expander"
39 depends on I2C 39 depends on I2C
40 help 40 help
41 Say Y here if you want to use a ADP5588 attached to your 41 Say Y here if you want to use a ADP5588/87 attached to your
42 system I2C bus. 42 system I2C bus.
43 43
44 To compile this driver as a module, choose M here: the 44 To compile this driver as a module, choose M here: the
@@ -144,13 +144,15 @@ config KEYBOARD_BFIN
144 module will be called bf54x-keys. 144 module will be called bf54x-keys.
145 145
146config KEYBOARD_CORGI 146config KEYBOARD_CORGI
147 tristate "Corgi keyboard" 147 tristate "Corgi keyboard (deprecated)"
148 depends on PXA_SHARPSL 148 depends on PXA_SHARPSL
149 default y
150 help 149 help
151 Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx 150 Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx
152 series of PDAs. 151 series of PDAs.
153 152
153 This driver is now deprecated, use generic GPIO based matrix
154 keyboard driver instead.
155
154 To compile this driver as a module, choose M here: the 156 To compile this driver as a module, choose M here: the
155 module will be called corgikbd. 157 module will be called corgikbd.
156 158
@@ -292,6 +294,15 @@ config KEYBOARD_MAX7359
292 To compile this driver as a module, choose M here: the 294 To compile this driver as a module, choose M here: the
293 module will be called max7359_keypad. 295 module will be called max7359_keypad.
294 296
297config KEYBOARD_IMX
298 tristate "IMX keypad support"
299 depends on ARCH_MXC
300 help
301 Enable support for IMX keypad port.
302
303 To compile this driver as a module, choose M here: the
304 module will be called imx_keypad.
305
295config KEYBOARD_NEWTON 306config KEYBOARD_NEWTON
296 tristate "Newton keyboard" 307 tristate "Newton keyboard"
297 select SERIO 308 select SERIO
@@ -329,13 +340,15 @@ config KEYBOARD_PXA930_ROTARY
329 module will be called pxa930_rotary. 340 module will be called pxa930_rotary.
330 341
331config KEYBOARD_SPITZ 342config KEYBOARD_SPITZ
332 tristate "Spitz keyboard" 343 tristate "Spitz keyboard (deprecated)"
333 depends on PXA_SHARPSL 344 depends on PXA_SHARPSL
334 default y
335 help 345 help
336 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000, 346 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000,
337 SL-C3000 and Sl-C3100 series of PDAs. 347 SL-C3000 and Sl-C3100 series of PDAs.
338 348
349 This driver is now deprecated, use generic GPIO based matrix
350 keyboard driver instead.
351
339 To compile this driver as a module, choose M here: the 352 To compile this driver as a module, choose M here: the
340 module will be called spitzkbd. 353 module will be called spitzkbd.
341 354
@@ -363,7 +376,7 @@ config KEYBOARD_SUNKBD
363 376
364config KEYBOARD_SH_KEYSC 377config KEYBOARD_SH_KEYSC
365 tristate "SuperH KEYSC keypad support" 378 tristate "SuperH KEYSC keypad support"
366 depends on SUPERH 379 depends on SUPERH || ARCH_SHMOBILE
367 help 380 help
368 Say Y here if you want to use a keypad attached to the KEYSC block 381 Say Y here if you want to use a keypad attached to the KEYSC block
369 on SuperH processors such as sh7722 and sh7343. 382 on SuperH processors such as sh7722 and sh7343.
@@ -402,12 +415,14 @@ config KEYBOARD_TWL4030
402 module will be called twl4030_keypad. 415 module will be called twl4030_keypad.
403 416
404config KEYBOARD_TOSA 417config KEYBOARD_TOSA
405 tristate "Tosa keyboard" 418 tristate "Tosa keyboard (deprecated)"
406 depends on MACH_TOSA 419 depends on MACH_TOSA
407 default y
408 help 420 help
409 Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa) 421 Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
410 422
423 This driver is now deprecated, use generic GPIO based matrix
424 keyboard driver instead.
425
411 To compile this driver as a module, choose M here: the 426 To compile this driver as a module, choose M here: the
412 module will be called tosakbd. 427 module will be called tosakbd.
413 428
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 78654ef65206..706c6b5ed5f4 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o
17obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o 17obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
18obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 18obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
19obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 19obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
20obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o
20obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o 21obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o
21obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o 22obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
22obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o 23obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index 1edb596d927b..b5142d2d5112 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * File: drivers/input/keyboard/adp5588_keys.c 2 * File: drivers/input/keyboard/adp5588_keys.c
3 * Description: keypad driver for ADP5588 I2C QWERTY Keypad and IO Expander 3 * Description: keypad driver for ADP5588 and ADP5587
4 * I2C QWERTY Keypad and IO Expander
4 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 5 * Bugs: Enter bugs at http://blackfin.uclinux.org/
5 * 6 *
6 * Copyright (C) 2008-2009 Analog Devices Inc. 7 * Copyright (C) 2008-2009 Analog Devices Inc.
@@ -327,6 +328,7 @@ static const struct dev_pm_ops adp5588_dev_pm_ops = {
327 328
328static const struct i2c_device_id adp5588_id[] = { 329static const struct i2c_device_id adp5588_id[] = {
329 { KBUILD_MODNAME, 0 }, 330 { KBUILD_MODNAME, 0 },
331 { "adp5587-keys", 0 },
330 { } 332 { }
331}; 333};
332MODULE_DEVICE_TABLE(i2c, adp5588_id); 334MODULE_DEVICE_TABLE(i2c, adp5588_id);
@@ -357,5 +359,5 @@ module_exit(adp5588_exit);
357 359
358MODULE_LICENSE("GPL"); 360MODULE_LICENSE("GPL");
359MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 361MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
360MODULE_DESCRIPTION("ADP5588 Keypad driver"); 362MODULE_DESCRIPTION("ADP5588/87 Keypad driver");
361MODULE_ALIAS("platform:adp5588-keys"); 363MODULE_ALIAS("platform:adp5588-keys");
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 7b4056292eaf..d358ef8623f4 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -40,26 +40,26 @@ module_param_named(set, atkbd_set, int, 0);
40MODULE_PARM_DESC(set, "Select keyboard code set (2 = default, 3 = PS/2 native)"); 40MODULE_PARM_DESC(set, "Select keyboard code set (2 = default, 3 = PS/2 native)");
41 41
42#if defined(__i386__) || defined(__x86_64__) || defined(__hppa__) 42#if defined(__i386__) || defined(__x86_64__) || defined(__hppa__)
43static int atkbd_reset; 43static bool atkbd_reset;
44#else 44#else
45static int atkbd_reset = 1; 45static bool atkbd_reset = true;
46#endif 46#endif
47module_param_named(reset, atkbd_reset, bool, 0); 47module_param_named(reset, atkbd_reset, bool, 0);
48MODULE_PARM_DESC(reset, "Reset keyboard during initialization"); 48MODULE_PARM_DESC(reset, "Reset keyboard during initialization");
49 49
50static int atkbd_softrepeat; 50static bool atkbd_softrepeat;
51module_param_named(softrepeat, atkbd_softrepeat, bool, 0); 51module_param_named(softrepeat, atkbd_softrepeat, bool, 0);
52MODULE_PARM_DESC(softrepeat, "Use software keyboard repeat"); 52MODULE_PARM_DESC(softrepeat, "Use software keyboard repeat");
53 53
54static int atkbd_softraw = 1; 54static bool atkbd_softraw = true;
55module_param_named(softraw, atkbd_softraw, bool, 0); 55module_param_named(softraw, atkbd_softraw, bool, 0);
56MODULE_PARM_DESC(softraw, "Use software generated rawmode"); 56MODULE_PARM_DESC(softraw, "Use software generated rawmode");
57 57
58static int atkbd_scroll; 58static bool atkbd_scroll;
59module_param_named(scroll, atkbd_scroll, bool, 0); 59module_param_named(scroll, atkbd_scroll, bool, 0);
60MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); 60MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards");
61 61
62static int atkbd_extra; 62static bool atkbd_extra;
63module_param_named(extra, atkbd_extra, bool, 0); 63module_param_named(extra, atkbd_extra, bool, 0);
64MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards"); 64MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards");
65 65
@@ -153,16 +153,16 @@ static const unsigned short atkbd_unxlate_table[128] = {
153#define ATKBD_RET_HANGEUL 0xf2 153#define ATKBD_RET_HANGEUL 0xf2
154#define ATKBD_RET_ERR 0xff 154#define ATKBD_RET_ERR 0xff
155 155
156#define ATKBD_KEY_UNKNOWN 0 156#define ATKBD_KEY_UNKNOWN 0
157#define ATKBD_KEY_NULL 255 157#define ATKBD_KEY_NULL 255
158 158
159#define ATKBD_SCR_1 254 159#define ATKBD_SCR_1 0xfffe
160#define ATKBD_SCR_2 253 160#define ATKBD_SCR_2 0xfffd
161#define ATKBD_SCR_4 252 161#define ATKBD_SCR_4 0xfffc
162#define ATKBD_SCR_8 251 162#define ATKBD_SCR_8 0xfffb
163#define ATKBD_SCR_CLICK 250 163#define ATKBD_SCR_CLICK 0xfffa
164#define ATKBD_SCR_LEFT 249 164#define ATKBD_SCR_LEFT 0xfff9
165#define ATKBD_SCR_RIGHT 248 165#define ATKBD_SCR_RIGHT 0xfff8
166 166
167#define ATKBD_SPECIAL ATKBD_SCR_RIGHT 167#define ATKBD_SPECIAL ATKBD_SCR_RIGHT
168 168
@@ -177,7 +177,7 @@ static const unsigned short atkbd_unxlate_table[128] = {
177#define ATKBD_XL_HANJA 0x20 177#define ATKBD_XL_HANJA 0x20
178 178
179static const struct { 179static const struct {
180 unsigned char keycode; 180 unsigned short keycode;
181 unsigned char set2; 181 unsigned char set2;
182} atkbd_scroll_keys[] = { 182} atkbd_scroll_keys[] = {
183 { ATKBD_SCR_1, 0xc5 }, 183 { ATKBD_SCR_1, 0xc5 },
@@ -206,18 +206,18 @@ struct atkbd {
206 unsigned short keycode[ATKBD_KEYMAP_SIZE]; 206 unsigned short keycode[ATKBD_KEYMAP_SIZE];
207 DECLARE_BITMAP(force_release_mask, ATKBD_KEYMAP_SIZE); 207 DECLARE_BITMAP(force_release_mask, ATKBD_KEYMAP_SIZE);
208 unsigned char set; 208 unsigned char set;
209 unsigned char translated; 209 bool translated;
210 unsigned char extra; 210 bool extra;
211 unsigned char write; 211 bool write;
212 unsigned char softrepeat; 212 bool softrepeat;
213 unsigned char softraw; 213 bool softraw;
214 unsigned char scroll; 214 bool scroll;
215 unsigned char enabled; 215 bool enabled;
216 216
217 /* Accessed only from interrupt */ 217 /* Accessed only from interrupt */
218 unsigned char emul; 218 unsigned char emul;
219 unsigned char resend; 219 bool resend;
220 unsigned char release; 220 bool release;
221 unsigned long xl_bit; 221 unsigned long xl_bit;
222 unsigned int last; 222 unsigned int last;
223 unsigned long time; 223 unsigned long time;
@@ -301,18 +301,18 @@ static const unsigned int xl_table[] = {
301 * Checks if we should mangle the scancode to extract 'release' bit 301 * Checks if we should mangle the scancode to extract 'release' bit
302 * in translated mode. 302 * in translated mode.
303 */ 303 */
304static int atkbd_need_xlate(unsigned long xl_bit, unsigned char code) 304static bool atkbd_need_xlate(unsigned long xl_bit, unsigned char code)
305{ 305{
306 int i; 306 int i;
307 307
308 if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1) 308 if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1)
309 return 0; 309 return false;
310 310
311 for (i = 0; i < ARRAY_SIZE(xl_table); i++) 311 for (i = 0; i < ARRAY_SIZE(xl_table); i++)
312 if (code == xl_table[i]) 312 if (code == xl_table[i])
313 return test_bit(i, &xl_bit); 313 return test_bit(i, &xl_bit);
314 314
315 return 1; 315 return true;
316} 316}
317 317
318/* 318/*
@@ -359,7 +359,7 @@ static unsigned int atkbd_compat_scancode(struct atkbd *atkbd, unsigned int code
359 */ 359 */
360 360
361static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, 361static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
362 unsigned int flags) 362 unsigned int flags)
363{ 363{
364 struct atkbd *atkbd = serio_get_drvdata(serio); 364 struct atkbd *atkbd = serio_get_drvdata(serio);
365 struct input_dev *dev = atkbd->dev; 365 struct input_dev *dev = atkbd->dev;
@@ -368,20 +368,18 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
368 int value; 368 int value;
369 unsigned short keycode; 369 unsigned short keycode;
370 370
371#ifdef ATKBD_DEBUG 371 dev_dbg(&serio->dev, "Received %02x flags %02x\n", data, flags);
372 printk(KERN_DEBUG "atkbd.c: Received %02x flags %02x\n", data, flags);
373#endif
374 372
375#if !defined(__i386__) && !defined (__x86_64__) 373#if !defined(__i386__) && !defined (__x86_64__)
376 if ((flags & (SERIO_FRAME | SERIO_PARITY)) && (~flags & SERIO_TIMEOUT) && !atkbd->resend && atkbd->write) { 374 if ((flags & (SERIO_FRAME | SERIO_PARITY)) && (~flags & SERIO_TIMEOUT) && !atkbd->resend && atkbd->write) {
377 printk(KERN_WARNING "atkbd.c: frame/parity error: %02x\n", flags); 375 dev_warn(&serio->dev, "Frame/parity error: %02x\n", flags);
378 serio_write(serio, ATKBD_CMD_RESEND); 376 serio_write(serio, ATKBD_CMD_RESEND);
379 atkbd->resend = 1; 377 atkbd->resend = true;
380 goto out; 378 goto out;
381 } 379 }
382 380
383 if (!flags && data == ATKBD_RET_ACK) 381 if (!flags && data == ATKBD_RET_ACK)
384 atkbd->resend = 0; 382 atkbd->resend = false;
385#endif 383#endif
386 384
387 if (unlikely(atkbd->ps2dev.flags & PS2_FLAG_ACK)) 385 if (unlikely(atkbd->ps2dev.flags & PS2_FLAG_ACK))
@@ -412,32 +410,32 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
412 } 410 }
413 411
414 switch (code) { 412 switch (code) {
415 case ATKBD_RET_BAT: 413 case ATKBD_RET_BAT:
416 atkbd->enabled = 0; 414 atkbd->enabled = false;
417 serio_reconnect(atkbd->ps2dev.serio); 415 serio_reconnect(atkbd->ps2dev.serio);
418 goto out; 416 goto out;
419 case ATKBD_RET_EMUL0: 417 case ATKBD_RET_EMUL0:
420 atkbd->emul = 1; 418 atkbd->emul = 1;
421 goto out; 419 goto out;
422 case ATKBD_RET_EMUL1: 420 case ATKBD_RET_EMUL1:
423 atkbd->emul = 2; 421 atkbd->emul = 2;
424 goto out; 422 goto out;
425 case ATKBD_RET_RELEASE: 423 case ATKBD_RET_RELEASE:
426 atkbd->release = 1; 424 atkbd->release = true;
427 goto out; 425 goto out;
428 case ATKBD_RET_ACK: 426 case ATKBD_RET_ACK:
429 case ATKBD_RET_NAK: 427 case ATKBD_RET_NAK:
430 if (printk_ratelimit()) 428 if (printk_ratelimit())
431 printk(KERN_WARNING "atkbd.c: Spurious %s on %s. " 429 dev_warn(&serio->dev,
432 "Some program might be trying access hardware directly.\n", 430 "Spurious %s on %s. "
433 data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); 431 "Some program might be trying access hardware directly.\n",
434 goto out; 432 data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys);
435 case ATKBD_RET_ERR: 433 goto out;
436 atkbd->err_count++; 434 case ATKBD_RET_ERR:
437#ifdef ATKBD_DEBUG 435 atkbd->err_count++;
438 printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); 436 dev_dbg(&serio->dev, "Keyboard on %s reports too many keys pressed.\n",
439#endif 437 serio->phys);
440 goto out; 438 goto out;
441 } 439 }
442 440
443 code = atkbd_compat_scancode(atkbd, code); 441 code = atkbd_compat_scancode(atkbd, code);
@@ -451,71 +449,72 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
451 input_event(dev, EV_MSC, MSC_SCAN, code); 449 input_event(dev, EV_MSC, MSC_SCAN, code);
452 450
453 switch (keycode) { 451 switch (keycode) {
454 case ATKBD_KEY_NULL: 452 case ATKBD_KEY_NULL:
455 break; 453 break;
456 case ATKBD_KEY_UNKNOWN: 454 case ATKBD_KEY_UNKNOWN:
457 printk(KERN_WARNING 455 dev_warn(&serio->dev,
458 "atkbd.c: Unknown key %s (%s set %d, code %#x on %s).\n", 456 "Unknown key %s (%s set %d, code %#x on %s).\n",
459 atkbd->release ? "released" : "pressed", 457 atkbd->release ? "released" : "pressed",
460 atkbd->translated ? "translated" : "raw", 458 atkbd->translated ? "translated" : "raw",
461 atkbd->set, code, serio->phys); 459 atkbd->set, code, serio->phys);
462 printk(KERN_WARNING 460 dev_warn(&serio->dev,
463 "atkbd.c: Use 'setkeycodes %s%02x <keycode>' to make it known.\n", 461 "Use 'setkeycodes %s%02x <keycode>' to make it known.\n",
464 code & 0x80 ? "e0" : "", code & 0x7f); 462 code & 0x80 ? "e0" : "", code & 0x7f);
465 input_sync(dev); 463 input_sync(dev);
466 break; 464 break;
467 case ATKBD_SCR_1: 465 case ATKBD_SCR_1:
468 scroll = 1 - atkbd->release * 2; 466 scroll = 1;
469 break; 467 break;
470 case ATKBD_SCR_2: 468 case ATKBD_SCR_2:
471 scroll = 2 - atkbd->release * 4; 469 scroll = 2;
472 break; 470 break;
473 case ATKBD_SCR_4: 471 case ATKBD_SCR_4:
474 scroll = 4 - atkbd->release * 8; 472 scroll = 4;
475 break; 473 break;
476 case ATKBD_SCR_8: 474 case ATKBD_SCR_8:
477 scroll = 8 - atkbd->release * 16; 475 scroll = 8;
478 break; 476 break;
479 case ATKBD_SCR_CLICK: 477 case ATKBD_SCR_CLICK:
480 click = !atkbd->release; 478 click = !atkbd->release;
481 break; 479 break;
482 case ATKBD_SCR_LEFT: 480 case ATKBD_SCR_LEFT:
483 hscroll = -1; 481 hscroll = -1;
484 break; 482 break;
485 case ATKBD_SCR_RIGHT: 483 case ATKBD_SCR_RIGHT:
486 hscroll = 1; 484 hscroll = 1;
487 break; 485 break;
488 default: 486 default:
489 if (atkbd->release) { 487 if (atkbd->release) {
490 value = 0; 488 value = 0;
491 atkbd->last = 0; 489 atkbd->last = 0;
492 } else if (!atkbd->softrepeat && test_bit(keycode, dev->key)) { 490 } else if (!atkbd->softrepeat && test_bit(keycode, dev->key)) {
493 /* Workaround Toshiba laptop multiple keypress */ 491 /* Workaround Toshiba laptop multiple keypress */
494 value = time_before(jiffies, atkbd->time) && atkbd->last == code ? 1 : 2; 492 value = time_before(jiffies, atkbd->time) && atkbd->last == code ? 1 : 2;
495 } else { 493 } else {
496 value = 1; 494 value = 1;
497 atkbd->last = code; 495 atkbd->last = code;
498 atkbd->time = jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]) / 2; 496 atkbd->time = jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]) / 2;
499 } 497 }
500 498
501 input_event(dev, EV_KEY, keycode, value); 499 input_event(dev, EV_KEY, keycode, value);
502 input_sync(dev); 500 input_sync(dev);
503 501
504 if (value && test_bit(code, atkbd->force_release_mask)) { 502 if (value && test_bit(code, atkbd->force_release_mask)) {
505 input_report_key(dev, keycode, 0); 503 input_report_key(dev, keycode, 0);
506 input_sync(dev); 504 input_sync(dev);
507 } 505 }
508 } 506 }
509 507
510 if (atkbd->scroll) { 508 if (atkbd->scroll) {
511 if (click != -1) 509 if (click != -1)
512 input_report_key(dev, BTN_MIDDLE, click); 510 input_report_key(dev, BTN_MIDDLE, click);
513 input_report_rel(dev, REL_WHEEL, scroll); 511 input_report_rel(dev, REL_WHEEL,
512 atkbd->release ? -scroll : scroll);
514 input_report_rel(dev, REL_HWHEEL, hscroll); 513 input_report_rel(dev, REL_HWHEEL, hscroll);
515 input_sync(dev); 514 input_sync(dev);
516 } 515 }
517 516
518 atkbd->release = 0; 517 atkbd->release = false;
519out: 518out:
520 return IRQ_HANDLED; 519 return IRQ_HANDLED;
521} 520}
@@ -634,17 +633,18 @@ static int atkbd_event(struct input_dev *dev,
634 633
635 switch (type) { 634 switch (type) {
636 635
637 case EV_LED: 636 case EV_LED:
638 atkbd_schedule_event_work(atkbd, ATKBD_LED_EVENT_BIT); 637 atkbd_schedule_event_work(atkbd, ATKBD_LED_EVENT_BIT);
639 return 0; 638 return 0;
640 639
641 case EV_REP: 640 case EV_REP:
642 if (!atkbd->softrepeat) 641 if (!atkbd->softrepeat)
643 atkbd_schedule_event_work(atkbd, ATKBD_REP_EVENT_BIT); 642 atkbd_schedule_event_work(atkbd, ATKBD_REP_EVENT_BIT);
644 return 0; 643 return 0;
645 }
646 644
647 return -1; 645 default:
646 return -1;
647 }
648} 648}
649 649
650/* 650/*
@@ -655,7 +655,7 @@ static int atkbd_event(struct input_dev *dev,
655static inline void atkbd_enable(struct atkbd *atkbd) 655static inline void atkbd_enable(struct atkbd *atkbd)
656{ 656{
657 serio_pause_rx(atkbd->ps2dev.serio); 657 serio_pause_rx(atkbd->ps2dev.serio);
658 atkbd->enabled = 1; 658 atkbd->enabled = true;
659 serio_continue_rx(atkbd->ps2dev.serio); 659 serio_continue_rx(atkbd->ps2dev.serio);
660} 660}
661 661
@@ -667,7 +667,7 @@ static inline void atkbd_enable(struct atkbd *atkbd)
667static inline void atkbd_disable(struct atkbd *atkbd) 667static inline void atkbd_disable(struct atkbd *atkbd)
668{ 668{
669 serio_pause_rx(atkbd->ps2dev.serio); 669 serio_pause_rx(atkbd->ps2dev.serio);
670 atkbd->enabled = 0; 670 atkbd->enabled = false;
671 serio_continue_rx(atkbd->ps2dev.serio); 671 serio_continue_rx(atkbd->ps2dev.serio);
672} 672}
673 673
@@ -688,7 +688,9 @@ static int atkbd_probe(struct atkbd *atkbd)
688 688
689 if (atkbd_reset) 689 if (atkbd_reset)
690 if (ps2_command(ps2dev, NULL, ATKBD_CMD_RESET_BAT)) 690 if (ps2_command(ps2dev, NULL, ATKBD_CMD_RESET_BAT))
691 printk(KERN_WARNING "atkbd.c: keyboard reset failed on %s\n", ps2dev->serio->phys); 691 dev_warn(&ps2dev->serio->dev,
692 "keyboard reset failed on %s\n",
693 ps2dev->serio->phys);
692 694
693/* 695/*
694 * Then we check the keyboard ID. We should get 0xab83 under normal conditions. 696 * Then we check the keyboard ID. We should get 0xab83 under normal conditions.
@@ -718,8 +720,9 @@ static int atkbd_probe(struct atkbd *atkbd)
718 atkbd->id = (param[0] << 8) | param[1]; 720 atkbd->id = (param[0] << 8) | param[1];
719 721
720 if (atkbd->id == 0xaca1 && atkbd->translated) { 722 if (atkbd->id == 0xaca1 && atkbd->translated) {
721 printk(KERN_ERR "atkbd.c: NCD terminal keyboards are only supported on non-translating\n"); 723 dev_err(&ps2dev->serio->dev,
722 printk(KERN_ERR "atkbd.c: controllers. Use i8042.direct=1 to disable translation.\n"); 724 "NCD terminal keyboards are only supported on non-translating controlelrs. "
725 "Use i8042.direct=1 to disable translation.\n");
723 return -1; 726 return -1;
724 } 727 }
725 728
@@ -737,7 +740,7 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra
737 struct ps2dev *ps2dev = &atkbd->ps2dev; 740 struct ps2dev *ps2dev = &atkbd->ps2dev;
738 unsigned char param[2]; 741 unsigned char param[2];
739 742
740 atkbd->extra = 0; 743 atkbd->extra = false;
741/* 744/*
742 * For known special keyboards we can go ahead and set the correct set. 745 * For known special keyboards we can go ahead and set the correct set.
743 * We check for NCD PS/2 Sun, NorthGate OmniKey 101 and 746 * We check for NCD PS/2 Sun, NorthGate OmniKey 101 and
@@ -756,7 +759,7 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra
756 if (allow_extra) { 759 if (allow_extra) {
757 param[0] = 0x71; 760 param[0] = 0x71;
758 if (!ps2_command(ps2dev, param, ATKBD_CMD_EX_ENABLE)) { 761 if (!ps2_command(ps2dev, param, ATKBD_CMD_EX_ENABLE)) {
759 atkbd->extra = 1; 762 atkbd->extra = true;
760 return 2; 763 return 2;
761 } 764 }
762 } 765 }
@@ -821,7 +824,8 @@ static int atkbd_activate(struct atkbd *atkbd)
821 */ 824 */
822 825
823 if (ps2_command(ps2dev, NULL, ATKBD_CMD_ENABLE)) { 826 if (ps2_command(ps2dev, NULL, ATKBD_CMD_ENABLE)) {
824 printk(KERN_ERR "atkbd.c: Failed to enable keyboard on %s\n", 827 dev_err(&ps2dev->serio->dev,
828 "Failed to enable keyboard on %s\n",
825 ps2dev->serio->phys); 829 ps2dev->serio->phys);
826 return -1; 830 return -1;
827 } 831 }
@@ -1070,9 +1074,13 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd)
1070 input_dev->keycodesize = sizeof(unsigned short); 1074 input_dev->keycodesize = sizeof(unsigned short);
1071 input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode); 1075 input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode);
1072 1076
1073 for (i = 0; i < ATKBD_KEYMAP_SIZE; i++) 1077 for (i = 0; i < ATKBD_KEYMAP_SIZE; i++) {
1074 if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL) 1078 if (atkbd->keycode[i] != KEY_RESERVED &&
1079 atkbd->keycode[i] != ATKBD_KEY_NULL &&
1080 atkbd->keycode[i] < ATKBD_SPECIAL) {
1075 __set_bit(atkbd->keycode[i], input_dev->keybit); 1081 __set_bit(atkbd->keycode[i], input_dev->keybit);
1082 }
1083 }
1076} 1084}
1077 1085
1078/* 1086/*
@@ -1100,12 +1108,14 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
1100 1108
1101 switch (serio->id.type) { 1109 switch (serio->id.type) {
1102 1110
1103 case SERIO_8042_XL: 1111 case SERIO_8042_XL:
1104 atkbd->translated = 1; 1112 atkbd->translated = true;
1105 case SERIO_8042: 1113 /* Fall through */
1106 if (serio->write) 1114
1107 atkbd->write = 1; 1115 case SERIO_8042:
1108 break; 1116 if (serio->write)
1117 atkbd->write = true;
1118 break;
1109 } 1119 }
1110 1120
1111 atkbd->softraw = atkbd_softraw; 1121 atkbd->softraw = atkbd_softraw;
@@ -1113,7 +1123,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
1113 atkbd->scroll = atkbd_scroll; 1123 atkbd->scroll = atkbd_scroll;
1114 1124
1115 if (atkbd->softrepeat) 1125 if (atkbd->softrepeat)
1116 atkbd->softraw = 1; 1126 atkbd->softraw = true;
1117 1127
1118 serio_set_drvdata(serio, atkbd); 1128 serio_set_drvdata(serio, atkbd);
1119 1129
@@ -1172,7 +1182,8 @@ static int atkbd_reconnect(struct serio *serio)
1172 int retval = -1; 1182 int retval = -1;
1173 1183
1174 if (!atkbd || !drv) { 1184 if (!atkbd || !drv) {
1175 printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n"); 1185 dev_dbg(&serio->dev,
1186 "reconnect request, but serio is disconnected, ignoring...\n");
1176 return -1; 1187 return -1;
1177 } 1188 }
1178 1189
@@ -1286,7 +1297,8 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
1286 struct input_dev *old_dev, *new_dev; 1297 struct input_dev *old_dev, *new_dev;
1287 unsigned long value; 1298 unsigned long value;
1288 int err; 1299 int err;
1289 unsigned char old_extra, old_set; 1300 bool old_extra;
1301 unsigned char old_set;
1290 1302
1291 if (!atkbd->write) 1303 if (!atkbd->write)
1292 return -EIO; 1304 return -EIO;
@@ -1369,7 +1381,7 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou
1369 struct input_dev *old_dev, *new_dev; 1381 struct input_dev *old_dev, *new_dev;
1370 unsigned long value; 1382 unsigned long value;
1371 int err; 1383 int err;
1372 unsigned char old_scroll; 1384 bool old_scroll;
1373 1385
1374 if (strict_strtoul(buf, 10, &value) || value > 1) 1386 if (strict_strtoul(buf, 10, &value) || value > 1)
1375 return -EINVAL; 1387 return -EINVAL;
@@ -1413,7 +1425,8 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
1413 struct input_dev *old_dev, *new_dev; 1425 struct input_dev *old_dev, *new_dev;
1414 unsigned long value; 1426 unsigned long value;
1415 int err; 1427 int err;
1416 unsigned char old_set, old_extra; 1428 unsigned char old_set;
1429 bool old_extra;
1417 1430
1418 if (!atkbd->write) 1431 if (!atkbd->write)
1419 return -EIO; 1432 return -EIO;
@@ -1463,7 +1476,7 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
1463 struct input_dev *old_dev, *new_dev; 1476 struct input_dev *old_dev, *new_dev;
1464 unsigned long value; 1477 unsigned long value;
1465 int err; 1478 int err;
1466 unsigned char old_softrepeat, old_softraw; 1479 bool old_softrepeat, old_softraw;
1467 1480
1468 if (!atkbd->write) 1481 if (!atkbd->write)
1469 return -EIO; 1482 return -EIO;
@@ -1483,7 +1496,7 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
1483 atkbd->dev = new_dev; 1496 atkbd->dev = new_dev;
1484 atkbd->softrepeat = value; 1497 atkbd->softrepeat = value;
1485 if (atkbd->softrepeat) 1498 if (atkbd->softrepeat)
1486 atkbd->softraw = 1; 1499 atkbd->softraw = true;
1487 atkbd_set_device_attrs(atkbd); 1500 atkbd_set_device_attrs(atkbd);
1488 1501
1489 err = input_register_device(atkbd->dev); 1502 err = input_register_device(atkbd->dev);
@@ -1513,7 +1526,7 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co
1513 struct input_dev *old_dev, *new_dev; 1526 struct input_dev *old_dev, *new_dev;
1514 unsigned long value; 1527 unsigned long value;
1515 int err; 1528 int err;
1516 unsigned char old_softraw; 1529 bool old_softraw;
1517 1530
1518 if (strict_strtoul(buf, 10, &value) || value > 1) 1531 if (strict_strtoul(buf, 10, &value) || value > 1)
1519 return -EINVAL; 1532 return -EINVAL;
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index e45740429f7e..bd25a3af1664 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -69,7 +69,7 @@ struct ep93xx_keypad {
69 69
70 void __iomem *mmio_base; 70 void __iomem *mmio_base;
71 71
72 unsigned int matrix_keycodes[EP93XX_MATRIX_SIZE]; 72 unsigned short keycodes[EP93XX_MATRIX_SIZE];
73 73
74 int key1; 74 int key1;
75 int key2; 75 int key2;
@@ -79,24 +79,6 @@ struct ep93xx_keypad {
79 bool enabled; 79 bool enabled;
80}; 80};
81 81
82static void ep93xx_keypad_build_keycode(struct ep93xx_keypad *keypad)
83{
84 struct ep93xx_keypad_platform_data *pdata = keypad->pdata;
85 struct input_dev *input_dev = keypad->input_dev;
86 unsigned int *key;
87 int i;
88
89 key = &pdata->matrix_key_map[0];
90 for (i = 0; i < pdata->matrix_key_map_size; i++, key++) {
91 int row = KEY_ROW(*key);
92 int col = KEY_COL(*key);
93 int code = KEY_VAL(*key);
94
95 keypad->matrix_keycodes[(row << 3) + col] = code;
96 __set_bit(code, input_dev->keybit);
97 }
98}
99
100static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id) 82static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id)
101{ 83{
102 struct ep93xx_keypad *keypad = dev_id; 84 struct ep93xx_keypad *keypad = dev_id;
@@ -107,10 +89,10 @@ static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id)
107 status = __raw_readl(keypad->mmio_base + KEY_REG); 89 status = __raw_readl(keypad->mmio_base + KEY_REG);
108 90
109 keycode = (status & KEY_REG_KEY1_MASK) >> KEY_REG_KEY1_SHIFT; 91 keycode = (status & KEY_REG_KEY1_MASK) >> KEY_REG_KEY1_SHIFT;
110 key1 = keypad->matrix_keycodes[keycode]; 92 key1 = keypad->keycodes[keycode];
111 93
112 keycode = (status & KEY_REG_KEY2_MASK) >> KEY_REG_KEY2_SHIFT; 94 keycode = (status & KEY_REG_KEY2_MASK) >> KEY_REG_KEY2_SHIFT;
113 key2 = keypad->matrix_keycodes[keycode]; 95 key2 = keypad->keycodes[keycode];
114 96
115 if (status & KEY_REG_2KEYS) { 97 if (status & KEY_REG_2KEYS) {
116 if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1) 98 if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1)
@@ -256,6 +238,7 @@ static int ep93xx_keypad_resume(struct platform_device *pdev)
256static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) 238static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
257{ 239{
258 struct ep93xx_keypad *keypad; 240 struct ep93xx_keypad *keypad;
241 const struct matrix_keymap_data *keymap_data;
259 struct input_dev *input_dev; 242 struct input_dev *input_dev;
260 struct resource *res; 243 struct resource *res;
261 int err; 244 int err;
@@ -270,6 +253,12 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
270 goto failed_free; 253 goto failed_free;
271 } 254 }
272 255
256 keymap_data = keypad->pdata->keymap_data;
257 if (!keymap_data) {
258 err = -EINVAL;
259 goto failed_free;
260 }
261
273 keypad->irq = platform_get_irq(pdev, 0); 262 keypad->irq = platform_get_irq(pdev, 0);
274 if (!keypad->irq) { 263 if (!keypad->irq) {
275 err = -ENXIO; 264 err = -ENXIO;
@@ -317,9 +306,9 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
317 input_dev->open = ep93xx_keypad_open; 306 input_dev->open = ep93xx_keypad_open;
318 input_dev->close = ep93xx_keypad_close; 307 input_dev->close = ep93xx_keypad_close;
319 input_dev->dev.parent = &pdev->dev; 308 input_dev->dev.parent = &pdev->dev;
320 input_dev->keycode = keypad->matrix_keycodes; 309 input_dev->keycode = keypad->keycodes;
321 input_dev->keycodesize = sizeof(keypad->matrix_keycodes[0]); 310 input_dev->keycodesize = sizeof(keypad->keycodes[0]);
322 input_dev->keycodemax = ARRAY_SIZE(keypad->matrix_keycodes); 311 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
323 312
324 input_set_drvdata(input_dev, keypad); 313 input_set_drvdata(input_dev, keypad);
325 314
@@ -327,7 +316,8 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
327 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) 316 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT)
328 input_dev->evbit[0] |= BIT_MASK(EV_REP); 317 input_dev->evbit[0] |= BIT_MASK(EV_REP);
329 318
330 ep93xx_keypad_build_keycode(keypad); 319 matrix_keypad_build_keymap(keymap_data, 3,
320 input_dev->keycode, input_dev->keybit);
331 platform_set_drvdata(pdev, keypad); 321 platform_set_drvdata(pdev, keypad);
332 322
333 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler, 323 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler,
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 1aff3b76effd..2b708aa85553 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -30,13 +30,289 @@ struct gpio_button_data {
30 struct input_dev *input; 30 struct input_dev *input;
31 struct timer_list timer; 31 struct timer_list timer;
32 struct work_struct work; 32 struct work_struct work;
33 bool disabled;
33}; 34};
34 35
35struct gpio_keys_drvdata { 36struct gpio_keys_drvdata {
36 struct input_dev *input; 37 struct input_dev *input;
38 struct mutex disable_lock;
39 unsigned int n_buttons;
37 struct gpio_button_data data[0]; 40 struct gpio_button_data data[0];
38}; 41};
39 42
43/*
44 * SYSFS interface for enabling/disabling keys and switches:
45 *
46 * There are 4 attributes under /sys/devices/platform/gpio-keys/
47 * keys [ro] - bitmap of keys (EV_KEY) which can be
48 * disabled
49 * switches [ro] - bitmap of switches (EV_SW) which can be
50 * disabled
51 * disabled_keys [rw] - bitmap of keys currently disabled
52 * disabled_switches [rw] - bitmap of switches currently disabled
53 *
54 * Userland can change these values and hence disable event generation
55 * for each key (or switch). Disabling a key means its interrupt line
56 * is disabled.
57 *
58 * For example, if we have following switches set up as gpio-keys:
59 * SW_DOCK = 5
60 * SW_CAMERA_LENS_COVER = 9
61 * SW_KEYPAD_SLIDE = 10
62 * SW_FRONT_PROXIMITY = 11
63 * This is read from switches:
64 * 11-9,5
65 * Next we want to disable proximity (11) and dock (5), we write:
66 * 11,5
67 * to file disabled_switches. Now proximity and dock IRQs are disabled.
68 * This can be verified by reading the file disabled_switches:
69 * 11,5
70 * If we now want to enable proximity (11) switch we write:
71 * 5
72 * to disabled_switches.
73 *
74 * We can disable only those keys which don't allow sharing the irq.
75 */
76
77/**
78 * get_n_events_by_type() - returns maximum number of events per @type
79 * @type: type of button (%EV_KEY, %EV_SW)
80 *
81 * Return value of this function can be used to allocate bitmap
82 * large enough to hold all bits for given type.
83 */
84static inline int get_n_events_by_type(int type)
85{
86 BUG_ON(type != EV_SW && type != EV_KEY);
87
88 return (type == EV_KEY) ? KEY_CNT : SW_CNT;
89}
90
91/**
92 * gpio_keys_disable_button() - disables given GPIO button
93 * @bdata: button data for button to be disabled
94 *
95 * Disables button pointed by @bdata. This is done by masking
96 * IRQ line. After this function is called, button won't generate
97 * input events anymore. Note that one can only disable buttons
98 * that don't share IRQs.
99 *
100 * Make sure that @bdata->disable_lock is locked when entering
101 * this function to avoid races when concurrent threads are
102 * disabling buttons at the same time.
103 */
104static void gpio_keys_disable_button(struct gpio_button_data *bdata)
105{
106 if (!bdata->disabled) {
107 /*
108 * Disable IRQ and possible debouncing timer.
109 */
110 disable_irq(gpio_to_irq(bdata->button->gpio));
111 if (bdata->button->debounce_interval)
112 del_timer_sync(&bdata->timer);
113
114 bdata->disabled = true;
115 }
116}
117
118/**
119 * gpio_keys_enable_button() - enables given GPIO button
120 * @bdata: button data for button to be disabled
121 *
122 * Enables given button pointed by @bdata.
123 *
124 * Make sure that @bdata->disable_lock is locked when entering
125 * this function to avoid races with concurrent threads trying
126 * to enable the same button at the same time.
127 */
128static void gpio_keys_enable_button(struct gpio_button_data *bdata)
129{
130 if (bdata->disabled) {
131 enable_irq(gpio_to_irq(bdata->button->gpio));
132 bdata->disabled = false;
133 }
134}
135
136/**
137 * gpio_keys_attr_show_helper() - fill in stringified bitmap of buttons
138 * @ddata: pointer to drvdata
139 * @buf: buffer where stringified bitmap is written
140 * @type: button type (%EV_KEY, %EV_SW)
141 * @only_disabled: does caller want only those buttons that are
142 * currently disabled or all buttons that can be
143 * disabled
144 *
145 * This function writes buttons that can be disabled to @buf. If
146 * @only_disabled is true, then @buf contains only those buttons
147 * that are currently disabled. Returns 0 on success or negative
148 * errno on failure.
149 */
150static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata,
151 char *buf, unsigned int type,
152 bool only_disabled)
153{
154 int n_events = get_n_events_by_type(type);
155 unsigned long *bits;
156 ssize_t ret;
157 int i;
158
159 bits = kcalloc(BITS_TO_LONGS(n_events), sizeof(*bits), GFP_KERNEL);
160 if (!bits)
161 return -ENOMEM;
162
163 for (i = 0; i < ddata->n_buttons; i++) {
164 struct gpio_button_data *bdata = &ddata->data[i];
165
166 if (bdata->button->type != type)
167 continue;
168
169 if (only_disabled && !bdata->disabled)
170 continue;
171
172 __set_bit(bdata->button->code, bits);
173 }
174
175 ret = bitmap_scnlistprintf(buf, PAGE_SIZE - 2, bits, n_events);
176 buf[ret++] = '\n';
177 buf[ret] = '\0';
178
179 kfree(bits);
180
181 return ret;
182}
183
184/**
185 * gpio_keys_attr_store_helper() - enable/disable buttons based on given bitmap
186 * @ddata: pointer to drvdata
187 * @buf: buffer from userspace that contains stringified bitmap
188 * @type: button type (%EV_KEY, %EV_SW)
189 *
190 * This function parses stringified bitmap from @buf and disables/enables
191 * GPIO buttons accordinly. Returns 0 on success and negative error
192 * on failure.
193 */
194static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata,
195 const char *buf, unsigned int type)
196{
197 int n_events = get_n_events_by_type(type);
198 unsigned long *bits;
199 ssize_t error;
200 int i;
201
202 bits = kcalloc(BITS_TO_LONGS(n_events), sizeof(*bits), GFP_KERNEL);
203 if (!bits)
204 return -ENOMEM;
205
206 error = bitmap_parselist(buf, bits, n_events);
207 if (error)
208 goto out;
209
210 /* First validate */
211 for (i = 0; i < ddata->n_buttons; i++) {
212 struct gpio_button_data *bdata = &ddata->data[i];
213
214 if (bdata->button->type != type)
215 continue;
216
217 if (test_bit(bdata->button->code, bits) &&
218 !bdata->button->can_disable) {
219 error = -EINVAL;
220 goto out;
221 }
222 }
223
224 mutex_lock(&ddata->disable_lock);
225
226 for (i = 0; i < ddata->n_buttons; i++) {
227 struct gpio_button_data *bdata = &ddata->data[i];
228
229 if (bdata->button->type != type)
230 continue;
231
232 if (test_bit(bdata->button->code, bits))
233 gpio_keys_disable_button(bdata);
234 else
235 gpio_keys_enable_button(bdata);
236 }
237
238 mutex_unlock(&ddata->disable_lock);
239
240out:
241 kfree(bits);
242 return error;
243}
244
245#define ATTR_SHOW_FN(name, type, only_disabled) \
246static ssize_t gpio_keys_show_##name(struct device *dev, \
247 struct device_attribute *attr, \
248 char *buf) \
249{ \
250 struct platform_device *pdev = to_platform_device(dev); \
251 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); \
252 \
253 return gpio_keys_attr_show_helper(ddata, buf, \
254 type, only_disabled); \
255}
256
257ATTR_SHOW_FN(keys, EV_KEY, false);
258ATTR_SHOW_FN(switches, EV_SW, false);
259ATTR_SHOW_FN(disabled_keys, EV_KEY, true);
260ATTR_SHOW_FN(disabled_switches, EV_SW, true);
261
262/*
263 * ATTRIBUTES:
264 *
265 * /sys/devices/platform/gpio-keys/keys [ro]
266 * /sys/devices/platform/gpio-keys/switches [ro]
267 */
268static DEVICE_ATTR(keys, S_IRUGO, gpio_keys_show_keys, NULL);
269static DEVICE_ATTR(switches, S_IRUGO, gpio_keys_show_switches, NULL);
270
271#define ATTR_STORE_FN(name, type) \
272static ssize_t gpio_keys_store_##name(struct device *dev, \
273 struct device_attribute *attr, \
274 const char *buf, \
275 size_t count) \
276{ \
277 struct platform_device *pdev = to_platform_device(dev); \
278 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); \
279 ssize_t error; \
280 \
281 error = gpio_keys_attr_store_helper(ddata, buf, type); \
282 if (error) \
283 return error; \
284 \
285 return count; \
286}
287
288ATTR_STORE_FN(disabled_keys, EV_KEY);
289ATTR_STORE_FN(disabled_switches, EV_SW);
290
291/*
292 * ATTRIBUTES:
293 *
294 * /sys/devices/platform/gpio-keys/disabled_keys [rw]
295 * /sys/devices/platform/gpio-keys/disables_switches [rw]
296 */
297static DEVICE_ATTR(disabled_keys, S_IWUSR | S_IRUGO,
298 gpio_keys_show_disabled_keys,
299 gpio_keys_store_disabled_keys);
300static DEVICE_ATTR(disabled_switches, S_IWUSR | S_IRUGO,
301 gpio_keys_show_disabled_switches,
302 gpio_keys_store_disabled_switches);
303
304static struct attribute *gpio_keys_attrs[] = {
305 &dev_attr_keys.attr,
306 &dev_attr_switches.attr,
307 &dev_attr_disabled_keys.attr,
308 &dev_attr_disabled_switches.attr,
309 NULL,
310};
311
312static struct attribute_group gpio_keys_attr_group = {
313 .attrs = gpio_keys_attrs,
314};
315
40static void gpio_keys_report_event(struct gpio_button_data *bdata) 316static void gpio_keys_report_event(struct gpio_button_data *bdata)
41{ 317{
42 struct gpio_keys_button *button = bdata->button; 318 struct gpio_keys_button *button = bdata->button;
@@ -79,11 +355,13 @@ static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
79 return IRQ_HANDLED; 355 return IRQ_HANDLED;
80} 356}
81 357
82static int __devinit gpio_keys_setup_key(struct device *dev, 358static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
83 struct gpio_button_data *bdata, 359 struct gpio_button_data *bdata,
84 struct gpio_keys_button *button) 360 struct gpio_keys_button *button)
85{ 361{
86 char *desc = button->desc ? button->desc : "gpio_keys"; 362 char *desc = button->desc ? button->desc : "gpio_keys";
363 struct device *dev = &pdev->dev;
364 unsigned long irqflags;
87 int irq, error; 365 int irq, error;
88 366
89 setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata); 367 setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata);
@@ -112,10 +390,15 @@ static int __devinit gpio_keys_setup_key(struct device *dev,
112 goto fail3; 390 goto fail3;
113 } 391 }
114 392
115 error = request_irq(irq, gpio_keys_isr, 393 irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
116 IRQF_SHARED | 394 /*
117 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 395 * If platform has specified that the button can be disabled,
118 desc, bdata); 396 * we don't want it to share the interrupt line.
397 */
398 if (!button->can_disable)
399 irqflags |= IRQF_SHARED;
400
401 error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
119 if (error) { 402 if (error) {
120 dev_err(dev, "Unable to claim irq %d; error %d\n", 403 dev_err(dev, "Unable to claim irq %d; error %d\n",
121 irq, error); 404 irq, error);
@@ -149,6 +432,10 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
149 goto fail1; 432 goto fail1;
150 } 433 }
151 434
435 ddata->input = input;
436 ddata->n_buttons = pdata->nbuttons;
437 mutex_init(&ddata->disable_lock);
438
152 platform_set_drvdata(pdev, ddata); 439 platform_set_drvdata(pdev, ddata);
153 440
154 input->name = pdev->name; 441 input->name = pdev->name;
@@ -164,8 +451,6 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
164 if (pdata->rep) 451 if (pdata->rep)
165 __set_bit(EV_REP, input->evbit); 452 __set_bit(EV_REP, input->evbit);
166 453
167 ddata->input = input;
168
169 for (i = 0; i < pdata->nbuttons; i++) { 454 for (i = 0; i < pdata->nbuttons; i++) {
170 struct gpio_keys_button *button = &pdata->buttons[i]; 455 struct gpio_keys_button *button = &pdata->buttons[i];
171 struct gpio_button_data *bdata = &ddata->data[i]; 456 struct gpio_button_data *bdata = &ddata->data[i];
@@ -174,7 +459,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
174 bdata->input = input; 459 bdata->input = input;
175 bdata->button = button; 460 bdata->button = button;
176 461
177 error = gpio_keys_setup_key(dev, bdata, button); 462 error = gpio_keys_setup_key(pdev, bdata, button);
178 if (error) 463 if (error)
179 goto fail2; 464 goto fail2;
180 465
@@ -184,13 +469,20 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
184 input_set_capability(input, type, button->code); 469 input_set_capability(input, type, button->code);
185 } 470 }
186 471
187 error = input_register_device(input); 472 error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group);
188 if (error) { 473 if (error) {
189 dev_err(dev, "Unable to register input device, " 474 dev_err(dev, "Unable to export keys/switches, error: %d\n",
190 "error: %d\n", error); 475 error);
191 goto fail2; 476 goto fail2;
192 } 477 }
193 478
479 error = input_register_device(input);
480 if (error) {
481 dev_err(dev, "Unable to register input device, error: %d\n",
482 error);
483 goto fail3;
484 }
485
194 /* get current state of buttons */ 486 /* get current state of buttons */
195 for (i = 0; i < pdata->nbuttons; i++) 487 for (i = 0; i < pdata->nbuttons; i++)
196 gpio_keys_report_event(&ddata->data[i]); 488 gpio_keys_report_event(&ddata->data[i]);
@@ -200,6 +492,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
200 492
201 return 0; 493 return 0;
202 494
495 fail3:
496 sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
203 fail2: 497 fail2:
204 while (--i >= 0) { 498 while (--i >= 0) {
205 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); 499 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]);
@@ -224,6 +518,8 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
224 struct input_dev *input = ddata->input; 518 struct input_dev *input = ddata->input;
225 int i; 519 int i;
226 520
521 sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
522
227 device_init_wakeup(&pdev->dev, 0); 523 device_init_wakeup(&pdev->dev, 0);
228 524
229 for (i = 0; i < pdata->nbuttons; i++) { 525 for (i = 0; i < pdata->nbuttons; i++) {
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
new file mode 100644
index 000000000000..2ee5b798024d
--- /dev/null
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -0,0 +1,594 @@
1/*
2 * Driver for the IMX keypad port.
3 * Copyright (C) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * <<Power management needs to be implemented>>.
10 */
11
12#include <linux/clk.h>
13#include <linux/delay.h>
14#include <linux/device.h>
15#include <linux/err.h>
16#include <linux/init.h>
17#include <linux/input/matrix_keypad.h>
18#include <linux/interrupt.h>
19#include <linux/io.h>
20#include <linux/jiffies.h>
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/platform_device.h>
24#include <linux/timer.h>
25
26/*
27 * Keypad Controller registers (halfword)
28 */
29#define KPCR 0x00 /* Keypad Control Register */
30
31#define KPSR 0x02 /* Keypad Status Register */
32#define KBD_STAT_KPKD (0x1 << 0) /* Key Press Interrupt Status bit (w1c) */
33#define KBD_STAT_KPKR (0x1 << 1) /* Key Release Interrupt Status bit (w1c) */
34#define KBD_STAT_KDSC (0x1 << 2) /* Key Depress Synch Chain Status bit (w1c)*/
35#define KBD_STAT_KRSS (0x1 << 3) /* Key Release Synch Status bit (w1c)*/
36#define KBD_STAT_KDIE (0x1 << 8) /* Key Depress Interrupt Enable Status bit */
37#define KBD_STAT_KRIE (0x1 << 9) /* Key Release Interrupt Enable */
38#define KBD_STAT_KPPEN (0x1 << 10) /* Keypad Clock Enable */
39
40#define KDDR 0x04 /* Keypad Data Direction Register */
41#define KPDR 0x06 /* Keypad Data Register */
42
43#define MAX_MATRIX_KEY_ROWS 8
44#define MAX_MATRIX_KEY_COLS 8
45#define MATRIX_ROW_SHIFT 3
46
47#define MAX_MATRIX_KEY_NUM (MAX_MATRIX_KEY_ROWS * MAX_MATRIX_KEY_COLS)
48
49struct imx_keypad {
50
51 struct clk *clk;
52 struct input_dev *input_dev;
53 void __iomem *mmio_base;
54
55 int irq;
56 struct timer_list check_matrix_timer;
57
58 /*
59 * The matrix is stable only if no changes are detected after
60 * IMX_KEYPAD_SCANS_FOR_STABILITY scans
61 */
62#define IMX_KEYPAD_SCANS_FOR_STABILITY 3
63 int stable_count;
64
65 bool enabled;
66
67 /* Masks for enabled rows/cols */
68 unsigned short rows_en_mask;
69 unsigned short cols_en_mask;
70
71 unsigned short keycodes[MAX_MATRIX_KEY_NUM];
72
73 /*
74 * Matrix states:
75 * -stable: achieved after a complete debounce process.
76 * -unstable: used in the debouncing process.
77 */
78 unsigned short matrix_stable_state[MAX_MATRIX_KEY_COLS];
79 unsigned short matrix_unstable_state[MAX_MATRIX_KEY_COLS];
80};
81
82/* Scan the matrix and return the new state in *matrix_volatile_state. */
83static void imx_keypad_scan_matrix(struct imx_keypad *keypad,
84 unsigned short *matrix_volatile_state)
85{
86 int col;
87 unsigned short reg_val;
88
89 for (col = 0; col < MAX_MATRIX_KEY_COLS; col++) {
90 if ((keypad->cols_en_mask & (1 << col)) == 0)
91 continue;
92 /*
93 * Discharge keypad capacitance:
94 * 2. write 1s on column data.
95 * 3. configure columns as totem-pole to discharge capacitance.
96 * 4. configure columns as open-drain.
97 */
98 reg_val = readw(keypad->mmio_base + KPDR);
99 reg_val |= 0xff00;
100 writew(reg_val, keypad->mmio_base + KPDR);
101
102 reg_val = readw(keypad->mmio_base + KPCR);
103 reg_val &= ~((keypad->cols_en_mask & 0xff) << 8);
104 writew(reg_val, keypad->mmio_base + KPCR);
105
106 udelay(2);
107
108 reg_val = readw(keypad->mmio_base + KPCR);
109 reg_val |= (keypad->cols_en_mask & 0xff) << 8;
110 writew(reg_val, keypad->mmio_base + KPCR);
111
112 /*
113 * 5. Write a single column to 0, others to 1.
114 * 6. Sample row inputs and save data.
115 * 7. Repeat steps 2 - 6 for remaining columns.
116 */
117 reg_val = readw(keypad->mmio_base + KPDR);
118 reg_val &= ~(1 << (8 + col));
119 writew(reg_val, keypad->mmio_base + KPDR);
120
121 /*
122 * Delay added to avoid propagating the 0 from column to row
123 * when scanning.
124 */
125 udelay(5);
126
127 /*
128 * 1s in matrix_volatile_state[col] means key pressures
129 * throw data from non enabled rows.
130 */
131 reg_val = readw(keypad->mmio_base + KPDR);
132 matrix_volatile_state[col] = (~reg_val) & keypad->rows_en_mask;
133 }
134
135 /*
136 * Return in standby mode:
137 * 9. write 0s to columns
138 */
139 reg_val = readw(keypad->mmio_base + KPDR);
140 reg_val &= 0x00ff;
141 writew(reg_val, keypad->mmio_base + KPDR);
142}
143
144/*
145 * Compare the new matrix state (volatile) with the stable one stored in
146 * keypad->matrix_stable_state and fire events if changes are detected.
147 */
148static void imx_keypad_fire_events(struct imx_keypad *keypad,
149 unsigned short *matrix_volatile_state)
150{
151 struct input_dev *input_dev = keypad->input_dev;
152 int row, col;
153
154 for (col = 0; col < MAX_MATRIX_KEY_COLS; col++) {
155 unsigned short bits_changed;
156 int code;
157
158 if ((keypad->cols_en_mask & (1 << col)) == 0)
159 continue; /* Column is not enabled */
160
161 bits_changed = keypad->matrix_stable_state[col] ^
162 matrix_volatile_state[col];
163
164 if (bits_changed == 0)
165 continue; /* Column does not contain changes */
166
167 for (row = 0; row < MAX_MATRIX_KEY_ROWS; row++) {
168 if ((keypad->rows_en_mask & (1 << row)) == 0)
169 continue; /* Row is not enabled */
170 if ((bits_changed & (1 << row)) == 0)
171 continue; /* Row does not contain changes */
172
173 code = MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT);
174 input_event(input_dev, EV_MSC, MSC_SCAN, code);
175 input_report_key(input_dev, keypad->keycodes[code],
176 matrix_volatile_state[col] & (1 << row));
177 dev_dbg(&input_dev->dev, "Event code: %d, val: %d",
178 keypad->keycodes[code],
179 matrix_volatile_state[col] & (1 << row));
180 }
181 }
182 input_sync(input_dev);
183}
184
185/*
186 * imx_keypad_check_for_events is the timer handler.
187 */
188static void imx_keypad_check_for_events(unsigned long data)
189{
190 struct imx_keypad *keypad = (struct imx_keypad *) data;
191 unsigned short matrix_volatile_state[MAX_MATRIX_KEY_COLS];
192 unsigned short reg_val;
193 bool state_changed, is_zero_matrix;
194 int i;
195
196 memset(matrix_volatile_state, 0, sizeof(matrix_volatile_state));
197
198 imx_keypad_scan_matrix(keypad, matrix_volatile_state);
199
200 state_changed = false;
201 for (i = 0; i < MAX_MATRIX_KEY_COLS; i++) {
202 if ((keypad->cols_en_mask & (1 << i)) == 0)
203 continue;
204
205 if (keypad->matrix_unstable_state[i] ^ matrix_volatile_state[i]) {
206 state_changed = true;
207 break;
208 }
209 }
210
211 /*
212 * If the matrix state is changed from the previous scan
213 * (Re)Begin the debouncing process, saving the new state in
214 * keypad->matrix_unstable_state.
215 * else
216 * Increase the count of number of scans with a stable state.
217 */
218 if (state_changed) {
219 memcpy(keypad->matrix_unstable_state, matrix_volatile_state,
220 sizeof(matrix_volatile_state));
221 keypad->stable_count = 0;
222 } else
223 keypad->stable_count++;
224
225 /*
226 * If the matrix is not as stable as we want reschedule scan
227 * in the near future.
228 */
229 if (keypad->stable_count < IMX_KEYPAD_SCANS_FOR_STABILITY) {
230 mod_timer(&keypad->check_matrix_timer,
231 jiffies + msecs_to_jiffies(10));
232 return;
233 }
234
235 /*
236 * If the matrix state is stable, fire the events and save the new
237 * stable state. Note, if the matrix is kept stable for longer
238 * (keypad->stable_count > IMX_KEYPAD_SCANS_FOR_STABILITY) all
239 * events have already been generated.
240 */
241 if (keypad->stable_count == IMX_KEYPAD_SCANS_FOR_STABILITY) {
242 imx_keypad_fire_events(keypad, matrix_volatile_state);
243
244 memcpy(keypad->matrix_stable_state, matrix_volatile_state,
245 sizeof(matrix_volatile_state));
246 }
247
248 is_zero_matrix = true;
249 for (i = 0; i < MAX_MATRIX_KEY_COLS; i++) {
250 if (matrix_volatile_state[i] != 0) {
251 is_zero_matrix = false;
252 break;
253 }
254 }
255
256
257 if (is_zero_matrix) {
258 /*
259 * All keys have been released. Enable only the KDI
260 * interrupt for future key presses (clear the KDI
261 * status bit and its sync chain before that).
262 */
263 reg_val = readw(keypad->mmio_base + KPSR);
264 reg_val |= KBD_STAT_KPKD | KBD_STAT_KDSC;
265 writew(reg_val, keypad->mmio_base + KPSR);
266
267 reg_val = readw(keypad->mmio_base + KPSR);
268 reg_val |= KBD_STAT_KDIE;
269 reg_val &= ~KBD_STAT_KRIE;
270 writew(reg_val, keypad->mmio_base + KPSR);
271 } else {
272 /*
273 * Some keys are still pressed. Schedule a rescan in
274 * attempt to detect multiple key presses and enable
275 * the KRI interrupt to react quickly to key release
276 * event.
277 */
278 mod_timer(&keypad->check_matrix_timer,
279 jiffies + msecs_to_jiffies(60));
280
281 reg_val = readw(keypad->mmio_base + KPSR);
282 reg_val |= KBD_STAT_KPKR | KBD_STAT_KRSS;
283 writew(reg_val, keypad->mmio_base + KPSR);
284
285 reg_val = readw(keypad->mmio_base + KPSR);
286 reg_val |= KBD_STAT_KRIE;
287 reg_val &= ~KBD_STAT_KDIE;
288 writew(reg_val, keypad->mmio_base + KPSR);
289 }
290}
291
292static irqreturn_t imx_keypad_irq_handler(int irq, void *dev_id)
293{
294 struct imx_keypad *keypad = dev_id;
295 unsigned short reg_val;
296
297 reg_val = readw(keypad->mmio_base + KPSR);
298
299 /* Disable both interrupt types */
300 reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE);
301 /* Clear interrupts status bits */
302 reg_val |= KBD_STAT_KPKR | KBD_STAT_KPKD;
303 writew(reg_val, keypad->mmio_base + KPSR);
304
305 if (keypad->enabled) {
306 /* The matrix is supposed to be changed */
307 keypad->stable_count = 0;
308
309 /* Schedule the scanning procedure near in the future */
310 mod_timer(&keypad->check_matrix_timer,
311 jiffies + msecs_to_jiffies(2));
312 }
313
314 return IRQ_HANDLED;
315}
316
317static void imx_keypad_config(struct imx_keypad *keypad)
318{
319 unsigned short reg_val;
320
321 /*
322 * Include enabled rows in interrupt generation (KPCR[7:0])
323 * Configure keypad columns as open-drain (KPCR[15:8])
324 */
325 reg_val = readw(keypad->mmio_base + KPCR);
326 reg_val |= keypad->rows_en_mask & 0xff; /* rows */
327 reg_val |= (keypad->cols_en_mask & 0xff) << 8; /* cols */
328 writew(reg_val, keypad->mmio_base + KPCR);
329
330 /* Write 0's to KPDR[15:8] (Colums) */
331 reg_val = readw(keypad->mmio_base + KPDR);
332 reg_val &= 0x00ff;
333 writew(reg_val, keypad->mmio_base + KPDR);
334
335 /* Configure columns as output, rows as input (KDDR[15:0]) */
336 writew(0xff00, keypad->mmio_base + KDDR);
337
338 /*
339 * Clear Key Depress and Key Release status bit.
340 * Clear both synchronizer chain.
341 */
342 reg_val = readw(keypad->mmio_base + KPSR);
343 reg_val |= KBD_STAT_KPKR | KBD_STAT_KPKD |
344 KBD_STAT_KDSC | KBD_STAT_KRSS;
345 writew(reg_val, keypad->mmio_base + KPSR);
346
347 /* Enable KDI and disable KRI (avoid false release events). */
348 reg_val |= KBD_STAT_KDIE;
349 reg_val &= ~KBD_STAT_KRIE;
350 writew(reg_val, keypad->mmio_base + KPSR);
351}
352
353static void imx_keypad_inhibit(struct imx_keypad *keypad)
354{
355 unsigned short reg_val;
356
357 /* Inhibit KDI and KRI interrupts. */
358 reg_val = readw(keypad->mmio_base + KPSR);
359 reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE);
360 writew(reg_val, keypad->mmio_base + KPSR);
361
362 /* Colums as open drain and disable all rows */
363 writew(0xff00, keypad->mmio_base + KPCR);
364}
365
366static void imx_keypad_close(struct input_dev *dev)
367{
368 struct imx_keypad *keypad = input_get_drvdata(dev);
369
370 dev_dbg(&dev->dev, ">%s\n", __func__);
371
372 /* Mark keypad as being inactive */
373 keypad->enabled = false;
374 synchronize_irq(keypad->irq);
375 del_timer_sync(&keypad->check_matrix_timer);
376
377 imx_keypad_inhibit(keypad);
378
379 /* Disable clock unit */
380 clk_disable(keypad->clk);
381}
382
383static int imx_keypad_open(struct input_dev *dev)
384{
385 struct imx_keypad *keypad = input_get_drvdata(dev);
386
387 dev_dbg(&dev->dev, ">%s\n", __func__);
388
389 /* We became active from now */
390 keypad->enabled = true;
391
392 /* Enable the kpp clock */
393 clk_enable(keypad->clk);
394 imx_keypad_config(keypad);
395
396 /* Sanity control, not all the rows must be actived now. */
397 if ((readw(keypad->mmio_base + KPDR) & keypad->rows_en_mask) == 0) {
398 dev_err(&dev->dev,
399 "too many keys pressed, control pins initialisation\n");
400 goto open_err;
401 }
402
403 return 0;
404
405open_err:
406 imx_keypad_close(dev);
407 return -EIO;
408}
409
410static int __devinit imx_keypad_probe(struct platform_device *pdev)
411{
412 const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data;
413 struct imx_keypad *keypad;
414 struct input_dev *input_dev;
415 struct resource *res;
416 int irq, error, i;
417
418 if (keymap_data == NULL) {
419 dev_err(&pdev->dev, "no keymap defined\n");
420 return -EINVAL;
421 }
422
423 irq = platform_get_irq(pdev, 0);
424 if (irq < 0) {
425 dev_err(&pdev->dev, "no irq defined in platform data\n");
426 return -EINVAL;
427 }
428
429 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
430 if (res == NULL) {
431 dev_err(&pdev->dev, "no I/O memory defined in platform data\n");
432 return -EINVAL;
433 }
434
435 res = request_mem_region(res->start, resource_size(res), pdev->name);
436 if (res == NULL) {
437 dev_err(&pdev->dev, "failed to request I/O memory\n");
438 return -EBUSY;
439 }
440
441 input_dev = input_allocate_device();
442 if (!input_dev) {
443 dev_err(&pdev->dev, "failed to allocate the input device\n");
444 error = -ENOMEM;
445 goto failed_rel_mem;
446 }
447
448 keypad = kzalloc(sizeof(struct imx_keypad), GFP_KERNEL);
449 if (!keypad) {
450 dev_err(&pdev->dev, "not enough memory for driver data\n");
451 error = -ENOMEM;
452 goto failed_free_input;
453 }
454
455 keypad->input_dev = input_dev;
456 keypad->irq = irq;
457 keypad->stable_count = 0;
458
459 setup_timer(&keypad->check_matrix_timer,
460 imx_keypad_check_for_events, (unsigned long) keypad);
461
462 keypad->mmio_base = ioremap(res->start, resource_size(res));
463 if (keypad->mmio_base == NULL) {
464 dev_err(&pdev->dev, "failed to remap I/O memory\n");
465 error = -ENOMEM;
466 goto failed_free_priv;
467 }
468
469 keypad->clk = clk_get(&pdev->dev, "kpp");
470 if (IS_ERR(keypad->clk)) {
471 dev_err(&pdev->dev, "failed to get keypad clock\n");
472 error = PTR_ERR(keypad->clk);
473 goto failed_unmap;
474 }
475
476 /* Search for rows and cols enabled */
477 for (i = 0; i < keymap_data->keymap_size; i++) {
478 keypad->rows_en_mask |= 1 << KEY_ROW(keymap_data->keymap[i]);
479 keypad->cols_en_mask |= 1 << KEY_COL(keymap_data->keymap[i]);
480 }
481
482 if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) ||
483 keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) {
484 dev_err(&pdev->dev,
485 "invalid key data (too many rows or colums)\n");
486 error = -EINVAL;
487 goto failed_clock_put;
488 }
489 dev_dbg(&pdev->dev, "enabled rows mask: %x\n", keypad->rows_en_mask);
490 dev_dbg(&pdev->dev, "enabled cols mask: %x\n", keypad->cols_en_mask);
491
492 /* Init the Input device */
493 input_dev->name = pdev->name;
494 input_dev->id.bustype = BUS_HOST;
495 input_dev->dev.parent = &pdev->dev;
496 input_dev->open = imx_keypad_open;
497 input_dev->close = imx_keypad_close;
498 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
499 input_dev->keycode = keypad->keycodes;
500 input_dev->keycodesize = sizeof(keypad->keycodes[0]);
501 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
502
503 matrix_keypad_build_keymap(keymap_data, MATRIX_ROW_SHIFT,
504 keypad->keycodes, input_dev->keybit);
505
506 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
507 input_set_drvdata(input_dev, keypad);
508
509 /* Ensure that the keypad will stay dormant until opened */
510 imx_keypad_inhibit(keypad);
511
512 error = request_irq(irq, imx_keypad_irq_handler, IRQF_DISABLED,
513 pdev->name, keypad);
514 if (error) {
515 dev_err(&pdev->dev, "failed to request IRQ\n");
516 goto failed_clock_put;
517 }
518
519 /* Register the input device */
520 error = input_register_device(input_dev);
521 if (error) {
522 dev_err(&pdev->dev, "failed to register input device\n");
523 goto failed_free_irq;
524 }
525
526 platform_set_drvdata(pdev, keypad);
527 device_init_wakeup(&pdev->dev, 1);
528
529 return 0;
530
531failed_free_irq:
532 free_irq(irq, pdev);
533failed_clock_put:
534 clk_put(keypad->clk);
535failed_unmap:
536 iounmap(keypad->mmio_base);
537failed_free_priv:
538 kfree(keypad);
539failed_free_input:
540 input_free_device(input_dev);
541failed_rel_mem:
542 release_mem_region(res->start, resource_size(res));
543 return error;
544}
545
546static int __devexit imx_keypad_remove(struct platform_device *pdev)
547{
548 struct imx_keypad *keypad = platform_get_drvdata(pdev);
549 struct resource *res;
550
551 dev_dbg(&pdev->dev, ">%s\n", __func__);
552
553 platform_set_drvdata(pdev, NULL);
554
555 input_unregister_device(keypad->input_dev);
556
557 free_irq(keypad->irq, keypad);
558 clk_put(keypad->clk);
559
560 iounmap(keypad->mmio_base);
561 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
562 release_mem_region(res->start, resource_size(res));
563
564 kfree(keypad);
565
566 return 0;
567}
568
569static struct platform_driver imx_keypad_driver = {
570 .driver = {
571 .name = "imx-keypad",
572 .owner = THIS_MODULE,
573 },
574 .probe = imx_keypad_probe,
575 .remove = __devexit_p(imx_keypad_remove),
576};
577
578static int __init imx_keypad_init(void)
579{
580 return platform_driver_register(&imx_keypad_driver);
581}
582
583static void __exit imx_keypad_exit(void)
584{
585 platform_driver_unregister(&imx_keypad_driver);
586}
587
588module_init(imx_keypad_init);
589module_exit(imx_keypad_exit);
590
591MODULE_AUTHOR("Alberto Panizzo <maramaopercheseimorto@gmail.com>");
592MODULE_DESCRIPTION("IMX Keypad Port Driver");
593MODULE_LICENSE("GPL v2");
594MODULE_ALIAS("platform:imx-keypad");
diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c
index 191cc51d6cf8..31f30087b591 100644
--- a/drivers/input/keyboard/qt2160.c
+++ b/drivers/input/keyboard/qt2160.c
@@ -362,7 +362,7 @@ static int __devexit qt2160_remove(struct i2c_client *client)
362 return 0; 362 return 0;
363} 363}
364 364
365static struct i2c_device_id qt2160_idtable[] = { 365static const struct i2c_device_id qt2160_idtable[] = {
366 { "qt2160", 0, }, 366 { "qt2160", 0, },
367 { } 367 { }
368}; 368};
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
index 8e9380bfed40..854e2035cd6e 100644
--- a/drivers/input/keyboard/sh_keysc.c
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -19,101 +19,141 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/input.h> 20#include <linux/input.h>
21#include <linux/input/sh_keysc.h> 21#include <linux/input/sh_keysc.h>
22#include <linux/bitmap.h>
22#include <linux/clk.h> 23#include <linux/clk.h>
23#include <linux/io.h> 24#include <linux/io.h>
24 25
25#define KYCR1_OFFS 0x00
26#define KYCR2_OFFS 0x04
27#define KYINDR_OFFS 0x08
28#define KYOUTDR_OFFS 0x0c
29
30#define KYCR2_IRQ_LEVEL 0x10
31#define KYCR2_IRQ_DISABLED 0x00
32
33static const struct { 26static const struct {
34 unsigned char kymd, keyout, keyin; 27 unsigned char kymd, keyout, keyin;
35} sh_keysc_mode[] = { 28} sh_keysc_mode[] = {
36 [SH_KEYSC_MODE_1] = { 0, 6, 5 }, 29 [SH_KEYSC_MODE_1] = { 0, 6, 5 },
37 [SH_KEYSC_MODE_2] = { 1, 5, 6 }, 30 [SH_KEYSC_MODE_2] = { 1, 5, 6 },
38 [SH_KEYSC_MODE_3] = { 2, 4, 7 }, 31 [SH_KEYSC_MODE_3] = { 2, 4, 7 },
32 [SH_KEYSC_MODE_4] = { 3, 6, 6 },
33 [SH_KEYSC_MODE_5] = { 4, 6, 7 },
34 [SH_KEYSC_MODE_6] = { 5, 7, 7 },
39}; 35};
40 36
41struct sh_keysc_priv { 37struct sh_keysc_priv {
42 void __iomem *iomem_base; 38 void __iomem *iomem_base;
43 struct clk *clk; 39 struct clk *clk;
44 unsigned long last_keys; 40 DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS);
45 struct input_dev *input; 41 struct input_dev *input;
46 struct sh_keysc_info pdata; 42 struct sh_keysc_info pdata;
47}; 43};
48 44
45#define KYCR1 0
46#define KYCR2 1
47#define KYINDR 2
48#define KYOUTDR 3
49
50#define KYCR2_IRQ_LEVEL 0x10
51#define KYCR2_IRQ_DISABLED 0x00
52
53static unsigned long sh_keysc_read(struct sh_keysc_priv *p, int reg_nr)
54{
55 return ioread16(p->iomem_base + (reg_nr << 2));
56}
57
58static void sh_keysc_write(struct sh_keysc_priv *p, int reg_nr,
59 unsigned long value)
60{
61 iowrite16(value, p->iomem_base + (reg_nr << 2));
62}
63
64static void sh_keysc_level_mode(struct sh_keysc_priv *p,
65 unsigned long keys_set)
66{
67 struct sh_keysc_info *pdata = &p->pdata;
68
69 sh_keysc_write(p, KYOUTDR, 0);
70 sh_keysc_write(p, KYCR2, KYCR2_IRQ_LEVEL | (keys_set << 8));
71
72 if (pdata->kycr2_delay)
73 udelay(pdata->kycr2_delay);
74}
75
76static void sh_keysc_map_dbg(struct device *dev, unsigned long *map,
77 const char *str)
78{
79 int k;
80
81 for (k = 0; k < BITS_TO_LONGS(SH_KEYSC_MAXKEYS); k++)
82 dev_dbg(dev, "%s[%d] 0x%lx\n", str, k, map[k]);
83}
84
49static irqreturn_t sh_keysc_isr(int irq, void *dev_id) 85static irqreturn_t sh_keysc_isr(int irq, void *dev_id)
50{ 86{
51 struct platform_device *pdev = dev_id; 87 struct platform_device *pdev = dev_id;
52 struct sh_keysc_priv *priv = platform_get_drvdata(pdev); 88 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
53 struct sh_keysc_info *pdata = &priv->pdata; 89 struct sh_keysc_info *pdata = &priv->pdata;
54 unsigned long keys, keys1, keys0, mask; 90 int keyout_nr = sh_keysc_mode[pdata->mode].keyout;
91 int keyin_nr = sh_keysc_mode[pdata->mode].keyin;
92 DECLARE_BITMAP(keys, SH_KEYSC_MAXKEYS);
93 DECLARE_BITMAP(keys0, SH_KEYSC_MAXKEYS);
94 DECLARE_BITMAP(keys1, SH_KEYSC_MAXKEYS);
55 unsigned char keyin_set, tmp; 95 unsigned char keyin_set, tmp;
56 int i, k; 96 int i, k, n;
57 97
58 dev_dbg(&pdev->dev, "isr!\n"); 98 dev_dbg(&pdev->dev, "isr!\n");
59 99
60 keys1 = ~0; 100 bitmap_fill(keys1, SH_KEYSC_MAXKEYS);
61 keys0 = 0; 101 bitmap_zero(keys0, SH_KEYSC_MAXKEYS);
62 102
63 do { 103 do {
64 keys = 0; 104 bitmap_zero(keys, SH_KEYSC_MAXKEYS);
65 keyin_set = 0; 105 keyin_set = 0;
66 106
67 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS); 107 sh_keysc_write(priv, KYCR2, KYCR2_IRQ_DISABLED);
108
109 for (i = 0; i < keyout_nr; i++) {
110 n = keyin_nr * i;
68 111
69 for (i = 0; i < sh_keysc_mode[pdata->mode].keyout; i++) { 112 /* drive one KEYOUT pin low, read KEYIN pins */
70 iowrite16(0xfff ^ (3 << (i * 2)), 113 sh_keysc_write(priv, KYOUTDR, 0xffff ^ (3 << (i * 2)));
71 priv->iomem_base + KYOUTDR_OFFS);
72 udelay(pdata->delay); 114 udelay(pdata->delay);
73 tmp = ioread16(priv->iomem_base + KYINDR_OFFS); 115 tmp = sh_keysc_read(priv, KYINDR);
74 keys |= tmp << (sh_keysc_mode[pdata->mode].keyin * i);
75 tmp ^= (1 << sh_keysc_mode[pdata->mode].keyin) - 1;
76 keyin_set |= tmp;
77 }
78 116
79 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); 117 /* set bit if key press has been detected */
80 iowrite16(KYCR2_IRQ_LEVEL | (keyin_set << 8), 118 for (k = 0; k < keyin_nr; k++) {
81 priv->iomem_base + KYCR2_OFFS); 119 if (tmp & (1 << k))
120 __set_bit(n + k, keys);
121 }
82 122
83 if (pdata->kycr2_delay) 123 /* keep track of which KEYIN bits that have been set */
84 udelay(pdata->kycr2_delay); 124 keyin_set |= tmp ^ ((1 << keyin_nr) - 1);
125 }
85 126
86 keys ^= ~0; 127 sh_keysc_level_mode(priv, keyin_set);
87 keys &= (1 << (sh_keysc_mode[pdata->mode].keyin *
88 sh_keysc_mode[pdata->mode].keyout)) - 1;
89 keys1 &= keys;
90 keys0 |= keys;
91 128
92 dev_dbg(&pdev->dev, "keys 0x%08lx\n", keys); 129 bitmap_complement(keys, keys, SH_KEYSC_MAXKEYS);
130 bitmap_and(keys1, keys1, keys, SH_KEYSC_MAXKEYS);
131 bitmap_or(keys0, keys0, keys, SH_KEYSC_MAXKEYS);
93 132
94 } while (ioread16(priv->iomem_base + KYCR2_OFFS) & 0x01); 133 sh_keysc_map_dbg(&pdev->dev, keys, "keys");
95 134
96 dev_dbg(&pdev->dev, "last_keys 0x%08lx keys0 0x%08lx keys1 0x%08lx\n", 135 } while (sh_keysc_read(priv, KYCR2) & 0x01);
97 priv->last_keys, keys0, keys1); 136
137 sh_keysc_map_dbg(&pdev->dev, priv->last_keys, "last_keys");
138 sh_keysc_map_dbg(&pdev->dev, keys0, "keys0");
139 sh_keysc_map_dbg(&pdev->dev, keys1, "keys1");
98 140
99 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { 141 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) {
100 k = pdata->keycodes[i]; 142 k = pdata->keycodes[i];
101 if (!k) 143 if (!k)
102 continue; 144 continue;
103 145
104 mask = 1 << i; 146 if (test_bit(i, keys0) == test_bit(i, priv->last_keys))
105
106 if (!((priv->last_keys ^ keys0) & mask))
107 continue; 147 continue;
108 148
109 if ((keys1 | keys0) & mask) { 149 if (test_bit(i, keys1) || test_bit(i, keys0)) {
110 input_event(priv->input, EV_KEY, k, 1); 150 input_event(priv->input, EV_KEY, k, 1);
111 priv->last_keys |= mask; 151 __set_bit(i, priv->last_keys);
112 } 152 }
113 153
114 if (!(keys1 & mask)) { 154 if (!test_bit(i, keys1)) {
115 input_event(priv->input, EV_KEY, k, 0); 155 input_event(priv->input, EV_KEY, k, 0);
116 priv->last_keys &= ~mask; 156 __clear_bit(i, priv->last_keys);
117 } 157 }
118 158
119 } 159 }
@@ -122,8 +162,6 @@ static irqreturn_t sh_keysc_isr(int irq, void *dev_id)
122 return IRQ_HANDLED; 162 return IRQ_HANDLED;
123} 163}
124 164
125#define res_size(res) ((res)->end - (res)->start + 1)
126
127static int __devinit sh_keysc_probe(struct platform_device *pdev) 165static int __devinit sh_keysc_probe(struct platform_device *pdev)
128{ 166{
129 struct sh_keysc_priv *priv; 167 struct sh_keysc_priv *priv;
@@ -164,7 +202,7 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
164 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); 202 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata));
165 pdata = &priv->pdata; 203 pdata = &priv->pdata;
166 204
167 priv->iomem_base = ioremap_nocache(res->start, res_size(res)); 205 priv->iomem_base = ioremap_nocache(res->start, resource_size(res));
168 if (priv->iomem_base == NULL) { 206 if (priv->iomem_base == NULL) {
169 dev_err(&pdev->dev, "failed to remap I/O memory\n"); 207 dev_err(&pdev->dev, "failed to remap I/O memory\n");
170 error = -ENXIO; 208 error = -ENXIO;
@@ -220,10 +258,9 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
220 258
221 clk_enable(priv->clk); 259 clk_enable(priv->clk);
222 260
223 iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | 261 sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) |
224 pdata->scan_timing, priv->iomem_base + KYCR1_OFFS); 262 pdata->scan_timing);
225 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); 263 sh_keysc_level_mode(priv, 0);
226 iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS);
227 264
228 device_init_wakeup(&pdev->dev, 1); 265 device_init_wakeup(&pdev->dev, 1);
229 266
@@ -248,7 +285,7 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev)
248{ 285{
249 struct sh_keysc_priv *priv = platform_get_drvdata(pdev); 286 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
250 287
251 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS); 288 sh_keysc_write(priv, KYCR2, KYCR2_IRQ_DISABLED);
252 289
253 input_unregister_device(priv->input); 290 input_unregister_device(priv->input);
254 free_irq(platform_get_irq(pdev, 0), pdev); 291 free_irq(platform_get_irq(pdev, 0), pdev);
@@ -270,7 +307,7 @@ static int sh_keysc_suspend(struct device *dev)
270 int irq = platform_get_irq(pdev, 0); 307 int irq = platform_get_irq(pdev, 0);
271 unsigned short value; 308 unsigned short value;
272 309
273 value = ioread16(priv->iomem_base + KYCR1_OFFS); 310 value = sh_keysc_read(priv, KYCR1);
274 311
275 if (device_may_wakeup(dev)) { 312 if (device_may_wakeup(dev)) {
276 value |= 0x80; 313 value |= 0x80;
@@ -279,7 +316,7 @@ static int sh_keysc_suspend(struct device *dev)
279 value &= ~0x80; 316 value &= ~0x80;
280 } 317 }
281 318
282 iowrite16(value, priv->iomem_base + KYCR1_OFFS); 319 sh_keysc_write(priv, KYCR1, value);
283 320
284 return 0; 321 return 0;
285} 322}
diff --git a/drivers/input/misc/apanel.c b/drivers/input/misc/apanel.c
index 71b82434264d..a8d2b8db4e35 100644
--- a/drivers/input/misc/apanel.c
+++ b/drivers/input/misc/apanel.c
@@ -149,7 +149,7 @@ static void apanel_shutdown(struct i2c_client *client)
149 apanel_remove(client); 149 apanel_remove(client);
150} 150}
151 151
152static struct i2c_device_id apanel_id[] = { 152static const struct i2c_device_id apanel_id[] = {
153 { "fujitsu_apanel", 0 }, 153 { "fujitsu_apanel", 0 },
154 { } 154 { }
155}; 155};
diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
index 1b871917340a..dfaa9a045ed8 100644
--- a/drivers/input/misc/atlas_btns.c
+++ b/drivers/input/misc/atlas_btns.c
@@ -47,7 +47,7 @@ static acpi_status acpi_atlas_button_setup(acpi_handle region_handle,
47 47
48static acpi_status acpi_atlas_button_handler(u32 function, 48static acpi_status acpi_atlas_button_handler(u32 function,
49 acpi_physical_address address, 49 acpi_physical_address address,
50 u32 bit_width, acpi_integer *value, 50 u32 bit_width, u64 *value,
51 void *handler_context, void *region_context) 51 void *handler_context, void *region_context)
52{ 52{
53 acpi_status status; 53 acpi_status status;
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 3b9f588fc747..4ae07935985e 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -152,6 +152,13 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
152 goto exit_unregister_input; 152 goto exit_unregister_input;
153 } 153 }
154 154
155 err = gpio_direction_input(pdata->gpio_a);
156 if (err) {
157 dev_err(&pdev->dev, "unable to set GPIO %d for input\n",
158 pdata->gpio_a);
159 goto exit_unregister_input;
160 }
161
155 err = gpio_request(pdata->gpio_b, DRV_NAME); 162 err = gpio_request(pdata->gpio_b, DRV_NAME);
156 if (err) { 163 if (err) {
157 dev_err(&pdev->dev, "unable to request GPIO %d\n", 164 dev_err(&pdev->dev, "unable to request GPIO %d\n",
@@ -159,6 +166,13 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
159 goto exit_free_gpio_a; 166 goto exit_free_gpio_a;
160 } 167 }
161 168
169 err = gpio_direction_input(pdata->gpio_b);
170 if (err) {
171 dev_err(&pdev->dev, "unable to set GPIO %d for input\n",
172 pdata->gpio_b);
173 goto exit_free_gpio_a;
174 }
175
162 /* request the IRQs */ 176 /* request the IRQs */
163 err = request_irq(encoder->irq_a, &rotary_encoder_irq, 177 err = request_irq(encoder->irq_a, &rotary_encoder_irq,
164 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE, 178 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE,
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index d3f57245420a..1477466076ad 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -34,7 +34,6 @@
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/smp_lock.h>
38#include <linux/fs.h> 37#include <linux/fs.h>
39#include <linux/miscdevice.h> 38#include <linux/miscdevice.h>
40#include <linux/uinput.h> 39#include <linux/uinput.h>
@@ -284,7 +283,6 @@ static int uinput_open(struct inode *inode, struct file *file)
284 if (!newdev) 283 if (!newdev)
285 return -ENOMEM; 284 return -ENOMEM;
286 285
287 lock_kernel();
288 mutex_init(&newdev->mutex); 286 mutex_init(&newdev->mutex);
289 spin_lock_init(&newdev->requests_lock); 287 spin_lock_init(&newdev->requests_lock);
290 init_waitqueue_head(&newdev->requests_waitq); 288 init_waitqueue_head(&newdev->requests_waitq);
@@ -292,7 +290,7 @@ static int uinput_open(struct inode *inode, struct file *file)
292 newdev->state = UIST_NEW_DEVICE; 290 newdev->state = UIST_NEW_DEVICE;
293 291
294 file->private_data = newdev; 292 file->private_data = newdev;
295 unlock_kernel(); 293 nonseekable_open(inode, file);
296 294
297 return 0; 295 return 0;
298} 296}
diff --git a/drivers/input/misc/winbond-cir.c b/drivers/input/misc/winbond-cir.c
index c8f5a9a3fa14..cbec3dfdd42b 100644
--- a/drivers/input/misc/winbond-cir.c
+++ b/drivers/input/misc/winbond-cir.c
@@ -538,6 +538,7 @@ wbcir_reset_irdata(struct wbcir_data *data)
538 data->irdata_count = 0; 538 data->irdata_count = 0;
539 data->irdata_off = 0; 539 data->irdata_off = 0;
540 data->irdata_error = 0; 540 data->irdata_error = 0;
541 data->idle_count = 0;
541} 542}
542 543
543/* Adds one bit of irdata */ 544/* Adds one bit of irdata */
@@ -1006,7 +1007,6 @@ wbcir_irq_handler(int irqno, void *cookie)
1006 } 1007 }
1007 1008
1008 wbcir_reset_irdata(data); 1009 wbcir_reset_irdata(data);
1009 data->idle_count = 0;
1010 } 1010 }
1011 1011
1012out: 1012out:
@@ -1018,7 +1018,7 @@ out:
1018 1018
1019/***************************************************************************** 1019/*****************************************************************************
1020 * 1020 *
1021 * SUSPEND/RESUME FUNCTIONS 1021 * SETUP/INIT/SUSPEND/RESUME FUNCTIONS
1022 * 1022 *
1023 *****************************************************************************/ 1023 *****************************************************************************/
1024 1024
@@ -1197,7 +1197,16 @@ finish:
1197 } 1197 }
1198 1198
1199 /* Disable interrupts */ 1199 /* Disable interrupts */
1200 wbcir_select_bank(data, WBCIR_BANK_0);
1200 outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER); 1201 outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER);
1202
1203 /*
1204 * ACPI will set the HW disable bit for SP3 which means that the
1205 * output signals are left in an undefined state which may cause
1206 * spurious interrupts which we need to ignore until the hardware
1207 * is reinitialized.
1208 */
1209 disable_irq(data->irq);
1201} 1210}
1202 1211
1203static int 1212static int
@@ -1207,37 +1216,15 @@ wbcir_suspend(struct pnp_dev *device, pm_message_t state)
1207 return 0; 1216 return 0;
1208} 1217}
1209 1218
1210static int
1211wbcir_resume(struct pnp_dev *device)
1212{
1213 struct wbcir_data *data = pnp_get_drvdata(device);
1214
1215 /* Clear BUFF_EN, Clear END_EN, Clear MATCH_EN */
1216 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07);
1217
1218 /* Clear CEIR_EN */
1219 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x00, 0x01);
1220
1221 /* Enable interrupts */
1222 wbcir_reset_irdata(data);
1223 outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER);
1224
1225 return 0;
1226}
1227
1228
1229
1230/*****************************************************************************
1231 *
1232 * SETUP/INIT FUNCTIONS
1233 *
1234 *****************************************************************************/
1235
1236static void 1219static void
1237wbcir_cfg_ceir(struct wbcir_data *data) 1220wbcir_init_hw(struct wbcir_data *data)
1238{ 1221{
1239 u8 tmp; 1222 u8 tmp;
1240 1223
1224 /* Disable interrupts */
1225 wbcir_select_bank(data, WBCIR_BANK_0);
1226 outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER);
1227
1241 /* Set PROT_SEL, RX_INV, Clear CEIR_EN (needed for the led) */ 1228 /* Set PROT_SEL, RX_INV, Clear CEIR_EN (needed for the led) */
1242 tmp = protocol << 4; 1229 tmp = protocol << 4;
1243 if (invert) 1230 if (invert)
@@ -1264,6 +1251,93 @@ wbcir_cfg_ceir(struct wbcir_data *data)
1264 * set SP3_IRRX_SW to binary 01, helpfully not documented 1251 * set SP3_IRRX_SW to binary 01, helpfully not documented
1265 */ 1252 */
1266 outb(0x10, data->ebase + WBCIR_REG_ECEIR_CTS); 1253 outb(0x10, data->ebase + WBCIR_REG_ECEIR_CTS);
1254
1255 /* Enable extended mode */
1256 wbcir_select_bank(data, WBCIR_BANK_2);
1257 outb(WBCIR_EXT_ENABLE, data->sbase + WBCIR_REG_SP3_EXCR1);
1258
1259 /*
1260 * Configure baud generator, IR data will be sampled at
1261 * a bitrate of: (24Mhz * prescaler) / (divisor * 16).
1262 *
1263 * The ECIR registers include a flag to change the
1264 * 24Mhz clock freq to 48Mhz.
1265 *
1266 * It's not documented in the specs, but fifo levels
1267 * other than 16 seems to be unsupported.
1268 */
1269
1270 /* prescaler 1.0, tx/rx fifo lvl 16 */
1271 outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2);
1272
1273 /* Set baud divisor to generate one byte per bit/cell */
1274 switch (protocol) {
1275 case IR_PROTOCOL_RC5:
1276 outb(0xA7, data->sbase + WBCIR_REG_SP3_BGDL);
1277 break;
1278 case IR_PROTOCOL_RC6:
1279 outb(0x53, data->sbase + WBCIR_REG_SP3_BGDL);
1280 break;
1281 case IR_PROTOCOL_NEC:
1282 outb(0x69, data->sbase + WBCIR_REG_SP3_BGDL);
1283 break;
1284 }
1285 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
1286
1287 /* Set CEIR mode */
1288 wbcir_select_bank(data, WBCIR_BANK_0);
1289 outb(0xC0, data->sbase + WBCIR_REG_SP3_MCR);
1290 inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */
1291 inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */
1292
1293 /* Disable RX demod, run-length encoding/decoding, set freq span */
1294 wbcir_select_bank(data, WBCIR_BANK_7);
1295 outb(0x10, data->sbase + WBCIR_REG_SP3_RCCFG);
1296
1297 /* Disable timer */
1298 wbcir_select_bank(data, WBCIR_BANK_4);
1299 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR1);
1300
1301 /* Enable MSR interrupt, Clear AUX_IRX */
1302 wbcir_select_bank(data, WBCIR_BANK_5);
1303 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR2);
1304
1305 /* Disable CRC */
1306 wbcir_select_bank(data, WBCIR_BANK_6);
1307 outb(0x20, data->sbase + WBCIR_REG_SP3_IRCR3);
1308
1309 /* Set RX/TX (de)modulation freq, not really used */
1310 wbcir_select_bank(data, WBCIR_BANK_7);
1311 outb(0xF2, data->sbase + WBCIR_REG_SP3_IRRXDC);
1312 outb(0x69, data->sbase + WBCIR_REG_SP3_IRTXMC);
1313
1314 /* Set invert and pin direction */
1315 if (invert)
1316 outb(0x10, data->sbase + WBCIR_REG_SP3_IRCFG4);
1317 else
1318 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCFG4);
1319
1320 /* Set FIFO thresholds (RX = 8, TX = 3), reset RX/TX */
1321 wbcir_select_bank(data, WBCIR_BANK_0);
1322 outb(0x97, data->sbase + WBCIR_REG_SP3_FCR);
1323
1324 /* Clear AUX status bits */
1325 outb(0xE0, data->sbase + WBCIR_REG_SP3_ASCR);
1326
1327 /* Enable interrupts */
1328 wbcir_reset_irdata(data);
1329 outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER);
1330}
1331
1332static int
1333wbcir_resume(struct pnp_dev *device)
1334{
1335 struct wbcir_data *data = pnp_get_drvdata(device);
1336
1337 wbcir_init_hw(data);
1338 enable_irq(data->irq);
1339
1340 return 0;
1267} 1341}
1268 1342
1269static int __devinit 1343static int __devinit
@@ -1393,86 +1467,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1393 1467
1394 device_init_wakeup(&device->dev, 1); 1468 device_init_wakeup(&device->dev, 1);
1395 1469
1396 wbcir_cfg_ceir(data); 1470 wbcir_init_hw(data);
1397
1398 /* Disable interrupts */
1399 wbcir_select_bank(data, WBCIR_BANK_0);
1400 outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER);
1401
1402 /* Enable extended mode */
1403 wbcir_select_bank(data, WBCIR_BANK_2);
1404 outb(WBCIR_EXT_ENABLE, data->sbase + WBCIR_REG_SP3_EXCR1);
1405
1406 /*
1407 * Configure baud generator, IR data will be sampled at
1408 * a bitrate of: (24Mhz * prescaler) / (divisor * 16).
1409 *
1410 * The ECIR registers include a flag to change the
1411 * 24Mhz clock freq to 48Mhz.
1412 *
1413 * It's not documented in the specs, but fifo levels
1414 * other than 16 seems to be unsupported.
1415 */
1416
1417 /* prescaler 1.0, tx/rx fifo lvl 16 */
1418 outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2);
1419
1420 /* Set baud divisor to generate one byte per bit/cell */
1421 switch (protocol) {
1422 case IR_PROTOCOL_RC5:
1423 outb(0xA7, data->sbase + WBCIR_REG_SP3_BGDL);
1424 break;
1425 case IR_PROTOCOL_RC6:
1426 outb(0x53, data->sbase + WBCIR_REG_SP3_BGDL);
1427 break;
1428 case IR_PROTOCOL_NEC:
1429 outb(0x69, data->sbase + WBCIR_REG_SP3_BGDL);
1430 break;
1431 }
1432 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
1433
1434 /* Set CEIR mode */
1435 wbcir_select_bank(data, WBCIR_BANK_0);
1436 outb(0xC0, data->sbase + WBCIR_REG_SP3_MCR);
1437 inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */
1438 inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */
1439
1440 /* Disable RX demod, run-length encoding/decoding, set freq span */
1441 wbcir_select_bank(data, WBCIR_BANK_7);
1442 outb(0x10, data->sbase + WBCIR_REG_SP3_RCCFG);
1443
1444 /* Disable timer */
1445 wbcir_select_bank(data, WBCIR_BANK_4);
1446 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR1);
1447
1448 /* Enable MSR interrupt, Clear AUX_IRX */
1449 wbcir_select_bank(data, WBCIR_BANK_5);
1450 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR2);
1451
1452 /* Disable CRC */
1453 wbcir_select_bank(data, WBCIR_BANK_6);
1454 outb(0x20, data->sbase + WBCIR_REG_SP3_IRCR3);
1455
1456 /* Set RX/TX (de)modulation freq, not really used */
1457 wbcir_select_bank(data, WBCIR_BANK_7);
1458 outb(0xF2, data->sbase + WBCIR_REG_SP3_IRRXDC);
1459 outb(0x69, data->sbase + WBCIR_REG_SP3_IRTXMC);
1460
1461 /* Set invert and pin direction */
1462 if (invert)
1463 outb(0x10, data->sbase + WBCIR_REG_SP3_IRCFG4);
1464 else
1465 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCFG4);
1466
1467 /* Set FIFO thresholds (RX = 8, TX = 3), reset RX/TX */
1468 wbcir_select_bank(data, WBCIR_BANK_0);
1469 outb(0x97, data->sbase + WBCIR_REG_SP3_FCR);
1470
1471 /* Clear AUX status bits */
1472 outb(0xE0, data->sbase + WBCIR_REG_SP3_ASCR);
1473
1474 /* Enable interrupts */
1475 outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER);
1476 1471
1477 return 0; 1472 return 0;
1478 1473
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
index 90be30e93556..9169d1591c1f 100644
--- a/drivers/input/mouse/hgpk.c
+++ b/drivers/input/mouse/hgpk.c
@@ -68,10 +68,6 @@ module_param(post_interrupt_delay, int, 0644);
68MODULE_PARM_DESC(post_interrupt_delay, 68MODULE_PARM_DESC(post_interrupt_delay,
69 "delay (ms) before recal after recal interrupt detected"); 69 "delay (ms) before recal after recal interrupt detected");
70 70
71static int autorecal = 1;
72module_param(autorecal, int, 0644);
73MODULE_PARM_DESC(autorecal, "enable recalibration in the driver");
74
75/* 71/*
76 * When the touchpad gets ultra-sensitive, one can keep their finger 1/2" 72 * When the touchpad gets ultra-sensitive, one can keep their finger 1/2"
77 * above the pad and still have it send packets. This causes a jump cursor 73 * above the pad and still have it send packets. This causes a jump cursor
diff --git a/drivers/input/serio/pcips2.c b/drivers/input/serio/pcips2.c
index 1dacbe0d9348..797314be7af2 100644
--- a/drivers/input/serio/pcips2.c
+++ b/drivers/input/serio/pcips2.c
@@ -186,7 +186,7 @@ static void __devexit pcips2_remove(struct pci_dev *dev)
186 pci_disable_device(dev); 186 pci_disable_device(dev);
187} 187}
188 188
189static struct pci_device_id pcips2_ids[] = { 189static const struct pci_device_id pcips2_ids[] = {
190 { 190 {
191 .vendor = 0x14f2, /* MOBILITY */ 191 .vendor = 0x14f2, /* MOBILITY */
192 .device = 0x0123, /* Keyboard */ 192 .device = 0x0123, /* Keyboard */
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index e0f30186d513..c3b626e9eae7 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -26,6 +26,8 @@
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 27 */
28 28
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30
29#include <linux/stddef.h> 31#include <linux/stddef.h>
30#include <linux/module.h> 32#include <linux/module.h>
31#include <linux/serio.h> 33#include <linux/serio.h>
@@ -119,11 +121,10 @@ static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
119 121
120 error = device_bind_driver(&serio->dev); 122 error = device_bind_driver(&serio->dev);
121 if (error) { 123 if (error) {
122 printk(KERN_WARNING 124 dev_warn(&serio->dev,
123 "serio: device_bind_driver() failed " 125 "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
124 "for %s (%s) and %s, error: %d\n", 126 serio->phys, serio->name,
125 serio->phys, serio->name, 127 drv->description, error);
126 drv->description, error);
127 serio_disconnect_driver(serio); 128 serio_disconnect_driver(serio);
128 serio->dev.driver = NULL; 129 serio->dev.driver = NULL;
129 return error; 130 return error;
@@ -138,9 +139,9 @@ static void serio_find_driver(struct serio *serio)
138 139
139 error = device_attach(&serio->dev); 140 error = device_attach(&serio->dev);
140 if (error < 0) 141 if (error < 0)
141 printk(KERN_WARNING 142 dev_warn(&serio->dev,
142 "serio: device_attach() failed for %s (%s), error: %d\n", 143 "device_attach() failed for %s (%s), error: %d\n",
143 serio->phys, serio->name, error); 144 serio->phys, serio->name, error);
144} 145}
145 146
146 147
@@ -194,17 +195,14 @@ static int serio_queue_event(void *object, struct module *owner,
194 195
195 event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC); 196 event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC);
196 if (!event) { 197 if (!event) {
197 printk(KERN_ERR 198 pr_err("Not enough memory to queue event %d\n", event_type);
198 "serio: Not enough memory to queue event %d\n",
199 event_type);
200 retval = -ENOMEM; 199 retval = -ENOMEM;
201 goto out; 200 goto out;
202 } 201 }
203 202
204 if (!try_module_get(owner)) { 203 if (!try_module_get(owner)) {
205 printk(KERN_WARNING 204 pr_warning("Can't get module reference, dropping event %d\n",
206 "serio: Can't get module reference, dropping event %d\n", 205 event_type);
207 event_type);
208 kfree(event); 206 kfree(event);
209 retval = -EINVAL; 207 retval = -EINVAL;
210 goto out; 208 goto out;
@@ -230,14 +228,12 @@ static void serio_free_event(struct serio_event *event)
230 228
231static void serio_remove_duplicate_events(struct serio_event *event) 229static void serio_remove_duplicate_events(struct serio_event *event)
232{ 230{
233 struct list_head *node, *next; 231 struct serio_event *e, *next;
234 struct serio_event *e;
235 unsigned long flags; 232 unsigned long flags;
236 233
237 spin_lock_irqsave(&serio_event_lock, flags); 234 spin_lock_irqsave(&serio_event_lock, flags);
238 235
239 list_for_each_safe(node, next, &serio_event_list) { 236 list_for_each_entry_safe(e, next, &serio_event_list, node) {
240 e = list_entry(node, struct serio_event, node);
241 if (event->object == e->object) { 237 if (event->object == e->object) {
242 /* 238 /*
243 * If this event is of different type we should not 239 * If this event is of different type we should not
@@ -247,7 +243,7 @@ static void serio_remove_duplicate_events(struct serio_event *event)
247 if (event->type != e->type) 243 if (event->type != e->type)
248 break; 244 break;
249 245
250 list_del_init(node); 246 list_del_init(&e->node);
251 serio_free_event(e); 247 serio_free_event(e);
252 } 248 }
253 } 249 }
@@ -258,23 +254,18 @@ static void serio_remove_duplicate_events(struct serio_event *event)
258 254
259static struct serio_event *serio_get_event(void) 255static struct serio_event *serio_get_event(void)
260{ 256{
261 struct serio_event *event; 257 struct serio_event *event = NULL;
262 struct list_head *node;
263 unsigned long flags; 258 unsigned long flags;
264 259
265 spin_lock_irqsave(&serio_event_lock, flags); 260 spin_lock_irqsave(&serio_event_lock, flags);
266 261
267 if (list_empty(&serio_event_list)) { 262 if (!list_empty(&serio_event_list)) {
268 spin_unlock_irqrestore(&serio_event_lock, flags); 263 event = list_first_entry(&serio_event_list,
269 return NULL; 264 struct serio_event, node);
265 list_del_init(&event->node);
270 } 266 }
271 267
272 node = serio_event_list.next;
273 event = list_entry(node, struct serio_event, node);
274 list_del_init(node);
275
276 spin_unlock_irqrestore(&serio_event_lock, flags); 268 spin_unlock_irqrestore(&serio_event_lock, flags);
277
278 return event; 269 return event;
279} 270}
280 271
@@ -287,29 +278,27 @@ static void serio_handle_event(void)
287 while ((event = serio_get_event())) { 278 while ((event = serio_get_event())) {
288 279
289 switch (event->type) { 280 switch (event->type) {
290 case SERIO_REGISTER_PORT:
291 serio_add_port(event->object);
292 break;
293 281
294 case SERIO_RECONNECT_PORT: 282 case SERIO_REGISTER_PORT:
295 serio_reconnect_port(event->object); 283 serio_add_port(event->object);
296 break; 284 break;
297 285
298 case SERIO_RESCAN_PORT: 286 case SERIO_RECONNECT_PORT:
299 serio_disconnect_port(event->object); 287 serio_reconnect_port(event->object);
300 serio_find_driver(event->object); 288 break;
301 break;
302 289
303 case SERIO_RECONNECT_CHAIN: 290 case SERIO_RESCAN_PORT:
304 serio_reconnect_chain(event->object); 291 serio_disconnect_port(event->object);
305 break; 292 serio_find_driver(event->object);
293 break;
306 294
307 case SERIO_ATTACH_DRIVER: 295 case SERIO_RECONNECT_CHAIN:
308 serio_attach_driver(event->object); 296 serio_reconnect_chain(event->object);
309 break; 297 break;
310 298
311 default: 299 case SERIO_ATTACH_DRIVER:
312 break; 300 serio_attach_driver(event->object);
301 break;
313 } 302 }
314 303
315 serio_remove_duplicate_events(event); 304 serio_remove_duplicate_events(event);
@@ -325,16 +314,14 @@ static void serio_handle_event(void)
325 */ 314 */
326static void serio_remove_pending_events(void *object) 315static void serio_remove_pending_events(void *object)
327{ 316{
328 struct list_head *node, *next; 317 struct serio_event *event, *next;
329 struct serio_event *event;
330 unsigned long flags; 318 unsigned long flags;
331 319
332 spin_lock_irqsave(&serio_event_lock, flags); 320 spin_lock_irqsave(&serio_event_lock, flags);
333 321
334 list_for_each_safe(node, next, &serio_event_list) { 322 list_for_each_entry_safe(event, next, &serio_event_list, node) {
335 event = list_entry(node, struct serio_event, node);
336 if (event->object == object) { 323 if (event->object == object) {
337 list_del_init(node); 324 list_del_init(&event->node);
338 serio_free_event(event); 325 serio_free_event(event);
339 } 326 }
340 } 327 }
@@ -380,7 +367,6 @@ static int serio_thread(void *nothing)
380 kthread_should_stop() || !list_empty(&serio_event_list)); 367 kthread_should_stop() || !list_empty(&serio_event_list));
381 } while (!kthread_should_stop()); 368 } while (!kthread_should_stop());
382 369
383 printk(KERN_DEBUG "serio: kseriod exiting\n");
384 return 0; 370 return 0;
385} 371}
386 372
@@ -445,6 +431,11 @@ static struct attribute_group serio_id_attr_group = {
445 .attrs = serio_device_id_attrs, 431 .attrs = serio_device_id_attrs,
446}; 432};
447 433
434static const struct attribute_group *serio_device_attr_groups[] = {
435 &serio_id_attr_group,
436 NULL
437};
438
448static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 439static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
449{ 440{
450 struct serio *serio = to_serio_port(dev); 441 struct serio *serio = to_serio_port(dev);
@@ -532,6 +523,7 @@ static void serio_init_port(struct serio *serio)
532 (long)atomic_inc_return(&serio_no) - 1); 523 (long)atomic_inc_return(&serio_no) - 1);
533 serio->dev.bus = &serio_bus; 524 serio->dev.bus = &serio_bus;
534 serio->dev.release = serio_release_port; 525 serio->dev.release = serio_release_port;
526 serio->dev.groups = serio_device_attr_groups;
535 if (serio->parent) { 527 if (serio->parent) {
536 serio->dev.parent = &serio->parent->dev; 528 serio->dev.parent = &serio->parent->dev;
537 serio->depth = serio->parent->depth + 1; 529 serio->depth = serio->parent->depth + 1;
@@ -555,21 +547,15 @@ static void serio_add_port(struct serio *serio)
555 } 547 }
556 548
557 list_add_tail(&serio->node, &serio_list); 549 list_add_tail(&serio->node, &serio_list);
550
558 if (serio->start) 551 if (serio->start)
559 serio->start(serio); 552 serio->start(serio);
553
560 error = device_add(&serio->dev); 554 error = device_add(&serio->dev);
561 if (error) 555 if (error)
562 printk(KERN_ERR 556 dev_err(&serio->dev,
563 "serio: device_add() failed for %s (%s), error: %d\n", 557 "device_add() failed for %s (%s), error: %d\n",
564 serio->phys, serio->name, error); 558 serio->phys, serio->name, error);
565 else {
566 serio->registered = true;
567 error = sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
568 if (error)
569 printk(KERN_ERR
570 "serio: sysfs_create_group() failed for %s (%s), error: %d\n",
571 serio->phys, serio->name, error);
572 }
573} 559}
574 560
575/* 561/*
@@ -596,11 +582,8 @@ static void serio_destroy_port(struct serio *serio)
596 serio->parent = NULL; 582 serio->parent = NULL;
597 } 583 }
598 584
599 if (serio->registered) { 585 if (device_is_registered(&serio->dev))
600 sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
601 device_del(&serio->dev); 586 device_del(&serio->dev);
602 serio->registered = false;
603 }
604 587
605 list_del_init(&serio->node); 588 list_del_init(&serio->node);
606 serio_remove_pending_events(serio); 589 serio_remove_pending_events(serio);
@@ -798,9 +781,8 @@ static void serio_attach_driver(struct serio_driver *drv)
798 781
799 error = driver_attach(&drv->driver); 782 error = driver_attach(&drv->driver);
800 if (error) 783 if (error)
801 printk(KERN_WARNING 784 pr_warning("driver_attach() failed for %s with error %d\n",
802 "serio: driver_attach() failed for %s with error %d\n", 785 drv->driver.name, error);
803 drv->driver.name, error);
804} 786}
805 787
806int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name) 788int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name)
@@ -820,8 +802,7 @@ int __serio_register_driver(struct serio_driver *drv, struct module *owner, cons
820 802
821 error = driver_register(&drv->driver); 803 error = driver_register(&drv->driver);
822 if (error) { 804 if (error) {
823 printk(KERN_ERR 805 pr_err("driver_register() failed for %s, error: %d\n",
824 "serio: driver_register() failed for %s, error: %d\n",
825 drv->driver.name, error); 806 drv->driver.name, error);
826 return error; 807 return error;
827 } 808 }
@@ -987,7 +968,7 @@ irqreturn_t serio_interrupt(struct serio *serio,
987 968
988 if (likely(serio->drv)) { 969 if (likely(serio->drv)) {
989 ret = serio->drv->interrupt(serio, data, dfl); 970 ret = serio->drv->interrupt(serio, data, dfl);
990 } else if (!dfl && serio->registered) { 971 } else if (!dfl && device_is_registered(&serio->dev)) {
991 serio_rescan(serio); 972 serio_rescan(serio);
992 ret = IRQ_HANDLED; 973 ret = IRQ_HANDLED;
993 } 974 }
@@ -1018,7 +999,7 @@ static int __init serio_init(void)
1018 999
1019 error = bus_register(&serio_bus); 1000 error = bus_register(&serio_bus);
1020 if (error) { 1001 if (error) {
1021 printk(KERN_ERR "serio: failed to register serio bus, error: %d\n", error); 1002 pr_err("Failed to register serio bus, error: %d\n", error);
1022 return error; 1003 return error;
1023 } 1004 }
1024 1005
@@ -1026,7 +1007,7 @@ static int __init serio_init(void)
1026 if (IS_ERR(serio_task)) { 1007 if (IS_ERR(serio_task)) {
1027 bus_unregister(&serio_bus); 1008 bus_unregister(&serio_bus);
1028 error = PTR_ERR(serio_task); 1009 error = PTR_ERR(serio_task);
1029 printk(KERN_ERR "serio: Failed to start kseriod, error: %d\n", error); 1010 pr_err("Failed to start kseriod, error: %d\n", error);
1030 return error; 1011 return error;
1031 } 1012 }
1032 1013
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c
index ebb22f88c842..8298e1f68234 100644
--- a/drivers/input/serio/xilinx_ps2.c
+++ b/drivers/input/serio/xilinx_ps2.c
@@ -270,7 +270,7 @@ static int __devinit xps2_of_probe(struct of_device *ofdev,
270 drvdata->irq = r_irq.start; 270 drvdata->irq = r_irq.start;
271 271
272 phys_addr = r_mem.start; 272 phys_addr = r_mem.start;
273 remap_size = r_mem.end - r_mem.start + 1; 273 remap_size = resource_size(&r_mem);
274 if (!request_mem_region(phys_addr, remap_size, DRIVER_NAME)) { 274 if (!request_mem_region(phys_addr, remap_size, DRIVER_NAME)) {
275 dev_err(dev, "Couldn't lock memory region at 0x%08llX\n", 275 dev_err(dev, "Couldn't lock memory region at 0x%08llX\n",
276 (unsigned long long)phys_addr); 276 (unsigned long long)phys_addr);
@@ -344,7 +344,7 @@ static int __devexit xps2_of_remove(struct of_device *of_dev)
344 if (of_address_to_resource(of_dev->node, 0, &r_mem)) 344 if (of_address_to_resource(of_dev->node, 0, &r_mem))
345 dev_err(dev, "invalid address\n"); 345 dev_err(dev, "invalid address\n");
346 else 346 else
347 release_mem_region(r_mem.start, r_mem.end - r_mem.start + 1); 347 release_mem_region(r_mem.start, resource_size(&r_mem));
348 348
349 kfree(drvdata); 349 kfree(drvdata);
350 350
@@ -354,7 +354,7 @@ static int __devexit xps2_of_remove(struct of_device *of_dev)
354} 354}
355 355
356/* Match table for of_platform binding */ 356/* Match table for of_platform binding */
357static struct of_device_id xps2_of_match[] __devinitdata = { 357static const struct of_device_id xps2_of_match[] __devinitconst = {
358 { .compatible = "xlnx,xps-ps2-1.00.a", }, 358 { .compatible = "xlnx,xps-ps2-1.00.a", },
359 { /* end of list */ }, 359 { /* end of list */ },
360}; 360};
diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
index 3d32d3f4e486..866a9ee1af1a 100644
--- a/drivers/input/tablet/gtco.c
+++ b/drivers/input/tablet/gtco.c
@@ -92,7 +92,7 @@ Scott Hill shill@gtcocalcomp.com
92/* DATA STRUCTURES */ 92/* DATA STRUCTURES */
93 93
94/* Device table */ 94/* Device table */
95static struct usb_device_id gtco_usbid_table [] = { 95static const struct usb_device_id gtco_usbid_table[] = {
96 { USB_DEVICE(VENDOR_ID_GTCO, PID_400) }, 96 { USB_DEVICE(VENDOR_ID_GTCO, PID_400) },
97 { USB_DEVICE(VENDOR_ID_GTCO, PID_401) }, 97 { USB_DEVICE(VENDOR_ID_GTCO, PID_401) },
98 { USB_DEVICE(VENDOR_ID_GTCO, PID_1000) }, 98 { USB_DEVICE(VENDOR_ID_GTCO, PID_1000) },
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index 16310f368dab..8fef1b689c69 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -85,6 +85,7 @@
85#include <linux/kernel.h> 85#include <linux/kernel.h>
86#include <linux/slab.h> 86#include <linux/slab.h>
87#include <linux/module.h> 87#include <linux/module.h>
88#include <linux/mod_devicetable.h>
88#include <linux/init.h> 89#include <linux/init.h>
89#include <linux/usb/input.h> 90#include <linux/usb/input.h>
90#include <asm/unaligned.h> 91#include <asm/unaligned.h>
@@ -120,6 +121,8 @@ struct wacom_combo {
120 struct urb *urb; 121 struct urb *urb;
121}; 122};
122 123
124extern const struct usb_device_id wacom_ids[];
125
123extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 126extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
124extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data); 127extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data);
125extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data); 128extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data);
@@ -142,7 +145,5 @@ extern void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wa
142extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 145extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
143extern __u16 wacom_le16_to_cpu(unsigned char *data); 146extern __u16 wacom_le16_to_cpu(unsigned char *data);
144extern __u16 wacom_be16_to_cpu(unsigned char *data); 147extern __u16 wacom_be16_to_cpu(unsigned char *data);
145extern struct wacom_features *get_wacom_feature(const struct usb_device_id *id);
146extern const struct usb_device_id *get_device_table(void);
147 148
148#endif 149#endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 072f33b3b2b0..a1770e6feeec 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -211,7 +211,8 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
211 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | 211 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
212 BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) | 212 BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) |
213 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); 213 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2);
214 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 214 input_set_abs_params(input_dev, ABS_DISTANCE,
215 0, wacom_wac->features.distance_max, 0, 0);
215} 216}
216 217
217void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 218void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -261,7 +262,8 @@ void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
261 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) | 262 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) |
262 BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) | 263 BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) |
263 BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2); 264 BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2);
264 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 265 input_set_abs_params(input_dev, ABS_DISTANCE,
266 0, wacom_wac->features.distance_max, 0, 0);
265 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); 267 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
266 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); 268 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
267 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); 269 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
@@ -282,17 +284,19 @@ void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
282 284
283void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 285void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
284{ 286{
285 if (wacom_wac->features->device_type == BTN_TOOL_DOUBLETAP || 287 struct wacom_features *features = &wacom_wac->features;
286 wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { 288
287 input_set_abs_params(input_dev, ABS_RX, 0, wacom_wac->features->x_phy, 0, 0); 289 if (features->device_type == BTN_TOOL_DOUBLETAP ||
288 input_set_abs_params(input_dev, ABS_RY, 0, wacom_wac->features->y_phy, 0, 0); 290 features->device_type == BTN_TOOL_TRIPLETAP) {
289 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_DOUBLETAP); 291 input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0);
292 input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0);
293 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
290 } 294 }
291} 295}
292 296
293void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 297void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
294{ 298{
295 if (wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { 299 if (wacom_wac->features.device_type == BTN_TOOL_TRIPLETAP) {
296 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP); 300 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP);
297 input_dev->evbit[0] |= BIT_MASK(EV_MSC); 301 input_dev->evbit[0] |= BIT_MASK(EV_MSC);
298 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); 302 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
@@ -532,21 +536,38 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
532 struct wacom_wac *wacom_wac; 536 struct wacom_wac *wacom_wac;
533 struct wacom_features *features; 537 struct wacom_features *features;
534 struct input_dev *input_dev; 538 struct input_dev *input_dev;
535 int error = -ENOMEM; 539 int error;
540
541 if (!id->driver_info)
542 return -EINVAL;
536 543
537 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 544 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
538 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); 545 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL);
539 input_dev = input_allocate_device(); 546 input_dev = input_allocate_device();
540 if (!wacom || !input_dev || !wacom_wac) 547 if (!wacom || !input_dev || !wacom_wac) {
548 error = -ENOMEM;
541 goto fail1; 549 goto fail1;
550 }
542 551
543 wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX, GFP_KERNEL, &wacom->data_dma); 552 wacom_wac->features = *((struct wacom_features *)id->driver_info);
544 if (!wacom_wac->data) 553 features = &wacom_wac->features;
554 if (features->pktlen > WACOM_PKGLEN_MAX) {
555 error = -EINVAL;
545 goto fail1; 556 goto fail1;
557 }
558
559 wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX,
560 GFP_KERNEL, &wacom->data_dma);
561 if (!wacom_wac->data) {
562 error = -ENOMEM;
563 goto fail1;
564 }
546 565
547 wacom->irq = usb_alloc_urb(0, GFP_KERNEL); 566 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
548 if (!wacom->irq) 567 if (!wacom->irq) {
568 error = -ENOMEM;
549 goto fail2; 569 goto fail2;
570 }
550 571
551 wacom->usbdev = dev; 572 wacom->usbdev = dev;
552 wacom->dev = input_dev; 573 wacom->dev = input_dev;
@@ -555,11 +576,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
555 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 576 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
556 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 577 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
557 578
558 wacom_wac->features = features = get_wacom_feature(id);
559 BUG_ON(features->pktlen > WACOM_PKGLEN_MAX);
560
561 input_dev->name = wacom_wac->features->name;
562 wacom->wacom_wac = wacom_wac;
563 usb_to_input_id(dev, &input_dev->id); 579 usb_to_input_id(dev, &input_dev->id);
564 580
565 input_dev->dev.parent = &intf->dev; 581 input_dev->dev.parent = &intf->dev;
@@ -576,6 +592,19 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
576 if (error) 592 if (error)
577 goto fail2; 593 goto fail2;
578 594
595 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
596
597 if (features->type == TABLETPC || features->type == TABLETPC2FG) {
598 /* Append the device type to the name */
599 strlcat(wacom_wac->name,
600 features->device_type == BTN_TOOL_PEN ?
601 " Pen" : " Finger",
602 sizeof(wacom_wac->name));
603 }
604
605 input_dev->name = wacom_wac->name;
606 wacom->wacom_wac = wacom_wac;
607
579 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 608 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
580 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH); 609 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH);
581 610
@@ -640,7 +669,7 @@ static int wacom_suspend(struct usb_interface *intf, pm_message_t message)
640static int wacom_resume(struct usb_interface *intf) 669static int wacom_resume(struct usb_interface *intf)
641{ 670{
642 struct wacom *wacom = usb_get_intfdata(intf); 671 struct wacom *wacom = usb_get_intfdata(intf);
643 struct wacom_features *features = wacom->wacom_wac->features; 672 struct wacom_features *features = &wacom->wacom_wac->features;
644 int rv; 673 int rv;
645 674
646 mutex_lock(&wacom->lock); 675 mutex_lock(&wacom->lock);
@@ -663,6 +692,7 @@ static int wacom_reset_resume(struct usb_interface *intf)
663 692
664static struct usb_driver wacom_driver = { 693static struct usb_driver wacom_driver = {
665 .name = "wacom", 694 .name = "wacom",
695 .id_table = wacom_ids,
666 .probe = wacom_probe, 696 .probe = wacom_probe,
667 .disconnect = wacom_disconnect, 697 .disconnect = wacom_disconnect,
668 .suspend = wacom_suspend, 698 .suspend = wacom_suspend,
@@ -674,7 +704,7 @@ static struct usb_driver wacom_driver = {
674static int __init wacom_init(void) 704static int __init wacom_init(void)
675{ 705{
676 int result; 706 int result;
677 wacom_driver.id_table = get_device_table(); 707
678 result = usb_register(&wacom_driver); 708 result = usb_register(&wacom_driver);
679 if (result == 0) 709 if (result == 0)
680 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 710 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 1056f149fe31..3d81443e683a 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -55,6 +55,7 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
55 55
56static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo) 56static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
57{ 57{
58 struct wacom_features *features = &wacom->features;
58 unsigned char *data = wacom->data; 59 unsigned char *data = wacom->data;
59 int prox, pressure; 60 int prox, pressure;
60 61
@@ -68,9 +69,9 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
68 if (prox) { 69 if (prox) {
69 wacom->id[0] = ERASER_DEVICE_ID; 70 wacom->id[0] = ERASER_DEVICE_ID;
70 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); 71 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
71 if (wacom->features->pressure_max > 255) 72 if (features->pressure_max > 255)
72 pressure = (pressure << 1) | ((data[4] >> 6) & 1); 73 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
73 pressure += (wacom->features->pressure_max + 1) / 2; 74 pressure += (features->pressure_max + 1) / 2;
74 75
75 /* 76 /*
76 * if going from out of proximity into proximity select between the eraser 77 * if going from out of proximity into proximity select between the eraser
@@ -152,6 +153,7 @@ static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
152 153
153static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo) 154static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
154{ 155{
156 struct wacom_features *features = &wacom->features;
155 unsigned char *data = wacom->data; 157 unsigned char *data = wacom->data;
156 int x, y, rw; 158 int x, y, rw;
157 static int penData = 0; 159 static int penData = 0;
@@ -179,8 +181,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
179 181
180 case 2: /* Mouse with wheel */ 182 case 2: /* Mouse with wheel */
181 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04); 183 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
182 if (wacom->features->type == WACOM_G4 || 184 if (features->type == WACOM_G4 || features->type == WACOM_MO) {
183 wacom->features->type == WACOM_MO) {
184 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03); 185 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
185 wacom_report_rel(wcombo, REL_WHEEL, -rw); 186 wacom_report_rel(wcombo, REL_WHEEL, -rw);
186 } else 187 } else
@@ -192,8 +193,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
192 wacom->id[0] = CURSOR_DEVICE_ID; 193 wacom->id[0] = CURSOR_DEVICE_ID;
193 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01); 194 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
194 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02); 195 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
195 if (wacom->features->type == WACOM_G4 || 196 if (features->type == WACOM_G4 || features->type == WACOM_MO)
196 wacom->features->type == WACOM_MO)
197 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f); 197 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
198 else 198 else
199 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f); 199 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
@@ -230,7 +230,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
230 } 230 }
231 231
232 /* send pad data */ 232 /* send pad data */
233 switch (wacom->features->type) { 233 switch (features->type) {
234 case WACOM_G4: 234 case WACOM_G4:
235 if (data[7] & 0xf8) { 235 if (data[7] & 0xf8) {
236 if (penData) { 236 if (penData) {
@@ -300,11 +300,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
300 300
301static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo) 301static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
302{ 302{
303 struct wacom_features *features = &wacom->features;
303 unsigned char *data = wacom->data; 304 unsigned char *data = wacom->data;
304 int idx = 0; 305 int idx = 0;
305 306
306 /* tool number */ 307 /* tool number */
307 if (wacom->features->type == INTUOS) 308 if (features->type == INTUOS)
308 idx = data[1] & 0x01; 309 idx = data[1] & 0x01;
309 310
310 /* Enter report */ 311 /* Enter report */
@@ -402,7 +403,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
402 wacom_report_key(wcombo, BTN_STYLUS2, 0); 403 wacom_report_key(wcombo, BTN_STYLUS2, 0);
403 wacom_report_key(wcombo, BTN_TOUCH, 0); 404 wacom_report_key(wcombo, BTN_TOUCH, 0);
404 wacom_report_abs(wcombo, ABS_WHEEL, 0); 405 wacom_report_abs(wcombo, ABS_WHEEL, 0);
405 if (wacom->features->type >= INTUOS3S) 406 if (features->type >= INTUOS3S)
406 wacom_report_abs(wcombo, ABS_Z, 0); 407 wacom_report_abs(wcombo, ABS_Z, 0);
407 } 408 }
408 wacom_report_key(wcombo, wacom->tool[idx], 0); 409 wacom_report_key(wcombo, wacom->tool[idx], 0);
@@ -416,13 +417,14 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
416 417
417static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo) 418static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
418{ 419{
420 struct wacom_features *features = &wacom->features;
419 unsigned char *data = wacom->data; 421 unsigned char *data = wacom->data;
420 unsigned int t; 422 unsigned int t;
421 423
422 /* general pen packet */ 424 /* general pen packet */
423 if ((data[1] & 0xb8) == 0xa0) { 425 if ((data[1] & 0xb8) == 0xa0) {
424 t = (data[6] << 2) | ((data[7] >> 6) & 3); 426 t = (data[6] << 2) | ((data[7] >> 6) & 3);
425 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) 427 if (features->type >= INTUOS4S && features->type <= INTUOS4L)
426 t = (t << 1) | (data[1] & 1); 428 t = (t << 1) | (data[1] & 1);
427 wacom_report_abs(wcombo, ABS_PRESSURE, t); 429 wacom_report_abs(wcombo, ABS_PRESSURE, t);
428 wacom_report_abs(wcombo, ABS_TILT_X, 430 wacom_report_abs(wcombo, ABS_TILT_X,
@@ -446,6 +448,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
446 448
447static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo) 449static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
448{ 450{
451 struct wacom_features *features = &wacom->features;
449 unsigned char *data = wacom->data; 452 unsigned char *data = wacom->data;
450 unsigned int t; 453 unsigned int t;
451 int idx = 0, result; 454 int idx = 0, result;
@@ -457,7 +460,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
457 } 460 }
458 461
459 /* tool number */ 462 /* tool number */
460 if (wacom->features->type == INTUOS) 463 if (features->type == INTUOS)
461 idx = data[1] & 0x01; 464 idx = data[1] & 0x01;
462 465
463 /* pad packets. Works as a second tool and is always in prox */ 466 /* pad packets. Works as a second tool and is always in prox */
@@ -466,7 +469,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
466 if (wacom->tool[1] != BTN_TOOL_FINGER) 469 if (wacom->tool[1] != BTN_TOOL_FINGER)
467 wacom->tool[1] = BTN_TOOL_FINGER; 470 wacom->tool[1] = BTN_TOOL_FINGER;
468 471
469 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) { 472 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
470 wacom_report_key(wcombo, BTN_0, (data[2] & 0x01)); 473 wacom_report_key(wcombo, BTN_0, (data[2] & 0x01));
471 wacom_report_key(wcombo, BTN_1, (data[3] & 0x01)); 474 wacom_report_key(wcombo, BTN_1, (data[3] & 0x01));
472 wacom_report_key(wcombo, BTN_2, (data[3] & 0x02)); 475 wacom_report_key(wcombo, BTN_2, (data[3] & 0x02));
@@ -480,7 +483,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
480 /* Out of proximity, clear wheel value. */ 483 /* Out of proximity, clear wheel value. */
481 wacom_report_abs(wcombo, ABS_WHEEL, 0); 484 wacom_report_abs(wcombo, ABS_WHEEL, 0);
482 } 485 }
483 if (wacom->features->type != INTUOS4S) { 486 if (features->type != INTUOS4S) {
484 wacom_report_key(wcombo, BTN_7, (data[3] & 0x40)); 487 wacom_report_key(wcombo, BTN_7, (data[3] & 0x40));
485 wacom_report_key(wcombo, BTN_8, (data[3] & 0x80)); 488 wacom_report_key(wcombo, BTN_8, (data[3] & 0x80));
486 } 489 }
@@ -528,18 +531,20 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
528 return 0; 531 return 0;
529 532
530 /* Only large Intuos support Lense Cursor */ 533 /* Only large Intuos support Lense Cursor */
531 if ((wacom->tool[idx] == BTN_TOOL_LENS) 534 if (wacom->tool[idx] == BTN_TOOL_LENS &&
532 && ((wacom->features->type == INTUOS3) 535 (features->type == INTUOS3 ||
533 || (wacom->features->type == INTUOS3S) 536 features->type == INTUOS3S ||
534 || (wacom->features->type == INTUOS4) 537 features->type == INTUOS4 ||
535 || (wacom->features->type == INTUOS4S))) 538 features->type == INTUOS4S)) {
539
536 return 0; 540 return 0;
541 }
537 542
538 /* Cintiq doesn't send data when RDY bit isn't set */ 543 /* Cintiq doesn't send data when RDY bit isn't set */
539 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40)) 544 if (features->type == CINTIQ && !(data[1] & 0x40))
540 return 0; 545 return 0;
541 546
542 if (wacom->features->type >= INTUOS3S) { 547 if (features->type >= INTUOS3S) {
543 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); 548 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
544 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); 549 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
545 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); 550 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
@@ -557,7 +562,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
557 562
558 if (data[1] & 0x02) { 563 if (data[1] & 0x02) {
559 /* Rotation packet */ 564 /* Rotation packet */
560 if (wacom->features->type >= INTUOS3S) { 565 if (features->type >= INTUOS3S) {
561 /* I3 marker pen rotation */ 566 /* I3 marker pen rotation */
562 t = (data[6] << 3) | ((data[7] >> 5) & 7); 567 t = (data[6] << 3) | ((data[7] >> 5) & 7);
563 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : 568 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
@@ -570,7 +575,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
570 ((t - 1) / 2) : -t / 2); 575 ((t - 1) / 2) : -t / 2);
571 } 576 }
572 577
573 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) { 578 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
574 /* 4D mouse packet */ 579 /* 4D mouse packet */
575 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 580 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
576 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 581 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
@@ -583,7 +588,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
583 588
584 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { 589 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
585 /* I4 mouse */ 590 /* I4 mouse */
586 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) { 591 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
587 wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01); 592 wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01);
588 wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02); 593 wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02);
589 wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04); 594 wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04);
@@ -604,13 +609,13 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
604 - ((data[8] & 0x02) >> 1)); 609 - ((data[8] & 0x02) >> 1));
605 610
606 /* I3 2D mouse side buttons */ 611 /* I3 2D mouse side buttons */
607 if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) { 612 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
608 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40); 613 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
609 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20); 614 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
610 } 615 }
611 } 616 }
612 } else if ((wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L || 617 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
613 wacom->features->type == INTUOS4L) && 618 features->type == INTUOS4L) &&
614 wacom->tool[idx] == BTN_TOOL_LENS) { 619 wacom->tool[idx] == BTN_TOOL_LENS) {
615 /* Lens cursor packets */ 620 /* Lens cursor packets */
616 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 621 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
@@ -718,6 +723,7 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
718 723
719static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo) 724static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
720{ 725{
726 struct wacom_features *features = &wacom->features;
721 char *data = wacom->data; 727 char *data = wacom->data;
722 int prox = 0, pressure, idx = -1; 728 int prox = 0, pressure, idx = -1;
723 static int stylusInProx, touchInProx = 1, touchOut; 729 static int stylusInProx, touchInProx = 1, touchOut;
@@ -791,7 +797,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
791 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); 797 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
792 pressure = ((data[7] & 0x01) << 8) | data[6]; 798 pressure = ((data[7] & 0x01) << 8) | data[6];
793 if (pressure < 0) 799 if (pressure < 0)
794 pressure = wacom->features->pressure_max + pressure + 1; 800 pressure = features->pressure_max + pressure + 1;
795 wacom_report_abs(wcombo, ABS_PRESSURE, pressure); 801 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
796 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05); 802 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05);
797 } else { 803 } else {
@@ -815,7 +821,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
815 821
816int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo) 822int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
817{ 823{
818 switch (wacom_wac->features->type) { 824 switch (wacom_wac->features.type) {
819 case PENPARTNER: 825 case PENPARTNER:
820 return wacom_penpartner_irq(wacom_wac, wcombo); 826 return wacom_penpartner_irq(wacom_wac, wcombo);
821 827
@@ -853,7 +859,7 @@ int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
853 859
854void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 860void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
855{ 861{
856 switch (wacom_wac->features->type) { 862 switch (wacom_wac->features.type) {
857 case WACOM_MO: 863 case WACOM_MO:
858 input_dev_mo(input_dev, wacom_wac); 864 input_dev_mo(input_dev, wacom_wac);
859 case WACOM_G4: 865 case WACOM_G4:
@@ -888,7 +894,7 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
888 /* fall through */ 894 /* fall through */
889 case TABLETPC: 895 case TABLETPC:
890 input_dev_tpc(input_dev, wacom_wac); 896 input_dev_tpc(input_dev, wacom_wac);
891 if (wacom_wac->features->device_type != BTN_TOOL_PEN) 897 if (wacom_wac->features.device_type != BTN_TOOL_PEN)
892 break; /* no need to process stylus stuff */ 898 break; /* no need to process stylus stuff */
893 899
894 /* fall through */ 900 /* fall through */
@@ -903,153 +909,201 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
903 return; 909 return;
904} 910}
905 911
906static struct wacom_features wacom_features[] = { 912static const struct wacom_features wacom_features_0x00 =
907 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER }, 913 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER };
908 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }, 914static const struct wacom_features wacom_features_0x10 =
909 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }, 915 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE };
910 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE }, 916static const struct wacom_features wacom_features_0x11 =
911 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE }, 917 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE };
912 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }, 918static const struct wacom_features wacom_features_0x12 =
913 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 }, 919 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE };
914 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 }, 920static const struct wacom_features wacom_features_0x13 =
915 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }, 921 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE };
916 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO }, 922static const struct wacom_features wacom_features_0x14 =
917 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }, 923 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE };
918 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }, 924static const struct wacom_features wacom_features_0x15 =
919 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE }, 925 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 };
920 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }, 926static const struct wacom_features wacom_features_0x16 =
921 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE }, 927 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 };
922 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE }, 928static const struct wacom_features wacom_features_0x17 =
923 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }, 929 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO };
924 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }, 930static const struct wacom_features wacom_features_0x18 =
925 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }, 931 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO };
926 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }, 932static const struct wacom_features wacom_features_0x19 =
927 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }, 933 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE };
928 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }, 934static const struct wacom_features wacom_features_0x60 =
929 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }, 935 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE };
930 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL }, 936static const struct wacom_features wacom_features_0x61 =
931 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL }, 937 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE };
932 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL }, 938static const struct wacom_features wacom_features_0x62 =
933 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL }, 939 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE };
934 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL }, 940static const struct wacom_features wacom_features_0x63 =
935 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL }, 941 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE };
936 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL }, 942static const struct wacom_features wacom_features_0x64 =
937 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }, 943 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE };
938 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL }, 944static const struct wacom_features wacom_features_0x65 =
939 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }, 945 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO };
940 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }, 946static const struct wacom_features wacom_features_0x69 =
941 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }, 947 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE };
942 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU }, 948static const struct wacom_features wacom_features_0x20 =
943 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }, 949 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS };
944 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }, 950static const struct wacom_features wacom_features_0x21 =
945 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }, 951 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
946 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }, 952static const struct wacom_features wacom_features_0x22 =
947 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }, 953 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS };
948 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S }, 954static const struct wacom_features wacom_features_0x23 =
949 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 }, 955 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS };
950 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 }, 956static const struct wacom_features wacom_features_0x24 =
951 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L }, 957 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS };
952 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L }, 958static const struct wacom_features wacom_features_0x30 =
953 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 }, 959 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL };
954 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S }, 960static const struct wacom_features wacom_features_0x31 =
955 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S }, 961 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL };
956 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 }, 962static const struct wacom_features wacom_features_0x32 =
957 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L }, 963 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL };
958 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L }, 964static const struct wacom_features wacom_features_0x33 =
959 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ }, 965 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL };
960 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE }, 966static const struct wacom_features wacom_features_0x34 =
961 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE }, 967 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL };
962 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL }, 968static const struct wacom_features wacom_features_0x35 =
963 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }, 969 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL };
964 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }, 970static const struct wacom_features wacom_features_0x37 =
965 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }, 971 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL };
966 { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC }, 972static const struct wacom_features wacom_features_0x38 =
967 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }, 973 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL };
968 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }, 974static const struct wacom_features wacom_features_0x39 =
969 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }, 975 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL };
976static const struct wacom_features wacom_features_0xC4 =
977 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL };
978static const struct wacom_features wacom_features_0xC0 =
979 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL };
980static const struct wacom_features wacom_features_0xC2 =
981 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL };
982static const struct wacom_features wacom_features_0x03 =
983 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU };
984static const struct wacom_features wacom_features_0x41 =
985 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS };
986static const struct wacom_features wacom_features_0x42 =
987 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
988static const struct wacom_features wacom_features_0x43 =
989 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS };
990static const struct wacom_features wacom_features_0x44 =
991 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS };
992static const struct wacom_features wacom_features_0x45 =
993 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS };
994static const struct wacom_features wacom_features_0xB0 =
995 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S };
996static const struct wacom_features wacom_features_0xB1 =
997 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 };
998static const struct wacom_features wacom_features_0xB2 =
999 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 };
1000static const struct wacom_features wacom_features_0xB3 =
1001 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L };
1002static const struct wacom_features wacom_features_0xB4 =
1003 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L };
1004static const struct wacom_features wacom_features_0xB5 =
1005 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 };
1006static const struct wacom_features wacom_features_0xB7 =
1007 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S };
1008static const struct wacom_features wacom_features_0xB8 =
1009 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S };
1010static const struct wacom_features wacom_features_0xB9 =
1011 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 };
1012static const struct wacom_features wacom_features_0xBA =
1013 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L };
1014static const struct wacom_features wacom_features_0xBB =
1015 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L };
1016static const struct wacom_features wacom_features_0x3F =
1017 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ };
1018static const struct wacom_features wacom_features_0xC5 =
1019 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE };
1020static const struct wacom_features wacom_features_0xC6 =
1021 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE };
1022static const struct wacom_features wacom_features_0xC7 =
1023 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL };
1024static const struct wacom_features wacom_features_0x90 =
1025 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
1026static const struct wacom_features wacom_features_0x93 =
1027 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
1028static const struct wacom_features wacom_features_0x9A =
1029 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
1030static const struct wacom_features wacom_features_0x9F =
1031 { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC };
1032static const struct wacom_features wacom_features_0xE2 =
1033 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG };
1034static const struct wacom_features wacom_features_0xE3 =
1035 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG };
1036static const struct wacom_features wacom_features_0x47 =
1037 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
1038
1039#define USB_DEVICE_WACOM(prod) \
1040 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
1041 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1042
1043const struct usb_device_id wacom_ids[] = {
1044 { USB_DEVICE_WACOM(0x00) },
1045 { USB_DEVICE_WACOM(0x10) },
1046 { USB_DEVICE_WACOM(0x11) },
1047 { USB_DEVICE_WACOM(0x12) },
1048 { USB_DEVICE_WACOM(0x13) },
1049 { USB_DEVICE_WACOM(0x14) },
1050 { USB_DEVICE_WACOM(0x15) },
1051 { USB_DEVICE_WACOM(0x16) },
1052 { USB_DEVICE_WACOM(0x17) },
1053 { USB_DEVICE_WACOM(0x18) },
1054 { USB_DEVICE_WACOM(0x19) },
1055 { USB_DEVICE_WACOM(0x60) },
1056 { USB_DEVICE_WACOM(0x61) },
1057 { USB_DEVICE_WACOM(0x62) },
1058 { USB_DEVICE_WACOM(0x63) },
1059 { USB_DEVICE_WACOM(0x64) },
1060 { USB_DEVICE_WACOM(0x65) },
1061 { USB_DEVICE_WACOM(0x69) },
1062 { USB_DEVICE_WACOM(0x20) },
1063 { USB_DEVICE_WACOM(0x21) },
1064 { USB_DEVICE_WACOM(0x22) },
1065 { USB_DEVICE_WACOM(0x23) },
1066 { USB_DEVICE_WACOM(0x24) },
1067 { USB_DEVICE_WACOM(0x30) },
1068 { USB_DEVICE_WACOM(0x31) },
1069 { USB_DEVICE_WACOM(0x32) },
1070 { USB_DEVICE_WACOM(0x33) },
1071 { USB_DEVICE_WACOM(0x34) },
1072 { USB_DEVICE_WACOM(0x35) },
1073 { USB_DEVICE_WACOM(0x37) },
1074 { USB_DEVICE_WACOM(0x38) },
1075 { USB_DEVICE_WACOM(0x39) },
1076 { USB_DEVICE_WACOM(0xC4) },
1077 { USB_DEVICE_WACOM(0xC0) },
1078 { USB_DEVICE_WACOM(0xC2) },
1079 { USB_DEVICE_WACOM(0x03) },
1080 { USB_DEVICE_WACOM(0x41) },
1081 { USB_DEVICE_WACOM(0x42) },
1082 { USB_DEVICE_WACOM(0x43) },
1083 { USB_DEVICE_WACOM(0x44) },
1084 { USB_DEVICE_WACOM(0x45) },
1085 { USB_DEVICE_WACOM(0xB0) },
1086 { USB_DEVICE_WACOM(0xB1) },
1087 { USB_DEVICE_WACOM(0xB2) },
1088 { USB_DEVICE_WACOM(0xB3) },
1089 { USB_DEVICE_WACOM(0xB4) },
1090 { USB_DEVICE_WACOM(0xB5) },
1091 { USB_DEVICE_WACOM(0xB7) },
1092 { USB_DEVICE_WACOM(0xB8) },
1093 { USB_DEVICE_WACOM(0xB9) },
1094 { USB_DEVICE_WACOM(0xBA) },
1095 { USB_DEVICE_WACOM(0xBB) },
1096 { USB_DEVICE_WACOM(0x3F) },
1097 { USB_DEVICE_WACOM(0xC5) },
1098 { USB_DEVICE_WACOM(0xC6) },
1099 { USB_DEVICE_WACOM(0xC7) },
1100 { USB_DEVICE_WACOM(0x90) },
1101 { USB_DEVICE_WACOM(0x93) },
1102 { USB_DEVICE_WACOM(0x9A) },
1103 { USB_DEVICE_WACOM(0x9F) },
1104 { USB_DEVICE_WACOM(0xE2) },
1105 { USB_DEVICE_WACOM(0xE3) },
1106 { USB_DEVICE_WACOM(0x47) },
970 { } 1107 { }
971}; 1108};
972
973static struct usb_device_id wacom_ids[] = {
974 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
975 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
976 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
977 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
978 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
979 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
980 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
981 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
982 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) },
983 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) },
984 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x19) },
985 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
986 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
987 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
988 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
989 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
990 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x65) },
991 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x69) },
992 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
993 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
994 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
995 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
996 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
997 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
998 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
999 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
1000 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
1001 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
1002 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
1003 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
1004 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
1005 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
1006 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
1007 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
1008 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC2) },
1009 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
1010 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
1011 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
1012 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
1013 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
1014 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
1015 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
1016 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
1017 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
1018 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
1019 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
1020 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
1021 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
1022 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB8) },
1023 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB9) },
1024 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBA) },
1025 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBB) },
1026 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
1027 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) },
1028 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
1029 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC7) },
1030 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x90) },
1031 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x93) },
1032 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9A) },
1033 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9F) },
1034 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE2) },
1035 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE3) },
1036 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
1037 { }
1038};
1039
1040const struct usb_device_id *get_device_table(void)
1041{
1042 const struct usb_device_id *id_table = wacom_ids;
1043
1044 return id_table;
1045}
1046
1047struct wacom_features * get_wacom_feature(const struct usb_device_id *id)
1048{
1049 int index = id - wacom_ids;
1050 struct wacom_features *wf = &wacom_features[index];
1051
1052 return wf;
1053}
1054
1055MODULE_DEVICE_TABLE(usb, wacom_ids); 1109MODULE_DEVICE_TABLE(usb, wacom_ids);
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index ee01e1902785..8590b1e8ec37 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -15,11 +15,11 @@
15/* packet length for individual models */ 15/* packet length for individual models */
16#define WACOM_PKGLEN_PENPRTN 7 16#define WACOM_PKGLEN_PENPRTN 7
17#define WACOM_PKGLEN_GRAPHIRE 8 17#define WACOM_PKGLEN_GRAPHIRE 8
18#define WACOM_PKGLEN_BBFUN 9 18#define WACOM_PKGLEN_BBFUN 9
19#define WACOM_PKGLEN_INTUOS 10 19#define WACOM_PKGLEN_INTUOS 10
20#define WACOM_PKGLEN_PENABLED 8 20#define WACOM_PKGLEN_PENABLED 8
21#define WACOM_PKGLEN_TPC1FG 5 21#define WACOM_PKGLEN_TPC1FG 5
22#define WACOM_PKGLEN_TPC2FG 14 22#define WACOM_PKGLEN_TPC2FG 14
23 23
24/* device IDs */ 24/* device IDs */
25#define STYLUS_DEVICE_ID 0x02 25#define STYLUS_DEVICE_ID 0x02
@@ -58,7 +58,7 @@ enum {
58}; 58};
59 59
60struct wacom_features { 60struct wacom_features {
61 char *name; 61 const char *name;
62 int pktlen; 62 int pktlen;
63 int x_max; 63 int x_max;
64 int y_max; 64 int y_max;
@@ -73,11 +73,12 @@ struct wacom_features {
73}; 73};
74 74
75struct wacom_wac { 75struct wacom_wac {
76 char name[64];
76 unsigned char *data; 77 unsigned char *data;
77 int tool[2]; 78 int tool[2];
78 int id[2]; 79 int id[2];
79 __u32 serial[2]; 80 __u32 serial[2];
80 struct wacom_features *features; 81 struct wacom_features features;
81}; 82};
82 83
83#endif 84#endif
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index dfafc76da4fb..6457e060ae49 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -90,7 +90,6 @@ config TOUCHSCREEN_CORGI
90 tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)" 90 tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)"
91 depends on PXA_SHARPSL 91 depends on PXA_SHARPSL
92 select CORGI_SSP_DEPRECATED 92 select CORGI_SSP_DEPRECATED
93 default y
94 help 93 help
95 Say Y here to enable the driver for the touchscreen on the 94 Say Y here to enable the driver for the touchscreen on the
96 Sharp SL-C7xx and SL-Cxx00 series of PDAs. 95 Sharp SL-C7xx and SL-Cxx00 series of PDAs.
@@ -537,6 +536,11 @@ config TOUCHSCREEN_USB_ETT_TC5UH
537 bool "ET&T TC5UH touchscreen controler support" if EMBEDDED 536 bool "ET&T TC5UH touchscreen controler support" if EMBEDDED
538 depends on TOUCHSCREEN_USB_COMPOSITE 537 depends on TOUCHSCREEN_USB_COMPOSITE
539 538
539config TOUCHSCREEN_USB_NEXIO
540 default y
541 bool "NEXIO/iNexio device support" if EMBEDDED
542 depends on TOUCHSCREEN_USB_COMPOSITE
543
540config TOUCHSCREEN_TOUCHIT213 544config TOUCHSCREEN_TOUCHIT213
541 tristate "Sahara TouchIT-213 touchscreen" 545 tristate "Sahara TouchIT-213 touchscreen"
542 select SERIO 546 select SERIO
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 52d2ca147d8f..8b05d8e97543 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -27,6 +27,7 @@
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
29#include <linux/spi/ads7846.h> 29#include <linux/spi/ads7846.h>
30#include <linux/regulator/consumer.h>
30#include <asm/irq.h> 31#include <asm/irq.h>
31 32
32/* 33/*
@@ -85,6 +86,7 @@ struct ads7846 {
85 char name[32]; 86 char name[32];
86 87
87 struct spi_device *spi; 88 struct spi_device *spi;
89 struct regulator *reg;
88 90
89#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) 91#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
90 struct attribute_group *attr_group; 92 struct attribute_group *attr_group;
@@ -788,6 +790,8 @@ static void ads7846_disable(struct ads7846 *ts)
788 } 790 }
789 } 791 }
790 792
793 regulator_disable(ts->reg);
794
791 /* we know the chip's in lowpower mode since we always 795 /* we know the chip's in lowpower mode since we always
792 * leave it that way after every request 796 * leave it that way after every request
793 */ 797 */
@@ -799,6 +803,8 @@ static void ads7846_enable(struct ads7846 *ts)
799 if (!ts->disabled) 803 if (!ts->disabled)
800 return; 804 return;
801 805
806 regulator_enable(ts->reg);
807
802 ts->disabled = 0; 808 ts->disabled = 0;
803 ts->irq_disabled = 0; 809 ts->irq_disabled = 0;
804 enable_irq(ts->spi->irq); 810 enable_irq(ts->spi->irq);
@@ -1139,6 +1145,19 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1139 1145
1140 ts->last_msg = m; 1146 ts->last_msg = m;
1141 1147
1148 ts->reg = regulator_get(&spi->dev, "vcc");
1149 if (IS_ERR(ts->reg)) {
1150 dev_err(&spi->dev, "unable to get regulator: %ld\n",
1151 PTR_ERR(ts->reg));
1152 goto err_free_gpio;
1153 }
1154
1155 err = regulator_enable(ts->reg);
1156 if (err) {
1157 dev_err(&spi->dev, "unable to enable regulator: %d\n", err);
1158 goto err_put_regulator;
1159 }
1160
1142 if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING, 1161 if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING,
1143 spi->dev.driver->name, ts)) { 1162 spi->dev.driver->name, ts)) {
1144 dev_info(&spi->dev, 1163 dev_info(&spi->dev,
@@ -1148,7 +1167,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1148 spi->dev.driver->name, ts); 1167 spi->dev.driver->name, ts);
1149 if (err) { 1168 if (err) {
1150 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 1169 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
1151 goto err_free_gpio; 1170 goto err_disable_regulator;
1152 } 1171 }
1153 } 1172 }
1154 1173
@@ -1180,6 +1199,10 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1180 ads784x_hwmon_unregister(spi, ts); 1199 ads784x_hwmon_unregister(spi, ts);
1181 err_free_irq: 1200 err_free_irq:
1182 free_irq(spi->irq, ts); 1201 free_irq(spi->irq, ts);
1202 err_disable_regulator:
1203 regulator_disable(ts->reg);
1204 err_put_regulator:
1205 regulator_put(ts->reg);
1183 err_free_gpio: 1206 err_free_gpio:
1184 if (ts->gpio_pendown != -1) 1207 if (ts->gpio_pendown != -1)
1185 gpio_free(ts->gpio_pendown); 1208 gpio_free(ts->gpio_pendown);
@@ -1208,6 +1231,9 @@ static int __devexit ads7846_remove(struct spi_device *spi)
1208 /* suspend left the IRQ disabled */ 1231 /* suspend left the IRQ disabled */
1209 enable_irq(ts->spi->irq); 1232 enable_irq(ts->spi->irq);
1210 1233
1234 regulator_disable(ts->reg);
1235 regulator_put(ts->reg);
1236
1211 if (ts->gpio_pendown != -1) 1237 if (ts->gpio_pendown != -1)
1212 gpio_free(ts->gpio_pendown); 1238 gpio_free(ts->gpio_pendown);
1213 1239
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
index 8f38c5e55ce6..486d31ba9c09 100644
--- a/drivers/input/touchscreen/elo.c
+++ b/drivers/input/touchscreen/elo.c
@@ -72,45 +72,49 @@ static void elo_process_data_10(struct elo *elo, unsigned char data)
72 struct input_dev *dev = elo->dev; 72 struct input_dev *dev = elo->dev;
73 73
74 elo->data[elo->idx] = data; 74 elo->data[elo->idx] = data;
75 switch (elo->idx++) {
76 case 0:
77 elo->csum = 0xaa;
78 if (data != ELO10_LEAD_BYTE) {
79 pr_debug("elo: unsynchronized data: 0x%02x\n", data);
80 elo->idx = 0;
81 }
82 break;
83 75
84 case 9: 76 switch (elo->idx++) {
77 case 0:
78 elo->csum = 0xaa;
79 if (data != ELO10_LEAD_BYTE) {
80 dev_dbg(&elo->serio->dev,
81 "unsynchronized data: 0x%02x\n", data);
85 elo->idx = 0; 82 elo->idx = 0;
86 if (data != elo->csum) { 83 }
87 pr_debug("elo: bad checksum: 0x%02x, expected 0x%02x\n", 84 break;
88 data, elo->csum); 85
89 break; 86 case 9:
90 } 87 elo->idx = 0;
91 if (elo->data[1] != elo->expected_packet) { 88 if (data != elo->csum) {
92 if (elo->data[1] != ELO10_TOUCH_PACKET) 89 dev_dbg(&elo->serio->dev,
93 pr_debug("elo: unexpected packet: 0x%02x\n", 90 "bad checksum: 0x%02x, expected 0x%02x\n",
94 elo->data[1]); 91 data, elo->csum);
95 break; 92 break;
96 } 93 }
97 if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) { 94 if (elo->data[1] != elo->expected_packet) {
98 input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); 95 if (elo->data[1] != ELO10_TOUCH_PACKET)
99 input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); 96 dev_dbg(&elo->serio->dev,
100 if (elo->data[2] & ELO10_PRESSURE) 97 "unexpected packet: 0x%02x\n",
101 input_report_abs(dev, ABS_PRESSURE, 98 elo->data[1]);
102 (elo->data[8] << 8) | elo->data[7]);
103 input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH);
104 input_sync(dev);
105 } else if (elo->data[1] == ELO10_ACK_PACKET) {
106 if (elo->data[2] == '0')
107 elo->expected_packet = ELO10_TOUCH_PACKET;
108 complete(&elo->cmd_done);
109 } else {
110 memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN);
111 elo->expected_packet = ELO10_ACK_PACKET;
112 }
113 break; 99 break;
100 }
101 if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) {
102 input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]);
103 input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]);
104 if (elo->data[2] & ELO10_PRESSURE)
105 input_report_abs(dev, ABS_PRESSURE,
106 (elo->data[8] << 8) | elo->data[7]);
107 input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH);
108 input_sync(dev);
109 } else if (elo->data[1] == ELO10_ACK_PACKET) {
110 if (elo->data[2] == '0')
111 elo->expected_packet = ELO10_TOUCH_PACKET;
112 complete(&elo->cmd_done);
113 } else {
114 memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN);
115 elo->expected_packet = ELO10_ACK_PACKET;
116 }
117 break;
114 } 118 }
115 elo->csum += data; 119 elo->csum += data;
116} 120}
@@ -123,42 +127,53 @@ static void elo_process_data_6(struct elo *elo, unsigned char data)
123 127
124 switch (elo->idx++) { 128 switch (elo->idx++) {
125 129
126 case 0: if ((data & 0xc0) != 0xc0) elo->idx = 0; break; 130 case 0:
127 case 1: if ((data & 0xc0) != 0x80) elo->idx = 0; break; 131 if ((data & 0xc0) != 0xc0)
128 case 2: if ((data & 0xc0) != 0x40) elo->idx = 0; break; 132 elo->idx = 0;
129 133 break;
130 case 3:
131 if (data & 0xc0) {
132 elo->idx = 0;
133 break;
134 }
135 134
136 input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f)); 135 case 1:
137 input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f)); 136 if ((data & 0xc0) != 0x80)
137 elo->idx = 0;
138 break;
138 139
139 if (elo->id == 2) { 140 case 2:
140 input_report_key(dev, BTN_TOUCH, 1); 141 if ((data & 0xc0) != 0x40)
141 input_sync(dev); 142 elo->idx = 0;
142 elo->idx = 0; 143 break;
143 }
144 144
145 case 3:
146 if (data & 0xc0) {
147 elo->idx = 0;
145 break; 148 break;
149 }
146 150
147 case 4: 151 input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f));
148 if (data) { 152 input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f));
149 input_sync(dev);
150 elo->idx = 0;
151 }
152 break;
153 153
154 case 5: 154 if (elo->id == 2) {
155 if ((data & 0xf0) == 0) { 155 input_report_key(dev, BTN_TOUCH, 1);
156 input_report_abs(dev, ABS_PRESSURE, elo->data[5]);
157 input_report_key(dev, BTN_TOUCH, !!elo->data[5]);
158 }
159 input_sync(dev); 156 input_sync(dev);
160 elo->idx = 0; 157 elo->idx = 0;
161 break; 158 }
159
160 break;
161
162 case 4:
163 if (data) {
164 input_sync(dev);
165 elo->idx = 0;
166 }
167 break;
168
169 case 5:
170 if ((data & 0xf0) == 0) {
171 input_report_abs(dev, ABS_PRESSURE, elo->data[5]);
172 input_report_key(dev, BTN_TOUCH, !!elo->data[5]);
173 }
174 input_sync(dev);
175 elo->idx = 0;
176 break;
162 } 177 }
163} 178}
164 179
@@ -170,17 +185,17 @@ static void elo_process_data_3(struct elo *elo, unsigned char data)
170 185
171 switch (elo->idx++) { 186 switch (elo->idx++) {
172 187
173 case 0: 188 case 0:
174 if ((data & 0x7f) != 0x01) 189 if ((data & 0x7f) != 0x01)
175 elo->idx = 0;
176 break;
177 case 2:
178 input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80));
179 input_report_abs(dev, ABS_X, elo->data[1]);
180 input_report_abs(dev, ABS_Y, elo->data[2]);
181 input_sync(dev);
182 elo->idx = 0; 190 elo->idx = 0;
183 break; 191 break;
192 case 2:
193 input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80));
194 input_report_abs(dev, ABS_X, elo->data[1]);
195 input_report_abs(dev, ABS_Y, elo->data[2]);
196 input_sync(dev);
197 elo->idx = 0;
198 break;
184 } 199 }
185} 200}
186 201
@@ -189,19 +204,19 @@ static irqreturn_t elo_interrupt(struct serio *serio,
189{ 204{
190 struct elo *elo = serio_get_drvdata(serio); 205 struct elo *elo = serio_get_drvdata(serio);
191 206
192 switch(elo->id) { 207 switch (elo->id) {
193 case 0: 208 case 0:
194 elo_process_data_10(elo, data); 209 elo_process_data_10(elo, data);
195 break; 210 break;
196 211
197 case 1: 212 case 1:
198 case 2: 213 case 2:
199 elo_process_data_6(elo, data); 214 elo_process_data_6(elo, data);
200 break; 215 break;
201 216
202 case 3: 217 case 3:
203 elo_process_data_3(elo, data); 218 elo_process_data_3(elo, data);
204 break; 219 break;
205 } 220 }
206 221
207 return IRQ_HANDLED; 222 return IRQ_HANDLED;
@@ -261,10 +276,10 @@ static int elo_setup_10(struct elo *elo)
261 if (packet[3] & ELO10_PRESSURE) 276 if (packet[3] & ELO10_PRESSURE)
262 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); 277 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
263 278
264 printk(KERN_INFO "elo: %sTouch touchscreen, fw: %02x.%02x, " 279 dev_info(&elo->serio->dev,
265 "features: 0x%02x, controller: 0x%02x\n", 280 "%sTouch touchscreen, fw: %02x.%02x, features: 0x%02x, controller: 0x%02x\n",
266 elo_types[(packet[1] -'0') & 0x03], 281 elo_types[(packet[1] -'0') & 0x03],
267 packet[5], packet[4], packet[3], packet[7]); 282 packet[5], packet[4], packet[3], packet[7]);
268 283
269 return 0; 284 return 0;
270} 285}
@@ -330,24 +345,24 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)
330 345
331 switch (elo->id) { 346 switch (elo->id) {
332 347
333 case 0: /* 10-byte protocol */ 348 case 0: /* 10-byte protocol */
334 if (elo_setup_10(elo)) 349 if (elo_setup_10(elo))
335 goto fail3; 350 goto fail3;
336 351
337 break; 352 break;
338 353
339 case 1: /* 6-byte protocol */ 354 case 1: /* 6-byte protocol */
340 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); 355 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0);
341 356
342 case 2: /* 4-byte protocol */ 357 case 2: /* 4-byte protocol */
343 input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); 358 input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0);
344 input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); 359 input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0);
345 break; 360 break;
346 361
347 case 3: /* 3-byte protocol */ 362 case 3: /* 3-byte protocol */
348 input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0); 363 input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0);
349 input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0); 364 input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0);
350 break; 365 break;
351 } 366 }
352 367
353 err = input_register_device(elo->dev); 368 err = input_register_device(elo->dev);
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index 6cdcf2a6e036..b6b8b1c7ecea 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -153,6 +153,9 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm)
153 if (pressure) 153 if (pressure)
154 p = MODR; 154 p = MODR;
155 155
156 dev_dbg(wm->dev, "Raw coordinates: x=%x, y=%x, p=%x\n",
157 x, y, p);
158
156 /* are samples valid */ 159 /* are samples valid */
157 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || 160 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X ||
158 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y || 161 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y ||
diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
index 6386b441ef85..3755a47d053c 100644
--- a/drivers/input/touchscreen/s3c2410_ts.c
+++ b/drivers/input/touchscreen/s3c2410_ts.c
@@ -128,27 +128,29 @@ static void touch_timer_fire(unsigned long data)
128 128
129 down = get_down(data0, data1); 129 down = get_down(data0, data1);
130 130
131 if (ts.count == (1 << ts.shift)) { 131 if (down) {
132 ts.xp >>= ts.shift; 132 if (ts.count == (1 << ts.shift)) {
133 ts.yp >>= ts.shift; 133 ts.xp >>= ts.shift;
134 ts.yp >>= ts.shift;
134 135
135 dev_dbg(ts.dev, "%s: X=%lu, Y=%lu, count=%d\n", 136 dev_dbg(ts.dev, "%s: X=%lu, Y=%lu, count=%d\n",
136 __func__, ts.xp, ts.yp, ts.count); 137 __func__, ts.xp, ts.yp, ts.count);
137 138
138 input_report_abs(ts.input, ABS_X, ts.xp); 139 input_report_abs(ts.input, ABS_X, ts.xp);
139 input_report_abs(ts.input, ABS_Y, ts.yp); 140 input_report_abs(ts.input, ABS_Y, ts.yp);
140 141
141 input_report_key(ts.input, BTN_TOUCH, 1); 142 input_report_key(ts.input, BTN_TOUCH, 1);
142 input_sync(ts.input); 143 input_sync(ts.input);
143 144
144 ts.xp = 0; 145 ts.xp = 0;
145 ts.yp = 0; 146 ts.yp = 0;
146 ts.count = 0; 147 ts.count = 0;
147 } 148 }
148 149
149 if (down) {
150 s3c_adc_start(ts.client, 0, 1 << ts.shift); 150 s3c_adc_start(ts.client, 0, 1 << ts.shift);
151 } else { 151 } else {
152 ts.xp = 0;
153 ts.yp = 0;
152 ts.count = 0; 154 ts.count = 0;
153 155
154 input_report_key(ts.input, BTN_TOUCH, 0); 156 input_report_key(ts.input, BTN_TOUCH, 0);
@@ -401,6 +403,7 @@ static int s3c2410ts_resume(struct device *dev)
401 struct s3c2410_ts_mach_info *info = pdev->dev.platform_data; 403 struct s3c2410_ts_mach_info *info = pdev->dev.platform_data;
402 404
403 clk_enable(ts.clock); 405 clk_enable(ts.clock);
406 enable_irq(ts.irq_tc);
404 407
405 /* Initialise registers */ 408 /* Initialise registers */
406 if ((info->delay & 0xffff) > 0) 409 if ((info->delay & 0xffff) > 0)
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 7ef0d1420d3c..be23780e8a3e 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -358,7 +358,7 @@ static int __devexit tsc2007_remove(struct i2c_client *client)
358 return 0; 358 return 0;
359} 359}
360 360
361static struct i2c_device_id tsc2007_idtable[] = { 361static const struct i2c_device_id tsc2007_idtable[] = {
362 { "tsc2007", 0 }, 362 { "tsc2007", 0 },
363 { } 363 { }
364}; 364};
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 5256123a5228..99330bbdbac7 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -15,6 +15,7 @@
15 * - GoTop Super_Q2/GogoPen/PenPower tablets 15 * - GoTop Super_Q2/GogoPen/PenPower tablets
16 * - JASTEC USB touch controller/DigiTech DTR-02U 16 * - JASTEC USB touch controller/DigiTech DTR-02U
17 * - Zytronic capacitive touchscreen 17 * - Zytronic capacitive touchscreen
18 * - NEXIO/iNexio
18 * 19 *
19 * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch> 20 * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch>
20 * Copyright (C) by Todd E. Johnson (mtouchusb.c) 21 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
@@ -95,6 +96,7 @@ struct usbtouch_device_info {
95 96
96 int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt); 97 int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt);
97 int (*init) (struct usbtouch_usb *usbtouch); 98 int (*init) (struct usbtouch_usb *usbtouch);
99 void (*exit) (struct usbtouch_usb *usbtouch);
98}; 100};
99 101
100/* a usbtouch device */ 102/* a usbtouch device */
@@ -104,11 +106,12 @@ struct usbtouch_usb {
104 unsigned char *buffer; 106 unsigned char *buffer;
105 int buf_len; 107 int buf_len;
106 struct urb *irq; 108 struct urb *irq;
107 struct usb_device *udev; 109 struct usb_interface *interface;
108 struct input_dev *input; 110 struct input_dev *input;
109 struct usbtouch_device_info *type; 111 struct usbtouch_device_info *type;
110 char name[128]; 112 char name[128];
111 char phys[64]; 113 char phys[64];
114 void *priv;
112 115
113 int x, y; 116 int x, y;
114 int touch, press; 117 int touch, press;
@@ -133,6 +136,7 @@ enum {
133 DEVTYPE_E2I, 136 DEVTYPE_E2I,
134 DEVTYPE_ZYTRONIC, 137 DEVTYPE_ZYTRONIC,
135 DEVTYPE_TC5UH, 138 DEVTYPE_TC5UH,
139 DEVTYPE_NEXIO,
136}; 140};
137 141
138#define USB_DEVICE_HID_CLASS(vend, prod) \ 142#define USB_DEVICE_HID_CLASS(vend, prod) \
@@ -144,7 +148,7 @@ enum {
144 .bInterfaceClass = USB_INTERFACE_CLASS_HID, \ 148 .bInterfaceClass = USB_INTERFACE_CLASS_HID, \
145 .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE 149 .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE
146 150
147static struct usb_device_id usbtouch_devices[] = { 151static const struct usb_device_id usbtouch_devices[] = {
148#ifdef CONFIG_TOUCHSCREEN_USB_EGALAX 152#ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
149 /* ignore the HID capable devices, handled by usbhid */ 153 /* ignore the HID capable devices, handled by usbhid */
150 {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE}, 154 {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE},
@@ -222,6 +226,14 @@ static struct usb_device_id usbtouch_devices[] = {
222 {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC5UH}, 226 {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC5UH},
223#endif 227#endif
224 228
229#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
230 /* data interface only */
231 {USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00),
232 .driver_info = DEVTYPE_NEXIO},
233 {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00),
234 .driver_info = DEVTYPE_NEXIO},
235#endif
236
225 {} 237 {}
226}; 238};
227 239
@@ -234,8 +246,9 @@ static struct usb_device_id usbtouch_devices[] = {
234static int e2i_init(struct usbtouch_usb *usbtouch) 246static int e2i_init(struct usbtouch_usb *usbtouch)
235{ 247{
236 int ret; 248 int ret;
249 struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
237 250
238 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 251 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
239 0x01, 0x02, 0x0000, 0x0081, 252 0x01, 0x02, 0x0000, 0x0081,
240 NULL, 0, USB_CTRL_SET_TIMEOUT); 253 NULL, 0, USB_CTRL_SET_TIMEOUT);
241 254
@@ -344,8 +357,9 @@ static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
344static int mtouch_init(struct usbtouch_usb *usbtouch) 357static int mtouch_init(struct usbtouch_usb *usbtouch)
345{ 358{
346 int ret, i; 359 int ret, i;
360 struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
347 361
348 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 362 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
349 MTOUCHUSB_RESET, 363 MTOUCHUSB_RESET,
350 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 364 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
351 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); 365 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
@@ -356,7 +370,7 @@ static int mtouch_init(struct usbtouch_usb *usbtouch)
356 msleep(150); 370 msleep(150);
357 371
358 for (i = 0; i < 3; i++) { 372 for (i = 0; i < 3; i++) {
359 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 373 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
360 MTOUCHUSB_ASYNC_REPORT, 374 MTOUCHUSB_ASYNC_REPORT,
361 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 375 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
362 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); 376 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
@@ -489,7 +503,7 @@ static int gunze_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
489 503
490static int dmc_tsc10_init(struct usbtouch_usb *usbtouch) 504static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
491{ 505{
492 struct usb_device *dev = usbtouch->udev; 506 struct usb_device *dev = interface_to_usbdev(usbtouch->interface);
493 int ret = -ENOMEM; 507 int ret = -ENOMEM;
494 unsigned char *buf; 508 unsigned char *buf;
495 509
@@ -690,6 +704,229 @@ static int zytronic_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
690#endif 704#endif
691 705
692/***************************************************************************** 706/*****************************************************************************
707 * NEXIO Part
708 */
709#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
710
711#define NEXIO_TIMEOUT 5000
712#define NEXIO_BUFSIZE 1024
713#define NEXIO_THRESHOLD 50
714
715struct nexio_priv {
716 struct urb *ack;
717 unsigned char *ack_buf;
718};
719
720struct nexio_touch_packet {
721 u8 flags; /* 0xe1 = touch, 0xe1 = release */
722 __be16 data_len; /* total bytes of touch data */
723 __be16 x_len; /* bytes for X axis */
724 __be16 y_len; /* bytes for Y axis */
725 u8 data[];
726} __attribute__ ((packed));
727
728static unsigned char nexio_ack_pkt[2] = { 0xaa, 0x02 };
729static unsigned char nexio_init_pkt[4] = { 0x82, 0x04, 0x0a, 0x0f };
730
731static void nexio_ack_complete(struct urb *urb)
732{
733}
734
735static int nexio_init(struct usbtouch_usb *usbtouch)
736{
737 struct usb_device *dev = interface_to_usbdev(usbtouch->interface);
738 struct usb_host_interface *interface = usbtouch->interface->cur_altsetting;
739 struct nexio_priv *priv;
740 int ret = -ENOMEM;
741 int actual_len, i;
742 unsigned char *buf;
743 char *firmware_ver = NULL, *device_name = NULL;
744 int input_ep = 0, output_ep = 0;
745
746 /* find first input and output endpoint */
747 for (i = 0; i < interface->desc.bNumEndpoints; i++) {
748 if (!input_ep &&
749 usb_endpoint_dir_in(&interface->endpoint[i].desc))
750 input_ep = interface->endpoint[i].desc.bEndpointAddress;
751 if (!output_ep &&
752 usb_endpoint_dir_out(&interface->endpoint[i].desc))
753 output_ep = interface->endpoint[i].desc.bEndpointAddress;
754 }
755 if (!input_ep || !output_ep)
756 return -ENXIO;
757
758 buf = kmalloc(NEXIO_BUFSIZE, GFP_KERNEL);
759 if (!buf)
760 goto out_buf;
761
762 /* two empty reads */
763 for (i = 0; i < 2; i++) {
764 ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep),
765 buf, NEXIO_BUFSIZE, &actual_len,
766 NEXIO_TIMEOUT);
767 if (ret < 0)
768 goto out_buf;
769 }
770
771 /* send init command */
772 memcpy(buf, nexio_init_pkt, sizeof(nexio_init_pkt));
773 ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, output_ep),
774 buf, sizeof(nexio_init_pkt), &actual_len,
775 NEXIO_TIMEOUT);
776 if (ret < 0)
777 goto out_buf;
778
779 /* read replies */
780 for (i = 0; i < 3; i++) {
781 memset(buf, 0, NEXIO_BUFSIZE);
782 ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep),
783 buf, NEXIO_BUFSIZE, &actual_len,
784 NEXIO_TIMEOUT);
785 if (ret < 0 || actual_len < 1 || buf[1] != actual_len)
786 continue;
787 switch (buf[0]) {
788 case 0x83: /* firmware version */
789 if (!firmware_ver)
790 firmware_ver = kstrdup(&buf[2], GFP_KERNEL);
791 break;
792 case 0x84: /* device name */
793 if (!device_name)
794 device_name = kstrdup(&buf[2], GFP_KERNEL);
795 break;
796 }
797 }
798
799 printk(KERN_INFO "Nexio device: %s, firmware version: %s\n",
800 device_name, firmware_ver);
801
802 kfree(firmware_ver);
803 kfree(device_name);
804
805 /* prepare ACK URB */
806 ret = -ENOMEM;
807
808 usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL);
809 if (!usbtouch->priv)
810 goto out_buf;
811
812 priv = usbtouch->priv;
813
814 priv->ack_buf = kmalloc(sizeof(nexio_ack_pkt), GFP_KERNEL);
815 if (!priv->ack_buf)
816 goto err_priv;
817
818 memcpy(priv->ack_buf, nexio_ack_pkt, sizeof(nexio_ack_pkt));
819
820 priv->ack = usb_alloc_urb(0, GFP_KERNEL);
821 if (!priv->ack) {
822 dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__);
823 goto err_ack_buf;
824 }
825
826 usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep),
827 priv->ack_buf, sizeof(nexio_ack_pkt),
828 nexio_ack_complete, usbtouch);
829 ret = 0;
830 goto out_buf;
831
832err_ack_buf:
833 kfree(priv->ack_buf);
834err_priv:
835 kfree(priv);
836out_buf:
837 kfree(buf);
838 return ret;
839}
840
841static void nexio_exit(struct usbtouch_usb *usbtouch)
842{
843 struct nexio_priv *priv = usbtouch->priv;
844
845 usb_kill_urb(priv->ack);
846 usb_free_urb(priv->ack);
847 kfree(priv->ack_buf);
848 kfree(priv);
849}
850
851static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt)
852{
853 int x, y, begin_x, begin_y, end_x, end_y, w, h, ret;
854 struct nexio_touch_packet *packet = (void *) pkt;
855 struct nexio_priv *priv = usbtouch->priv;
856
857 /* got touch data? */
858 if ((pkt[0] & 0xe0) != 0xe0)
859 return 0;
860
861 /* send ACK */
862 ret = usb_submit_urb(priv->ack, GFP_ATOMIC);
863
864 if (!usbtouch->type->max_xc) {
865 usbtouch->type->max_xc = 2 * be16_to_cpu(packet->x_len);
866 input_set_abs_params(usbtouch->input, ABS_X, 0,
867 2 * be16_to_cpu(packet->x_len), 0, 0);
868 usbtouch->type->max_yc = 2 * be16_to_cpu(packet->y_len);
869 input_set_abs_params(usbtouch->input, ABS_Y, 0,
870 2 * be16_to_cpu(packet->y_len), 0, 0);
871 }
872 /*
873 * The device reports state of IR sensors on X and Y axes.
874 * Each byte represents "darkness" percentage (0-100) of one element.
875 * 17" touchscreen reports only 64 x 52 bytes so the resolution is low.
876 * This also means that there's a limited multi-touch capability but
877 * it's disabled (and untested) here as there's no X driver for that.
878 */
879 begin_x = end_x = begin_y = end_y = -1;
880 for (x = 0; x < be16_to_cpu(packet->x_len); x++) {
881 if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) {
882 begin_x = x;
883 continue;
884 }
885 if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) {
886 end_x = x - 1;
887 for (y = be16_to_cpu(packet->x_len);
888 y < be16_to_cpu(packet->data_len); y++) {
889 if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) {
890 begin_y = y - be16_to_cpu(packet->x_len);
891 continue;
892 }
893 if (end_y == -1 &&
894 begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) {
895 end_y = y - 1 - be16_to_cpu(packet->x_len);
896 w = end_x - begin_x;
897 h = end_y - begin_y;
898#if 0
899 /* multi-touch */
900 input_report_abs(usbtouch->input,
901 ABS_MT_TOUCH_MAJOR, max(w,h));
902 input_report_abs(usbtouch->input,
903 ABS_MT_TOUCH_MINOR, min(x,h));
904 input_report_abs(usbtouch->input,
905 ABS_MT_POSITION_X, 2*begin_x+w);
906 input_report_abs(usbtouch->input,
907 ABS_MT_POSITION_Y, 2*begin_y+h);
908 input_report_abs(usbtouch->input,
909 ABS_MT_ORIENTATION, w > h);
910 input_mt_sync(usbtouch->input);
911#endif
912 /* single touch */
913 usbtouch->x = 2 * begin_x + w;
914 usbtouch->y = 2 * begin_y + h;
915 usbtouch->touch = packet->flags & 0x01;
916 begin_y = end_y = -1;
917 return 1;
918 }
919 }
920 begin_x = end_x = -1;
921 }
922
923 }
924 return 0;
925}
926#endif
927
928
929/*****************************************************************************
693 * the different device descriptors 930 * the different device descriptors
694 */ 931 */
695#ifdef MULTI_PACKET 932#ifdef MULTI_PACKET
@@ -873,6 +1110,16 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
873 .read_data = tc5uh_read_data, 1110 .read_data = tc5uh_read_data,
874 }, 1111 },
875#endif 1112#endif
1113
1114#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
1115 [DEVTYPE_NEXIO] = {
1116 .rept_size = 128,
1117 .irq_always = true,
1118 .read_data = nexio_read_data,
1119 .init = nexio_init,
1120 .exit = nexio_exit,
1121 },
1122#endif
876}; 1123};
877 1124
878 1125
@@ -998,6 +1245,7 @@ static void usbtouch_irq(struct urb *urb)
998 case -ECONNRESET: 1245 case -ECONNRESET:
999 case -ENOENT: 1246 case -ENOENT:
1000 case -ESHUTDOWN: 1247 case -ESHUTDOWN:
1248 case -EPIPE:
1001 /* this urb is terminated, clean up */ 1249 /* this urb is terminated, clean up */
1002 dbg("%s - urb shutting down with status: %d", 1250 dbg("%s - urb shutting down with status: %d",
1003 __func__, urb->status); 1251 __func__, urb->status);
@@ -1021,7 +1269,7 @@ static int usbtouch_open(struct input_dev *input)
1021{ 1269{
1022 struct usbtouch_usb *usbtouch = input_get_drvdata(input); 1270 struct usbtouch_usb *usbtouch = input_get_drvdata(input);
1023 1271
1024 usbtouch->irq->dev = usbtouch->udev; 1272 usbtouch->irq->dev = interface_to_usbdev(usbtouch->interface);
1025 1273
1026 if (!usbtouch->type->irq_always) { 1274 if (!usbtouch->type->irq_always) {
1027 if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) 1275 if (usb_submit_urb(usbtouch->irq, GFP_KERNEL))
@@ -1048,13 +1296,23 @@ static void usbtouch_free_buffers(struct usb_device *udev,
1048 kfree(usbtouch->buffer); 1296 kfree(usbtouch->buffer);
1049} 1297}
1050 1298
1299static struct usb_endpoint_descriptor *
1300usbtouch_get_input_endpoint(struct usb_host_interface *interface)
1301{
1302 int i;
1303
1304 for (i = 0; i < interface->desc.bNumEndpoints; i++)
1305 if (usb_endpoint_dir_in(&interface->endpoint[i].desc))
1306 return &interface->endpoint[i].desc;
1307
1308 return NULL;
1309}
1051 1310
1052static int usbtouch_probe(struct usb_interface *intf, 1311static int usbtouch_probe(struct usb_interface *intf,
1053 const struct usb_device_id *id) 1312 const struct usb_device_id *id)
1054{ 1313{
1055 struct usbtouch_usb *usbtouch; 1314 struct usbtouch_usb *usbtouch;
1056 struct input_dev *input_dev; 1315 struct input_dev *input_dev;
1057 struct usb_host_interface *interface;
1058 struct usb_endpoint_descriptor *endpoint; 1316 struct usb_endpoint_descriptor *endpoint;
1059 struct usb_device *udev = interface_to_usbdev(intf); 1317 struct usb_device *udev = interface_to_usbdev(intf);
1060 struct usbtouch_device_info *type; 1318 struct usbtouch_device_info *type;
@@ -1064,8 +1322,9 @@ static int usbtouch_probe(struct usb_interface *intf,
1064 if (id->driver_info == DEVTYPE_IGNORE) 1322 if (id->driver_info == DEVTYPE_IGNORE)
1065 return -ENODEV; 1323 return -ENODEV;
1066 1324
1067 interface = intf->cur_altsetting; 1325 endpoint = usbtouch_get_input_endpoint(intf->cur_altsetting);
1068 endpoint = &interface->endpoint[0].desc; 1326 if (!endpoint)
1327 return -ENXIO;
1069 1328
1070 usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL); 1329 usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL);
1071 input_dev = input_allocate_device(); 1330 input_dev = input_allocate_device();
@@ -1094,7 +1353,7 @@ static int usbtouch_probe(struct usb_interface *intf,
1094 goto out_free_buffers; 1353 goto out_free_buffers;
1095 } 1354 }
1096 1355
1097 usbtouch->udev = udev; 1356 usbtouch->interface = intf;
1098 usbtouch->input = input_dev; 1357 usbtouch->input = input_dev;
1099 1358
1100 if (udev->manufacturer) 1359 if (udev->manufacturer)
@@ -1133,12 +1392,18 @@ static int usbtouch_probe(struct usb_interface *intf,
1133 input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press, 1392 input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press,
1134 type->max_press, 0, 0); 1393 type->max_press, 0, 0);
1135 1394
1136 usb_fill_int_urb(usbtouch->irq, usbtouch->udev, 1395 if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT)
1137 usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress), 1396 usb_fill_int_urb(usbtouch->irq, udev,
1397 usb_rcvintpipe(udev, endpoint->bEndpointAddress),
1138 usbtouch->data, type->rept_size, 1398 usbtouch->data, type->rept_size,
1139 usbtouch_irq, usbtouch, endpoint->bInterval); 1399 usbtouch_irq, usbtouch, endpoint->bInterval);
1400 else
1401 usb_fill_bulk_urb(usbtouch->irq, udev,
1402 usb_rcvbulkpipe(udev, endpoint->bEndpointAddress),
1403 usbtouch->data, type->rept_size,
1404 usbtouch_irq, usbtouch);
1140 1405
1141 usbtouch->irq->dev = usbtouch->udev; 1406 usbtouch->irq->dev = udev;
1142 usbtouch->irq->transfer_dma = usbtouch->data_dma; 1407 usbtouch->irq->transfer_dma = usbtouch->data_dma;
1143 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1408 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1144 1409
@@ -1147,23 +1412,37 @@ static int usbtouch_probe(struct usb_interface *intf,
1147 err = type->init(usbtouch); 1412 err = type->init(usbtouch);
1148 if (err) { 1413 if (err) {
1149 dbg("%s - type->init() failed, err: %d", __func__, err); 1414 dbg("%s - type->init() failed, err: %d", __func__, err);
1150 goto out_free_buffers; 1415 goto out_free_urb;
1151 } 1416 }
1152 } 1417 }
1153 1418
1154 err = input_register_device(usbtouch->input); 1419 err = input_register_device(usbtouch->input);
1155 if (err) { 1420 if (err) {
1156 dbg("%s - input_register_device failed, err: %d", __func__, err); 1421 dbg("%s - input_register_device failed, err: %d", __func__, err);
1157 goto out_free_buffers; 1422 goto out_do_exit;
1158 } 1423 }
1159 1424
1160 usb_set_intfdata(intf, usbtouch); 1425 usb_set_intfdata(intf, usbtouch);
1161 1426
1162 if (usbtouch->type->irq_always) 1427 if (usbtouch->type->irq_always) {
1163 usb_submit_urb(usbtouch->irq, GFP_KERNEL); 1428 err = usb_submit_urb(usbtouch->irq, GFP_KERNEL);
1429 if (err) {
1430 err("%s - usb_submit_urb failed with result: %d",
1431 __func__, err);
1432 goto out_unregister_input;
1433 }
1434 }
1164 1435
1165 return 0; 1436 return 0;
1166 1437
1438out_unregister_input:
1439 input_unregister_device(input_dev);
1440 input_dev = NULL;
1441out_do_exit:
1442 if (type->exit)
1443 type->exit(usbtouch);
1444out_free_urb:
1445 usb_free_urb(usbtouch->irq);
1167out_free_buffers: 1446out_free_buffers:
1168 usbtouch_free_buffers(udev, usbtouch); 1447 usbtouch_free_buffers(udev, usbtouch);
1169out_free: 1448out_free:
@@ -1186,6 +1465,8 @@ static void usbtouch_disconnect(struct usb_interface *intf)
1186 /* this will stop IO via close */ 1465 /* this will stop IO via close */
1187 input_unregister_device(usbtouch->input); 1466 input_unregister_device(usbtouch->input);
1188 usb_free_urb(usbtouch->irq); 1467 usb_free_urb(usbtouch->irq);
1468 if (usbtouch->type->exit)
1469 usbtouch->type->exit(usbtouch);
1189 usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch); 1470 usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch);
1190 kfree(usbtouch); 1471 kfree(usbtouch);
1191} 1472}
diff --git a/drivers/input/touchscreen/zylonite-wm97xx.c b/drivers/input/touchscreen/zylonite-wm97xx.c
index eca54dbdf493..048849867643 100644
--- a/drivers/input/touchscreen/zylonite-wm97xx.c
+++ b/drivers/input/touchscreen/zylonite-wm97xx.c
@@ -118,6 +118,9 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm)
118 if (pressure) 118 if (pressure)
119 p = MODR; 119 p = MODR;
120 120
121 dev_dbg(wm->dev, "Raw coordinates: x=%x, y=%x, p=%x\n",
122 x, y, p);
123
121 /* are samples valid */ 124 /* are samples valid */
122 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || 125 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X ||
123 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y || 126 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y ||
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c
index c721c0a23eb8..d30436fee476 100644
--- a/drivers/input/xen-kbdfront.c
+++ b/drivers/input/xen-kbdfront.c
@@ -321,7 +321,7 @@ InitWait:
321 } 321 }
322} 322}
323 323
324static struct xenbus_device_id xenkbd_ids[] = { 324static const struct xenbus_device_id xenkbd_ids[] = {
325 { "vkbd" }, 325 { "vkbd" },
326 { "" } 326 { "" }
327}; 327};
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 3d906833948d..fd85bde283a0 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -171,8 +171,8 @@ config INPUT_ADBHID
171 If unsure, say Y. 171 If unsure, say Y.
172 172
173config MAC_EMUMOUSEBTN 173config MAC_EMUMOUSEBTN
174 bool "Support for mouse button 2+3 emulation" 174 tristate "Support for mouse button 2+3 emulation"
175 select INPUT 175 depends on SYSCTL && INPUT
176 help 176 help
177 This provides generic support for emulating the 2nd and 3rd mouse 177 This provides generic support for emulating the 2nd and 3rd mouse
178 button with keypresses. If you say Y here, the emulation is still 178 button with keypresses. If you say Y here, the emulation is still
@@ -184,6 +184,9 @@ config MAC_EMUMOUSEBTN
184 184
185 If you have an Apple machine with a 1-button mouse, say Y here. 185 If you have an Apple machine with a 1-button mouse, say Y here.
186 186
187 To compile this driver as a module, choose M here: the
188 module will be called mac_hid.
189
187config THERM_WINDTUNNEL 190config THERM_WINDTUNNEL
188 tristate "Support for thermal management on Windtunnel G4s" 191 tristate "Support for thermal management on Windtunnel G4s"
189 depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64 192 depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index 7b4ef5bb556b..e943d2a29253 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -13,17 +13,197 @@
13#include <linux/sysctl.h> 13#include <linux/sysctl.h>
14#include <linux/input.h> 14#include <linux/input.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kbd_kern.h>
17 16
17MODULE_LICENSE("GPL");
18 18
19static struct input_dev *emumousebtn;
20static int emumousebtn_input_register(void);
21static int mouse_emulate_buttons; 19static int mouse_emulate_buttons;
22static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ 20static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */
23static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ 21static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */
24static int mouse_last_keycode;
25 22
26#if defined(CONFIG_SYSCTL) 23static struct input_dev *mac_hid_emumouse_dev;
24
25static int mac_hid_create_emumouse(void)
26{
27 static struct lock_class_key mac_hid_emumouse_dev_event_class;
28 static struct lock_class_key mac_hid_emumouse_dev_mutex_class;
29 int err;
30
31 mac_hid_emumouse_dev = input_allocate_device();
32 if (!mac_hid_emumouse_dev)
33 return -ENOMEM;
34
35 lockdep_set_class(&mac_hid_emumouse_dev->event_lock,
36 &mac_hid_emumouse_dev_event_class);
37 lockdep_set_class(&mac_hid_emumouse_dev->mutex,
38 &mac_hid_emumouse_dev_mutex_class);
39
40 mac_hid_emumouse_dev->name = "Macintosh mouse button emulation";
41 mac_hid_emumouse_dev->id.bustype = BUS_ADB;
42 mac_hid_emumouse_dev->id.vendor = 0x0001;
43 mac_hid_emumouse_dev->id.product = 0x0001;
44 mac_hid_emumouse_dev->id.version = 0x0100;
45
46 mac_hid_emumouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
47 mac_hid_emumouse_dev->keybit[BIT_WORD(BTN_MOUSE)] =
48 BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
49 mac_hid_emumouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
50
51 err = input_register_device(mac_hid_emumouse_dev);
52 if (err) {
53 input_free_device(mac_hid_emumouse_dev);
54 mac_hid_emumouse_dev = NULL;
55 return err;
56 }
57
58 return 0;
59}
60
61static void mac_hid_destroy_emumouse(void)
62{
63 input_unregister_device(mac_hid_emumouse_dev);
64 mac_hid_emumouse_dev = NULL;
65}
66
67static bool mac_hid_emumouse_filter(struct input_handle *handle,
68 unsigned int type, unsigned int code,
69 int value)
70{
71 unsigned int btn;
72
73 if (type != EV_KEY)
74 return false;
75
76 if (code == mouse_button2_keycode)
77 btn = BTN_MIDDLE;
78 else if (code == mouse_button3_keycode)
79 btn = BTN_RIGHT;
80 else
81 return false;
82
83 input_report_key(mac_hid_emumouse_dev, btn, value);
84 input_sync(mac_hid_emumouse_dev);
85
86 return true;
87}
88
89static int mac_hid_emumouse_connect(struct input_handler *handler,
90 struct input_dev *dev,
91 const struct input_device_id *id)
92{
93 struct input_handle *handle;
94 int error;
95
96 /* Don't bind to ourselves */
97 if (dev == mac_hid_emumouse_dev)
98 return -ENODEV;
99
100 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
101 if (!handle)
102 return -ENOMEM;
103
104 handle->dev = dev;
105 handle->handler = handler;
106 handle->name = "mac-button-emul";
107
108 error = input_register_handle(handle);
109 if (error) {
110 printk(KERN_ERR
111 "mac_hid: Failed to register button emulation handle, "
112 "error %d\n", error);
113 goto err_free;
114 }
115
116 error = input_open_device(handle);
117 if (error) {
118 printk(KERN_ERR
119 "mac_hid: Failed to open input device, error %d\n",
120 error);
121 goto err_unregister;
122 }
123
124 return 0;
125
126 err_unregister:
127 input_unregister_handle(handle);
128 err_free:
129 kfree(handle);
130 return error;
131}
132
133static void mac_hid_emumouse_disconnect(struct input_handle *handle)
134{
135 input_close_device(handle);
136 input_unregister_handle(handle);
137 kfree(handle);
138}
139
140static const struct input_device_id mac_hid_emumouse_ids[] = {
141 {
142 .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
143 .evbit = { BIT_MASK(EV_KEY) },
144 },
145 { },
146};
147
148MODULE_DEVICE_TABLE(input, mac_hid_emumouse_ids);
149
150static struct input_handler mac_hid_emumouse_handler = {
151 .filter = mac_hid_emumouse_filter,
152 .connect = mac_hid_emumouse_connect,
153 .disconnect = mac_hid_emumouse_disconnect,
154 .name = "mac-button-emul",
155 .id_table = mac_hid_emumouse_ids,
156};
157
158static int mac_hid_start_emulation(void)
159{
160 int err;
161
162 err = mac_hid_create_emumouse();
163 if (err)
164 return err;
165
166 err = input_register_handler(&mac_hid_emumouse_handler);
167 if (err) {
168 mac_hid_destroy_emumouse();
169 return err;
170 }
171
172 return 0;
173}
174
175static void mac_hid_stop_emulation(void)
176{
177 input_unregister_handler(&mac_hid_emumouse_handler);
178 mac_hid_destroy_emumouse();
179}
180
181static int mac_hid_toggle_emumouse(ctl_table *table, int write,
182 void __user *buffer, size_t *lenp,
183 loff_t *ppos)
184{
185 int *valp = table->data;
186 int old_val = *valp;
187 int rc;
188
189 rc = proc_dointvec(table, write, buffer, lenp, ppos);
190
191 if (rc == 0 && write && *valp != old_val) {
192 if (*valp == 1)
193 rc = mac_hid_start_emulation();
194 else if (*valp == 0)
195 mac_hid_stop_emulation();
196 else
197 rc = -EINVAL;
198 }
199
200 /* Restore the old value in case of error */
201 if (rc)
202 *valp = old_val;
203
204 return rc;
205}
206
27/* file(s) in /proc/sys/dev/mac_hid */ 207/* file(s) in /proc/sys/dev/mac_hid */
28static ctl_table mac_hid_files[] = { 208static ctl_table mac_hid_files[] = {
29 { 209 {
@@ -31,7 +211,7 @@ static ctl_table mac_hid_files[] = {
31 .data = &mouse_emulate_buttons, 211 .data = &mouse_emulate_buttons,
32 .maxlen = sizeof(int), 212 .maxlen = sizeof(int),
33 .mode = 0644, 213 .mode = 0644,
34 .proc_handler = proc_dointvec, 214 .proc_handler = mac_hid_toggle_emumouse,
35 }, 215 },
36 { 216 {
37 .procname = "mouse_button2_keycode", 217 .procname = "mouse_button2_keycode",
@@ -74,75 +254,21 @@ static ctl_table mac_hid_root_dir[] = {
74 254
75static struct ctl_table_header *mac_hid_sysctl_header; 255static struct ctl_table_header *mac_hid_sysctl_header;
76 256
77#endif /* endif CONFIG_SYSCTL */ 257static int __init mac_hid_init(void)
78
79int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down)
80{
81 switch (caller) {
82 case 1:
83 /* Called from keyboard.c */
84 if (mouse_emulate_buttons
85 && (keycode == mouse_button2_keycode
86 || keycode == mouse_button3_keycode)) {
87 if (mouse_emulate_buttons == 1) {
88 input_report_key(emumousebtn,
89 keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT,
90 down);
91 input_sync(emumousebtn);
92 return 1;
93 }
94 mouse_last_keycode = down ? keycode : 0;
95 }
96 break;
97 }
98 return 0;
99}
100
101static struct lock_class_key emumousebtn_event_class;
102static struct lock_class_key emumousebtn_mutex_class;
103
104static int emumousebtn_input_register(void)
105{ 258{
106 int ret; 259 mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir);
107 260 if (!mac_hid_sysctl_header)
108 emumousebtn = input_allocate_device();
109 if (!emumousebtn)
110 return -ENOMEM; 261 return -ENOMEM;
111 262
112 lockdep_set_class(&emumousebtn->event_lock, &emumousebtn_event_class); 263 return 0;
113 lockdep_set_class(&emumousebtn->mutex, &emumousebtn_mutex_class);
114
115 emumousebtn->name = "Macintosh mouse button emulation";
116 emumousebtn->id.bustype = BUS_ADB;
117 emumousebtn->id.vendor = 0x0001;
118 emumousebtn->id.product = 0x0001;
119 emumousebtn->id.version = 0x0100;
120
121 emumousebtn->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
122 emumousebtn->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
123 BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
124 emumousebtn->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
125
126 ret = input_register_device(emumousebtn);
127 if (ret)
128 input_free_device(emumousebtn);
129
130 return ret;
131} 264}
265module_init(mac_hid_init);
132 266
133static int __init mac_hid_init(void) 267static void __exit mac_hid_exit(void)
134{ 268{
135 int err; 269 unregister_sysctl_table(mac_hid_sysctl_header);
136
137 err = emumousebtn_input_register();
138 if (err)
139 return err;
140
141#if defined(CONFIG_SYSCTL)
142 mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir);
143#endif /* CONFIG_SYSCTL */
144 270
145 return 0; 271 if (mouse_emulate_buttons)
272 mac_hid_stop_emulation();
146} 273}
147 274module_exit(mac_hid_exit);
148device_initcall(mac_hid_init);
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 00435bd20699..af2d39d603c7 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -177,7 +177,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
177 */ 177 */
178 if (rdev->bdev->bd_disk->queue->merge_bvec_fn && 178 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
179 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) 179 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
180 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 180 blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9);
181 181
182 conf->array_sectors += rdev->sectors; 182 conf->array_sectors += rdev->sectors;
183 cnt++; 183 cnt++;
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 32a662fc55c9..4b323f45ad74 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -308,7 +308,7 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
308 */ 308 */
309 if (q->merge_bvec_fn && 309 if (q->merge_bvec_fn &&
310 queue_max_sectors(q) > (PAGE_SIZE>>9)) 310 queue_max_sectors(q) > (PAGE_SIZE>>9))
311 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 311 blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9);
312 312
313 conf->working_disks++; 313 conf->working_disks++;
314 mddev->degraded--; 314 mddev->degraded--;
@@ -478,7 +478,7 @@ static int multipath_run (mddev_t *mddev)
478 * a merge_bvec_fn to be involved in multipath */ 478 * a merge_bvec_fn to be involved in multipath */
479 if (rdev->bdev->bd_disk->queue->merge_bvec_fn && 479 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
480 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) 480 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
481 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 481 blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9);
482 482
483 if (!test_bit(Faulty, &rdev->flags)) 483 if (!test_bit(Faulty, &rdev->flags))
484 conf->working_disks++; 484 conf->working_disks++;
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 77605cdceaf1..a1f7147b757f 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -182,7 +182,7 @@ static int create_strip_zones(mddev_t *mddev)
182 182
183 if (rdev1->bdev->bd_disk->queue->merge_bvec_fn && 183 if (rdev1->bdev->bd_disk->queue->merge_bvec_fn &&
184 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) 184 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
185 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 185 blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9);
186 186
187 if (!smallest || (rdev1->sectors < smallest->sectors)) 187 if (!smallest || (rdev1->sectors < smallest->sectors))
188 smallest = rdev1; 188 smallest = rdev1;
@@ -325,7 +325,7 @@ static int raid0_run(mddev_t *mddev)
325 } 325 }
326 if (md_check_no_bitmap(mddev)) 326 if (md_check_no_bitmap(mddev))
327 return -EINVAL; 327 return -EINVAL;
328 blk_queue_max_sectors(mddev->queue, mddev->chunk_sectors); 328 blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors);
329 mddev->queue->queue_lock = &mddev->queue->__queue_lock; 329 mddev->queue->queue_lock = &mddev->queue->__queue_lock;
330 330
331 ret = create_strip_zones(mddev); 331 ret = create_strip_zones(mddev);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 859bd3ffe435..5a06122abd3b 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1158,7 +1158,7 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
1158 */ 1158 */
1159 if (rdev->bdev->bd_disk->queue->merge_bvec_fn && 1159 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
1160 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) 1160 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
1161 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 1161 blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9);
1162 1162
1163 p->head_position = 0; 1163 p->head_position = 0;
1164 rdev->raid_disk = mirror; 1164 rdev->raid_disk = mirror;
@@ -2103,7 +2103,7 @@ static int run(mddev_t *mddev)
2103 */ 2103 */
2104 if (rdev->bdev->bd_disk->queue->merge_bvec_fn && 2104 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
2105 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) 2105 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
2106 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 2106 blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9);
2107 } 2107 }
2108 2108
2109 mddev->degraded = 0; 2109 mddev->degraded = 0;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index d119b7b75e71..7584f9ab9bcf 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1161,7 +1161,7 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
1161 */ 1161 */
1162 if (rdev->bdev->bd_disk->queue->merge_bvec_fn && 1162 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
1163 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) 1163 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
1164 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 1164 blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9);
1165 1165
1166 p->head_position = 0; 1166 p->head_position = 0;
1167 rdev->raid_disk = mirror; 1167 rdev->raid_disk = mirror;
@@ -2260,7 +2260,7 @@ static int run(mddev_t *mddev)
2260 */ 2260 */
2261 if (rdev->bdev->bd_disk->queue->merge_bvec_fn && 2261 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
2262 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) 2262 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
2263 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 2263 blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9);
2264 2264
2265 disk->head_position = 0; 2265 disk->head_position = 0;
2266 } 2266 }
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ceb24afdc147..509c8f3dd9a5 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3739,7 +3739,7 @@ static int bio_fits_rdev(struct bio *bi)
3739 if ((bi->bi_size>>9) > queue_max_sectors(q)) 3739 if ((bi->bi_size>>9) > queue_max_sectors(q))
3740 return 0; 3740 return 0;
3741 blk_recount_segments(q, bi); 3741 blk_recount_segments(q, bi);
3742 if (bi->bi_phys_segments > queue_max_phys_segments(q)) 3742 if (bi->bi_phys_segments > queue_max_segments(q))
3743 return 0; 3743 return 0;
3744 3744
3745 if (q->merge_bvec_fn) 3745 if (q->merge_bvec_fn)
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index bd83fa0a4970..972b87069d55 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -1226,9 +1226,8 @@ static int mspro_block_init_disk(struct memstick_dev *card)
1226 blk_queue_prep_rq(msb->queue, mspro_block_prepare_req); 1226 blk_queue_prep_rq(msb->queue, mspro_block_prepare_req);
1227 1227
1228 blk_queue_bounce_limit(msb->queue, limit); 1228 blk_queue_bounce_limit(msb->queue, limit);
1229 blk_queue_max_sectors(msb->queue, MSPRO_BLOCK_MAX_PAGES); 1229 blk_queue_max_hw_sectors(msb->queue, MSPRO_BLOCK_MAX_PAGES);
1230 blk_queue_max_phys_segments(msb->queue, MSPRO_BLOCK_MAX_SEGS); 1230 blk_queue_max_segments(msb->queue, MSPRO_BLOCK_MAX_SEGS);
1231 blk_queue_max_hw_segments(msb->queue, MSPRO_BLOCK_MAX_SEGS);
1232 blk_queue_max_segment_size(msb->queue, 1231 blk_queue_max_segment_size(msb->queue,
1233 MSPRO_BLOCK_MAX_PAGES * msb->page_size); 1232 MSPRO_BLOCK_MAX_PAGES * msb->page_size);
1234 1233
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index e39986a78273..2658b1484a2c 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -1065,9 +1065,8 @@ static int i2o_block_probe(struct device *dev)
1065 queue = gd->queue; 1065 queue = gd->queue;
1066 queue->queuedata = i2o_blk_dev; 1066 queue->queuedata = i2o_blk_dev;
1067 1067
1068 blk_queue_max_phys_segments(queue, I2O_MAX_PHYS_SEGMENTS); 1068 blk_queue_max_hw_sectors(queue, max_sectors);
1069 blk_queue_max_sectors(queue, max_sectors); 1069 blk_queue_max_segments(queue, i2o_sg_tablesize(c, body_size));
1070 blk_queue_max_hw_segments(queue, i2o_sg_tablesize(c, body_size));
1071 1070
1072 osm_debug("max sectors = %d\n", queue->max_sectors); 1071 osm_debug("max sectors = %d\n", queue->max_sectors);
1073 osm_debug("phys segments = %d\n", queue->max_phys_segments); 1072 osm_debug("phys segments = %d\n", queue->max_phys_segments);
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 413576a2f313..b670d10d5c92 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -94,7 +94,7 @@ config TPS65010
94 94
95config MENELAUS 95config MENELAUS
96 bool "Texas Instruments TWL92330/Menelaus PM chip" 96 bool "Texas Instruments TWL92330/Menelaus PM chip"
97 depends on I2C=y && ARCH_OMAP24XX 97 depends on I2C=y && ARCH_OMAP2
98 help 98 help
99 If you say yes here you get support for the Texas Instruments 99 If you say yes here you get support for the Texas Instruments
100 TWL92330/Menelaus Power Management chip. This include voltage 100 TWL92330/Menelaus Power Management chip. This include voltage
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 2a7606534196..19a930d06241 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -115,7 +115,8 @@
115#define twl_has_watchdog() false 115#define twl_has_watchdog() false
116#endif 116#endif
117 117
118#if defined(CONFIG_TWL4030_CODEC) || defined(CONFIG_TWL4030_CODEC_MODULE) 118#if defined(CONFIG_TWL4030_CODEC) || defined(CONFIG_TWL4030_CODEC_MODULE) ||\
119 defined(CONFIG_SND_SOC_TWL6030) || defined(CONFIG_SND_SOC_TWL6030_MODULE)
119#define twl_has_codec() true 120#define twl_has_codec() true
120#else 121#else
121#define twl_has_codec() false 122#define twl_has_codec() false
@@ -711,8 +712,19 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
711 return PTR_ERR(child); 712 return PTR_ERR(child);
712 } 713 }
713 714
714 if (twl_has_codec() && pdata->codec) { 715 if (twl_has_codec() && pdata->codec && twl_class_is_4030()) {
715 child = add_child(1, "twl4030_codec", 716 sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid;
717 child = add_child(sub_chip_id, "twl4030_codec",
718 pdata->codec, sizeof(*pdata->codec),
719 false, 0, 0);
720 if (IS_ERR(child))
721 return PTR_ERR(child);
722 }
723
724 /* Phoenix*/
725 if (twl_has_codec() && pdata->codec && twl_class_is_6030()) {
726 sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid;
727 child = add_child(sub_chip_id, "twl6030_codec",
716 pdata->codec, sizeof(*pdata->codec), 728 pdata->codec, sizeof(*pdata->codec),
717 false, 0, 0); 729 false, 0, 0);
718 if (IS_ERR(child)) 730 if (IS_ERR(child))
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index c5a7a855f4b1..381fe032caa1 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -154,9 +154,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
154 154
155 if (mq->bounce_buf) { 155 if (mq->bounce_buf) {
156 blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_ANY); 156 blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_ANY);
157 blk_queue_max_sectors(mq->queue, bouncesz / 512); 157 blk_queue_max_hw_sectors(mq->queue, bouncesz / 512);
158 blk_queue_max_phys_segments(mq->queue, bouncesz / 512); 158 blk_queue_max_segments(mq->queue, bouncesz / 512);
159 blk_queue_max_hw_segments(mq->queue, bouncesz / 512);
160 blk_queue_max_segment_size(mq->queue, bouncesz); 159 blk_queue_max_segment_size(mq->queue, bouncesz);
161 160
162 mq->sg = kmalloc(sizeof(struct scatterlist), 161 mq->sg = kmalloc(sizeof(struct scatterlist),
@@ -180,10 +179,9 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
180 179
181 if (!mq->bounce_buf) { 180 if (!mq->bounce_buf) {
182 blk_queue_bounce_limit(mq->queue, limit); 181 blk_queue_bounce_limit(mq->queue, limit);
183 blk_queue_max_sectors(mq->queue, 182 blk_queue_max_hw_sectors(mq->queue,
184 min(host->max_blk_count, host->max_req_size / 512)); 183 min(host->max_blk_count, host->max_req_size / 512));
185 blk_queue_max_phys_segments(mq->queue, host->max_phys_segs); 184 blk_queue_max_segments(mq->queue, host->max_hw_segs);
186 blk_queue_max_hw_segments(mq->queue, host->max_hw_segs);
187 blk_queue_max_segment_size(mq->queue, host->max_seg_size); 185 blk_queue_max_segment_size(mq->queue, host->max_seg_size);
188 186
189 mq->sg = kmalloc(sizeof(struct scatterlist) * 187 mq->sg = kmalloc(sizeof(struct scatterlist) *
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 90d168ad03b6..84c103a7ee13 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -2,6 +2,7 @@
2 * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver 2 * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver
3 * 3 *
4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved. 4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
5 * Copyright (C) 2010 ST-Ericsson AB.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -34,9 +35,6 @@
34 35
35#define DRIVER_NAME "mmci-pl18x" 36#define DRIVER_NAME "mmci-pl18x"
36 37
37#define DBG(host,fmt,args...) \
38 pr_debug("%s: %s: " fmt, mmc_hostname(host->mmc), __func__ , args)
39
40static unsigned int fmax = 515633; 38static unsigned int fmax = 515633;
41 39
42/* 40/*
@@ -105,8 +103,8 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
105 void __iomem *base; 103 void __iomem *base;
106 int blksz_bits; 104 int blksz_bits;
107 105
108 DBG(host, "blksz %04x blks %04x flags %08x\n", 106 dev_dbg(mmc_dev(host->mmc), "blksz %04x blks %04x flags %08x\n",
109 data->blksz, data->blocks, data->flags); 107 data->blksz, data->blocks, data->flags);
110 108
111 host->data = data; 109 host->data = data;
112 host->size = data->blksz; 110 host->size = data->blksz;
@@ -155,7 +153,7 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
155{ 153{
156 void __iomem *base = host->base; 154 void __iomem *base = host->base;
157 155
158 DBG(host, "op %02x arg %08x flags %08x\n", 156 dev_dbg(mmc_dev(host->mmc), "op %02x arg %08x flags %08x\n",
159 cmd->opcode, cmd->arg, cmd->flags); 157 cmd->opcode, cmd->arg, cmd->flags);
160 158
161 if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) { 159 if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) {
@@ -184,8 +182,20 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
184{ 182{
185 if (status & MCI_DATABLOCKEND) { 183 if (status & MCI_DATABLOCKEND) {
186 host->data_xfered += data->blksz; 184 host->data_xfered += data->blksz;
185#ifdef CONFIG_ARCH_U300
186 /*
187 * On the U300 some signal or other is
188 * badly routed so that a data write does
189 * not properly terminate with a MCI_DATAEND
190 * status flag. This quirk will make writes
191 * work again.
192 */
193 if (data->flags & MMC_DATA_WRITE)
194 status |= MCI_DATAEND;
195#endif
187 } 196 }
188 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) { 197 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
198 dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status);
189 if (status & MCI_DATACRCFAIL) 199 if (status & MCI_DATACRCFAIL)
190 data->error = -EILSEQ; 200 data->error = -EILSEQ;
191 else if (status & MCI_DATATIMEOUT) 201 else if (status & MCI_DATATIMEOUT)
@@ -307,7 +317,7 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
307 317
308 status = readl(base + MMCISTATUS); 318 status = readl(base + MMCISTATUS);
309 319
310 DBG(host, "irq1 %08x\n", status); 320 dev_dbg(mmc_dev(host->mmc), "irq1 (pio) %08x\n", status);
311 321
312 do { 322 do {
313 unsigned long flags; 323 unsigned long flags;
@@ -401,7 +411,7 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
401 status &= readl(host->base + MMCIMASK0); 411 status &= readl(host->base + MMCIMASK0);
402 writel(status, host->base + MMCICLEAR); 412 writel(status, host->base + MMCICLEAR);
403 413
404 DBG(host, "irq0 %08x\n", status); 414 dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status);
405 415
406 data = host->data; 416 data = host->data;
407 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN| 417 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|
@@ -428,8 +438,8 @@ static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
428 WARN_ON(host->mrq != NULL); 438 WARN_ON(host->mrq != NULL);
429 439
430 if (mrq->data && !is_power_of_2(mrq->data->blksz)) { 440 if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
431 printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n", 441 dev_err(mmc_dev(mmc), "unsupported block size (%d bytes)\n",
432 mmc_hostname(mmc), mrq->data->blksz); 442 mrq->data->blksz);
433 mrq->cmd->error = -EINVAL; 443 mrq->cmd->error = -EINVAL;
434 mmc_request_done(mmc, mrq); 444 mmc_request_done(mmc, mrq);
435 return; 445 return;
@@ -582,8 +592,8 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
582 592
583 host->hw_designer = amba_manf(dev); 593 host->hw_designer = amba_manf(dev);
584 host->hw_revision = amba_rev(dev); 594 host->hw_revision = amba_rev(dev);
585 DBG(host, "designer ID = 0x%02x\n", host->hw_designer); 595 dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer);
586 DBG(host, "revision = 0x%01x\n", host->hw_revision); 596 dev_dbg(mmc_dev(mmc), "revision = 0x%01x\n", host->hw_revision);
587 597
588 host->clk = clk_get(&dev->dev, NULL); 598 host->clk = clk_get(&dev->dev, NULL);
589 if (IS_ERR(host->clk)) { 599 if (IS_ERR(host->clk)) {
@@ -608,7 +618,8 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
608 if (ret < 0) 618 if (ret < 0)
609 goto clk_disable; 619 goto clk_disable;
610 host->mclk = clk_get_rate(host->clk); 620 host->mclk = clk_get_rate(host->clk);
611 DBG(host, "eventual mclk rate: %u Hz\n", host->mclk); 621 dev_dbg(mmc_dev(mmc), "eventual mclk rate: %u Hz\n",
622 host->mclk);
612 } 623 }
613 host->base = ioremap(dev->res.start, resource_size(&dev->res)); 624 host->base = ioremap(dev->res.start, resource_size(&dev->res));
614 if (!host->base) { 625 if (!host->base) {
@@ -619,6 +630,8 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
619 mmc->ops = &mmci_ops; 630 mmc->ops = &mmci_ops;
620 mmc->f_min = (host->mclk + 511) / 512; 631 mmc->f_min = (host->mclk + 511) / 512;
621 mmc->f_max = min(host->mclk, fmax); 632 mmc->f_max = min(host->mclk, fmax);
633 dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max);
634
622#ifdef CONFIG_REGULATOR 635#ifdef CONFIG_REGULATOR
623 /* If we're using the regulator framework, try to fetch a regulator */ 636 /* If we're using the regulator framework, try to fetch a regulator */
624 host->vcc = regulator_get(&dev->dev, "vmmc"); 637 host->vcc = regulator_get(&dev->dev, "vmmc");
@@ -712,7 +725,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
712 725
713 mmc_add_host(mmc); 726 mmc_add_host(mmc);
714 727
715 printk(KERN_INFO "%s: MMCI rev %x cfg %02x at 0x%016llx irq %d,%d\n", 728 dev_info(&dev->dev, "%s: MMCI rev %x cfg %02x at 0x%016llx irq %d,%d\n",
716 mmc_hostname(mmc), amba_rev(dev), amba_config(dev), 729 mmc_hostname(mmc), amba_rev(dev), amba_config(dev),
717 (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]); 730 (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]);
718 731
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 4b2322518909..83f0affadcae 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -30,6 +30,8 @@
30#include <linux/mmc/core.h> 30#include <linux/mmc/core.h>
31#include <linux/io.h> 31#include <linux/io.h>
32#include <linux/semaphore.h> 32#include <linux/semaphore.h>
33#include <linux/gpio.h>
34#include <linux/regulator/consumer.h>
33#include <plat/dma.h> 35#include <plat/dma.h>
34#include <mach/hardware.h> 36#include <mach/hardware.h>
35#include <plat/board.h> 37#include <plat/board.h>
@@ -146,6 +148,15 @@ struct omap_hsmmc_host {
146 struct clk *fclk; 148 struct clk *fclk;
147 struct clk *iclk; 149 struct clk *iclk;
148 struct clk *dbclk; 150 struct clk *dbclk;
151 /*
152 * vcc == configured supply
153 * vcc_aux == optional
154 * - MMC1, supply for DAT4..DAT7
155 * - MMC2/MMC2, external level shifter voltage supply, for
156 * chip (SDIO, eMMC, etc) or transceiver (MMC2 only)
157 */
158 struct regulator *vcc;
159 struct regulator *vcc_aux;
149 struct semaphore sem; 160 struct semaphore sem;
150 struct work_struct mmc_carddetect_work; 161 struct work_struct mmc_carddetect_work;
151 void __iomem *base; 162 void __iomem *base;
@@ -171,10 +182,337 @@ struct omap_hsmmc_host {
171 int vdd; 182 int vdd;
172 int protect_card; 183 int protect_card;
173 int reqs_blocked; 184 int reqs_blocked;
185 int use_reg;
174 186
175 struct omap_mmc_platform_data *pdata; 187 struct omap_mmc_platform_data *pdata;
176}; 188};
177 189
190static int omap_hsmmc_card_detect(struct device *dev, int slot)
191{
192 struct omap_mmc_platform_data *mmc = dev->platform_data;
193
194 /* NOTE: assumes card detect signal is active-low */
195 return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
196}
197
198static int omap_hsmmc_get_wp(struct device *dev, int slot)
199{
200 struct omap_mmc_platform_data *mmc = dev->platform_data;
201
202 /* NOTE: assumes write protect signal is active-high */
203 return gpio_get_value_cansleep(mmc->slots[0].gpio_wp);
204}
205
206static int omap_hsmmc_get_cover_state(struct device *dev, int slot)
207{
208 struct omap_mmc_platform_data *mmc = dev->platform_data;
209
210 /* NOTE: assumes card detect signal is active-low */
211 return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
212}
213
214#ifdef CONFIG_PM
215
216static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot)
217{
218 struct omap_mmc_platform_data *mmc = dev->platform_data;
219
220 disable_irq(mmc->slots[0].card_detect_irq);
221 return 0;
222}
223
224static int omap_hsmmc_resume_cdirq(struct device *dev, int slot)
225{
226 struct omap_mmc_platform_data *mmc = dev->platform_data;
227
228 enable_irq(mmc->slots[0].card_detect_irq);
229 return 0;
230}
231
232#else
233
234#define omap_hsmmc_suspend_cdirq NULL
235#define omap_hsmmc_resume_cdirq NULL
236
237#endif
238
239#ifdef CONFIG_REGULATOR
240
241static int omap_hsmmc_1_set_power(struct device *dev, int slot, int power_on,
242 int vdd)
243{
244 struct omap_hsmmc_host *host =
245 platform_get_drvdata(to_platform_device(dev));
246 int ret;
247
248 if (mmc_slot(host).before_set_reg)
249 mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
250
251 if (power_on)
252 ret = mmc_regulator_set_ocr(host->vcc, vdd);
253 else
254 ret = mmc_regulator_set_ocr(host->vcc, 0);
255
256 if (mmc_slot(host).after_set_reg)
257 mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
258
259 return ret;
260}
261
262static int omap_hsmmc_23_set_power(struct device *dev, int slot, int power_on,
263 int vdd)
264{
265 struct omap_hsmmc_host *host =
266 platform_get_drvdata(to_platform_device(dev));
267 int ret = 0;
268
269 /*
270 * If we don't see a Vcc regulator, assume it's a fixed
271 * voltage always-on regulator.
272 */
273 if (!host->vcc)
274 return 0;
275
276 if (mmc_slot(host).before_set_reg)
277 mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
278
279 /*
280 * Assume Vcc regulator is used only to power the card ... OMAP
281 * VDDS is used to power the pins, optionally with a transceiver to
282 * support cards using voltages other than VDDS (1.8V nominal). When a
283 * transceiver is used, DAT3..7 are muxed as transceiver control pins.
284 *
285 * In some cases this regulator won't support enable/disable;
286 * e.g. it's a fixed rail for a WLAN chip.
287 *
288 * In other cases vcc_aux switches interface power. Example, for
289 * eMMC cards it represents VccQ. Sometimes transceivers or SDIO
290 * chips/cards need an interface voltage rail too.
291 */
292 if (power_on) {
293 ret = mmc_regulator_set_ocr(host->vcc, vdd);
294 /* Enable interface voltage rail, if needed */
295 if (ret == 0 && host->vcc_aux) {
296 ret = regulator_enable(host->vcc_aux);
297 if (ret < 0)
298 ret = mmc_regulator_set_ocr(host->vcc, 0);
299 }
300 } else {
301 if (host->vcc_aux)
302 ret = regulator_disable(host->vcc_aux);
303 if (ret == 0)
304 ret = mmc_regulator_set_ocr(host->vcc, 0);
305 }
306
307 if (mmc_slot(host).after_set_reg)
308 mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
309
310 return ret;
311}
312
313static int omap_hsmmc_1_set_sleep(struct device *dev, int slot, int sleep,
314 int vdd, int cardsleep)
315{
316 struct omap_hsmmc_host *host =
317 platform_get_drvdata(to_platform_device(dev));
318 int mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL;
319
320 return regulator_set_mode(host->vcc, mode);
321}
322
323static int omap_hsmmc_23_set_sleep(struct device *dev, int slot, int sleep,
324 int vdd, int cardsleep)
325{
326 struct omap_hsmmc_host *host =
327 platform_get_drvdata(to_platform_device(dev));
328 int err, mode;
329
330 /*
331 * If we don't see a Vcc regulator, assume it's a fixed
332 * voltage always-on regulator.
333 */
334 if (!host->vcc)
335 return 0;
336
337 mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL;
338
339 if (!host->vcc_aux)
340 return regulator_set_mode(host->vcc, mode);
341
342 if (cardsleep) {
343 /* VCC can be turned off if card is asleep */
344 if (sleep)
345 err = mmc_regulator_set_ocr(host->vcc, 0);
346 else
347 err = mmc_regulator_set_ocr(host->vcc, vdd);
348 } else
349 err = regulator_set_mode(host->vcc, mode);
350 if (err)
351 return err;
352
353 if (!mmc_slot(host).vcc_aux_disable_is_sleep)
354 return regulator_set_mode(host->vcc_aux, mode);
355
356 if (sleep)
357 return regulator_disable(host->vcc_aux);
358 else
359 return regulator_enable(host->vcc_aux);
360}
361
362static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
363{
364 struct regulator *reg;
365 int ret = 0;
366
367 switch (host->id) {
368 case OMAP_MMC1_DEVID:
369 /* On-chip level shifting via PBIAS0/PBIAS1 */
370 mmc_slot(host).set_power = omap_hsmmc_1_set_power;
371 mmc_slot(host).set_sleep = omap_hsmmc_1_set_sleep;
372 break;
373 case OMAP_MMC2_DEVID:
374 case OMAP_MMC3_DEVID:
375 /* Off-chip level shifting, or none */
376 mmc_slot(host).set_power = omap_hsmmc_23_set_power;
377 mmc_slot(host).set_sleep = omap_hsmmc_23_set_sleep;
378 break;
379 default:
380 pr_err("MMC%d configuration not supported!\n", host->id);
381 return -EINVAL;
382 }
383
384 reg = regulator_get(host->dev, "vmmc");
385 if (IS_ERR(reg)) {
386 dev_dbg(host->dev, "vmmc regulator missing\n");
387 /*
388 * HACK: until fixed.c regulator is usable,
389 * we don't require a main regulator
390 * for MMC2 or MMC3
391 */
392 if (host->id == OMAP_MMC1_DEVID) {
393 ret = PTR_ERR(reg);
394 goto err;
395 }
396 } else {
397 host->vcc = reg;
398 mmc_slot(host).ocr_mask = mmc_regulator_get_ocrmask(reg);
399
400 /* Allow an aux regulator */
401 reg = regulator_get(host->dev, "vmmc_aux");
402 host->vcc_aux = IS_ERR(reg) ? NULL : reg;
403
404 /*
405 * UGLY HACK: workaround regulator framework bugs.
406 * When the bootloader leaves a supply active, it's
407 * initialized with zero usecount ... and we can't
408 * disable it without first enabling it. Until the
409 * framework is fixed, we need a workaround like this
410 * (which is safe for MMC, but not in general).
411 */
412 if (regulator_is_enabled(host->vcc) > 0) {
413 regulator_enable(host->vcc);
414 regulator_disable(host->vcc);
415 }
416 if (host->vcc_aux) {
417 if (regulator_is_enabled(reg) > 0) {
418 regulator_enable(reg);
419 regulator_disable(reg);
420 }
421 }
422 }
423
424 return 0;
425
426err:
427 mmc_slot(host).set_power = NULL;
428 mmc_slot(host).set_sleep = NULL;
429 return ret;
430}
431
432static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
433{
434 regulator_put(host->vcc);
435 regulator_put(host->vcc_aux);
436 mmc_slot(host).set_power = NULL;
437 mmc_slot(host).set_sleep = NULL;
438}
439
440static inline int omap_hsmmc_have_reg(void)
441{
442 return 1;
443}
444
445#else
446
447static inline int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
448{
449 return -EINVAL;
450}
451
452static inline void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
453{
454}
455
456static inline int omap_hsmmc_have_reg(void)
457{
458 return 0;
459}
460
461#endif
462
463static int omap_hsmmc_gpio_init(struct omap_mmc_platform_data *pdata)
464{
465 int ret;
466
467 if (gpio_is_valid(pdata->slots[0].switch_pin)) {
468 pdata->suspend = omap_hsmmc_suspend_cdirq;
469 pdata->resume = omap_hsmmc_resume_cdirq;
470 if (pdata->slots[0].cover)
471 pdata->slots[0].get_cover_state =
472 omap_hsmmc_get_cover_state;
473 else
474 pdata->slots[0].card_detect = omap_hsmmc_card_detect;
475 pdata->slots[0].card_detect_irq =
476 gpio_to_irq(pdata->slots[0].switch_pin);
477 ret = gpio_request(pdata->slots[0].switch_pin, "mmc_cd");
478 if (ret)
479 return ret;
480 ret = gpio_direction_input(pdata->slots[0].switch_pin);
481 if (ret)
482 goto err_free_sp;
483 } else
484 pdata->slots[0].switch_pin = -EINVAL;
485
486 if (gpio_is_valid(pdata->slots[0].gpio_wp)) {
487 pdata->slots[0].get_ro = omap_hsmmc_get_wp;
488 ret = gpio_request(pdata->slots[0].gpio_wp, "mmc_wp");
489 if (ret)
490 goto err_free_cd;
491 ret = gpio_direction_input(pdata->slots[0].gpio_wp);
492 if (ret)
493 goto err_free_wp;
494 } else
495 pdata->slots[0].gpio_wp = -EINVAL;
496
497 return 0;
498
499err_free_wp:
500 gpio_free(pdata->slots[0].gpio_wp);
501err_free_cd:
502 if (gpio_is_valid(pdata->slots[0].switch_pin))
503err_free_sp:
504 gpio_free(pdata->slots[0].switch_pin);
505 return ret;
506}
507
508static void omap_hsmmc_gpio_free(struct omap_mmc_platform_data *pdata)
509{
510 if (gpio_is_valid(pdata->slots[0].gpio_wp))
511 gpio_free(pdata->slots[0].gpio_wp);
512 if (gpio_is_valid(pdata->slots[0].switch_pin))
513 gpio_free(pdata->slots[0].switch_pin);
514}
515
178/* 516/*
179 * Stop clock to the card 517 * Stop clock to the card
180 */ 518 */
@@ -835,7 +1173,7 @@ static void omap_hsmmc_detect(struct work_struct *work)
835 sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); 1173 sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
836 1174
837 if (slot->card_detect) 1175 if (slot->card_detect)
838 carddetect = slot->card_detect(slot->card_detect_irq); 1176 carddetect = slot->card_detect(host->dev, host->slot_id);
839 else { 1177 else {
840 omap_hsmmc_protect_card(host); 1178 omap_hsmmc_protect_card(host);
841 carddetect = -ENOSYS; 1179 carddetect = -ENOSYS;
@@ -1242,7 +1580,7 @@ static int omap_hsmmc_get_cd(struct mmc_host *mmc)
1242 1580
1243 if (!mmc_slot(host).card_detect) 1581 if (!mmc_slot(host).card_detect)
1244 return -ENOSYS; 1582 return -ENOSYS;
1245 return mmc_slot(host).card_detect(mmc_slot(host).card_detect_irq); 1583 return mmc_slot(host).card_detect(host->dev, host->slot_id);
1246} 1584}
1247 1585
1248static int omap_hsmmc_get_ro(struct mmc_host *mmc) 1586static int omap_hsmmc_get_ro(struct mmc_host *mmc)
@@ -1311,7 +1649,7 @@ static int omap_hsmmc_enabled_to_disabled(struct omap_hsmmc_host *host)
1311 if (host->power_mode == MMC_POWER_OFF) 1649 if (host->power_mode == MMC_POWER_OFF)
1312 return 0; 1650 return 0;
1313 1651
1314 return msecs_to_jiffies(OMAP_MMC_SLEEP_TIMEOUT); 1652 return OMAP_MMC_SLEEP_TIMEOUT;
1315} 1653}
1316 1654
1317/* Handler for [DISABLED -> REGSLEEP / CARDSLEEP] transition */ 1655/* Handler for [DISABLED -> REGSLEEP / CARDSLEEP] transition */
@@ -1347,11 +1685,14 @@ static int omap_hsmmc_disabled_to_sleep(struct omap_hsmmc_host *host)
1347 dev_dbg(mmc_dev(host->mmc), "DISABLED -> %s\n", 1685 dev_dbg(mmc_dev(host->mmc), "DISABLED -> %s\n",
1348 host->dpm_state == CARDSLEEP ? "CARDSLEEP" : "REGSLEEP"); 1686 host->dpm_state == CARDSLEEP ? "CARDSLEEP" : "REGSLEEP");
1349 1687
1688 if (mmc_slot(host).no_off)
1689 return 0;
1690
1350 if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) || 1691 if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) ||
1351 mmc_slot(host).card_detect || 1692 mmc_slot(host).card_detect ||
1352 (mmc_slot(host).get_cover_state && 1693 (mmc_slot(host).get_cover_state &&
1353 mmc_slot(host).get_cover_state(host->dev, host->slot_id))) 1694 mmc_slot(host).get_cover_state(host->dev, host->slot_id)))
1354 return msecs_to_jiffies(OMAP_MMC_OFF_TIMEOUT); 1695 return OMAP_MMC_OFF_TIMEOUT;
1355 1696
1356 return 0; 1697 return 0;
1357} 1698}
@@ -1362,6 +1703,9 @@ static int omap_hsmmc_sleep_to_off(struct omap_hsmmc_host *host)
1362 if (!mmc_try_claim_host(host->mmc)) 1703 if (!mmc_try_claim_host(host->mmc))
1363 return 0; 1704 return 0;
1364 1705
1706 if (mmc_slot(host).no_off)
1707 return 0;
1708
1365 if (!((host->mmc->caps & MMC_CAP_NONREMOVABLE) || 1709 if (!((host->mmc->caps & MMC_CAP_NONREMOVABLE) ||
1366 mmc_slot(host).card_detect || 1710 mmc_slot(host).card_detect ||
1367 (mmc_slot(host).get_cover_state && 1711 (mmc_slot(host).get_cover_state &&
@@ -1616,7 +1960,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1616 struct mmc_host *mmc; 1960 struct mmc_host *mmc;
1617 struct omap_hsmmc_host *host = NULL; 1961 struct omap_hsmmc_host *host = NULL;
1618 struct resource *res; 1962 struct resource *res;
1619 int ret = 0, irq; 1963 int ret, irq;
1620 1964
1621 if (pdata == NULL) { 1965 if (pdata == NULL) {
1622 dev_err(&pdev->dev, "Platform Data is missing\n"); 1966 dev_err(&pdev->dev, "Platform Data is missing\n");
@@ -1638,10 +1982,14 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1638 if (res == NULL) 1982 if (res == NULL)
1639 return -EBUSY; 1983 return -EBUSY;
1640 1984
1985 ret = omap_hsmmc_gpio_init(pdata);
1986 if (ret)
1987 goto err;
1988
1641 mmc = mmc_alloc_host(sizeof(struct omap_hsmmc_host), &pdev->dev); 1989 mmc = mmc_alloc_host(sizeof(struct omap_hsmmc_host), &pdev->dev);
1642 if (!mmc) { 1990 if (!mmc) {
1643 ret = -ENOMEM; 1991 ret = -ENOMEM;
1644 goto err; 1992 goto err_alloc;
1645 } 1993 }
1646 1994
1647 host = mmc_priv(mmc); 1995 host = mmc_priv(mmc);
@@ -1656,7 +2004,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1656 host->slot_id = 0; 2004 host->slot_id = 0;
1657 host->mapbase = res->start; 2005 host->mapbase = res->start;
1658 host->base = ioremap(host->mapbase, SZ_4K); 2006 host->base = ioremap(host->mapbase, SZ_4K);
1659 host->power_mode = -1; 2007 host->power_mode = MMC_POWER_OFF;
1660 2008
1661 platform_set_drvdata(pdev, host); 2009 platform_set_drvdata(pdev, host);
1662 INIT_WORK(&host->mmc_carddetect_work, omap_hsmmc_detect); 2010 INIT_WORK(&host->mmc_carddetect_work, omap_hsmmc_detect);
@@ -1666,6 +2014,13 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1666 else 2014 else
1667 mmc->ops = &omap_hsmmc_ops; 2015 mmc->ops = &omap_hsmmc_ops;
1668 2016
2017 /*
2018 * If regulator_disable can only put vcc_aux to sleep then there is
2019 * no off state.
2020 */
2021 if (mmc_slot(host).vcc_aux_disable_is_sleep)
2022 mmc_slot(host).no_off = 1;
2023
1669 mmc->f_min = 400000; 2024 mmc->f_min = 400000;
1670 mmc->f_max = 52000000; 2025 mmc->f_max = 52000000;
1671 2026
@@ -1781,7 +2136,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1781 goto err_irq; 2136 goto err_irq;
1782 } 2137 }
1783 2138
1784 /* initialize power supplies, gpios, etc */
1785 if (pdata->init != NULL) { 2139 if (pdata->init != NULL) {
1786 if (pdata->init(&pdev->dev) != 0) { 2140 if (pdata->init(&pdev->dev) != 0) {
1787 dev_dbg(mmc_dev(host->mmc), 2141 dev_dbg(mmc_dev(host->mmc),
@@ -1789,6 +2143,14 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1789 goto err_irq_cd_init; 2143 goto err_irq_cd_init;
1790 } 2144 }
1791 } 2145 }
2146
2147 if (omap_hsmmc_have_reg() && !mmc_slot(host).set_power) {
2148 ret = omap_hsmmc_reg_get(host);
2149 if (ret)
2150 goto err_reg;
2151 host->use_reg = 1;
2152 }
2153
1792 mmc->ocr_avail = mmc_slot(host).ocr_mask; 2154 mmc->ocr_avail = mmc_slot(host).ocr_mask;
1793 2155
1794 /* Request IRQ for card detect */ 2156 /* Request IRQ for card detect */
@@ -1823,19 +2185,22 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1823 ret = device_create_file(&mmc->class_dev, 2185 ret = device_create_file(&mmc->class_dev,
1824 &dev_attr_cover_switch); 2186 &dev_attr_cover_switch);
1825 if (ret < 0) 2187 if (ret < 0)
1826 goto err_cover_switch; 2188 goto err_slot_name;
1827 } 2189 }
1828 2190
1829 omap_hsmmc_debugfs(mmc); 2191 omap_hsmmc_debugfs(mmc);
1830 2192
1831 return 0; 2193 return 0;
1832 2194
1833err_cover_switch:
1834 device_remove_file(&mmc->class_dev, &dev_attr_cover_switch);
1835err_slot_name: 2195err_slot_name:
1836 mmc_remove_host(mmc); 2196 mmc_remove_host(mmc);
1837err_irq_cd:
1838 free_irq(mmc_slot(host).card_detect_irq, host); 2197 free_irq(mmc_slot(host).card_detect_irq, host);
2198err_irq_cd:
2199 if (host->use_reg)
2200 omap_hsmmc_reg_put(host);
2201err_reg:
2202 if (host->pdata->cleanup)
2203 host->pdata->cleanup(&pdev->dev);
1839err_irq_cd_init: 2204err_irq_cd_init:
1840 free_irq(host->irq, host); 2205 free_irq(host->irq, host);
1841err_irq: 2206err_irq:
@@ -1847,14 +2212,14 @@ err_irq:
1847 clk_disable(host->dbclk); 2212 clk_disable(host->dbclk);
1848 clk_put(host->dbclk); 2213 clk_put(host->dbclk);
1849 } 2214 }
1850
1851err1: 2215err1:
1852 iounmap(host->base); 2216 iounmap(host->base);
2217 platform_set_drvdata(pdev, NULL);
2218 mmc_free_host(mmc);
2219err_alloc:
2220 omap_hsmmc_gpio_free(pdata);
1853err: 2221err:
1854 dev_dbg(mmc_dev(host->mmc), "Probe Failed\n");
1855 release_mem_region(res->start, res->end - res->start + 1); 2222 release_mem_region(res->start, res->end - res->start + 1);
1856 if (host)
1857 mmc_free_host(mmc);
1858 return ret; 2223 return ret;
1859} 2224}
1860 2225
@@ -1866,6 +2231,8 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
1866 if (host) { 2231 if (host) {
1867 mmc_host_enable(host->mmc); 2232 mmc_host_enable(host->mmc);
1868 mmc_remove_host(host->mmc); 2233 mmc_remove_host(host->mmc);
2234 if (host->use_reg)
2235 omap_hsmmc_reg_put(host);
1869 if (host->pdata->cleanup) 2236 if (host->pdata->cleanup)
1870 host->pdata->cleanup(&pdev->dev); 2237 host->pdata->cleanup(&pdev->dev);
1871 free_irq(host->irq, host); 2238 free_irq(host->irq, host);
@@ -1884,6 +2251,7 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
1884 2251
1885 mmc_free_host(host->mmc); 2252 mmc_free_host(host->mmc);
1886 iounmap(host->base); 2253 iounmap(host->base);
2254 omap_hsmmc_gpio_free(pdev->dev.platform_data);
1887 } 2255 }
1888 2256
1889 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2257 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 2bb03a8b9ef1..aa2807d0ce72 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -422,15 +422,6 @@ config MTD_H720X
422 This enables access to the flash chips on the Hynix evaluation boards. 422 This enables access to the flash chips on the Hynix evaluation boards.
423 If you have such a board, say 'Y'. 423 If you have such a board, say 'Y'.
424 424
425config MTD_OMAP_NOR
426 tristate "TI OMAP board mappings"
427 depends on MTD_CFI && ARCH_OMAP
428 help
429 This enables access to the NOR flash chips on TI OMAP-based
430 boards defining flash platform devices and flash platform data.
431 These boards include the Innovator, H2, H3, OSK, Perseus2, and
432 more. If you have such a board, say 'Y'.
433
434# This needs CFI or JEDEC, depending on the cards found. 425# This needs CFI or JEDEC, depending on the cards found.
435config MTD_PCI 426config MTD_PCI
436 tristate "PCI MTD driver" 427 tristate "PCI MTD driver"
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index a44919f3f3d2..bb035cd54c72 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -54,7 +54,6 @@ obj-$(CONFIG_MTD_IXP2000) += ixp2000.o
54obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o 54obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o
55obj-$(CONFIG_MTD_DMV182) += dmv182.o 55obj-$(CONFIG_MTD_DMV182) += dmv182.o
56obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o 56obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o
57obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
58obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o 57obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o
59obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o 58obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o
60obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o 59obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
index ead0b2fab670..e69de29bb2d1 100644
--- a/drivers/mtd/maps/omap_nor.c
+++ b/drivers/mtd/maps/omap_nor.c
@@ -1,188 +0,0 @@
1/*
2 * Flash memory support for various TI OMAP boards
3 *
4 * Copyright (C) 2001-2002 MontaVista Software Inc.
5 * Copyright (C) 2003-2004 Texas Instruments
6 * Copyright (C) 2004 Nokia Corporation
7 *
8 * Assembled using driver code copyright the companies above
9 * and written by David Brownell, Jian Zhang <jzhang@ti.com>,
10 * Tony Lindgren <tony@atomide.com> and others.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 */
32
33#include <linux/platform_device.h>
34#include <linux/module.h>
35#include <linux/types.h>
36#include <linux/kernel.h>
37#include <linux/init.h>
38#include <linux/ioport.h>
39#include <linux/slab.h>
40
41#include <linux/mtd/mtd.h>
42#include <linux/mtd/map.h>
43#include <linux/mtd/partitions.h>
44
45#include <asm/io.h>
46#include <mach/hardware.h>
47#include <asm/mach/flash.h>
48#include <plat/tc.h>
49
50#ifdef CONFIG_MTD_PARTITIONS
51static const char *part_probes[] = { /* "RedBoot", */ "cmdlinepart", NULL };
52#endif
53
54struct omapflash_info {
55 struct mtd_partition *parts;
56 struct mtd_info *mtd;
57 struct map_info map;
58};
59
60static void omap_set_vpp(struct map_info *map, int enable)
61{
62 static int count;
63 u32 l;
64
65 if (cpu_class_is_omap1()) {
66 if (enable) {
67 if (count++ == 0) {
68 l = omap_readl(EMIFS_CONFIG);
69 l |= OMAP_EMIFS_CONFIG_WP;
70 omap_writel(l, EMIFS_CONFIG);
71 }
72 } else {
73 if (count && (--count == 0)) {
74 l = omap_readl(EMIFS_CONFIG);
75 l &= ~OMAP_EMIFS_CONFIG_WP;
76 omap_writel(l, EMIFS_CONFIG);
77 }
78 }
79 }
80}
81
82static int __init omapflash_probe(struct platform_device *pdev)
83{
84 int err;
85 struct omapflash_info *info;
86 struct flash_platform_data *pdata = pdev->dev.platform_data;
87 struct resource *res = pdev->resource;
88 unsigned long size = res->end - res->start + 1;
89
90 info = kzalloc(sizeof(struct omapflash_info), GFP_KERNEL);
91 if (!info)
92 return -ENOMEM;
93
94 if (!request_mem_region(res->start, size, "flash")) {
95 err = -EBUSY;
96 goto out_free_info;
97 }
98
99 info->map.virt = ioremap(res->start, size);
100 if (!info->map.virt) {
101 err = -ENOMEM;
102 goto out_release_mem_region;
103 }
104 info->map.name = dev_name(&pdev->dev);
105 info->map.phys = res->start;
106 info->map.size = size;
107 info->map.bankwidth = pdata->width;
108 info->map.set_vpp = omap_set_vpp;
109
110 simple_map_init(&info->map);
111 info->mtd = do_map_probe(pdata->map_name, &info->map);
112 if (!info->mtd) {
113 err = -EIO;
114 goto out_iounmap;
115 }
116 info->mtd->owner = THIS_MODULE;
117
118 info->mtd->dev.parent = &pdev->dev;
119
120#ifdef CONFIG_MTD_PARTITIONS
121 err = parse_mtd_partitions(info->mtd, part_probes, &info->parts, 0);
122 if (err > 0)
123 add_mtd_partitions(info->mtd, info->parts, err);
124 else if (err <= 0 && pdata->parts)
125 add_mtd_partitions(info->mtd, pdata->parts, pdata->nr_parts);
126 else
127#endif
128 add_mtd_device(info->mtd);
129
130 platform_set_drvdata(pdev, info);
131
132 return 0;
133
134out_iounmap:
135 iounmap(info->map.virt);
136out_release_mem_region:
137 release_mem_region(res->start, size);
138out_free_info:
139 kfree(info);
140
141 return err;
142}
143
144static int __exit omapflash_remove(struct platform_device *pdev)
145{
146 struct omapflash_info *info = platform_get_drvdata(pdev);
147
148 platform_set_drvdata(pdev, NULL);
149
150 if (info) {
151 if (info->parts) {
152 del_mtd_partitions(info->mtd);
153 kfree(info->parts);
154 } else
155 del_mtd_device(info->mtd);
156 map_destroy(info->mtd);
157 release_mem_region(info->map.phys, info->map.size);
158 iounmap((void __iomem *) info->map.virt);
159 kfree(info);
160 }
161
162 return 0;
163}
164
165static struct platform_driver omapflash_driver = {
166 .remove = __exit_p(omapflash_remove),
167 .driver = {
168 .name = "omapflash",
169 .owner = THIS_MODULE,
170 },
171};
172
173static int __init omapflash_init(void)
174{
175 return platform_driver_probe(&omapflash_driver, omapflash_probe);
176}
177
178static void __exit omapflash_exit(void)
179{
180 platform_driver_unregister(&omapflash_driver);
181}
182
183module_init(omapflash_init);
184module_exit(omapflash_exit);
185
186MODULE_LICENSE("GPL");
187MODULE_DESCRIPTION("MTD NOR map driver for TI OMAP boards");
188MODULE_ALIAS("platform:omapflash");
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 1bb799f0125c..26aec0080184 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -30,12 +30,8 @@
30 30
31#define DRIVER_NAME "omap2-nand" 31#define DRIVER_NAME "omap2-nand"
32 32
33/* size (4 KiB) for IO mapping */
34#define NAND_IO_SIZE SZ_4K
35
36#define NAND_WP_OFF 0 33#define NAND_WP_OFF 0
37#define NAND_WP_BIT 0x00000010 34#define NAND_WP_BIT 0x00000010
38#define WR_RD_PIN_MONITORING 0x00600000
39 35
40#define GPMC_BUF_FULL 0x00000001 36#define GPMC_BUF_FULL 0x00000001
41#define GPMC_BUF_EMPTY 0x00000000 37#define GPMC_BUF_EMPTY 0x00000000
@@ -882,8 +878,6 @@ static int __devinit omap_nand_probe(struct platform_device *pdev)
882 struct omap_nand_info *info; 878 struct omap_nand_info *info;
883 struct omap_nand_platform_data *pdata; 879 struct omap_nand_platform_data *pdata;
884 int err; 880 int err;
885 unsigned long val;
886
887 881
888 pdata = pdev->dev.platform_data; 882 pdata = pdev->dev.platform_data;
889 if (pdata == NULL) { 883 if (pdata == NULL) {
@@ -905,28 +899,14 @@ static int __devinit omap_nand_probe(struct platform_device *pdev)
905 info->gpmc_cs = pdata->cs; 899 info->gpmc_cs = pdata->cs;
906 info->gpmc_baseaddr = pdata->gpmc_baseaddr; 900 info->gpmc_baseaddr = pdata->gpmc_baseaddr;
907 info->gpmc_cs_baseaddr = pdata->gpmc_cs_baseaddr; 901 info->gpmc_cs_baseaddr = pdata->gpmc_cs_baseaddr;
902 info->phys_base = pdata->phys_base;
908 903
909 info->mtd.priv = &info->nand; 904 info->mtd.priv = &info->nand;
910 info->mtd.name = dev_name(&pdev->dev); 905 info->mtd.name = dev_name(&pdev->dev);
911 info->mtd.owner = THIS_MODULE; 906 info->mtd.owner = THIS_MODULE;
912 907
913 err = gpmc_cs_request(info->gpmc_cs, NAND_IO_SIZE, &info->phys_base); 908 info->nand.options |= pdata->devsize ? NAND_BUSWIDTH_16 : 0;
914 if (err < 0) { 909 info->nand.options |= NAND_SKIP_BBTSCAN;
915 dev_err(&pdev->dev, "Cannot request GPMC CS\n");
916 goto out_free_info;
917 }
918
919 /* Enable RD PIN Monitoring Reg */
920 if (pdata->dev_ready) {
921 val = gpmc_cs_read_reg(info->gpmc_cs, GPMC_CS_CONFIG1);
922 val |= WR_RD_PIN_MONITORING;
923 gpmc_cs_write_reg(info->gpmc_cs, GPMC_CS_CONFIG1, val);
924 }
925
926 val = gpmc_cs_read_reg(info->gpmc_cs, GPMC_CS_CONFIG7);
927 val &= ~(0xf << 8);
928 val |= (0xc & 0xf) << 8;
929 gpmc_cs_write_reg(info->gpmc_cs, GPMC_CS_CONFIG7, val);
930 910
931 /* NAND write protect off */ 911 /* NAND write protect off */
932 omap_nand_wp(&info->mtd, NAND_WP_OFF); 912 omap_nand_wp(&info->mtd, NAND_WP_OFF);
@@ -934,7 +914,7 @@ static int __devinit omap_nand_probe(struct platform_device *pdev)
934 if (!request_mem_region(info->phys_base, NAND_IO_SIZE, 914 if (!request_mem_region(info->phys_base, NAND_IO_SIZE,
935 pdev->dev.driver->name)) { 915 pdev->dev.driver->name)) {
936 err = -EBUSY; 916 err = -EBUSY;
937 goto out_free_cs; 917 goto out_free_info;
938 } 918 }
939 919
940 info->nand.IO_ADDR_R = ioremap(info->phys_base, NAND_IO_SIZE); 920 info->nand.IO_ADDR_R = ioremap(info->phys_base, NAND_IO_SIZE);
@@ -963,11 +943,6 @@ static int __devinit omap_nand_probe(struct platform_device *pdev)
963 info->nand.chip_delay = 50; 943 info->nand.chip_delay = 50;
964 } 944 }
965 945
966 info->nand.options |= NAND_SKIP_BBTSCAN;
967 if ((gpmc_cs_read_reg(info->gpmc_cs, GPMC_CS_CONFIG1) & 0x3000)
968 == 0x1000)
969 info->nand.options |= NAND_BUSWIDTH_16;
970
971 if (use_prefetch) { 946 if (use_prefetch) {
972 /* copy the virtual address of nand base for fifo access */ 947 /* copy the virtual address of nand base for fifo access */
973 info->nand_pref_fifo_add = info->nand.IO_ADDR_R; 948 info->nand_pref_fifo_add = info->nand.IO_ADDR_R;
@@ -1043,8 +1018,6 @@ static int __devinit omap_nand_probe(struct platform_device *pdev)
1043 1018
1044out_release_mem_region: 1019out_release_mem_region:
1045 release_mem_region(info->phys_base, NAND_IO_SIZE); 1020 release_mem_region(info->phys_base, NAND_IO_SIZE);
1046out_free_cs:
1047 gpmc_cs_free(info->gpmc_cs);
1048out_free_info: 1021out_free_info:
1049 kfree(info); 1022 kfree(info);
1050 1023
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 46af867af85f..7029cd50c458 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -932,7 +932,7 @@ config NET_NETX
932 932
933config TI_DAVINCI_EMAC 933config TI_DAVINCI_EMAC
934 tristate "TI DaVinci EMAC Support" 934 tristate "TI DaVinci EMAC Support"
935 depends on ARM && ARCH_DAVINCI 935 depends on ARM && ( ARCH_DAVINCI || ARCH_OMAP3 )
936 select PHYLIB 936 select PHYLIB
937 help 937 help
938 This driver supports TI's DaVinci Ethernet . 938 This driver supports TI's DaVinci Ethernet .
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
index 8ca639127dbc..a1d4188c430b 100644
--- a/drivers/net/arm/ks8695net.c
+++ b/drivers/net/arm/ks8695net.c
@@ -575,9 +575,9 @@ static int ks8695_poll(struct napi_struct *napi, int budget)
575 if (work_done < budget) { 575 if (work_done < budget) {
576 unsigned long flags; 576 unsigned long flags;
577 spin_lock_irqsave(&ksp->rx_lock, flags); 577 spin_lock_irqsave(&ksp->rx_lock, flags);
578 __napi_complete(napi);
578 /*enable rx interrupt*/ 579 /*enable rx interrupt*/
579 writel(isr | mask_bit, KS8695_IRQ_VA + KS8695_INTEN); 580 writel(isr | mask_bit, KS8695_IRQ_VA + KS8695_INTEN);
580 __napi_complete(napi);
581 spin_unlock_irqrestore(&ksp->rx_lock, flags); 581 spin_unlock_irqrestore(&ksp->rx_lock, flags);
582 } 582 }
583 return work_done; 583 return work_done;
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index be81fb2d10f7..8f0752553681 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -290,11 +290,6 @@ extern const struct ethtool_ops be_ethtool_ops;
290 290
291#define drvr_stats(adapter) (&adapter->stats.drvr_stats) 291#define drvr_stats(adapter) (&adapter->stats.drvr_stats)
292 292
293static inline unsigned int be_pci_func(struct be_adapter *adapter)
294{
295 return PCI_FUNC(adapter->pdev->devfn);
296}
297
298#define BE_SET_NETDEV_OPS(netdev, ops) (netdev->netdev_ops = ops) 293#define BE_SET_NETDEV_OPS(netdev, ops) (netdev->netdev_ops = ops)
299 294
300#define PAGE_SHIFT_4K 12 295#define PAGE_SHIFT_4K 12
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 4b1f80519ca4..c59215361f4e 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -465,8 +465,6 @@ int be_cmd_eq_create(struct be_adapter *adapter,
465 465
466 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); 466 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
467 467
468 AMAP_SET_BITS(struct amap_eq_context, func, req->context,
469 be_pci_func(adapter));
470 AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1); 468 AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1);
471 /* 4byte eqe*/ 469 /* 4byte eqe*/
472 AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0); 470 AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0);
@@ -629,7 +627,6 @@ int be_cmd_cq_create(struct be_adapter *adapter,
629 AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1); 627 AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1);
630 AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id); 628 AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id);
631 AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1); 629 AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1);
632 AMAP_SET_BITS(struct amap_cq_context, func, ctxt, be_pci_func(adapter));
633 be_dws_cpu_to_le(ctxt, sizeof(req->context)); 630 be_dws_cpu_to_le(ctxt, sizeof(req->context));
634 631
635 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); 632 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
@@ -678,7 +675,6 @@ int be_cmd_mccq_create(struct be_adapter *adapter,
678 675
679 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); 676 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size);
680 677
681 AMAP_SET_BITS(struct amap_mcc_context, fid, ctxt, be_pci_func(adapter));
682 AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1); 678 AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1);
683 AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt, 679 AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt,
684 be_encoded_q_len(mccq->len)); 680 be_encoded_q_len(mccq->len));
@@ -727,8 +723,6 @@ int be_cmd_txq_create(struct be_adapter *adapter,
727 723
728 AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt, 724 AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt,
729 be_encoded_q_len(txq->len)); 725 be_encoded_q_len(txq->len));
730 AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt,
731 be_pci_func(adapter));
732 AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1); 726 AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1);
733 AMAP_SET_BITS(struct amap_tx_context, cq_id_send, ctxt, cq->id); 727 AMAP_SET_BITS(struct amap_tx_context, cq_id_send, ctxt, cq->id);
734 728
diff --git a/drivers/net/benet/be_hw.h b/drivers/net/benet/be_hw.h
index 5ffb149181ad..2d4a4b827637 100644
--- a/drivers/net/benet/be_hw.h
+++ b/drivers/net/benet/be_hw.h
@@ -114,8 +114,7 @@
114#define IMG_TYPE_ISCSI_BACKUP 9 114#define IMG_TYPE_ISCSI_BACKUP 9
115#define IMG_TYPE_FCOE_FW_ACTIVE 10 115#define IMG_TYPE_FCOE_FW_ACTIVE 10
116#define IMG_TYPE_FCOE_FW_BACKUP 11 116#define IMG_TYPE_FCOE_FW_BACKUP 11
117#define IMG_TYPE_NCSI_BITFILE 13 117#define IMG_TYPE_NCSI_FW 13
118#define IMG_TYPE_NCSI_8051 14
119 118
120#define FLASHROM_OPER_FLASH 1 119#define FLASHROM_OPER_FLASH 1
121#define FLASHROM_OPER_SAVE 2 120#define FLASHROM_OPER_SAVE 2
@@ -127,6 +126,7 @@
127#define FLASH_IMAGE_MAX_SIZE_g3 (2097152) /* Max fw image size */ 126#define FLASH_IMAGE_MAX_SIZE_g3 (2097152) /* Max fw image size */
128#define FLASH_BIOS_IMAGE_MAX_SIZE_g3 (524288) /* Max OPTION ROM img sz */ 127#define FLASH_BIOS_IMAGE_MAX_SIZE_g3 (524288) /* Max OPTION ROM img sz */
129#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g3 (1048576) /* Max Redboot image sz */ 128#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g3 (1048576) /* Max Redboot image sz */
129#define FLASH_NCSI_IMAGE_MAX_SIZE_g3 (262144) /* Max NSCI image sz */
130 130
131#define FLASH_NCSI_MAGIC (0x16032009) 131#define FLASH_NCSI_MAGIC (0x16032009)
132#define FLASH_NCSI_DISABLED (0) 132#define FLASH_NCSI_DISABLED (0)
@@ -144,6 +144,7 @@
144#define FLASH_FCoE_BIOS_START_g2 (524288) 144#define FLASH_FCoE_BIOS_START_g2 (524288)
145#define FLASH_REDBOOT_START_g2 (0) 145#define FLASH_REDBOOT_START_g2 (0)
146 146
147#define FLASH_NCSI_START_g3 (15990784)
147#define FLASH_iSCSI_PRIMARY_IMAGE_START_g3 (2097152) 148#define FLASH_iSCSI_PRIMARY_IMAGE_START_g3 (2097152)
148#define FLASH_iSCSI_BACKUP_IMAGE_START_g3 (4194304) 149#define FLASH_iSCSI_BACKUP_IMAGE_START_g3 (4194304)
149#define FLASH_FCoE_PRIMARY_IMAGE_START_g3 (6291456) 150#define FLASH_FCoE_PRIMARY_IMAGE_START_g3 (6291456)
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index a703ed8e24fe..43e8032f9236 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -1382,7 +1382,7 @@ rx_eq_free:
1382/* There are 8 evt ids per func. Retruns the evt id's bit number */ 1382/* There are 8 evt ids per func. Retruns the evt id's bit number */
1383static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id) 1383static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id)
1384{ 1384{
1385 return eq_id - 8 * be_pci_func(adapter); 1385 return eq_id % 8;
1386} 1386}
1387 1387
1388static irqreturn_t be_intx(int irq, void *dev) 1388static irqreturn_t be_intx(int irq, void *dev)
@@ -1880,8 +1880,9 @@ static int be_flash_data(struct be_adapter *adapter,
1880 const u8 *p = fw->data; 1880 const u8 *p = fw->data;
1881 struct be_cmd_write_flashrom *req = flash_cmd->va; 1881 struct be_cmd_write_flashrom *req = flash_cmd->va;
1882 struct flash_comp *pflashcomp; 1882 struct flash_comp *pflashcomp;
1883 int num_comp;
1883 1884
1884 struct flash_comp gen3_flash_types[8] = { 1885 struct flash_comp gen3_flash_types[9] = {
1885 { FLASH_iSCSI_PRIMARY_IMAGE_START_g3, IMG_TYPE_ISCSI_ACTIVE, 1886 { FLASH_iSCSI_PRIMARY_IMAGE_START_g3, IMG_TYPE_ISCSI_ACTIVE,
1886 FLASH_IMAGE_MAX_SIZE_g3}, 1887 FLASH_IMAGE_MAX_SIZE_g3},
1887 { FLASH_REDBOOT_START_g3, IMG_TYPE_REDBOOT, 1888 { FLASH_REDBOOT_START_g3, IMG_TYPE_REDBOOT,
@@ -1897,7 +1898,9 @@ static int be_flash_data(struct be_adapter *adapter,
1897 { FLASH_FCoE_PRIMARY_IMAGE_START_g3, IMG_TYPE_FCOE_FW_ACTIVE, 1898 { FLASH_FCoE_PRIMARY_IMAGE_START_g3, IMG_TYPE_FCOE_FW_ACTIVE,
1898 FLASH_IMAGE_MAX_SIZE_g3}, 1899 FLASH_IMAGE_MAX_SIZE_g3},
1899 { FLASH_FCoE_BACKUP_IMAGE_START_g3, IMG_TYPE_FCOE_FW_BACKUP, 1900 { FLASH_FCoE_BACKUP_IMAGE_START_g3, IMG_TYPE_FCOE_FW_BACKUP,
1900 FLASH_IMAGE_MAX_SIZE_g3} 1901 FLASH_IMAGE_MAX_SIZE_g3},
1902 { FLASH_NCSI_START_g3, IMG_TYPE_NCSI_FW,
1903 FLASH_NCSI_IMAGE_MAX_SIZE_g3}
1901 }; 1904 };
1902 struct flash_comp gen2_flash_types[8] = { 1905 struct flash_comp gen2_flash_types[8] = {
1903 { FLASH_iSCSI_PRIMARY_IMAGE_START_g2, IMG_TYPE_ISCSI_ACTIVE, 1906 { FLASH_iSCSI_PRIMARY_IMAGE_START_g2, IMG_TYPE_ISCSI_ACTIVE,
@@ -1921,11 +1924,16 @@ static int be_flash_data(struct be_adapter *adapter,
1921 if (adapter->generation == BE_GEN3) { 1924 if (adapter->generation == BE_GEN3) {
1922 pflashcomp = gen3_flash_types; 1925 pflashcomp = gen3_flash_types;
1923 filehdr_size = sizeof(struct flash_file_hdr_g3); 1926 filehdr_size = sizeof(struct flash_file_hdr_g3);
1927 num_comp = 9;
1924 } else { 1928 } else {
1925 pflashcomp = gen2_flash_types; 1929 pflashcomp = gen2_flash_types;
1926 filehdr_size = sizeof(struct flash_file_hdr_g2); 1930 filehdr_size = sizeof(struct flash_file_hdr_g2);
1931 num_comp = 8;
1927 } 1932 }
1928 for (i = 0; i < 8; i++) { 1933 for (i = 0; i < num_comp; i++) {
1934 if ((pflashcomp[i].optype == IMG_TYPE_NCSI_FW) &&
1935 memcmp(adapter->fw_ver, "3.102.148.0", 11) < 0)
1936 continue;
1929 if ((pflashcomp[i].optype == IMG_TYPE_REDBOOT) && 1937 if ((pflashcomp[i].optype == IMG_TYPE_REDBOOT) &&
1930 (!be_flash_redboot(adapter, fw->data, 1938 (!be_flash_redboot(adapter, fw->data,
1931 pflashcomp[i].offset, pflashcomp[i].size, 1939 pflashcomp[i].offset, pflashcomp[i].size,
@@ -1985,16 +1993,7 @@ int be_load_fw(struct be_adapter *adapter, u8 *func)
1985 struct be_dma_mem flash_cmd; 1993 struct be_dma_mem flash_cmd;
1986 int status, i = 0; 1994 int status, i = 0;
1987 const u8 *p; 1995 const u8 *p;
1988 char fw_ver[FW_VER_LEN];
1989 char fw_cfg;
1990
1991 status = be_cmd_get_fw_ver(adapter, fw_ver);
1992 if (status)
1993 return status;
1994 1996
1995 fw_cfg = *(fw_ver + 2);
1996 if (fw_cfg == '0')
1997 fw_cfg = '1';
1998 strcpy(fw_file, func); 1997 strcpy(fw_file, func);
1999 1998
2000 status = request_firmware(&fw, fw_file, &adapter->pdev->dev); 1999 status = request_firmware(&fw, fw_file, &adapter->pdev->dev);
diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c
index bf7f9ba2d903..866905fa4119 100644
--- a/drivers/net/can/bfin_can.c
+++ b/drivers/net/can/bfin_can.c
@@ -26,6 +26,7 @@
26 26
27#define DRV_NAME "bfin_can" 27#define DRV_NAME "bfin_can"
28#define BFIN_CAN_TIMEOUT 100 28#define BFIN_CAN_TIMEOUT 100
29#define TX_ECHO_SKB_MAX 1
29 30
30/* 31/*
31 * transmit and receive channels 32 * transmit and receive channels
@@ -593,7 +594,7 @@ struct net_device *alloc_bfin_candev(void)
593 struct net_device *dev; 594 struct net_device *dev;
594 struct bfin_can_priv *priv; 595 struct bfin_can_priv *priv;
595 596
596 dev = alloc_candev(sizeof(*priv)); 597 dev = alloc_candev(sizeof(*priv), TX_ECHO_SKB_MAX);
597 if (!dev) 598 if (!dev)
598 return NULL; 599 return NULL;
599 600
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 11c87840cc00..33451092b8e8 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -876,9 +876,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
876 return NETDEV_TX_OK; 876 return NETDEV_TX_OK;
877 877
878nomem: 878nomem:
879 if (skb) 879 dev_kfree_skb(skb);
880 dev_kfree_skb(skb);
881
882 stats->tx_dropped++; 880 stats->tx_dropped++;
883 881
884 return NETDEV_TX_OK; 882 return NETDEV_TX_OK;
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 7cbcfb0ade1c..9bd155e4111c 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -5072,7 +5072,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5072 INIT_WORK(&cp->reset_task, cas_reset_task); 5072 INIT_WORK(&cp->reset_task, cas_reset_task);
5073 5073
5074 /* Default link parameters */ 5074 /* Default link parameters */
5075 if (link_mode >= 0 && link_mode <= 6) 5075 if (link_mode >= 0 && link_mode < 6)
5076 cp->link_cntl = link_modes[link_mode]; 5076 cp->link_cntl = link_modes[link_mode];
5077 else 5077 else
5078 cp->link_cntl = BMCR_ANENABLE; 5078 cp->link_cntl = BMCR_ANENABLE;
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index b85c81f60d10..60777fd90b33 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -28,6 +28,7 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29 29
30#include <linux/netdevice.h> 30#include <linux/netdevice.h>
31#include <linux/if_vlan.h>
31#include <linux/etherdevice.h> 32#include <linux/etherdevice.h>
32#include <linux/ethtool.h> 33#include <linux/ethtool.h>
33#include <linux/skbuff.h> 34#include <linux/skbuff.h>
@@ -55,9 +56,9 @@ module_param(dumb_switch, int, 0444);
55MODULE_PARM_DESC(debug_level, "Number of NETIF_MSG bits to enable"); 56MODULE_PARM_DESC(debug_level, "Number of NETIF_MSG bits to enable");
56MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus"); 57MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus");
57 58
58#define CPMAC_VERSION "0.5.1" 59#define CPMAC_VERSION "0.5.2"
59/* frame size + 802.1q tag */ 60/* frame size + 802.1q tag + FCS size */
60#define CPMAC_SKB_SIZE (ETH_FRAME_LEN + 4) 61#define CPMAC_SKB_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
61#define CPMAC_QUEUES 8 62#define CPMAC_QUEUES 8
62 63
63/* Ethernet registers */ 64/* Ethernet registers */
@@ -1136,8 +1137,9 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1136 } 1137 }
1137 1138
1138 if (phy_id == PHY_MAX_ADDR) { 1139 if (phy_id == PHY_MAX_ADDR) {
1139 dev_err(&pdev->dev, "no PHY present\n"); 1140 dev_err(&pdev->dev, "no PHY present, falling back to switch on MDIO bus 0\n");
1140 return -ENODEV; 1141 strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */
1142 phy_id = pdev->id;
1141 } 1143 }
1142 1144
1143 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); 1145 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
@@ -1290,8 +1292,8 @@ void __devexit cpmac_exit(void)
1290{ 1292{
1291 platform_driver_unregister(&cpmac_driver); 1293 platform_driver_unregister(&cpmac_driver);
1292 mdiobus_unregister(cpmac_mii); 1294 mdiobus_unregister(cpmac_mii);
1293 mdiobus_free(cpmac_mii);
1294 iounmap(cpmac_mii->priv); 1295 iounmap(cpmac_mii->priv);
1296 mdiobus_free(cpmac_mii);
1295} 1297}
1296 1298
1297module_init(cpmac_init); 1299module_init(cpmac_init);
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 6fd968abb073..cecdec1551db 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -1280,6 +1280,7 @@ static void cxgb_down(struct adapter *adapter)
1280 1280
1281 free_irq_resources(adapter); 1281 free_irq_resources(adapter);
1282 quiesce_rx(adapter); 1282 quiesce_rx(adapter);
1283 t3_sge_stop(adapter);
1283 flush_workqueue(cxgb3_wq); /* wait for external IRQ handler */ 1284 flush_workqueue(cxgb3_wq); /* wait for external IRQ handler */
1284} 1285}
1285 1286
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 3f5db83c7cbb..32960b9b02ae 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -62,12 +62,11 @@
62#include <linux/bitops.h> 62#include <linux/bitops.h>
63#include <linux/io.h> 63#include <linux/io.h>
64#include <linux/uaccess.h> 64#include <linux/uaccess.h>
65#include <linux/davinci_emac.h>
65 66
66#include <asm/irq.h> 67#include <asm/irq.h>
67#include <asm/page.h> 68#include <asm/page.h>
68 69
69#include <mach/emac.h>
70
71static int debug_level; 70static int debug_level;
72module_param(debug_level, int, 0); 71module_param(debug_level, int, 0);
73MODULE_PARM_DESC(debug_level, "DaVinci EMAC debug level (NETIF_MSG bits)"); 72MODULE_PARM_DESC(debug_level, "DaVinci EMAC debug level (NETIF_MSG bits)");
@@ -465,6 +464,7 @@ struct emac_priv {
465 void __iomem *ctrl_base; 464 void __iomem *ctrl_base;
466 void __iomem *emac_ctrl_ram; 465 void __iomem *emac_ctrl_ram;
467 u32 ctrl_ram_size; 466 u32 ctrl_ram_size;
467 u32 hw_ram_addr;
468 struct emac_txch *txch[EMAC_DEF_MAX_TX_CH]; 468 struct emac_txch *txch[EMAC_DEF_MAX_TX_CH];
469 struct emac_rxch *rxch[EMAC_DEF_MAX_RX_CH]; 469 struct emac_rxch *rxch[EMAC_DEF_MAX_RX_CH];
470 u32 link; /* 1=link on, 0=link off */ 470 u32 link; /* 1=link on, 0=link off */
@@ -488,6 +488,9 @@ struct emac_priv {
488 struct mii_bus *mii_bus; 488 struct mii_bus *mii_bus;
489 struct phy_device *phydev; 489 struct phy_device *phydev;
490 spinlock_t lock; 490 spinlock_t lock;
491 /*platform specific members*/
492 void (*int_enable) (void);
493 void (*int_disable) (void);
491}; 494};
492 495
493/* clock frequency for EMAC */ 496/* clock frequency for EMAC */
@@ -495,11 +498,9 @@ static struct clk *emac_clk;
495static unsigned long emac_bus_frequency; 498static unsigned long emac_bus_frequency;
496static unsigned long mdio_max_freq; 499static unsigned long mdio_max_freq;
497 500
498/* EMAC internal utility function */ 501#define emac_virt_to_phys(addr, priv) \
499static inline u32 emac_virt_to_phys(void __iomem *addr) 502 (((u32 __force)(addr) - (u32 __force)(priv->emac_ctrl_ram)) \
500{ 503 + priv->hw_ram_addr)
501 return (u32 __force) io_v2p(addr);
502}
503 504
504/* Cache macros - Packet buffers would be from skb pool which is cached */ 505/* Cache macros - Packet buffers would be from skb pool which is cached */
505#define EMAC_VIRT_NOCACHE(addr) (addr) 506#define EMAC_VIRT_NOCACHE(addr) (addr)
@@ -1001,6 +1002,8 @@ static void emac_int_disable(struct emac_priv *priv)
1001 emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0x0); 1002 emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0x0);
1002 emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0x0); 1003 emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0x0);
1003 /* NOTE: Rx Threshold and Misc interrupts are not disabled */ 1004 /* NOTE: Rx Threshold and Misc interrupts are not disabled */
1005 if (priv->int_disable)
1006 priv->int_disable();
1004 1007
1005 local_irq_restore(flags); 1008 local_irq_restore(flags);
1006 1009
@@ -1020,6 +1023,9 @@ static void emac_int_disable(struct emac_priv *priv)
1020static void emac_int_enable(struct emac_priv *priv) 1023static void emac_int_enable(struct emac_priv *priv)
1021{ 1024{
1022 if (priv->version == EMAC_VERSION_2) { 1025 if (priv->version == EMAC_VERSION_2) {
1026 if (priv->int_enable)
1027 priv->int_enable();
1028
1023 emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0xff); 1029 emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0xff);
1024 emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0xff); 1030 emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0xff);
1025 1031
@@ -1301,7 +1307,7 @@ static int emac_tx_bdproc(struct emac_priv *priv, u32 ch, u32 budget)
1301 curr_bd = txch->active_queue_head; 1307 curr_bd = txch->active_queue_head;
1302 if (NULL == curr_bd) { 1308 if (NULL == curr_bd) {
1303 emac_write(EMAC_TXCP(ch), 1309 emac_write(EMAC_TXCP(ch),
1304 emac_virt_to_phys(txch->last_hw_bdprocessed)); 1310 emac_virt_to_phys(txch->last_hw_bdprocessed, priv));
1305 txch->no_active_pkts++; 1311 txch->no_active_pkts++;
1306 spin_unlock_irqrestore(&priv->tx_lock, flags); 1312 spin_unlock_irqrestore(&priv->tx_lock, flags);
1307 return 0; 1313 return 0;
@@ -1311,7 +1317,7 @@ static int emac_tx_bdproc(struct emac_priv *priv, u32 ch, u32 budget)
1311 while ((curr_bd) && 1317 while ((curr_bd) &&
1312 ((frame_status & EMAC_CPPI_OWNERSHIP_BIT) == 0) && 1318 ((frame_status & EMAC_CPPI_OWNERSHIP_BIT) == 0) &&
1313 (pkts_processed < budget)) { 1319 (pkts_processed < budget)) {
1314 emac_write(EMAC_TXCP(ch), emac_virt_to_phys(curr_bd)); 1320 emac_write(EMAC_TXCP(ch), emac_virt_to_phys(curr_bd, priv));
1315 txch->active_queue_head = curr_bd->next; 1321 txch->active_queue_head = curr_bd->next;
1316 if (frame_status & EMAC_CPPI_EOQ_BIT) { 1322 if (frame_status & EMAC_CPPI_EOQ_BIT) {
1317 if (curr_bd->next) { /* misqueued packet */ 1323 if (curr_bd->next) { /* misqueued packet */
@@ -1398,7 +1404,7 @@ static int emac_send(struct emac_priv *priv, struct emac_netpktobj *pkt, u32 ch)
1398 txch->active_queue_tail = curr_bd; 1404 txch->active_queue_tail = curr_bd;
1399 if (1 != txch->queue_active) { 1405 if (1 != txch->queue_active) {
1400 emac_write(EMAC_TXHDP(ch), 1406 emac_write(EMAC_TXHDP(ch),
1401 emac_virt_to_phys(curr_bd)); 1407 emac_virt_to_phys(curr_bd, priv));
1402 txch->queue_active = 1; 1408 txch->queue_active = 1;
1403 } 1409 }
1404 ++txch->queue_reinit; 1410 ++txch->queue_reinit;
@@ -1410,10 +1416,11 @@ static int emac_send(struct emac_priv *priv, struct emac_netpktobj *pkt, u32 ch)
1410 tail_bd->next = curr_bd; 1416 tail_bd->next = curr_bd;
1411 txch->active_queue_tail = curr_bd; 1417 txch->active_queue_tail = curr_bd;
1412 tail_bd = EMAC_VIRT_NOCACHE(tail_bd); 1418 tail_bd = EMAC_VIRT_NOCACHE(tail_bd);
1413 tail_bd->h_next = (int)emac_virt_to_phys(curr_bd); 1419 tail_bd->h_next = (int)emac_virt_to_phys(curr_bd, priv);
1414 frame_status = tail_bd->mode; 1420 frame_status = tail_bd->mode;
1415 if (frame_status & EMAC_CPPI_EOQ_BIT) { 1421 if (frame_status & EMAC_CPPI_EOQ_BIT) {
1416 emac_write(EMAC_TXHDP(ch), emac_virt_to_phys(curr_bd)); 1422 emac_write(EMAC_TXHDP(ch),
1423 emac_virt_to_phys(curr_bd, priv));
1417 frame_status &= ~(EMAC_CPPI_EOQ_BIT); 1424 frame_status &= ~(EMAC_CPPI_EOQ_BIT);
1418 tail_bd->mode = frame_status; 1425 tail_bd->mode = frame_status;
1419 ++txch->end_of_queue_add; 1426 ++txch->end_of_queue_add;
@@ -1603,7 +1610,8 @@ static int emac_init_rxch(struct emac_priv *priv, u32 ch, char *param)
1603 } 1610 }
1604 1611
1605 /* populate the hardware descriptor */ 1612 /* populate the hardware descriptor */
1606 curr_bd->h_next = emac_virt_to_phys(rxch->active_queue_head); 1613 curr_bd->h_next = emac_virt_to_phys(rxch->active_queue_head,
1614 priv);
1607 /* FIXME buff_ptr = dma_map_single(... data_ptr ...) */ 1615 /* FIXME buff_ptr = dma_map_single(... data_ptr ...) */
1608 curr_bd->buff_ptr = virt_to_phys(curr_bd->data_ptr); 1616 curr_bd->buff_ptr = virt_to_phys(curr_bd->data_ptr);
1609 curr_bd->off_b_len = rxch->buf_size; 1617 curr_bd->off_b_len = rxch->buf_size;
@@ -1878,7 +1886,7 @@ static void emac_addbd_to_rx_queue(struct emac_priv *priv, u32 ch,
1878 rxch->active_queue_tail = curr_bd; 1886 rxch->active_queue_tail = curr_bd;
1879 if (0 != rxch->queue_active) { 1887 if (0 != rxch->queue_active) {
1880 emac_write(EMAC_RXHDP(ch), 1888 emac_write(EMAC_RXHDP(ch),
1881 emac_virt_to_phys(rxch->active_queue_head)); 1889 emac_virt_to_phys(rxch->active_queue_head, priv));
1882 rxch->queue_active = 1; 1890 rxch->queue_active = 1;
1883 } 1891 }
1884 } else { 1892 } else {
@@ -1889,11 +1897,11 @@ static void emac_addbd_to_rx_queue(struct emac_priv *priv, u32 ch,
1889 rxch->active_queue_tail = curr_bd; 1897 rxch->active_queue_tail = curr_bd;
1890 tail_bd->next = curr_bd; 1898 tail_bd->next = curr_bd;
1891 tail_bd = EMAC_VIRT_NOCACHE(tail_bd); 1899 tail_bd = EMAC_VIRT_NOCACHE(tail_bd);
1892 tail_bd->h_next = emac_virt_to_phys(curr_bd); 1900 tail_bd->h_next = emac_virt_to_phys(curr_bd, priv);
1893 frame_status = tail_bd->mode; 1901 frame_status = tail_bd->mode;
1894 if (frame_status & EMAC_CPPI_EOQ_BIT) { 1902 if (frame_status & EMAC_CPPI_EOQ_BIT) {
1895 emac_write(EMAC_RXHDP(ch), 1903 emac_write(EMAC_RXHDP(ch),
1896 emac_virt_to_phys(curr_bd)); 1904 emac_virt_to_phys(curr_bd, priv));
1897 frame_status &= ~(EMAC_CPPI_EOQ_BIT); 1905 frame_status &= ~(EMAC_CPPI_EOQ_BIT);
1898 tail_bd->mode = frame_status; 1906 tail_bd->mode = frame_status;
1899 ++rxch->end_of_queue_add; 1907 ++rxch->end_of_queue_add;
@@ -1986,7 +1994,7 @@ static int emac_rx_bdproc(struct emac_priv *priv, u32 ch, u32 budget)
1986 curr_pkt->num_bufs = 1; 1994 curr_pkt->num_bufs = 1;
1987 curr_pkt->pkt_length = 1995 curr_pkt->pkt_length =
1988 (frame_status & EMAC_RX_BD_PKT_LENGTH_MASK); 1996 (frame_status & EMAC_RX_BD_PKT_LENGTH_MASK);
1989 emac_write(EMAC_RXCP(ch), emac_virt_to_phys(curr_bd)); 1997 emac_write(EMAC_RXCP(ch), emac_virt_to_phys(curr_bd, priv));
1990 ++rxch->processed_bd; 1998 ++rxch->processed_bd;
1991 last_bd = curr_bd; 1999 last_bd = curr_bd;
1992 curr_bd = last_bd->next; 2000 curr_bd = last_bd->next;
@@ -1997,7 +2005,7 @@ static int emac_rx_bdproc(struct emac_priv *priv, u32 ch, u32 budget)
1997 if (curr_bd) { 2005 if (curr_bd) {
1998 ++rxch->mis_queued_packets; 2006 ++rxch->mis_queued_packets;
1999 emac_write(EMAC_RXHDP(ch), 2007 emac_write(EMAC_RXHDP(ch),
2000 emac_virt_to_phys(curr_bd)); 2008 emac_virt_to_phys(curr_bd, priv));
2001 } else { 2009 } else {
2002 ++rxch->end_of_queue; 2010 ++rxch->end_of_queue;
2003 rxch->queue_active = 0; 2011 rxch->queue_active = 0;
@@ -2098,7 +2106,7 @@ static int emac_hw_enable(struct emac_priv *priv)
2098 emac_write(EMAC_RXINTMASKSET, BIT(ch)); 2106 emac_write(EMAC_RXINTMASKSET, BIT(ch));
2099 rxch->queue_active = 1; 2107 rxch->queue_active = 1;
2100 emac_write(EMAC_RXHDP(ch), 2108 emac_write(EMAC_RXHDP(ch),
2101 emac_virt_to_phys(rxch->active_queue_head)); 2109 emac_virt_to_phys(rxch->active_queue_head, priv));
2102 } 2110 }
2103 2111
2104 /* Enable MII */ 2112 /* Enable MII */
@@ -2377,7 +2385,7 @@ static int emac_dev_open(struct net_device *ndev)
2377 struct emac_priv *priv = netdev_priv(ndev); 2385 struct emac_priv *priv = netdev_priv(ndev);
2378 2386
2379 netif_carrier_off(ndev); 2387 netif_carrier_off(ndev);
2380 for (cnt = 0; cnt <= ETH_ALEN; cnt++) 2388 for (cnt = 0; cnt < ETH_ALEN; cnt++)
2381 ndev->dev_addr[cnt] = priv->mac_addr[cnt]; 2389 ndev->dev_addr[cnt] = priv->mac_addr[cnt];
2382 2390
2383 /* Configuration items */ 2391 /* Configuration items */
@@ -2659,6 +2667,9 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
2659 priv->phy_mask = pdata->phy_mask; 2667 priv->phy_mask = pdata->phy_mask;
2660 priv->rmii_en = pdata->rmii_en; 2668 priv->rmii_en = pdata->rmii_en;
2661 priv->version = pdata->version; 2669 priv->version = pdata->version;
2670 priv->int_enable = pdata->interrupt_enable;
2671 priv->int_disable = pdata->interrupt_disable;
2672
2662 emac_dev = &ndev->dev; 2673 emac_dev = &ndev->dev;
2663 /* Get EMAC platform data */ 2674 /* Get EMAC platform data */
2664 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2675 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -2690,6 +2701,12 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
2690 priv->ctrl_ram_size = pdata->ctrl_ram_size; 2701 priv->ctrl_ram_size = pdata->ctrl_ram_size;
2691 priv->emac_ctrl_ram = priv->remap_addr + pdata->ctrl_ram_offset; 2702 priv->emac_ctrl_ram = priv->remap_addr + pdata->ctrl_ram_offset;
2692 2703
2704 if (pdata->hw_ram_addr)
2705 priv->hw_ram_addr = pdata->hw_ram_addr;
2706 else
2707 priv->hw_ram_addr = (u32 __force)res->start +
2708 pdata->ctrl_ram_offset;
2709
2693 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2710 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
2694 if (!res) { 2711 if (!res) {
2695 dev_err(emac_dev, "DaVinci EMAC: Error getting irq res\n"); 2712 dev_err(emac_dev, "DaVinci EMAC: Error getting irq res\n");
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index db05ec355749..e301e26d6897 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -320,6 +320,8 @@
320#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */ 320#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */
321 321
322/* Header split receive */ 322/* Header split receive */
323#define E1000_RFCTL_NFSW_DIS 0x00000040
324#define E1000_RFCTL_NFSR_DIS 0x00000080
323#define E1000_RFCTL_ACK_DIS 0x00001000 325#define E1000_RFCTL_ACK_DIS 0x00001000
324#define E1000_RFCTL_EXTEN 0x00008000 326#define E1000_RFCTL_EXTEN 0x00008000
325#define E1000_RFCTL_IPV6_EX_DIS 0x00010000 327#define E1000_RFCTL_IPV6_EX_DIS 0x00010000
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 54d03a0ce3ce..8b5e157e9c87 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -2740,6 +2740,16 @@ static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
2740 reg &= ~(1 << 31); 2740 reg &= ~(1 << 31);
2741 ew32(STATUS, reg); 2741 ew32(STATUS, reg);
2742 } 2742 }
2743
2744 /*
2745 * work-around descriptor data corruption issue during nfs v2 udp
2746 * traffic, just disable the nfs filtering capability
2747 */
2748 reg = er32(RFCTL);
2749 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
2750 ew32(RFCTL, reg);
2751
2752 return;
2743} 2753}
2744 2754
2745/** 2755/**
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 6aa526ee9096..c3f061957c04 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -2021,7 +2021,6 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2021 } 2021 }
2022 2022
2023 /* setup the TxBD length and buffer pointer for the first BD */ 2023 /* setup the TxBD length and buffer pointer for the first BD */
2024 tx_queue->tx_skbuff[tx_queue->skb_curtx] = skb;
2025 txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data, 2024 txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data,
2026 skb_headlen(skb), DMA_TO_DEVICE); 2025 skb_headlen(skb), DMA_TO_DEVICE);
2027 2026
@@ -2053,6 +2052,10 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2053 2052
2054 txbdp_start->lstatus = lstatus; 2053 txbdp_start->lstatus = lstatus;
2055 2054
2055 eieio(); /* force lstatus write before tx_skbuff */
2056
2057 tx_queue->tx_skbuff[tx_queue->skb_curtx] = skb;
2058
2056 /* Update the current skb pointer to the next entry we will use 2059 /* Update the current skb pointer to the next entry we will use
2057 * (wrapping if necessary) */ 2060 * (wrapping if necessary) */
2058 tx_queue->skb_curtx = (tx_queue->skb_curtx + 1) & 2061 tx_queue->skb_curtx = (tx_queue->skb_curtx + 1) &
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index e8e33bb9d876..2c9b3af16612 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1651,6 +1651,8 @@ static int irda_usb_probe(struct usb_interface *intf,
1651 1651
1652 self->rx_urb = kcalloc(self->max_rx_urb, sizeof(struct urb *), 1652 self->rx_urb = kcalloc(self->max_rx_urb, sizeof(struct urb *),
1653 GFP_KERNEL); 1653 GFP_KERNEL);
1654 if (!self->rx_urb)
1655 goto err_free_net;
1654 1656
1655 for (i = 0; i < self->max_rx_urb; i++) { 1657 for (i = 0; i < self->max_rx_urb; i++) {
1656 self->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); 1658 self->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
@@ -1783,6 +1785,8 @@ err_out_2:
1783err_out_1: 1785err_out_1:
1784 for (i = 0; i < self->max_rx_urb; i++) 1786 for (i = 0; i < self->max_rx_urb; i++)
1785 usb_free_urb(self->rx_urb[i]); 1787 usb_free_urb(self->rx_urb[i]);
1788 kfree(self->rx_urb);
1789err_free_net:
1786 free_netdev(net); 1790 free_netdev(net);
1787err_out: 1791err_out:
1788 return ret; 1792 return ret;
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index b40a851ec7d1..0da94b208db1 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -423,6 +423,11 @@ struct qlcnic_adapter_stats {
423 u64 lro_pkts; 423 u64 lro_pkts;
424 u64 rxbytes; 424 u64 rxbytes;
425 u64 txbytes; 425 u64 txbytes;
426 u64 lrobytes;
427 u64 lso_frames;
428 u64 xmit_on;
429 u64 xmit_off;
430 u64 skb_alloc_failure;
426}; 431};
427 432
428/* 433/*
@@ -1095,11 +1100,11 @@ struct qlcnic_brdinfo {
1095 1100
1096static const struct qlcnic_brdinfo qlcnic_boards[] = { 1101static const struct qlcnic_brdinfo qlcnic_boards[] = {
1097 {0x1077, 0x8020, 0x1077, 0x203, 1102 {0x1077, 0x8020, 0x1077, 0x203,
1098 "8200 Series Single Port 10GbE Converged Network Adapter \ 1103 "8200 Series Single Port 10GbE Converged Network Adapter "
1099 (TCP/IP Networking)"}, 1104 "(TCP/IP Networking)"},
1100 {0x1077, 0x8020, 0x1077, 0x207, 1105 {0x1077, 0x8020, 0x1077, 0x207,
1101 "8200 Series Dual Port 10GbE Converged Network Adapter \ 1106 "8200 Series Dual Port 10GbE Converged Network Adapter "
1102 (TCP/IP Networking)"}, 1107 "(TCP/IP Networking)"},
1103 {0x1077, 0x8020, 0x1077, 0x20b, 1108 {0x1077, 0x8020, 0x1077, 0x20b,
1104 "3200 Series Dual Port 10Gb Intelligent Ethernet Adapter"}, 1109 "3200 Series Dual Port 10Gb Intelligent Ethernet Adapter"},
1105 {0x1077, 0x8020, 0x1077, 0x20c, 1110 {0x1077, 0x8020, 0x1077, 0x20c,
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c
index 8da6ec8c13b9..f83e15fe3e1b 100644
--- a/drivers/net/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/qlcnic/qlcnic_ethtool.c
@@ -59,6 +59,17 @@ static const struct qlcnic_stats qlcnic_gstrings_stats[] = {
59 QLC_SIZEOF(stats.rxbytes), QLC_OFF(stats.rxbytes)}, 59 QLC_SIZEOF(stats.rxbytes), QLC_OFF(stats.rxbytes)},
60 {"tx_bytes", 60 {"tx_bytes",
61 QLC_SIZEOF(stats.txbytes), QLC_OFF(stats.txbytes)}, 61 QLC_SIZEOF(stats.txbytes), QLC_OFF(stats.txbytes)},
62 {"lrobytes",
63 QLC_SIZEOF(stats.lrobytes), QLC_OFF(stats.lrobytes)},
64 {"lso_frames",
65 QLC_SIZEOF(stats.lso_frames), QLC_OFF(stats.lso_frames)},
66 {"xmit_on",
67 QLC_SIZEOF(stats.xmit_on), QLC_OFF(stats.xmit_on)},
68 {"xmit_off",
69 QLC_SIZEOF(stats.xmit_off), QLC_OFF(stats.xmit_off)},
70 {"skb_alloc_failure", QLC_SIZEOF(stats.skb_alloc_failure),
71 QLC_OFF(stats.skb_alloc_failure)},
72
62}; 73};
63 74
64#define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats) 75#define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats)
@@ -785,6 +796,11 @@ qlcnic_get_ethtool_stats(struct net_device *dev,
785 } 796 }
786} 797}
787 798
799static u32 qlcnic_get_tx_csum(struct net_device *dev)
800{
801 return dev->features & NETIF_F_IP_CSUM;
802}
803
788static u32 qlcnic_get_rx_csum(struct net_device *dev) 804static u32 qlcnic_get_rx_csum(struct net_device *dev)
789{ 805{
790 struct qlcnic_adapter *adapter = netdev_priv(dev); 806 struct qlcnic_adapter *adapter = netdev_priv(dev);
@@ -995,6 +1011,7 @@ const struct ethtool_ops qlcnic_ethtool_ops = {
995 .set_ringparam = qlcnic_set_ringparam, 1011 .set_ringparam = qlcnic_set_ringparam,
996 .get_pauseparam = qlcnic_get_pauseparam, 1012 .get_pauseparam = qlcnic_get_pauseparam,
997 .set_pauseparam = qlcnic_set_pauseparam, 1013 .set_pauseparam = qlcnic_set_pauseparam,
1014 .get_tx_csum = qlcnic_get_tx_csum,
998 .set_tx_csum = ethtool_op_set_tx_csum, 1015 .set_tx_csum = ethtool_op_set_tx_csum,
999 .set_sg = ethtool_op_set_sg, 1016 .set_sg = ethtool_op_set_sg,
1000 .get_tso = qlcnic_get_tso, 1017 .get_tso = qlcnic_get_tso,
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c
index 99a4d1379d00..da00e162b6d3 100644
--- a/drivers/net/qlcnic/qlcnic_hw.c
+++ b/drivers/net/qlcnic/qlcnic_hw.c
@@ -349,6 +349,7 @@ qlcnic_send_cmd_descs(struct qlcnic_adapter *adapter,
349 if (nr_desc >= qlcnic_tx_avail(tx_ring)) { 349 if (nr_desc >= qlcnic_tx_avail(tx_ring)) {
350 netif_tx_stop_queue(tx_ring->txq); 350 netif_tx_stop_queue(tx_ring->txq);
351 __netif_tx_unlock_bh(tx_ring->txq); 351 __netif_tx_unlock_bh(tx_ring->txq);
352 adapter->stats.xmit_off++;
352 return -EBUSY; 353 return -EBUSY;
353 } 354 }
354 355
@@ -397,20 +398,16 @@ qlcnic_sre_macaddr_change(struct qlcnic_adapter *adapter, u8 *addr,
397 return qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); 398 return qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
398} 399}
399 400
400static int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, 401static int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, u8 *addr)
401 u8 *addr, struct list_head *del_list)
402{ 402{
403 struct list_head *head; 403 struct list_head *head;
404 struct qlcnic_mac_list_s *cur; 404 struct qlcnic_mac_list_s *cur;
405 405
406 /* look up if already exists */ 406 /* look up if already exists */
407 list_for_each(head, del_list) { 407 list_for_each(head, &adapter->mac_list) {
408 cur = list_entry(head, struct qlcnic_mac_list_s, list); 408 cur = list_entry(head, struct qlcnic_mac_list_s, list);
409 409 if (memcmp(addr, cur->mac_addr, ETH_ALEN) == 0)
410 if (memcmp(addr, cur->mac_addr, ETH_ALEN) == 0) {
411 list_move_tail(head, &adapter->mac_list);
412 return 0; 410 return 0;
413 }
414 } 411 }
415 412
416 cur = kzalloc(sizeof(struct qlcnic_mac_list_s), GFP_ATOMIC); 413 cur = kzalloc(sizeof(struct qlcnic_mac_list_s), GFP_ATOMIC);
@@ -432,14 +429,9 @@ void qlcnic_set_multi(struct net_device *netdev)
432 struct dev_mc_list *mc_ptr; 429 struct dev_mc_list *mc_ptr;
433 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 430 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
434 u32 mode = VPORT_MISS_MODE_DROP; 431 u32 mode = VPORT_MISS_MODE_DROP;
435 LIST_HEAD(del_list);
436 struct list_head *head;
437 struct qlcnic_mac_list_s *cur;
438 432
439 list_splice_tail_init(&adapter->mac_list, &del_list); 433 qlcnic_nic_add_mac(adapter, adapter->mac_addr);
440 434 qlcnic_nic_add_mac(adapter, bcast_addr);
441 qlcnic_nic_add_mac(adapter, adapter->mac_addr, &del_list);
442 qlcnic_nic_add_mac(adapter, bcast_addr, &del_list);
443 435
444 if (netdev->flags & IFF_PROMISC) { 436 if (netdev->flags & IFF_PROMISC) {
445 mode = VPORT_MISS_MODE_ACCEPT_ALL; 437 mode = VPORT_MISS_MODE_ACCEPT_ALL;
@@ -454,22 +446,12 @@ void qlcnic_set_multi(struct net_device *netdev)
454 446
455 if (!netdev_mc_empty(netdev)) { 447 if (!netdev_mc_empty(netdev)) {
456 netdev_for_each_mc_addr(mc_ptr, netdev) { 448 netdev_for_each_mc_addr(mc_ptr, netdev) {
457 qlcnic_nic_add_mac(adapter, mc_ptr->dmi_addr, 449 qlcnic_nic_add_mac(adapter, mc_ptr->dmi_addr);
458 &del_list);
459 } 450 }
460 } 451 }
461 452
462send_fw_cmd: 453send_fw_cmd:
463 qlcnic_nic_set_promisc(adapter, mode); 454 qlcnic_nic_set_promisc(adapter, mode);
464 head = &del_list;
465 while (!list_empty(head)) {
466 cur = list_entry(head->next, struct qlcnic_mac_list_s, list);
467
468 qlcnic_sre_macaddr_change(adapter,
469 cur->mac_addr, QLCNIC_MAC_DEL);
470 list_del(&cur->list);
471 kfree(cur);
472 }
473} 455}
474 456
475int qlcnic_nic_set_promisc(struct qlcnic_adapter *adapter, u32 mode) 457int qlcnic_nic_set_promisc(struct qlcnic_adapter *adapter, u32 mode)
diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c
index ea00ab4d4feb..7c34e4e29b3f 100644
--- a/drivers/net/qlcnic/qlcnic_init.c
+++ b/drivers/net/qlcnic/qlcnic_init.c
@@ -568,21 +568,123 @@ struct uni_table_desc *qlcnic_get_table_desc(const u8 *unirom, int section)
568 return NULL; 568 return NULL;
569} 569}
570 570
571#define FILEHEADER_SIZE (14 * 4)
572
571static int 573static int
572qlcnic_set_product_offs(struct qlcnic_adapter *adapter) 574qlcnic_validate_header(struct qlcnic_adapter *adapter)
573{ 575{
574 struct uni_table_desc *ptab_descr;
575 const u8 *unirom = adapter->fw->data; 576 const u8 *unirom = adapter->fw->data;
576 u32 i; 577 struct uni_table_desc *directory = (struct uni_table_desc *) &unirom[0];
578 __le32 fw_file_size = adapter->fw->size;
577 __le32 entries; 579 __le32 entries;
580 __le32 entry_size;
581 __le32 tab_size;
582
583 if (fw_file_size < FILEHEADER_SIZE)
584 return -EINVAL;
585
586 entries = cpu_to_le32(directory->num_entries);
587 entry_size = cpu_to_le32(directory->entry_size);
588 tab_size = cpu_to_le32(directory->findex) + (entries * entry_size);
589
590 if (fw_file_size < tab_size)
591 return -EINVAL;
592
593 return 0;
594}
595
596static int
597qlcnic_validate_bootld(struct qlcnic_adapter *adapter)
598{
599 struct uni_table_desc *tab_desc;
600 struct uni_data_desc *descr;
601 const u8 *unirom = adapter->fw->data;
602 int idx = cpu_to_le32(*((int *)&unirom[adapter->file_prd_off] +
603 QLCNIC_UNI_BOOTLD_IDX_OFF));
604 __le32 offs;
605 __le32 tab_size;
606 __le32 data_size;
607
608 tab_desc = qlcnic_get_table_desc(unirom, QLCNIC_UNI_DIR_SECT_BOOTLD);
609
610 if (!tab_desc)
611 return -EINVAL;
612
613 tab_size = cpu_to_le32(tab_desc->findex) +
614 (cpu_to_le32(tab_desc->entry_size * (idx + 1)));
615
616 if (adapter->fw->size < tab_size)
617 return -EINVAL;
618
619 offs = cpu_to_le32(tab_desc->findex) +
620 (cpu_to_le32(tab_desc->entry_size) * (idx));
621 descr = (struct uni_data_desc *)&unirom[offs];
622
623 data_size = descr->findex + cpu_to_le32(descr->size);
624
625 if (adapter->fw->size < data_size)
626 return -EINVAL;
627
628 return 0;
629}
630
631static int
632qlcnic_validate_fw(struct qlcnic_adapter *adapter)
633{
634 struct uni_table_desc *tab_desc;
635 struct uni_data_desc *descr;
636 const u8 *unirom = adapter->fw->data;
637 int idx = cpu_to_le32(*((int *)&unirom[adapter->file_prd_off] +
638 QLCNIC_UNI_FIRMWARE_IDX_OFF));
639 __le32 offs;
640 __le32 tab_size;
641 __le32 data_size;
642
643 tab_desc = qlcnic_get_table_desc(unirom, QLCNIC_UNI_DIR_SECT_FW);
644
645 if (!tab_desc)
646 return -EINVAL;
647
648 tab_size = cpu_to_le32(tab_desc->findex) +
649 (cpu_to_le32(tab_desc->entry_size * (idx + 1)));
650
651 if (adapter->fw->size < tab_size)
652 return -EINVAL;
653
654 offs = cpu_to_le32(tab_desc->findex) +
655 (cpu_to_le32(tab_desc->entry_size) * (idx));
656 descr = (struct uni_data_desc *)&unirom[offs];
657 data_size = descr->findex + cpu_to_le32(descr->size);
658
659 if (adapter->fw->size < data_size)
660 return -EINVAL;
661
662 return 0;
663}
664
665static int
666qlcnic_validate_product_offs(struct qlcnic_adapter *adapter)
667{
668 struct uni_table_desc *ptab_descr;
669 const u8 *unirom = adapter->fw->data;
578 int mn_present = qlcnic_has_mn(adapter); 670 int mn_present = qlcnic_has_mn(adapter);
671 __le32 entries;
672 __le32 entry_size;
673 __le32 tab_size;
674 u32 i;
579 675
580 ptab_descr = qlcnic_get_table_desc(unirom, 676 ptab_descr = qlcnic_get_table_desc(unirom,
581 QLCNIC_UNI_DIR_SECT_PRODUCT_TBL); 677 QLCNIC_UNI_DIR_SECT_PRODUCT_TBL);
582 if (ptab_descr == NULL) 678 if (!ptab_descr)
583 return -1; 679 return -EINVAL;
584 680
585 entries = cpu_to_le32(ptab_descr->num_entries); 681 entries = cpu_to_le32(ptab_descr->num_entries);
682 entry_size = cpu_to_le32(ptab_descr->entry_size);
683 tab_size = cpu_to_le32(ptab_descr->findex) + (entries * entry_size);
684
685 if (adapter->fw->size < tab_size)
686 return -EINVAL;
687
586nomn: 688nomn:
587 for (i = 0; i < entries; i++) { 689 for (i = 0; i < entries; i++) {
588 690
@@ -609,7 +711,37 @@ nomn:
609 mn_present = 0; 711 mn_present = 0;
610 goto nomn; 712 goto nomn;
611 } 713 }
612 return -1; 714 return -EINVAL;
715}
716
717static int
718qlcnic_validate_unified_romimage(struct qlcnic_adapter *adapter)
719{
720 if (qlcnic_validate_header(adapter)) {
721 dev_err(&adapter->pdev->dev,
722 "unified image: header validation failed\n");
723 return -EINVAL;
724 }
725
726 if (qlcnic_validate_product_offs(adapter)) {
727 dev_err(&adapter->pdev->dev,
728 "unified image: product validation failed\n");
729 return -EINVAL;
730 }
731
732 if (qlcnic_validate_bootld(adapter)) {
733 dev_err(&adapter->pdev->dev,
734 "unified image: bootld validation failed\n");
735 return -EINVAL;
736 }
737
738 if (qlcnic_validate_fw(adapter)) {
739 dev_err(&adapter->pdev->dev,
740 "unified image: firmware validation failed\n");
741 return -EINVAL;
742 }
743
744 return 0;
613} 745}
614 746
615static 747static
@@ -715,7 +847,7 @@ qlcnic_get_bios_version(struct qlcnic_adapter *adapter)
715 bios_ver = cpu_to_le32(*((u32 *) (&fw->data[prd_off]) 847 bios_ver = cpu_to_le32(*((u32 *) (&fw->data[prd_off])
716 + QLCNIC_UNI_BIOS_VERSION_OFF)); 848 + QLCNIC_UNI_BIOS_VERSION_OFF));
717 849
718 return (bios_ver << 24) + ((bios_ver >> 8) & 0xff00) + (bios_ver >> 24); 850 return (bios_ver << 16) + ((bios_ver >> 8) & 0xff00) + (bios_ver >> 24);
719} 851}
720 852
721int 853int
@@ -858,7 +990,7 @@ qlcnic_validate_firmware(struct qlcnic_adapter *adapter)
858 u8 fw_type = adapter->fw_type; 990 u8 fw_type = adapter->fw_type;
859 991
860 if (fw_type == QLCNIC_UNIFIED_ROMIMAGE) { 992 if (fw_type == QLCNIC_UNIFIED_ROMIMAGE) {
861 if (qlcnic_set_product_offs(adapter)) 993 if (qlcnic_validate_unified_romimage(adapter))
862 return -EINVAL; 994 return -EINVAL;
863 995
864 min_size = QLCNIC_UNI_FW_MIN_SIZE; 996 min_size = QLCNIC_UNI_FW_MIN_SIZE;
@@ -1114,8 +1246,10 @@ qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
1114 struct pci_dev *pdev = adapter->pdev; 1246 struct pci_dev *pdev = adapter->pdev;
1115 1247
1116 buffer->skb = dev_alloc_skb(rds_ring->skb_size); 1248 buffer->skb = dev_alloc_skb(rds_ring->skb_size);
1117 if (!buffer->skb) 1249 if (!buffer->skb) {
1250 adapter->stats.skb_alloc_failure++;
1118 return -ENOMEM; 1251 return -ENOMEM;
1252 }
1119 1253
1120 skb = buffer->skb; 1254 skb = buffer->skb;
1121 1255
@@ -1289,7 +1423,7 @@ qlcnic_process_lro(struct qlcnic_adapter *adapter,
1289 netif_receive_skb(skb); 1423 netif_receive_skb(skb);
1290 1424
1291 adapter->stats.lro_pkts++; 1425 adapter->stats.lro_pkts++;
1292 adapter->stats.rxbytes += length; 1426 adapter->stats.lrobytes += length;
1293 1427
1294 return buffer; 1428 return buffer;
1295} 1429}
@@ -1505,6 +1639,8 @@ qlcnic_process_rcv_diag(struct qlcnic_adapter *adapter,
1505 adapter->diag_cnt++; 1639 adapter->diag_cnt++;
1506 1640
1507 dev_kfree_skb_any(skb); 1641 dev_kfree_skb_any(skb);
1642 adapter->stats.rx_pkts++;
1643 adapter->stats.rxbytes += length;
1508 1644
1509 return buffer; 1645 return buffer;
1510} 1646}
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 665e8e56b6a8..fc721564e69e 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -118,6 +118,7 @@ qlcnic_update_cmd_producer(struct qlcnic_adapter *adapter,
118 if (qlcnic_tx_avail(tx_ring) <= TX_STOP_THRESH) { 118 if (qlcnic_tx_avail(tx_ring) <= TX_STOP_THRESH) {
119 netif_stop_queue(adapter->netdev); 119 netif_stop_queue(adapter->netdev);
120 smp_mb(); 120 smp_mb();
121 adapter->stats.xmit_off++;
121 } 122 }
122} 123}
123 124
@@ -1385,6 +1386,7 @@ qlcnic_tso_check(struct net_device *netdev,
1385 int copied, offset, copy_len, hdr_len = 0, tso = 0, vlan_oob = 0; 1386 int copied, offset, copy_len, hdr_len = 0, tso = 0, vlan_oob = 0;
1386 struct cmd_desc_type0 *hwdesc; 1387 struct cmd_desc_type0 *hwdesc;
1387 struct vlan_ethhdr *vh; 1388 struct vlan_ethhdr *vh;
1389 struct qlcnic_adapter *adapter = netdev_priv(netdev);
1388 1390
1389 if (protocol == cpu_to_be16(ETH_P_8021Q)) { 1391 if (protocol == cpu_to_be16(ETH_P_8021Q)) {
1390 1392
@@ -1494,6 +1496,7 @@ qlcnic_tso_check(struct net_device *netdev,
1494 1496
1495 tx_ring->producer = producer; 1497 tx_ring->producer = producer;
1496 barrier(); 1498 barrier();
1499 adapter->stats.lso_frames++;
1497} 1500}
1498 1501
1499static int 1502static int
@@ -1573,6 +1576,7 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1573 1576
1574 if (unlikely(no_of_desc + 2 > qlcnic_tx_avail(tx_ring))) { 1577 if (unlikely(no_of_desc + 2 > qlcnic_tx_avail(tx_ring))) {
1575 netif_stop_queue(netdev); 1578 netif_stop_queue(netdev);
1579 adapter->stats.xmit_off++;
1576 return NETDEV_TX_BUSY; 1580 return NETDEV_TX_BUSY;
1577 } 1581 }
1578 1582
@@ -1880,6 +1884,7 @@ static int qlcnic_process_cmd_ring(struct qlcnic_adapter *adapter)
1880 if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH) { 1884 if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH) {
1881 netif_wake_queue(netdev); 1885 netif_wake_queue(netdev);
1882 adapter->tx_timeo_cnt = 0; 1886 adapter->tx_timeo_cnt = 0;
1887 adapter->stats.xmit_on++;
1883 } 1888 }
1884 __netif_tx_unlock(tx_ring->txq); 1889 __netif_tx_unlock(tx_ring->txq);
1885 } 1890 }
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index dfc3573c91bb..9d3ebf3e975e 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -4270,7 +4270,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
4270 4270
4271 tp->cur_tx += frags + 1; 4271 tp->cur_tx += frags + 1;
4272 4272
4273 smp_wmb(); 4273 wmb();
4274 4274
4275 RTL_W8(TxPoll, NPQ); /* set polling bit */ 4275 RTL_W8(TxPoll, NPQ); /* set polling bit */
4276 4276
@@ -4621,7 +4621,7 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
4621 * until it does. 4621 * until it does.
4622 */ 4622 */
4623 tp->intr_mask = 0xffff; 4623 tp->intr_mask = 0xffff;
4624 smp_wmb(); 4624 wmb();
4625 RTL_W16(IntrMask, tp->intr_event); 4625 RTL_W16(IntrMask, tp->intr_event);
4626 } 4626 }
4627 4627
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 43bc66aa8405..df70657260dd 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -923,8 +923,8 @@ static int init_shared_mem(struct s2io_nic *nic)
923 tmp_v_addr = mac_control->stats_mem; 923 tmp_v_addr = mac_control->stats_mem;
924 mac_control->stats_info = (struct stat_block *)tmp_v_addr; 924 mac_control->stats_info = (struct stat_block *)tmp_v_addr;
925 memset(tmp_v_addr, 0, size); 925 memset(tmp_v_addr, 0, size);
926 DBG_PRINT(INIT_DBG, "%s: Ring Mem PHY: 0x%llx\n", dev->name, 926 DBG_PRINT(INIT_DBG, "%s: Ring Mem PHY: 0x%llx\n",
927 (unsigned long long)tmp_p_addr); 927 dev_name(&nic->pdev->dev), (unsigned long long)tmp_p_addr);
928 mac_control->stats_info->sw_stat.mem_allocated += mem_allocated; 928 mac_control->stats_info->sw_stat.mem_allocated += mem_allocated;
929 return SUCCESS; 929 return SUCCESS;
930} 930}
@@ -3480,7 +3480,7 @@ static void s2io_reset(struct s2io_nic *sp)
3480 struct swStat *swstats; 3480 struct swStat *swstats;
3481 3481
3482 DBG_PRINT(INIT_DBG, "%s: Resetting XFrame card %s\n", 3482 DBG_PRINT(INIT_DBG, "%s: Resetting XFrame card %s\n",
3483 __func__, sp->dev->name); 3483 __func__, pci_name(sp->pdev));
3484 3484
3485 /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */ 3485 /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */
3486 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd)); 3486 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd));
diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
index 05adb6a666cf..3269292efecc 100644
--- a/drivers/net/smc911x.h
+++ b/drivers/net/smc911x.h
@@ -42,12 +42,12 @@
42 #define SMC_USE_16BIT 0 42 #define SMC_USE_16BIT 0
43 #define SMC_USE_32BIT 1 43 #define SMC_USE_32BIT 1
44 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW 44 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW
45#elif defined(CONFIG_ARCH_OMAP34XX) 45#elif defined(CONFIG_ARCH_OMAP3)
46 #define SMC_USE_16BIT 0 46 #define SMC_USE_16BIT 0
47 #define SMC_USE_32BIT 1 47 #define SMC_USE_32BIT 1
48 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW 48 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW
49 #define SMC_MEM_RESERVED 1 49 #define SMC_MEM_RESERVED 1
50#elif defined(CONFIG_ARCH_OMAP24XX) 50#elif defined(CONFIG_ARCH_OMAP2)
51 #define SMC_USE_16BIT 0 51 #define SMC_USE_16BIT 0
52 #define SMC_USE_32BIT 1 52 #define SMC_USE_32BIT 1
53 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW 53 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 54799544bda3..a6ee883d1b0e 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -330,6 +330,20 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
330 330
331#include <unit/smc91111.h> 331#include <unit/smc91111.h>
332 332
333#elif defined(CONFIG_ARCH_MSM)
334
335#define SMC_CAN_USE_8BIT 0
336#define SMC_CAN_USE_16BIT 1
337#define SMC_CAN_USE_32BIT 0
338#define SMC_NOWAIT 1
339
340#define SMC_inw(a, r) readw((a) + (r))
341#define SMC_outw(v, a, r) writew(v, (a) + (r))
342#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
343#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)
344
345#define SMC_IRQ_FLAGS IRQF_TRIGGER_HIGH
346
333#else 347#else
334 348
335/* 349/*
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index e3ddcb8f29df..1cf012d3e072 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -480,7 +480,7 @@ typhoon_hello(struct typhoon *tp)
480 typhoon_inc_cmd_index(&ring->lastWrite, 1); 480 typhoon_inc_cmd_index(&ring->lastWrite, 1);
481 481
482 INIT_COMMAND_NO_RESPONSE(cmd, TYPHOON_CMD_HELLO_RESP); 482 INIT_COMMAND_NO_RESPONSE(cmd, TYPHOON_CMD_HELLO_RESP);
483 smp_wmb(); 483 wmb();
484 iowrite32(ring->lastWrite, tp->ioaddr + TYPHOON_REG_CMD_READY); 484 iowrite32(ring->lastWrite, tp->ioaddr + TYPHOON_REG_CMD_READY);
485 spin_unlock(&tp->command_lock); 485 spin_unlock(&tp->command_lock);
486 } 486 }
@@ -1311,13 +1311,15 @@ typhoon_init_interface(struct typhoon *tp)
1311 1311
1312 tp->txlo_dma_addr = le32_to_cpu(iface->txLoAddr); 1312 tp->txlo_dma_addr = le32_to_cpu(iface->txLoAddr);
1313 tp->card_state = Sleeping; 1313 tp->card_state = Sleeping;
1314 smp_wmb();
1315 1314
1316 tp->offload = TYPHOON_OFFLOAD_IP_CHKSUM | TYPHOON_OFFLOAD_TCP_CHKSUM; 1315 tp->offload = TYPHOON_OFFLOAD_IP_CHKSUM | TYPHOON_OFFLOAD_TCP_CHKSUM;
1317 tp->offload |= TYPHOON_OFFLOAD_UDP_CHKSUM | TSO_OFFLOAD_ON; 1316 tp->offload |= TYPHOON_OFFLOAD_UDP_CHKSUM | TSO_OFFLOAD_ON;
1318 1317
1319 spin_lock_init(&tp->command_lock); 1318 spin_lock_init(&tp->command_lock);
1320 spin_lock_init(&tp->state_lock); 1319 spin_lock_init(&tp->state_lock);
1320
1321 /* Force the writes to the shared memory area out before continuing. */
1322 wmb();
1321} 1323}
1322 1324
1323static void 1325static void
diff --git a/drivers/net/usb/pegasus.h b/drivers/net/usb/pegasus.h
index 5d02f0200737..b90d8766ab74 100644
--- a/drivers/net/usb/pegasus.h
+++ b/drivers/net/usb/pegasus.h
@@ -177,7 +177,7 @@ PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x400c,
177PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0xabc1, 177PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0xabc1,
178 DEFAULT_GPIO_RESET ) 178 DEFAULT_GPIO_RESET )
179PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x200c, 179PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x200c,
180 DEFAULT_GPIO_RESET | PEGASUS_II ) 180 DEFAULT_GPIO_RESET | PEGASUS_II )
181PEGASUS_DEV( "Accton USB 10/100 Ethernet Adapter", VENDOR_ACCTON, 0x1046, 181PEGASUS_DEV( "Accton USB 10/100 Ethernet Adapter", VENDOR_ACCTON, 0x1046,
182 DEFAULT_GPIO_RESET ) 182 DEFAULT_GPIO_RESET )
183PEGASUS_DEV( "SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046, 183PEGASUS_DEV( "SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046,
@@ -208,6 +208,8 @@ PEGASUS_DEV( "Allied Telesyn Int. AT-USB100", VENDOR_ALLIEDTEL, 0xb100,
208 */ 208 */
209PEGASUS_DEV_CLASS( "Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121, 0x00, 209PEGASUS_DEV_CLASS( "Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121, 0x00,
210 DEFAULT_GPIO_RESET | PEGASUS_II ) 210 DEFAULT_GPIO_RESET | PEGASUS_II )
211PEGASUS_DEV( "Belkin F5U122 10/100 USB Ethernet", VENDOR_BELKIN, 0x0122,
212 DEFAULT_GPIO_RESET | PEGASUS_II )
211PEGASUS_DEV( "Billionton USB-100", VENDOR_BILLIONTON, 0x0986, 213PEGASUS_DEV( "Billionton USB-100", VENDOR_BILLIONTON, 0x0986,
212 DEFAULT_GPIO_RESET ) 214 DEFAULT_GPIO_RESET )
213PEGASUS_DEV( "Billionton USBLP-100", VENDOR_BILLIONTON, 0x0987, 215PEGASUS_DEV( "Billionton USBLP-100", VENDOR_BILLIONTON, 0x0987,
@@ -249,7 +251,7 @@ PEGASUS_DEV( "GIGABYTE GN-BR402W Wireless Router", VENDOR_GIGABYTE, 0x8002,
249PEGASUS_DEV( "Hawking UF100 10/100 Ethernet", VENDOR_HAWKING, 0x400c, 251PEGASUS_DEV( "Hawking UF100 10/100 Ethernet", VENDOR_HAWKING, 0x400c,
250 DEFAULT_GPIO_RESET | PEGASUS_II ) 252 DEFAULT_GPIO_RESET | PEGASUS_II )
251PEGASUS_DEV( "HP hn210c Ethernet USB", VENDOR_HP, 0x811c, 253PEGASUS_DEV( "HP hn210c Ethernet USB", VENDOR_HP, 0x811c,
252 DEFAULT_GPIO_RESET | PEGASUS_II ) 254 DEFAULT_GPIO_RESET | PEGASUS_II )
253PEGASUS_DEV( "IO DATA USB ET/TX", VENDOR_IODATA, 0x0904, 255PEGASUS_DEV( "IO DATA USB ET/TX", VENDOR_IODATA, 0x0904,
254 DEFAULT_GPIO_RESET ) 256 DEFAULT_GPIO_RESET )
255PEGASUS_DEV( "IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913, 257PEGASUS_DEV( "IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913,
diff --git a/drivers/net/wireless/ath/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c
index 4e30197afff6..6b1cb706e410 100644
--- a/drivers/net/wireless/ath/ar9170/usb.c
+++ b/drivers/net/wireless/ath/ar9170/usb.c
@@ -94,6 +94,8 @@ static struct usb_device_id ar9170_usb_ids[] = {
94 { USB_DEVICE(0x04bb, 0x093f) }, 94 { USB_DEVICE(0x04bb, 0x093f) },
95 /* AVM FRITZ!WLAN USB Stick N */ 95 /* AVM FRITZ!WLAN USB Stick N */
96 { USB_DEVICE(0x057C, 0x8401) }, 96 { USB_DEVICE(0x057C, 0x8401) },
97 /* NEC WL300NU-G */
98 { USB_DEVICE(0x0409, 0x0249) },
97 /* AVM FRITZ!WLAN USB Stick N 2.4 */ 99 /* AVM FRITZ!WLAN USB Stick N 2.4 */
98 { USB_DEVICE(0x057C, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY }, 100 { USB_DEVICE(0x057C, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY },
99 101
@@ -416,7 +418,7 @@ static int ar9170_usb_exec_cmd(struct ar9170 *ar, enum ar9170_cmd cmd,
416 spin_unlock_irqrestore(&aru->common.cmdlock, flags); 418 spin_unlock_irqrestore(&aru->common.cmdlock, flags);
417 419
418 usb_fill_int_urb(urb, aru->udev, 420 usb_fill_int_urb(urb, aru->udev,
419 usb_sndbulkpipe(aru->udev, AR9170_EP_CMD), 421 usb_sndintpipe(aru->udev, AR9170_EP_CMD),
420 aru->common.cmdbuf, plen + 4, 422 aru->common.cmdbuf, plen + 4,
421 ar9170_usb_tx_urb_complete, NULL, 1); 423 ar9170_usb_tx_urb_complete, NULL, 1);
422 424
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index 86654b9e1092..a3cbfe4fc389 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -431,8 +431,8 @@ static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
431 ee->ee_margin_tx_rx[mode] = (val >> 8) & 0x3f; 431 ee->ee_margin_tx_rx[mode] = (val >> 8) & 0x3f;
432 432
433 AR5K_EEPROM_READ(o++, val); 433 AR5K_EEPROM_READ(o++, val);
434 ee->ee_i_cal[mode] = (val >> 8) & 0x3f; 434 ee->ee_i_cal[mode] = (val >> 5) & 0x3f;
435 ee->ee_q_cal[mode] = (val >> 3) & 0x1f; 435 ee->ee_q_cal[mode] = val & 0x1f;
436 436
437 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_2) { 437 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_2) {
438 AR5K_EEPROM_READ(o++, val); 438 AR5K_EEPROM_READ(o++, val);
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index cb569dbffa63..b6704c93f808 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -1362,10 +1362,16 @@ static int ath5k_hw_rf511x_calibrate(struct ath5k_hw *ah,
1362 goto done; 1362 goto done;
1363 1363
1364 /* Calibration has finished, get the results and re-run */ 1364 /* Calibration has finished, get the results and re-run */
1365
1366 /* work around empty results which can apparently happen on 5212 */
1365 for (i = 0; i <= 10; i++) { 1367 for (i = 0; i <= 10; i++) {
1366 iq_corr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_CORR); 1368 iq_corr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_CORR);
1367 i_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_I); 1369 i_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_I);
1368 q_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_Q); 1370 q_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_Q);
1371 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_CALIBRATE,
1372 "iq_corr:%x i_pwr:%x q_pwr:%x", iq_corr, i_pwr, q_pwr);
1373 if (i_pwr && q_pwr)
1374 break;
1369 } 1375 }
1370 1376
1371 i_coffd = ((i_pwr >> 1) + (q_pwr >> 1)) >> 7; 1377 i_coffd = ((i_pwr >> 1) + (q_pwr >> 1)) >> 7;
@@ -1375,32 +1381,24 @@ static int ath5k_hw_rf511x_calibrate(struct ath5k_hw *ah,
1375 else 1381 else
1376 q_coffd = q_pwr >> 7; 1382 q_coffd = q_pwr >> 7;
1377 1383
1378 /* No correction */ 1384 /* protect against divide by 0 and loss of sign bits */
1379 if (i_coffd == 0 || q_coffd == 0) 1385 if (i_coffd == 0 || q_coffd < 2)
1380 goto done; 1386 goto done;
1381 1387
1382 i_coff = ((-iq_corr) / i_coffd); 1388 i_coff = (-iq_corr) / i_coffd;
1389 i_coff = clamp(i_coff, -32, 31); /* signed 6 bit */
1383 1390
1384 /* Boundary check */ 1391 q_coff = (i_pwr / q_coffd) - 128;
1385 if (i_coff > 31) 1392 q_coff = clamp(q_coff, -16, 15); /* signed 5 bit */
1386 i_coff = 31;
1387 if (i_coff < -32)
1388 i_coff = -32;
1389
1390 if (ah->ah_version == AR5K_AR5211)
1391 q_coff = (i_pwr / q_coffd) - 64;
1392 else
1393 q_coff = (i_pwr / q_coffd) - 128;
1394 1393
1395 /* Boundary check */ 1394 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_CALIBRATE,
1396 if (q_coff > 15) 1395 "new I:%d Q:%d (i_coffd:%x q_coffd:%x)",
1397 q_coff = 15; 1396 i_coff, q_coff, i_coffd, q_coffd);
1398 if (q_coff < -16)
1399 q_coff = -16;
1400 1397
1401 /* Commit new I/Q value */ 1398 /* Commit new I/Q values (set enable bit last to match HAL sources) */
1402 AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_ENABLE | 1399 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_Q_I_COFF, i_coff);
1403 ((u32)q_coff) | ((u32)i_coff << AR5K_PHY_IQ_CORR_Q_I_COFF_S)); 1400 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_Q_Q_COFF, q_coff);
1401 AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_ENABLE);
1404 1402
1405 /* Re-enable calibration -if we don't we'll commit 1403 /* Re-enable calibration -if we don't we'll commit
1406 * the same values again and again */ 1404 * the same values again and again */
@@ -1846,7 +1844,7 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
1846 break; 1844 break;
1847 case AR5K_ANTMODE_FIXED_A: 1845 case AR5K_ANTMODE_FIXED_A:
1848 def_ant = 1; 1846 def_ant = 1;
1849 tx_ant = 0; 1847 tx_ant = 1;
1850 use_def_for_tx = true; 1848 use_def_for_tx = true;
1851 update_def_on_tx = false; 1849 update_def_on_tx = false;
1852 use_def_for_rts = true; 1850 use_def_for_rts = true;
@@ -1855,7 +1853,7 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
1855 break; 1853 break;
1856 case AR5K_ANTMODE_FIXED_B: 1854 case AR5K_ANTMODE_FIXED_B:
1857 def_ant = 2; 1855 def_ant = 2;
1858 tx_ant = 0; 1856 tx_ant = 2;
1859 use_def_for_tx = true; 1857 use_def_for_tx = true;
1860 update_def_on_tx = false; 1858 update_def_on_tx = false;
1861 use_def_for_rts = true; 1859 use_def_for_rts = true;
diff --git a/drivers/net/wireless/ath/ath5k/reg.h b/drivers/net/wireless/ath/ath5k/reg.h
index cbd11d4c98e8..45d62e915e4c 100644
--- a/drivers/net/wireless/ath/ath5k/reg.h
+++ b/drivers/net/wireless/ath/ath5k/reg.h
@@ -2203,6 +2203,7 @@
2203 */ 2203 */
2204#define AR5K_PHY_IQ 0x9920 /* Register Address */ 2204#define AR5K_PHY_IQ 0x9920 /* Register Address */
2205#define AR5K_PHY_IQ_CORR_Q_Q_COFF 0x0000001f /* Mask for q correction info */ 2205#define AR5K_PHY_IQ_CORR_Q_Q_COFF 0x0000001f /* Mask for q correction info */
2206#define AR5K_PHY_IQ_CORR_Q_Q_COFF_S 0
2206#define AR5K_PHY_IQ_CORR_Q_I_COFF 0x000007e0 /* Mask for i correction info */ 2207#define AR5K_PHY_IQ_CORR_Q_I_COFF 0x000007e0 /* Mask for i correction info */
2207#define AR5K_PHY_IQ_CORR_Q_I_COFF_S 5 2208#define AR5K_PHY_IQ_CORR_Q_I_COFF_S 5
2208#define AR5K_PHY_IQ_CORR_ENABLE 0x00000800 /* Enable i/q correction */ 2209#define AR5K_PHY_IQ_CORR_ENABLE 0x00000800 /* Enable i/q correction */
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index 4120068792ec..44bbbf2a6edd 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -870,12 +870,15 @@ static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah,
870 AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1, 870 AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1,
871 AR5K_INIT_CYCRSSI_THR1); 871 AR5K_INIT_CYCRSSI_THR1);
872 872
873 /* I/Q correction 873 /* I/Q correction (set enable bit last to match HAL sources) */
874 * TODO: Per channel i/q infos ? */ 874 /* TODO: Per channel i/q infos ? */
875 AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, 875 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0) {
876 AR5K_PHY_IQ_CORR_ENABLE | 876 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_Q_I_COFF,
877 (ee->ee_i_cal[ee_mode] << AR5K_PHY_IQ_CORR_Q_I_COFF_S) | 877 ee->ee_i_cal[ee_mode]);
878 ee->ee_q_cal[ee_mode]); 878 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_Q_Q_COFF,
879 ee->ee_q_cal[ee_mode]);
880 AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_ENABLE);
881 }
879 882
880 /* Heavy clipping -disable for now */ 883 /* Heavy clipping -disable for now */
881 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_5_1) 884 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_5_1)
@@ -1393,10 +1396,9 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1393 ath5k_hw_set_sleep_clock(ah, true); 1396 ath5k_hw_set_sleep_clock(ah, true);
1394 1397
1395 /* 1398 /*
1396 * Disable beacons and reset the register 1399 * Disable beacons and reset the TSF
1397 */ 1400 */
1398 AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE | 1401 AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
1399 AR5K_BEACON_RESET_TSF); 1402 ath5k_hw_reset_tsf(ah);
1400
1401 return 0; 1403 return 0;
1402} 1404}
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index c25216be616f..f7ef11407e27 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1534,8 +1534,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1534 all_wiphys_idle = ath9k_all_wiphys_idle(sc); 1534 all_wiphys_idle = ath9k_all_wiphys_idle(sc);
1535 ath9k_set_wiphy_idle(aphy, idle); 1535 ath9k_set_wiphy_idle(aphy, idle);
1536 1536
1537 if (!idle && all_wiphys_idle) 1537 enable_radio = (!idle && all_wiphys_idle);
1538 enable_radio = true;
1539 1538
1540 /* 1539 /*
1541 * After we unlock here its possible another wiphy 1540 * After we unlock here its possible another wiphy
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index b632c803ee1a..02df4cbf179f 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1359,25 +1359,6 @@ static enum ath9k_pkt_type get_hw_packet_type(struct sk_buff *skb)
1359 return htype; 1359 return htype;
1360} 1360}
1361 1361
1362static bool is_pae(struct sk_buff *skb)
1363{
1364 struct ieee80211_hdr *hdr;
1365 __le16 fc;
1366
1367 hdr = (struct ieee80211_hdr *)skb->data;
1368 fc = hdr->frame_control;
1369
1370 if (ieee80211_is_data(fc)) {
1371 if (ieee80211_is_nullfunc(fc) ||
1372 /* Port Access Entity (IEEE 802.1X) */
1373 (skb->protocol == cpu_to_be16(ETH_P_PAE))) {
1374 return true;
1375 }
1376 }
1377
1378 return false;
1379}
1380
1381static int get_hw_crypto_keytype(struct sk_buff *skb) 1362static int get_hw_crypto_keytype(struct sk_buff *skb)
1382{ 1363{
1383 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1364 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
@@ -1702,7 +1683,7 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf,
1702 goto tx_done; 1683 goto tx_done;
1703 } 1684 }
1704 1685
1705 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && !is_pae(skb)) { 1686 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
1706 /* 1687 /*
1707 * Try aggregation if it's a unicast data frame 1688 * Try aggregation if it's a unicast data frame
1708 * and the destination is HT capable. 1689 * and the destination is HT capable.
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 192abfdc5039..9e2ae8f3ecb0 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -3186,14 +3186,27 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
3186 int total_nr = 0; 3186 int total_nr = 0;
3187 int i; 3187 int i;
3188 struct pci_pool *pool; 3188 struct pci_pool *pool;
3189 u32 *virts[CB_NUMBER_OF_ELEMENTS_SMALL]; 3189 void **virts;
3190 dma_addr_t phys[CB_NUMBER_OF_ELEMENTS_SMALL]; 3190 dma_addr_t *phys;
3191 3191
3192 IPW_DEBUG_TRACE("<< :\n"); 3192 IPW_DEBUG_TRACE("<< :\n");
3193 3193
3194 virts = kmalloc(sizeof(void *) * CB_NUMBER_OF_ELEMENTS_SMALL,
3195 GFP_KERNEL);
3196 if (!virts)
3197 return -ENOMEM;
3198
3199 phys = kmalloc(sizeof(dma_addr_t) * CB_NUMBER_OF_ELEMENTS_SMALL,
3200 GFP_KERNEL);
3201 if (!phys) {
3202 kfree(virts);
3203 return -ENOMEM;
3204 }
3194 pool = pci_pool_create("ipw2200", priv->pci_dev, CB_MAX_LENGTH, 0, 0); 3205 pool = pci_pool_create("ipw2200", priv->pci_dev, CB_MAX_LENGTH, 0, 0);
3195 if (!pool) { 3206 if (!pool) {
3196 IPW_ERROR("pci_pool_create failed\n"); 3207 IPW_ERROR("pci_pool_create failed\n");
3208 kfree(phys);
3209 kfree(virts);
3197 return -ENOMEM; 3210 return -ENOMEM;
3198 } 3211 }
3199 3212
@@ -3263,6 +3276,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
3263 pci_pool_free(pool, virts[i], phys[i]); 3276 pci_pool_free(pool, virts[i], phys[i]);
3264 3277
3265 pci_pool_destroy(pool); 3278 pci_pool_destroy(pool);
3279 kfree(phys);
3280 kfree(virts);
3266 3281
3267 return ret; 3282 return ret;
3268} 3283}
diff --git a/drivers/net/wireless/ipw2x00/libipw.h b/drivers/net/wireless/ipw2x00/libipw.h
index 9ac136b98bb3..284b0e4cb815 100644
--- a/drivers/net/wireless/ipw2x00/libipw.h
+++ b/drivers/net/wireless/ipw2x00/libipw.h
@@ -797,7 +797,7 @@ struct libipw_device {
797 /* Probe / Beacon management */ 797 /* Probe / Beacon management */
798 struct list_head network_free_list; 798 struct list_head network_free_list;
799 struct list_head network_list; 799 struct list_head network_list;
800 struct libipw_network *networks; 800 struct libipw_network *networks[MAX_NETWORK_COUNT];
801 int scans; 801 int scans;
802 int scan_age; 802 int scan_age;
803 803
diff --git a/drivers/net/wireless/ipw2x00/libipw_module.c b/drivers/net/wireless/ipw2x00/libipw_module.c
index 5b8841159b7c..55965408ff3f 100644
--- a/drivers/net/wireless/ipw2x00/libipw_module.c
+++ b/drivers/net/wireless/ipw2x00/libipw_module.c
@@ -67,16 +67,17 @@ void *libipw_wiphy_privid = &libipw_wiphy_privid;
67 67
68static int libipw_networks_allocate(struct libipw_device *ieee) 68static int libipw_networks_allocate(struct libipw_device *ieee)
69{ 69{
70 if (ieee->networks) 70 int i, j;
71 return 0; 71
72 72 for (i = 0; i < MAX_NETWORK_COUNT; i++) {
73 ieee->networks = 73 ieee->networks[i] = kzalloc(sizeof(struct libipw_network),
74 kzalloc(MAX_NETWORK_COUNT * sizeof(struct libipw_network), 74 GFP_KERNEL);
75 GFP_KERNEL); 75 if (!ieee->networks[i]) {
76 if (!ieee->networks) { 76 LIBIPW_ERROR("Out of memory allocating beacons\n");
77 printk(KERN_WARNING "%s: Out of memory allocating beacons\n", 77 for (j = 0; j < i; j++)
78 ieee->dev->name); 78 kfree(ieee->networks[j]);
79 return -ENOMEM; 79 return -ENOMEM;
80 }
80 } 81 }
81 82
82 return 0; 83 return 0;
@@ -97,15 +98,11 @@ static inline void libipw_networks_free(struct libipw_device *ieee)
97{ 98{
98 int i; 99 int i;
99 100
100 if (!ieee->networks) 101 for (i = 0; i < MAX_NETWORK_COUNT; i++) {
101 return; 102 if (ieee->networks[i]->ibss_dfs)
102 103 kfree(ieee->networks[i]->ibss_dfs);
103 for (i = 0; i < MAX_NETWORK_COUNT; i++) 104 kfree(ieee->networks[i]);
104 if (ieee->networks[i].ibss_dfs) 105 }
105 kfree(ieee->networks[i].ibss_dfs);
106
107 kfree(ieee->networks);
108 ieee->networks = NULL;
109} 106}
110 107
111void libipw_networks_age(struct libipw_device *ieee, 108void libipw_networks_age(struct libipw_device *ieee,
@@ -130,7 +127,7 @@ static void libipw_networks_initialize(struct libipw_device *ieee)
130 INIT_LIST_HEAD(&ieee->network_free_list); 127 INIT_LIST_HEAD(&ieee->network_free_list);
131 INIT_LIST_HEAD(&ieee->network_list); 128 INIT_LIST_HEAD(&ieee->network_list);
132 for (i = 0; i < MAX_NETWORK_COUNT; i++) 129 for (i = 0; i < MAX_NETWORK_COUNT; i++)
133 list_add_tail(&ieee->networks[i].list, 130 list_add_tail(&ieee->networks[i]->list,
134 &ieee->network_free_list); 131 &ieee->network_free_list);
135} 132}
136 133
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index e81577b1a253..f88f75dfd96e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -184,7 +184,7 @@ static int iwl3945_hwrate_to_plcp_idx(u8 plcp)
184{ 184{
185 int idx; 185 int idx;
186 186
187 for (idx = 0; idx < IWL_RATE_COUNT; idx++) 187 for (idx = 0; idx < IWL_RATE_COUNT_3945; idx++)
188 if (iwl3945_rates[idx].plcp == plcp) 188 if (iwl3945_rates[idx].plcp == plcp)
189 return idx; 189 return idx;
190 return -1; 190 return -1;
@@ -755,7 +755,7 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv,
755 int sta_id, int tx_id) 755 int sta_id, int tx_id)
756{ 756{
757 u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value; 757 u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value;
758 u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT - 1); 758 u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT_3945);
759 u16 rate_mask; 759 u16 rate_mask;
760 int rate; 760 int rate;
761 u8 rts_retry_limit; 761 u8 rts_retry_limit;
@@ -2088,7 +2088,7 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv)
2088 2088
2089 /* fill in channel group's nominal powers for each rate */ 2089 /* fill in channel group's nominal powers for each rate */
2090 for (rate_index = 0; 2090 for (rate_index = 0;
2091 rate_index < IWL_RATE_COUNT; rate_index++, clip_pwrs++) { 2091 rate_index < IWL_RATE_COUNT_3945; rate_index++, clip_pwrs++) {
2092 switch (rate_index) { 2092 switch (rate_index) {
2093 case IWL_RATE_36M_INDEX_TABLE: 2093 case IWL_RATE_36M_INDEX_TABLE:
2094 if (i == 0) /* B/G */ 2094 if (i == 0) /* B/G */
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 9a220d415449..6edae9b83bb7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2040,16 +2040,14 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2040 tx_resp->failure_frame); 2040 tx_resp->failure_frame);
2041 2041
2042 freed = iwlagn_tx_queue_reclaim(priv, txq_id, index); 2042 freed = iwlagn_tx_queue_reclaim(priv, txq_id, index);
2043 if (qc && likely(sta_id != IWL_INVALID_STATION)) 2043 iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
2044 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
2045 2044
2046 if (priv->mac80211_registered && 2045 if (priv->mac80211_registered &&
2047 (iwl_queue_space(&txq->q) > txq->q.low_mark)) 2046 (iwl_queue_space(&txq->q) > txq->q.low_mark))
2048 iwl_wake_queue(priv, txq_id); 2047 iwl_wake_queue(priv, txq_id);
2049 } 2048 }
2050 2049
2051 if (qc && likely(sta_id != IWL_INVALID_STATION)) 2050 iwlagn_txq_check_empty(priv, sta_id, tid, txq_id);
2052 iwlagn_txq_check_empty(priv, sta_id, tid, txq_id);
2053 2051
2054 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) 2052 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
2055 IWL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n"); 2053 IWL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n");
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 0f881947627b..0c3c76803c5e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -345,6 +345,17 @@ static inline int get_num_of_ant_from_rate(u32 rate_n_flags)
345 !!(rate_n_flags & RATE_MCS_ANT_C_MSK); 345 !!(rate_n_flags & RATE_MCS_ANT_C_MSK);
346} 346}
347 347
348/*
349 * Static function to get the expected throughput from an iwl_scale_tbl_info
350 * that wraps a NULL pointer check
351 */
352static s32 get_expected_tpt(struct iwl_scale_tbl_info *tbl, int rs_index)
353{
354 if (tbl->expected_tpt)
355 return tbl->expected_tpt[rs_index];
356 return 0;
357}
358
348/** 359/**
349 * rs_collect_tx_data - Update the success/failure sliding window 360 * rs_collect_tx_data - Update the success/failure sliding window
350 * 361 *
@@ -352,19 +363,21 @@ static inline int get_num_of_ant_from_rate(u32 rate_n_flags)
352 * at this rate. window->data contains the bitmask of successful 363 * at this rate. window->data contains the bitmask of successful
353 * packets. 364 * packets.
354 */ 365 */
355static int rs_collect_tx_data(struct iwl_rate_scale_data *windows, 366static int rs_collect_tx_data(struct iwl_scale_tbl_info *tbl,
356 int scale_index, s32 tpt, int attempts, 367 int scale_index, int attempts, int successes)
357 int successes)
358{ 368{
359 struct iwl_rate_scale_data *window = NULL; 369 struct iwl_rate_scale_data *window = NULL;
360 static const u64 mask = (((u64)1) << (IWL_RATE_MAX_WINDOW - 1)); 370 static const u64 mask = (((u64)1) << (IWL_RATE_MAX_WINDOW - 1));
361 s32 fail_count; 371 s32 fail_count, tpt;
362 372
363 if (scale_index < 0 || scale_index >= IWL_RATE_COUNT) 373 if (scale_index < 0 || scale_index >= IWL_RATE_COUNT)
364 return -EINVAL; 374 return -EINVAL;
365 375
366 /* Select window for current tx bit rate */ 376 /* Select window for current tx bit rate */
367 window = &(windows[scale_index]); 377 window = &(tbl->win[scale_index]);
378
379 /* Get expected throughput */
380 tpt = get_expected_tpt(tbl, scale_index);
368 381
369 /* 382 /*
370 * Keep track of only the latest 62 tx frame attempts in this rate's 383 * Keep track of only the latest 62 tx frame attempts in this rate's
@@ -734,16 +747,6 @@ static bool table_type_matches(struct iwl_scale_tbl_info *a,
734 return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) && 747 return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) &&
735 (a->is_SGI == b->is_SGI); 748 (a->is_SGI == b->is_SGI);
736} 749}
737/*
738 * Static function to get the expected throughput from an iwl_scale_tbl_info
739 * that wraps a NULL pointer check
740 */
741static s32 get_expected_tpt(struct iwl_scale_tbl_info *tbl, int rs_index)
742{
743 if (tbl->expected_tpt)
744 return tbl->expected_tpt[rs_index];
745 return 0;
746}
747 750
748/* 751/*
749 * mac80211 sends us Tx status 752 * mac80211 sends us Tx status
@@ -760,12 +763,10 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
760 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 763 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
761 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 764 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
762 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 765 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
763 struct iwl_rate_scale_data *window = NULL;
764 enum mac80211_rate_control_flags mac_flags; 766 enum mac80211_rate_control_flags mac_flags;
765 u32 tx_rate; 767 u32 tx_rate;
766 struct iwl_scale_tbl_info tbl_type; 768 struct iwl_scale_tbl_info tbl_type;
767 struct iwl_scale_tbl_info *curr_tbl, *other_tbl; 769 struct iwl_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl;
768 s32 tpt = 0;
769 770
770 IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n"); 771 IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n");
771 772
@@ -853,7 +854,6 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
853 IWL_DEBUG_RATE(priv, "Neither active nor search matches tx rate\n"); 854 IWL_DEBUG_RATE(priv, "Neither active nor search matches tx rate\n");
854 return; 855 return;
855 } 856 }
856 window = (struct iwl_rate_scale_data *)&(curr_tbl->win[0]);
857 857
858 /* 858 /*
859 * Updating the frame history depends on whether packets were 859 * Updating the frame history depends on whether packets were
@@ -866,8 +866,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
866 tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); 866 tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags);
867 rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, 867 rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type,
868 &rs_index); 868 &rs_index);
869 tpt = get_expected_tpt(curr_tbl, rs_index); 869 rs_collect_tx_data(curr_tbl, rs_index,
870 rs_collect_tx_data(window, rs_index, tpt,
871 info->status.ampdu_ack_len, 870 info->status.ampdu_ack_len,
872 info->status.ampdu_ack_map); 871 info->status.ampdu_ack_map);
873 872
@@ -897,19 +896,13 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
897 * table as active/search. 896 * table as active/search.
898 */ 897 */
899 if (table_type_matches(&tbl_type, curr_tbl)) 898 if (table_type_matches(&tbl_type, curr_tbl))
900 tpt = get_expected_tpt(curr_tbl, rs_index); 899 tmp_tbl = curr_tbl;
901 else if (table_type_matches(&tbl_type, other_tbl)) 900 else if (table_type_matches(&tbl_type, other_tbl))
902 tpt = get_expected_tpt(other_tbl, rs_index); 901 tmp_tbl = other_tbl;
903 else 902 else
904 continue; 903 continue;
905 904 rs_collect_tx_data(tmp_tbl, rs_index, 1,
906 /* Constants mean 1 transmission, 0 successes */ 905 i < retries ? 0 : legacy_success);
907 if (i < retries)
908 rs_collect_tx_data(window, rs_index, tpt, 1,
909 0);
910 else
911 rs_collect_tx_data(window, rs_index, tpt, 1,
912 legacy_success);
913 } 906 }
914 907
915 /* Update success/fail counts if not searching for new mode */ 908 /* Update success/fail counts if not searching for new mode */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 629cbf38aa9b..4f0cb803f732 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1229,7 +1229,15 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1229 /* Ack/clear/reset pending uCode interrupts. 1229 /* Ack/clear/reset pending uCode interrupts.
1230 * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, 1230 * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS,
1231 */ 1231 */
1232 iwl_write32(priv, CSR_INT, priv->_agn.inta); 1232 /* There is a hardware bug in the interrupt mask function that some
1233 * interrupts (i.e. CSR_INT_BIT_SCD) can still be generated even if
1234 * they are disabled in the CSR_INT_MASK register. Furthermore the
1235 * ICT interrupt handling mechanism has another bug that might cause
1236 * these unmasked interrupts fail to be detected. We workaround the
1237 * hardware bugs here by ACKing all the possible interrupts so that
1238 * interrupt coalescing can still be achieved.
1239 */
1240 iwl_write32(priv, CSR_INT, priv->_agn.inta | ~priv->inta_mask);
1233 1241
1234 inta = priv->_agn.inta; 1242 inta = priv->_agn.inta;
1235 1243
@@ -2653,7 +2661,7 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2653 BIT(NL80211_IFTYPE_STATION) | 2661 BIT(NL80211_IFTYPE_STATION) |
2654 BIT(NL80211_IFTYPE_ADHOC); 2662 BIT(NL80211_IFTYPE_ADHOC);
2655 2663
2656 hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY | 2664 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
2657 WIPHY_FLAG_DISABLE_BEACON_HINTS; 2665 WIPHY_FLAG_DISABLE_BEACON_HINTS;
2658 2666
2659 /* 2667 /*
@@ -2662,7 +2670,7 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2662 */ 2670 */
2663 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 2671 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
2664 2672
2665 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX + 1; 2673 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
2666 /* we create the 802.11 header and a zero-length SSID element */ 2674 /* we create the 802.11 header and a zero-length SSID element */
2667 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2; 2675 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2;
2668 2676
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index bc04b43cad36..10f95724536f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -458,6 +458,8 @@ void iwl_free_tfds_in_queue(struct iwl_priv *priv,
458void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq); 458void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
459int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, 459int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
460 int slots_num, u32 txq_id); 460 int slots_num, u32 txq_id);
461void iwl_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq,
462 int slots_num, u32 txq_id);
461void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id); 463void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id);
462/***************************************************** 464/*****************************************************
463 * TX power 465 * TX power
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 0daa1c9f1c6b..d817c9c184a5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -637,20 +637,9 @@ u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
637 if (left < 0) 637 if (left < 0)
638 return 0; 638 return 0;
639 *pos++ = WLAN_EID_SSID; 639 *pos++ = WLAN_EID_SSID;
640 if (!priv->is_internal_short_scan && 640 *pos++ = 0;
641 priv->scan_request->n_ssids) { 641
642 struct cfg80211_ssid *ssid = 642 len += 2;
643 priv->scan_request->ssids;
644
645 /* Broadcast if ssid_len is 0 */
646 *pos++ = ssid->ssid_len;
647 memcpy(pos, ssid->ssid, ssid->ssid_len);
648 pos += ssid->ssid_len;
649 len += 2 + ssid->ssid_len;
650 } else {
651 *pos++ = 0;
652 len += 2;
653 }
654 643
655 if (WARN_ON(left < ie_len)) 644 if (WARN_ON(left < ie_len))
656 return len; 645 return len;
@@ -778,26 +767,20 @@ static void iwl_bg_request_scan(struct work_struct *data)
778 if (priv->is_internal_short_scan) { 767 if (priv->is_internal_short_scan) {
779 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n"); 768 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
780 } else if (priv->scan_request->n_ssids) { 769 } else if (priv->scan_request->n_ssids) {
770 int i, p = 0;
781 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); 771 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
782 /* 772 for (i = 0; i < priv->scan_request->n_ssids; i++) {
783 * The first SSID to scan is stuffed into the probe request 773 /* always does wildcard anyway */
784 * template and the remaining ones are handled through the 774 if (!priv->scan_request->ssids[i].ssid_len)
785 * direct_scan array. 775 continue;
786 */ 776 scan->direct_scan[p].id = WLAN_EID_SSID;
787 if (priv->scan_request->n_ssids > 1) { 777 scan->direct_scan[p].len =
788 int i, p = 0; 778 priv->scan_request->ssids[i].ssid_len;
789 for (i = 1; i < priv->scan_request->n_ssids; i++) { 779 memcpy(scan->direct_scan[p].ssid,
790 if (!priv->scan_request->ssids[i].ssid_len) 780 priv->scan_request->ssids[i].ssid,
791 continue; 781 priv->scan_request->ssids[i].ssid_len);
792 scan->direct_scan[p].id = WLAN_EID_SSID; 782 n_probes++;
793 scan->direct_scan[p].len = 783 p++;
794 priv->scan_request->ssids[i].ssid_len;
795 memcpy(scan->direct_scan[p].ssid,
796 priv->scan_request->ssids[i].ssid,
797 priv->scan_request->ssids[i].ssid_len);
798 n_probes++;
799 p++;
800 }
801 } 784 }
802 is_active = true; 785 is_active = true;
803 } else 786 } else
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 65090d386a53..a631afef5e33 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -83,7 +83,7 @@ void iwl_free_tfds_in_queue(struct iwl_priv *priv,
83 if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed) 83 if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed)
84 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 84 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
85 else { 85 else {
86 IWL_ERR(priv, "free more than tfds_in_queue (%u:%d)\n", 86 IWL_DEBUG_TX(priv, "free more than tfds_in_queue (%u:%d)\n",
87 priv->stations[sta_id].tid[tid].tfds_in_queue, 87 priv->stations[sta_id].tid[tid].tfds_in_queue,
88 freed); 88 freed);
89 priv->stations[sta_id].tid[tid].tfds_in_queue = 0; 89 priv->stations[sta_id].tid[tid].tfds_in_queue = 0;
@@ -152,10 +152,34 @@ void iwl_cmd_queue_free(struct iwl_priv *priv)
152 struct iwl_queue *q = &txq->q; 152 struct iwl_queue *q = &txq->q;
153 struct device *dev = &priv->pci_dev->dev; 153 struct device *dev = &priv->pci_dev->dev;
154 int i; 154 int i;
155 bool huge = false;
155 156
156 if (q->n_bd == 0) 157 if (q->n_bd == 0)
157 return; 158 return;
158 159
160 for (; q->read_ptr != q->write_ptr;
161 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
162 /* we have no way to tell if it is a huge cmd ATM */
163 i = get_cmd_index(q, q->read_ptr, 0);
164
165 if (txq->meta[i].flags & CMD_SIZE_HUGE) {
166 huge = true;
167 continue;
168 }
169
170 pci_unmap_single(priv->pci_dev,
171 pci_unmap_addr(&txq->meta[i], mapping),
172 pci_unmap_len(&txq->meta[i], len),
173 PCI_DMA_BIDIRECTIONAL);
174 }
175 if (huge) {
176 i = q->n_window;
177 pci_unmap_single(priv->pci_dev,
178 pci_unmap_addr(&txq->meta[i], mapping),
179 pci_unmap_len(&txq->meta[i], len),
180 PCI_DMA_BIDIRECTIONAL);
181 }
182
159 /* De-alloc array of command/tx buffers */ 183 /* De-alloc array of command/tx buffers */
160 for (i = 0; i <= TFD_CMD_SLOTS; i++) 184 for (i = 0; i <= TFD_CMD_SLOTS; i++)
161 kfree(txq->cmd[i]); 185 kfree(txq->cmd[i]);
@@ -424,6 +448,14 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
424 448
425 spin_lock_irqsave(&priv->hcmd_lock, flags); 449 spin_lock_irqsave(&priv->hcmd_lock, flags);
426 450
451 /* If this is a huge cmd, mark the huge flag also on the meta.flags
452 * of the _original_ cmd. This is used for DMA mapping clean up.
453 */
454 if (cmd->flags & CMD_SIZE_HUGE) {
455 idx = get_cmd_index(q, q->write_ptr, 0);
456 txq->meta[idx].flags = CMD_SIZE_HUGE;
457 }
458
427 idx = get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); 459 idx = get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE);
428 out_cmd = txq->cmd[idx]; 460 out_cmd = txq->cmd[idx];
429 out_meta = &txq->meta[idx]; 461 out_meta = &txq->meta[idx];
@@ -546,6 +578,7 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
546 bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); 578 bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME);
547 struct iwl_device_cmd *cmd; 579 struct iwl_device_cmd *cmd;
548 struct iwl_cmd_meta *meta; 580 struct iwl_cmd_meta *meta;
581 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
549 582
550 /* If a Tx command is being handled and it isn't in the actual 583 /* If a Tx command is being handled and it isn't in the actual
551 * command queue then there a command routing bug has been introduced 584 * command queue then there a command routing bug has been introduced
@@ -559,9 +592,17 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
559 return; 592 return;
560 } 593 }
561 594
562 cmd_index = get_cmd_index(&priv->txq[IWL_CMD_QUEUE_NUM].q, index, huge); 595 /* If this is a huge cmd, clear the huge flag on the meta.flags
563 cmd = priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_index]; 596 * of the _original_ cmd. So that iwl_cmd_queue_free won't unmap
564 meta = &priv->txq[IWL_CMD_QUEUE_NUM].meta[cmd_index]; 597 * the DMA buffer for the scan (huge) command.
598 */
599 if (huge) {
600 cmd_index = get_cmd_index(&txq->q, index, 0);
601 txq->meta[cmd_index].flags = 0;
602 }
603 cmd_index = get_cmd_index(&txq->q, index, huge);
604 cmd = txq->cmd[cmd_index];
605 meta = &txq->meta[cmd_index];
565 606
566 pci_unmap_single(priv->pci_dev, 607 pci_unmap_single(priv->pci_dev,
567 pci_unmap_addr(meta, mapping), 608 pci_unmap_addr(meta, mapping),
@@ -583,6 +624,7 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
583 get_cmd_string(cmd->hdr.cmd)); 624 get_cmd_string(cmd->hdr.cmd));
584 wake_up_interruptible(&priv->wait_command_queue); 625 wake_up_interruptible(&priv->wait_command_queue);
585 } 626 }
627 meta->flags = 0;
586} 628}
587EXPORT_SYMBOL(iwl_tx_cmd_complete); 629EXPORT_SYMBOL(iwl_tx_cmd_complete);
588 630
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 4d0394b3fb59..c9188b9c5651 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1946,7 +1946,7 @@ static void iwl3945_init_hw_rates(struct iwl_priv *priv,
1946{ 1946{
1947 int i; 1947 int i;
1948 1948
1949 for (i = 0; i < IWL_RATE_COUNT; i++) { 1949 for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) {
1950 rates[i].bitrate = iwl3945_rates[i].ieee * 5; 1950 rates[i].bitrate = iwl3945_rates[i].ieee * 5;
1951 rates[i].hw_value = i; /* Rate scaling will work on indexes */ 1951 rates[i].hw_value = i; /* Rate scaling will work on indexes */
1952 rates[i].hw_value_short = i; 1952 rates[i].hw_value_short = i;
@@ -3943,7 +3943,7 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3943 BIT(NL80211_IFTYPE_STATION) | 3943 BIT(NL80211_IFTYPE_STATION) |
3944 BIT(NL80211_IFTYPE_ADHOC); 3944 BIT(NL80211_IFTYPE_ADHOC);
3945 3945
3946 hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY | 3946 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
3947 WIPHY_FLAG_DISABLE_BEACON_HINTS; 3947 WIPHY_FLAG_DISABLE_BEACON_HINTS;
3948 3948
3949 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; 3949 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945;
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
index 4396dccd12ac..82ebe1461a77 100644
--- a/drivers/net/wireless/libertas/cfg.c
+++ b/drivers/net/wireless/libertas/cfg.c
@@ -172,6 +172,8 @@ int lbs_cfg_register(struct lbs_private *priv)
172 if (ret < 0) 172 if (ret < 0)
173 lbs_pr_err("cannot register wiphy device\n"); 173 lbs_pr_err("cannot register wiphy device\n");
174 174
175 priv->wiphy_registered = true;
176
175 ret = register_netdev(priv->dev); 177 ret = register_netdev(priv->dev);
176 if (ret) 178 if (ret)
177 lbs_pr_err("cannot register network device\n"); 179 lbs_pr_err("cannot register network device\n");
@@ -190,9 +192,11 @@ void lbs_cfg_free(struct lbs_private *priv)
190 if (!wdev) 192 if (!wdev)
191 return; 193 return;
192 194
193 if (wdev->wiphy) { 195 if (priv->wiphy_registered)
194 wiphy_unregister(wdev->wiphy); 196 wiphy_unregister(wdev->wiphy);
197
198 if (wdev->wiphy)
195 wiphy_free(wdev->wiphy); 199 wiphy_free(wdev->wiphy);
196 } 200
197 kfree(wdev); 201 kfree(wdev);
198} 202}
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 058d1720242e..a54880e4ad2b 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -36,6 +36,7 @@ struct lbs_private {
36 36
37 /* CFG80211 */ 37 /* CFG80211 */
38 struct wireless_dev *wdev; 38 struct wireless_dev *wdev;
39 bool wiphy_registered;
39 40
40 /* Mesh */ 41 /* Mesh */
41 struct net_device *mesh_dev; /* Virtual device */ 42 struct net_device *mesh_dev; /* Virtual device */
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index ac65e13eb0de..4e58ebe15580 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -3851,6 +3851,7 @@ MODULE_FIRMWARE("mwl8k/helper_8366.fw");
3851MODULE_FIRMWARE("mwl8k/fmimage_8366.fw"); 3851MODULE_FIRMWARE("mwl8k/fmimage_8366.fw");
3852 3852
3853static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = { 3853static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = {
3854 { PCI_VDEVICE(MARVELL, 0x2a0a), .driver_data = MWL8363, },
3854 { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, }, 3855 { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, },
3855 { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, }, 3856 { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, },
3856 { PCI_VDEVICE(MARVELL, 0x2a2b), .driver_data = MWL8687, }, 3857 { PCI_VDEVICE(MARVELL, 0x2a2b), .driver_data = MWL8687, },
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index b3c4fbd80d8d..e3cfc001d2fd 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -35,6 +35,7 @@ MODULE_FIRMWARE("isl3887usb");
35static struct usb_device_id p54u_table[] __devinitdata = { 35static struct usb_device_id p54u_table[] __devinitdata = {
36 /* Version 1 devices (pci chip + net2280) */ 36 /* Version 1 devices (pci chip + net2280) */
37 {USB_DEVICE(0x0506, 0x0a11)}, /* 3COM 3CRWE254G72 */ 37 {USB_DEVICE(0x0506, 0x0a11)}, /* 3COM 3CRWE254G72 */
38 {USB_DEVICE(0x06b9, 0x0120)}, /* Thomson SpeedTouch 120g */
38 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */ 39 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */
39 {USB_DEVICE(0x07aa, 0x001c)}, /* Corega CG-WLUSB2GT */ 40 {USB_DEVICE(0x07aa, 0x001c)}, /* Corega CG-WLUSB2GT */
40 {USB_DEVICE(0x083a, 0x4501)}, /* Accton 802.11g WN4501 USB */ 41 {USB_DEVICE(0x083a, 0x4501)}, /* Accton 802.11g WN4501 USB */
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 267afd714c74..aceb95ef7274 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -1546,51 +1546,67 @@ static void set_multicast_list(struct usbnet *usbdev)
1546{ 1546{
1547 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1547 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1548 struct dev_mc_list *mclist; 1548 struct dev_mc_list *mclist;
1549 __le32 filter; 1549 __le32 filter, basefilter;
1550 int ret, i, size; 1550 int ret;
1551 char *buf; 1551 char *mc_addrs = NULL;
1552 int mc_count;
1552 1553
1553 filter = RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_BROADCAST; 1554 basefilter = filter = RNDIS_PACKET_TYPE_DIRECTED |
1555 RNDIS_PACKET_TYPE_BROADCAST;
1554 1556
1555 netif_addr_lock_bh(usbdev->net);
1556 if (usbdev->net->flags & IFF_PROMISC) { 1557 if (usbdev->net->flags & IFF_PROMISC) {
1557 filter |= RNDIS_PACKET_TYPE_PROMISCUOUS | 1558 filter |= RNDIS_PACKET_TYPE_PROMISCUOUS |
1558 RNDIS_PACKET_TYPE_ALL_LOCAL; 1559 RNDIS_PACKET_TYPE_ALL_LOCAL;
1559 } else if (usbdev->net->flags & IFF_ALLMULTI || 1560 } else if (usbdev->net->flags & IFF_ALLMULTI) {
1560 netdev_mc_count(usbdev->net) > priv->multicast_size) { 1561 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST;
1562 }
1563
1564 if (filter != basefilter)
1565 goto set_filter;
1566
1567 /*
1568 * mc_list should be accessed holding the lock, so copy addresses to
1569 * local buffer first.
1570 */
1571 netif_addr_lock_bh(usbdev->net);
1572 mc_count = netdev_mc_count(usbdev->net);
1573 if (mc_count > priv->multicast_size) {
1561 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST; 1574 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST;
1562 } else if (!netdev_mc_empty(usbdev->net)) { 1575 } else if (mc_count) {
1563 size = min(priv->multicast_size, netdev_mc_count(usbdev->net)); 1576 int i = 0;
1564 buf = kmalloc(size * ETH_ALEN, GFP_KERNEL); 1577
1565 if (!buf) { 1578 mc_addrs = kmalloc(mc_count * ETH_ALEN, GFP_ATOMIC);
1579 if (!mc_addrs) {
1566 netdev_warn(usbdev->net, 1580 netdev_warn(usbdev->net,
1567 "couldn't alloc %d bytes of memory\n", 1581 "couldn't alloc %d bytes of memory\n",
1568 size * ETH_ALEN); 1582 mc_count * ETH_ALEN);
1569 netif_addr_unlock_bh(usbdev->net); 1583 netif_addr_unlock_bh(usbdev->net);
1570 return; 1584 return;
1571 } 1585 }
1572 1586
1573 i = 0; 1587 netdev_for_each_mc_addr(mclist, usbdev->net)
1574 netdev_for_each_mc_addr(mclist, usbdev->net) { 1588 memcpy(mc_addrs + i++ * ETH_ALEN,
1575 if (i == size) 1589 mclist->dmi_addr, ETH_ALEN);
1576 break; 1590 }
1577 memcpy(buf + i++ * ETH_ALEN, mclist->dmi_addr, ETH_ALEN); 1591 netif_addr_unlock_bh(usbdev->net);
1578 }
1579 1592
1580 ret = rndis_set_oid(usbdev, OID_802_3_MULTICAST_LIST, buf, 1593 if (filter != basefilter)
1581 i * ETH_ALEN); 1594 goto set_filter;
1582 if (ret == 0 && i > 0) 1595
1596 if (mc_count) {
1597 ret = rndis_set_oid(usbdev, OID_802_3_MULTICAST_LIST, mc_addrs,
1598 mc_count * ETH_ALEN);
1599 kfree(mc_addrs);
1600 if (ret == 0)
1583 filter |= RNDIS_PACKET_TYPE_MULTICAST; 1601 filter |= RNDIS_PACKET_TYPE_MULTICAST;
1584 else 1602 else
1585 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST; 1603 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST;
1586 1604
1587 netdev_dbg(usbdev->net, "OID_802_3_MULTICAST_LIST(%d, max: %d) -> %d\n", 1605 netdev_dbg(usbdev->net, "OID_802_3_MULTICAST_LIST(%d, max: %d) -> %d\n",
1588 i, priv->multicast_size, ret); 1606 mc_count, priv->multicast_size, ret);
1589
1590 kfree(buf);
1591 } 1607 }
1592 netif_addr_unlock_bh(usbdev->net);
1593 1608
1609set_filter:
1594 ret = rndis_set_oid(usbdev, OID_GEN_CURRENT_PACKET_FILTER, &filter, 1610 ret = rndis_set_oid(usbdev, OID_GEN_CURRENT_PACKET_FILTER, &filter,
1595 sizeof(filter)); 1611 sizeof(filter));
1596 if (ret < 0) { 1612 if (ret < 0) {
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index c1eec17fe186..54d2716e389c 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1647,6 +1647,11 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1647 unsigned int i; 1647 unsigned int i;
1648 1648
1649 /* 1649 /*
1650 * Disable powersaving as default.
1651 */
1652 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
1653
1654 /*
1650 * Initialize all hw fields. 1655 * Initialize all hw fields.
1651 */ 1656 */
1652 rt2x00dev->hw->flags = 1657 rt2x00dev->hw->flags =
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index d1694912310e..68d0cfee3f20 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -812,9 +812,9 @@ static void rt2800_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
812 rt2800_rfcsr_write(rt2x00dev, 24, 812 rt2800_rfcsr_write(rt2x00dev, 24,
813 rt2x00dev->calibration[conf_is_ht40(conf)]); 813 rt2x00dev->calibration[conf_is_ht40(conf)]);
814 814
815 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr); 815 rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr);
816 rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1); 816 rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1);
817 rt2800_rfcsr_write(rt2x00dev, 23, rfcsr); 817 rt2800_rfcsr_write(rt2x00dev, 7, rfcsr);
818} 818}
819 819
820static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, 820static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00soc.h b/drivers/net/wireless/rt2x00/rt2x00soc.h
index 4739edfe2f00..474cbfc1efc7 100644
--- a/drivers/net/wireless/rt2x00/rt2x00soc.h
+++ b/drivers/net/wireless/rt2x00/rt2x00soc.h
@@ -26,8 +26,6 @@
26#ifndef RT2X00SOC_H 26#ifndef RT2X00SOC_H
27#define RT2X00SOC_H 27#define RT2X00SOC_H
28 28
29#define KSEG1ADDR(__ptr) __ptr
30
31/* 29/*
32 * SoC driver handlers. 30 * SoC driver handlers.
33 */ 31 */
diff --git a/drivers/net/wireless/wl12xx/wl1251_debugfs.c b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
index 0ccba57fb9fb..05e4d68eb4cc 100644
--- a/drivers/net/wireless/wl12xx/wl1251_debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
@@ -466,7 +466,8 @@ out:
466 466
467void wl1251_debugfs_reset(struct wl1251 *wl) 467void wl1251_debugfs_reset(struct wl1251 *wl)
468{ 468{
469 memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats)); 469 if (wl->stats.fw_stats != NULL)
470 memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
470 wl->stats.retry_count = 0; 471 wl->stats.retry_count = 0;
471 wl->stats.excessive_retries = 0; 472 wl->stats.excessive_retries = 0;
472} 473}
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index c0c73913833d..2e7a3bf13824 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -354,7 +354,7 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = {
354static int acpi_pci_find_device(struct device *dev, acpi_handle *handle) 354static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
355{ 355{
356 struct pci_dev * pci_dev; 356 struct pci_dev * pci_dev;
357 acpi_integer addr; 357 u64 addr;
358 358
359 pci_dev = to_pci_dev(dev); 359 pci_dev = to_pci_dev(dev);
360 /* Please ref to ACPI spec for the syntax of _ADR */ 360 /* Please ref to ACPI spec for the syntax of _ADR */
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index bf32f07c4efb..4fe36d2e1049 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -101,9 +101,17 @@ static void __assign_resources_sorted(struct resource_list *head,
101 for (list = head->next; list;) { 101 for (list = head->next; list;) {
102 res = list->res; 102 res = list->res;
103 idx = res - &list->dev->resource[0]; 103 idx = res - &list->dev->resource[0];
104
104 if (pci_assign_resource(list->dev, idx)) { 105 if (pci_assign_resource(list->dev, idx)) {
105 if (fail_head && !pci_is_root_bus(list->dev->bus)) 106 if (fail_head && !pci_is_root_bus(list->dev->bus)) {
106 add_to_failed_list(fail_head, list->dev, res); 107 /*
108 * if the failed res is for ROM BAR, and it will
109 * be enabled later, don't add it to the list
110 */
111 if (!((idx == PCI_ROM_RESOURCE) &&
112 (!(res->flags & IORESOURCE_ROM_ENABLE))))
113 add_to_failed_list(fail_head, list->dev, res);
114 }
107 res->start = 0; 115 res->start = 0;
108 res->end = 0; 116 res->end = 0;
109 res->flags = 0; 117 res->flags = 0;
diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c
index a350418e87ea..944068611919 100644
--- a/drivers/platform/x86/toshiba_bluetooth.c
+++ b/drivers/platform/x86/toshiba_bluetooth.c
@@ -57,7 +57,7 @@ static struct acpi_driver toshiba_bt_rfkill_driver = {
57static int toshiba_bluetooth_enable(acpi_handle handle) 57static int toshiba_bluetooth_enable(acpi_handle handle)
58{ 58{
59 acpi_status res1, res2; 59 acpi_status res1, res2;
60 acpi_integer result; 60 u64 result;
61 61
62 /* 62 /*
63 * Query ACPI to verify RFKill switch is set to 'on'. 63 * Query ACPI to verify RFKill switch is set to 'on'.
@@ -95,7 +95,7 @@ static int toshiba_bt_resume(struct acpi_device *device)
95static int toshiba_bt_rfkill_add(struct acpi_device *device) 95static int toshiba_bt_rfkill_add(struct acpi_device *device)
96{ 96{
97 acpi_status status; 97 acpi_status status;
98 acpi_integer bt_present; 98 u64 bt_present;
99 int result = -ENODEV; 99 int result = -ENODEV;
100 100
101 /* 101 /*
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index b104302fea0a..09e9918c69c1 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -796,7 +796,7 @@ static __init acpi_status parse_wdg(acpi_handle handle)
796 */ 796 */
797static acpi_status 797static acpi_status
798acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, 798acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
799 u32 bits, acpi_integer * value, 799 u32 bits, u64 *value,
800 void *handler_context, void *region_context) 800 void *handler_context, void *region_context)
801{ 801{
802 int result = 0, i = 0; 802 int result = 0, i = 0;
@@ -813,7 +813,7 @@ acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
813 813
814 if (function == ACPI_READ) { 814 if (function == ACPI_READ) {
815 result = ec_read(address, &temp); 815 result = ec_read(address, &temp);
816 (*value) |= ((acpi_integer)temp) << i; 816 (*value) |= ((u64)temp) << i;
817 } else { 817 } else {
818 temp = 0xff & ((*value) >> i); 818 temp = 0xff & ((*value) >> i);
819 result = ec_write(address, temp); 819 result = ec_write(address, temp);
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 0264b117893b..c256aacfa954 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -7,6 +7,9 @@
7 * 7 *
8 * Copyright 2006 (c) MontaVista Software, Inc. 8 * Copyright 2006 (c) MontaVista Software, Inc.
9 * 9 *
10 * Author: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
11 * Copyright 2010 (c) ST-Ericsson AB
12 *
10 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 14 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 15 * as published by the Free Software Foundation; either version
@@ -18,6 +21,9 @@
18#include <linux/interrupt.h> 21#include <linux/interrupt.h>
19#include <linux/amba/bus.h> 22#include <linux/amba/bus.h>
20#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/bcd.h>
25#include <linux/delay.h>
26#include <linux/version.h>
21 27
22/* 28/*
23 * Register definitions 29 * Register definitions
@@ -30,35 +36,207 @@
30#define RTC_RIS 0x14 /* Raw interrupt status register */ 36#define RTC_RIS 0x14 /* Raw interrupt status register */
31#define RTC_MIS 0x18 /* Masked interrupt status register */ 37#define RTC_MIS 0x18 /* Masked interrupt status register */
32#define RTC_ICR 0x1c /* Interrupt clear register */ 38#define RTC_ICR 0x1c /* Interrupt clear register */
39/* ST variants have additional timer functionality */
40#define RTC_TDR 0x20 /* Timer data read register */
41#define RTC_TLR 0x24 /* Timer data load register */
42#define RTC_TCR 0x28 /* Timer control register */
43#define RTC_YDR 0x30 /* Year data read register */
44#define RTC_YMR 0x34 /* Year match register */
45#define RTC_YLR 0x38 /* Year data load register */
46
47#define RTC_CR_CWEN (1 << 26) /* Clockwatch enable bit */
48
49#define RTC_TCR_EN (1 << 1) /* Periodic timer enable bit */
50
51/* Common bit definitions for Interrupt status and control registers */
52#define RTC_BIT_AI (1 << 0) /* Alarm interrupt bit */
53#define RTC_BIT_PI (1 << 1) /* Periodic interrupt bit. ST variants only. */
54
55/* Common bit definations for ST v2 for reading/writing time */
56#define RTC_SEC_SHIFT 0
57#define RTC_SEC_MASK (0x3F << RTC_SEC_SHIFT) /* Second [0-59] */
58#define RTC_MIN_SHIFT 6
59#define RTC_MIN_MASK (0x3F << RTC_MIN_SHIFT) /* Minute [0-59] */
60#define RTC_HOUR_SHIFT 12
61#define RTC_HOUR_MASK (0x1F << RTC_HOUR_SHIFT) /* Hour [0-23] */
62#define RTC_WDAY_SHIFT 17
63#define RTC_WDAY_MASK (0x7 << RTC_WDAY_SHIFT) /* Day of Week [1-7] 1=Sunday */
64#define RTC_MDAY_SHIFT 20
65#define RTC_MDAY_MASK (0x1F << RTC_MDAY_SHIFT) /* Day of Month [1-31] */
66#define RTC_MON_SHIFT 25
67#define RTC_MON_MASK (0xF << RTC_MON_SHIFT) /* Month [1-12] 1=January */
68
69#define RTC_TIMER_FREQ 32768
33 70
34struct pl031_local { 71struct pl031_local {
35 struct rtc_device *rtc; 72 struct rtc_device *rtc;
36 void __iomem *base; 73 void __iomem *base;
74 u8 hw_designer;
75 u8 hw_revision:4;
37}; 76};
38 77
39static irqreturn_t pl031_interrupt(int irq, void *dev_id) 78static int pl031_alarm_irq_enable(struct device *dev,
79 unsigned int enabled)
80{
81 struct pl031_local *ldata = dev_get_drvdata(dev);
82 unsigned long imsc;
83
84 /* Clear any pending alarm interrupts. */
85 writel(RTC_BIT_AI, ldata->base + RTC_ICR);
86
87 imsc = readl(ldata->base + RTC_IMSC);
88
89 if (enabled == 1)
90 writel(imsc | RTC_BIT_AI, ldata->base + RTC_IMSC);
91 else
92 writel(imsc & ~RTC_BIT_AI, ldata->base + RTC_IMSC);
93
94 return 0;
95}
96
97/*
98 * Convert Gregorian date to ST v2 RTC format.
99 */
100static int pl031_stv2_tm_to_time(struct device *dev,
101 struct rtc_time *tm, unsigned long *st_time,
102 unsigned long *bcd_year)
103{
104 int year = tm->tm_year + 1900;
105 int wday = tm->tm_wday;
106
107 /* wday masking is not working in hardware so wday must be valid */
108 if (wday < -1 || wday > 6) {
109 dev_err(dev, "invalid wday value %d\n", tm->tm_wday);
110 return -EINVAL;
111 } else if (wday == -1) {
112 /* wday is not provided, calculate it here */
113 unsigned long time;
114 struct rtc_time calc_tm;
115
116 rtc_tm_to_time(tm, &time);
117 rtc_time_to_tm(time, &calc_tm);
118 wday = calc_tm.tm_wday;
119 }
120
121 *bcd_year = (bin2bcd(year % 100) | bin2bcd(year / 100) << 8);
122
123 *st_time = ((tm->tm_mon + 1) << RTC_MON_SHIFT)
124 | (tm->tm_mday << RTC_MDAY_SHIFT)
125 | ((wday + 1) << RTC_WDAY_SHIFT)
126 | (tm->tm_hour << RTC_HOUR_SHIFT)
127 | (tm->tm_min << RTC_MIN_SHIFT)
128 | (tm->tm_sec << RTC_SEC_SHIFT);
129
130 return 0;
131}
132
133/*
134 * Convert ST v2 RTC format to Gregorian date.
135 */
136static int pl031_stv2_time_to_tm(unsigned long st_time, unsigned long bcd_year,
137 struct rtc_time *tm)
138{
139 tm->tm_year = bcd2bin(bcd_year) + (bcd2bin(bcd_year >> 8) * 100);
140 tm->tm_mon = ((st_time & RTC_MON_MASK) >> RTC_MON_SHIFT) - 1;
141 tm->tm_mday = ((st_time & RTC_MDAY_MASK) >> RTC_MDAY_SHIFT);
142 tm->tm_wday = ((st_time & RTC_WDAY_MASK) >> RTC_WDAY_SHIFT) - 1;
143 tm->tm_hour = ((st_time & RTC_HOUR_MASK) >> RTC_HOUR_SHIFT);
144 tm->tm_min = ((st_time & RTC_MIN_MASK) >> RTC_MIN_SHIFT);
145 tm->tm_sec = ((st_time & RTC_SEC_MASK) >> RTC_SEC_SHIFT);
146
147 tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
148 tm->tm_year -= 1900;
149
150 return 0;
151}
152
153static int pl031_stv2_read_time(struct device *dev, struct rtc_time *tm)
154{
155 struct pl031_local *ldata = dev_get_drvdata(dev);
156
157 pl031_stv2_time_to_tm(readl(ldata->base + RTC_DR),
158 readl(ldata->base + RTC_YDR), tm);
159
160 return 0;
161}
162
163static int pl031_stv2_set_time(struct device *dev, struct rtc_time *tm)
164{
165 unsigned long time;
166 unsigned long bcd_year;
167 struct pl031_local *ldata = dev_get_drvdata(dev);
168 int ret;
169
170 ret = pl031_stv2_tm_to_time(dev, tm, &time, &bcd_year);
171 if (ret == 0) {
172 writel(bcd_year, ldata->base + RTC_YLR);
173 writel(time, ldata->base + RTC_LR);
174 }
175
176 return ret;
177}
178
179static int pl031_stv2_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
40{ 180{
41 struct rtc_device *rtc = dev_id; 181 struct pl031_local *ldata = dev_get_drvdata(dev);
182 int ret;
42 183
43 rtc_update_irq(rtc, 1, RTC_AF); 184 ret = pl031_stv2_time_to_tm(readl(ldata->base + RTC_MR),
185 readl(ldata->base + RTC_YMR), &alarm->time);
44 186
45 return IRQ_HANDLED; 187 alarm->pending = readl(ldata->base + RTC_RIS) & RTC_BIT_AI;
188 alarm->enabled = readl(ldata->base + RTC_IMSC) & RTC_BIT_AI;
189
190 return ret;
46} 191}
47 192
48static int pl031_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 193static int pl031_stv2_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
49{ 194{
50 struct pl031_local *ldata = dev_get_drvdata(dev); 195 struct pl031_local *ldata = dev_get_drvdata(dev);
196 unsigned long time;
197 unsigned long bcd_year;
198 int ret;
199
200 /* At the moment, we can only deal with non-wildcarded alarm times. */
201 ret = rtc_valid_tm(&alarm->time);
202 if (ret == 0) {
203 ret = pl031_stv2_tm_to_time(dev, &alarm->time,
204 &time, &bcd_year);
205 if (ret == 0) {
206 writel(bcd_year, ldata->base + RTC_YMR);
207 writel(time, ldata->base + RTC_MR);
208
209 pl031_alarm_irq_enable(dev, alarm->enabled);
210 }
211 }
212
213 return ret;
214}
215
216static irqreturn_t pl031_interrupt(int irq, void *dev_id)
217{
218 struct pl031_local *ldata = dev_id;
219 unsigned long rtcmis;
220 unsigned long events = 0;
221
222 rtcmis = readl(ldata->base + RTC_MIS);
223 if (rtcmis) {
224 writel(rtcmis, ldata->base + RTC_ICR);
225
226 if (rtcmis & RTC_BIT_AI)
227 events |= (RTC_AF | RTC_IRQF);
228
229 /* Timer interrupt is only available in ST variants */
230 if ((rtcmis & RTC_BIT_PI) &&
231 (ldata->hw_designer == AMBA_VENDOR_ST))
232 events |= (RTC_PF | RTC_IRQF);
233
234 rtc_update_irq(ldata->rtc, 1, events);
51 235
52 switch (cmd) { 236 return IRQ_HANDLED;
53 case RTC_AIE_OFF:
54 writel(1, ldata->base + RTC_MIS);
55 return 0;
56 case RTC_AIE_ON:
57 writel(0, ldata->base + RTC_MIS);
58 return 0;
59 } 237 }
60 238
61 return -ENOIOCTLCMD; 239 return IRQ_NONE;
62} 240}
63 241
64static int pl031_read_time(struct device *dev, struct rtc_time *tm) 242static int pl031_read_time(struct device *dev, struct rtc_time *tm)
@@ -74,11 +252,14 @@ static int pl031_set_time(struct device *dev, struct rtc_time *tm)
74{ 252{
75 unsigned long time; 253 unsigned long time;
76 struct pl031_local *ldata = dev_get_drvdata(dev); 254 struct pl031_local *ldata = dev_get_drvdata(dev);
255 int ret;
77 256
78 rtc_tm_to_time(tm, &time); 257 ret = rtc_tm_to_time(tm, &time);
79 writel(time, ldata->base + RTC_LR);
80 258
81 return 0; 259 if (ret == 0)
260 writel(time, ldata->base + RTC_LR);
261
262 return ret;
82} 263}
83 264
84static int pl031_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) 265static int pl031_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
@@ -86,8 +267,9 @@ static int pl031_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
86 struct pl031_local *ldata = dev_get_drvdata(dev); 267 struct pl031_local *ldata = dev_get_drvdata(dev);
87 268
88 rtc_time_to_tm(readl(ldata->base + RTC_MR), &alarm->time); 269 rtc_time_to_tm(readl(ldata->base + RTC_MR), &alarm->time);
89 alarm->pending = readl(ldata->base + RTC_RIS); 270
90 alarm->enabled = readl(ldata->base + RTC_IMSC); 271 alarm->pending = readl(ldata->base + RTC_RIS) & RTC_BIT_AI;
272 alarm->enabled = readl(ldata->base + RTC_IMSC) & RTC_BIT_AI;
91 273
92 return 0; 274 return 0;
93} 275}
@@ -96,22 +278,71 @@ static int pl031_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
96{ 278{
97 struct pl031_local *ldata = dev_get_drvdata(dev); 279 struct pl031_local *ldata = dev_get_drvdata(dev);
98 unsigned long time; 280 unsigned long time;
281 int ret;
282
283 /* At the moment, we can only deal with non-wildcarded alarm times. */
284 ret = rtc_valid_tm(&alarm->time);
285 if (ret == 0) {
286 ret = rtc_tm_to_time(&alarm->time, &time);
287 if (ret == 0) {
288 writel(time, ldata->base + RTC_MR);
289 pl031_alarm_irq_enable(dev, alarm->enabled);
290 }
291 }
292
293 return ret;
294}
295
296/* Periodic interrupt is only available in ST variants. */
297static int pl031_irq_set_state(struct device *dev, int enabled)
298{
299 struct pl031_local *ldata = dev_get_drvdata(dev);
300
301 if (enabled == 1) {
302 /* Clear any pending timer interrupt. */
303 writel(RTC_BIT_PI, ldata->base + RTC_ICR);
304
305 writel(readl(ldata->base + RTC_IMSC) | RTC_BIT_PI,
306 ldata->base + RTC_IMSC);
99 307
100 rtc_tm_to_time(&alarm->time, &time); 308 /* Now start the timer */
309 writel(readl(ldata->base + RTC_TCR) | RTC_TCR_EN,
310 ldata->base + RTC_TCR);
101 311
102 writel(time, ldata->base + RTC_MR); 312 } else {
103 writel(!alarm->enabled, ldata->base + RTC_MIS); 313 writel(readl(ldata->base + RTC_IMSC) & (~RTC_BIT_PI),
314 ldata->base + RTC_IMSC);
315
316 /* Also stop the timer */
317 writel(readl(ldata->base + RTC_TCR) & (~RTC_TCR_EN),
318 ldata->base + RTC_TCR);
319 }
320 /* Wait at least 1 RTC32 clock cycle to ensure next access
321 * to RTC_TCR will succeed.
322 */
323 udelay(40);
104 324
105 return 0; 325 return 0;
106} 326}
107 327
108static const struct rtc_class_ops pl031_ops = { 328static int pl031_irq_set_freq(struct device *dev, int freq)
109 .ioctl = pl031_ioctl, 329{
110 .read_time = pl031_read_time, 330 struct pl031_local *ldata = dev_get_drvdata(dev);
111 .set_time = pl031_set_time, 331
112 .read_alarm = pl031_read_alarm, 332 /* Cant set timer if it is already enabled */
113 .set_alarm = pl031_set_alarm, 333 if (readl(ldata->base + RTC_TCR) & RTC_TCR_EN) {
114}; 334 dev_err(dev, "can't change frequency while timer enabled\n");
335 return -EINVAL;
336 }
337
338 /* If self start bit in RTC_TCR is set timer will start here,
339 * but we never set that bit. Instead we start the timer when
340 * set_state is called with enabled == 1.
341 */
342 writel(RTC_TIMER_FREQ / freq, ldata->base + RTC_TLR);
343
344 return 0;
345}
115 346
116static int pl031_remove(struct amba_device *adev) 347static int pl031_remove(struct amba_device *adev)
117{ 348{
@@ -131,18 +362,20 @@ static int pl031_probe(struct amba_device *adev, struct amba_id *id)
131{ 362{
132 int ret; 363 int ret;
133 struct pl031_local *ldata; 364 struct pl031_local *ldata;
365 struct rtc_class_ops *ops = id->data;
134 366
135 ret = amba_request_regions(adev, NULL); 367 ret = amba_request_regions(adev, NULL);
136 if (ret) 368 if (ret)
137 goto err_req; 369 goto err_req;
138 370
139 ldata = kmalloc(sizeof(struct pl031_local), GFP_KERNEL); 371 ldata = kzalloc(sizeof(struct pl031_local), GFP_KERNEL);
140 if (!ldata) { 372 if (!ldata) {
141 ret = -ENOMEM; 373 ret = -ENOMEM;
142 goto out; 374 goto out;
143 } 375 }
144 376
145 ldata->base = ioremap(adev->res.start, resource_size(&adev->res)); 377 ldata->base = ioremap(adev->res.start, resource_size(&adev->res));
378
146 if (!ldata->base) { 379 if (!ldata->base) {
147 ret = -ENOMEM; 380 ret = -ENOMEM;
148 goto out_no_remap; 381 goto out_no_remap;
@@ -150,24 +383,36 @@ static int pl031_probe(struct amba_device *adev, struct amba_id *id)
150 383
151 amba_set_drvdata(adev, ldata); 384 amba_set_drvdata(adev, ldata);
152 385
153 if (request_irq(adev->irq[0], pl031_interrupt, IRQF_DISABLED, 386 ldata->hw_designer = amba_manf(adev);
154 "rtc-pl031", ldata->rtc)) { 387 ldata->hw_revision = amba_rev(adev);
155 ret = -EIO; 388
156 goto out_no_irq; 389 dev_dbg(&adev->dev, "designer ID = 0x%02x\n", ldata->hw_designer);
157 } 390 dev_dbg(&adev->dev, "revision = 0x%01x\n", ldata->hw_revision);
158 391
159 ldata->rtc = rtc_device_register("pl031", &adev->dev, &pl031_ops, 392 /* Enable the clockwatch on ST Variants */
160 THIS_MODULE); 393 if ((ldata->hw_designer == AMBA_VENDOR_ST) &&
394 (ldata->hw_revision > 1))
395 writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN,
396 ldata->base + RTC_CR);
397
398 ldata->rtc = rtc_device_register("pl031", &adev->dev, ops,
399 THIS_MODULE);
161 if (IS_ERR(ldata->rtc)) { 400 if (IS_ERR(ldata->rtc)) {
162 ret = PTR_ERR(ldata->rtc); 401 ret = PTR_ERR(ldata->rtc);
163 goto out_no_rtc; 402 goto out_no_rtc;
164 } 403 }
165 404
405 if (request_irq(adev->irq[0], pl031_interrupt,
406 IRQF_DISABLED | IRQF_SHARED, "rtc-pl031", ldata)) {
407 ret = -EIO;
408 goto out_no_irq;
409 }
410
166 return 0; 411 return 0;
167 412
168out_no_rtc:
169 free_irq(adev->irq[0], ldata->rtc);
170out_no_irq: 413out_no_irq:
414 rtc_device_unregister(ldata->rtc);
415out_no_rtc:
171 iounmap(ldata->base); 416 iounmap(ldata->base);
172 amba_set_drvdata(adev, NULL); 417 amba_set_drvdata(adev, NULL);
173out_no_remap: 418out_no_remap:
@@ -175,13 +420,57 @@ out_no_remap:
175out: 420out:
176 amba_release_regions(adev); 421 amba_release_regions(adev);
177err_req: 422err_req:
423
178 return ret; 424 return ret;
179} 425}
180 426
427/* Operations for the original ARM version */
428static struct rtc_class_ops arm_pl031_ops = {
429 .read_time = pl031_read_time,
430 .set_time = pl031_set_time,
431 .read_alarm = pl031_read_alarm,
432 .set_alarm = pl031_set_alarm,
433 .alarm_irq_enable = pl031_alarm_irq_enable,
434};
435
436/* The First ST derivative */
437static struct rtc_class_ops stv1_pl031_ops = {
438 .read_time = pl031_read_time,
439 .set_time = pl031_set_time,
440 .read_alarm = pl031_read_alarm,
441 .set_alarm = pl031_set_alarm,
442 .alarm_irq_enable = pl031_alarm_irq_enable,
443 .irq_set_state = pl031_irq_set_state,
444 .irq_set_freq = pl031_irq_set_freq,
445};
446
447/* And the second ST derivative */
448static struct rtc_class_ops stv2_pl031_ops = {
449 .read_time = pl031_stv2_read_time,
450 .set_time = pl031_stv2_set_time,
451 .read_alarm = pl031_stv2_read_alarm,
452 .set_alarm = pl031_stv2_set_alarm,
453 .alarm_irq_enable = pl031_alarm_irq_enable,
454 .irq_set_state = pl031_irq_set_state,
455 .irq_set_freq = pl031_irq_set_freq,
456};
457
181static struct amba_id pl031_ids[] __initdata = { 458static struct amba_id pl031_ids[] __initdata = {
182 { 459 {
183 .id = 0x00041031, 460 .id = 0x00041031,
184 .mask = 0x000fffff, 461 .mask = 0x000fffff,
462 .data = &arm_pl031_ops,
463 },
464 /* ST Micro variants */
465 {
466 .id = 0x00180031,
467 .mask = 0x00ffffff,
468 .data = &stv1_pl031_ops,
469 },
470 {
471 .id = 0x00280031,
472 .mask = 0x00ffffff,
473 .data = &stv2_pl031_ops,
185 }, 474 },
186 {0, 0}, 475 {0, 0},
187}; 476};
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 9ab1ae40565f..4951aa82e9f5 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -2139,9 +2139,8 @@ static void dasd_setup_queue(struct dasd_block *block)
2139 2139
2140 blk_queue_logical_block_size(block->request_queue, block->bp_block); 2140 blk_queue_logical_block_size(block->request_queue, block->bp_block);
2141 max = block->base->discipline->max_blocks << block->s2b_shift; 2141 max = block->base->discipline->max_blocks << block->s2b_shift;
2142 blk_queue_max_sectors(block->request_queue, max); 2142 blk_queue_max_hw_sectors(block->request_queue, max);
2143 blk_queue_max_phys_segments(block->request_queue, -1L); 2143 blk_queue_max_segments(block->request_queue, -1L);
2144 blk_queue_max_hw_segments(block->request_queue, -1L);
2145 /* with page sized segments we can translate each segement into 2144 /* with page sized segments we can translate each segement into
2146 * one idaw/tidaw 2145 * one idaw/tidaw
2147 */ 2146 */
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
index 8d3d720737da..097da8ce6be6 100644
--- a/drivers/s390/char/tape_block.c
+++ b/drivers/s390/char/tape_block.c
@@ -222,9 +222,8 @@ tapeblock_setup_device(struct tape_device * device)
222 goto cleanup_queue; 222 goto cleanup_queue;
223 223
224 blk_queue_logical_block_size(blkdat->request_queue, TAPEBLOCK_HSEC_SIZE); 224 blk_queue_logical_block_size(blkdat->request_queue, TAPEBLOCK_HSEC_SIZE);
225 blk_queue_max_sectors(blkdat->request_queue, TAPEBLOCK_MAX_SEC); 225 blk_queue_max_hw_sectors(blkdat->request_queue, TAPEBLOCK_MAX_SEC);
226 blk_queue_max_phys_segments(blkdat->request_queue, -1L); 226 blk_queue_max_segments(blkdat->request_queue, -1L);
227 blk_queue_max_hw_segments(blkdat->request_queue, -1L);
228 blk_queue_max_segment_size(blkdat->request_queue, -1L); 227 blk_queue_max_segment_size(blkdat->request_queue, -1L);
229 blk_queue_segment_boundary(blkdat->request_queue, -1L); 228 blk_queue_segment_boundary(blkdat->request_queue, -1L);
230 229
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 87b536a97cb4..732f6d35b4a8 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -4195,7 +4195,7 @@ static void ibmvfc_tgt_add_rport(struct ibmvfc_target *tgt)
4195 if (tgt->service_parms.class3_parms[0] & 0x80000000) 4195 if (tgt->service_parms.class3_parms[0] & 0x80000000)
4196 rport->supported_classes |= FC_COS_CLASS3; 4196 rport->supported_classes |= FC_COS_CLASS3;
4197 if (rport->rqst_q) 4197 if (rport->rqst_q)
4198 blk_queue_max_hw_segments(rport->rqst_q, 1); 4198 blk_queue_max_segments(rport->rqst_q, 1);
4199 } else 4199 } else
4200 tgt_dbg(tgt, "rport add failed\n"); 4200 tgt_dbg(tgt, "rport add failed\n");
4201 spin_unlock_irqrestore(vhost->host->host_lock, flags); 4201 spin_unlock_irqrestore(vhost->host->host_lock, flags);
@@ -4669,7 +4669,7 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
4669 } 4669 }
4670 4670
4671 if (shost_to_fc_host(shost)->rqst_q) 4671 if (shost_to_fc_host(shost)->rqst_q)
4672 blk_queue_max_hw_segments(shost_to_fc_host(shost)->rqst_q, 1); 4672 blk_queue_max_segments(shost_to_fc_host(shost)->rqst_q, 1);
4673 dev_set_drvdata(dev, vhost); 4673 dev_set_drvdata(dev, vhost);
4674 spin_lock(&ibmvfc_driver_lock); 4674 spin_lock(&ibmvfc_driver_lock);
4675 list_add_tail(&vhost->queue, &ibmvfc_head); 4675 list_add_tail(&vhost->queue, &ibmvfc_head);
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 9e52d16c7c39..032f0d0e6cb4 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -3674,7 +3674,7 @@ static int ipr_slave_configure(struct scsi_device *sdev)
3674 if (ipr_is_vset_device(res)) { 3674 if (ipr_is_vset_device(res)) {
3675 blk_queue_rq_timeout(sdev->request_queue, 3675 blk_queue_rq_timeout(sdev->request_queue,
3676 IPR_VSET_RW_TIMEOUT); 3676 IPR_VSET_RW_TIMEOUT);
3677 blk_queue_max_sectors(sdev->request_queue, IPR_VSET_MAX_SECTORS); 3677 blk_queue_max_hw_sectors(sdev->request_queue, IPR_VSET_MAX_SECTORS);
3678 } 3678 }
3679 if (ipr_is_vset_device(res) || ipr_is_scsi_disk(res)) 3679 if (ipr_is_vset_device(res) || ipr_is_scsi_disk(res))
3680 sdev->allow_restart = 1; 3680 sdev->allow_restart = 1;
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index b6f1ef954af1..9b1c1433c26b 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -235,7 +235,7 @@ static int pmcraid_slave_configure(struct scsi_device *scsi_dev)
235 scsi_dev->allow_restart = 1; 235 scsi_dev->allow_restart = 1;
236 blk_queue_rq_timeout(scsi_dev->request_queue, 236 blk_queue_rq_timeout(scsi_dev->request_queue,
237 PMCRAID_VSET_IO_TIMEOUT); 237 PMCRAID_VSET_IO_TIMEOUT);
238 blk_queue_max_sectors(scsi_dev->request_queue, 238 blk_queue_max_hw_sectors(scsi_dev->request_queue,
239 PMCRAID_VSET_MAX_SECTORS); 239 PMCRAID_VSET_MAX_SECTORS);
240 } 240 }
241 241
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 513661f45e5f..1c08f6164658 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -1018,6 +1018,8 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
1018 * scsi_get_vpd_page - Get Vital Product Data from a SCSI device 1018 * scsi_get_vpd_page - Get Vital Product Data from a SCSI device
1019 * @sdev: The device to ask 1019 * @sdev: The device to ask
1020 * @page: Which Vital Product Data to return 1020 * @page: Which Vital Product Data to return
1021 * @buf: where to store the VPD
1022 * @buf_len: number of bytes in the VPD buffer area
1021 * 1023 *
1022 * SCSI devices may optionally supply Vital Product Data. Each 'page' 1024 * SCSI devices may optionally supply Vital Product Data. Each 'page'
1023 * of VPD is defined in the appropriate SCSI document (eg SPC, SBC). 1025 * of VPD is defined in the appropriate SCSI document (eg SPC, SBC).
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 56977097de9f..1646fe7cbd4b 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1630,10 +1630,10 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
1630 /* 1630 /*
1631 * this limit is imposed by hardware restrictions 1631 * this limit is imposed by hardware restrictions
1632 */ 1632 */
1633 blk_queue_max_hw_segments(q, shost->sg_tablesize); 1633 blk_queue_max_segments(q, min_t(unsigned short, shost->sg_tablesize,
1634 blk_queue_max_phys_segments(q, SCSI_MAX_SG_CHAIN_SEGMENTS); 1634 SCSI_MAX_SG_CHAIN_SEGMENTS));
1635 1635
1636 blk_queue_max_sectors(q, shost->max_sectors); 1636 blk_queue_max_hw_sectors(q, shost->max_sectors);
1637 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost)); 1637 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
1638 blk_queue_segment_boundary(q, shost->dma_boundary); 1638 blk_queue_segment_boundary(q, shost->dma_boundary);
1639 dma_set_seg_boundary(dev, shost->dma_boundary); 1639 dma_set_seg_boundary(dev, shost->dma_boundary);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index f697229ae5a9..4bc8b77a2ef3 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -879,7 +879,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
879 * broken RA4x00 Compaq Disk Array 879 * broken RA4x00 Compaq Disk Array
880 */ 880 */
881 if (*bflags & BLIST_MAX_512) 881 if (*bflags & BLIST_MAX_512)
882 blk_queue_max_sectors(sdev->request_queue, 512); 882 blk_queue_max_hw_sectors(sdev->request_queue, 512);
883 883
884 /* 884 /*
885 * Some devices may not want to have a start command automatically 885 * Some devices may not want to have a start command automatically
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 040f751809ea..c996d98636f3 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -287,8 +287,7 @@ sg_open(struct inode *inode, struct file *filp)
287 if (list_empty(&sdp->sfds)) { /* no existing opens on this device */ 287 if (list_empty(&sdp->sfds)) { /* no existing opens on this device */
288 sdp->sgdebug = 0; 288 sdp->sgdebug = 0;
289 q = sdp->device->request_queue; 289 q = sdp->device->request_queue;
290 sdp->sg_tablesize = min(queue_max_hw_segments(q), 290 sdp->sg_tablesize = queue_max_segments(q);
291 queue_max_phys_segments(q));
292 } 291 }
293 if ((sfp = sg_add_sfp(sdp, dev))) 292 if ((sfp = sg_add_sfp(sdp, dev)))
294 filp->private_data = sfp; 293 filp->private_data = sfp;
@@ -1376,8 +1375,7 @@ static Sg_device *sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1376 sdp->device = scsidp; 1375 sdp->device = scsidp;
1377 INIT_LIST_HEAD(&sdp->sfds); 1376 INIT_LIST_HEAD(&sdp->sfds);
1378 init_waitqueue_head(&sdp->o_excl_wait); 1377 init_waitqueue_head(&sdp->o_excl_wait);
1379 sdp->sg_tablesize = min(queue_max_hw_segments(q), 1378 sdp->sg_tablesize = queue_max_segments(q);
1380 queue_max_phys_segments(q));
1381 sdp->index = k; 1379 sdp->index = k;
1382 kref_init(&sdp->d_ref); 1380 kref_init(&sdp->d_ref);
1383 1381
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index d04ea9a6f673..f67d1a159aad 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3983,8 +3983,7 @@ static int st_probe(struct device *dev)
3983 return -ENODEV; 3983 return -ENODEV;
3984 } 3984 }
3985 3985
3986 i = min(queue_max_hw_segments(SDp->request_queue), 3986 i = queue_max_segments(SDp->request_queue);
3987 queue_max_phys_segments(SDp->request_queue));
3988 if (st_max_sg_segs < i) 3987 if (st_max_sg_segs < i)
3989 i = st_max_sg_segs; 3988 i = st_max_sg_segs;
3990 buffer = new_tape_buffer((SDp->host)->unchecked_isa_dma, i); 3989 buffer = new_tape_buffer((SDp->host)->unchecked_isa_dma, i);
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index ef7adc8135dd..ce6c35333ff7 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -71,6 +71,7 @@ struct uart_amba_port {
71 unsigned int im; /* interrupt mask */ 71 unsigned int im; /* interrupt mask */
72 unsigned int old_status; 72 unsigned int old_status;
73 unsigned int ifls; /* vendor-specific */ 73 unsigned int ifls; /* vendor-specific */
74 bool autorts;
74}; 75};
75 76
76/* There is by now at least one vendor with differing details, so handle it */ 77/* There is by now at least one vendor with differing details, so handle it */
@@ -308,6 +309,11 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl)
308 TIOCMBIT(TIOCM_OUT1, UART011_CR_OUT1); 309 TIOCMBIT(TIOCM_OUT1, UART011_CR_OUT1);
309 TIOCMBIT(TIOCM_OUT2, UART011_CR_OUT2); 310 TIOCMBIT(TIOCM_OUT2, UART011_CR_OUT2);
310 TIOCMBIT(TIOCM_LOOP, UART011_CR_LBE); 311 TIOCMBIT(TIOCM_LOOP, UART011_CR_LBE);
312
313 if (uap->autorts) {
314 /* We need to disable auto-RTS if we want to turn RTS off */
315 TIOCMBIT(TIOCM_RTS, UART011_CR_RTSEN);
316 }
311#undef TIOCMBIT 317#undef TIOCMBIT
312 318
313 writew(cr, uap->port.membase + UART011_CR); 319 writew(cr, uap->port.membase + UART011_CR);
@@ -437,6 +443,7 @@ static void pl011_shutdown(struct uart_port *port)
437 /* 443 /*
438 * disable the port 444 * disable the port
439 */ 445 */
446 uap->autorts = false;
440 writew(UART01x_CR_UARTEN | UART011_CR_TXE, uap->port.membase + UART011_CR); 447 writew(UART01x_CR_UARTEN | UART011_CR_TXE, uap->port.membase + UART011_CR);
441 448
442 /* 449 /*
@@ -456,6 +463,7 @@ static void
456pl011_set_termios(struct uart_port *port, struct ktermios *termios, 463pl011_set_termios(struct uart_port *port, struct ktermios *termios,
457 struct ktermios *old) 464 struct ktermios *old)
458{ 465{
466 struct uart_amba_port *uap = (struct uart_amba_port *)port;
459 unsigned int lcr_h, old_cr; 467 unsigned int lcr_h, old_cr;
460 unsigned long flags; 468 unsigned long flags;
461 unsigned int baud, quot; 469 unsigned int baud, quot;
@@ -532,6 +540,17 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
532 old_cr = readw(port->membase + UART011_CR); 540 old_cr = readw(port->membase + UART011_CR);
533 writew(0, port->membase + UART011_CR); 541 writew(0, port->membase + UART011_CR);
534 542
543 if (termios->c_cflag & CRTSCTS) {
544 if (old_cr & UART011_CR_RTS)
545 old_cr |= UART011_CR_RTSEN;
546
547 old_cr |= UART011_CR_CTSEN;
548 uap->autorts = true;
549 } else {
550 old_cr &= ~(UART011_CR_CTSEN | UART011_CR_RTSEN);
551 uap->autorts = false;
552 }
553
535 /* Set baud rate */ 554 /* Set baud rate */
536 writew(quot & 0x3f, port->membase + UART011_FBRD); 555 writew(quot & 0x3f, port->membase + UART011_FBRD);
537 writew(quot >> 6, port->membase + UART011_IBRD); 556 writew(quot >> 6, port->membase + UART011_IBRD);
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 0fee95cd9a49..a191fa2be7c5 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -181,7 +181,7 @@ config SPI_OMAP_UWIRE
181 181
182config SPI_OMAP24XX 182config SPI_OMAP24XX
183 tristate "McSPI driver for OMAP24xx/OMAP34xx" 183 tristate "McSPI driver for OMAP24xx/OMAP34xx"
184 depends on ARCH_OMAP24XX || ARCH_OMAP34XX 184 depends on ARCH_OMAP2 || ARCH_OMAP3
185 help 185 help
186 SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI 186 SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI
187 (McSPI) modules. 187 (McSPI) modules.
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
index ff5bbb9c43c9..9aeb68113100 100644
--- a/drivers/spi/amba-pl022.c
+++ b/drivers/spi/amba-pl022.c
@@ -363,6 +363,7 @@ struct pl022 {
363 void *rx_end; 363 void *rx_end;
364 enum ssp_reading read; 364 enum ssp_reading read;
365 enum ssp_writing write; 365 enum ssp_writing write;
366 u32 exp_fifo_level;
366}; 367};
367 368
368/** 369/**
@@ -501,6 +502,9 @@ static int flush(struct pl022 *pl022)
501 while (readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE) 502 while (readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
502 readw(SSP_DR(pl022->virtbase)); 503 readw(SSP_DR(pl022->virtbase));
503 } while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_BSY) && limit--); 504 } while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_BSY) && limit--);
505
506 pl022->exp_fifo_level = 0;
507
504 return limit; 508 return limit;
505} 509}
506 510
@@ -583,10 +587,9 @@ static void readwriter(struct pl022 *pl022)
583 * errons in 8bit wide transfers on ARM variants (just 8 words 587 * errons in 8bit wide transfers on ARM variants (just 8 words
584 * FIFO, means only 8x8 = 64 bits in FIFO) at least. 588 * FIFO, means only 8x8 = 64 bits in FIFO) at least.
585 * 589 *
586 * FIXME: currently we have no logic to account for this. 590 * To prevent this issue, the TX FIFO is only filled to the
587 * perhaps there is even something broken in HW regarding 591 * unused RX FIFO fill length, regardless of what the TX
588 * 8bit transfers (it doesn't fail on 16bit) so this needs 592 * FIFO status flag indicates.
589 * more investigation...
590 */ 593 */
591 dev_dbg(&pl022->adev->dev, 594 dev_dbg(&pl022->adev->dev,
592 "%s, rx: %p, rxend: %p, tx: %p, txend: %p\n", 595 "%s, rx: %p, rxend: %p, tx: %p, txend: %p\n",
@@ -613,11 +616,12 @@ static void readwriter(struct pl022 *pl022)
613 break; 616 break;
614 } 617 }
615 pl022->rx += (pl022->cur_chip->n_bytes); 618 pl022->rx += (pl022->cur_chip->n_bytes);
619 pl022->exp_fifo_level--;
616 } 620 }
617 /* 621 /*
618 * Write as much as you can, while keeping an eye on the RX FIFO! 622 * Write as much as possible up to the RX FIFO size
619 */ 623 */
620 while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_TNF) 624 while ((pl022->exp_fifo_level < pl022->vendor->fifodepth)
621 && (pl022->tx < pl022->tx_end)) { 625 && (pl022->tx < pl022->tx_end)) {
622 switch (pl022->write) { 626 switch (pl022->write) {
623 case WRITING_NULL: 627 case WRITING_NULL:
@@ -634,6 +638,7 @@ static void readwriter(struct pl022 *pl022)
634 break; 638 break;
635 } 639 }
636 pl022->tx += (pl022->cur_chip->n_bytes); 640 pl022->tx += (pl022->cur_chip->n_bytes);
641 pl022->exp_fifo_level++;
637 /* 642 /*
638 * This inner reader takes care of things appearing in the RX 643 * This inner reader takes care of things appearing in the RX
639 * FIFO as we're transmitting. This will happen a lot since the 644 * FIFO as we're transmitting. This will happen a lot since the
@@ -660,6 +665,7 @@ static void readwriter(struct pl022 *pl022)
660 break; 665 break;
661 } 666 }
662 pl022->rx += (pl022->cur_chip->n_bytes); 667 pl022->rx += (pl022->cur_chip->n_bytes);
668 pl022->exp_fifo_level--;
663 } 669 }
664 } 670 }
665 /* 671 /*
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index bf5f95a19413..715c518b1b68 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -1014,7 +1014,7 @@ static u8 __initdata spi2_txdma_id[] = {
1014 OMAP24XX_DMA_SPI2_TX1, 1014 OMAP24XX_DMA_SPI2_TX1,
1015}; 1015};
1016 1016
1017#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) \ 1017#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) \
1018 || defined(CONFIG_ARCH_OMAP4) 1018 || defined(CONFIG_ARCH_OMAP4)
1019static u8 __initdata spi3_rxdma_id[] = { 1019static u8 __initdata spi3_rxdma_id[] = {
1020 OMAP24XX_DMA_SPI3_RX0, 1020 OMAP24XX_DMA_SPI3_RX0,
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 62b282844a53..45d908114d11 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -363,10 +363,7 @@ static int blkvsc_probe(struct device *device)
363 blkdev->gd->queue = blk_init_queue(blkvsc_request, &blkdev->lock); 363 blkdev->gd->queue = blk_init_queue(blkvsc_request, &blkdev->lock);
364 364
365 blk_queue_max_segment_size(blkdev->gd->queue, PAGE_SIZE); 365 blk_queue_max_segment_size(blkdev->gd->queue, PAGE_SIZE);
366 blk_queue_max_phys_segments(blkdev->gd->queue, 366 blk_queue_max_segments(blkdev->gd->queue, MAX_MULTIPAGE_BUFFER_COUNT);
367 MAX_MULTIPAGE_BUFFER_COUNT);
368 blk_queue_max_hw_segments(blkdev->gd->queue,
369 MAX_MULTIPAGE_BUFFER_COUNT);
370 blk_queue_segment_boundary(blkdev->gd->queue, PAGE_SIZE-1); 367 blk_queue_segment_boundary(blkdev->gd->queue, PAGE_SIZE-1);
371 blk_queue_bounce_limit(blkdev->gd->queue, BLK_BOUNCE_ANY); 368 blk_queue_bounce_limit(blkdev->gd->queue, BLK_BOUNCE_ANY);
372 blk_queue_dma_alignment(blkdev->gd->queue, 511); 369 blk_queue_dma_alignment(blkdev->gd->queue, 511);
diff --git a/drivers/staging/phison/phison.c b/drivers/staging/phison/phison.c
index 3817d7497049..fcba78d21636 100644
--- a/drivers/staging/phison/phison.c
+++ b/drivers/staging/phison/phison.c
@@ -62,7 +62,7 @@ static int phison_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
62 }; 62 };
63 const struct ata_port_info *ppi[] = { &info, NULL }; 63 const struct ata_port_info *ppi[] = { &info, NULL };
64 64
65 ret = ata_pci_sff_init_one(pdev, ppi, &phison_sht, NULL); 65 ret = ata_pci_sff_init_one(pdev, ppi, &phison_sht, NULL, 0);
66 66
67 dev_dbg(&pdev->dev, "phison_init_one(), ret = %x\n", ret); 67 dev_dbg(&pdev->dev, "phison_init_one(), ret = %x\n", ret);
68 68
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 81aac7f4ca59..4f5bb5698f5d 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -61,7 +61,7 @@ config USB_ARCH_HAS_EHCI
61 default y if ARCH_W90X900 61 default y if ARCH_W90X900
62 default y if ARCH_AT91SAM9G45 62 default y if ARCH_AT91SAM9G45
63 default y if ARCH_MXC 63 default y if ARCH_MXC
64 default y if ARCH_OMAP34XX 64 default y if ARCH_OMAP3
65 default PCI 65 default PCI
66 66
67# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. 67# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
diff --git a/drivers/usb/gadget/f_audio.c b/drivers/usb/gadget/f_audio.c
index df77f6131c73..f1e3aad76c37 100644
--- a/drivers/usb/gadget/f_audio.c
+++ b/drivers/usb/gadget/f_audio.c
@@ -60,7 +60,7 @@ DECLARE_UAC_AC_HEADER_DESCRIPTOR(2);
60#define UAC_DT_TOTAL_LENGTH (UAC_DT_AC_HEADER_LENGTH + UAC_DT_INPUT_TERMINAL_SIZE \ 60#define UAC_DT_TOTAL_LENGTH (UAC_DT_AC_HEADER_LENGTH + UAC_DT_INPUT_TERMINAL_SIZE \
61 + UAC_DT_OUTPUT_TERMINAL_SIZE + UAC_DT_FEATURE_UNIT_SIZE(0)) 61 + UAC_DT_OUTPUT_TERMINAL_SIZE + UAC_DT_FEATURE_UNIT_SIZE(0))
62/* B.3.2 Class-Specific AC Interface Descriptor */ 62/* B.3.2 Class-Specific AC Interface Descriptor */
63static struct uac_ac_header_descriptor_2 ac_header_desc = { 63static struct uac_ac_header_descriptor_v1_2 ac_header_desc = {
64 .bLength = UAC_DT_AC_HEADER_LENGTH, 64 .bLength = UAC_DT_AC_HEADER_LENGTH,
65 .bDescriptorType = USB_DT_CS_INTERFACE, 65 .bDescriptorType = USB_DT_CS_INTERFACE,
66 .bDescriptorSubtype = UAC_HEADER, 66 .bDescriptorSubtype = UAC_HEADER,
@@ -124,7 +124,7 @@ static struct usb_audio_control_selector feature_unit = {
124}; 124};
125 125
126#define OUTPUT_TERMINAL_ID 3 126#define OUTPUT_TERMINAL_ID 3
127static struct uac_output_terminal_descriptor output_terminal_desc = { 127static struct uac_output_terminal_descriptor_v1 output_terminal_desc = {
128 .bLength = UAC_DT_OUTPUT_TERMINAL_SIZE, 128 .bLength = UAC_DT_OUTPUT_TERMINAL_SIZE,
129 .bDescriptorType = USB_DT_CS_INTERFACE, 129 .bDescriptorType = USB_DT_CS_INTERFACE,
130 .bDescriptorSubtype = UAC_OUTPUT_TERMINAL, 130 .bDescriptorSubtype = UAC_OUTPUT_TERMINAL,
@@ -154,7 +154,7 @@ static struct usb_interface_descriptor as_interface_alt_1_desc = {
154}; 154};
155 155
156/* B.4.2 Class-Specific AS Interface Descriptor */ 156/* B.4.2 Class-Specific AS Interface Descriptor */
157static struct uac_as_header_descriptor as_header_desc = { 157static struct uac_as_header_descriptor_v1 as_header_desc = {
158 .bLength = UAC_DT_AS_HEADER_SIZE, 158 .bLength = UAC_DT_AS_HEADER_SIZE,
159 .bDescriptorType = USB_DT_CS_INTERFACE, 159 .bDescriptorType = USB_DT_CS_INTERFACE,
160 .bDescriptorSubtype = UAC_AS_GENERAL, 160 .bDescriptorSubtype = UAC_AS_GENERAL,
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index d0b1e836f0e0..5f6a2e0a9357 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -237,7 +237,7 @@ static const struct usb_interface_descriptor ac_interface_desc = {
237}; 237};
238 238
239/* B.3.2 Class-Specific AC Interface Descriptor */ 239/* B.3.2 Class-Specific AC Interface Descriptor */
240static const struct uac_ac_header_descriptor_1 ac_header_desc = { 240static const struct uac_ac_header_descriptor_v1_1 ac_header_desc = {
241 .bLength = UAC_DT_AC_HEADER_SIZE(1), 241 .bLength = UAC_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,
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 1ec3857f22e6..d8d6d3461d32 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1118,7 +1118,7 @@ MODULE_LICENSE ("GPL");
1118#define PLATFORM_DRIVER ehci_hcd_au1xxx_driver 1118#define PLATFORM_DRIVER ehci_hcd_au1xxx_driver
1119#endif 1119#endif
1120 1120
1121#ifdef CONFIG_ARCH_OMAP34XX 1121#ifdef CONFIG_ARCH_OMAP3
1122#include "ehci-omap.c" 1122#include "ehci-omap.c"
1123#define PLATFORM_DRIVER ehci_hcd_omap_driver 1123#define PLATFORM_DRIVER ehci_hcd_omap_driver
1124#endif 1124#endif
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index d9db86498022..b4c783c284ba 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -37,7 +37,7 @@ config USB_MUSB_SOC
37 depends on USB_MUSB_HDRC 37 depends on USB_MUSB_HDRC
38 default y if ARCH_DAVINCI 38 default y if ARCH_DAVINCI
39 default y if ARCH_OMAP2430 39 default y if ARCH_OMAP2430
40 default y if ARCH_OMAP34XX 40 default y if ARCH_OMAP3
41 default y if (BF54x && !BF544) 41 default y if (BF54x && !BF544)
42 default y if (BF52x && !BF522 && !BF523) 42 default y if (BF52x && !BF522 && !BF523)
43 43
@@ -48,7 +48,7 @@ comment "OMAP 243x high speed USB support"
48 depends on USB_MUSB_HDRC && ARCH_OMAP2430 48 depends on USB_MUSB_HDRC && ARCH_OMAP2430
49 49
50comment "OMAP 343x high speed USB support" 50comment "OMAP 343x high speed USB support"
51 depends on USB_MUSB_HDRC && ARCH_OMAP34XX 51 depends on USB_MUSB_HDRC && ARCH_OMAP3
52 52
53comment "Blackfin high speed USB Support" 53comment "Blackfin high speed USB Support"
54 depends on USB_MUSB_HDRC && ((BF54x && !BF544) || (BF52x && !BF522 && !BF523)) 54 depends on USB_MUSB_HDRC && ((BF54x && !BF544) || (BF52x && !BF522 && !BF523))
@@ -153,7 +153,7 @@ config MUSB_PIO_ONLY
153config USB_INVENTRA_DMA 153config USB_INVENTRA_DMA
154 bool 154 bool
155 depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY 155 depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY
156 default ARCH_OMAP2430 || ARCH_OMAP34XX || BLACKFIN 156 default ARCH_OMAP2430 || ARCH_OMAP3 || BLACKFIN
157 help 157 help
158 Enable DMA transfers using Mentor's engine. 158 Enable DMA transfers using Mentor's engine.
159 159
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 5eb9318cff77..738efd8063b5 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1000,7 +1000,7 @@ static void musb_shutdown(struct platform_device *pdev)
1000 * more than selecting one of a bunch of predefined configurations. 1000 * more than selecting one of a bunch of predefined configurations.
1001 */ 1001 */
1002#if defined(CONFIG_USB_TUSB6010) || \ 1002#if defined(CONFIG_USB_TUSB6010) || \
1003 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) 1003 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
1004static ushort __initdata fifo_mode = 4; 1004static ushort __initdata fifo_mode = 4;
1005#else 1005#else
1006static ushort __initdata fifo_mode = 2; 1006static ushort __initdata fifo_mode = 2;
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 03d50909b078..5514c7ee85bd 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -562,7 +562,7 @@ extern void musb_hnp_stop(struct musb *musb);
562extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode); 562extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode);
563 563
564#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \ 564#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \
565 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) 565 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
566extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout); 566extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout);
567#else 567#else
568#define musb_platform_try_idle(x, y) do {} while (0) 568#define musb_platform_try_idle(x, y) do {} while (0)
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index e5e6df39e737..aadc16b5eed7 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -134,14 +134,14 @@ static int slave_configure(struct scsi_device *sdev)
134 if (us->fflags & US_FL_MAX_SECTORS_MIN) 134 if (us->fflags & US_FL_MAX_SECTORS_MIN)
135 max_sectors = PAGE_CACHE_SIZE >> 9; 135 max_sectors = PAGE_CACHE_SIZE >> 9;
136 if (queue_max_sectors(sdev->request_queue) > max_sectors) 136 if (queue_max_sectors(sdev->request_queue) > max_sectors)
137 blk_queue_max_sectors(sdev->request_queue, 137 blk_queue_max_hw_sectors(sdev->request_queue,
138 max_sectors); 138 max_sectors);
139 } else if (sdev->type == TYPE_TAPE) { 139 } else if (sdev->type == TYPE_TAPE) {
140 /* Tapes need much higher max_sector limits, so just 140 /* Tapes need much higher max_sector limits, so just
141 * raise it to the maximum possible (4 GB / 512) and 141 * raise it to the maximum possible (4 GB / 512) and
142 * let the queue segment size sort out the real limit. 142 * let the queue segment size sort out the real limit.
143 */ 143 */
144 blk_queue_max_sectors(sdev->request_queue, 0x7FFFFF); 144 blk_queue_max_hw_sectors(sdev->request_queue, 0x7FFFFF);
145 } 145 }
146 146
147 /* Some USB host controllers can't do DMA; they have to use PIO. 147 /* Some USB host controllers can't do DMA; they have to use PIO.
@@ -495,7 +495,7 @@ static ssize_t store_max_sectors(struct device *dev, struct device_attribute *at
495 unsigned short ms; 495 unsigned short ms;
496 496
497 if (sscanf(buf, "%hu", &ms) > 0 && ms <= SCSI_DEFAULT_MAX_SECTORS) { 497 if (sscanf(buf, "%hu", &ms) > 0 && ms <= SCSI_DEFAULT_MAX_SECTORS) {
498 blk_queue_max_sectors(sdev->request_queue, ms); 498 blk_queue_max_hw_sectors(sdev->request_queue, ms);
499 return strlen(buf); 499 return strlen(buf);
500 } 500 }
501 return -EINVAL; 501 return -EINVAL;
diff --git a/drivers/video/omap/lcd_ams_delta.c b/drivers/video/omap/lcd_ams_delta.c
index 567db6ac32c8..6978ae4ef83a 100644
--- a/drivers/video/omap/lcd_ams_delta.c
+++ b/drivers/video/omap/lcd_ams_delta.c
@@ -24,6 +24,7 @@
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/lcd.h>
27 28
28#include <plat/board-ams-delta.h> 29#include <plat/board-ams-delta.h>
29#include <mach/hardware.h> 30#include <mach/hardware.h>
@@ -32,6 +33,71 @@
32 33
33#define AMS_DELTA_DEFAULT_CONTRAST 112 34#define AMS_DELTA_DEFAULT_CONTRAST 112
34 35
36#define AMS_DELTA_MAX_CONTRAST 0x00FF
37#define AMS_DELTA_LCD_POWER 0x0100
38
39
40/* LCD class device section */
41
42static int ams_delta_lcd;
43
44static int ams_delta_lcd_set_power(struct lcd_device *dev, int power)
45{
46 if (power == FB_BLANK_UNBLANK) {
47 if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER)) {
48 omap_writeb(ams_delta_lcd & AMS_DELTA_MAX_CONTRAST,
49 OMAP_PWL_ENABLE);
50 omap_writeb(1, OMAP_PWL_CLK_ENABLE);
51 ams_delta_lcd |= AMS_DELTA_LCD_POWER;
52 }
53 } else {
54 if (ams_delta_lcd & AMS_DELTA_LCD_POWER) {
55 omap_writeb(0, OMAP_PWL_ENABLE);
56 omap_writeb(0, OMAP_PWL_CLK_ENABLE);
57 ams_delta_lcd &= ~AMS_DELTA_LCD_POWER;
58 }
59 }
60 return 0;
61}
62
63static int ams_delta_lcd_set_contrast(struct lcd_device *dev, int value)
64{
65 if ((value >= 0) && (value <= AMS_DELTA_MAX_CONTRAST)) {
66 omap_writeb(value, OMAP_PWL_ENABLE);
67 ams_delta_lcd &= ~AMS_DELTA_MAX_CONTRAST;
68 ams_delta_lcd |= value;
69 }
70 return 0;
71}
72
73#ifdef CONFIG_LCD_CLASS_DEVICE
74static int ams_delta_lcd_get_power(struct lcd_device *dev)
75{
76 if (ams_delta_lcd & AMS_DELTA_LCD_POWER)
77 return FB_BLANK_UNBLANK;
78 else
79 return FB_BLANK_POWERDOWN;
80}
81
82static int ams_delta_lcd_get_contrast(struct lcd_device *dev)
83{
84 if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER))
85 return 0;
86
87 return ams_delta_lcd & AMS_DELTA_MAX_CONTRAST;
88}
89
90static struct lcd_ops ams_delta_lcd_ops = {
91 .get_power = ams_delta_lcd_get_power,
92 .set_power = ams_delta_lcd_set_power,
93 .get_contrast = ams_delta_lcd_get_contrast,
94 .set_contrast = ams_delta_lcd_set_contrast,
95};
96#endif
97
98
99/* omapfb panel section */
100
35static int ams_delta_panel_init(struct lcd_panel *panel, 101static int ams_delta_panel_init(struct lcd_panel *panel,
36 struct omapfb_device *fbdev) 102 struct omapfb_device *fbdev)
37{ 103{
@@ -48,10 +114,6 @@ static int ams_delta_panel_enable(struct lcd_panel *panel)
48 AMS_DELTA_LATCH2_LCD_NDISP); 114 AMS_DELTA_LATCH2_LCD_NDISP);
49 ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN, 115 ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN,
50 AMS_DELTA_LATCH2_LCD_VBLEN); 116 AMS_DELTA_LATCH2_LCD_VBLEN);
51
52 omap_writeb(1, OMAP_PWL_CLK_ENABLE);
53 omap_writeb(AMS_DELTA_DEFAULT_CONTRAST, OMAP_PWL_ENABLE);
54
55 return 0; 117 return 0;
56} 118}
57 119
@@ -91,8 +153,31 @@ static struct lcd_panel ams_delta_panel = {
91 .get_caps = ams_delta_panel_get_caps, 153 .get_caps = ams_delta_panel_get_caps,
92}; 154};
93 155
156
157/* platform driver section */
158
94static int ams_delta_panel_probe(struct platform_device *pdev) 159static int ams_delta_panel_probe(struct platform_device *pdev)
95{ 160{
161 struct lcd_device *lcd_device = NULL;
162#ifdef CONFIG_LCD_CLASS_DEVICE
163 int ret;
164
165 lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL,
166 &ams_delta_lcd_ops);
167
168 if (IS_ERR(lcd_device)) {
169 ret = PTR_ERR(lcd_device);
170 dev_err(&pdev->dev, "failed to register device\n");
171 return ret;
172 }
173
174 platform_set_drvdata(pdev, lcd_device);
175 lcd_device->props.max_contrast = AMS_DELTA_MAX_CONTRAST;
176#endif
177
178 ams_delta_lcd_set_contrast(lcd_device, AMS_DELTA_DEFAULT_CONTRAST);
179 ams_delta_lcd_set_power(lcd_device, FB_BLANK_UNBLANK);
180
96 omapfb_register_panel(&ams_delta_panel); 181 omapfb_register_panel(&ams_delta_panel);
97 return 0; 182 return 0;
98} 183}
diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c
index 2c4f470fa086..8ce60e1b220a 100644
--- a/drivers/video/omap/omapfb_main.c
+++ b/drivers/video/omap/omapfb_main.c
@@ -486,10 +486,11 @@ static int set_color_mode(struct omapfb_plane_struct *plane,
486 return 0; 486 return 0;
487 case 12: 487 case 12:
488 var->bits_per_pixel = 16; 488 var->bits_per_pixel = 16;
489 plane->color_mode = OMAPFB_COLOR_RGB444;
490 return 0;
491 case 16: 489 case 16:
492 plane->color_mode = OMAPFB_COLOR_RGB565; 490 if (plane->fbdev->panel->bpp == 12)
491 plane->color_mode = OMAPFB_COLOR_RGB444;
492 else
493 plane->color_mode = OMAPFB_COLOR_RGB565;
493 return 0; 494 return 0;
494 default: 495 default:
495 return -EINVAL; 496 return -EINVAL;
diff --git a/drivers/video/omap2/displays/Kconfig b/drivers/video/omap2/displays/Kconfig
index b12a59c9c50a..dfb57ee50861 100644
--- a/drivers/video/omap2/displays/Kconfig
+++ b/drivers/video/omap2/displays/Kconfig
@@ -13,10 +13,28 @@ config PANEL_SHARP_LS037V7DW01
13 help 13 help
14 LCD Panel used in TI's SDP3430 and EVM boards 14 LCD Panel used in TI's SDP3430 and EVM boards
15 15
16config PANEL_SHARP_LQ043T1DG01
17 tristate "Sharp LQ043T1DG01 LCD Panel"
18 depends on OMAP2_DSS
19 help
20 LCD Panel used in TI's OMAP3517 EVM boards
21
16config PANEL_TAAL 22config PANEL_TAAL
17 tristate "Taal DSI Panel" 23 tristate "Taal DSI Panel"
18 depends on OMAP2_DSS_DSI 24 depends on OMAP2_DSS_DSI
19 help 25 help
20 Taal DSI command mode panel from TPO. 26 Taal DSI command mode panel from TPO.
21 27
28config PANEL_TOPPOLY_TDO35S
29 tristate "Toppoly TDO35S LCD Panel support"
30 depends on OMAP2_DSS
31 help
32 LCD Panel used in CM-T35
33
34config PANEL_TPO_TD043MTEA1
35 tristate "TPO TD043MTEA1 LCD Panel"
36 depends on OMAP2_DSS && I2C
37 help
38 LCD Panel used in OMAP3 Pandora
39
22endmenu 40endmenu
diff --git a/drivers/video/omap2/displays/Makefile b/drivers/video/omap2/displays/Makefile
index 955646440b3a..e2bb32168dee 100644
--- a/drivers/video/omap2/displays/Makefile
+++ b/drivers/video/omap2/displays/Makefile
@@ -1,4 +1,7 @@
1obj-$(CONFIG_PANEL_GENERIC) += panel-generic.o 1obj-$(CONFIG_PANEL_GENERIC) += panel-generic.o
2obj-$(CONFIG_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o 2obj-$(CONFIG_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o
3obj-$(CONFIG_PANEL_SHARP_LQ043T1DG01) += panel-sharp-lq043t1dg01.o
3 4
4obj-$(CONFIG_PANEL_TAAL) += panel-taal.o 5obj-$(CONFIG_PANEL_TAAL) += panel-taal.o
6obj-$(CONFIG_PANEL_TOPPOLY_TDO35S) += panel-toppoly-tdo35s.o
7obj-$(CONFIG_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
diff --git a/drivers/video/omap2/displays/panel-generic.c b/drivers/video/omap2/displays/panel-generic.c
index eb48d1afd800..c59e4baed8b2 100644
--- a/drivers/video/omap2/displays/panel-generic.c
+++ b/drivers/video/omap2/displays/panel-generic.c
@@ -35,6 +35,35 @@ static struct omap_video_timings generic_panel_timings = {
35 .vbp = 7, 35 .vbp = 7,
36}; 36};
37 37
38static int generic_panel_power_on(struct omap_dss_device *dssdev)
39{
40 int r;
41
42 r = omapdss_dpi_display_enable(dssdev);
43 if (r)
44 goto err0;
45
46 if (dssdev->platform_enable) {
47 r = dssdev->platform_enable(dssdev);
48 if (r)
49 goto err1;
50 }
51
52 return 0;
53err1:
54 omapdss_dpi_display_disable(dssdev);
55err0:
56 return r;
57}
58
59static void generic_panel_power_off(struct omap_dss_device *dssdev)
60{
61 if (dssdev->platform_disable)
62 dssdev->platform_disable(dssdev);
63
64 omapdss_dpi_display_disable(dssdev);
65}
66
38static int generic_panel_probe(struct omap_dss_device *dssdev) 67static int generic_panel_probe(struct omap_dss_device *dssdev)
39{ 68{
40 dssdev->panel.config = OMAP_DSS_LCD_TFT; 69 dssdev->panel.config = OMAP_DSS_LCD_TFT;
@@ -51,27 +80,40 @@ static int generic_panel_enable(struct omap_dss_device *dssdev)
51{ 80{
52 int r = 0; 81 int r = 0;
53 82
54 if (dssdev->platform_enable) 83 r = generic_panel_power_on(dssdev);
55 r = dssdev->platform_enable(dssdev); 84 if (r)
85 return r;
56 86
57 return r; 87 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
88
89 return 0;
58} 90}
59 91
60static void generic_panel_disable(struct omap_dss_device *dssdev) 92static void generic_panel_disable(struct omap_dss_device *dssdev)
61{ 93{
62 if (dssdev->platform_disable) 94 generic_panel_power_off(dssdev);
63 dssdev->platform_disable(dssdev); 95
96 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
64} 97}
65 98
66static int generic_panel_suspend(struct omap_dss_device *dssdev) 99static int generic_panel_suspend(struct omap_dss_device *dssdev)
67{ 100{
68 generic_panel_disable(dssdev); 101 generic_panel_power_off(dssdev);
102 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
69 return 0; 103 return 0;
70} 104}
71 105
72static int generic_panel_resume(struct omap_dss_device *dssdev) 106static int generic_panel_resume(struct omap_dss_device *dssdev)
73{ 107{
74 return generic_panel_enable(dssdev); 108 int r = 0;
109
110 r = generic_panel_power_on(dssdev);
111 if (r)
112 return r;
113
114 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
115
116 return 0;
75} 117}
76 118
77static struct omap_dss_driver generic_driver = { 119static struct omap_dss_driver generic_driver = {
diff --git a/drivers/video/omap2/displays/panel-sharp-lq043t1dg01.c b/drivers/video/omap2/displays/panel-sharp-lq043t1dg01.c
new file mode 100644
index 000000000000..10267461991c
--- /dev/null
+++ b/drivers/video/omap2/displays/panel-sharp-lq043t1dg01.c
@@ -0,0 +1,159 @@
1/*
2 * LCD panel driver for Sharp LQ043T1DG01
3 *
4 * Copyright (C) 2009 Texas Instruments Inc
5 * Author: Vaibhav Hiremath <hvaibhav@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <linux/module.h>
21#include <linux/delay.h>
22#include <linux/device.h>
23#include <linux/err.h>
24
25#include <plat/display.h>
26
27static struct omap_video_timings sharp_lq_timings = {
28 .x_res = 480,
29 .y_res = 272,
30
31 .pixel_clock = 9000,
32
33 .hsw = 42,
34 .hfp = 3,
35 .hbp = 2,
36
37 .vsw = 11,
38 .vfp = 3,
39 .vbp = 2,
40};
41
42static int sharp_lq_panel_power_on(struct omap_dss_device *dssdev)
43{
44 int r;
45
46 r = omapdss_dpi_display_enable(dssdev);
47 if (r)
48 goto err0;
49
50 /* wait couple of vsyncs until enabling the LCD */
51 msleep(50);
52
53 if (dssdev->platform_enable) {
54 r = dssdev->platform_enable(dssdev);
55 if (r)
56 goto err1;
57 }
58
59 return 0;
60err1:
61 omapdss_dpi_display_disable(dssdev);
62err0:
63 return r;
64}
65
66static void sharp_lq_panel_power_off(struct omap_dss_device *dssdev)
67{
68 if (dssdev->platform_disable)
69 dssdev->platform_disable(dssdev);
70
71 /* wait at least 5 vsyncs after disabling the LCD */
72 msleep(100);
73
74 omapdss_dpi_display_disable(dssdev);
75}
76
77static int sharp_lq_panel_probe(struct omap_dss_device *dssdev)
78{
79
80 dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
81 OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO;
82 dssdev->panel.acb = 0x0;
83 dssdev->panel.timings = sharp_lq_timings;
84
85 return 0;
86}
87
88static void sharp_lq_panel_remove(struct omap_dss_device *dssdev)
89{
90}
91
92static int sharp_lq_panel_enable(struct omap_dss_device *dssdev)
93{
94 int r = 0;
95
96 r = sharp_lq_panel_power_on(dssdev);
97 if (r)
98 return r;
99
100 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
101
102 return 0;
103}
104
105static void sharp_lq_panel_disable(struct omap_dss_device *dssdev)
106{
107 sharp_lq_panel_power_off(dssdev);
108
109 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
110}
111
112static int sharp_lq_panel_suspend(struct omap_dss_device *dssdev)
113{
114 sharp_lq_panel_power_off(dssdev);
115 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
116 return 0;
117}
118
119static int sharp_lq_panel_resume(struct omap_dss_device *dssdev)
120{
121 int r = 0;
122
123 r = sharp_lq_panel_power_on(dssdev);
124 if (r)
125 return r;
126
127 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
128
129 return 0;
130}
131
132static struct omap_dss_driver sharp_lq_driver = {
133 .probe = sharp_lq_panel_probe,
134 .remove = sharp_lq_panel_remove,
135
136 .enable = sharp_lq_panel_enable,
137 .disable = sharp_lq_panel_disable,
138 .suspend = sharp_lq_panel_suspend,
139 .resume = sharp_lq_panel_resume,
140
141 .driver = {
142 .name = "sharp_lq_panel",
143 .owner = THIS_MODULE,
144 },
145};
146
147static int __init sharp_lq_panel_drv_init(void)
148{
149 return omap_dss_register_driver(&sharp_lq_driver);
150}
151
152static void __exit sharp_lq_panel_drv_exit(void)
153{
154 omap_dss_unregister_driver(&sharp_lq_driver);
155}
156
157module_init(sharp_lq_panel_drv_init);
158module_exit(sharp_lq_panel_drv_exit);
159MODULE_LICENSE("GPL");
diff --git a/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c b/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c
index bbe880bbe795..8d51a5e6341c 100644
--- a/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c
+++ b/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c
@@ -20,19 +20,10 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/regulator/consumer.h>
24#include <linux/err.h> 23#include <linux/err.h>
25 24
26#include <plat/display.h> 25#include <plat/display.h>
27 26
28struct sharp_data {
29 /* XXX This regulator should actually be in SDP board file, not here,
30 * as it doesn't actually power the LCD, but something else that
31 * affects the output to LCD (I think. Somebody clarify). It doesn't do
32 * harm here, as SDP is the only board using this currently */
33 struct regulator *vdvi_reg;
34};
35
36static struct omap_video_timings sharp_ls_timings = { 27static struct omap_video_timings sharp_ls_timings = {
37 .x_res = 480, 28 .x_res = 480,
38 .y_res = 640, 29 .y_res = 640,
@@ -50,77 +41,81 @@ static struct omap_video_timings sharp_ls_timings = {
50 41
51static int sharp_ls_panel_probe(struct omap_dss_device *dssdev) 42static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
52{ 43{
53 struct sharp_data *sd;
54
55 dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS | 44 dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
56 OMAP_DSS_LCD_IHS; 45 OMAP_DSS_LCD_IHS;
57 dssdev->panel.acb = 0x28; 46 dssdev->panel.acb = 0x28;
58 dssdev->panel.timings = sharp_ls_timings; 47 dssdev->panel.timings = sharp_ls_timings;
59 48
60 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
61 if (!sd)
62 return -ENOMEM;
63
64 dev_set_drvdata(&dssdev->dev, sd);
65
66 sd->vdvi_reg = regulator_get(&dssdev->dev, "vdvi");
67 if (IS_ERR(sd->vdvi_reg)) {
68 kfree(sd);
69 pr_err("failed to get VDVI regulator\n");
70 return PTR_ERR(sd->vdvi_reg);
71 }
72
73 return 0; 49 return 0;
74} 50}
75 51
76static void sharp_ls_panel_remove(struct omap_dss_device *dssdev) 52static void sharp_ls_panel_remove(struct omap_dss_device *dssdev)
77{ 53{
78 struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);
79
80 regulator_put(sd->vdvi_reg);
81
82 kfree(sd);
83} 54}
84 55
85static int sharp_ls_panel_enable(struct omap_dss_device *dssdev) 56static int sharp_ls_power_on(struct omap_dss_device *dssdev)
86{ 57{
87 struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);
88 int r = 0; 58 int r = 0;
89 59
60 r = omapdss_dpi_display_enable(dssdev);
61 if (r)
62 goto err0;
63
90 /* wait couple of vsyncs until enabling the LCD */ 64 /* wait couple of vsyncs until enabling the LCD */
91 msleep(50); 65 msleep(50);
92 66
93 regulator_enable(sd->vdvi_reg); 67 if (dssdev->platform_enable) {
94
95 if (dssdev->platform_enable)
96 r = dssdev->platform_enable(dssdev); 68 r = dssdev->platform_enable(dssdev);
69 if (r)
70 goto err1;
71 }
97 72
73 return 0;
74err1:
75 omapdss_dpi_display_disable(dssdev);
76err0:
98 return r; 77 return r;
99} 78}
100 79
101static void sharp_ls_panel_disable(struct omap_dss_device *dssdev) 80static void sharp_ls_power_off(struct omap_dss_device *dssdev)
102{ 81{
103 struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);
104
105 if (dssdev->platform_disable) 82 if (dssdev->platform_disable)
106 dssdev->platform_disable(dssdev); 83 dssdev->platform_disable(dssdev);
107 84
108 regulator_disable(sd->vdvi_reg);
109
110 /* wait at least 5 vsyncs after disabling the LCD */ 85 /* wait at least 5 vsyncs after disabling the LCD */
111 86
112 msleep(100); 87 msleep(100);
88
89 omapdss_dpi_display_disable(dssdev);
90}
91
92static int sharp_ls_panel_enable(struct omap_dss_device *dssdev)
93{
94 int r;
95 r = sharp_ls_power_on(dssdev);
96 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
97 return r;
98}
99
100static void sharp_ls_panel_disable(struct omap_dss_device *dssdev)
101{
102 sharp_ls_power_off(dssdev);
103 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
113} 104}
114 105
115static int sharp_ls_panel_suspend(struct omap_dss_device *dssdev) 106static int sharp_ls_panel_suspend(struct omap_dss_device *dssdev)
116{ 107{
117 sharp_ls_panel_disable(dssdev); 108 sharp_ls_power_off(dssdev);
109 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
118 return 0; 110 return 0;
119} 111}
120 112
121static int sharp_ls_panel_resume(struct omap_dss_device *dssdev) 113static int sharp_ls_panel_resume(struct omap_dss_device *dssdev)
122{ 114{
123 return sharp_ls_panel_enable(dssdev); 115 int r;
116 r = sharp_ls_power_on(dssdev);
117 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
118 return r;
124} 119}
125 120
126static struct omap_dss_driver sharp_ls_driver = { 121static struct omap_dss_driver sharp_ls_driver = {
diff --git a/drivers/video/omap2/displays/panel-taal.c b/drivers/video/omap2/displays/panel-taal.c
index 1f01dfc5e52e..fcd6a61a91eb 100644
--- a/drivers/video/omap2/displays/panel-taal.c
+++ b/drivers/video/omap2/displays/panel-taal.c
@@ -63,6 +63,8 @@
63/* #define TAAL_USE_ESD_CHECK */ 63/* #define TAAL_USE_ESD_CHECK */
64#define TAAL_ESD_CHECK_PERIOD msecs_to_jiffies(5000) 64#define TAAL_ESD_CHECK_PERIOD msecs_to_jiffies(5000)
65 65
66static int _taal_enable_te(struct omap_dss_device *dssdev, bool enable);
67
66struct taal_data { 68struct taal_data {
67 struct backlight_device *bldev; 69 struct backlight_device *bldev;
68 70
@@ -510,15 +512,12 @@ static int taal_probe(struct omap_dss_device *dssdev)
510 if (td->esd_wq == NULL) { 512 if (td->esd_wq == NULL) {
511 dev_err(&dssdev->dev, "can't create ESD workqueue\n"); 513 dev_err(&dssdev->dev, "can't create ESD workqueue\n");
512 r = -ENOMEM; 514 r = -ENOMEM;
513 goto err2; 515 goto err1;
514 } 516 }
515 INIT_DELAYED_WORK_DEFERRABLE(&td->esd_work, taal_esd_work); 517 INIT_DELAYED_WORK_DEFERRABLE(&td->esd_work, taal_esd_work);
516 518
517 dev_set_drvdata(&dssdev->dev, td); 519 dev_set_drvdata(&dssdev->dev, td);
518 520
519 dssdev->get_timings = taal_get_timings;
520 dssdev->get_resolution = taal_get_resolution;
521
522 /* if no platform set_backlight() defined, presume DSI backlight 521 /* if no platform set_backlight() defined, presume DSI backlight
523 * control */ 522 * control */
524 if (!dssdev->set_backlight) 523 if (!dssdev->set_backlight)
@@ -528,7 +527,7 @@ static int taal_probe(struct omap_dss_device *dssdev)
528 &taal_bl_ops); 527 &taal_bl_ops);
529 if (IS_ERR(bldev)) { 528 if (IS_ERR(bldev)) {
530 r = PTR_ERR(bldev); 529 r = PTR_ERR(bldev);
531 goto err1; 530 goto err2;
532 } 531 }
533 532
534 td->bldev = bldev; 533 td->bldev = bldev;
@@ -621,14 +620,12 @@ static void taal_remove(struct omap_dss_device *dssdev)
621 kfree(td); 620 kfree(td);
622} 621}
623 622
624static int taal_enable(struct omap_dss_device *dssdev) 623static int taal_power_on(struct omap_dss_device *dssdev)
625{ 624{
626 struct taal_data *td = dev_get_drvdata(&dssdev->dev); 625 struct taal_data *td = dev_get_drvdata(&dssdev->dev);
627 u8 id1, id2, id3; 626 u8 id1, id2, id3;
628 int r; 627 int r;
629 628
630 dev_dbg(&dssdev->dev, "enable\n");
631
632 if (dssdev->platform_enable) { 629 if (dssdev->platform_enable) {
633 r = dssdev->platform_enable(dssdev); 630 r = dssdev->platform_enable(dssdev);
634 if (r) 631 if (r)
@@ -638,6 +635,16 @@ static int taal_enable(struct omap_dss_device *dssdev)
638 /* it seems we have to wait a bit until taal is ready */ 635 /* it seems we have to wait a bit until taal is ready */
639 msleep(5); 636 msleep(5);
640 637
638 dsi_bus_lock();
639
640 r = omapdss_dsi_display_enable(dssdev);
641 if (r) {
642 dev_err(&dssdev->dev, "failed to enable DSI\n");
643 goto err0;
644 }
645
646 omapdss_dsi_vc_enable_hs(TCH, false);
647
641 r = taal_sleep_out(td); 648 r = taal_sleep_out(td);
642 if (r) 649 if (r)
643 goto err; 650 goto err;
@@ -661,6 +668,10 @@ static int taal_enable(struct omap_dss_device *dssdev)
661 668
662 taal_dcs_write_0(DCS_DISPLAY_ON); 669 taal_dcs_write_0(DCS_DISPLAY_ON);
663 670
671 r = _taal_enable_te(dssdev, td->te_enabled);
672 if (r)
673 goto err;
674
664#ifdef TAAL_USE_ESD_CHECK 675#ifdef TAAL_USE_ESD_CHECK
665 queue_delayed_work(td->esd_wq, &td->esd_work, TAAL_ESD_CHECK_PERIOD); 676 queue_delayed_work(td->esd_wq, &td->esd_work, TAAL_ESD_CHECK_PERIOD);
666#endif 677#endif
@@ -676,19 +687,27 @@ static int taal_enable(struct omap_dss_device *dssdev)
676 td->intro_printed = true; 687 td->intro_printed = true;
677 } 688 }
678 689
690 omapdss_dsi_vc_enable_hs(TCH, true);
691
692 dsi_bus_unlock();
693
679 return 0; 694 return 0;
680err: 695err:
696 dsi_bus_unlock();
697
698 omapdss_dsi_display_disable(dssdev);
699err0:
681 if (dssdev->platform_disable) 700 if (dssdev->platform_disable)
682 dssdev->platform_disable(dssdev); 701 dssdev->platform_disable(dssdev);
683 702
684 return r; 703 return r;
685} 704}
686 705
687static void taal_disable(struct omap_dss_device *dssdev) 706static void taal_power_off(struct omap_dss_device *dssdev)
688{ 707{
689 struct taal_data *td = dev_get_drvdata(&dssdev->dev); 708 struct taal_data *td = dev_get_drvdata(&dssdev->dev);
690 709
691 dev_dbg(&dssdev->dev, "disable\n"); 710 dsi_bus_lock();
692 711
693 cancel_delayed_work(&td->esd_work); 712 cancel_delayed_work(&td->esd_work);
694 713
@@ -698,41 +717,124 @@ static void taal_disable(struct omap_dss_device *dssdev)
698 /* wait a bit so that the message goes through */ 717 /* wait a bit so that the message goes through */
699 msleep(10); 718 msleep(10);
700 719
720 omapdss_dsi_display_disable(dssdev);
721
701 if (dssdev->platform_disable) 722 if (dssdev->platform_disable)
702 dssdev->platform_disable(dssdev); 723 dssdev->platform_disable(dssdev);
703 724
704 td->enabled = 0; 725 td->enabled = 0;
726
727 dsi_bus_unlock();
728}
729
730static int taal_enable(struct omap_dss_device *dssdev)
731{
732 int r;
733 dev_dbg(&dssdev->dev, "enable\n");
734
735 if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED)
736 return -EINVAL;
737
738 r = taal_power_on(dssdev);
739 if (r)
740 return r;
741
742 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
743
744 return r;
745}
746
747static void taal_disable(struct omap_dss_device *dssdev)
748{
749 dev_dbg(&dssdev->dev, "disable\n");
750
751 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
752 taal_power_off(dssdev);
753
754 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
705} 755}
706 756
707static int taal_suspend(struct omap_dss_device *dssdev) 757static int taal_suspend(struct omap_dss_device *dssdev)
708{ 758{
709 struct taal_data *td = dev_get_drvdata(&dssdev->dev); 759 dev_dbg(&dssdev->dev, "suspend\n");
710 struct backlight_device *bldev = td->bldev;
711 760
712 bldev->props.power = FB_BLANK_POWERDOWN; 761 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
713 taal_bl_update_status(bldev); 762 return -EINVAL;
763
764 taal_power_off(dssdev);
765 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
714 766
715 return 0; 767 return 0;
716} 768}
717 769
718static int taal_resume(struct omap_dss_device *dssdev) 770static int taal_resume(struct omap_dss_device *dssdev)
719{ 771{
772 int r;
773 dev_dbg(&dssdev->dev, "resume\n");
774
775 if (dssdev->state != OMAP_DSS_DISPLAY_SUSPENDED)
776 return -EINVAL;
777
778 r = taal_power_on(dssdev);
779 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
780 return r;
781}
782
783static void taal_framedone_cb(int err, void *data)
784{
785 struct omap_dss_device *dssdev = data;
786 dev_dbg(&dssdev->dev, "framedone, err %d\n", err);
787 dsi_bus_unlock();
788}
789
790static int taal_update(struct omap_dss_device *dssdev,
791 u16 x, u16 y, u16 w, u16 h)
792{
720 struct taal_data *td = dev_get_drvdata(&dssdev->dev); 793 struct taal_data *td = dev_get_drvdata(&dssdev->dev);
721 struct backlight_device *bldev = td->bldev; 794 int r;
722 795
723 bldev->props.power = FB_BLANK_UNBLANK; 796 dev_dbg(&dssdev->dev, "update %d, %d, %d x %d\n", x, y, w, h);
724 taal_bl_update_status(bldev); 797
798 dsi_bus_lock();
799
800 if (!td->enabled) {
801 r = 0;
802 goto err;
803 }
804
805 r = omap_dsi_prepare_update(dssdev, &x, &y, &w, &h);
806 if (r)
807 goto err;
808
809 r = taal_set_update_window(x, y, w, h);
810 if (r)
811 goto err;
812
813 r = omap_dsi_update(dssdev, TCH, x, y, w, h,
814 taal_framedone_cb, dssdev);
815 if (r)
816 goto err;
725 817
818 /* note: no bus_unlock here. unlock is in framedone_cb */
726 return 0; 819 return 0;
820err:
821 dsi_bus_unlock();
822 return r;
727} 823}
728 824
729static void taal_setup_update(struct omap_dss_device *dssdev, 825static int taal_sync(struct omap_dss_device *dssdev)
730 u16 x, u16 y, u16 w, u16 h)
731{ 826{
732 taal_set_update_window(x, y, w, h); 827 dev_dbg(&dssdev->dev, "sync\n");
828
829 dsi_bus_lock();
830 dsi_bus_unlock();
831
832 dev_dbg(&dssdev->dev, "sync done\n");
833
834 return 0;
733} 835}
734 836
735static int taal_enable_te(struct omap_dss_device *dssdev, bool enable) 837static int _taal_enable_te(struct omap_dss_device *dssdev, bool enable)
736{ 838{
737 struct taal_data *td = dev_get_drvdata(&dssdev->dev); 839 struct taal_data *td = dev_get_drvdata(&dssdev->dev);
738 int r; 840 int r;
@@ -744,25 +846,32 @@ static int taal_enable_te(struct omap_dss_device *dssdev, bool enable)
744 else 846 else
745 r = taal_dcs_write_0(DCS_TEAR_OFF); 847 r = taal_dcs_write_0(DCS_TEAR_OFF);
746 848
849 omapdss_dsi_enable_te(dssdev, enable);
850
851 /* XXX for some reason, DSI TE breaks if we don't wait here.
852 * Panel bug? Needs more studying */
853 msleep(100);
854
747 return r; 855 return r;
748} 856}
749 857
750static int taal_wait_te(struct omap_dss_device *dssdev) 858static int taal_enable_te(struct omap_dss_device *dssdev, bool enable)
751{ 859{
752 struct taal_data *td = dev_get_drvdata(&dssdev->dev); 860 int r;
753 long wait = msecs_to_jiffies(500);
754 861
755 if (!td->use_ext_te || !td->te_enabled) 862 dsi_bus_lock();
756 return 0;
757 863
758 INIT_COMPLETION(td->te_completion); 864 r = _taal_enable_te(dssdev, enable);
759 wait = wait_for_completion_timeout(&td->te_completion, wait);
760 if (wait == 0) {
761 dev_err(&dssdev->dev, "timeout waiting TE\n");
762 return -ETIME;
763 }
764 865
765 return 0; 866 dsi_bus_unlock();
867
868 return r;
869}
870
871static int taal_get_te(struct omap_dss_device *dssdev)
872{
873 struct taal_data *td = dev_get_drvdata(&dssdev->dev);
874 return td->te_enabled;
766} 875}
767 876
768static int taal_rotate(struct omap_dss_device *dssdev, u8 rotate) 877static int taal_rotate(struct omap_dss_device *dssdev, u8 rotate)
@@ -772,16 +881,21 @@ static int taal_rotate(struct omap_dss_device *dssdev, u8 rotate)
772 881
773 dev_dbg(&dssdev->dev, "rotate %d\n", rotate); 882 dev_dbg(&dssdev->dev, "rotate %d\n", rotate);
774 883
884 dsi_bus_lock();
885
775 if (td->enabled) { 886 if (td->enabled) {
776 r = taal_set_addr_mode(rotate, td->mirror); 887 r = taal_set_addr_mode(rotate, td->mirror);
777
778 if (r) 888 if (r)
779 return r; 889 goto err;
780 } 890 }
781 891
782 td->rotate = rotate; 892 td->rotate = rotate;
783 893
894 dsi_bus_unlock();
784 return 0; 895 return 0;
896err:
897 dsi_bus_unlock();
898 return r;
785} 899}
786 900
787static u8 taal_get_rotate(struct omap_dss_device *dssdev) 901static u8 taal_get_rotate(struct omap_dss_device *dssdev)
@@ -797,16 +911,20 @@ static int taal_mirror(struct omap_dss_device *dssdev, bool enable)
797 911
798 dev_dbg(&dssdev->dev, "mirror %d\n", enable); 912 dev_dbg(&dssdev->dev, "mirror %d\n", enable);
799 913
914 dsi_bus_lock();
800 if (td->enabled) { 915 if (td->enabled) {
801 r = taal_set_addr_mode(td->rotate, enable); 916 r = taal_set_addr_mode(td->rotate, enable);
802
803 if (r) 917 if (r)
804 return r; 918 goto err;
805 } 919 }
806 920
807 td->mirror = enable; 921 td->mirror = enable;
808 922
923 dsi_bus_unlock();
809 return 0; 924 return 0;
925err:
926 dsi_bus_unlock();
927 return r;
810} 928}
811 929
812static bool taal_get_mirror(struct omap_dss_device *dssdev) 930static bool taal_get_mirror(struct omap_dss_device *dssdev)
@@ -820,17 +938,23 @@ static int taal_run_test(struct omap_dss_device *dssdev, int test_num)
820 u8 id1, id2, id3; 938 u8 id1, id2, id3;
821 int r; 939 int r;
822 940
941 dsi_bus_lock();
942
823 r = taal_dcs_read_1(DCS_GET_ID1, &id1); 943 r = taal_dcs_read_1(DCS_GET_ID1, &id1);
824 if (r) 944 if (r)
825 return r; 945 goto err;
826 r = taal_dcs_read_1(DCS_GET_ID2, &id2); 946 r = taal_dcs_read_1(DCS_GET_ID2, &id2);
827 if (r) 947 if (r)
828 return r; 948 goto err;
829 r = taal_dcs_read_1(DCS_GET_ID3, &id3); 949 r = taal_dcs_read_1(DCS_GET_ID3, &id3);
830 if (r) 950 if (r)
831 return r; 951 goto err;
832 952
953 dsi_bus_unlock();
833 return 0; 954 return 0;
955err:
956 dsi_bus_unlock();
957 return r;
834} 958}
835 959
836static int taal_memory_read(struct omap_dss_device *dssdev, 960static int taal_memory_read(struct omap_dss_device *dssdev,
@@ -841,6 +965,10 @@ static int taal_memory_read(struct omap_dss_device *dssdev,
841 int first = 1; 965 int first = 1;
842 int plen; 966 int plen;
843 unsigned buf_used = 0; 967 unsigned buf_used = 0;
968 struct taal_data *td = dev_get_drvdata(&dssdev->dev);
969
970 if (!td->enabled)
971 return -ENODEV;
844 972
845 if (size < w * h * 3) 973 if (size < w * h * 3)
846 return -ENOMEM; 974 return -ENOMEM;
@@ -849,6 +977,8 @@ static int taal_memory_read(struct omap_dss_device *dssdev,
849 dssdev->panel.timings.x_res * 977 dssdev->panel.timings.x_res *
850 dssdev->panel.timings.y_res * 3); 978 dssdev->panel.timings.y_res * 3);
851 979
980 dsi_bus_lock();
981
852 /* plen 1 or 2 goes into short packet. until checksum error is fixed, 982 /* plen 1 or 2 goes into short packet. until checksum error is fixed,
853 * use short packets. plen 32 works, but bigger packets seem to cause 983 * use short packets. plen 32 works, but bigger packets seem to cause
854 * an error. */ 984 * an error. */
@@ -857,11 +987,11 @@ static int taal_memory_read(struct omap_dss_device *dssdev,
857 else 987 else
858 plen = 2; 988 plen = 2;
859 989
860 taal_setup_update(dssdev, x, y, w, h); 990 taal_set_update_window(x, y, w, h);
861 991
862 r = dsi_vc_set_max_rx_packet_size(TCH, plen); 992 r = dsi_vc_set_max_rx_packet_size(TCH, plen);
863 if (r) 993 if (r)
864 return r; 994 goto err0;
865 995
866 while (buf_used < size) { 996 while (buf_used < size) {
867 u8 dcs_cmd = first ? 0x2e : 0x3e; 997 u8 dcs_cmd = first ? 0x2e : 0x3e;
@@ -894,7 +1024,8 @@ static int taal_memory_read(struct omap_dss_device *dssdev,
894 1024
895err: 1025err:
896 dsi_vc_set_max_rx_packet_size(TCH, 1); 1026 dsi_vc_set_max_rx_packet_size(TCH, 1);
897 1027err0:
1028 dsi_bus_unlock();
898 return r; 1029 return r;
899} 1030}
900 1031
@@ -939,8 +1070,11 @@ static void taal_esd_work(struct work_struct *work)
939 } 1070 }
940 /* Self-diagnostics result is also shown on TE GPIO line. We need 1071 /* Self-diagnostics result is also shown on TE GPIO line. We need
941 * to re-enable TE after self diagnostics */ 1072 * to re-enable TE after self diagnostics */
942 if (td->use_ext_te && td->te_enabled) 1073 if (td->use_ext_te && td->te_enabled) {
943 taal_enable_te(dssdev, true); 1074 r = taal_dcs_write_1(DCS_TEAR_ON, 0);
1075 if (r)
1076 goto err;
1077 }
944 1078
945 dsi_bus_unlock(); 1079 dsi_bus_unlock();
946 1080
@@ -958,6 +1092,20 @@ err:
958 queue_delayed_work(td->esd_wq, &td->esd_work, TAAL_ESD_CHECK_PERIOD); 1092 queue_delayed_work(td->esd_wq, &td->esd_work, TAAL_ESD_CHECK_PERIOD);
959} 1093}
960 1094
1095static int taal_set_update_mode(struct omap_dss_device *dssdev,
1096 enum omap_dss_update_mode mode)
1097{
1098 if (mode != OMAP_DSS_UPDATE_MANUAL)
1099 return -EINVAL;
1100 return 0;
1101}
1102
1103static enum omap_dss_update_mode taal_get_update_mode(
1104 struct omap_dss_device *dssdev)
1105{
1106 return OMAP_DSS_UPDATE_MANUAL;
1107}
1108
961static struct omap_dss_driver taal_driver = { 1109static struct omap_dss_driver taal_driver = {
962 .probe = taal_probe, 1110 .probe = taal_probe,
963 .remove = taal_remove, 1111 .remove = taal_remove,
@@ -967,9 +1115,18 @@ static struct omap_dss_driver taal_driver = {
967 .suspend = taal_suspend, 1115 .suspend = taal_suspend,
968 .resume = taal_resume, 1116 .resume = taal_resume,
969 1117
970 .setup_update = taal_setup_update, 1118 .set_update_mode = taal_set_update_mode,
1119 .get_update_mode = taal_get_update_mode,
1120
1121 .update = taal_update,
1122 .sync = taal_sync,
1123
1124 .get_resolution = taal_get_resolution,
1125 .get_recommended_bpp = omapdss_default_get_recommended_bpp,
1126
971 .enable_te = taal_enable_te, 1127 .enable_te = taal_enable_te,
972 .wait_for_te = taal_wait_te, 1128 .get_te = taal_get_te,
1129
973 .set_rotate = taal_rotate, 1130 .set_rotate = taal_rotate,
974 .get_rotate = taal_get_rotate, 1131 .get_rotate = taal_get_rotate,
975 .set_mirror = taal_mirror, 1132 .set_mirror = taal_mirror,
@@ -977,6 +1134,8 @@ static struct omap_dss_driver taal_driver = {
977 .run_test = taal_run_test, 1134 .run_test = taal_run_test,
978 .memory_read = taal_memory_read, 1135 .memory_read = taal_memory_read,
979 1136
1137 .get_timings = taal_get_timings,
1138
980 .driver = { 1139 .driver = {
981 .name = "taal", 1140 .name = "taal",
982 .owner = THIS_MODULE, 1141 .owner = THIS_MODULE,
diff --git a/drivers/video/omap2/displays/panel-toppoly-tdo35s.c b/drivers/video/omap2/displays/panel-toppoly-tdo35s.c
new file mode 100644
index 000000000000..fa434ca6e4b7
--- /dev/null
+++ b/drivers/video/omap2/displays/panel-toppoly-tdo35s.c
@@ -0,0 +1,154 @@
1/*
2 * LCD panel driver for Toppoly TDO35S
3 *
4 * Copyright (C) 2009 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
6 *
7 * Based on generic panel support
8 * Copyright (C) 2008 Nokia Corporation
9 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published by
13 * the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#include <linux/module.h>
25#include <linux/delay.h>
26
27#include <plat/display.h>
28
29static struct omap_video_timings toppoly_tdo_panel_timings = {
30 /* 640 x 480 @ 60 Hz Reduced blanking VESA CVT 0.31M3-R */
31 .x_res = 480,
32 .y_res = 640,
33
34 .pixel_clock = 26000,
35
36 .hfp = 104,
37 .hsw = 8,
38 .hbp = 8,
39
40 .vfp = 4,
41 .vsw = 2,
42 .vbp = 2,
43};
44
45static int toppoly_tdo_panel_power_on(struct omap_dss_device *dssdev)
46{
47 int r;
48
49 r = omapdss_dpi_display_enable(dssdev);
50 if (r)
51 goto err0;
52
53 if (dssdev->platform_enable) {
54 r = dssdev->platform_enable(dssdev);
55 if (r)
56 goto err1;
57 }
58
59 return 0;
60err1:
61 omapdss_dpi_display_disable(dssdev);
62err0:
63 return r;
64}
65
66static void toppoly_tdo_panel_power_off(struct omap_dss_device *dssdev)
67{
68 if (dssdev->platform_disable)
69 dssdev->platform_disable(dssdev);
70
71 omapdss_dpi_display_disable(dssdev);
72}
73
74static int toppoly_tdo_panel_probe(struct omap_dss_device *dssdev)
75{
76 dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
77 OMAP_DSS_LCD_IHS;
78 dssdev->panel.timings = toppoly_tdo_panel_timings;
79
80 return 0;
81}
82
83static void toppoly_tdo_panel_remove(struct omap_dss_device *dssdev)
84{
85}
86
87static int toppoly_tdo_panel_enable(struct omap_dss_device *dssdev)
88{
89 int r = 0;
90
91 r = toppoly_tdo_panel_power_on(dssdev);
92 if (r)
93 return r;
94
95 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
96
97 return 0;
98}
99
100static void toppoly_tdo_panel_disable(struct omap_dss_device *dssdev)
101{
102 toppoly_tdo_panel_power_off(dssdev);
103
104 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
105}
106
107static int toppoly_tdo_panel_suspend(struct omap_dss_device *dssdev)
108{
109 toppoly_tdo_panel_power_off(dssdev);
110 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
111 return 0;
112}
113
114static int toppoly_tdo_panel_resume(struct omap_dss_device *dssdev)
115{
116 int r = 0;
117
118 r = toppoly_tdo_panel_power_on(dssdev);
119 if (r)
120 return r;
121
122 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
123
124 return 0;
125}
126
127static struct omap_dss_driver generic_driver = {
128 .probe = toppoly_tdo_panel_probe,
129 .remove = toppoly_tdo_panel_remove,
130
131 .enable = toppoly_tdo_panel_enable,
132 .disable = toppoly_tdo_panel_disable,
133 .suspend = toppoly_tdo_panel_suspend,
134 .resume = toppoly_tdo_panel_resume,
135
136 .driver = {
137 .name = "toppoly_tdo35s_panel",
138 .owner = THIS_MODULE,
139 },
140};
141
142static int __init toppoly_tdo_panel_drv_init(void)
143{
144 return omap_dss_register_driver(&generic_driver);
145}
146
147static void __exit toppoly_tdo_panel_drv_exit(void)
148{
149 omap_dss_unregister_driver(&generic_driver);
150}
151
152module_init(toppoly_tdo_panel_drv_init);
153module_exit(toppoly_tdo_panel_drv_exit);
154MODULE_LICENSE("GPL");
diff --git a/drivers/video/omap2/displays/panel-tpo-td043mtea1.c b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
new file mode 100644
index 000000000000..d578feee3550
--- /dev/null
+++ b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
@@ -0,0 +1,528 @@
1/*
2 * LCD panel driver for TPO TD043MTEA1
3 *
4 * Author: Gražvydas Ignotas <notasas@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License 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/module.h>
13#include <linux/delay.h>
14#include <linux/spi/spi.h>
15#include <linux/regulator/consumer.h>
16#include <linux/gpio.h>
17#include <linux/err.h>
18
19#include <plat/display.h>
20
21#define TPO_R02_MODE(x) ((x) & 7)
22#define TPO_R02_MODE_800x480 7
23#define TPO_R02_NCLK_RISING BIT(3)
24#define TPO_R02_HSYNC_HIGH BIT(4)
25#define TPO_R02_VSYNC_HIGH BIT(5)
26
27#define TPO_R03_NSTANDBY BIT(0)
28#define TPO_R03_EN_CP_CLK BIT(1)
29#define TPO_R03_EN_VGL_PUMP BIT(2)
30#define TPO_R03_EN_PWM BIT(3)
31#define TPO_R03_DRIVING_CAP_100 BIT(4)
32#define TPO_R03_EN_PRE_CHARGE BIT(6)
33#define TPO_R03_SOFTWARE_CTL BIT(7)
34
35#define TPO_R04_NFLIP_H BIT(0)
36#define TPO_R04_NFLIP_V BIT(1)
37#define TPO_R04_CP_CLK_FREQ_1H BIT(2)
38#define TPO_R04_VGL_FREQ_1H BIT(4)
39
40#define TPO_R03_VAL_NORMAL (TPO_R03_NSTANDBY | TPO_R03_EN_CP_CLK | \
41 TPO_R03_EN_VGL_PUMP | TPO_R03_EN_PWM | \
42 TPO_R03_DRIVING_CAP_100 | TPO_R03_EN_PRE_CHARGE | \
43 TPO_R03_SOFTWARE_CTL)
44
45#define TPO_R03_VAL_STANDBY (TPO_R03_DRIVING_CAP_100 | \
46 TPO_R03_EN_PRE_CHARGE | TPO_R03_SOFTWARE_CTL)
47
48static const u16 tpo_td043_def_gamma[12] = {
49 106, 200, 289, 375, 460, 543, 625, 705, 785, 864, 942, 1020
50};
51
52struct tpo_td043_device {
53 struct spi_device *spi;
54 struct regulator *vcc_reg;
55 u16 gamma[12];
56 u32 mode;
57 u32 hmirror:1;
58 u32 vmirror:1;
59};
60
61static int tpo_td043_write(struct spi_device *spi, u8 addr, u8 data)
62{
63 struct spi_message m;
64 struct spi_transfer xfer;
65 u16 w;
66 int r;
67
68 spi_message_init(&m);
69
70 memset(&xfer, 0, sizeof(xfer));
71
72 w = ((u16)addr << 10) | (1 << 8) | data;
73 xfer.tx_buf = &w;
74 xfer.bits_per_word = 16;
75 xfer.len = 2;
76 spi_message_add_tail(&xfer, &m);
77
78 r = spi_sync(spi, &m);
79 if (r < 0)
80 dev_warn(&spi->dev, "failed to write to LCD reg (%d)\n", r);
81 return r;
82}
83
84static void tpo_td043_write_gamma(struct spi_device *spi, u16 gamma[12])
85{
86 u8 i, val;
87
88 /* gamma bits [9:8] */
89 for (val = i = 0; i < 4; i++)
90 val |= (gamma[i] & 0x300) >> ((i + 1) * 2);
91 tpo_td043_write(spi, 0x11, val);
92
93 for (val = i = 0; i < 4; i++)
94 val |= (gamma[i+4] & 0x300) >> ((i + 1) * 2);
95 tpo_td043_write(spi, 0x12, val);
96
97 for (val = i = 0; i < 4; i++)
98 val |= (gamma[i+8] & 0x300) >> ((i + 1) * 2);
99 tpo_td043_write(spi, 0x13, val);
100
101 /* gamma bits [7:0] */
102 for (val = i = 0; i < 12; i++)
103 tpo_td043_write(spi, 0x14 + i, gamma[i] & 0xff);
104}
105
106static int tpo_td043_write_mirror(struct spi_device *spi, bool h, bool v)
107{
108 u8 reg4 = TPO_R04_NFLIP_H | TPO_R04_NFLIP_V | \
109 TPO_R04_CP_CLK_FREQ_1H | TPO_R04_VGL_FREQ_1H;
110 if (h)
111 reg4 &= ~TPO_R04_NFLIP_H;
112 if (v)
113 reg4 &= ~TPO_R04_NFLIP_V;
114
115 return tpo_td043_write(spi, 4, reg4);
116}
117
118static int tpo_td043_set_hmirror(struct omap_dss_device *dssdev, bool enable)
119{
120 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
121
122 tpo_td043->hmirror = enable;
123 return tpo_td043_write_mirror(tpo_td043->spi, tpo_td043->hmirror,
124 tpo_td043->vmirror);
125}
126
127static bool tpo_td043_get_hmirror(struct omap_dss_device *dssdev)
128{
129 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
130
131 return tpo_td043->hmirror;
132}
133
134static ssize_t tpo_td043_vmirror_show(struct device *dev,
135 struct device_attribute *attr, char *buf)
136{
137 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
138
139 return snprintf(buf, PAGE_SIZE, "%d\n", tpo_td043->vmirror);
140}
141
142static ssize_t tpo_td043_vmirror_store(struct device *dev,
143 struct device_attribute *attr, const char *buf, size_t count)
144{
145 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
146 long val;
147 int ret;
148
149 ret = strict_strtol(buf, 0, &val);
150 if (ret < 0)
151 return ret;
152
153 ret = tpo_td043_write_mirror(tpo_td043->spi, tpo_td043->hmirror, val);
154 if (ret < 0)
155 return ret;
156
157 tpo_td043->vmirror = val;
158
159 return count;
160}
161
162static ssize_t tpo_td043_mode_show(struct device *dev,
163 struct device_attribute *attr, char *buf)
164{
165 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
166
167 return snprintf(buf, PAGE_SIZE, "%d\n", tpo_td043->mode);
168}
169
170static ssize_t tpo_td043_mode_store(struct device *dev,
171 struct device_attribute *attr, const char *buf, size_t count)
172{
173 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
174 long val;
175 int ret;
176
177 ret = strict_strtol(buf, 0, &val);
178 if (ret != 0 || val & ~7)
179 return -EINVAL;
180
181 tpo_td043->mode = val;
182
183 val |= TPO_R02_NCLK_RISING;
184 tpo_td043_write(tpo_td043->spi, 2, val);
185
186 return count;
187}
188
189static ssize_t tpo_td043_gamma_show(struct device *dev,
190 struct device_attribute *attr, char *buf)
191{
192 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
193 ssize_t len = 0;
194 int ret;
195 int i;
196
197 for (i = 0; i < ARRAY_SIZE(tpo_td043->gamma); i++) {
198 ret = snprintf(buf + len, PAGE_SIZE - len, "%u ",
199 tpo_td043->gamma[i]);
200 if (ret < 0)
201 return ret;
202 len += ret;
203 }
204 buf[len - 1] = '\n';
205
206 return len;
207}
208
209static ssize_t tpo_td043_gamma_store(struct device *dev,
210 struct device_attribute *attr, const char *buf, size_t count)
211{
212 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
213 unsigned int g[12];
214 int ret;
215 int i;
216
217 ret = sscanf(buf, "%u %u %u %u %u %u %u %u %u %u %u %u",
218 &g[0], &g[1], &g[2], &g[3], &g[4], &g[5],
219 &g[6], &g[7], &g[8], &g[9], &g[10], &g[11]);
220
221 if (ret != 12)
222 return -EINVAL;
223
224 for (i = 0; i < 12; i++)
225 tpo_td043->gamma[i] = g[i];
226
227 tpo_td043_write_gamma(tpo_td043->spi, tpo_td043->gamma);
228
229 return count;
230}
231
232static DEVICE_ATTR(vmirror, S_IRUGO | S_IWUSR,
233 tpo_td043_vmirror_show, tpo_td043_vmirror_store);
234static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
235 tpo_td043_mode_show, tpo_td043_mode_store);
236static DEVICE_ATTR(gamma, S_IRUGO | S_IWUSR,
237 tpo_td043_gamma_show, tpo_td043_gamma_store);
238
239static struct attribute *tpo_td043_attrs[] = {
240 &dev_attr_vmirror.attr,
241 &dev_attr_mode.attr,
242 &dev_attr_gamma.attr,
243 NULL,
244};
245
246static struct attribute_group tpo_td043_attr_group = {
247 .attrs = tpo_td043_attrs,
248};
249
250static const struct omap_video_timings tpo_td043_timings = {
251 .x_res = 800,
252 .y_res = 480,
253
254 .pixel_clock = 36000,
255
256 .hsw = 1,
257 .hfp = 68,
258 .hbp = 214,
259
260 .vsw = 1,
261 .vfp = 39,
262 .vbp = 34,
263};
264
265static int tpo_td043_power_on(struct omap_dss_device *dssdev)
266{
267 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
268 int nreset_gpio = dssdev->reset_gpio;
269 int r;
270
271 r = omapdss_dpi_display_enable(dssdev);
272 if (r)
273 goto err0;
274
275 if (dssdev->platform_enable) {
276 r = dssdev->platform_enable(dssdev);
277 if (r)
278 goto err1;
279 }
280
281 regulator_enable(tpo_td043->vcc_reg);
282
283 /* wait for power up */
284 msleep(160);
285
286 if (gpio_is_valid(nreset_gpio))
287 gpio_set_value(nreset_gpio, 1);
288
289 tpo_td043_write(tpo_td043->spi, 2,
290 TPO_R02_MODE(tpo_td043->mode) | TPO_R02_NCLK_RISING);
291 tpo_td043_write(tpo_td043->spi, 3, TPO_R03_VAL_NORMAL);
292 tpo_td043_write(tpo_td043->spi, 0x20, 0xf0);
293 tpo_td043_write(tpo_td043->spi, 0x21, 0xf0);
294 tpo_td043_write_mirror(tpo_td043->spi, tpo_td043->hmirror,
295 tpo_td043->vmirror);
296 tpo_td043_write_gamma(tpo_td043->spi, tpo_td043->gamma);
297
298 return 0;
299err1:
300 omapdss_dpi_display_disable(dssdev);
301err0:
302 return r;
303}
304
305static void tpo_td043_power_off(struct omap_dss_device *dssdev)
306{
307 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
308 int nreset_gpio = dssdev->reset_gpio;
309
310 tpo_td043_write(tpo_td043->spi, 3,
311 TPO_R03_VAL_STANDBY | TPO_R03_EN_PWM);
312
313 if (gpio_is_valid(nreset_gpio))
314 gpio_set_value(nreset_gpio, 0);
315
316 /* wait for at least 2 vsyncs before cutting off power */
317 msleep(50);
318
319 tpo_td043_write(tpo_td043->spi, 3, TPO_R03_VAL_STANDBY);
320
321 regulator_disable(tpo_td043->vcc_reg);
322
323 if (dssdev->platform_disable)
324 dssdev->platform_disable(dssdev);
325
326 omapdss_dpi_display_disable(dssdev);
327}
328
329static int tpo_td043_enable(struct omap_dss_device *dssdev)
330{
331 int ret;
332
333 dev_dbg(&dssdev->dev, "enable\n");
334
335 ret = tpo_td043_power_on(dssdev);
336 if (ret)
337 return ret;
338
339 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
340
341 return 0;
342}
343
344static void tpo_td043_disable(struct omap_dss_device *dssdev)
345{
346 dev_dbg(&dssdev->dev, "disable\n");
347
348 tpo_td043_power_off(dssdev);
349
350 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
351}
352
353static int tpo_td043_suspend(struct omap_dss_device *dssdev)
354{
355 tpo_td043_power_off(dssdev);
356 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
357 return 0;
358}
359
360static int tpo_td043_resume(struct omap_dss_device *dssdev)
361{
362 int r = 0;
363
364 r = tpo_td043_power_on(dssdev);
365 if (r)
366 return r;
367
368 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
369
370 return 0;
371}
372
373static int tpo_td043_probe(struct omap_dss_device *dssdev)
374{
375 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
376 int nreset_gpio = dssdev->reset_gpio;
377 int ret = 0;
378
379 dev_dbg(&dssdev->dev, "probe\n");
380
381 if (tpo_td043 == NULL) {
382 dev_err(&dssdev->dev, "missing tpo_td043_device\n");
383 return -ENODEV;
384 }
385
386 dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IHS |
387 OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IPC;
388 dssdev->panel.timings = tpo_td043_timings;
389 dssdev->ctrl.pixel_size = 24;
390
391 tpo_td043->mode = TPO_R02_MODE_800x480;
392 memcpy(tpo_td043->gamma, tpo_td043_def_gamma, sizeof(tpo_td043->gamma));
393
394 tpo_td043->vcc_reg = regulator_get(&dssdev->dev, "vcc");
395 if (IS_ERR(tpo_td043->vcc_reg)) {
396 dev_err(&dssdev->dev, "failed to get LCD VCC regulator\n");
397 ret = PTR_ERR(tpo_td043->vcc_reg);
398 goto fail_regulator;
399 }
400
401 if (gpio_is_valid(nreset_gpio)) {
402 ret = gpio_request(nreset_gpio, "lcd reset");
403 if (ret < 0) {
404 dev_err(&dssdev->dev, "couldn't request reset GPIO\n");
405 goto fail_gpio_req;
406 }
407
408 ret = gpio_direction_output(nreset_gpio, 0);
409 if (ret < 0) {
410 dev_err(&dssdev->dev, "couldn't set GPIO direction\n");
411 goto fail_gpio_direction;
412 }
413 }
414
415 ret = sysfs_create_group(&dssdev->dev.kobj, &tpo_td043_attr_group);
416 if (ret)
417 dev_warn(&dssdev->dev, "failed to create sysfs files\n");
418
419 return 0;
420
421fail_gpio_direction:
422 gpio_free(nreset_gpio);
423fail_gpio_req:
424 regulator_put(tpo_td043->vcc_reg);
425fail_regulator:
426 kfree(tpo_td043);
427 return ret;
428}
429
430static void tpo_td043_remove(struct omap_dss_device *dssdev)
431{
432 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
433 int nreset_gpio = dssdev->reset_gpio;
434
435 dev_dbg(&dssdev->dev, "remove\n");
436
437 sysfs_remove_group(&dssdev->dev.kobj, &tpo_td043_attr_group);
438 regulator_put(tpo_td043->vcc_reg);
439 if (gpio_is_valid(nreset_gpio))
440 gpio_free(nreset_gpio);
441}
442
443static struct omap_dss_driver tpo_td043_driver = {
444 .probe = tpo_td043_probe,
445 .remove = tpo_td043_remove,
446
447 .enable = tpo_td043_enable,
448 .disable = tpo_td043_disable,
449 .suspend = tpo_td043_suspend,
450 .resume = tpo_td043_resume,
451 .set_mirror = tpo_td043_set_hmirror,
452 .get_mirror = tpo_td043_get_hmirror,
453
454 .driver = {
455 .name = "tpo_td043mtea1_panel",
456 .owner = THIS_MODULE,
457 },
458};
459
460static int tpo_td043_spi_probe(struct spi_device *spi)
461{
462 struct omap_dss_device *dssdev = spi->dev.platform_data;
463 struct tpo_td043_device *tpo_td043;
464 int ret;
465
466 if (dssdev == NULL) {
467 dev_err(&spi->dev, "missing dssdev\n");
468 return -ENODEV;
469 }
470
471 spi->bits_per_word = 16;
472 spi->mode = SPI_MODE_0;
473
474 ret = spi_setup(spi);
475 if (ret < 0) {
476 dev_err(&spi->dev, "spi_setup failed: %d\n", ret);
477 return ret;
478 }
479
480 tpo_td043 = kzalloc(sizeof(*tpo_td043), GFP_KERNEL);
481 if (tpo_td043 == NULL)
482 return -ENOMEM;
483
484 tpo_td043->spi = spi;
485 dev_set_drvdata(&spi->dev, tpo_td043);
486 dev_set_drvdata(&dssdev->dev, tpo_td043);
487
488 omap_dss_register_driver(&tpo_td043_driver);
489
490 return 0;
491}
492
493static int __devexit tpo_td043_spi_remove(struct spi_device *spi)
494{
495 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&spi->dev);
496
497 omap_dss_unregister_driver(&tpo_td043_driver);
498 kfree(tpo_td043);
499
500 return 0;
501}
502
503static struct spi_driver tpo_td043_spi_driver = {
504 .driver = {
505 .name = "tpo_td043mtea1_panel_spi",
506 .bus = &spi_bus_type,
507 .owner = THIS_MODULE,
508 },
509 .probe = tpo_td043_spi_probe,
510 .remove = __devexit_p(tpo_td043_spi_remove),
511};
512
513static int __init tpo_td043_init(void)
514{
515 return spi_register_driver(&tpo_td043_spi_driver);
516}
517
518static void __exit tpo_td043_exit(void)
519{
520 spi_unregister_driver(&tpo_td043_spi_driver);
521}
522
523module_init(tpo_td043_init);
524module_exit(tpo_td043_exit);
525
526MODULE_AUTHOR("Gražvydas Ignotas <notasas@gmail.com>");
527MODULE_DESCRIPTION("TPO TD043MTEA1 LCD Driver");
528MODULE_LICENSE("GPL");
diff --git a/drivers/video/omap2/dss/Kconfig b/drivers/video/omap2/dss/Kconfig
index c63ce767b277..87afb81b2c44 100644
--- a/drivers/video/omap2/dss/Kconfig
+++ b/drivers/video/omap2/dss/Kconfig
@@ -30,19 +30,29 @@ config OMAP2_DSS_COLLECT_IRQ_STATS
30 depends on OMAP2_DSS_DEBUG_SUPPORT 30 depends on OMAP2_DSS_DEBUG_SUPPORT
31 default n 31 default n
32 help 32 help
33 Collect DSS IRQ statistics, printable via debugfs 33 Collect DSS IRQ statistics, printable via debugfs.
34
35 The statistics can be found from
36 <debugfs>/omapdss/dispc_irq for DISPC interrupts, and
37 <debugfs>/omapdss/dsi_irq for DSI interrupts.
34 38
35config OMAP2_DSS_RFBI 39config OMAP2_DSS_RFBI
36 bool "RFBI support" 40 bool "RFBI support"
37 default n 41 default n
38 help 42 help
39 MIPI DBI, or RFBI (Remote Framebuffer Interface), support. 43 MIPI DBI support (RFBI, Remote Framebuffer Interface, in Texas
44 Instrument's terminology).
45
46 DBI is a bus between the host processor and a peripheral,
47 such as a display or a framebuffer chip.
48
49 See http://www.mipi.org/ for DBI spesifications.
40 50
41config OMAP2_DSS_VENC 51config OMAP2_DSS_VENC
42 bool "VENC support" 52 bool "VENC support"
43 default y 53 default y
44 help 54 help
45 OMAP Video Encoder support. 55 OMAP Video Encoder support for S-Video and composite TV-out.
46 56
47config OMAP2_DSS_SDI 57config OMAP2_DSS_SDI
48 bool "SDI support" 58 bool "SDI support"
@@ -51,12 +61,20 @@ config OMAP2_DSS_SDI
51 help 61 help
52 SDI (Serial Display Interface) support. 62 SDI (Serial Display Interface) support.
53 63
64 SDI is a high speed one-way display serial bus between the host
65 processor and a display.
66
54config OMAP2_DSS_DSI 67config OMAP2_DSS_DSI
55 bool "DSI support" 68 bool "DSI support"
56 depends on ARCH_OMAP3 69 depends on ARCH_OMAP3
57 default n 70 default n
58 help 71 help
59 MIPI DSI support. 72 MIPI DSI (Display Serial Interface) support.
73
74 DSI is a high speed half-duplex serial interface between the host
75 processor and a peripheral, such as a display or a framebuffer chip.
76
77 See http://www.mipi.org/ for DSI spesifications.
60 78
61config OMAP2_DSS_USE_DSI_PLL 79config OMAP2_DSS_USE_DSI_PLL
62 bool "Use DSI PLL for PCLK (EXPERIMENTAL)" 80 bool "Use DSI PLL for PCLK (EXPERIMENTAL)"
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 82918eec6d2e..7ebe50b335ed 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -31,6 +31,7 @@
31#include <linux/debugfs.h> 31#include <linux/debugfs.h>
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/device.h> 33#include <linux/device.h>
34#include <linux/regulator/consumer.h>
34 35
35#include <plat/display.h> 36#include <plat/display.h>
36#include <plat/clock.h> 37#include <plat/clock.h>
@@ -47,6 +48,10 @@ static struct {
47 struct clk *dss_54m_fck; 48 struct clk *dss_54m_fck;
48 struct clk *dss_96m_fck; 49 struct clk *dss_96m_fck;
49 unsigned num_clks_enabled; 50 unsigned num_clks_enabled;
51
52 struct regulator *vdds_dsi_reg;
53 struct regulator *vdds_sdi_reg;
54 struct regulator *vdda_dac_reg;
50} core; 55} core;
51 56
52static void dss_clk_enable_all_no_ctx(void); 57static void dss_clk_enable_all_no_ctx(void);
@@ -284,9 +289,11 @@ static void dss_clk_enable_no_ctx(enum dss_clock clks)
284 289
285void dss_clk_enable(enum dss_clock clks) 290void dss_clk_enable(enum dss_clock clks)
286{ 291{
292 bool check_ctx = core.num_clks_enabled == 0;
293
287 dss_clk_enable_no_ctx(clks); 294 dss_clk_enable_no_ctx(clks);
288 295
289 if (cpu_is_omap34xx() && dss_need_ctx_restore()) 296 if (check_ctx && cpu_is_omap34xx() && dss_need_ctx_restore())
290 restore_all_ctx(); 297 restore_all_ctx();
291} 298}
292 299
@@ -352,6 +359,50 @@ static void dss_clk_disable_all(void)
352 dss_clk_disable(clks); 359 dss_clk_disable(clks);
353} 360}
354 361
362/* REGULATORS */
363
364struct regulator *dss_get_vdds_dsi(void)
365{
366 struct regulator *reg;
367
368 if (core.vdds_dsi_reg != NULL)
369 return core.vdds_dsi_reg;
370
371 reg = regulator_get(&core.pdev->dev, "vdds_dsi");
372 if (!IS_ERR(reg))
373 core.vdds_dsi_reg = reg;
374
375 return reg;
376}
377
378struct regulator *dss_get_vdds_sdi(void)
379{
380 struct regulator *reg;
381
382 if (core.vdds_sdi_reg != NULL)
383 return core.vdds_sdi_reg;
384
385 reg = regulator_get(&core.pdev->dev, "vdds_sdi");
386 if (!IS_ERR(reg))
387 core.vdds_sdi_reg = reg;
388
389 return reg;
390}
391
392struct regulator *dss_get_vdda_dac(void)
393{
394 struct regulator *reg;
395
396 if (core.vdda_dac_reg != NULL)
397 return core.vdda_dac_reg;
398
399 reg = regulator_get(&core.pdev->dev, "vdda_dac");
400 if (!IS_ERR(reg))
401 core.vdda_dac_reg = reg;
402
403 return reg;
404}
405
355/* DEBUGFS */ 406/* DEBUGFS */
356#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_OMAP2_DSS_DEBUG_SUPPORT) 407#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_OMAP2_DSS_DEBUG_SUPPORT)
357static void dss_debug_dump_clocks(struct seq_file *s) 408static void dss_debug_dump_clocks(struct seq_file *s)
@@ -397,10 +448,12 @@ static int dss_initialize_debugfs(void)
397 debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir, 448 debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir,
398 &dss_debug_dump_clocks, &dss_debug_fops); 449 &dss_debug_dump_clocks, &dss_debug_fops);
399 450
451#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
400 debugfs_create_file("dispc_irq", S_IRUGO, dss_debugfs_dir, 452 debugfs_create_file("dispc_irq", S_IRUGO, dss_debugfs_dir,
401 &dispc_dump_irqs, &dss_debug_fops); 453 &dispc_dump_irqs, &dss_debug_fops);
454#endif
402 455
403#ifdef CONFIG_OMAP2_DSS_DSI 456#if defined(CONFIG_OMAP2_DSS_DSI) && defined(CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS)
404 debugfs_create_file("dsi_irq", S_IRUGO, dss_debugfs_dir, 457 debugfs_create_file("dsi_irq", S_IRUGO, dss_debugfs_dir,
405 &dsi_dump_irqs, &dss_debug_fops); 458 &dsi_dump_irqs, &dss_debug_fops);
406#endif 459#endif
@@ -473,7 +526,7 @@ static int omap_dss_probe(struct platform_device *pdev)
473 } 526 }
474#endif 527#endif
475 528
476 r = dpi_init(); 529 r = dpi_init(pdev);
477 if (r) { 530 if (r) {
478 DSSERR("Failed to initialize dpi\n"); 531 DSSERR("Failed to initialize dpi\n");
479 goto fail0; 532 goto fail0;
@@ -718,16 +771,14 @@ static int dss_driver_probe(struct device *dev)
718 771
719 dss_init_device(core.pdev, dssdev); 772 dss_init_device(core.pdev, dssdev);
720 773
721 /* skip this if the device is behind a ctrl */ 774 force = pdata->default_device == dssdev;
722 if (!dssdev->panel.ctrl) { 775 dss_recheck_connections(dssdev, force);
723 force = pdata->default_device == dssdev;
724 dss_recheck_connections(dssdev, force);
725 }
726 776
727 r = dssdrv->probe(dssdev); 777 r = dssdrv->probe(dssdev);
728 778
729 if (r) { 779 if (r) {
730 DSSERR("driver probe failed: %d\n", r); 780 DSSERR("driver probe failed: %d\n", r);
781 dss_uninit_device(core.pdev, dssdev);
731 return r; 782 return r;
732 } 783 }
733 784
@@ -760,6 +811,13 @@ int omap_dss_register_driver(struct omap_dss_driver *dssdriver)
760 dssdriver->driver.bus = &dss_bus_type; 811 dssdriver->driver.bus = &dss_bus_type;
761 dssdriver->driver.probe = dss_driver_probe; 812 dssdriver->driver.probe = dss_driver_probe;
762 dssdriver->driver.remove = dss_driver_remove; 813 dssdriver->driver.remove = dss_driver_remove;
814
815 if (dssdriver->get_resolution == NULL)
816 dssdriver->get_resolution = omapdss_default_get_resolution;
817 if (dssdriver->get_recommended_bpp == NULL)
818 dssdriver->get_recommended_bpp =
819 omapdss_default_get_recommended_bpp;
820
763 return driver_register(&dssdriver->driver); 821 return driver_register(&dssdriver->driver);
764} 822}
765EXPORT_SYMBOL(omap_dss_register_driver); 823EXPORT_SYMBOL(omap_dss_register_driver);
@@ -808,8 +866,6 @@ static void omap_dss_dev_release(struct device *dev)
808int omap_dss_register_device(struct omap_dss_device *dssdev) 866int omap_dss_register_device(struct omap_dss_device *dssdev)
809{ 867{
810 static int dev_num; 868 static int dev_num;
811 static int panel_num;
812 int r;
813 869
814 WARN_ON(!dssdev->driver_name); 870 WARN_ON(!dssdev->driver_name);
815 871
@@ -818,36 +874,12 @@ int omap_dss_register_device(struct omap_dss_device *dssdev)
818 dssdev->dev.parent = &dss_bus; 874 dssdev->dev.parent = &dss_bus;
819 dssdev->dev.release = omap_dss_dev_release; 875 dssdev->dev.release = omap_dss_dev_release;
820 dev_set_name(&dssdev->dev, "display%d", dev_num++); 876 dev_set_name(&dssdev->dev, "display%d", dev_num++);
821 r = device_register(&dssdev->dev); 877 return device_register(&dssdev->dev);
822 if (r)
823 return r;
824
825 if (dssdev->ctrl.panel) {
826 struct omap_dss_device *panel = dssdev->ctrl.panel;
827
828 panel->panel.ctrl = dssdev;
829
830 reset_device(&panel->dev, 1);
831 panel->dev.bus = &dss_bus_type;
832 panel->dev.parent = &dssdev->dev;
833 panel->dev.release = omap_dss_dev_release;
834 dev_set_name(&panel->dev, "panel%d", panel_num++);
835 r = device_register(&panel->dev);
836 if (r)
837 return r;
838 }
839
840 return 0;
841} 878}
842 879
843void omap_dss_unregister_device(struct omap_dss_device *dssdev) 880void omap_dss_unregister_device(struct omap_dss_device *dssdev)
844{ 881{
845 device_unregister(&dssdev->dev); 882 device_unregister(&dssdev->dev);
846
847 if (dssdev->ctrl.panel) {
848 struct omap_dss_device *panel = dssdev->ctrl.panel;
849 device_unregister(&panel->dev);
850 }
851} 883}
852 884
853/* BUS */ 885/* BUS */
@@ -901,6 +933,21 @@ static int __init omap_dss_init(void)
901 933
902static void __exit omap_dss_exit(void) 934static void __exit omap_dss_exit(void)
903{ 935{
936 if (core.vdds_dsi_reg != NULL) {
937 regulator_put(core.vdds_dsi_reg);
938 core.vdds_dsi_reg = NULL;
939 }
940
941 if (core.vdds_sdi_reg != NULL) {
942 regulator_put(core.vdds_sdi_reg);
943 core.vdds_sdi_reg = NULL;
944 }
945
946 if (core.vdda_dac_reg != NULL) {
947 regulator_put(core.vdda_dac_reg);
948 core.vdda_dac_reg = NULL;
949 }
950
904 platform_driver_unregister(&omap_dss_driver); 951 platform_driver_unregister(&omap_dss_driver);
905 952
906 omap_dss_bus_unregister(); 953 omap_dss_bus_unregister();
diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c
index de8bfbac9e26..e777e352dbcd 100644
--- a/drivers/video/omap2/dss/dispc.c
+++ b/drivers/video/omap2/dss/dispc.c
@@ -1725,7 +1725,7 @@ static void _enable_lcd_out(bool enable)
1725 REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 0, 0); 1725 REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 0, 0);
1726} 1726}
1727 1727
1728void dispc_enable_lcd_out(bool enable) 1728static void dispc_enable_lcd_out(bool enable)
1729{ 1729{
1730 struct completion frame_done_completion; 1730 struct completion frame_done_completion;
1731 bool is_on; 1731 bool is_on;
@@ -1772,7 +1772,7 @@ static void _enable_digit_out(bool enable)
1772 REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 1, 1); 1772 REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 1, 1);
1773} 1773}
1774 1774
1775void dispc_enable_digit_out(bool enable) 1775static void dispc_enable_digit_out(bool enable)
1776{ 1776{
1777 struct completion frame_done_completion; 1777 struct completion frame_done_completion;
1778 int r; 1778 int r;
@@ -1836,6 +1836,26 @@ void dispc_enable_digit_out(bool enable)
1836 enable_clocks(0); 1836 enable_clocks(0);
1837} 1837}
1838 1838
1839bool dispc_is_channel_enabled(enum omap_channel channel)
1840{
1841 if (channel == OMAP_DSS_CHANNEL_LCD)
1842 return !!REG_GET(DISPC_CONTROL, 0, 0);
1843 else if (channel == OMAP_DSS_CHANNEL_DIGIT)
1844 return !!REG_GET(DISPC_CONTROL, 1, 1);
1845 else
1846 BUG();
1847}
1848
1849void dispc_enable_channel(enum omap_channel channel, bool enable)
1850{
1851 if (channel == OMAP_DSS_CHANNEL_LCD)
1852 dispc_enable_lcd_out(enable);
1853 else if (channel == OMAP_DSS_CHANNEL_DIGIT)
1854 dispc_enable_digit_out(enable);
1855 else
1856 BUG();
1857}
1858
1839void dispc_lcd_enable_signal_polarity(bool act_high) 1859void dispc_lcd_enable_signal_polarity(bool act_high)
1840{ 1860{
1841 enable_clocks(1); 1861 enable_clocks(1);
@@ -2198,7 +2218,7 @@ unsigned long dispc_fclk_rate(void)
2198{ 2218{
2199 unsigned long r = 0; 2219 unsigned long r = 0;
2200 2220
2201 if (dss_get_dispc_clk_source() == 0) 2221 if (dss_get_dispc_clk_source() == DSS_SRC_DSS1_ALWON_FCLK)
2202 r = dss_clk_get_rate(DSS_CLK_FCK1); 2222 r = dss_clk_get_rate(DSS_CLK_FCK1);
2203 else 2223 else
2204#ifdef CONFIG_OMAP2_DSS_DSI 2224#ifdef CONFIG_OMAP2_DSS_DSI
@@ -2251,7 +2271,7 @@ void dispc_dump_clocks(struct seq_file *s)
2251 seq_printf(s, "- DISPC -\n"); 2271 seq_printf(s, "- DISPC -\n");
2252 2272
2253 seq_printf(s, "dispc fclk source = %s\n", 2273 seq_printf(s, "dispc fclk source = %s\n",
2254 dss_get_dispc_clk_source() == 0 ? 2274 dss_get_dispc_clk_source() == DSS_SRC_DSS1_ALWON_FCLK ?
2255 "dss1_alwon_fclk" : "dsi1_pll_fclk"); 2275 "dss1_alwon_fclk" : "dsi1_pll_fclk");
2256 2276
2257 seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate()); 2277 seq_printf(s, "fck\t\t%-16lu\n", dispc_fclk_rate());
@@ -2301,8 +2321,6 @@ void dispc_dump_irqs(struct seq_file *s)
2301 PIS(WAKEUP); 2321 PIS(WAKEUP);
2302#undef PIS 2322#undef PIS
2303} 2323}
2304#else
2305void dispc_dump_irqs(struct seq_file *s) { }
2306#endif 2324#endif
2307 2325
2308void dispc_dump_regs(struct seq_file *s) 2326void dispc_dump_regs(struct seq_file *s)
@@ -2854,12 +2872,13 @@ static void dispc_error_worker(struct work_struct *work)
2854 manager = mgr; 2872 manager = mgr;
2855 enable = mgr->device->state == 2873 enable = mgr->device->state ==
2856 OMAP_DSS_DISPLAY_ACTIVE; 2874 OMAP_DSS_DISPLAY_ACTIVE;
2857 mgr->device->disable(mgr->device); 2875 mgr->device->driver->disable(mgr->device);
2858 break; 2876 break;
2859 } 2877 }
2860 } 2878 }
2861 2879
2862 if (manager) { 2880 if (manager) {
2881 struct omap_dss_device *dssdev = manager->device;
2863 for (i = 0; i < omap_dss_get_num_overlays(); ++i) { 2882 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
2864 struct omap_overlay *ovl; 2883 struct omap_overlay *ovl;
2865 ovl = omap_dss_get_overlay(i); 2884 ovl = omap_dss_get_overlay(i);
@@ -2874,7 +2893,7 @@ static void dispc_error_worker(struct work_struct *work)
2874 dispc_go(manager->id); 2893 dispc_go(manager->id);
2875 mdelay(50); 2894 mdelay(50);
2876 if (enable) 2895 if (enable)
2877 manager->device->enable(manager->device); 2896 dssdev->driver->enable(dssdev);
2878 } 2897 }
2879 } 2898 }
2880 2899
@@ -2892,12 +2911,13 @@ static void dispc_error_worker(struct work_struct *work)
2892 manager = mgr; 2911 manager = mgr;
2893 enable = mgr->device->state == 2912 enable = mgr->device->state ==
2894 OMAP_DSS_DISPLAY_ACTIVE; 2913 OMAP_DSS_DISPLAY_ACTIVE;
2895 mgr->device->disable(mgr->device); 2914 mgr->device->driver->disable(mgr->device);
2896 break; 2915 break;
2897 } 2916 }
2898 } 2917 }
2899 2918
2900 if (manager) { 2919 if (manager) {
2920 struct omap_dss_device *dssdev = manager->device;
2901 for (i = 0; i < omap_dss_get_num_overlays(); ++i) { 2921 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
2902 struct omap_overlay *ovl; 2922 struct omap_overlay *ovl;
2903 ovl = omap_dss_get_overlay(i); 2923 ovl = omap_dss_get_overlay(i);
@@ -2912,7 +2932,7 @@ static void dispc_error_worker(struct work_struct *work)
2912 dispc_go(manager->id); 2932 dispc_go(manager->id);
2913 mdelay(50); 2933 mdelay(50);
2914 if (enable) 2934 if (enable)
2915 manager->device->enable(manager->device); 2935 dssdev->driver->enable(dssdev);
2916 } 2936 }
2917 } 2937 }
2918 2938
@@ -2923,7 +2943,7 @@ static void dispc_error_worker(struct work_struct *work)
2923 mgr = omap_dss_get_overlay_manager(i); 2943 mgr = omap_dss_get_overlay_manager(i);
2924 2944
2925 if (mgr->caps & OMAP_DSS_OVL_CAP_DISPC) 2945 if (mgr->caps & OMAP_DSS_OVL_CAP_DISPC)
2926 mgr->device->disable(mgr->device); 2946 mgr->device->driver->disable(mgr->device);
2927 } 2947 }
2928 } 2948 }
2929 2949
diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c
index 3b92b84b9560..6a74ea116d29 100644
--- a/drivers/video/omap2/dss/display.c
+++ b/drivers/video/omap2/dss/display.c
@@ -53,11 +53,11 @@ static ssize_t display_enabled_store(struct device *dev,
53 53
54 if (enabled != (dssdev->state != OMAP_DSS_DISPLAY_DISABLED)) { 54 if (enabled != (dssdev->state != OMAP_DSS_DISPLAY_DISABLED)) {
55 if (enabled) { 55 if (enabled) {
56 r = dssdev->enable(dssdev); 56 r = dssdev->driver->enable(dssdev);
57 if (r) 57 if (r)
58 return r; 58 return r;
59 } else { 59 } else {
60 dssdev->disable(dssdev); 60 dssdev->driver->disable(dssdev);
61 } 61 }
62 } 62 }
63 63
@@ -69,8 +69,8 @@ static ssize_t display_upd_mode_show(struct device *dev,
69{ 69{
70 struct omap_dss_device *dssdev = to_dss_device(dev); 70 struct omap_dss_device *dssdev = to_dss_device(dev);
71 enum omap_dss_update_mode mode = OMAP_DSS_UPDATE_AUTO; 71 enum omap_dss_update_mode mode = OMAP_DSS_UPDATE_AUTO;
72 if (dssdev->get_update_mode) 72 if (dssdev->driver->get_update_mode)
73 mode = dssdev->get_update_mode(dssdev); 73 mode = dssdev->driver->get_update_mode(dssdev);
74 return snprintf(buf, PAGE_SIZE, "%d\n", mode); 74 return snprintf(buf, PAGE_SIZE, "%d\n", mode);
75} 75}
76 76
@@ -94,7 +94,7 @@ static ssize_t display_upd_mode_store(struct device *dev,
94 return -EINVAL; 94 return -EINVAL;
95 } 95 }
96 96
97 r = dssdev->set_update_mode(dssdev, mode); 97 r = dssdev->driver->set_update_mode(dssdev, mode);
98 if (r) 98 if (r)
99 return r; 99 return r;
100 100
@@ -106,7 +106,8 @@ static ssize_t display_tear_show(struct device *dev,
106{ 106{
107 struct omap_dss_device *dssdev = to_dss_device(dev); 107 struct omap_dss_device *dssdev = to_dss_device(dev);
108 return snprintf(buf, PAGE_SIZE, "%d\n", 108 return snprintf(buf, PAGE_SIZE, "%d\n",
109 dssdev->get_te ? dssdev->get_te(dssdev) : 0); 109 dssdev->driver->get_te ?
110 dssdev->driver->get_te(dssdev) : 0);
110} 111}
111 112
112static ssize_t display_tear_store(struct device *dev, 113static ssize_t display_tear_store(struct device *dev,
@@ -116,12 +117,12 @@ static ssize_t display_tear_store(struct device *dev,
116 unsigned long te; 117 unsigned long te;
117 int r; 118 int r;
118 119
119 if (!dssdev->enable_te || !dssdev->get_te) 120 if (!dssdev->driver->enable_te || !dssdev->driver->get_te)
120 return -ENOENT; 121 return -ENOENT;
121 122
122 te = simple_strtoul(buf, NULL, 0); 123 te = simple_strtoul(buf, NULL, 0);
123 124
124 r = dssdev->enable_te(dssdev, te); 125 r = dssdev->driver->enable_te(dssdev, te);
125 if (r) 126 if (r)
126 return r; 127 return r;
127 128
@@ -134,10 +135,10 @@ static ssize_t display_timings_show(struct device *dev,
134 struct omap_dss_device *dssdev = to_dss_device(dev); 135 struct omap_dss_device *dssdev = to_dss_device(dev);
135 struct omap_video_timings t; 136 struct omap_video_timings t;
136 137
137 if (!dssdev->get_timings) 138 if (!dssdev->driver->get_timings)
138 return -ENOENT; 139 return -ENOENT;
139 140
140 dssdev->get_timings(dssdev, &t); 141 dssdev->driver->get_timings(dssdev, &t);
141 142
142 return snprintf(buf, PAGE_SIZE, "%u,%u/%u/%u/%u,%u/%u/%u/%u\n", 143 return snprintf(buf, PAGE_SIZE, "%u,%u/%u/%u/%u,%u/%u/%u/%u\n",
143 t.pixel_clock, 144 t.pixel_clock,
@@ -152,7 +153,7 @@ static ssize_t display_timings_store(struct device *dev,
152 struct omap_video_timings t; 153 struct omap_video_timings t;
153 int r, found; 154 int r, found;
154 155
155 if (!dssdev->set_timings || !dssdev->check_timings) 156 if (!dssdev->driver->set_timings || !dssdev->driver->check_timings)
156 return -ENOENT; 157 return -ENOENT;
157 158
158 found = 0; 159 found = 0;
@@ -171,11 +172,11 @@ static ssize_t display_timings_store(struct device *dev,
171 &t.y_res, &t.vfp, &t.vbp, &t.vsw) != 9) 172 &t.y_res, &t.vfp, &t.vbp, &t.vsw) != 9)
172 return -EINVAL; 173 return -EINVAL;
173 174
174 r = dssdev->check_timings(dssdev, &t); 175 r = dssdev->driver->check_timings(dssdev, &t);
175 if (r) 176 if (r)
176 return r; 177 return r;
177 178
178 dssdev->set_timings(dssdev, &t); 179 dssdev->driver->set_timings(dssdev, &t);
179 180
180 return size; 181 return size;
181} 182}
@@ -185,9 +186,9 @@ static ssize_t display_rotate_show(struct device *dev,
185{ 186{
186 struct omap_dss_device *dssdev = to_dss_device(dev); 187 struct omap_dss_device *dssdev = to_dss_device(dev);
187 int rotate; 188 int rotate;
188 if (!dssdev->get_rotate) 189 if (!dssdev->driver->get_rotate)
189 return -ENOENT; 190 return -ENOENT;
190 rotate = dssdev->get_rotate(dssdev); 191 rotate = dssdev->driver->get_rotate(dssdev);
191 return snprintf(buf, PAGE_SIZE, "%u\n", rotate); 192 return snprintf(buf, PAGE_SIZE, "%u\n", rotate);
192} 193}
193 194
@@ -198,12 +199,12 @@ static ssize_t display_rotate_store(struct device *dev,
198 unsigned long rot; 199 unsigned long rot;
199 int r; 200 int r;
200 201
201 if (!dssdev->set_rotate || !dssdev->get_rotate) 202 if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate)
202 return -ENOENT; 203 return -ENOENT;
203 204
204 rot = simple_strtoul(buf, NULL, 0); 205 rot = simple_strtoul(buf, NULL, 0);
205 206
206 r = dssdev->set_rotate(dssdev, rot); 207 r = dssdev->driver->set_rotate(dssdev, rot);
207 if (r) 208 if (r)
208 return r; 209 return r;
209 210
@@ -215,9 +216,9 @@ static ssize_t display_mirror_show(struct device *dev,
215{ 216{
216 struct omap_dss_device *dssdev = to_dss_device(dev); 217 struct omap_dss_device *dssdev = to_dss_device(dev);
217 int mirror; 218 int mirror;
218 if (!dssdev->get_mirror) 219 if (!dssdev->driver->get_mirror)
219 return -ENOENT; 220 return -ENOENT;
220 mirror = dssdev->get_mirror(dssdev); 221 mirror = dssdev->driver->get_mirror(dssdev);
221 return snprintf(buf, PAGE_SIZE, "%u\n", mirror); 222 return snprintf(buf, PAGE_SIZE, "%u\n", mirror);
222} 223}
223 224
@@ -228,12 +229,12 @@ static ssize_t display_mirror_store(struct device *dev,
228 unsigned long mirror; 229 unsigned long mirror;
229 int r; 230 int r;
230 231
231 if (!dssdev->set_mirror || !dssdev->get_mirror) 232 if (!dssdev->driver->set_mirror || !dssdev->driver->get_mirror)
232 return -ENOENT; 233 return -ENOENT;
233 234
234 mirror = simple_strtoul(buf, NULL, 0); 235 mirror = simple_strtoul(buf, NULL, 0);
235 236
236 r = dssdev->set_mirror(dssdev, mirror); 237 r = dssdev->driver->set_mirror(dssdev, mirror);
237 if (r) 238 if (r)
238 return r; 239 return r;
239 240
@@ -246,10 +247,10 @@ static ssize_t display_wss_show(struct device *dev,
246 struct omap_dss_device *dssdev = to_dss_device(dev); 247 struct omap_dss_device *dssdev = to_dss_device(dev);
247 unsigned int wss; 248 unsigned int wss;
248 249
249 if (!dssdev->get_wss) 250 if (!dssdev->driver->get_wss)
250 return -ENOENT; 251 return -ENOENT;
251 252
252 wss = dssdev->get_wss(dssdev); 253 wss = dssdev->driver->get_wss(dssdev);
253 254
254 return snprintf(buf, PAGE_SIZE, "0x%05x\n", wss); 255 return snprintf(buf, PAGE_SIZE, "0x%05x\n", wss);
255} 256}
@@ -261,7 +262,7 @@ static ssize_t display_wss_store(struct device *dev,
261 unsigned long wss; 262 unsigned long wss;
262 int r; 263 int r;
263 264
264 if (!dssdev->get_wss || !dssdev->set_wss) 265 if (!dssdev->driver->get_wss || !dssdev->driver->set_wss)
265 return -ENOENT; 266 return -ENOENT;
266 267
267 if (strict_strtoul(buf, 0, &wss)) 268 if (strict_strtoul(buf, 0, &wss))
@@ -270,7 +271,7 @@ static ssize_t display_wss_store(struct device *dev,
270 if (wss > 0xfffff) 271 if (wss > 0xfffff)
271 return -EINVAL; 272 return -EINVAL;
272 273
273 r = dssdev->set_wss(dssdev, wss); 274 r = dssdev->driver->set_wss(dssdev, wss);
274 if (r) 275 if (r)
275 return r; 276 return r;
276 277
@@ -303,12 +304,13 @@ static struct device_attribute *display_sysfs_attrs[] = {
303 NULL 304 NULL
304}; 305};
305 306
306static void default_get_resolution(struct omap_dss_device *dssdev, 307void omapdss_default_get_resolution(struct omap_dss_device *dssdev,
307 u16 *xres, u16 *yres) 308 u16 *xres, u16 *yres)
308{ 309{
309 *xres = dssdev->panel.timings.x_res; 310 *xres = dssdev->panel.timings.x_res;
310 *yres = dssdev->panel.timings.y_res; 311 *yres = dssdev->panel.timings.y_res;
311} 312}
313EXPORT_SYMBOL(omapdss_default_get_resolution);
312 314
313void default_get_overlay_fifo_thresholds(enum omap_plane plane, 315void default_get_overlay_fifo_thresholds(enum omap_plane plane,
314 u32 fifo_size, enum omap_burst_size *burst_size, 316 u32 fifo_size, enum omap_burst_size *burst_size,
@@ -323,24 +325,8 @@ void default_get_overlay_fifo_thresholds(enum omap_plane plane,
323 *fifo_low = fifo_size - burst_size_bytes; 325 *fifo_low = fifo_size - burst_size_bytes;
324} 326}
325 327
326static int default_wait_vsync(struct omap_dss_device *dssdev) 328int omapdss_default_get_recommended_bpp(struct omap_dss_device *dssdev)
327{ 329{
328 unsigned long timeout = msecs_to_jiffies(500);
329 u32 irq;
330
331 if (dssdev->type == OMAP_DISPLAY_TYPE_VENC)
332 irq = DISPC_IRQ_EVSYNC_ODD;
333 else
334 irq = DISPC_IRQ_VSYNC;
335
336 return omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout);
337}
338
339static int default_get_recommended_bpp(struct omap_dss_device *dssdev)
340{
341 if (dssdev->panel.recommended_bpp)
342 return dssdev->panel.recommended_bpp;
343
344 switch (dssdev->type) { 330 switch (dssdev->type) {
345 case OMAP_DISPLAY_TYPE_DPI: 331 case OMAP_DISPLAY_TYPE_DPI:
346 if (dssdev->phy.dpi.data_lines == 24) 332 if (dssdev->phy.dpi.data_lines == 24)
@@ -362,6 +348,7 @@ static int default_get_recommended_bpp(struct omap_dss_device *dssdev)
362 BUG(); 348 BUG();
363 } 349 }
364} 350}
351EXPORT_SYMBOL(omapdss_default_get_recommended_bpp);
365 352
366/* Checks if replication logic should be used. Only use for active matrix, 353/* Checks if replication logic should be used. Only use for active matrix,
367 * when overlay is in RGB12U or RGB16 mode, and LCD interface is 354 * when overlay is in RGB12U or RGB16 mode, and LCD interface is
@@ -425,10 +412,6 @@ void dss_init_device(struct platform_device *pdev,
425 return; 412 return;
426 } 413 }
427 414
428 dssdev->get_resolution = default_get_resolution;
429 dssdev->get_recommended_bpp = default_get_recommended_bpp;
430 dssdev->wait_vsync = default_wait_vsync;
431
432 switch (dssdev->type) { 415 switch (dssdev->type) {
433 case OMAP_DISPLAY_TYPE_DPI: 416 case OMAP_DISPLAY_TYPE_DPI:
434 r = dpi_init_display(dssdev); 417 r = dpi_init_display(dssdev);
@@ -502,13 +485,13 @@ static int dss_suspend_device(struct device *dev, void *data)
502 return 0; 485 return 0;
503 } 486 }
504 487
505 if (!dssdev->suspend) { 488 if (!dssdev->driver->suspend) {
506 DSSERR("display '%s' doesn't implement suspend\n", 489 DSSERR("display '%s' doesn't implement suspend\n",
507 dssdev->name); 490 dssdev->name);
508 return -ENOSYS; 491 return -ENOSYS;
509 } 492 }
510 493
511 r = dssdev->suspend(dssdev); 494 r = dssdev->driver->suspend(dssdev);
512 if (r) 495 if (r)
513 return r; 496 return r;
514 497
@@ -537,8 +520,8 @@ static int dss_resume_device(struct device *dev, void *data)
537 int r; 520 int r;
538 struct omap_dss_device *dssdev = to_dss_device(dev); 521 struct omap_dss_device *dssdev = to_dss_device(dev);
539 522
540 if (dssdev->activate_after_resume && dssdev->resume) { 523 if (dssdev->activate_after_resume && dssdev->driver->resume) {
541 r = dssdev->resume(dssdev); 524 r = dssdev->driver->resume(dssdev);
542 if (r) 525 if (r)
543 return r; 526 return r;
544 } 527 }
@@ -558,7 +541,7 @@ int dss_resume_all_devices(void)
558static int dss_disable_device(struct device *dev, void *data) 541static int dss_disable_device(struct device *dev, void *data)
559{ 542{
560 struct omap_dss_device *dssdev = to_dss_device(dev); 543 struct omap_dss_device *dssdev = to_dss_device(dev);
561 dssdev->disable(dssdev); 544 dssdev->driver->disable(dssdev);
562 return 0; 545 return 0;
563} 546}
564 547
@@ -591,10 +574,6 @@ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
591 574
592 int match(struct device *dev, void *data) 575 int match(struct device *dev, void *data)
593 { 576 {
594 /* skip panels connected to controllers */
595 if (to_dss_device(dev)->panel.ctrl)
596 return 0;
597
598 return 1; 577 return 1;
599 } 578 }
600 579
@@ -626,45 +605,21 @@ EXPORT_SYMBOL(omap_dss_find_device);
626 605
627int omap_dss_start_device(struct omap_dss_device *dssdev) 606int omap_dss_start_device(struct omap_dss_device *dssdev)
628{ 607{
629 int r;
630
631 if (!dssdev->driver) { 608 if (!dssdev->driver) {
632 DSSDBG("no driver\n"); 609 DSSDBG("no driver\n");
633 r = -ENODEV; 610 return -ENODEV;
634 goto err0;
635 }
636
637 if (dssdev->ctrl.panel && !dssdev->ctrl.panel->driver) {
638 DSSDBG("no panel driver\n");
639 r = -ENODEV;
640 goto err0;
641 } 611 }
642 612
643 if (!try_module_get(dssdev->dev.driver->owner)) { 613 if (!try_module_get(dssdev->dev.driver->owner)) {
644 r = -ENODEV; 614 return -ENODEV;
645 goto err0;
646 }
647
648 if (dssdev->ctrl.panel) {
649 if (!try_module_get(dssdev->ctrl.panel->dev.driver->owner)) {
650 r = -ENODEV;
651 goto err1;
652 }
653 } 615 }
654 616
655 return 0; 617 return 0;
656err1:
657 module_put(dssdev->dev.driver->owner);
658err0:
659 return r;
660} 618}
661EXPORT_SYMBOL(omap_dss_start_device); 619EXPORT_SYMBOL(omap_dss_start_device);
662 620
663void omap_dss_stop_device(struct omap_dss_device *dssdev) 621void omap_dss_stop_device(struct omap_dss_device *dssdev)
664{ 622{
665 if (dssdev->ctrl.panel)
666 module_put(dssdev->ctrl.panel->dev.driver->owner);
667
668 module_put(dssdev->dev.driver->owner); 623 module_put(dssdev->dev.driver->owner);
669} 624}
670EXPORT_SYMBOL(omap_dss_stop_device); 625EXPORT_SYMBOL(omap_dss_stop_device);
diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index 2d71031baa25..960e977a8bf0 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -25,7 +25,10 @@
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/err.h>
28#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/platform_device.h>
31#include <linux/regulator/consumer.h>
29 32
30#include <plat/display.h> 33#include <plat/display.h>
31#include <plat/cpu.h> 34#include <plat/cpu.h>
@@ -33,7 +36,7 @@
33#include "dss.h" 36#include "dss.h"
34 37
35static struct { 38static struct {
36 int update_enabled; 39 struct regulator *vdds_dsi_reg;
37} dpi; 40} dpi;
38 41
39#ifdef CONFIG_OMAP2_DSS_USE_DSI_PLL 42#ifdef CONFIG_OMAP2_DSS_USE_DSI_PLL
@@ -53,7 +56,7 @@ static int dpi_set_dsi_clk(bool is_tft, unsigned long pck_req,
53 if (r) 56 if (r)
54 return r; 57 return r;
55 58
56 dss_select_clk_source(0, 1); 59 dss_select_dispc_clk_source(DSS_SRC_DSI1_PLL_FCLK);
57 60
58 r = dispc_set_clock_div(&dispc_cinfo); 61 r = dispc_set_clock_div(&dispc_cinfo);
59 if (r) 62 if (r)
@@ -150,7 +153,7 @@ static int dpi_basic_init(struct omap_dss_device *dssdev)
150 return 0; 153 return 0;
151} 154}
152 155
153static int dpi_display_enable(struct omap_dss_device *dssdev) 156int omapdss_dpi_display_enable(struct omap_dss_device *dssdev)
154{ 157{
155 int r; 158 int r;
156 159
@@ -160,10 +163,10 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
160 goto err0; 163 goto err0;
161 } 164 }
162 165
163 if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) { 166 if (cpu_is_omap34xx()) {
164 DSSERR("display already enabled\n"); 167 r = regulator_enable(dpi.vdds_dsi_reg);
165 r = -EINVAL; 168 if (r)
166 goto err1; 169 goto err1;
167 } 170 }
168 171
169 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1); 172 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
@@ -184,18 +187,10 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
184 187
185 mdelay(2); 188 mdelay(2);
186 189
187 dispc_enable_lcd_out(1); 190 dssdev->manager->enable(dssdev->manager);
188
189 r = dssdev->driver->enable(dssdev);
190 if (r)
191 goto err5;
192
193 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
194 191
195 return 0; 192 return 0;
196 193
197err5:
198 dispc_enable_lcd_out(0);
199err4: 194err4:
200#ifdef CONFIG_OMAP2_DSS_USE_DSI_PLL 195#ifdef CONFIG_OMAP2_DSS_USE_DSI_PLL
201 dsi_pll_uninit(); 196 dsi_pll_uninit();
@@ -204,78 +199,35 @@ err3:
204#endif 199#endif
205err2: 200err2:
206 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1); 201 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
202 if (cpu_is_omap34xx())
203 regulator_disable(dpi.vdds_dsi_reg);
207err1: 204err1:
208 omap_dss_stop_device(dssdev); 205 omap_dss_stop_device(dssdev);
209err0: 206err0:
210 return r; 207 return r;
211} 208}
209EXPORT_SYMBOL(omapdss_dpi_display_enable);
212 210
213static int dpi_display_resume(struct omap_dss_device *dssdev); 211void omapdss_dpi_display_disable(struct omap_dss_device *dssdev)
214
215static void dpi_display_disable(struct omap_dss_device *dssdev)
216{ 212{
217 if (dssdev->state == OMAP_DSS_DISPLAY_DISABLED) 213 dssdev->manager->disable(dssdev->manager);
218 return;
219
220 if (dssdev->state == OMAP_DSS_DISPLAY_SUSPENDED)
221 dpi_display_resume(dssdev);
222
223 dssdev->driver->disable(dssdev);
224
225 dispc_enable_lcd_out(0);
226 214
227#ifdef CONFIG_OMAP2_DSS_USE_DSI_PLL 215#ifdef CONFIG_OMAP2_DSS_USE_DSI_PLL
228 dss_select_clk_source(0, 0); 216 dss_select_dispc_clk_source(DSS_SRC_DSS1_ALWON_FCLK);
229 dsi_pll_uninit(); 217 dsi_pll_uninit();
230 dss_clk_disable(DSS_CLK_FCK2); 218 dss_clk_disable(DSS_CLK_FCK2);
231#endif 219#endif
232 220
233 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1); 221 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
234 222
235 dssdev->state = OMAP_DSS_DISPLAY_DISABLED; 223 if (cpu_is_omap34xx())
224 regulator_disable(dpi.vdds_dsi_reg);
236 225
237 omap_dss_stop_device(dssdev); 226 omap_dss_stop_device(dssdev);
238} 227}
228EXPORT_SYMBOL(omapdss_dpi_display_disable);
239 229
240static int dpi_display_suspend(struct omap_dss_device *dssdev) 230void dpi_set_timings(struct omap_dss_device *dssdev,
241{
242 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
243 return -EINVAL;
244
245 DSSDBG("dpi_display_suspend\n");
246
247 if (dssdev->driver->suspend)
248 dssdev->driver->suspend(dssdev);
249
250 dispc_enable_lcd_out(0);
251
252 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
253
254 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
255
256 return 0;
257}
258
259static int dpi_display_resume(struct omap_dss_device *dssdev)
260{
261 if (dssdev->state != OMAP_DSS_DISPLAY_SUSPENDED)
262 return -EINVAL;
263
264 DSSDBG("dpi_display_resume\n");
265
266 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
267
268 dispc_enable_lcd_out(1);
269
270 if (dssdev->driver->resume)
271 dssdev->driver->resume(dssdev);
272
273 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
274
275 return 0;
276}
277
278static void dpi_set_timings(struct omap_dss_device *dssdev,
279 struct omap_video_timings *timings) 231 struct omap_video_timings *timings)
280{ 232{
281 DSSDBG("dpi_set_timings\n"); 233 DSSDBG("dpi_set_timings\n");
@@ -285,8 +237,9 @@ static void dpi_set_timings(struct omap_dss_device *dssdev,
285 dispc_go(OMAP_DSS_CHANNEL_LCD); 237 dispc_go(OMAP_DSS_CHANNEL_LCD);
286 } 238 }
287} 239}
240EXPORT_SYMBOL(dpi_set_timings);
288 241
289static int dpi_check_timings(struct omap_dss_device *dssdev, 242int dpi_check_timings(struct omap_dss_device *dssdev,
290 struct omap_video_timings *timings) 243 struct omap_video_timings *timings)
291{ 244{
292 bool is_tft; 245 bool is_tft;
@@ -340,56 +293,25 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
340 293
341 return 0; 294 return 0;
342} 295}
343 296EXPORT_SYMBOL(dpi_check_timings);
344static void dpi_get_timings(struct omap_dss_device *dssdev,
345 struct omap_video_timings *timings)
346{
347 *timings = dssdev->panel.timings;
348}
349
350static int dpi_display_set_update_mode(struct omap_dss_device *dssdev,
351 enum omap_dss_update_mode mode)
352{
353 if (mode == OMAP_DSS_UPDATE_MANUAL)
354 return -EINVAL;
355
356 if (mode == OMAP_DSS_UPDATE_DISABLED) {
357 dispc_enable_lcd_out(0);
358 dpi.update_enabled = 0;
359 } else {
360 dispc_enable_lcd_out(1);
361 dpi.update_enabled = 1;
362 }
363
364 return 0;
365}
366
367static enum omap_dss_update_mode dpi_display_get_update_mode(
368 struct omap_dss_device *dssdev)
369{
370 return dpi.update_enabled ? OMAP_DSS_UPDATE_AUTO :
371 OMAP_DSS_UPDATE_DISABLED;
372}
373 297
374int dpi_init_display(struct omap_dss_device *dssdev) 298int dpi_init_display(struct omap_dss_device *dssdev)
375{ 299{
376 DSSDBG("init_display\n"); 300 DSSDBG("init_display\n");
377 301
378 dssdev->enable = dpi_display_enable;
379 dssdev->disable = dpi_display_disable;
380 dssdev->suspend = dpi_display_suspend;
381 dssdev->resume = dpi_display_resume;
382 dssdev->set_timings = dpi_set_timings;
383 dssdev->check_timings = dpi_check_timings;
384 dssdev->get_timings = dpi_get_timings;
385 dssdev->set_update_mode = dpi_display_set_update_mode;
386 dssdev->get_update_mode = dpi_display_get_update_mode;
387
388 return 0; 302 return 0;
389} 303}
390 304
391int dpi_init(void) 305int dpi_init(struct platform_device *pdev)
392{ 306{
307 if (cpu_is_omap34xx()) {
308 dpi.vdds_dsi_reg = dss_get_vdds_dsi();
309 if (IS_ERR(dpi.vdds_dsi_reg)) {
310 DSSERR("can't get VDDS_DSI regulator\n");
311 return PTR_ERR(dpi.vdds_dsi_reg);
312 }
313 }
314
393 return 0; 315 return 0;
394} 316}
395 317
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index 6122178f5f85..3af207b2bde3 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -27,11 +27,12 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/semaphore.h>
30#include <linux/seq_file.h> 31#include <linux/seq_file.h>
31#include <linux/platform_device.h> 32#include <linux/platform_device.h>
32#include <linux/regulator/consumer.h> 33#include <linux/regulator/consumer.h>
33#include <linux/kthread.h>
34#include <linux/wait.h> 34#include <linux/wait.h>
35#include <linux/workqueue.h>
35 36
36#include <plat/display.h> 37#include <plat/display.h>
37#include <plat/clock.h> 38#include <plat/clock.h>
@@ -199,7 +200,6 @@ enum dsi_vc_mode {
199}; 200};
200 201
201struct dsi_update_region { 202struct dsi_update_region {
202 bool dirty;
203 u16 x, y, w, h; 203 u16 x, y, w, h;
204 struct omap_dss_device *device; 204 struct omap_dss_device *device;
205}; 205};
@@ -224,29 +224,25 @@ static struct
224 enum dsi_vc_mode mode; 224 enum dsi_vc_mode mode;
225 struct omap_dss_device *dssdev; 225 struct omap_dss_device *dssdev;
226 enum fifo_size fifo_size; 226 enum fifo_size fifo_size;
227 int dest_per; /* destination peripheral 0-3 */
228 } vc[4]; 227 } vc[4];
229 228
230 struct mutex lock; 229 struct mutex lock;
231 struct mutex bus_lock; 230 struct semaphore bus_lock;
232 231
233 unsigned pll_locked; 232 unsigned pll_locked;
234 233
235 struct completion bta_completion; 234 struct completion bta_completion;
236 235
237 struct task_struct *thread; 236 int update_channel;
238 wait_queue_head_t waitqueue;
239
240 spinlock_t update_lock;
241 bool framedone_received;
242 struct dsi_update_region update_region; 237 struct dsi_update_region update_region;
243 struct dsi_update_region active_update_region;
244 struct completion update_completion;
245 238
246 enum omap_dss_update_mode user_update_mode;
247 enum omap_dss_update_mode update_mode;
248 bool te_enabled; 239 bool te_enabled;
249 bool use_ext_te; 240
241 struct work_struct framedone_work;
242 void (*framedone_callback)(int, void *);
243 void *framedone_data;
244
245 struct delayed_work framedone_timeout_work;
250 246
251#ifdef DSI_CATCH_MISSING_TE 247#ifdef DSI_CATCH_MISSING_TE
252 struct timer_list te_timer; 248 struct timer_list te_timer;
@@ -261,8 +257,6 @@ static struct
261#ifdef DEBUG 257#ifdef DEBUG
262 ktime_t perf_setup_time; 258 ktime_t perf_setup_time;
263 ktime_t perf_start_time; 259 ktime_t perf_start_time;
264 ktime_t perf_start_time_auto;
265 int perf_measure_frames;
266#endif 260#endif
267 int debug_read; 261 int debug_read;
268 int debug_write; 262 int debug_write;
@@ -299,16 +293,21 @@ void dsi_restore_context(void)
299 293
300void dsi_bus_lock(void) 294void dsi_bus_lock(void)
301{ 295{
302 mutex_lock(&dsi.bus_lock); 296 down(&dsi.bus_lock);
303} 297}
304EXPORT_SYMBOL(dsi_bus_lock); 298EXPORT_SYMBOL(dsi_bus_lock);
305 299
306void dsi_bus_unlock(void) 300void dsi_bus_unlock(void)
307{ 301{
308 mutex_unlock(&dsi.bus_lock); 302 up(&dsi.bus_lock);
309} 303}
310EXPORT_SYMBOL(dsi_bus_unlock); 304EXPORT_SYMBOL(dsi_bus_unlock);
311 305
306static bool dsi_bus_is_locked(void)
307{
308 return dsi.bus_lock.count == 0;
309}
310
312static inline int wait_for_bit_change(const struct dsi_reg idx, int bitnum, 311static inline int wait_for_bit_change(const struct dsi_reg idx, int bitnum,
313 int value) 312 int value)
314{ 313{
@@ -333,12 +332,6 @@ static void dsi_perf_mark_start(void)
333 dsi.perf_start_time = ktime_get(); 332 dsi.perf_start_time = ktime_get();
334} 333}
335 334
336static void dsi_perf_mark_start_auto(void)
337{
338 dsi.perf_measure_frames = 0;
339 dsi.perf_start_time_auto = ktime_get();
340}
341
342static void dsi_perf_show(const char *name) 335static void dsi_perf_show(const char *name)
343{ 336{
344 ktime_t t, setup_time, trans_time; 337 ktime_t t, setup_time, trans_time;
@@ -348,9 +341,6 @@ static void dsi_perf_show(const char *name)
348 if (!dsi_perf) 341 if (!dsi_perf)
349 return; 342 return;
350 343
351 if (dsi.update_mode == OMAP_DSS_UPDATE_DISABLED)
352 return;
353
354 t = ktime_get(); 344 t = ktime_get();
355 345
356 setup_time = ktime_sub(dsi.perf_start_time, dsi.perf_setup_time); 346 setup_time = ktime_sub(dsi.perf_start_time, dsi.perf_setup_time);
@@ -365,76 +355,23 @@ static void dsi_perf_show(const char *name)
365 355
366 total_us = setup_us + trans_us; 356 total_us = setup_us + trans_us;
367 357
368 total_bytes = dsi.active_update_region.w * 358 total_bytes = dsi.update_region.w *
369 dsi.active_update_region.h * 359 dsi.update_region.h *
370 dsi.active_update_region.device->ctrl.pixel_size / 8; 360 dsi.update_region.device->ctrl.pixel_size / 8;
371
372 if (dsi.update_mode == OMAP_DSS_UPDATE_AUTO) {
373 static u32 s_total_trans_us, s_total_setup_us;
374 static u32 s_min_trans_us = 0xffffffff, s_min_setup_us;
375 static u32 s_max_trans_us, s_max_setup_us;
376 const int numframes = 100;
377 ktime_t total_time_auto;
378 u32 total_time_auto_us;
379
380 dsi.perf_measure_frames++;
381
382 if (setup_us < s_min_setup_us)
383 s_min_setup_us = setup_us;
384 361
385 if (setup_us > s_max_setup_us) 362 printk(KERN_INFO "DSI(%s): %u us + %u us = %u us (%uHz), "
386 s_max_setup_us = setup_us; 363 "%u bytes, %u kbytes/sec\n",
387 364 name,
388 s_total_setup_us += setup_us; 365 setup_us,
389 366 trans_us,
390 if (trans_us < s_min_trans_us) 367 total_us,
391 s_min_trans_us = trans_us; 368 1000*1000 / total_us,
392 369 total_bytes,
393 if (trans_us > s_max_trans_us) 370 total_bytes * 1000 / total_us);
394 s_max_trans_us = trans_us;
395
396 s_total_trans_us += trans_us;
397
398 if (dsi.perf_measure_frames < numframes)
399 return;
400
401 total_time_auto = ktime_sub(t, dsi.perf_start_time_auto);
402 total_time_auto_us = (u32)ktime_to_us(total_time_auto);
403
404 printk(KERN_INFO "DSI(%s): %u fps, setup %u/%u/%u, "
405 "trans %u/%u/%u\n",
406 name,
407 1000 * 1000 * numframes / total_time_auto_us,
408 s_min_setup_us,
409 s_max_setup_us,
410 s_total_setup_us / numframes,
411 s_min_trans_us,
412 s_max_trans_us,
413 s_total_trans_us / numframes);
414
415 s_total_setup_us = 0;
416 s_min_setup_us = 0xffffffff;
417 s_max_setup_us = 0;
418 s_total_trans_us = 0;
419 s_min_trans_us = 0xffffffff;
420 s_max_trans_us = 0;
421 dsi_perf_mark_start_auto();
422 } else {
423 printk(KERN_INFO "DSI(%s): %u us + %u us = %u us (%uHz), "
424 "%u bytes, %u kbytes/sec\n",
425 name,
426 setup_us,
427 trans_us,
428 total_us,
429 1000*1000 / total_us,
430 total_bytes,
431 total_bytes * 1000 / total_us);
432 }
433} 371}
434#else 372#else
435#define dsi_perf_mark_setup() 373#define dsi_perf_mark_setup()
436#define dsi_perf_mark_start() 374#define dsi_perf_mark_start()
437#define dsi_perf_mark_start_auto()
438#define dsi_perf_show(x) 375#define dsi_perf_show(x)
439#endif 376#endif
440 377
@@ -774,7 +711,7 @@ static unsigned long dsi_fclk_rate(void)
774{ 711{
775 unsigned long r; 712 unsigned long r;
776 713
777 if (dss_get_dsi_clk_source() == 0) { 714 if (dss_get_dsi_clk_source() == DSS_SRC_DSS1_ALWON_FCLK) {
778 /* DSI FCLK source is DSS1_ALWON_FCK, which is dss1_fck */ 715 /* DSI FCLK source is DSS1_ALWON_FCK, which is dss1_fck */
779 r = dss_clk_get_rate(DSS_CLK_FCK1); 716 r = dss_clk_get_rate(DSS_CLK_FCK1);
780 } else { 717 } else {
@@ -1227,17 +1164,19 @@ void dsi_dump_clocks(struct seq_file *s)
1227 seq_printf(s, "dsi1_pll_fck\t%-16luregm3 %u\t(%s)\n", 1164 seq_printf(s, "dsi1_pll_fck\t%-16luregm3 %u\t(%s)\n",
1228 cinfo->dsi1_pll_fclk, 1165 cinfo->dsi1_pll_fclk,
1229 cinfo->regm3, 1166 cinfo->regm3,
1230 dss_get_dispc_clk_source() == 0 ? "off" : "on"); 1167 dss_get_dispc_clk_source() == DSS_SRC_DSS1_ALWON_FCLK ?
1168 "off" : "on");
1231 1169
1232 seq_printf(s, "dsi2_pll_fck\t%-16luregm4 %u\t(%s)\n", 1170 seq_printf(s, "dsi2_pll_fck\t%-16luregm4 %u\t(%s)\n",
1233 cinfo->dsi2_pll_fclk, 1171 cinfo->dsi2_pll_fclk,
1234 cinfo->regm4, 1172 cinfo->regm4,
1235 dss_get_dsi_clk_source() == 0 ? "off" : "on"); 1173 dss_get_dsi_clk_source() == DSS_SRC_DSS1_ALWON_FCLK ?
1174 "off" : "on");
1236 1175
1237 seq_printf(s, "- DSI -\n"); 1176 seq_printf(s, "- DSI -\n");
1238 1177
1239 seq_printf(s, "dsi fclk source = %s\n", 1178 seq_printf(s, "dsi fclk source = %s\n",
1240 dss_get_dsi_clk_source() == 0 ? 1179 dss_get_dsi_clk_source() == DSS_SRC_DSS1_ALWON_FCLK ?
1241 "dss1_alwon_fclk" : "dsi2_pll_fclk"); 1180 "dss1_alwon_fclk" : "dsi2_pll_fclk");
1242 1181
1243 seq_printf(s, "DSI_FCLK\t%lu\n", dsi_fclk_rate()); 1182 seq_printf(s, "DSI_FCLK\t%lu\n", dsi_fclk_rate());
@@ -1756,29 +1695,10 @@ static int dsi_force_tx_stop_mode_io(void)
1756 return 0; 1695 return 0;
1757} 1696}
1758 1697
1759static void dsi_vc_print_status(int channel)
1760{
1761 u32 r;
1762
1763 r = dsi_read_reg(DSI_VC_CTRL(channel));
1764 DSSDBG("vc %d: TX_FIFO_NOT_EMPTY %d, BTA_EN %d, VC_BUSY %d, "
1765 "TX_FIFO_FULL %d, RX_FIFO_NOT_EMPTY %d, ",
1766 channel,
1767 FLD_GET(r, 5, 5),
1768 FLD_GET(r, 6, 6),
1769 FLD_GET(r, 15, 15),
1770 FLD_GET(r, 16, 16),
1771 FLD_GET(r, 20, 20));
1772
1773 r = dsi_read_reg(DSI_TX_FIFO_VC_EMPTINESS);
1774 DSSDBG("EMPTINESS %d\n", (r >> (8 * channel)) & 0xff);
1775}
1776
1777static int dsi_vc_enable(int channel, bool enable) 1698static int dsi_vc_enable(int channel, bool enable)
1778{ 1699{
1779 if (dsi.update_mode != OMAP_DSS_UPDATE_AUTO) 1700 DSSDBG("dsi_vc_enable channel %d, enable %d\n",
1780 DSSDBG("dsi_vc_enable channel %d, enable %d\n", 1701 channel, enable);
1781 channel, enable);
1782 1702
1783 enable = enable ? 1 : 0; 1703 enable = enable ? 1 : 0;
1784 1704
@@ -1859,10 +1779,12 @@ static void dsi_vc_config_vp(int channel)
1859} 1779}
1860 1780
1861 1781
1862static void dsi_vc_enable_hs(int channel, bool enable) 1782void omapdss_dsi_vc_enable_hs(int channel, bool enable)
1863{ 1783{
1864 DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable); 1784 DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable);
1865 1785
1786 WARN_ON(!dsi_bus_is_locked());
1787
1866 dsi_vc_enable(channel, 0); 1788 dsi_vc_enable(channel, 0);
1867 dsi_if_enable(0); 1789 dsi_if_enable(0);
1868 1790
@@ -1873,6 +1795,7 @@ static void dsi_vc_enable_hs(int channel, bool enable)
1873 1795
1874 dsi_force_tx_stop_mode_io(); 1796 dsi_force_tx_stop_mode_io();
1875} 1797}
1798EXPORT_SYMBOL(omapdss_dsi_vc_enable_hs);
1876 1799
1877static void dsi_vc_flush_long_data(int channel) 1800static void dsi_vc_flush_long_data(int channel)
1878{ 1801{
@@ -1955,11 +1878,10 @@ static u16 dsi_vc_flush_receive_data(int channel)
1955 1878
1956static int dsi_vc_send_bta(int channel) 1879static int dsi_vc_send_bta(int channel)
1957{ 1880{
1958 if (dsi.update_mode != OMAP_DSS_UPDATE_AUTO && 1881 if (dsi.debug_write || dsi.debug_read)
1959 (dsi.debug_write || dsi.debug_read))
1960 DSSDBG("dsi_vc_send_bta %d\n", channel); 1882 DSSDBG("dsi_vc_send_bta %d\n", channel);
1961 1883
1962 WARN_ON(!mutex_is_locked(&dsi.bus_lock)); 1884 WARN_ON(!dsi_bus_is_locked());
1963 1885
1964 if (REG_GET(DSI_VC_CTRL(channel), 20, 20)) { /* RX_FIFO_NOT_EMPTY */ 1886 if (REG_GET(DSI_VC_CTRL(channel), 20, 20)) { /* RX_FIFO_NOT_EMPTY */
1965 DSSERR("rx fifo not empty when sending BTA, dumping data:\n"); 1887 DSSERR("rx fifo not empty when sending BTA, dumping data:\n");
@@ -2010,10 +1932,9 @@ static inline void dsi_vc_write_long_header(int channel, u8 data_type,
2010 u32 val; 1932 u32 val;
2011 u8 data_id; 1933 u8 data_id;
2012 1934
2013 WARN_ON(!mutex_is_locked(&dsi.bus_lock)); 1935 WARN_ON(!dsi_bus_is_locked());
2014 1936
2015 /*data_id = data_type | channel << 6; */ 1937 data_id = data_type | channel << 6;
2016 data_id = data_type | dsi.vc[channel].dest_per << 6;
2017 1938
2018 val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) | 1939 val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) |
2019 FLD_VAL(ecc, 31, 24); 1940 FLD_VAL(ecc, 31, 24);
@@ -2056,13 +1977,10 @@ static int dsi_vc_send_long(int channel, u8 data_type, u8 *data, u16 len,
2056 1977
2057 dsi_vc_write_long_header(channel, data_type, len, ecc); 1978 dsi_vc_write_long_header(channel, data_type, len, ecc);
2058 1979
2059 /*dsi_vc_print_status(0); */
2060
2061 p = data; 1980 p = data;
2062 for (i = 0; i < len >> 2; i++) { 1981 for (i = 0; i < len >> 2; i++) {
2063 if (dsi.debug_write) 1982 if (dsi.debug_write)
2064 DSSDBG("\tsending full packet %d\n", i); 1983 DSSDBG("\tsending full packet %d\n", i);
2065 /*dsi_vc_print_status(0); */
2066 1984
2067 b1 = *p++; 1985 b1 = *p++;
2068 b2 = *p++; 1986 b2 = *p++;
@@ -2105,7 +2023,7 @@ static int dsi_vc_send_short(int channel, u8 data_type, u16 data, u8 ecc)
2105 u32 r; 2023 u32 r;
2106 u8 data_id; 2024 u8 data_id;
2107 2025
2108 WARN_ON(!mutex_is_locked(&dsi.bus_lock)); 2026 WARN_ON(!dsi_bus_is_locked());
2109 2027
2110 if (dsi.debug_write) 2028 if (dsi.debug_write)
2111 DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n", 2029 DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
@@ -2119,7 +2037,7 @@ static int dsi_vc_send_short(int channel, u8 data_type, u16 data, u8 ecc)
2119 return -EINVAL; 2037 return -EINVAL;
2120 } 2038 }
2121 2039
2122 data_id = data_type | dsi.vc[channel].dest_per << 6; 2040 data_id = data_type | channel << 6;
2123 2041
2124 r = (data_id << 0) | (data << 8) | (ecc << 24); 2042 r = (data_id << 0) | (data << 8) | (ecc << 24);
2125 2043
@@ -2163,14 +2081,35 @@ int dsi_vc_dcs_write(int channel, u8 *data, int len)
2163 2081
2164 r = dsi_vc_dcs_write_nosync(channel, data, len); 2082 r = dsi_vc_dcs_write_nosync(channel, data, len);
2165 if (r) 2083 if (r)
2166 return r; 2084 goto err;
2167 2085
2168 r = dsi_vc_send_bta_sync(channel); 2086 r = dsi_vc_send_bta_sync(channel);
2087 if (r)
2088 goto err;
2169 2089
2090 return 0;
2091err:
2092 DSSERR("dsi_vc_dcs_write(ch %d, cmd 0x%02x, len %d) failed\n",
2093 channel, data[0], len);
2170 return r; 2094 return r;
2171} 2095}
2172EXPORT_SYMBOL(dsi_vc_dcs_write); 2096EXPORT_SYMBOL(dsi_vc_dcs_write);
2173 2097
2098int dsi_vc_dcs_write_0(int channel, u8 dcs_cmd)
2099{
2100 return dsi_vc_dcs_write(channel, &dcs_cmd, 1);
2101}
2102EXPORT_SYMBOL(dsi_vc_dcs_write_0);
2103
2104int dsi_vc_dcs_write_1(int channel, u8 dcs_cmd, u8 param)
2105{
2106 u8 buf[2];
2107 buf[0] = dcs_cmd;
2108 buf[1] = param;
2109 return dsi_vc_dcs_write(channel, buf, 2);
2110}
2111EXPORT_SYMBOL(dsi_vc_dcs_write_1);
2112
2174int dsi_vc_dcs_read(int channel, u8 dcs_cmd, u8 *buf, int buflen) 2113int dsi_vc_dcs_read(int channel, u8 dcs_cmd, u8 *buf, int buflen)
2175{ 2114{
2176 u32 val; 2115 u32 val;
@@ -2182,16 +2121,17 @@ int dsi_vc_dcs_read(int channel, u8 dcs_cmd, u8 *buf, int buflen)
2182 2121
2183 r = dsi_vc_send_short(channel, DSI_DT_DCS_READ, dcs_cmd, 0); 2122 r = dsi_vc_send_short(channel, DSI_DT_DCS_READ, dcs_cmd, 0);
2184 if (r) 2123 if (r)
2185 return r; 2124 goto err;
2186 2125
2187 r = dsi_vc_send_bta_sync(channel); 2126 r = dsi_vc_send_bta_sync(channel);
2188 if (r) 2127 if (r)
2189 return r; 2128 goto err;
2190 2129
2191 /* RX_FIFO_NOT_EMPTY */ 2130 /* RX_FIFO_NOT_EMPTY */
2192 if (REG_GET(DSI_VC_CTRL(channel), 20, 20) == 0) { 2131 if (REG_GET(DSI_VC_CTRL(channel), 20, 20) == 0) {
2193 DSSERR("RX fifo empty when trying to read.\n"); 2132 DSSERR("RX fifo empty when trying to read.\n");
2194 return -EIO; 2133 r = -EIO;
2134 goto err;
2195 } 2135 }
2196 2136
2197 val = dsi_read_reg(DSI_VC_SHORT_PACKET_HEADER(channel)); 2137 val = dsi_read_reg(DSI_VC_SHORT_PACKET_HEADER(channel));
@@ -2201,15 +2141,18 @@ int dsi_vc_dcs_read(int channel, u8 dcs_cmd, u8 *buf, int buflen)
2201 if (dt == DSI_DT_RX_ACK_WITH_ERR) { 2141 if (dt == DSI_DT_RX_ACK_WITH_ERR) {
2202 u16 err = FLD_GET(val, 23, 8); 2142 u16 err = FLD_GET(val, 23, 8);
2203 dsi_show_rx_ack_with_err(err); 2143 dsi_show_rx_ack_with_err(err);
2204 return -EIO; 2144 r = -EIO;
2145 goto err;
2205 2146
2206 } else if (dt == DSI_DT_RX_SHORT_READ_1) { 2147 } else if (dt == DSI_DT_RX_SHORT_READ_1) {
2207 u8 data = FLD_GET(val, 15, 8); 2148 u8 data = FLD_GET(val, 15, 8);
2208 if (dsi.debug_read) 2149 if (dsi.debug_read)
2209 DSSDBG("\tDCS short response, 1 byte: %02x\n", data); 2150 DSSDBG("\tDCS short response, 1 byte: %02x\n", data);
2210 2151
2211 if (buflen < 1) 2152 if (buflen < 1) {
2212 return -EIO; 2153 r = -EIO;
2154 goto err;
2155 }
2213 2156
2214 buf[0] = data; 2157 buf[0] = data;
2215 2158
@@ -2219,8 +2162,10 @@ int dsi_vc_dcs_read(int channel, u8 dcs_cmd, u8 *buf, int buflen)
2219 if (dsi.debug_read) 2162 if (dsi.debug_read)
2220 DSSDBG("\tDCS short response, 2 byte: %04x\n", data); 2163 DSSDBG("\tDCS short response, 2 byte: %04x\n", data);
2221 2164
2222 if (buflen < 2) 2165 if (buflen < 2) {
2223 return -EIO; 2166 r = -EIO;
2167 goto err;
2168 }
2224 2169
2225 buf[0] = data & 0xff; 2170 buf[0] = data & 0xff;
2226 buf[1] = (data >> 8) & 0xff; 2171 buf[1] = (data >> 8) & 0xff;
@@ -2232,8 +2177,10 @@ int dsi_vc_dcs_read(int channel, u8 dcs_cmd, u8 *buf, int buflen)
2232 if (dsi.debug_read) 2177 if (dsi.debug_read)
2233 DSSDBG("\tDCS long response, len %d\n", len); 2178 DSSDBG("\tDCS long response, len %d\n", len);
2234 2179
2235 if (len > buflen) 2180 if (len > buflen) {
2236 return -EIO; 2181 r = -EIO;
2182 goto err;
2183 }
2237 2184
2238 /* two byte checksum ends the packet, not included in len */ 2185 /* two byte checksum ends the packet, not included in len */
2239 for (w = 0; w < len + 2;) { 2186 for (w = 0; w < len + 2;) {
@@ -2255,14 +2202,52 @@ int dsi_vc_dcs_read(int channel, u8 dcs_cmd, u8 *buf, int buflen)
2255 } 2202 }
2256 2203
2257 return len; 2204 return len;
2258
2259 } else { 2205 } else {
2260 DSSERR("\tunknown datatype 0x%02x\n", dt); 2206 DSSERR("\tunknown datatype 0x%02x\n", dt);
2261 return -EIO; 2207 r = -EIO;
2208 goto err;
2262 } 2209 }
2210
2211 BUG();
2212err:
2213 DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n",
2214 channel, dcs_cmd);
2215 return r;
2216
2263} 2217}
2264EXPORT_SYMBOL(dsi_vc_dcs_read); 2218EXPORT_SYMBOL(dsi_vc_dcs_read);
2265 2219
2220int dsi_vc_dcs_read_1(int channel, u8 dcs_cmd, u8 *data)
2221{
2222 int r;
2223
2224 r = dsi_vc_dcs_read(channel, dcs_cmd, data, 1);
2225
2226 if (r < 0)
2227 return r;
2228
2229 if (r != 1)
2230 return -EIO;
2231
2232 return 0;
2233}
2234EXPORT_SYMBOL(dsi_vc_dcs_read_1);
2235
2236int dsi_vc_dcs_read_2(int channel, u8 dcs_cmd, u16 *data)
2237{
2238 int r;
2239
2240 r = dsi_vc_dcs_read(channel, dcs_cmd, (u8 *)data, 2);
2241
2242 if (r < 0)
2243 return r;
2244
2245 if (r != 2)
2246 return -EIO;
2247
2248 return 0;
2249}
2250EXPORT_SYMBOL(dsi_vc_dcs_read_2);
2266 2251
2267int dsi_vc_set_max_rx_packet_size(int channel, u16 len) 2252int dsi_vc_set_max_rx_packet_size(int channel, u16 len)
2268{ 2253{
@@ -2491,15 +2476,15 @@ static int dsi_proto_config(struct omap_dss_device *dssdev)
2491 u32 r; 2476 u32 r;
2492 int buswidth = 0; 2477 int buswidth = 0;
2493 2478
2494 dsi_config_tx_fifo(DSI_FIFO_SIZE_128, 2479 dsi_config_tx_fifo(DSI_FIFO_SIZE_32,
2495 DSI_FIFO_SIZE_0, 2480 DSI_FIFO_SIZE_32,
2496 DSI_FIFO_SIZE_0, 2481 DSI_FIFO_SIZE_32,
2497 DSI_FIFO_SIZE_0); 2482 DSI_FIFO_SIZE_32);
2498 2483
2499 dsi_config_rx_fifo(DSI_FIFO_SIZE_128, 2484 dsi_config_rx_fifo(DSI_FIFO_SIZE_32,
2500 DSI_FIFO_SIZE_0, 2485 DSI_FIFO_SIZE_32,
2501 DSI_FIFO_SIZE_0, 2486 DSI_FIFO_SIZE_32,
2502 DSI_FIFO_SIZE_0); 2487 DSI_FIFO_SIZE_32);
2503 2488
2504 /* XXX what values for the timeouts? */ 2489 /* XXX what values for the timeouts? */
2505 dsi_set_stop_state_counter(1000); 2490 dsi_set_stop_state_counter(1000);
@@ -2537,12 +2522,9 @@ static int dsi_proto_config(struct omap_dss_device *dssdev)
2537 dsi_write_reg(DSI_CTRL, r); 2522 dsi_write_reg(DSI_CTRL, r);
2538 2523
2539 dsi_vc_initial_config(0); 2524 dsi_vc_initial_config(0);
2540 2525 dsi_vc_initial_config(1);
2541 /* set all vc targets to peripheral 0 */ 2526 dsi_vc_initial_config(2);
2542 dsi.vc[0].dest_per = 0; 2527 dsi_vc_initial_config(3);
2543 dsi.vc[1].dest_per = 0;
2544 dsi.vc[2].dest_per = 0;
2545 dsi.vc[3].dest_per = 0;
2546 2528
2547 return 0; 2529 return 0;
2548} 2530}
@@ -2777,18 +2759,16 @@ static void dsi_update_screen_dispc(struct omap_dss_device *dssdev,
2777 unsigned packet_payload; 2759 unsigned packet_payload;
2778 unsigned packet_len; 2760 unsigned packet_len;
2779 u32 l; 2761 u32 l;
2780 bool use_te_trigger; 2762 const unsigned channel = dsi.update_channel;
2781 const unsigned channel = 0;
2782 /* line buffer is 1024 x 24bits */ 2763 /* line buffer is 1024 x 24bits */
2783 /* XXX: for some reason using full buffer size causes considerable TX 2764 /* XXX: for some reason using full buffer size causes considerable TX
2784 * slowdown with update sizes that fill the whole buffer */ 2765 * slowdown with update sizes that fill the whole buffer */
2785 const unsigned line_buf_size = 1023 * 3; 2766 const unsigned line_buf_size = 1023 * 3;
2786 2767
2787 use_te_trigger = dsi.te_enabled && !dsi.use_ext_te; 2768 DSSDBG("dsi_update_screen_dispc(%d,%d %dx%d)\n",
2769 x, y, w, h);
2788 2770
2789 if (dsi.update_mode != OMAP_DSS_UPDATE_AUTO) 2771 dsi_vc_config_vp(channel);
2790 DSSDBG("dsi_update_screen_dispc(%d,%d %dx%d)\n",
2791 x, y, w, h);
2792 2772
2793 bytespp = dssdev->ctrl.pixel_size / 8; 2773 bytespp = dssdev->ctrl.pixel_size / 8;
2794 bytespl = w * bytespp; 2774 bytespl = w * bytespp;
@@ -2808,15 +2788,12 @@ static void dsi_update_screen_dispc(struct omap_dss_device *dssdev,
2808 if (bytespf % packet_payload) 2788 if (bytespf % packet_payload)
2809 total_len += (bytespf % packet_payload) + 1; 2789 total_len += (bytespf % packet_payload) + 1;
2810 2790
2811 if (0)
2812 dsi_vc_print_status(1);
2813
2814 l = FLD_VAL(total_len, 23, 0); /* TE_SIZE */ 2791 l = FLD_VAL(total_len, 23, 0); /* TE_SIZE */
2815 dsi_write_reg(DSI_VC_TE(channel), l); 2792 dsi_write_reg(DSI_VC_TE(channel), l);
2816 2793
2817 dsi_vc_write_long_header(channel, DSI_DT_DCS_LONG_WRITE, packet_len, 0); 2794 dsi_vc_write_long_header(channel, DSI_DT_DCS_LONG_WRITE, packet_len, 0);
2818 2795
2819 if (use_te_trigger) 2796 if (dsi.te_enabled)
2820 l = FLD_MOD(l, 1, 30, 30); /* TE_EN */ 2797 l = FLD_MOD(l, 1, 30, 30); /* TE_EN */
2821 else 2798 else
2822 l = FLD_MOD(l, 1, 31, 31); /* TE_START */ 2799 l = FLD_MOD(l, 1, 31, 31); /* TE_START */
@@ -2830,9 +2807,14 @@ static void dsi_update_screen_dispc(struct omap_dss_device *dssdev,
2830 */ 2807 */
2831 dispc_disable_sidle(); 2808 dispc_disable_sidle();
2832 2809
2810 dsi_perf_mark_start();
2811
2812 schedule_delayed_work(&dsi.framedone_timeout_work,
2813 msecs_to_jiffies(250));
2814
2833 dss_start_update(dssdev); 2815 dss_start_update(dssdev);
2834 2816
2835 if (use_te_trigger) { 2817 if (dsi.te_enabled) {
2836 /* disable LP_RX_TO, so that we can receive TE. Time to wait 2818 /* disable LP_RX_TO, so that we can receive TE. Time to wait
2837 * for TE is longer than the timer allows */ 2819 * for TE is longer than the timer allows */
2838 REG_FLD_MOD(DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */ 2820 REG_FLD_MOD(DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */
@@ -2852,110 +2834,64 @@ static void dsi_te_timeout(unsigned long arg)
2852} 2834}
2853#endif 2835#endif
2854 2836
2855static void dsi_framedone_irq_callback(void *data, u32 mask) 2837static void dsi_framedone_timeout_work_callback(struct work_struct *work)
2856{ 2838{
2857 /* Note: We get FRAMEDONE when DISPC has finished sending pixels and 2839 int r;
2858 * turns itself off. However, DSI still has the pixels in its buffers, 2840 const int channel = dsi.update_channel;
2859 * and is sending the data. 2841
2860 */ 2842 DSSERR("Framedone not received for 250ms!\n");
2861 2843
2862 /* SIDLEMODE back to smart-idle */ 2844 /* SIDLEMODE back to smart-idle */
2863 dispc_enable_sidle(); 2845 dispc_enable_sidle();
2864 2846
2865 dsi.framedone_received = true; 2847 if (dsi.te_enabled) {
2866 wake_up(&dsi.waitqueue); 2848 /* enable LP_RX_TO again after the TE */
2867} 2849 REG_FLD_MOD(DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
2868
2869static void dsi_set_update_region(struct omap_dss_device *dssdev,
2870 u16 x, u16 y, u16 w, u16 h)
2871{
2872 spin_lock(&dsi.update_lock);
2873 if (dsi.update_region.dirty) {
2874 dsi.update_region.x = min(x, dsi.update_region.x);
2875 dsi.update_region.y = min(y, dsi.update_region.y);
2876 dsi.update_region.w = max(w, dsi.update_region.w);
2877 dsi.update_region.h = max(h, dsi.update_region.h);
2878 } else {
2879 dsi.update_region.x = x;
2880 dsi.update_region.y = y;
2881 dsi.update_region.w = w;
2882 dsi.update_region.h = h;
2883 } 2850 }
2884 2851
2885 dsi.update_region.device = dssdev; 2852 /* Send BTA after the frame. We need this for the TE to work, as TE
2886 dsi.update_region.dirty = true; 2853 * trigger is only sent for BTAs without preceding packet. Thus we need
2887 2854 * to BTA after the pixel packets so that next BTA will cause TE
2888 spin_unlock(&dsi.update_lock); 2855 * trigger.
2889 2856 *
2890} 2857 * This is not needed when TE is not in use, but we do it anyway to
2891 2858 * make sure that the transfer has been completed. It would be more
2892static int dsi_set_update_mode(struct omap_dss_device *dssdev, 2859 * optimal, but more complex, to wait only just before starting next
2893 enum omap_dss_update_mode mode) 2860 * transfer. */
2894{ 2861 r = dsi_vc_send_bta_sync(channel);
2895 int r = 0; 2862 if (r)
2896 int i; 2863 DSSERR("BTA after framedone failed\n");
2897
2898 WARN_ON(!mutex_is_locked(&dsi.bus_lock));
2899
2900 if (dsi.update_mode != mode) {
2901 dsi.update_mode = mode;
2902
2903 /* Mark the overlays dirty, and do apply(), so that we get the
2904 * overlays configured properly after update mode change. */
2905 for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
2906 struct omap_overlay *ovl;
2907 ovl = omap_dss_get_overlay(i);
2908 if (ovl->manager == dssdev->manager)
2909 ovl->info_dirty = true;
2910 }
2911
2912 r = dssdev->manager->apply(dssdev->manager);
2913
2914 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE &&
2915 mode == OMAP_DSS_UPDATE_AUTO) {
2916 u16 w, h;
2917
2918 DSSDBG("starting auto update\n");
2919
2920 dssdev->get_resolution(dssdev, &w, &h);
2921
2922 dsi_set_update_region(dssdev, 0, 0, w, h);
2923
2924 dsi_perf_mark_start_auto();
2925 2864
2926 wake_up(&dsi.waitqueue); 2865 /* RX_FIFO_NOT_EMPTY */
2927 } 2866 if (REG_GET(DSI_VC_CTRL(channel), 20, 20)) {
2867 DSSERR("Received error during frame transfer:\n");
2868 dsi_vc_flush_receive_data(channel);
2928 } 2869 }
2929 2870
2930 return r; 2871 dsi.framedone_callback(-ETIMEDOUT, dsi.framedone_data);
2931} 2872}
2932 2873
2933static int dsi_set_te(struct omap_dss_device *dssdev, bool enable) 2874static void dsi_framedone_irq_callback(void *data, u32 mask)
2934{ 2875{
2935 int r = 0; 2876 /* Note: We get FRAMEDONE when DISPC has finished sending pixels and
2877 * turns itself off. However, DSI still has the pixels in its buffers,
2878 * and is sending the data.
2879 */
2936 2880
2937 if (dssdev->driver->enable_te) { 2881 /* SIDLEMODE back to smart-idle */
2938 r = dssdev->driver->enable_te(dssdev, enable); 2882 dispc_enable_sidle();
2939 /* XXX for some reason, DSI TE breaks if we don't wait here.
2940 * Panel bug? Needs more studying */
2941 msleep(100);
2942 }
2943 2883
2944 return r; 2884 schedule_work(&dsi.framedone_work);
2945} 2885}
2946 2886
2947static void dsi_handle_framedone(void) 2887static void dsi_handle_framedone(void)
2948{ 2888{
2949 int r; 2889 int r;
2950 const int channel = 0; 2890 const int channel = dsi.update_channel;
2951 bool use_te_trigger;
2952
2953 use_te_trigger = dsi.te_enabled && !dsi.use_ext_te;
2954 2891
2955 if (dsi.update_mode != OMAP_DSS_UPDATE_AUTO) 2892 DSSDBG("FRAMEDONE\n");
2956 DSSDBG("FRAMEDONE\n");
2957 2893
2958 if (use_te_trigger) { 2894 if (dsi.te_enabled) {
2959 /* enable LP_RX_TO again after the TE */ 2895 /* enable LP_RX_TO again after the TE */
2960 REG_FLD_MOD(DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */ 2896 REG_FLD_MOD(DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
2961 } 2897 }
@@ -2976,7 +2912,7 @@ static void dsi_handle_framedone(void)
2976 /* RX_FIFO_NOT_EMPTY */ 2912 /* RX_FIFO_NOT_EMPTY */
2977 if (REG_GET(DSI_VC_CTRL(channel), 20, 20)) { 2913 if (REG_GET(DSI_VC_CTRL(channel), 20, 20)) {
2978 DSSERR("Received error during frame transfer:\n"); 2914 DSSERR("Received error during frame transfer:\n");
2979 dsi_vc_flush_receive_data(0); 2915 dsi_vc_flush_receive_data(channel);
2980 } 2916 }
2981 2917
2982#ifdef CONFIG_OMAP2_DSS_FAKE_VSYNC 2918#ifdef CONFIG_OMAP2_DSS_FAKE_VSYNC
@@ -2984,118 +2920,79 @@ static void dsi_handle_framedone(void)
2984#endif 2920#endif
2985} 2921}
2986 2922
2987static int dsi_update_thread(void *data) 2923static void dsi_framedone_work_callback(struct work_struct *work)
2988{ 2924{
2989 unsigned long timeout; 2925 DSSDBGF();
2990 struct omap_dss_device *device;
2991 u16 x, y, w, h;
2992
2993 while (1) {
2994 bool sched;
2995
2996 wait_event_interruptible(dsi.waitqueue,
2997 dsi.update_mode == OMAP_DSS_UPDATE_AUTO ||
2998 (dsi.update_mode == OMAP_DSS_UPDATE_MANUAL &&
2999 dsi.update_region.dirty == true) ||
3000 kthread_should_stop());
3001
3002 if (kthread_should_stop())
3003 break;
3004
3005 dsi_bus_lock();
3006
3007 if (dsi.update_mode == OMAP_DSS_UPDATE_DISABLED ||
3008 kthread_should_stop()) {
3009 dsi_bus_unlock();
3010 break;
3011 }
3012
3013 dsi_perf_mark_setup();
3014
3015 if (dsi.update_region.dirty) {
3016 spin_lock(&dsi.update_lock);
3017 dsi.active_update_region = dsi.update_region;
3018 dsi.update_region.dirty = false;
3019 spin_unlock(&dsi.update_lock);
3020 }
3021 2926
3022 device = dsi.active_update_region.device; 2927 cancel_delayed_work_sync(&dsi.framedone_timeout_work);
3023 x = dsi.active_update_region.x;
3024 y = dsi.active_update_region.y;
3025 w = dsi.active_update_region.w;
3026 h = dsi.active_update_region.h;
3027 2928
3028 if (device->manager->caps & OMAP_DSS_OVL_MGR_CAP_DISPC) { 2929 dsi_handle_framedone();
3029 2930
3030 if (dsi.update_mode == OMAP_DSS_UPDATE_MANUAL) 2931 dsi_perf_show("DISPC");
3031 dss_setup_partial_planes(device,
3032 &x, &y, &w, &h);
3033 2932
3034 dispc_set_lcd_size(w, h); 2933 dsi.framedone_callback(0, dsi.framedone_data);
3035 } 2934}
3036 2935
3037 if (dsi.active_update_region.dirty) { 2936int omap_dsi_prepare_update(struct omap_dss_device *dssdev,
3038 dsi.active_update_region.dirty = false; 2937 u16 *x, u16 *y, u16 *w, u16 *h)
3039 /* XXX TODO we don't need to send the coords, if they 2938{
3040 * are the same that are already programmed to the 2939 u16 dw, dh;
3041 * panel. That should speed up manual update a bit */
3042 device->driver->setup_update(device, x, y, w, h);
3043 }
3044 2940
3045 dsi_perf_mark_start(); 2941 dssdev->driver->get_resolution(dssdev, &dw, &dh);
3046 2942
3047 if (device->manager->caps & OMAP_DSS_OVL_MGR_CAP_DISPC) { 2943 if (*x > dw || *y > dh)
3048 dsi_vc_config_vp(0); 2944 return -EINVAL;
3049 2945
3050 if (dsi.te_enabled && dsi.use_ext_te) 2946 if (*x + *w > dw)
3051 device->driver->wait_for_te(device); 2947 return -EINVAL;
3052 2948
3053 dsi.framedone_received = false; 2949 if (*y + *h > dh)
2950 return -EINVAL;
3054 2951
3055 dsi_update_screen_dispc(device, x, y, w, h); 2952 if (*w == 1)
2953 return -EINVAL;
3056 2954
3057 /* wait for framedone */ 2955 if (*w == 0 || *h == 0)
3058 timeout = msecs_to_jiffies(1000); 2956 return -EINVAL;
3059 wait_event_timeout(dsi.waitqueue,
3060 dsi.framedone_received == true,
3061 timeout);
3062 2957
3063 if (!dsi.framedone_received) { 2958 dsi_perf_mark_setup();
3064 DSSERR("framedone timeout\n");
3065 DSSERR("failed update %d,%d %dx%d\n",
3066 x, y, w, h);
3067 2959
3068 dispc_enable_sidle(); 2960 if (dssdev->manager->caps & OMAP_DSS_OVL_MGR_CAP_DISPC) {
3069 dispc_enable_lcd_out(0); 2961 dss_setup_partial_planes(dssdev, x, y, w, h);
2962 dispc_set_lcd_size(*w, *h);
2963 }
3070 2964
3071 dsi_reset_tx_fifo(0); 2965 return 0;
3072 } else { 2966}
3073 dsi_handle_framedone(); 2967EXPORT_SYMBOL(omap_dsi_prepare_update);
3074 dsi_perf_show("DISPC");
3075 }
3076 } else {
3077 dsi_update_screen_l4(device, x, y, w, h);
3078 dsi_perf_show("L4");
3079 }
3080 2968
3081 sched = atomic_read(&dsi.bus_lock.count) < 0; 2969int omap_dsi_update(struct omap_dss_device *dssdev,
2970 int channel,
2971 u16 x, u16 y, u16 w, u16 h,
2972 void (*callback)(int, void *), void *data)
2973{
2974 dsi.update_channel = channel;
3082 2975
3083 complete_all(&dsi.update_completion); 2976 if (dssdev->manager->caps & OMAP_DSS_OVL_MGR_CAP_DISPC) {
2977 dsi.framedone_callback = callback;
2978 dsi.framedone_data = data;
3084 2979
3085 dsi_bus_unlock(); 2980 dsi.update_region.x = x;
2981 dsi.update_region.y = y;
2982 dsi.update_region.w = w;
2983 dsi.update_region.h = h;
2984 dsi.update_region.device = dssdev;
3086 2985
3087 /* XXX We need to give others chance to get the bus lock. Is 2986 dsi_update_screen_dispc(dssdev, x, y, w, h);
3088 * there a better way for this? */ 2987 } else {
3089 if (dsi.update_mode == OMAP_DSS_UPDATE_AUTO && sched) 2988 dsi_update_screen_l4(dssdev, x, y, w, h);
3090 schedule_timeout_interruptible(1); 2989 dsi_perf_show("L4");
2990 callback(0, data);
3091 } 2991 }
3092 2992
3093 DSSDBG("update thread exiting\n");
3094
3095 return 0; 2993 return 0;
3096} 2994}
3097 2995EXPORT_SYMBOL(omap_dsi_update);
3098
3099 2996
3100/* Display funcs */ 2997/* Display funcs */
3101 2998
@@ -3203,7 +3100,8 @@ static int dsi_display_init_dsi(struct omap_dss_device *dssdev)
3203 if (r) 3100 if (r)
3204 goto err1; 3101 goto err1;
3205 3102
3206 dss_select_clk_source(true, true); 3103 dss_select_dispc_clk_source(DSS_SRC_DSI1_PLL_FCLK);
3104 dss_select_dsi_clk_source(DSS_SRC_DSI2_PLL_FCLK);
3207 3105
3208 DSSDBG("PLL OK\n"); 3106 DSSDBG("PLL OK\n");
3209 3107
@@ -3229,25 +3127,18 @@ static int dsi_display_init_dsi(struct omap_dss_device *dssdev)
3229 3127
3230 /* enable interface */ 3128 /* enable interface */
3231 dsi_vc_enable(0, 1); 3129 dsi_vc_enable(0, 1);
3130 dsi_vc_enable(1, 1);
3131 dsi_vc_enable(2, 1);
3132 dsi_vc_enable(3, 1);
3232 dsi_if_enable(1); 3133 dsi_if_enable(1);
3233 dsi_force_tx_stop_mode_io(); 3134 dsi_force_tx_stop_mode_io();
3234 3135
3235 if (dssdev->driver->enable) {
3236 r = dssdev->driver->enable(dssdev);
3237 if (r)
3238 goto err4;
3239 }
3240
3241 /* enable high-speed after initial config */
3242 dsi_vc_enable_hs(0, 1);
3243
3244 return 0; 3136 return 0;
3245err4:
3246 dsi_if_enable(0);
3247err3: 3137err3:
3248 dsi_complexio_uninit(); 3138 dsi_complexio_uninit();
3249err2: 3139err2:
3250 dss_select_clk_source(false, false); 3140 dss_select_dispc_clk_source(DSS_SRC_DSS1_ALWON_FCLK);
3141 dss_select_dsi_clk_source(DSS_SRC_DSS1_ALWON_FCLK);
3251err1: 3142err1:
3252 dsi_pll_uninit(); 3143 dsi_pll_uninit();
3253err0: 3144err0:
@@ -3256,10 +3147,8 @@ err0:
3256 3147
3257static void dsi_display_uninit_dsi(struct omap_dss_device *dssdev) 3148static void dsi_display_uninit_dsi(struct omap_dss_device *dssdev)
3258{ 3149{
3259 if (dssdev->driver->disable) 3150 dss_select_dispc_clk_source(DSS_SRC_DSS1_ALWON_FCLK);
3260 dssdev->driver->disable(dssdev); 3151 dss_select_dsi_clk_source(DSS_SRC_DSS1_ALWON_FCLK);
3261
3262 dss_select_clk_source(false, false);
3263 dsi_complexio_uninit(); 3152 dsi_complexio_uninit();
3264 dsi_pll_uninit(); 3153 dsi_pll_uninit();
3265} 3154}
@@ -3280,14 +3169,15 @@ static int dsi_core_init(void)
3280 return 0; 3169 return 0;
3281} 3170}
3282 3171
3283static int dsi_display_enable(struct omap_dss_device *dssdev) 3172int omapdss_dsi_display_enable(struct omap_dss_device *dssdev)
3284{ 3173{
3285 int r = 0; 3174 int r = 0;
3286 3175
3287 DSSDBG("dsi_display_enable\n"); 3176 DSSDBG("dsi_display_enable\n");
3288 3177
3178 WARN_ON(!dsi_bus_is_locked());
3179
3289 mutex_lock(&dsi.lock); 3180 mutex_lock(&dsi.lock);
3290 dsi_bus_lock();
3291 3181
3292 r = omap_dss_start_device(dssdev); 3182 r = omap_dss_start_device(dssdev);
3293 if (r) { 3183 if (r) {
@@ -3295,100 +3185,47 @@ static int dsi_display_enable(struct omap_dss_device *dssdev)
3295 goto err0; 3185 goto err0;
3296 } 3186 }
3297 3187
3298 if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) {
3299 DSSERR("dssdev already enabled\n");
3300 r = -EINVAL;
3301 goto err1;
3302 }
3303
3304 enable_clocks(1); 3188 enable_clocks(1);
3305 dsi_enable_pll_clock(1); 3189 dsi_enable_pll_clock(1);
3306 3190
3307 r = _dsi_reset(); 3191 r = _dsi_reset();
3308 if (r) 3192 if (r)
3309 goto err2; 3193 goto err1;
3310 3194
3311 dsi_core_init(); 3195 dsi_core_init();
3312 3196
3313 r = dsi_display_init_dispc(dssdev); 3197 r = dsi_display_init_dispc(dssdev);
3314 if (r) 3198 if (r)
3315 goto err2; 3199 goto err1;
3316 3200
3317 r = dsi_display_init_dsi(dssdev); 3201 r = dsi_display_init_dsi(dssdev);
3318 if (r) 3202 if (r)
3319 goto err3; 3203 goto err2;
3320
3321 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
3322
3323 dsi.use_ext_te = dssdev->phy.dsi.ext_te;
3324 r = dsi_set_te(dssdev, dsi.te_enabled);
3325 if (r)
3326 goto err4;
3327
3328 dsi_set_update_mode(dssdev, dsi.user_update_mode);
3329 3204
3330 dsi_bus_unlock();
3331 mutex_unlock(&dsi.lock); 3205 mutex_unlock(&dsi.lock);
3332 3206
3333 return 0; 3207 return 0;
3334 3208
3335err4:
3336
3337 dsi_display_uninit_dsi(dssdev);
3338err3:
3339 dsi_display_uninit_dispc(dssdev);
3340err2: 3209err2:
3210 dsi_display_uninit_dispc(dssdev);
3211err1:
3341 enable_clocks(0); 3212 enable_clocks(0);
3342 dsi_enable_pll_clock(0); 3213 dsi_enable_pll_clock(0);
3343err1:
3344 omap_dss_stop_device(dssdev); 3214 omap_dss_stop_device(dssdev);
3345err0: 3215err0:
3346 dsi_bus_unlock();
3347 mutex_unlock(&dsi.lock); 3216 mutex_unlock(&dsi.lock);
3348 DSSDBG("dsi_display_enable FAILED\n"); 3217 DSSDBG("dsi_display_enable FAILED\n");
3349 return r; 3218 return r;
3350} 3219}
3220EXPORT_SYMBOL(omapdss_dsi_display_enable);
3351 3221
3352static void dsi_display_disable(struct omap_dss_device *dssdev) 3222void omapdss_dsi_display_disable(struct omap_dss_device *dssdev)
3353{ 3223{
3354 DSSDBG("dsi_display_disable\n"); 3224 DSSDBG("dsi_display_disable\n");
3355 3225
3356 mutex_lock(&dsi.lock); 3226 WARN_ON(!dsi_bus_is_locked());
3357 dsi_bus_lock();
3358
3359 if (dssdev->state == OMAP_DSS_DISPLAY_DISABLED ||
3360 dssdev->state == OMAP_DSS_DISPLAY_SUSPENDED)
3361 goto end;
3362
3363 dsi.update_mode = OMAP_DSS_UPDATE_DISABLED;
3364 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
3365
3366 dsi_display_uninit_dispc(dssdev);
3367
3368 dsi_display_uninit_dsi(dssdev);
3369
3370 enable_clocks(0);
3371 dsi_enable_pll_clock(0);
3372
3373 omap_dss_stop_device(dssdev);
3374end:
3375 dsi_bus_unlock();
3376 mutex_unlock(&dsi.lock);
3377}
3378
3379static int dsi_display_suspend(struct omap_dss_device *dssdev)
3380{
3381 DSSDBG("dsi_display_suspend\n");
3382 3227
3383 mutex_lock(&dsi.lock); 3228 mutex_lock(&dsi.lock);
3384 dsi_bus_lock();
3385
3386 if (dssdev->state == OMAP_DSS_DISPLAY_DISABLED ||
3387 dssdev->state == OMAP_DSS_DISPLAY_SUSPENDED)
3388 goto end;
3389
3390 dsi.update_mode = OMAP_DSS_UPDATE_DISABLED;
3391 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
3392 3229
3393 dsi_display_uninit_dispc(dssdev); 3230 dsi_display_uninit_dispc(dssdev);
3394 3231
@@ -3396,312 +3233,19 @@ static int dsi_display_suspend(struct omap_dss_device *dssdev)
3396 3233
3397 enable_clocks(0); 3234 enable_clocks(0);
3398 dsi_enable_pll_clock(0); 3235 dsi_enable_pll_clock(0);
3399end:
3400 dsi_bus_unlock();
3401 mutex_unlock(&dsi.lock);
3402
3403 return 0;
3404}
3405
3406static int dsi_display_resume(struct omap_dss_device *dssdev)
3407{
3408 int r;
3409
3410 DSSDBG("dsi_display_resume\n");
3411
3412 mutex_lock(&dsi.lock);
3413 dsi_bus_lock();
3414
3415 if (dssdev->state != OMAP_DSS_DISPLAY_SUSPENDED) {
3416 DSSERR("dssdev not suspended\n");
3417 r = -EINVAL;
3418 goto err0;
3419 }
3420
3421 enable_clocks(1);
3422 dsi_enable_pll_clock(1);
3423
3424 r = _dsi_reset();
3425 if (r)
3426 goto err1;
3427
3428 dsi_core_init();
3429
3430 r = dsi_display_init_dispc(dssdev);
3431 if (r)
3432 goto err1;
3433
3434 r = dsi_display_init_dsi(dssdev);
3435 if (r)
3436 goto err2;
3437
3438 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
3439
3440 r = dsi_set_te(dssdev, dsi.te_enabled);
3441 if (r)
3442 goto err2;
3443
3444 dsi_set_update_mode(dssdev, dsi.user_update_mode);
3445
3446 dsi_bus_unlock();
3447 mutex_unlock(&dsi.lock);
3448
3449 return 0;
3450
3451err2:
3452 dsi_display_uninit_dispc(dssdev);
3453err1:
3454 enable_clocks(0);
3455 dsi_enable_pll_clock(0);
3456err0:
3457 dsi_bus_unlock();
3458 mutex_unlock(&dsi.lock);
3459 DSSDBG("dsi_display_resume FAILED\n");
3460 return r;
3461}
3462
3463static int dsi_display_update(struct omap_dss_device *dssdev,
3464 u16 x, u16 y, u16 w, u16 h)
3465{
3466 int r = 0;
3467 u16 dw, dh;
3468
3469 DSSDBG("dsi_display_update(%d,%d %dx%d)\n", x, y, w, h);
3470 3236
3471 mutex_lock(&dsi.lock); 3237 omap_dss_stop_device(dssdev);
3472
3473 if (dsi.update_mode != OMAP_DSS_UPDATE_MANUAL)
3474 goto end;
3475
3476 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
3477 goto end;
3478
3479 dssdev->get_resolution(dssdev, &dw, &dh);
3480
3481 if (x > dw || y > dh)
3482 goto end;
3483
3484 if (x + w > dw)
3485 w = dw - x;
3486
3487 if (y + h > dh)
3488 h = dh - y;
3489
3490 if (w == 0 || h == 0)
3491 goto end;
3492
3493 if (w == 1) {
3494 r = -EINVAL;
3495 goto end;
3496 }
3497
3498 dsi_set_update_region(dssdev, x, y, w, h);
3499
3500 wake_up(&dsi.waitqueue);
3501
3502end:
3503 mutex_unlock(&dsi.lock);
3504
3505 return r;
3506}
3507
3508static int dsi_display_sync(struct omap_dss_device *dssdev)
3509{
3510 bool wait;
3511
3512 DSSDBG("dsi_display_sync()\n");
3513
3514 mutex_lock(&dsi.lock);
3515 dsi_bus_lock();
3516
3517 if (dsi.update_mode == OMAP_DSS_UPDATE_MANUAL &&
3518 dsi.update_region.dirty) {
3519 INIT_COMPLETION(dsi.update_completion);
3520 wait = true;
3521 } else {
3522 wait = false;
3523 }
3524
3525 dsi_bus_unlock();
3526 mutex_unlock(&dsi.lock);
3527
3528 if (wait)
3529 wait_for_completion_interruptible(&dsi.update_completion);
3530
3531 DSSDBG("dsi_display_sync() done\n");
3532 return 0;
3533}
3534
3535static int dsi_display_set_update_mode(struct omap_dss_device *dssdev,
3536 enum omap_dss_update_mode mode)
3537{
3538 int r = 0;
3539
3540 DSSDBGF("%d", mode);
3541
3542 mutex_lock(&dsi.lock);
3543 dsi_bus_lock();
3544
3545 dsi.user_update_mode = mode;
3546 r = dsi_set_update_mode(dssdev, mode);
3547 3238
3548 dsi_bus_unlock();
3549 mutex_unlock(&dsi.lock); 3239 mutex_unlock(&dsi.lock);
3550
3551 return r;
3552} 3240}
3241EXPORT_SYMBOL(omapdss_dsi_display_disable);
3553 3242
3554static enum omap_dss_update_mode dsi_display_get_update_mode( 3243int omapdss_dsi_enable_te(struct omap_dss_device *dssdev, bool enable)
3555 struct omap_dss_device *dssdev)
3556{ 3244{
3557 return dsi.update_mode;
3558}
3559
3560
3561static int dsi_display_enable_te(struct omap_dss_device *dssdev, bool enable)
3562{
3563 int r = 0;
3564
3565 DSSDBGF("%d", enable);
3566
3567 if (!dssdev->driver->enable_te)
3568 return -ENOENT;
3569
3570 dsi_bus_lock();
3571
3572 dsi.te_enabled = enable; 3245 dsi.te_enabled = enable;
3573
3574 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
3575 goto end;
3576
3577 r = dsi_set_te(dssdev, enable);
3578end:
3579 dsi_bus_unlock();
3580
3581 return r;
3582}
3583
3584static int dsi_display_get_te(struct omap_dss_device *dssdev)
3585{
3586 return dsi.te_enabled;
3587}
3588
3589static int dsi_display_set_rotate(struct omap_dss_device *dssdev, u8 rotate)
3590{
3591
3592 DSSDBGF("%d", rotate);
3593
3594 if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate)
3595 return -EINVAL;
3596
3597 dsi_bus_lock();
3598 dssdev->driver->set_rotate(dssdev, rotate);
3599 if (dsi.update_mode == OMAP_DSS_UPDATE_AUTO) {
3600 u16 w, h;
3601 /* the display dimensions may have changed, so set a new
3602 * update region */
3603 dssdev->get_resolution(dssdev, &w, &h);
3604 dsi_set_update_region(dssdev, 0, 0, w, h);
3605 }
3606 dsi_bus_unlock();
3607
3608 return 0; 3246 return 0;
3609} 3247}
3610 3248EXPORT_SYMBOL(omapdss_dsi_enable_te);
3611static u8 dsi_display_get_rotate(struct omap_dss_device *dssdev)
3612{
3613 if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate)
3614 return 0;
3615
3616 return dssdev->driver->get_rotate(dssdev);
3617}
3618
3619static int dsi_display_set_mirror(struct omap_dss_device *dssdev, bool mirror)
3620{
3621 DSSDBGF("%d", mirror);
3622
3623 if (!dssdev->driver->set_mirror || !dssdev->driver->get_mirror)
3624 return -EINVAL;
3625
3626 dsi_bus_lock();
3627 dssdev->driver->set_mirror(dssdev, mirror);
3628 dsi_bus_unlock();
3629
3630 return 0;
3631}
3632
3633static bool dsi_display_get_mirror(struct omap_dss_device *dssdev)
3634{
3635 if (!dssdev->driver->set_mirror || !dssdev->driver->get_mirror)
3636 return 0;
3637
3638 return dssdev->driver->get_mirror(dssdev);
3639}
3640
3641static int dsi_display_run_test(struct omap_dss_device *dssdev, int test_num)
3642{
3643 int r;
3644
3645 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
3646 return -EIO;
3647
3648 DSSDBGF("%d", test_num);
3649
3650 dsi_bus_lock();
3651
3652 /* run test first in low speed mode */
3653 dsi_vc_enable_hs(0, 0);
3654
3655 if (dssdev->driver->run_test) {
3656 r = dssdev->driver->run_test(dssdev, test_num);
3657 if (r)
3658 goto end;
3659 }
3660
3661 /* then in high speed */
3662 dsi_vc_enable_hs(0, 1);
3663
3664 if (dssdev->driver->run_test) {
3665 r = dssdev->driver->run_test(dssdev, test_num);
3666 if (r)
3667 goto end;
3668 }
3669
3670end:
3671 dsi_vc_enable_hs(0, 1);
3672
3673 dsi_bus_unlock();
3674
3675 return r;
3676}
3677
3678static int dsi_display_memory_read(struct omap_dss_device *dssdev,
3679 void *buf, size_t size,
3680 u16 x, u16 y, u16 w, u16 h)
3681{
3682 int r;
3683
3684 DSSDBGF("");
3685
3686 if (!dssdev->driver->memory_read)
3687 return -EINVAL;
3688
3689 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
3690 return -EIO;
3691
3692 dsi_bus_lock();
3693
3694 r = dssdev->driver->memory_read(dssdev, buf, size,
3695 x, y, w, h);
3696
3697 /* Memory read usually changes the update area. This will
3698 * force the next update to re-set the update area */
3699 dsi.active_update_region.dirty = true;
3700
3701 dsi_bus_unlock();
3702
3703 return r;
3704}
3705 3249
3706void dsi_get_overlay_fifo_thresholds(enum omap_plane plane, 3250void dsi_get_overlay_fifo_thresholds(enum omap_plane plane,
3707 u32 fifo_size, enum omap_burst_size *burst_size, 3251 u32 fifo_size, enum omap_burst_size *burst_size,
@@ -3720,26 +3264,6 @@ int dsi_init_display(struct omap_dss_device *dssdev)
3720{ 3264{
3721 DSSDBG("DSI init\n"); 3265 DSSDBG("DSI init\n");
3722 3266
3723 dssdev->enable = dsi_display_enable;
3724 dssdev->disable = dsi_display_disable;
3725 dssdev->suspend = dsi_display_suspend;
3726 dssdev->resume = dsi_display_resume;
3727 dssdev->update = dsi_display_update;
3728 dssdev->sync = dsi_display_sync;
3729 dssdev->set_update_mode = dsi_display_set_update_mode;
3730 dssdev->get_update_mode = dsi_display_get_update_mode;
3731 dssdev->enable_te = dsi_display_enable_te;
3732 dssdev->get_te = dsi_display_get_te;
3733
3734 dssdev->get_rotate = dsi_display_get_rotate;
3735 dssdev->set_rotate = dsi_display_set_rotate;
3736
3737 dssdev->get_mirror = dsi_display_get_mirror;
3738 dssdev->set_mirror = dsi_display_set_mirror;
3739
3740 dssdev->run_test = dsi_display_run_test;
3741 dssdev->memory_read = dsi_display_memory_read;
3742
3743 /* XXX these should be figured out dynamically */ 3267 /* XXX these should be figured out dynamically */
3744 dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE | 3268 dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE |
3745 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM; 3269 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM;
@@ -3754,9 +3278,6 @@ int dsi_init(struct platform_device *pdev)
3754{ 3278{
3755 u32 rev; 3279 u32 rev;
3756 int r; 3280 int r;
3757 struct sched_param param = {
3758 .sched_priority = MAX_USER_RT_PRIO-1
3759 };
3760 3281
3761 spin_lock_init(&dsi.errors_lock); 3282 spin_lock_init(&dsi.errors_lock);
3762 dsi.errors = 0; 3283 dsi.errors = 0;
@@ -3767,31 +3288,19 @@ int dsi_init(struct platform_device *pdev)
3767#endif 3288#endif
3768 3289
3769 init_completion(&dsi.bta_completion); 3290 init_completion(&dsi.bta_completion);
3770 init_completion(&dsi.update_completion);
3771
3772 dsi.thread = kthread_create(dsi_update_thread, NULL, "dsi");
3773 if (IS_ERR(dsi.thread)) {
3774 DSSERR("cannot create kthread\n");
3775 r = PTR_ERR(dsi.thread);
3776 goto err0;
3777 }
3778 sched_setscheduler(dsi.thread, SCHED_FIFO, &param);
3779
3780 init_waitqueue_head(&dsi.waitqueue);
3781 spin_lock_init(&dsi.update_lock);
3782 3291
3783 mutex_init(&dsi.lock); 3292 mutex_init(&dsi.lock);
3784 mutex_init(&dsi.bus_lock); 3293 sema_init(&dsi.bus_lock, 1);
3294
3295 INIT_WORK(&dsi.framedone_work, dsi_framedone_work_callback);
3296 INIT_DELAYED_WORK_DEFERRABLE(&dsi.framedone_timeout_work,
3297 dsi_framedone_timeout_work_callback);
3785 3298
3786#ifdef DSI_CATCH_MISSING_TE 3299#ifdef DSI_CATCH_MISSING_TE
3787 init_timer(&dsi.te_timer); 3300 init_timer(&dsi.te_timer);
3788 dsi.te_timer.function = dsi_te_timeout; 3301 dsi.te_timer.function = dsi_te_timeout;
3789 dsi.te_timer.data = 0; 3302 dsi.te_timer.data = 0;
3790#endif 3303#endif
3791
3792 dsi.update_mode = OMAP_DSS_UPDATE_DISABLED;
3793 dsi.user_update_mode = OMAP_DSS_UPDATE_DISABLED;
3794
3795 dsi.base = ioremap(DSI_BASE, DSI_SZ_REGS); 3304 dsi.base = ioremap(DSI_BASE, DSI_SZ_REGS);
3796 if (!dsi.base) { 3305 if (!dsi.base) {
3797 DSSERR("can't ioremap DSI\n"); 3306 DSSERR("can't ioremap DSI\n");
@@ -3799,7 +3308,7 @@ int dsi_init(struct platform_device *pdev)
3799 goto err1; 3308 goto err1;
3800 } 3309 }
3801 3310
3802 dsi.vdds_dsi_reg = regulator_get(&pdev->dev, "vdds_dsi"); 3311 dsi.vdds_dsi_reg = dss_get_vdds_dsi();
3803 if (IS_ERR(dsi.vdds_dsi_reg)) { 3312 if (IS_ERR(dsi.vdds_dsi_reg)) {
3804 iounmap(dsi.base); 3313 iounmap(dsi.base);
3805 DSSERR("can't get VDDS_DSI regulator\n"); 3314 DSSERR("can't get VDDS_DSI regulator\n");
@@ -3815,23 +3324,15 @@ int dsi_init(struct platform_device *pdev)
3815 3324
3816 enable_clocks(0); 3325 enable_clocks(0);
3817 3326
3818 wake_up_process(dsi.thread);
3819
3820 return 0; 3327 return 0;
3821err2: 3328err2:
3822 iounmap(dsi.base); 3329 iounmap(dsi.base);
3823err1: 3330err1:
3824 kthread_stop(dsi.thread);
3825err0:
3826 return r; 3331 return r;
3827} 3332}
3828 3333
3829void dsi_exit(void) 3334void dsi_exit(void)
3830{ 3335{
3831 kthread_stop(dsi.thread);
3832
3833 regulator_put(dsi.vdds_dsi_reg);
3834
3835 iounmap(dsi.base); 3336 iounmap(dsi.base);
3836 3337
3837 DSSDBG("omap_dsi_exit\n"); 3338 DSSDBG("omap_dsi_exit\n");
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 0a26b7d84d41..8254a4232a53 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -68,6 +68,9 @@ static struct {
68 struct dss_clock_info cache_dss_cinfo; 68 struct dss_clock_info cache_dss_cinfo;
69 struct dispc_clock_info cache_dispc_cinfo; 69 struct dispc_clock_info cache_dispc_cinfo;
70 70
71 enum dss_clk_source dsi_clk_source;
72 enum dss_clk_source dispc_clk_source;
73
71 u32 ctx[DSS_SZ_REGS / sizeof(u32)]; 74 u32 ctx[DSS_SZ_REGS / sizeof(u32)];
72} dss; 75} dss;
73 76
@@ -247,23 +250,42 @@ void dss_dump_regs(struct seq_file *s)
247#undef DUMPREG 250#undef DUMPREG
248} 251}
249 252
250void dss_select_clk_source(bool dsi, bool dispc) 253void dss_select_dispc_clk_source(enum dss_clk_source clk_src)
254{
255 int b;
256
257 BUG_ON(clk_src != DSS_SRC_DSI1_PLL_FCLK &&
258 clk_src != DSS_SRC_DSS1_ALWON_FCLK);
259
260 b = clk_src == DSS_SRC_DSS1_ALWON_FCLK ? 0 : 1;
261
262 REG_FLD_MOD(DSS_CONTROL, b, 0, 0); /* DISPC_CLK_SWITCH */
263
264 dss.dispc_clk_source = clk_src;
265}
266
267void dss_select_dsi_clk_source(enum dss_clk_source clk_src)
251{ 268{
252 u32 r; 269 int b;
253 r = dss_read_reg(DSS_CONTROL); 270
254 r = FLD_MOD(r, dsi, 1, 1); /* DSI_CLK_SWITCH */ 271 BUG_ON(clk_src != DSS_SRC_DSI2_PLL_FCLK &&
255 r = FLD_MOD(r, dispc, 0, 0); /* DISPC_CLK_SWITCH */ 272 clk_src != DSS_SRC_DSS1_ALWON_FCLK);
256 dss_write_reg(DSS_CONTROL, r); 273
274 b = clk_src == DSS_SRC_DSS1_ALWON_FCLK ? 0 : 1;
275
276 REG_FLD_MOD(DSS_CONTROL, b, 1, 1); /* DSI_CLK_SWITCH */
277
278 dss.dsi_clk_source = clk_src;
257} 279}
258 280
259int dss_get_dsi_clk_source(void) 281enum dss_clk_source dss_get_dispc_clk_source(void)
260{ 282{
261 return FLD_GET(dss_read_reg(DSS_CONTROL), 1, 1); 283 return dss.dispc_clk_source;
262} 284}
263 285
264int dss_get_dispc_clk_source(void) 286enum dss_clk_source dss_get_dsi_clk_source(void)
265{ 287{
266 return FLD_GET(dss_read_reg(DSS_CONTROL), 0, 0); 288 return dss.dsi_clk_source;
267} 289}
268 290
269/* calculate clock rates using dividers in cinfo */ 291/* calculate clock rates using dividers in cinfo */
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 2bcb1245d6c2..24326a5fd292 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -119,6 +119,12 @@ enum dss_clock {
119 DSS_CLK_96M = 1 << 4, 119 DSS_CLK_96M = 1 << 4,
120}; 120};
121 121
122enum dss_clk_source {
123 DSS_SRC_DSI1_PLL_FCLK,
124 DSS_SRC_DSI2_PLL_FCLK,
125 DSS_SRC_DSS1_ALWON_FCLK,
126};
127
122struct dss_clock_info { 128struct dss_clock_info {
123 /* rates that we get with dividers below */ 129 /* rates that we get with dividers below */
124 unsigned long fck; 130 unsigned long fck;
@@ -169,6 +175,9 @@ unsigned long dss_clk_get_rate(enum dss_clock clk);
169int dss_need_ctx_restore(void); 175int dss_need_ctx_restore(void);
170void dss_dump_clocks(struct seq_file *s); 176void dss_dump_clocks(struct seq_file *s);
171struct bus_type *dss_get_bus(void); 177struct bus_type *dss_get_bus(void);
178struct regulator *dss_get_vdds_dsi(void);
179struct regulator *dss_get_vdds_sdi(void);
180struct regulator *dss_get_vdda_dac(void);
172 181
173/* display */ 182/* display */
174int dss_suspend_all_devices(void); 183int dss_suspend_all_devices(void);
@@ -216,9 +225,11 @@ void dss_sdi_init(u8 datapairs);
216int dss_sdi_enable(void); 225int dss_sdi_enable(void);
217void dss_sdi_disable(void); 226void dss_sdi_disable(void);
218 227
219void dss_select_clk_source(bool dsi, bool dispc); 228void dss_select_dispc_clk_source(enum dss_clk_source clk_src);
220int dss_get_dsi_clk_source(void); 229void dss_select_dsi_clk_source(enum dss_clk_source clk_src);
221int dss_get_dispc_clk_source(void); 230enum dss_clk_source dss_get_dispc_clk_source(void);
231enum dss_clk_source dss_get_dsi_clk_source(void);
232
222void dss_set_venc_output(enum omap_dss_venc_type type); 233void dss_set_venc_output(enum omap_dss_venc_type type);
223void dss_set_dac_pwrdn_bgz(bool enable); 234void dss_set_dac_pwrdn_bgz(bool enable);
224 235
@@ -261,7 +272,7 @@ void dsi_get_overlay_fifo_thresholds(enum omap_plane plane,
261 u32 *fifo_low, u32 *fifo_high); 272 u32 *fifo_low, u32 *fifo_high);
262 273
263/* DPI */ 274/* DPI */
264int dpi_init(void); 275int dpi_init(struct platform_device *pdev);
265void dpi_exit(void); 276void dpi_exit(void);
266int dpi_init_display(struct omap_dss_device *dssdev); 277int dpi_init_display(struct omap_dss_device *dssdev);
267 278
@@ -313,8 +324,8 @@ int dispc_setup_plane(enum omap_plane plane,
313 324
314bool dispc_go_busy(enum omap_channel channel); 325bool dispc_go_busy(enum omap_channel channel);
315void dispc_go(enum omap_channel channel); 326void dispc_go(enum omap_channel channel);
316void dispc_enable_lcd_out(bool enable); 327void dispc_enable_channel(enum omap_channel channel, bool enable);
317void dispc_enable_digit_out(bool enable); 328bool dispc_is_channel_enabled(enum omap_channel channel);
318int dispc_enable_plane(enum omap_plane plane, bool enable); 329int dispc_enable_plane(enum omap_plane plane, bool enable);
319void dispc_enable_replication(enum omap_plane plane, bool enable); 330void dispc_enable_replication(enum omap_plane plane, bool enable);
320 331
diff --git a/drivers/video/omap2/dss/manager.c b/drivers/video/omap2/dss/manager.c
index 27d9c465c851..913142d4cab1 100644
--- a/drivers/video/omap2/dss/manager.c
+++ b/drivers/video/omap2/dss/manager.c
@@ -501,6 +501,19 @@ static int omap_dss_unset_device(struct omap_overlay_manager *mgr)
501 return 0; 501 return 0;
502} 502}
503 503
504static int dss_mgr_wait_for_vsync(struct omap_overlay_manager *mgr)
505{
506 unsigned long timeout = msecs_to_jiffies(500);
507 u32 irq;
508
509 if (mgr->device->type == OMAP_DISPLAY_TYPE_VENC)
510 irq = DISPC_IRQ_EVSYNC_ODD;
511 else
512 irq = DISPC_IRQ_VSYNC;
513
514 return omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout);
515}
516
504static int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr) 517static int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr)
505{ 518{
506 unsigned long timeout = msecs_to_jiffies(500); 519 unsigned long timeout = msecs_to_jiffies(500);
@@ -509,17 +522,18 @@ static int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr)
509 u32 irq; 522 u32 irq;
510 int r; 523 int r;
511 int i; 524 int i;
525 struct omap_dss_device *dssdev = mgr->device;
512 526
513 if (!mgr->device) 527 if (!dssdev)
514 return 0; 528 return 0;
515 529
516 if (mgr->device->type == OMAP_DISPLAY_TYPE_VENC) { 530 if (dssdev->type == OMAP_DISPLAY_TYPE_VENC) {
517 irq = DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_EVSYNC_EVEN; 531 irq = DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_EVSYNC_EVEN;
518 channel = OMAP_DSS_CHANNEL_DIGIT; 532 channel = OMAP_DSS_CHANNEL_DIGIT;
519 } else { 533 } else {
520 if (mgr->device->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) { 534 if (dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) {
521 enum omap_dss_update_mode mode; 535 enum omap_dss_update_mode mode;
522 mode = mgr->device->get_update_mode(mgr->device); 536 mode = dssdev->driver->get_update_mode(dssdev);
523 if (mode != OMAP_DSS_UPDATE_AUTO) 537 if (mode != OMAP_DSS_UPDATE_AUTO)
524 return 0; 538 return 0;
525 539
@@ -592,7 +606,7 @@ int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl)
592 } else { 606 } else {
593 if (dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) { 607 if (dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) {
594 enum omap_dss_update_mode mode; 608 enum omap_dss_update_mode mode;
595 mode = dssdev->get_update_mode(dssdev); 609 mode = dssdev->driver->get_update_mode(dssdev);
596 if (mode != OMAP_DSS_UPDATE_AUTO) 610 if (mode != OMAP_DSS_UPDATE_AUTO)
597 return 0; 611 return 0;
598 612
@@ -1064,7 +1078,7 @@ void dss_start_update(struct omap_dss_device *dssdev)
1064 mc->shadow_dirty = false; 1078 mc->shadow_dirty = false;
1065 } 1079 }
1066 1080
1067 dispc_enable_lcd_out(1); 1081 dssdev->manager->enable(dssdev->manager);
1068} 1082}
1069 1083
1070static void dss_apply_irq_handler(void *data, u32 mask) 1084static void dss_apply_irq_handler(void *data, u32 mask)
@@ -1196,7 +1210,8 @@ static int omap_dss_mgr_apply(struct omap_overlay_manager *mgr)
1196 1210
1197 oc->manual_update = 1211 oc->manual_update =
1198 dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE && 1212 dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE &&
1199 dssdev->get_update_mode(dssdev) != OMAP_DSS_UPDATE_AUTO; 1213 dssdev->driver->get_update_mode(dssdev) !=
1214 OMAP_DSS_UPDATE_AUTO;
1200 1215
1201 ++num_planes_enabled; 1216 ++num_planes_enabled;
1202 } 1217 }
@@ -1237,7 +1252,8 @@ static int omap_dss_mgr_apply(struct omap_overlay_manager *mgr)
1237 1252
1238 mc->manual_update = 1253 mc->manual_update =
1239 dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE && 1254 dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE &&
1240 dssdev->get_update_mode(dssdev) != OMAP_DSS_UPDATE_AUTO; 1255 dssdev->driver->get_update_mode(dssdev) !=
1256 OMAP_DSS_UPDATE_AUTO;
1241 } 1257 }
1242 1258
1243 /* XXX TODO: Try to get fifomerge working. The problem is that it 1259 /* XXX TODO: Try to get fifomerge working. The problem is that it
@@ -1351,6 +1367,18 @@ static void omap_dss_mgr_get_info(struct omap_overlay_manager *mgr,
1351 *info = mgr->info; 1367 *info = mgr->info;
1352} 1368}
1353 1369
1370static int dss_mgr_enable(struct omap_overlay_manager *mgr)
1371{
1372 dispc_enable_channel(mgr->id, 1);
1373 return 0;
1374}
1375
1376static int dss_mgr_disable(struct omap_overlay_manager *mgr)
1377{
1378 dispc_enable_channel(mgr->id, 0);
1379 return 0;
1380}
1381
1354static void omap_dss_add_overlay_manager(struct omap_overlay_manager *manager) 1382static void omap_dss_add_overlay_manager(struct omap_overlay_manager *manager)
1355{ 1383{
1356 ++num_managers; 1384 ++num_managers;
@@ -1394,6 +1422,10 @@ int dss_init_overlay_managers(struct platform_device *pdev)
1394 mgr->set_manager_info = &omap_dss_mgr_set_info; 1422 mgr->set_manager_info = &omap_dss_mgr_set_info;
1395 mgr->get_manager_info = &omap_dss_mgr_get_info; 1423 mgr->get_manager_info = &omap_dss_mgr_get_info;
1396 mgr->wait_for_go = &dss_mgr_wait_for_go; 1424 mgr->wait_for_go = &dss_mgr_wait_for_go;
1425 mgr->wait_for_vsync = &dss_mgr_wait_for_vsync;
1426
1427 mgr->enable = &dss_mgr_enable;
1428 mgr->disable = &dss_mgr_disable;
1397 1429
1398 mgr->caps = OMAP_DSS_OVL_MGR_CAP_DISPC; 1430 mgr->caps = OMAP_DSS_OVL_MGR_CAP_DISPC;
1399 1431
diff --git a/drivers/video/omap2/dss/overlay.c b/drivers/video/omap2/dss/overlay.c
index b7f9a7339842..0c5bea263ac6 100644
--- a/drivers/video/omap2/dss/overlay.c
+++ b/drivers/video/omap2/dss/overlay.c
@@ -350,7 +350,7 @@ int dss_check_overlay(struct omap_overlay *ovl, struct omap_dss_device *dssdev)
350 return -EINVAL; 350 return -EINVAL;
351 } 351 }
352 352
353 dssdev->get_resolution(dssdev, &dw, &dh); 353 dssdev->driver->get_resolution(dssdev, &dw, &dh);
354 354
355 DSSDBG("check_overlay %d: (%d,%d %dx%d -> %dx%d) disp (%dx%d)\n", 355 DSSDBG("check_overlay %d: (%d,%d %dx%d -> %dx%d) disp (%dx%d)\n",
356 ovl->id, 356 ovl->id,
diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c
index b936495c065d..cc23f53cc62d 100644
--- a/drivers/video/omap2/dss/rfbi.c
+++ b/drivers/video/omap2/dss/rfbi.c
@@ -36,8 +36,6 @@
36#include <plat/display.h> 36#include <plat/display.h>
37#include "dss.h" 37#include "dss.h"
38 38
39/*#define MEASURE_PERF*/
40
41#define RFBI_BASE 0x48050800 39#define RFBI_BASE 0x48050800
42 40
43struct rfbi_reg { u16 idx; }; 41struct rfbi_reg { u16 idx; };
@@ -66,8 +64,6 @@ struct rfbi_reg { u16 idx; };
66#define RFBI_VSYNC_WIDTH RFBI_REG(0x0090) 64#define RFBI_VSYNC_WIDTH RFBI_REG(0x0090)
67#define RFBI_HSYNC_WIDTH RFBI_REG(0x0094) 65#define RFBI_HSYNC_WIDTH RFBI_REG(0x0094)
68 66
69#define RFBI_CMD_FIFO_LEN_BYTES (16 * sizeof(struct update_param))
70
71#define REG_FLD_MOD(idx, val, start, end) \ 67#define REG_FLD_MOD(idx, val, start, end) \
72 rfbi_write_reg(idx, FLD_MOD(rfbi_read_reg(idx), val, start, end)) 68 rfbi_write_reg(idx, FLD_MOD(rfbi_read_reg(idx), val, start, end))
73 69
@@ -102,7 +98,6 @@ enum update_cmd {
102 98
103static int rfbi_convert_timings(struct rfbi_timings *t); 99static int rfbi_convert_timings(struct rfbi_timings *t);
104static void rfbi_get_clk_info(u32 *clk_period, u32 *max_clk_div); 100static void rfbi_get_clk_info(u32 *clk_period, u32 *max_clk_div);
105static void process_cmd_fifo(void);
106 101
107static struct { 102static struct {
108 void __iomem *base; 103 void __iomem *base;
@@ -125,11 +120,6 @@ static struct {
125 struct completion cmd_done; 120 struct completion cmd_done;
126 atomic_t cmd_fifo_full; 121 atomic_t cmd_fifo_full;
127 atomic_t cmd_pending; 122 atomic_t cmd_pending;
128#ifdef MEASURE_PERF
129 unsigned perf_bytes;
130 ktime_t perf_setup_time;
131 ktime_t perf_start_time;
132#endif
133} rfbi; 123} rfbi;
134 124
135struct update_region { 125struct update_region {
@@ -139,16 +129,6 @@ struct update_region {
139 u16 h; 129 u16 h;
140}; 130};
141 131
142struct update_param {
143 u8 rfbi_module;
144 u8 cmd;
145
146 union {
147 struct update_region r;
148 struct completion *sync;
149 } par;
150};
151
152static inline void rfbi_write_reg(const struct rfbi_reg idx, u32 val) 132static inline void rfbi_write_reg(const struct rfbi_reg idx, u32 val)
153{ 133{
154 __raw_writel(val, rfbi.base + idx.idx); 134 __raw_writel(val, rfbi.base + idx.idx);
@@ -321,55 +301,6 @@ void omap_rfbi_write_pixels(const void __iomem *buf, int scr_width,
321} 301}
322EXPORT_SYMBOL(omap_rfbi_write_pixels); 302EXPORT_SYMBOL(omap_rfbi_write_pixels);
323 303
324#ifdef MEASURE_PERF
325static void perf_mark_setup(void)
326{
327 rfbi.perf_setup_time = ktime_get();
328}
329
330static void perf_mark_start(void)
331{
332 rfbi.perf_start_time = ktime_get();
333}
334
335static void perf_show(const char *name)
336{
337 ktime_t t, setup_time, trans_time;
338 u32 total_bytes;
339 u32 setup_us, trans_us, total_us;
340
341 t = ktime_get();
342
343 setup_time = ktime_sub(rfbi.perf_start_time, rfbi.perf_setup_time);
344 setup_us = (u32)ktime_to_us(setup_time);
345 if (setup_us == 0)
346 setup_us = 1;
347
348 trans_time = ktime_sub(t, rfbi.perf_start_time);
349 trans_us = (u32)ktime_to_us(trans_time);
350 if (trans_us == 0)
351 trans_us = 1;
352
353 total_us = setup_us + trans_us;
354
355 total_bytes = rfbi.perf_bytes;
356
357 DSSINFO("%s update %u us + %u us = %u us (%uHz), %u bytes, "
358 "%u kbytes/sec\n",
359 name,
360 setup_us,
361 trans_us,
362 total_us,
363 1000*1000 / total_us,
364 total_bytes,
365 total_bytes * 1000 / total_us);
366}
367#else
368#define perf_mark_setup()
369#define perf_mark_start()
370#define perf_show(x)
371#endif
372
373void rfbi_transfer_area(u16 width, u16 height, 304void rfbi_transfer_area(u16 width, u16 height,
374 void (callback)(void *data), void *data) 305 void (callback)(void *data), void *data)
375{ 306{
@@ -382,7 +313,7 @@ void rfbi_transfer_area(u16 width, u16 height,
382 313
383 dispc_set_lcd_size(width, height); 314 dispc_set_lcd_size(width, height);
384 315
385 dispc_enable_lcd_out(1); 316 dispc_enable_channel(OMAP_DSS_CHANNEL_LCD, true);
386 317
387 rfbi.framedone_callback = callback; 318 rfbi.framedone_callback = callback;
388 rfbi.framedone_callback_data = data; 319 rfbi.framedone_callback_data = data;
@@ -396,8 +327,6 @@ void rfbi_transfer_area(u16 width, u16 height,
396 if (!rfbi.te_enabled) 327 if (!rfbi.te_enabled)
397 l = FLD_MOD(l, 1, 4, 4); /* ITE */ 328 l = FLD_MOD(l, 1, 4, 4); /* ITE */
398 329
399 perf_mark_start();
400
401 rfbi_write_reg(RFBI_CONTROL, l); 330 rfbi_write_reg(RFBI_CONTROL, l);
402} 331}
403 332
@@ -407,8 +336,6 @@ static void framedone_callback(void *data, u32 mask)
407 336
408 DSSDBG("FRAMEDONE\n"); 337 DSSDBG("FRAMEDONE\n");
409 338
410 perf_show("DISPC");
411
412 REG_FLD_MOD(RFBI_CONTROL, 0, 0, 0); 339 REG_FLD_MOD(RFBI_CONTROL, 0, 0, 0);
413 340
414 rfbi_enable_clocks(0); 341 rfbi_enable_clocks(0);
@@ -416,11 +343,10 @@ static void framedone_callback(void *data, u32 mask)
416 callback = rfbi.framedone_callback; 343 callback = rfbi.framedone_callback;
417 rfbi.framedone_callback = NULL; 344 rfbi.framedone_callback = NULL;
418 345
419 /*callback(rfbi.framedone_callback_data);*/ 346 if (callback != NULL)
347 callback(rfbi.framedone_callback_data);
420 348
421 atomic_set(&rfbi.cmd_pending, 0); 349 atomic_set(&rfbi.cmd_pending, 0);
422
423 process_cmd_fifo();
424} 350}
425 351
426#if 1 /* VERBOSE */ 352#if 1 /* VERBOSE */
@@ -937,52 +863,43 @@ int rfbi_configure(int rfbi_module, int bpp, int lines)
937} 863}
938EXPORT_SYMBOL(rfbi_configure); 864EXPORT_SYMBOL(rfbi_configure);
939 865
940static int rfbi_find_display(struct omap_dss_device *dssdev) 866int omap_rfbi_prepare_update(struct omap_dss_device *dssdev,
867 u16 *x, u16 *y, u16 *w, u16 *h)
941{ 868{
942 if (dssdev == rfbi.dssdev[0]) 869 u16 dw, dh;
943 return 0;
944 870
945 if (dssdev == rfbi.dssdev[1]) 871 dssdev->driver->get_resolution(dssdev, &dw, &dh);
946 return 1;
947 872
948 BUG(); 873 if (*x > dw || *y > dh)
949 return -1; 874 return -EINVAL;
950}
951 875
876 if (*x + *w > dw)
877 return -EINVAL;
952 878
953static void signal_fifo_waiters(void) 879 if (*y + *h > dh)
954{ 880 return -EINVAL;
955 if (atomic_read(&rfbi.cmd_fifo_full) > 0) {
956 /* DSSDBG("SIGNALING: Fifo not full for waiter!\n"); */
957 complete(&rfbi.cmd_done);
958 atomic_dec(&rfbi.cmd_fifo_full);
959 }
960}
961 881
962/* returns 1 for async op, and 0 for sync op */ 882 if (*w == 1)
963static int do_update(struct omap_dss_device *dssdev, struct update_region *upd) 883 return -EINVAL;
964{
965 u16 x = upd->x;
966 u16 y = upd->y;
967 u16 w = upd->w;
968 u16 h = upd->h;
969 884
970 perf_mark_setup(); 885 if (*w == 0 || *h == 0)
886 return -EINVAL;
971 887
972 if (dssdev->manager->caps & OMAP_DSS_OVL_MGR_CAP_DISPC) { 888 if (dssdev->manager->caps & OMAP_DSS_OVL_MGR_CAP_DISPC) {
973 /*dssdev->driver->enable_te(dssdev, 1); */ 889 dss_setup_partial_planes(dssdev, x, y, w, h);
974 dss_setup_partial_planes(dssdev, &x, &y, &w, &h); 890 dispc_set_lcd_size(*w, *h);
975 } 891 }
976 892
977#ifdef MEASURE_PERF 893 return 0;
978 rfbi.perf_bytes = w * h * 2; /* XXX always 16bit */ 894}
979#endif 895EXPORT_SYMBOL(omap_rfbi_prepare_update);
980
981 dssdev->driver->setup_update(dssdev, x, y, w, h);
982 896
897int omap_rfbi_update(struct omap_dss_device *dssdev,
898 u16 x, u16 y, u16 w, u16 h,
899 void (*callback)(void *), void *data)
900{
983 if (dssdev->manager->caps & OMAP_DSS_OVL_MGR_CAP_DISPC) { 901 if (dssdev->manager->caps & OMAP_DSS_OVL_MGR_CAP_DISPC) {
984 rfbi_transfer_area(w, h, NULL, NULL); 902 rfbi_transfer_area(w, h, callback, data);
985 return 1;
986 } else { 903 } else {
987 struct omap_overlay *ovl; 904 struct omap_overlay *ovl;
988 void __iomem *addr; 905 void __iomem *addr;
@@ -994,123 +911,12 @@ static int do_update(struct omap_dss_device *dssdev, struct update_region *upd)
994 911
995 omap_rfbi_write_pixels(addr, scr_width, x, y, w, h); 912 omap_rfbi_write_pixels(addr, scr_width, x, y, w, h);
996 913
997 perf_show("L4"); 914 callback(data);
998
999 return 0;
1000 } 915 }
1001}
1002
1003static void process_cmd_fifo(void)
1004{
1005 int len;
1006 struct update_param p;
1007 struct omap_dss_device *dssdev;
1008 unsigned long flags;
1009
1010 if (atomic_inc_return(&rfbi.cmd_pending) != 1)
1011 return;
1012
1013 while (true) {
1014 spin_lock_irqsave(&rfbi.cmd_lock, flags);
1015
1016 len = kfifo_out(&rfbi.cmd_fifo, (unsigned char *)&p,
1017 sizeof(struct update_param));
1018 if (len == 0) {
1019 DSSDBG("nothing more in fifo\n");
1020 atomic_set(&rfbi.cmd_pending, 0);
1021 spin_unlock_irqrestore(&rfbi.cmd_lock, flags);
1022 break;
1023 }
1024
1025 /* DSSDBG("fifo full %d\n", rfbi.cmd_fifo_full.counter);*/
1026
1027 spin_unlock_irqrestore(&rfbi.cmd_lock, flags);
1028
1029 BUG_ON(len != sizeof(struct update_param));
1030 BUG_ON(p.rfbi_module > 1);
1031
1032 dssdev = rfbi.dssdev[p.rfbi_module];
1033
1034 if (p.cmd == RFBI_CMD_UPDATE) {
1035 if (do_update(dssdev, &p.par.r))
1036 break; /* async op */
1037 } else if (p.cmd == RFBI_CMD_SYNC) {
1038 DSSDBG("Signaling SYNC done!\n");
1039 complete(p.par.sync);
1040 } else
1041 BUG();
1042 }
1043
1044 signal_fifo_waiters();
1045}
1046 916
1047static void rfbi_push_cmd(struct update_param *p) 917 return 0;
1048{
1049 int ret;
1050
1051 while (1) {
1052 unsigned long flags;
1053 int available;
1054
1055 spin_lock_irqsave(&rfbi.cmd_lock, flags);
1056 available = RFBI_CMD_FIFO_LEN_BYTES -
1057 kfifo_len(&rfbi.cmd_fifo);
1058
1059/* DSSDBG("%d bytes left in fifo\n", available); */
1060 if (available < sizeof(struct update_param)) {
1061 DSSDBG("Going to wait because FIFO FULL..\n");
1062 spin_unlock_irqrestore(&rfbi.cmd_lock, flags);
1063 atomic_inc(&rfbi.cmd_fifo_full);
1064 wait_for_completion(&rfbi.cmd_done);
1065 /*DSSDBG("Woke up because fifo not full anymore\n");*/
1066 continue;
1067 }
1068
1069 ret = kfifo_in(&rfbi.cmd_fifo, (unsigned char *)p,
1070 sizeof(struct update_param));
1071/* DSSDBG("pushed %d bytes\n", ret);*/
1072
1073 spin_unlock_irqrestore(&rfbi.cmd_lock, flags);
1074
1075 BUG_ON(ret != sizeof(struct update_param));
1076
1077 break;
1078 }
1079}
1080
1081static void rfbi_push_update(int rfbi_module, int x, int y, int w, int h)
1082{
1083 struct update_param p;
1084
1085 p.rfbi_module = rfbi_module;
1086 p.cmd = RFBI_CMD_UPDATE;
1087
1088 p.par.r.x = x;
1089 p.par.r.y = y;
1090 p.par.r.w = w;
1091 p.par.r.h = h;
1092
1093 DSSDBG("RFBI pushed %d,%d %dx%d\n", x, y, w, h);
1094
1095 rfbi_push_cmd(&p);
1096
1097 process_cmd_fifo();
1098}
1099
1100static void rfbi_push_sync(int rfbi_module, struct completion *sync_comp)
1101{
1102 struct update_param p;
1103
1104 p.rfbi_module = rfbi_module;
1105 p.cmd = RFBI_CMD_SYNC;
1106 p.par.sync = sync_comp;
1107
1108 rfbi_push_cmd(&p);
1109
1110 DSSDBG("RFBI sync pushed to cmd fifo\n");
1111
1112 process_cmd_fifo();
1113} 918}
919EXPORT_SYMBOL(omap_rfbi_update);
1114 920
1115void rfbi_dump_regs(struct seq_file *s) 921void rfbi_dump_regs(struct seq_file *s)
1116{ 922{
@@ -1155,12 +961,8 @@ int rfbi_init(void)
1155{ 961{
1156 u32 rev; 962 u32 rev;
1157 u32 l; 963 u32 l;
1158 int r;
1159 964
1160 spin_lock_init(&rfbi.cmd_lock); 965 spin_lock_init(&rfbi.cmd_lock);
1161 r = kfifo_alloc(&rfbi.cmd_fifo, RFBI_CMD_FIFO_LEN_BYTES, GFP_KERNEL);
1162 if (r)
1163 return r;
1164 966
1165 init_completion(&rfbi.cmd_done); 967 init_completion(&rfbi.cmd_done);
1166 atomic_set(&rfbi.cmd_fifo_full, 0); 968 atomic_set(&rfbi.cmd_fifo_full, 0);
@@ -1196,49 +998,10 @@ void rfbi_exit(void)
1196{ 998{
1197 DSSDBG("rfbi_exit\n"); 999 DSSDBG("rfbi_exit\n");
1198 1000
1199 kfifo_free(&rfbi.cmd_fifo);
1200
1201 iounmap(rfbi.base); 1001 iounmap(rfbi.base);
1202} 1002}
1203 1003
1204/* struct omap_display support */ 1004int omapdss_rfbi_display_enable(struct omap_dss_device *dssdev)
1205static int rfbi_display_update(struct omap_dss_device *dssdev,
1206 u16 x, u16 y, u16 w, u16 h)
1207{
1208 int rfbi_module;
1209
1210 if (w == 0 || h == 0)
1211 return 0;
1212
1213 rfbi_module = rfbi_find_display(dssdev);
1214
1215 rfbi_push_update(rfbi_module, x, y, w, h);
1216
1217 return 0;
1218}
1219
1220static int rfbi_display_sync(struct omap_dss_device *dssdev)
1221{
1222 struct completion sync_comp;
1223 int rfbi_module;
1224
1225 rfbi_module = rfbi_find_display(dssdev);
1226
1227 init_completion(&sync_comp);
1228 rfbi_push_sync(rfbi_module, &sync_comp);
1229 DSSDBG("Waiting for SYNC to happen...\n");
1230 wait_for_completion(&sync_comp);
1231 DSSDBG("Released from SYNC\n");
1232 return 0;
1233}
1234
1235static int rfbi_display_enable_te(struct omap_dss_device *dssdev, bool enable)
1236{
1237 dssdev->driver->enable_te(dssdev, enable);
1238 return 0;
1239}
1240
1241static int rfbi_display_enable(struct omap_dss_device *dssdev)
1242{ 1005{
1243 int r; 1006 int r;
1244 1007
@@ -1269,41 +1032,25 @@ static int rfbi_display_enable(struct omap_dss_device *dssdev)
1269 &dssdev->ctrl.rfbi_timings); 1032 &dssdev->ctrl.rfbi_timings);
1270 1033
1271 1034
1272 if (dssdev->driver->enable) {
1273 r = dssdev->driver->enable(dssdev);
1274 if (r)
1275 goto err2;
1276 }
1277
1278 return 0; 1035 return 0;
1279err2:
1280 omap_dispc_unregister_isr(framedone_callback, NULL,
1281 DISPC_IRQ_FRAMEDONE);
1282err1: 1036err1:
1283 omap_dss_stop_device(dssdev); 1037 omap_dss_stop_device(dssdev);
1284err0: 1038err0:
1285 return r; 1039 return r;
1286} 1040}
1041EXPORT_SYMBOL(omapdss_rfbi_display_enable);
1287 1042
1288static void rfbi_display_disable(struct omap_dss_device *dssdev) 1043void omapdss_rfbi_display_disable(struct omap_dss_device *dssdev)
1289{ 1044{
1290 dssdev->driver->disable(dssdev);
1291 omap_dispc_unregister_isr(framedone_callback, NULL, 1045 omap_dispc_unregister_isr(framedone_callback, NULL,
1292 DISPC_IRQ_FRAMEDONE); 1046 DISPC_IRQ_FRAMEDONE);
1293 omap_dss_stop_device(dssdev); 1047 omap_dss_stop_device(dssdev);
1294} 1048}
1049EXPORT_SYMBOL(omapdss_rfbi_display_disable);
1295 1050
1296int rfbi_init_display(struct omap_dss_device *dssdev) 1051int rfbi_init_display(struct omap_dss_device *dssdev)
1297{ 1052{
1298 dssdev->enable = rfbi_display_enable;
1299 dssdev->disable = rfbi_display_disable;
1300 dssdev->update = rfbi_display_update;
1301 dssdev->sync = rfbi_display_sync;
1302 dssdev->enable_te = rfbi_display_enable_te;
1303
1304 rfbi.dssdev[dssdev->phy.rfbi.channel] = dssdev; 1053 rfbi.dssdev[dssdev->phy.rfbi.channel] = dssdev;
1305
1306 dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE; 1054 dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE;
1307
1308 return 0; 1055 return 0;
1309} 1056}
diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index c24f307d3da1..12eb4042dd82 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -41,7 +41,7 @@ static void sdi_basic_init(void)
41 dispc_lcd_enable_signal_polarity(1); 41 dispc_lcd_enable_signal_polarity(1);
42} 42}
43 43
44static int sdi_display_enable(struct omap_dss_device *dssdev) 44int omapdss_sdi_display_enable(struct omap_dss_device *dssdev)
45{ 45{
46 struct omap_video_timings *t = &dssdev->panel.timings; 46 struct omap_video_timings *t = &dssdev->panel.timings;
47 struct dss_clock_info dss_cinfo; 47 struct dss_clock_info dss_cinfo;
@@ -57,12 +57,6 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
57 goto err0; 57 goto err0;
58 } 58 }
59 59
60 if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) {
61 DSSERR("dssdev already enabled\n");
62 r = -EINVAL;
63 goto err1;
64 }
65
66 /* In case of skip_init sdi_init has already enabled the clocks */ 60 /* In case of skip_init sdi_init has already enabled the clocks */
67 if (!sdi.skip_init) 61 if (!sdi.skip_init)
68 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1); 62 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
@@ -119,7 +113,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
119 mdelay(2); 113 mdelay(2);
120 } 114 }
121 115
122 dispc_enable_lcd_out(1); 116 dssdev->manager->enable(dssdev->manager);
123 117
124 if (dssdev->driver->enable) { 118 if (dssdev->driver->enable) {
125 r = dssdev->driver->enable(dssdev); 119 r = dssdev->driver->enable(dssdev);
@@ -127,13 +121,11 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
127 goto err3; 121 goto err3;
128 } 122 }
129 123
130 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
131
132 sdi.skip_init = 0; 124 sdi.skip_init = 0;
133 125
134 return 0; 126 return 0;
135err3: 127err3:
136 dispc_enable_lcd_out(0); 128 dssdev->manager->disable(dssdev->manager);
137err2: 129err2:
138 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1); 130 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
139err1: 131err1:
@@ -141,120 +133,27 @@ err1:
141err0: 133err0:
142 return r; 134 return r;
143} 135}
136EXPORT_SYMBOL(omapdss_sdi_display_enable);
144 137
145static int sdi_display_resume(struct omap_dss_device *dssdev); 138void omapdss_sdi_display_disable(struct omap_dss_device *dssdev)
146
147static void sdi_display_disable(struct omap_dss_device *dssdev)
148{ 139{
149 if (dssdev->state == OMAP_DSS_DISPLAY_DISABLED)
150 return;
151
152 if (dssdev->state == OMAP_DSS_DISPLAY_SUSPENDED)
153 if (sdi_display_resume(dssdev))
154 return;
155
156 if (dssdev->driver->disable) 140 if (dssdev->driver->disable)
157 dssdev->driver->disable(dssdev); 141 dssdev->driver->disable(dssdev);
158 142
159 dispc_enable_lcd_out(0); 143 dssdev->manager->disable(dssdev->manager);
160 144
161 dss_sdi_disable(); 145 dss_sdi_disable();
162 146
163 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1); 147 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
164 148
165 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
166
167 omap_dss_stop_device(dssdev); 149 omap_dss_stop_device(dssdev);
168} 150}
169 151EXPORT_SYMBOL(omapdss_sdi_display_disable);
170static int sdi_display_suspend(struct omap_dss_device *dssdev)
171{
172 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
173 return -EINVAL;
174
175 if (dssdev->driver->suspend)
176 dssdev->driver->suspend(dssdev);
177
178 dispc_enable_lcd_out(0);
179
180 dss_sdi_disable();
181
182 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
183
184 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
185
186 return 0;
187}
188
189static int sdi_display_resume(struct omap_dss_device *dssdev)
190{
191 int r;
192
193 if (dssdev->state != OMAP_DSS_DISPLAY_SUSPENDED)
194 return -EINVAL;
195
196 dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
197
198 r = dss_sdi_enable();
199 if (r)
200 goto err;
201 mdelay(2);
202
203 dispc_enable_lcd_out(1);
204
205 if (dssdev->driver->resume)
206 dssdev->driver->resume(dssdev);
207
208 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
209
210 return 0;
211err:
212 dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
213 return r;
214}
215
216static int sdi_display_set_update_mode(struct omap_dss_device *dssdev,
217 enum omap_dss_update_mode mode)
218{
219 if (mode == OMAP_DSS_UPDATE_MANUAL)
220 return -EINVAL;
221
222 if (mode == OMAP_DSS_UPDATE_DISABLED) {
223 dispc_enable_lcd_out(0);
224 sdi.update_enabled = 0;
225 } else {
226 dispc_enable_lcd_out(1);
227 sdi.update_enabled = 1;
228 }
229
230 return 0;
231}
232
233static enum omap_dss_update_mode sdi_display_get_update_mode(
234 struct omap_dss_device *dssdev)
235{
236 return sdi.update_enabled ? OMAP_DSS_UPDATE_AUTO :
237 OMAP_DSS_UPDATE_DISABLED;
238}
239
240static void sdi_get_timings(struct omap_dss_device *dssdev,
241 struct omap_video_timings *timings)
242{
243 *timings = dssdev->panel.timings;
244}
245 152
246int sdi_init_display(struct omap_dss_device *dssdev) 153int sdi_init_display(struct omap_dss_device *dssdev)
247{ 154{
248 DSSDBG("SDI init\n"); 155 DSSDBG("SDI init\n");
249 156
250 dssdev->enable = sdi_display_enable;
251 dssdev->disable = sdi_display_disable;
252 dssdev->suspend = sdi_display_suspend;
253 dssdev->resume = sdi_display_resume;
254 dssdev->set_update_mode = sdi_display_set_update_mode;
255 dssdev->get_update_mode = sdi_display_get_update_mode;
256 dssdev->get_timings = sdi_get_timings;
257
258 return 0; 157 return 0;
259} 158}
260 159
diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
index 749a5a0f5be4..f0ba5732d84a 100644
--- a/drivers/video/omap2/dss/venc.c
+++ b/drivers/video/omap2/dss/venc.c
@@ -400,114 +400,6 @@ static const struct venc_config *venc_timings_to_config(
400 BUG(); 400 BUG();
401} 401}
402 402
403
404
405
406
407/* driver */
408static int venc_panel_probe(struct omap_dss_device *dssdev)
409{
410 dssdev->panel.timings = omap_dss_pal_timings;
411
412 return 0;
413}
414
415static void venc_panel_remove(struct omap_dss_device *dssdev)
416{
417}
418
419static int venc_panel_enable(struct omap_dss_device *dssdev)
420{
421 int r = 0;
422
423 /* wait couple of vsyncs until enabling the LCD */
424 msleep(50);
425
426 if (dssdev->platform_enable)
427 r = dssdev->platform_enable(dssdev);
428
429 return r;
430}
431
432static void venc_panel_disable(struct omap_dss_device *dssdev)
433{
434 if (dssdev->platform_disable)
435 dssdev->platform_disable(dssdev);
436
437 /* wait at least 5 vsyncs after disabling the LCD */
438
439 msleep(100);
440}
441
442static int venc_panel_suspend(struct omap_dss_device *dssdev)
443{
444 venc_panel_disable(dssdev);
445 return 0;
446}
447
448static int venc_panel_resume(struct omap_dss_device *dssdev)
449{
450 return venc_panel_enable(dssdev);
451}
452
453static struct omap_dss_driver venc_driver = {
454 .probe = venc_panel_probe,
455 .remove = venc_panel_remove,
456
457 .enable = venc_panel_enable,
458 .disable = venc_panel_disable,
459 .suspend = venc_panel_suspend,
460 .resume = venc_panel_resume,
461
462 .driver = {
463 .name = "venc",
464 .owner = THIS_MODULE,
465 },
466};
467/* driver end */
468
469
470
471int venc_init(struct platform_device *pdev)
472{
473 u8 rev_id;
474
475 mutex_init(&venc.venc_lock);
476
477 venc.wss_data = 0;
478
479 venc.base = ioremap(VENC_BASE, SZ_1K);
480 if (!venc.base) {
481 DSSERR("can't ioremap VENC\n");
482 return -ENOMEM;
483 }
484
485 venc.vdda_dac_reg = regulator_get(&pdev->dev, "vdda_dac");
486 if (IS_ERR(venc.vdda_dac_reg)) {
487 iounmap(venc.base);
488 DSSERR("can't get VDDA_DAC regulator\n");
489 return PTR_ERR(venc.vdda_dac_reg);
490 }
491
492 venc_enable_clocks(1);
493
494 rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff);
495 printk(KERN_INFO "OMAP VENC rev %d\n", rev_id);
496
497 venc_enable_clocks(0);
498
499 return omap_dss_register_driver(&venc_driver);
500}
501
502void venc_exit(void)
503{
504 omap_dss_unregister_driver(&venc_driver);
505
506 regulator_put(venc.vdda_dac_reg);
507
508 iounmap(venc.base);
509}
510
511static void venc_power_on(struct omap_dss_device *dssdev) 403static void venc_power_on(struct omap_dss_device *dssdev)
512{ 404{
513 u32 l; 405 u32 l;
@@ -540,7 +432,7 @@ static void venc_power_on(struct omap_dss_device *dssdev)
540 if (dssdev->platform_enable) 432 if (dssdev->platform_enable)
541 dssdev->platform_enable(dssdev); 433 dssdev->platform_enable(dssdev);
542 434
543 dispc_enable_digit_out(1); 435 dssdev->manager->enable(dssdev->manager);
544} 436}
545 437
546static void venc_power_off(struct omap_dss_device *dssdev) 438static void venc_power_off(struct omap_dss_device *dssdev)
@@ -548,7 +440,7 @@ static void venc_power_off(struct omap_dss_device *dssdev)
548 venc_write_reg(VENC_OUTPUT_CONTROL, 0); 440 venc_write_reg(VENC_OUTPUT_CONTROL, 0);
549 dss_set_dac_pwrdn_bgz(0); 441 dss_set_dac_pwrdn_bgz(0);
550 442
551 dispc_enable_digit_out(0); 443 dssdev->manager->disable(dssdev->manager);
552 444
553 if (dssdev->platform_disable) 445 if (dssdev->platform_disable)
554 dssdev->platform_disable(dssdev); 446 dssdev->platform_disable(dssdev);
@@ -558,7 +450,23 @@ static void venc_power_off(struct omap_dss_device *dssdev)
558 venc_enable_clocks(0); 450 venc_enable_clocks(0);
559} 451}
560 452
561static int venc_enable_display(struct omap_dss_device *dssdev) 453
454
455
456
457/* driver */
458static int venc_panel_probe(struct omap_dss_device *dssdev)
459{
460 dssdev->panel.timings = omap_dss_pal_timings;
461
462 return 0;
463}
464
465static void venc_panel_remove(struct omap_dss_device *dssdev)
466{
467}
468
469static int venc_panel_enable(struct omap_dss_device *dssdev)
562{ 470{
563 int r = 0; 471 int r = 0;
564 472
@@ -568,7 +476,13 @@ static int venc_enable_display(struct omap_dss_device *dssdev)
568 476
569 if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) { 477 if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) {
570 r = -EINVAL; 478 r = -EINVAL;
571 goto err; 479 goto err1;
480 }
481
482 if (dssdev->platform_enable) {
483 r = dssdev->platform_enable(dssdev);
484 if (r)
485 goto err2;
572 } 486 }
573 487
574 venc_power_on(dssdev); 488 venc_power_on(dssdev);
@@ -576,13 +490,21 @@ static int venc_enable_display(struct omap_dss_device *dssdev)
576 venc.wss_data = 0; 490 venc.wss_data = 0;
577 491
578 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; 492 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
579err: 493
494 /* wait couple of vsyncs until enabling the LCD */
495 msleep(50);
496
580 mutex_unlock(&venc.venc_lock); 497 mutex_unlock(&venc.venc_lock);
581 498
582 return r; 499 return r;
500err2:
501 venc_power_off(dssdev);
502err1:
503 mutex_unlock(&venc.venc_lock);
504 return r;
583} 505}
584 506
585static void venc_disable_display(struct omap_dss_device *dssdev) 507static void venc_panel_disable(struct omap_dss_device *dssdev)
586{ 508{
587 DSSDBG("venc_disable_display\n"); 509 DSSDBG("venc_disable_display\n");
588 510
@@ -599,53 +521,40 @@ static void venc_disable_display(struct omap_dss_device *dssdev)
599 521
600 venc_power_off(dssdev); 522 venc_power_off(dssdev);
601 523
524 /* wait at least 5 vsyncs after disabling the LCD */
525 msleep(100);
526
527 if (dssdev->platform_disable)
528 dssdev->platform_disable(dssdev);
529
602 dssdev->state = OMAP_DSS_DISPLAY_DISABLED; 530 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
603end: 531end:
604 mutex_unlock(&venc.venc_lock); 532 mutex_unlock(&venc.venc_lock);
605} 533}
606 534
607static int venc_display_suspend(struct omap_dss_device *dssdev) 535static int venc_panel_suspend(struct omap_dss_device *dssdev)
608{ 536{
609 int r = 0; 537 venc_panel_disable(dssdev);
610 538 return 0;
611 DSSDBG("venc_display_suspend\n");
612
613 mutex_lock(&venc.venc_lock);
614
615 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) {
616 r = -EINVAL;
617 goto err;
618 }
619
620 venc_power_off(dssdev);
621
622 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
623err:
624 mutex_unlock(&venc.venc_lock);
625
626 return r;
627} 539}
628 540
629static int venc_display_resume(struct omap_dss_device *dssdev) 541static int venc_panel_resume(struct omap_dss_device *dssdev)
630{ 542{
631 int r = 0; 543 return venc_panel_enable(dssdev);
632 544}
633 DSSDBG("venc_display_resume\n");
634
635 mutex_lock(&venc.venc_lock);
636
637 if (dssdev->state != OMAP_DSS_DISPLAY_SUSPENDED) {
638 r = -EINVAL;
639 goto err;
640 }
641
642 venc_power_on(dssdev);
643 545
644 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; 546static enum omap_dss_update_mode venc_get_update_mode(
645err: 547 struct omap_dss_device *dssdev)
646 mutex_unlock(&venc.venc_lock); 548{
549 return OMAP_DSS_UPDATE_AUTO;
550}
647 551
648 return r; 552static int venc_set_update_mode(struct omap_dss_device *dssdev,
553 enum omap_dss_update_mode mode)
554{
555 if (mode != OMAP_DSS_UPDATE_AUTO)
556 return -EINVAL;
557 return 0;
649} 558}
650 559
651static void venc_get_timings(struct omap_dss_device *dssdev, 560static void venc_get_timings(struct omap_dss_device *dssdev,
@@ -666,8 +575,8 @@ static void venc_set_timings(struct omap_dss_device *dssdev,
666 dssdev->panel.timings = *timings; 575 dssdev->panel.timings = *timings;
667 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) { 576 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) {
668 /* turn the venc off and on to get new timings to use */ 577 /* turn the venc off and on to get new timings to use */
669 venc_disable_display(dssdev); 578 venc_panel_disable(dssdev);
670 venc_enable_display(dssdev); 579 venc_panel_enable(dssdev);
671 } 580 }
672} 581}
673 582
@@ -716,30 +625,79 @@ static int venc_set_wss(struct omap_dss_device *dssdev, u32 wss)
716 return 0; 625 return 0;
717} 626}
718 627
719static enum omap_dss_update_mode venc_display_get_update_mode( 628static struct omap_dss_driver venc_driver = {
720 struct omap_dss_device *dssdev) 629 .probe = venc_panel_probe,
630 .remove = venc_panel_remove,
631
632 .enable = venc_panel_enable,
633 .disable = venc_panel_disable,
634 .suspend = venc_panel_suspend,
635 .resume = venc_panel_resume,
636
637 .get_resolution = omapdss_default_get_resolution,
638 .get_recommended_bpp = omapdss_default_get_recommended_bpp,
639
640 .set_update_mode = venc_set_update_mode,
641 .get_update_mode = venc_get_update_mode,
642
643 .get_timings = venc_get_timings,
644 .set_timings = venc_set_timings,
645 .check_timings = venc_check_timings,
646
647 .get_wss = venc_get_wss,
648 .set_wss = venc_set_wss,
649
650 .driver = {
651 .name = "venc",
652 .owner = THIS_MODULE,
653 },
654};
655/* driver end */
656
657
658
659int venc_init(struct platform_device *pdev)
721{ 660{
722 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) 661 u8 rev_id;
723 return OMAP_DSS_UPDATE_AUTO; 662
724 else 663 mutex_init(&venc.venc_lock);
725 return OMAP_DSS_UPDATE_DISABLED; 664
665 venc.wss_data = 0;
666
667 venc.base = ioremap(VENC_BASE, SZ_1K);
668 if (!venc.base) {
669 DSSERR("can't ioremap VENC\n");
670 return -ENOMEM;
671 }
672
673 venc.vdda_dac_reg = dss_get_vdda_dac();
674 if (IS_ERR(venc.vdda_dac_reg)) {
675 iounmap(venc.base);
676 DSSERR("can't get VDDA_DAC regulator\n");
677 return PTR_ERR(venc.vdda_dac_reg);
678 }
679
680 venc_enable_clocks(1);
681
682 rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff);
683 printk(KERN_INFO "OMAP VENC rev %d\n", rev_id);
684
685 venc_enable_clocks(0);
686
687 return omap_dss_register_driver(&venc_driver);
688}
689
690void venc_exit(void)
691{
692 omap_dss_unregister_driver(&venc_driver);
693
694 iounmap(venc.base);
726} 695}
727 696
728int venc_init_display(struct omap_dss_device *dssdev) 697int venc_init_display(struct omap_dss_device *dssdev)
729{ 698{
730 DSSDBG("init_display\n"); 699 DSSDBG("init_display\n");
731 700
732 dssdev->enable = venc_enable_display;
733 dssdev->disable = venc_disable_display;
734 dssdev->suspend = venc_display_suspend;
735 dssdev->resume = venc_display_resume;
736 dssdev->get_timings = venc_get_timings;
737 dssdev->set_timings = venc_set_timings;
738 dssdev->check_timings = venc_check_timings;
739 dssdev->get_wss = venc_get_wss;
740 dssdev->set_wss = venc_set_wss;
741 dssdev->get_update_mode = venc_display_get_update_mode;
742
743 return 0; 701 return 0;
744} 702}
745 703
diff --git a/drivers/video/omap2/omapfb/Kconfig b/drivers/video/omap2/omapfb/Kconfig
index bb694cc52a50..43496d6c377f 100644
--- a/drivers/video/omap2/omapfb/Kconfig
+++ b/drivers/video/omap2/omapfb/Kconfig
@@ -16,16 +16,7 @@ config FB_OMAP2_DEBUG_SUPPORT
16 depends on FB_OMAP2 16 depends on FB_OMAP2
17 help 17 help
18 Support for debug output. You have to enable the actual printing 18 Support for debug output. You have to enable the actual printing
19 with debug module parameter. 19 with 'debug' module parameter.
20
21config FB_OMAP2_FORCE_AUTO_UPDATE
22 bool "Force main display to automatic update mode"
23 depends on FB_OMAP2
24 help
25 Forces main display to automatic update mode (if possible),
26 and also enables tearsync (if possible). By default
27 displays that support manual update are started in manual
28 update mode.
29 20
30config FB_OMAP2_NUM_FBS 21config FB_OMAP2_NUM_FBS
31 int "Number of framebuffers" 22 int "Number of framebuffers"
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c
index 4c4bafdfaa43..1ffa760b8545 100644
--- a/drivers/video/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c
@@ -167,12 +167,12 @@ static int omapfb_update_window_nolock(struct fb_info *fbi,
167 if (w == 0 || h == 0) 167 if (w == 0 || h == 0)
168 return 0; 168 return 0;
169 169
170 display->get_resolution(display, &dw, &dh); 170 display->driver->get_resolution(display, &dw, &dh);
171 171
172 if (x + w > dw || y + h > dh) 172 if (x + w > dw || y + h > dh)
173 return -EINVAL; 173 return -EINVAL;
174 174
175 return display->update(display, x, y, w, h); 175 return display->driver->update(display, x, y, w, h);
176} 176}
177 177
178/* This function is exported for SGX driver use */ 178/* This function is exported for SGX driver use */
@@ -202,7 +202,7 @@ static int omapfb_set_update_mode(struct fb_info *fbi,
202 enum omap_dss_update_mode um; 202 enum omap_dss_update_mode um;
203 int r; 203 int r;
204 204
205 if (!display || !display->set_update_mode) 205 if (!display || !display->driver->set_update_mode)
206 return -EINVAL; 206 return -EINVAL;
207 207
208 switch (mode) { 208 switch (mode) {
@@ -222,7 +222,7 @@ static int omapfb_set_update_mode(struct fb_info *fbi,
222 return -EINVAL; 222 return -EINVAL;
223 } 223 }
224 224
225 r = display->set_update_mode(display, um); 225 r = display->driver->set_update_mode(display, um);
226 226
227 return r; 227 return r;
228} 228}
@@ -233,10 +233,15 @@ static int omapfb_get_update_mode(struct fb_info *fbi,
233 struct omap_dss_device *display = fb2display(fbi); 233 struct omap_dss_device *display = fb2display(fbi);
234 enum omap_dss_update_mode m; 234 enum omap_dss_update_mode m;
235 235
236 if (!display || !display->get_update_mode) 236 if (!display)
237 return -EINVAL; 237 return -EINVAL;
238 238
239 m = display->get_update_mode(display); 239 if (!display->driver->get_update_mode) {
240 *mode = OMAPFB_AUTO_UPDATE;
241 return 0;
242 }
243
244 m = display->driver->get_update_mode(display);
240 245
241 switch (m) { 246 switch (m) {
242 case OMAP_DSS_UPDATE_DISABLED: 247 case OMAP_DSS_UPDATE_DISABLED:
@@ -374,7 +379,7 @@ static int omapfb_memory_read(struct fb_info *fbi,
374 void *buf; 379 void *buf;
375 int r; 380 int r;
376 381
377 if (!display || !display->memory_read) 382 if (!display || !display->driver->memory_read)
378 return -ENOENT; 383 return -ENOENT;
379 384
380 if (!access_ok(VERIFY_WRITE, mr->buffer, mr->buffer_size)) 385 if (!access_ok(VERIFY_WRITE, mr->buffer, mr->buffer_size))
@@ -389,7 +394,7 @@ static int omapfb_memory_read(struct fb_info *fbi,
389 return -ENOMEM; 394 return -ENOMEM;
390 } 395 }
391 396
392 r = display->memory_read(display, buf, mr->buffer_size, 397 r = display->driver->memory_read(display, buf, mr->buffer_size,
393 mr->x, mr->y, mr->w, mr->h); 398 mr->x, mr->y, mr->w, mr->h);
394 399
395 if (r > 0) { 400 if (r > 0) {
@@ -483,6 +488,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
483 struct omapfb_memory_read memory_read; 488 struct omapfb_memory_read memory_read;
484 struct omapfb_vram_info vram_info; 489 struct omapfb_vram_info vram_info;
485 struct omapfb_tearsync_info tearsync_info; 490 struct omapfb_tearsync_info tearsync_info;
491 struct omapfb_display_info display_info;
486 } p; 492 } p;
487 493
488 int r = 0; 494 int r = 0;
@@ -490,18 +496,18 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
490 switch (cmd) { 496 switch (cmd) {
491 case OMAPFB_SYNC_GFX: 497 case OMAPFB_SYNC_GFX:
492 DBG("ioctl SYNC_GFX\n"); 498 DBG("ioctl SYNC_GFX\n");
493 if (!display || !display->sync) { 499 if (!display || !display->driver->sync) {
494 /* DSS1 never returns an error here, so we neither */ 500 /* DSS1 never returns an error here, so we neither */
495 /*r = -EINVAL;*/ 501 /*r = -EINVAL;*/
496 break; 502 break;
497 } 503 }
498 504
499 r = display->sync(display); 505 r = display->driver->sync(display);
500 break; 506 break;
501 507
502 case OMAPFB_UPDATE_WINDOW_OLD: 508 case OMAPFB_UPDATE_WINDOW_OLD:
503 DBG("ioctl UPDATE_WINDOW_OLD\n"); 509 DBG("ioctl UPDATE_WINDOW_OLD\n");
504 if (!display || !display->update) { 510 if (!display || !display->driver->update) {
505 r = -EINVAL; 511 r = -EINVAL;
506 break; 512 break;
507 } 513 }
@@ -519,7 +525,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
519 525
520 case OMAPFB_UPDATE_WINDOW: 526 case OMAPFB_UPDATE_WINDOW:
521 DBG("ioctl UPDATE_WINDOW\n"); 527 DBG("ioctl UPDATE_WINDOW\n");
522 if (!display || !display->update) { 528 if (!display || !display->driver->update) {
523 r = -EINVAL; 529 r = -EINVAL;
524 break; 530 break;
525 } 531 }
@@ -648,7 +654,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
648 break; 654 break;
649 } 655 }
650 656
651 r = display->wait_vsync(display); 657 r = display->manager->wait_for_vsync(display->manager);
652 break; 658 break;
653 659
654 case OMAPFB_WAITFORGO: 660 case OMAPFB_WAITFORGO:
@@ -669,12 +675,12 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
669 r = -EFAULT; 675 r = -EFAULT;
670 break; 676 break;
671 } 677 }
672 if (!display || !display->run_test) { 678 if (!display || !display->driver->run_test) {
673 r = -EINVAL; 679 r = -EINVAL;
674 break; 680 break;
675 } 681 }
676 682
677 r = display->run_test(display, p.test_num); 683 r = display->driver->run_test(display, p.test_num);
678 684
679 break; 685 break;
680 686
@@ -684,12 +690,12 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
684 r = -EFAULT; 690 r = -EFAULT;
685 break; 691 break;
686 } 692 }
687 if (!display || !display->run_test) { 693 if (!display || !display->driver->run_test) {
688 r = -EINVAL; 694 r = -EINVAL;
689 break; 695 break;
690 } 696 }
691 697
692 r = display->run_test(display, p.test_num); 698 r = display->driver->run_test(display, p.test_num);
693 699
694 break; 700 break;
695 701
@@ -731,13 +737,37 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
731 break; 737 break;
732 } 738 }
733 739
734 if (!display->enable_te) { 740 if (!display->driver->enable_te) {
735 r = -ENODEV; 741 r = -ENODEV;
736 break; 742 break;
737 } 743 }
738 744
739 r = display->enable_te(display, !!p.tearsync_info.enabled); 745 r = display->driver->enable_te(display,
746 !!p.tearsync_info.enabled);
747
748 break;
749 }
750
751 case OMAPFB_GET_DISPLAY_INFO: {
752 u16 xres, yres;
740 753
754 DBG("ioctl GET_DISPLAY_INFO\n");
755
756 if (display == NULL) {
757 r = -ENODEV;
758 break;
759 }
760
761 display->driver->get_resolution(display, &xres, &yres);
762
763 p.display_info.xres = xres;
764 p.display_info.yres = yres;
765 p.display_info.width = 0;
766 p.display_info.height = 0;
767
768 if (copy_to_user((void __user *)arg, &p.display_info,
769 sizeof(p.display_info)))
770 r = -EFAULT;
741 break; 771 break;
742 } 772 }
743 773
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
index d17caef6915a..4a76917b7cc8 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -54,6 +54,8 @@ module_param_named(test, omapfb_test_pattern, bool, 0644);
54#endif 54#endif
55 55
56static int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi); 56static int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi);
57static int omapfb_get_recommended_bpp(struct omapfb2_device *fbdev,
58 struct omap_dss_device *dssdev);
57 59
58#ifdef DEBUG 60#ifdef DEBUG
59static void draw_pixel(struct fb_info *fbi, int x, int y, unsigned color) 61static void draw_pixel(struct fb_info *fbi, int x, int y, unsigned color)
@@ -152,9 +154,9 @@ static void fill_fb(struct fb_info *fbi)
152} 154}
153#endif 155#endif
154 156
155static unsigned omapfb_get_vrfb_offset(struct omapfb_info *ofbi, int rot) 157static unsigned omapfb_get_vrfb_offset(const struct omapfb_info *ofbi, int rot)
156{ 158{
157 struct vrfb *vrfb = &ofbi->region.vrfb; 159 const struct vrfb *vrfb = &ofbi->region.vrfb;
158 unsigned offset; 160 unsigned offset;
159 161
160 switch (rot) { 162 switch (rot) {
@@ -179,7 +181,7 @@ static unsigned omapfb_get_vrfb_offset(struct omapfb_info *ofbi, int rot)
179 return offset; 181 return offset;
180} 182}
181 183
182static u32 omapfb_get_region_rot_paddr(struct omapfb_info *ofbi, int rot) 184static u32 omapfb_get_region_rot_paddr(const struct omapfb_info *ofbi, int rot)
183{ 185{
184 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { 186 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
185 return ofbi->region.vrfb.paddr[rot] 187 return ofbi->region.vrfb.paddr[rot]
@@ -189,7 +191,7 @@ static u32 omapfb_get_region_rot_paddr(struct omapfb_info *ofbi, int rot)
189 } 191 }
190} 192}
191 193
192static u32 omapfb_get_region_paddr(struct omapfb_info *ofbi) 194static u32 omapfb_get_region_paddr(const struct omapfb_info *ofbi)
193{ 195{
194 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) 196 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
195 return ofbi->region.vrfb.paddr[0]; 197 return ofbi->region.vrfb.paddr[0];
@@ -197,7 +199,7 @@ static u32 omapfb_get_region_paddr(struct omapfb_info *ofbi)
197 return ofbi->region.paddr; 199 return ofbi->region.paddr;
198} 200}
199 201
200static void __iomem *omapfb_get_region_vaddr(struct omapfb_info *ofbi) 202static void __iomem *omapfb_get_region_vaddr(const struct omapfb_info *ofbi)
201{ 203{
202 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) 204 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
203 return ofbi->region.vrfb.vaddr[0]; 205 return ofbi->region.vrfb.vaddr[0];
@@ -703,9 +705,9 @@ int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var)
703 var->width = -1; 705 var->width = -1;
704 var->grayscale = 0; 706 var->grayscale = 0;
705 707
706 if (display && display->get_timings) { 708 if (display && display->driver->get_timings) {
707 struct omap_video_timings timings; 709 struct omap_video_timings timings;
708 display->get_timings(display, &timings); 710 display->driver->get_timings(display, &timings);
709 711
710 /* pixclock in ps, the rest in pixclock */ 712 /* pixclock in ps, the rest in pixclock */
711 var->pixclock = timings.pixel_clock != 0 ? 713 var->pixclock = timings.pixel_clock != 0 ?
@@ -778,8 +780,8 @@ static int omapfb_release(struct fb_info *fbi, int user)
778 return 0; 780 return 0;
779} 781}
780 782
781static unsigned calc_rotation_offset_dma(struct fb_var_screeninfo *var, 783static unsigned calc_rotation_offset_dma(const struct fb_var_screeninfo *var,
782 struct fb_fix_screeninfo *fix, int rotation) 784 const struct fb_fix_screeninfo *fix, int rotation)
783{ 785{
784 unsigned offset; 786 unsigned offset;
785 787
@@ -789,8 +791,8 @@ static unsigned calc_rotation_offset_dma(struct fb_var_screeninfo *var,
789 return offset; 791 return offset;
790} 792}
791 793
792static unsigned calc_rotation_offset_vrfb(struct fb_var_screeninfo *var, 794static unsigned calc_rotation_offset_vrfb(const struct fb_var_screeninfo *var,
793 struct fb_fix_screeninfo *fix, int rotation) 795 const struct fb_fix_screeninfo *fix, int rotation)
794{ 796{
795 unsigned offset; 797 unsigned offset;
796 798
@@ -1221,11 +1223,11 @@ static int omapfb_blank(int blank, struct fb_info *fbi)
1221 if (display->state != OMAP_DSS_DISPLAY_SUSPENDED) 1223 if (display->state != OMAP_DSS_DISPLAY_SUSPENDED)
1222 goto exit; 1224 goto exit;
1223 1225
1224 if (display->resume) 1226 if (display->driver->resume)
1225 r = display->resume(display); 1227 r = display->driver->resume(display);
1226 1228
1227 if (r == 0 && display->get_update_mode && 1229 if (r == 0 && display->driver->get_update_mode &&
1228 display->get_update_mode(display) == 1230 display->driver->get_update_mode(display) ==
1229 OMAP_DSS_UPDATE_MANUAL) 1231 OMAP_DSS_UPDATE_MANUAL)
1230 do_update = 1; 1232 do_update = 1;
1231 1233
@@ -1240,8 +1242,8 @@ static int omapfb_blank(int blank, struct fb_info *fbi)
1240 if (display->state != OMAP_DSS_DISPLAY_ACTIVE) 1242 if (display->state != OMAP_DSS_DISPLAY_ACTIVE)
1241 goto exit; 1243 goto exit;
1242 1244
1243 if (display->suspend) 1245 if (display->driver->suspend)
1244 r = display->suspend(display); 1246 r = display->driver->suspend(display);
1245 1247
1246 break; 1248 break;
1247 1249
@@ -1252,11 +1254,11 @@ static int omapfb_blank(int blank, struct fb_info *fbi)
1252exit: 1254exit:
1253 omapfb_unlock(fbdev); 1255 omapfb_unlock(fbdev);
1254 1256
1255 if (r == 0 && do_update && display->update) { 1257 if (r == 0 && do_update && display->driver->update) {
1256 u16 w, h; 1258 u16 w, h;
1257 display->get_resolution(display, &w, &h); 1259 display->driver->get_resolution(display, &w, &h);
1258 1260
1259 r = display->update(display, 0, 0, w, h); 1261 r = display->driver->update(display, 0, 0, w, h);
1260 } 1262 }
1261 1263
1262 return r; 1264 return r;
@@ -1404,6 +1406,7 @@ static int omapfb_alloc_fbmem_display(struct fb_info *fbi, unsigned long size,
1404 unsigned long paddr) 1406 unsigned long paddr)
1405{ 1407{
1406 struct omapfb_info *ofbi = FB2OFB(fbi); 1408 struct omapfb_info *ofbi = FB2OFB(fbi);
1409 struct omapfb2_device *fbdev = ofbi->fbdev;
1407 struct omap_dss_device *display; 1410 struct omap_dss_device *display;
1408 int bytespp; 1411 int bytespp;
1409 1412
@@ -1412,7 +1415,7 @@ static int omapfb_alloc_fbmem_display(struct fb_info *fbi, unsigned long size,
1412 if (!display) 1415 if (!display)
1413 return 0; 1416 return 0;
1414 1417
1415 switch (display->get_recommended_bpp(display)) { 1418 switch (omapfb_get_recommended_bpp(fbdev, display)) {
1416 case 16: 1419 case 16:
1417 bytespp = 2; 1420 bytespp = 2;
1418 break; 1421 break;
@@ -1427,7 +1430,7 @@ static int omapfb_alloc_fbmem_display(struct fb_info *fbi, unsigned long size,
1427 if (!size) { 1430 if (!size) {
1428 u16 w, h; 1431 u16 w, h;
1429 1432
1430 display->get_resolution(display, &w, &h); 1433 display->driver->get_resolution(display, &w, &h);
1431 1434
1432 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { 1435 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
1433 size = max(omap_vrfb_min_phys_size(w, h, bytespp), 1436 size = max(omap_vrfb_min_phys_size(w, h, bytespp),
@@ -1636,8 +1639,8 @@ int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type)
1636 if (old_size == size && old_type == type) 1639 if (old_size == size && old_type == type)
1637 return 0; 1640 return 0;
1638 1641
1639 if (display && display->sync) 1642 if (display && display->driver->sync)
1640 display->sync(display); 1643 display->driver->sync(display);
1641 1644
1642 omapfb_free_fbmem(fbi); 1645 omapfb_free_fbmem(fbi);
1643 1646
@@ -1745,7 +1748,7 @@ static int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi)
1745 u16 w, h; 1748 u16 w, h;
1746 int rotation = (var->rotate + ofbi->rotation[0]) % 4; 1749 int rotation = (var->rotate + ofbi->rotation[0]) % 4;
1747 1750
1748 display->get_resolution(display, &w, &h); 1751 display->driver->get_resolution(display, &w, &h);
1749 1752
1750 if (rotation == FB_ROTATE_CW || 1753 if (rotation == FB_ROTATE_CW ||
1751 rotation == FB_ROTATE_CCW) { 1754 rotation == FB_ROTATE_CCW) {
@@ -1760,7 +1763,7 @@ static int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi)
1760 var->yres_virtual = var->yres; 1763 var->yres_virtual = var->yres;
1761 1764
1762 if (!var->bits_per_pixel) { 1765 if (!var->bits_per_pixel) {
1763 switch (display->get_recommended_bpp(display)) { 1766 switch (omapfb_get_recommended_bpp(fbdev, display)) {
1764 case 16: 1767 case 16:
1765 var->bits_per_pixel = 16; 1768 var->bits_per_pixel = 16;
1766 break; 1769 break;
@@ -1828,7 +1831,7 @@ static void omapfb_free_resources(struct omapfb2_device *fbdev)
1828 1831
1829 for (i = 0; i < fbdev->num_displays; i++) { 1832 for (i = 0; i < fbdev->num_displays; i++) {
1830 if (fbdev->displays[i]->state != OMAP_DSS_DISPLAY_DISABLED) 1833 if (fbdev->displays[i]->state != OMAP_DSS_DISPLAY_DISABLED)
1831 fbdev->displays[i]->disable(fbdev->displays[i]); 1834 fbdev->displays[i]->driver->disable(fbdev->displays[i]);
1832 1835
1833 omap_dss_put_device(fbdev->displays[i]); 1836 omap_dss_put_device(fbdev->displays[i]);
1834 } 1837 }
@@ -2011,7 +2014,8 @@ static int omapfb_mode_to_timings(const char *mode_str,
2011 } 2014 }
2012} 2015}
2013 2016
2014static int omapfb_set_def_mode(struct omap_dss_device *display, char *mode_str) 2017static int omapfb_set_def_mode(struct omapfb2_device *fbdev,
2018 struct omap_dss_device *display, char *mode_str)
2015{ 2019{
2016 int r; 2020 int r;
2017 u8 bpp; 2021 u8 bpp;
@@ -2021,20 +2025,37 @@ static int omapfb_set_def_mode(struct omap_dss_device *display, char *mode_str)
2021 if (r) 2025 if (r)
2022 return r; 2026 return r;
2023 2027
2024 display->panel.recommended_bpp = bpp; 2028 fbdev->bpp_overrides[fbdev->num_bpp_overrides].dssdev = display;
2029 fbdev->bpp_overrides[fbdev->num_bpp_overrides].bpp = bpp;
2030 ++fbdev->num_bpp_overrides;
2025 2031
2026 if (!display->check_timings || !display->set_timings) 2032 if (!display->driver->check_timings || !display->driver->set_timings)
2027 return -EINVAL; 2033 return -EINVAL;
2028 2034
2029 r = display->check_timings(display, &timings); 2035 r = display->driver->check_timings(display, &timings);
2030 if (r) 2036 if (r)
2031 return r; 2037 return r;
2032 2038
2033 display->set_timings(display, &timings); 2039 display->driver->set_timings(display, &timings);
2034 2040
2035 return 0; 2041 return 0;
2036} 2042}
2037 2043
2044static int omapfb_get_recommended_bpp(struct omapfb2_device *fbdev,
2045 struct omap_dss_device *dssdev)
2046{
2047 int i;
2048
2049 BUG_ON(dssdev->driver->get_recommended_bpp == NULL);
2050
2051 for (i = 0; i < fbdev->num_bpp_overrides; ++i) {
2052 if (dssdev == fbdev->bpp_overrides[i].dssdev)
2053 return fbdev->bpp_overrides[i].bpp;
2054 }
2055
2056 return dssdev->driver->get_recommended_bpp(dssdev);
2057}
2058
2038static int omapfb_parse_def_modes(struct omapfb2_device *fbdev) 2059static int omapfb_parse_def_modes(struct omapfb2_device *fbdev)
2039{ 2060{
2040 char *str, *options, *this_opt; 2061 char *str, *options, *this_opt;
@@ -2073,7 +2094,7 @@ static int omapfb_parse_def_modes(struct omapfb2_device *fbdev)
2073 break; 2094 break;
2074 } 2095 }
2075 2096
2076 r = omapfb_set_def_mode(display, mode_str); 2097 r = omapfb_set_def_mode(fbdev, display, mode_str);
2077 if (r) 2098 if (r)
2078 break; 2099 break;
2079 } 2100 }
@@ -2111,18 +2132,23 @@ static int omapfb_probe(struct platform_device *pdev)
2111 fbdev->dev = &pdev->dev; 2132 fbdev->dev = &pdev->dev;
2112 platform_set_drvdata(pdev, fbdev); 2133 platform_set_drvdata(pdev, fbdev);
2113 2134
2135 r = 0;
2114 fbdev->num_displays = 0; 2136 fbdev->num_displays = 0;
2115 dssdev = NULL; 2137 dssdev = NULL;
2116 for_each_dss_dev(dssdev) { 2138 for_each_dss_dev(dssdev) {
2117 omap_dss_get_device(dssdev); 2139 omap_dss_get_device(dssdev);
2140
2118 if (!dssdev->driver) { 2141 if (!dssdev->driver) {
2119 dev_err(&pdev->dev, "no driver for display\n"); 2142 dev_err(&pdev->dev, "no driver for display\n");
2120 r = -EINVAL; 2143 r = -ENODEV;
2121 goto cleanup;
2122 } 2144 }
2145
2123 fbdev->displays[fbdev->num_displays++] = dssdev; 2146 fbdev->displays[fbdev->num_displays++] = dssdev;
2124 } 2147 }
2125 2148
2149 if (r)
2150 goto cleanup;
2151
2126 if (fbdev->num_displays == 0) { 2152 if (fbdev->num_displays == 0) {
2127 dev_err(&pdev->dev, "no displays\n"); 2153 dev_err(&pdev->dev, "no displays\n");
2128 r = -EINVAL; 2154 r = -EINVAL;
@@ -2167,35 +2193,28 @@ static int omapfb_probe(struct platform_device *pdev)
2167 } 2193 }
2168 2194
2169 if (def_display) { 2195 if (def_display) {
2170#ifndef CONFIG_FB_OMAP2_FORCE_AUTO_UPDATE 2196 struct omap_dss_driver *dssdrv = def_display->driver;
2171 u16 w, h; 2197
2172#endif 2198 r = def_display->driver->enable(def_display);
2173 r = def_display->enable(def_display); 2199 if (r) {
2174 if (r)
2175 dev_warn(fbdev->dev, "Failed to enable display '%s'\n", 2200 dev_warn(fbdev->dev, "Failed to enable display '%s'\n",
2176 def_display->name); 2201 def_display->name);
2202 goto cleanup;
2203 }
2177 2204
2178 /* set the update mode */
2179 if (def_display->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) { 2205 if (def_display->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) {
2180#ifdef CONFIG_FB_OMAP2_FORCE_AUTO_UPDATE 2206 u16 w, h;
2181 if (def_display->enable_te) 2207 if (dssdrv->enable_te)
2182 def_display->enable_te(def_display, 1); 2208 dssdrv->enable_te(def_display, 1);
2183 if (def_display->set_update_mode) 2209 if (dssdrv->set_update_mode)
2184 def_display->set_update_mode(def_display, 2210 dssdrv->set_update_mode(def_display,
2185 OMAP_DSS_UPDATE_AUTO);
2186#else /* MANUAL_UPDATE */
2187 if (def_display->enable_te)
2188 def_display->enable_te(def_display, 0);
2189 if (def_display->set_update_mode)
2190 def_display->set_update_mode(def_display,
2191 OMAP_DSS_UPDATE_MANUAL); 2211 OMAP_DSS_UPDATE_MANUAL);
2192 2212
2193 def_display->get_resolution(def_display, &w, &h); 2213 dssdrv->get_resolution(def_display, &w, &h);
2194 def_display->update(def_display, 0, 0, w, h); 2214 def_display->driver->update(def_display, 0, 0, w, h);
2195#endif
2196 } else { 2215 } else {
2197 if (def_display->set_update_mode) 2216 if (dssdrv->set_update_mode)
2198 def_display->set_update_mode(def_display, 2217 dssdrv->set_update_mode(def_display,
2199 OMAP_DSS_UPDATE_AUTO); 2218 OMAP_DSS_UPDATE_AUTO);
2200 } 2219 }
2201 } 2220 }
diff --git a/drivers/video/omap2/omapfb/omapfb.h b/drivers/video/omap2/omapfb/omapfb.h
index f7c9c739e5ef..cd54fdbfd8bb 100644
--- a/drivers/video/omap2/omapfb/omapfb.h
+++ b/drivers/video/omap2/omapfb/omapfb.h
@@ -83,6 +83,12 @@ struct omapfb2_device {
83 struct omap_overlay *overlays[10]; 83 struct omap_overlay *overlays[10];
84 unsigned num_managers; 84 unsigned num_managers;
85 struct omap_overlay_manager *managers[10]; 85 struct omap_overlay_manager *managers[10];
86
87 unsigned num_bpp_overrides;
88 struct {
89 struct omap_dss_device *dssdev;
90 u8 bpp;
91 } bpp_overrides[10];
86}; 92};
87 93
88struct omapfb_colormode { 94struct omapfb_colormode {
@@ -105,6 +111,9 @@ void omapfb_remove_sysfs(struct omapfb2_device *fbdev);
105 111
106int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg); 112int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg);
107 113
114int omapfb_update_window(struct fb_info *fbi,
115 u32 x, u32 y, u32 w, u32 h);
116
108int dss_mode_to_fb_mode(enum omap_color_mode dssmode, 117int dss_mode_to_fb_mode(enum omap_color_mode dssmode,
109 struct fb_var_screeninfo *var); 118 struct fb_var_screeninfo *var);
110 119
diff --git a/drivers/video/sunxvr500.c b/drivers/video/sunxvr500.c
index 18b950706cad..4cd50497264d 100644
--- a/drivers/video/sunxvr500.c
+++ b/drivers/video/sunxvr500.c
@@ -400,6 +400,7 @@ static void __devexit e3d_pci_unregister(struct pci_dev *pdev)
400 400
401static struct pci_device_id e3d_pci_table[] = { 401static struct pci_device_id e3d_pci_table[] = {
402 { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x7a0), }, 402 { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x7a0), },
403 { PCI_DEVICE(0x1091, 0x7a0), },
403 { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x7a2), }, 404 { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x7a2), },
404 { .vendor = PCI_VENDOR_ID_3DLABS, 405 { .vendor = PCI_VENDOR_ID_3DLABS,
405 .device = PCI_ANY_ID, 406 .device = PCI_ANY_ID,
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 1d5191fab62e..1b6573216998 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -473,7 +473,8 @@ static void vp_del_vqs(struct virtio_device *vdev)
473 473
474 list_for_each_entry_safe(vq, n, &vdev->vqs, list) { 474 list_for_each_entry_safe(vq, n, &vdev->vqs, list) {
475 info = vq->priv; 475 info = vq->priv;
476 if (vp_dev->per_vq_vectors) 476 if (vp_dev->per_vq_vectors &&
477 info->msix_vector != VIRTIO_MSI_NO_VECTOR)
477 free_irq(vp_dev->msix_entries[info->msix_vector].vector, 478 free_irq(vp_dev->msix_entries[info->msix_vector].vector,
478 vq); 479 vq);
479 vp_del_vq(vq); 480 vp_del_vq(vq);
diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig
index 3195fb8b7d9a..80b3b123dd7f 100644
--- a/drivers/w1/masters/Kconfig
+++ b/drivers/w1/masters/Kconfig
@@ -60,7 +60,7 @@ config W1_MASTER_GPIO
60 60
61config HDQ_MASTER_OMAP 61config HDQ_MASTER_OMAP
62 tristate "OMAP HDQ driver" 62 tristate "OMAP HDQ driver"
63 depends on ARCH_OMAP2430 || ARCH_OMAP34XX 63 depends on ARCH_OMAP2430 || ARCH_OMAP3
64 help 64 help
65 Say Y here if you want support for the 1-wire or HDQ Interface 65 Say Y here if you want support for the 1-wire or HDQ Interface
66 on an OMAP processor. 66 on an OMAP processor.
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 050ee147592f..3da3f48720a7 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -194,7 +194,7 @@ config EP93XX_WATCHDOG
194 194
195config OMAP_WATCHDOG 195config OMAP_WATCHDOG
196 tristate "OMAP Watchdog" 196 tristate "OMAP Watchdog"
197 depends on ARCH_OMAP16XX || ARCH_OMAP24XX || ARCH_OMAP34XX 197 depends on ARCH_OMAP16XX || ARCH_OMAP2 || ARCH_OMAP3
198 help 198 help
199 Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430 watchdog. Say 'Y' 199 Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430 watchdog. Say 'Y'
200 here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430 watchdog timer. 200 here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430 watchdog timer.
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index 430a5848a9a5..c7a9479934af 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -96,9 +96,6 @@ static void wdt_enable(void)
96{ 96{
97 spin_lock(&io_lock); 97 spin_lock(&io_lock);
98 98
99 if (wdt_clk)
100 clk_set_rate(wdt_clk, 1);
101
102 /* stop counter, initiate counter reset */ 99 /* stop counter, initiate counter reset */
103 __raw_writel(RESET_COUNT, WDTIM_CTRL(wdt_base)); 100 __raw_writel(RESET_COUNT, WDTIM_CTRL(wdt_base));
104 /*wait for reset to complete. 100% guarantee event */ 101 /*wait for reset to complete. 100% guarantee event */
@@ -125,19 +122,25 @@ static void wdt_disable(void)
125 spin_lock(&io_lock); 122 spin_lock(&io_lock);
126 123
127 __raw_writel(0, WDTIM_CTRL(wdt_base)); /*stop counter */ 124 __raw_writel(0, WDTIM_CTRL(wdt_base)); /*stop counter */
128 if (wdt_clk)
129 clk_set_rate(wdt_clk, 0);
130 125
131 spin_unlock(&io_lock); 126 spin_unlock(&io_lock);
132} 127}
133 128
134static int pnx4008_wdt_open(struct inode *inode, struct file *file) 129static int pnx4008_wdt_open(struct inode *inode, struct file *file)
135{ 130{
131 int ret;
132
136 if (test_and_set_bit(WDT_IN_USE, &wdt_status)) 133 if (test_and_set_bit(WDT_IN_USE, &wdt_status))
137 return -EBUSY; 134 return -EBUSY;
138 135
139 clear_bit(WDT_OK_TO_CLOSE, &wdt_status); 136 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
140 137
138 ret = clk_enable(wdt_clk);
139 if (ret) {
140 clear_bit(WDT_IN_USE, &wdt_status);
141 return ret;
142 }
143
141 wdt_enable(); 144 wdt_enable();
142 145
143 return nonseekable_open(inode, file); 146 return nonseekable_open(inode, file);
@@ -225,6 +228,7 @@ static int pnx4008_wdt_release(struct inode *inode, struct file *file)
225 printk(KERN_WARNING "WATCHDOG: Device closed unexpectdly\n"); 228 printk(KERN_WARNING "WATCHDOG: Device closed unexpectdly\n");
226 229
227 wdt_disable(); 230 wdt_disable();
231 clk_disable(wdt_clk);
228 clear_bit(WDT_IN_USE, &wdt_status); 232 clear_bit(WDT_IN_USE, &wdt_status);
229 clear_bit(WDT_OK_TO_CLOSE, &wdt_status); 233 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
230 234
@@ -273,25 +277,33 @@ static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
273 } 277 }
274 wdt_base = (void __iomem *)IO_ADDRESS(res->start); 278 wdt_base = (void __iomem *)IO_ADDRESS(res->start);
275 279
276 wdt_clk = clk_get(&pdev->dev, "wdt_ck"); 280 wdt_clk = clk_get(&pdev->dev, NULL);
277 if (IS_ERR(wdt_clk)) { 281 if (IS_ERR(wdt_clk)) {
278 ret = PTR_ERR(wdt_clk); 282 ret = PTR_ERR(wdt_clk);
279 release_resource(wdt_mem); 283 release_resource(wdt_mem);
280 kfree(wdt_mem); 284 kfree(wdt_mem);
281 goto out; 285 goto out;
282 } else 286 }
283 clk_set_rate(wdt_clk, 1); 287
288 ret = clk_enable(wdt_clk);
289 if (ret) {
290 release_resource(wdt_mem);
291 kfree(wdt_mem);
292 goto out;
293 }
284 294
285 ret = misc_register(&pnx4008_wdt_miscdev); 295 ret = misc_register(&pnx4008_wdt_miscdev);
286 if (ret < 0) { 296 if (ret < 0) {
287 printk(KERN_ERR MODULE_NAME "cannot register misc device\n"); 297 printk(KERN_ERR MODULE_NAME "cannot register misc device\n");
288 release_resource(wdt_mem); 298 release_resource(wdt_mem);
289 kfree(wdt_mem); 299 kfree(wdt_mem);
290 clk_set_rate(wdt_clk, 0); 300 clk_disable(wdt_clk);
301 clk_put(wdt_clk);
291 } else { 302 } else {
292 boot_status = (__raw_readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? 303 boot_status = (__raw_readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ?
293 WDIOF_CARDRESET : 0; 304 WDIOF_CARDRESET : 0;
294 wdt_disable(); /*disable for now */ 305 wdt_disable(); /*disable for now */
306 clk_disable(wdt_clk);
295 set_bit(WDT_DEVICE_INITED, &wdt_status); 307 set_bit(WDT_DEVICE_INITED, &wdt_status);
296 } 308 }
297 309
@@ -302,11 +314,10 @@ out:
302static int __devexit pnx4008_wdt_remove(struct platform_device *pdev) 314static int __devexit pnx4008_wdt_remove(struct platform_device *pdev)
303{ 315{
304 misc_deregister(&pnx4008_wdt_miscdev); 316 misc_deregister(&pnx4008_wdt_miscdev);
305 if (wdt_clk) { 317
306 clk_set_rate(wdt_clk, 0); 318 clk_disable(wdt_clk);
307 clk_put(wdt_clk); 319 clk_put(wdt_clk);
308 wdt_clk = NULL; 320
309 }
310 if (wdt_mem) { 321 if (wdt_mem) {
311 release_resource(wdt_mem); 322 release_resource(wdt_mem);
312 kfree(wdt_mem); 323 kfree(wdt_mem);