aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-07-13 16:23:51 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-07-13 16:23:51 -0400
commit327309e899662b482c58cf25f574513d38b5788c (patch)
tree069de438aa0e92dd9b6ba28e6b207e2cd07151a5 /drivers
parent0c168775709faa74c1b87f1e61046e0c51ade7f3 (diff)
parentc32511e2718618f0b53479eb36e07439aa363a74 (diff)
Merge upstream 2.6.13-rc3 into ieee80211 branch of netdev-2.6.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Kconfig4
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acpi/Kconfig38
-rw-r--r--drivers/acpi/Makefile5
-rw-r--r--drivers/acpi/asus_acpi.c4
-rw-r--r--drivers/acpi/bus.c8
-rw-r--r--drivers/acpi/button.c245
-rw-r--r--drivers/acpi/dispatcher/dsfield.c58
-rw-r--r--drivers/acpi/dispatcher/dsinit.c28
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c11
-rw-r--r--drivers/acpi/dispatcher/dsmthdat.c195
-rw-r--r--drivers/acpi/dispatcher/dsobject.c79
-rw-r--r--drivers/acpi/dispatcher/dsopcode.c105
-rw-r--r--drivers/acpi/dispatcher/dsutils.c41
-rw-r--r--drivers/acpi/dispatcher/dswexec.c57
-rw-r--r--drivers/acpi/dispatcher/dswload.c118
-rw-r--r--drivers/acpi/dispatcher/dswscope.c31
-rw-r--r--drivers/acpi/dispatcher/dswstate.c458
-rw-r--r--drivers/acpi/ec.c420
-rw-r--r--drivers/acpi/events/evevent.c33
-rw-r--r--drivers/acpi/events/evgpe.c39
-rw-r--r--drivers/acpi/events/evgpeblk.c63
-rw-r--r--drivers/acpi/events/evmisc.c97
-rw-r--r--drivers/acpi/events/evregion.c35
-rw-r--r--drivers/acpi/events/evrgnini.c14
-rw-r--r--drivers/acpi/events/evsci.c12
-rw-r--r--drivers/acpi/events/evxface.c19
-rw-r--r--drivers/acpi/events/evxfevnt.c25
-rw-r--r--drivers/acpi/executer/exconfig.c31
-rw-r--r--drivers/acpi/executer/exconvrt.c44
-rw-r--r--drivers/acpi/executer/excreate.c50
-rw-r--r--drivers/acpi/executer/exdump.c105
-rw-r--r--drivers/acpi/executer/exfield.c25
-rw-r--r--drivers/acpi/executer/exfldio.c133
-rw-r--r--drivers/acpi/executer/exmisc.c7
-rw-r--r--drivers/acpi/executer/exmutex.c45
-rw-r--r--drivers/acpi/executer/exnames.c70
-rw-r--r--drivers/acpi/executer/exoparg1.c94
-rw-r--r--drivers/acpi/executer/exoparg2.c69
-rw-r--r--drivers/acpi/executer/exoparg3.c25
-rw-r--r--drivers/acpi/executer/exoparg6.c26
-rw-r--r--drivers/acpi/executer/exprep.c104
-rw-r--r--drivers/acpi/executer/exregion.c34
-rw-r--r--drivers/acpi/executer/exresnte.c24
-rw-r--r--drivers/acpi/executer/exresolv.c63
-rw-r--r--drivers/acpi/executer/exresop.c80
-rw-r--r--drivers/acpi/executer/exstore.c260
-rw-r--r--drivers/acpi/executer/exstoren.c20
-rw-r--r--drivers/acpi/executer/exstorob.c9
-rw-r--r--drivers/acpi/executer/exsystem.c48
-rw-r--r--drivers/acpi/executer/exutils.c37
-rw-r--r--drivers/acpi/glue.c360
-rw-r--r--drivers/acpi/hardware/hwacpi.c19
-rw-r--r--drivers/acpi/hardware/hwgpe.c31
-rw-r--r--drivers/acpi/hardware/hwregs.c114
-rw-r--r--drivers/acpi/hardware/hwsleep.c101
-rw-r--r--drivers/acpi/hardware/hwtimer.c4
-rw-r--r--drivers/acpi/hotkey.c1019
-rw-r--r--drivers/acpi/ibm_acpi.c8
-rw-r--r--drivers/acpi/namespace/nsaccess.c5
-rw-r--r--drivers/acpi/namespace/nsalloc.c121
-rw-r--r--drivers/acpi/namespace/nsdump.c109
-rw-r--r--drivers/acpi/namespace/nsdumpdv.c18
-rw-r--r--drivers/acpi/namespace/nseval.c70
-rw-r--r--drivers/acpi/namespace/nsinit.c28
-rw-r--r--drivers/acpi/namespace/nsload.c28
-rw-r--r--drivers/acpi/namespace/nsnames.c12
-rw-r--r--drivers/acpi/namespace/nsobject.c14
-rw-r--r--drivers/acpi/namespace/nssearch.c29
-rw-r--r--drivers/acpi/namespace/nsutils.c167
-rw-r--r--drivers/acpi/namespace/nswalk.c2
-rw-r--r--drivers/acpi/namespace/nsxfeval.c16
-rw-r--r--drivers/acpi/namespace/nsxfname.c8
-rw-r--r--drivers/acpi/namespace/nsxfobj.c4
-rw-r--r--drivers/acpi/osl.c12
-rw-r--r--drivers/acpi/parser/psargs.c55
-rw-r--r--drivers/acpi/parser/psopcode.c298
-rw-r--r--drivers/acpi/parser/psparse.c144
-rw-r--r--drivers/acpi/parser/psscope.c45
-rw-r--r--drivers/acpi/parser/pstree.c159
-rw-r--r--drivers/acpi/parser/psutils.c15
-rw-r--r--drivers/acpi/parser/pswalk.c11
-rw-r--r--drivers/acpi/parser/psxface.c21
-rw-r--r--drivers/acpi/pci_irq.c2
-rw-r--r--drivers/acpi/pci_link.c43
-rw-r--r--drivers/acpi/processor_core.c37
-rw-r--r--drivers/acpi/processor_idle.c138
-rw-r--r--drivers/acpi/processor_perflib.c33
-rw-r--r--drivers/acpi/resources/rsaddr.c480
-rw-r--r--drivers/acpi/resources/rscalc.c144
-rw-r--r--drivers/acpi/resources/rscreate.c45
-rw-r--r--drivers/acpi/resources/rsdump.c402
-rw-r--r--drivers/acpi/resources/rsio.c197
-rw-r--r--drivers/acpi/resources/rsirq.c167
-rw-r--r--drivers/acpi/resources/rslist.c68
-rw-r--r--drivers/acpi/resources/rsmemory.c236
-rw-r--r--drivers/acpi/resources/rsmisc.c160
-rw-r--r--drivers/acpi/resources/rsutils.c53
-rw-r--r--drivers/acpi/resources/rsxface.c43
-rw-r--r--drivers/acpi/scan.c12
-rw-r--r--drivers/acpi/sleep/main.c74
-rw-r--r--drivers/acpi/sleep/poweroff.c81
-rw-r--r--drivers/acpi/sleep/proc.c9
-rw-r--r--drivers/acpi/tables/tbconvrt.c105
-rw-r--r--drivers/acpi/tables/tbget.c63
-rw-r--r--drivers/acpi/tables/tbgetall.c45
-rw-r--r--drivers/acpi/tables/tbinstal.c31
-rw-r--r--drivers/acpi/tables/tbrsdt.c19
-rw-r--r--drivers/acpi/tables/tbutils.c97
-rw-r--r--drivers/acpi/tables/tbxface.c39
-rw-r--r--drivers/acpi/tables/tbxfroot.c123
-rw-r--r--drivers/acpi/toshiba_acpi.c8
-rw-r--r--drivers/acpi/utilities/utalloc.c84
-rw-r--r--drivers/acpi/utilities/utcopy.c126
-rw-r--r--drivers/acpi/utilities/utdebug.c106
-rw-r--r--drivers/acpi/utilities/utdelete.c63
-rw-r--r--drivers/acpi/utilities/uteval.c36
-rw-r--r--drivers/acpi/utilities/utglobal.c133
-rw-r--r--drivers/acpi/utilities/utinit.c36
-rw-r--r--drivers/acpi/utilities/utmath.c2
-rw-r--r--drivers/acpi/utilities/utmisc.c187
-rw-r--r--drivers/acpi/utilities/utobject.c68
-rw-r--r--drivers/acpi/utilities/utxface.c61
-rw-r--r--drivers/acpi/video.c15
-rw-r--r--drivers/base/base.h1
-rw-r--r--drivers/base/bus.c117
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/base/dd.c2
-rw-r--r--drivers/base/driver.c35
-rw-r--r--drivers/base/sys.c1
-rw-r--r--drivers/bluetooth/bluecard_cs.c7
-rw-r--r--drivers/bluetooth/bt3c_cs.c7
-rw-r--r--drivers/bluetooth/btuart_cs.c7
-rw-r--r--drivers/bluetooth/dtl1_cs.c7
-rw-r--r--drivers/bluetooth/hci_vhci.c2
-rw-r--r--drivers/char/Makefile2
-rw-r--r--drivers/char/drm/Kconfig7
-rw-r--r--drivers/char/drm/Makefile5
-rw-r--r--drivers/char/drm/ati_pcigart.c2
-rw-r--r--drivers/char/drm/drm.h2
-rw-r--r--drivers/char/drm/drmP.h30
-rw-r--r--drivers/char/drm/drm_auth.c4
-rw-r--r--drivers/char/drm/drm_bufs.c12
-rw-r--r--drivers/char/drm/drm_context.c4
-rw-r--r--drivers/char/drm/drm_drv.c9
-rw-r--r--drivers/char/drm/drm_fops.c14
-rw-r--r--drivers/char/drm/drm_irq.c2
-rw-r--r--drivers/char/drm/drm_lock.c12
-rw-r--r--drivers/char/drm/drm_memory.c13
-rw-r--r--drivers/char/drm/drm_pciids.h7
-rw-r--r--drivers/char/drm/drm_proc.c2
-rw-r--r--drivers/char/drm/drm_stub.c92
-rw-r--r--drivers/char/drm/drm_vm.c10
-rw-r--r--drivers/char/drm/i810_dma.c24
-rw-r--r--drivers/char/drm/i810_drv.h1
-rw-r--r--drivers/char/drm/i830_dma.c20
-rw-r--r--drivers/char/drm/i830_drv.c2
-rw-r--r--drivers/char/drm/i830_drv.h2
-rw-r--r--drivers/char/drm/i830_irq.c5
-rw-r--r--drivers/char/drm/i915_dma.c60
-rw-r--r--drivers/char/drm/i915_drv.c5
-rw-r--r--drivers/char/drm/i915_drv.h14
-rw-r--r--drivers/char/drm/i915_ioc32.c221
-rw-r--r--drivers/char/drm/i915_irq.c4
-rw-r--r--drivers/char/drm/mga_drv.c3
-rw-r--r--drivers/char/drm/mga_drv.h2
-rw-r--r--drivers/char/drm/mga_ioc32.c167
-rw-r--r--drivers/char/drm/r128_drv.c3
-rw-r--r--drivers/char/drm/r128_drv.h3
-rw-r--r--drivers/char/drm/r128_ioc32.c219
-rw-r--r--drivers/char/drm/r128_state.c2
-rw-r--r--drivers/char/drm/via_3d_reg.h1651
-rw-r--r--drivers/char/drm/via_dma.c741
-rw-r--r--drivers/char/drm/via_drm.h243
-rw-r--r--drivers/char/drm/via_drv.c126
-rw-r--r--drivers/char/drm/via_drv.h118
-rw-r--r--drivers/char/drm/via_ds.c280
-rw-r--r--drivers/char/drm/via_ds.h104
-rw-r--r--drivers/char/drm/via_irq.c339
-rw-r--r--drivers/char/drm/via_map.c110
-rw-r--r--drivers/char/drm/via_mm.c358
-rw-r--r--drivers/char/drm/via_mm.h40
-rw-r--r--drivers/char/drm/via_verifier.c1061
-rw-r--r--drivers/char/drm/via_verifier.h61
-rw-r--r--drivers/char/drm/via_video.c97
-rw-r--r--drivers/char/hvc_console.c429
-rw-r--r--drivers/char/hvc_vio.c152
-rw-r--r--drivers/char/hvsi.c8
-rw-r--r--drivers/char/hw_random.c2
-rw-r--r--drivers/char/n_tty.c33
-rw-r--r--drivers/char/pcmcia/synclink_cs.c7
-rw-r--r--drivers/char/random.c2
-rw-r--r--drivers/char/sysrq.c2
-rw-r--r--drivers/char/tb0219.c19
-rw-r--r--drivers/char/tpm/tpm.c2
-rw-r--r--drivers/char/watchdog/i8xx_tco.c2
-rw-r--r--drivers/cpufreq/cpufreq.c4
-rw-r--r--drivers/crypto/padlock-aes.c153
-rw-r--r--drivers/crypto/padlock.h22
-rw-r--r--drivers/hwmon/Kconfig420
-rw-r--r--drivers/hwmon/Makefile44
-rw-r--r--drivers/hwmon/adm1021.c (renamed from drivers/i2c/chips/adm1021.c)0
-rw-r--r--drivers/hwmon/adm1025.c (renamed from drivers/i2c/chips/adm1025.c)0
-rw-r--r--drivers/hwmon/adm1026.c (renamed from drivers/i2c/chips/adm1026.c)0
-rw-r--r--drivers/hwmon/adm1031.c (renamed from drivers/i2c/chips/adm1031.c)0
-rw-r--r--drivers/hwmon/adm9240.c (renamed from drivers/i2c/chips/adm9240.c)0
-rw-r--r--drivers/hwmon/asb100.c (renamed from drivers/i2c/chips/asb100.c)0
-rw-r--r--drivers/hwmon/atxp1.c (renamed from drivers/i2c/chips/atxp1.c)0
-rw-r--r--drivers/hwmon/ds1621.c (renamed from drivers/i2c/chips/ds1621.c)0
-rw-r--r--drivers/hwmon/fscher.c (renamed from drivers/i2c/chips/fscher.c)0
-rw-r--r--drivers/hwmon/fscpos.c (renamed from drivers/i2c/chips/fscpos.c)0
-rw-r--r--drivers/hwmon/gl518sm.c (renamed from drivers/i2c/chips/gl518sm.c)0
-rw-r--r--drivers/hwmon/gl520sm.c (renamed from drivers/i2c/chips/gl520sm.c)0
-rw-r--r--drivers/hwmon/it87.c (renamed from drivers/i2c/chips/it87.c)0
-rw-r--r--drivers/hwmon/lm63.c (renamed from drivers/i2c/chips/lm63.c)0
-rw-r--r--drivers/hwmon/lm75.c (renamed from drivers/i2c/chips/lm75.c)0
-rw-r--r--drivers/hwmon/lm75.h (renamed from drivers/i2c/chips/lm75.h)0
-rw-r--r--drivers/hwmon/lm77.c (renamed from drivers/i2c/chips/lm77.c)0
-rw-r--r--drivers/hwmon/lm78.c (renamed from drivers/i2c/chips/lm78.c)0
-rw-r--r--drivers/hwmon/lm80.c (renamed from drivers/i2c/chips/lm80.c)0
-rw-r--r--drivers/hwmon/lm83.c (renamed from drivers/i2c/chips/lm83.c)0
-rw-r--r--drivers/hwmon/lm85.c (renamed from drivers/i2c/chips/lm85.c)0
-rw-r--r--drivers/hwmon/lm87.c (renamed from drivers/i2c/chips/lm87.c)0
-rw-r--r--drivers/hwmon/lm90.c (renamed from drivers/i2c/chips/lm90.c)0
-rw-r--r--drivers/hwmon/lm92.c (renamed from drivers/i2c/chips/lm92.c)0
-rw-r--r--drivers/hwmon/max1619.c (renamed from drivers/i2c/chips/max1619.c)0
-rw-r--r--drivers/hwmon/pc87360.c (renamed from drivers/i2c/chips/pc87360.c)0
-rw-r--r--drivers/hwmon/sis5595.c (renamed from drivers/i2c/chips/sis5595.c)0
-rw-r--r--drivers/hwmon/smsc47b397.c (renamed from drivers/i2c/chips/smsc47b397.c)0
-rw-r--r--drivers/hwmon/smsc47m1.c (renamed from drivers/i2c/chips/smsc47m1.c)0
-rw-r--r--drivers/hwmon/via686a.c (renamed from drivers/i2c/chips/via686a.c)12
-rw-r--r--drivers/hwmon/w83627ehf.c (renamed from drivers/i2c/chips/w83627ehf.c)0
-rw-r--r--drivers/hwmon/w83627hf.c (renamed from drivers/i2c/chips/w83627hf.c)0
-rw-r--r--drivers/hwmon/w83781d.c (renamed from drivers/i2c/chips/w83781d.c)0
-rw-r--r--drivers/hwmon/w83l785ts.c (renamed from drivers/i2c/chips/w83l785ts.c)0
-rw-r--r--drivers/i2c/algos/i2c-algo-ite.c8
-rw-r--r--drivers/i2c/busses/i2c-i801.c4
-rw-r--r--drivers/i2c/busses/i2c-keywest.c7
-rw-r--r--drivers/i2c/busses/i2c-piix4.c2
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c2
-rw-r--r--drivers/i2c/chips/Kconfig413
-rw-r--r--drivers/i2c/chips/Makefile38
-rw-r--r--drivers/i2c/chips/eeprom.c3
-rw-r--r--drivers/i2c/chips/m41t00.c2
-rw-r--r--drivers/i2c/chips/max6875.c6
-rw-r--r--drivers/i2c/chips/tps65010.c59
-rw-r--r--drivers/i2c/i2c-core.c17
-rw-r--r--drivers/ide/Makefile1
-rw-r--r--drivers/ide/ide-cd.c4
-rw-r--r--drivers/ide/ide-lib.c13
-rw-r--r--drivers/ide/legacy/hd.c4
-rw-r--r--drivers/ide/legacy/ide-cs.c7
-rw-r--r--drivers/ide/pci/alim15x3.c10
-rw-r--r--drivers/ide/pci/amd74xx.c7
-rw-r--r--drivers/ide/pci/cs5530.c4
-rw-r--r--drivers/ide/pci/cy82c693.c8
-rw-r--r--drivers/ide/pci/it8172.c4
-rw-r--r--drivers/ide/pci/ns87415.c2
-rw-r--r--drivers/ide/pci/opti621.c2
-rw-r--r--drivers/ide/pci/sc1200.c2
-rw-r--r--drivers/ide/pci/sl82c105.c6
-rw-r--r--drivers/ide/pci/slc90e66.c2
-rw-r--r--drivers/ide/pci/triflex.c2
-rw-r--r--drivers/ide/pci/via82cxxx.c4
-rw-r--r--drivers/ide/ppc/pmac.c12
-rw-r--r--drivers/ide/setup-pci.c2
-rw-r--r--drivers/ieee1394/Kconfig12
-rw-r--r--drivers/ieee1394/csr.c3
-rw-r--r--drivers/ieee1394/csr1212.c37
-rw-r--r--drivers/ieee1394/dma.c2
-rw-r--r--drivers/ieee1394/eth1394.c6
-rw-r--r--drivers/ieee1394/ieee1394_core.c35
-rw-r--r--drivers/ieee1394/ieee1394_core.h4
-rw-r--r--drivers/ieee1394/iso.c27
-rw-r--r--drivers/ieee1394/iso.h13
-rw-r--r--drivers/ieee1394/nodemgr.c2
-rw-r--r--drivers/ieee1394/ohci1394.c40
-rw-r--r--drivers/ieee1394/pcilynx.c4
-rw-r--r--drivers/ieee1394/raw1394.c7
-rw-r--r--drivers/ieee1394/sbp2.c135
-rw-r--r--drivers/infiniband/Kconfig10
-rw-r--r--drivers/infiniband/core/Makefile5
-rw-r--r--drivers/infiniband/core/uverbs.h132
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c1006
-rw-r--r--drivers/infiniband/core/uverbs_main.c698
-rw-r--r--drivers/infiniband/core/uverbs_mem.c221
-rw-r--r--drivers/infiniband/core/verbs.c32
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c76
-rw-r--r--drivers/infiniband/hw/mthca/mthca_dev.h6
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c141
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.h14
-rw-r--r--drivers/infiniband/hw/mthca/mthca_pd.c24
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c330
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.h16
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c215
-rw-r--r--drivers/infiniband/hw/mthca/mthca_user.h81
-rw-r--r--drivers/infiniband/include/ib_user_verbs.h389
-rw-r--r--drivers/infiniband/include/ib_verbs.h124
-rw-r--r--drivers/input/gameport/gameport.c3
-rw-r--r--drivers/input/joystick/analog.c4
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c7
-rw-r--r--drivers/isdn/hisax/avma1_cs.c7
-rw-r--r--drivers/isdn/hisax/elsa_cs.c7
-rw-r--r--drivers/isdn/hisax/isdnl1.c3
-rw-r--r--drivers/isdn/hisax/isdnl2.c17
-rw-r--r--drivers/isdn/hisax/isdnl3.c2
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c7
-rw-r--r--drivers/isdn/hisax/teles_cs.c7
-rw-r--r--drivers/isdn/i4l/isdn_tty.c4
-rw-r--r--drivers/isdn/icn/icn.c4
-rw-r--r--drivers/macintosh/Makefile2
-rw-r--r--drivers/macintosh/macio_asic.c78
-rw-r--r--drivers/macintosh/macio_sysfs.c50
-rw-r--r--drivers/macintosh/mediabay.c7
-rw-r--r--drivers/macintosh/therm_pm72.c9
-rw-r--r--drivers/macintosh/therm_windtunnel.c6
-rw-r--r--drivers/md/dm-mpath.c68
-rw-r--r--drivers/md/dm-raid1.c1
-rw-r--r--drivers/md/dm-snap.c6
-rw-r--r--drivers/md/dm-table.c1
-rw-r--r--drivers/md/dm.c27
-rw-r--r--drivers/media/common/ir-common.c255
-rw-r--r--drivers/media/common/saa7146_core.c13
-rw-r--r--drivers/media/dvb/Kconfig4
-rw-r--r--drivers/media/dvb/Makefile2
-rw-r--r--drivers/media/dvb/b2c2/Kconfig14
-rw-r--r--drivers/media/dvb/b2c2/Makefile2
-rw-r--r--drivers/media/dvb/b2c2/flexcop-common.h6
-rw-r--r--drivers/media/dvb/b2c2/flexcop-dma.c165
-rw-r--r--drivers/media/dvb/b2c2/flexcop-hw-filter.c12
-rw-r--r--drivers/media/dvb/b2c2/flexcop-misc.c12
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c122
-rw-r--r--drivers/media/dvb/b2c2/flexcop-reg.h548
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.c2
-rw-r--r--drivers/media/dvb/b2c2/flexcop.c34
-rw-r--r--drivers/media/dvb/b2c2/flexcop.h1
-rw-r--r--drivers/media/dvb/b2c2/flexcop_ibi_value_be.h458
-rw-r--r--drivers/media/dvb/b2c2/flexcop_ibi_value_le.h458
-rw-r--r--drivers/media/dvb/b2c2/skystar2.c2644
-rw-r--r--drivers/media/dvb/bt8xx/dst.c233
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c349
-rw-r--r--drivers/media/dvb/bt8xx/dst_common.h3
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c4
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c19
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c44
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.h22
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig34
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile3
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c10
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c295
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.h30
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mb.c62
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mc.c2
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c73
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u-fe.c76
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.c96
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.h42
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-common.h4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-dvb.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h10
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c10
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c14
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-urb.c182
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h26
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c2
-rw-r--r--drivers/media/dvb/dvb-usb/umt-010.c2
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c49
-rw-r--r--drivers/media/dvb/frontends/Kconfig13
-rw-r--r--drivers/media/dvb/frontends/Makefile2
-rw-r--r--drivers/media/dvb/frontends/cx22702.c29
-rw-r--r--drivers/media/dvb/frontends/cx22702.h5
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c85
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.h6
-rw-r--r--drivers/media/dvb/frontends/l64781.c9
-rw-r--r--drivers/media/dvb/frontends/lgdt3302.c609
-rw-r--r--drivers/media/dvb/frontends/lgdt3302.h49
-rw-r--r--drivers/media/dvb/frontends/lgdt3302_priv.h72
-rw-r--r--drivers/media/dvb/frontends/s5h1420.c800
-rw-r--r--drivers/media/dvb/frontends/s5h1420.h41
-rw-r--r--drivers/media/dvb/frontends/stv0297.c8
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c235
-rw-r--r--drivers/media/dvb/frontends/tda1004x.h31
-rw-r--r--drivers/media/dvb/frontends/tda80xx.c1
-rw-r--r--drivers/media/dvb/pluto2/Kconfig16
-rw-r--r--drivers/media/dvb/pluto2/Makefile3
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c809
-rw-r--r--drivers/media/dvb/ttpci/Kconfig9
-rw-r--r--drivers/media/dvb/ttpci/av7110.c251
-rw-r--r--drivers/media/dvb/ttpci/av7110.h7
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c220
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.h4
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c395
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.h12
-rw-r--r--drivers/media/dvb/ttpci/av7110_ipack.c2
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c12
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c21
-rw-r--r--drivers/media/dvb/ttpci/budget.c99
-rw-r--r--drivers/media/dvb/ttusb-budget/Kconfig1
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c52
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c11
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusbdecfe.c14
-rw-r--r--drivers/media/video/Kconfig14
-rw-r--r--drivers/media/video/bt832.c12
-rw-r--r--drivers/media/video/bttv-cards.c110
-rw-r--r--drivers/media/video/bttv-driver.c19
-rw-r--r--drivers/media/video/bttv-i2c.c26
-rw-r--r--drivers/media/video/bttv-risc.c9
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c5
-rw-r--r--drivers/media/video/cx88/cx88-cards.c65
-rw-r--r--drivers/media/video/cx88/cx88-core.c59
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c93
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c32
-rw-r--r--drivers/media/video/cx88/cx88-input.c384
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c33
-rw-r--r--drivers/media/video/cx88/cx88-reg.h11
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c76
-rw-r--r--drivers/media/video/cx88/cx88-video.c358
-rw-r--r--drivers/media/video/cx88/cx88.h20
-rw-r--r--drivers/media/video/ir-kbd-i2c.c51
-rw-r--r--drivers/media/video/msp3400.c25
-rw-r--r--drivers/media/video/mt20xx.c16
-rw-r--r--drivers/media/video/mxb.c7
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c2096
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c74
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c423
-rw-r--r--drivers/media/video/saa7134/saa7134-i2c.c45
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c48
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c19
-rw-r--r--drivers/media/video/saa7134/saa7134-ts.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-tvaudio.c121
-rw-r--r--drivers/media/video/saa7134/saa7134-vbi.c12
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c54
-rw-r--r--drivers/media/video/saa7134/saa7134.h21
-rw-r--r--drivers/media/video/tda7432.c13
-rw-r--r--drivers/media/video/tda8290.c13
-rw-r--r--drivers/media/video/tda9875.c13
-rw-r--r--drivers/media/video/tda9887.c9
-rw-r--r--drivers/media/video/tea5767.c158
-rw-r--r--drivers/media/video/tuner-3036.c2
-rw-r--r--drivers/media/video/tuner-core.c707
-rw-r--r--drivers/media/video/tuner-simple.c85
-rw-r--r--drivers/media/video/tvaudio.c5
-rw-r--r--drivers/media/video/tveeprom.c9
-rw-r--r--drivers/message/fusion/mptbase.c14
-rw-r--r--drivers/message/fusion/mptscsih.h2
-rw-r--r--drivers/message/i2o/config-osm.c2
-rw-r--r--drivers/misc/Kconfig5
-rw-r--r--drivers/mmc/mmci.c9
-rw-r--r--drivers/mmc/wbsd.c80
-rw-r--r--drivers/mmc/wbsd.h9
-rw-r--r--drivers/mtd/afs.c16
-rw-r--r--drivers/mtd/chips/Kconfig29
-rw-r--r--drivers/mtd/chips/amd_flash.c14
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c580
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c497
-rw-r--r--drivers/mtd/chips/fwh_lock.h6
-rw-r--r--drivers/mtd/chips/gen_probe.c4
-rw-r--r--drivers/mtd/chips/jedec_probe.c28
-rw-r--r--drivers/mtd/cmdlinepart.c8
-rw-r--r--drivers/mtd/devices/block2mtd.c20
-rw-r--r--drivers/mtd/devices/ms02-nv.c8
-rw-r--r--drivers/mtd/devices/mtdram.c265
-rw-r--r--drivers/mtd/devices/phram.c34
-rw-r--r--drivers/mtd/devices/slram.c23
-rw-r--r--drivers/mtd/ftl.c5
-rw-r--r--drivers/mtd/maps/Kconfig117
-rw-r--r--drivers/mtd/maps/Makefile11
-rw-r--r--drivers/mtd/maps/alchemy-flash.c192
-rw-r--r--drivers/mtd/maps/amd76xrom.c4
-rw-r--r--drivers/mtd/maps/bast-flash.c13
-rw-r--r--drivers/mtd/maps/db1550-flash.c187
-rw-r--r--drivers/mtd/maps/db1x00-flash.c226
-rw-r--r--drivers/mtd/maps/elan-104nc.c228
-rw-r--r--drivers/mtd/maps/ichxrom.c6
-rw-r--r--drivers/mtd/maps/ixp2000.c7
-rw-r--r--drivers/mtd/maps/mainstone-flash.c178
-rw-r--r--drivers/mtd/maps/map_funcs.c11
-rw-r--r--drivers/mtd/maps/omap_nor.c179
-rw-r--r--drivers/mtd/maps/pb1550-flash.c203
-rw-r--r--drivers/mtd/maps/pb1xxx-flash.c178
-rw-r--r--drivers/mtd/maps/pci.c4
-rw-r--r--drivers/mtd/maps/pcmciamtd.c7
-rw-r--r--drivers/mtd/maps/plat-ram.c278
-rw-r--r--drivers/mtd/maps/scb2_flash.c4
-rw-r--r--drivers/mtd/maps/sharpsl-flash.c33
-rw-r--r--drivers/mtd/mtdchar.c176
-rw-r--r--drivers/mtd/mtdcore.c6
-rw-r--r--drivers/mtd/mtdpart.c28
-rw-r--r--drivers/mtd/nand/Kconfig21
-rw-r--r--drivers/mtd/nand/Makefile2
-rw-r--r--drivers/mtd/nand/diskonchip.c96
-rw-r--r--drivers/mtd/nand/nand_base.c299
-rw-r--r--drivers/mtd/nand/nand_bbt.c114
-rw-r--r--drivers/mtd/nand/nand_ids.c18
-rw-r--r--drivers/mtd/nand/nandsim.c41
-rw-r--r--drivers/mtd/nand/rtc_from4.c140
-rw-r--r--drivers/mtd/nand/s3c2410.c297
-rw-r--r--[-rwxr-xr-x]drivers/mtd/nand/sharpsl.c4
-rw-r--r--drivers/mtd/nand/tx4925ndfmc.c416
-rw-r--r--drivers/mtd/nand/tx4938ndfmc.c406
-rw-r--r--drivers/net/Kconfig3
-rw-r--r--drivers/net/appletalk/Kconfig27
-rw-r--r--drivers/net/b44.c3
-rw-r--r--drivers/net/bmac.c7
-rw-r--r--drivers/net/hamradio/scc.c5
-rw-r--r--drivers/net/mace.c6
-rw-r--r--drivers/net/myri_sbus.c2
-rw-r--r--drivers/net/ne2k-pci.c3
-rw-r--r--drivers/net/pcmcia/3c574_cs.c7
-rw-r--r--drivers/net/pcmcia/3c589_cs.c7
-rw-r--r--drivers/net/pcmcia/axnet_cs.c7
-rw-r--r--drivers/net/pcmcia/com20020_cs.c7
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c7
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c7
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c7
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c7
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c6
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c7
-rw-r--r--drivers/net/plip.c2
-rw-r--r--drivers/net/ppp_async.c2
-rw-r--r--drivers/net/ppp_generic.c12
-rw-r--r--drivers/net/ppp_synctty.c2
-rw-r--r--drivers/net/shaper.c42
-rw-r--r--drivers/net/skge.c4
-rw-r--r--drivers/net/skge.h1
-rw-r--r--drivers/net/sungem.c4
-rw-r--r--drivers/net/sungem_phy.c69
-rw-r--r--drivers/net/sungem_phy.h3
-rw-r--r--drivers/net/tg3.c69
-rw-r--r--drivers/net/tg3.h10
-rw-r--r--drivers/net/tun.c2
-rw-r--r--drivers/net/typhoon.c6
-rw-r--r--drivers/net/wan/farsync.c3
-rw-r--r--drivers/net/wan/hdlc_cisco.c3
-rw-r--r--drivers/net/wan/hdlc_ppp.c3
-rw-r--r--drivers/net/wan/hdlc_raw.c3
-rw-r--r--drivers/net/wireless/airo.c4
-rw-r--r--drivers/net/wireless/airo_cs.c7
-rw-r--r--drivers/net/wireless/airport.c8
-rw-r--r--drivers/net/wireless/atmel_cs.c17
-rw-r--r--drivers/net/wireless/netwave_cs.c7
-rw-r--r--drivers/net/wireless/orinoco_cs.c7
-rw-r--r--drivers/net/wireless/ray_cs.c7
-rw-r--r--drivers/net/wireless/wavelan_cs.c7
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h1
-rw-r--r--drivers/net/wireless/wl3501_cs.c19
-rw-r--r--drivers/parport/parport_cs.c7
-rw-r--r--drivers/parport/parport_pc.c2
-rw-r--r--drivers/pci/Makefile1
-rw-r--r--drivers/pci/hotplug.c2
-rw-r--r--drivers/pci/hotplug/Kconfig5
-rw-r--r--drivers/pci/hotplug/Makefile1
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c611
-rw-r--r--drivers/pci/pci-acpi.c110
-rw-r--r--drivers/pci/pci-driver.c198
-rw-r--r--drivers/pci/pci.c28
-rw-r--r--drivers/pci/pci.h4
-rw-r--r--drivers/pci/pcie/portdrv.h5
-rw-r--r--drivers/pci/pcie/portdrv_core.c14
-rw-r--r--drivers/pci/pcie/portdrv_pci.c79
-rw-r--r--drivers/pci/probe.c24
-rw-r--r--drivers/pci/quirks.c1
-rw-r--r--drivers/pci/search.c1
-rw-r--r--drivers/pci/setup-bus.c3
-rw-r--r--drivers/pcmcia/Kconfig17
-rw-r--r--drivers/pcmcia/au1000_generic.h1
-rw-r--r--drivers/pcmcia/au1000_pb1x00.c1
-rw-r--r--drivers/pcmcia/au1000_xxs1500.c1
-rw-r--r--drivers/pcmcia/cardbus.c1
-rw-r--r--drivers/pcmcia/cs.c16
-rw-r--r--drivers/pcmcia/cs_internal.h16
-rw-r--r--drivers/pcmcia/ds.c101
-rw-r--r--drivers/pcmcia/hd64465_ss.c1
-rw-r--r--drivers/pcmcia/i82365.c9
-rw-r--r--drivers/pcmcia/m32r_cfc.c1
-rw-r--r--drivers/pcmcia/m32r_pcc.c1
-rw-r--r--drivers/pcmcia/pcmcia_compat.c48
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c27
-rw-r--r--drivers/pcmcia/pcmcia_resource.c143
-rw-r--r--drivers/pcmcia/sa1100_generic.c1
-rw-r--r--drivers/pcmcia/soc_common.h1
-rw-r--r--drivers/pcmcia/socket_sysfs.c1
-rw-r--r--drivers/pcmcia/tcic.c1
-rw-r--r--drivers/pcmcia/ti113x.h4
-rw-r--r--drivers/pcmcia/yenta_socket.c174
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c15
-rw-r--r--drivers/pnp/pnpbios/rsparser.c2
-rw-r--r--drivers/pnp/resource.c2
-rw-r--r--drivers/s390/net/claw.c4
-rw-r--r--drivers/s390/net/ctctty.c6
-rw-r--r--drivers/s390/net/qeth_main.c2
-rw-r--r--drivers/sbus/char/bpp.c20
-rw-r--r--drivers/scsi/aacraid/commctrl.c2
-rw-r--r--drivers/scsi/mac53c94.c7
-rw-r--r--drivers/scsi/mesh.c8
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c7
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c7
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c17
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c4
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c5
-rw-r--r--drivers/serial/8250.c3
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.c32
-rw-r--r--drivers/serial/pmac_zilog.c9
-rw-r--r--drivers/serial/s3c2410.c5
-rw-r--r--drivers/serial/serial_core.c14
-rw-r--r--drivers/serial/serial_cs.c7
-rw-r--r--drivers/telephony/ixj_pcmcia.c7
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/atm/cxacru.c2
-rw-r--r--drivers/usb/atm/speedtch.c63
-rw-r--r--drivers/usb/class/cdc-acm.c31
-rw-r--r--drivers/usb/core/buffer.c2
-rw-r--r--drivers/usb/core/hcd-pci.c1
-rw-r--r--drivers/usb/core/hcd.c2
-rw-r--r--drivers/usb/core/hcd.h8
-rw-r--r--drivers/usb/core/hub.c40
-rw-r--r--drivers/usb/core/message.c2
-rw-r--r--drivers/usb/core/sysfs.c2
-rw-r--r--drivers/usb/core/urb.c4
-rw-r--r--drivers/usb/core/usb.c5
-rw-r--r--drivers/usb/gadget/dummy_hcd.c9
-rw-r--r--drivers/usb/gadget/ether.c22
-rw-r--r--drivers/usb/gadget/goku_udc.c6
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c6
-rw-r--r--drivers/usb/gadget/net2280.c8
-rw-r--r--drivers/usb/gadget/omap_udc.c9
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c6
-rw-r--r--drivers/usb/gadget/zero.c8
-rw-r--r--drivers/usb/host/ehci-hcd.c2
-rw-r--r--drivers/usb/host/ehci-q.c2
-rw-r--r--drivers/usb/host/ehci-sched.c19
-rw-r--r--drivers/usb/host/hc_crisv10.c10
-rw-r--r--drivers/usb/host/isp116x-hcd.c20
-rw-r--r--drivers/usb/host/ohci-hcd.c6
-rw-r--r--drivers/usb/host/ohci-hub.c3
-rw-r--r--drivers/usb/host/ohci-mem.c4
-rw-r--r--drivers/usb/host/ohci-omap.c53
-rw-r--r--drivers/usb/host/sl811-hcd.c2
-rw-r--r--drivers/usb/host/sl811_cs.c7
-rw-r--r--drivers/usb/host/uhci-q.c2
-rw-r--r--drivers/usb/input/Kconfig13
-rw-r--r--drivers/usb/input/Makefile1
-rw-r--r--drivers/usb/input/hid-core.c24
-rw-r--r--drivers/usb/input/keyspan_remote.c633
-rw-r--r--drivers/usb/media/Makefile2
-rw-r--r--drivers/usb/media/sn9c102.h2
-rw-r--r--drivers/usb/media/sn9c102_core.c2
-rw-r--r--drivers/usb/media/sn9c102_ov7630.c394
-rw-r--r--drivers/usb/media/sn9c102_sensor.h16
-rw-r--r--drivers/usb/media/sn9c102_tas5110c1b.c21
-rw-r--r--drivers/usb/media/sn9c102_tas5130d1b.c27
-rw-r--r--drivers/usb/misc/Kconfig10
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/ldusb.c794
-rw-r--r--drivers/usb/mon/mon_text.c48
-rw-r--r--drivers/usb/net/kaweth.c4
-rw-r--r--drivers/usb/net/usbnet.c6
-rw-r--r--drivers/usb/serial/ftdi_sio.c756
-rw-r--r--drivers/usb/storage/unusual_devs.h2
-rw-r--r--drivers/video/console/fbcon.c8
-rw-r--r--drivers/video/fbsysfs.c2
-rw-r--r--drivers/video/logo/Kconfig5
-rw-r--r--drivers/video/logo/Makefile1
-rw-r--r--drivers/video/logo/logo.c5
-rw-r--r--drivers/video/logo/logo_m32r_clut224.ppm1292
-rw-r--r--drivers/video/platinumfb.c6
-rw-r--r--drivers/video/s1d13xxxfb.c10
-rw-r--r--drivers/video/savage/savagefb_driver.c2
-rw-r--r--drivers/w1/w1.c5
671 files changed, 34276 insertions, 17226 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index aed4a9b97c14..cecab0acc3fe 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -28,7 +28,7 @@ source "drivers/message/i2o/Kconfig"
28 28
29source "drivers/macintosh/Kconfig" 29source "drivers/macintosh/Kconfig"
30 30
31source "net/Kconfig" 31source "drivers/net/Kconfig"
32 32
33source "drivers/isdn/Kconfig" 33source "drivers/isdn/Kconfig"
34 34
@@ -44,6 +44,8 @@ source "drivers/i2c/Kconfig"
44 44
45source "drivers/w1/Kconfig" 45source "drivers/w1/Kconfig"
46 46
47source "drivers/hwmon/Kconfig"
48
47source "drivers/misc/Kconfig" 49source "drivers/misc/Kconfig"
48 50
49source "drivers/media/Kconfig" 51source "drivers/media/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 3167be54fedd..126a851d5653 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_INPUT) += input/
52obj-$(CONFIG_I2O) += message/ 52obj-$(CONFIG_I2O) += message/
53obj-$(CONFIG_I2C) += i2c/ 53obj-$(CONFIG_I2C) += i2c/
54obj-$(CONFIG_W1) += w1/ 54obj-$(CONFIG_W1) += w1/
55obj-$(CONFIG_HWMON) += hwmon/
55obj-$(CONFIG_PHONE) += telephony/ 56obj-$(CONFIG_PHONE) += telephony/
56obj-$(CONFIG_MD) += md/ 57obj-$(CONFIG_MD) += md/
57obj-$(CONFIG_BT) += bluetooth/ 58obj-$(CONFIG_BT) += bluetooth/
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 86c52520ed34..986410e7b483 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -3,6 +3,7 @@
3# 3#
4 4
5menu "ACPI (Advanced Configuration and Power Interface) Support" 5menu "ACPI (Advanced Configuration and Power Interface) Support"
6 depends on PM
6 depends on !X86_VISWS 7 depends on !X86_VISWS
7 depends on !IA64_HP_SIM 8 depends on !IA64_HP_SIM
8 depends on IA64 || X86 9 depends on IA64 || X86
@@ -48,7 +49,6 @@ config ACPI_BOOT
48 49
49config ACPI_INTERPRETER 50config ACPI_INTERPRETER
50 bool 51 bool
51 depends on !IA64_SGI_SN
52 default y 52 default y
53 53
54if ACPI_INTERPRETER 54if ACPI_INTERPRETER
@@ -79,6 +79,14 @@ config ACPI_SLEEP_PROC_FS
79 depends on ACPI_SLEEP && PROC_FS 79 depends on ACPI_SLEEP && PROC_FS
80 default y 80 default y
81 81
82config ACPI_SLEEP_PROC_SLEEP
83 bool "/proc/acpi/sleep (deprecated)"
84 depends on ACPI_SLEEP_PROC_FS
85 default n
86 ---help---
87 Create /proc/acpi/sleep
88 Deprecated by /sys/power/state
89
82config ACPI_AC 90config ACPI_AC
83 tristate "AC Adapter" 91 tristate "AC Adapter"
84 depends on X86 92 depends on X86
@@ -99,7 +107,6 @@ config ACPI_BATTERY
99 107
100config ACPI_BUTTON 108config ACPI_BUTTON
101 tristate "Button" 109 tristate "Button"
102 depends on !IA64_SGI_SN
103 default m 110 default m
104 help 111 help
105 This driver registers for events based on buttons, such as the 112 This driver registers for events based on buttons, such as the
@@ -111,7 +118,6 @@ config ACPI_BUTTON
111config ACPI_VIDEO 118config ACPI_VIDEO
112 tristate "Video" 119 tristate "Video"
113 depends on EXPERIMENTAL 120 depends on EXPERIMENTAL
114 depends on !IA64_SGI_SN
115 default m 121 default m
116 help 122 help
117 This driver implement the ACPI Extensions For Display Adapters 123 This driver implement the ACPI Extensions For Display Adapters
@@ -122,9 +128,17 @@ config ACPI_VIDEO
122 Note that this is an ref. implementation only. It may or may not work 128 Note that this is an ref. implementation only. It may or may not work
123 for your integrated video device. 129 for your integrated video device.
124 130
131config ACPI_HOTKEY
132 tristate "Generic Hotkey"
133 depends on ACPI_INTERPRETER
134 depends on EXPERIMENTAL
135 depends on !IA64_SGI_SN
136 default m
137 help
138 ACPI generic hotkey
139
125config ACPI_FAN 140config ACPI_FAN
126 tristate "Fan" 141 tristate "Fan"
127 depends on !IA64_SGI_SN
128 default m 142 default m
129 help 143 help
130 This driver adds support for ACPI fan devices, allowing user-mode 144 This driver adds support for ACPI fan devices, allowing user-mode
@@ -132,7 +146,6 @@ config ACPI_FAN
132 146
133config ACPI_PROCESSOR 147config ACPI_PROCESSOR
134 tristate "Processor" 148 tristate "Processor"
135 depends on !IA64_SGI_SN
136 default m 149 default m
137 help 150 help
138 This driver installs ACPI as the idle handler for Linux, and uses 151 This driver installs ACPI as the idle handler for Linux, and uses
@@ -142,7 +155,6 @@ config ACPI_PROCESSOR
142config ACPI_HOTPLUG_CPU 155config ACPI_HOTPLUG_CPU
143 bool "Processor Hotplug (EXPERIMENTAL)" 156 bool "Processor Hotplug (EXPERIMENTAL)"
144 depends on ACPI_PROCESSOR && HOTPLUG_CPU && EXPERIMENTAL 157 depends on ACPI_PROCESSOR && HOTPLUG_CPU && EXPERIMENTAL
145 depends on !IA64_SGI_SN
146 select ACPI_CONTAINER 158 select ACPI_CONTAINER
147 default n 159 default n
148 ---help--- 160 ---help---
@@ -262,7 +274,6 @@ config ACPI_BLACKLIST_YEAR
262 274
263config ACPI_DEBUG 275config ACPI_DEBUG
264 bool "Debug Statements" 276 bool "Debug Statements"
265 depends on !IA64_SGI_SN
266 default n 277 default n
267 help 278 help
268 The ACPI driver can optionally report errors with a great deal 279 The ACPI driver can optionally report errors with a great deal
@@ -271,7 +282,6 @@ config ACPI_DEBUG
271 282
272config ACPI_BUS 283config ACPI_BUS
273 bool 284 bool
274 depends on !IA64_SGI_SN
275 default y 285 default y
276 286
277config ACPI_EC 287config ACPI_EC
@@ -285,17 +295,14 @@ config ACPI_EC
285 295
286config ACPI_POWER 296config ACPI_POWER
287 bool 297 bool
288 depends on !IA64_SGI_SN
289 default y 298 default y
290 299
291config ACPI_PCI 300config ACPI_PCI
292 bool 301 bool
293 depends on !IA64_SGI_SN
294 default PCI 302 default PCI
295 303
296config ACPI_SYSTEM 304config ACPI_SYSTEM
297 bool 305 bool
298 depends on !IA64_SGI_SN
299 default y 306 default y
300 help 307 help
301 This driver will enable your system to shut down using ACPI, and 308 This driver will enable your system to shut down using ACPI, and
@@ -327,8 +334,13 @@ config ACPI_CONTAINER
327 depends on EXPERIMENTAL 334 depends on EXPERIMENTAL
328 default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_CPU || ACPI_HOTPLUG_IO) 335 default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_CPU || ACPI_HOTPLUG_IO)
329 ---help--- 336 ---help---
330 This is the ACPI generic container driver which supports 337 This allows _physical_ insertion and removal of CPUs and memory.
331 ACPI0004, PNP0A05 and PNP0A06 devices 338 This can be useful, for example, on NUMA machines that support
339 ACPI based physical hotplug of nodes, or non-NUMA machines that
340 support physical cpu/memory hot-plug.
341
342 If one selects "m", this driver can be loaded with
343 "modprobe acpi_container".
332 344
333config ACPI_HOTPLUG_MEMORY 345config ACPI_HOTPLUG_MEMORY
334 tristate "Memory Hotplug" 346 tristate "Memory Hotplug"
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 65c92e20566d..ad67e8f61e6c 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -36,13 +36,14 @@ processor-objs += processor_perflib.o
36endif 36endif
37 37
38obj-$(CONFIG_ACPI_BUS) += sleep/ 38obj-$(CONFIG_ACPI_BUS) += sleep/
39obj-$(CONFIG_ACPI_BUS) += bus.o 39obj-$(CONFIG_ACPI_BUS) += bus.o glue.o
40obj-$(CONFIG_ACPI_AC) += ac.o 40obj-$(CONFIG_ACPI_AC) += ac.o
41obj-$(CONFIG_ACPI_BATTERY) += battery.o 41obj-$(CONFIG_ACPI_BATTERY) += battery.o
42obj-$(CONFIG_ACPI_BUTTON) += button.o 42obj-$(CONFIG_ACPI_BUTTON) += button.o
43obj-$(CONFIG_ACPI_EC) += ec.o 43obj-$(CONFIG_ACPI_EC) += ec.o
44obj-$(CONFIG_ACPI_FAN) += fan.o 44obj-$(CONFIG_ACPI_FAN) += fan.o
45obj-$(CONFIG_ACPI_VIDEO) += video.o 45obj-$(CONFIG_ACPI_VIDEO) += video.o
46obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o
46obj-$(CONFIG_ACPI_PCI) += pci_root.o pci_link.o pci_irq.o pci_bind.o 47obj-$(CONFIG_ACPI_PCI) += pci_root.o pci_link.o pci_irq.o pci_bind.o
47obj-$(CONFIG_ACPI_POWER) += power.o 48obj-$(CONFIG_ACPI_POWER) += power.o
48obj-$(CONFIG_ACPI_PROCESSOR) += processor.o 49obj-$(CONFIG_ACPI_PROCESSOR) += processor.o
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index a75cb565caeb..a560b1e2da77 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -1204,6 +1204,10 @@ static int __init asus_acpi_init(void)
1204 if (acpi_disabled) 1204 if (acpi_disabled)
1205 return -ENODEV; 1205 return -ENODEV;
1206 1206
1207 if (!acpi_specific_hotkey_enabled){
1208 printk(KERN_ERR "Using generic hotkey driver\n");
1209 return -ENODEV;
1210 }
1207 asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir); 1211 asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
1208 if (!asus_proc_dir) { 1212 if (!asus_proc_dir) {
1209 printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n"); 1213 printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 4edff1738579..d77c2307883c 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -212,6 +212,12 @@ acpi_bus_set_power (
212 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n")); 212 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n"));
213 return_VALUE(-ENODEV); 213 return_VALUE(-ENODEV);
214 } 214 }
215 /*
216 * Get device's current power state if it's unknown
217 * This means device power state isn't initialized or previous setting failed
218 */
219 if (device->power.state == ACPI_STATE_UNKNOWN)
220 acpi_bus_get_power(device->handle, &device->power.state);
215 if (state == device->power.state) { 221 if (state == device->power.state) {
216 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state)); 222 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state));
217 return_VALUE(0); 223 return_VALUE(0);
@@ -231,7 +237,7 @@ acpi_bus_set_power (
231 * On transitions to a high-powered state we first apply power (via 237 * On transitions to a high-powered state we first apply power (via
232 * power resources) then evalute _PSx. Conversly for transitions to 238 * power resources) then evalute _PSx. Conversly for transitions to
233 * a lower-powered state. 239 * a lower-powered state.
234 */ 240 */
235 if (state < device->power.state) { 241 if (state < device->power.state) {
236 if (device->power.flags.power_resources) { 242 if (device->power.flags.power_resources) {
237 result = acpi_power_transition(device, state); 243 result = acpi_power_transition(device, state);
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index ec4430e3053f..0f45d45f05a0 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -26,9 +26,6 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h>
30#include <linux/proc_fs.h>
31#include <linux/seq_file.h>
32#include <acpi/acpi_bus.h> 29#include <acpi/acpi_bus.h>
33#include <acpi/acpi_drivers.h> 30#include <acpi/acpi_drivers.h>
34 31
@@ -36,9 +33,6 @@
36#define ACPI_BUTTON_COMPONENT 0x00080000 33#define ACPI_BUTTON_COMPONENT 0x00080000
37#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" 34#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver"
38#define ACPI_BUTTON_CLASS "button" 35#define ACPI_BUTTON_CLASS "button"
39#define ACPI_BUTTON_FILE_INFO "info"
40#define ACPI_BUTTON_FILE_STATE "state"
41#define ACPI_BUTTON_TYPE_UNKNOWN 0x00
42#define ACPI_BUTTON_NOTIFY_STATUS 0x80 36#define ACPI_BUTTON_NOTIFY_STATUS 0x80
43 37
44#define ACPI_BUTTON_SUBCLASS_POWER "power" 38#define ACPI_BUTTON_SUBCLASS_POWER "power"
@@ -70,8 +64,6 @@ MODULE_LICENSE("GPL");
70 64
71static int acpi_button_add (struct acpi_device *device); 65static int acpi_button_add (struct acpi_device *device);
72static int acpi_button_remove (struct acpi_device *device, int type); 66static int acpi_button_remove (struct acpi_device *device, int type);
73static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
74static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
75 67
76static struct acpi_driver acpi_button_driver = { 68static struct acpi_driver acpi_button_driver = {
77 .name = ACPI_BUTTON_DRIVER_NAME, 69 .name = ACPI_BUTTON_DRIVER_NAME,
@@ -90,187 +82,6 @@ struct acpi_button {
90 unsigned long pushed; 82 unsigned long pushed;
91}; 83};
92 84
93static struct file_operations acpi_button_info_fops = {
94 .open = acpi_button_info_open_fs,
95 .read = seq_read,
96 .llseek = seq_lseek,
97 .release = single_release,
98};
99
100static struct file_operations acpi_button_state_fops = {
101 .open = acpi_button_state_open_fs,
102 .read = seq_read,
103 .llseek = seq_lseek,
104 .release = single_release,
105};
106/* --------------------------------------------------------------------------
107 FS Interface (/proc)
108 -------------------------------------------------------------------------- */
109
110static struct proc_dir_entry *acpi_button_dir;
111
112static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
113{
114 struct acpi_button *button = (struct acpi_button *) seq->private;
115
116 ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
117
118 if (!button || !button->device)
119 return_VALUE(0);
120
121 seq_printf(seq, "type: %s\n",
122 acpi_device_name(button->device));
123
124 return_VALUE(0);
125}
126
127static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
128{
129 return single_open(file, acpi_button_info_seq_show, PDE(inode)->data);
130}
131
132static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
133{
134 struct acpi_button *button = (struct acpi_button *) seq->private;
135 acpi_status status;
136 unsigned long state;
137
138 ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
139
140 if (!button || !button->device)
141 return_VALUE(0);
142
143 status = acpi_evaluate_integer(button->handle,"_LID",NULL,&state);
144 if (ACPI_FAILURE(status)) {
145 seq_printf(seq, "state: unsupported\n");
146 }
147 else{
148 seq_printf(seq, "state: %s\n", (state ? "open" : "closed"));
149 }
150
151 return_VALUE(0);
152}
153
154static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
155{
156 return single_open(file, acpi_button_state_seq_show, PDE(inode)->data);
157}
158
159static int
160acpi_button_add_fs (
161 struct acpi_device *device)
162{
163 struct proc_dir_entry *entry = NULL;
164 struct acpi_button *button = NULL;
165
166 ACPI_FUNCTION_TRACE("acpi_button_add_fs");
167
168 if (!device || !acpi_driver_data(device))
169 return_VALUE(-EINVAL);
170
171 button = acpi_driver_data(device);
172
173 switch (button->type) {
174 case ACPI_BUTTON_TYPE_POWER:
175 case ACPI_BUTTON_TYPE_POWERF:
176 entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER,
177 acpi_button_dir);
178 break;
179 case ACPI_BUTTON_TYPE_SLEEP:
180 case ACPI_BUTTON_TYPE_SLEEPF:
181 entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
182 acpi_button_dir);
183 break;
184 case ACPI_BUTTON_TYPE_LID:
185 entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
186 acpi_button_dir);
187 break;
188 }
189
190 if (!entry)
191 return_VALUE(-ENODEV);
192 entry->owner = THIS_MODULE;
193
194 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
195 if (!acpi_device_dir(device))
196 return_VALUE(-ENODEV);
197 acpi_device_dir(device)->owner = THIS_MODULE;
198
199 /* 'info' [R] */
200 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
201 S_IRUGO, acpi_device_dir(device));
202 if (!entry)
203 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
204 "Unable to create '%s' fs entry\n",
205 ACPI_BUTTON_FILE_INFO));
206 else {
207 entry->proc_fops = &acpi_button_info_fops;
208 entry->data = acpi_driver_data(device);
209 entry->owner = THIS_MODULE;
210 }
211
212 /* show lid state [R] */
213 if (button->type == ACPI_BUTTON_TYPE_LID) {
214 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
215 S_IRUGO, acpi_device_dir(device));
216 if (!entry)
217 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
218 "Unable to create '%s' fs entry\n",
219 ACPI_BUTTON_FILE_INFO));
220 else {
221 entry->proc_fops = &acpi_button_state_fops;
222 entry->data = acpi_driver_data(device);
223 entry->owner = THIS_MODULE;
224 }
225 }
226
227 return_VALUE(0);
228}
229
230
231static int
232acpi_button_remove_fs (
233 struct acpi_device *device)
234{
235 struct acpi_button *button = NULL;
236
237 ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
238
239 button = acpi_driver_data(device);
240 if (acpi_device_dir(device)) {
241 if (button->type == ACPI_BUTTON_TYPE_LID)
242 remove_proc_entry(ACPI_BUTTON_FILE_STATE,
243 acpi_device_dir(device));
244 remove_proc_entry(ACPI_BUTTON_FILE_INFO,
245 acpi_device_dir(device));
246
247 remove_proc_entry(acpi_device_bid(device),
248 acpi_device_dir(device)->parent);
249
250
251 switch (button->type) {
252 case ACPI_BUTTON_TYPE_POWER:
253 case ACPI_BUTTON_TYPE_POWERF:
254 remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER,
255 acpi_button_dir);
256 break;
257 case ACPI_BUTTON_TYPE_SLEEP:
258 case ACPI_BUTTON_TYPE_SLEEPF:
259 remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP,
260 acpi_button_dir);
261 break;
262 case ACPI_BUTTON_TYPE_LID:
263 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID,
264 acpi_button_dir);
265 break;
266 }
267 acpi_device_dir(device) = NULL;
268 }
269
270 return_VALUE(0);
271}
272
273
274/* -------------------------------------------------------------------------- 85/* --------------------------------------------------------------------------
275 Driver Interface 86 Driver Interface
276 -------------------------------------------------------------------------- */ 87 -------------------------------------------------------------------------- */
@@ -310,8 +121,7 @@ acpi_button_notify_fixed (
310 121
311 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); 122 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
312 123
313 if (!button) 124 BUG_ON(!button);
314 return_ACPI_STATUS(AE_BAD_PARAMETER);
315 125
316 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); 126 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
317 127
@@ -327,10 +137,6 @@ acpi_button_add (
327 acpi_status status = AE_OK; 137 acpi_status status = AE_OK;
328 struct acpi_button *button = NULL; 138 struct acpi_button *button = NULL;
329 139
330 static struct acpi_device *power_button;
331 static struct acpi_device *sleep_button;
332 static struct acpi_device *lid_button;
333
334 ACPI_FUNCTION_TRACE("acpi_button_add"); 140 ACPI_FUNCTION_TRACE("acpi_button_add");
335 141
336 if (!device) 142 if (!device)
@@ -391,42 +197,6 @@ acpi_button_add (
391 goto end; 197 goto end;
392 } 198 }
393 199
394 /*
395 * Ensure only one button of each type is used.
396 */
397 switch (button->type) {
398 case ACPI_BUTTON_TYPE_POWER:
399 case ACPI_BUTTON_TYPE_POWERF:
400 if (!power_button)
401 power_button = device;
402 else {
403 kfree(button);
404 return_VALUE(-ENODEV);
405 }
406 break;
407 case ACPI_BUTTON_TYPE_SLEEP:
408 case ACPI_BUTTON_TYPE_SLEEPF:
409 if (!sleep_button)
410 sleep_button = device;
411 else {
412 kfree(button);
413 return_VALUE(-ENODEV);
414 }
415 break;
416 case ACPI_BUTTON_TYPE_LID:
417 if (!lid_button)
418 lid_button = device;
419 else {
420 kfree(button);
421 return_VALUE(-ENODEV);
422 }
423 break;
424 }
425
426 result = acpi_button_add_fs(device);
427 if (result)
428 goto end;
429
430 switch (button->type) { 200 switch (button->type) {
431 case ACPI_BUTTON_TYPE_POWERF: 201 case ACPI_BUTTON_TYPE_POWERF:
432 status = acpi_install_fixed_event_handler ( 202 status = acpi_install_fixed_event_handler (
@@ -470,7 +240,6 @@ acpi_button_add (
470 240
471end: 241end:
472 if (result) { 242 if (result) {
473 acpi_button_remove_fs(device);
474 kfree(button); 243 kfree(button);
475 } 244 }
476 245
@@ -511,8 +280,6 @@ acpi_button_remove (struct acpi_device *device, int type)
511 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 280 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
512 "Error removing notify handler\n")); 281 "Error removing notify handler\n"));
513 282
514 acpi_button_remove_fs(device);
515
516 kfree(button); 283 kfree(button);
517 284
518 return_VALUE(0); 285 return_VALUE(0);
@@ -526,21 +293,14 @@ acpi_button_init (void)
526 293
527 ACPI_FUNCTION_TRACE("acpi_button_init"); 294 ACPI_FUNCTION_TRACE("acpi_button_init");
528 295
529 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
530 if (!acpi_button_dir)
531 return_VALUE(-ENODEV);
532 acpi_button_dir->owner = THIS_MODULE;
533
534 result = acpi_bus_register_driver(&acpi_button_driver); 296 result = acpi_bus_register_driver(&acpi_button_driver);
535 if (result < 0) { 297 if (result < 0) {
536 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
537 return_VALUE(-ENODEV); 298 return_VALUE(-ENODEV);
538 } 299 }
539 300
540 return_VALUE(0); 301 return_VALUE(0);
541} 302}
542 303
543
544static void __exit 304static void __exit
545acpi_button_exit (void) 305acpi_button_exit (void)
546{ 306{
@@ -548,11 +308,8 @@ acpi_button_exit (void)
548 308
549 acpi_bus_unregister_driver(&acpi_button_driver); 309 acpi_bus_unregister_driver(&acpi_button_driver);
550 310
551 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
552
553 return_VOID; 311 return_VOID;
554} 312}
555 313
556
557module_init(acpi_button_init); 314module_init(acpi_button_init);
558module_exit(acpi_button_exit); 315module_exit(acpi_button_exit);
diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c
index 2779211be756..84193983d6ba 100644
--- a/drivers/acpi/dispatcher/dsfield.c
+++ b/drivers/acpi/dispatcher/dsfield.c
@@ -53,13 +53,20 @@
53#define _COMPONENT ACPI_DISPATCHER 53#define _COMPONENT ACPI_DISPATCHER
54 ACPI_MODULE_NAME ("dsfield") 54 ACPI_MODULE_NAME ("dsfield")
55 55
56/* Local prototypes */
57
58static acpi_status
59acpi_ds_get_field_names (
60 struct acpi_create_field_info *info,
61 struct acpi_walk_state *walk_state,
62 union acpi_parse_object *arg);
63
56 64
57/******************************************************************************* 65/*******************************************************************************
58 * 66 *
59 * FUNCTION: acpi_ds_create_buffer_field 67 * FUNCTION: acpi_ds_create_buffer_field
60 * 68 *
61 * PARAMETERS: Opcode - The opcode to be executed 69 * PARAMETERS: Op - Current parse op (create_xXField)
62 * Operands - List of operands for the opcode
63 * walk_state - Current state 70 * walk_state - Current state
64 * 71 *
65 * RETURN: Status 72 * RETURN: Status
@@ -70,7 +77,7 @@
70 * create_word_field_op, 77 * create_word_field_op,
71 * create_dword_field_op, 78 * create_dword_field_op,
72 * create_qword_field_op, 79 * create_qword_field_op,
73 * create_field_op (all of which define fields in buffers) 80 * create_field_op (all of which define a field in a buffer)
74 * 81 *
75 ******************************************************************************/ 82 ******************************************************************************/
76 83
@@ -119,7 +126,8 @@ acpi_ds_create_buffer_field (
119 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE; 126 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
120 } 127 }
121 else { 128 else {
122 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND; 129 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
130 ACPI_NS_ERROR_IF_FOUND;
123 } 131 }
124 132
125 /* 133 /*
@@ -134,16 +142,16 @@ acpi_ds_create_buffer_field (
134 } 142 }
135 } 143 }
136 144
137 /* We could put the returned object (Node) on the object stack for later, but 145 /* We could put the returned object (Node) on the object stack for later,
138 * for now, we will put it in the "op" object that the parser uses, so we 146 * but for now, we will put it in the "op" object that the parser uses,
139 * can get it again at the end of this scope 147 * so we can get it again at the end of this scope
140 */ 148 */
141 op->common.node = node; 149 op->common.node = node;
142 150
143 /* 151 /*
144 * If there is no object attached to the node, this node was just created and 152 * If there is no object attached to the node, this node was just created
145 * we need to create the field object. Otherwise, this was a lookup of an 153 * and we need to create the field object. Otherwise, this was a lookup
146 * existing node and we don't want to create the field object again. 154 * of an existing node and we don't want to create the field object again.
147 */ 155 */
148 obj_desc = acpi_ns_get_attached_object (node); 156 obj_desc = acpi_ns_get_attached_object (node);
149 if (obj_desc) { 157 if (obj_desc) {
@@ -205,7 +213,7 @@ cleanup:
205 * 213 *
206 ******************************************************************************/ 214 ******************************************************************************/
207 215
208acpi_status 216static acpi_status
209acpi_ds_get_field_names ( 217acpi_ds_get_field_names (
210 struct acpi_create_field_info *info, 218 struct acpi_create_field_info *info,
211 struct acpi_walk_state *walk_state, 219 struct acpi_walk_state *walk_state,
@@ -238,7 +246,8 @@ acpi_ds_get_field_names (
238 + (acpi_integer) arg->common.value.size; 246 + (acpi_integer) arg->common.value.size;
239 247
240 if (position > ACPI_UINT32_MAX) { 248 if (position > ACPI_UINT32_MAX) {
241 ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n")); 249 ACPI_REPORT_ERROR ((
250 "Bit offset within field too large (> 0xFFFFFFFF)\n"));
242 return_ACPI_STATUS (AE_SUPPORT); 251 return_ACPI_STATUS (AE_SUPPORT);
243 } 252 }
244 253
@@ -250,12 +259,15 @@ acpi_ds_get_field_names (
250 259
251 /* 260 /*
252 * Get a new access_type and access_attribute -- to be used for all 261 * Get a new access_type and access_attribute -- to be used for all
253 * field units that follow, until field end or another access_as keyword. 262 * field units that follow, until field end or another access_as
263 * keyword.
254 * 264 *
255 * In field_flags, preserve the flag bits other than the ACCESS_TYPE bits 265 * In field_flags, preserve the flag bits other than the
266 * ACCESS_TYPE bits
256 */ 267 */
257 info->field_flags = (u8) ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | 268 info->field_flags = (u8)
258 ((u8) ((u32) arg->common.value.integer >> 8))); 269 ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
270 ((u8) ((u32) arg->common.value.integer >> 8)));
259 271
260 info->attribute = (u8) (arg->common.value.integer); 272 info->attribute = (u8) (arg->common.value.integer);
261 break; 273 break;
@@ -267,7 +279,8 @@ acpi_ds_get_field_names (
267 279
268 status = acpi_ns_lookup (walk_state->scope_info, 280 status = acpi_ns_lookup (walk_state->scope_info,
269 (char *) &arg->named.name, 281 (char *) &arg->named.name,
270 info->field_type, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, 282 info->field_type, ACPI_IMODE_EXECUTE,
283 ACPI_NS_DONT_OPEN_SCOPE,
271 walk_state, &info->field_node); 284 walk_state, &info->field_node);
272 if (ACPI_FAILURE (status)) { 285 if (ACPI_FAILURE (status)) {
273 ACPI_REPORT_NSERROR ((char *) &arg->named.name, status); 286 ACPI_REPORT_NSERROR ((char *) &arg->named.name, status);
@@ -295,8 +308,9 @@ acpi_ds_get_field_names (
295 + (acpi_integer) arg->common.value.size; 308 + (acpi_integer) arg->common.value.size;
296 309
297 if (position > ACPI_UINT32_MAX) { 310 if (position > ACPI_UINT32_MAX) {
298 ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", 311 ACPI_REPORT_ERROR ((
299 (char *) &info->field_node->name)); 312 "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n",
313 (char *) &info->field_node->name));
300 return_ACPI_STATUS (AE_SUPPORT); 314 return_ACPI_STATUS (AE_SUPPORT);
301 } 315 }
302 316
@@ -306,7 +320,8 @@ acpi_ds_get_field_names (
306 320
307 default: 321 default:
308 322
309 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n", 323 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
324 "Invalid opcode in field list: %X\n",
310 arg->common.aml_opcode)); 325 arg->common.aml_opcode));
311 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 326 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
312 } 327 }
@@ -435,7 +450,8 @@ acpi_ds_init_field_objects (
435 status = acpi_ns_lookup (walk_state->scope_info, 450 status = acpi_ns_lookup (walk_state->scope_info,
436 (char *) &arg->named.name, 451 (char *) &arg->named.name,
437 type, ACPI_IMODE_LOAD_PASS1, 452 type, ACPI_IMODE_LOAD_PASS1,
438 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, 453 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
454 ACPI_NS_ERROR_IF_FOUND,
439 walk_state, &node); 455 walk_state, &node);
440 if (ACPI_FAILURE (status)) { 456 if (ACPI_FAILURE (status)) {
441 ACPI_REPORT_NSERROR ((char *) &arg->named.name, status); 457 ACPI_REPORT_NSERROR ((char *) &arg->named.name, status);
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c
index b4d264dbbf67..d7790db50178 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/dispatcher/dsinit.c
@@ -49,12 +49,21 @@
49#define _COMPONENT ACPI_DISPATCHER 49#define _COMPONENT ACPI_DISPATCHER
50 ACPI_MODULE_NAME ("dsinit") 50 ACPI_MODULE_NAME ("dsinit")
51 51
52/* Local prototypes */
53
54static acpi_status
55acpi_ds_init_one_object (
56 acpi_handle obj_handle,
57 u32 level,
58 void *context,
59 void **return_value);
60
52 61
53/******************************************************************************* 62/*******************************************************************************
54 * 63 *
55 * FUNCTION: acpi_ds_init_one_object 64 * FUNCTION: acpi_ds_init_one_object
56 * 65 *
57 * PARAMETERS: obj_handle - Node 66 * PARAMETERS: obj_handle - Node for the object
58 * Level - Current nesting level 67 * Level - Current nesting level
59 * Context - Points to a init info struct 68 * Context - Points to a init info struct
60 * return_value - Not used 69 * return_value - Not used
@@ -70,7 +79,7 @@
70 * 79 *
71 ******************************************************************************/ 80 ******************************************************************************/
72 81
73acpi_status 82static acpi_status
74acpi_ds_init_one_object ( 83acpi_ds_init_one_object (
75 acpi_handle obj_handle, 84 acpi_handle obj_handle,
76 u32 level, 85 u32 level,
@@ -105,7 +114,8 @@ acpi_ds_init_one_object (
105 114
106 status = acpi_ds_initialize_region (obj_handle); 115 status = acpi_ds_initialize_region (obj_handle);
107 if (ACPI_FAILURE (status)) { 116 if (ACPI_FAILURE (status)) {
108 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n", 117 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
118 "Region %p [%4.4s] - Init failure, %s\n",
109 obj_handle, acpi_ut_get_node_name (obj_handle), 119 obj_handle, acpi_ut_get_node_name (obj_handle),
110 acpi_format_exception (status))); 120 acpi_format_exception (status)));
111 } 121 }
@@ -118,8 +128,10 @@ acpi_ds_init_one_object (
118 128
119 info->method_count++; 129 info->method_count++;
120 130
121 /* Print a dot for each method unless we are going to print the entire pathname */ 131 /*
122 132 * Print a dot for each method unless we are going to print
133 * the entire pathname
134 */
123 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { 135 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
124 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 136 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
125 } 137 }
@@ -140,7 +152,8 @@ acpi_ds_init_one_object (
140 */ 152 */
141 status = acpi_ds_parse_method (obj_handle); 153 status = acpi_ds_parse_method (obj_handle);
142 if (ACPI_FAILURE (status)) { 154 if (ACPI_FAILURE (status)) {
143 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n", 155 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
156 "Method %p [%4.4s] - parse failure, %s\n",
144 obj_handle, acpi_ut_get_node_name (obj_handle), 157 obj_handle, acpi_ut_get_node_name (obj_handle),
145 acpi_format_exception (status))); 158 acpi_format_exception (status)));
146 159
@@ -154,7 +167,8 @@ acpi_ds_init_one_object (
154 * for every execution since there isn't much overhead 167 * for every execution since there isn't much overhead
155 */ 168 */
156 acpi_ns_delete_namespace_subtree (obj_handle); 169 acpi_ns_delete_namespace_subtree (obj_handle);
157 acpi_ns_delete_namespace_by_owner (((struct acpi_namespace_node *) obj_handle)->object->method.owning_id); 170 acpi_ns_delete_namespace_by_owner (
171 ((struct acpi_namespace_node *) obj_handle)->object->method.owning_id);
158 break; 172 break;
159 173
160 174
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index 9f0456cb9bb5..9fc3f4c033eb 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -153,12 +153,11 @@ acpi_ds_parse_method (
153 /* 153 /*
154 * Parse the method, first pass 154 * Parse the method, first pass
155 * 155 *
156 * The first pass load is where newly declared named objects are 156 * The first pass load is where newly declared named objects are added into
157 * added into the namespace. Actual evaluation of 157 * the namespace. Actual evaluation of the named objects (what would be
158 * the named objects (what would be called a "second 158 * called a "second pass") happens during the actual execution of the
159 * pass") happens during the actual execution of the 159 * method so that operands to the named objects can take on dynamic
160 * method so that operands to the named objects can 160 * run-time values.
161 * take on dynamic run-time values.
162 */ 161 */
163 status = acpi_ps_parse_aml (walk_state); 162 status = acpi_ps_parse_aml (walk_state);
164 if (ACPI_FAILURE (status)) { 163 if (ACPI_FAILURE (status)) {
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
index f31d095f9833..f7998306f756 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/dispatcher/dsmthdat.c
@@ -52,6 +52,29 @@
52#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
53 ACPI_MODULE_NAME ("dsmthdat") 53 ACPI_MODULE_NAME ("dsmthdat")
54 54
55/* Local prototypes */
56
57static void
58acpi_ds_method_data_delete_value (
59 u16 opcode,
60 u32 index,
61 struct acpi_walk_state *walk_state);
62
63static acpi_status
64acpi_ds_method_data_set_value (
65 u16 opcode,
66 u32 index,
67 union acpi_operand_object *object,
68 struct acpi_walk_state *walk_state);
69
70#ifdef ACPI_OBSOLETE_FUNCTIONS
71acpi_object_type
72acpi_ds_method_data_get_type (
73 u16 opcode,
74 u32 index,
75 struct acpi_walk_state *walk_state);
76#endif
77
55 78
56/******************************************************************************* 79/*******************************************************************************
57 * 80 *
@@ -62,8 +85,8 @@
62 * RETURN: Status 85 * RETURN: Status
63 * 86 *
64 * DESCRIPTION: Initialize the data structures that hold the method's arguments 87 * DESCRIPTION: Initialize the data structures that hold the method's arguments
65 * and locals. The data struct is an array of NTEs for each. 88 * and locals. The data struct is an array of namespace nodes for
66 * This allows ref_of and de_ref_of to work properly for these 89 * each - this allows ref_of and de_ref_of to work properly for these
67 * special data types. 90 * special data types.
68 * 91 *
69 * NOTES: walk_state fields are initialized to zero by the 92 * NOTES: walk_state fields are initialized to zero by the
@@ -92,7 +115,8 @@ acpi_ds_method_data_init (
92 walk_state->arguments[i].name.integer |= (i << 24); 115 walk_state->arguments[i].name.integer |= (i << 24);
93 walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED; 116 walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
94 walk_state->arguments[i].type = ACPI_TYPE_ANY; 117 walk_state->arguments[i].type = ACPI_TYPE_ANY;
95 walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; 118 walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST |
119 ANOBJ_METHOD_ARG;
96 } 120 }
97 121
98 /* Init the method locals */ 122 /* Init the method locals */
@@ -104,7 +128,8 @@ acpi_ds_method_data_init (
104 walk_state->local_variables[i].name.integer |= (i << 24); 128 walk_state->local_variables[i].name.integer |= (i << 24);
105 walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED; 129 walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED;
106 walk_state->local_variables[i].type = ACPI_TYPE_ANY; 130 walk_state->local_variables[i].type = ACPI_TYPE_ANY;
107 walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; 131 walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST |
132 ANOBJ_METHOD_LOCAL;
108 } 133 }
109 134
110 return_VOID; 135 return_VOID;
@@ -198,15 +223,18 @@ acpi_ds_method_data_init_args (
198 return_ACPI_STATUS (AE_OK); 223 return_ACPI_STATUS (AE_OK);
199 } 224 }
200 225
201 /* Copy passed parameters into the new method stack frame */ 226 /* Copy passed parameters into the new method stack frame */
202 227
203 while ((index < ACPI_METHOD_NUM_ARGS) && (index < max_param_count) && params[index]) { 228 while ((index < ACPI_METHOD_NUM_ARGS) &&
229 (index < max_param_count) &&
230 params[index]) {
204 /* 231 /*
205 * A valid parameter. 232 * A valid parameter.
206 * Store the argument in the method/walk descriptor. 233 * Store the argument in the method/walk descriptor.
207 * Do not copy the arg in order to implement call by reference 234 * Do not copy the arg in order to implement call by reference
208 */ 235 */
209 status = acpi_ds_method_data_set_value (AML_ARG_OP, index, params[index], walk_state); 236 status = acpi_ds_method_data_set_value (AML_ARG_OP, index,
237 params[index], walk_state);
210 if (ACPI_FAILURE (status)) { 238 if (ACPI_FAILURE (status)) {
211 return_ACPI_STATUS (status); 239 return_ACPI_STATUS (status);
212 } 240 }
@@ -224,11 +252,13 @@ acpi_ds_method_data_init_args (
224 * FUNCTION: acpi_ds_method_data_get_node 252 * FUNCTION: acpi_ds_method_data_get_node
225 * 253 *
226 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 254 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
227 * Index - which local_var or argument whose type 255 * Index - Which Local or Arg whose type to get
228 * to get
229 * walk_state - Current walk state object 256 * walk_state - Current walk state object
257 * Node - Where the node is returned.
230 * 258 *
231 * RETURN: Get the Node associated with a local or arg. 259 * RETURN: Status and node
260 *
261 * DESCRIPTION: Get the Node associated with a local or arg.
232 * 262 *
233 ******************************************************************************/ 263 ******************************************************************************/
234 264
@@ -249,7 +279,8 @@ acpi_ds_method_data_get_node (
249 case AML_LOCAL_OP: 279 case AML_LOCAL_OP:
250 280
251 if (index > ACPI_METHOD_MAX_LOCAL) { 281 if (index > ACPI_METHOD_MAX_LOCAL) {
252 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", 282 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
283 "Local index %d is invalid (max %d)\n",
253 index, ACPI_METHOD_MAX_LOCAL)); 284 index, ACPI_METHOD_MAX_LOCAL));
254 return_ACPI_STATUS (AE_AML_INVALID_INDEX); 285 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
255 } 286 }
@@ -262,7 +293,8 @@ acpi_ds_method_data_get_node (
262 case AML_ARG_OP: 293 case AML_ARG_OP:
263 294
264 if (index > ACPI_METHOD_MAX_ARG) { 295 if (index > ACPI_METHOD_MAX_ARG) {
265 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", 296 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
297 "Arg index %d is invalid (max %d)\n",
266 index, ACPI_METHOD_MAX_ARG)); 298 index, ACPI_METHOD_MAX_ARG));
267 return_ACPI_STATUS (AE_AML_INVALID_INDEX); 299 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
268 } 300 }
@@ -286,7 +318,7 @@ acpi_ds_method_data_get_node (
286 * FUNCTION: acpi_ds_method_data_set_value 318 * FUNCTION: acpi_ds_method_data_set_value
287 * 319 *
288 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 320 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
289 * Index - which local_var or argument to get 321 * Index - Which Local or Arg to get
290 * Object - Object to be inserted into the stack entry 322 * Object - Object to be inserted into the stack entry
291 * walk_state - Current walk state object 323 * walk_state - Current walk state object
292 * 324 *
@@ -297,7 +329,7 @@ acpi_ds_method_data_get_node (
297 * 329 *
298 ******************************************************************************/ 330 ******************************************************************************/
299 331
300acpi_status 332static acpi_status
301acpi_ds_method_data_set_value ( 333acpi_ds_method_data_set_value (
302 u16 opcode, 334 u16 opcode,
303 u32 index, 335 u32 index,
@@ -340,68 +372,16 @@ acpi_ds_method_data_set_value (
340 372
341/******************************************************************************* 373/*******************************************************************************
342 * 374 *
343 * FUNCTION: acpi_ds_method_data_get_type
344 *
345 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
346 * Index - which local_var or argument whose type
347 * to get
348 * walk_state - Current walk state object
349 *
350 * RETURN: Data type of current value of the selected Arg or Local
351 *
352 ******************************************************************************/
353#ifdef ACPI_FUTURE_USAGE
354acpi_object_type
355acpi_ds_method_data_get_type (
356 u16 opcode,
357 u32 index,
358 struct acpi_walk_state *walk_state)
359{
360 acpi_status status;
361 struct acpi_namespace_node *node;
362 union acpi_operand_object *object;
363
364
365 ACPI_FUNCTION_TRACE ("ds_method_data_get_type");
366
367
368 /* Get the namespace node for the arg/local */
369
370 status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
371 if (ACPI_FAILURE (status)) {
372 return_VALUE ((ACPI_TYPE_NOT_FOUND));
373 }
374
375 /* Get the object */
376
377 object = acpi_ns_get_attached_object (node);
378 if (!object) {
379 /* Uninitialized local/arg, return TYPE_ANY */
380
381 return_VALUE (ACPI_TYPE_ANY);
382 }
383
384 /* Get the object type */
385
386 return_VALUE (ACPI_GET_OBJECT_TYPE (object));
387}
388#endif /* ACPI_FUTURE_USAGE */
389
390
391/*******************************************************************************
392 *
393 * FUNCTION: acpi_ds_method_data_get_value 375 * FUNCTION: acpi_ds_method_data_get_value
394 * 376 *
395 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 377 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
396 * Index - which local_var or argument to get 378 * Index - which local_var or argument to get
397 * walk_state - Current walk state object 379 * walk_state - Current walk state object
398 * *dest_desc - Ptr to Descriptor into which selected Arg 380 * dest_desc - Where Arg or Local value is returned
399 * or Local value should be copied
400 * 381 *
401 * RETURN: Status 382 * RETURN: Status
402 * 383 *
403 * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame 384 * DESCRIPTION: Retrieve value of selected Arg or Local for this method
404 * at the current top of the method stack.
405 * Used only in acpi_ex_resolve_to_value(). 385 * Used only in acpi_ex_resolve_to_value().
406 * 386 *
407 ******************************************************************************/ 387 ******************************************************************************/
@@ -467,14 +447,16 @@ acpi_ds_method_data_get_value (
467 else switch (opcode) { 447 else switch (opcode) {
468 case AML_ARG_OP: 448 case AML_ARG_OP:
469 449
470 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n", 450 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
451 "Uninitialized Arg[%d] at node %p\n",
471 index, node)); 452 index, node));
472 453
473 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); 454 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
474 455
475 case AML_LOCAL_OP: 456 case AML_LOCAL_OP:
476 457
477 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n", 458 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
459 "Uninitialized Local[%d] at node %p\n",
478 index, node)); 460 index, node));
479 461
480 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); 462 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
@@ -506,12 +488,12 @@ acpi_ds_method_data_get_value (
506 * 488 *
507 * RETURN: None 489 * RETURN: None
508 * 490 *
509 * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts 491 * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
510 * a null into the stack slot after the object is deleted. 492 * a null into the stack slot after the object is deleted.
511 * 493 *
512 ******************************************************************************/ 494 ******************************************************************************/
513 495
514void 496static void
515acpi_ds_method_data_delete_value ( 497acpi_ds_method_data_delete_value (
516 u16 opcode, 498 u16 opcode,
517 u32 index, 499 u32 index,
@@ -562,7 +544,7 @@ acpi_ds_method_data_delete_value (
562 * FUNCTION: acpi_ds_store_object_to_local 544 * FUNCTION: acpi_ds_store_object_to_local
563 * 545 *
564 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 546 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
565 * Index - which local_var or argument to set 547 * Index - Which Local or Arg to set
566 * obj_desc - Value to be stored 548 * obj_desc - Value to be stored
567 * walk_state - Current walk state 549 * walk_state - Current walk state
568 * 550 *
@@ -651,19 +633,20 @@ acpi_ds_store_object_to_local (
651 */ 633 */
652 if (opcode == AML_ARG_OP) { 634 if (opcode == AML_ARG_OP) {
653 /* 635 /*
654 * Make sure that the object is the correct type. This may be overkill, but 636 * Make sure that the object is the correct type. This may be
655 * it is here because references were NS nodes in the past. Now they are 637 * overkill, butit is here because references were NS nodes in
656 * operand objects of type Reference. 638 * the past. Now they are operand objects of type Reference.
657 */ 639 */
658 if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) { 640 if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) {
659 ACPI_REPORT_ERROR (("Invalid descriptor type while storing to method arg: [%s]\n", 641 ACPI_REPORT_ERROR ((
660 acpi_ut_get_descriptor_name (current_obj_desc))); 642 "Invalid descriptor type while storing to method arg: [%s]\n",
643 acpi_ut_get_descriptor_name (current_obj_desc)));
661 return_ACPI_STATUS (AE_AML_INTERNAL); 644 return_ACPI_STATUS (AE_AML_INTERNAL);
662 } 645 }
663 646
664 /* 647 /*
665 * If we have a valid reference object that came from ref_of(), do the 648 * If we have a valid reference object that came from ref_of(),
666 * indirect store 649 * do the indirect store
667 */ 650 */
668 if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && 651 if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
669 (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { 652 (current_obj_desc->reference.opcode == AML_REF_OF_OP)) {
@@ -713,3 +696,55 @@ acpi_ds_store_object_to_local (
713} 696}
714 697
715 698
699#ifdef ACPI_OBSOLETE_FUNCTIONS
700/*******************************************************************************
701 *
702 * FUNCTION: acpi_ds_method_data_get_type
703 *
704 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
705 * Index - Which Local or Arg whose type to get
706 * walk_state - Current walk state object
707 *
708 * RETURN: Data type of current value of the selected Arg or Local
709 *
710 * DESCRIPTION: Get the type of the object stored in the Local or Arg
711 *
712 ******************************************************************************/
713
714acpi_object_type
715acpi_ds_method_data_get_type (
716 u16 opcode,
717 u32 index,
718 struct acpi_walk_state *walk_state)
719{
720 acpi_status status;
721 struct acpi_namespace_node *node;
722 union acpi_operand_object *object;
723
724
725 ACPI_FUNCTION_TRACE ("ds_method_data_get_type");
726
727
728 /* Get the namespace node for the arg/local */
729
730 status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
731 if (ACPI_FAILURE (status)) {
732 return_VALUE ((ACPI_TYPE_NOT_FOUND));
733 }
734
735 /* Get the object */
736
737 object = acpi_ns_get_attached_object (node);
738 if (!object) {
739 /* Uninitialized local/arg, return TYPE_ANY */
740
741 return_VALUE (ACPI_TYPE_ANY);
742 }
743
744 /* Get the object type */
745
746 return_VALUE (ACPI_GET_OBJECT_TYPE (object));
747}
748#endif
749
750
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c
index eb8af4785bcb..bfbae4e4c667 100644
--- a/drivers/acpi/dispatcher/dsobject.c
+++ b/drivers/acpi/dispatcher/dsobject.c
@@ -52,9 +52,15 @@
52#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
53 ACPI_MODULE_NAME ("dsobject") 53 ACPI_MODULE_NAME ("dsobject")
54 54
55static acpi_status
56acpi_ds_build_internal_object (
57 struct acpi_walk_state *walk_state,
58 union acpi_parse_object *op,
59 union acpi_operand_object **obj_desc_ptr);
60
55 61
56#ifndef ACPI_NO_METHOD_EXECUTION 62#ifndef ACPI_NO_METHOD_EXECUTION
57/***************************************************************************** 63/*******************************************************************************
58 * 64 *
59 * FUNCTION: acpi_ds_build_internal_object 65 * FUNCTION: acpi_ds_build_internal_object
60 * 66 *
@@ -67,9 +73,9 @@
67 * DESCRIPTION: Translate a parser Op object to the equivalent namespace object 73 * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
68 * Simple objects are any objects other than a package object! 74 * Simple objects are any objects other than a package object!
69 * 75 *
70 ****************************************************************************/ 76 ******************************************************************************/
71 77
72acpi_status 78static acpi_status
73acpi_ds_build_internal_object ( 79acpi_ds_build_internal_object (
74 struct acpi_walk_state *walk_state, 80 struct acpi_walk_state *walk_state,
75 union acpi_parse_object *op, 81 union acpi_parse_object *op,
@@ -90,9 +96,11 @@ acpi_ds_build_internal_object (
90 * Otherwise, go ahead and look it up now 96 * Otherwise, go ahead and look it up now
91 */ 97 */
92 if (!op->common.node) { 98 if (!op->common.node) {
93 status = acpi_ns_lookup (walk_state->scope_info, op->common.value.string, 99 status = acpi_ns_lookup (walk_state->scope_info,
100 op->common.value.string,
94 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 101 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
95 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, 102 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
103 NULL,
96 (struct acpi_namespace_node **) &(op->common.node)); 104 (struct acpi_namespace_node **) &(op->common.node));
97 105
98 if (ACPI_FAILURE (status)) { 106 if (ACPI_FAILURE (status)) {
@@ -104,12 +112,14 @@ acpi_ds_build_internal_object (
104 112
105 /* Create and init the internal ACPI object */ 113 /* Create and init the internal ACPI object */
106 114
107 obj_desc = acpi_ut_create_internal_object ((acpi_ps_get_opcode_info (op->common.aml_opcode))->object_type); 115 obj_desc = acpi_ut_create_internal_object (
116 (acpi_ps_get_opcode_info (op->common.aml_opcode))->object_type);
108 if (!obj_desc) { 117 if (!obj_desc) {
109 return_ACPI_STATUS (AE_NO_MEMORY); 118 return_ACPI_STATUS (AE_NO_MEMORY);
110 } 119 }
111 120
112 status = acpi_ds_init_object_from_op (walk_state, op, op->common.aml_opcode, &obj_desc); 121 status = acpi_ds_init_object_from_op (walk_state, op, op->common.aml_opcode,
122 &obj_desc);
113 if (ACPI_FAILURE (status)) { 123 if (ACPI_FAILURE (status)) {
114 acpi_ut_remove_reference (obj_desc); 124 acpi_ut_remove_reference (obj_desc);
115 return_ACPI_STATUS (status); 125 return_ACPI_STATUS (status);
@@ -120,7 +130,7 @@ acpi_ds_build_internal_object (
120} 130}
121 131
122 132
123/***************************************************************************** 133/*******************************************************************************
124 * 134 *
125 * FUNCTION: acpi_ds_build_internal_buffer_obj 135 * FUNCTION: acpi_ds_build_internal_buffer_obj
126 * 136 *
@@ -134,7 +144,7 @@ acpi_ds_build_internal_object (
134 * DESCRIPTION: Translate a parser Op package object to the equivalent 144 * DESCRIPTION: Translate a parser Op package object to the equivalent
135 * namespace object 145 * namespace object
136 * 146 *
137 ****************************************************************************/ 147 ******************************************************************************/
138 148
139acpi_status 149acpi_status
140acpi_ds_build_internal_buffer_obj ( 150acpi_ds_build_internal_buffer_obj (
@@ -229,7 +239,7 @@ acpi_ds_build_internal_buffer_obj (
229} 239}
230 240
231 241
232/***************************************************************************** 242/*******************************************************************************
233 * 243 *
234 * FUNCTION: acpi_ds_build_internal_package_obj 244 * FUNCTION: acpi_ds_build_internal_package_obj
235 * 245 *
@@ -243,7 +253,7 @@ acpi_ds_build_internal_buffer_obj (
243 * DESCRIPTION: Translate a parser Op package object to the equivalent 253 * DESCRIPTION: Translate a parser Op package object to the equivalent
244 * namespace object 254 * namespace object
245 * 255 *
246 ****************************************************************************/ 256 ******************************************************************************/
247 257
248acpi_status 258acpi_status
249acpi_ds_build_internal_package_obj ( 259acpi_ds_build_internal_package_obj (
@@ -331,11 +341,12 @@ acpi_ds_build_internal_package_obj (
331 if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { 341 if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
332 /* Object (package or buffer) is already built */ 342 /* Object (package or buffer) is already built */
333 343
334 obj_desc->package.elements[i] = ACPI_CAST_PTR (union acpi_operand_object, arg->common.node); 344 obj_desc->package.elements[i] =
345 ACPI_CAST_PTR (union acpi_operand_object, arg->common.node);
335 } 346 }
336 else { 347 else {
337 status = acpi_ds_build_internal_object (walk_state, arg, 348 status = acpi_ds_build_internal_object (walk_state, arg,
338 &obj_desc->package.elements[i]); 349 &obj_desc->package.elements[i]);
339 } 350 }
340 351
341 i++; 352 i++;
@@ -348,7 +359,7 @@ acpi_ds_build_internal_package_obj (
348} 359}
349 360
350 361
351/***************************************************************************** 362/*******************************************************************************
352 * 363 *
353 * FUNCTION: acpi_ds_create_node 364 * FUNCTION: acpi_ds_create_node
354 * 365 *
@@ -360,7 +371,7 @@ acpi_ds_build_internal_package_obj (
360 * 371 *
361 * DESCRIPTION: Create the object to be associated with a namespace node 372 * DESCRIPTION: Create the object to be associated with a namespace node
362 * 373 *
363 ****************************************************************************/ 374 ******************************************************************************/
364 375
365acpi_status 376acpi_status
366acpi_ds_create_node ( 377acpi_ds_create_node (
@@ -392,7 +403,8 @@ acpi_ds_create_node (
392 403
393 /* Build an internal object for the argument(s) */ 404 /* Build an internal object for the argument(s) */
394 405
395 status = acpi_ds_build_internal_object (walk_state, op->common.value.arg, &obj_desc); 406 status = acpi_ds_build_internal_object (walk_state, op->common.value.arg,
407 &obj_desc);
396 if (ACPI_FAILURE (status)) { 408 if (ACPI_FAILURE (status)) {
397 return_ACPI_STATUS (status); 409 return_ACPI_STATUS (status);
398 } 410 }
@@ -414,7 +426,7 @@ acpi_ds_create_node (
414#endif /* ACPI_NO_METHOD_EXECUTION */ 426#endif /* ACPI_NO_METHOD_EXECUTION */
415 427
416 428
417/***************************************************************************** 429/*******************************************************************************
418 * 430 *
419 * FUNCTION: acpi_ds_init_object_from_op 431 * FUNCTION: acpi_ds_init_object_from_op
420 * 432 *
@@ -429,7 +441,7 @@ acpi_ds_create_node (
429 * associated arguments. The namespace object is a more compact 441 * associated arguments. The namespace object is a more compact
430 * representation of the Op and its arguments. 442 * representation of the Op and its arguments.
431 * 443 *
432 ****************************************************************************/ 444 ******************************************************************************/
433 445
434acpi_status 446acpi_status
435acpi_ds_init_object_from_op ( 447acpi_ds_init_object_from_op (
@@ -462,7 +474,8 @@ acpi_ds_init_object_from_op (
462 /* 474 /*
463 * Defer evaluation of Buffer term_arg operand 475 * Defer evaluation of Buffer term_arg operand
464 */ 476 */
465 obj_desc->buffer.node = (struct acpi_namespace_node *) walk_state->operands[0]; 477 obj_desc->buffer.node = (struct acpi_namespace_node *)
478 walk_state->operands[0];
466 obj_desc->buffer.aml_start = op->named.data; 479 obj_desc->buffer.aml_start = op->named.data;
467 obj_desc->buffer.aml_length = op->named.length; 480 obj_desc->buffer.aml_length = op->named.length;
468 break; 481 break;
@@ -473,7 +486,8 @@ acpi_ds_init_object_from_op (
473 /* 486 /*
474 * Defer evaluation of Package term_arg operand 487 * Defer evaluation of Package term_arg operand
475 */ 488 */
476 obj_desc->package.node = (struct acpi_namespace_node *) walk_state->operands[0]; 489 obj_desc->package.node = (struct acpi_namespace_node *)
490 walk_state->operands[0];
477 obj_desc->package.aml_start = op->named.data; 491 obj_desc->package.aml_start = op->named.data;
478 obj_desc->package.aml_length = op->named.length; 492 obj_desc->package.aml_length = op->named.length;
479 break; 493 break;
@@ -486,9 +500,10 @@ acpi_ds_init_object_from_op (
486 /* 500 /*
487 * Resolve AML Constants here - AND ONLY HERE! 501 * Resolve AML Constants here - AND ONLY HERE!
488 * All constants are integers. 502 * All constants are integers.
489 * We mark the integer with a flag that indicates that it started life 503 * We mark the integer with a flag that indicates that it started
490 * as a constant -- so that stores to constants will perform as expected (noop). 504 * life as a constant -- so that stores to constants will perform
491 * (zero_op is used as a placeholder for optional target operands.) 505 * as expected (noop). zero_op is used as a placeholder for optional
506 * target operands.
492 */ 507 */
493 obj_desc->common.flags = AOPOBJ_AML_CONSTANT; 508 obj_desc->common.flags = AOPOBJ_AML_CONSTANT;
494 509
@@ -521,7 +536,8 @@ acpi_ds_init_object_from_op (
521 536
522 default: 537 default:
523 538
524 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown constant opcode %X\n", opcode)); 539 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
540 "Unknown constant opcode %X\n", opcode));
525 status = AE_AML_OPERAND_TYPE; 541 status = AE_AML_OPERAND_TYPE;
526 break; 542 break;
527 } 543 }
@@ -535,7 +551,8 @@ acpi_ds_init_object_from_op (
535 551
536 552
537 default: 553 default:
538 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", op_info->type)); 554 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n",
555 op_info->type));
539 status = AE_AML_OPERAND_TYPE; 556 status = AE_AML_OPERAND_TYPE;
540 break; 557 break;
541 } 558 }
@@ -570,8 +587,10 @@ acpi_ds_init_object_from_op (
570 obj_desc->reference.offset = opcode - AML_LOCAL_OP; 587 obj_desc->reference.offset = opcode - AML_LOCAL_OP;
571 588
572#ifndef ACPI_NO_METHOD_EXECUTION 589#ifndef ACPI_NO_METHOD_EXECUTION
573 status = acpi_ds_method_data_get_node (AML_LOCAL_OP, obj_desc->reference.offset, 590 status = acpi_ds_method_data_get_node (AML_LOCAL_OP,
574 walk_state, (struct acpi_namespace_node **) &obj_desc->reference.object); 591 obj_desc->reference.offset,
592 walk_state,
593 (struct acpi_namespace_node **) &obj_desc->reference.object);
575#endif 594#endif
576 break; 595 break;
577 596
@@ -584,8 +603,10 @@ acpi_ds_init_object_from_op (
584 obj_desc->reference.offset = opcode - AML_ARG_OP; 603 obj_desc->reference.offset = opcode - AML_ARG_OP;
585 604
586#ifndef ACPI_NO_METHOD_EXECUTION 605#ifndef ACPI_NO_METHOD_EXECUTION
587 status = acpi_ds_method_data_get_node (AML_ARG_OP, obj_desc->reference.offset, 606 status = acpi_ds_method_data_get_node (AML_ARG_OP,
588 walk_state, (struct acpi_namespace_node **) &obj_desc->reference.object); 607 obj_desc->reference.offset,
608 walk_state,
609 (struct acpi_namespace_node **) &obj_desc->reference.object);
589#endif 610#endif
590 break; 611 break;
591 612
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index 5c987a0e7b75..ba13bca28bee 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/dispatcher/dsopcode.c
@@ -54,12 +54,31 @@
54#define _COMPONENT ACPI_DISPATCHER 54#define _COMPONENT ACPI_DISPATCHER
55 ACPI_MODULE_NAME ("dsopcode") 55 ACPI_MODULE_NAME ("dsopcode")
56 56
57/* Local prototypes */
57 58
58/***************************************************************************** 59static acpi_status
60acpi_ds_execute_arguments (
61 struct acpi_namespace_node *node,
62 struct acpi_namespace_node *scope_node,
63 u32 aml_length,
64 u8 *aml_start);
65
66static acpi_status
67acpi_ds_init_buffer_field (
68 u16 aml_opcode,
69 union acpi_operand_object *obj_desc,
70 union acpi_operand_object *buffer_desc,
71 union acpi_operand_object *offset_desc,
72 union acpi_operand_object *length_desc,
73 union acpi_operand_object *result_desc);
74
75
76/*******************************************************************************
59 * 77 *
60 * FUNCTION: acpi_ds_execute_arguments 78 * FUNCTION: acpi_ds_execute_arguments
61 * 79 *
62 * PARAMETERS: Node - Parent NS node 80 * PARAMETERS: Node - Object NS node
81 * scope_node - Parent NS node
63 * aml_length - Length of executable AML 82 * aml_length - Length of executable AML
64 * aml_start - Pointer to the AML 83 * aml_start - Pointer to the AML
65 * 84 *
@@ -67,9 +86,9 @@
67 * 86 *
68 * DESCRIPTION: Late (deferred) execution of region or field arguments 87 * DESCRIPTION: Late (deferred) execution of region or field arguments
69 * 88 *
70 ****************************************************************************/ 89 ******************************************************************************/
71 90
72acpi_status 91static acpi_status
73acpi_ds_execute_arguments ( 92acpi_ds_execute_arguments (
74 struct acpi_namespace_node *node, 93 struct acpi_namespace_node *node,
75 struct acpi_namespace_node *scope_node, 94 struct acpi_namespace_node *scope_node,
@@ -162,7 +181,7 @@ acpi_ds_execute_arguments (
162} 181}
163 182
164 183
165/***************************************************************************** 184/*******************************************************************************
166 * 185 *
167 * FUNCTION: acpi_ds_get_buffer_field_arguments 186 * FUNCTION: acpi_ds_get_buffer_field_arguments
168 * 187 *
@@ -173,7 +192,7 @@ acpi_ds_execute_arguments (
173 * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late 192 * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
174 * evaluation of these field attributes. 193 * evaluation of these field attributes.
175 * 194 *
176 ****************************************************************************/ 195 ******************************************************************************/
177 196
178acpi_status 197acpi_status
179acpi_ds_get_buffer_field_arguments ( 198acpi_ds_get_buffer_field_arguments (
@@ -208,7 +227,7 @@ acpi_ds_get_buffer_field_arguments (
208} 227}
209 228
210 229
211/***************************************************************************** 230/*******************************************************************************
212 * 231 *
213 * FUNCTION: acpi_ds_get_buffer_arguments 232 * FUNCTION: acpi_ds_get_buffer_arguments
214 * 233 *
@@ -219,7 +238,7 @@ acpi_ds_get_buffer_field_arguments (
219 * DESCRIPTION: Get Buffer length and initializer byte list. This implements 238 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
220 * the late evaluation of these attributes. 239 * the late evaluation of these attributes.
221 * 240 *
222 ****************************************************************************/ 241 ******************************************************************************/
223 242
224acpi_status 243acpi_status
225acpi_ds_get_buffer_arguments ( 244acpi_ds_get_buffer_arguments (
@@ -255,7 +274,7 @@ acpi_ds_get_buffer_arguments (
255} 274}
256 275
257 276
258/***************************************************************************** 277/*******************************************************************************
259 * 278 *
260 * FUNCTION: acpi_ds_get_package_arguments 279 * FUNCTION: acpi_ds_get_package_arguments
261 * 280 *
@@ -266,7 +285,7 @@ acpi_ds_get_buffer_arguments (
266 * DESCRIPTION: Get Package length and initializer byte list. This implements 285 * DESCRIPTION: Get Package length and initializer byte list. This implements
267 * the late evaluation of these attributes. 286 * the late evaluation of these attributes.
268 * 287 *
269 ****************************************************************************/ 288 ******************************************************************************/
270 289
271acpi_status 290acpi_status
272acpi_ds_get_package_arguments ( 291acpi_ds_get_package_arguments (
@@ -353,17 +372,17 @@ acpi_ds_get_region_arguments (
353} 372}
354 373
355 374
356/***************************************************************************** 375/*******************************************************************************
357 * 376 *
358 * FUNCTION: acpi_ds_initialize_region 377 * FUNCTION: acpi_ds_initialize_region
359 * 378 *
360 * PARAMETERS: Op - A valid region Op object 379 * PARAMETERS: obj_handle - Region namespace node
361 * 380 *
362 * RETURN: Status 381 * RETURN: Status
363 * 382 *
364 * DESCRIPTION: Front end to ev_initialize_region 383 * DESCRIPTION: Front end to ev_initialize_region
365 * 384 *
366 ****************************************************************************/ 385 ******************************************************************************/
367 386
368acpi_status 387acpi_status
369acpi_ds_initialize_region ( 388acpi_ds_initialize_region (
@@ -382,7 +401,7 @@ acpi_ds_initialize_region (
382} 401}
383 402
384 403
385/***************************************************************************** 404/*******************************************************************************
386 * 405 *
387 * FUNCTION: acpi_ds_init_buffer_field 406 * FUNCTION: acpi_ds_init_buffer_field
388 * 407 *
@@ -390,16 +409,16 @@ acpi_ds_initialize_region (
390 * obj_desc - buffer_field object 409 * obj_desc - buffer_field object
391 * buffer_desc - Host Buffer 410 * buffer_desc - Host Buffer
392 * offset_desc - Offset into buffer 411 * offset_desc - Offset into buffer
393 * Length - Length of field (CREATE_FIELD_OP only) 412 * length_desc - Length of field (CREATE_FIELD_OP only)
394 * Result - Where to store the result 413 * result_desc - Where to store the result
395 * 414 *
396 * RETURN: Status 415 * RETURN: Status
397 * 416 *
398 * DESCRIPTION: Perform actual initialization of a buffer field 417 * DESCRIPTION: Perform actual initialization of a buffer field
399 * 418 *
400 ****************************************************************************/ 419 ******************************************************************************/
401 420
402acpi_status 421static acpi_status
403acpi_ds_init_buffer_field ( 422acpi_ds_init_buffer_field (
404 u16 aml_opcode, 423 u16 aml_opcode,
405 union acpi_operand_object *obj_desc, 424 union acpi_operand_object *obj_desc,
@@ -435,8 +454,10 @@ acpi_ds_init_buffer_field (
435 * after resolution in acpi_ex_resolve_operands(). 454 * after resolution in acpi_ex_resolve_operands().
436 */ 455 */
437 if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) { 456 if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) {
438 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination not a NS Node [%s]\n", 457 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
439 acpi_ps_get_opcode_name (aml_opcode), acpi_ut_get_descriptor_name (result_desc))); 458 "(%s) destination not a NS Node [%s]\n",
459 acpi_ps_get_opcode_name (aml_opcode),
460 acpi_ut_get_descriptor_name (result_desc)));
440 461
441 status = AE_AML_OPERAND_TYPE; 462 status = AE_AML_OPERAND_TYPE;
442 goto cleanup; 463 goto cleanup;
@@ -452,9 +473,18 @@ acpi_ds_init_buffer_field (
452 473
453 /* Offset is in bits, count is in bits */ 474 /* Offset is in bits, count is in bits */
454 475
476 field_flags = AML_FIELD_ACCESS_BYTE;
455 bit_offset = offset; 477 bit_offset = offset;
456 bit_count = (u32) length_desc->integer.value; 478 bit_count = (u32) length_desc->integer.value;
457 field_flags = AML_FIELD_ACCESS_BYTE; 479
480 /* Must have a valid (>0) bit count */
481
482 if (bit_count == 0) {
483 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
484 "Attempt to create_field of length 0\n"));
485 status = AE_AML_OPERAND_VALUE;
486 goto cleanup;
487 }
458 break; 488 break;
459 489
460 case AML_CREATE_BIT_FIELD_OP: 490 case AML_CREATE_BIT_FIELD_OP:
@@ -527,7 +557,8 @@ acpi_ds_init_buffer_field (
527 557
528 /* 558 /*
529 * Initialize areas of the field object that are common to all fields 559 * Initialize areas of the field object that are common to all fields
530 * For field_flags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE) 560 * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
561 * UPDATE_RULE = 0 (UPDATE_PRESERVE)
531 */ 562 */
532 status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0, 563 status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0,
533 bit_offset, bit_count); 564 bit_offset, bit_count);
@@ -539,8 +570,8 @@ acpi_ds_init_buffer_field (
539 570
540 /* Reference count for buffer_desc inherits obj_desc count */ 571 /* Reference count for buffer_desc inherits obj_desc count */
541 572
542 buffer_desc->common.reference_count = (u16) (buffer_desc->common.reference_count + 573 buffer_desc->common.reference_count = (u16)
543 obj_desc->common.reference_count); 574 (buffer_desc->common.reference_count + obj_desc->common.reference_count);
544 575
545 576
546cleanup: 577cleanup:
@@ -569,7 +600,7 @@ cleanup:
569} 600}
570 601
571 602
572/***************************************************************************** 603/*******************************************************************************
573 * 604 *
574 * FUNCTION: acpi_ds_eval_buffer_field_operands 605 * FUNCTION: acpi_ds_eval_buffer_field_operands
575 * 606 *
@@ -581,7 +612,7 @@ cleanup:
581 * DESCRIPTION: Get buffer_field Buffer and Index 612 * DESCRIPTION: Get buffer_field Buffer and Index
582 * Called from acpi_ds_exec_end_op during buffer_field parse tree walk 613 * Called from acpi_ds_exec_end_op during buffer_field parse tree walk
583 * 614 *
584 ****************************************************************************/ 615 ******************************************************************************/
585 616
586acpi_status 617acpi_status
587acpi_ds_eval_buffer_field_operands ( 618acpi_ds_eval_buffer_field_operands (
@@ -656,7 +687,7 @@ acpi_ds_eval_buffer_field_operands (
656} 687}
657 688
658 689
659/***************************************************************************** 690/*******************************************************************************
660 * 691 *
661 * FUNCTION: acpi_ds_eval_region_operands 692 * FUNCTION: acpi_ds_eval_region_operands
662 * 693 *
@@ -668,7 +699,7 @@ acpi_ds_eval_buffer_field_operands (
668 * DESCRIPTION: Get region address and length 699 * DESCRIPTION: Get region address and length
669 * Called from acpi_ds_exec_end_op during op_region parse tree walk 700 * Called from acpi_ds_exec_end_op during op_region parse tree walk
670 * 701 *
671 ****************************************************************************/ 702 ******************************************************************************/
672 703
673acpi_status 704acpi_status
674acpi_ds_eval_region_operands ( 705acpi_ds_eval_region_operands (
@@ -686,7 +717,8 @@ acpi_ds_eval_region_operands (
686 717
687 718
688 /* 719 /*
689 * This is where we evaluate the address and length fields of the op_region declaration 720 * This is where we evaluate the address and length fields of the
721 * op_region declaration
690 */ 722 */
691 node = op->common.node; 723 node = op->common.node;
692 724
@@ -707,7 +739,8 @@ acpi_ds_eval_region_operands (
707 739
708 /* Resolve the length and address operands to numbers */ 740 /* Resolve the length and address operands to numbers */
709 741
710 status = acpi_ex_resolve_operands (op->common.aml_opcode, ACPI_WALK_OPERANDS, walk_state); 742 status = acpi_ex_resolve_operands (op->common.aml_opcode,
743 ACPI_WALK_OPERANDS, walk_state);
711 if (ACPI_FAILURE (status)) { 744 if (ACPI_FAILURE (status)) {
712 return_ACPI_STATUS (status); 745 return_ACPI_STATUS (status);
713 } 746 }
@@ -736,7 +769,8 @@ acpi_ds_eval_region_operands (
736 */ 769 */
737 operand_desc = walk_state->operands[walk_state->num_operands - 2]; 770 operand_desc = walk_state->operands[walk_state->num_operands - 2];
738 771
739 obj_desc->region.address = (acpi_physical_address) operand_desc->integer.value; 772 obj_desc->region.address = (acpi_physical_address)
773 operand_desc->integer.value;
740 acpi_ut_remove_reference (operand_desc); 774 acpi_ut_remove_reference (operand_desc);
741 775
742 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n", 776 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n",
@@ -752,7 +786,7 @@ acpi_ds_eval_region_operands (
752} 786}
753 787
754 788
755/***************************************************************************** 789/*******************************************************************************
756 * 790 *
757 * FUNCTION: acpi_ds_eval_data_object_operands 791 * FUNCTION: acpi_ds_eval_data_object_operands
758 * 792 *
@@ -765,7 +799,7 @@ acpi_ds_eval_region_operands (
765 * DESCRIPTION: Get the operands and complete the following data object types: 799 * DESCRIPTION: Get the operands and complete the following data object types:
766 * Buffer, Package. 800 * Buffer, Package.
767 * 801 *
768 ****************************************************************************/ 802 ******************************************************************************/
769 803
770acpi_status 804acpi_status
771acpi_ds_eval_data_object_operands ( 805acpi_ds_eval_data_object_operands (
@@ -830,7 +864,7 @@ acpi_ds_eval_data_object_operands (
830 864
831 if (ACPI_SUCCESS (status)) { 865 if (ACPI_SUCCESS (status)) {
832 /* 866 /*
833 * Return the object in the walk_state, unless the parent is a package -- 867 * Return the object in the walk_state, unless the parent is a package -
834 * in this case, the return object will be stored in the parse tree 868 * in this case, the return object will be stored in the parse tree
835 * for the package. 869 * for the package.
836 */ 870 */
@@ -988,7 +1022,8 @@ acpi_ds_exec_end_control_op (
988 status = AE_CTRL_PENDING; 1022 status = AE_CTRL_PENDING;
989 } 1023 }
990 1024
991 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", op)); 1025 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1026 "[WHILE_OP] termination! Op=%p\n",op));
992 1027
993 /* Pop this control state and free it */ 1028 /* Pop this control state and free it */
994 1029
diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c
index 462c5d83e747..9613349ac31d 100644
--- a/drivers/acpi/dispatcher/dsutils.c
+++ b/drivers/acpi/dispatcher/dsutils.c
@@ -100,7 +100,6 @@ acpi_ds_clear_implicit_return (
100 100
101 101
102#ifndef ACPI_NO_METHOD_EXECUTION 102#ifndef ACPI_NO_METHOD_EXECUTION
103
104/******************************************************************************* 103/*******************************************************************************
105 * 104 *
106 * FUNCTION: acpi_ds_do_implicit_return 105 * FUNCTION: acpi_ds_do_implicit_return
@@ -205,7 +204,7 @@ acpi_ds_is_result_used (
205 * NOTE: this is optional because the ASL language does not actually 204 * NOTE: this is optional because the ASL language does not actually
206 * support this behavior. 205 * support this behavior.
207 */ 206 */
208 acpi_ds_do_implicit_return (walk_state->result_obj, walk_state, TRUE); 207 (void) acpi_ds_do_implicit_return (walk_state->result_obj, walk_state, TRUE);
209 208
210 /* 209 /*
211 * Now determine if the parent will use the result 210 * Now determine if the parent will use the result
@@ -219,8 +218,9 @@ acpi_ds_is_result_used (
219 (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) { 218 (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) {
220 /* No parent, the return value cannot possibly be used */ 219 /* No parent, the return value cannot possibly be used */
221 220
222 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "At Method level, result of [%s] not used\n", 221 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
223 acpi_ps_get_opcode_name (op->common.aml_opcode))); 222 "At Method level, result of [%s] not used\n",
223 acpi_ps_get_opcode_name (op->common.aml_opcode)));
224 return_VALUE (FALSE); 224 return_VALUE (FALSE);
225 } 225 }
226 226
@@ -228,7 +228,8 @@ acpi_ds_is_result_used (
228 228
229 parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode); 229 parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode);
230 if (parent_info->class == AML_CLASS_UNKNOWN) { 230 if (parent_info->class == AML_CLASS_UNKNOWN) {
231 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", op)); 231 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
232 "Unknown parent opcode. Op=%p\n", op));
232 return_VALUE (FALSE); 233 return_VALUE (FALSE);
233 } 234 }
234 235
@@ -309,17 +310,19 @@ acpi_ds_is_result_used (
309 310
310 311
311result_used: 312result_used:
312 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n", 313 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
313 acpi_ps_get_opcode_name (op->common.aml_opcode), 314 "Result of [%s] used by Parent [%s] Op=%p\n",
314 acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op)); 315 acpi_ps_get_opcode_name (op->common.aml_opcode),
316 acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
315 317
316 return_VALUE (TRUE); 318 return_VALUE (TRUE);
317 319
318 320
319result_not_used: 321result_not_used:
320 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n", 322 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
321 acpi_ps_get_opcode_name (op->common.aml_opcode), 323 "Result of [%s] not used by Parent [%s] Op=%p\n",
322 acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op)); 324 acpi_ps_get_opcode_name (op->common.aml_opcode),
325 acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
323 326
324 return_VALUE (FALSE); 327 return_VALUE (FALSE);
325} 328}
@@ -522,7 +525,8 @@ acpi_ds_create_operand (
522 if ((walk_state->deferred_node) && 525 if ((walk_state->deferred_node) &&
523 (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) && 526 (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) &&
524 (arg_index != 0)) { 527 (arg_index != 0)) {
525 obj_desc = ACPI_CAST_PTR (union acpi_operand_object, walk_state->deferred_node); 528 obj_desc = ACPI_CAST_PTR (
529 union acpi_operand_object, walk_state->deferred_node);
526 status = AE_OK; 530 status = AE_OK;
527 } 531 }
528 else /* All other opcodes */ { 532 else /* All other opcodes */ {
@@ -565,7 +569,8 @@ acpi_ds_create_operand (
565 * indicate this to the interpreter, set the 569 * indicate this to the interpreter, set the
566 * object to the root 570 * object to the root
567 */ 571 */
568 obj_desc = ACPI_CAST_PTR (union acpi_operand_object, acpi_gbl_root_node); 572 obj_desc = ACPI_CAST_PTR (
573 union acpi_operand_object, acpi_gbl_root_node);
569 status = AE_OK; 574 status = AE_OK;
570 } 575 }
571 else { 576 else {
@@ -612,7 +617,8 @@ acpi_ds_create_operand (
612 */ 617 */
613 opcode = AML_ZERO_OP; /* Has no arguments! */ 618 opcode = AML_ZERO_OP; /* Has no arguments! */
614 619
615 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", arg)); 620 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
621 "Null namepath: Arg=%p\n", arg));
616 } 622 }
617 else { 623 else {
618 opcode = arg->common.aml_opcode; 624 opcode = arg->common.aml_opcode;
@@ -642,7 +648,8 @@ acpi_ds_create_operand (
642 * Only error is underflow, and this indicates 648 * Only error is underflow, and this indicates
643 * a missing or null operand! 649 * a missing or null operand!
644 */ 650 */
645 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n", 651 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
652 "Missing or null operand, %s\n",
646 acpi_format_exception (status))); 653 acpi_format_exception (status)));
647 return_ACPI_STATUS (status); 654 return_ACPI_STATUS (status);
648 } 655 }
@@ -657,8 +664,8 @@ acpi_ds_create_operand (
657 664
658 /* Initialize the new object */ 665 /* Initialize the new object */
659 666
660 status = acpi_ds_init_object_from_op (walk_state, arg, 667 status = acpi_ds_init_object_from_op (
661 opcode, &obj_desc); 668 walk_state, arg, opcode, &obj_desc);
662 if (ACPI_FAILURE (status)) { 669 if (ACPI_FAILURE (status)) {
663 acpi_ut_delete_object_desc (obj_desc); 670 acpi_ut_delete_object_desc (obj_desc);
664 return_ACPI_STATUS (status); 671 return_ACPI_STATUS (status);
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
index 2071a0d2bbbb..10f71318e23b 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/dispatcher/dswexec.c
@@ -73,11 +73,13 @@ static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch [] = {
73 acpi_ex_opcode_3A_1T_1R, 73 acpi_ex_opcode_3A_1T_1R,
74 acpi_ex_opcode_6A_0T_1R}; 74 acpi_ex_opcode_6A_0T_1R};
75 75
76
76/***************************************************************************** 77/*****************************************************************************
77 * 78 *
78 * FUNCTION: acpi_ds_get_predicate_value 79 * FUNCTION: acpi_ds_get_predicate_value
79 * 80 *
80 * PARAMETERS: walk_state - Current state of the parse tree walk 81 * PARAMETERS: walk_state - Current state of the parse tree walk
82 * result_obj - if non-zero, pop result from result stack
81 * 83 *
82 * RETURN: Status 84 * RETURN: Status
83 * 85 *
@@ -124,7 +126,8 @@ acpi_ds_get_predicate_value (
124 } 126 }
125 127
126 if (!obj_desc) { 128 if (!obj_desc) {
127 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No predicate obj_desc=%p State=%p\n", 129 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
130 "No predicate obj_desc=%p State=%p\n",
128 obj_desc, walk_state)); 131 obj_desc, walk_state));
129 132
130 return_ACPI_STATUS (AE_AML_NO_OPERAND); 133 return_ACPI_STATUS (AE_AML_NO_OPERAND);
@@ -197,7 +200,7 @@ cleanup:
197 * FUNCTION: acpi_ds_exec_begin_op 200 * FUNCTION: acpi_ds_exec_begin_op
198 * 201 *
199 * PARAMETERS: walk_state - Current state of the parse tree walk 202 * PARAMETERS: walk_state - Current state of the parse tree walk
200 * out_op - Return op if a new one is created 203 * out_op - Where to return op if a new one is created
201 * 204 *
202 * RETURN: Status 205 * RETURN: Status
203 * 206 *
@@ -233,7 +236,8 @@ acpi_ds_exec_begin_op (
233 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 236 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
234 237
235 if (acpi_ns_opens_scope (walk_state->op_info->object_type)) { 238 if (acpi_ns_opens_scope (walk_state->op_info->object_type)) {
236 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", 239 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
240 "(%s) Popping scope for Op %p\n",
237 acpi_ut_get_type_name (walk_state->op_info->object_type), op)); 241 acpi_ut_get_type_name (walk_state->op_info->object_type), op));
238 242
239 status = acpi_ds_scope_stack_pop (walk_state); 243 status = acpi_ds_scope_stack_pop (walk_state);
@@ -297,11 +301,10 @@ acpi_ds_exec_begin_op (
297 301
298 if (walk_state->walk_type == ACPI_WALK_METHOD) { 302 if (walk_state->walk_type == ACPI_WALK_METHOD) {
299 /* 303 /*
300 * Found a named object declaration during method 304 * Found a named object declaration during method execution;
301 * execution; we must enter this object into the 305 * we must enter this object into the namespace. The created
302 * namespace. The created object is temporary and 306 * object is temporary and will be deleted upon completion of
303 * will be deleted upon completion of the execution 307 * the execution of this method.
304 * of this method.
305 */ 308 */
306 status = acpi_ds_load2_begin_op (walk_state, NULL); 309 status = acpi_ds_load2_begin_op (walk_state, NULL);
307 } 310 }
@@ -338,8 +341,6 @@ acpi_ds_exec_begin_op (
338 * FUNCTION: acpi_ds_exec_end_op 341 * FUNCTION: acpi_ds_exec_end_op
339 * 342 *
340 * PARAMETERS: walk_state - Current state of the parse tree walk 343 * PARAMETERS: walk_state - Current state of the parse tree walk
341 * Op - Op that has been just been completed in the
342 * walk; Arguments have now been evaluated.
343 * 344 *
344 * RETURN: Status 345 * RETURN: Status
345 * 346 *
@@ -389,7 +390,7 @@ acpi_ds_exec_end_op (
389 /* Decode the Opcode Class */ 390 /* Decode the Opcode Class */
390 391
391 switch (op_class) { 392 switch (op_class) {
392 case AML_CLASS_ARGUMENT: /* constants, literals, etc. -- do nothing */ 393 case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */
393 break; 394 break;
394 395
395 396
@@ -417,12 +418,12 @@ acpi_ds_exec_end_op (
417 /* Resolve all operands */ 418 /* Resolve all operands */
418 419
419 status = acpi_ex_resolve_operands (walk_state->opcode, 420 status = acpi_ex_resolve_operands (walk_state->opcode,
420 &(walk_state->operands [walk_state->num_operands -1]), 421 &(walk_state->operands [walk_state->num_operands -1]),
421 walk_state); 422 walk_state);
422 if (ACPI_SUCCESS (status)) { 423 if (ACPI_SUCCESS (status)) {
423 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 424 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
424 acpi_ps_get_opcode_name (walk_state->opcode), 425 acpi_ps_get_opcode_name (walk_state->opcode),
425 walk_state->num_operands, "after ex_resolve_operands"); 426 walk_state->num_operands, "after ex_resolve_operands");
426 } 427 }
427 } 428 }
428 429
@@ -506,7 +507,8 @@ acpi_ds_exec_end_op (
506 if ((op->asl.parent) && 507 if ((op->asl.parent) &&
507 ((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP) || 508 ((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP) ||
508 (op->asl.parent->asl.aml_opcode == AML_VAR_PACKAGE_OP))) { 509 (op->asl.parent->asl.aml_opcode == AML_VAR_PACKAGE_OP))) {
509 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method Reference in a Package, Op=%p\n", op)); 510 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
511 "Method Reference in a Package, Op=%p\n", op));
510 op->common.node = (struct acpi_namespace_node *) op->asl.value.arg->asl.node->object; 512 op->common.node = (struct acpi_namespace_node *) op->asl.value.arg->asl.node->object;
511 acpi_ut_add_reference (op->asl.value.arg->asl.node->object); 513 acpi_ut_add_reference (op->asl.value.arg->asl.node->object);
512 return_ACPI_STATUS (AE_OK); 514 return_ACPI_STATUS (AE_OK);
@@ -583,13 +585,15 @@ acpi_ds_exec_end_op (
583 case AML_NAME_OP: 585 case AML_NAME_OP:
584 586
585 /* 587 /*
586 * Put the Node on the object stack (Contains the ACPI Name of 588 * Put the Node on the object stack (Contains the ACPI Name
587 * this object) 589 * of this object)
588 */ 590 */
589 walk_state->operands[0] = (void *) op->common.parent->common.node; 591 walk_state->operands[0] = (void *) op->common.parent->common.node;
590 walk_state->num_operands = 1; 592 walk_state->num_operands = 1;
591 593
592 status = acpi_ds_create_node (walk_state, op->common.parent->common.node, op->common.parent); 594 status = acpi_ds_create_node (walk_state,
595 op->common.parent->common.node,
596 op->common.parent);
593 if (ACPI_FAILURE (status)) { 597 if (ACPI_FAILURE (status)) {
594 break; 598 break;
595 } 599 }
@@ -600,7 +604,7 @@ acpi_ds_exec_end_op (
600 case AML_INT_EVAL_SUBTREE_OP: 604 case AML_INT_EVAL_SUBTREE_OP:
601 605
602 status = acpi_ds_eval_data_object_operands (walk_state, op, 606 status = acpi_ds_eval_data_object_operands (walk_state, op,
603 acpi_ns_get_attached_object (op->common.parent->common.node)); 607 acpi_ns_get_attached_object (op->common.parent->common.node));
604 break; 608 break;
605 609
606 default: 610 default:
@@ -609,7 +613,7 @@ acpi_ds_exec_end_op (
609 break; 613 break;
610 } 614 }
611 615
612 /* Done with this result state (Now that operand stack is built) */ 616 /* Done with result state (Now that operand stack is built) */
613 617
614 status = acpi_ds_result_stack_pop (walk_state); 618 status = acpi_ds_result_stack_pop (walk_state);
615 if (ACPI_FAILURE (status)) { 619 if (ACPI_FAILURE (status)) {
@@ -620,8 +624,7 @@ acpi_ds_exec_end_op (
620 * If a result object was returned from above, push it on the 624 * If a result object was returned from above, push it on the
621 * current result stack 625 * current result stack
622 */ 626 */
623 if (ACPI_SUCCESS (status) && 627 if (walk_state->result_obj) {
624 walk_state->result_obj) {
625 status = acpi_ds_result_push (walk_state->result_obj, walk_state); 628 status = acpi_ds_result_push (walk_state->result_obj, walk_state);
626 } 629 }
627 break; 630 break;
@@ -654,7 +657,8 @@ acpi_ds_exec_end_op (
654 657
655 case AML_TYPE_UNDEFINED: 658 case AML_TYPE_UNDEFINED:
656 659
657 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", op)); 660 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
661 "Undefined opcode type Op=%p\n", op));
658 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 662 return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
659 663
660 664
@@ -709,13 +713,14 @@ cleanup:
709 status = acpi_gbl_exception_handler (status, 713 status = acpi_gbl_exception_handler (status,
710 walk_state->method_node->name.integer, walk_state->opcode, 714 walk_state->method_node->name.integer, walk_state->opcode,
711 walk_state->aml_offset, NULL); 715 walk_state->aml_offset, NULL);
712 acpi_ex_enter_interpreter (); 716 (void) acpi_ex_enter_interpreter ();
713 } 717 }
714 718
715 if (walk_state->result_obj) { 719 if (walk_state->result_obj) {
716 /* Break to debugger to display result */ 720 /* Break to debugger to display result */
717 721
718 ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj, walk_state)); 722 ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj,
723 walk_state));
719 724
720 /* 725 /*
721 * Delete the result op if and only if: 726 * Delete the result op if and only if:
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 06d758679588..1ac197ccfc80 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -79,20 +79,23 @@ acpi_ds_init_callbacks (
79 79
80 switch (pass_number) { 80 switch (pass_number) {
81 case 1: 81 case 1:
82 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; 82 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
83 ACPI_PARSE_DELETE_TREE;
83 walk_state->descending_callback = acpi_ds_load1_begin_op; 84 walk_state->descending_callback = acpi_ds_load1_begin_op;
84 walk_state->ascending_callback = acpi_ds_load1_end_op; 85 walk_state->ascending_callback = acpi_ds_load1_end_op;
85 break; 86 break;
86 87
87 case 2: 88 case 2:
88 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; 89 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
90 ACPI_PARSE_DELETE_TREE;
89 walk_state->descending_callback = acpi_ds_load2_begin_op; 91 walk_state->descending_callback = acpi_ds_load2_begin_op;
90 walk_state->ascending_callback = acpi_ds_load2_end_op; 92 walk_state->ascending_callback = acpi_ds_load2_end_op;
91 break; 93 break;
92 94
93 case 3: 95 case 3:
94#ifndef ACPI_NO_METHOD_EXECUTION 96#ifndef ACPI_NO_METHOD_EXECUTION
95 walk_state->parse_flags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE; 97 walk_state->parse_flags |= ACPI_PARSE_EXECUTE |
98 ACPI_PARSE_DELETE_TREE;
96 walk_state->descending_callback = acpi_ds_exec_begin_op; 99 walk_state->descending_callback = acpi_ds_exec_begin_op;
97 walk_state->ascending_callback = acpi_ds_exec_end_op; 100 walk_state->ascending_callback = acpi_ds_exec_end_op;
98#endif 101#endif
@@ -111,8 +114,7 @@ acpi_ds_init_callbacks (
111 * FUNCTION: acpi_ds_load1_begin_op 114 * FUNCTION: acpi_ds_load1_begin_op
112 * 115 *
113 * PARAMETERS: walk_state - Current state of the parse tree walk 116 * PARAMETERS: walk_state - Current state of the parse tree walk
114 * Op - Op that has been just been reached in the 117 * out_op - Where to return op if a new one is created
115 * walk; Arguments have not been evaluated yet.
116 * 118 *
117 * RETURN: Status 119 * RETURN: Status
118 * 120 *
@@ -146,7 +148,8 @@ acpi_ds_load1_begin_op (
146#if 0 148#if 0
147 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || 149 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
148 (walk_state->op_info->class == AML_CLASS_CONTROL)) { 150 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
149 acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n", walk_state->op_info->name); 151 acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n",
152 walk_state->op_info->name);
150 *out_op = op; 153 *out_op = op;
151 return (AE_CTRL_SKIP); 154 return (AE_CTRL_SKIP);
152 } 155 }
@@ -191,7 +194,8 @@ acpi_ds_load1_begin_op (
191 */ 194 */
192 acpi_dm_add_to_external_list (path); 195 acpi_dm_add_to_external_list (path);
193 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 196 status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
194 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 197 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
198 walk_state, &(node));
195 } 199 }
196#endif 200#endif
197 if (ACPI_FAILURE (status)) { 201 if (ACPI_FAILURE (status)) {
@@ -224,10 +228,12 @@ acpi_ds_load1_begin_op (
224 * Name (DEB, 0) 228 * Name (DEB, 0)
225 * Scope (DEB) { ... } 229 * Scope (DEB) { ... }
226 * 230 *
227 * Note: silently change the type here. On the second pass, we will report a warning 231 * Note: silently change the type here. On the second pass, we will report
232 * a warning
228 */ 233 */
229 234
230 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", 235 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
236 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
231 path, acpi_ut_get_type_name (node->type))); 237 path, acpi_ut_get_type_name (node->type)));
232 238
233 node->type = ACPI_TYPE_ANY; 239 node->type = ACPI_TYPE_ANY;
@@ -238,7 +244,8 @@ acpi_ds_load1_begin_op (
238 244
239 /* All other types are an error */ 245 /* All other types are an error */
240 246
241 ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", 247 ACPI_REPORT_ERROR ((
248 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
242 acpi_ut_get_type_name (node->type), path)); 249 acpi_ut_get_type_name (node->type), path));
243 250
244 return (AE_AML_OPERAND_TYPE); 251 return (AE_AML_OPERAND_TYPE);
@@ -249,7 +256,8 @@ acpi_ds_load1_begin_op (
249 default: 256 default:
250 257
251 /* 258 /*
252 * For all other named opcodes, we will enter the name into the namespace. 259 * For all other named opcodes, we will enter the name into
260 * the namespace.
253 * 261 *
254 * Setup the search flags. 262 * Setup the search flags.
255 * Since we are entering a name into the namespace, we do not want to 263 * Since we are entering a name into the namespace, we do not want to
@@ -279,14 +287,16 @@ acpi_ds_load1_begin_op (
279 acpi_ut_get_type_name (object_type))); 287 acpi_ut_get_type_name (object_type)));
280 } 288 }
281 else { 289 else {
282 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Both Find or Create allowed\n", 290 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
291 "[%s] Both Find or Create allowed\n",
283 acpi_ut_get_type_name (object_type))); 292 acpi_ut_get_type_name (object_type)));
284 } 293 }
285 294
286 /* 295 /*
287 * Enter the named type into the internal namespace. We enter the name 296 * Enter the named type into the internal namespace. We enter the name
288 * as we go downward in the parse tree. Any necessary subobjects that involve 297 * as we go downward in the parse tree. Any necessary subobjects that
289 * arguments to the opcode must be created as we go back up the parse tree later. 298 * involve arguments to the opcode must be created as we go back up the
299 * parse tree later.
290 */ 300 */
291 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 301 status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
292 ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node)); 302 ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node));
@@ -335,8 +345,6 @@ acpi_ds_load1_begin_op (
335 * FUNCTION: acpi_ds_load1_end_op 345 * FUNCTION: acpi_ds_load1_end_op
336 * 346 *
337 * PARAMETERS: walk_state - Current state of the parse tree walk 347 * PARAMETERS: walk_state - Current state of the parse tree walk
338 * Op - Op that has been just been completed in the
339 * walk; Arguments have now been evaluated.
340 * 348 *
341 * RETURN: Status 349 * RETURN: Status
342 * 350 *
@@ -383,7 +391,9 @@ acpi_ds_load1_end_op (
383 391
384 if (op->common.aml_opcode == AML_REGION_OP) { 392 if (op->common.aml_opcode == AML_REGION_OP) {
385 status = acpi_ex_create_region (op->named.data, op->named.length, 393 status = acpi_ex_create_region (op->named.data, op->named.length,
386 (acpi_adr_space_type) ((op->common.value.arg)->common.value.integer), walk_state); 394 (acpi_adr_space_type)
395 ((op->common.value.arg)->common.value.integer),
396 walk_state);
387 if (ACPI_FAILURE (status)) { 397 if (ACPI_FAILURE (status)) {
388 return (status); 398 return (status);
389 } 399 }
@@ -394,7 +404,8 @@ acpi_ds_load1_end_op (
394 /* For Name opcode, get the object type from the argument */ 404 /* For Name opcode, get the object type from the argument */
395 405
396 if (op->common.value.arg) { 406 if (op->common.value.arg) {
397 object_type = (acpi_ps_get_opcode_info ((op->common.value.arg)->common.aml_opcode))->object_type; 407 object_type = (acpi_ps_get_opcode_info (
408 (op->common.value.arg)->common.aml_opcode))->object_type;
398 op->common.node->type = (u8) object_type; 409 op->common.node->type = (u8) object_type;
399 } 410 }
400 } 411 }
@@ -448,8 +459,7 @@ acpi_ds_load1_end_op (
448 * FUNCTION: acpi_ds_load2_begin_op 459 * FUNCTION: acpi_ds_load2_begin_op
449 * 460 *
450 * PARAMETERS: walk_state - Current state of the parse tree walk 461 * PARAMETERS: walk_state - Current state of the parse tree walk
451 * Op - Op that has been just been reached in the 462 * out_op - Wher to return op if a new one is created
452 * walk; Arguments have not been evaluated yet.
453 * 463 *
454 * RETURN: Status 464 * RETURN: Status
455 * 465 *
@@ -478,14 +488,20 @@ acpi_ds_load2_begin_op (
478 if (op) { 488 if (op) {
479 /* We only care about Namespace opcodes here */ 489 /* We only care about Namespace opcodes here */
480 490
481 if ((!(walk_state->op_info->flags & AML_NSOPCODE) && (walk_state->opcode != AML_INT_NAMEPATH_OP)) || 491 if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
492 (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
482 (!(walk_state->op_info->flags & AML_NAMED))) { 493 (!(walk_state->op_info->flags & AML_NAMED))) {
494 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
495 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
496 ACPI_REPORT_WARNING ((
497 "Encountered executable code at module level, [%s]\n",
498 acpi_ps_get_opcode_name (walk_state->opcode)));
499 }
483 return_ACPI_STATUS (AE_OK); 500 return_ACPI_STATUS (AE_OK);
484 } 501 }
485 502
486 /* 503 /* Get the name we are going to enter or lookup in the namespace */
487 * Get the name we are going to enter or lookup in the namespace 504
488 */
489 if (walk_state->opcode == AML_INT_NAMEPATH_OP) { 505 if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
490 /* For Namepath op, get the path string */ 506 /* For Namepath op, get the path string */
491 507
@@ -528,21 +544,25 @@ acpi_ds_load2_begin_op (
528 case AML_INT_NAMEPATH_OP: 544 case AML_INT_NAMEPATH_OP:
529 545
530 /* 546 /*
531 * The name_path is an object reference to an existing object. Don't enter the 547 * The name_path is an object reference to an existing object.
532 * name into the namespace, but look it up for use later 548 * Don't enter the name into the namespace, but look it up
549 * for use later.
533 */ 550 */
534 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 551 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
535 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 552 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
553 walk_state, &(node));
536 break; 554 break;
537 555
538 case AML_SCOPE_OP: 556 case AML_SCOPE_OP:
539 557
540 /* 558 /*
541 * The Path is an object reference to an existing object. Don't enter the 559 * The Path is an object reference to an existing object.
542 * name into the namespace, but look it up for use later 560 * Don't enter the name into the namespace, but look it up
561 * for use later.
543 */ 562 */
544 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 563 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
545 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 564 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
565 walk_state, &(node));
546 if (ACPI_FAILURE (status)) { 566 if (ACPI_FAILURE (status)) {
547#ifdef _ACPI_ASL_COMPILER 567#ifdef _ACPI_ASL_COMPILER
548 if (status == AE_NOT_FOUND) { 568 if (status == AE_NOT_FOUND) {
@@ -582,7 +602,8 @@ acpi_ds_load2_begin_op (
582 * Scope (DEB) { ... } 602 * Scope (DEB) { ... }
583 */ 603 */
584 604
585 ACPI_REPORT_WARNING (("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", 605 ACPI_REPORT_WARNING ((
606 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
586 buffer_ptr, acpi_ut_get_type_name (node->type))); 607 buffer_ptr, acpi_ut_get_type_name (node->type)));
587 608
588 node->type = ACPI_TYPE_ANY; 609 node->type = ACPI_TYPE_ANY;
@@ -593,7 +614,8 @@ acpi_ds_load2_begin_op (
593 614
594 /* All other types are an error */ 615 /* All other types are an error */
595 616
596 ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s]\n", 617 ACPI_REPORT_ERROR ((
618 "Invalid type (%s) for target of Scope operator [%4.4s]\n",
597 acpi_ut_get_type_name (node->type), buffer_ptr)); 619 acpi_ut_get_type_name (node->type), buffer_ptr));
598 620
599 return (AE_AML_OPERAND_TYPE); 621 return (AE_AML_OPERAND_TYPE);
@@ -621,8 +643,9 @@ acpi_ds_load2_begin_op (
621 643
622 /* 644 /*
623 * Enter the named type into the internal namespace. We enter the name 645 * Enter the named type into the internal namespace. We enter the name
624 * as we go downward in the parse tree. Any necessary subobjects that involve 646 * as we go downward in the parse tree. Any necessary subobjects that
625 * arguments to the opcode must be created as we go back up the parse tree later. 647 * involve arguments to the opcode must be created as we go back up the
648 * parse tree later.
626 * 649 *
627 * Note: Name may already exist if we are executing a deferred opcode. 650 * Note: Name may already exist if we are executing a deferred opcode.
628 */ 651 */
@@ -635,7 +658,8 @@ acpi_ds_load2_begin_op (
635 } 658 }
636 659
637 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 660 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
638 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, walk_state, &(node)); 661 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH,
662 walk_state, &(node));
639 break; 663 break;
640 } 664 }
641 665
@@ -678,8 +702,6 @@ acpi_ds_load2_begin_op (
678 * FUNCTION: acpi_ds_load2_end_op 702 * FUNCTION: acpi_ds_load2_end_op
679 * 703 *
680 * PARAMETERS: walk_state - Current state of the parse tree walk 704 * PARAMETERS: walk_state - Current state of the parse tree walk
681 * Op - Op that has been just been completed in the
682 * walk; Arguments have now been evaluated.
683 * 705 *
684 * RETURN: Status 706 * RETURN: Status
685 * 707 *
@@ -738,7 +760,8 @@ acpi_ds_load2_end_op (
738 760
739 /* Pop the scope stack */ 761 /* Pop the scope stack */
740 762
741 if (acpi_ns_opens_scope (object_type) && (op->common.aml_opcode != AML_INT_METHODCALL_OP)) { 763 if (acpi_ns_opens_scope (object_type) &&
764 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
742 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", 765 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
743 acpi_ut_get_type_name (object_type), op)); 766 acpi_ut_get_type_name (object_type), op));
744 767
@@ -803,7 +826,7 @@ acpi_ds_load2_end_op (
803 case AML_INDEX_FIELD_OP: 826 case AML_INDEX_FIELD_OP:
804 827
805 status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node, 828 status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node,
806 walk_state); 829 walk_state);
807 break; 830 break;
808 831
809 case AML_BANK_FIELD_OP: 832 case AML_BANK_FIELD_OP:
@@ -884,14 +907,16 @@ acpi_ds_load2_end_op (
884#ifndef ACPI_NO_METHOD_EXECUTION 907#ifndef ACPI_NO_METHOD_EXECUTION
885 case AML_REGION_OP: 908 case AML_REGION_OP:
886 /* 909 /*
887 * The op_region is not fully parsed at this time. Only valid argument is the space_id. 910 * The op_region is not fully parsed at this time. Only valid
888 * (We must save the address of the AML of the address and length operands) 911 * argument is the space_id. (We must save the address of the
912 * AML of the address and length operands)
889 */ 913 */
890 /* 914 /*
891 * If we have a valid region, initialize it 915 * If we have a valid region, initialize it
892 * Namespace is NOT locked at this point. 916 * Namespace is NOT locked at this point.
893 */ 917 */
894 status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node), FALSE); 918 status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node),
919 FALSE);
895 if (ACPI_FAILURE (status)) { 920 if (ACPI_FAILURE (status)) {
896 /* 921 /*
897 * If AE_NOT_EXIST is returned, it is not fatal 922 * If AE_NOT_EXIST is returned, it is not fatal
@@ -942,15 +967,16 @@ acpi_ds_load2_end_op (
942 if (ACPI_SUCCESS (status)) { 967 if (ACPI_SUCCESS (status)) {
943 /* 968 /*
944 * Make sure that what we found is indeed a method 969 * Make sure that what we found is indeed a method
945 * We didn't search for a method on purpose, to see if the name would resolve 970 * We didn't search for a method on purpose, to see if the name
971 * would resolve
946 */ 972 */
947 if (new_node->type != ACPI_TYPE_METHOD) { 973 if (new_node->type != ACPI_TYPE_METHOD) {
948 status = AE_AML_OPERAND_TYPE; 974 status = AE_AML_OPERAND_TYPE;
949 } 975 }
950 976
951 /* We could put the returned object (Node) on the object stack for later, but 977 /* We could put the returned object (Node) on the object stack for
952 * for now, we will put it in the "op" object that the parser uses, so we 978 * later, but for now, we will put it in the "op" object that the
953 * can get it again at the end of this scope 979 * parser uses, so we can get it again at the end of this scope
954 */ 980 */
955 op->common.node = new_node; 981 op->common.node = new_node;
956 } 982 }
diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c
index 65f456151e25..21f4548ff323 100644
--- a/drivers/acpi/dispatcher/dswscope.c
+++ b/drivers/acpi/dispatcher/dswscope.c
@@ -50,14 +50,13 @@
50 ACPI_MODULE_NAME ("dswscope") 50 ACPI_MODULE_NAME ("dswscope")
51 51
52 52
53#define STACK_POP(head) head
54
55
56/**************************************************************************** 53/****************************************************************************
57 * 54 *
58 * FUNCTION: acpi_ds_scope_stack_clear 55 * FUNCTION: acpi_ds_scope_stack_clear
59 * 56 *
60 * PARAMETERS: None 57 * PARAMETERS: walk_state - Current state
58 *
59 * RETURN: None
61 * 60 *
62 * DESCRIPTION: Pop (and free) everything on the scope stack except the 61 * DESCRIPTION: Pop (and free) everything on the scope stack except the
63 * root scope object (which remains at the stack top.) 62 * root scope object (which remains at the stack top.)
@@ -80,7 +79,8 @@ acpi_ds_scope_stack_clear (
80 walk_state->scope_info = scope_info->scope.next; 79 walk_state->scope_info = scope_info->scope.next;
81 80
82 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 81 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
83 "Popped object type (%s)\n", acpi_ut_get_type_name (scope_info->common.value))); 82 "Popped object type (%s)\n",
83 acpi_ut_get_type_name (scope_info->common.value)));
84 acpi_ut_delete_generic_state (scope_info); 84 acpi_ut_delete_generic_state (scope_info);
85 } 85 }
86} 86}
@@ -90,8 +90,11 @@ acpi_ds_scope_stack_clear (
90 * 90 *
91 * FUNCTION: acpi_ds_scope_stack_push 91 * FUNCTION: acpi_ds_scope_stack_push
92 * 92 *
93 * PARAMETERS: *Node, - Name to be made current 93 * PARAMETERS: Node - Name to be made current
94 * Type, - Type of frame being pushed 94 * Type - Type of frame being pushed
95 * walk_state - Current state
96 *
97 * RETURN: Status
95 * 98 *
96 * DESCRIPTION: Push the current scope on the scope stack, and make the 99 * DESCRIPTION: Push the current scope on the scope stack, and make the
97 * passed Node current. 100 * passed Node current.
@@ -121,7 +124,8 @@ acpi_ds_scope_stack_push (
121 /* Make sure object type is valid */ 124 /* Make sure object type is valid */
122 125
123 if (!acpi_ut_valid_object_type (type)) { 126 if (!acpi_ut_valid_object_type (type)) {
124 ACPI_REPORT_WARNING (("ds_scope_stack_push: Invalid object type: 0x%X\n", type)); 127 ACPI_REPORT_WARNING ((
128 "ds_scope_stack_push: Invalid object type: 0x%X\n", type));
125 } 129 }
126 130
127 /* Allocate a new scope object */ 131 /* Allocate a new scope object */
@@ -170,16 +174,11 @@ acpi_ds_scope_stack_push (
170 * 174 *
171 * FUNCTION: acpi_ds_scope_stack_pop 175 * FUNCTION: acpi_ds_scope_stack_pop
172 * 176 *
173 * PARAMETERS: Type - The type of frame to be found 177 * PARAMETERS: walk_state - Current state
174 * 178 *
175 * DESCRIPTION: Pop the scope stack until a frame of the requested type 179 * RETURN: Status
176 * is found.
177 * 180 *
178 * RETURN: Count of frames popped. If no frame of the requested type 181 * DESCRIPTION: Pop the scope stack once.
179 * was found, the count is returned as a negative number and
180 * the scope stack is emptied (which sets the current scope
181 * to the root). If the scope stack was empty at entry, the
182 * function is a no-op and returns 0.
183 * 182 *
184 ***************************************************************************/ 183 ***************************************************************************/
185 184
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c
index e555b3fbd5e5..9cd3db652b31 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/dispatcher/dswstate.c
@@ -50,67 +50,31 @@
50#define _COMPONENT ACPI_DISPATCHER 50#define _COMPONENT ACPI_DISPATCHER
51 ACPI_MODULE_NAME ("dswstate") 51 ACPI_MODULE_NAME ("dswstate")
52 52
53/* Local prototypes */
53 54
54#ifdef ACPI_FUTURE_USAGE 55#ifdef ACPI_OBSOLETE_FUNCTIONS
55
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_ds_result_insert
59 *
60 * PARAMETERS: Object - Object to push
61 * Index - Where to insert the object
62 * walk_state - Current Walk state
63 *
64 * RETURN: Status
65 *
66 * DESCRIPTION: Insert an object onto this walk's result stack
67 *
68 ******************************************************************************/
69
70acpi_status 56acpi_status
71acpi_ds_result_insert ( 57acpi_ds_result_insert (
72 void *object, 58 void *object,
73 u32 index, 59 u32 index,
74 struct acpi_walk_state *walk_state) 60 struct acpi_walk_state *walk_state);
75{
76 union acpi_generic_state *state;
77
78 61
79 ACPI_FUNCTION_NAME ("ds_result_insert"); 62acpi_status
80 63acpi_ds_obj_stack_delete_all (
81 64 struct acpi_walk_state *walk_state);
82 state = walk_state->results;
83 if (!state) {
84 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
85 walk_state));
86 return (AE_NOT_EXIST);
87 }
88
89 if (index >= ACPI_OBJ_NUM_OPERANDS) {
90 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
91 "Index out of range: %X Obj=%p State=%p Num=%X\n",
92 index, object, walk_state, state->results.num_results));
93 return (AE_BAD_PARAMETER);
94 }
95
96 if (!object) {
97 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
98 "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
99 index, object, walk_state, state->results.num_results));
100 return (AE_BAD_PARAMETER);
101 }
102
103 state->results.obj_desc [index] = object;
104 state->results.num_results++;
105 65
106 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 66acpi_status
107 "Obj=%p [%s] State=%p Num=%X Cur=%X\n", 67acpi_ds_obj_stack_pop_object (
108 object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL", 68 union acpi_operand_object **object,
109 walk_state, state->results.num_results, walk_state->current_result)); 69 struct acpi_walk_state *walk_state);
110 70
111 return (AE_OK); 71void *
112} 72acpi_ds_obj_stack_get_value (
73 u32 index,
74 struct acpi_walk_state *walk_state);
75#endif
113 76
77#ifdef ACPI_FUTURE_USAGE
114 78
115/******************************************************************************* 79/*******************************************************************************
116 * 80 *
@@ -178,7 +142,6 @@ acpi_ds_result_remove (
178 142
179#endif /* ACPI_FUTURE_USAGE */ 143#endif /* ACPI_FUTURE_USAGE */
180 144
181
182/******************************************************************************* 145/*******************************************************************************
183 * 146 *
184 * FUNCTION: acpi_ds_result_pop 147 * FUNCTION: acpi_ds_result_pop
@@ -227,15 +190,18 @@ acpi_ds_result_pop (
227 *object = state->results.obj_desc [index -1]; 190 *object = state->results.obj_desc [index -1];
228 state->results.obj_desc [index -1] = NULL; 191 state->results.obj_desc [index -1] = NULL;
229 192
230 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n", 193 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
231 *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", 194 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
195 *object,
196 (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
232 (u32) index -1, walk_state, state->results.num_results)); 197 (u32) index -1, walk_state, state->results.num_results));
233 198
234 return (AE_OK); 199 return (AE_OK);
235 } 200 }
236 } 201 }
237 202
238 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", walk_state)); 203 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
204 "No result objects! State=%p\n", walk_state));
239 return (AE_AML_NO_RETURN_VALUE); 205 return (AE_AML_NO_RETURN_VALUE);
240} 206}
241 207
@@ -274,7 +240,8 @@ acpi_ds_result_pop_from_bottom (
274 } 240 }
275 241
276 if (!state->results.num_results) { 242 if (!state->results.num_results) {
277 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", walk_state)); 243 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n",
244 walk_state));
278 return (AE_AML_NO_RETURN_VALUE); 245 return (AE_AML_NO_RETURN_VALUE);
279 } 246 }
280 247
@@ -293,7 +260,8 @@ acpi_ds_result_pop_from_bottom (
293 /* Check for a valid result object */ 260 /* Check for a valid result object */
294 261
295 if (!*object) { 262 if (!*object) {
296 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n", 263 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
264 "Null operand! State=%p #Ops=%X, Index=%X\n",
297 walk_state, state->results.num_results, (u32) index)); 265 walk_state, state->results.num_results, (u32) index));
298 return (AE_AML_NO_RETURN_VALUE); 266 return (AE_AML_NO_RETURN_VALUE);
299 } 267 }
@@ -344,7 +312,8 @@ acpi_ds_result_push (
344 } 312 }
345 313
346 if (!object) { 314 if (!object) {
347 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n", 315 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
316 "Null Object! Obj=%p State=%p Num=%X\n",
348 object, walk_state, state->results.num_results)); 317 object, walk_state, state->results.num_results));
349 return (AE_BAD_PARAMETER); 318 return (AE_BAD_PARAMETER);
350 } 319 }
@@ -439,43 +408,6 @@ acpi_ds_result_stack_pop (
439 408
440/******************************************************************************* 409/*******************************************************************************
441 * 410 *
442 * FUNCTION: acpi_ds_obj_stack_delete_all
443 *
444 * PARAMETERS: walk_state - Current Walk state
445 *
446 * RETURN: Status
447 *
448 * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
449 * Should be used with great care, if at all!
450 *
451 ******************************************************************************/
452#ifdef ACPI_FUTURE_USAGE
453acpi_status
454acpi_ds_obj_stack_delete_all (
455 struct acpi_walk_state *walk_state)
456{
457 u32 i;
458
459
460 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state);
461
462
463 /* The stack size is configurable, but fixed */
464
465 for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
466 if (walk_state->operands[i]) {
467 acpi_ut_remove_reference (walk_state->operands[i]);
468 walk_state->operands[i] = NULL;
469 }
470 }
471
472 return_ACPI_STATUS (AE_OK);
473}
474#endif /* ACPI_FUTURE_USAGE */
475
476
477/*******************************************************************************
478 *
479 * FUNCTION: acpi_ds_obj_stack_push 411 * FUNCTION: acpi_ds_obj_stack_push
480 * 412 *
481 * PARAMETERS: Object - Object to push 413 * PARAMETERS: Object - Object to push
@@ -517,67 +449,6 @@ acpi_ds_obj_stack_push (
517} 449}
518 450
519 451
520#if 0
521/*******************************************************************************
522 *
523 * FUNCTION: acpi_ds_obj_stack_pop_object
524 *
525 * PARAMETERS: pop_count - Number of objects/entries to pop
526 * walk_state - Current Walk state
527 *
528 * RETURN: Status
529 *
530 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
531 * deleted by this routine.
532 *
533 ******************************************************************************/
534
535acpi_status
536acpi_ds_obj_stack_pop_object (
537 union acpi_operand_object **object,
538 struct acpi_walk_state *walk_state)
539{
540 ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object");
541
542
543 /* Check for stack underflow */
544
545 if (walk_state->num_operands == 0) {
546 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
547 "Missing operand/stack empty! State=%p #Ops=%X\n",
548 walk_state, walk_state->num_operands));
549 *object = NULL;
550 return (AE_AML_NO_OPERAND);
551 }
552
553 /* Pop the stack */
554
555 walk_state->num_operands--;
556
557 /* Check for a valid operand */
558
559 if (!walk_state->operands [walk_state->num_operands]) {
560 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
561 "Null operand! State=%p #Ops=%X\n",
562 walk_state, walk_state->num_operands));
563 *object = NULL;
564 return (AE_AML_NO_OPERAND);
565 }
566
567 /* Get operand and set stack entry to null */
568
569 *object = walk_state->operands [walk_state->num_operands];
570 walk_state->operands [walk_state->num_operands] = NULL;
571
572 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
573 *object, acpi_ut_get_object_type_name (*object),
574 walk_state, walk_state->num_operands));
575
576 return (AE_OK);
577}
578#endif
579
580
581/******************************************************************************* 452/*******************************************************************************
582 * 453 *
583 * FUNCTION: acpi_ds_obj_stack_pop 454 * FUNCTION: acpi_ds_obj_stack_pop
@@ -680,48 +551,6 @@ acpi_ds_obj_stack_pop_and_delete (
680 551
681/******************************************************************************* 552/*******************************************************************************
682 * 553 *
683 * FUNCTION: acpi_ds_obj_stack_get_value
684 *
685 * PARAMETERS: Index - Stack index whose value is desired. Based
686 * on the top of the stack (index=0 == top)
687 * walk_state - Current Walk state
688 *
689 * RETURN: Status
690 *
691 * DESCRIPTION: Retrieve an object from this walk's object stack. Index must
692 * be within the range of the current stack pointer.
693 *
694 ******************************************************************************/
695#ifdef ACPI_FUTURE_USAGE
696void *
697acpi_ds_obj_stack_get_value (
698 u32 index,
699 struct acpi_walk_state *walk_state)
700{
701
702 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state);
703
704
705 /* Can't do it if the stack is empty */
706
707 if (walk_state->num_operands == 0) {
708 return_PTR (NULL);
709 }
710
711 /* or if the index is past the top of the stack */
712
713 if (index > (walk_state->num_operands - (u32) 1)) {
714 return_PTR (NULL);
715 }
716
717 return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) -
718 index]);
719}
720#endif /* ACPI_FUTURE_USAGE */
721
722
723/*******************************************************************************
724 *
725 * FUNCTION: acpi_ds_get_current_walk_state 554 * FUNCTION: acpi_ds_get_current_walk_state
726 * 555 *
727 * PARAMETERS: Thread - Get current active state for this Thread 556 * PARAMETERS: Thread - Get current active state for this Thread
@@ -757,11 +586,11 @@ acpi_ds_get_current_walk_state (
757 * FUNCTION: acpi_ds_push_walk_state 586 * FUNCTION: acpi_ds_push_walk_state
758 * 587 *
759 * PARAMETERS: walk_state - State to push 588 * PARAMETERS: walk_state - State to push
760 * walk_list - The list that owns the walk stack 589 * Thread - Thread state object
761 * 590 *
762 * RETURN: None 591 * RETURN: None
763 * 592 *
764 * DESCRIPTION: Place the walk_state at the head of the state list. 593 * DESCRIPTION: Place the Thread state at the head of the state list.
765 * 594 *
766 ******************************************************************************/ 595 ******************************************************************************/
767 596
@@ -784,9 +613,9 @@ acpi_ds_push_walk_state (
784 * 613 *
785 * FUNCTION: acpi_ds_pop_walk_state 614 * FUNCTION: acpi_ds_pop_walk_state
786 * 615 *
787 * PARAMETERS: walk_list - The list that owns the walk stack 616 * PARAMETERS: Thread - Current thread state
788 * 617 *
789 * RETURN: A walk_state object popped from the stack 618 * RETURN: A walk_state object popped from the thread's stack
790 * 619 *
791 * DESCRIPTION: Remove and return the walkstate object that is at the head of 620 * DESCRIPTION: Remove and return the walkstate object that is at the head of
792 * the walk stack for the given walk list. NULL indicates that 621 * the walk stack for the given walk list. NULL indicates that
@@ -814,7 +643,7 @@ acpi_ds_pop_walk_state (
814 /* 643 /*
815 * Don't clear the NEXT field, this serves as an indicator 644 * Don't clear the NEXT field, this serves as an indicator
816 * that there is a parent WALK STATE 645 * that there is a parent WALK STATE
817 * NO: walk_state->Next = NULL; 646 * Do Not: walk_state->Next = NULL;
818 */ 647 */
819 } 648 }
820 649
@@ -826,7 +655,9 @@ acpi_ds_pop_walk_state (
826 * 655 *
827 * FUNCTION: acpi_ds_create_walk_state 656 * FUNCTION: acpi_ds_create_walk_state
828 * 657 *
829 * PARAMETERS: Origin - Starting point for this walk 658 * PARAMETERS: owner_id - ID for object creation
659 * Origin - Starting point for this walk
660 * mth_desc - Method object
830 * Thread - Current thread state 661 * Thread - Current thread state
831 * 662 *
832 * RETURN: Pointer to the new walk state. 663 * RETURN: Pointer to the new walk state.
@@ -896,8 +727,7 @@ acpi_ds_create_walk_state (
896 * method_node - Control method NS node, if any 727 * method_node - Control method NS node, if any
897 * aml_start - Start of AML 728 * aml_start - Start of AML
898 * aml_length - Length of AML 729 * aml_length - Length of AML
899 * Params - Method args, if any 730 * Info - Method info block (params, etc.)
900 * return_obj_desc - Where to store a return object, if any
901 * pass_number - 1, 2, or 3 731 * pass_number - 1, 2, or 3
902 * 732 *
903 * RETURN: Status 733 * RETURN: Status
@@ -931,7 +761,7 @@ acpi_ds_init_aml_walk (
931 761
932 /* The next_op of the next_walk will be the beginning of the method */ 762 /* The next_op of the next_walk will be the beginning of the method */
933 763
934 walk_state->next_op = NULL; 764 walk_state->next_op = NULL;
935 765
936 if (info) { 766 if (info) {
937 if (info->parameter_type == ACPI_PARAM_GPE) { 767 if (info->parameter_type == ACPI_PARAM_GPE) {
@@ -939,8 +769,8 @@ acpi_ds_init_aml_walk (
939 info->parameters); 769 info->parameters);
940 } 770 }
941 else { 771 else {
942 walk_state->params = info->parameters; 772 walk_state->params = info->parameters;
943 walk_state->caller_return_desc = &info->return_object; 773 walk_state->caller_return_desc = &info->return_object;
944 } 774 }
945 } 775 }
946 776
@@ -964,7 +794,8 @@ acpi_ds_init_aml_walk (
964 794
965 /* Init the method arguments */ 795 /* Init the method arguments */
966 796
967 status = acpi_ds_method_data_init_args (walk_state->params, ACPI_METHOD_NUM_ARGS, walk_state); 797 status = acpi_ds_method_data_init_args (walk_state->params,
798 ACPI_METHOD_NUM_ARGS, walk_state);
968 if (ACPI_FAILURE (status)) { 799 if (ACPI_FAILURE (status)) {
969 return_ACPI_STATUS (status); 800 return_ACPI_STATUS (status);
970 } 801 }
@@ -1031,12 +862,14 @@ acpi_ds_delete_walk_state (
1031 } 862 }
1032 863
1033 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { 864 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
1034 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", walk_state)); 865 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n",
866 walk_state));
1035 return; 867 return;
1036 } 868 }
1037 869
1038 if (walk_state->parser_state.scope) { 870 if (walk_state->parser_state.scope) {
1039 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", walk_state)); 871 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n",
872 walk_state));
1040 } 873 }
1041 874
1042 /* Always must free any linked control states */ 875 /* Always must free any linked control states */
@@ -1078,7 +911,7 @@ acpi_ds_delete_walk_state (
1078 * 911 *
1079 * PARAMETERS: None 912 * PARAMETERS: None
1080 * 913 *
1081 * RETURN: Status 914 * RETURN: None
1082 * 915 *
1083 * DESCRIPTION: Purge the global state object cache. Used during subsystem 916 * DESCRIPTION: Purge the global state object cache. Used during subsystem
1084 * termination. 917 * termination.
@@ -1098,3 +931,200 @@ acpi_ds_delete_walk_state_cache (
1098#endif 931#endif
1099 932
1100 933
934#ifdef ACPI_OBSOLETE_FUNCTIONS
935/*******************************************************************************
936 *
937 * FUNCTION: acpi_ds_result_insert
938 *
939 * PARAMETERS: Object - Object to push
940 * Index - Where to insert the object
941 * walk_state - Current Walk state
942 *
943 * RETURN: Status
944 *
945 * DESCRIPTION: Insert an object onto this walk's result stack
946 *
947 ******************************************************************************/
948
949acpi_status
950acpi_ds_result_insert (
951 void *object,
952 u32 index,
953 struct acpi_walk_state *walk_state)
954{
955 union acpi_generic_state *state;
956
957
958 ACPI_FUNCTION_NAME ("ds_result_insert");
959
960
961 state = walk_state->results;
962 if (!state) {
963 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
964 walk_state));
965 return (AE_NOT_EXIST);
966 }
967
968 if (index >= ACPI_OBJ_NUM_OPERANDS) {
969 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
970 "Index out of range: %X Obj=%p State=%p Num=%X\n",
971 index, object, walk_state, state->results.num_results));
972 return (AE_BAD_PARAMETER);
973 }
974
975 if (!object) {
976 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
977 "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
978 index, object, walk_state, state->results.num_results));
979 return (AE_BAD_PARAMETER);
980 }
981
982 state->results.obj_desc [index] = object;
983 state->results.num_results++;
984
985 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
986 "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
987 object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL",
988 walk_state, state->results.num_results, walk_state->current_result));
989
990 return (AE_OK);
991}
992
993
994/*******************************************************************************
995 *
996 * FUNCTION: acpi_ds_obj_stack_delete_all
997 *
998 * PARAMETERS: walk_state - Current Walk state
999 *
1000 * RETURN: Status
1001 *
1002 * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
1003 * Should be used with great care, if at all!
1004 *
1005 ******************************************************************************/
1006
1007acpi_status
1008acpi_ds_obj_stack_delete_all (
1009 struct acpi_walk_state *walk_state)
1010{
1011 u32 i;
1012
1013
1014 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state);
1015
1016
1017 /* The stack size is configurable, but fixed */
1018
1019 for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
1020 if (walk_state->operands[i]) {
1021 acpi_ut_remove_reference (walk_state->operands[i]);
1022 walk_state->operands[i] = NULL;
1023 }
1024 }
1025
1026 return_ACPI_STATUS (AE_OK);
1027}
1028
1029
1030/*******************************************************************************
1031 *
1032 * FUNCTION: acpi_ds_obj_stack_pop_object
1033 *
1034 * PARAMETERS: Object - Where to return the popped object
1035 * walk_state - Current Walk state
1036 *
1037 * RETURN: Status
1038 *
1039 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
1040 * deleted by this routine.
1041 *
1042 ******************************************************************************/
1043
1044acpi_status
1045acpi_ds_obj_stack_pop_object (
1046 union acpi_operand_object **object,
1047 struct acpi_walk_state *walk_state)
1048{
1049 ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object");
1050
1051
1052 /* Check for stack underflow */
1053
1054 if (walk_state->num_operands == 0) {
1055 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
1056 "Missing operand/stack empty! State=%p #Ops=%X\n",
1057 walk_state, walk_state->num_operands));
1058 *object = NULL;
1059 return (AE_AML_NO_OPERAND);
1060 }
1061
1062 /* Pop the stack */
1063
1064 walk_state->num_operands--;
1065
1066 /* Check for a valid operand */
1067
1068 if (!walk_state->operands [walk_state->num_operands]) {
1069 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
1070 "Null operand! State=%p #Ops=%X\n",
1071 walk_state, walk_state->num_operands));
1072 *object = NULL;
1073 return (AE_AML_NO_OPERAND);
1074 }
1075
1076 /* Get operand and set stack entry to null */
1077
1078 *object = walk_state->operands [walk_state->num_operands];
1079 walk_state->operands [walk_state->num_operands] = NULL;
1080
1081 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
1082 *object, acpi_ut_get_object_type_name (*object),
1083 walk_state, walk_state->num_operands));
1084
1085 return (AE_OK);
1086}
1087
1088
1089/*******************************************************************************
1090 *
1091 * FUNCTION: acpi_ds_obj_stack_get_value
1092 *
1093 * PARAMETERS: Index - Stack index whose value is desired. Based
1094 * on the top of the stack (index=0 == top)
1095 * walk_state - Current Walk state
1096 *
1097 * RETURN: Pointer to the requested operand
1098 *
1099 * DESCRIPTION: Retrieve an object from this walk's operand stack. Index must
1100 * be within the range of the current stack pointer.
1101 *
1102 ******************************************************************************/
1103
1104void *
1105acpi_ds_obj_stack_get_value (
1106 u32 index,
1107 struct acpi_walk_state *walk_state)
1108{
1109
1110 ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state);
1111
1112
1113 /* Can't do it if the stack is empty */
1114
1115 if (walk_state->num_operands == 0) {
1116 return_PTR (NULL);
1117 }
1118
1119 /* or if the index is past the top of the stack */
1120
1121 if (index > (walk_state->num_operands - (u32) 1)) {
1122 return_PTR (NULL);
1123 }
1124
1125 return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) -
1126 index]);
1127}
1128#endif
1129
1130
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index fdf143b405be..8e665f2e3138 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -31,6 +31,7 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/proc_fs.h> 32#include <linux/proc_fs.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34#include <linux/interrupt.h>
34#include <asm/io.h> 35#include <asm/io.h>
35#include <acpi/acpi_bus.h> 36#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h> 37#include <acpi/acpi_drivers.h>
@@ -49,17 +50,19 @@ ACPI_MODULE_NAME ("acpi_ec")
49 50
50#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ 51#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
51#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ 52#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
53#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
52#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ 54#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
53 55
54#define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */ 56#define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */
55#define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */ 57#define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */
56 58
57#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ 59#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
58#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
59#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ 60#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
60 61
61#define ACPI_EC_COMMAND_READ 0x80 62#define ACPI_EC_COMMAND_READ 0x80
62#define ACPI_EC_COMMAND_WRITE 0x81 63#define ACPI_EC_COMMAND_WRITE 0x81
64#define ACPI_EC_BURST_ENABLE 0x82
65#define ACPI_EC_BURST_DISABLE 0x83
63#define ACPI_EC_COMMAND_QUERY 0x84 66#define ACPI_EC_COMMAND_QUERY 0x84
64 67
65static int acpi_ec_add (struct acpi_device *device); 68static int acpi_ec_add (struct acpi_device *device);
@@ -87,7 +90,11 @@ struct acpi_ec {
87 struct acpi_generic_address command_addr; 90 struct acpi_generic_address command_addr;
88 struct acpi_generic_address data_addr; 91 struct acpi_generic_address data_addr;
89 unsigned long global_lock; 92 unsigned long global_lock;
90 spinlock_t lock; 93 unsigned int expect_event;
94 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/
95 atomic_t pending_gpe;
96 struct semaphore sem;
97 wait_queue_head_t wait;
91}; 98};
92 99
93/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 100/* If we find an EC via the ECDT, we need to keep a ptr to its context */
@@ -100,42 +107,122 @@ static struct acpi_device *first_ec;
100 Transaction Management 107 Transaction Management
101 -------------------------------------------------------------------------- */ 108 -------------------------------------------------------------------------- */
102 109
103static int 110static inline u32 acpi_ec_read_status(struct acpi_ec *ec)
104acpi_ec_wait (
105 struct acpi_ec *ec,
106 u8 event)
107{ 111{
108 u32 acpi_ec_status = 0; 112 u32 status = 0;
109 u32 i = ACPI_EC_UDELAY_COUNT;
110 113
111 if (!ec) 114 acpi_hw_low_level_read(8, &status, &ec->status_addr);
112 return -EINVAL; 115 return status;
116}
117
118static int acpi_ec_wait(struct acpi_ec *ec, unsigned int event)
119{
120 int result = 0;
121
122 ACPI_FUNCTION_TRACE("acpi_ec_wait");
113 123
114 /* Poll the EC status register waiting for the event to occur. */ 124 ec->expect_event = event;
125 smp_mb();
126
127 result = wait_event_interruptible_timeout(ec->wait,
128 !ec->expect_event,
129 msecs_to_jiffies(ACPI_EC_DELAY));
130
131 ec->expect_event = 0;
132 smp_mb();
133
134 if (result < 0){
135 ACPI_DEBUG_PRINT((ACPI_DB_ERROR," result = %d ", result));
136 return_VALUE(result);
137 }
138
139 /*
140 * Verify that the event in question has actually happened by
141 * querying EC status. Do the check even if operation timed-out
142 * to make sure that we did not miss interrupt.
143 */
115 switch (event) { 144 switch (event) {
116 case ACPI_EC_EVENT_OBF: 145 case ACPI_EC_EVENT_OBF:
117 do { 146 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
118 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->status_addr); 147 return_VALUE(0);
119 if (acpi_ec_status & ACPI_EC_FLAG_OBF)
120 return 0;
121 udelay(ACPI_EC_UDELAY);
122 } while (--i>0);
123 break; 148 break;
149
124 case ACPI_EC_EVENT_IBE: 150 case ACPI_EC_EVENT_IBE:
125 do { 151 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
126 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->status_addr); 152 return_VALUE(0);
127 if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
128 return 0;
129 udelay(ACPI_EC_UDELAY);
130 } while (--i>0);
131 break; 153 break;
132 default:
133 return -EINVAL;
134 } 154 }
135 155
136 return -ETIME; 156 return_VALUE(-ETIME);
157}
158
159
160
161static int
162acpi_ec_enter_burst_mode (
163 struct acpi_ec *ec)
164{
165 u32 tmp = 0;
166 int status = 0;
167
168 ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode");
169
170 status = acpi_ec_read_status(ec);
171 if (status != -EINVAL &&
172 !(status & ACPI_EC_FLAG_BURST)){
173 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"entering burst mode \n"));
174 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr);
175 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
176 if (status){
177 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
178 ACPI_DEBUG_PRINT((ACPI_DB_ERROR," status = %d\n", status));
179 return_VALUE(-EINVAL);
180 }
181 acpi_hw_low_level_read(8, &tmp, &ec->data_addr);
182 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
183 if(tmp != 0x90 ) {/* Burst ACK byte*/
184 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Ack failed \n"));
185 return_VALUE(-EINVAL);
186 }
187 } else
188 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in burst mode \n"));
189 atomic_set(&ec->leaving_burst , 0);
190 return_VALUE(0);
137} 191}
138 192
193static int
194acpi_ec_leave_burst_mode (
195 struct acpi_ec *ec)
196{
197 int status =0;
198
199 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
200
201 atomic_set(&ec->leaving_burst , 1);
202 status = acpi_ec_read_status(ec);
203 if (status != -EINVAL &&
204 (status & ACPI_EC_FLAG_BURST)){
205 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n"));
206 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr);
207 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
208 if (status){
209 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n"));
211 return_VALUE(-EINVAL);
212 }
213 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
214 status = acpi_ec_read_status(ec);
215 if (status != -EINVAL &&
216 (status & ACPI_EC_FLAG_BURST)) {
217 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->status fail\n"));
218 return_VALUE(-EINVAL);
219 }
220 }else
221 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in Non-burst mode \n"));
222 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n"));
223
224 return_VALUE(0);
225}
139 226
140static int 227static int
141acpi_ec_read ( 228acpi_ec_read (
@@ -143,16 +230,15 @@ acpi_ec_read (
143 u8 address, 230 u8 address,
144 u32 *data) 231 u32 *data)
145{ 232{
146 acpi_status status = AE_OK; 233 int status = 0;
147 int result = 0; 234 u32 glk;
148 unsigned long flags = 0;
149 u32 glk = 0;
150 235
151 ACPI_FUNCTION_TRACE("acpi_ec_read"); 236 ACPI_FUNCTION_TRACE("acpi_ec_read");
152 237
153 if (!ec || !data) 238 if (!ec || !data)
154 return_VALUE(-EINVAL); 239 return_VALUE(-EINVAL);
155 240
241retry:
156 *data = 0; 242 *data = 0;
157 243
158 if (ec->global_lock) { 244 if (ec->global_lock) {
@@ -160,32 +246,50 @@ acpi_ec_read (
160 if (ACPI_FAILURE(status)) 246 if (ACPI_FAILURE(status))
161 return_VALUE(-ENODEV); 247 return_VALUE(-ENODEV);
162 } 248 }
163 249
164 spin_lock_irqsave(&ec->lock, flags); 250 WARN_ON(in_interrupt());
251 down(&ec->sem);
252
253 if(acpi_ec_enter_burst_mode(ec))
254 goto end;
165 255
166 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->command_addr); 256 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->command_addr);
167 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 257 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
168 if (result) 258 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
259 if (status) {
169 goto end; 260 goto end;
261 }
170 262
171 acpi_hw_low_level_write(8, address, &ec->data_addr); 263 acpi_hw_low_level_write(8, address, &ec->data_addr);
172 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 264 status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
173 if (result) 265 if (status){
266 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
174 goto end; 267 goto end;
175 268 }
176 269
177 acpi_hw_low_level_read(8, data, &ec->data_addr); 270 acpi_hw_low_level_read(8, data, &ec->data_addr);
271 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
178 272
179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", 273 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
180 *data, address)); 274 *data, address));
181 275
182end: 276end:
183 spin_unlock_irqrestore(&ec->lock, flags); 277 acpi_ec_leave_burst_mode(ec);
278 up(&ec->sem);
184 279
185 if (ec->global_lock) 280 if (ec->global_lock)
186 acpi_release_global_lock(glk); 281 acpi_release_global_lock(glk);
187 282
188 return_VALUE(result); 283 if(atomic_read(&ec->leaving_burst) == 2){
284 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
285 while(atomic_read(&ec->pending_gpe)){
286 msleep(1);
287 }
288 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
289 goto retry;
290 }
291
292 return_VALUE(status);
189} 293}
190 294
191 295
@@ -195,49 +299,80 @@ acpi_ec_write (
195 u8 address, 299 u8 address,
196 u8 data) 300 u8 data)
197{ 301{
198 int result = 0; 302 int status = 0;
199 acpi_status status = AE_OK; 303 u32 glk;
200 unsigned long flags = 0; 304 u32 tmp;
201 u32 glk = 0;
202 305
203 ACPI_FUNCTION_TRACE("acpi_ec_write"); 306 ACPI_FUNCTION_TRACE("acpi_ec_write");
204 307
205 if (!ec) 308 if (!ec)
206 return_VALUE(-EINVAL); 309 return_VALUE(-EINVAL);
207 310retry:
208 if (ec->global_lock) { 311 if (ec->global_lock) {
209 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 312 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
210 if (ACPI_FAILURE(status)) 313 if (ACPI_FAILURE(status))
211 return_VALUE(-ENODEV); 314 return_VALUE(-ENODEV);
212 } 315 }
213 316
214 spin_lock_irqsave(&ec->lock, flags); 317 WARN_ON(in_interrupt());
318 down(&ec->sem);
319
320 if(acpi_ec_enter_burst_mode(ec))
321 goto end;
322
323 status = acpi_ec_read_status(ec);
324 if (status != -EINVAL &&
325 !(status & ACPI_EC_FLAG_BURST)){
326 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr);
327 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
328 if (status)
329 goto end;
330 acpi_hw_low_level_read(8, &tmp, &ec->data_addr);
331 if(tmp != 0x90 ) /* Burst ACK byte*/
332 goto end;
333 }
334 /*Now we are in burst mode*/
215 335
216 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->command_addr); 336 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->command_addr);
217 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 337 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
218 if (result) 338 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
339 if (status){
219 goto end; 340 goto end;
341 }
220 342
221 acpi_hw_low_level_write(8, address, &ec->data_addr); 343 acpi_hw_low_level_write(8, address, &ec->data_addr);
222 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 344 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
223 if (result) 345 if (status){
346 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
224 goto end; 347 goto end;
348 }
225 349
226 acpi_hw_low_level_write(8, data, &ec->data_addr); 350 acpi_hw_low_level_write(8, data, &ec->data_addr);
227 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 351 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
228 if (result) 352 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
353 if (status)
229 goto end; 354 goto end;
230 355
231 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 356 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
232 data, address)); 357 data, address));
233 358
234end: 359end:
235 spin_unlock_irqrestore(&ec->lock, flags); 360 acpi_ec_leave_burst_mode(ec);
361 up(&ec->sem);
236 362
237 if (ec->global_lock) 363 if (ec->global_lock)
238 acpi_release_global_lock(glk); 364 acpi_release_global_lock(glk);
239 365
240 return_VALUE(result); 366 if(atomic_read(&ec->leaving_burst) == 2){
367 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
368 while(atomic_read(&ec->pending_gpe)){
369 msleep(1);
370 }
371 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
372 goto retry;
373 }
374
375 return_VALUE(status);
241} 376}
242 377
243/* 378/*
@@ -289,16 +424,13 @@ acpi_ec_query (
289 struct acpi_ec *ec, 424 struct acpi_ec *ec,
290 u32 *data) 425 u32 *data)
291{ 426{
292 int result = 0; 427 int status = 0;
293 acpi_status status = AE_OK; 428 u32 glk;
294 unsigned long flags = 0;
295 u32 glk = 0;
296 429
297 ACPI_FUNCTION_TRACE("acpi_ec_query"); 430 ACPI_FUNCTION_TRACE("acpi_ec_query");
298 431
299 if (!ec || !data) 432 if (!ec || !data)
300 return_VALUE(-EINVAL); 433 return_VALUE(-EINVAL);
301
302 *data = 0; 434 *data = 0;
303 435
304 if (ec->global_lock) { 436 if (ec->global_lock) {
@@ -307,29 +439,39 @@ acpi_ec_query (
307 return_VALUE(-ENODEV); 439 return_VALUE(-ENODEV);
308 } 440 }
309 441
442 down(&ec->sem);
443 if(acpi_ec_enter_burst_mode(ec))
444 goto end;
310 /* 445 /*
311 * Query the EC to find out which _Qxx method we need to evaluate. 446 * Query the EC to find out which _Qxx method we need to evaluate.
312 * Note that successful completion of the query causes the ACPI_EC_SCI 447 * Note that successful completion of the query causes the ACPI_EC_SCI
313 * bit to be cleared (and thus clearing the interrupt source). 448 * bit to be cleared (and thus clearing the interrupt source).
314 */ 449 */
315 spin_lock_irqsave(&ec->lock, flags);
316
317 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->command_addr); 450 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->command_addr);
318 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 451 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
319 if (result) 452 if (status){
453 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
320 goto end; 454 goto end;
321 455 }
456
322 acpi_hw_low_level_read(8, data, &ec->data_addr); 457 acpi_hw_low_level_read(8, data, &ec->data_addr);
458 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
323 if (!*data) 459 if (!*data)
324 result = -ENODATA; 460 status = -ENODATA;
325 461
326end: 462end:
327 spin_unlock_irqrestore(&ec->lock, flags); 463 acpi_ec_leave_burst_mode(ec);
464 up(&ec->sem);
328 465
329 if (ec->global_lock) 466 if (ec->global_lock)
330 acpi_release_global_lock(glk); 467 acpi_release_global_lock(glk);
331 468
332 return_VALUE(result); 469 if(atomic_read(&ec->leaving_burst) == 2){
470 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
471 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
472 status = -ENODATA;
473 }
474 return_VALUE(status);
333} 475}
334 476
335 477
@@ -347,42 +489,29 @@ acpi_ec_gpe_query (
347 void *ec_cxt) 489 void *ec_cxt)
348{ 490{
349 struct acpi_ec *ec = (struct acpi_ec *) ec_cxt; 491 struct acpi_ec *ec = (struct acpi_ec *) ec_cxt;
350 u32 value = 0; 492 u32 value;
351 unsigned long flags = 0; 493 int result = -ENODATA;
352 static char object_name[5] = {'_','Q','0','0','\0'}; 494 static char object_name[5] = {'_','Q','0','0','\0'};
353 const char hex[] = {'0','1','2','3','4','5','6','7', 495 const char hex[] = {'0','1','2','3','4','5','6','7',
354 '8','9','A','B','C','D','E','F'}; 496 '8','9','A','B','C','D','E','F'};
355 497
356 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); 498 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
357 499
358 if (!ec_cxt) 500 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI)
359 goto end; 501 result = acpi_ec_query(ec, &value);
360
361 spin_lock_irqsave(&ec->lock, flags);
362 acpi_hw_low_level_read(8, &value, &ec->command_addr);
363 spin_unlock_irqrestore(&ec->lock, flags);
364 502
365 /* TBD: Implement asynch events! 503 if (result)
366 * NOTE: All we care about are EC-SCI's. Other EC events are
367 * handled via polling (yuck!). This is because some systems
368 * treat EC-SCIs as level (versus EDGE!) triggered, preventing
369 * a purely interrupt-driven approach (grumble, grumble).
370 */
371 if (!(value & ACPI_EC_FLAG_SCI))
372 goto end; 504 goto end;
373 505
374 if (acpi_ec_query(ec, &value))
375 goto end;
376
377 object_name[2] = hex[((value >> 4) & 0x0F)]; 506 object_name[2] = hex[((value >> 4) & 0x0F)];
378 object_name[3] = hex[(value & 0x0F)]; 507 object_name[3] = hex[(value & 0x0F)];
379 508
380 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); 509 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
381 510
382 acpi_evaluate_object(ec->handle, object_name, NULL, NULL); 511 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
383 512end:
384end: 513 atomic_dec(&ec->pending_gpe);
385 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 514 return;
386} 515}
387 516
388static u32 517static u32
@@ -390,6 +519,7 @@ acpi_ec_gpe_handler (
390 void *data) 519 void *data)
391{ 520{
392 acpi_status status = AE_OK; 521 acpi_status status = AE_OK;
522 u32 value;
393 struct acpi_ec *ec = (struct acpi_ec *) data; 523 struct acpi_ec *ec = (struct acpi_ec *) data;
394 524
395 if (!ec) 525 if (!ec)
@@ -397,13 +527,41 @@ acpi_ec_gpe_handler (
397 527
398 acpi_disable_gpe(NULL, ec->gpe_bit, ACPI_ISR); 528 acpi_disable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
399 529
400 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 530 value = acpi_ec_read_status(ec);
401 acpi_ec_gpe_query, ec);
402 531
403 if (status == AE_OK) 532 if((value & ACPI_EC_FLAG_IBF) &&
404 return ACPI_INTERRUPT_HANDLED; 533 !(value & ACPI_EC_FLAG_BURST) &&
405 else 534 (atomic_read(&ec->leaving_burst) == 0)) {
406 return ACPI_INTERRUPT_NOT_HANDLED; 535 /*
536 * the embedded controller disables
537 * burst mode for any reason other
538 * than the burst disable command
539 * to process critical event.
540 */
541 atomic_set(&ec->leaving_burst , 2); /* block current pending transaction
542 and retry */
543 wake_up(&ec->wait);
544 }else {
545 if ((ec->expect_event == ACPI_EC_EVENT_OBF &&
546 (value & ACPI_EC_FLAG_OBF)) ||
547 (ec->expect_event == ACPI_EC_EVENT_IBE &&
548 !(value & ACPI_EC_FLAG_IBF))) {
549 ec->expect_event = 0;
550 wake_up(&ec->wait);
551 return ACPI_INTERRUPT_HANDLED;
552 }
553 }
554
555 if (value & ACPI_EC_FLAG_SCI){
556 atomic_add(1, &ec->pending_gpe) ;
557 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
558 acpi_ec_gpe_query, ec);
559 return status == AE_OK ?
560 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
561 }
562 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
563 return status == AE_OK ?
564 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
407} 565}
408 566
409/* -------------------------------------------------------------------------- 567/* --------------------------------------------------------------------------
@@ -421,10 +579,8 @@ acpi_ec_space_setup (
421 * The EC object is in the handler context and is needed 579 * The EC object is in the handler context and is needed
422 * when calling the acpi_ec_space_handler. 580 * when calling the acpi_ec_space_handler.
423 */ 581 */
424 if(function == ACPI_REGION_DEACTIVATE) 582 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
425 *return_context = NULL; 583 handler_context : NULL;
426 else
427 *return_context = handler_context;
428 584
429 return AE_OK; 585 return AE_OK;
430} 586}
@@ -441,7 +597,7 @@ acpi_ec_space_handler (
441{ 597{
442 int result = 0; 598 int result = 0;
443 struct acpi_ec *ec = NULL; 599 struct acpi_ec *ec = NULL;
444 u32 temp = 0; 600 u64 temp = *value;
445 acpi_integer f_v = 0; 601 acpi_integer f_v = 0;
446 int i = 0; 602 int i = 0;
447 603
@@ -450,10 +606,9 @@ acpi_ec_space_handler (
450 if ((address > 0xFF) || !value || !handler_context) 606 if ((address > 0xFF) || !value || !handler_context)
451 return_VALUE(AE_BAD_PARAMETER); 607 return_VALUE(AE_BAD_PARAMETER);
452 608
453 if(bit_width != 8) { 609 if (bit_width != 8 && acpi_strict) {
454 printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n"); 610 printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n");
455 if (acpi_strict) 611 return_VALUE(AE_BAD_PARAMETER);
456 return_VALUE(AE_BAD_PARAMETER);
457 } 612 }
458 613
459 ec = (struct acpi_ec *) handler_context; 614 ec = (struct acpi_ec *) handler_context;
@@ -461,11 +616,11 @@ acpi_ec_space_handler (
461next_byte: 616next_byte:
462 switch (function) { 617 switch (function) {
463 case ACPI_READ: 618 case ACPI_READ:
464 result = acpi_ec_read(ec, (u8) address, &temp); 619 temp = 0;
465 *value = (acpi_integer) temp; 620 result = acpi_ec_read(ec, (u8) address, (u32 *)&temp);
466 break; 621 break;
467 case ACPI_WRITE: 622 case ACPI_WRITE:
468 result = acpi_ec_write(ec, (u8) address, (u8) *value); 623 result = acpi_ec_write(ec, (u8) address, (u8) temp);
469 break; 624 break;
470 default: 625 default:
471 result = -EINVAL; 626 result = -EINVAL;
@@ -474,19 +629,18 @@ next_byte:
474 } 629 }
475 630
476 bit_width -= 8; 631 bit_width -= 8;
477 if(bit_width){ 632 if (bit_width) {
478 633 if (function == ACPI_READ)
479 if(function == ACPI_READ) 634 f_v |= temp << 8 * i;
480 f_v |= (acpi_integer) (*value) << 8*i; 635 if (function == ACPI_WRITE)
481 if(function == ACPI_WRITE) 636 temp >>= 8;
482 (*value) >>=8;
483 i++; 637 i++;
638 address++;
484 goto next_byte; 639 goto next_byte;
485 } 640 }
486 641
487 642 if (function == ACPI_READ) {
488 if(function == ACPI_READ){ 643 f_v |= temp << 8 * i;
489 f_v |= (acpi_integer) (*value) << 8*i;
490 *value = f_v; 644 *value = f_v;
491 } 645 }
492 646
@@ -505,8 +659,6 @@ out:
505 default: 659 default:
506 return_VALUE(AE_OK); 660 return_VALUE(AE_OK);
507 } 661 }
508
509
510} 662}
511 663
512 664
@@ -533,6 +685,7 @@ acpi_ec_read_info (struct seq_file *seq, void *offset)
533 (u32) ec->status_addr.address, (u32) ec->data_addr.address); 685 (u32) ec->status_addr.address, (u32) ec->data_addr.address);
534 seq_printf(seq, "use global lock: %s\n", 686 seq_printf(seq, "use global lock: %s\n",
535 ec->global_lock?"yes":"no"); 687 ec->global_lock?"yes":"no");
688 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
536 689
537end: 690end:
538 return_VALUE(0); 691 return_VALUE(0);
@@ -555,7 +708,7 @@ static int
555acpi_ec_add_fs ( 708acpi_ec_add_fs (
556 struct acpi_device *device) 709 struct acpi_device *device)
557{ 710{
558 struct proc_dir_entry *entry = NULL; 711 struct proc_dir_entry *entry;
559 712
560 ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); 713 ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
561 714
@@ -606,9 +759,9 @@ static int
606acpi_ec_add ( 759acpi_ec_add (
607 struct acpi_device *device) 760 struct acpi_device *device)
608{ 761{
609 int result = 0; 762 int result;
610 acpi_status status = AE_OK; 763 acpi_status status;
611 struct acpi_ec *ec = NULL; 764 struct acpi_ec *ec;
612 unsigned long uid; 765 unsigned long uid;
613 766
614 ACPI_FUNCTION_TRACE("acpi_ec_add"); 767 ACPI_FUNCTION_TRACE("acpi_ec_add");
@@ -623,7 +776,10 @@ acpi_ec_add (
623 776
624 ec->handle = device->handle; 777 ec->handle = device->handle;
625 ec->uid = -1; 778 ec->uid = -1;
626 spin_lock_init(&ec->lock); 779 atomic_set(&ec->pending_gpe, 0);
780 atomic_set(&ec->leaving_burst , 1);
781 init_MUTEX(&ec->sem);
782 init_waitqueue_head(&ec->wait);
627 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 783 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
628 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 784 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
629 acpi_driver_data(device) = ec; 785 acpi_driver_data(device) = ec;
@@ -637,7 +793,7 @@ acpi_ec_add (
637 if (ec_ecdt && ec_ecdt->uid == uid) { 793 if (ec_ecdt && ec_ecdt->uid == uid) {
638 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, 794 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
639 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 795 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
640 796
641 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, &acpi_ec_gpe_handler); 797 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, &acpi_ec_gpe_handler);
642 798
643 kfree(ec_ecdt); 799 kfree(ec_ecdt);
@@ -677,7 +833,7 @@ acpi_ec_remove (
677 struct acpi_device *device, 833 struct acpi_device *device,
678 int type) 834 int type)
679{ 835{
680 struct acpi_ec *ec = NULL; 836 struct acpi_ec *ec;
681 837
682 ACPI_FUNCTION_TRACE("acpi_ec_remove"); 838 ACPI_FUNCTION_TRACE("acpi_ec_remove");
683 839
@@ -732,8 +888,8 @@ static int
732acpi_ec_start ( 888acpi_ec_start (
733 struct acpi_device *device) 889 struct acpi_device *device)
734{ 890{
735 acpi_status status = AE_OK; 891 acpi_status status;
736 struct acpi_ec *ec = NULL; 892 struct acpi_ec *ec;
737 893
738 ACPI_FUNCTION_TRACE("acpi_ec_start"); 894 ACPI_FUNCTION_TRACE("acpi_ec_start");
739 895
@@ -789,8 +945,8 @@ acpi_ec_stop (
789 struct acpi_device *device, 945 struct acpi_device *device,
790 int type) 946 int type)
791{ 947{
792 acpi_status status = AE_OK; 948 acpi_status status;
793 struct acpi_ec *ec = NULL; 949 struct acpi_ec *ec;
794 950
795 ACPI_FUNCTION_TRACE("acpi_ec_stop"); 951 ACPI_FUNCTION_TRACE("acpi_ec_stop");
796 952
@@ -832,7 +988,6 @@ acpi_fake_ecdt_callback (
832 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe_bit); 988 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe_bit);
833 if (ACPI_FAILURE(status)) 989 if (ACPI_FAILURE(status))
834 return status; 990 return status;
835 spin_lock_init(&ec_ecdt->lock);
836 ec_ecdt->global_lock = TRUE; 991 ec_ecdt->global_lock = TRUE;
837 ec_ecdt->handle = handle; 992 ec_ecdt->handle = handle;
838 993
@@ -890,7 +1045,7 @@ acpi_ec_get_real_ecdt(void)
890 acpi_status status; 1045 acpi_status status;
891 struct acpi_table_ecdt *ecdt_ptr; 1046 struct acpi_table_ecdt *ecdt_ptr;
892 1047
893 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, 1048 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
894 (struct acpi_table_header **) &ecdt_ptr); 1049 (struct acpi_table_header **) &ecdt_ptr);
895 if (ACPI_FAILURE(status)) 1050 if (ACPI_FAILURE(status))
896 return -ENODEV; 1051 return -ENODEV;
@@ -905,11 +1060,12 @@ acpi_ec_get_real_ecdt(void)
905 return -ENOMEM; 1060 return -ENOMEM;
906 memset(ec_ecdt, 0, sizeof(struct acpi_ec)); 1061 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
907 1062
1063 init_MUTEX(&ec_ecdt->sem);
1064 init_waitqueue_head(&ec_ecdt->wait);
908 ec_ecdt->command_addr = ecdt_ptr->ec_control; 1065 ec_ecdt->command_addr = ecdt_ptr->ec_control;
909 ec_ecdt->status_addr = ecdt_ptr->ec_control; 1066 ec_ecdt->status_addr = ecdt_ptr->ec_control;
910 ec_ecdt->data_addr = ecdt_ptr->ec_data; 1067 ec_ecdt->data_addr = ecdt_ptr->ec_data;
911 ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit; 1068 ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit;
912 spin_lock_init(&ec_ecdt->lock);
913 /* use the GL just to be safe */ 1069 /* use the GL just to be safe */
914 ec_ecdt->global_lock = TRUE; 1070 ec_ecdt->global_lock = TRUE;
915 ec_ecdt->uid = ecdt_ptr->uid; 1071 ec_ecdt->uid = ecdt_ptr->uid;
@@ -978,7 +1134,7 @@ error:
978 1134
979static int __init acpi_ec_init (void) 1135static int __init acpi_ec_init (void)
980{ 1136{
981 int result = 0; 1137 int result;
982 1138
983 ACPI_FUNCTION_TRACE("acpi_ec_init"); 1139 ACPI_FUNCTION_TRACE("acpi_ec_init");
984 1140
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c
index 2a213604ae51..dd3a72a869f4 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/events/evevent.c
@@ -47,6 +47,16 @@
47#define _COMPONENT ACPI_EVENTS 47#define _COMPONENT ACPI_EVENTS
48 ACPI_MODULE_NAME ("evevent") 48 ACPI_MODULE_NAME ("evevent")
49 49
50/* Local prototypes */
51
52static acpi_status
53acpi_ev_fixed_event_initialize (
54 void);
55
56static u32
57acpi_ev_fixed_event_dispatch (
58 u32 event);
59
50 60
51/******************************************************************************* 61/*******************************************************************************
52 * 62 *
@@ -56,7 +66,7 @@
56 * 66 *
57 * RETURN: Status 67 * RETURN: Status
58 * 68 *
59 * DESCRIPTION: Initialize global data structures for events. 69 * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE)
60 * 70 *
61 ******************************************************************************/ 71 ******************************************************************************/
62 72
@@ -78,9 +88,9 @@ acpi_ev_initialize_events (
78 } 88 }
79 89
80 /* 90 /*
81 * Initialize the Fixed and General Purpose Events. This is 91 * Initialize the Fixed and General Purpose Events. This is done prior to
82 * done prior to enabling SCIs to prevent interrupts from 92 * enabling SCIs to prevent interrupts from occurring before the handlers are
83 * occurring before handers are installed. 93 * installed.
84 */ 94 */
85 status = acpi_ev_fixed_event_initialize (); 95 status = acpi_ev_fixed_event_initialize ();
86 if (ACPI_FAILURE (status)) { 96 if (ACPI_FAILURE (status)) {
@@ -161,7 +171,7 @@ acpi_ev_install_xrupt_handlers (
161 * 171 *
162 ******************************************************************************/ 172 ******************************************************************************/
163 173
164acpi_status 174static acpi_status
165acpi_ev_fixed_event_initialize ( 175acpi_ev_fixed_event_initialize (
166 void) 176 void)
167{ 177{
@@ -180,7 +190,8 @@ acpi_ev_fixed_event_initialize (
180 /* Enable the fixed event */ 190 /* Enable the fixed event */
181 191
182 if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) { 192 if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) {
183 status = acpi_set_register (acpi_gbl_fixed_event_info[i].enable_register_id, 193 status = acpi_set_register (
194 acpi_gbl_fixed_event_info[i].enable_register_id,
184 0, ACPI_MTX_LOCK); 195 0, ACPI_MTX_LOCK);
185 if (ACPI_FAILURE (status)) { 196 if (ACPI_FAILURE (status)) {
186 return (status); 197 return (status);
@@ -200,7 +211,7 @@ acpi_ev_fixed_event_initialize (
200 * 211 *
201 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED 212 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
202 * 213 *
203 * DESCRIPTION: Checks the PM status register for fixed events 214 * DESCRIPTION: Checks the PM status register for active fixed events
204 * 215 *
205 ******************************************************************************/ 216 ******************************************************************************/
206 217
@@ -221,8 +232,10 @@ acpi_ev_fixed_event_detect (
221 * Read the fixed feature status and enable registers, as all the cases 232 * Read the fixed feature status and enable registers, as all the cases
222 * depend on their values. Ignore errors here. 233 * depend on their values. Ignore errors here.
223 */ 234 */
224 (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, &fixed_status); 235 (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
225 (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, &fixed_enable); 236 &fixed_status);
237 (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE,
238 &fixed_enable);
226 239
227 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, 240 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
228 "Fixed Event Block: Enable %08X Status %08X\n", 241 "Fixed Event Block: Enable %08X Status %08X\n",
@@ -259,7 +272,7 @@ acpi_ev_fixed_event_detect (
259 * 272 *
260 ******************************************************************************/ 273 ******************************************************************************/
261 274
262u32 275static u32
263acpi_ev_fixed_event_dispatch ( 276acpi_ev_fixed_event_dispatch (
264 u32 event) 277 u32 event)
265{ 278{
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index 118d72ac7c76..081120b109ba 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -48,6 +48,12 @@
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49 ACPI_MODULE_NAME ("evgpe") 49 ACPI_MODULE_NAME ("evgpe")
50 50
51/* Local prototypes */
52
53static void ACPI_SYSTEM_XFACE
54acpi_ev_asynch_execute_gpe_method (
55 void *context);
56
51 57
52/******************************************************************************* 58/*******************************************************************************
53 * 59 *
@@ -335,8 +341,10 @@ acpi_ev_get_gpe_event_info (
335 gpe_block = acpi_gbl_gpe_fadt_blocks[i]; 341 gpe_block = acpi_gbl_gpe_fadt_blocks[i];
336 if (gpe_block) { 342 if (gpe_block) {
337 if ((gpe_number >= gpe_block->block_base_number) && 343 if ((gpe_number >= gpe_block->block_base_number) &&
338 (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) { 344 (gpe_number < gpe_block->block_base_number +
339 return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]); 345 (gpe_block->register_count * 8))) {
346 return (&gpe_block->event_info[gpe_number -
347 gpe_block->block_base_number]);
340 } 348 }
341 } 349 }
342 } 350 }
@@ -437,7 +445,7 @@ acpi_ev_gpe_detect (
437 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", 445 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
438 gpe_register_info->base_gpe_number, status_reg, enable_reg)); 446 gpe_register_info->base_gpe_number, status_reg, enable_reg));
439 447
440 /* First check if there is anything active at all in this register */ 448 /* Check if there is anything active at all in this register */
441 449
442 enabled_status_byte = (u8) (status_reg & enable_reg); 450 enabled_status_byte = (u8) (status_reg & enable_reg);
443 if (!enabled_status_byte) { 451 if (!enabled_status_byte) {
@@ -457,8 +465,8 @@ acpi_ev_gpe_detect (
457 * or method. 465 * or method.
458 */ 466 */
459 int_status |= acpi_ev_gpe_dispatch ( 467 int_status |= acpi_ev_gpe_dispatch (
460 &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j], 468 &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j],
461 (u32) j + gpe_register_info->base_gpe_number); 469 (u32) j + gpe_register_info->base_gpe_number);
462 } 470 }
463 } 471 }
464 } 472 }
@@ -523,7 +531,8 @@ acpi_ev_asynch_execute_gpe_method (
523 * Take a snapshot of the GPE info for this level - we copy the 531 * Take a snapshot of the GPE info for this level - we copy the
524 * info to prevent a race condition with remove_handler/remove_block. 532 * info to prevent a race condition with remove_handler/remove_block.
525 */ 533 */
526 ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info, sizeof (struct acpi_gpe_event_info)); 534 ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info,
535 sizeof (struct acpi_gpe_event_info));
527 536
528 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); 537 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
529 if (ACPI_FAILURE (status)) { 538 if (ACPI_FAILURE (status)) {
@@ -534,7 +543,8 @@ acpi_ev_asynch_execute_gpe_method (
534 * Must check for control method type dispatch one more 543 * Must check for control method type dispatch one more
535 * time to avoid race with ev_gpe_install_handler 544 * time to avoid race with ev_gpe_install_handler
536 */ 545 */
537 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) { 546 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
547 ACPI_GPE_DISPATCH_METHOD) {
538 /* 548 /*
539 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx 549 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
540 * control method that corresponds to this GPE 550 * control method that corresponds to this GPE
@@ -553,7 +563,8 @@ acpi_ev_asynch_execute_gpe_method (
553 } 563 }
554 } 564 }
555 565
556 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED) { 566 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
567 ACPI_GPE_LEVEL_TRIGGERED) {
557 /* 568 /*
558 * GPE is level-triggered, we clear the GPE status bit after 569 * GPE is level-triggered, we clear the GPE status bit after
559 * handling the event. 570 * handling the event.
@@ -575,7 +586,7 @@ acpi_ev_asynch_execute_gpe_method (
575 * 586 *
576 * FUNCTION: acpi_ev_gpe_dispatch 587 * FUNCTION: acpi_ev_gpe_dispatch
577 * 588 *
578 * PARAMETERS: gpe_event_info - info for this GPE 589 * PARAMETERS: gpe_event_info - Info for this GPE
579 * gpe_number - Number relative to the parent GPE block 590 * gpe_number - Number relative to the parent GPE block
580 * 591 *
581 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED 592 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
@@ -602,10 +613,12 @@ acpi_ev_gpe_dispatch (
602 * If edge-triggered, clear the GPE status bit now. Note that 613 * If edge-triggered, clear the GPE status bit now. Note that
603 * level-triggered events are cleared after the GPE is serviced. 614 * level-triggered events are cleared after the GPE is serviced.
604 */ 615 */
605 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_EDGE_TRIGGERED) { 616 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
617 ACPI_GPE_EDGE_TRIGGERED) {
606 status = acpi_hw_clear_gpe (gpe_event_info); 618 status = acpi_hw_clear_gpe (gpe_event_info);
607 if (ACPI_FAILURE (status)) { 619 if (ACPI_FAILURE (status)) {
608 ACPI_REPORT_ERROR (("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", 620 ACPI_REPORT_ERROR ((
621 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n",
609 acpi_format_exception (status), gpe_number)); 622 acpi_format_exception (status), gpe_number));
610 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); 623 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
611 } 624 }
@@ -639,7 +652,8 @@ acpi_ev_gpe_dispatch (
639 652
640 /* It is now safe to clear level-triggered events. */ 653 /* It is now safe to clear level-triggered events. */
641 654
642 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED) { 655 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
656 ACPI_GPE_LEVEL_TRIGGERED) {
643 status = acpi_hw_clear_gpe (gpe_event_info); 657 status = acpi_hw_clear_gpe (gpe_event_info);
644 if (ACPI_FAILURE (status)) { 658 if (ACPI_FAILURE (status)) {
645 ACPI_REPORT_ERROR (( 659 ACPI_REPORT_ERROR ((
@@ -704,7 +718,6 @@ acpi_ev_gpe_dispatch (
704 718
705 719
706#ifdef ACPI_GPE_NOTIFY_CHECK 720#ifdef ACPI_GPE_NOTIFY_CHECK
707
708/******************************************************************************* 721/*******************************************************************************
709 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED 722 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
710 * 723 *
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index 00d981f53c6a..84186a7d17b2 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -48,6 +48,39 @@
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49 ACPI_MODULE_NAME ("evgpeblk") 49 ACPI_MODULE_NAME ("evgpeblk")
50 50
51/* Local prototypes */
52
53static acpi_status
54acpi_ev_save_method_info (
55 acpi_handle obj_handle,
56 u32 level,
57 void *obj_desc,
58 void **return_value);
59
60static acpi_status
61acpi_ev_match_prw_and_gpe (
62 acpi_handle obj_handle,
63 u32 level,
64 void *info,
65 void **return_value);
66
67static struct acpi_gpe_xrupt_info *
68acpi_ev_get_gpe_xrupt_block (
69 u32 interrupt_level);
70
71static acpi_status
72acpi_ev_delete_gpe_xrupt (
73 struct acpi_gpe_xrupt_info *gpe_xrupt);
74
75static acpi_status
76acpi_ev_install_gpe_block (
77 struct acpi_gpe_block_info *gpe_block,
78 u32 interrupt_level);
79
80static acpi_status
81acpi_ev_create_gpe_info_blocks (
82 struct acpi_gpe_block_info *gpe_block);
83
51 84
52/******************************************************************************* 85/*******************************************************************************
53 * 86 *
@@ -155,7 +188,7 @@ unlock_and_exit:
155} 188}
156 189
157 190
158/****************************************************************************** 191/*******************************************************************************
159 * 192 *
160 * FUNCTION: acpi_ev_delete_gpe_handlers 193 * FUNCTION: acpi_ev_delete_gpe_handlers
161 * 194 *
@@ -190,7 +223,8 @@ acpi_ev_delete_gpe_handlers (
190 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { 223 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
191 gpe_event_info = &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j]; 224 gpe_event_info = &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j];
192 225
193 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { 226 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
227 ACPI_GPE_DISPATCH_HANDLER) {
194 ACPI_MEM_FREE (gpe_event_info->dispatch.handler); 228 ACPI_MEM_FREE (gpe_event_info->dispatch.handler);
195 gpe_event_info->dispatch.handler = NULL; 229 gpe_event_info->dispatch.handler = NULL;
196 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; 230 gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK;
@@ -471,7 +505,7 @@ acpi_ev_get_gpe_xrupt_block (
471 ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block"); 505 ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block");
472 506
473 507
474 /* No need for spin lock since we are not changing any list elements here */ 508 /* No need for lock since we are not changing any list elements here */
475 509
476 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; 510 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
477 while (next_gpe_xrupt) { 511 while (next_gpe_xrupt) {
@@ -619,7 +653,7 @@ acpi_ev_install_gpe_block (
619 goto unlock_and_exit; 653 goto unlock_and_exit;
620 } 654 }
621 655
622 /* Install the new block at the end of the list for this interrupt with lock */ 656 /* Install the new block at the end of the list with lock */
623 657
624 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); 658 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
625 if (gpe_xrupt_block->gpe_block_list_head) { 659 if (gpe_xrupt_block->gpe_block_list_head) {
@@ -756,10 +790,12 @@ acpi_ev_create_gpe_info_blocks (
756 * per register. Initialization to zeros is sufficient. 790 * per register. Initialization to zeros is sufficient.
757 */ 791 */
758 gpe_event_info = ACPI_MEM_CALLOCATE ( 792 gpe_event_info = ACPI_MEM_CALLOCATE (
759 ((acpi_size) gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) * 793 ((acpi_size) gpe_block->register_count *
794 ACPI_GPE_REGISTER_WIDTH) *
760 sizeof (struct acpi_gpe_event_info)); 795 sizeof (struct acpi_gpe_event_info));
761 if (!gpe_event_info) { 796 if (!gpe_event_info) {
762 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the gpe_event_info table\n")); 797 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
798 "Could not allocate the gpe_event_info table\n"));
763 status = AE_NO_MEMORY; 799 status = AE_NO_MEMORY;
764 goto error_exit; 800 goto error_exit;
765 } 801 }
@@ -899,7 +935,8 @@ acpi_ev_create_gpe_block (
899 gpe_block->block_base_number = gpe_block_base_number; 935 gpe_block->block_base_number = gpe_block_base_number;
900 gpe_block->node = gpe_device; 936 gpe_block->node = gpe_device;
901 937
902 ACPI_MEMCPY (&gpe_block->block_address, gpe_block_address, sizeof (struct acpi_generic_address)); 938 ACPI_MEMCPY (&gpe_block->block_address, gpe_block_address,
939 sizeof (struct acpi_generic_address));
903 940
904 /* Create the register_info and event_info sub-structures */ 941 /* Create the register_info and event_info sub-structures */
905 942
@@ -1061,8 +1098,9 @@ acpi_ev_gpe_initialize (
1061 1098
1062 /* Install GPE Block 0 */ 1099 /* Install GPE Block 0 */
1063 1100
1064 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, &acpi_gbl_FADT->xgpe0_blk, 1101 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device,
1065 register_count0, 0, acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[0]); 1102 &acpi_gbl_FADT->xgpe0_blk, register_count0, 0,
1103 acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[0]);
1066 1104
1067 if (ACPI_FAILURE (status)) { 1105 if (ACPI_FAILURE (status)) {
1068 ACPI_REPORT_ERROR (( 1106 ACPI_REPORT_ERROR ((
@@ -1094,8 +1132,9 @@ acpi_ev_gpe_initialize (
1094 else { 1132 else {
1095 /* Install GPE Block 1 */ 1133 /* Install GPE Block 1 */
1096 1134
1097 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, &acpi_gbl_FADT->xgpe1_blk, 1135 status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device,
1098 register_count1, acpi_gbl_FADT->gpe1_base, 1136 &acpi_gbl_FADT->xgpe1_blk, register_count1,
1137 acpi_gbl_FADT->gpe1_base,
1099 acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[1]); 1138 acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[1]);
1100 1139
1101 if (ACPI_FAILURE (status)) { 1140 if (ACPI_FAILURE (status)) {
@@ -1109,7 +1148,7 @@ acpi_ev_gpe_initialize (
1109 * space. However, GPE0 always starts at GPE number zero. 1148 * space. However, GPE0 always starts at GPE number zero.
1110 */ 1149 */
1111 gpe_number_max = acpi_gbl_FADT->gpe1_base + 1150 gpe_number_max = acpi_gbl_FADT->gpe1_base +
1112 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); 1151 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1);
1113 } 1152 }
1114 } 1153 }
1115 1154
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 2548efa7a45f..659e90956112 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -50,6 +50,35 @@
50 ACPI_MODULE_NAME ("evmisc") 50 ACPI_MODULE_NAME ("evmisc")
51 51
52 52
53#ifdef ACPI_DEBUG_OUTPUT
54static const char *acpi_notify_value_names[] =
55{
56 "Bus Check",
57 "Device Check",
58 "Device Wake",
59 "Eject request",
60 "Device Check Light",
61 "Frequency Mismatch",
62 "Bus Mode Mismatch",
63 "Power Fault"
64};
65#endif
66
67/* Local prototypes */
68
69static void ACPI_SYSTEM_XFACE
70acpi_ev_notify_dispatch (
71 void *context);
72
73static void ACPI_SYSTEM_XFACE
74acpi_ev_global_lock_thread (
75 void *context);
76
77static u32
78acpi_ev_global_lock_handler (
79 void *context);
80
81
53/******************************************************************************* 82/*******************************************************************************
54 * 83 *
55 * FUNCTION: acpi_ev_is_notify_object 84 * FUNCTION: acpi_ev_is_notify_object
@@ -98,20 +127,6 @@ acpi_ev_is_notify_object (
98 * 127 *
99 ******************************************************************************/ 128 ******************************************************************************/
100 129
101#ifdef ACPI_DEBUG_OUTPUT
102static const char *acpi_notify_value_names[] =
103{
104 "Bus Check",
105 "Device Check",
106 "Device Wake",
107 "Eject request",
108 "Device Check Light",
109 "Frequency Mismatch",
110 "Bus Mode Mismatch",
111 "Power Fault"
112};
113#endif
114
115acpi_status 130acpi_status
116acpi_ev_queue_notify_request ( 131acpi_ev_queue_notify_request (
117 struct acpi_namespace_node *node, 132 struct acpi_namespace_node *node,
@@ -128,9 +143,10 @@ acpi_ev_queue_notify_request (
128 143
129 /* 144 /*
130 * For value 3 (Ejection Request), some device method may need to be run. 145 * For value 3 (Ejection Request), some device method may need to be run.
131 * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run. 146 * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need
147 * to be run.
132 * For value 0x80 (Status Change) on the power button or sleep button, 148 * For value 0x80 (Status Change) on the power button or sleep button,
133 * initiate soft-off or sleep operation? 149 * initiate soft-off or sleep operation?
134 */ 150 */
135 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 151 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
136 "Dispatching Notify(%X) on node %p\n", notify_value, node)); 152 "Dispatching Notify(%X) on node %p\n", notify_value, node));
@@ -140,8 +156,9 @@ acpi_ev_queue_notify_request (
140 acpi_notify_value_names[notify_value])); 156 acpi_notify_value_names[notify_value]));
141 } 157 }
142 else { 158 else {
143 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: 0x%2.2X **Device Specific**\n", 159 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
144 notify_value)); 160 "Notify value: 0x%2.2X **Device Specific**\n",
161 notify_value));
145 } 162 }
146 163
147 /* Get the notify object attached to the NS Node */ 164 /* Get the notify object attached to the NS Node */
@@ -210,7 +227,7 @@ acpi_ev_queue_notify_request (
210 * 227 *
211 * FUNCTION: acpi_ev_notify_dispatch 228 * FUNCTION: acpi_ev_notify_dispatch
212 * 229 *
213 * PARAMETERS: Context - To be passsed to the notify handler 230 * PARAMETERS: Context - To be passed to the notify handler
214 * 231 *
215 * RETURN: None. 232 * RETURN: None.
216 * 233 *
@@ -219,7 +236,7 @@ acpi_ev_queue_notify_request (
219 * 236 *
220 ******************************************************************************/ 237 ******************************************************************************/
221 238
222void ACPI_SYSTEM_XFACE 239static void ACPI_SYSTEM_XFACE
223acpi_ev_notify_dispatch ( 240acpi_ev_notify_dispatch (
224 void *context) 241 void *context)
225{ 242{
@@ -234,7 +251,8 @@ acpi_ev_notify_dispatch (
234 251
235 /* 252 /*
236 * We will invoke a global notify handler if installed. 253 * We will invoke a global notify handler if installed.
237 * This is done _before_ we invoke the per-device handler attached to the device. 254 * This is done _before_ we invoke the per-device handler attached
255 * to the device.
238 */ 256 */
239 if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) { 257 if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) {
240 /* Global system notification handler */ 258 /* Global system notification handler */
@@ -256,15 +274,17 @@ acpi_ev_notify_dispatch (
256 /* Invoke the system handler first, if present */ 274 /* Invoke the system handler first, if present */
257 275
258 if (global_handler) { 276 if (global_handler) {
259 global_handler (notify_info->notify.node, notify_info->notify.value, global_context); 277 global_handler (notify_info->notify.node, notify_info->notify.value,
278 global_context);
260 } 279 }
261 280
262 /* Now invoke the per-device handler, if present */ 281 /* Now invoke the per-device handler, if present */
263 282
264 handler_obj = notify_info->notify.handler_obj; 283 handler_obj = notify_info->notify.handler_obj;
265 if (handler_obj) { 284 if (handler_obj) {
266 handler_obj->notify.handler (notify_info->notify.node, notify_info->notify.value, 285 handler_obj->notify.handler (notify_info->notify.node,
267 handler_obj->notify.context); 286 notify_info->notify.value,
287 handler_obj->notify.context);
268 } 288 }
269 289
270 /* All done with the info object */ 290 /* All done with the info object */
@@ -370,7 +390,8 @@ acpi_ev_global_lock_handler (
370 ******************************************************************************/ 390 ******************************************************************************/
371 391
372acpi_status 392acpi_status
373acpi_ev_init_global_lock_handler (void) 393acpi_ev_init_global_lock_handler (
394 void)
374{ 395{
375 acpi_status status; 396 acpi_status status;
376 397
@@ -380,7 +401,7 @@ acpi_ev_init_global_lock_handler (void)
380 401
381 acpi_gbl_global_lock_present = TRUE; 402 acpi_gbl_global_lock_present = TRUE;
382 status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL, 403 status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL,
383 acpi_ev_global_lock_handler, NULL); 404 acpi_ev_global_lock_handler, NULL);
384 405
385 /* 406 /*
386 * If the global lock does not exist on this platform, the attempt 407 * If the global lock does not exist on this platform, the attempt
@@ -433,8 +454,10 @@ acpi_ev_acquire_global_lock (
433 454
434 acpi_gbl_global_lock_thread_count++; 455 acpi_gbl_global_lock_thread_count++;
435 456
436 /* If we (OS side vs. BIOS side) have the hardware lock already, we are done */ 457 /*
437 458 * If we (OS side vs. BIOS side) have the hardware lock already,
459 * we are done
460 */
438 if (acpi_gbl_global_lock_acquired) { 461 if (acpi_gbl_global_lock_acquired) {
439 return_ACPI_STATUS (AE_OK); 462 return_ACPI_STATUS (AE_OK);
440 } 463 }
@@ -480,7 +503,8 @@ acpi_ev_acquire_global_lock (
480 ******************************************************************************/ 503 ******************************************************************************/
481 504
482acpi_status 505acpi_status
483acpi_ev_release_global_lock (void) 506acpi_ev_release_global_lock (
507 void)
484{ 508{
485 u8 pending = FALSE; 509 u8 pending = FALSE;
486 acpi_status status = AE_OK; 510 acpi_status status = AE_OK;
@@ -490,7 +514,8 @@ acpi_ev_release_global_lock (void)
490 514
491 515
492 if (!acpi_gbl_global_lock_thread_count) { 516 if (!acpi_gbl_global_lock_thread_count) {
493 ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n")); 517 ACPI_REPORT_WARNING((
518 "Cannot release HW Global Lock, it has not been acquired\n"));
494 return_ACPI_STATUS (AE_NOT_ACQUIRED); 519 return_ACPI_STATUS (AE_NOT_ACQUIRED);
495 } 520 }
496 521
@@ -515,7 +540,8 @@ acpi_ev_release_global_lock (void)
515 * register 540 * register
516 */ 541 */
517 if (pending) { 542 if (pending) {
518 status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK); 543 status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE,
544 1, ACPI_MTX_LOCK);
519 } 545 }
520 546
521 return_ACPI_STATUS (status); 547 return_ACPI_STATUS (status);
@@ -535,7 +561,8 @@ acpi_ev_release_global_lock (void)
535 ******************************************************************************/ 561 ******************************************************************************/
536 562
537void 563void
538acpi_ev_terminate (void) 564acpi_ev_terminate (
565 void)
539{ 566{
540 acpi_native_uint i; 567 acpi_native_uint i;
541 acpi_status status; 568 acpi_status status;
@@ -555,7 +582,8 @@ acpi_ev_terminate (void)
555 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 582 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
556 status = acpi_disable_event ((u32) i, 0); 583 status = acpi_disable_event ((u32) i, 0);
557 if (ACPI_FAILURE (status)) { 584 if (ACPI_FAILURE (status)) {
558 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable fixed event %d\n", (u32) i)); 585 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
586 "Could not disable fixed event %d\n", (u32) i));
559 } 587 }
560 } 588 }
561 589
@@ -567,7 +595,8 @@ acpi_ev_terminate (void)
567 595
568 status = acpi_ev_remove_sci_handler (); 596 status = acpi_ev_remove_sci_handler ();
569 if (ACPI_FAILURE(status)) { 597 if (ACPI_FAILURE(status)) {
570 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not remove SCI handler\n")); 598 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
599 "Could not remove SCI handler\n"));
571 } 600 }
572 } 601 }
573 602
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
index 772342708a7a..a1d7276c5742 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/events/evregion.c
@@ -58,6 +58,22 @@ static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPA
58 ACPI_ADR_SPACE_PCI_CONFIG, 58 ACPI_ADR_SPACE_PCI_CONFIG,
59 ACPI_ADR_SPACE_DATA_TABLE}; 59 ACPI_ADR_SPACE_DATA_TABLE};
60 60
61/* Local prototypes */
62
63static acpi_status
64acpi_ev_reg_run (
65 acpi_handle obj_handle,
66 u32 level,
67 void *context,
68 void **return_value);
69
70static acpi_status
71acpi_ev_install_handler (
72 acpi_handle obj_handle,
73 u32 level,
74 void *context,
75 void **return_value);
76
61 77
62/******************************************************************************* 78/*******************************************************************************
63 * 79 *
@@ -179,8 +195,8 @@ acpi_ev_initialize_op_regions (
179 * 195 *
180 * FUNCTION: acpi_ev_execute_reg_method 196 * FUNCTION: acpi_ev_execute_reg_method
181 * 197 *
182 * PARAMETERS: region_obj - Object structure 198 * PARAMETERS: region_obj - Region object
183 * Function - Passed to _REG: On (1) or Off (0) 199 * Function - Passed to _REG: On (1) or Off (0)
184 * 200 *
185 * RETURN: Status 201 * RETURN: Status
186 * 202 *
@@ -323,14 +339,16 @@ acpi_ev_address_space_dispatch (
323 if (!region_setup) { 339 if (!region_setup) {
324 /* No initialization routine, exit with error */ 340 /* No initialization routine, exit with error */
325 341
326 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No init routine for region(%p) [%s]\n", 342 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
343 "No init routine for region(%p) [%s]\n",
327 region_obj, acpi_ut_get_region_name (region_obj->region.space_id))); 344 region_obj, acpi_ut_get_region_name (region_obj->region.space_id)));
328 return_ACPI_STATUS (AE_NOT_EXIST); 345 return_ACPI_STATUS (AE_NOT_EXIST);
329 } 346 }
330 347
331 /* 348 /*
332 * We must exit the interpreter because the region setup will potentially 349 * We must exit the interpreter because the region
333 * execute control methods (e.g., _REG method for this region) 350 * setup will potentially execute control methods
351 * (e.g., _REG method for this region)
334 */ 352 */
335 acpi_ex_exit_interpreter (); 353 acpi_ex_exit_interpreter ();
336 354
@@ -621,7 +639,7 @@ acpi_ev_attach_region (
621 * 639 *
622 ******************************************************************************/ 640 ******************************************************************************/
623 641
624acpi_status 642static acpi_status
625acpi_ev_install_handler ( 643acpi_ev_install_handler (
626 acpi_handle obj_handle, 644 acpi_handle obj_handle,
627 u32 level, 645 u32 level,
@@ -848,7 +866,8 @@ acpi_ev_install_space_handler (
848 if (handler_obj->address_space.handler == handler) { 866 if (handler_obj->address_space.handler == handler) {
849 /* 867 /*
850 * It is (relatively) OK to attempt to install the SAME 868 * It is (relatively) OK to attempt to install the SAME
851 * handler twice. This can easily happen with PCI_Config space. 869 * handler twice. This can easily happen
870 * with PCI_Config space.
852 */ 871 */
853 status = AE_SAME_HANDLER; 872 status = AE_SAME_HANDLER;
854 goto unlock_and_exit; 873 goto unlock_and_exit;
@@ -1011,7 +1030,7 @@ acpi_ev_execute_reg_methods (
1011 * 1030 *
1012 ******************************************************************************/ 1031 ******************************************************************************/
1013 1032
1014acpi_status 1033static acpi_status
1015acpi_ev_reg_run ( 1034acpi_ev_reg_run (
1016 acpi_handle obj_handle, 1035 acpi_handle obj_handle,
1017 u32 level, 1036 u32 level,
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index 4983a3378be5..95bc09c73a6a 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -61,7 +61,7 @@
61 * 61 *
62 * RETURN: Status 62 * RETURN: Status
63 * 63 *
64 * DESCRIPTION: Do any prep work for region handling, a nop for now 64 * DESCRIPTION: Setup a system_memory operation region
65 * 65 *
66 ******************************************************************************/ 66 ******************************************************************************/
67 67
@@ -115,7 +115,7 @@ acpi_ev_system_memory_region_setup (
115 * 115 *
116 * RETURN: Status 116 * RETURN: Status
117 * 117 *
118 * DESCRIPTION: Do any prep work for region handling 118 * DESCRIPTION: Setup a IO operation region
119 * 119 *
120 ******************************************************************************/ 120 ******************************************************************************/
121 121
@@ -144,14 +144,14 @@ acpi_ev_io_space_region_setup (
144 * 144 *
145 * FUNCTION: acpi_ev_pci_config_region_setup 145 * FUNCTION: acpi_ev_pci_config_region_setup
146 * 146 *
147 * PARAMETERS: Handle - Region we are interested in 147 * PARAMETERS: Handle - Region we are interested in
148 * Function - Start or stop 148 * Function - Start or stop
149 * handler_context - Address space handler context 149 * handler_context - Address space handler context
150 * region_context - Region specific context 150 * region_context - Region specific context
151 * 151 *
152 * RETURN: Status 152 * RETURN: Status
153 * 153 *
154 * DESCRIPTION: Do any prep work for region handling 154 * DESCRIPTION: Setup a PCI_Config operation region
155 * 155 *
156 * MUTEX: Assumes namespace is not locked 156 * MUTEX: Assumes namespace is not locked
157 * 157 *
@@ -324,7 +324,7 @@ acpi_ev_pci_config_region_setup (
324 * 324 *
325 * RETURN: Status 325 * RETURN: Status
326 * 326 *
327 * DESCRIPTION: Do any prep work for region handling 327 * DESCRIPTION: Setup a pci_bAR operation region
328 * 328 *
329 * MUTEX: Assumes namespace is not locked 329 * MUTEX: Assumes namespace is not locked
330 * 330 *
@@ -355,7 +355,7 @@ acpi_ev_pci_bar_region_setup (
355 * 355 *
356 * RETURN: Status 356 * RETURN: Status
357 * 357 *
358 * DESCRIPTION: Do any prep work for region handling 358 * DESCRIPTION: Setup a CMOS operation region
359 * 359 *
360 * MUTEX: Assumes namespace is not locked 360 * MUTEX: Assumes namespace is not locked
361 * 361 *
@@ -386,7 +386,7 @@ acpi_ev_cmos_region_setup (
386 * 386 *
387 * RETURN: Status 387 * RETURN: Status
388 * 388 *
389 * DESCRIPTION: Do any prep work for region handling 389 * DESCRIPTION: Default region initialization
390 * 390 *
391 ******************************************************************************/ 391 ******************************************************************************/
392 392
diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c
index 46b31995c827..f3123c26ae98 100644
--- a/drivers/acpi/events/evsci.c
+++ b/drivers/acpi/events/evsci.c
@@ -49,6 +49,12 @@
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evsci") 50 ACPI_MODULE_NAME ("evsci")
51 51
52/* Local prototypes */
53
54static u32 ACPI_SYSTEM_XFACE
55acpi_ev_sci_xrupt_handler (
56 void *context);
57
52 58
53/******************************************************************************* 59/*******************************************************************************
54 * 60 *
@@ -146,7 +152,8 @@ acpi_ev_gpe_xrupt_handler (
146 ******************************************************************************/ 152 ******************************************************************************/
147 153
148u32 154u32
149acpi_ev_install_sci_handler (void) 155acpi_ev_install_sci_handler (
156 void)
150{ 157{
151 u32 status = AE_OK; 158 u32 status = AE_OK;
152 159
@@ -180,7 +187,8 @@ acpi_ev_install_sci_handler (void)
180 ******************************************************************************/ 187 ******************************************************************************/
181 188
182acpi_status 189acpi_status
183acpi_ev_remove_sci_handler (void) 190acpi_ev_remove_sci_handler (
191 void)
184{ 192{
185 acpi_status status; 193 acpi_status status;
186 194
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 0bfec10a5f1e..4092d47f6758 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -64,6 +64,7 @@
64 * DESCRIPTION: Saves the pointer to the handler function 64 * DESCRIPTION: Saves the pointer to the handler function
65 * 65 *
66 ******************************************************************************/ 66 ******************************************************************************/
67
67#ifdef ACPI_FUTURE_USAGE 68#ifdef ACPI_FUTURE_USAGE
68acpi_status 69acpi_status
69acpi_install_exception_handler ( 70acpi_install_exception_handler (
@@ -457,7 +458,8 @@ acpi_remove_notify_handler (
457 /* Root Object */ 458 /* Root Object */
458 459
459 if (device == ACPI_ROOT_OBJECT) { 460 if (device == ACPI_ROOT_OBJECT) {
460 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n")); 461 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
462 "Removing notify handler for ROOT object.\n"));
461 463
462 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 464 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
463 !acpi_gbl_system_notify.handler) || 465 !acpi_gbl_system_notify.handler) ||
@@ -564,8 +566,9 @@ EXPORT_SYMBOL(acpi_remove_notify_handler);
564 * 566 *
565 * FUNCTION: acpi_install_gpe_handler 567 * FUNCTION: acpi_install_gpe_handler
566 * 568 *
567 * PARAMETERS: gpe_number - The GPE number within the GPE block 569 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
568 * gpe_block - GPE block (NULL == FADT GPEs) 570 * defined GPEs)
571 * gpe_number - The GPE number within the GPE block
569 * Type - Whether this GPE should be treated as an 572 * Type - Whether this GPE should be treated as an
570 * edge- or level-triggered interrupt. 573 * edge- or level-triggered interrupt.
571 * Address - Address of the handler 574 * Address - Address of the handler
@@ -662,8 +665,9 @@ EXPORT_SYMBOL(acpi_install_gpe_handler);
662 * 665 *
663 * FUNCTION: acpi_remove_gpe_handler 666 * FUNCTION: acpi_remove_gpe_handler
664 * 667 *
665 * PARAMETERS: gpe_number - The event to remove a handler 668 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
666 * gpe_block - GPE block (NULL == FADT GPEs) 669 * defined GPEs)
670 * gpe_number - The event to remove a handler
667 * Address - Address of the handler 671 * Address - Address of the handler
668 * 672 *
669 * RETURN: Status 673 * RETURN: Status
@@ -766,7 +770,8 @@ EXPORT_SYMBOL(acpi_remove_gpe_handler);
766 * FUNCTION: acpi_acquire_global_lock 770 * FUNCTION: acpi_acquire_global_lock
767 * 771 *
768 * PARAMETERS: Timeout - How long the caller is willing to wait 772 * PARAMETERS: Timeout - How long the caller is willing to wait
769 * out_handle - A handle to the lock if acquired 773 * Handle - Where the handle to the lock is returned
774 * (if acquired)
770 * 775 *
771 * RETURN: Status 776 * RETURN: Status
772 * 777 *
@@ -812,7 +817,7 @@ EXPORT_SYMBOL(acpi_acquire_global_lock);
812 * 817 *
813 * RETURN: Status 818 * RETURN: Status
814 * 819 *
815 * DESCRIPTION: Release the ACPI Global Lock 820 * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid.
816 * 821 *
817 ******************************************************************************/ 822 ******************************************************************************/
818 823
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
index fa8d5f25be62..f337dc2cc569 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/events/evxfevnt.c
@@ -64,7 +64,8 @@
64 ******************************************************************************/ 64 ******************************************************************************/
65 65
66acpi_status 66acpi_status
67acpi_enable (void) 67acpi_enable (
68 void)
68{ 69{
69 acpi_status status = AE_OK; 70 acpi_status status = AE_OK;
70 71
@@ -91,7 +92,8 @@ acpi_enable (void)
91 return_ACPI_STATUS (status); 92 return_ACPI_STATUS (status);
92 } 93 }
93 94
94 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Transition to ACPI mode successful\n")); 95 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
96 "Transition to ACPI mode successful\n"));
95 } 97 }
96 98
97 return_ACPI_STATUS (status); 99 return_ACPI_STATUS (status);
@@ -106,12 +108,13 @@ acpi_enable (void)
106 * 108 *
107 * RETURN: Status 109 * RETURN: Status
108 * 110 *
109 * DESCRIPTION: Transfers the system into LEGACY mode. 111 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
110 * 112 *
111 ******************************************************************************/ 113 ******************************************************************************/
112 114
113acpi_status 115acpi_status
114acpi_disable (void) 116acpi_disable (
117 void)
115{ 118{
116 acpi_status status = AE_OK; 119 acpi_status status = AE_OK;
117 120
@@ -125,7 +128,8 @@ acpi_disable (void)
125 } 128 }
126 129
127 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { 130 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
128 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in legacy (non-ACPI) mode\n")); 131 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
132 "System is already in legacy (non-ACPI) mode\n"));
129 } 133 }
130 else { 134 else {
131 /* Transition to LEGACY mode */ 135 /* Transition to LEGACY mode */
@@ -133,7 +137,8 @@ acpi_disable (void)
133 status = acpi_hw_set_mode (ACPI_SYS_MODE_LEGACY); 137 status = acpi_hw_set_mode (ACPI_SYS_MODE_LEGACY);
134 138
135 if (ACPI_FAILURE (status)) { 139 if (ACPI_FAILURE (status)) {
136 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not exit ACPI mode to legacy mode")); 140 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
141 "Could not exit ACPI mode to legacy mode"));
137 return_ACPI_STATUS (status); 142 return_ACPI_STATUS (status);
138 } 143 }
139 144
@@ -214,7 +219,7 @@ EXPORT_SYMBOL(acpi_enable_event);
214 * 219 *
215 * RETURN: Status 220 * RETURN: Status
216 * 221 *
217 * DESCRIPTION: Enable an ACPI event (general purpose) 222 * DESCRIPTION: Set the type of an individual GPE
218 * 223 *
219 ******************************************************************************/ 224 ******************************************************************************/
220 225
@@ -519,13 +524,12 @@ unlock_and_exit:
519 524
520 525
521#ifdef ACPI_FUTURE_USAGE 526#ifdef ACPI_FUTURE_USAGE
522
523/******************************************************************************* 527/*******************************************************************************
524 * 528 *
525 * FUNCTION: acpi_get_event_status 529 * FUNCTION: acpi_get_event_status
526 * 530 *
527 * PARAMETERS: Event - The fixed event 531 * PARAMETERS: Event - The fixed event
528 * Event Status - Where the current status of the event will 532 * event_status - Where the current status of the event will
529 * be returned 533 * be returned
530 * 534 *
531 * RETURN: Status 535 * RETURN: Status
@@ -571,7 +575,7 @@ acpi_get_event_status (
571 * PARAMETERS: gpe_device - Parent GPE Device 575 * PARAMETERS: gpe_device - Parent GPE Device
572 * gpe_number - GPE level within the GPE block 576 * gpe_number - GPE level within the GPE block
573 * Flags - Called from an ISR or not 577 * Flags - Called from an ISR or not
574 * Event Status - Where the current status of the event will 578 * event_status - Where the current status of the event will
575 * be returned 579 * be returned
576 * 580 *
577 * RETURN: Status 581 * RETURN: Status
@@ -775,4 +779,5 @@ unlock_and_exit:
775 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 779 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
776 return_ACPI_STATUS (status); 780 return_ACPI_STATUS (status);
777} 781}
782
778EXPORT_SYMBOL(acpi_remove_gpe_block); 783EXPORT_SYMBOL(acpi_remove_gpe_block);
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index ac3c061967f2..734b2f24af48 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -54,6 +54,14 @@
54#define _COMPONENT ACPI_EXECUTER 54#define _COMPONENT ACPI_EXECUTER
55 ACPI_MODULE_NAME ("exconfig") 55 ACPI_MODULE_NAME ("exconfig")
56 56
57/* Local prototypes */
58
59static acpi_status
60acpi_ex_add_table (
61 struct acpi_table_header *table,
62 struct acpi_namespace_node *parent_node,
63 union acpi_operand_object **ddb_handle);
64
57 65
58/******************************************************************************* 66/*******************************************************************************
59 * 67 *
@@ -70,7 +78,7 @@
70 * 78 *
71 ******************************************************************************/ 79 ******************************************************************************/
72 80
73acpi_status 81static acpi_status
74acpi_ex_add_table ( 82acpi_ex_add_table (
75 struct acpi_table_header *table, 83 struct acpi_table_header *table,
76 struct acpi_namespace_node *parent_node, 84 struct acpi_namespace_node *parent_node,
@@ -95,10 +103,10 @@ acpi_ex_add_table (
95 103
96 ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc)); 104 ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc));
97 105
98 table_info.type = ACPI_TABLE_SSDT; 106 table_info.type = ACPI_TABLE_SSDT;
99 table_info.pointer = table; 107 table_info.pointer = table;
100 table_info.length = (acpi_size) table->length; 108 table_info.length = (acpi_size) table->length;
101 table_info.allocation = ACPI_MEM_ALLOCATED; 109 table_info.allocation = ACPI_MEM_ALLOCATED;
102 110
103 status = acpi_tb_install_table (&table_info); 111 status = acpi_tb_install_table (&table_info);
104 if (ACPI_FAILURE (status)) { 112 if (ACPI_FAILURE (status)) {
@@ -226,11 +234,10 @@ acpi_ex_load_table_op (
226 start_node = parent_node; 234 start_node = parent_node;
227 } 235 }
228 236
229 /* 237 /* Find the node referenced by the parameter_path_string */
230 * Find the node referenced by the parameter_path_string 238
231 */
232 status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node, 239 status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node,
233 ACPI_NS_SEARCH_PARENT, &parameter_node); 240 ACPI_NS_SEARCH_PARENT, &parameter_node);
234 if (ACPI_FAILURE (status)) { 241 if (ACPI_FAILURE (status)) {
235 return_ACPI_STATUS (status); 242 return_ACPI_STATUS (status);
236 } 243 }
@@ -248,7 +255,8 @@ acpi_ex_load_table_op (
248 if (parameter_node) { 255 if (parameter_node) {
249 /* Store the parameter data into the optional parameter object */ 256 /* Store the parameter data into the optional parameter object */
250 257
251 status = acpi_ex_store (operand[5], ACPI_CAST_PTR (union acpi_operand_object, parameter_node), 258 status = acpi_ex_store (operand[5],
259 ACPI_CAST_PTR (union acpi_operand_object, parameter_node),
252 walk_state); 260 walk_state);
253 if (ACPI_FAILURE (status)) { 261 if (ACPI_FAILURE (status)) {
254 (void) acpi_ex_unload_table (ddb_handle); 262 (void) acpi_ex_unload_table (ddb_handle);
@@ -371,7 +379,8 @@ acpi_ex_load_op (
371 goto cleanup; 379 goto cleanup;
372 } 380 }
373 381
374 table_ptr = ACPI_CAST_PTR (struct acpi_table_header, buffer_desc->buffer.pointer); 382 table_ptr = ACPI_CAST_PTR (struct acpi_table_header,
383 buffer_desc->buffer.pointer);
375 384
376 /* Sanity check the table length */ 385 /* Sanity check the table length */
377 386
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index df7ba1219bf6..97856c48bd74 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -50,6 +50,15 @@
50#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exconvrt") 51 ACPI_MODULE_NAME ("exconvrt")
52 52
53/* Local prototypes */
54
55static u32
56acpi_ex_convert_to_ascii (
57 acpi_integer integer,
58 u16 base,
59 u8 *string,
60 u8 max_length);
61
53 62
54/******************************************************************************* 63/*******************************************************************************
55 * 64 *
@@ -115,9 +124,8 @@ acpi_ex_convert_to_integer (
115 */ 124 */
116 result = 0; 125 result = 0;
117 126
118 /* 127 /* String conversion is different than Buffer conversion */
119 * String conversion is different than Buffer conversion 128
120 */
121 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 129 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
122 case ACPI_TYPE_STRING: 130 case ACPI_TYPE_STRING:
123 131
@@ -168,9 +176,8 @@ acpi_ex_convert_to_integer (
168 break; 176 break;
169 } 177 }
170 178
171 /* 179 /* Create a new integer */
172 * Create a new integer 180
173 */
174 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 181 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
175 if (!return_desc) { 182 if (!return_desc) {
176 return_ACPI_STATUS (AE_NO_MEMORY); 183 return_ACPI_STATUS (AE_NO_MEMORY);
@@ -251,7 +258,8 @@ acpi_ex_convert_to_buffer (
251 * ASL/AML code that depends on the null being transferred to the new 258 * ASL/AML code that depends on the null being transferred to the new
252 * buffer. 259 * buffer.
253 */ 260 */
254 return_desc = acpi_ut_create_buffer_object ((acpi_size) obj_desc->string.length + 1); 261 return_desc = acpi_ut_create_buffer_object (
262 (acpi_size) obj_desc->string.length + 1);
255 if (!return_desc) { 263 if (!return_desc) {
256 return_ACPI_STATUS (AE_NO_MEMORY); 264 return_ACPI_STATUS (AE_NO_MEMORY);
257 } 265 }
@@ -291,7 +299,7 @@ acpi_ex_convert_to_buffer (
291 * 299 *
292 ******************************************************************************/ 300 ******************************************************************************/
293 301
294u32 302static u32
295acpi_ex_convert_to_ascii ( 303acpi_ex_convert_to_ascii (
296 acpi_integer integer, 304 acpi_integer integer,
297 u16 base, 305 u16 base,
@@ -357,8 +365,9 @@ acpi_ex_convert_to_ascii (
357 365
358 case 16: 366 case 16:
359 367
360 hex_length = ACPI_MUL_2 (data_width); /* 2 ascii hex chars per data byte */ 368 /* hex_length: 2 ascii hex chars per data byte */
361 369
370 hex_length = ACPI_MUL_2 (data_width);
362 for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { 371 for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) {
363 /* Get one hex digit, most significant digits first */ 372 /* Get one hex digit, most significant digits first */
364 373
@@ -475,7 +484,7 @@ acpi_ex_convert_to_string (
475 /* Setup string length, base, and separator */ 484 /* Setup string length, base, and separator */
476 485
477 switch (type) { 486 switch (type) {
478 case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string operator */ 487 case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */
479 /* 488 /*
480 * From ACPI: "If Data is a buffer, it is converted to a string of 489 * From ACPI: "If Data is a buffer, it is converted to a string of
481 * decimal values separated by commas." 490 * decimal values separated by commas."
@@ -509,7 +518,7 @@ acpi_ex_convert_to_string (
509 string_length = (obj_desc->buffer.length * 3); 518 string_length = (obj_desc->buffer.length * 3);
510 break; 519 break;
511 520
512 case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string operator */ 521 case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */
513 /* 522 /*
514 * From ACPI: "If Data is a buffer, it is converted to a string of 523 * From ACPI: "If Data is a buffer, it is converted to a string of
515 * hexadecimal values separated by commas." 524 * hexadecimal values separated by commas."
@@ -530,9 +539,8 @@ acpi_ex_convert_to_string (
530 return_ACPI_STATUS (AE_AML_STRING_LIMIT); 539 return_ACPI_STATUS (AE_AML_STRING_LIMIT);
531 } 540 }
532 541
533 /* 542 /* Create a new string object and string buffer */
534 * Create a new string object and string buffer 543
535 */
536 return_desc = acpi_ut_create_string_object ((acpi_size) string_length); 544 return_desc = acpi_ut_create_string_object ((acpi_size) string_length);
537 if (!return_desc) { 545 if (!return_desc) {
538 return_ACPI_STATUS (AE_NO_MEMORY); 546 return_ACPI_STATUS (AE_NO_MEMORY);
@@ -551,8 +559,10 @@ acpi_ex_convert_to_string (
551 *new_buf++ = separator; /* each separated by a comma or space */ 559 *new_buf++ = separator; /* each separated by a comma or space */
552 } 560 }
553 561
554 /* Null terminate the string (overwrites final comma/space from above) */ 562 /*
555 563 * Null terminate the string
564 * (overwrites final comma/space from above)
565 */
556 new_buf--; 566 new_buf--;
557 *new_buf = 0; 567 *new_buf = 0;
558 break; 568 break;
@@ -645,7 +655,6 @@ acpi_ex_convert_to_target_type (
645 655
646 656
647 case ACPI_TYPE_STRING: 657 case ACPI_TYPE_STRING:
648
649 /* 658 /*
650 * The operand must be a String. We can convert an 659 * The operand must be a String. We can convert an
651 * Integer or Buffer if necessary 660 * Integer or Buffer if necessary
@@ -656,7 +665,6 @@ acpi_ex_convert_to_target_type (
656 665
657 666
658 case ACPI_TYPE_BUFFER: 667 case ACPI_TYPE_BUFFER:
659
660 /* 668 /*
661 * The operand must be a Buffer. We can convert an 669 * The operand must be a Buffer. We can convert an
662 * Integer or String if necessary 670 * Integer or String if necessary
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c
index d94c260dac6d..812cdcb2e370 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/executer/excreate.c
@@ -55,7 +55,7 @@
55 55
56 56
57#ifndef ACPI_NO_METHOD_EXECUTION 57#ifndef ACPI_NO_METHOD_EXECUTION
58/***************************************************************************** 58/*******************************************************************************
59 * 59 *
60 * FUNCTION: acpi_ex_create_alias 60 * FUNCTION: acpi_ex_create_alias
61 * 61 *
@@ -65,7 +65,7 @@
65 * 65 *
66 * DESCRIPTION: Create a new named alias 66 * DESCRIPTION: Create a new named alias
67 * 67 *
68 ****************************************************************************/ 68 ******************************************************************************/
69 69
70acpi_status 70acpi_status
71acpi_ex_create_alias ( 71acpi_ex_create_alias (
@@ -140,8 +140,7 @@ acpi_ex_create_alias (
140 * target node or the alias Node 140 * target node or the alias Node
141 */ 141 */
142 status = acpi_ns_attach_object (alias_node, 142 status = acpi_ns_attach_object (alias_node,
143 acpi_ns_get_attached_object (target_node), 143 acpi_ns_get_attached_object (target_node), target_node->type);
144 target_node->type);
145 break; 144 break;
146 } 145 }
147 146
@@ -151,7 +150,7 @@ acpi_ex_create_alias (
151} 150}
152 151
153 152
154/***************************************************************************** 153/*******************************************************************************
155 * 154 *
156 * FUNCTION: acpi_ex_create_event 155 * FUNCTION: acpi_ex_create_event
157 * 156 *
@@ -161,7 +160,7 @@ acpi_ex_create_alias (
161 * 160 *
162 * DESCRIPTION: Create a new event object 161 * DESCRIPTION: Create a new event object
163 * 162 *
164 ****************************************************************************/ 163 ******************************************************************************/
165 164
166acpi_status 165acpi_status
167acpi_ex_create_event ( 166acpi_ex_create_event (
@@ -185,7 +184,7 @@ acpi_ex_create_event (
185 * that the event is created in an unsignalled state 184 * that the event is created in an unsignalled state
186 */ 185 */
187 status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0, 186 status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0,
188 &obj_desc->event.semaphore); 187 &obj_desc->event.semaphore);
189 if (ACPI_FAILURE (status)) { 188 if (ACPI_FAILURE (status)) {
190 goto cleanup; 189 goto cleanup;
191 } 190 }
@@ -193,7 +192,7 @@ acpi_ex_create_event (
193 /* Attach object to the Node */ 192 /* Attach object to the Node */
194 193
195 status = acpi_ns_attach_object ((struct acpi_namespace_node *) walk_state->operands[0], 194 status = acpi_ns_attach_object ((struct acpi_namespace_node *) walk_state->operands[0],
196 obj_desc, ACPI_TYPE_EVENT); 195 obj_desc, ACPI_TYPE_EVENT);
197 196
198cleanup: 197cleanup:
199 /* 198 /*
@@ -205,7 +204,7 @@ cleanup:
205} 204}
206 205
207 206
208/***************************************************************************** 207/*******************************************************************************
209 * 208 *
210 * FUNCTION: acpi_ex_create_mutex 209 * FUNCTION: acpi_ex_create_mutex
211 * 210 *
@@ -217,7 +216,7 @@ cleanup:
217 * 216 *
218 * Mutex (Name[0], sync_level[1]) 217 * Mutex (Name[0], sync_level[1])
219 * 218 *
220 ****************************************************************************/ 219 ******************************************************************************/
221 220
222acpi_status 221acpi_status
223acpi_ex_create_mutex ( 222acpi_ex_create_mutex (
@@ -267,20 +266,20 @@ cleanup:
267} 266}
268 267
269 268
270/***************************************************************************** 269/*******************************************************************************
271 * 270 *
272 * FUNCTION: acpi_ex_create_region 271 * FUNCTION: acpi_ex_create_region
273 * 272 *
274 * PARAMETERS: aml_start - Pointer to the region declaration AML 273 * PARAMETERS: aml_start - Pointer to the region declaration AML
275 * aml_length - Max length of the declaration AML 274 * aml_length - Max length of the declaration AML
276 * Operands - List of operands for the opcode 275 * region_space - space_iD for the region
277 * walk_state - Current state 276 * walk_state - Current state
278 * 277 *
279 * RETURN: Status 278 * RETURN: Status
280 * 279 *
281 * DESCRIPTION: Create a new operation region object 280 * DESCRIPTION: Create a new operation region object
282 * 281 *
283 ****************************************************************************/ 282 ******************************************************************************/
284 283
285acpi_status 284acpi_status
286acpi_ex_create_region ( 285acpi_ex_create_region (
@@ -321,7 +320,7 @@ acpi_ex_create_region (
321 } 320 }
322 321
323 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", 322 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
324 acpi_ut_get_region_name (region_space), region_space)); 323 acpi_ut_get_region_name (region_space), region_space));
325 324
326 /* Create the region descriptor */ 325 /* Create the region descriptor */
327 326
@@ -360,7 +359,7 @@ cleanup:
360} 359}
361 360
362 361
363/***************************************************************************** 362/*******************************************************************************
364 * 363 *
365 * FUNCTION: acpi_ex_create_table_region 364 * FUNCTION: acpi_ex_create_table_region
366 * 365 *
@@ -370,7 +369,7 @@ cleanup:
370 * 369 *
371 * DESCRIPTION: Create a new data_table_region object 370 * DESCRIPTION: Create a new data_table_region object
372 * 371 *
373 ****************************************************************************/ 372 ******************************************************************************/
374 373
375acpi_status 374acpi_status
376acpi_ex_create_table_region ( 375acpi_ex_create_table_region (
@@ -455,7 +454,7 @@ cleanup:
455} 454}
456 455
457 456
458/***************************************************************************** 457/*******************************************************************************
459 * 458 *
460 * FUNCTION: acpi_ex_create_processor 459 * FUNCTION: acpi_ex_create_processor
461 * 460 *
@@ -467,7 +466,7 @@ cleanup:
467 * 466 *
468 * Processor (Name[0], cpu_iD[1], pblock_addr[2], pblock_length[3]) 467 * Processor (Name[0], cpu_iD[1], pblock_addr[2], pblock_length[3])
469 * 468 *
470 ****************************************************************************/ 469 ******************************************************************************/
471 470
472acpi_status 471acpi_status
473acpi_ex_create_processor ( 472acpi_ex_create_processor (
@@ -488,9 +487,8 @@ acpi_ex_create_processor (
488 return_ACPI_STATUS (AE_NO_MEMORY); 487 return_ACPI_STATUS (AE_NO_MEMORY);
489 } 488 }
490 489
491 /* 490 /* Initialize the processor object from the operands */
492 * Initialize the processor object from the operands 491
493 */
494 obj_desc->processor.proc_id = (u8) operand[1]->integer.value; 492 obj_desc->processor.proc_id = (u8) operand[1]->integer.value;
495 obj_desc->processor.address = (acpi_io_address) operand[2]->integer.value; 493 obj_desc->processor.address = (acpi_io_address) operand[2]->integer.value;
496 obj_desc->processor.length = (u8) operand[3]->integer.value; 494 obj_desc->processor.length = (u8) operand[3]->integer.value;
@@ -507,7 +505,7 @@ acpi_ex_create_processor (
507} 505}
508 506
509 507
510/***************************************************************************** 508/*******************************************************************************
511 * 509 *
512 * FUNCTION: acpi_ex_create_power_resource 510 * FUNCTION: acpi_ex_create_power_resource
513 * 511 *
@@ -519,7 +517,7 @@ acpi_ex_create_processor (
519 * 517 *
520 * power_resource (Name[0], system_level[1], resource_order[2]) 518 * power_resource (Name[0], system_level[1], resource_order[2])
521 * 519 *
522 ****************************************************************************/ 520 ******************************************************************************/
523 521
524acpi_status 522acpi_status
525acpi_ex_create_power_resource ( 523acpi_ex_create_power_resource (
@@ -555,10 +553,10 @@ acpi_ex_create_power_resource (
555 acpi_ut_remove_reference (obj_desc); 553 acpi_ut_remove_reference (obj_desc);
556 return_ACPI_STATUS (status); 554 return_ACPI_STATUS (status);
557} 555}
558
559#endif 556#endif
560 557
561/***************************************************************************** 558
559/*******************************************************************************
562 * 560 *
563 * FUNCTION: acpi_ex_create_method 561 * FUNCTION: acpi_ex_create_method
564 * 562 *
@@ -570,7 +568,7 @@ acpi_ex_create_power_resource (
570 * 568 *
571 * DESCRIPTION: Create a new method object 569 * DESCRIPTION: Create a new method object
572 * 570 *
573 ****************************************************************************/ 571 ******************************************************************************/
574 572
575acpi_status 573acpi_status
576acpi_ex_create_method ( 574acpi_ex_create_method (
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index e2f7c32f28de..408500648114 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -51,23 +51,48 @@
51#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
52 ACPI_MODULE_NAME ("exdump") 52 ACPI_MODULE_NAME ("exdump")
53 53
54/* Local prototypes */
55
56#ifdef ACPI_FUTURE_USAGE
57static void
58acpi_ex_out_string (
59 char *title,
60 char *value);
61
62static void
63acpi_ex_out_pointer (
64 char *title,
65 void *value);
66
67static void
68acpi_ex_out_integer (
69 char *title,
70 u32 value);
71
72static void
73acpi_ex_out_address (
74 char *title,
75 acpi_physical_address value);
76#endif /* ACPI_FUTURE_USAGE */
77
54 78
55/* 79/*
56 * The following routines are used for debug output only 80 * The following routines are used for debug output only
57 */ 81 */
58#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 82#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
59 83
60/***************************************************************************** 84/*******************************************************************************
61 * 85 *
62 * FUNCTION: acpi_ex_dump_operand 86 * FUNCTION: acpi_ex_dump_operand
63 * 87 *
64 * PARAMETERS: *obj_desc - Pointer to entry to be dumped 88 * PARAMETERS: *obj_desc - Pointer to entry to be dumped
89 * Depth - Current nesting depth
65 * 90 *
66 * RETURN: None 91 * RETURN: None
67 * 92 *
68 * DESCRIPTION: Dump an operand object 93 * DESCRIPTION: Dump an operand object
69 * 94 *
70 ****************************************************************************/ 95 ******************************************************************************/
71 96
72void 97void
73acpi_ex_dump_operand ( 98acpi_ex_dump_operand (
@@ -86,9 +111,8 @@ acpi_ex_dump_operand (
86 } 111 }
87 112
88 if (!obj_desc) { 113 if (!obj_desc) {
89 /* 114 /* This could be a null element of a package */
90 * This could be a null element of a package 115
91 */
92 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); 116 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
93 return; 117 return;
94 } 118 }
@@ -117,6 +141,8 @@ acpi_ex_dump_operand (
117 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc)); 141 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc));
118 } 142 }
119 143
144 /* Decode object type */
145
120 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 146 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
121 case ACPI_TYPE_LOCAL_REFERENCE: 147 case ACPI_TYPE_LOCAL_REFERENCE:
122 148
@@ -274,7 +300,9 @@ acpi_ex_dump_operand (
274 case ACPI_TYPE_STRING: 300 case ACPI_TYPE_STRING:
275 301
276 acpi_os_printf ("String length %X @ %p ", 302 acpi_os_printf ("String length %X @ %p ",
277 obj_desc->string.length, obj_desc->string.pointer); 303 obj_desc->string.length,
304 obj_desc->string.pointer);
305
278 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX); 306 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
279 acpi_os_printf ("\n"); 307 acpi_os_printf ("\n");
280 break; 308 break;
@@ -290,10 +318,13 @@ acpi_ex_dump_operand (
290 318
291 acpi_os_printf ( 319 acpi_os_printf (
292 "region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", 320 "region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
293 obj_desc->field.bit_length, obj_desc->field.access_byte_width, 321 obj_desc->field.bit_length,
322 obj_desc->field.access_byte_width,
294 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK, 323 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
295 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK, 324 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
296 obj_desc->field.base_byte_offset, obj_desc->field.start_field_bit_offset); 325 obj_desc->field.base_byte_offset,
326 obj_desc->field.start_field_bit_offset);
327
297 acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1); 328 acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1);
298 break; 329 break;
299 330
@@ -308,13 +339,15 @@ acpi_ex_dump_operand (
308 339
309 acpi_os_printf ( 340 acpi_os_printf (
310 "buffer_field: %X bits at byte %X bit %X of \n", 341 "buffer_field: %X bits at byte %X bit %X of \n",
311 obj_desc->buffer_field.bit_length, obj_desc->buffer_field.base_byte_offset, 342 obj_desc->buffer_field.bit_length,
343 obj_desc->buffer_field.base_byte_offset,
312 obj_desc->buffer_field.start_field_bit_offset); 344 obj_desc->buffer_field.start_field_bit_offset);
313 345
314 if (!obj_desc->buffer_field.buffer_obj) { 346 if (!obj_desc->buffer_field.buffer_obj) {
315 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n")); 347 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n"));
316 } 348 }
317 else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != ACPI_TYPE_BUFFER) { 349 else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) !=
350 ACPI_TYPE_BUFFER) {
318 acpi_os_printf ("*not a Buffer* \n"); 351 acpi_os_printf ("*not a Buffer* \n");
319 } 352 }
320 else { 353 else {
@@ -331,10 +364,10 @@ acpi_ex_dump_operand (
331 364
332 case ACPI_TYPE_METHOD: 365 case ACPI_TYPE_METHOD:
333 366
334 acpi_os_printf ( 367 acpi_os_printf ("Method(%X) @ %p:%X\n",
335 "Method(%X) @ %p:%X\n",
336 obj_desc->method.param_count, 368 obj_desc->method.param_count,
337 obj_desc->method.aml_start, obj_desc->method.aml_length); 369 obj_desc->method.aml_start,
370 obj_desc->method.aml_length);
338 break; 371 break;
339 372
340 373
@@ -379,7 +412,7 @@ acpi_ex_dump_operand (
379} 412}
380 413
381 414
382/***************************************************************************** 415/*******************************************************************************
383 * 416 *
384 * FUNCTION: acpi_ex_dump_operands 417 * FUNCTION: acpi_ex_dump_operands
385 * 418 *
@@ -393,7 +426,7 @@ acpi_ex_dump_operand (
393 * 426 *
394 * DESCRIPTION: Dump the object stack 427 * DESCRIPTION: Dump the object stack
395 * 428 *
396 ****************************************************************************/ 429 ******************************************************************************/
397 430
398void 431void
399acpi_ex_dump_operands ( 432acpi_ex_dump_operands (
@@ -441,10 +474,9 @@ acpi_ex_dump_operands (
441 474
442 475
443#ifdef ACPI_FUTURE_USAGE 476#ifdef ACPI_FUTURE_USAGE
444 477/*******************************************************************************
445/*****************************************************************************
446 * 478 *
447 * FUNCTION: acpi_ex_out* 479 * FUNCTION: acpi_ex_out* functions
448 * 480 *
449 * PARAMETERS: Title - Descriptive text 481 * PARAMETERS: Title - Descriptive text
450 * Value - Value to be displayed 482 * Value - Value to be displayed
@@ -453,9 +485,9 @@ acpi_ex_dump_operands (
453 * reduce the number of format strings required and keeps them 485 * reduce the number of format strings required and keeps them
454 * all in one place for easy modification. 486 * all in one place for easy modification.
455 * 487 *
456 ****************************************************************************/ 488 ******************************************************************************/
457 489
458void 490static void
459acpi_ex_out_string ( 491acpi_ex_out_string (
460 char *title, 492 char *title,
461 char *value) 493 char *value)
@@ -463,7 +495,7 @@ acpi_ex_out_string (
463 acpi_os_printf ("%20s : %s\n", title, value); 495 acpi_os_printf ("%20s : %s\n", title, value);
464} 496}
465 497
466void 498static void
467acpi_ex_out_pointer ( 499acpi_ex_out_pointer (
468 char *title, 500 char *title,
469 void *value) 501 void *value)
@@ -471,7 +503,7 @@ acpi_ex_out_pointer (
471 acpi_os_printf ("%20s : %p\n", title, value); 503 acpi_os_printf ("%20s : %p\n", title, value);
472} 504}
473 505
474void 506static void
475acpi_ex_out_integer ( 507acpi_ex_out_integer (
476 char *title, 508 char *title,
477 u32 value) 509 u32 value)
@@ -479,7 +511,7 @@ acpi_ex_out_integer (
479 acpi_os_printf ("%20s : %X\n", title, value); 511 acpi_os_printf ("%20s : %X\n", title, value);
480} 512}
481 513
482void 514static void
483acpi_ex_out_address ( 515acpi_ex_out_address (
484 char *title, 516 char *title,
485 acpi_physical_address value) 517 acpi_physical_address value)
@@ -493,16 +525,16 @@ acpi_ex_out_address (
493} 525}
494 526
495 527
496/***************************************************************************** 528/*******************************************************************************
497 * 529 *
498 * FUNCTION: acpi_ex_dump_node 530 * FUNCTION: acpi_ex_dump_node
499 * 531 *
500 * PARAMETERS: *Node - Descriptor to dump 532 * PARAMETERS: *Node - Descriptor to dump
501 * Flags - Force display 533 * Flags - Force display if TRUE
502 * 534 *
503 * DESCRIPTION: Dumps the members of the given.Node 535 * DESCRIPTION: Dumps the members of the given.Node
504 * 536 *
505 ****************************************************************************/ 537 ******************************************************************************/
506 538
507void 539void
508acpi_ex_dump_node ( 540acpi_ex_dump_node (
@@ -531,16 +563,16 @@ acpi_ex_dump_node (
531} 563}
532 564
533 565
534/***************************************************************************** 566/*******************************************************************************
535 * 567 *
536 * FUNCTION: acpi_ex_dump_object_descriptor 568 * FUNCTION: acpi_ex_dump_object_descriptor
537 * 569 *
538 * PARAMETERS: *Object - Descriptor to dump 570 * PARAMETERS: *Object - Descriptor to dump
539 * Flags - Force display 571 * Flags - Force display if TRUE
540 * 572 *
541 * DESCRIPTION: Dumps the members of the object descriptor given. 573 * DESCRIPTION: Dumps the members of the object descriptor given.
542 * 574 *
543 ****************************************************************************/ 575 ******************************************************************************/
544 576
545void 577void
546acpi_ex_dump_object_descriptor ( 578acpi_ex_dump_object_descriptor (
@@ -553,6 +585,10 @@ acpi_ex_dump_object_descriptor (
553 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); 585 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
554 586
555 587
588 if (!obj_desc) {
589 return_VOID;
590 }
591
556 if (!flags) { 592 if (!flags) {
557 if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { 593 if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
558 return_VOID; 594 return_VOID;
@@ -747,11 +783,17 @@ acpi_ex_dump_object_descriptor (
747 case ACPI_TYPE_LOCAL_REFERENCE: 783 case ACPI_TYPE_LOCAL_REFERENCE:
748 784
749 acpi_ex_out_integer ("target_type", obj_desc->reference.target_type); 785 acpi_ex_out_integer ("target_type", obj_desc->reference.target_type);
750 acpi_ex_out_string ("Opcode", (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name); 786 acpi_ex_out_string ("Opcode", (acpi_ps_get_opcode_info (
787 obj_desc->reference.opcode))->name);
751 acpi_ex_out_integer ("Offset", obj_desc->reference.offset); 788 acpi_ex_out_integer ("Offset", obj_desc->reference.offset);
752 acpi_ex_out_pointer ("obj_desc", obj_desc->reference.object); 789 acpi_ex_out_pointer ("obj_desc", obj_desc->reference.object);
753 acpi_ex_out_pointer ("Node", obj_desc->reference.node); 790 acpi_ex_out_pointer ("Node", obj_desc->reference.node);
754 acpi_ex_out_pointer ("Where", obj_desc->reference.where); 791 acpi_ex_out_pointer ("Where", obj_desc->reference.where);
792
793 if (obj_desc->reference.object) {
794 acpi_os_printf ("\nReferenced Object:\n");
795 acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags);
796 }
755 break; 797 break;
756 798
757 799
@@ -788,6 +830,5 @@ acpi_ex_dump_object_descriptor (
788} 830}
789 831
790#endif /* ACPI_FUTURE_USAGE */ 832#endif /* ACPI_FUTURE_USAGE */
791
792#endif 833#endif
793 834
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c
index be7f2124fa02..22c8fa480f60 100644
--- a/drivers/acpi/executer/exfield.c
+++ b/drivers/acpi/executer/exfield.c
@@ -120,8 +120,8 @@ acpi_ex_read_data_from_field (
120 * Note: Smbus protocol value is passed in upper 16-bits of Function 120 * Note: Smbus protocol value is passed in upper 16-bits of Function
121 */ 121 */
122 status = acpi_ex_access_region (obj_desc, 0, 122 status = acpi_ex_access_region (obj_desc, 0,
123 ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer), 123 ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer),
124 ACPI_READ | (obj_desc->field.attribute << 16)); 124 ACPI_READ | (obj_desc->field.attribute << 16));
125 acpi_ex_release_global_lock (locked); 125 acpi_ex_release_global_lock (locked);
126 goto exit; 126 goto exit;
127 } 127 }
@@ -196,6 +196,7 @@ exit:
196 * 196 *
197 * PARAMETERS: source_desc - Contains data to write 197 * PARAMETERS: source_desc - Contains data to write
198 * obj_desc - The named field 198 * obj_desc - The named field
199 * result_desc - Where the return value is returned, if any
199 * 200 *
200 * RETURN: Status 201 * RETURN: Status
201 * 202 *
@@ -250,12 +251,15 @@ acpi_ex_write_data_to_field (
250 if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) { 251 if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) {
251 ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n", 252 ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n",
252 acpi_ut_get_object_type_name (source_desc))); 253 acpi_ut_get_object_type_name (source_desc)));
254
253 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 255 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
254 } 256 }
255 257
256 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) { 258 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) {
257 ACPI_REPORT_ERROR (("SMBus write requires Buffer of length %X, found length %X\n", 259 ACPI_REPORT_ERROR ((
260 "SMBus write requires Buffer of length %X, found length %X\n",
258 ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length)); 261 ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length));
262
259 return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); 263 return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
260 } 264 }
261 265
@@ -265,14 +269,16 @@ acpi_ex_write_data_to_field (
265 } 269 }
266 270
267 buffer = buffer_desc->buffer.pointer; 271 buffer = buffer_desc->buffer.pointer;
268 ACPI_MEMCPY (buffer, source_desc->buffer.pointer, ACPI_SMBUS_BUFFER_SIZE); 272 ACPI_MEMCPY (buffer, source_desc->buffer.pointer,
273 ACPI_SMBUS_BUFFER_SIZE);
269 274
270 /* Lock entire transaction if requested */ 275 /* Lock entire transaction if requested */
271 276
272 locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags); 277 locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
273 278
274 /* 279 /*
275 * Perform the write (returns status and perhaps data in the same buffer) 280 * Perform the write (returns status and perhaps data in the
281 * same buffer)
276 * Note: SMBus protocol type is passed in upper 16-bits of Function. 282 * Note: SMBus protocol type is passed in upper 16-bits of Function.
277 */ 283 */
278 status = acpi_ex_access_region (obj_desc, 0, 284 status = acpi_ex_access_region (obj_desc, 0,
@@ -284,9 +290,8 @@ acpi_ex_write_data_to_field (
284 return_ACPI_STATUS (status); 290 return_ACPI_STATUS (status);
285 } 291 }
286 292
287 /* 293 /* Get a pointer to the data to be written */
288 * Get a pointer to the data to be written 294
289 */
290 switch (ACPI_GET_OBJECT_TYPE (source_desc)) { 295 switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
291 case ACPI_TYPE_INTEGER: 296 case ACPI_TYPE_INTEGER:
292 buffer = &source_desc->integer.value; 297 buffer = &source_desc->integer.value;
@@ -314,7 +319,8 @@ acpi_ex_write_data_to_field (
314 * the ACPI specification. 319 * the ACPI specification.
315 */ 320 */
316 new_buffer = NULL; 321 new_buffer = NULL;
317 required_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length); 322 required_length = ACPI_ROUND_BITS_UP_TO_BYTES (
323 obj_desc->common_field.bit_length);
318 324
319 if (length < required_length) { 325 if (length < required_length) {
320 /* We need to create a new buffer */ 326 /* We need to create a new buffer */
@@ -338,6 +344,7 @@ acpi_ex_write_data_to_field (
338 "field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n", 344 "field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n",
339 source_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (source_desc)), 345 source_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (source_desc)),
340 ACPI_GET_OBJECT_TYPE (source_desc), buffer, length)); 346 ACPI_GET_OBJECT_TYPE (source_desc), buffer, length));
347
341 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 348 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
342 "field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n", 349 "field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n",
343 obj_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)), 350 obj_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)),
diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
index 9d0f9d2e9061..3c2f89e00f78 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/executer/exfldio.c
@@ -52,12 +52,31 @@
52#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exfldio") 53 ACPI_MODULE_NAME ("exfldio")
54 54
55/* Local prototypes */
56
57static acpi_status
58acpi_ex_field_datum_io (
59 union acpi_operand_object *obj_desc,
60 u32 field_datum_byte_offset,
61 acpi_integer *value,
62 u32 read_write);
63
64static u8
65acpi_ex_register_overflow (
66 union acpi_operand_object *obj_desc,
67 acpi_integer value);
68
69static acpi_status
70acpi_ex_setup_region (
71 union acpi_operand_object *obj_desc,
72 u32 field_datum_byte_offset);
73
55 74
56/******************************************************************************* 75/*******************************************************************************
57 * 76 *
58 * FUNCTION: acpi_ex_setup_region 77 * FUNCTION: acpi_ex_setup_region
59 * 78 *
60 * PARAMETERS: *obj_desc - Field to be read or written 79 * PARAMETERS: obj_desc - Field to be read or written
61 * field_datum_byte_offset - Byte offset of this datum within the 80 * field_datum_byte_offset - Byte offset of this datum within the
62 * parent field 81 * parent field
63 * 82 *
@@ -69,7 +88,7 @@
69 * 88 *
70 ******************************************************************************/ 89 ******************************************************************************/
71 90
72acpi_status 91static acpi_status
73acpi_ex_setup_region ( 92acpi_ex_setup_region (
74 union acpi_operand_object *obj_desc, 93 union acpi_operand_object *obj_desc,
75 u32 field_datum_byte_offset) 94 u32 field_datum_byte_offset)
@@ -127,9 +146,9 @@ acpi_ex_setup_region (
127 * length of one field datum (access width) must fit within the region. 146 * length of one field datum (access width) must fit within the region.
128 * (Region length is specified in bytes) 147 * (Region length is specified in bytes)
129 */ 148 */
130 if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset 149 if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset +
131 + field_datum_byte_offset 150 field_datum_byte_offset +
132 + obj_desc->common_field.access_byte_width)) { 151 obj_desc->common_field.access_byte_width)) {
133 if (acpi_gbl_enable_interpreter_slack) { 152 if (acpi_gbl_enable_interpreter_slack) {
134 /* 153 /*
135 * Slack mode only: We will go ahead and allow access to this 154 * Slack mode only: We will go ahead and allow access to this
@@ -155,7 +174,8 @@ acpi_ex_setup_region (
155 "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", 174 "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n",
156 acpi_ut_get_node_name (obj_desc->common_field.node), 175 acpi_ut_get_node_name (obj_desc->common_field.node),
157 obj_desc->common_field.access_byte_width, 176 obj_desc->common_field.access_byte_width,
158 acpi_ut_get_node_name (rgn_desc->region.node), rgn_desc->region.length)); 177 acpi_ut_get_node_name (rgn_desc->region.node),
178 rgn_desc->region.length));
159 } 179 }
160 180
161 /* 181 /*
@@ -167,7 +187,8 @@ acpi_ex_setup_region (
167 acpi_ut_get_node_name (obj_desc->common_field.node), 187 acpi_ut_get_node_name (obj_desc->common_field.node),
168 obj_desc->common_field.base_byte_offset, 188 obj_desc->common_field.base_byte_offset,
169 field_datum_byte_offset, obj_desc->common_field.access_byte_width, 189 field_datum_byte_offset, obj_desc->common_field.access_byte_width,
170 acpi_ut_get_node_name (rgn_desc->region.node), rgn_desc->region.length)); 190 acpi_ut_get_node_name (rgn_desc->region.node),
191 rgn_desc->region.length));
171 192
172 return_ACPI_STATUS (AE_AML_REGION_LIMIT); 193 return_ACPI_STATUS (AE_AML_REGION_LIMIT);
173 } 194 }
@@ -180,10 +201,10 @@ acpi_ex_setup_region (
180 * 201 *
181 * FUNCTION: acpi_ex_access_region 202 * FUNCTION: acpi_ex_access_region
182 * 203 *
183 * PARAMETERS: *obj_desc - Field to be read 204 * PARAMETERS: obj_desc - Field to be read
184 * field_datum_byte_offset - Byte offset of this datum within the 205 * field_datum_byte_offset - Byte offset of this datum within the
185 * parent field 206 * parent field
186 * *Value - Where to store value (must at least 207 * Value - Where to store value (must at least
187 * the size of acpi_integer) 208 * the size of acpi_integer)
188 * Function - Read or Write flag plus other region- 209 * Function - Read or Write flag plus other region-
189 * dependent flags 210 * dependent flags
@@ -226,9 +247,9 @@ acpi_ex_access_region (
226 * 3) The current offset into the field 247 * 3) The current offset into the field
227 */ 248 */
228 rgn_desc = obj_desc->common_field.region_obj; 249 rgn_desc = obj_desc->common_field.region_obj;
229 address = rgn_desc->region.address 250 address = rgn_desc->region.address +
230 + obj_desc->common_field.base_byte_offset 251 obj_desc->common_field.base_byte_offset +
231 + field_datum_byte_offset; 252 field_datum_byte_offset;
232 253
233 if ((function & ACPI_IO_MASK) == ACPI_READ) { 254 if ((function & ACPI_IO_MASK) == ACPI_READ) {
234 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]")); 255 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
@@ -249,7 +270,8 @@ acpi_ex_access_region (
249 /* Invoke the appropriate address_space/op_region handler */ 270 /* Invoke the appropriate address_space/op_region handler */
250 271
251 status = acpi_ev_address_space_dispatch (rgn_desc, function, 272 status = acpi_ev_address_space_dispatch (rgn_desc, function,
252 address, ACPI_MUL_8 (obj_desc->common_field.access_byte_width), value); 273 address,
274 ACPI_MUL_8 (obj_desc->common_field.access_byte_width), value);
253 275
254 if (ACPI_FAILURE (status)) { 276 if (ACPI_FAILURE (status)) {
255 if (status == AE_NOT_IMPLEMENTED) { 277 if (status == AE_NOT_IMPLEMENTED) {
@@ -274,7 +296,7 @@ acpi_ex_access_region (
274 * 296 *
275 * FUNCTION: acpi_ex_register_overflow 297 * FUNCTION: acpi_ex_register_overflow
276 * 298 *
277 * PARAMETERS: *obj_desc - Register(Field) to be written 299 * PARAMETERS: obj_desc - Register(Field) to be written
278 * Value - Value to be stored 300 * Value - Value to be stored
279 * 301 *
280 * RETURN: TRUE if value overflows the field, FALSE otherwise 302 * RETURN: TRUE if value overflows the field, FALSE otherwise
@@ -287,7 +309,7 @@ acpi_ex_access_region (
287 * 309 *
288 ******************************************************************************/ 310 ******************************************************************************/
289 311
290u8 312static u8
291acpi_ex_register_overflow ( 313acpi_ex_register_overflow (
292 union acpi_operand_object *obj_desc, 314 union acpi_operand_object *obj_desc,
293 acpi_integer value) 315 acpi_integer value)
@@ -319,10 +341,10 @@ acpi_ex_register_overflow (
319 * 341 *
320 * FUNCTION: acpi_ex_field_datum_io 342 * FUNCTION: acpi_ex_field_datum_io
321 * 343 *
322 * PARAMETERS: *obj_desc - Field to be read 344 * PARAMETERS: obj_desc - Field to be read
323 * field_datum_byte_offset - Byte offset of this datum within the 345 * field_datum_byte_offset - Byte offset of this datum within the
324 * parent field 346 * parent field
325 * *Value - Where to store value (must be 64 bits) 347 * Value - Where to store value (must be 64 bits)
326 * read_write - Read or Write flag 348 * read_write - Read or Write flag
327 * 349 *
328 * RETURN: Status 350 * RETURN: Status
@@ -333,7 +355,7 @@ acpi_ex_register_overflow (
333 * 355 *
334 ******************************************************************************/ 356 ******************************************************************************/
335 357
336acpi_status 358static acpi_status
337acpi_ex_field_datum_io ( 359acpi_ex_field_datum_io (
338 union acpi_operand_object *obj_desc, 360 union acpi_operand_object *obj_desc,
339 u32 field_datum_byte_offset, 361 u32 field_datum_byte_offset,
@@ -350,7 +372,9 @@ acpi_ex_field_datum_io (
350 if (read_write == ACPI_READ) { 372 if (read_write == ACPI_READ) {
351 if (!value) { 373 if (!value) {
352 local_value = 0; 374 local_value = 0;
353 value = &local_value; /* To support reads without saving return value */ 375
376 /* To support reads without saving return value */
377 value = &local_value;
354 } 378 }
355 379
356 /* Clear the entire return buffer first, [Very Important!] */ 380 /* Clear the entire return buffer first, [Very Important!] */
@@ -363,8 +387,10 @@ acpi_ex_field_datum_io (
363 * 387 *
364 * buffer_field - Read/write from/to a Buffer 388 * buffer_field - Read/write from/to a Buffer
365 * region_field - Read/write from/to a Operation Region. 389 * region_field - Read/write from/to a Operation Region.
366 * bank_field - Write to a Bank Register, then read/write from/to an op_region 390 * bank_field - Write to a Bank Register, then read/write from/to an
367 * index_field - Write to an Index Register, then read/write from/to a Data Register 391 * operation_region
392 * index_field - Write to an Index Register, then read/write from/to a
393 * Data Register
368 */ 394 */
369 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 395 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
370 case ACPI_TYPE_BUFFER_FIELD: 396 case ACPI_TYPE_BUFFER_FIELD:
@@ -384,19 +410,20 @@ acpi_ex_field_datum_io (
384 * Copy the data from the source buffer. 410 * Copy the data from the source buffer.
385 * Length is the field width in bytes. 411 * Length is the field width in bytes.
386 */ 412 */
387 ACPI_MEMCPY (value, (obj_desc->buffer_field.buffer_obj)->buffer.pointer 413 ACPI_MEMCPY (value,
388 + obj_desc->buffer_field.base_byte_offset 414 (obj_desc->buffer_field.buffer_obj)->buffer.pointer +
389 + field_datum_byte_offset, 415 obj_desc->buffer_field.base_byte_offset +
390 obj_desc->common_field.access_byte_width); 416 field_datum_byte_offset,
417 obj_desc->common_field.access_byte_width);
391 } 418 }
392 else { 419 else {
393 /* 420 /*
394 * Copy the data to the target buffer. 421 * Copy the data to the target buffer.
395 * Length is the field width in bytes. 422 * Length is the field width in bytes.
396 */ 423 */
397 ACPI_MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer 424 ACPI_MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer +
398 + obj_desc->buffer_field.base_byte_offset 425 obj_desc->buffer_field.base_byte_offset +
399 + field_datum_byte_offset, 426 field_datum_byte_offset,
400 value, obj_desc->common_field.access_byte_width); 427 value, obj_desc->common_field.access_byte_width);
401 } 428 }
402 429
@@ -406,8 +433,10 @@ acpi_ex_field_datum_io (
406 433
407 case ACPI_TYPE_LOCAL_BANK_FIELD: 434 case ACPI_TYPE_LOCAL_BANK_FIELD:
408 435
409 /* Ensure that the bank_value is not beyond the capacity of the register */ 436 /*
410 437 * Ensure that the bank_value is not beyond the capacity of
438 * the register
439 */
411 if (acpi_ex_register_overflow (obj_desc->bank_field.bank_obj, 440 if (acpi_ex_register_overflow (obj_desc->bank_field.bank_obj,
412 (acpi_integer) obj_desc->bank_field.value)) { 441 (acpi_integer) obj_desc->bank_field.value)) {
413 return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); 442 return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
@@ -445,8 +474,10 @@ acpi_ex_field_datum_io (
445 case ACPI_TYPE_LOCAL_INDEX_FIELD: 474 case ACPI_TYPE_LOCAL_INDEX_FIELD:
446 475
447 476
448 /* Ensure that the index_value is not beyond the capacity of the register */ 477 /*
449 478 * Ensure that the index_value is not beyond the capacity of
479 * the register
480 */
450 if (acpi_ex_register_overflow (obj_desc->index_field.index_obj, 481 if (acpi_ex_register_overflow (obj_desc->index_field.index_obj,
451 (acpi_integer) obj_desc->index_field.value)) { 482 (acpi_integer) obj_desc->index_field.value)) {
452 return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); 483 return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
@@ -496,14 +527,16 @@ acpi_ex_field_datum_io (
496 527
497 if (ACPI_SUCCESS (status)) { 528 if (ACPI_SUCCESS (status)) {
498 if (read_write == ACPI_READ) { 529 if (read_write == ACPI_READ) {
499 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read %8.8X%8.8X, Width %d\n", 530 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
500 ACPI_FORMAT_UINT64 (*value), 531 "Value Read %8.8X%8.8X, Width %d\n",
501 obj_desc->common_field.access_byte_width)); 532 ACPI_FORMAT_UINT64 (*value),
533 obj_desc->common_field.access_byte_width));
502 } 534 }
503 else { 535 else {
504 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written %8.8X%8.8X, Width %d\n", 536 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
505 ACPI_FORMAT_UINT64 (*value), 537 "Value Written %8.8X%8.8X, Width %d\n",
506 obj_desc->common_field.access_byte_width)); 538 ACPI_FORMAT_UINT64 (*value),
539 obj_desc->common_field.access_byte_width));
507 } 540 }
508 } 541 }
509 542
@@ -515,8 +548,10 @@ acpi_ex_field_datum_io (
515 * 548 *
516 * FUNCTION: acpi_ex_write_with_update_rule 549 * FUNCTION: acpi_ex_write_with_update_rule
517 * 550 *
518 * PARAMETERS: *obj_desc - Field to be set 551 * PARAMETERS: obj_desc - Field to be written
519 * Value - Value to store 552 * Mask - bitmask within field datum
553 * field_value - Value to write
554 * field_datum_byte_offset - Offset of datum within field
520 * 555 *
521 * RETURN: Status 556 * RETURN: Status
522 * 557 *
@@ -689,7 +724,8 @@ acpi_ex_extract_from_field (
689 /* Merge with previous datum if necessary */ 724 /* Merge with previous datum if necessary */
690 725
691 merged_datum |= raw_datum << 726 merged_datum |= raw_datum <<
692 (obj_desc->common_field.access_bit_width - obj_desc->common_field.start_field_bit_offset); 727 (obj_desc->common_field.access_bit_width -
728 obj_desc->common_field.start_field_bit_offset);
693 729
694 if (i == datum_count) { 730 if (i == datum_count) {
695 break; 731 break;
@@ -707,7 +743,8 @@ acpi_ex_extract_from_field (
707 743
708 /* Mask off any extra bits in the last datum */ 744 /* Mask off any extra bits in the last datum */
709 745
710 buffer_tail_bits = obj_desc->common_field.bit_length % obj_desc->common_field.access_bit_width; 746 buffer_tail_bits = obj_desc->common_field.bit_length %
747 obj_desc->common_field.access_bit_width;
711 if (buffer_tail_bits) { 748 if (buffer_tail_bits) {
712 merged_datum &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits); 749 merged_datum &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits);
713 } 750 }
@@ -791,7 +828,8 @@ acpi_ex_insert_into_field (
791 /* Write merged datum to the target field */ 828 /* Write merged datum to the target field */
792 829
793 merged_datum &= mask; 830 merged_datum &= mask;
794 status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum, field_offset); 831 status = acpi_ex_write_with_update_rule (obj_desc, mask,
832 merged_datum, field_offset);
795 if (ACPI_FAILURE (status)) { 833 if (ACPI_FAILURE (status)) {
796 return_ACPI_STATUS (status); 834 return_ACPI_STATUS (status);
797 } 835 }
@@ -800,7 +838,8 @@ acpi_ex_insert_into_field (
800 838
801 field_offset += obj_desc->common_field.access_byte_width; 839 field_offset += obj_desc->common_field.access_byte_width;
802 merged_datum = raw_datum >> 840 merged_datum = raw_datum >>
803 (obj_desc->common_field.access_bit_width - obj_desc->common_field.start_field_bit_offset); 841 (obj_desc->common_field.access_bit_width -
842 obj_desc->common_field.start_field_bit_offset);
804 mask = ACPI_INTEGER_MAX; 843 mask = ACPI_INTEGER_MAX;
805 844
806 if (i == datum_count) { 845 if (i == datum_count) {
@@ -819,7 +858,8 @@ acpi_ex_insert_into_field (
819 /* Mask off any extra bits in the last datum */ 858 /* Mask off any extra bits in the last datum */
820 859
821 buffer_tail_bits = (obj_desc->common_field.bit_length + 860 buffer_tail_bits = (obj_desc->common_field.bit_length +
822 obj_desc->common_field.start_field_bit_offset) % obj_desc->common_field.access_bit_width; 861 obj_desc->common_field.start_field_bit_offset) %
862 obj_desc->common_field.access_bit_width;
823 if (buffer_tail_bits) { 863 if (buffer_tail_bits) {
824 mask &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits); 864 mask &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits);
825 } 865 }
@@ -827,7 +867,8 @@ acpi_ex_insert_into_field (
827 /* Write the last datum to the field */ 867 /* Write the last datum to the field */
828 868
829 merged_datum &= mask; 869 merged_datum &= mask;
830 status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum, field_offset); 870 status = acpi_ex_write_with_update_rule (obj_desc,
871 mask, merged_datum, field_offset);
831 872
832 return_ACPI_STATUS (status); 873 return_ACPI_STATUS (status);
833} 874}
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index b542dcd58c07..022f281345b8 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -139,8 +139,9 @@ acpi_ex_get_object_reference (
139 reference_obj->reference.object = referenced_obj; 139 reference_obj->reference.object = referenced_obj;
140 *return_desc = reference_obj; 140 *return_desc = reference_obj;
141 141
142 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p Type [%s], returning Reference %p\n", 142 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
143 obj_desc, acpi_ut_get_object_type_name (obj_desc), *return_desc)); 143 "Object %p Type [%s], returning Reference %p\n",
144 obj_desc, acpi_ut_get_object_type_name (obj_desc), *return_desc));
144 145
145 return_ACPI_STATUS (AE_OK); 146 return_ACPI_STATUS (AE_OK);
146} 147}
@@ -456,7 +457,7 @@ acpi_ex_do_math_op (
456 return (integer0 * integer1); 457 return (integer0 * integer1);
457 458
458 459
459 case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result) */ 460 case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result)*/
460 461
461 return (integer0 << integer1); 462 return (integer0 << integer1);
462 463
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index 68c4bb1970a5..c3cb714d2cba 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -49,6 +49,13 @@
49#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
50 ACPI_MODULE_NAME ("exmutex") 50 ACPI_MODULE_NAME ("exmutex")
51 51
52/* Local prototypes */
53
54static void
55acpi_ex_link_mutex (
56 union acpi_operand_object *obj_desc,
57 struct acpi_thread_state *thread);
58
52 59
53/******************************************************************************* 60/*******************************************************************************
54 * 61 *
@@ -56,7 +63,7 @@
56 * 63 *
57 * PARAMETERS: obj_desc - The mutex to be unlinked 64 * PARAMETERS: obj_desc - The mutex to be unlinked
58 * 65 *
59 * RETURN: Status 66 * RETURN: None
60 * 67 *
61 * DESCRIPTION: Remove a mutex from the "acquired_mutex" list 68 * DESCRIPTION: Remove a mutex from the "acquired_mutex" list
62 * 69 *
@@ -92,16 +99,16 @@ acpi_ex_unlink_mutex (
92 * 99 *
93 * FUNCTION: acpi_ex_link_mutex 100 * FUNCTION: acpi_ex_link_mutex
94 * 101 *
95 * PARAMETERS: obj_desc - The mutex to be linked 102 * PARAMETERS: obj_desc - The mutex to be linked
96 * list_head - head of the "acquired_mutex" list 103 * Thread - Current executing thread object
97 * 104 *
98 * RETURN: Status 105 * RETURN: None
99 * 106 *
100 * DESCRIPTION: Add a mutex to the "acquired_mutex" list for this walk 107 * DESCRIPTION: Add a mutex to the "acquired_mutex" list for this walk
101 * 108 *
102 ******************************************************************************/ 109 ******************************************************************************/
103 110
104void 111static void
105acpi_ex_link_mutex ( 112acpi_ex_link_mutex (
106 union acpi_operand_object *obj_desc, 113 union acpi_operand_object *obj_desc,
107 struct acpi_thread_state *thread) 114 struct acpi_thread_state *thread)
@@ -132,8 +139,9 @@ acpi_ex_link_mutex (
132 * 139 *
133 * FUNCTION: acpi_ex_acquire_mutex 140 * FUNCTION: acpi_ex_acquire_mutex
134 * 141 *
135 * PARAMETERS: time_desc - The 'time to delay' object descriptor 142 * PARAMETERS: time_desc - Timeout integer
136 * obj_desc - The object descriptor for this op 143 * obj_desc - Mutex object
144 * walk_state - Current method execution state
137 * 145 *
138 * RETURN: Status 146 * RETURN: Status
139 * 147 *
@@ -161,7 +169,7 @@ acpi_ex_acquire_mutex (
161 169
162 if (!walk_state->thread) { 170 if (!walk_state->thread) {
163 ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n", 171 ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n",
164 acpi_ut_get_node_name (obj_desc->mutex.node))); 172 acpi_ut_get_node_name (obj_desc->mutex.node)));
165 return_ACPI_STATUS (AE_AML_INTERNAL); 173 return_ACPI_STATUS (AE_AML_INTERNAL);
166 } 174 }
167 175
@@ -170,8 +178,9 @@ acpi_ex_acquire_mutex (
170 * mutex. This mechanism provides some deadlock prevention 178 * mutex. This mechanism provides some deadlock prevention
171 */ 179 */
172 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { 180 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
173 ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], incorrect sync_level\n", 181 ACPI_REPORT_ERROR ((
174 acpi_ut_get_node_name (obj_desc->mutex.node))); 182 "Cannot acquire Mutex [%4.4s], incorrect sync_level\n",
183 acpi_ut_get_node_name (obj_desc->mutex.node)));
175 return_ACPI_STATUS (AE_AML_MUTEX_ORDER); 184 return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
176 } 185 }
177 186
@@ -180,8 +189,10 @@ acpi_ex_acquire_mutex (
180 if (obj_desc->mutex.owner_thread) { 189 if (obj_desc->mutex.owner_thread) {
181 /* Special case for Global Lock, allow all threads */ 190 /* Special case for Global Lock, allow all threads */
182 191
183 if ((obj_desc->mutex.owner_thread->thread_id == walk_state->thread->thread_id) || 192 if ((obj_desc->mutex.owner_thread->thread_id ==
184 (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore)) { 193 walk_state->thread->thread_id) ||
194 (obj_desc->mutex.semaphore ==
195 acpi_gbl_global_lock_semaphore)) {
185 /* 196 /*
186 * The mutex is already owned by this thread, 197 * The mutex is already owned by this thread,
187 * just increment the acquisition depth 198 * just increment the acquisition depth
@@ -221,6 +232,7 @@ acpi_ex_acquire_mutex (
221 * FUNCTION: acpi_ex_release_mutex 232 * FUNCTION: acpi_ex_release_mutex
222 * 233 *
223 * PARAMETERS: obj_desc - The object descriptor for this op 234 * PARAMETERS: obj_desc - The object descriptor for this op
235 * walk_state - Current method execution state
224 * 236 *
225 * RETURN: Status 237 * RETURN: Status
226 * 238 *
@@ -278,8 +290,9 @@ acpi_ex_release_mutex (
278 * equal to the current sync level 290 * equal to the current sync level
279 */ 291 */
280 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { 292 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) {
281 ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], incorrect sync_level\n", 293 ACPI_REPORT_ERROR ((
282 acpi_ut_get_node_name (obj_desc->mutex.node))); 294 "Cannot release Mutex [%4.4s], incorrect sync_level\n",
295 acpi_ut_get_node_name (obj_desc->mutex.node)));
283 return_ACPI_STATUS (AE_AML_MUTEX_ORDER); 296 return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
284 } 297 }
285 298
@@ -313,11 +326,11 @@ acpi_ex_release_mutex (
313 * 326 *
314 * FUNCTION: acpi_ex_release_all_mutexes 327 * FUNCTION: acpi_ex_release_all_mutexes
315 * 328 *
316 * PARAMETERS: mutex_list - Head of the mutex list 329 * PARAMETERS: Thread - Current executing thread object
317 * 330 *
318 * RETURN: Status 331 * RETURN: Status
319 * 332 *
320 * DESCRIPTION: Release all mutexes in the list 333 * DESCRIPTION: Release all mutexes held by this thread
321 * 334 *
322 ******************************************************************************/ 335 ******************************************************************************/
323 336
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c
index 7911c533c265..639f0bd3f6d8 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/executer/exnames.c
@@ -50,13 +50,17 @@
50#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exnames") 51 ACPI_MODULE_NAME ("exnames")
52 52
53/* Local prototypes */
53 54
54/* AML Package Length encodings */ 55static char *
56acpi_ex_allocate_name_string (
57 u32 prefix_count,
58 u32 num_name_segs);
55 59
56#define ACPI_AML_PACKAGE_TYPE1 0x40 60static acpi_status
57#define ACPI_AML_PACKAGE_TYPE2 0x4000 61acpi_ex_name_segment (
58#define ACPI_AML_PACKAGE_TYPE3 0x400000 62 u8 **in_aml_address,
59#define ACPI_AML_PACKAGE_TYPE4 0x40000000 63 char *name_string);
60 64
61 65
62/******************************************************************************* 66/*******************************************************************************
@@ -64,7 +68,7 @@
64 * FUNCTION: acpi_ex_allocate_name_string 68 * FUNCTION: acpi_ex_allocate_name_string
65 * 69 *
66 * PARAMETERS: prefix_count - Count of parent levels. Special cases: 70 * PARAMETERS: prefix_count - Count of parent levels. Special cases:
67 * (-1) = root, 0 = none 71 * (-1)==root, 0==none
68 * num_name_segs - count of 4-character name segments 72 * num_name_segs - count of 4-character name segments
69 * 73 *
70 * RETURN: A pointer to the allocated string segment. This segment must 74 * RETURN: A pointer to the allocated string segment. This segment must
@@ -75,7 +79,7 @@
75 * 79 *
76 ******************************************************************************/ 80 ******************************************************************************/
77 81
78char * 82static char *
79acpi_ex_allocate_name_string ( 83acpi_ex_allocate_name_string (
80 u32 prefix_count, 84 u32 prefix_count,
81 u32 num_name_segs) 85 u32 num_name_segs)
@@ -88,7 +92,7 @@ acpi_ex_allocate_name_string (
88 92
89 93
90 /* 94 /*
91 * Allow room for all \ and ^ prefixes, all segments, and a multi_name_prefix. 95 * Allow room for all \ and ^ prefixes, all segments and a multi_name_prefix.
92 * Also, one byte for the null terminator. 96 * Also, one byte for the null terminator.
93 * This may actually be somewhat longer than needed. 97 * This may actually be somewhat longer than needed.
94 */ 98 */
@@ -107,7 +111,8 @@ acpi_ex_allocate_name_string (
107 */ 111 */
108 name_string = ACPI_MEM_ALLOCATE (size_needed); 112 name_string = ACPI_MEM_ALLOCATE (size_needed);
109 if (!name_string) { 113 if (!name_string) {
110 ACPI_REPORT_ERROR (("ex_allocate_name_string: Could not allocate size %d\n", size_needed)); 114 ACPI_REPORT_ERROR ((
115 "ex_allocate_name_string: Could not allocate size %d\n", size_needed));
111 return_PTR (NULL); 116 return_PTR (NULL);
112 } 117 }
113 118
@@ -152,15 +157,17 @@ acpi_ex_allocate_name_string (
152 * 157 *
153 * FUNCTION: acpi_ex_name_segment 158 * FUNCTION: acpi_ex_name_segment
154 * 159 *
155 * PARAMETERS: interpreter_mode - Current running mode (load1/Load2/Exec) 160 * PARAMETERS: in_aml_address - Pointer to the name in the AML code
161 * name_string - Where to return the name. The name is appended
162 * to any existing string to form a namepath
156 * 163 *
157 * RETURN: Status 164 * RETURN: Status
158 * 165 *
159 * DESCRIPTION: Execute a name segment (4 bytes) 166 * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream
160 * 167 *
161 ******************************************************************************/ 168 ******************************************************************************/
162 169
163acpi_status 170static acpi_status
164acpi_ex_name_segment ( 171acpi_ex_name_segment (
165 u8 **in_aml_address, 172 u8 **in_aml_address,
166 char *name_string) 173 char *name_string)
@@ -223,10 +230,13 @@ acpi_ex_name_segment (
223 status = AE_CTRL_PENDING; 230 status = AE_CTRL_PENDING;
224 } 231 }
225 else { 232 else {
226 /* Segment started with one or more valid characters, but fewer than 4 */ 233 /*
227 234 * Segment started with one or more valid characters, but fewer than
235 * the required 4
236 */
228 status = AE_AML_BAD_NAME; 237 status = AE_AML_BAD_NAME;
229 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad character %02x in name, at %p\n", 238 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
239 "Bad character %02x in name, at %p\n",
230 *aml_address, aml_address)); 240 *aml_address, aml_address));
231 } 241 }
232 242
@@ -239,11 +249,16 @@ acpi_ex_name_segment (
239 * 249 *
240 * FUNCTION: acpi_ex_get_name_string 250 * FUNCTION: acpi_ex_get_name_string
241 * 251 *
242 * PARAMETERS: data_type - Data type to be associated with this name 252 * PARAMETERS: data_type - Object type to be associated with this
253 * name
254 * in_aml_address - Pointer to the namestring in the AML code
255 * out_name_string - Where the namestring is returned
256 * out_name_length - Length of the returned string
243 * 257 *
244 * RETURN: Status 258 * RETURN: Status, namestring and length
245 * 259 *
246 * DESCRIPTION: Get a name, including any prefixes. 260 * DESCRIPTION: Extract a full namepath from the AML byte stream,
261 * including any prefixes.
247 * 262 *
248 ******************************************************************************/ 263 ******************************************************************************/
249 264
@@ -286,7 +301,8 @@ acpi_ex_get_name_string (
286 switch (*aml_address) { 301 switch (*aml_address) {
287 case AML_ROOT_PREFIX: 302 case AML_ROOT_PREFIX:
288 303
289 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "root_prefix(\\) at %p\n", aml_address)); 304 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "root_prefix(\\) at %p\n",
305 aml_address));
290 306
291 /* 307 /*
292 * Remember that we have a root_prefix -- 308 * Remember that we have a root_prefix --
@@ -303,7 +319,8 @@ acpi_ex_get_name_string (
303 /* Increment past possibly multiple parent prefixes */ 319 /* Increment past possibly multiple parent prefixes */
304 320
305 do { 321 do {
306 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "parent_prefix (^) at %p\n", aml_address)); 322 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "parent_prefix (^) at %p\n",
323 aml_address));
307 324
308 aml_address++; 325 aml_address++;
309 prefix_count++; 326 prefix_count++;
@@ -321,13 +338,13 @@ acpi_ex_get_name_string (
321 break; 338 break;
322 } 339 }
323 340
324
325 /* Examine first character of name for name segment prefix operator */ 341 /* Examine first character of name for name segment prefix operator */
326 342
327 switch (*aml_address) { 343 switch (*aml_address) {
328 case AML_DUAL_NAME_PREFIX: 344 case AML_DUAL_NAME_PREFIX:
329 345
330 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "dual_name_prefix at %p\n", aml_address)); 346 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "dual_name_prefix at %p\n",
347 aml_address));
331 348
332 aml_address++; 349 aml_address++;
333 name_string = acpi_ex_allocate_name_string (prefix_count, 2); 350 name_string = acpi_ex_allocate_name_string (prefix_count, 2);
@@ -349,7 +366,8 @@ acpi_ex_get_name_string (
349 366
350 case AML_MULTI_NAME_PREFIX_OP: 367 case AML_MULTI_NAME_PREFIX_OP:
351 368
352 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "multi_name_prefix at %p\n", aml_address)); 369 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "multi_name_prefix at %p\n",
370 aml_address));
353 371
354 /* Fetch count of segments remaining in name path */ 372 /* Fetch count of segments remaining in name path */
355 373
@@ -368,7 +386,8 @@ acpi_ex_get_name_string (
368 has_prefix = TRUE; 386 has_prefix = TRUE;
369 387
370 while (num_segments && 388 while (num_segments &&
371 (status = acpi_ex_name_segment (&aml_address, name_string)) == AE_OK) { 389 (status = acpi_ex_name_segment (&aml_address, name_string)) ==
390 AE_OK) {
372 num_segments--; 391 num_segments--;
373 } 392 }
374 393
@@ -380,7 +399,8 @@ acpi_ex_get_name_string (
380 /* null_name valid as of 8-12-98 ASL/AML Grammar Update */ 399 /* null_name valid as of 8-12-98 ASL/AML Grammar Update */
381 400
382 if (prefix_count == ACPI_UINT32_MAX) { 401 if (prefix_count == ACPI_UINT32_MAX) {
383 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "name_seg is \"\\\" followed by NULL\n")); 402 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
403 "name_seg is \"\\\" followed by NULL\n"));
384 } 404 }
385 405
386 /* Consume the NULL byte */ 406 /* Consume the NULL byte */
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index 8482aefaf38b..dbdf8262ba00 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/executer/exoparg1.c
@@ -97,7 +97,8 @@ acpi_ex_opcode_0A_0T_1R (
97 union acpi_operand_object *return_desc = NULL; 97 union acpi_operand_object *return_desc = NULL;
98 98
99 99
100 ACPI_FUNCTION_TRACE_STR ("ex_opcode_0A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode)); 100 ACPI_FUNCTION_TRACE_STR ("ex_opcode_0A_0T_1R",
101 acpi_ps_get_opcode_name (walk_state->opcode));
101 102
102 103
103 /* Examine the AML opcode */ 104 /* Examine the AML opcode */
@@ -161,7 +162,8 @@ acpi_ex_opcode_1A_0T_0R (
161 acpi_status status = AE_OK; 162 acpi_status status = AE_OK;
162 163
163 164
164 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode)); 165 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R",
166 acpi_ps_get_opcode_name (walk_state->opcode));
165 167
166 168
167 /* Examine the AML opcode */ 169 /* Examine the AML opcode */
@@ -236,7 +238,8 @@ acpi_ex_opcode_1A_1T_0R (
236 union acpi_operand_object **operand = &walk_state->operands[0]; 238 union acpi_operand_object **operand = &walk_state->operands[0];
237 239
238 240
239 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R", acpi_ps_get_opcode_name (walk_state->opcode)); 241 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R",
242 acpi_ps_get_opcode_name (walk_state->opcode));
240 243
241 244
242 /* Examine the AML opcode */ 245 /* Examine the AML opcode */
@@ -289,7 +292,8 @@ acpi_ex_opcode_1A_1T_1R (
289 acpi_integer digit; 292 acpi_integer digit;
290 293
291 294
292 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode)); 295 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R",
296 acpi_ps_get_opcode_name (walk_state->opcode));
293 297
294 298
295 /* Examine the AML opcode */ 299 /* Examine the AML opcode */
@@ -409,8 +413,10 @@ acpi_ex_opcode_1A_1T_1R (
409 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) { 413 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
410 (void) acpi_ut_short_divide (digit, 10, &digit, &temp32); 414 (void) acpi_ut_short_divide (digit, 10, &digit, &temp32);
411 415
412 /* Insert the BCD digit that resides in the remainder from above */ 416 /*
413 417 * Insert the BCD digit that resides in the
418 * remainder from above
419 */
414 return_desc->integer.value |= (((acpi_integer) temp32) << 420 return_desc->integer.value |= (((acpi_integer) temp32) <<
415 ACPI_MUL_4 (i)); 421 ACPI_MUL_4 (i));
416 } 422 }
@@ -445,7 +451,8 @@ acpi_ex_opcode_1A_1T_1R (
445 451
446 /* Get the object reference, store it, and remove our reference */ 452 /* Get the object reference, store it, and remove our reference */
447 453
448 status = acpi_ex_get_object_reference (operand[0], &return_desc2, walk_state); 454 status = acpi_ex_get_object_reference (operand[0],
455 &return_desc2, walk_state);
449 if (ACPI_FAILURE (status)) { 456 if (ACPI_FAILURE (status)) {
450 goto cleanup; 457 goto cleanup;
451 } 458 }
@@ -482,10 +489,10 @@ acpi_ex_opcode_1A_1T_1R (
482 489
483 if (!walk_state->result_obj) { 490 if (!walk_state->result_obj) {
484 /* 491 /*
485 * Normally, we would remove a reference on the Operand[0] parameter; 492 * Normally, we would remove a reference on the Operand[0]
486 * But since it is being used as the internal return object 493 * parameter; But since it is being used as the internal return
487 * (meaning we would normally increment it), the two cancel out, 494 * object (meaning we would normally increment it), the two
488 * and we simply don't do anything. 495 * cancel out, and we simply don't do anything.
489 */ 496 */
490 walk_state->result_obj = operand[0]; 497 walk_state->result_obj = operand[0];
491 walk_state->operands[0] = NULL; /* Prevent deletion */ 498 walk_state->operands[0] = NULL; /* Prevent deletion */
@@ -549,9 +556,8 @@ acpi_ex_opcode_1A_1T_1R (
549 case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */ 556 case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */
550 case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */ 557 case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
551 558
552 /* 559 /* These are two obsolete opcodes */
553 * These are two obsolete opcodes 560
554 */
555 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 561 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
556 "%s is obsolete and not implemented\n", 562 "%s is obsolete and not implemented\n",
557 acpi_ps_get_opcode_name (walk_state->opcode))); 563 acpi_ps_get_opcode_name (walk_state->opcode)));
@@ -568,9 +574,8 @@ acpi_ex_opcode_1A_1T_1R (
568 } 574 }
569 575
570 if (ACPI_SUCCESS (status)) { 576 if (ACPI_SUCCESS (status)) {
571 /* 577 /* Store the return value computed above into the target object */
572 * Store the return value computed above into the target object 578
573 */
574 status = acpi_ex_store (return_desc, operand[1], walk_state); 579 status = acpi_ex_store (return_desc, operand[1], walk_state);
575 } 580 }
576 581
@@ -615,7 +620,8 @@ acpi_ex_opcode_1A_0T_1R (
615 acpi_integer value; 620 acpi_integer value;
616 621
617 622
618 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode)); 623 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R",
624 acpi_ps_get_opcode_name (walk_state->opcode));
619 625
620 626
621 /* Examine the AML opcode */ 627 /* Examine the AML opcode */
@@ -706,9 +712,9 @@ acpi_ex_opcode_1A_0T_1R (
706 712
707 /* 713 /*
708 * Note: The operand is not resolved at this point because we want to 714 * Note: The operand is not resolved at this point because we want to
709 * get the associated object, not its value. For example, we don't want 715 * get the associated object, not its value. For example, we don't
710 * to resolve a field_unit to its value, we want the actual field_unit 716 * want to resolve a field_unit to its value, we want the actual
711 * object. 717 * field_unit object.
712 */ 718 */
713 719
714 /* Get the type of the base object */ 720 /* Get the type of the base object */
@@ -738,7 +744,8 @@ acpi_ex_opcode_1A_0T_1R (
738 744
739 /* Get the base object */ 745 /* Get the base object */
740 746
741 status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, &temp_desc); 747 status = acpi_ex_resolve_multiple (walk_state,
748 operand[0], &type, &temp_desc);
742 if (ACPI_FAILURE (status)) { 749 if (ACPI_FAILURE (status)) {
743 goto cleanup; 750 goto cleanup;
744 } 751 }
@@ -818,8 +825,10 @@ acpi_ex_opcode_1A_0T_1R (
818 825
819 /* Set Operand[0] to the value of the local/arg */ 826 /* Set Operand[0] to the value of the local/arg */
820 827
821 status = acpi_ds_method_data_get_value (operand[0]->reference.opcode, 828 status = acpi_ds_method_data_get_value (
822 operand[0]->reference.offset, walk_state, &temp_desc); 829 operand[0]->reference.opcode,
830 operand[0]->reference.offset,
831 walk_state, &temp_desc);
823 if (ACPI_FAILURE (status)) { 832 if (ACPI_FAILURE (status)) {
824 goto cleanup; 833 goto cleanup;
825 } 834 }
@@ -852,21 +861,26 @@ acpi_ex_opcode_1A_0T_1R (
852 case ACPI_TYPE_STRING: 861 case ACPI_TYPE_STRING:
853 862
854 /* 863 /*
855 * This is a deref_of (String). The string is a reference to a named ACPI object. 864 * This is a deref_of (String). The string is a reference
865 * to a named ACPI object.
856 * 866 *
857 * 1) Find the owning Node 867 * 1) Find the owning Node
858 * 2) Dereference the node to an actual object. Could be a Field, so we nee 868 * 2) Dereference the node to an actual object. Could be a
859 * to resolve the node to a value. 869 * Field, so we need to resolve the node to a value.
860 */ 870 */
861 status = acpi_ns_get_node_by_path (operand[0]->string.pointer, 871 status = acpi_ns_get_node_by_path (operand[0]->string.pointer,
862 walk_state->scope_info->scope.node, ACPI_NS_SEARCH_PARENT, 872 walk_state->scope_info->scope.node,
863 ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &return_desc)); 873 ACPI_NS_SEARCH_PARENT,
874 ACPI_CAST_INDIRECT_PTR (
875 struct acpi_namespace_node, &return_desc));
864 if (ACPI_FAILURE (status)) { 876 if (ACPI_FAILURE (status)) {
865 goto cleanup; 877 goto cleanup;
866 } 878 }
867 879
868 status = acpi_ex_resolve_node_to_value ( 880 status = acpi_ex_resolve_node_to_value (
869 ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &return_desc), walk_state); 881 ACPI_CAST_INDIRECT_PTR (
882 struct acpi_namespace_node, &return_desc),
883 walk_state);
870 goto cleanup; 884 goto cleanup;
871 885
872 886
@@ -883,14 +897,16 @@ acpi_ex_opcode_1A_0T_1R (
883 /* 897 /*
884 * This is a deref_of (object_reference) 898 * This is a deref_of (object_reference)
885 * Get the actual object from the Node (This is the dereference). 899 * Get the actual object from the Node (This is the dereference).
886 * -- This case may only happen when a local_x or arg_x is dereferenced above. 900 * This case may only happen when a local_x or arg_x is
901 * dereferenced above.
887 */ 902 */
888 return_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) operand[0]); 903 return_desc = acpi_ns_get_attached_object (
904 (struct acpi_namespace_node *) operand[0]);
889 } 905 }
890 else { 906 else {
891 /* 907 /*
892 * This must be a reference object produced by either the Index() or 908 * This must be a reference object produced by either the
893 * ref_of() operator 909 * Index() or ref_of() operator
894 */ 910 */
895 switch (operand[0]->reference.opcode) { 911 switch (operand[0]->reference.opcode) {
896 case AML_INDEX_OP: 912 case AML_INDEX_OP:
@@ -931,8 +947,8 @@ acpi_ex_opcode_1A_0T_1R (
931 case ACPI_TYPE_PACKAGE: 947 case ACPI_TYPE_PACKAGE:
932 948
933 /* 949 /*
934 * Return the referenced element of the package. We must add 950 * Return the referenced element of the package. We must
935 * another reference to the referenced object, however. 951 * add another reference to the referenced object, however.
936 */ 952 */
937 return_desc = *(operand[0]->reference.where); 953 return_desc = *(operand[0]->reference.where);
938 if (!return_desc) { 954 if (!return_desc) {
@@ -967,9 +983,11 @@ acpi_ex_opcode_1A_0T_1R (
967 983
968 return_desc = operand[0]->reference.object; 984 return_desc = operand[0]->reference.object;
969 985
970 if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) == ACPI_DESC_TYPE_NAMED) { 986 if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) ==
987 ACPI_DESC_TYPE_NAMED) {
971 988
972 return_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) return_desc); 989 return_desc = acpi_ns_get_attached_object (
990 (struct acpi_namespace_node *) return_desc);
973 } 991 }
974 992
975 /* Add another reference to the object! */ 993 /* Add another reference to the object! */
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c
index 8be4d80ceed5..7429032c2b6c 100644
--- a/drivers/acpi/executer/exoparg2.c
+++ b/drivers/acpi/executer/exoparg2.c
@@ -118,7 +118,7 @@ acpi_ex_opcode_2A_0T_0R (
118 118
119 value = (u32) operand[1]->integer.value; 119 value = (u32) operand[1]->integer.value;
120 120
121 /* Notifies allowed on this object? */ 121 /* Are notifies allowed on this object? */
122 122
123 if (!acpi_ev_is_notify_object (node)) { 123 if (!acpi_ev_is_notify_object (node)) {
124 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 124 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -203,11 +203,12 @@ acpi_ex_opcode_2A_2T_1R (
203 acpi_ps_get_opcode_name (walk_state->opcode)); 203 acpi_ps_get_opcode_name (walk_state->opcode));
204 204
205 205
206 /* 206 /* Execute the opcode */
207 * Execute the opcode 207
208 */
209 switch (walk_state->opcode) { 208 switch (walk_state->opcode) {
210 case AML_DIVIDE_OP: /* Divide (Dividend, Divisor, remainder_result quotient_result) */ 209 case AML_DIVIDE_OP:
210
211 /* Divide (Dividend, Divisor, remainder_result quotient_result) */
211 212
212 return_desc1 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 213 return_desc1 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
213 if (!return_desc1) { 214 if (!return_desc1) {
@@ -241,7 +242,6 @@ acpi_ex_opcode_2A_2T_1R (
241 goto cleanup; 242 goto cleanup;
242 } 243 }
243 244
244
245 /* Store the results to the target reference operands */ 245 /* Store the results to the target reference operands */
246 246
247 status = acpi_ex_store (return_desc2, operand[2], walk_state); 247 status = acpi_ex_store (return_desc2, operand[2], walk_state);
@@ -295,7 +295,7 @@ acpi_ex_opcode_2A_1T_1R (
295{ 295{
296 union acpi_operand_object **operand = &walk_state->operands[0]; 296 union acpi_operand_object **operand = &walk_state->operands[0];
297 union acpi_operand_object *return_desc = NULL; 297 union acpi_operand_object *return_desc = NULL;
298 u32 index; 298 acpi_integer index;
299 acpi_status status = AE_OK; 299 acpi_status status = AE_OK;
300 acpi_size length; 300 acpi_size length;
301 301
@@ -304,9 +304,8 @@ acpi_ex_opcode_2A_1T_1R (
304 acpi_ps_get_opcode_name (walk_state->opcode)); 304 acpi_ps_get_opcode_name (walk_state->opcode));
305 305
306 306
307 /* 307 /* Execute the opcode */
308 * Execute the opcode 308
309 */
310 if (walk_state->op_info->flags & AML_MATH) { 309 if (walk_state->op_info->flags & AML_MATH) {
311 /* All simple math opcodes (add, etc.) */ 310 /* All simple math opcodes (add, etc.) */
312 311
@@ -322,9 +321,8 @@ acpi_ex_opcode_2A_1T_1R (
322 goto store_result_to_target; 321 goto store_result_to_target;
323 } 322 }
324 323
325
326 switch (walk_state->opcode) { 324 switch (walk_state->opcode) {
327 case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */ 325 case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */
328 326
329 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 327 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
330 if (!return_desc) { 328 if (!return_desc) {
@@ -341,18 +339,19 @@ acpi_ex_opcode_2A_1T_1R (
341 break; 339 break;
342 340
343 341
344 case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ 342 case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
345 343
346 status = acpi_ex_do_concatenate (operand[0], operand[1], 344 status = acpi_ex_do_concatenate (operand[0], operand[1],
347 &return_desc, walk_state); 345 &return_desc, walk_state);
348 break; 346 break;
349 347
350 348
351 case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */ 349 case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */
352 350
353 /* 351 /*
354 * Input object is guaranteed to be a buffer at this point (it may have 352 * Input object is guaranteed to be a buffer at this point (it may have
355 * been converted.) Copy the raw buffer data to a new object of type String. 353 * been converted.) Copy the raw buffer data to a new object of
354 * type String.
356 */ 355 */
357 356
358 /* 357 /*
@@ -383,14 +382,16 @@ acpi_ex_opcode_2A_1T_1R (
383 goto cleanup; 382 goto cleanup;
384 } 383 }
385 384
386 /* Copy the raw buffer data with no transform. NULL terminated already. */ 385 /* Copy the raw buffer data with no transform. NULL terminated already*/
387 386
388 ACPI_MEMCPY (return_desc->string.pointer, 387 ACPI_MEMCPY (return_desc->string.pointer,
389 operand[0]->buffer.pointer, length); 388 operand[0]->buffer.pointer, length);
390 break; 389 break;
391 390
392 391
393 case AML_CONCAT_RES_OP: /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */ 392 case AML_CONCAT_RES_OP:
393
394 /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
394 395
395 status = acpi_ex_concat_template (operand[0], operand[1], 396 status = acpi_ex_concat_template (operand[0], operand[1],
396 &return_desc, walk_state); 397 &return_desc, walk_state);
@@ -407,33 +408,33 @@ acpi_ex_opcode_2A_1T_1R (
407 goto cleanup; 408 goto cleanup;
408 } 409 }
409 410
410 index = (u32) operand[1]->integer.value; 411 index = operand[1]->integer.value;
412
413 /* At this point, the Source operand is a Package, Buffer, or String */
411 414
412 /*
413 * At this point, the Source operand is a Package, Buffer, or String
414 */
415 if (ACPI_GET_OBJECT_TYPE (operand[0]) == ACPI_TYPE_PACKAGE) { 415 if (ACPI_GET_OBJECT_TYPE (operand[0]) == ACPI_TYPE_PACKAGE) {
416 /* Object to be indexed is a Package */ 416 /* Object to be indexed is a Package */
417 417
418 if (index >= operand[0]->package.count) { 418 if (index >= operand[0]->package.count) {
419 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 419 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
420 "Index value (%X) beyond package end (%X)\n", 420 "Index value (%X%8.8X) beyond package end (%X)\n",
421 index, operand[0]->package.count)); 421 ACPI_FORMAT_UINT64 (index), operand[0]->package.count));
422 status = AE_AML_PACKAGE_LIMIT; 422 status = AE_AML_PACKAGE_LIMIT;
423 goto cleanup; 423 goto cleanup;
424 } 424 }
425 425
426 return_desc->reference.target_type = ACPI_TYPE_PACKAGE; 426 return_desc->reference.target_type = ACPI_TYPE_PACKAGE;
427 return_desc->reference.object = operand[0]; 427 return_desc->reference.object = operand[0];
428 return_desc->reference.where = &operand[0]->package.elements [index]; 428 return_desc->reference.where = &operand[0]->package.elements [
429 index];
429 } 430 }
430 else { 431 else {
431 /* Object to be indexed is a Buffer/String */ 432 /* Object to be indexed is a Buffer/String */
432 433
433 if (index >= operand[0]->buffer.length) { 434 if (index >= operand[0]->buffer.length) {
434 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 435 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
435 "Index value (%X) beyond end of buffer (%X)\n", 436 "Index value (%X%8.8X) beyond end of buffer (%X)\n",
436 index, operand[0]->buffer.length)); 437 ACPI_FORMAT_UINT64 (index), operand[0]->buffer.length));
437 status = AE_AML_BUFFER_LIMIT; 438 status = AE_AML_BUFFER_LIMIT;
438 goto cleanup; 439 goto cleanup;
439 } 440 }
@@ -451,7 +452,7 @@ acpi_ex_opcode_2A_1T_1R (
451 /* Complete the Index reference object */ 452 /* Complete the Index reference object */
452 453
453 return_desc->reference.opcode = AML_INDEX_OP; 454 return_desc->reference.opcode = AML_INDEX_OP;
454 return_desc->reference.offset = index; 455 return_desc->reference.offset = (u32) index;
455 456
456 /* Store the reference to the Target */ 457 /* Store the reference to the Target */
457 458
@@ -536,22 +537,24 @@ acpi_ex_opcode_2A_0T_1R (
536 goto cleanup; 537 goto cleanup;
537 } 538 }
538 539
539 /* 540 /* Execute the Opcode */
540 * Execute the Opcode 541
541 */ 542 if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) {
542 if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) /* logical_op (Operand0, Operand1) */ { 543 /* logical_op (Operand0, Operand1) */
544
543 status = acpi_ex_do_logical_numeric_op (walk_state->opcode, 545 status = acpi_ex_do_logical_numeric_op (walk_state->opcode,
544 operand[0]->integer.value, operand[1]->integer.value, 546 operand[0]->integer.value, operand[1]->integer.value,
545 &logical_result); 547 &logical_result);
546 goto store_logical_result; 548 goto store_logical_result;
547 } 549 }
548 else if (walk_state->op_info->flags & AML_LOGICAL) /* logical_op (Operand0, Operand1) */ { 550 else if (walk_state->op_info->flags & AML_LOGICAL) {
551 /* logical_op (Operand0, Operand1) */
552
549 status = acpi_ex_do_logical_op (walk_state->opcode, operand[0], 553 status = acpi_ex_do_logical_op (walk_state->opcode, operand[0],
550 operand[1], &logical_result); 554 operand[1], &logical_result);
551 goto store_logical_result; 555 goto store_logical_result;
552 } 556 }
553 557
554
555 switch (walk_state->opcode) { 558 switch (walk_state->opcode) {
556 case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */ 559 case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */
557 560
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c
index 29d0b167745d..23b068adbf58 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/executer/exoparg3.c
@@ -97,11 +97,12 @@ acpi_ex_opcode_3A_0T_0R (
97 acpi_status status = AE_OK; 97 acpi_status status = AE_OK;
98 98
99 99
100 ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode)); 100 ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_0T_0R",
101 acpi_ps_get_opcode_name (walk_state->opcode));
101 102
102 103
103 switch (walk_state->opcode) { 104 switch (walk_state->opcode) {
104 case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */ 105 case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */
105 106
106 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 107 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
107 "fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", 108 "fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
@@ -116,9 +117,8 @@ acpi_ex_opcode_3A_0T_0R (
116 fatal->argument = (u32) operand[2]->integer.value; 117 fatal->argument = (u32) operand[2]->integer.value;
117 } 118 }
118 119
119 /* 120 /* Always signal the OS! */
120 * Always signal the OS! 121
121 */
122 status = acpi_os_signal (ACPI_SIGNAL_FATAL, fatal); 122 status = acpi_os_signal (ACPI_SIGNAL_FATAL, fatal);
123 123
124 /* Might return while OS is shutting down, just continue */ 124 /* Might return while OS is shutting down, just continue */
@@ -162,21 +162,23 @@ acpi_ex_opcode_3A_1T_1R (
162 union acpi_operand_object *return_desc = NULL; 162 union acpi_operand_object *return_desc = NULL;
163 char *buffer; 163 char *buffer;
164 acpi_status status = AE_OK; 164 acpi_status status = AE_OK;
165 acpi_native_uint index; 165 acpi_integer index;
166 acpi_size length; 166 acpi_size length;
167 167
168 168
169 ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode)); 169 ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_1T_1R",
170 acpi_ps_get_opcode_name (walk_state->opcode));
170 171
171 172
172 switch (walk_state->opcode) { 173 switch (walk_state->opcode) {
173 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ 174 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
174 175
175 /* 176 /*
176 * Create the return object. The Source operand is guaranteed to be 177 * Create the return object. The Source operand is guaranteed to be
177 * either a String or a Buffer, so just use its type. 178 * either a String or a Buffer, so just use its type.
178 */ 179 */
179 return_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (operand[0])); 180 return_desc = acpi_ut_create_internal_object (
181 ACPI_GET_OBJECT_TYPE (operand[0]));
180 if (!return_desc) { 182 if (!return_desc) {
181 status = AE_NO_MEMORY; 183 status = AE_NO_MEMORY;
182 goto cleanup; 184 goto cleanup;
@@ -184,7 +186,7 @@ acpi_ex_opcode_3A_1T_1R (
184 186
185 /* Get the Integer values from the objects */ 187 /* Get the Integer values from the objects */
186 188
187 index = (acpi_native_uint) operand[1]->integer.value; 189 index = operand[1]->integer.value;
188 length = (acpi_size) operand[2]->integer.value; 190 length = (acpi_size) operand[2]->integer.value;
189 191
190 /* 192 /*
@@ -197,7 +199,8 @@ acpi_ex_opcode_3A_1T_1R (
197 199
198 if ((index + length) > 200 if ((index + length) >
199 operand[0]->string.length) { 201 operand[0]->string.length) {
200 length = (acpi_size) operand[0]->string.length - index; 202 length = (acpi_size) operand[0]->string.length -
203 (acpi_size) index;
201 } 204 }
202 205
203 /* Allocate a new buffer for the String/Buffer */ 206 /* Allocate a new buffer for the String/Buffer */
diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c
index d32624331626..17f81d42ee41 100644
--- a/drivers/acpi/executer/exoparg6.c
+++ b/drivers/acpi/executer/exoparg6.c
@@ -75,6 +75,14 @@
75 * fully resolved operands. 75 * fully resolved operands.
76!*/ 76!*/
77 77
78/* Local prototypes */
79
80static u8
81acpi_ex_do_match (
82 u32 match_op,
83 union acpi_operand_object *package_obj,
84 union acpi_operand_object *match_obj);
85
78 86
79/******************************************************************************* 87/*******************************************************************************
80 * 88 *
@@ -92,7 +100,7 @@
92 * 100 *
93 ******************************************************************************/ 101 ******************************************************************************/
94 102
95u8 103static u8
96acpi_ex_do_match ( 104acpi_ex_do_match (
97 u32 match_op, 105 u32 match_op,
98 union acpi_operand_object *package_obj, 106 union acpi_operand_object *package_obj,
@@ -216,11 +224,12 @@ acpi_ex_opcode_6A_0T_1R (
216 union acpi_operand_object **operand = &walk_state->operands[0]; 224 union acpi_operand_object **operand = &walk_state->operands[0];
217 union acpi_operand_object *return_desc = NULL; 225 union acpi_operand_object *return_desc = NULL;
218 acpi_status status = AE_OK; 226 acpi_status status = AE_OK;
219 u32 index; 227 acpi_integer index;
220 union acpi_operand_object *this_element; 228 union acpi_operand_object *this_element;
221 229
222 230
223 ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode)); 231 ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R",
232 acpi_ps_get_opcode_name (walk_state->opcode));
224 233
225 234
226 switch (walk_state->opcode) { 235 switch (walk_state->opcode) {
@@ -241,9 +250,11 @@ acpi_ex_opcode_6A_0T_1R (
241 250
242 /* Get the package start_index, validate against the package length */ 251 /* Get the package start_index, validate against the package length */
243 252
244 index = (u32) operand[5]->integer.value; 253 index = operand[5]->integer.value;
245 if (index >= (u32) operand[0]->package.count) { 254 if (index >= operand[0]->package.count) {
246 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index beyond package end\n")); 255 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
256 "Index (%X%8.8X) beyond package end (%X)\n",
257 ACPI_FORMAT_UINT64 (index), operand[0]->package.count));
247 status = AE_AML_PACKAGE_LIMIT; 258 status = AE_AML_PACKAGE_LIMIT;
248 goto cleanup; 259 goto cleanup;
249 } 260 }
@@ -314,13 +325,12 @@ acpi_ex_opcode_6A_0T_1R (
314 325
315 default: 326 default:
316 327
317 ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", 328 ACPI_REPORT_ERROR (("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n",
318 walk_state->opcode)); 329 walk_state->opcode));
319 status = AE_AML_BAD_OPCODE; 330 status = AE_AML_BAD_OPCODE;
320 goto cleanup; 331 goto cleanup;
321 } 332 }
322 333
323
324 walk_state->result_obj = return_desc; 334 walk_state->result_obj = return_desc;
325 335
326 336
diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c
index 264ef3bba31b..c9e3c68b5549 100644
--- a/drivers/acpi/executer/exprep.c
+++ b/drivers/acpi/executer/exprep.c
@@ -52,8 +52,23 @@
52#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exprep") 53 ACPI_MODULE_NAME ("exprep")
54 54
55/* Local prototypes */
56
57static u32
58acpi_ex_decode_field_access (
59 union acpi_operand_object *obj_desc,
60 u8 field_flags,
61 u32 *return_byte_alignment);
62
55 63
56#ifdef ACPI_UNDER_DEVELOPMENT 64#ifdef ACPI_UNDER_DEVELOPMENT
65
66static u32
67acpi_ex_generate_access (
68 u32 field_bit_offset,
69 u32 field_bit_length,
70 u32 region_length);
71
57/******************************************************************************* 72/*******************************************************************************
58 * 73 *
59 * FUNCTION: acpi_ex_generate_access 74 * FUNCTION: acpi_ex_generate_access
@@ -99,12 +114,14 @@ acpi_ex_generate_access (
99 /* Round Field start offset and length to "minimal" byte boundaries */ 114 /* Round Field start offset and length to "minimal" byte boundaries */
100 115
101 field_byte_offset = ACPI_DIV_8 (ACPI_ROUND_DOWN (field_bit_offset, 8)); 116 field_byte_offset = ACPI_DIV_8 (ACPI_ROUND_DOWN (field_bit_offset, 8));
102 field_byte_end_offset = ACPI_DIV_8 (ACPI_ROUND_UP (field_bit_length + field_bit_offset, 8)); 117 field_byte_end_offset = ACPI_DIV_8 (ACPI_ROUND_UP (field_bit_length +
118 field_bit_offset, 8));
103 field_byte_length = field_byte_end_offset - field_byte_offset; 119 field_byte_length = field_byte_end_offset - field_byte_offset;
104 120
105 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 121 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
106 "Bit length %d, Bit offset %d\n", 122 "Bit length %d, Bit offset %d\n",
107 field_bit_length, field_bit_offset)); 123 field_bit_length, field_bit_offset));
124
108 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 125 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
109 "Byte Length %d, Byte Offset %d, End Offset %d\n", 126 "Byte Length %d, Byte Offset %d, End Offset %d\n",
110 field_byte_length, field_byte_offset, field_byte_end_offset)); 127 field_byte_length, field_byte_offset, field_byte_end_offset));
@@ -117,20 +134,26 @@ acpi_ex_generate_access (
117 */ 134 */
118 for (access_byte_width = 1; access_byte_width <= 8; access_byte_width <<= 1) { 135 for (access_byte_width = 1; access_byte_width <= 8; access_byte_width <<= 1) {
119 /* 136 /*
120 * 1) Round end offset up to next access boundary and make sure that this 137 * 1) Round end offset up to next access boundary and make sure that
121 * does not go beyond the end of the parent region. 138 * this does not go beyond the end of the parent region.
122 * 2) When the Access width is greater than the field_byte_length, we are done. 139 * 2) When the Access width is greater than the field_byte_length, we
123 * (This does not optimize for the perfectly aligned case yet). 140 * are done. (This does not optimize for the perfectly aligned
141 * case yet).
124 */ 142 */
125 if (ACPI_ROUND_UP (field_byte_end_offset, access_byte_width) <= region_length) { 143 if (ACPI_ROUND_UP (field_byte_end_offset, access_byte_width) <= region_length) {
126 field_start_offset = ACPI_ROUND_DOWN (field_byte_offset, access_byte_width) / 144 field_start_offset =
127 access_byte_width; 145 ACPI_ROUND_DOWN (field_byte_offset, access_byte_width) /
128 field_end_offset = ACPI_ROUND_UP ((field_byte_length + field_byte_offset), 146 access_byte_width;
129 access_byte_width) / access_byte_width; 147
130 accesses = field_end_offset - field_start_offset; 148 field_end_offset =
149 ACPI_ROUND_UP ((field_byte_length + field_byte_offset),
150 access_byte_width) / access_byte_width;
151
152 accesses = field_end_offset - field_start_offset;
131 153
132 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 154 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
133 "access_width %d end is within region\n", access_byte_width)); 155 "access_width %d end is within region\n", access_byte_width));
156
134 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 157 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
135 "Field Start %d, Field End %d -- requires %d accesses\n", 158 "Field Start %d, Field End %d -- requires %d accesses\n",
136 field_start_offset, field_end_offset, accesses)); 159 field_start_offset, field_end_offset, accesses));
@@ -139,8 +162,8 @@ acpi_ex_generate_access (
139 162
140 if (accesses <= 1) { 163 if (accesses <= 1) {
141 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 164 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
142 "Entire field can be accessed with one operation of size %d\n", 165 "Entire field can be accessed with one operation of size %d\n",
143 access_byte_width)); 166 access_byte_width));
144 return_VALUE (access_byte_width); 167 return_VALUE (access_byte_width);
145 } 168 }
146 169
@@ -155,15 +178,20 @@ acpi_ex_generate_access (
155 } 178 }
156 else { 179 else {
157 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 180 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
158 "access_width %d end is NOT within region\n", access_byte_width)); 181 "access_width %d end is NOT within region\n", access_byte_width));
159 if (access_byte_width == 1) { 182 if (access_byte_width == 1) {
160 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 183 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
161 "Field goes beyond end-of-region!\n")); 184 "Field goes beyond end-of-region!\n"));
162 return_VALUE (0); /* Field does not fit in the region at all */
163 }
164 185
165 /* This width goes beyond the end-of-region, back off to previous access */ 186 /* Field does not fit in the region at all */
166 187
188 return_VALUE (0);
189 }
190
191 /*
192 * This width goes beyond the end-of-region, back off to
193 * previous access
194 */
167 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 195 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
168 "Backing off to previous optimal access width of %d\n", 196 "Backing off to previous optimal access width of %d\n",
169 minimum_access_width)); 197 minimum_access_width));
@@ -171,8 +199,10 @@ acpi_ex_generate_access (
171 } 199 }
172 } 200 }
173 201
174 /* Could not read/write field with one operation, just use max access width */ 202 /*
175 203 * Could not read/write field with one operation,
204 * just use max access width
205 */
176 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, 206 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
177 "Cannot access field in one operation, using width 8\n")); 207 "Cannot access field in one operation, using width 8\n"));
178 return_VALUE (8); 208 return_VALUE (8);
@@ -184,8 +214,9 @@ acpi_ex_generate_access (
184 * 214 *
185 * FUNCTION: acpi_ex_decode_field_access 215 * FUNCTION: acpi_ex_decode_field_access
186 * 216 *
187 * PARAMETERS: Access - Encoded field access bits 217 * PARAMETERS: obj_desc - Field object
188 * Length - Field length. 218 * field_flags - Encoded fieldflags (contains access bits)
219 * return_byte_alignment - Where the byte alignment is returned
189 * 220 *
190 * RETURN: Field granularity (8, 16, 32 or 64) and 221 * RETURN: Field granularity (8, 16, 32 or 64) and
191 * byte_alignment (1, 2, 3, or 4) 222 * byte_alignment (1, 2, 3, or 4)
@@ -214,9 +245,10 @@ acpi_ex_decode_field_access (
214 case AML_FIELD_ACCESS_ANY: 245 case AML_FIELD_ACCESS_ANY:
215 246
216#ifdef ACPI_UNDER_DEVELOPMENT 247#ifdef ACPI_UNDER_DEVELOPMENT
217 byte_alignment = acpi_ex_generate_access (obj_desc->common_field.start_field_bit_offset, 248 byte_alignment =
218 obj_desc->common_field.bit_length, 249 acpi_ex_generate_access (obj_desc->common_field.start_field_bit_offset,
219 0xFFFFFFFF /* Temp until we pass region_length as param */); 250 obj_desc->common_field.bit_length,
251 0xFFFFFFFF /* Temp until we pass region_length as parameter */);
220 bit_length = byte_alignment * 8; 252 bit_length = byte_alignment * 8;
221#endif 253#endif
222 254
@@ -276,6 +308,7 @@ acpi_ex_decode_field_access (
276 * field_flags - Access, lock_rule, and update_rule. 308 * field_flags - Access, lock_rule, and update_rule.
277 * The format of a field_flag is described 309 * The format of a field_flag is described
278 * in the ACPI specification 310 * in the ACPI specification
311 * field_attribute - Special attributes (not used)
279 * field_bit_position - Field start position 312 * field_bit_position - Field start position
280 * field_bit_length - Field length in number of bits 313 * field_bit_length - Field length in number of bits
281 * 314 *
@@ -337,7 +370,7 @@ acpi_ex_prep_common_field_object (
337 /* Setup width (access granularity) fields */ 370 /* Setup width (access granularity) fields */
338 371
339 obj_desc->common_field.access_byte_width = (u8) 372 obj_desc->common_field.access_byte_width = (u8)
340 ACPI_DIV_8 (access_bit_width); /* 1, 2, 4, 8 */ 373 ACPI_DIV_8 (access_bit_width); /* 1, 2, 4, 8 */
341 374
342 obj_desc->common_field.access_bit_width = (u8) access_bit_width; 375 obj_desc->common_field.access_bit_width = (u8) access_bit_width;
343 376
@@ -380,11 +413,7 @@ acpi_ex_prep_common_field_object (
380 * 413 *
381 * FUNCTION: acpi_ex_prep_field_value 414 * FUNCTION: acpi_ex_prep_field_value
382 * 415 *
383 * PARAMETERS: Node - Owning Node 416 * PARAMETERS: Info - Contains all field creation info
384 * region_node - Region in which field is being defined
385 * field_flags - Access, lock_rule, and update_rule.
386 * field_bit_position - Field start position
387 * field_bit_length - Field length in number of bits
388 * 417 *
389 * RETURN: Status 418 * RETURN: Status
390 * 419 *
@@ -445,7 +474,7 @@ acpi_ex_prep_field_value (
445 switch (info->field_type) { 474 switch (info->field_type) {
446 case ACPI_TYPE_LOCAL_REGION_FIELD: 475 case ACPI_TYPE_LOCAL_REGION_FIELD:
447 476
448 obj_desc->field.region_obj = acpi_ns_get_attached_object (info->region_node); 477 obj_desc->field.region_obj = acpi_ns_get_attached_object (info->region_node);
449 478
450 /* An additional reference for the container */ 479 /* An additional reference for the container */
451 480
@@ -461,8 +490,10 @@ acpi_ex_prep_field_value (
461 case ACPI_TYPE_LOCAL_BANK_FIELD: 490 case ACPI_TYPE_LOCAL_BANK_FIELD:
462 491
463 obj_desc->bank_field.value = info->bank_value; 492 obj_desc->bank_field.value = info->bank_value;
464 obj_desc->bank_field.region_obj = acpi_ns_get_attached_object (info->region_node); 493 obj_desc->bank_field.region_obj = acpi_ns_get_attached_object (
465 obj_desc->bank_field.bank_obj = acpi_ns_get_attached_object (info->register_node); 494 info->region_node);
495 obj_desc->bank_field.bank_obj = acpi_ns_get_attached_object (
496 info->register_node);
466 497
467 /* An additional reference for the attached objects */ 498 /* An additional reference for the attached objects */
468 499
@@ -481,10 +512,13 @@ acpi_ex_prep_field_value (
481 512
482 case ACPI_TYPE_LOCAL_INDEX_FIELD: 513 case ACPI_TYPE_LOCAL_INDEX_FIELD:
483 514
484 obj_desc->index_field.index_obj = acpi_ns_get_attached_object (info->register_node); 515 obj_desc->index_field.index_obj = acpi_ns_get_attached_object (
485 obj_desc->index_field.data_obj = acpi_ns_get_attached_object (info->data_register_node); 516 info->register_node);
517 obj_desc->index_field.data_obj = acpi_ns_get_attached_object (
518 info->data_register_node);
486 obj_desc->index_field.value = (u32) 519 obj_desc->index_field.value = (u32)
487 (info->field_bit_position / ACPI_MUL_8 (obj_desc->field.access_byte_width)); 520 (info->field_bit_position / ACPI_MUL_8 (
521 obj_desc->field.access_byte_width));
488 522
489 if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) { 523 if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) {
490 ACPI_REPORT_ERROR (("Null Index Object during field prep\n")); 524 ACPI_REPORT_ERROR (("Null Index Object during field prep\n"));
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
index 7cfd0684c70b..723aaef4bb4a 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/executer/exregion.c
@@ -115,7 +115,6 @@ acpi_ex_system_memory_space_handler (
115 return_ACPI_STATUS (AE_AML_OPERAND_VALUE); 115 return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
116 } 116 }
117 117
118
119#ifndef ACPI_MISALIGNED_TRANSFERS 118#ifndef ACPI_MISALIGNED_TRANSFERS
120 /* 119 /*
121 * Hardware does not support non-aligned data transfers, we must verify 120 * Hardware does not support non-aligned data transfers, we must verify
@@ -134,7 +133,8 @@ acpi_ex_system_memory_space_handler (
134 */ 133 */
135 if ((address < mem_info->mapped_physical_address) || 134 if ((address < mem_info->mapped_physical_address) ||
136 (((acpi_integer) address + length) > 135 (((acpi_integer) address + length) >
137 ((acpi_integer) mem_info->mapped_physical_address + mem_info->mapped_length))) { 136 ((acpi_integer)
137 mem_info->mapped_physical_address + mem_info->mapped_length))) {
138 /* 138 /*
139 * The request cannot be resolved by the current memory mapping; 139 * The request cannot be resolved by the current memory mapping;
140 * Delete the existing mapping and create a new one. 140 * Delete the existing mapping and create a new one.
@@ -150,7 +150,9 @@ acpi_ex_system_memory_space_handler (
150 * Don't attempt to map memory beyond the end of the region, and 150 * Don't attempt to map memory beyond the end of the region, and
151 * constrain the maximum mapping size to something reasonable. 151 * constrain the maximum mapping size to something reasonable.
152 */ 152 */
153 window_size = (acpi_size) ((mem_info->address + mem_info->length) - address); 153 window_size = (acpi_size)
154 ((mem_info->address + mem_info->length) - address);
155
154 if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) { 156 if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) {
155 window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE; 157 window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE;
156 } 158 }
@@ -160,8 +162,9 @@ acpi_ex_system_memory_space_handler (
160 status = acpi_os_map_memory (address, window_size, 162 status = acpi_os_map_memory (address, window_size,
161 (void **) &mem_info->mapped_logical_address); 163 (void **) &mem_info->mapped_logical_address);
162 if (ACPI_FAILURE (status)) { 164 if (ACPI_FAILURE (status)) {
163 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X%8.8X, size %X\n", 165 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
164 ACPI_FORMAT_UINT64 (address), (u32) window_size)); 166 "Could not map memory at %8.8X%8.8X, size %X\n",
167 ACPI_FORMAT_UINT64 (address), (u32) window_size));
165 mem_info->mapped_length = 0; 168 mem_info->mapped_length = 0;
166 return_ACPI_STATUS (status); 169 return_ACPI_STATUS (status);
167 } 170 }
@@ -177,10 +180,12 @@ acpi_ex_system_memory_space_handler (
177 * access 180 * access
178 */ 181 */
179 logical_addr_ptr = mem_info->mapped_logical_address + 182 logical_addr_ptr = mem_info->mapped_logical_address +
180 ((acpi_integer) address - (acpi_integer) mem_info->mapped_physical_address); 183 ((acpi_integer) address -
184 (acpi_integer) mem_info->mapped_physical_address);
181 185
182 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 186 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
183 "system_memory %d (%d width) Address=%8.8X%8.8X\n", function, bit_width, 187 "system_memory %d (%d width) Address=%8.8X%8.8X\n",
188 function, bit_width,
184 ACPI_FORMAT_UINT64 (address))); 189 ACPI_FORMAT_UINT64 (address)));
185 190
186 /* 191 /*
@@ -298,13 +303,15 @@ acpi_ex_system_io_space_handler (
298 switch (function) { 303 switch (function) {
299 case ACPI_READ: 304 case ACPI_READ:
300 305
301 status = acpi_os_read_port ((acpi_io_address) address, &value32, bit_width); 306 status = acpi_os_read_port ((acpi_io_address) address,
307 &value32, bit_width);
302 *value = value32; 308 *value = value32;
303 break; 309 break;
304 310
305 case ACPI_WRITE: 311 case ACPI_WRITE:
306 312
307 status = acpi_os_write_port ((acpi_io_address) address, (u32) *value, bit_width); 313 status = acpi_os_write_port ((acpi_io_address) address,
314 (u32) *value, bit_width);
308 break; 315 break;
309 316
310 default: 317 default:
@@ -375,12 +382,14 @@ acpi_ex_pci_config_space_handler (
375 case ACPI_READ: 382 case ACPI_READ:
376 383
377 *value = 0; 384 *value = 0;
378 status = acpi_os_read_pci_configuration (pci_id, pci_register, value, bit_width); 385 status = acpi_os_read_pci_configuration (pci_id, pci_register,
386 value, bit_width);
379 break; 387 break;
380 388
381 case ACPI_WRITE: 389 case ACPI_WRITE:
382 390
383 status = acpi_os_write_pci_configuration (pci_id, pci_register, *value, bit_width); 391 status = acpi_os_write_pci_configuration (pci_id, pci_register,
392 *value, bit_width);
384 break; 393 break;
385 394
386 default: 395 default:
@@ -505,8 +514,7 @@ acpi_ex_data_table_space_handler (
505 514
506 logical_addr_ptr = ACPI_PHYSADDR_TO_PTR (address); 515 logical_addr_ptr = ACPI_PHYSADDR_TO_PTR (address);
507 516
508 517 /* Perform the memory read or write */
509 /* Perform the memory read or write */
510 518
511 switch (function) { 519 switch (function) {
512 case ACPI_READ: 520 case ACPI_READ:
diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c
index 7936329a0e35..21d5c74fa309 100644
--- a/drivers/acpi/executer/exresnte.c
+++ b/drivers/acpi/executer/exresnte.c
@@ -210,15 +210,15 @@ acpi_ex_resolve_node_to_value (
210 case ACPI_TYPE_LOCAL_BANK_FIELD: 210 case ACPI_TYPE_LOCAL_BANK_FIELD:
211 case ACPI_TYPE_LOCAL_INDEX_FIELD: 211 case ACPI_TYPE_LOCAL_INDEX_FIELD:
212 212
213 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "field_read Node=%p source_desc=%p Type=%X\n", 213 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
214 "field_read Node=%p source_desc=%p Type=%X\n",
214 node, source_desc, entry_type)); 215 node, source_desc, entry_type));
215 216
216 status = acpi_ex_read_data_from_field (walk_state, source_desc, &obj_desc); 217 status = acpi_ex_read_data_from_field (walk_state, source_desc, &obj_desc);
217 break; 218 break;
218 219
219 /* 220 /* For these objects, just return the object attached to the Node */
220 * For these objects, just return the object attached to the Node 221
221 */
222 case ACPI_TYPE_MUTEX: 222 case ACPI_TYPE_MUTEX:
223 case ACPI_TYPE_METHOD: 223 case ACPI_TYPE_METHOD:
224 case ACPI_TYPE_POWER: 224 case ACPI_TYPE_POWER:
@@ -233,12 +233,12 @@ acpi_ex_resolve_node_to_value (
233 acpi_ut_add_reference (obj_desc); 233 acpi_ut_add_reference (obj_desc);
234 break; 234 break;
235 235
236
237 /* TYPE_ANY is untyped, and thus there is no object associated with it */ 236 /* TYPE_ANY is untyped, and thus there is no object associated with it */
238 237
239 case ACPI_TYPE_ANY: 238 case ACPI_TYPE_ANY:
240 239
241 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Untyped entry %p, no attached object!\n", 240 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
241 "Untyped entry %p, no attached object!\n",
242 node)); 242 node));
243 243
244 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ 244 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
@@ -259,7 +259,8 @@ acpi_ex_resolve_node_to_value (
259 default: 259 default:
260 /* No named references are allowed here */ 260 /* No named references are allowed here */
261 261
262 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported Reference opcode %X (%s)\n", 262 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
263 "Unsupported Reference opcode %X (%s)\n",
263 source_desc->reference.opcode, 264 source_desc->reference.opcode,
264 acpi_ps_get_opcode_name (source_desc->reference.opcode))); 265 acpi_ps_get_opcode_name (source_desc->reference.opcode)));
265 266
@@ -268,11 +269,12 @@ acpi_ex_resolve_node_to_value (
268 break; 269 break;
269 270
270 271
271 /* Default case is for unknown types */
272
273 default: 272 default:
274 273
275 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Node %p - Unknown object type %X\n", 274 /* Default case is for unknown types */
275
276 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
277 "Node %p - Unknown object type %X\n",
276 node, entry_type)); 278 node, entry_type));
277 279
278 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 280 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
@@ -280,7 +282,7 @@ acpi_ex_resolve_node_to_value (
280 } /* switch (entry_type) */ 282 } /* switch (entry_type) */
281 283
282 284
283 /* Put the object descriptor on the stack */ 285 /* Return the object descriptor */
284 286
285 *object_ptr = (void *) obj_desc; 287 *object_ptr = (void *) obj_desc;
286 return_ACPI_STATUS (status); 288 return_ACPI_STATUS (status);
diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c
index 7be604911156..3de45672379a 100644
--- a/drivers/acpi/executer/exresolv.c
+++ b/drivers/acpi/executer/exresolv.c
@@ -54,6 +54,13 @@
54#define _COMPONENT ACPI_EXECUTER 54#define _COMPONENT ACPI_EXECUTER
55 ACPI_MODULE_NAME ("exresolv") 55 ACPI_MODULE_NAME ("exresolv")
56 56
57/* Local prototypes */
58
59static acpi_status
60acpi_ex_resolve_object_to_value (
61 union acpi_operand_object **stack_ptr,
62 struct acpi_walk_state *walk_state);
63
57 64
58/******************************************************************************* 65/*******************************************************************************
59 * 66 *
@@ -96,6 +103,11 @@ acpi_ex_resolve_to_value (
96 if (ACPI_FAILURE (status)) { 103 if (ACPI_FAILURE (status)) {
97 return_ACPI_STATUS (status); 104 return_ACPI_STATUS (status);
98 } 105 }
106
107 if (!*stack_ptr) {
108 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n"));
109 return_ACPI_STATUS (AE_AML_NO_OPERAND);
110 }
99 } 111 }
100 112
101 /* 113 /*
@@ -120,18 +132,17 @@ acpi_ex_resolve_to_value (
120 * 132 *
121 * FUNCTION: acpi_ex_resolve_object_to_value 133 * FUNCTION: acpi_ex_resolve_object_to_value
122 * 134 *
123 * PARAMETERS: stack_ptr - Pointer to a stack location that contains a 135 * PARAMETERS: stack_ptr - Pointer to an internal object
124 * ptr to an internal object.
125 * walk_state - Current method state 136 * walk_state - Current method state
126 * 137 *
127 * RETURN: Status 138 * RETURN: Status
128 * 139 *
129 * DESCRIPTION: Retrieve the value from an internal object. The Reference type 140 * DESCRIPTION: Retrieve the value from an internal object. The Reference type
130 * uses the associated AML opcode to determine the value. 141 * uses the associated AML opcode to determine the value.
131 * 142 *
132 ******************************************************************************/ 143 ******************************************************************************/
133 144
134acpi_status 145static acpi_status
135acpi_ex_resolve_object_to_value ( 146acpi_ex_resolve_object_to_value (
136 union acpi_operand_object **stack_ptr, 147 union acpi_operand_object **stack_ptr,
137 struct acpi_walk_state *walk_state) 148 struct acpi_walk_state *walk_state)
@@ -159,7 +170,7 @@ acpi_ex_resolve_object_to_value (
159 case AML_NAME_OP: 170 case AML_NAME_OP:
160 171
161 /* 172 /*
162 * Convert indirect name ptr to a direct name ptr. 173 * Convert name reference to a namespace node
163 * Then, acpi_ex_resolve_node_to_value can be used to get the value 174 * Then, acpi_ex_resolve_node_to_value can be used to get the value
164 */ 175 */
165 temp_node = stack_desc->reference.object; 176 temp_node = stack_desc->reference.object;
@@ -168,7 +179,7 @@ acpi_ex_resolve_object_to_value (
168 179
169 acpi_ut_remove_reference (stack_desc); 180 acpi_ut_remove_reference (stack_desc);
170 181
171 /* Put direct name pointer onto stack and exit */ 182 /* Return the namespace node */
172 183
173 (*stack_ptr) = temp_node; 184 (*stack_ptr) = temp_node;
174 break; 185 break;
@@ -255,10 +266,19 @@ acpi_ex_resolve_object_to_value (
255 266
256 break; 267 break;
257 268
269 case AML_INT_NAMEPATH_OP: /* Reference to a named object */
270
271 /* Get the object pointed to by the namespace node */
272
273 *stack_ptr = (stack_desc->reference.node)->object;
274 acpi_ut_add_reference (*stack_ptr);
275 acpi_ut_remove_reference (stack_desc);
276 break;
258 277
259 default: 278 default:
260 279
261 ACPI_REPORT_ERROR (("During resolve, Unknown Reference opcode %X (%s) in %p\n", 280 ACPI_REPORT_ERROR ((
281 "During resolve, Unknown Reference opcode %X (%s) in %p\n",
262 opcode, acpi_ps_get_opcode_name (opcode), stack_desc)); 282 opcode, acpi_ps_get_opcode_name (opcode), stack_desc));
263 status = AE_AML_INTERNAL; 283 status = AE_AML_INTERNAL;
264 break; 284 break;
@@ -278,9 +298,8 @@ acpi_ex_resolve_object_to_value (
278 break; 298 break;
279 299
280 300
281 /* 301 /* These cases may never happen here, but just in case.. */
282 * These cases may never happen here, but just in case.. 302
283 */
284 case ACPI_TYPE_BUFFER_FIELD: 303 case ACPI_TYPE_BUFFER_FIELD:
285 case ACPI_TYPE_LOCAL_REGION_FIELD: 304 case ACPI_TYPE_LOCAL_REGION_FIELD:
286 case ACPI_TYPE_LOCAL_BANK_FIELD: 305 case ACPI_TYPE_LOCAL_BANK_FIELD:
@@ -333,9 +352,8 @@ acpi_ex_resolve_multiple (
333 ACPI_FUNCTION_TRACE ("acpi_ex_resolve_multiple"); 352 ACPI_FUNCTION_TRACE ("acpi_ex_resolve_multiple");
334 353
335 354
336 /* 355 /* Operand can be either a namespace node or an operand descriptor */
337 * Operand can be either a namespace node or an operand descriptor 356
338 */
339 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { 357 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
340 case ACPI_DESC_TYPE_OPERAND: 358 case ACPI_DESC_TYPE_OPERAND:
341 type = obj_desc->common.type; 359 type = obj_desc->common.type;
@@ -357,10 +375,8 @@ acpi_ex_resolve_multiple (
357 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 375 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
358 } 376 }
359 377
378 /* If type is anything other than a reference, we are done */
360 379
361 /*
362 * If type is anything other than a reference, we are done
363 */
364 if (type != ACPI_TYPE_LOCAL_REFERENCE) { 380 if (type != ACPI_TYPE_LOCAL_REFERENCE) {
365 goto exit; 381 goto exit;
366 } 382 }
@@ -382,8 +398,9 @@ acpi_ex_resolve_multiple (
382 /* All "References" point to a NS node */ 398 /* All "References" point to a NS node */
383 399
384 if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { 400 if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
385 ACPI_REPORT_ERROR (("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", 401 ACPI_REPORT_ERROR ((
386 node, acpi_ut_get_descriptor_name (node))); 402 "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n",
403 node, acpi_ut_get_descriptor_name (node)));
387 return_ACPI_STATUS (AE_AML_INTERNAL); 404 return_ACPI_STATUS (AE_AML_INTERNAL);
388 } 405 }
389 406
@@ -440,8 +457,9 @@ acpi_ex_resolve_multiple (
440 /* All "References" point to a NS node */ 457 /* All "References" point to a NS node */
441 458
442 if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { 459 if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
443 ACPI_REPORT_ERROR (("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", 460 ACPI_REPORT_ERROR ((
444 node, acpi_ut_get_descriptor_name (node))); 461 "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n",
462 node, acpi_ut_get_descriptor_name (node)));
445 return_ACPI_STATUS (AE_AML_INTERNAL); 463 return_ACPI_STATUS (AE_AML_INTERNAL);
446 } 464 }
447 465
@@ -468,7 +486,7 @@ acpi_ex_resolve_multiple (
468 486
469 if (return_desc) { 487 if (return_desc) {
470 status = acpi_ds_method_data_get_value (obj_desc->reference.opcode, 488 status = acpi_ds_method_data_get_value (obj_desc->reference.opcode,
471 obj_desc->reference.offset, walk_state, &obj_desc); 489 obj_desc->reference.offset, walk_state, &obj_desc);
472 if (ACPI_FAILURE (status)) { 490 if (ACPI_FAILURE (status)) {
473 return_ACPI_STATUS (status); 491 return_ACPI_STATUS (status);
474 } 492 }
@@ -500,7 +518,8 @@ acpi_ex_resolve_multiple (
500 518
501 default: 519 default:
502 520
503 ACPI_REPORT_ERROR (("acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", 521 ACPI_REPORT_ERROR ((
522 "acpi_ex_resolve_multiple: Unknown Reference subtype %X\n",
504 obj_desc->reference.opcode)); 523 obj_desc->reference.opcode));
505 return_ACPI_STATUS (AE_AML_INTERNAL); 524 return_ACPI_STATUS (AE_AML_INTERNAL);
506 } 525 }
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c
index c92890220c32..d8b470eefe7a 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/executer/exresop.c
@@ -52,6 +52,14 @@
52#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
53 ACPI_MODULE_NAME ("exresop") 53 ACPI_MODULE_NAME ("exresop")
54 54
55/* Local prototypes */
56
57static acpi_status
58acpi_ex_check_object_type (
59 acpi_object_type type_needed,
60 acpi_object_type this_type,
61 void *object);
62
55 63
56/******************************************************************************* 64/*******************************************************************************
57 * 65 *
@@ -67,7 +75,7 @@
67 * 75 *
68 ******************************************************************************/ 76 ******************************************************************************/
69 77
70acpi_status 78static acpi_status
71acpi_ex_check_object_type ( 79acpi_ex_check_object_type (
72 acpi_object_type type_needed, 80 acpi_object_type type_needed,
73 acpi_object_type this_type, 81 acpi_object_type this_type,
@@ -142,6 +150,7 @@ acpi_ex_resolve_operands (
142 const struct acpi_opcode_info *op_info; 150 const struct acpi_opcode_info *op_info;
143 u32 this_arg_type; 151 u32 this_arg_type;
144 acpi_object_type type_needed; 152 acpi_object_type type_needed;
153 u16 target_op = 0;
145 154
146 155
147 ACPI_FUNCTION_TRACE_U32 ("ex_resolve_operands", opcode); 156 ACPI_FUNCTION_TRACE_U32 ("ex_resolve_operands", opcode);
@@ -160,7 +169,8 @@ acpi_ex_resolve_operands (
160 return_ACPI_STATUS (AE_AML_INTERNAL); 169 return_ACPI_STATUS (AE_AML_INTERNAL);
161 } 170 }
162 171
163 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] required_operand_types=%8.8X \n", 172 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
173 "Opcode %X [%s] required_operand_types=%8.8X \n",
164 opcode, op_info->name, arg_types)); 174 opcode, op_info->name, arg_types));
165 175
166 /* 176 /*
@@ -187,7 +197,7 @@ acpi_ex_resolve_operands (
187 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { 197 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
188 case ACPI_DESC_TYPE_NAMED: 198 case ACPI_DESC_TYPE_NAMED:
189 199
190 /* Node */ 200 /* Namespace Node */
191 201
192 object_type = ((struct acpi_namespace_node *) obj_desc)->type; 202 object_type = ((struct acpi_namespace_node *) obj_desc)->type;
193 break; 203 break;
@@ -202,16 +212,16 @@ acpi_ex_resolve_operands (
202 /* Check for bad acpi_object_type */ 212 /* Check for bad acpi_object_type */
203 213
204 if (!acpi_ut_valid_object_type (object_type)) { 214 if (!acpi_ut_valid_object_type (object_type)) {
205 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad operand object type [%X]\n", 215 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
216 "Bad operand object type [%X]\n",
206 object_type)); 217 object_type));
207 218
208 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 219 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
209 } 220 }
210 221
211 if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) { 222 if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) {
212 /* 223 /* Decode the Reference */
213 * Decode the Reference 224
214 */
215 op_info = acpi_ps_get_opcode_info (opcode); 225 op_info = acpi_ps_get_opcode_info (opcode);
216 if (op_info->class == AML_CLASS_UNKNOWN) { 226 if (op_info->class == AML_CLASS_UNKNOWN) {
217 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 227 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
@@ -219,12 +229,17 @@ acpi_ex_resolve_operands (
219 229
220 switch (obj_desc->reference.opcode) { 230 switch (obj_desc->reference.opcode) {
221 case AML_DEBUG_OP: 231 case AML_DEBUG_OP:
232 target_op = AML_DEBUG_OP;
233
234 /*lint -fallthrough */
235
222 case AML_NAME_OP: 236 case AML_NAME_OP:
223 case AML_INDEX_OP: 237 case AML_INDEX_OP:
224 case AML_REF_OF_OP: 238 case AML_REF_OF_OP:
225 case AML_ARG_OP: 239 case AML_ARG_OP:
226 case AML_LOCAL_OP: 240 case AML_LOCAL_OP:
227 case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ 241 case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
242 case AML_INT_NAMEPATH_OP: /* Reference to a named object */
228 243
229 ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 244 ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
230 "Operand is a Reference, ref_opcode [%s]\n", 245 "Operand is a Reference, ref_opcode [%s]\n",
@@ -254,10 +269,8 @@ acpi_ex_resolve_operands (
254 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 269 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
255 } 270 }
256 271
272 /* Get one argument type, point to the next */
257 273
258 /*
259 * Get one argument type, point to the next
260 */
261 this_arg_type = GET_CURRENT_ARG_TYPE (arg_types); 274 this_arg_type = GET_CURRENT_ARG_TYPE (arg_types);
262 INCREMENT_ARG_LIST (arg_types); 275 INCREMENT_ARG_LIST (arg_types);
263 276
@@ -271,26 +284,31 @@ acpi_ex_resolve_operands (
271 if ((ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) && 284 if ((ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) &&
272 (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_STRING)) { 285 (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_STRING)) {
273 /* 286 /*
274 * String found - the string references a named object and must be 287 * String found - the string references a named object and
275 * resolved to a node 288 * must be resolved to a node
276 */ 289 */
277 goto next_operand; 290 goto next_operand;
278 } 291 }
279 292
280 /* Else not a string - fall through to the normal Reference case below */ 293 /*
294 * Else not a string - fall through to the normal Reference
295 * case below
296 */
281 /*lint -fallthrough */ 297 /*lint -fallthrough */
282 298
283 case ARGI_REFERENCE: /* References: */ 299 case ARGI_REFERENCE: /* References: */
284 case ARGI_INTEGER_REF: 300 case ARGI_INTEGER_REF:
285 case ARGI_OBJECT_REF: 301 case ARGI_OBJECT_REF:
286 case ARGI_DEVICE_REF: 302 case ARGI_DEVICE_REF:
287 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ 303 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
288 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ 304 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
289 case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ 305 case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
290
291 /* Need an operand of type ACPI_TYPE_LOCAL_REFERENCE */
292 306
293 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */ { 307 /*
308 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
309 * A Namespace Node is OK as-is
310 */
311 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
294 goto next_operand; 312 goto next_operand;
295 } 313 }
296 314
@@ -300,11 +318,9 @@ acpi_ex_resolve_operands (
300 return_ACPI_STATUS (status); 318 return_ACPI_STATUS (status);
301 } 319 }
302 320
303 if (AML_NAME_OP == obj_desc->reference.opcode) { 321 if (obj_desc->reference.opcode == AML_NAME_OP) {
304 /* 322 /* Convert a named reference to the actual named object */
305 * Convert an indirect name ptr to direct name ptr and put 323
306 * it on the stack
307 */
308 temp_node = obj_desc->reference.object; 324 temp_node = obj_desc->reference.object;
309 acpi_ut_remove_reference (obj_desc); 325 acpi_ut_remove_reference (obj_desc);
310 (*stack_ptr) = temp_node; 326 (*stack_ptr) = temp_node;
@@ -332,7 +348,6 @@ acpi_ex_resolve_operands (
332 break; 348 break;
333 } 349 }
334 350
335
336 /* 351 /*
337 * Resolve this object to a value 352 * Resolve this object to a value
338 */ 353 */
@@ -392,7 +407,7 @@ acpi_ex_resolve_operands (
392 /* 407 /*
393 * The more complex cases allow multiple resolved object types 408 * The more complex cases allow multiple resolved object types
394 */ 409 */
395 case ARGI_INTEGER: /* Number */ 410 case ARGI_INTEGER:
396 411
397 /* 412 /*
398 * Need an operand of type ACPI_TYPE_INTEGER, 413 * Need an operand of type ACPI_TYPE_INTEGER,
@@ -563,7 +578,7 @@ acpi_ex_resolve_operands (
563 578
564 case ARGI_REGION_OR_FIELD: 579 case ARGI_REGION_OR_FIELD:
565 580
566 /* Need an operand of type ACPI_TYPE_REGION or a FIELD in a region */ 581 /* Need an operand of type REGION or a FIELD in a region */
567 582
568 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 583 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
569 case ACPI_TYPE_REGION: 584 case ACPI_TYPE_REGION:
@@ -614,6 +629,12 @@ acpi_ex_resolve_operands (
614 break; 629 break;
615 } 630 }
616 631
632 if (target_op == AML_DEBUG_OP) {
633 /* Allow store of any object to the Debug object */
634
635 break;
636 }
637
617 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 638 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
618 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", 639 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n",
619 acpi_ut_get_object_type_name (obj_desc), obj_desc)); 640 acpi_ut_get_object_type_name (obj_desc), obj_desc));
@@ -652,8 +673,7 @@ next_operand:
652 if (GET_CURRENT_ARG_TYPE (arg_types)) { 673 if (GET_CURRENT_ARG_TYPE (arg_types)) {
653 stack_ptr--; 674 stack_ptr--;
654 } 675 }
655 676 }
656 } /* while (*Types) */
657 677
658 return_ACPI_STATUS (status); 678 return_ACPI_STATUS (status);
659} 679}
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index e0fc6aba1253..2725db0901b8 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/executer/exstore.c
@@ -48,11 +48,171 @@
48#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
49#include <acpi/amlcode.h> 49#include <acpi/amlcode.h>
50#include <acpi/acnamesp.h> 50#include <acpi/acnamesp.h>
51#include <acpi/acparser.h>
51 52
52 53
53#define _COMPONENT ACPI_EXECUTER 54#define _COMPONENT ACPI_EXECUTER
54 ACPI_MODULE_NAME ("exstore") 55 ACPI_MODULE_NAME ("exstore")
55 56
57/* Local prototypes */
58
59static void
60acpi_ex_do_debug_object (
61 union acpi_operand_object *source_desc,
62 u32 level,
63 u32 index);
64
65static acpi_status
66acpi_ex_store_object_to_index (
67 union acpi_operand_object *val_desc,
68 union acpi_operand_object *dest_desc,
69 struct acpi_walk_state *walk_state);
70
71
72/*******************************************************************************
73 *
74 * FUNCTION: acpi_ex_do_debug_object
75 *
76 * PARAMETERS: source_desc - Value to be stored
77 * Level - Indentation level (used for packages)
78 * Index - Current package element, zero if not pkg
79 *
80 * RETURN: None
81 *
82 * DESCRIPTION: Handles stores to the Debug Object.
83 *
84 ******************************************************************************/
85
86static void
87acpi_ex_do_debug_object (
88 union acpi_operand_object *source_desc,
89 u32 level,
90 u32 index)
91{
92 u32 i;
93
94
95 ACPI_FUNCTION_TRACE_PTR ("ex_do_debug_object", source_desc);
96
97
98 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s",
99 level, " "));
100
101 /* Display index for package output only */
102
103 if (index > 0) {
104 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
105 "(%.2u) ", index -1));
106 }
107
108 if (!source_desc) {
109 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "<Null Object>\n"));
110 return_VOID;
111 }
112
113 if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_OPERAND) {
114 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: ",
115 acpi_ut_get_object_type_name (source_desc)));
116
117 if (!acpi_ut_valid_internal_object (source_desc)) {
118 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
119 "%p, Invalid Internal Object!\n", source_desc));
120 return_VOID;
121 }
122 }
123 else if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_NAMED) {
124 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n",
125 acpi_ut_get_type_name (((struct acpi_namespace_node *) source_desc)->type),
126 source_desc));
127 return_VOID;
128 }
129 else {
130 return_VOID;
131 }
132
133 switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
134 case ACPI_TYPE_INTEGER:
135
136 /* Output correct integer width */
137
138 if (acpi_gbl_integer_byte_width == 4) {
139 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
140 (u32) source_desc->integer.value));
141 }
142 else {
143 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n",
144 ACPI_FORMAT_UINT64 (source_desc->integer.value)));
145 }
146 break;
147
148 case ACPI_TYPE_BUFFER:
149
150 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]",
151 (u32) source_desc->buffer.length));
152 ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
153 (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
154 break;
155
156 case ACPI_TYPE_STRING:
157
158 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
159 source_desc->string.length, source_desc->string.pointer));
160 break;
161
162 case ACPI_TYPE_PACKAGE:
163
164 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X Elements]\n",
165 source_desc->package.count));
166
167 /* Output the entire contents of the package */
168
169 for (i = 0; i < source_desc->package.count; i++) {
170 acpi_ex_do_debug_object (source_desc->package.elements[i],
171 level+4, i+1);
172 }
173 break;
174
175 case ACPI_TYPE_LOCAL_REFERENCE:
176
177 if (source_desc->reference.opcode == AML_INDEX_OP) {
178 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s, 0x%X]\n",
179 acpi_ps_get_opcode_name (source_desc->reference.opcode),
180 source_desc->reference.offset));
181 }
182 else {
183 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s]\n",
184 acpi_ps_get_opcode_name (source_desc->reference.opcode)));
185 }
186
187
188 if (source_desc->reference.object) {
189 if (ACPI_GET_DESCRIPTOR_TYPE (source_desc->reference.object) ==
190 ACPI_DESC_TYPE_NAMED) {
191 acpi_ex_do_debug_object (((struct acpi_namespace_node *)
192 source_desc->reference.object)->object,
193 level+4, 0);
194 }
195 else {
196 acpi_ex_do_debug_object (source_desc->reference.object, level+4, 0);
197 }
198 }
199 else if (source_desc->reference.node) {
200 acpi_ex_do_debug_object ((source_desc->reference.node)->object,
201 level+4, 0);
202 }
203 break;
204
205 default:
206
207 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p %s\n",
208 source_desc, acpi_ut_get_object_type_name (source_desc)));
209 break;
210 }
211
212 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
213 return_VOID;
214}
215
56 216
57/******************************************************************************* 217/*******************************************************************************
58 * 218 *
@@ -154,8 +314,9 @@ acpi_ex_store (
154 314
155 /* Storing an object into a Name "container" */ 315 /* Storing an object into a Name "container" */
156 316
157 status = acpi_ex_store_object_to_node (source_desc, ref_desc->reference.object, 317 status = acpi_ex_store_object_to_node (source_desc,
158 walk_state, ACPI_IMPLICIT_CONVERSION); 318 ref_desc->reference.object,
319 walk_state, ACPI_IMPLICIT_CONVERSION);
159 break; 320 break;
160 321
161 322
@@ -173,7 +334,7 @@ acpi_ex_store (
173 /* Store to a method local/arg */ 334 /* Store to a method local/arg */
174 335
175 status = acpi_ds_store_object_to_local (ref_desc->reference.opcode, 336 status = acpi_ds_store_object_to_local (ref_desc->reference.opcode,
176 ref_desc->reference.offset, source_desc, walk_state); 337 ref_desc->reference.offset, source_desc, walk_state);
177 break; 338 break;
178 339
179 340
@@ -187,60 +348,7 @@ acpi_ex_store (
187 "**** Write to Debug Object: Object %p %s ****:\n\n", 348 "**** Write to Debug Object: Object %p %s ****:\n\n",
188 source_desc, acpi_ut_get_object_type_name (source_desc))); 349 source_desc, acpi_ut_get_object_type_name (source_desc)));
189 350
190 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ", 351 acpi_ex_do_debug_object (source_desc, 0, 0);
191 acpi_ut_get_object_type_name (source_desc)));
192
193 if (!acpi_ut_valid_internal_object (source_desc)) {
194 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
195 "%p, Invalid Internal Object!\n", source_desc));
196 break;
197 }
198
199 switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
200 case ACPI_TYPE_INTEGER:
201
202 if (acpi_gbl_integer_byte_width == 4) {
203 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
204 (u32) source_desc->integer.value));
205 }
206 else {
207 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n",
208 ACPI_FORMAT_UINT64 (source_desc->integer.value)));
209 }
210 break;
211
212
213 case ACPI_TYPE_BUFFER:
214
215 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]",
216 (u32) source_desc->buffer.length));
217 ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
218 (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
219 break;
220
221
222 case ACPI_TYPE_STRING:
223
224 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
225 source_desc->string.length, source_desc->string.pointer));
226 break;
227
228
229 case ACPI_TYPE_PACKAGE:
230
231 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] Elements Ptr - %p\n",
232 source_desc->package.count, source_desc->package.elements));
233 break;
234
235
236 default:
237
238 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n",
239 source_desc));
240 break;
241 }
242
243 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
244 break; 352 break;
245 353
246 354
@@ -272,7 +380,7 @@ acpi_ex_store (
272 * 380 *
273 ******************************************************************************/ 381 ******************************************************************************/
274 382
275acpi_status 383static acpi_status
276acpi_ex_store_object_to_index ( 384acpi_ex_store_object_to_index (
277 union acpi_operand_object *source_desc, 385 union acpi_operand_object *source_desc,
278 union acpi_operand_object *index_desc, 386 union acpi_operand_object *index_desc,
@@ -313,16 +421,22 @@ acpi_ex_store_object_to_index (
313 if (obj_desc) { 421 if (obj_desc) {
314 /* Decrement reference count by the ref count of the parent package */ 422 /* Decrement reference count by the ref count of the parent package */
315 423
316 for (i = 0; i < ((union acpi_operand_object *) index_desc->reference.object)->common.reference_count; i++) { 424 for (i = 0;
425 i < ((union acpi_operand_object *)
426 index_desc->reference.object)->common.reference_count;
427 i++) {
317 acpi_ut_remove_reference (obj_desc); 428 acpi_ut_remove_reference (obj_desc);
318 } 429 }
319 } 430 }
320 431
321 *(index_desc->reference.where) = new_desc; 432 *(index_desc->reference.where) = new_desc;
322 433
323 /* Increment reference count by the ref count of the parent package -1 */ 434 /* Increment ref count by the ref count of the parent package-1 */
324 435
325 for (i = 1; i < ((union acpi_operand_object *) index_desc->reference.object)->common.reference_count; i++) { 436 for (i = 1;
437 i < ((union acpi_operand_object *)
438 index_desc->reference.object)->common.reference_count;
439 i++) {
326 acpi_ut_add_reference (new_desc); 440 acpi_ut_add_reference (new_desc);
327 } 441 }
328 442
@@ -440,9 +554,8 @@ acpi_ex_store_object_to_node (
440 ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_node", source_desc); 554 ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_node", source_desc);
441 555
442 556
443 /* 557 /* Get current type of the node, and object attached to Node */
444 * Get current type of the node, and object attached to Node 558
445 */
446 target_type = acpi_ns_get_type (node); 559 target_type = acpi_ns_get_type (node);
447 target_desc = acpi_ns_get_attached_object (node); 560 target_desc = acpi_ns_get_attached_object (node);
448 561
@@ -467,19 +580,18 @@ acpi_ex_store_object_to_node (
467 target_type = ACPI_TYPE_ANY; 580 target_type = ACPI_TYPE_ANY;
468 } 581 }
469 582
470 /* 583 /* Do the actual store operation */
471 * Do the actual store operation 584
472 */
473 switch (target_type) { 585 switch (target_type) {
474 case ACPI_TYPE_BUFFER_FIELD: 586 case ACPI_TYPE_BUFFER_FIELD:
475 case ACPI_TYPE_LOCAL_REGION_FIELD: 587 case ACPI_TYPE_LOCAL_REGION_FIELD:
476 case ACPI_TYPE_LOCAL_BANK_FIELD: 588 case ACPI_TYPE_LOCAL_BANK_FIELD:
477 case ACPI_TYPE_LOCAL_INDEX_FIELD: 589 case ACPI_TYPE_LOCAL_INDEX_FIELD:
478 590
479 /* 591 /* For fields, copy the source data to the target field. */
480 * For fields, copy the source data to the target field. 592
481 */ 593 status = acpi_ex_write_data_to_field (source_desc, target_desc,
482 status = acpi_ex_write_data_to_field (source_desc, target_desc, &walk_state->result_obj); 594 &walk_state->result_obj);
483 break; 595 break;
484 596
485 597
@@ -493,7 +605,8 @@ acpi_ex_store_object_to_node (
493 * 605 *
494 * Copy and/or convert the source object to a new target object 606 * Copy and/or convert the source object to a new target object
495 */ 607 */
496 status = acpi_ex_store_object_to_object (source_desc, target_desc, &new_desc, walk_state); 608 status = acpi_ex_store_object_to_object (source_desc, target_desc,
609 &new_desc, walk_state);
497 if (ACPI_FAILURE (status)) { 610 if (ACPI_FAILURE (status)) {
498 return_ACPI_STATUS (status); 611 return_ACPI_STATUS (status);
499 } 612 }
@@ -526,7 +639,8 @@ acpi_ex_store_object_to_node (
526 639
527 /* No conversions for all other types. Just attach the source object */ 640 /* No conversions for all other types. Just attach the source object */
528 641
529 status = acpi_ns_attach_object (node, source_desc, ACPI_GET_OBJECT_TYPE (source_desc)); 642 status = acpi_ns_attach_object (node, source_desc,
643 ACPI_GET_OBJECT_TYPE (source_desc));
530 break; 644 break;
531 } 645 }
532 646
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c
index d3677feb07fd..120f30ed0bd4 100644
--- a/drivers/acpi/executer/exstoren.c
+++ b/drivers/acpi/executer/exstoren.c
@@ -81,9 +81,8 @@ acpi_ex_resolve_object (
81 ACPI_FUNCTION_TRACE ("ex_resolve_object"); 81 ACPI_FUNCTION_TRACE ("ex_resolve_object");
82 82
83 83
84 /* 84 /* Ensure we have a Target that can be stored to */
85 * Ensure we have a Target that can be stored to 85
86 */
87 switch (target_type) { 86 switch (target_type) {
88 case ACPI_TYPE_BUFFER_FIELD: 87 case ACPI_TYPE_BUFFER_FIELD:
89 case ACPI_TYPE_LOCAL_REGION_FIELD: 88 case ACPI_TYPE_LOCAL_REGION_FIELD:
@@ -118,16 +117,14 @@ acpi_ex_resolve_object (
118 break; 117 break;
119 } 118 }
120 119
121 /* 120 /* Must have a Integer, Buffer, or String */
122 * Must have a Integer, Buffer, or String 121
123 */
124 if ((ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) && 122 if ((ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) &&
125 (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) && 123 (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) &&
126 (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) && 124 (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) &&
127 !((ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) && (source_desc->reference.opcode == AML_LOAD_OP))) { 125 !((ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) && (source_desc->reference.opcode == AML_LOAD_OP))) {
128 /* 126 /* Conversion successful but still not a valid type */
129 * Conversion successful but still not a valid type 127
130 */
131 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 128 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
132 "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", 129 "Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
133 acpi_ut_get_object_type_name (source_desc), 130 acpi_ut_get_object_type_name (source_desc),
@@ -140,9 +137,8 @@ acpi_ex_resolve_object (
140 case ACPI_TYPE_LOCAL_ALIAS: 137 case ACPI_TYPE_LOCAL_ALIAS:
141 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 138 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
142 139
143 /* 140 /* Aliases are resolved by acpi_ex_prep_operands */
144 * Aliases are resolved by acpi_ex_prep_operands 141
145 */
146 ACPI_REPORT_ERROR (("Store into Alias - should never happen\n")); 142 ACPI_REPORT_ERROR (("Store into Alias - should never happen\n"));
147 status = AE_AML_INTERNAL; 143 status = AE_AML_INTERNAL;
148 break; 144 break;
diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c
index 05e1ecae8d92..12d1527669c8 100644
--- a/drivers/acpi/executer/exstorob.c
+++ b/drivers/acpi/executer/exstorob.c
@@ -128,7 +128,8 @@ acpi_ex_store_buffer_to_buffer (
128 else { 128 else {
129 /* Truncate the source, copy only what will fit */ 129 /* Truncate the source, copy only what will fit */
130 130
131 ACPI_MEMCPY (target_desc->buffer.pointer, buffer, target_desc->buffer.length); 131 ACPI_MEMCPY (target_desc->buffer.pointer, buffer,
132 target_desc->buffer.length);
132 133
133 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 134 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
134 "Truncating source buffer from %X to %X\n", 135 "Truncating source buffer from %X to %X\n",
@@ -183,7 +184,8 @@ acpi_ex_store_string_to_string (
183 * String will fit in existing non-static buffer. 184 * String will fit in existing non-static buffer.
184 * Clear old string and copy in the new one 185 * Clear old string and copy in the new one
185 */ 186 */
186 ACPI_MEMSET (target_desc->string.pointer, 0, (acpi_size) target_desc->string.length + 1); 187 ACPI_MEMSET (target_desc->string.pointer, 0,
188 (acpi_size) target_desc->string.length + 1);
187 ACPI_MEMCPY (target_desc->string.pointer, buffer, length); 189 ACPI_MEMCPY (target_desc->string.pointer, buffer, length);
188 } 190 }
189 else { 191 else {
@@ -198,7 +200,8 @@ acpi_ex_store_string_to_string (
198 ACPI_MEM_FREE (target_desc->string.pointer); 200 ACPI_MEM_FREE (target_desc->string.pointer);
199 } 201 }
200 202
201 target_desc->string.pointer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); 203 target_desc->string.pointer = ACPI_MEM_CALLOCATE (
204 (acpi_size) length + 1);
202 if (!target_desc->string.pointer) { 205 if (!target_desc->string.pointer) {
203 return_ACPI_STATUS (AE_NO_MEMORY); 206 return_ACPI_STATUS (AE_NO_MEMORY);
204 } 207 }
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
index f92efc512890..cafa702108dc 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/executer/exsystem.c
@@ -55,8 +55,8 @@
55 * 55 *
56 * FUNCTION: acpi_ex_system_wait_semaphore 56 * FUNCTION: acpi_ex_system_wait_semaphore
57 * 57 *
58 * PARAMETERS: Semaphore - OSD semaphore to wait on 58 * PARAMETERS: Semaphore - Semaphore to wait on
59 * Timeout - Max time to wait 59 * Timeout - Max time to wait
60 * 60 *
61 * RETURN: Status 61 * RETURN: Status
62 * 62 *
@@ -90,7 +90,8 @@ acpi_ex_system_wait_semaphore (
90 90
91 status = acpi_os_wait_semaphore (semaphore, 1, timeout); 91 status = acpi_os_wait_semaphore (semaphore, 1, timeout);
92 92
93 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*** Thread awake after blocking, %s\n", 93 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
94 "*** Thread awake after blocking, %s\n",
94 acpi_format_exception (status))); 95 acpi_format_exception (status)));
95 96
96 /* Reacquire the interpreter */ 97 /* Reacquire the interpreter */
@@ -111,8 +112,8 @@ acpi_ex_system_wait_semaphore (
111 * 112 *
112 * FUNCTION: acpi_ex_system_do_stall 113 * FUNCTION: acpi_ex_system_do_stall
113 * 114 *
114 * PARAMETERS: how_long - The amount of time to stall, 115 * PARAMETERS: how_long - The amount of time to stall,
115 * in microseconds 116 * in microseconds
116 * 117 *
117 * RETURN: Status 118 * RETURN: Status
118 * 119 *
@@ -141,7 +142,8 @@ acpi_ex_system_do_stall (
141 * (ACPI specifies 100 usec as max, but this gives some slack in 142 * (ACPI specifies 100 usec as max, but this gives some slack in
142 * order to support existing BIOSs) 143 * order to support existing BIOSs)
143 */ 144 */
144 ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n", how_long)); 145 ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n",
146 how_long));
145 status = AE_AML_OPERAND_VALUE; 147 status = AE_AML_OPERAND_VALUE;
146 } 148 }
147 else { 149 else {
@@ -156,8 +158,8 @@ acpi_ex_system_do_stall (
156 * 158 *
157 * FUNCTION: acpi_ex_system_do_suspend 159 * FUNCTION: acpi_ex_system_do_suspend
158 * 160 *
159 * PARAMETERS: how_long - The amount of time to suspend, 161 * PARAMETERS: how_long - The amount of time to suspend,
160 * in milliseconds 162 * in milliseconds
161 * 163 *
162 * RETURN: None 164 * RETURN: None
163 * 165 *
@@ -192,8 +194,8 @@ acpi_ex_system_do_suspend (
192 * 194 *
193 * FUNCTION: acpi_ex_system_acquire_mutex 195 * FUNCTION: acpi_ex_system_acquire_mutex
194 * 196 *
195 * PARAMETERS: *time_desc - The 'time to delay' object descriptor 197 * PARAMETERS: time_desc - The 'time to delay' object descriptor
196 * *obj_desc - The object descriptor for this op 198 * obj_desc - The object descriptor for this op
197 * 199 *
198 * RETURN: Status 200 * RETURN: Status
199 * 201 *
@@ -218,16 +220,15 @@ acpi_ex_system_acquire_mutex (
218 return_ACPI_STATUS (AE_BAD_PARAMETER); 220 return_ACPI_STATUS (AE_BAD_PARAMETER);
219 } 221 }
220 222
221 /* 223 /* Support for the _GL_ Mutex object -- go get the global lock */
222 * Support for the _GL_ Mutex object -- go get the global lock 224
223 */
224 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 225 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
225 status = acpi_ev_acquire_global_lock ((u16) time_desc->integer.value); 226 status = acpi_ev_acquire_global_lock ((u16) time_desc->integer.value);
226 return_ACPI_STATUS (status); 227 return_ACPI_STATUS (status);
227 } 228 }
228 229
229 status = acpi_ex_system_wait_semaphore (obj_desc->mutex.semaphore, 230 status = acpi_ex_system_wait_semaphore (obj_desc->mutex.semaphore,
230 (u16) time_desc->integer.value); 231 (u16) time_desc->integer.value);
231 return_ACPI_STATUS (status); 232 return_ACPI_STATUS (status);
232} 233}
233 234
@@ -236,7 +237,7 @@ acpi_ex_system_acquire_mutex (
236 * 237 *
237 * FUNCTION: acpi_ex_system_release_mutex 238 * FUNCTION: acpi_ex_system_release_mutex
238 * 239 *
239 * PARAMETERS: *obj_desc - The object descriptor for this op 240 * PARAMETERS: obj_desc - The object descriptor for this op
240 * 241 *
241 * RETURN: Status 242 * RETURN: Status
242 * 243 *
@@ -261,9 +262,8 @@ acpi_ex_system_release_mutex (
261 return_ACPI_STATUS (AE_BAD_PARAMETER); 262 return_ACPI_STATUS (AE_BAD_PARAMETER);
262 } 263 }
263 264
264 /* 265 /* Support for the _GL_ Mutex object -- release the global lock */
265 * Support for the _GL_ Mutex object -- release the global lock 266
266 */
267 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 267 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
268 status = acpi_ev_release_global_lock (); 268 status = acpi_ev_release_global_lock ();
269 return_ACPI_STATUS (status); 269 return_ACPI_STATUS (status);
@@ -278,9 +278,9 @@ acpi_ex_system_release_mutex (
278 * 278 *
279 * FUNCTION: acpi_ex_system_signal_event 279 * FUNCTION: acpi_ex_system_signal_event
280 * 280 *
281 * PARAMETERS: *obj_desc - The object descriptor for this op 281 * PARAMETERS: obj_desc - The object descriptor for this op
282 * 282 *
283 * RETURN: AE_OK 283 * RETURN: Status
284 * 284 *
285 * DESCRIPTION: Provides an access point to perform synchronization operations 285 * DESCRIPTION: Provides an access point to perform synchronization operations
286 * within the AML. 286 * within the AML.
@@ -309,8 +309,8 @@ acpi_ex_system_signal_event (
309 * 309 *
310 * FUNCTION: acpi_ex_system_wait_event 310 * FUNCTION: acpi_ex_system_wait_event
311 * 311 *
312 * PARAMETERS: *time_desc - The 'time to delay' object descriptor 312 * PARAMETERS: time_desc - The 'time to delay' object descriptor
313 * *obj_desc - The object descriptor for this op 313 * obj_desc - The object descriptor for this op
314 * 314 *
315 * RETURN: Status 315 * RETURN: Status
316 * 316 *
@@ -333,7 +333,7 @@ acpi_ex_system_wait_event (
333 333
334 if (obj_desc) { 334 if (obj_desc) {
335 status = acpi_ex_system_wait_semaphore (obj_desc->event.semaphore, 335 status = acpi_ex_system_wait_semaphore (obj_desc->event.semaphore,
336 (u16) time_desc->integer.value); 336 (u16) time_desc->integer.value);
337 } 337 }
338 338
339 return_ACPI_STATUS (status); 339 return_ACPI_STATUS (status);
@@ -344,7 +344,7 @@ acpi_ex_system_wait_event (
344 * 344 *
345 * FUNCTION: acpi_ex_system_reset_event 345 * FUNCTION: acpi_ex_system_reset_event
346 * 346 *
347 * PARAMETERS: *obj_desc - The object descriptor for this op 347 * PARAMETERS: obj_desc - The object descriptor for this op
348 * 348 *
349 * RETURN: Status 349 * RETURN: Status
350 * 350 *
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index 40c6abb8b49a..5c7ec0c04177 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -67,22 +67,31 @@
67#define _COMPONENT ACPI_EXECUTER 67#define _COMPONENT ACPI_EXECUTER
68 ACPI_MODULE_NAME ("exutils") 68 ACPI_MODULE_NAME ("exutils")
69 69
70/* Local prototypes */
70 71
71#ifndef ACPI_NO_METHOD_EXECUTION 72static u32
73acpi_ex_digits_needed (
74 acpi_integer value,
75 u32 base);
72 76
77
78#ifndef ACPI_NO_METHOD_EXECUTION
73/******************************************************************************* 79/*******************************************************************************
74 * 80 *
75 * FUNCTION: acpi_ex_enter_interpreter 81 * FUNCTION: acpi_ex_enter_interpreter
76 * 82 *
77 * PARAMETERS: None 83 * PARAMETERS: None
78 * 84 *
85 * RETURN: Status
86 *
79 * DESCRIPTION: Enter the interpreter execution region. Failure to enter 87 * DESCRIPTION: Enter the interpreter execution region. Failure to enter
80 * the interpreter region is a fatal system error 88 * the interpreter region is a fatal system error
81 * 89 *
82 ******************************************************************************/ 90 ******************************************************************************/
83 91
84acpi_status 92acpi_status
85acpi_ex_enter_interpreter (void) 93acpi_ex_enter_interpreter (
94 void)
86{ 95{
87 acpi_status status; 96 acpi_status status;
88 97
@@ -104,6 +113,8 @@ acpi_ex_enter_interpreter (void)
104 * 113 *
105 * PARAMETERS: None 114 * PARAMETERS: None
106 * 115 *
116 * RETURN: None
117 *
107 * DESCRIPTION: Exit the interpreter execution region 118 * DESCRIPTION: Exit the interpreter execution region
108 * 119 *
109 * Cases where the interpreter is unlocked: 120 * Cases where the interpreter is unlocked:
@@ -119,7 +130,8 @@ acpi_ex_enter_interpreter (void)
119 ******************************************************************************/ 130 ******************************************************************************/
120 131
121void 132void
122acpi_ex_exit_interpreter (void) 133acpi_ex_exit_interpreter (
134 void)
123{ 135{
124 acpi_status status; 136 acpi_status status;
125 137
@@ -212,7 +224,8 @@ acpi_ex_acquire_global_lock (
212 locked = TRUE; 224 locked = TRUE;
213 } 225 }
214 else { 226 else {
215 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not acquire Global Lock, %s\n", 227 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
228 "Could not acquire Global Lock, %s\n",
216 acpi_format_exception (status))); 229 acpi_format_exception (status)));
217 } 230 }
218 } 231 }
@@ -228,7 +241,7 @@ acpi_ex_acquire_global_lock (
228 * PARAMETERS: locked_by_me - Return value from corresponding call to 241 * PARAMETERS: locked_by_me - Return value from corresponding call to
229 * acquire_global_lock. 242 * acquire_global_lock.
230 * 243 *
231 * RETURN: Status 244 * RETURN: None
232 * 245 *
233 * DESCRIPTION: Release the global lock if it is locked. 246 * DESCRIPTION: Release the global lock if it is locked.
234 * 247 *
@@ -269,11 +282,14 @@ acpi_ex_release_global_lock (
269 * PARAMETERS: Value - Value to be represented 282 * PARAMETERS: Value - Value to be represented
270 * Base - Base of representation 283 * Base - Base of representation
271 * 284 *
272 * RETURN: the number of digits needed to represent Value in Base 285 * RETURN: The number of digits.
286 *
287 * DESCRIPTION: Calculate the number of digits needed to represent the Value
288 * in the given Base (Radix)
273 * 289 *
274 ******************************************************************************/ 290 ******************************************************************************/
275 291
276u32 292static u32
277acpi_ex_digits_needed ( 293acpi_ex_digits_needed (
278 acpi_integer value, 294 acpi_integer value,
279 u32 base) 295 u32 base)
@@ -312,6 +328,8 @@ acpi_ex_digits_needed (
312 * PARAMETERS: numeric_id - EISA ID to be converted 328 * PARAMETERS: numeric_id - EISA ID to be converted
313 * out_string - Where to put the converted string (8 bytes) 329 * out_string - Where to put the converted string (8 bytes)
314 * 330 *
331 * RETURN: None
332 *
315 * DESCRIPTION: Convert a numeric EISA ID to string representation 333 * DESCRIPTION: Convert a numeric EISA ID to string representation
316 * 334 *
317 ******************************************************************************/ 335 ******************************************************************************/
@@ -349,7 +367,10 @@ acpi_ex_eisa_id_to_string (
349 * PARAMETERS: Value - Value to be converted 367 * PARAMETERS: Value - Value to be converted
350 * out_string - Where to put the converted string (8 bytes) 368 * out_string - Where to put the converted string (8 bytes)
351 * 369 *
352 * RETURN: Convert a number to string representation 370 * RETURN: None, string
371 *
372 * DESCRIPTOIN: Convert a number to string representation. Assumes string
373 * buffer is large enough to hold the string.
353 * 374 *
354 ******************************************************************************/ 375 ******************************************************************************/
355 376
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
new file mode 100644
index 000000000000..770cfc8b17e0
--- /dev/null
+++ b/drivers/acpi/glue.c
@@ -0,0 +1,360 @@
1/*
2 * Link physical devices with ACPI devices support
3 *
4 * Copyright (c) 2005 David Shaohua Li <shaohua.li@intel.com>
5 * Copyright (c) 2005 Intel Corp.
6 *
7 * This file is released under the GPLv2.
8 */
9#include <linux/init.h>
10#include <linux/list.h>
11#include <linux/device.h>
12#include <linux/rwsem.h>
13#include <linux/acpi.h>
14
15#define ACPI_GLUE_DEBUG 0
16#if ACPI_GLUE_DEBUG
17#define DBG(x...) printk(PREFIX x)
18#else
19#define DBG(x...)
20#endif
21static LIST_HEAD(bus_type_list);
22static DECLARE_RWSEM(bus_type_sem);
23
24int register_acpi_bus_type(struct acpi_bus_type *type)
25{
26 if (acpi_disabled)
27 return -ENODEV;
28 if (type && type->bus && type->find_device) {
29 down_write(&bus_type_sem);
30 list_add_tail(&type->list, &bus_type_list);
31 up_write(&bus_type_sem);
32 printk(KERN_INFO PREFIX "bus type %s registered\n", type->bus->name);
33 return 0;
34 }
35 return -ENODEV;
36}
37
38EXPORT_SYMBOL(register_acpi_bus_type);
39
40int unregister_acpi_bus_type(struct acpi_bus_type *type)
41{
42 if (acpi_disabled)
43 return 0;
44 if (type) {
45 down_write(&bus_type_sem);
46 list_del_init(&type->list);
47 up_write(&bus_type_sem);
48 printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", type->bus->name);
49 return 0;
50 }
51 return -ENODEV;
52}
53
54EXPORT_SYMBOL(unregister_acpi_bus_type);
55
56static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
57{
58 struct acpi_bus_type *tmp, *ret = NULL;
59
60 down_read(&bus_type_sem);
61 list_for_each_entry(tmp, &bus_type_list, list) {
62 if (tmp->bus == type) {
63 ret = tmp;
64 break;
65 }
66 }
67 up_read(&bus_type_sem);
68 return ret;
69}
70
71static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
72{
73 struct acpi_bus_type *tmp;
74 int ret = -ENODEV;
75
76 down_read(&bus_type_sem);
77 list_for_each_entry(tmp, &bus_type_list, list) {
78 if (tmp->find_bridge && !tmp->find_bridge(dev, handle)) {
79 ret = 0;
80 break;
81 }
82 }
83 up_read(&bus_type_sem);
84 return ret;
85}
86
87/* Get PCI root bridge's handle from its segment and bus number */
88struct acpi_find_pci_root {
89 unsigned int seg;
90 unsigned int bus;
91 acpi_handle handle;
92};
93
94static acpi_status
95do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
96{
97 int *busnr = (int *)data;
98 struct acpi_resource_address64 address;
99
100 if (resource->id != ACPI_RSTYPE_ADDRESS16 &&
101 resource->id != ACPI_RSTYPE_ADDRESS32 &&
102 resource->id != ACPI_RSTYPE_ADDRESS64)
103 return AE_OK;
104
105 acpi_resource_to_address64(resource, &address);
106 if ((address.address_length > 0) &&
107 (address.resource_type == ACPI_BUS_NUMBER_RANGE))
108 *busnr = address.min_address_range;
109
110 return AE_OK;
111}
112
113static int get_root_bridge_busnr(acpi_handle handle)
114{
115 acpi_status status;
116 int bus, bbn;
117 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
118
119 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
120
121 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL,
122 (unsigned long *)&bbn);
123 if (status == AE_NOT_FOUND) {
124 /* Assume bus = 0 */
125 printk(KERN_INFO PREFIX
126 "Assume root bridge [%s] bus is 0\n",
127 (char *)buffer.pointer);
128 status = AE_OK;
129 bbn = 0;
130 }
131 if (ACPI_FAILURE(status)) {
132 bbn = -ENODEV;
133 goto exit;
134 }
135 if (bbn > 0)
136 goto exit;
137
138 /* _BBN in some systems return 0 for all root bridges */
139 bus = -1;
140 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
141 do_root_bridge_busnr_callback, &bus);
142 /* If _CRS failed, we just use _BBN */
143 if (ACPI_FAILURE(status) || (bus == -1))
144 goto exit;
145 /* We select _CRS */
146 if (bbn != bus) {
147 printk(KERN_INFO PREFIX
148 "_BBN and _CRS returns different value for %s. Select _CRS\n",
149 (char *)buffer.pointer);
150 bbn = bus;
151 }
152 exit:
153 acpi_os_free(buffer.pointer);
154 return bbn;
155}
156
157static acpi_status
158find_pci_rootbridge(acpi_handle handle, u32 lvl, void *context, void **rv)
159{
160 struct acpi_find_pci_root *find = (struct acpi_find_pci_root *)context;
161 unsigned long seg, bus;
162 acpi_status status;
163 int tmp;
164 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
165
166 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
167
168 status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &seg);
169 if (status == AE_NOT_FOUND) {
170 /* Assume seg = 0 */
171 printk(KERN_INFO PREFIX
172 "Assume root bridge [%s] segment is 0\n",
173 (char *)buffer.pointer);
174 status = AE_OK;
175 seg = 0;
176 }
177 if (ACPI_FAILURE(status)) {
178 status = AE_CTRL_DEPTH;
179 goto exit;
180 }
181
182 tmp = get_root_bridge_busnr(handle);
183 if (tmp < 0) {
184 printk(KERN_ERR PREFIX
185 "Find root bridge failed for %s\n",
186 (char *)buffer.pointer);
187 status = AE_CTRL_DEPTH;
188 goto exit;
189 }
190 bus = tmp;
191
192 if (seg == find->seg && bus == find->bus)
193 find->handle = handle;
194 status = AE_OK;
195 exit:
196 acpi_os_free(buffer.pointer);
197 return status;
198}
199
200acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
201{
202 struct acpi_find_pci_root find = { seg, bus, NULL };
203
204 acpi_get_devices(PCI_ROOT_HID_STRING, find_pci_rootbridge, &find, NULL);
205 return find.handle;
206}
207
208/* Get device's handler per its address under its parent */
209struct acpi_find_child {
210 acpi_handle handle;
211 acpi_integer address;
212};
213
214static acpi_status
215do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
216{
217 acpi_status status;
218 struct acpi_device_info *info;
219 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
220 struct acpi_find_child *find = (struct acpi_find_child *)context;
221
222 status = acpi_get_object_info(handle, &buffer);
223 if (ACPI_SUCCESS(status)) {
224 info = buffer.pointer;
225 if (info->address == find->address)
226 find->handle = handle;
227 acpi_os_free(buffer.pointer);
228 }
229 return AE_OK;
230}
231
232acpi_handle acpi_get_child(acpi_handle parent, acpi_integer address)
233{
234 struct acpi_find_child find = { NULL, address };
235
236 if (!parent)
237 return NULL;
238 acpi_walk_namespace(ACPI_TYPE_DEVICE, parent,
239 1, do_acpi_find_child, &find, NULL);
240 return find.handle;
241}
242
243EXPORT_SYMBOL(acpi_get_child);
244
245/* Link ACPI devices with physical devices */
246static void acpi_glue_data_handler(acpi_handle handle,
247 u32 function, void *context)
248{
249 /* we provide an empty handler */
250}
251
252/* Note: a success call will increase reference count by one */
253struct device *acpi_get_physical_device(acpi_handle handle)
254{
255 acpi_status status;
256 struct device *dev;
257
258 status = acpi_get_data(handle, acpi_glue_data_handler, (void **)&dev);
259 if (ACPI_SUCCESS(status))
260 return get_device(dev);
261 return NULL;
262}
263
264EXPORT_SYMBOL(acpi_get_physical_device);
265
266static int acpi_bind_one(struct device *dev, acpi_handle handle)
267{
268 acpi_status status;
269
270 if (dev->firmware_data) {
271 printk(KERN_WARNING PREFIX
272 "Drivers changed 'firmware_data' for %s\n", dev->bus_id);
273 return -EINVAL;
274 }
275 get_device(dev);
276 status = acpi_attach_data(handle, acpi_glue_data_handler, dev);
277 if (ACPI_FAILURE(status)) {
278 put_device(dev);
279 return -EINVAL;
280 }
281 dev->firmware_data = handle;
282
283 return 0;
284}
285
286static int acpi_unbind_one(struct device *dev)
287{
288 if (!dev->firmware_data)
289 return 0;
290 if (dev == acpi_get_physical_device(dev->firmware_data)) {
291 /* acpi_get_physical_device increase refcnt by one */
292 put_device(dev);
293 acpi_detach_data(dev->firmware_data, acpi_glue_data_handler);
294 dev->firmware_data = NULL;
295 /* acpi_bind_one increase refcnt by one */
296 put_device(dev);
297 } else {
298 printk(KERN_ERR PREFIX
299 "Oops, 'firmware_data' corrupt for %s\n", dev->bus_id);
300 }
301 return 0;
302}
303
304static int acpi_platform_notify(struct device *dev)
305{
306 struct acpi_bus_type *type;
307 acpi_handle handle;
308 int ret = -EINVAL;
309
310 if (!dev->bus || !dev->parent) {
311 /* bridge devices genernally haven't bus or parent */
312 ret = acpi_find_bridge_device(dev, &handle);
313 goto end;
314 }
315 type = acpi_get_bus_type(dev->bus);
316 if (!type) {
317 DBG("No ACPI bus support for %s\n", dev->bus_id);
318 ret = -EINVAL;
319 goto end;
320 }
321 if ((ret = type->find_device(dev, &handle)) != 0)
322 DBG("Can't get handler for %s\n", dev->bus_id);
323 end:
324 if (!ret)
325 acpi_bind_one(dev, handle);
326
327#if ACPI_GLUE_DEBUG
328 if (!ret) {
329 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
330
331 acpi_get_name(dev->firmware_data, ACPI_FULL_PATHNAME, &buffer);
332 DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer);
333 acpi_os_free(buffer.pointer);
334 } else
335 DBG("Device %s -> No ACPI support\n", dev->bus_id);
336#endif
337
338 return ret;
339}
340
341static int acpi_platform_notify_remove(struct device *dev)
342{
343 acpi_unbind_one(dev);
344 return 0;
345}
346
347static int __init init_acpi_device_notify(void)
348{
349 if (acpi_disabled)
350 return 0;
351 if (platform_notify || platform_notify_remove) {
352 printk(KERN_ERR PREFIX "Can't use platform_notify\n");
353 return 0;
354 }
355 platform_notify = acpi_platform_notify;
356 platform_notify_remove = acpi_platform_notify_remove;
357 return 0;
358}
359
360arch_initcall(init_acpi_device_notify);
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c
index 529e922bdc85..b51001e74eea 100644
--- a/drivers/acpi/hardware/hwacpi.c
+++ b/drivers/acpi/hardware/hwacpi.c
@@ -58,7 +58,8 @@
58 * 58 *
59 * RETURN: Status 59 * RETURN: Status
60 * 60 *
61 * DESCRIPTION: Initialize and validate various ACPI registers 61 * DESCRIPTION: Initialize and validate the various ACPI registers defined in
62 * the FADT.
62 * 63 *
63 ******************************************************************************/ 64 ******************************************************************************/
64 65
@@ -75,7 +76,7 @@ acpi_hw_initialize (
75 /* We must have the ACPI tables by the time we get here */ 76 /* We must have the ACPI tables by the time we get here */
76 77
77 if (!acpi_gbl_FADT) { 78 if (!acpi_gbl_FADT) {
78 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "A FADT is not loaded\n")); 79 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT is present\n"));
79 80
80 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 81 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
81 } 82 }
@@ -131,7 +132,8 @@ acpi_hw_set_mode (
131 * transitions are not supported. 132 * transitions are not supported.
132 */ 133 */
133 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) { 134 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) {
134 ACPI_REPORT_ERROR (("No ACPI mode transition supported in this system (enable/disable both zero)\n")); 135 ACPI_REPORT_ERROR ((
136 "No ACPI mode transition supported in this system (enable/disable both zero)\n"));
135 return_ACPI_STATUS (AE_OK); 137 return_ACPI_STATUS (AE_OK);
136 } 138 }
137 139
@@ -162,7 +164,8 @@ acpi_hw_set_mode (
162 } 164 }
163 165
164 if (ACPI_FAILURE (status)) { 166 if (ACPI_FAILURE (status)) {
165 ACPI_REPORT_ERROR (("Could not write mode change, %s\n", acpi_format_exception (status))); 167 ACPI_REPORT_ERROR (("Could not write mode change, %s\n",
168 acpi_format_exception (status)));
166 return_ACPI_STATUS (status); 169 return_ACPI_STATUS (status);
167 } 170 }
168 171
@@ -173,7 +176,8 @@ acpi_hw_set_mode (
173 retry = 3000; 176 retry = 3000;
174 while (retry) { 177 while (retry) {
175 if (acpi_hw_get_mode() == mode) { 178 if (acpi_hw_get_mode() == mode) {
176 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", mode)); 179 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n",
180 mode));
177 return_ACPI_STATUS (AE_OK); 181 return_ACPI_STATUS (AE_OK);
178 } 182 }
179 acpi_os_stall(1000); 183 acpi_os_stall(1000);
@@ -185,7 +189,7 @@ acpi_hw_set_mode (
185} 189}
186 190
187 191
188/****************************************************************************** 192/*******************************************************************************
189 * 193 *
190 * FUNCTION: acpi_hw_get_mode 194 * FUNCTION: acpi_hw_get_mode
191 * 195 *
@@ -199,7 +203,8 @@ acpi_hw_set_mode (
199 ******************************************************************************/ 203 ******************************************************************************/
200 204
201u32 205u32
202acpi_hw_get_mode (void) 206acpi_hw_get_mode (
207 void)
203{ 208{
204 acpi_status status; 209 acpi_status status;
205 u32 value; 210 u32 value;
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c
index 9ac1d639bf51..8daeabb2fc7a 100644
--- a/drivers/acpi/hardware/hwgpe.c
+++ b/drivers/acpi/hardware/hwgpe.c
@@ -48,6 +48,13 @@
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49 ACPI_MODULE_NAME ("hwgpe") 49 ACPI_MODULE_NAME ("hwgpe")
50 50
51/* Local prototypes */
52
53static acpi_status
54acpi_hw_enable_wakeup_gpe_block (
55 struct acpi_gpe_xrupt_info *gpe_xrupt_info,
56 struct acpi_gpe_block_info *gpe_block);
57
51 58
52/****************************************************************************** 59/******************************************************************************
53 * 60 *
@@ -135,6 +142,7 @@ acpi_hw_clear_gpe (
135 * DESCRIPTION: Return the status of a single GPE. 142 * DESCRIPTION: Return the status of a single GPE.
136 * 143 *
137 ******************************************************************************/ 144 ******************************************************************************/
145
138#ifdef ACPI_FUTURE_USAGE 146#ifdef ACPI_FUTURE_USAGE
139acpi_status 147acpi_status
140acpi_hw_get_gpe_status ( 148acpi_hw_get_gpe_status (
@@ -206,7 +214,7 @@ unlock_and_exit:
206 * 214 *
207 * RETURN: Status 215 * RETURN: Status
208 * 216 *
209 * DESCRIPTION: Disable all GPEs within a GPE block 217 * DESCRIPTION: Disable all GPEs within a single GPE block
210 * 218 *
211 ******************************************************************************/ 219 ******************************************************************************/
212 220
@@ -244,7 +252,7 @@ acpi_hw_disable_gpe_block (
244 * 252 *
245 * RETURN: Status 253 * RETURN: Status
246 * 254 *
247 * DESCRIPTION: Clear status bits for all GPEs within a GPE block 255 * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
248 * 256 *
249 ******************************************************************************/ 257 ******************************************************************************/
250 258
@@ -282,8 +290,8 @@ acpi_hw_clear_gpe_block (
282 * 290 *
283 * RETURN: Status 291 * RETURN: Status
284 * 292 *
285 * DESCRIPTION: Enable all "runtime" GPEs within a GPE block. (Includes 293 * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
286 * combination wake/run GPEs.) 294 * combination wake/run GPEs.
287 * 295 *
288 ******************************************************************************/ 296 ******************************************************************************/
289 297
@@ -327,12 +335,12 @@ acpi_hw_enable_runtime_gpe_block (
327 * 335 *
328 * RETURN: Status 336 * RETURN: Status
329 * 337 *
330 * DESCRIPTION: Enable all "wake" GPEs within a GPE block. (Includes 338 * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
331 * combination wake/run GPEs.) 339 * combination wake/run GPEs.
332 * 340 *
333 ******************************************************************************/ 341 ******************************************************************************/
334 342
335acpi_status 343static acpi_status
336acpi_hw_enable_wakeup_gpe_block ( 344acpi_hw_enable_wakeup_gpe_block (
337 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 345 struct acpi_gpe_xrupt_info *gpe_xrupt_info,
338 struct acpi_gpe_block_info *gpe_block) 346 struct acpi_gpe_block_info *gpe_block)
@@ -350,7 +358,8 @@ acpi_hw_enable_wakeup_gpe_block (
350 358
351 /* Enable all "wake" GPEs in this register */ 359 /* Enable all "wake" GPEs in this register */
352 360
353 status = acpi_hw_low_level_write (8, gpe_block->register_info[i].enable_for_wake, 361 status = acpi_hw_low_level_write (8,
362 gpe_block->register_info[i].enable_for_wake,
354 &gpe_block->register_info[i].enable_address); 363 &gpe_block->register_info[i].enable_address);
355 if (ACPI_FAILURE (status)) { 364 if (ACPI_FAILURE (status)) {
356 return (status); 365 return (status);
@@ -369,7 +378,7 @@ acpi_hw_enable_wakeup_gpe_block (
369 * 378 *
370 * RETURN: Status 379 * RETURN: Status
371 * 380 *
372 * DESCRIPTION: Disable and clear all GPEs 381 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
373 * 382 *
374 ******************************************************************************/ 383 ******************************************************************************/
375 384
@@ -397,7 +406,7 @@ acpi_hw_disable_all_gpes (
397 * 406 *
398 * RETURN: Status 407 * RETURN: Status
399 * 408 *
400 * DESCRIPTION: Enable all GPEs of the given type 409 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
401 * 410 *
402 ******************************************************************************/ 411 ******************************************************************************/
403 412
@@ -424,7 +433,7 @@ acpi_hw_enable_all_runtime_gpes (
424 * 433 *
425 * RETURN: Status 434 * RETURN: Status
426 * 435 *
427 * DESCRIPTION: Enable all GPEs of the given type 436 * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
428 * 437 *
429 ******************************************************************************/ 438 ******************************************************************************/
430 439
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index 91af0c2ddcf7..6d9e4eb84836 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -87,8 +87,9 @@ acpi_hw_clear_acpi_status (
87 } 87 }
88 } 88 }
89 89
90 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, 90 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
91 ACPI_BITMASK_ALL_FIXED_STATUS); 91 ACPI_REGISTER_PM1_STATUS,
92 ACPI_BITMASK_ALL_FIXED_STATUS);
92 if (ACPI_FAILURE (status)) { 93 if (ACPI_FAILURE (status)) {
93 goto unlock_and_exit; 94 goto unlock_and_exit;
94 } 95 }
@@ -138,28 +139,30 @@ acpi_get_sleep_type_data (
138{ 139{
139 acpi_status status = AE_OK; 140 acpi_status status = AE_OK;
140 struct acpi_parameter_info info; 141 struct acpi_parameter_info info;
142 char *sleep_state_name;
141 143
142 144
143 ACPI_FUNCTION_TRACE ("acpi_get_sleep_type_data"); 145 ACPI_FUNCTION_TRACE ("acpi_get_sleep_type_data");
144 146
145 147
146 /* 148 /* Validate parameters */
147 * Validate parameters 149
148 */
149 if ((sleep_state > ACPI_S_STATES_MAX) || 150 if ((sleep_state > ACPI_S_STATES_MAX) ||
150 !sleep_type_a || !sleep_type_b) { 151 !sleep_type_a || !sleep_type_b) {
151 return_ACPI_STATUS (AE_BAD_PARAMETER); 152 return_ACPI_STATUS (AE_BAD_PARAMETER);
152 } 153 }
153 154
154 /* 155 /* Evaluate the namespace object containing the values for this state */
155 * Evaluate the namespace object containing the values for this state 156
156 */
157 info.parameters = NULL; 157 info.parameters = NULL;
158 status = acpi_ns_evaluate_by_name ((char *) acpi_gbl_sleep_state_names[sleep_state], 158 info.return_object = NULL;
159 &info); 159 sleep_state_name = (char *) acpi_gbl_sleep_state_names[sleep_state];
160
161 status = acpi_ns_evaluate_by_name (sleep_state_name, &info);
160 if (ACPI_FAILURE (status)) { 162 if (ACPI_FAILURE (status)) {
161 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating sleep_state [%s]\n", 163 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
162 acpi_format_exception (status), acpi_gbl_sleep_state_names[sleep_state])); 164 "%s while evaluating sleep_state [%s]\n",
165 acpi_format_exception (status), sleep_state_name));
163 166
164 return_ACPI_STATUS (status); 167 return_ACPI_STATUS (status);
165 } 168 }
@@ -167,45 +170,57 @@ acpi_get_sleep_type_data (
167 /* Must have a return object */ 170 /* Must have a return object */
168 171
169 if (!info.return_object) { 172 if (!info.return_object) {
170 ACPI_REPORT_ERROR (("Missing Sleep State object\n")); 173 ACPI_REPORT_ERROR (("No Sleep State object returned from [%s]\n",
174 sleep_state_name));
171 status = AE_NOT_EXIST; 175 status = AE_NOT_EXIST;
172 } 176 }
173 177
174 /* It must be of type Package */ 178 /* It must be of type Package */
175 179
176 else if (ACPI_GET_OBJECT_TYPE (info.return_object) != ACPI_TYPE_PACKAGE) { 180 else if (ACPI_GET_OBJECT_TYPE (info.return_object) != ACPI_TYPE_PACKAGE) {
177 ACPI_REPORT_ERROR (("Sleep State object not a Package\n")); 181 ACPI_REPORT_ERROR (("Sleep State return object is not a Package\n"));
178 status = AE_AML_OPERAND_TYPE; 182 status = AE_AML_OPERAND_TYPE;
179 } 183 }
180 184
181 /* The package must have at least two elements */ 185 /*
182 186 * The package must have at least two elements. NOTE (March 2005): This
187 * goes against the current ACPI spec which defines this object as a
188 * package with one encoded DWORD element. However, existing practice
189 * by BIOS vendors seems to be to have 2 or more elements, at least
190 * one per sleep type (A/B).
191 */
183 else if (info.return_object->package.count < 2) { 192 else if (info.return_object->package.count < 2) {
184 ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n")); 193 ACPI_REPORT_ERROR ((
194 "Sleep State return package does not have at least two elements\n"));
185 status = AE_AML_NO_OPERAND; 195 status = AE_AML_NO_OPERAND;
186 } 196 }
187 197
188 /* The first two elements must both be of type Integer */ 198 /* The first two elements must both be of type Integer */
189 199
190 else if ((ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[0]) != ACPI_TYPE_INTEGER) || 200 else if ((ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[0])
191 (ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[1]) != ACPI_TYPE_INTEGER)) { 201 != ACPI_TYPE_INTEGER) ||
192 ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n", 202 (ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[1])
203 != ACPI_TYPE_INTEGER)) {
204 ACPI_REPORT_ERROR ((
205 "Sleep State return package elements are not both Integers (%s, %s)\n",
193 acpi_ut_get_object_type_name (info.return_object->package.elements[0]), 206 acpi_ut_get_object_type_name (info.return_object->package.elements[0]),
194 acpi_ut_get_object_type_name (info.return_object->package.elements[1]))); 207 acpi_ut_get_object_type_name (info.return_object->package.elements[1])));
195 status = AE_AML_OPERAND_TYPE; 208 status = AE_AML_OPERAND_TYPE;
196 } 209 }
197 else { 210 else {
198 /* 211 /* Valid _Sx_ package size, type, and value */
199 * Valid _Sx_ package size, type, and value 212
200 */ 213 *sleep_type_a = (u8)
201 *sleep_type_a = (u8) (info.return_object->package.elements[0])->integer.value; 214 (info.return_object->package.elements[0])->integer.value;
202 *sleep_type_b = (u8) (info.return_object->package.elements[1])->integer.value; 215 *sleep_type_b = (u8)
216 (info.return_object->package.elements[1])->integer.value;
203 } 217 }
204 218
205 if (ACPI_FAILURE (status)) { 219 if (ACPI_FAILURE (status)) {
206 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 220 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
207 "While evaluating sleep_state [%s], bad Sleep object %p type %s\n", 221 "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n",
208 acpi_gbl_sleep_state_names[sleep_state], info.return_object, 222 acpi_format_exception (status),
223 sleep_state_name, info.return_object,
209 acpi_ut_get_object_type_name (info.return_object))); 224 acpi_ut_get_object_type_name (info.return_object)));
210 } 225 }
211 226
@@ -221,9 +236,9 @@ EXPORT_SYMBOL(acpi_get_sleep_type_data);
221 * 236 *
222 * PARAMETERS: register_id - Index of ACPI Register to access 237 * PARAMETERS: register_id - Index of ACPI Register to access
223 * 238 *
224 * RETURN: The bit mask to be used when accessing the register 239 * RETURN: The bitmask to be used when accessing the register
225 * 240 *
226 * DESCRIPTION: Map register_id into a register bit mask. 241 * DESCRIPTION: Map register_id into a register bitmask.
227 * 242 *
228 ******************************************************************************/ 243 ******************************************************************************/
229 244
@@ -359,7 +374,7 @@ acpi_set_register (
359 /* Always do a register read first so we can insert the new bits */ 374 /* Always do a register read first so we can insert the new bits */
360 375
361 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 376 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
362 bit_reg_info->parent_register, &register_value); 377 bit_reg_info->parent_register, &register_value);
363 if (ACPI_FAILURE (status)) { 378 if (ACPI_FAILURE (status)) {
364 goto unlock_and_exit; 379 goto unlock_and_exit;
365 } 380 }
@@ -396,7 +411,7 @@ acpi_set_register (
396 bit_reg_info->access_bit_mask, value); 411 bit_reg_info->access_bit_mask, value);
397 412
398 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 413 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
399 ACPI_REGISTER_PM1_ENABLE, (u16) register_value); 414 ACPI_REGISTER_PM1_ENABLE, (u16) register_value);
400 break; 415 break;
401 416
402 417
@@ -413,7 +428,7 @@ acpi_set_register (
413 bit_reg_info->access_bit_mask, value); 428 bit_reg_info->access_bit_mask, value);
414 429
415 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 430 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
416 ACPI_REGISTER_PM1_CONTROL, (u16) register_value); 431 ACPI_REGISTER_PM1_CONTROL, (u16) register_value);
417 break; 432 break;
418 433
419 434
@@ -427,17 +442,19 @@ acpi_set_register (
427 442
428 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n", 443 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n",
429 register_value, 444 register_value,
430 ACPI_FORMAT_UINT64 (acpi_gbl_FADT->xpm2_cnt_blk.address))); 445 ACPI_FORMAT_UINT64 (
446 acpi_gbl_FADT->xpm2_cnt_blk.address)));
431 447
432 ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, 448 ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position,
433 bit_reg_info->access_bit_mask, value); 449 bit_reg_info->access_bit_mask, value);
434 450
435 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", 451 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n",
436 register_value, 452 register_value,
437 ACPI_FORMAT_UINT64 (acpi_gbl_FADT->xpm2_cnt_blk.address))); 453 ACPI_FORMAT_UINT64 (
454 acpi_gbl_FADT->xpm2_cnt_blk.address)));
438 455
439 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 456 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
440 ACPI_REGISTER_PM2_CONTROL, (u8) (register_value)); 457 ACPI_REGISTER_PM2_CONTROL, (u8) (register_value));
441 break; 458 break;
442 459
443 460
@@ -454,7 +471,9 @@ unlock_and_exit:
454 471
455 /* Normalize the value that was read */ 472 /* Normalize the value that was read */
456 473
457 ACPI_DEBUG_EXEC (register_value = ((register_value & bit_reg_info->access_bit_mask) >> bit_reg_info->bit_position)); 474 ACPI_DEBUG_EXEC (register_value =
475 ((register_value & bit_reg_info->access_bit_mask) >>
476 bit_reg_info->bit_position));
458 477
459 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", 478 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n",
460 value, register_value, bit_reg_info->parent_register)); 479 value, register_value, bit_reg_info->parent_register));
@@ -469,7 +488,7 @@ EXPORT_SYMBOL(acpi_set_register);
469 * 488 *
470 * PARAMETERS: use_lock - Mutex hw access 489 * PARAMETERS: use_lock - Mutex hw access
471 * register_id - register_iD + Offset 490 * register_id - register_iD + Offset
472 * return_value - Value that was read from the register 491 * return_value - Where the register value is returned
473 * 492 *
474 * RETURN: Status and the value read. 493 * RETURN: Status and the value read.
475 * 494 *
@@ -557,7 +576,8 @@ acpi_hw_register_read (
557 break; 576 break;
558 577
559 default: 578 default:
560 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", register_id)); 579 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n",
580 register_id));
561 status = AE_BAD_PARAMETER; 581 status = AE_BAD_PARAMETER;
562 break; 582 break;
563 } 583 }
@@ -763,10 +783,11 @@ acpi_hw_low_level_read (
763 return (AE_BAD_PARAMETER); 783 return (AE_BAD_PARAMETER);
764 } 784 }
765 785
766 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", 786 ACPI_DEBUG_PRINT ((ACPI_DB_IO,
767 *value, width, 787 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
768 ACPI_FORMAT_UINT64 (address), 788 *value, width,
769 acpi_ut_get_region_name (reg->address_space_id))); 789 ACPI_FORMAT_UINT64 (address),
790 acpi_ut_get_region_name (reg->address_space_id)));
770 791
771 return (status); 792 return (status);
772} 793}
@@ -841,10 +862,11 @@ acpi_hw_low_level_write (
841 return (AE_BAD_PARAMETER); 862 return (AE_BAD_PARAMETER);
842 } 863 }
843 864
844 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", 865 ACPI_DEBUG_PRINT ((ACPI_DB_IO,
845 value, width, 866 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
846 ACPI_FORMAT_UINT64 (address), 867 value, width,
847 acpi_ut_get_region_name (reg->address_space_id))); 868 ACPI_FORMAT_UINT64 (address),
869 acpi_ut_get_region_name (reg->address_space_id)));
848 870
849 return (status); 871 return (status);
850} 872}
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 77b3e9a8550b..415d342aeab5 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -43,27 +43,13 @@
43 */ 43 */
44 44
45#include <linux/module.h> 45#include <linux/module.h>
46
47#include <acpi/acpi.h> 46#include <acpi/acpi.h>
48 47
49#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
50 ACPI_MODULE_NAME ("hwsleep") 49 ACPI_MODULE_NAME ("hwsleep")
51 50
52 51
53#define METHOD_NAME__BFS "\\_BFS" 52/*******************************************************************************
54#define METHOD_NAME__GTS "\\_GTS"
55#define METHOD_NAME__PTS "\\_PTS"
56#define METHOD_NAME__SST "\\_SI._SST"
57#define METHOD_NAME__WAK "\\_WAK"
58
59#define ACPI_SST_INDICATOR_OFF 0
60#define ACPI_SST_WORKING 1
61#define ACPI_SST_WAKING 2
62#define ACPI_SST_SLEEPING 3
63#define ACPI_SST_SLEEP_CONTEXT 4
64
65
66/******************************************************************************
67 * 53 *
68 * FUNCTION: acpi_set_firmware_waking_vector 54 * FUNCTION: acpi_set_firmware_waking_vector
69 * 55 *
@@ -72,7 +58,7 @@
72 * 58 *
73 * RETURN: Status 59 * RETURN: Status
74 * 60 *
75 * DESCRIPTION: access function for d_firmware_waking_vector field in FACS 61 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
76 * 62 *
77 ******************************************************************************/ 63 ******************************************************************************/
78 64
@@ -99,19 +85,20 @@ acpi_set_firmware_waking_vector (
99} 85}
100 86
101 87
102/****************************************************************************** 88/*******************************************************************************
103 * 89 *
104 * FUNCTION: acpi_get_firmware_waking_vector 90 * FUNCTION: acpi_get_firmware_waking_vector
105 * 91 *
106 * PARAMETERS: *physical_address - Output buffer where contents of 92 * PARAMETERS: *physical_address - Where the contents of
107 * the firmware_waking_vector field of 93 * the firmware_waking_vector field of
108 * the FACS will be stored. 94 * the FACS will be returned.
109 * 95 *
110 * RETURN: Status 96 * RETURN: Status, vector
111 * 97 *
112 * DESCRIPTION: Access function for firmware_waking_vector field in FACS 98 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
113 * 99 *
114 ******************************************************************************/ 100 ******************************************************************************/
101
115#ifdef ACPI_FUTURE_USAGE 102#ifdef ACPI_FUTURE_USAGE
116acpi_status 103acpi_status
117acpi_get_firmware_waking_vector ( 104acpi_get_firmware_waking_vector (
@@ -141,7 +128,7 @@ acpi_get_firmware_waking_vector (
141#endif 128#endif
142 129
143 130
144/****************************************************************************** 131/*******************************************************************************
145 * 132 *
146 * FUNCTION: acpi_enter_sleep_state_prep 133 * FUNCTION: acpi_enter_sleep_state_prep
147 * 134 *
@@ -215,7 +202,7 @@ acpi_enter_sleep_state_prep (
215 break; 202 break;
216 203
217 default: 204 default:
218 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is indicator off */ 205 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */
219 break; 206 break;
220 } 207 }
221 208
@@ -223,14 +210,15 @@ acpi_enter_sleep_state_prep (
223 210
224 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 211 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL);
225 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 212 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
226 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", acpi_format_exception (status))); 213 ACPI_REPORT_ERROR (("Method _SST failed, %s\n",
214 acpi_format_exception (status)));
227 } 215 }
228 216
229 return_ACPI_STATUS (AE_OK); 217 return_ACPI_STATUS (AE_OK);
230} 218}
231 219
232 220
233/****************************************************************************** 221/*******************************************************************************
234 * 222 *
235 * FUNCTION: acpi_enter_sleep_state 223 * FUNCTION: acpi_enter_sleep_state
236 * 224 *
@@ -299,15 +287,18 @@ acpi_enter_sleep_state (
299 287
300 /* Get current value of PM1A control */ 288 /* Get current value of PM1A control */
301 289
302 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); 290 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
291 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
303 if (ACPI_FAILURE (status)) { 292 if (ACPI_FAILURE (status)) {
304 return_ACPI_STATUS (status); 293 return_ACPI_STATUS (status);
305 } 294 }
306 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%d]\n", sleep_state)); 295 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
296 "Entering sleep state [S%d]\n", sleep_state));
307 297
308 /* Clear SLP_EN and SLP_TYP fields */ 298 /* Clear SLP_EN and SLP_TYP fields */
309 299
310 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | sleep_enable_reg_info->access_bit_mask); 300 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
301 sleep_enable_reg_info->access_bit_mask);
311 PM1Bcontrol = PM1Acontrol; 302 PM1Bcontrol = PM1Acontrol;
312 303
313 /* Insert SLP_TYP bits */ 304 /* Insert SLP_TYP bits */
@@ -322,12 +313,14 @@ acpi_enter_sleep_state (
322 313
323 /* Write #1: fill in SLP_TYP data */ 314 /* Write #1: fill in SLP_TYP data */
324 315
325 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 316 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
317 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
326 if (ACPI_FAILURE (status)) { 318 if (ACPI_FAILURE (status)) {
327 return_ACPI_STATUS (status); 319 return_ACPI_STATUS (status);
328 } 320 }
329 321
330 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 322 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
323 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
331 if (ACPI_FAILURE (status)) { 324 if (ACPI_FAILURE (status)) {
332 return_ACPI_STATUS (status); 325 return_ACPI_STATUS (status);
333 } 326 }
@@ -341,22 +334,25 @@ acpi_enter_sleep_state (
341 334
342 ACPI_FLUSH_CPU_CACHE (); 335 ACPI_FLUSH_CPU_CACHE ();
343 336
344 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 337 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
338 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
345 if (ACPI_FAILURE (status)) { 339 if (ACPI_FAILURE (status)) {
346 return_ACPI_STATUS (status); 340 return_ACPI_STATUS (status);
347 } 341 }
348 342
349 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 343 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
344 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
350 if (ACPI_FAILURE (status)) { 345 if (ACPI_FAILURE (status)) {
351 return_ACPI_STATUS (status); 346 return_ACPI_STATUS (status);
352 } 347 }
353 348
354 if (sleep_state > ACPI_STATE_S3) { 349 if (sleep_state > ACPI_STATE_S3) {
355 /* 350 /*
356 * We wanted to sleep > S3, but it didn't happen (by virtue of the fact that 351 * We wanted to sleep > S3, but it didn't happen (by virtue of the
357 * we are still executing!) 352 * fact that we are still executing!)
358 * 353 *
359 * Wait ten seconds, then try again. This is to get S4/S5 to work on all machines. 354 * Wait ten seconds, then try again. This is to get S4/S5 to work on
355 * all machines.
360 * 356 *
361 * We wait so long to allow chipsets that poll this reg very slowly to 357 * We wait so long to allow chipsets that poll this reg very slowly to
362 * still read the right value. Ideally, this block would go 358 * still read the right value. Ideally, this block would go
@@ -364,7 +360,8 @@ acpi_enter_sleep_state (
364 */ 360 */
365 acpi_os_stall (10000000); 361 acpi_os_stall (10000000);
366 362
367 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, 363 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
364 ACPI_REGISTER_PM1_CONTROL,
368 sleep_enable_reg_info->access_bit_mask); 365 sleep_enable_reg_info->access_bit_mask);
369 if (ACPI_FAILURE (status)) { 366 if (ACPI_FAILURE (status)) {
370 return_ACPI_STATUS (status); 367 return_ACPI_STATUS (status);
@@ -374,7 +371,8 @@ acpi_enter_sleep_state (
374 /* Wait until we enter sleep state */ 371 /* Wait until we enter sleep state */
375 372
376 do { 373 do {
377 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, ACPI_MTX_DO_NOT_LOCK); 374 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value,
375 ACPI_MTX_DO_NOT_LOCK);
378 if (ACPI_FAILURE (status)) { 376 if (ACPI_FAILURE (status)) {
379 return_ACPI_STATUS (status); 377 return_ACPI_STATUS (status);
380 } 378 }
@@ -388,7 +386,7 @@ acpi_enter_sleep_state (
388EXPORT_SYMBOL(acpi_enter_sleep_state); 386EXPORT_SYMBOL(acpi_enter_sleep_state);
389 387
390 388
391/****************************************************************************** 389/*******************************************************************************
392 * 390 *
393 * FUNCTION: acpi_enter_sleep_state_s4bios 391 * FUNCTION: acpi_enter_sleep_state_s4bios
394 * 392 *
@@ -439,11 +437,13 @@ acpi_enter_sleep_state_s4bios (
439 437
440 ACPI_FLUSH_CPU_CACHE (); 438 ACPI_FLUSH_CPU_CACHE ();
441 439
442 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, (u32) acpi_gbl_FADT->S4bios_req, 8); 440 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd,
441 (u32) acpi_gbl_FADT->S4bios_req, 8);
443 442
444 do { 443 do {
445 acpi_os_stall(1000); 444 acpi_os_stall(1000);
446 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, ACPI_MTX_DO_NOT_LOCK); 445 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value,
446 ACPI_MTX_DO_NOT_LOCK);
447 if (ACPI_FAILURE (status)) { 447 if (ACPI_FAILURE (status)) {
448 return_ACPI_STATUS (status); 448 return_ACPI_STATUS (status);
449 } 449 }
@@ -454,7 +454,7 @@ acpi_enter_sleep_state_s4bios (
454EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios); 454EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
455 455
456 456
457/****************************************************************************** 457/*******************************************************************************
458 * 458 *
459 * FUNCTION: acpi_leave_sleep_state 459 * FUNCTION: acpi_leave_sleep_state
460 * 460 *
@@ -534,18 +534,21 @@ acpi_leave_sleep_state (
534 arg.integer.value = ACPI_SST_WAKING; 534 arg.integer.value = ACPI_SST_WAKING;
535 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 535 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL);
536 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 536 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
537 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", acpi_format_exception (status))); 537 ACPI_REPORT_ERROR (("Method _SST failed, %s\n",
538 acpi_format_exception (status)));
538 } 539 }
539 540
540 arg.integer.value = sleep_state; 541 arg.integer.value = sleep_state;
541 status = acpi_evaluate_object (NULL, METHOD_NAME__BFS, &arg_list, NULL); 542 status = acpi_evaluate_object (NULL, METHOD_NAME__BFS, &arg_list, NULL);
542 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 543 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
543 ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", acpi_format_exception (status))); 544 ACPI_REPORT_ERROR (("Method _BFS failed, %s\n",
545 acpi_format_exception (status)));
544 } 546 }
545 547
546 status = acpi_evaluate_object (NULL, METHOD_NAME__WAK, &arg_list, NULL); 548 status = acpi_evaluate_object (NULL, METHOD_NAME__WAK, &arg_list, NULL);
547 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 549 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
548 ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", acpi_format_exception (status))); 550 ACPI_REPORT_ERROR (("Method _WAK failed, %s\n",
551 acpi_format_exception (status)));
549 } 552 }
550 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ 553 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
551 554
@@ -567,15 +570,19 @@ acpi_leave_sleep_state (
567 570
568 /* Enable power button */ 571 /* Enable power button */
569 572
570 (void) acpi_set_register(acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].enable_register_id, 573 (void) acpi_set_register(
574 acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].enable_register_id,
571 1, ACPI_MTX_DO_NOT_LOCK); 575 1, ACPI_MTX_DO_NOT_LOCK);
572 (void) acpi_set_register(acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].status_register_id, 576
577 (void) acpi_set_register(
578 acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].status_register_id,
573 1, ACPI_MTX_DO_NOT_LOCK); 579 1, ACPI_MTX_DO_NOT_LOCK);
574 580
575 arg.integer.value = ACPI_SST_WORKING; 581 arg.integer.value = ACPI_SST_WORKING;
576 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 582 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL);
577 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 583 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
578 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", acpi_format_exception (status))); 584 ACPI_REPORT_ERROR (("Method _SST failed, %s\n",
585 acpi_format_exception (status)));
579 } 586 }
580 587
581 return_ACPI_STATUS (status); 588 return_ACPI_STATUS (status);
diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c
index 1906167d7294..49d7b395322e 100644
--- a/drivers/acpi/hardware/hwtimer.c
+++ b/drivers/acpi/hardware/hwtimer.c
@@ -43,7 +43,6 @@
43 */ 43 */
44 44
45#include <linux/module.h> 45#include <linux/module.h>
46
47#include <acpi/acpi.h> 46#include <acpi/acpi.h>
48 47
49#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
@@ -90,7 +89,7 @@ acpi_get_timer_resolution (
90 * 89 *
91 * PARAMETERS: Ticks - Where the timer value is returned 90 * PARAMETERS: Ticks - Where the timer value is returned
92 * 91 *
93 * RETURN: Status and current ticks 92 * RETURN: Status and current timer value (ticks)
94 * 93 *
95 * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks). 94 * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks).
96 * 95 *
@@ -199,5 +198,6 @@ acpi_get_timer_duration (
199 *time_elapsed = (u32) quotient; 198 *time_elapsed = (u32) quotient;
200 return_ACPI_STATUS (status); 199 return_ACPI_STATUS (status);
201} 200}
201
202EXPORT_SYMBOL(acpi_get_timer_duration); 202EXPORT_SYMBOL(acpi_get_timer_duration);
203 203
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c
new file mode 100644
index 000000000000..babdf762eadb
--- /dev/null
+++ b/drivers/acpi/hotkey.c
@@ -0,0 +1,1019 @@
1/*
2 * hotkey.c - ACPI Hotkey Driver ($Revision:$)
3 *
4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/types.h>
28#include <linux/proc_fs.h>
29#include <linux/sched.h>
30#include <linux/kmod.h>
31#include <linux/seq_file.h>
32#include <acpi/acpi_drivers.h>
33#include <acpi/acpi_bus.h>
34#include <asm/uaccess.h>
35
36#define HOTKEY_ACPI_VERSION "0.1"
37
38#define HOTKEY_PROC "hotkey"
39#define HOTKEY_EV_CONFIG "event_config"
40#define HOTKEY_PL_CONFIG "poll_config"
41#define HOTKEY_ACTION "action"
42#define HOTKEY_INFO "info"
43
44#define ACPI_HOTK_NAME "Generic Hotkey Driver"
45#define ACPI_HOTK_CLASS "Hotkey"
46#define ACPI_HOTK_DEVICE_NAME "Hotkey"
47#define ACPI_HOTK_HID "Unknown?"
48#define ACPI_HOTKEY_COMPONENT 0x20000000
49
50#define ACPI_HOTKEY_EVENT 0x1
51#define ACPI_HOTKEY_POLLING 0x2
52#define ACPI_UNDEFINED_EVENT 0xf
53
54#define MAX_CONFIG_RECORD_LEN 80
55#define MAX_NAME_PATH_LEN 80
56#define MAX_CALL_PARM 80
57
58#define IS_EVENT(e) 0xff /* ((e) & 0x40000000) */
59#define IS_POLL(e) 0xff /* (~((e) & 0x40000000)) */
60
61#define _COMPONENT ACPI_HOTKEY_COMPONENT
62ACPI_MODULE_NAME("acpi_hotkey")
63
64 MODULE_AUTHOR("luming.yu@intel.com");
65MODULE_DESCRIPTION(ACPI_HOTK_NAME);
66MODULE_LICENSE("GPL");
67
68/* standardized internal hotkey number/event */
69enum {
70 /* Video Extension event */
71 HK_EVENT_CYCLE_OUTPUT_DEVICE = 0x80,
72 HK_EVENT_OUTPUT_DEVICE_STATUS_CHANGE,
73 HK_EVENT_CYCLE_DISPLAY_OUTPUT,
74 HK_EVENT_NEXT_DISPLAY_OUTPUT,
75 HK_EVENT_PREVIOUS_DISPLAY_OUTPUT,
76 HK_EVENT_CYCLE_BRIGHTNESS,
77 HK_EVENT_INCREASE_BRIGHTNESS,
78 HK_EVENT_DECREASE_BRIGHTNESS,
79 HK_EVENT_ZERO_BRIGHTNESS,
80 HK_EVENT_DISPLAY_DEVICE_OFF,
81
82 /* Snd Card event */
83 HK_EVENT_VOLUME_MUTE,
84 HK_EVENT_VOLUME_INCLREASE,
85 HK_EVENT_VOLUME_DECREASE,
86
87 /* running state control */
88 HK_EVENT_ENTERRING_S3,
89 HK_EVENT_ENTERRING_S4,
90 HK_EVENT_ENTERRING_S5,
91};
92
93/* procdir we use */
94static struct proc_dir_entry *hotkey_proc_dir;
95static struct proc_dir_entry *hotkey_config;
96static struct proc_dir_entry *hotkey_poll_config;
97static struct proc_dir_entry *hotkey_action;
98static struct proc_dir_entry *hotkey_info;
99
100/* linkage for all type of hotkey */
101struct acpi_hotkey_link {
102 struct list_head entries;
103 int hotkey_type; /* event or polling based hotkey */
104 int hotkey_standard_num; /* standardized hotkey(event) number */
105};
106
107/* event based hotkey */
108struct acpi_event_hotkey {
109 struct acpi_hotkey_link hotkey_link;
110 int flag;
111 acpi_handle bus_handle; /* bus to install notify handler */
112 int external_hotkey_num; /* external hotkey/event number */
113 acpi_handle action_handle; /* acpi handle attached aml action method */
114 char *action_method; /* action method */
115};
116
117/*
118 * There are two ways to poll status
119 * 1. directy call read_xxx method, without any arguments passed in
120 * 2. call write_xxx method, with arguments passed in, you need
121 * the result is saved in acpi_polling_hotkey.poll_result.
122 * anthoer read command through polling interface.
123 *
124 */
125
126/* polling based hotkey */
127struct acpi_polling_hotkey {
128 struct acpi_hotkey_link hotkey_link;
129 int flag;
130 acpi_handle poll_handle; /* acpi handle attached polling method */
131 char *poll_method; /* poll method */
132 acpi_handle action_handle; /* acpi handle attached action method */
133 char *action_method; /* action method */
134 void *poll_result; /* polling_result */
135 struct proc_dir_entry *proc;
136};
137
138/* hotkey object union */
139union acpi_hotkey {
140 struct list_head entries;
141 struct acpi_hotkey_link link;
142 struct acpi_event_hotkey event_hotkey;
143 struct acpi_polling_hotkey poll_hotkey;
144};
145
146/* hotkey object list */
147struct acpi_hotkey_list {
148 struct list_head *entries;
149 int count;
150};
151
152static int auto_hotkey_add(struct acpi_device *device);
153static int auto_hotkey_remove(struct acpi_device *device, int type);
154
155static struct acpi_driver hotkey_driver = {
156 .name = ACPI_HOTK_NAME,
157 .class = ACPI_HOTK_CLASS,
158 .ids = ACPI_HOTK_HID,
159 .ops = {
160 .add = auto_hotkey_add,
161 .remove = auto_hotkey_remove,
162 },
163};
164
165static int hotkey_open_config(struct inode *inode, struct file *file);
166static ssize_t hotkey_write_config(struct file *file,
167 const char __user * buffer,
168 size_t count, loff_t * data);
169static ssize_t hotkey_write_poll_config(struct file *file,
170 const char __user * buffer,
171 size_t count, loff_t * data);
172static int hotkey_info_open_fs(struct inode *inode, struct file *file);
173static int hotkey_action_open_fs(struct inode *inode, struct file *file);
174static ssize_t hotkey_execute_aml_method(struct file *file,
175 const char __user * buffer,
176 size_t count, loff_t * data);
177static int hotkey_config_seq_show(struct seq_file *seq, void *offset);
178static int hotkey_polling_open_fs(struct inode *inode, struct file *file);
179
180/* event based config */
181static struct file_operations hotkey_config_fops = {
182 .open = hotkey_open_config,
183 .read = seq_read,
184 .write = hotkey_write_config,
185 .llseek = seq_lseek,
186 .release = single_release,
187};
188
189/* polling based config */
190static struct file_operations hotkey_poll_config_fops = {
191 .open = hotkey_open_config,
192 .read = seq_read,
193 .write = hotkey_write_poll_config,
194 .llseek = seq_lseek,
195 .release = single_release,
196};
197
198/* hotkey driver info */
199static struct file_operations hotkey_info_fops = {
200 .open = hotkey_info_open_fs,
201 .read = seq_read,
202 .llseek = seq_lseek,
203 .release = single_release,
204};
205
206/* action */
207static struct file_operations hotkey_action_fops = {
208 .open = hotkey_action_open_fs,
209 .read = seq_read,
210 .write = hotkey_execute_aml_method,
211 .llseek = seq_lseek,
212 .release = single_release,
213};
214
215/* polling results */
216static struct file_operations hotkey_polling_fops = {
217 .open = hotkey_polling_open_fs,
218 .read = seq_read,
219 .llseek = seq_lseek,
220 .release = single_release,
221};
222
223struct acpi_hotkey_list global_hotkey_list; /* link all ev or pl hotkey */
224struct list_head hotkey_entries; /* head of the list of hotkey_list */
225
226static int hotkey_info_seq_show(struct seq_file *seq, void *offset)
227{
228 ACPI_FUNCTION_TRACE("hotkey_info_seq_show");
229
230 seq_printf(seq, "Hotkey generic driver ver: %s", HOTKEY_ACPI_VERSION);
231
232 return_VALUE(0);
233}
234
235static int hotkey_info_open_fs(struct inode *inode, struct file *file)
236{
237 return single_open(file, hotkey_info_seq_show, PDE(inode)->data);
238}
239
240static char *format_result(union acpi_object *object)
241{
242 char *buf = (char *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
243
244 memset(buf, 0, sizeof(union acpi_object));
245
246 /* Now, just support integer type */
247 if (object->type == ACPI_TYPE_INTEGER)
248 sprintf(buf, "%d", (u32) object->integer.value);
249
250 return buf;
251}
252
253static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
254{
255 struct acpi_polling_hotkey *poll_hotkey =
256 (struct acpi_polling_hotkey *)seq->private;
257
258 ACPI_FUNCTION_TRACE("hotkey_polling_seq_show");
259
260 if (poll_hotkey->poll_result)
261 seq_printf(seq, "%s", format_result(poll_hotkey->poll_result));
262
263 return_VALUE(0);
264}
265
266static int hotkey_polling_open_fs(struct inode *inode, struct file *file)
267{
268 return single_open(file, hotkey_polling_seq_show, PDE(inode)->data);
269}
270
271static int hotkey_action_open_fs(struct inode *inode, struct file *file)
272{
273 return single_open(file, hotkey_info_seq_show, PDE(inode)->data);
274}
275
276/* Mapping external hotkey number to standardized hotkey event num */
277static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
278{
279 struct list_head *entries, *next;
280 int val = 0;
281
282 ACPI_FUNCTION_TRACE("hotkey_get_internal_event");
283
284 list_for_each_safe(entries, next, list->entries) {
285 union acpi_hotkey *key =
286 container_of(entries, union acpi_hotkey, entries);
287 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT
288 && key->event_hotkey.external_hotkey_num == event)
289 val = key->link.hotkey_standard_num;
290 else
291 val = -1;
292 }
293
294 return_VALUE(val);
295}
296
297static void
298acpi_hotkey_notify_handler(acpi_handle handle, u32 event, void *data)
299{
300 struct acpi_device *device = NULL;
301 u32 internal_event;
302
303 ACPI_FUNCTION_TRACE("acpi_hotkey_notify_handler");
304
305 if (acpi_bus_get_device(handle, &device))
306 return_VOID;
307
308 internal_event = hotkey_get_internal_event(event, &global_hotkey_list);
309 acpi_bus_generate_event(device, event, 0);
310
311 return_VOID;
312}
313
314/* Need to invent automatically hotkey add method */
315static int auto_hotkey_add(struct acpi_device *device)
316{
317 /* Implement me */
318 return 0;
319}
320
321/* Need to invent automatically hotkey remove method */
322static int auto_hotkey_remove(struct acpi_device *device, int type)
323{
324 /* Implement me */
325 return 0;
326}
327
328/* Create a proc file for each polling method */
329static int create_polling_proc(union acpi_hotkey *device)
330{
331 struct proc_dir_entry *proc;
332 mode_t mode;
333
334 ACPI_FUNCTION_TRACE("create_polling_proc");
335 mode = S_IFREG | S_IRUGO | S_IWUGO;
336
337 proc = create_proc_entry(device->poll_hotkey.action_method,
338 mode, hotkey_proc_dir);
339
340 if (!proc) {
341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
342 "Hotkey: Unable to create %s entry\n",
343 device->poll_hotkey.poll_method));
344 return_VALUE(-ENODEV);
345 } else {
346 proc->proc_fops = &hotkey_polling_fops;
347 proc->owner = THIS_MODULE;
348 proc->data = device;
349 proc->uid = 0;
350 proc->gid = 0;
351 device->poll_hotkey.proc = proc;
352 }
353 return_VALUE(0);
354}
355
356static int is_valid_acpi_path(const char *pathname)
357{
358 acpi_handle handle;
359 acpi_status status;
360 ACPI_FUNCTION_TRACE("is_valid_acpi_path");
361
362 status = acpi_get_handle(NULL, (char *)pathname, &handle);
363 return_VALUE(!ACPI_FAILURE(status));
364}
365
366static int is_valid_hotkey(union acpi_hotkey *device)
367{
368 ACPI_FUNCTION_TRACE("is_valid_hotkey");
369 /* Implement valid check */
370 return_VALUE(1);
371}
372
373static int hotkey_add(union acpi_hotkey *device)
374{
375 int status = 0;
376 struct acpi_device *dev = NULL;
377
378 ACPI_FUNCTION_TRACE("hotkey_add");
379
380 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) {
381 status =
382 acpi_bus_get_device(device->event_hotkey.bus_handle, &dev);
383 if (status)
384 return_VALUE(status);
385
386 status = acpi_install_notify_handler(dev->handle,
387 ACPI_SYSTEM_NOTIFY,
388 acpi_hotkey_notify_handler,
389 device);
390 } else /* Add polling hotkey */
391 create_polling_proc(device);
392
393 global_hotkey_list.count++;
394
395 list_add_tail(&device->link.entries, global_hotkey_list.entries);
396
397 return_VALUE(status);
398}
399
400static int hotkey_remove(union acpi_hotkey *device)
401{
402 struct list_head *entries, *next;
403
404 ACPI_FUNCTION_TRACE("hotkey_remove");
405
406 list_for_each_safe(entries, next, global_hotkey_list.entries) {
407 union acpi_hotkey *key =
408 container_of(entries, union acpi_hotkey, entries);
409 if (key->link.hotkey_standard_num ==
410 device->link.hotkey_standard_num) {
411 list_del(&key->link.entries);
412 remove_proc_entry(key->poll_hotkey.action_method,
413 hotkey_proc_dir);
414 global_hotkey_list.count--;
415 break;
416 }
417 }
418 return_VALUE(0);
419}
420
421static void hotkey_update(union acpi_hotkey *key)
422{
423 struct list_head *entries, *next;
424
425 ACPI_FUNCTION_TRACE("hotkey_update");
426
427 list_for_each_safe(entries, next, global_hotkey_list.entries) {
428 union acpi_hotkey *key =
429 container_of(entries, union acpi_hotkey, entries);
430 if (key->link.hotkey_standard_num ==
431 key->link.hotkey_standard_num) {
432 key->event_hotkey.bus_handle =
433 key->event_hotkey.bus_handle;
434 key->event_hotkey.external_hotkey_num =
435 key->event_hotkey.external_hotkey_num;
436 key->event_hotkey.action_handle =
437 key->event_hotkey.action_handle;
438 key->event_hotkey.action_method =
439 key->event_hotkey.action_method;
440 break;
441 }
442 }
443
444 return_VOID;
445}
446
447static void free_hotkey_device(union acpi_hotkey *key)
448{
449 struct acpi_device *dev;
450 int status;
451
452 ACPI_FUNCTION_TRACE("free_hotkey_device");
453
454 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
455 status =
456 acpi_bus_get_device(key->event_hotkey.bus_handle, &dev);
457 if (dev->handle)
458 acpi_remove_notify_handler(dev->handle,
459 ACPI_SYSTEM_NOTIFY,
460 acpi_hotkey_notify_handler);
461 } else
462 remove_proc_entry(key->poll_hotkey.action_method,
463 hotkey_proc_dir);
464 kfree(key);
465 return_VOID;
466}
467
468static int
469init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
470 char *method, int std_num, int external_num)
471{
472 ACPI_FUNCTION_TRACE("init_hotkey_device");
473
474 key->link.hotkey_type = ACPI_HOTKEY_EVENT;
475 key->link.hotkey_standard_num = std_num;
476 key->event_hotkey.flag = 0;
477 if (is_valid_acpi_path(bus_str))
478 acpi_get_handle((acpi_handle) 0,
479 bus_str, &(key->event_hotkey.bus_handle));
480 else
481 return_VALUE(-ENODEV);
482 key->event_hotkey.external_hotkey_num = external_num;
483 if (is_valid_acpi_path(action_str))
484 acpi_get_handle((acpi_handle) 0,
485 action_str, &(key->event_hotkey.action_handle));
486 key->event_hotkey.action_method = kmalloc(sizeof(method), GFP_KERNEL);
487 strcpy(key->event_hotkey.action_method, method);
488
489 return_VALUE(!is_valid_hotkey(key));
490}
491
492static int
493init_poll_hotkey_device(union acpi_hotkey *key,
494 char *poll_str,
495 char *poll_method,
496 char *action_str, char *action_method, int std_num)
497{
498 ACPI_FUNCTION_TRACE("init_poll_hotkey_device");
499
500 key->link.hotkey_type = ACPI_HOTKEY_POLLING;
501 key->link.hotkey_standard_num = std_num;
502 key->poll_hotkey.flag = 0;
503 if (is_valid_acpi_path(poll_str))
504 acpi_get_handle((acpi_handle) 0,
505 poll_str, &(key->poll_hotkey.poll_handle));
506 else
507 return_VALUE(-ENODEV);
508 key->poll_hotkey.poll_method = poll_method;
509 if (is_valid_acpi_path(action_str))
510 acpi_get_handle((acpi_handle) 0,
511 action_str, &(key->poll_hotkey.action_handle));
512 key->poll_hotkey.action_method =
513 kmalloc(sizeof(action_method), GFP_KERNEL);
514 strcpy(key->poll_hotkey.action_method, action_method);
515 key->poll_hotkey.poll_result =
516 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
517 return_VALUE(is_valid_hotkey(key));
518}
519
520static int check_hotkey_valid(union acpi_hotkey *key,
521 struct acpi_hotkey_list *list)
522{
523 ACPI_FUNCTION_TRACE("check_hotkey_valid");
524 return_VALUE(0);
525}
526
527static int hotkey_open_config(struct inode *inode, struct file *file)
528{
529 ACPI_FUNCTION_TRACE("hotkey_open_config");
530 return_VALUE(single_open
531 (file, hotkey_config_seq_show, PDE(inode)->data));
532}
533
534static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
535{
536 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
537 struct list_head *entries, *next;
538 char bus_name[ACPI_PATHNAME_MAX] = { 0 };
539 char action_name[ACPI_PATHNAME_MAX] = { 0 };
540 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
541 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
542
543 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
544
545 if (!hotkey_list)
546 goto end;
547
548 list_for_each_safe(entries, next, hotkey_list->entries) {
549 union acpi_hotkey *key =
550 container_of(entries, union acpi_hotkey, entries);
551 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
552 acpi_get_name(key->event_hotkey.bus_handle,
553 ACPI_NAME_TYPE_MAX, &bus);
554 acpi_get_name(key->event_hotkey.action_handle,
555 ACPI_NAME_TYPE_MAX, &act);
556 seq_printf(seq, "%s:%s:%s:%d:%d", bus_name,
557 action_name,
558 key->event_hotkey.action_method,
559 key->link.hotkey_standard_num,
560 key->event_hotkey.external_hotkey_num);
561 } /* ACPI_HOTKEY_POLLING */
562 else {
563 acpi_get_name(key->poll_hotkey.poll_handle,
564 ACPI_NAME_TYPE_MAX, &bus);
565 acpi_get_name(key->poll_hotkey.action_handle,
566 ACPI_NAME_TYPE_MAX, &act);
567 seq_printf(seq, "%s:%s:%s:%s:%d", bus_name,
568 key->poll_hotkey.poll_method,
569 action_name,
570 key->poll_hotkey.action_method,
571 key->link.hotkey_standard_num);
572 }
573 }
574 seq_puts(seq, "\n");
575 end:
576 return_VALUE(0);
577}
578
579static int
580get_parms(char *config_record,
581 int *cmd,
582 char *bus_handle,
583 char *bus_method,
584 char *action_handle,
585 char *method, int *internal_event_num, int *external_event_num)
586{
587 char *tmp, *tmp1;
588 ACPI_FUNCTION_TRACE(("get_parms"));
589
590 sscanf(config_record, "%d", cmd);
591
592 tmp = strchr(config_record, ':');
593 tmp++;
594 tmp1 = strchr(tmp, ':');
595 strncpy(bus_handle, tmp, tmp1 - tmp);
596 bus_handle[tmp1 - tmp] = 0;
597
598 tmp = tmp1;
599 tmp++;
600 tmp1 = strchr(tmp, ':');
601 strncpy(bus_method, tmp, tmp1 - tmp);
602 bus_method[tmp1 - tmp] = 0;
603
604 tmp = tmp1;
605 tmp++;
606 tmp1 = strchr(tmp, ':');
607 strncpy(action_handle, tmp, tmp1 - tmp);
608 action_handle[tmp1 - tmp] = 0;
609
610 tmp = tmp1;
611 tmp++;
612 tmp1 = strchr(tmp, ':');
613 strncpy(method, tmp, tmp1 - tmp);
614 method[tmp1 - tmp] = 0;
615
616 sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num);
617 return_VALUE(6);
618}
619
620/* count is length for one input record */
621static ssize_t hotkey_write_config(struct file *file,
622 const char __user * buffer,
623 size_t count, loff_t * data)
624{
625 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
626 char config_record[MAX_CONFIG_RECORD_LEN];
627 char bus_handle[MAX_NAME_PATH_LEN];
628 char bus_method[MAX_NAME_PATH_LEN];
629 char action_handle[MAX_NAME_PATH_LEN];
630 char method[20];
631 int cmd, internal_event_num, external_event_num;
632 int ret = 0;
633 union acpi_hotkey *key = NULL;
634
635 ACPI_FUNCTION_TRACE(("hotkey_write_config"));
636
637 if (!hotkey_list || count > MAX_CONFIG_RECORD_LEN) {
638 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid arguments\n"));
639 return_VALUE(-EINVAL);
640 }
641
642 if (copy_from_user(config_record, buffer, count)) {
643 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n"));
644 return_VALUE(-EINVAL);
645 }
646 config_record[count] = '\0';
647
648 ret = get_parms(config_record,
649 &cmd,
650 bus_handle,
651 bus_method,
652 action_handle,
653 method, &internal_event_num, &external_event_num);
654 if (ret != 6) {
655 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
656 "Invalid data format ret=%d\n", ret));
657 return_VALUE(-EINVAL);
658 }
659
660 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
661 ret = init_hotkey_device(key, bus_handle, action_handle, method,
662 internal_event_num, external_event_num);
663
664 if (ret || check_hotkey_valid(key, hotkey_list)) {
665 kfree(key);
666 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n"));
667 return_VALUE(-EINVAL);
668 }
669 switch (cmd) {
670 case 0:
671 hotkey_add(key);
672 break;
673 case 1:
674 hotkey_remove(key);
675 free_hotkey_device(key);
676 break;
677 case 2:
678 hotkey_update(key);
679 break;
680 default:
681 break;
682 }
683 return_VALUE(count);
684}
685
686/* count is length for one input record */
687static ssize_t hotkey_write_poll_config(struct file *file,
688 const char __user * buffer,
689 size_t count, loff_t * data)
690{
691 struct seq_file *m = (struct seq_file *)file->private_data;
692 struct acpi_hotkey_list *hotkey_list =
693 (struct acpi_hotkey_list *)m->private;
694
695 char config_record[MAX_CONFIG_RECORD_LEN];
696 char polling_handle[MAX_NAME_PATH_LEN];
697 char action_handle[MAX_NAME_PATH_LEN];
698 char poll_method[20], action_method[20];
699 int ret, internal_event_num, cmd, external_event_num;
700 union acpi_hotkey *key = NULL;
701
702 ACPI_FUNCTION_TRACE("hotkey_write_poll_config");
703
704 if (!hotkey_list || count > MAX_CONFIG_RECORD_LEN) {
705 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid arguments\n"));
706 return_VALUE(-EINVAL);
707 }
708
709 if (copy_from_user(config_record, buffer, count)) {
710 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n"));
711 return_VALUE(-EINVAL);
712 }
713 config_record[count] = '\0';
714
715 ret = get_parms(config_record,
716 &cmd,
717 polling_handle,
718 poll_method,
719 action_handle,
720 action_method,
721 &internal_event_num, &external_event_num);
722
723 if (ret != 6) {
724 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
725 return_VALUE(-EINVAL);
726 }
727
728 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
729 ret = init_poll_hotkey_device(key, polling_handle, poll_method,
730 action_handle, action_method,
731 internal_event_num);
732 if (ret || check_hotkey_valid(key, hotkey_list)) {
733 kfree(key);
734 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n"));
735 return_VALUE(-EINVAL);
736 }
737 switch (cmd) {
738 case 0:
739 hotkey_add(key);
740 break;
741 case 1:
742 hotkey_remove(key);
743 break;
744 case 2:
745 hotkey_update(key);
746 break;
747 default:
748 break;
749 }
750 return_VALUE(count);
751}
752
753/*
754 * This function evaluates an ACPI method, given an int as parameter, the
755 * method is searched within the scope of the handle, can be NULL. The output
756 * of the method is written is output, which can also be NULL
757 *
758 * returns 1 if write is successful, 0 else.
759 */
760static int write_acpi_int(acpi_handle handle, const char *method, int val,
761 struct acpi_buffer *output)
762{
763 struct acpi_object_list params; /* list of input parameters (an int here) */
764 union acpi_object in_obj; /* the only param we use */
765 acpi_status status;
766
767 ACPI_FUNCTION_TRACE("write_acpi_int");
768 params.count = 1;
769 params.pointer = &in_obj;
770 in_obj.type = ACPI_TYPE_INTEGER;
771 in_obj.integer.value = val;
772
773 status = acpi_evaluate_object(handle, (char *)method, &params, output);
774
775 return_VALUE(status == AE_OK);
776}
777
778static int read_acpi_int(acpi_handle handle, const char *method, int *val)
779{
780 struct acpi_buffer output;
781 union acpi_object out_obj;
782 acpi_status status;
783
784 ACPI_FUNCTION_TRACE("read_acpi_int");
785 output.length = sizeof(out_obj);
786 output.pointer = &out_obj;
787
788 status = acpi_evaluate_object(handle, (char *)method, NULL, &output);
789 *val = out_obj.integer.value;
790 return_VALUE((status == AE_OK)
791 && (out_obj.type == ACPI_TYPE_INTEGER));
792}
793
794static acpi_handle
795get_handle_from_hotkeylist(struct acpi_hotkey_list *hotkey_list, int event_num)
796{
797 struct list_head *entries, *next;
798
799 list_for_each_safe(entries, next, hotkey_list->entries) {
800 union acpi_hotkey *key =
801 container_of(entries, union acpi_hotkey, entries);
802 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT
803 && key->link.hotkey_standard_num == event_num) {
804 return (key->event_hotkey.action_handle);
805 }
806 }
807 return (NULL);
808}
809
810static
811char *get_method_from_hotkeylist(struct acpi_hotkey_list *hotkey_list,
812 int event_num)
813{
814 struct list_head *entries, *next;
815
816 list_for_each_safe(entries, next, hotkey_list->entries) {
817 union acpi_hotkey *key =
818 container_of(entries, union acpi_hotkey, entries);
819
820 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT &&
821 key->link.hotkey_standard_num == event_num)
822 return (key->event_hotkey.action_method);
823 }
824 return (NULL);
825}
826
827static struct acpi_polling_hotkey *get_hotkey_by_event(struct
828 acpi_hotkey_list
829 *hotkey_list, int event)
830{
831 struct list_head *entries, *next;
832
833 list_for_each_safe(entries, next, hotkey_list->entries) {
834 union acpi_hotkey *key =
835 container_of(entries, union acpi_hotkey, entries);
836 if (key->link.hotkey_type == ACPI_HOTKEY_POLLING
837 && key->link.hotkey_standard_num == event) {
838 return (&key->poll_hotkey);
839 }
840 }
841 return (NULL);
842}
843
844/*
845 * user call AML method interface:
846 * Call convention:
847 * echo "event_num: arg type : value"
848 * example: echo "1:1:30" > /proc/acpi/action
849 * Just support 1 integer arg passing to AML method
850 */
851
852static ssize_t hotkey_execute_aml_method(struct file *file,
853 const char __user * buffer,
854 size_t count, loff_t * data)
855{
856 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
857 char arg[MAX_CALL_PARM];
858 int event, type, value;
859
860 char *method;
861 acpi_handle handle;
862
863 ACPI_FUNCTION_TRACE("hotkey_execte_aml_method");
864
865 if (!hotkey_list || count > MAX_CALL_PARM) {
866 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 1"));
867 return_VALUE(-EINVAL);
868 }
869
870 if (copy_from_user(arg, buffer, count)) {
871 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2"));
872 return_VALUE(-EINVAL);
873 }
874
875 arg[count] = '\0';
876
877 if (sscanf(arg, "%d:%d:%d", &event, &type, &value) != 3) {
878 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3"));
879 return_VALUE(-EINVAL);
880 }
881
882 if (type == ACPI_TYPE_INTEGER) {
883 handle = get_handle_from_hotkeylist(hotkey_list, event);
884 method = (char *)get_method_from_hotkeylist(hotkey_list, event);
885 if (IS_EVENT(event))
886 write_acpi_int(handle, method, value, NULL);
887 else if (IS_POLL(event)) {
888 struct acpi_polling_hotkey *key;
889 key = (struct acpi_polling_hotkey *)
890 get_hotkey_by_event(hotkey_list, event);
891 read_acpi_int(handle, method, key->poll_result);
892 }
893 } else {
894 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported"));
895 return_VALUE(-EINVAL);
896 }
897
898 return_VALUE(count);
899}
900
901static int __init hotkey_init(void)
902{
903 int result;
904 mode_t mode = S_IFREG | S_IRUGO | S_IWUGO;
905
906 ACPI_FUNCTION_TRACE("hotkey_init");
907
908 if (acpi_disabled)
909 return -ENODEV;
910
911 if (acpi_specific_hotkey_enabled) {
912 printk("Using specific hotkey driver\n");
913 return -ENODEV;
914 }
915
916 hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir);
917 if (!hotkey_proc_dir) {
918 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
919 "Hotkey: Unable to create %s entry\n",
920 HOTKEY_PROC));
921 return (-ENODEV);
922 }
923 hotkey_proc_dir->owner = THIS_MODULE;
924
925 hotkey_config =
926 create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir);
927 if (!hotkey_config) {
928 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
929 "Hotkey: Unable to create %s entry\n",
930 HOTKEY_EV_CONFIG));
931 return (-ENODEV);
932 } else {
933 hotkey_config->proc_fops = &hotkey_config_fops;
934 hotkey_config->data = &global_hotkey_list;
935 hotkey_config->owner = THIS_MODULE;
936 hotkey_config->uid = 0;
937 hotkey_config->gid = 0;
938 }
939
940 hotkey_poll_config =
941 create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir);
942 if (!hotkey_poll_config) {
943 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
944 "Hotkey: Unable to create %s entry\n",
945 HOTKEY_EV_CONFIG));
946 return (-ENODEV);
947 } else {
948 hotkey_poll_config->proc_fops = &hotkey_poll_config_fops;
949 hotkey_poll_config->data = &global_hotkey_list;
950 hotkey_poll_config->owner = THIS_MODULE;
951 hotkey_poll_config->uid = 0;
952 hotkey_poll_config->gid = 0;
953 }
954
955 hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir);
956 if (!hotkey_action) {
957 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
958 "Hotkey: Unable to create %s entry\n",
959 HOTKEY_ACTION));
960 return (-ENODEV);
961 } else {
962 hotkey_action->proc_fops = &hotkey_action_fops;
963 hotkey_action->owner = THIS_MODULE;
964 hotkey_action->uid = 0;
965 hotkey_action->gid = 0;
966 }
967
968 hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir);
969 if (!hotkey_info) {
970 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
971 "Hotkey: Unable to create %s entry\n",
972 HOTKEY_INFO));
973 return (-ENODEV);
974 } else {
975 hotkey_info->proc_fops = &hotkey_info_fops;
976 hotkey_info->owner = THIS_MODULE;
977 hotkey_info->uid = 0;
978 hotkey_info->gid = 0;
979 }
980
981 result = acpi_bus_register_driver(&hotkey_driver);
982 if (result < 0) {
983 remove_proc_entry(HOTKEY_PROC, acpi_root_dir);
984 return (-ENODEV);
985 }
986 global_hotkey_list.count = 0;
987 global_hotkey_list.entries = &hotkey_entries;
988
989 INIT_LIST_HEAD(&hotkey_entries);
990
991 return (0);
992}
993
994static void __exit hotkey_exit(void)
995{
996 struct list_head *entries, *next;
997
998 ACPI_FUNCTION_TRACE("hotkey_remove");
999
1000 list_for_each_safe(entries, next, global_hotkey_list.entries) {
1001 union acpi_hotkey *key =
1002 container_of(entries, union acpi_hotkey, entries);
1003
1004 acpi_os_wait_events_complete(NULL);
1005 list_del(&key->link.entries);
1006 global_hotkey_list.count--;
1007 free_hotkey_device(key);
1008 }
1009 acpi_bus_unregister_driver(&hotkey_driver);
1010 remove_proc_entry(HOTKEY_EV_CONFIG, hotkey_proc_dir);
1011 remove_proc_entry(HOTKEY_PL_CONFIG, hotkey_proc_dir);
1012 remove_proc_entry(HOTKEY_ACTION, hotkey_proc_dir);
1013 remove_proc_entry(HOTKEY_INFO, hotkey_proc_dir);
1014 remove_proc_entry(HOTKEY_PROC, acpi_root_dir);
1015 return;
1016}
1017
1018module_init(hotkey_init);
1019module_exit(hotkey_exit);
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index 0fb731a470dc..ad85e10001f4 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -1025,7 +1025,7 @@ static int setup_notify(struct ibm_struct *ibm)
1025 return 0; 1025 return 0;
1026} 1026}
1027 1027
1028static int device_add(struct acpi_device *device) 1028static int ibmacpi_device_add(struct acpi_device *device)
1029{ 1029{
1030 return 0; 1030 return 0;
1031} 1031}
@@ -1043,7 +1043,7 @@ static int register_driver(struct ibm_struct *ibm)
1043 memset(ibm->driver, 0, sizeof(struct acpi_driver)); 1043 memset(ibm->driver, 0, sizeof(struct acpi_driver));
1044 sprintf(ibm->driver->name, "%s/%s", IBM_NAME, ibm->name); 1044 sprintf(ibm->driver->name, "%s/%s", IBM_NAME, ibm->name);
1045 ibm->driver->ids = ibm->hid; 1045 ibm->driver->ids = ibm->hid;
1046 ibm->driver->ops.add = &device_add; 1046 ibm->driver->ops.add = &ibmacpi_device_add;
1047 1047
1048 ret = acpi_bus_register_driver(ibm->driver); 1048 ret = acpi_bus_register_driver(ibm->driver);
1049 if (ret < 0) { 1049 if (ret < 0) {
@@ -1185,6 +1185,10 @@ static int __init acpi_ibm_init(void)
1185 if (acpi_disabled) 1185 if (acpi_disabled)
1186 return -ENODEV; 1186 return -ENODEV;
1187 1187
1188 if (!acpi_specific_hotkey_enabled){
1189 printk(IBM_ERR "Using generic hotkey driver\n");
1190 return -ENODEV;
1191 }
1188 /* these handles are required */ 1192 /* these handles are required */
1189 if (IBM_HANDLE_INIT(ec, 1) < 0 || 1193 if (IBM_HANDLE_INIT(ec, 1) < 0 ||
1190 IBM_HANDLE_INIT(hkey, 1) < 0 || 1194 IBM_HANDLE_INIT(hkey, 1) < 0 ||
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index 1c0c12336c57..ece7a9dedd5c 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -67,7 +67,8 @@
67 ******************************************************************************/ 67 ******************************************************************************/
68 68
69acpi_status 69acpi_status
70acpi_ns_root_initialize (void) 70acpi_ns_root_initialize (
71 void)
71{ 72{
72 acpi_status status; 73 acpi_status status;
73 const struct acpi_predefined_names *init_val = NULL; 74 const struct acpi_predefined_names *init_val = NULL;
@@ -265,7 +266,7 @@ unlock_and_exit:
265 * 266 *
266 * FUNCTION: acpi_ns_lookup 267 * FUNCTION: acpi_ns_lookup
267 * 268 *
268 * PARAMETERS: prefix_node - Search scope if name is not fully qualified 269 * PARAMETERS: scope_info - Current scope info block
269 * Pathname - Search pathname, in internal format 270 * Pathname - Search pathname, in internal format
270 * (as represented in the AML stream) 271 * (as represented in the AML stream)
271 * Type - Type associated with name 272 * Type - Type associated with name
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index bfd922c5c7d1..5653a19d7172 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -49,14 +49,20 @@
49#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME ("nsalloc") 50 ACPI_MODULE_NAME ("nsalloc")
51 51
52/* Local prototypes */
53
54static void
55acpi_ns_remove_reference (
56 struct acpi_namespace_node *node);
57
52 58
53/******************************************************************************* 59/*******************************************************************************
54 * 60 *
55 * FUNCTION: acpi_ns_create_node 61 * FUNCTION: acpi_ns_create_node
56 * 62 *
57 * PARAMETERS: acpi_name - Name of the new node 63 * PARAMETERS: Name - Name of the new node (4 char ACPI name)
58 * 64 *
59 * RETURN: None 65 * RETURN: New namespace node (Null on failure)
60 * 66 *
61 * DESCRIPTION: Create a namespace node 67 * DESCRIPTION: Create a namespace node
62 * 68 *
@@ -145,7 +151,6 @@ acpi_ns_delete_node (
145 } 151 }
146 } 152 }
147 153
148
149 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); 154 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++);
150 155
151 /* 156 /*
@@ -157,57 +162,6 @@ acpi_ns_delete_node (
157} 162}
158 163
159 164
160#ifdef ACPI_ALPHABETIC_NAMESPACE
161/*******************************************************************************
162 *
163 * FUNCTION: acpi_ns_compare_names
164 *
165 * PARAMETERS: Name1 - First name to compare
166 * Name2 - Second name to compare
167 *
168 * RETURN: value from strncmp
169 *
170 * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an
171 * underscore are forced to be alphabetically first.
172 *
173 ******************************************************************************/
174
175int
176acpi_ns_compare_names (
177 char *name1,
178 char *name2)
179{
180 char reversed_name1[ACPI_NAME_SIZE];
181 char reversed_name2[ACPI_NAME_SIZE];
182 u32 i;
183 u32 j;
184
185
186 /*
187 * Replace all instances of "underscore" with a value that is smaller so
188 * that all names that are prefixed with underscore(s) are alphabetically
189 * first.
190 *
191 * Reverse the name bytewise so we can just do a 32-bit compare instead
192 * of a strncmp.
193 */
194 for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) {
195 reversed_name1[j] = name1[i];
196 if (name1[i] == '_') {
197 reversed_name1[j] = '*';
198 }
199
200 reversed_name2[j] = name2[i];
201 if (name2[i] == '_') {
202 reversed_name2[j] = '*';
203 }
204 }
205
206 return (*(int *) reversed_name1 - *(int *) reversed_name2);
207}
208#endif
209
210
211/******************************************************************************* 165/*******************************************************************************
212 * 166 *
213 * FUNCTION: acpi_ns_install_node 167 * FUNCTION: acpi_ns_install_node
@@ -271,7 +225,8 @@ acpi_ns_install_node (
271 * alphabetic placement. 225 * alphabetic placement.
272 */ 226 */
273 previous_child_node = NULL; 227 previous_child_node = NULL;
274 while (acpi_ns_compare_names (acpi_ut_get_node_name (child_node), acpi_ut_get_node_name (node)) < 0) { 228 while (acpi_ns_compare_names (acpi_ut_get_node_name (child_node),
229 acpi_ut_get_node_name (node)) < 0) {
275 if (child_node->flags & ANOBJ_END_OF_PEER_LIST) { 230 if (child_node->flags & ANOBJ_END_OF_PEER_LIST) {
276 /* Last peer; Clear end-of-list flag */ 231 /* Last peer; Clear end-of-list flag */
277 232
@@ -429,7 +384,8 @@ acpi_ns_delete_children (
429 /* There should be only one reference remaining on this node */ 384 /* There should be only one reference remaining on this node */
430 385
431 if (child_node->reference_count != 1) { 386 if (child_node->reference_count != 1) {
432 ACPI_REPORT_WARNING (("Existing references (%d) on node being deleted (%p)\n", 387 ACPI_REPORT_WARNING ((
388 "Existing references (%d) on node being deleted (%p)\n",
433 child_node->reference_count, child_node)); 389 child_node->reference_count, child_node));
434 } 390 }
435 391
@@ -548,7 +504,7 @@ acpi_ns_delete_namespace_subtree (
548 * 504 *
549 ******************************************************************************/ 505 ******************************************************************************/
550 506
551void 507static void
552acpi_ns_remove_reference ( 508acpi_ns_remove_reference (
553 struct acpi_namespace_node *node) 509 struct acpi_namespace_node *node)
554{ 510{
@@ -683,3 +639,54 @@ acpi_ns_delete_namespace_by_owner (
683} 639}
684 640
685 641
642#ifdef ACPI_ALPHABETIC_NAMESPACE
643/*******************************************************************************
644 *
645 * FUNCTION: acpi_ns_compare_names
646 *
647 * PARAMETERS: Name1 - First name to compare
648 * Name2 - Second name to compare
649 *
650 * RETURN: value from strncmp
651 *
652 * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an
653 * underscore are forced to be alphabetically first.
654 *
655 ******************************************************************************/
656
657int
658acpi_ns_compare_names (
659 char *name1,
660 char *name2)
661{
662 char reversed_name1[ACPI_NAME_SIZE];
663 char reversed_name2[ACPI_NAME_SIZE];
664 u32 i;
665 u32 j;
666
667
668 /*
669 * Replace all instances of "underscore" with a value that is smaller so
670 * that all names that are prefixed with underscore(s) are alphabetically
671 * first.
672 *
673 * Reverse the name bytewise so we can just do a 32-bit compare instead
674 * of a strncmp.
675 */
676 for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) {
677 reversed_name1[j] = name1[i];
678 if (name1[i] == '_') {
679 reversed_name1[j] = '*';
680 }
681
682 reversed_name2[j] = name2[i];
683 if (name2[i] == '_') {
684 reversed_name2[j] = '*';
685 }
686 }
687
688 return (*(int *) reversed_name1 - *(int *) reversed_name2);
689}
690#endif
691
692
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index 1f6af3eb6c91..6c2aef0e0dd4 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/namespace/nsdump.c
@@ -50,16 +50,32 @@
50#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsdump") 51 ACPI_MODULE_NAME ("nsdump")
52 52
53/* Local prototypes */
53 54
54#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 55#ifdef ACPI_OBSOLETE_FUNCTIONS
56void
57acpi_ns_dump_root_devices (
58 void);
55 59
60static acpi_status
61acpi_ns_dump_one_device (
62 acpi_handle obj_handle,
63 u32 level,
64 void *context,
65 void **return_value);
66#endif
67
68
69#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
56/******************************************************************************* 70/*******************************************************************************
57 * 71 *
58 * FUNCTION: acpi_ns_print_pathname 72 * FUNCTION: acpi_ns_print_pathname
59 * 73 *
60 * PARAMETERS: num_segment - Number of ACPI name segments 74 * PARAMETERS: num_segments - Number of ACPI name segments
61 * Pathname - The compressed (internal) path 75 * Pathname - The compressed (internal) path
62 * 76 *
77 * RETURN: None
78 *
63 * DESCRIPTION: Print an object's full namespace pathname 79 * DESCRIPTION: Print an object's full namespace pathname
64 * 80 *
65 ******************************************************************************/ 81 ******************************************************************************/
@@ -103,6 +119,8 @@ acpi_ns_print_pathname (
103 * Level - Desired debug level 119 * Level - Desired debug level
104 * Component - Caller's component ID 120 * Component - Caller's component ID
105 * 121 *
122 * RETURN: None
123 *
106 * DESCRIPTION: Print an object's full namespace pathname 124 * DESCRIPTION: Print an object's full namespace pathname
107 * Manages allocation/freeing of a pathname buffer 125 * Manages allocation/freeing of a pathname buffer
108 * 126 *
@@ -137,9 +155,12 @@ acpi_ns_dump_pathname (
137 * 155 *
138 * FUNCTION: acpi_ns_dump_one_object 156 * FUNCTION: acpi_ns_dump_one_object
139 * 157 *
140 * PARAMETERS: Handle - Node to be dumped 158 * PARAMETERS: obj_handle - Node to be dumped
141 * Level - Nesting level of the handle 159 * Level - Nesting level of the handle
142 * Context - Passed into walk_namespace 160 * Context - Passed into walk_namespace
161 * return_value - Not used
162 *
163 * RETURN: Status
143 * 164 *
144 * DESCRIPTION: Dump a single Node 165 * DESCRIPTION: Dump a single Node
145 * This procedure is a user_function called by acpi_ns_walk_namespace. 166 * This procedure is a user_function called by acpi_ns_walk_namespace.
@@ -394,8 +415,7 @@ acpi_ns_dump_one_object (
394 return (AE_OK); 415 return (AE_OK);
395 } 416 }
396 417
397 acpi_os_printf ("(R%d)", 418 acpi_os_printf ("(R%d)", obj_desc->common.reference_count);
398 obj_desc->common.reference_count);
399 419
400 switch (type) { 420 switch (type) {
401 case ACPI_TYPE_METHOD: 421 case ACPI_TYPE_METHOD:
@@ -551,18 +571,20 @@ cleanup:
551 571
552 572
553#ifdef ACPI_FUTURE_USAGE 573#ifdef ACPI_FUTURE_USAGE
554
555/******************************************************************************* 574/*******************************************************************************
556 * 575 *
557 * FUNCTION: acpi_ns_dump_objects 576 * FUNCTION: acpi_ns_dump_objects
558 * 577 *
559 * PARAMETERS: Type - Object type to be dumped 578 * PARAMETERS: Type - Object type to be dumped
579 * display_type - 0 or ACPI_DISPLAY_SUMMARY
560 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX 580 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
561 * for an effectively unlimited depth. 581 * for an effectively unlimited depth.
562 * owner_id - Dump only objects owned by this ID. Use 582 * owner_id - Dump only objects owned by this ID. Use
563 * ACPI_UINT32_MAX to match all owners. 583 * ACPI_UINT32_MAX to match all owners.
564 * start_handle - Where in namespace to start/end search 584 * start_handle - Where in namespace to start/end search
565 * 585 *
586 * RETURN: None
587 *
566 * DESCRIPTION: Dump typed objects within the loaded namespace. 588 * DESCRIPTION: Dump typed objects within the loaded namespace.
567 * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object. 589 * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
568 * 590 *
@@ -590,10 +612,44 @@ acpi_ns_dump_objects (
590 ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object, 612 ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object,
591 (void *) &info, NULL); 613 (void *) &info, NULL);
592} 614}
615#endif /* ACPI_FUTURE_USAGE */
593 616
594 617
595/******************************************************************************* 618/*******************************************************************************
596 * 619 *
620 * FUNCTION: acpi_ns_dump_entry
621 *
622 * PARAMETERS: Handle - Node to be dumped
623 * debug_level - Output level
624 *
625 * RETURN: None
626 *
627 * DESCRIPTION: Dump a single Node
628 *
629 ******************************************************************************/
630
631void
632acpi_ns_dump_entry (
633 acpi_handle handle,
634 u32 debug_level)
635{
636 struct acpi_walk_info info;
637
638
639 ACPI_FUNCTION_ENTRY ();
640
641
642 info.debug_level = debug_level;
643 info.owner_id = ACPI_UINT32_MAX;
644 info.display_type = ACPI_DISPLAY_SUMMARY;
645
646 (void) acpi_ns_dump_one_object (handle, 1, &info, NULL);
647}
648
649
650#ifdef _ACPI_ASL_COMPILER
651/*******************************************************************************
652 *
597 * FUNCTION: acpi_ns_dump_tables 653 * FUNCTION: acpi_ns_dump_tables
598 * 654 *
599 * PARAMETERS: search_base - Root of subtree to be dumped, or 655 * PARAMETERS: search_base - Root of subtree to be dumped, or
@@ -601,6 +657,8 @@ acpi_ns_dump_objects (
601 * max_depth - Maximum depth of dump. Use INT_MAX 657 * max_depth - Maximum depth of dump. Use INT_MAX
602 * for an effectively unlimited depth. 658 * for an effectively unlimited depth.
603 * 659 *
660 * RETURN: None
661 *
604 * DESCRIPTION: Dump the name space, or a portion of it. 662 * DESCRIPTION: Dump the name space, or a portion of it.
605 * 663 *
606 ******************************************************************************/ 664 ******************************************************************************/
@@ -626,7 +684,7 @@ acpi_ns_dump_tables (
626 } 684 }
627 685
628 if (ACPI_NS_ALL == search_base) { 686 if (ACPI_NS_ALL == search_base) {
629 /* entire namespace */ 687 /* Entire namespace */
630 688
631 search_handle = acpi_gbl_root_node; 689 search_handle = acpi_gbl_root_node;
632 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); 690 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
@@ -636,38 +694,5 @@ acpi_ns_dump_tables (
636 ACPI_UINT32_MAX, search_handle); 694 ACPI_UINT32_MAX, search_handle);
637 return_VOID; 695 return_VOID;
638} 696}
639 697#endif /* _ACPI_ASL_COMPILER */
640#endif /* ACPI_FUTURE_USAGE */ 698#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */
641
642
643/*******************************************************************************
644 *
645 * FUNCTION: acpi_ns_dump_entry
646 *
647 * PARAMETERS: Handle - Node to be dumped
648 * debug_level - Output level
649 *
650 * DESCRIPTION: Dump a single Node
651 *
652 ******************************************************************************/
653
654void
655acpi_ns_dump_entry (
656 acpi_handle handle,
657 u32 debug_level)
658{
659 struct acpi_walk_info info;
660
661
662 ACPI_FUNCTION_ENTRY ();
663
664
665 info.debug_level = debug_level;
666 info.owner_id = ACPI_UINT32_MAX;
667 info.display_type = ACPI_DISPLAY_SUMMARY;
668
669 (void) acpi_ns_dump_one_object (handle, 1, &info, NULL);
670}
671
672#endif
673
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c
index d30a59e6b07d..27c4f7cd2a43 100644
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ b/drivers/acpi/namespace/nsdumpdv.c
@@ -43,15 +43,18 @@
43 43
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h>
47 46
48 47
48/* TBD: This entire module is apparently obsolete and should be removed */
49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME ("nsdumpdv") 51 ACPI_MODULE_NAME ("nsdumpdv")
51 52
52 53#ifdef ACPI_OBSOLETE_FUNCTIONS
53#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 54#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
54 55
56#include <acpi/acnamesp.h>
57
55/******************************************************************************* 58/*******************************************************************************
56 * 59 *
57 * FUNCTION: acpi_ns_dump_one_device 60 * FUNCTION: acpi_ns_dump_one_device
@@ -59,13 +62,16 @@
59 * PARAMETERS: Handle - Node to be dumped 62 * PARAMETERS: Handle - Node to be dumped
60 * Level - Nesting level of the handle 63 * Level - Nesting level of the handle
61 * Context - Passed into walk_namespace 64 * Context - Passed into walk_namespace
65 * return_value - Not used
66 *
67 * RETURN: Status
62 * 68 *
63 * DESCRIPTION: Dump a single Node that represents a device 69 * DESCRIPTION: Dump a single Node that represents a device
64 * This procedure is a user_function called by acpi_ns_walk_namespace. 70 * This procedure is a user_function called by acpi_ns_walk_namespace.
65 * 71 *
66 ******************************************************************************/ 72 ******************************************************************************/
67 73
68acpi_status 74static acpi_status
69acpi_ns_dump_one_device ( 75acpi_ns_dump_one_device (
70 acpi_handle obj_handle, 76 acpi_handle obj_handle,
71 u32 level, 77 u32 level,
@@ -108,12 +114,15 @@ acpi_ns_dump_one_device (
108 * 114 *
109 * PARAMETERS: None 115 * PARAMETERS: None
110 * 116 *
117 * RETURN: None
118 *
111 * DESCRIPTION: Dump all objects of type "device" 119 * DESCRIPTION: Dump all objects of type "device"
112 * 120 *
113 ******************************************************************************/ 121 ******************************************************************************/
114 122
115void 123void
116acpi_ns_dump_root_devices (void) 124acpi_ns_dump_root_devices (
125 void)
117{ 126{
118 acpi_handle sys_bus_handle; 127 acpi_handle sys_bus_handle;
119 acpi_status status; 128 acpi_status status;
@@ -142,5 +151,6 @@ acpi_ns_dump_root_devices (void)
142} 151}
143 152
144#endif 153#endif
154#endif
145 155
146 156
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index 0d008d53657e..1ae89a1c8826 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -52,19 +52,33 @@
52#define _COMPONENT ACPI_NAMESPACE 52#define _COMPONENT ACPI_NAMESPACE
53 ACPI_MODULE_NAME ("nseval") 53 ACPI_MODULE_NAME ("nseval")
54 54
55/* Local prototypes */
56
57static acpi_status
58acpi_ns_execute_control_method (
59 struct acpi_parameter_info *info);
60
61static acpi_status
62acpi_ns_get_object_value (
63 struct acpi_parameter_info *info);
64
55 65
56/******************************************************************************* 66/*******************************************************************************
57 * 67 *
58 * FUNCTION: acpi_ns_evaluate_relative 68 * FUNCTION: acpi_ns_evaluate_relative
59 * 69 *
60 * PARAMETERS: Pathname - Name of method to execute, If NULL, the 70 * PARAMETERS: Pathname - Name of method to execute, If NULL, the
61 * handle is the object to execute 71 * handle is the object to execute
62 * Info - Method info block 72 * Info - Method info block, contains:
73 * return_object - Where to put method's return value (if
74 * any). If NULL, no value is returned.
75 * Params - List of parameters to pass to the method,
76 * terminated by NULL. Params itself may be
77 * NULL if no parameters are being passed.
63 * 78 *
64 * RETURN: Status 79 * RETURN: Status
65 * 80 *
66 * DESCRIPTION: Find and execute the requested method using the handle as a 81 * DESCRIPTION: Evaluate the object or find and execute the requested method
67 * scope
68 * 82 *
69 * MUTEX: Locks Namespace 83 * MUTEX: Locks Namespace
70 * 84 *
@@ -157,8 +171,8 @@ cleanup1:
157 * 171 *
158 * FUNCTION: acpi_ns_evaluate_by_name 172 * FUNCTION: acpi_ns_evaluate_by_name
159 * 173 *
160 * PARAMETERS: Pathname - Fully qualified pathname to the object 174 * PARAMETERS: Pathname - Fully qualified pathname to the object
161 * Info - Contains: 175 * Info - Method info block, contains:
162 * return_object - Where to put method's return value (if 176 * return_object - Where to put method's return value (if
163 * any). If NULL, no value is returned. 177 * any). If NULL, no value is returned.
164 * Params - List of parameters to pass to the method, 178 * Params - List of parameters to pass to the method,
@@ -167,8 +181,8 @@ cleanup1:
167 * 181 *
168 * RETURN: Status 182 * RETURN: Status
169 * 183 *
170 * DESCRIPTION: Find and execute the requested method passing the given 184 * DESCRIPTION: Evaluate the object or rind and execute the requested method
171 * parameters 185 * passing the given parameters
172 * 186 *
173 * MUTEX: Locks Namespace 187 * MUTEX: Locks Namespace
174 * 188 *
@@ -241,17 +255,21 @@ cleanup:
241 * 255 *
242 * FUNCTION: acpi_ns_evaluate_by_handle 256 * FUNCTION: acpi_ns_evaluate_by_handle
243 * 257 *
244 * PARAMETERS: Handle - Method Node to execute 258 * PARAMETERS: Info - Method info block, contains:
245 * Params - List of parameters to pass to the method, 259 * Node - Method/Object Node to execute
246 * terminated by NULL. Params itself may be 260 * Parameters - List of parameters to pass to the method,
261 * terminated by NULL. Params itself may be
247 * NULL if no parameters are being passed. 262 * NULL if no parameters are being passed.
248 * param_type - Type of Parameter list 263 * return_object - Where to put method's return value (if
249 * return_object - Where to put method's return value (if 264 * any). If NULL, no value is returned.
250 * any). If NULL, no value is returned. 265 * parameter_type - Type of Parameter list
266 * return_object - Where to put method's return value (if
267 * any). If NULL, no value is returned.
251 * 268 *
252 * RETURN: Status 269 * RETURN: Status
253 * 270 *
254 * DESCRIPTION: Execute the requested method passing the given parameters 271 * DESCRIPTION: Evaluate object or execute the requested method passing the
272 * given parameters
255 * 273 *
256 * MUTEX: Locks Namespace 274 * MUTEX: Locks Namespace
257 * 275 *
@@ -345,7 +363,16 @@ acpi_ns_evaluate_by_handle (
345 * 363 *
346 * FUNCTION: acpi_ns_execute_control_method 364 * FUNCTION: acpi_ns_execute_control_method
347 * 365 *
348 * PARAMETERS: Info - Method info block (w/params) 366 * PARAMETERS: Info - Method info block, contains:
367 * Node - Method Node to execute
368 * Parameters - List of parameters to pass to the method,
369 * terminated by NULL. Params itself may be
370 * NULL if no parameters are being passed.
371 * return_object - Where to put method's return value (if
372 * any). If NULL, no value is returned.
373 * parameter_type - Type of Parameter list
374 * return_object - Where to put method's return value (if
375 * any). If NULL, no value is returned.
349 * 376 *
350 * RETURN: Status 377 * RETURN: Status
351 * 378 *
@@ -355,7 +382,7 @@ acpi_ns_evaluate_by_handle (
355 * 382 *
356 ******************************************************************************/ 383 ******************************************************************************/
357 384
358acpi_status 385static acpi_status
359acpi_ns_execute_control_method ( 386acpi_ns_execute_control_method (
360 struct acpi_parameter_info *info) 387 struct acpi_parameter_info *info)
361{ 388{
@@ -414,7 +441,10 @@ acpi_ns_execute_control_method (
414 * 441 *
415 * FUNCTION: acpi_ns_get_object_value 442 * FUNCTION: acpi_ns_get_object_value
416 * 443 *
417 * PARAMETERS: Info - Method info block (w/params) 444 * PARAMETERS: Info - Method info block, contains:
445 * Node - Object's NS node
446 * return_object - Where to put object value (if
447 * any). If NULL, no value is returned.
418 * 448 *
419 * RETURN: Status 449 * RETURN: Status
420 * 450 *
@@ -424,7 +454,7 @@ acpi_ns_execute_control_method (
424 * 454 *
425 ******************************************************************************/ 455 ******************************************************************************/
426 456
427acpi_status 457static acpi_status
428acpi_ns_get_object_value ( 458acpi_ns_get_object_value (
429 struct acpi_parameter_info *info) 459 struct acpi_parameter_info *info)
430{ 460{
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
index 4a46b380605b..362802ae29a2 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/namespace/nsinit.c
@@ -50,6 +50,22 @@
50#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsinit") 51 ACPI_MODULE_NAME ("nsinit")
52 52
53/* Local prototypes */
54
55static acpi_status
56acpi_ns_init_one_object (
57 acpi_handle obj_handle,
58 u32 level,
59 void *context,
60 void **return_value);
61
62static acpi_status
63acpi_ns_init_one_device (
64 acpi_handle obj_handle,
65 u32 nesting_level,
66 void *context,
67 void **return_value);
68
53 69
54/******************************************************************************* 70/*******************************************************************************
55 * 71 *
@@ -191,7 +207,7 @@ acpi_ns_initialize_devices (
191 * 207 *
192 ******************************************************************************/ 208 ******************************************************************************/
193 209
194acpi_status 210static acpi_status
195acpi_ns_init_one_object ( 211acpi_ns_init_one_object (
196 acpi_handle obj_handle, 212 acpi_handle obj_handle,
197 u32 level, 213 u32 level,
@@ -331,7 +347,7 @@ acpi_ns_init_one_object (
331 * 347 *
332 ******************************************************************************/ 348 ******************************************************************************/
333 349
334acpi_status 350static acpi_status
335acpi_ns_init_one_device ( 351acpi_ns_init_one_device (
336 acpi_handle obj_handle, 352 acpi_handle obj_handle,
337 u32 nesting_level, 353 u32 nesting_level,
@@ -374,7 +390,8 @@ acpi_ns_init_one_device (
374 /* 390 /*
375 * Run _STA to determine if we can run _INI on the device. 391 * Run _STA to determine if we can run _INI on the device.
376 */ 392 */
377 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, pinfo.node, "_STA")); 393 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD,
394 pinfo.node, METHOD_NAME__STA));
378 status = acpi_ut_execute_STA (pinfo.node, &flags); 395 status = acpi_ut_execute_STA (pinfo.node, &flags);
379 396
380 if (ACPI_FAILURE (status)) { 397 if (ACPI_FAILURE (status)) {
@@ -399,8 +416,9 @@ acpi_ns_init_one_device (
399 /* 416 /*
400 * The device is present. Run _INI. 417 * The device is present. Run _INI.
401 */ 418 */
402 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, pinfo.node, "_INI")); 419 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD,
403 status = acpi_ns_evaluate_relative ("_INI", &pinfo); 420 pinfo.node, METHOD_NAME__INI));
421 status = acpi_ns_evaluate_relative (METHOD_NAME__INI, &pinfo);
404 if (ACPI_FAILURE (status)) { 422 if (ACPI_FAILURE (status)) {
405 /* No _INI (AE_NOT_FOUND) means device requires no initialization */ 423 /* No _INI (AE_NOT_FOUND) means device requires no initialization */
406 424
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
index 1d7aedf68a77..34e497016601 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/namespace/nsload.c
@@ -50,9 +50,24 @@
50#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsload") 51 ACPI_MODULE_NAME ("nsload")
52 52
53/* Local prototypes */
53 54
54#ifndef ACPI_NO_METHOD_EXECUTION 55static acpi_status
56acpi_ns_load_table_by_type (
57 acpi_table_type table_type);
58
59#ifdef ACPI_FUTURE_IMPLEMENTATION
60acpi_status
61acpi_ns_unload_namespace (
62 acpi_handle handle);
63
64static acpi_status
65acpi_ns_delete_subtree (
66 acpi_handle start_handle);
67#endif
55 68
69
70#ifndef ACPI_NO_METHOD_EXECUTION
56/******************************************************************************* 71/*******************************************************************************
57 * 72 *
58 * FUNCTION: acpi_ns_load_table 73 * FUNCTION: acpi_ns_load_table
@@ -159,7 +174,7 @@ acpi_ns_load_table (
159 * 174 *
160 ******************************************************************************/ 175 ******************************************************************************/
161 176
162acpi_status 177static acpi_status
163acpi_ns_load_table_by_type ( 178acpi_ns_load_table_by_type (
164 acpi_table_type table_type) 179 acpi_table_type table_type)
165{ 180{
@@ -321,8 +336,7 @@ acpi_ns_load_namespace (
321} 336}
322 337
323 338
324#ifdef ACPI_FUTURE_USAGE 339#ifdef ACPI_FUTURE_IMPLEMENTATION
325
326/******************************************************************************* 340/*******************************************************************************
327 * 341 *
328 * FUNCTION: acpi_ns_delete_subtree 342 * FUNCTION: acpi_ns_delete_subtree
@@ -339,7 +353,7 @@ acpi_ns_load_namespace (
339 * 353 *
340 ******************************************************************************/ 354 ******************************************************************************/
341 355
342acpi_status 356static acpi_status
343acpi_ns_delete_subtree ( 357acpi_ns_delete_subtree (
344 acpi_handle start_handle) 358 acpi_handle start_handle)
345{ 359{
@@ -453,8 +467,6 @@ acpi_ns_unload_namespace (
453 467
454 return_ACPI_STATUS (status); 468 return_ACPI_STATUS (status);
455} 469}
456 470#endif
457#endif /* ACPI_FUTURE_USAGE */
458
459#endif 471#endif
460 472
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index b6f8f910eff0..d8ce7e39795f 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -50,6 +50,14 @@
50#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsnames") 51 ACPI_MODULE_NAME ("nsnames")
52 52
53/* Local prototypes */
54
55static void
56acpi_ns_build_external_path (
57 struct acpi_namespace_node *node,
58 acpi_size size,
59 char *name_buffer);
60
53 61
54/******************************************************************************* 62/*******************************************************************************
55 * 63 *
@@ -66,7 +74,7 @@
66 * 74 *
67 ******************************************************************************/ 75 ******************************************************************************/
68 76
69void 77static void
70acpi_ns_build_external_path ( 78acpi_ns_build_external_path (
71 struct acpi_namespace_node *node, 79 struct acpi_namespace_node *node,
72 acpi_size size, 80 acpi_size size,
@@ -126,7 +134,7 @@ acpi_ns_build_external_path (
126 * 134 *
127 * FUNCTION: acpi_ns_get_external_pathname 135 * FUNCTION: acpi_ns_get_external_pathname
128 * 136 *
129 * PARAMETERS: Node - NS node whose pathname is needed 137 * PARAMETERS: Node - Namespace node whose pathname is needed
130 * 138 *
131 * RETURN: Pointer to storage containing the fully qualified name of 139 * RETURN: Pointer to storage containing the fully qualified name of
132 * the node, In external format (name segments separated by path 140 * the node, In external format (name segments separated by path
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
index 4e41e66db61f..27258c1ca4f1 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/namespace/nsobject.c
@@ -60,6 +60,8 @@
60 * Type - Type of object, or ACPI_TYPE_ANY if not 60 * Type - Type of object, or ACPI_TYPE_ANY if not
61 * known 61 * known
62 * 62 *
63 * RETURN: Status
64 *
63 * DESCRIPTION: Record the given object as the value associated with the 65 * DESCRIPTION: Record the given object as the value associated with the
64 * name whose acpi_handle is passed. If Object is NULL 66 * name whose acpi_handle is passed. If Object is NULL
65 * and Type is ACPI_TYPE_ANY, set the name as having no value. 67 * and Type is ACPI_TYPE_ANY, set the name as having no value.
@@ -97,7 +99,8 @@ acpi_ns_attach_object (
97 if (!object && (ACPI_TYPE_ANY != type)) { 99 if (!object && (ACPI_TYPE_ANY != type)) {
98 /* Null object */ 100 /* Null object */
99 101
100 ACPI_REPORT_ERROR (("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); 102 ACPI_REPORT_ERROR ((
103 "ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
101 return_ACPI_STATUS (AE_BAD_PARAMETER); 104 return_ACPI_STATUS (AE_BAD_PARAMETER);
102 } 105 }
103 106
@@ -112,7 +115,8 @@ acpi_ns_attach_object (
112 /* Check if this object is already attached */ 115 /* Check if this object is already attached */
113 116
114 if (node->object == object) { 117 if (node->object == object) {
115 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj %p already installed in name_obj %p\n", 118 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
119 "Obj %p already installed in name_obj %p\n",
116 object, node)); 120 object, node));
117 121
118 return_ACPI_STATUS (AE_OK); 122 return_ACPI_STATUS (AE_OK);
@@ -192,7 +196,7 @@ acpi_ns_attach_object (
192 * 196 *
193 * FUNCTION: acpi_ns_detach_object 197 * FUNCTION: acpi_ns_detach_object
194 * 198 *
195 * PARAMETERS: Node - An node whose object will be detached 199 * PARAMETERS: Node - A Namespace node whose object will be detached
196 * 200 *
197 * RETURN: None. 201 * RETURN: None.
198 * 202 *
@@ -248,7 +252,7 @@ acpi_ns_detach_object (
248 * 252 *
249 * FUNCTION: acpi_ns_get_attached_object 253 * FUNCTION: acpi_ns_get_attached_object
250 * 254 *
251 * PARAMETERS: Node - Parent Node to be examined 255 * PARAMETERS: Node - Namespace node
252 * 256 *
253 * RETURN: Current value of the object field from the Node whose 257 * RETURN: Current value of the object field from the Node whose
254 * handle is passed 258 * handle is passed
@@ -284,7 +288,7 @@ acpi_ns_get_attached_object (
284 * 288 *
285 * FUNCTION: acpi_ns_get_secondary_object 289 * FUNCTION: acpi_ns_get_secondary_object
286 * 290 *
287 * PARAMETERS: Node - Parent Node to be examined 291 * PARAMETERS: Node - Namespace node
288 * 292 *
289 * RETURN: Current value of the object field from the Node whose 293 * RETURN: Current value of the object field from the Node whose
290 * handle is passed. 294 * handle is passed.
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
index 0e6dea23603b..af8aaa9cc4f3 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/namespace/nssearch.c
@@ -49,15 +49,24 @@
49#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME ("nssearch") 50 ACPI_MODULE_NAME ("nssearch")
51 51
52/* Local prototypes */
53
54static acpi_status
55acpi_ns_search_parent_tree (
56 u32 target_name,
57 struct acpi_namespace_node *node,
58 acpi_object_type type,
59 struct acpi_namespace_node **return_node);
60
52 61
53/******************************************************************************* 62/*******************************************************************************
54 * 63 *
55 * FUNCTION: acpi_ns_search_node 64 * FUNCTION: acpi_ns_search_node
56 * 65 *
57 * PARAMETERS: *target_name - Ascii ACPI name to search for 66 * PARAMETERS: target_name - Ascii ACPI name to search for
58 * *Node - Starting node where search will begin 67 * Node - Starting node where search will begin
59 * Type - Object type to match 68 * Type - Object type to match
60 * **return_node - Where the matched Named obj is returned 69 * return_node - Where the matched Named obj is returned
61 * 70 *
62 * RETURN: Status 71 * RETURN: Status
63 * 72 *
@@ -163,10 +172,10 @@ acpi_ns_search_node (
163 * 172 *
164 * FUNCTION: acpi_ns_search_parent_tree 173 * FUNCTION: acpi_ns_search_parent_tree
165 * 174 *
166 * PARAMETERS: *target_name - Ascii ACPI name to search for 175 * PARAMETERS: target_name - Ascii ACPI name to search for
167 * *Node - Starting node where search will begin 176 * Node - Starting node where search will begin
168 * Type - Object type to match 177 * Type - Object type to match
169 * **return_node - Where the matched Node is returned 178 * return_node - Where the matched Node is returned
170 * 179 *
171 * RETURN: Status 180 * RETURN: Status
172 * 181 *
@@ -257,12 +266,12 @@ acpi_ns_search_parent_tree (
257 * 266 *
258 * PARAMETERS: target_name - Ascii ACPI name to search for (4 chars) 267 * PARAMETERS: target_name - Ascii ACPI name to search for (4 chars)
259 * walk_state - Current state of the walk 268 * walk_state - Current state of the walk
260 * *Node - Starting node where search will begin 269 * Node - Starting node where search will begin
261 * interpreter_mode - Add names only in ACPI_MODE_LOAD_PASS_x. 270 * interpreter_mode - Add names only in ACPI_MODE_LOAD_PASS_x.
262 * Otherwise,search only. 271 * Otherwise,search only.
263 * Type - Object type to match 272 * Type - Object type to match
264 * Flags - Flags describing the search restrictions 273 * Flags - Flags describing the search restrictions
265 * **return_node - Where the Node is returned 274 * return_node - Where the Node is returned
266 * 275 *
267 * RETURN: Status 276 * RETURN: Status
268 * 277 *
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index 75da76cc0b19..c53b82e94ce3 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -51,6 +51,18 @@
51#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsutils") 52 ACPI_MODULE_NAME ("nsutils")
53 53
54/* Local prototypes */
55
56static u8
57acpi_ns_valid_path_separator (
58 char sep);
59
60#ifdef ACPI_OBSOLETE_FUNCTIONS
61acpi_name
62acpi_ns_find_parent_name (
63 struct acpi_namespace_node *node_to_search);
64#endif
65
54 66
55/******************************************************************************* 67/*******************************************************************************
56 * 68 *
@@ -59,7 +71,8 @@
59 * PARAMETERS: module_name - Caller's module name (for error output) 71 * PARAMETERS: module_name - Caller's module name (for error output)
60 * line_number - Caller's line number (for error output) 72 * line_number - Caller's line number (for error output)
61 * component_id - Caller's component ID (for error output) 73 * component_id - Caller's component ID (for error output)
62 * Message - Error message to use on failure 74 * internal_name - Name or path of the namespace node
75 * lookup_status - Exception code from NS lookup
63 * 76 *
64 * RETURN: None 77 * RETURN: None
65 * 78 *
@@ -121,6 +134,9 @@ acpi_ns_report_error (
121 * line_number - Caller's line number (for error output) 134 * line_number - Caller's line number (for error output)
122 * component_id - Caller's component ID (for error output) 135 * component_id - Caller's component ID (for error output)
123 * Message - Error message to use on failure 136 * Message - Error message to use on failure
137 * prefix_node - Prefix relative to the path
138 * Path - Path to the node
139 * method_status - Execution status
124 * 140 *
125 * RETURN: None 141 * RETURN: None
126 * 142 *
@@ -161,8 +177,8 @@ acpi_ns_report_method_error (
161 * 177 *
162 * FUNCTION: acpi_ns_print_node_pathname 178 * FUNCTION: acpi_ns_print_node_pathname
163 * 179 *
164 * PARAMETERS: Node - Object 180 * PARAMETERS: Node - Object
165 * Msg - Prefix message 181 * Message - Prefix message
166 * 182 *
167 * DESCRIPTION: Print an object's full namespace pathname 183 * DESCRIPTION: Print an object's full namespace pathname
168 * Manages allocation/freeing of a pathname buffer 184 * Manages allocation/freeing of a pathname buffer
@@ -172,7 +188,7 @@ acpi_ns_report_method_error (
172void 188void
173acpi_ns_print_node_pathname ( 189acpi_ns_print_node_pathname (
174 struct acpi_namespace_node *node, 190 struct acpi_namespace_node *node,
175 char *msg) 191 char *message)
176{ 192{
177 struct acpi_buffer buffer; 193 struct acpi_buffer buffer;
178 acpi_status status; 194 acpi_status status;
@@ -189,8 +205,8 @@ acpi_ns_print_node_pathname (
189 205
190 status = acpi_ns_handle_to_pathname (node, &buffer); 206 status = acpi_ns_handle_to_pathname (node, &buffer);
191 if (ACPI_SUCCESS (status)) { 207 if (ACPI_SUCCESS (status)) {
192 if (msg) { 208 if (message) {
193 acpi_os_printf ("%s ", msg); 209 acpi_os_printf ("%s ", message);
194 } 210 }
195 211
196 acpi_os_printf ("[%s] (Node %p)", (char *) buffer.pointer, node); 212 acpi_os_printf ("[%s] (Node %p)", (char *) buffer.pointer, node);
@@ -224,7 +240,7 @@ acpi_ns_valid_root_prefix (
224 * 240 *
225 * FUNCTION: acpi_ns_valid_path_separator 241 * FUNCTION: acpi_ns_valid_path_separator
226 * 242 *
227 * PARAMETERS: Sep - Character to be checked 243 * PARAMETERS: Sep - Character to be checked
228 * 244 *
229 * RETURN: TRUE if a valid path separator 245 * RETURN: TRUE if a valid path separator
230 * 246 *
@@ -232,7 +248,7 @@ acpi_ns_valid_root_prefix (
232 * 248 *
233 ******************************************************************************/ 249 ******************************************************************************/
234 250
235u8 251static u8
236acpi_ns_valid_path_separator ( 252acpi_ns_valid_path_separator (
237 char sep) 253 char sep)
238{ 254{
@@ -245,10 +261,12 @@ acpi_ns_valid_path_separator (
245 * 261 *
246 * FUNCTION: acpi_ns_get_type 262 * FUNCTION: acpi_ns_get_type
247 * 263 *
248 * PARAMETERS: Handle - Parent Node to be examined 264 * PARAMETERS: Node - Parent Node to be examined
249 * 265 *
250 * RETURN: Type field from Node whose handle is passed 266 * RETURN: Type field from Node whose handle is passed
251 * 267 *
268 * DESCRIPTION: Return the type of a Namespace node
269 *
252 ******************************************************************************/ 270 ******************************************************************************/
253 271
254acpi_object_type 272acpi_object_type
@@ -271,11 +289,13 @@ acpi_ns_get_type (
271 * 289 *
272 * FUNCTION: acpi_ns_local 290 * FUNCTION: acpi_ns_local
273 * 291 *
274 * PARAMETERS: Type - A namespace object type 292 * PARAMETERS: Type - A namespace object type
275 * 293 *
276 * RETURN: LOCAL if names must be found locally in objects of the 294 * RETURN: LOCAL if names must be found locally in objects of the
277 * passed type, 0 if enclosing scopes should be searched 295 * passed type, 0 if enclosing scopes should be searched
278 * 296 *
297 * DESCRIPTION: Returns scope rule for the given object type.
298 *
279 ******************************************************************************/ 299 ******************************************************************************/
280 300
281u32 301u32
@@ -303,7 +323,7 @@ acpi_ns_local (
303 * PARAMETERS: Info - Info struct initialized with the 323 * PARAMETERS: Info - Info struct initialized with the
304 * external name pointer. 324 * external name pointer.
305 * 325 *
306 * RETURN: Status 326 * RETURN: None
307 * 327 *
308 * DESCRIPTION: Calculate the length of the internal (AML) namestring 328 * DESCRIPTION: Calculate the length of the internal (AML) namestring
309 * corresponding to the external (ASL) namestring. 329 * corresponding to the external (ASL) namestring.
@@ -551,14 +571,16 @@ acpi_ns_internalize_name (
551 * 571 *
552 * FUNCTION: acpi_ns_externalize_name 572 * FUNCTION: acpi_ns_externalize_name
553 * 573 *
554 * PARAMETERS: *internal_name - Internal representation of name 574 * PARAMETERS: internal_name_length - Lenth of the internal name below
555 * **converted_name - Where to return the resulting 575 * internal_name - Internal representation of name
556 * external representation of name 576 * converted_name_length - Where the length is returned
577 * converted_name - Where the resulting external name
578 * is returned
557 * 579 *
558 * RETURN: Status 580 * RETURN: Status
559 * 581 *
560 * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) 582 * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
561 * to its external form (e.g. "\_PR_.CPU0") 583 * to its external (printable) form (e.g. "\_PR_.CPU0")
562 * 584 *
563 ******************************************************************************/ 585 ******************************************************************************/
564 586
@@ -717,8 +739,9 @@ acpi_ns_externalize_name (
717 * 739 *
718 * DESCRIPTION: Convert a namespace handle to a real Node 740 * DESCRIPTION: Convert a namespace handle to a real Node
719 * 741 *
720 * Note: Real integer handles allow for more verification 742 * Note: Real integer handles would allow for more verification
721 * and keep all pointers within this subsystem. 743 * and keep all pointers within this subsystem - however this introduces
744 * more (and perhaps unnecessary) overhead.
722 * 745 *
723 ******************************************************************************/ 746 ******************************************************************************/
724 747
@@ -775,7 +798,7 @@ acpi_ns_convert_entry_to_handle (
775 return ((acpi_handle) node); 798 return ((acpi_handle) node);
776 799
777 800
778/* --------------------------------------------------- 801/* Example future implementation ---------------------
779 802
780 if (!Node) 803 if (!Node)
781 { 804 {
@@ -801,12 +824,13 @@ acpi_ns_convert_entry_to_handle (
801 * 824 *
802 * RETURN: none 825 * RETURN: none
803 * 826 *
804 * DESCRIPTION: free memory allocated for table storage. 827 * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
805 * 828 *
806 ******************************************************************************/ 829 ******************************************************************************/
807 830
808void 831void
809acpi_ns_terminate (void) 832acpi_ns_terminate (
833 void)
810{ 834{
811 union acpi_operand_object *obj_desc; 835 union acpi_operand_object *obj_desc;
812 836
@@ -940,7 +964,6 @@ acpi_ns_get_node_by_path (
940 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 964 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
941 965
942cleanup: 966cleanup:
943 /* Cleanup */
944 if (internal_path) { 967 if (internal_path) {
945 ACPI_MEM_FREE (internal_path); 968 ACPI_MEM_FREE (internal_path);
946 } 969 }
@@ -950,55 +973,6 @@ cleanup:
950 973
951/******************************************************************************* 974/*******************************************************************************
952 * 975 *
953 * FUNCTION: acpi_ns_find_parent_name
954 *
955 * PARAMETERS: *child_node - Named Obj whose name is to be found
956 *
957 * RETURN: The ACPI name
958 *
959 * DESCRIPTION: Search for the given obj in its parent scope and return the
960 * name segment, or "????" if the parent name can't be found
961 * (which "should not happen").
962 *
963 ******************************************************************************/
964#ifdef ACPI_FUTURE_USAGE
965acpi_name
966acpi_ns_find_parent_name (
967 struct acpi_namespace_node *child_node)
968{
969 struct acpi_namespace_node *parent_node;
970
971
972 ACPI_FUNCTION_TRACE ("ns_find_parent_name");
973
974
975 if (child_node) {
976 /* Valid entry. Get the parent Node */
977
978 parent_node = acpi_ns_get_parent_node (child_node);
979 if (parent_node) {
980 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
981 "Parent of %p [%4.4s] is %p [%4.4s]\n",
982 child_node, acpi_ut_get_node_name (child_node),
983 parent_node, acpi_ut_get_node_name (parent_node)));
984
985 if (parent_node->name.integer) {
986 return_VALUE ((acpi_name) parent_node->name.integer);
987 }
988 }
989
990 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
991 "Unable to find parent of %p (%4.4s)\n",
992 child_node, acpi_ut_get_node_name (child_node)));
993 }
994
995 return_VALUE (ACPI_UNKNOWN_NAME);
996}
997#endif
998
999
1000/*******************************************************************************
1001 *
1002 * FUNCTION: acpi_ns_get_parent_node 976 * FUNCTION: acpi_ns_get_parent_node
1003 * 977 *
1004 * PARAMETERS: Node - Current table entry 978 * PARAMETERS: Node - Current table entry
@@ -1009,7 +983,6 @@ acpi_ns_find_parent_name (
1009 * 983 *
1010 ******************************************************************************/ 984 ******************************************************************************/
1011 985
1012
1013struct acpi_namespace_node * 986struct acpi_namespace_node *
1014acpi_ns_get_parent_node ( 987acpi_ns_get_parent_node (
1015 struct acpi_namespace_node *node) 988 struct acpi_namespace_node *node)
@@ -1030,7 +1003,6 @@ acpi_ns_get_parent_node (
1030 node = node->peer; 1003 node = node->peer;
1031 } 1004 }
1032 1005
1033
1034 return (node->peer); 1006 return (node->peer);
1035} 1007}
1036 1008
@@ -1049,7 +1021,6 @@ acpi_ns_get_parent_node (
1049 * 1021 *
1050 ******************************************************************************/ 1022 ******************************************************************************/
1051 1023
1052
1053struct acpi_namespace_node * 1024struct acpi_namespace_node *
1054acpi_ns_get_next_valid_node ( 1025acpi_ns_get_next_valid_node (
1055 struct acpi_namespace_node *node) 1026 struct acpi_namespace_node *node)
@@ -1067,3 +1038,53 @@ acpi_ns_get_next_valid_node (
1067} 1038}
1068 1039
1069 1040
1041#ifdef ACPI_OBSOLETE_FUNCTIONS
1042/*******************************************************************************
1043 *
1044 * FUNCTION: acpi_ns_find_parent_name
1045 *
1046 * PARAMETERS: *child_node - Named Obj whose name is to be found
1047 *
1048 * RETURN: The ACPI name
1049 *
1050 * DESCRIPTION: Search for the given obj in its parent scope and return the
1051 * name segment, or "????" if the parent name can't be found
1052 * (which "should not happen").
1053 *
1054 ******************************************************************************/
1055
1056acpi_name
1057acpi_ns_find_parent_name (
1058 struct acpi_namespace_node *child_node)
1059{
1060 struct acpi_namespace_node *parent_node;
1061
1062
1063 ACPI_FUNCTION_TRACE ("ns_find_parent_name");
1064
1065
1066 if (child_node) {
1067 /* Valid entry. Get the parent Node */
1068
1069 parent_node = acpi_ns_get_parent_node (child_node);
1070 if (parent_node) {
1071 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
1072 "Parent of %p [%4.4s] is %p [%4.4s]\n",
1073 child_node, acpi_ut_get_node_name (child_node),
1074 parent_node, acpi_ut_get_node_name (parent_node)));
1075
1076 if (parent_node->name.integer) {
1077 return_VALUE ((acpi_name) parent_node->name.integer);
1078 }
1079 }
1080
1081 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
1082 "Unable to find parent of %p (%4.4s)\n",
1083 child_node, acpi_ut_get_node_name (child_node)));
1084 }
1085
1086 return_VALUE (ACPI_UNKNOWN_NAME);
1087}
1088#endif
1089
1090
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
index 4de2444df300..f9a7277dca6e 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/namespace/nswalk.c
@@ -56,7 +56,7 @@
56 * 56 *
57 * PARAMETERS: Type - Type of node to be searched for 57 * PARAMETERS: Type - Type of node to be searched for
58 * parent_node - Parent node whose children we are 58 * parent_node - Parent node whose children we are
59 * getting 59 * getting
60 * child_node - Previous child that was found. 60 * child_node - Previous child that was found.
61 * The NEXT child will be returned 61 * The NEXT child will be returned
62 * 62 *
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index 1dc995586cbe..12ea202257fa 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -58,11 +58,11 @@
58 * FUNCTION: acpi_evaluate_object_typed 58 * FUNCTION: acpi_evaluate_object_typed
59 * 59 *
60 * PARAMETERS: Handle - Object handle (optional) 60 * PARAMETERS: Handle - Object handle (optional)
61 * *Pathname - Object pathname (optional) 61 * Pathname - Object pathname (optional)
62 * **external_params - List of parameters to pass to method, 62 * external_params - List of parameters to pass to method,
63 * terminated by NULL. May be NULL 63 * terminated by NULL. May be NULL
64 * if no parameters are being passed. 64 * if no parameters are being passed.
65 * *return_buffer - Where to put method's return value (if 65 * return_buffer - Where to put method's return value (if
66 * any). If NULL, no value is returned. 66 * any). If NULL, no value is returned.
67 * return_type - Expected type of return object 67 * return_type - Expected type of return object
68 * 68 *
@@ -73,6 +73,7 @@
73 * be valid (non-null) 73 * be valid (non-null)
74 * 74 *
75 ******************************************************************************/ 75 ******************************************************************************/
76
76#ifdef ACPI_FUTURE_USAGE 77#ifdef ACPI_FUTURE_USAGE
77acpi_status 78acpi_status
78acpi_evaluate_object_typed ( 79acpi_evaluate_object_typed (
@@ -307,7 +308,8 @@ acpi_evaluate_object (
307 if (ACPI_SUCCESS (status)) { 308 if (ACPI_SUCCESS (status)) {
308 /* Validate/Allocate/Clear caller buffer */ 309 /* Validate/Allocate/Clear caller buffer */
309 310
310 status = acpi_ut_initialize_buffer (return_buffer, buffer_space_needed); 311 status = acpi_ut_initialize_buffer (return_buffer,
312 buffer_space_needed);
311 if (ACPI_FAILURE (status)) { 313 if (ACPI_FAILURE (status)) {
312 /* 314 /*
313 * Caller's buffer is too small or a new one can't be allocated 315 * Caller's buffer is too small or a new one can't be allocated
@@ -423,7 +425,8 @@ acpi_walk_namespace (
423 return_ACPI_STATUS (status); 425 return_ACPI_STATUS (status);
424 } 426 }
425 427
426 status = acpi_ns_walk_namespace (type, start_object, max_depth, ACPI_NS_WALK_UNLOCK, 428 status = acpi_ns_walk_namespace (type, start_object, max_depth,
429 ACPI_NS_WALK_UNLOCK,
427 user_function, context, return_value); 430 user_function, context, return_value);
428 431
429 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 432 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
@@ -525,7 +528,8 @@ acpi_ns_get_device_callback (
525 } 528 }
526 } 529 }
527 530
528 status = info->user_function (obj_handle, nesting_level, info->context, return_value); 531 status = info->user_function (obj_handle, nesting_level, info->context,
532 return_value);
529 return (status); 533 return (status);
530} 534}
531 535
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
index f2405efd1b9a..8d097914c49a 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/namespace/nsxfname.c
@@ -57,9 +57,9 @@
57 * FUNCTION: acpi_get_handle 57 * FUNCTION: acpi_get_handle
58 * 58 *
59 * PARAMETERS: Parent - Object to search under (search scope). 59 * PARAMETERS: Parent - Object to search under (search scope).
60 * path_name - Pointer to an asciiz string containing the 60 * Pathname - Pointer to an asciiz string containing the
61 * name 61 * name
62 * ret_handle - Where the return handle is placed 62 * ret_handle - Where the return handle is returned
63 * 63 *
64 * RETURN: Status 64 * RETURN: Status
65 * 65 *
@@ -220,7 +220,7 @@ EXPORT_SYMBOL(acpi_get_name);
220 * FUNCTION: acpi_get_object_info 220 * FUNCTION: acpi_get_object_info
221 * 221 *
222 * PARAMETERS: Handle - Object Handle 222 * PARAMETERS: Handle - Object Handle
223 * Info - Where the info is returned 223 * Buffer - Where the info is returned
224 * 224 *
225 * RETURN: Status 225 * RETURN: Status
226 * 226 *
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
index 19acf32674b9..363e1f6cfb18 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/namespace/nsxfobj.c
@@ -56,7 +56,7 @@
56 * FUNCTION: acpi_get_type 56 * FUNCTION: acpi_get_type
57 * 57 *
58 * PARAMETERS: Handle - Handle of object whose type is desired 58 * PARAMETERS: Handle - Handle of object whose type is desired
59 * *ret_type - Where the type will be placed 59 * ret_type - Where the type will be placed
60 * 60 *
61 * RETURN: Status 61 * RETURN: Status
62 * 62 *
@@ -258,5 +258,5 @@ unlock_and_exit:
258 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 258 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
259 return (status); 259 return (status);
260} 260}
261EXPORT_SYMBOL(acpi_get_next_object);
262 261
262EXPORT_SYMBOL(acpi_get_next_object);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 5a9128de6226..bdd9f37f8101 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -71,6 +71,9 @@ EXPORT_SYMBOL(acpi_in_debugger);
71extern char line_buf[80]; 71extern char line_buf[80];
72#endif /*ENABLE_DEBUGGER*/ 72#endif /*ENABLE_DEBUGGER*/
73 73
74int acpi_specific_hotkey_enabled;
75EXPORT_SYMBOL(acpi_specific_hotkey_enabled);
76
74static unsigned int acpi_irq_irq; 77static unsigned int acpi_irq_irq;
75static acpi_osd_handler acpi_irq_handler; 78static acpi_osd_handler acpi_irq_handler;
76static void *acpi_irq_context; 79static void *acpi_irq_context;
@@ -1152,6 +1155,15 @@ acpi_wake_gpes_always_on_setup(char *str)
1152 1155
1153__setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); 1156__setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
1154 1157
1158int __init
1159acpi_hotkey_setup(char *str)
1160{
1161 acpi_specific_hotkey_enabled = TRUE;
1162 return 1;
1163}
1164
1165__setup("acpi_specific_hotkey", acpi_hotkey_setup);
1166
1155/* 1167/*
1156 * max_cstate is defined in the base kernel so modules can 1168 * max_cstate is defined in the base kernel so modules can
1157 * change it w/o depending on the state of the processor module. 1169 * change it w/o depending on the state of the processor module.
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c
index b5d98895f6a8..b7ac68cc9e1c 100644
--- a/drivers/acpi/parser/psargs.c
+++ b/drivers/acpi/parser/psargs.c
@@ -50,6 +50,16 @@
50#define _COMPONENT ACPI_PARSER 50#define _COMPONENT ACPI_PARSER
51 ACPI_MODULE_NAME ("psargs") 51 ACPI_MODULE_NAME ("psargs")
52 52
53/* Local prototypes */
54
55static u32
56acpi_ps_get_next_package_length (
57 struct acpi_parse_state *parser_state);
58
59static union acpi_parse_object *
60acpi_ps_get_next_field (
61 struct acpi_parse_state *parser_state);
62
53 63
54/******************************************************************************* 64/*******************************************************************************
55 * 65 *
@@ -64,7 +74,7 @@
64 * 74 *
65 ******************************************************************************/ 75 ******************************************************************************/
66 76
67u32 77static u32
68acpi_ps_get_next_package_length ( 78acpi_ps_get_next_package_length (
69 struct acpi_parse_state *parser_state) 79 struct acpi_parse_state *parser_state)
70{ 80{
@@ -78,7 +88,6 @@ acpi_ps_get_next_package_length (
78 encoded_length = (u32) ACPI_GET8 (parser_state->aml); 88 encoded_length = (u32) ACPI_GET8 (parser_state->aml);
79 parser_state->aml++; 89 parser_state->aml++;
80 90
81
82 switch (encoded_length >> 6) /* bits 6-7 contain encoding scheme */ { 91 switch (encoded_length >> 6) /* bits 6-7 contain encoding scheme */ {
83 case 0: /* 1-byte encoding (bits 0-5) */ 92 case 0: /* 1-byte encoding (bits 0-5) */
84 93
@@ -287,13 +296,14 @@ acpi_ps_get_next_namepath (
287 * parent tree, but don't open a new scope -- we just want to lookup the 296 * parent tree, but don't open a new scope -- we just want to lookup the
288 * object (MUST BE mode EXECUTE to perform upsearch) 297 * object (MUST BE mode EXECUTE to perform upsearch)
289 */ 298 */
290 status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 299 status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY,
291 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &node); 300 ACPI_IMODE_EXECUTE,
301 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
302 NULL, &node);
292 if (ACPI_SUCCESS (status) && method_call) { 303 if (ACPI_SUCCESS (status) && method_call) {
293 if (node->type == ACPI_TYPE_METHOD) { 304 if (node->type == ACPI_TYPE_METHOD) {
294 /* 305 /* This name is actually a control method invocation */
295 * This name is actually a control method invocation 306
296 */
297 method_desc = acpi_ns_get_attached_object (node); 307 method_desc = acpi_ns_get_attached_object (node);
298 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 308 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
299 "Control Method - %p Desc %p Path=%p\n", 309 "Control Method - %p Desc %p Path=%p\n",
@@ -360,7 +370,7 @@ acpi_ps_get_next_namepath (
360 /* 370 /*
361 * We got a NOT_FOUND during table load or we encountered 371 * We got a NOT_FOUND during table load or we encountered
362 * a cond_ref_of(x) where the target does not exist. 372 * a cond_ref_of(x) where the target does not exist.
363 * -- either case is ok 373 * Either case is ok
364 */ 374 */
365 status = AE_OK; 375 status = AE_OK;
366 } 376 }
@@ -486,12 +496,13 @@ acpi_ps_get_next_simple_arg (
486 * 496 *
487 ******************************************************************************/ 497 ******************************************************************************/
488 498
489union acpi_parse_object * 499static union acpi_parse_object *
490acpi_ps_get_next_field ( 500acpi_ps_get_next_field (
491 struct acpi_parse_state *parser_state) 501 struct acpi_parse_state *parser_state)
492{ 502{
493 u32 aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, 503 u32 aml_offset = (u32)
494 parser_state->aml_start); 504 ACPI_PTR_DIFF (parser_state->aml,
505 parser_state->aml_start);
495 union acpi_parse_object *field; 506 union acpi_parse_object *field;
496 u16 opcode; 507 u16 opcode;
497 u32 name; 508 u32 name;
@@ -500,7 +511,7 @@ acpi_ps_get_next_field (
500 ACPI_FUNCTION_TRACE ("ps_get_next_field"); 511 ACPI_FUNCTION_TRACE ("ps_get_next_field");
501 512
502 513
503 /* determine field type */ 514 /* Determine field type */
504 515
505 switch (ACPI_GET8 (parser_state->aml)) { 516 switch (ACPI_GET8 (parser_state->aml)) {
506 default: 517 default:
@@ -521,7 +532,6 @@ acpi_ps_get_next_field (
521 break; 532 break;
522 } 533 }
523 534
524
525 /* Allocate a new field op */ 535 /* Allocate a new field op */
526 536
527 field = acpi_ps_alloc_op (opcode); 537 field = acpi_ps_alloc_op (opcode);
@@ -582,10 +592,10 @@ acpi_ps_get_next_field (
582 * 592 *
583 * FUNCTION: acpi_ps_get_next_arg 593 * FUNCTION: acpi_ps_get_next_arg
584 * 594 *
585 * PARAMETERS: parser_state - Current parser state object 595 * PARAMETERS: walk_state - Current state
596 * parser_state - Current parser state object
586 * arg_type - The argument type (AML_*_ARG) 597 * arg_type - The argument type (AML_*_ARG)
587 * arg_count - If the argument points to a control method 598 * return_arg - Where the next arg is returned
588 * the method's argument is returned here.
589 * 599 *
590 * RETURN: Status, and an op object containing the next argument. 600 * RETURN: Status, and an op object containing the next argument.
591 * 601 *
@@ -619,7 +629,7 @@ acpi_ps_get_next_arg (
619 case ARGP_NAME: 629 case ARGP_NAME:
620 case ARGP_NAMESTRING: 630 case ARGP_NAMESTRING:
621 631
622 /* constants, strings, and namestrings are all the same size */ 632 /* Constants, strings, and namestrings are all the same size */
623 633
624 arg = acpi_ps_alloc_op (AML_BYTE_OP); 634 arg = acpi_ps_alloc_op (AML_BYTE_OP);
625 if (!arg) { 635 if (!arg) {
@@ -654,7 +664,6 @@ acpi_ps_get_next_arg (
654 else { 664 else {
655 arg = field; 665 arg = field;
656 } 666 }
657
658 prev = field; 667 prev = field;
659 } 668 }
660 669
@@ -677,8 +686,8 @@ acpi_ps_get_next_arg (
677 686
678 /* Fill in bytelist data */ 687 /* Fill in bytelist data */
679 688
680 arg->common.value.size = (u32) ACPI_PTR_DIFF (parser_state->pkg_end, 689 arg->common.value.size = (u32)
681 parser_state->aml); 690 ACPI_PTR_DIFF (parser_state->pkg_end, parser_state->aml);
682 arg->named.data = parser_state->aml; 691 arg->named.data = parser_state->aml;
683 692
684 /* Skip to End of byte data */ 693 /* Skip to End of byte data */
@@ -706,7 +715,7 @@ acpi_ps_get_next_arg (
706 status = acpi_ps_get_next_namepath (walk_state, parser_state, arg, 0); 715 status = acpi_ps_get_next_namepath (walk_state, parser_state, arg, 0);
707 } 716 }
708 else { 717 else {
709 /* single complex argument, nothing returned */ 718 /* Single complex argument, nothing returned */
710 719
711 walk_state->arg_count = 1; 720 walk_state->arg_count = 1;
712 } 721 }
@@ -716,7 +725,7 @@ acpi_ps_get_next_arg (
716 case ARGP_DATAOBJ: 725 case ARGP_DATAOBJ:
717 case ARGP_TERMARG: 726 case ARGP_TERMARG:
718 727
719 /* single complex argument, nothing returned */ 728 /* Single complex argument, nothing returned */
720 729
721 walk_state->arg_count = 1; 730 walk_state->arg_count = 1;
722 break; 731 break;
@@ -727,7 +736,7 @@ acpi_ps_get_next_arg (
727 case ARGP_OBJLIST: 736 case ARGP_OBJLIST:
728 737
729 if (parser_state->aml < parser_state->pkg_end) { 738 if (parser_state->aml < parser_state->pkg_end) {
730 /* non-empty list of variable arguments, nothing returned */ 739 /* Non-empty list of variable arguments, nothing returned */
731 740
732 walk_state->arg_count = ACPI_VAR_ARGS; 741 walk_state->arg_count = ACPI_VAR_ARGS;
733 } 742 }
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c
index 03e33fedc11a..5744673568c0 100644
--- a/drivers/acpi/parser/psopcode.c
+++ b/drivers/acpi/parser/psopcode.c
@@ -44,6 +44,7 @@
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acparser.h> 46#include <acpi/acparser.h>
47#include <acpi/acopcode.h>
47#include <acpi/amlcode.h> 48#include <acpi/amlcode.h>
48 49
49 50
@@ -51,23 +52,6 @@
51 ACPI_MODULE_NAME ("psopcode") 52 ACPI_MODULE_NAME ("psopcode")
52 53
53 54
54#define _UNK 0x6B
55/*
56 * Reserved ASCII characters. Do not use any of these for
57 * internal opcodes, since they are used to differentiate
58 * name strings from AML opcodes
59 */
60#define _ASC 0x6C
61#define _NAM 0x6C
62#define _PFX 0x6D
63#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */
64
65#define MAX_EXTENDED_OPCODE 0x88
66#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1)
67#define MAX_INTERNAL_OPCODE
68#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1)
69
70
71/******************************************************************************* 55/*******************************************************************************
72 * 56 *
73 * NAME: acpi_gbl_aml_op_info 57 * NAME: acpi_gbl_aml_op_info
@@ -79,274 +63,9 @@
79 * 63 *
80 ******************************************************************************/ 64 ******************************************************************************/
81 65
82
83/*
84 * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed
85 * into a 32-bit number and stored in the master opcode table at the end of this file.
86 */
87
88
89#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
90#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA)
91#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
92#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME)
93#define ARGP_ARG0 ARG_NONE
94#define ARGP_ARG1 ARG_NONE
95#define ARGP_ARG2 ARG_NONE
96#define ARGP_ARG3 ARG_NONE
97#define ARGP_ARG4 ARG_NONE
98#define ARGP_ARG5 ARG_NONE
99#define ARGP_ARG6 ARG_NONE
100#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST)
101#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
102#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
103#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
104#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
105#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
106#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
107#define ARGP_BREAK_OP ARG_NONE
108#define ARGP_BREAK_POINT_OP ARG_NONE
109#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST)
110#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA)
111#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING)
112#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
113#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
114#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME)
115#define ARGP_CONTINUE_OP ARG_NONE
116#define ARGP_COPY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SIMPLENAME)
117#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
118#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
119#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
120#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
121#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
122#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
123#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
124#define ARGP_DEBUG_OP ARG_NONE
125#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
126#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG)
127#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
128#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET)
129#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA)
130#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST)
131#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME)
132#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG)
133#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST)
134#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
135#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
136#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
137#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
138#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
139#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST)
140#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
141#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
142#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
143#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
144#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
145#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
146#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
147#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG)
148#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
149#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME)
150#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
151#define ARGP_LOCAL0 ARG_NONE
152#define ARGP_LOCAL1 ARG_NONE
153#define ARGP_LOCAL2 ARG_NONE
154#define ARGP_LOCAL3 ARG_NONE
155#define ARGP_LOCAL4 ARG_NONE
156#define ARGP_LOCAL5 ARG_NONE
157#define ARGP_LOCAL6 ARG_NONE
158#define ARGP_LOCAL7 ARG_NONE
159#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
160#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
161#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST)
162#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING)
163#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
164#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
165#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
166#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA)
167#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ)
168#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
169#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING)
170#define ARGP_NOOP_OP ARG_NONE
171#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
172#define ARGP_ONE_OP ARG_NONE
173#define ARGP_ONES_OP ARG_NONE
174#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST)
175#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST)
176#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST)
177#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA)
178#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
179#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
180#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME)
181#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
182#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME)
183#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG)
184#define ARGP_REVISION_OP ARG_NONE
185#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST)
186#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
187#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
188#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME)
189#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
190#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG)
191#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG)
192#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING)
193#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME)
194#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST)
195#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
196#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
197#define ARGP_TIMER_OP ARG_NONE
198#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
199#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
200#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
201#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
202#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
203#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
204#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME)
205#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME)
206#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST)
207#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
208#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
209#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA)
210#define ARGP_ZERO_OP ARG_NONE
211
212
213/*
214 * All AML opcodes and the runtime arguments for each. Used by the AML interpreter Each list is compressed
215 * into a 32-bit number and stored in the master opcode table at the end of this file.
216 *
217 * (Used by prep_operands procedure and the ASL Compiler)
218 */
219
220
221#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE
222#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER)
223#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
224#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE
225#define ARGI_ARG0 ARG_NONE
226#define ARGI_ARG1 ARG_NONE
227#define ARGI_ARG2 ARG_NONE
228#define ARGI_ARG3 ARG_NONE
229#define ARGI_ARG4 ARG_NONE
230#define ARGI_ARG5 ARG_NONE
231#define ARGI_ARG6 ARG_NONE
232#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE
233#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
234#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
235#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
236#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
237#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
238#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
239#define ARGI_BREAK_OP ARG_NONE
240#define ARGI_BREAK_POINT_OP ARG_NONE
241#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER)
242#define ARGI_BYTE_OP ARGI_INVALID_OPCODE
243#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE
244#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF)
245#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF)
246#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF)
247#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE
248#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET)
249#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
250#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
251#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
252#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE)
253#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
254#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
255#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING)
256#define ARGI_DEBUG_OP ARG_NONE
257#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF)
258#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING)
259#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE
260#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF)
261#define ARGI_DWORD_OP ARGI_INVALID_OPCODE
262#define ARGI_ELSE_OP ARGI_INVALID_OPCODE
263#define ARGI_EVENT_OP ARGI_INVALID_OPCODE
264#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER)
265#define ARGI_FIELD_OP ARGI_INVALID_OPCODE
266#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
267#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
268#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
269#define ARGI_IF_OP ARGI_INVALID_OPCODE
270#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF)
271#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE
272#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF)
273#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
274#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
275#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
276#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE
277#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
278#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE
279#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER)
280#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE
281#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_FIELD,ARGI_TARGETREF)
282#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE)
283#define ARGI_LOCAL0 ARG_NONE
284#define ARGI_LOCAL1 ARG_NONE
285#define ARGI_LOCAL2 ARG_NONE
286#define ARGI_LOCAL3 ARG_NONE
287#define ARGI_LOCAL4 ARG_NONE
288#define ARGI_LOCAL5 ARG_NONE
289#define ARGI_LOCAL6 ARG_NONE
290#define ARGI_LOCAL7 ARG_NONE
291#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
292#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER)
293#define ARGI_METHOD_OP ARGI_INVALID_OPCODE
294#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE
295#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
296#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
297#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
298#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE
299#define ARGI_NAME_OP ARGI_INVALID_OPCODE
300#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE
301#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE
302#define ARGI_NOOP_OP ARG_NONE
303#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER)
304#define ARGI_ONE_OP ARG_NONE
305#define ARGI_ONES_OP ARG_NONE
306#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
307#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE
308#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE
309#define ARGI_QWORD_OP ARGI_INVALID_OPCODE
310#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF)
311#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
312#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX)
313#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE
314#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT)
315#define ARGI_RETURN_OP ARGI_INVALID_OPCODE
316#define ARGI_REVISION_OP ARG_NONE
317#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE
318#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
319#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
320#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT)
321#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT)
322#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER)
323#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER)
324#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE
325#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF)
326#define ARGI_STRING_OP ARGI_INVALID_OPCODE
327#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
328#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE
329#define ARGI_TIMER_OP ARG_NONE
330#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
331#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
332#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
333#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
334#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
335#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET)
336#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE)
337#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE)
338#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
339#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER)
340#define ARGI_WHILE_OP ARGI_INVALID_OPCODE
341#define ARGI_WORD_OP ARGI_INVALID_OPCODE
342#define ARGI_ZERO_OP ARG_NONE
343
344
345/* 66/*
346 * Summary of opcode types/flags 67 * Summary of opcode types/flags
347 */ 68 *
348
349/******************************************************************************
350 69
351 Opcodes that have associated namespace objects (AML_NSOBJECT flag) 70 Opcodes that have associated namespace objects (AML_NSOBJECT flag)
352 71
@@ -460,14 +179,13 @@
460 AML_CREATE_DWORD_FIELD_OP 179 AML_CREATE_DWORD_FIELD_OP
461 AML_CREATE_QWORD_FIELD_OP 180 AML_CREATE_QWORD_FIELD_OP
462 181
463******************************************************************************/ 182 ******************************************************************************/
464 183
465 184
466/* 185/*
467 * Master Opcode information table. A summary of everything we know about each opcode, all in one place. 186 * Master Opcode information table. A summary of everything we know about each
187 * opcode, all in one place.
468 */ 188 */
469
470
471const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = 189const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] =
472{ 190{
473/*! [Begin] no source code translation */ 191/*! [Begin] no source code translation */
@@ -693,8 +411,7 @@ static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] =
693 * 411 *
694 * PARAMETERS: Opcode - The AML opcode 412 * PARAMETERS: Opcode - The AML opcode
695 * 413 *
696 * RETURN: A pointer to the info about the opcode. NULL if the opcode was 414 * RETURN: A pointer to the info about the opcode.
697 * not found in the table.
698 * 415 *
699 * DESCRIPTION: Find AML opcode description based on the opcode. 416 * DESCRIPTION: Find AML opcode description based on the opcode.
700 * NOTE: This procedure must ALWAYS return a valid pointer! 417 * NOTE: This procedure must ALWAYS return a valid pointer!
@@ -731,7 +448,8 @@ acpi_ps_get_opcode_info (
731 448
732 default: 449 default:
733 450
734 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown AML opcode [%4.4X]\n", opcode)); 451 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
452 "Unknown AML opcode [%4.4X]\n", opcode));
735 break; 453 break;
736 } 454 }
737 455
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index e79edb53cb3b..bbfdc1a58c27 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -64,6 +64,23 @@
64 64
65static u32 acpi_gbl_depth = 0; 65static u32 acpi_gbl_depth = 0;
66 66
67/* Local prototypes */
68
69static void
70acpi_ps_complete_this_op (
71 struct acpi_walk_state *walk_state,
72 union acpi_parse_object *op);
73
74static acpi_status
75acpi_ps_next_parse_state (
76 struct acpi_walk_state *walk_state,
77 union acpi_parse_object *op,
78 acpi_status callback_status);
79
80static acpi_status
81acpi_ps_parse_loop (
82 struct acpi_walk_state *walk_state);
83
67 84
68/******************************************************************************* 85/*******************************************************************************
69 * 86 *
@@ -100,7 +117,7 @@ acpi_ps_get_opcode_size (
100 * 117 *
101 * PARAMETERS: parser_state - A parser state object 118 * PARAMETERS: parser_state - A parser state object
102 * 119 *
103 * RETURN: Status 120 * RETURN: Next AML opcode
104 * 121 *
105 * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) 122 * DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
106 * 123 *
@@ -117,7 +134,6 @@ acpi_ps_peek_opcode (
117 aml = parser_state->aml; 134 aml = parser_state->aml;
118 opcode = (u16) ACPI_GET8 (aml); 135 opcode = (u16) ACPI_GET8 (aml);
119 136
120
121 if (opcode == AML_EXTOP) { 137 if (opcode == AML_EXTOP) {
122 /* Extended opcode */ 138 /* Extended opcode */
123 139
@@ -142,7 +158,7 @@ acpi_ps_peek_opcode (
142 * 158 *
143 ******************************************************************************/ 159 ******************************************************************************/
144 160
145void 161static void
146acpi_ps_complete_this_op ( 162acpi_ps_complete_this_op (
147 struct acpi_walk_state *walk_state, 163 struct acpi_walk_state *walk_state,
148 union acpi_parse_object *op) 164 union acpi_parse_object *op)
@@ -272,7 +288,6 @@ acpi_ps_complete_this_op (
272 next = NULL; 288 next = NULL;
273 } 289 }
274 } 290 }
275
276 prev = next; 291 prev = next;
277 } 292 }
278 } 293 }
@@ -280,7 +295,7 @@ acpi_ps_complete_this_op (
280 295
281cleanup: 296cleanup:
282 297
283 /* Now we can actually delete the subtree rooted at op */ 298 /* Now we can actually delete the subtree rooted at Op */
284 299
285 acpi_ps_delete_parse_tree (op); 300 acpi_ps_delete_parse_tree (op);
286 return_VOID; 301 return_VOID;
@@ -291,7 +306,9 @@ cleanup:
291 * 306 *
292 * FUNCTION: acpi_ps_next_parse_state 307 * FUNCTION: acpi_ps_next_parse_state
293 * 308 *
294 * PARAMETERS: parser_state - Current parser state object 309 * PARAMETERS: walk_state - Current state
310 * Op - Current parse op
311 * callback_status - Status from previous operation
295 * 312 *
296 * RETURN: Status 313 * RETURN: Status
297 * 314 *
@@ -300,7 +317,7 @@ cleanup:
300 * 317 *
301 ******************************************************************************/ 318 ******************************************************************************/
302 319
303acpi_status 320static acpi_status
304acpi_ps_next_parse_state ( 321acpi_ps_next_parse_state (
305 struct acpi_walk_state *walk_state, 322 struct acpi_walk_state *walk_state,
306 union acpi_parse_object *op, 323 union acpi_parse_object *op,
@@ -382,9 +399,8 @@ acpi_ps_next_parse_state (
382 399
383 case AE_CTRL_TRANSFER: 400 case AE_CTRL_TRANSFER:
384 401
385 /* 402 /* A method call (invocation) -- transfer control */
386 * A method call (invocation) -- transfer control 403
387 */
388 status = AE_CTRL_TRANSFER; 404 status = AE_CTRL_TRANSFER;
389 walk_state->prev_op = op; 405 walk_state->prev_op = op;
390 walk_state->method_call_op = op; 406 walk_state->method_call_op = op;
@@ -397,6 +413,7 @@ acpi_ps_next_parse_state (
397 413
398 414
399 default: 415 default:
416
400 status = callback_status; 417 status = callback_status;
401 if ((callback_status & AE_CODE_MASK) == AE_CODE_CONTROL) { 418 if ((callback_status & AE_CODE_MASK) == AE_CODE_CONTROL) {
402 status = AE_OK; 419 status = AE_OK;
@@ -412,7 +429,7 @@ acpi_ps_next_parse_state (
412 * 429 *
413 * FUNCTION: acpi_ps_parse_loop 430 * FUNCTION: acpi_ps_parse_loop
414 * 431 *
415 * PARAMETERS: parser_state - Current parser state object 432 * PARAMETERS: walk_state - Current state
416 * 433 *
417 * RETURN: Status 434 * RETURN: Status
418 * 435 *
@@ -421,7 +438,7 @@ acpi_ps_next_parse_state (
421 * 438 *
422 ******************************************************************************/ 439 ******************************************************************************/
423 440
424acpi_status 441static acpi_status
425acpi_ps_parse_loop ( 442acpi_ps_parse_loop (
426 struct acpi_walk_state *walk_state) 443 struct acpi_walk_state *walk_state)
427{ 444{
@@ -443,6 +460,7 @@ acpi_ps_parse_loop (
443 walk_state->arg_types = 0; 460 walk_state->arg_types = 0;
444 461
445#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) 462#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
463
446 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { 464 if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
447 /* We are restarting a preempted control method */ 465 /* We are restarting a preempted control method */
448 466
@@ -471,7 +489,8 @@ acpi_ps_parse_loop (
471 acpi_format_exception (status))); 489 acpi_format_exception (status)));
472 490
473 } 491 }
474 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "get_predicate Failed, %s\n", 492 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
493 "get_predicate Failed, %s\n",
475 acpi_format_exception (status))); 494 acpi_format_exception (status)));
476 return_ACPI_STATUS (status); 495 return_ACPI_STATUS (status);
477 } 496 }
@@ -492,16 +511,15 @@ acpi_ps_parse_loop (
492 } 511 }
493#endif 512#endif
494 513
495 /* 514 /* Iterative parsing loop, while there is more AML to process: */
496 * Iterative parsing loop, while there is more aml to process: 515
497 */
498 while ((parser_state->aml < parser_state->aml_end) || (op)) { 516 while ((parser_state->aml < parser_state->aml_end) || (op)) {
499 aml_op_start = parser_state->aml; 517 aml_op_start = parser_state->aml;
500 if (!op) { 518 if (!op) {
501 /* Get the next opcode from the AML stream */ 519 /* Get the next opcode from the AML stream */
502 520
503 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, 521 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
504 parser_state->aml_start); 522 parser_state->aml_start);
505 walk_state->opcode = acpi_ps_peek_opcode (parser_state); 523 walk_state->opcode = acpi_ps_peek_opcode (parser_state);
506 524
507 /* 525 /*
@@ -578,8 +596,10 @@ acpi_ps_parse_loop (
578 INCREMENT_ARG_LIST (walk_state->arg_types); 596 INCREMENT_ARG_LIST (walk_state->arg_types);
579 } 597 }
580 598
581 /* Make sure that we found a NAME and didn't run out of arguments */ 599 /*
582 600 * Make sure that we found a NAME and didn't run out of
601 * arguments
602 */
583 if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) { 603 if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) {
584 status = AE_AML_NO_OPERAND; 604 status = AE_AML_NO_OPERAND;
585 goto close_this_op; 605 goto close_this_op;
@@ -597,12 +617,13 @@ acpi_ps_parse_loop (
597 617
598 status = walk_state->descending_callback (walk_state, &op); 618 status = walk_state->descending_callback (walk_state, &op);
599 if (ACPI_FAILURE (status)) { 619 if (ACPI_FAILURE (status)) {
600 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n", 620 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
601 acpi_format_exception (status))); 621 "During name lookup/catalog, %s\n",
622 acpi_format_exception (status)));
602 goto close_this_op; 623 goto close_this_op;
603 } 624 }
604 625
605 if (op == NULL) { 626 if (!op) {
606 continue; 627 continue;
607 } 628 }
608 629
@@ -659,7 +680,7 @@ acpi_ps_parse_loop (
659 680
660 if ((walk_state->descending_callback != NULL)) { 681 if ((walk_state->descending_callback != NULL)) {
661 /* 682 /*
662 * Find the object. This will either insert the object into 683 * Find the object. This will either insert the object into
663 * the namespace or simply look it up 684 * the namespace or simply look it up
664 */ 685 */
665 walk_state->op = op; 686 walk_state->op = op;
@@ -688,11 +709,15 @@ acpi_ps_parse_loop (
688 } 709 }
689 710
690 711
691 /* Start arg_count at zero because we don't know if there are any args yet */ 712 /*
692 713 * Start arg_count at zero because we don't know if there are
714 * any args yet
715 */
693 walk_state->arg_count = 0; 716 walk_state->arg_count = 0;
694 717
695 if (walk_state->arg_types) /* Are there any arguments that must be processed? */ { 718 /* Are there any arguments that must be processed? */
719
720 if (walk_state->arg_types) {
696 /* Get arguments */ 721 /* Get arguments */
697 722
698 switch (op->common.aml_opcode) { 723 switch (op->common.aml_opcode) {
@@ -720,14 +745,18 @@ acpi_ps_parse_loop (
720 745
721 default: 746 default:
722 747
723 /* Op is not a constant or string, append each argument to the Op */ 748 /*
724 749 * Op is not a constant or string, append each argument
750 * to the Op
751 */
725 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && 752 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
726 !walk_state->arg_count) { 753 !walk_state->arg_count) {
727 walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, 754 walk_state->aml_offset = (u32)
728 parser_state->aml_start); 755 ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start);
756
729 status = acpi_ps_get_next_arg (walk_state, parser_state, 757 status = acpi_ps_get_next_arg (walk_state, parser_state,
730 GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg); 758 GET_CURRENT_ARG_TYPE (walk_state->arg_types),
759 &arg);
731 if (ACPI_FAILURE (status)) { 760 if (ACPI_FAILURE (status)) {
732 goto close_this_op; 761 goto close_this_op;
733 } 762 }
@@ -752,7 +781,8 @@ acpi_ps_parse_loop (
752 * Save the length and address of the body 781 * Save the length and address of the body
753 */ 782 */
754 op->named.data = parser_state->aml; 783 op->named.data = parser_state->aml;
755 op->named.length = (u32) (parser_state->pkg_end - parser_state->aml); 784 op->named.length = (u32) (parser_state->pkg_end -
785 parser_state->aml);
756 786
757 /* Skip body of method */ 787 /* Skip body of method */
758 788
@@ -773,7 +803,8 @@ acpi_ps_parse_loop (
773 * to parse them correctly. 803 * to parse them correctly.
774 */ 804 */
775 op->named.data = aml_op_start; 805 op->named.data = aml_op_start;
776 op->named.length = (u32) (parser_state->pkg_end - aml_op_start); 806 op->named.length = (u32) (parser_state->pkg_end -
807 aml_op_start);
777 808
778 /* Skip body */ 809 /* Skip body */
779 810
@@ -785,7 +816,8 @@ acpi_ps_parse_loop (
785 case AML_WHILE_OP: 816 case AML_WHILE_OP:
786 817
787 if (walk_state->control_state) { 818 if (walk_state->control_state) {
788 walk_state->control_state->control.package_end = parser_state->pkg_end; 819 walk_state->control_state->control.package_end =
820 parser_state->pkg_end;
789 } 821 }
790 break; 822 break;
791 823
@@ -801,8 +833,10 @@ acpi_ps_parse_loop (
801 /* Check for arguments that need to be processed */ 833 /* Check for arguments that need to be processed */
802 834
803 if (walk_state->arg_count) { 835 if (walk_state->arg_count) {
804 /* There are arguments (complex ones), push Op and prepare for argument */ 836 /*
805 837 * There are arguments (complex ones), push Op and
838 * prepare for argument
839 */
806 status = acpi_ps_push_scope (parser_state, op, 840 status = acpi_ps_push_scope (parser_state, op,
807 walk_state->arg_types, walk_state->arg_count); 841 walk_state->arg_types, walk_state->arg_count);
808 if (ACPI_FAILURE (status)) { 842 if (ACPI_FAILURE (status)) {
@@ -812,8 +846,10 @@ acpi_ps_parse_loop (
812 continue; 846 continue;
813 } 847 }
814 848
815 /* All arguments have been processed -- Op is complete, prepare for next */ 849 /*
816 850 * All arguments have been processed -- Op is complete,
851 * prepare for next
852 */
817 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); 853 walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
818 if (walk_state->op_info->flags & AML_NAMED) { 854 if (walk_state->op_info->flags & AML_NAMED) {
819 if (acpi_gbl_depth) { 855 if (acpi_gbl_depth) {
@@ -880,9 +916,8 @@ close_this_op:
880 916
881 case AE_CTRL_TRANSFER: 917 case AE_CTRL_TRANSFER:
882 918
883 /* 919 /* We are about to transfer to a called method. */
884 * We are about to transfer to a called method. 920
885 */
886 walk_state->prev_op = op; 921 walk_state->prev_op = op;
887 walk_state->prev_arg_types = walk_state->arg_types; 922 walk_state->prev_arg_types = walk_state->arg_types;
888 return_ACPI_STATUS (status); 923 return_ACPI_STATUS (status);
@@ -1051,10 +1086,7 @@ close_this_op:
1051 * 1086 *
1052 * FUNCTION: acpi_ps_parse_aml 1087 * FUNCTION: acpi_ps_parse_aml
1053 * 1088 *
1054 * PARAMETERS: start_scope - The starting point of the parse. Becomes the 1089 * PARAMETERS: walk_state - Current state
1055 * root of the parsed op tree.
1056 * Aml - Pointer to the raw AML code to parse
1057 * aml_size - Length of the AML to parse
1058 * 1090 *
1059 * 1091 *
1060 * RETURN: Status 1092 * RETURN: Status
@@ -1076,8 +1108,10 @@ acpi_ps_parse_aml (
1076 1108
1077 ACPI_FUNCTION_TRACE ("ps_parse_aml"); 1109 ACPI_FUNCTION_TRACE ("ps_parse_aml");
1078 1110
1079 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with walk_state=%p Aml=%p size=%X\n", 1111 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
1080 walk_state, walk_state->parser_state.aml, walk_state->parser_state.aml_size)); 1112 "Entered with walk_state=%p Aml=%p size=%X\n",
1113 walk_state, walk_state->parser_state.aml,
1114 walk_state->parser_state.aml_size));
1081 1115
1082 1116
1083 /* Create and initialize a new thread state */ 1117 /* Create and initialize a new thread state */
@@ -1142,9 +1176,10 @@ acpi_ps_parse_aml (
1142 if ((status == AE_ALREADY_EXISTS) && 1176 if ((status == AE_ALREADY_EXISTS) &&
1143 (!walk_state->method_desc->method.semaphore)) { 1177 (!walk_state->method_desc->method.semaphore)) {
1144 /* 1178 /*
1145 * This method is marked not_serialized, but it tried to create a named 1179 * This method is marked not_serialized, but it tried to create
1146 * object, causing the second thread entrance to fail. We will workaround 1180 * a named object, causing the second thread entrance to fail.
1147 * this by marking the method permanently as Serialized. 1181 * We will workaround this by marking the method permanently
1182 * as Serialized.
1148 */ 1183 */
1149 walk_state->method_desc->method.method_flags |= AML_METHOD_SERIALIZED; 1184 walk_state->method_desc->method.method_flags |= AML_METHOD_SERIALIZED;
1150 walk_state->method_desc->method.concurrency = 1; 1185 walk_state->method_desc->method.concurrency = 1;
@@ -1187,7 +1222,8 @@ acpi_ps_parse_aml (
1187 1222
1188 previous_walk_state = walk_state; 1223 previous_walk_state = walk_state;
1189 1224
1190 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "return_value=%p, implicit_value=%p State=%p\n", 1225 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
1226 "return_value=%p, implicit_value=%p State=%p\n",
1191 walk_state->return_desc, walk_state->implicit_return_obj, walk_state)); 1227 walk_state->return_desc, walk_state->implicit_return_obj, walk_state));
1192 1228
1193 /* Check if we have restarted a preempted walk */ 1229 /* Check if we have restarted a preempted walk */
@@ -1231,12 +1267,14 @@ acpi_ps_parse_aml (
1231 */ 1267 */
1232 else if (previous_walk_state->caller_return_desc) { 1268 else if (previous_walk_state->caller_return_desc) {
1233 if (previous_walk_state->implicit_return_obj) { 1269 if (previous_walk_state->implicit_return_obj) {
1234 *(previous_walk_state->caller_return_desc) = previous_walk_state->implicit_return_obj; 1270 *(previous_walk_state->caller_return_desc) =
1271 previous_walk_state->implicit_return_obj;
1235 } 1272 }
1236 else { 1273 else {
1237 /* NULL if no return value */ 1274 /* NULL if no return value */
1238 1275
1239 *(previous_walk_state->caller_return_desc) = previous_walk_state->return_desc; 1276 *(previous_walk_state->caller_return_desc) =
1277 previous_walk_state->return_desc;
1240 } 1278 }
1241 } 1279 }
1242 else { 1280 else {
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c
index dcbed49608b0..8dcd1b1e7131 100644
--- a/drivers/acpi/parser/psscope.c
+++ b/drivers/acpi/parser/psscope.c
@@ -65,6 +65,7 @@ union acpi_parse_object *
65acpi_ps_get_parent_scope ( 65acpi_ps_get_parent_scope (
66 struct acpi_parse_state *parser_state) 66 struct acpi_parse_state *parser_state)
67{ 67{
68
68 return (parser_state->scope->parse_scope.op); 69 return (parser_state->scope->parse_scope.op);
69} 70}
70 71
@@ -87,8 +88,10 @@ u8
87acpi_ps_has_completed_scope ( 88acpi_ps_has_completed_scope (
88 struct acpi_parse_state *parser_state) 89 struct acpi_parse_state *parser_state)
89{ 90{
90 return ((u8) ((parser_state->aml >= parser_state->scope->parse_scope.arg_end || 91
91 !parser_state->scope->parse_scope.arg_count))); 92 return ((u8)
93 ((parser_state->aml >= parser_state->scope->parse_scope.arg_end ||
94 !parser_state->scope->parse_scope.arg_count)));
92} 95}
93 96
94 97
@@ -167,23 +170,23 @@ acpi_ps_push_scope (
167 return_ACPI_STATUS (AE_NO_MEMORY); 170 return_ACPI_STATUS (AE_NO_MEMORY);
168 } 171 }
169 172
170 scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE; 173 scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE;
171 scope->parse_scope.op = op; 174 scope->parse_scope.op = op;
172 scope->parse_scope.arg_list = remaining_args; 175 scope->parse_scope.arg_list = remaining_args;
173 scope->parse_scope.arg_count = arg_count; 176 scope->parse_scope.arg_count = arg_count;
174 scope->parse_scope.pkg_end = parser_state->pkg_end; 177 scope->parse_scope.pkg_end = parser_state->pkg_end;
175 178
176 /* Push onto scope stack */ 179 /* Push onto scope stack */
177 180
178 acpi_ut_push_generic_state (&parser_state->scope, scope); 181 acpi_ut_push_generic_state (&parser_state->scope, scope);
179 182
180 if (arg_count == ACPI_VAR_ARGS) { 183 if (arg_count == ACPI_VAR_ARGS) {
181 /* multiple arguments */ 184 /* Multiple arguments */
182 185
183 scope->parse_scope.arg_end = parser_state->pkg_end; 186 scope->parse_scope.arg_end = parser_state->pkg_end;
184 } 187 }
185 else { 188 else {
186 /* single argument */ 189 /* Single argument */
187 190
188 scope->parse_scope.arg_end = ACPI_TO_POINTER (ACPI_MAX_PTR); 191 scope->parse_scope.arg_end = ACPI_TO_POINTER (ACPI_MAX_PTR);
189 } 192 }
@@ -221,18 +224,17 @@ acpi_ps_pop_scope (
221 ACPI_FUNCTION_TRACE ("ps_pop_scope"); 224 ACPI_FUNCTION_TRACE ("ps_pop_scope");
222 225
223 226
224 /* 227 /* Only pop the scope if there is in fact a next scope */
225 * Only pop the scope if there is in fact a next scope 228
226 */
227 if (scope->common.next) { 229 if (scope->common.next) {
228 scope = acpi_ut_pop_generic_state (&parser_state->scope); 230 scope = acpi_ut_pop_generic_state (&parser_state->scope);
229 231
230 /* return to parsing previous op */ 232 /* return to parsing previous op */
231 233
232 *op = scope->parse_scope.op; 234 *op = scope->parse_scope.op;
233 *arg_list = scope->parse_scope.arg_list; 235 *arg_list = scope->parse_scope.arg_list;
234 *arg_count = scope->parse_scope.arg_count; 236 *arg_count = scope->parse_scope.arg_count;
235 parser_state->pkg_end = scope->parse_scope.pkg_end; 237 parser_state->pkg_end = scope->parse_scope.pkg_end;
236 238
237 /* All done with this scope state structure */ 239 /* All done with this scope state structure */
238 240
@@ -241,12 +243,13 @@ acpi_ps_pop_scope (
241 else { 243 else {
242 /* empty parse stack, prepare to fetch next opcode */ 244 /* empty parse stack, prepare to fetch next opcode */
243 245
244 *op = NULL; 246 *op = NULL;
245 *arg_list = 0; 247 *arg_list = 0;
246 *arg_count = 0; 248 *arg_count = 0;
247 } 249 }
248 250
249 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped Op %p Args %X\n", *op, *arg_count)); 251 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
252 "Popped Op %p Args %X\n", *op, *arg_count));
250 return_VOID; 253 return_VOID;
251} 254}
252 255
@@ -257,7 +260,7 @@ acpi_ps_pop_scope (
257 * 260 *
258 * PARAMETERS: parser_state - Current parser state object 261 * PARAMETERS: parser_state - Current parser state object
259 * 262 *
260 * RETURN: Status 263 * RETURN: None
261 * 264 *
262 * DESCRIPTION: Destroy available list, remaining stack levels, and return 265 * DESCRIPTION: Destroy available list, remaining stack levels, and return
263 * root scope 266 * root scope
diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c
index 2140bd1ac10b..d5aafe73fca0 100644
--- a/drivers/acpi/parser/pstree.c
+++ b/drivers/acpi/parser/pstree.c
@@ -49,6 +49,14 @@
49#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
50 ACPI_MODULE_NAME ("pstree") 50 ACPI_MODULE_NAME ("pstree")
51 51
52/* Local prototypes */
53
54#ifdef ACPI_OBSOLETE_FUNCTIONS
55union acpi_parse_object *
56acpi_ps_get_child (
57 union acpi_parse_object *op);
58#endif
59
52 60
53/******************************************************************************* 61/*******************************************************************************
54 * 62 *
@@ -57,7 +65,7 @@
57 * PARAMETERS: Op - Get an argument for this op 65 * PARAMETERS: Op - Get an argument for this op
58 * Argn - Nth argument to get 66 * Argn - Nth argument to get
59 * 67 *
60 * RETURN: The argument (as an Op object). NULL if argument does not exist 68 * RETURN: The argument (as an Op object). NULL if argument does not exist
61 * 69 *
62 * DESCRIPTION: Get the specified op's argument. 70 * DESCRIPTION: Get the specified op's argument.
63 * 71 *
@@ -152,7 +160,6 @@ acpi_ps_append_arg (
152 return; 160 return;
153 } 161 }
154 162
155
156 /* Append the argument to the linked argument list */ 163 /* Append the argument to the linked argument list */
157 164
158 if (op->common.value.arg) { 165 if (op->common.value.arg) {
@@ -164,14 +171,12 @@ acpi_ps_append_arg (
164 } 171 }
165 prev_arg->common.next = arg; 172 prev_arg->common.next = arg;
166 } 173 }
167
168 else { 174 else {
169 /* No argument list, this will be the first argument */ 175 /* No argument list, this will be the first argument */
170 176
171 op->common.value.arg = arg; 177 op->common.value.arg = arg;
172 } 178 }
173 179
174
175 /* Set the parent in this arg and any args linked after it */ 180 /* Set the parent in this arg and any args linked after it */
176 181
177 while (arg) { 182 while (arg) {
@@ -182,73 +187,6 @@ acpi_ps_append_arg (
182 187
183 188
184#ifdef ACPI_FUTURE_USAGE 189#ifdef ACPI_FUTURE_USAGE
185
186/*******************************************************************************
187 *
188 * FUNCTION: acpi_ps_get_child
189 *
190 * PARAMETERS: Op - Get the child of this Op
191 *
192 * RETURN: Child Op, Null if none is found.
193 *
194 * DESCRIPTION: Get op's children or NULL if none
195 *
196 ******************************************************************************/
197union acpi_parse_object *
198acpi_ps_get_child (
199 union acpi_parse_object *op)
200{
201 union acpi_parse_object *child = NULL;
202
203
204 ACPI_FUNCTION_ENTRY ();
205
206
207 switch (op->common.aml_opcode) {
208 case AML_SCOPE_OP:
209 case AML_ELSE_OP:
210 case AML_DEVICE_OP:
211 case AML_THERMAL_ZONE_OP:
212 case AML_INT_METHODCALL_OP:
213
214 child = acpi_ps_get_arg (op, 0);
215 break;
216
217
218 case AML_BUFFER_OP:
219 case AML_PACKAGE_OP:
220 case AML_METHOD_OP:
221 case AML_IF_OP:
222 case AML_WHILE_OP:
223 case AML_FIELD_OP:
224
225 child = acpi_ps_get_arg (op, 1);
226 break;
227
228
229 case AML_POWER_RES_OP:
230 case AML_INDEX_FIELD_OP:
231
232 child = acpi_ps_get_arg (op, 2);
233 break;
234
235
236 case AML_PROCESSOR_OP:
237 case AML_BANK_FIELD_OP:
238
239 child = acpi_ps_get_arg (op, 3);
240 break;
241
242
243 default:
244 /* All others have no children */
245 break;
246 }
247
248 return (child);
249}
250
251
252/******************************************************************************* 190/*******************************************************************************
253 * 191 *
254 * FUNCTION: acpi_ps_get_depth_next 192 * FUNCTION: acpi_ps_get_depth_next
@@ -280,21 +218,21 @@ acpi_ps_get_depth_next (
280 return (NULL); 218 return (NULL);
281 } 219 }
282 220
283 /* look for an argument or child */ 221 /* Look for an argument or child */
284 222
285 next = acpi_ps_get_arg (op, 0); 223 next = acpi_ps_get_arg (op, 0);
286 if (next) { 224 if (next) {
287 return (next); 225 return (next);
288 } 226 }
289 227
290 /* look for a sibling */ 228 /* Look for a sibling */
291 229
292 next = op->common.next; 230 next = op->common.next;
293 if (next) { 231 if (next) {
294 return (next); 232 return (next);
295 } 233 }
296 234
297 /* look for a sibling of parent */ 235 /* Look for a sibling of parent */
298 236
299 parent = op->common.parent; 237 parent = op->common.parent;
300 238
@@ -305,13 +243,13 @@ acpi_ps_get_depth_next (
305 } 243 }
306 244
307 if (arg == origin) { 245 if (arg == origin) {
308 /* reached parent of origin, end search */ 246 /* Reached parent of origin, end search */
309 247
310 return (NULL); 248 return (NULL);
311 } 249 }
312 250
313 if (parent->common.next) { 251 if (parent->common.next) {
314 /* found sibling of parent */ 252 /* Found sibling of parent */
315 253
316 return (parent->common.next); 254 return (parent->common.next);
317 } 255 }
@@ -323,5 +261,74 @@ acpi_ps_get_depth_next (
323 return (next); 261 return (next);
324} 262}
325 263
264
265#ifdef ACPI_OBSOLETE_FUNCTIONS
266/*******************************************************************************
267 *
268 * FUNCTION: acpi_ps_get_child
269 *
270 * PARAMETERS: Op - Get the child of this Op
271 *
272 * RETURN: Child Op, Null if none is found.
273 *
274 * DESCRIPTION: Get op's children or NULL if none
275 *
276 ******************************************************************************/
277
278union acpi_parse_object *
279acpi_ps_get_child (
280 union acpi_parse_object *op)
281{
282 union acpi_parse_object *child = NULL;
283
284
285 ACPI_FUNCTION_ENTRY ();
286
287
288 switch (op->common.aml_opcode) {
289 case AML_SCOPE_OP:
290 case AML_ELSE_OP:
291 case AML_DEVICE_OP:
292 case AML_THERMAL_ZONE_OP:
293 case AML_INT_METHODCALL_OP:
294
295 child = acpi_ps_get_arg (op, 0);
296 break;
297
298
299 case AML_BUFFER_OP:
300 case AML_PACKAGE_OP:
301 case AML_METHOD_OP:
302 case AML_IF_OP:
303 case AML_WHILE_OP:
304 case AML_FIELD_OP:
305
306 child = acpi_ps_get_arg (op, 1);
307 break;
308
309
310 case AML_POWER_RES_OP:
311 case AML_INDEX_FIELD_OP:
312
313 child = acpi_ps_get_arg (op, 2);
314 break;
315
316
317 case AML_PROCESSOR_OP:
318 case AML_BANK_FIELD_OP:
319
320 child = acpi_ps_get_arg (op, 3);
321 break;
322
323
324 default:
325 /* All others have no children */
326 break;
327 }
328
329 return (child);
330}
331#endif
332
326#endif /* ACPI_FUTURE_USAGE */ 333#endif /* ACPI_FUTURE_USAGE */
327 334
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
index b3597cb19f88..a10f88715d43 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/parser/psutils.c
@@ -45,7 +45,6 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acparser.h> 46#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
48#include <acpi/acnamesp.h>
49 48
50#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
51 ACPI_MODULE_NAME ("psutils") 50 ACPI_MODULE_NAME ("psutils")
@@ -57,7 +56,7 @@
57 * 56 *
58 * PARAMETERS: None 57 * PARAMETERS: None
59 * 58 *
60 * RETURN: scope_op 59 * RETURN: A new Scope object, null on failure
61 * 60 *
62 * DESCRIPTION: Create a Scope and associated namepath op with the root name 61 * DESCRIPTION: Create a Scope and associated namepath op with the root name
63 * 62 *
@@ -75,7 +74,6 @@ acpi_ps_create_scope_op (
75 return (NULL); 74 return (NULL);
76 } 75 }
77 76
78
79 scope_op->named.name = ACPI_ROOT_NAME; 77 scope_op->named.name = ACPI_ROOT_NAME;
80 return (scope_op); 78 return (scope_op);
81} 79}
@@ -88,10 +86,9 @@ acpi_ps_create_scope_op (
88 * PARAMETERS: Op - A newly allocated Op object 86 * PARAMETERS: Op - A newly allocated Op object
89 * Opcode - Opcode to store in the Op 87 * Opcode - Opcode to store in the Op
90 * 88 *
91 * RETURN: Status 89 * RETURN: None
92 * 90 *
93 * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on 91 * DESCRIPTION: Initialize a parse (Op) object
94 * opcode
95 * 92 *
96 ******************************************************************************/ 93 ******************************************************************************/
97 94
@@ -107,7 +104,8 @@ acpi_ps_init_op (
107 op->common.aml_opcode = opcode; 104 op->common.aml_opcode = opcode;
108 105
109 ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (op->common.aml_op_name, 106 ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (op->common.aml_op_name,
110 (acpi_ps_get_opcode_info (opcode))->name, sizeof (op->common.aml_op_name))); 107 (acpi_ps_get_opcode_info (opcode))->name,
108 sizeof (op->common.aml_op_name)));
111} 109}
112 110
113 111
@@ -117,7 +115,7 @@ acpi_ps_init_op (
117 * 115 *
118 * PARAMETERS: Opcode - Opcode that will be stored in the new Op 116 * PARAMETERS: Opcode - Opcode that will be stored in the new Op
119 * 117 *
120 * RETURN: Pointer to the new Op. 118 * RETURN: Pointer to the new Op, null on failure
121 * 119 *
122 * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on 120 * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
123 * opcode. A cache of opcodes is available for the pure 121 * opcode. A cache of opcodes is available for the pure
@@ -275,7 +273,6 @@ acpi_ps_get_name (
275 union acpi_parse_object *op) 273 union acpi_parse_object *op)
276{ 274{
277 275
278
279 /* The "generic" object has no name associated with it */ 276 /* The "generic" object has no name associated with it */
280 277
281 if (op->common.flags & ACPI_PARSEOP_GENERIC) { 278 if (op->common.flags & ACPI_PARSEOP_GENERIC) {
diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c
index 110d2ce917b6..9d20cb2ceb51 100644
--- a/drivers/acpi/parser/pswalk.c
+++ b/drivers/acpi/parser/pswalk.c
@@ -90,17 +90,15 @@ acpi_ps_delete_parse_tree (
90 } 90 }
91 } 91 }
92 92
93 /* 93 /* No more children, this Op is complete. */
94 * No more children, this Op is complete. 94
95 */
96 next = op->common.next; 95 next = op->common.next;
97 parent = op->common.parent; 96 parent = op->common.parent;
98 97
99 acpi_ps_free_op (op); 98 acpi_ps_free_op (op);
100 99
101 /* 100 /* If we are back to the starting point, the walk is complete. */
102 * If we are back to the starting point, the walk is complete. 101
103 */
104 if (op == subtree_root) { 102 if (op == subtree_root) {
105 return_VOID; 103 return_VOID;
106 } 104 }
@@ -111,5 +109,6 @@ acpi_ps_delete_parse_tree (
111 op = parent; 109 op = parent;
112 } 110 }
113 } 111 }
112
114 return_VOID; 113 return_VOID;
115} 114}
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c
index b318ad24726d..dba893648e84 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/parser/psxface.c
@@ -57,13 +57,16 @@
57 * 57 *
58 * FUNCTION: acpi_psx_execute 58 * FUNCTION: acpi_psx_execute
59 * 59 *
60 * PARAMETERS: Info->Node - A method object containing both the AML 60 * PARAMETERS: Info - Method info block, contains:
61 * address and length. 61 * Node - Method Node to execute
62 * **Params - List of parameters to pass to method, 62 * Parameters - List of parameters to pass to the method,
63 * terminated by NULL. Params itself may be 63 * terminated by NULL. Params itself may be
64 * NULL if no parameters are being passed. 64 * NULL if no parameters are being passed.
65 * **return_obj_desc - Return object from execution of the 65 * return_object - Where to put method's return value (if
66 * method. 66 * any). If NULL, no value is returned.
67 * parameter_type - Type of Parameter list
68 * return_object - Where to put method's return value (if
69 * any). If NULL, no value is returned.
67 * 70 *
68 * RETURN: Status 71 * RETURN: Status
69 * 72 *
@@ -196,9 +199,8 @@ acpi_psx_execute (
196 goto cleanup3; 199 goto cleanup3;
197 } 200 }
198 201
199 /* 202 /* The walk of the parse tree is where we actually execute the method */
200 * The walk of the parse tree is where we actually execute the method 203
201 */
202 status = acpi_ps_parse_aml (walk_state); 204 status = acpi_ps_parse_aml (walk_state);
203 goto cleanup2; /* Walk state already deleted */ 205 goto cleanup2; /* Walk state already deleted */
204 206
@@ -217,7 +219,8 @@ cleanup1:
217 for (i = 0; info->parameters[i]; i++) { 219 for (i = 0; info->parameters[i]; i++) {
218 /* Ignore errors, just do them all */ 220 /* Ignore errors, just do them all */
219 221
220 (void) acpi_ut_update_object_reference (info->parameters[i], REF_DECREMENT); 222 (void) acpi_ut_update_object_reference (
223 info->parameters[i], REF_DECREMENT);
221 } 224 }
222 } 225 }
223 226
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 8dbf802ee7f8..d1f42b972821 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -433,7 +433,7 @@ acpi_pci_irq_enable (
433 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: no GSI", 433 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: no GSI",
434 pci_name(dev), ('A' + pin)); 434 pci_name(dev), ('A' + pin));
435 /* Interrupt Line values above 0xF are forbidden */ 435 /* Interrupt Line values above 0xF are forbidden */
436 if (dev->irq >= 0 && (dev->irq <= 0xF)) { 436 if (dev->irq > 0 && (dev->irq <= 0xF)) {
437 printk(" - using IRQ %d\n", dev->irq); 437 printk(" - using IRQ %d\n", dev->irq);
438 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW); 438 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW);
439 return_VALUE(0); 439 return_VALUE(0);
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 520b28ad0740..6ad0e77df9b3 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -72,10 +72,12 @@ struct acpi_pci_link_irq {
72 u8 active; /* Current IRQ */ 72 u8 active; /* Current IRQ */
73 u8 edge_level; /* All IRQs */ 73 u8 edge_level; /* All IRQs */
74 u8 active_high_low; /* All IRQs */ 74 u8 active_high_low; /* All IRQs */
75 u8 initialized;
76 u8 resource_type; 75 u8 resource_type;
77 u8 possible_count; 76 u8 possible_count;
78 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; 77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
78 u8 initialized:1;
79 u8 suspend_resume:1;
80 u8 reserved:6;
79}; 81};
80 82
81struct acpi_pci_link { 83struct acpi_pci_link {
@@ -530,6 +532,10 @@ static int acpi_pci_link_allocate(
530 532
531 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); 533 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
532 534
535 if (link->irq.suspend_resume) {
536 acpi_pci_link_set(link, link->irq.active);
537 link->irq.suspend_resume = 0;
538 }
533 if (link->irq.initialized) 539 if (link->irq.initialized)
534 return_VALUE(0); 540 return_VALUE(0);
535 541
@@ -713,38 +719,24 @@ end:
713 return_VALUE(result); 719 return_VALUE(result);
714} 720}
715 721
716
717static int
718acpi_pci_link_resume (
719 struct acpi_pci_link *link)
720{
721 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
722
723 if (link->irq.active && link->irq.initialized)
724 return_VALUE(acpi_pci_link_set(link, link->irq.active));
725 else
726 return_VALUE(0);
727}
728
729
730static int 722static int
731irqrouter_resume( 723irqrouter_suspend(
732 struct sys_device *dev) 724 struct sys_device *dev,
725 u32 state)
733{ 726{
734 struct list_head *node = NULL; 727 struct list_head *node = NULL;
735 struct acpi_pci_link *link = NULL; 728 struct acpi_pci_link *link = NULL;
736 729
737 ACPI_FUNCTION_TRACE("irqrouter_resume"); 730 ACPI_FUNCTION_TRACE("irqrouter_suspend");
738 731
739 list_for_each(node, &acpi_link.entries) { 732 list_for_each(node, &acpi_link.entries) {
740
741 link = list_entry(node, struct acpi_pci_link, node); 733 link = list_entry(node, struct acpi_pci_link, node);
742 if (!link) { 734 if (!link) {
743 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 735 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
744 continue; 736 continue;
745 } 737 }
746 738 if (link->irq.active && link->irq.initialized)
747 acpi_pci_link_resume(link); 739 link->irq.suspend_resume = 1;
748 } 740 }
749 return_VALUE(0); 741 return_VALUE(0);
750} 742}
@@ -812,9 +804,12 @@ static int __init acpi_irq_penalty_update(char *str, int used)
812 * There is no ISA_POSSIBLE weight, so we simply use 804 * There is no ISA_POSSIBLE weight, so we simply use
813 * the (small) PCI_USING penalty. 805 * the (small) PCI_USING penalty.
814 */ 806 */
815void acpi_penalize_isa_irq(int irq) 807void acpi_penalize_isa_irq(int irq, int active)
816{ 808{
817 acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING; 809 if (active)
810 acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
811 else
812 acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
818} 813}
819 814
820/* 815/*
@@ -856,7 +851,7 @@ __setup("acpi_irq_balance", acpi_irq_balance_set);
856 851
857static struct sysdev_class irqrouter_sysdev_class = { 852static struct sysdev_class irqrouter_sysdev_class = {
858 set_kset_name("irqrouter"), 853 set_kset_name("irqrouter"),
859 .resume = irqrouter_resume, 854 .suspend = irqrouter_suspend,
860}; 855};
861 856
862 857
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 76156ac91bd3..d56a439ac614 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -256,6 +256,43 @@ acpi_processor_errata (
256 256
257 257
258/* -------------------------------------------------------------------------- 258/* --------------------------------------------------------------------------
259 Common ACPI processor fucntions
260 -------------------------------------------------------------------------- */
261
262/*
263 * _PDC is required for a BIOS-OS handshake for most of the newer
264 * ACPI processor features.
265 */
266
267int acpi_processor_set_pdc(struct acpi_processor *pr,
268 struct acpi_object_list *pdc_in)
269{
270 acpi_status status = AE_OK;
271 u32 arg0_buf[3];
272 union acpi_object arg0 = {ACPI_TYPE_BUFFER};
273 struct acpi_object_list no_object = {1, &arg0};
274 struct acpi_object_list *pdc;
275
276 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
277
278 arg0.buffer.length = 12;
279 arg0.buffer.pointer = (u8 *) arg0_buf;
280 arg0_buf[0] = ACPI_PDC_REVISION_ID;
281 arg0_buf[1] = 0;
282 arg0_buf[2] = 0;
283
284 pdc = (pdc_in) ? pdc_in : &no_object;
285
286 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);
287
288 if ((ACPI_FAILURE(status)) && (pdc_in))
289 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n"));
290
291 return_VALUE(status);
292}
293
294
295/* --------------------------------------------------------------------------
259 FS Interface (/proc) 296 FS Interface (/proc)
260 -------------------------------------------------------------------------- */ 297 -------------------------------------------------------------------------- */
261 298
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index c9d671cf7857..893b074e3d1a 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -6,6 +6,8 @@
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> 6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> 7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 * - Added processor hotplug support 8 * - Added processor hotplug support
9 * Copyright (C) 2005 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
10 * - Added support for C3 on SMP
9 * 11 *
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 * 13 *
@@ -142,7 +144,7 @@ acpi_processor_power_activate (
142 switch (old->type) { 144 switch (old->type) {
143 case ACPI_STATE_C3: 145 case ACPI_STATE_C3:
144 /* Disable bus master reload */ 146 /* Disable bus master reload */
145 if (new->type != ACPI_STATE_C3) 147 if (new->type != ACPI_STATE_C3 && pr->flags.bm_check)
146 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK); 148 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK);
147 break; 149 break;
148 } 150 }
@@ -152,7 +154,7 @@ acpi_processor_power_activate (
152 switch (new->type) { 154 switch (new->type) {
153 case ACPI_STATE_C3: 155 case ACPI_STATE_C3:
154 /* Enable bus master reload */ 156 /* Enable bus master reload */
155 if (old->type != ACPI_STATE_C3) 157 if (old->type != ACPI_STATE_C3 && pr->flags.bm_check)
156 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1, ACPI_MTX_DO_NOT_LOCK); 158 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1, ACPI_MTX_DO_NOT_LOCK);
157 break; 159 break;
158 } 160 }
@@ -163,6 +165,9 @@ acpi_processor_power_activate (
163} 165}
164 166
165 167
168static atomic_t c3_cpu_count;
169
170
166static void acpi_processor_idle (void) 171static void acpi_processor_idle (void)
167{ 172{
168 struct acpi_processor *pr = NULL; 173 struct acpi_processor *pr = NULL;
@@ -297,8 +302,22 @@ static void acpi_processor_idle (void)
297 break; 302 break;
298 303
299 case ACPI_STATE_C3: 304 case ACPI_STATE_C3:
300 /* Disable bus master arbitration */ 305
301 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK); 306 if (pr->flags.bm_check) {
307 if (atomic_inc_return(&c3_cpu_count) ==
308 num_online_cpus()) {
309 /*
310 * All CPUs are trying to go to C3
311 * Disable bus master arbitration
312 */
313 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1,
314 ACPI_MTX_DO_NOT_LOCK);
315 }
316 } else {
317 /* SMP with no shared cache... Invalidate cache */
318 ACPI_FLUSH_CPU_CACHE();
319 }
320
302 /* Get start time (ticks) */ 321 /* Get start time (ticks) */
303 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 322 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
304 /* Invoke C3 */ 323 /* Invoke C3 */
@@ -307,8 +326,12 @@ static void acpi_processor_idle (void)
307 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 326 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
308 /* Get end time (ticks) */ 327 /* Get end time (ticks) */
309 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 328 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
310 /* Enable bus master arbitration */ 329 if (pr->flags.bm_check) {
311 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK); 330 /* Enable bus master arbitration */
331 atomic_dec(&c3_cpu_count);
332 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
333 }
334
312 /* Re-enable interrupts */ 335 /* Re-enable interrupts */
313 local_irq_enable(); 336 local_irq_enable();
314 /* Compute time (ticks) that we were actually asleep */ 337 /* Compute time (ticks) that we were actually asleep */
@@ -519,6 +542,29 @@ static int acpi_processor_get_power_info_fadt (struct acpi_processor *pr)
519} 542}
520 543
521 544
545static int acpi_processor_get_power_info_default_c1 (struct acpi_processor *pr)
546{
547 int i;
548
549 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
550
551 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++)
552 memset(pr->power.states, 0, sizeof(struct acpi_processor_cx));
553
554 /* if info is obtained from pblk/fadt, type equals state */
555 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
556 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2;
557 pr->power.states[ACPI_STATE_C3].type = ACPI_STATE_C3;
558
559 /* the C0 state only exists as a filler in our array,
560 * and all processors need to support C1 */
561 pr->power.states[ACPI_STATE_C0].valid = 1;
562 pr->power.states[ACPI_STATE_C1].valid = 1;
563
564 return_VALUE(0);
565}
566
567
522static int acpi_processor_get_power_info_cst (struct acpi_processor *pr) 568static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
523{ 569{
524 acpi_status status = 0; 570 acpi_status status = 0;
@@ -529,9 +575,6 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
529 575
530 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst"); 576 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst");
531 577
532 if (errata.smp)
533 return_VALUE(-ENODEV);
534
535 if (nocst) 578 if (nocst)
536 return_VALUE(-ENODEV); 579 return_VALUE(-ENODEV);
537 580
@@ -664,13 +707,6 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
664 return_VOID; 707 return_VOID;
665 } 708 }
666 709
667 /* We're (currently) only supporting C2 on UP */
668 else if (errata.smp) {
669 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
670 "C2 not supported in SMP mode\n"));
671 return_VOID;
672 }
673
674 /* 710 /*
675 * Otherwise we've met all of our C2 requirements. 711 * Otherwise we've met all of our C2 requirements.
676 * Normalize the C2 latency to expidite policy 712 * Normalize the C2 latency to expidite policy
@@ -686,6 +722,8 @@ static void acpi_processor_power_verify_c3(
686 struct acpi_processor *pr, 722 struct acpi_processor *pr,
687 struct acpi_processor_cx *cx) 723 struct acpi_processor_cx *cx)
688{ 724{
725 static int bm_check_flag;
726
689 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3"); 727 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3");
690 728
691 if (!cx->address) 729 if (!cx->address)
@@ -702,20 +740,6 @@ static void acpi_processor_power_verify_c3(
702 return_VOID; 740 return_VOID;
703 } 741 }
704 742
705 /* bus mastering control is necessary */
706 else if (!pr->flags.bm_control) {
707 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
708 "C3 support requires bus mastering control\n"));
709 return_VOID;
710 }
711
712 /* We're (currently) only supporting C2 on UP */
713 else if (errata.smp) {
714 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
715 "C3 not supported in SMP mode\n"));
716 return_VOID;
717 }
718
719 /* 743 /*
720 * PIIX4 Erratum #18: We don't support C3 when Type-F (fast) 744 * PIIX4 Erratum #18: We don't support C3 when Type-F (fast)
721 * DMA transfers are used by any ISA device to avoid livelock. 745 * DMA transfers are used by any ISA device to avoid livelock.
@@ -729,6 +753,39 @@ static void acpi_processor_power_verify_c3(
729 return_VOID; 753 return_VOID;
730 } 754 }
731 755
756 /* All the logic here assumes flags.bm_check is same across all CPUs */
757 if (!bm_check_flag) {
758 /* Determine whether bm_check is needed based on CPU */
759 acpi_processor_power_init_bm_check(&(pr->flags), pr->id);
760 bm_check_flag = pr->flags.bm_check;
761 } else {
762 pr->flags.bm_check = bm_check_flag;
763 }
764
765 if (pr->flags.bm_check) {
766 printk("Disabling BM access before entering C3\n");
767 /* bus mastering control is necessary */
768 if (!pr->flags.bm_control) {
769 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
770 "C3 support requires bus mastering control\n"));
771 return_VOID;
772 }
773 } else {
774 printk("Invalidating cache before entering C3\n");
775 /*
776 * WBINVD should be set in fadt, for C3 state to be
777 * supported on when bm_check is not required.
778 */
779 if (acpi_fadt.wb_invd != 1) {
780 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
781 "Cache invalidation should work properly"
782 " for C3 to be enabled on SMP systems\n"));
783 return_VOID;
784 }
785 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD,
786 0, ACPI_MTX_DO_NOT_LOCK);
787 }
788
732 /* 789 /*
733 * Otherwise we've met all of our C3 requirements. 790 * Otherwise we've met all of our C3 requirements.
734 * Normalize the C3 latency to expidite policy. Enable 791 * Normalize the C3 latency to expidite policy. Enable
@@ -737,7 +794,6 @@ static void acpi_processor_power_verify_c3(
737 */ 794 */
738 cx->valid = 1; 795 cx->valid = 1;
739 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); 796 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
740 pr->flags.bm_check = 1;
741 797
742 return_VOID; 798 return_VOID;
743} 799}
@@ -787,10 +843,7 @@ static int acpi_processor_get_power_info (
787 if ((result) || (acpi_processor_power_verify(pr) < 2)) { 843 if ((result) || (acpi_processor_power_verify(pr) < 2)) {
788 result = acpi_processor_get_power_info_fadt(pr); 844 result = acpi_processor_get_power_info_fadt(pr);
789 if (result) 845 if (result)
790 return_VALUE(result); 846 result = acpi_processor_get_power_info_default_c1(pr);
791
792 if (acpi_processor_power_verify(pr) < 2)
793 return_VALUE(-ENODEV);
794 } 847 }
795 848
796 /* 849 /*
@@ -810,11 +863,10 @@ static int acpi_processor_get_power_info (
810 * CPU as being "idle manageable" 863 * CPU as being "idle manageable"
811 */ 864 */
812 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 865 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
813 if (pr->power.states[i].valid) 866 if (pr->power.states[i].valid) {
814 pr->power.count = i; 867 pr->power.count = i;
815 if ((pr->power.states[i].valid) &&
816 (pr->power.states[i].type >= ACPI_STATE_C2))
817 pr->flags.power = 1; 868 pr->flags.power = 1;
869 }
818 } 870 }
819 871
820 return_VALUE(0); 872 return_VALUE(0);
@@ -829,7 +881,7 @@ int acpi_processor_cst_has_changed (struct acpi_processor *pr)
829 if (!pr) 881 if (!pr)
830 return_VALUE(-EINVAL); 882 return_VALUE(-EINVAL);
831 883
832 if (errata.smp || nocst) { 884 if ( nocst) {
833 return_VALUE(-ENODEV); 885 return_VALUE(-ENODEV);
834 } 886 }
835 887
@@ -929,7 +981,6 @@ static struct file_operations acpi_processor_power_fops = {
929 .release = single_release, 981 .release = single_release,
930}; 982};
931 983
932
933int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device) 984int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device)
934{ 985{
935 acpi_status status = 0; 986 acpi_status status = 0;
@@ -946,7 +997,10 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
946 first_run++; 997 first_run++;
947 } 998 }
948 999
949 if (!errata.smp && (pr->id == 0) && acpi_fadt.cst_cnt && !nocst) { 1000 if (!pr)
1001 return_VALUE(-EINVAL);
1002
1003 if (acpi_fadt.cst_cnt && !nocst) {
950 status = acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8); 1004 status = acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8);
951 if (ACPI_FAILURE(status)) { 1005 if (ACPI_FAILURE(status)) {
952 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1006 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -954,6 +1008,8 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
954 } 1008 }
955 } 1009 }
956 1010
1011 acpi_processor_power_init_pdc(&(pr->power), pr->id);
1012 acpi_processor_set_pdc(pr, pr->power.pdc);
957 acpi_processor_get_power_info(pr); 1013 acpi_processor_get_power_info(pr);
958 1014
959 /* 1015 /*
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index a9a1a8fe3199..1f0d6256302f 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -165,37 +165,6 @@ void acpi_processor_ppc_exit(void) {
165 acpi_processor_ppc_status &= ~PPC_REGISTERED; 165 acpi_processor_ppc_status &= ~PPC_REGISTERED;
166} 166}
167 167
168/*
169 * when registering a cpufreq driver with this ACPI processor driver, the
170 * _PCT and _PSS structures are read out and written into struct
171 * acpi_processor_performance.
172 */
173static int acpi_processor_set_pdc (struct acpi_processor *pr)
174{
175 acpi_status status = AE_OK;
176 u32 arg0_buf[3];
177 union acpi_object arg0 = {ACPI_TYPE_BUFFER};
178 struct acpi_object_list no_object = {1, &arg0};
179 struct acpi_object_list *pdc;
180
181 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
182
183 arg0.buffer.length = 12;
184 arg0.buffer.pointer = (u8 *) arg0_buf;
185 arg0_buf[0] = ACPI_PDC_REVISION_ID;
186 arg0_buf[1] = 0;
187 arg0_buf[2] = 0;
188
189 pdc = (pr->performance->pdc) ? pr->performance->pdc : &no_object;
190
191 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);
192
193 if ((ACPI_FAILURE(status)) && (pr->performance->pdc))
194 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n"));
195
196 return_VALUE(status);
197}
198
199 168
200static int 169static int
201acpi_processor_get_performance_control ( 170acpi_processor_get_performance_control (
@@ -357,7 +326,7 @@ acpi_processor_get_performance_info (
357 if (!pr || !pr->performance || !pr->handle) 326 if (!pr || !pr->performance || !pr->handle)
358 return_VALUE(-EINVAL); 327 return_VALUE(-EINVAL);
359 328
360 acpi_processor_set_pdc(pr); 329 acpi_processor_set_pdc(pr, pr->performance->pdc);
361 330
362 status = acpi_get_handle(pr->handle, "_PCT", &handle); 331 status = acpi_get_handle(pr->handle, "_PCT", &handle);
363 if (ACPI_FAILURE(status)) { 332 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c
index 4788c079735d..55d264771c48 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/resources/rsaddr.c
@@ -77,21 +77,21 @@ acpi_rs_address16_resource (
77 u8 **output_buffer, 77 u8 **output_buffer,
78 acpi_size *structure_size) 78 acpi_size *structure_size)
79{ 79{
80 u8 *buffer = byte_stream_buffer;
81 struct acpi_resource *output_struct = (void *) *output_buffer;
82 u8 *temp_ptr;
83 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16);
84 u32 index; 80 u32 index;
85 u16 temp16; 81 u16 temp16;
86 u8 temp8; 82 u8 temp8;
83 u8 *temp_ptr;
84 u8 *buffer = byte_stream_buffer;
85 struct acpi_resource *output_struct = (void *) *output_buffer;
86 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
87 struct acpi_resource_address16);
87 88
88 89
89 ACPI_FUNCTION_TRACE ("rs_address16_resource"); 90 ACPI_FUNCTION_TRACE ("rs_address16_resource");
90 91
91 92
92 /* 93 /* Point past the Descriptor to get the number of bytes consumed */
93 * Point past the Descriptor to get the number of bytes consumed 94
94 */
95 buffer += 1; 95 buffer += 1;
96 ACPI_MOVE_16_TO_16 (&temp16, buffer); 96 ACPI_MOVE_16_TO_16 (&temp16, buffer);
97 97
@@ -104,9 +104,8 @@ acpi_rs_address16_resource (
104 *bytes_consumed = temp16 + 3; 104 *bytes_consumed = temp16 + 3;
105 output_struct->id = ACPI_RSTYPE_ADDRESS16; 105 output_struct->id = ACPI_RSTYPE_ADDRESS16;
106 106
107 /* 107 /* Get the Resource Type (Byte3) */
108 * Get the Resource Type (Byte3) 108
109 */
110 buffer += 2; 109 buffer += 2;
111 temp8 = *buffer; 110 temp8 = *buffer;
112 111
@@ -118,9 +117,8 @@ acpi_rs_address16_resource (
118 117
119 output_struct->data.address16.resource_type = temp8; 118 output_struct->data.address16.resource_type = temp8;
120 119
121 /* 120 /* Get the General Flags (Byte4) */
122 * Get the General Flags (Byte4) 121
123 */
124 buffer += 1; 122 buffer += 1;
125 temp8 = *buffer; 123 temp8 = *buffer;
126 124
@@ -140,9 +138,8 @@ acpi_rs_address16_resource (
140 138
141 output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01; 139 output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01;
142 140
143 /* 141 /* Get the Type Specific Flags (Byte5) */
144 * Get the Type Specific Flags (Byte5) 142
145 */
146 buffer += 1; 143 buffer += 1;
147 temp8 = *buffer; 144 temp8 = *buffer;
148 145
@@ -165,39 +162,34 @@ acpi_rs_address16_resource (
165 } 162 }
166 } 163 }
167 164
168 /* 165 /* Get Granularity (Bytes 6-7) */
169 * Get Granularity (Bytes 6-7) 166
170 */
171 buffer += 1; 167 buffer += 1;
172 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.granularity, buffer); 168 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.granularity, buffer);
173 169
174 /* 170 /* Get min_address_range (Bytes 8-9) */
175 * Get min_address_range (Bytes 8-9) 171
176 */
177 buffer += 2; 172 buffer += 2;
178 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.min_address_range, buffer); 173 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.min_address_range, buffer);
179 174
180 /* 175 /* Get max_address_range (Bytes 10-11) */
181 * Get max_address_range (Bytes 10-11) 176
182 */
183 buffer += 2; 177 buffer += 2;
184 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.max_address_range, buffer); 178 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.max_address_range, buffer);
185 179
186 /* 180 /* Get address_translation_offset (Bytes 12-13) */
187 * Get address_translation_offset (Bytes 12-13) 181
188 */
189 buffer += 2; 182 buffer += 2;
190 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset, buffer); 183 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset,
184 buffer);
185
186 /* Get address_length (Bytes 14-15) */
191 187
192 /*
193 * Get address_length (Bytes 14-15)
194 */
195 buffer += 2; 188 buffer += 2;
196 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_length, buffer); 189 ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_length, buffer);
197 190
198 /* 191 /* Resource Source Index (if present) */
199 * Resource Source Index (if present) 192
200 */
201 buffer += 2; 193 buffer += 2;
202 194
203 /* 195 /*
@@ -225,7 +217,8 @@ acpi_rs_address16_resource (
225 output_struct->data.address16.resource_source.string_ptr = 217 output_struct->data.address16.resource_source.string_ptr =
226 (char *)((u8 * )output_struct + struct_size); 218 (char *)((u8 * )output_struct + struct_size);
227 219
228 temp_ptr = (u8 *) output_struct->data.address16.resource_source.string_ptr; 220 temp_ptr = (u8 *)
221 output_struct->data.address16.resource_source.string_ptr;
229 222
230 /* Copy the string into the buffer */ 223 /* Copy the string into the buffer */
231 224
@@ -239,9 +232,8 @@ acpi_rs_address16_resource (
239 index += 1; 232 index += 1;
240 } 233 }
241 234
242 /* 235 /* Add the terminating null */
243 * Add the terminating null 236
244 */
245 *temp_ptr = 0x00; 237 *temp_ptr = 0x00;
246 238
247 output_struct->data.address16.resource_source.string_length = index + 1; 239 output_struct->data.address16.resource_source.string_length = index + 1;
@@ -260,14 +252,12 @@ acpi_rs_address16_resource (
260 output_struct->data.address16.resource_source.string_ptr = NULL; 252 output_struct->data.address16.resource_source.string_ptr = NULL;
261 } 253 }
262 254
263 /* 255 /* Set the Length parameter */
264 * Set the Length parameter 256
265 */
266 output_struct->length = (u32) struct_size; 257 output_struct->length = (u32) struct_size;
267 258
268 /* 259 /* Return the final size of the structure */
269 * Return the final size of the structure 260
270 */
271 *structure_size = struct_size; 261 *structure_size = struct_size;
272 return_ACPI_STATUS (AE_OK); 262 return_ACPI_STATUS (AE_OK);
273} 263}
@@ -305,28 +295,24 @@ acpi_rs_address16_stream (
305 ACPI_FUNCTION_TRACE ("rs_address16_stream"); 295 ACPI_FUNCTION_TRACE ("rs_address16_stream");
306 296
307 297
308 /* 298 /* The descriptor field is static */
309 * The descriptor field is static 299
310 */
311 *buffer = 0x88; 300 *buffer = 0x88;
312 buffer += 1; 301 buffer += 1;
313 302
314 /* 303 /* Save a pointer to the Length field - to be filled in later */
315 * Save a pointer to the Length field - to be filled in later 304
316 */
317 length_field = buffer; 305 length_field = buffer;
318 buffer += 2; 306 buffer += 2;
319 307
320 /* 308 /* Set the Resource Type (Memory, Io, bus_number) */
321 * Set the Resource Type (Memory, Io, bus_number) 309
322 */
323 temp8 = (u8) (linked_list->data.address16.resource_type & 0x03); 310 temp8 = (u8) (linked_list->data.address16.resource_type & 0x03);
324 *buffer = temp8; 311 *buffer = temp8;
325 buffer += 1; 312 buffer += 1;
326 313
327 /* 314 /* Set the general flags */
328 * Set the general flags 315
329 */
330 temp8 = (u8) (linked_list->data.address16.producer_consumer & 0x01); 316 temp8 = (u8) (linked_list->data.address16.producer_consumer & 0x01);
331 317
332 temp8 |= (linked_list->data.address16.decode & 0x01) << 1; 318 temp8 |= (linked_list->data.address16.decode & 0x01) << 1;
@@ -336,9 +322,8 @@ acpi_rs_address16_stream (
336 *buffer = temp8; 322 *buffer = temp8;
337 buffer += 1; 323 buffer += 1;
338 324
339 /* 325 /* Set the type specific flags */
340 * Set the type specific flags 326
341 */
342 temp8 = 0; 327 temp8 = 0;
343 328
344 if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) { 329 if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) {
@@ -362,39 +347,34 @@ acpi_rs_address16_stream (
362 *buffer = temp8; 347 *buffer = temp8;
363 buffer += 1; 348 buffer += 1;
364 349
365 /* 350 /* Set the address space granularity */
366 * Set the address space granularity 351
367 */
368 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.granularity); 352 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.granularity);
369 buffer += 2; 353 buffer += 2;
370 354
371 /* 355 /* Set the address range minimum */
372 * Set the address range minimum 356
373 */
374 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.min_address_range); 357 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.min_address_range);
375 buffer += 2; 358 buffer += 2;
376 359
377 /* 360 /* Set the address range maximum */
378 * Set the address range maximum 361
379 */
380 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.max_address_range); 362 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.max_address_range);
381 buffer += 2; 363 buffer += 2;
382 364
383 /* 365 /* Set the address translation offset */
384 * Set the address translation offset 366
385 */ 367 ACPI_MOVE_32_TO_16 (buffer,
386 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_translation_offset); 368 &linked_list->data.address16.address_translation_offset);
387 buffer += 2; 369 buffer += 2;
388 370
389 /* 371 /* Set the address length */
390 * Set the address length 372
391 */
392 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_length); 373 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_length);
393 buffer += 2; 374 buffer += 2;
394 375
395 /* 376 /* Resource Source Index and Resource Source are optional */
396 * Resource Source Index and Resource Source are optional 377
397 */
398 if (0 != linked_list->data.address16.resource_source.string_length) { 378 if (0 != linked_list->data.address16.resource_source.string_length) {
399 temp8 = (u8) linked_list->data.address16.resource_source.index; 379 temp8 = (u8) linked_list->data.address16.resource_source.index;
400 380
@@ -403,9 +383,8 @@ acpi_rs_address16_stream (
403 383
404 temp_pointer = (char *) buffer; 384 temp_pointer = (char *) buffer;
405 385
406 /* 386 /* Copy the string */
407 * Copy the string 387
408 */
409 ACPI_STRCPY (temp_pointer, 388 ACPI_STRCPY (temp_pointer,
410 linked_list->data.address16.resource_source.string_ptr); 389 linked_list->data.address16.resource_source.string_ptr);
411 390
@@ -413,12 +392,12 @@ acpi_rs_address16_stream (
413 * Buffer needs to be set to the length of the sting + one for the 392 * Buffer needs to be set to the length of the sting + one for the
414 * terminating null 393 * terminating null
415 */ 394 */
416 buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address16.resource_source.string_ptr) + 1); 395 buffer += (acpi_size)(ACPI_STRLEN (
396 linked_list->data.address16.resource_source.string_ptr) + 1);
417 } 397 }
418 398
419 /* 399 /* Return the number of bytes consumed in this operation */
420 * Return the number of bytes consumed in this operation 400
421 */
422 actual_bytes = ACPI_PTR_DIFF (buffer, *output_buffer); 401 actual_bytes = ACPI_PTR_DIFF (buffer, *output_buffer);
423 *bytes_consumed = actual_bytes; 402 *bytes_consumed = actual_bytes;
424 403
@@ -475,9 +454,8 @@ acpi_rs_address32_resource (
475 buffer = byte_stream_buffer; 454 buffer = byte_stream_buffer;
476 struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32); 455 struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32);
477 456
478 /* 457 /* Point past the Descriptor to get the number of bytes consumed */
479 * Point past the Descriptor to get the number of bytes consumed 458
480 */
481 buffer += 1; 459 buffer += 1;
482 ACPI_MOVE_16_TO_16 (&temp16, buffer); 460 ACPI_MOVE_16_TO_16 (&temp16, buffer);
483 461
@@ -490,9 +468,8 @@ acpi_rs_address32_resource (
490 *bytes_consumed = temp16 + 3; 468 *bytes_consumed = temp16 + 3;
491 output_struct->id = ACPI_RSTYPE_ADDRESS32; 469 output_struct->id = ACPI_RSTYPE_ADDRESS32;
492 470
493 /* 471 /* Get the Resource Type (Byte3) */
494 * Get the Resource Type (Byte3) 472
495 */
496 buffer += 2; 473 buffer += 2;
497 temp8 = *buffer; 474 temp8 = *buffer;
498 475
@@ -504,35 +481,29 @@ acpi_rs_address32_resource (
504 481
505 output_struct->data.address32.resource_type = temp8; 482 output_struct->data.address32.resource_type = temp8;
506 483
507 /* 484 /* Get the General Flags (Byte4) */
508 * Get the General Flags (Byte4) 485
509 */
510 buffer += 1; 486 buffer += 1;
511 temp8 = *buffer; 487 temp8 = *buffer;
512 488
513 /* 489 /* Producer / Consumer */
514 * Producer / Consumer 490
515 */
516 output_struct->data.address32.producer_consumer = temp8 & 0x01; 491 output_struct->data.address32.producer_consumer = temp8 & 0x01;
517 492
518 /* 493 /* Decode */
519 * Decode 494
520 */
521 output_struct->data.address32.decode = (temp8 >> 1) & 0x01; 495 output_struct->data.address32.decode = (temp8 >> 1) & 0x01;
522 496
523 /* 497 /* Min Address Fixed */
524 * Min Address Fixed 498
525 */
526 output_struct->data.address32.min_address_fixed = (temp8 >> 2) & 0x01; 499 output_struct->data.address32.min_address_fixed = (temp8 >> 2) & 0x01;
527 500
528 /* 501 /* Max Address Fixed */
529 * Max Address Fixed 502
530 */
531 output_struct->data.address32.max_address_fixed = (temp8 >> 3) & 0x01; 503 output_struct->data.address32.max_address_fixed = (temp8 >> 3) & 0x01;
532 504
533 /* 505 /* Get the Type Specific Flags (Byte5) */
534 * Get the Type Specific Flags (Byte5) 506
535 */
536 buffer += 1; 507 buffer += 1;
537 temp8 = *buffer; 508 temp8 = *buffer;
538 509
@@ -556,39 +527,34 @@ acpi_rs_address32_resource (
556 } 527 }
557 } 528 }
558 529
559 /* 530 /* Get Granularity (Bytes 6-9) */
560 * Get Granularity (Bytes 6-9) 531
561 */
562 buffer += 1; 532 buffer += 1;
563 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.granularity, buffer); 533 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.granularity, buffer);
564 534
565 /* 535 /* Get min_address_range (Bytes 10-13) */
566 * Get min_address_range (Bytes 10-13) 536
567 */
568 buffer += 4; 537 buffer += 4;
569 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.min_address_range, buffer); 538 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.min_address_range, buffer);
570 539
571 /* 540 /* Get max_address_range (Bytes 14-17) */
572 * Get max_address_range (Bytes 14-17) 541
573 */
574 buffer += 4; 542 buffer += 4;
575 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.max_address_range, buffer); 543 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.max_address_range, buffer);
576 544
577 /* 545 /* Get address_translation_offset (Bytes 18-21) */
578 * Get address_translation_offset (Bytes 18-21) 546
579 */
580 buffer += 4; 547 buffer += 4;
581 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset, buffer); 548 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset,
549 buffer);
550
551 /* Get address_length (Bytes 22-25) */
582 552
583 /*
584 * Get address_length (Bytes 22-25)
585 */
586 buffer += 4; 553 buffer += 4;
587 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_length, buffer); 554 ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_length, buffer);
588 555
589 /* 556 /* Resource Source Index (if present) */
590 * Resource Source Index (if present) 557
591 */
592 buffer += 4; 558 buffer += 4;
593 559
594 /* 560 /*
@@ -615,7 +581,8 @@ acpi_rs_address32_resource (
615 output_struct->data.address32.resource_source.string_ptr = 581 output_struct->data.address32.resource_source.string_ptr =
616 (char *)((u8 *)output_struct + struct_size); 582 (char *)((u8 *)output_struct + struct_size);
617 583
618 temp_ptr = (u8 *) output_struct->data.address32.resource_source.string_ptr; 584 temp_ptr = (u8 *)
585 output_struct->data.address32.resource_source.string_ptr;
619 586
620 /* Copy the string into the buffer */ 587 /* Copy the string into the buffer */
621 588
@@ -628,9 +595,8 @@ acpi_rs_address32_resource (
628 index += 1; 595 index += 1;
629 } 596 }
630 597
631 /* 598 /* Add the terminating null */
632 * Add the terminating null 599
633 */
634 *temp_ptr = 0x00; 600 *temp_ptr = 0x00;
635 output_struct->data.address32.resource_source.string_length = index + 1; 601 output_struct->data.address32.resource_source.string_length = index + 1;
636 602
@@ -648,14 +614,12 @@ acpi_rs_address32_resource (
648 output_struct->data.address32.resource_source.string_ptr = NULL; 614 output_struct->data.address32.resource_source.string_ptr = NULL;
649 } 615 }
650 616
651 /* 617 /* Set the Length parameter */
652 * Set the Length parameter 618
653 */
654 output_struct->length = (u32) struct_size; 619 output_struct->length = (u32) struct_size;
655 620
656 /* 621 /* Return the final size of the structure */
657 * Return the final size of the structure 622
658 */
659 *structure_size = struct_size; 623 *structure_size = struct_size;
660 return_ACPI_STATUS (AE_OK); 624 return_ACPI_STATUS (AE_OK);
661} 625}
@@ -694,29 +658,25 @@ acpi_rs_address32_stream (
694 658
695 buffer = *output_buffer; 659 buffer = *output_buffer;
696 660
697 /* 661 /* The descriptor field is static */
698 * The descriptor field is static 662
699 */
700 *buffer = 0x87; 663 *buffer = 0x87;
701 buffer += 1; 664 buffer += 1;
702 665
703 /* 666 /* Set a pointer to the Length field - to be filled in later */
704 * Set a pointer to the Length field - to be filled in later 667
705 */
706 length_field = ACPI_CAST_PTR (u16, buffer); 668 length_field = ACPI_CAST_PTR (u16, buffer);
707 buffer += 2; 669 buffer += 2;
708 670
709 /* 671 /* Set the Resource Type (Memory, Io, bus_number) */
710 * Set the Resource Type (Memory, Io, bus_number) 672
711 */
712 temp8 = (u8) (linked_list->data.address32.resource_type & 0x03); 673 temp8 = (u8) (linked_list->data.address32.resource_type & 0x03);
713 674
714 *buffer = temp8; 675 *buffer = temp8;
715 buffer += 1; 676 buffer += 1;
716 677
717 /* 678 /* Set the general flags */
718 * Set the general flags 679
719 */
720 temp8 = (u8) (linked_list->data.address32.producer_consumer & 0x01); 680 temp8 = (u8) (linked_list->data.address32.producer_consumer & 0x01);
721 temp8 |= (linked_list->data.address32.decode & 0x01) << 1; 681 temp8 |= (linked_list->data.address32.decode & 0x01) << 1;
722 temp8 |= (linked_list->data.address32.min_address_fixed & 0x01) << 2; 682 temp8 |= (linked_list->data.address32.min_address_fixed & 0x01) << 2;
@@ -725,9 +685,8 @@ acpi_rs_address32_stream (
725 *buffer = temp8; 685 *buffer = temp8;
726 buffer += 1; 686 buffer += 1;
727 687
728 /* 688 /* Set the type specific flags */
729 * Set the type specific flags 689
730 */
731 temp8 = 0; 690 temp8 = 0;
732 691
733 if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) { 692 if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) {
@@ -751,39 +710,34 @@ acpi_rs_address32_stream (
751 *buffer = temp8; 710 *buffer = temp8;
752 buffer += 1; 711 buffer += 1;
753 712
754 /* 713 /* Set the address space granularity */
755 * Set the address space granularity 714
756 */
757 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.granularity); 715 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.granularity);
758 buffer += 4; 716 buffer += 4;
759 717
760 /* 718 /* Set the address range minimum */
761 * Set the address range minimum 719
762 */
763 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.min_address_range); 720 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.min_address_range);
764 buffer += 4; 721 buffer += 4;
765 722
766 /* 723 /* Set the address range maximum */
767 * Set the address range maximum 724
768 */
769 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.max_address_range); 725 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.max_address_range);
770 buffer += 4; 726 buffer += 4;
771 727
772 /* 728 /* Set the address translation offset */
773 * Set the address translation offset 729
774 */ 730 ACPI_MOVE_32_TO_32 (buffer,
775 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_translation_offset); 731 &linked_list->data.address32.address_translation_offset);
776 buffer += 4; 732 buffer += 4;
777 733
778 /* 734 /* Set the address length */
779 * Set the address length 735
780 */
781 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_length); 736 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_length);
782 buffer += 4; 737 buffer += 4;
783 738
784 /* 739 /* Resource Source Index and Resource Source are optional */
785 * Resource Source Index and Resource Source are optional 740
786 */
787 if (0 != linked_list->data.address32.resource_source.string_length) { 741 if (0 != linked_list->data.address32.resource_source.string_length) {
788 temp8 = (u8) linked_list->data.address32.resource_source.index; 742 temp8 = (u8) linked_list->data.address32.resource_source.index;
789 743
@@ -792,9 +746,8 @@ acpi_rs_address32_stream (
792 746
793 temp_pointer = (char *) buffer; 747 temp_pointer = (char *) buffer;
794 748
795 /* 749 /* Copy the string */
796 * Copy the string 750
797 */
798 ACPI_STRCPY (temp_pointer, 751 ACPI_STRCPY (temp_pointer,
799 linked_list->data.address32.resource_source.string_ptr); 752 linked_list->data.address32.resource_source.string_ptr);
800 753
@@ -802,12 +755,12 @@ acpi_rs_address32_stream (
802 * Buffer needs to be set to the length of the sting + one for the 755 * Buffer needs to be set to the length of the sting + one for the
803 * terminating null 756 * terminating null
804 */ 757 */
805 buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address32.resource_source.string_ptr) + 1); 758 buffer += (acpi_size)(ACPI_STRLEN (
759 linked_list->data.address32.resource_source.string_ptr) + 1);
806 } 760 }
807 761
808 /* 762 /* Return the number of bytes consumed in this operation */
809 * Return the number of bytes consumed in this operation 763
810 */
811 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 764 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
812 765
813 /* 766 /*
@@ -864,9 +817,8 @@ acpi_rs_address64_resource (
864 struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64); 817 struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64);
865 resource_type = *buffer; 818 resource_type = *buffer;
866 819
867 /* 820 /* Point past the Descriptor to get the number of bytes consumed */
868 * Point past the Descriptor to get the number of bytes consumed 821
869 */
870 buffer += 1; 822 buffer += 1;
871 ACPI_MOVE_16_TO_16 (&temp16, buffer); 823 ACPI_MOVE_16_TO_16 (&temp16, buffer);
872 824
@@ -879,9 +831,8 @@ acpi_rs_address64_resource (
879 *bytes_consumed = temp16 + 3; 831 *bytes_consumed = temp16 + 3;
880 output_struct->id = ACPI_RSTYPE_ADDRESS64; 832 output_struct->id = ACPI_RSTYPE_ADDRESS64;
881 833
882 /* 834 /* Get the Resource Type (Byte3) */
883 * Get the Resource Type (Byte3) 835
884 */
885 buffer += 2; 836 buffer += 2;
886 temp8 = *buffer; 837 temp8 = *buffer;
887 838
@@ -893,35 +844,29 @@ acpi_rs_address64_resource (
893 844
894 output_struct->data.address64.resource_type = temp8; 845 output_struct->data.address64.resource_type = temp8;
895 846
896 /* 847 /* Get the General Flags (Byte4) */
897 * Get the General Flags (Byte4) 848
898 */
899 buffer += 1; 849 buffer += 1;
900 temp8 = *buffer; 850 temp8 = *buffer;
901 851
902 /* 852 /* Producer / Consumer */
903 * Producer / Consumer 853
904 */
905 output_struct->data.address64.producer_consumer = temp8 & 0x01; 854 output_struct->data.address64.producer_consumer = temp8 & 0x01;
906 855
907 /* 856 /* Decode */
908 * Decode 857
909 */
910 output_struct->data.address64.decode = (temp8 >> 1) & 0x01; 858 output_struct->data.address64.decode = (temp8 >> 1) & 0x01;
911 859
912 /* 860 /* Min Address Fixed */
913 * Min Address Fixed 861
914 */
915 output_struct->data.address64.min_address_fixed = (temp8 >> 2) & 0x01; 862 output_struct->data.address64.min_address_fixed = (temp8 >> 2) & 0x01;
916 863
917 /* 864 /* Max Address Fixed */
918 * Max Address Fixed 865
919 */
920 output_struct->data.address64.max_address_fixed = (temp8 >> 3) & 0x01; 866 output_struct->data.address64.max_address_fixed = (temp8 >> 3) & 0x01;
921 867
922 /* 868 /* Get the Type Specific Flags (Byte5) */
923 * Get the Type Specific Flags (Byte5) 869
924 */
925 buffer += 1; 870 buffer += 1;
926 temp8 = *buffer; 871 temp8 = *buffer;
927 872
@@ -951,33 +896,29 @@ acpi_rs_address64_resource (
951 buffer += 2; 896 buffer += 2;
952 } 897 }
953 898
954 /* 899 /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */
955 * Get Granularity (Bytes 6-13) or (Bytes 8-15) 900
956 */
957 buffer += 1; 901 buffer += 1;
958 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.granularity, buffer); 902 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.granularity, buffer);
959 903
960 /* 904 /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */
961 * Get min_address_range (Bytes 14-21) or (Bytes 16-23) 905
962 */
963 buffer += 8; 906 buffer += 8;
964 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.min_address_range, buffer); 907 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.min_address_range, buffer);
965 908
966 /* 909 /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */
967 * Get max_address_range (Bytes 22-29) or (Bytes 24-31) 910
968 */
969 buffer += 8; 911 buffer += 8;
970 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.max_address_range, buffer); 912 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.max_address_range, buffer);
971 913
972 /* 914 /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */
973 * Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) 915
974 */
975 buffer += 8; 916 buffer += 8;
976 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset, buffer); 917 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset,
918 buffer);
919
920 /* Get address_length (Bytes 38-45) or (Bytes 40-47) */
977 921
978 /*
979 * Get address_length (Bytes 38-45) or (Bytes 40-47)
980 */
981 buffer += 8; 922 buffer += 8;
982 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_length, buffer); 923 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_length, buffer);
983 924
@@ -989,14 +930,15 @@ acpi_rs_address64_resource (
989 /* Get type_specific_attribute (Bytes 48-55) */ 930 /* Get type_specific_attribute (Bytes 48-55) */
990 931
991 buffer += 8; 932 buffer += 8;
992 ACPI_MOVE_64_TO_64 (&output_struct->data.address64.type_specific_attributes, buffer); 933 ACPI_MOVE_64_TO_64 (
934 &output_struct->data.address64.type_specific_attributes,
935 buffer);
993 } 936 }
994 else { 937 else {
995 output_struct->data.address64.type_specific_attributes = 0; 938 output_struct->data.address64.type_specific_attributes = 0;
996 939
997 /* 940 /* Resource Source Index (if present) */
998 * Resource Source Index (if present) 941
999 */
1000 buffer += 8; 942 buffer += 8;
1001 943
1002 /* 944 /*
@@ -1025,7 +967,8 @@ acpi_rs_address64_resource (
1025 output_struct->data.address64.resource_source.string_ptr = 967 output_struct->data.address64.resource_source.string_ptr =
1026 (char *)((u8 *)output_struct + struct_size); 968 (char *)((u8 *)output_struct + struct_size);
1027 969
1028 temp_ptr = (u8 *) output_struct->data.address64.resource_source.string_ptr; 970 temp_ptr = (u8 *)
971 output_struct->data.address64.resource_source.string_ptr;
1029 972
1030 /* Copy the string into the buffer */ 973 /* Copy the string into the buffer */
1031 974
@@ -1042,7 +985,8 @@ acpi_rs_address64_resource (
1042 * Add the terminating null 985 * Add the terminating null
1043 */ 986 */
1044 *temp_ptr = 0x00; 987 *temp_ptr = 0x00;
1045 output_struct->data.address64.resource_source.string_length = index + 1; 988 output_struct->data.address64.resource_source.string_length =
989 index + 1;
1046 990
1047 /* 991 /*
1048 * In order for the struct_size to fall on a 32-bit boundary, 992 * In order for the struct_size to fall on a 32-bit boundary,
@@ -1054,14 +998,12 @@ acpi_rs_address64_resource (
1054 } 998 }
1055 } 999 }
1056 1000
1057 /* 1001 /* Set the Length parameter */
1058 * Set the Length parameter 1002
1059 */
1060 output_struct->length = (u32) struct_size; 1003 output_struct->length = (u32) struct_size;
1061 1004
1062 /* 1005 /* Return the final size of the structure */
1063 * Return the final size of the structure 1006
1064 */
1065 *structure_size = struct_size; 1007 *structure_size = struct_size;
1066 return_ACPI_STATUS (AE_OK); 1008 return_ACPI_STATUS (AE_OK);
1067} 1009}
@@ -1100,29 +1042,25 @@ acpi_rs_address64_stream (
1100 1042
1101 buffer = *output_buffer; 1043 buffer = *output_buffer;
1102 1044
1103 /* 1045 /* The descriptor field is static */
1104 * The descriptor field is static 1046
1105 */
1106 *buffer = 0x8A; 1047 *buffer = 0x8A;
1107 buffer += 1; 1048 buffer += 1;
1108 1049
1109 /* 1050 /* Set a pointer to the Length field - to be filled in later */
1110 * Set a pointer to the Length field - to be filled in later 1051
1111 */
1112 length_field = ACPI_CAST_PTR (u16, buffer); 1052 length_field = ACPI_CAST_PTR (u16, buffer);
1113 buffer += 2; 1053 buffer += 2;
1114 1054
1115 /* 1055 /* Set the Resource Type (Memory, Io, bus_number) */
1116 * Set the Resource Type (Memory, Io, bus_number) 1056
1117 */
1118 temp8 = (u8) (linked_list->data.address64.resource_type & 0x03); 1057 temp8 = (u8) (linked_list->data.address64.resource_type & 0x03);
1119 1058
1120 *buffer = temp8; 1059 *buffer = temp8;
1121 buffer += 1; 1060 buffer += 1;
1122 1061
1123 /* 1062 /* Set the general flags */
1124 * Set the general flags 1063
1125 */
1126 temp8 = (u8) (linked_list->data.address64.producer_consumer & 0x01); 1064 temp8 = (u8) (linked_list->data.address64.producer_consumer & 0x01);
1127 temp8 |= (linked_list->data.address64.decode & 0x01) << 1; 1065 temp8 |= (linked_list->data.address64.decode & 0x01) << 1;
1128 temp8 |= (linked_list->data.address64.min_address_fixed & 0x01) << 2; 1066 temp8 |= (linked_list->data.address64.min_address_fixed & 0x01) << 2;
@@ -1131,9 +1069,8 @@ acpi_rs_address64_stream (
1131 *buffer = temp8; 1069 *buffer = temp8;
1132 buffer += 1; 1070 buffer += 1;
1133 1071
1134 /* 1072 /* Set the type specific flags */
1135 * Set the type specific flags 1073
1136 */
1137 temp8 = 0; 1074 temp8 = 0;
1138 1075
1139 if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) { 1076 if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) {
@@ -1157,39 +1094,34 @@ acpi_rs_address64_stream (
1157 *buffer = temp8; 1094 *buffer = temp8;
1158 buffer += 1; 1095 buffer += 1;
1159 1096
1160 /* 1097 /* Set the address space granularity */
1161 * Set the address space granularity 1098
1162 */
1163 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.granularity); 1099 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.granularity);
1164 buffer += 8; 1100 buffer += 8;
1165 1101
1166 /* 1102 /* Set the address range minimum */
1167 * Set the address range minimum 1103
1168 */
1169 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.min_address_range); 1104 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.min_address_range);
1170 buffer += 8; 1105 buffer += 8;
1171 1106
1172 /* 1107 /* Set the address range maximum */
1173 * Set the address range maximum 1108
1174 */
1175 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.max_address_range); 1109 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.max_address_range);
1176 buffer += 8; 1110 buffer += 8;
1177 1111
1178 /* 1112 /* Set the address translation offset */
1179 * Set the address translation offset 1113
1180 */ 1114 ACPI_MOVE_64_TO_64 (buffer,
1181 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_translation_offset); 1115 &linked_list->data.address64.address_translation_offset);
1182 buffer += 8; 1116 buffer += 8;
1183 1117
1184 /* 1118 /* Set the address length */
1185 * Set the address length 1119
1186 */
1187 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_length); 1120 ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_length);
1188 buffer += 8; 1121 buffer += 8;
1189 1122
1190 /* 1123 /* Resource Source Index and Resource Source are optional */
1191 * Resource Source Index and Resource Source are optional 1124
1192 */
1193 if (0 != linked_list->data.address64.resource_source.string_length) { 1125 if (0 != linked_list->data.address64.resource_source.string_length) {
1194 temp8 = (u8) linked_list->data.address64.resource_source.index; 1126 temp8 = (u8) linked_list->data.address64.resource_source.index;
1195 1127
@@ -1198,21 +1130,21 @@ acpi_rs_address64_stream (
1198 1130
1199 temp_pointer = (char *) buffer; 1131 temp_pointer = (char *) buffer;
1200 1132
1201 /* 1133 /* Copy the string */
1202 * Copy the string 1134
1203 */ 1135 ACPI_STRCPY (temp_pointer,
1204 ACPI_STRCPY (temp_pointer, linked_list->data.address64.resource_source.string_ptr); 1136 linked_list->data.address64.resource_source.string_ptr);
1205 1137
1206 /* 1138 /*
1207 * Buffer needs to be set to the length of the sting + one for the 1139 * Buffer needs to be set to the length of the sting + one for the
1208 * terminating null 1140 * terminating null
1209 */ 1141 */
1210 buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address64.resource_source.string_ptr) + 1); 1142 buffer += (acpi_size)(ACPI_STRLEN (
1143 linked_list->data.address64.resource_source.string_ptr) + 1);
1211 } 1144 }
1212 1145
1213 /* 1146 /* Return the number of bytes consumed in this operation */
1214 * Return the number of bytes consumed in this operation 1147
1215 */
1216 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 1148 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
1217 1149
1218 /* 1150 /*
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index 8a5f0a52371d..98176f2fcb5d 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -81,9 +81,8 @@ acpi_rs_get_byte_stream_length (
81 81
82 82
83 while (!done) { 83 while (!done) {
84 /* 84 /* Init the variable that will hold the size to add to the total. */
85 * Init the variable that will hold the size to add to the total. 85
86 */
87 segment_size = 0; 86 segment_size = 0;
88 87
89 switch (linked_list->id) { 88 switch (linked_list->id) {
@@ -196,7 +195,8 @@ acpi_rs_get_byte_stream_length (
196 segment_size = 16; 195 segment_size = 16;
197 196
198 if (linked_list->data.address16.resource_source.string_ptr) { 197 if (linked_list->data.address16.resource_source.string_ptr) {
199 segment_size += linked_list->data.address16.resource_source.string_length; 198 segment_size +=
199 linked_list->data.address16.resource_source.string_length;
200 segment_size++; 200 segment_size++;
201 } 201 }
202 break; 202 break;
@@ -212,7 +212,8 @@ acpi_rs_get_byte_stream_length (
212 segment_size = 26; 212 segment_size = 26;
213 213
214 if (linked_list->data.address32.resource_source.string_ptr) { 214 if (linked_list->data.address32.resource_source.string_ptr) {
215 segment_size += linked_list->data.address32.resource_source.string_length; 215 segment_size +=
216 linked_list->data.address32.resource_source.string_length;
216 segment_size++; 217 segment_size++;
217 } 218 }
218 break; 219 break;
@@ -227,7 +228,8 @@ acpi_rs_get_byte_stream_length (
227 segment_size = 46; 228 segment_size = 46;
228 229
229 if (linked_list->data.address64.resource_source.string_ptr) { 230 if (linked_list->data.address64.resource_source.string_ptr) {
230 segment_size += linked_list->data.address64.resource_source.string_length; 231 segment_size +=
232 linked_list->data.address64.resource_source.string_length;
231 segment_size++; 233 segment_size++;
232 } 234 }
233 break; 235 break;
@@ -241,38 +243,36 @@ acpi_rs_get_byte_stream_length (
241 * Index + the length of the null terminated string 243 * Index + the length of the null terminated string
242 * Resource Source + 1 for the null. 244 * Resource Source + 1 for the null.
243 */ 245 */
244 segment_size = 9 + 246 segment_size = 9 + (((acpi_size)
245 (((acpi_size) linked_list->data.extended_irq.number_of_interrupts - 1) * 4); 247 linked_list->data.extended_irq.number_of_interrupts - 1) * 4);
246 248
247 if (linked_list->data.extended_irq.resource_source.string_ptr) { 249 if (linked_list->data.extended_irq.resource_source.string_ptr) {
248 segment_size += linked_list->data.extended_irq.resource_source.string_length; 250 segment_size +=
251 linked_list->data.extended_irq.resource_source.string_length;
249 segment_size++; 252 segment_size++;
250 } 253 }
251 break; 254 break;
252 255
253 default: 256 default:
254 /* 257
255 * If we get here, everything is out of sync, exit with error 258 /* If we get here, everything is out of sync, exit with error */
256 */ 259
257 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 260 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
258 261
259 } /* switch (linked_list->Id) */ 262 } /* switch (linked_list->Id) */
260 263
261 /* 264 /* Update the total */
262 * Update the total 265
263 */
264 byte_stream_size_needed += segment_size; 266 byte_stream_size_needed += segment_size;
265 267
266 /* 268 /* Point to the next object */
267 * Point to the next object 269
268 */
269 linked_list = ACPI_PTR_ADD (struct acpi_resource, 270 linked_list = ACPI_PTR_ADD (struct acpi_resource,
270 linked_list, linked_list->length); 271 linked_list, linked_list->length);
271 } 272 }
272 273
273 /* 274 /* This is the data the caller needs */
274 * This is the data the caller needs 275
275 */
276 *size_needed = byte_stream_size_needed; 276 *size_needed = byte_stream_size_needed;
277 return_ACPI_STATUS (AE_OK); 277 return_ACPI_STATUS (AE_OK);
278} 278}
@@ -320,9 +320,8 @@ acpi_rs_get_list_length (
320 320
321 321
322 while (bytes_parsed < byte_stream_buffer_length) { 322 while (bytes_parsed < byte_stream_buffer_length) {
323 /* 323 /* The next byte in the stream is the resource type */
324 * The next byte in the stream is the resource type 324
325 */
326 resource_type = acpi_rs_get_resource_type (*byte_stream_buffer); 325 resource_type = acpi_rs_get_resource_type (*byte_stream_buffer);
327 326
328 switch (resource_type) { 327 switch (resource_type) {
@@ -346,9 +345,8 @@ acpi_rs_get_list_length (
346 ACPI_MOVE_16_TO_16 (&temp16, buffer); 345 ACPI_MOVE_16_TO_16 (&temp16, buffer);
347 bytes_consumed = temp16 + 3; 346 bytes_consumed = temp16 + 3;
348 347
349 /* 348 /* Ensure a 32-bit boundary for the structure */
350 * Ensure a 32-bit boundary for the structure 349
351 */
352 temp16 = (u16) ACPI_ROUND_UP_to_32_bITS (temp16); 350 temp16 = (u16) ACPI_ROUND_UP_to_32_bITS (temp16);
353 351
354 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) + 352 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) +
@@ -416,9 +414,8 @@ acpi_rs_get_list_length (
416 temp8 = 0; 414 temp8 = 0;
417 } 415 }
418 416
419 /* 417 /* Ensure a 64-bit boundary for the structure */
420 * Ensure a 64-bit boundary for the structure 418
421 */
422 temp8 = (u8) ACPI_ROUND_UP_to_64_bITS (temp8); 419 temp8 = (u8) ACPI_ROUND_UP_to_64_bITS (temp8);
423 420
424 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64) + 421 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64) +
@@ -452,9 +449,8 @@ acpi_rs_get_list_length (
452 temp8 = 0; 449 temp8 = 0;
453 } 450 }
454 451
455 /* 452 /* Ensure a 32-bit boundary for the structure */
456 * Ensure a 32-bit boundary for the structure 453
457 */
458 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); 454 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
459 455
460 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32) + 456 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32) +
@@ -488,9 +484,8 @@ acpi_rs_get_list_length (
488 temp8 = 0; 484 temp8 = 0;
489 } 485 }
490 486
491 /* 487 /* Ensure a 32-bit boundary for the structure */
492 * Ensure a 32-bit boundary for the structure 488
493 */
494 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); 489 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
495 490
496 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16) + 491 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16) +
@@ -537,9 +532,8 @@ acpi_rs_get_list_length (
537 temp8 = 0; 532 temp8 = 0;
538 } 533 }
539 534
540 /* 535 /* Ensure a 32-bit boundary for the structure */
541 * Ensure a 32-bit boundary for the structure 536
542 */
543 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); 537 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
544 538
545 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq) + 539 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq) +
@@ -567,9 +561,8 @@ acpi_rs_get_list_length (
567 561
568 ++buffer; 562 ++buffer;
569 563
570 /* 564 /* Look at the number of bits set */
571 * Look at the number of bits set 565
572 */
573 ACPI_MOVE_16_TO_16 (&temp16, buffer); 566 ACPI_MOVE_16_TO_16 (&temp16, buffer);
574 567
575 for (index = 0; index < 16; index++) { 568 for (index = 0; index < 16; index++) {
@@ -596,9 +589,8 @@ acpi_rs_get_list_length (
596 589
597 ++buffer; 590 ++buffer;
598 591
599 /* 592 /* Look at the number of bits set */
600 * Look at the number of bits set 593
601 */
602 temp8 = *buffer; 594 temp8 = *buffer;
603 595
604 for(index = 0; index < 8; index++) { 596 for(index = 0; index < 8; index++) {
@@ -670,9 +662,8 @@ acpi_rs_get_list_length (
670 temp8 = (u8) (temp8 & 0x7); 662 temp8 = (u8) (temp8 & 0x7);
671 bytes_consumed = temp8 + 1; 663 bytes_consumed = temp8 + 1;
672 664
673 /* 665 /* Ensure a 32-bit boundary for the structure */
674 * Ensure a 32-bit boundary for the structure 666
675 */
676 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8); 667 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
677 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) + 668 structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) +
678 (temp8 * sizeof (u8)); 669 (temp8 * sizeof (u8));
@@ -697,21 +688,18 @@ acpi_rs_get_list_length (
697 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 688 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
698 } 689 }
699 690
700 /* 691 /* Update the return value and counter */
701 * Update the return value and counter 692
702 */
703 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE (structure_size); 693 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE (structure_size);
704 bytes_parsed += bytes_consumed; 694 bytes_parsed += bytes_consumed;
705 695
706 /* 696 /* Set the byte stream to point to the next resource */
707 * Set the byte stream to point to the next resource 697
708 */
709 byte_stream_buffer += bytes_consumed; 698 byte_stream_buffer += bytes_consumed;
710 } 699 }
711 700
712 /* 701 /* This is the data the caller needs */
713 * This is the data the caller needs 702
714 */
715 *size_needed = buffer_size; 703 *size_needed = buffer_size;
716 return_ACPI_STATUS (AE_OK); 704 return_ACPI_STATUS (AE_OK);
717} 705}
@@ -767,9 +755,8 @@ acpi_rs_get_pci_routing_table_length (
767 top_object_list = package_object->package.elements; 755 top_object_list = package_object->package.elements;
768 756
769 for (index = 0; index < number_of_elements; index++) { 757 for (index = 0; index < number_of_elements; index++) {
770 /* 758 /* Dereference the sub-package */
771 * Dereference the sub-package 759
772 */
773 package_element = *top_object_list; 760 package_element = *top_object_list;
774 761
775 /* 762 /*
@@ -778,37 +765,40 @@ acpi_rs_get_pci_routing_table_length (
778 */ 765 */
779 sub_object_list = package_element->package.elements; 766 sub_object_list = package_element->package.elements;
780 767
781 /* 768 /* Scan the irq_table_elements for the Source Name String */
782 * Scan the irq_table_elements for the Source Name String 769
783 */
784 name_found = FALSE; 770 name_found = FALSE;
785 771
786 for (table_index = 0; table_index < 4 && !name_found; table_index++) { 772 for (table_index = 0; table_index < 4 && !name_found; table_index++) {
787 if ((ACPI_TYPE_STRING == ACPI_GET_OBJECT_TYPE (*sub_object_list)) || 773 if ((ACPI_TYPE_STRING ==
788 ((ACPI_TYPE_LOCAL_REFERENCE == ACPI_GET_OBJECT_TYPE (*sub_object_list)) && 774 ACPI_GET_OBJECT_TYPE (*sub_object_list)) ||
789 ((*sub_object_list)->reference.opcode == AML_INT_NAMEPATH_OP))) { 775
776 ((ACPI_TYPE_LOCAL_REFERENCE ==
777 ACPI_GET_OBJECT_TYPE (*sub_object_list)) &&
778
779 ((*sub_object_list)->reference.opcode ==
780 AML_INT_NAMEPATH_OP))) {
790 name_found = TRUE; 781 name_found = TRUE;
791 } 782 }
792 else { 783 else {
793 /* 784 /* Look at the next element */
794 * Look at the next element 785
795 */
796 sub_object_list++; 786 sub_object_list++;
797 } 787 }
798 } 788 }
799 789
800 temp_size_needed += (sizeof (struct acpi_pci_routing_table) - 4); 790 temp_size_needed += (sizeof (struct acpi_pci_routing_table) - 4);
801 791
802 /* 792 /* Was a String type found? */
803 * Was a String type found? 793
804 */
805 if (name_found) { 794 if (name_found) {
806 if (ACPI_GET_OBJECT_TYPE (*sub_object_list) == ACPI_TYPE_STRING) { 795 if (ACPI_GET_OBJECT_TYPE (*sub_object_list) == ACPI_TYPE_STRING) {
807 /* 796 /*
808 * The length String.Length field does not include the 797 * The length String.Length field does not include the
809 * terminating NULL, add 1 798 * terminating NULL, add 1
810 */ 799 */
811 temp_size_needed += ((acpi_size) (*sub_object_list)->string.length + 1); 800 temp_size_needed += ((acpi_size)
801 (*sub_object_list)->string.length + 1);
812 } 802 }
813 else { 803 else {
814 temp_size_needed += acpi_ns_get_pathname_length ( 804 temp_size_needed += acpi_ns_get_pathname_length (
@@ -827,14 +817,14 @@ acpi_rs_get_pci_routing_table_length (
827 817
828 temp_size_needed = ACPI_ROUND_UP_to_64_bITS (temp_size_needed); 818 temp_size_needed = ACPI_ROUND_UP_to_64_bITS (temp_size_needed);
829 819
830 /* 820 /* Point to the next union acpi_operand_object */
831 * Point to the next union acpi_operand_object 821
832 */
833 top_object_list++; 822 top_object_list++;
834 } 823 }
835 824
836 /* 825 /*
837 * Adding an extra element to the end of the list, essentially a NULL terminator 826 * Adding an extra element to the end of the list, essentially a
827 * NULL terminator
838 */ 828 */
839 *buffer_size_needed = temp_size_needed + sizeof (struct acpi_pci_routing_table); 829 *buffer_size_needed = temp_size_needed + sizeof (struct acpi_pci_routing_table);
840 return_ACPI_STATUS (AE_OK); 830 return_ACPI_STATUS (AE_OK);
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c
index a3a0cbfda68d..8e0eae0d50bb 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/resources/rscreate.c
@@ -87,9 +87,8 @@ acpi_rs_create_resource_list (
87 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_buffer = %p\n", 87 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_buffer = %p\n",
88 byte_stream_buffer)); 88 byte_stream_buffer));
89 89
90 /* 90 /* Params already validated, so we don't re-validate here */
91 * Params already validated, so we don't re-validate here 91
92 */
93 byte_stream_buffer_length = byte_stream_buffer->buffer.length; 92 byte_stream_buffer_length = byte_stream_buffer->buffer.length;
94 byte_stream_start = byte_stream_buffer->buffer.pointer; 93 byte_stream_start = byte_stream_buffer->buffer.pointer;
95 94
@@ -171,9 +170,8 @@ acpi_rs_create_pci_routing_table (
171 170
172 /* Params already validated, so we don't re-validate here */ 171 /* Params already validated, so we don't re-validate here */
173 172
174 /* 173 /* Get the required buffer length */
175 * Get the required buffer length 174
176 */
177 status = acpi_rs_get_pci_routing_table_length (package_object, 175 status = acpi_rs_get_pci_routing_table_length (package_object,
178 &buffer_size_needed); 176 &buffer_size_needed);
179 if (ACPI_FAILURE (status)) { 177 if (ACPI_FAILURE (status)) {
@@ -217,9 +215,8 @@ acpi_rs_create_pci_routing_table (
217 */ 215 */
218 user_prt->length = (sizeof (struct acpi_pci_routing_table) - 4); 216 user_prt->length = (sizeof (struct acpi_pci_routing_table) - 4);
219 217
220 /* 218 /* Each element of the top-level package must also be a package */
221 * Each element of the top-level package must also be a package 219
222 */
223 if (ACPI_GET_OBJECT_TYPE (*top_object_list) != ACPI_TYPE_PACKAGE) { 220 if (ACPI_GET_OBJECT_TYPE (*top_object_list) != ACPI_TYPE_PACKAGE) {
224 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 221 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
225 "(PRT[%X]) Need sub-package, found %s\n", 222 "(PRT[%X]) Need sub-package, found %s\n",
@@ -243,9 +240,8 @@ acpi_rs_create_pci_routing_table (
243 */ 240 */
244 sub_object_list = (*top_object_list)->package.elements; 241 sub_object_list = (*top_object_list)->package.elements;
245 242
246 /* 243 /* 1) First subobject: Dereference the PRT.Address */
247 * 1) First subobject: Dereference the PRT.Address 244
248 */
249 obj_desc = sub_object_list[0]; 245 obj_desc = sub_object_list[0];
250 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 246 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
251 user_prt->address = obj_desc->integer.value; 247 user_prt->address = obj_desc->integer.value;
@@ -257,9 +253,8 @@ acpi_rs_create_pci_routing_table (
257 return_ACPI_STATUS (AE_BAD_DATA); 253 return_ACPI_STATUS (AE_BAD_DATA);
258 } 254 }
259 255
260 /* 256 /* 2) Second subobject: Dereference the PRT.Pin */
261 * 2) Second subobject: Dereference the PRT.Pin 257
262 */
263 obj_desc = sub_object_list[1]; 258 obj_desc = sub_object_list[1];
264 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 259 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
265 user_prt->pin = (u32) obj_desc->integer.value; 260 user_prt->pin = (u32) obj_desc->integer.value;
@@ -271,9 +266,8 @@ acpi_rs_create_pci_routing_table (
271 return_ACPI_STATUS (AE_BAD_DATA); 266 return_ACPI_STATUS (AE_BAD_DATA);
272 } 267 }
273 268
274 /* 269 /* 3) Third subobject: Dereference the PRT.source_name */
275 * 3) Third subobject: Dereference the PRT.source_name 270
276 */
277 obj_desc = sub_object_list[2]; 271 obj_desc = sub_object_list[2];
278 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { 272 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
279 case ACPI_TYPE_LOCAL_REFERENCE: 273 case ACPI_TYPE_LOCAL_REFERENCE:
@@ -296,7 +290,9 @@ acpi_rs_create_pci_routing_table (
296 290
297 status = acpi_ns_handle_to_pathname ((acpi_handle) node, &path_buffer); 291 status = acpi_ns_handle_to_pathname ((acpi_handle) node, &path_buffer);
298 292
299 user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1; /* include null terminator */ 293 /* +1 to include null terminator */
294
295 user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1;
300 break; 296 break;
301 297
302 298
@@ -304,8 +300,10 @@ acpi_rs_create_pci_routing_table (
304 300
305 ACPI_STRCPY (user_prt->source, obj_desc->string.pointer); 301 ACPI_STRCPY (user_prt->source, obj_desc->string.pointer);
306 302
307 /* Add to the Length field the length of the string (add 1 for terminator) */ 303 /*
308 304 * Add to the Length field the length of the string
305 * (add 1 for terminator)
306 */
309 user_prt->length += obj_desc->string.length + 1; 307 user_prt->length += obj_desc->string.length + 1;
310 break; 308 break;
311 309
@@ -333,9 +331,8 @@ acpi_rs_create_pci_routing_table (
333 331
334 user_prt->length = (u32) ACPI_ROUND_UP_to_64_bITS (user_prt->length); 332 user_prt->length = (u32) ACPI_ROUND_UP_to_64_bITS (user_prt->length);
335 333
336 /* 334 /* 4) Fourth subobject: Dereference the PRT.source_index */
337 * 4) Fourth subobject: Dereference the PRT.source_index 335
338 */
339 obj_desc = sub_object_list[3]; 336 obj_desc = sub_object_list[3];
340 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 337 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
341 user_prt->source_index = (u32) obj_desc->integer.value; 338 user_prt->source_index = (u32) obj_desc->integer.value;
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c
index eef1b1f2c685..1935dab2ab51 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -48,9 +48,62 @@
48#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsdump") 49 ACPI_MODULE_NAME ("rsdump")
50 50
51/* Local prototypes */
51 52
52#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 53static void
54acpi_rs_dump_irq (
55 union acpi_resource_data *data);
56
57static void
58acpi_rs_dump_address16 (
59 union acpi_resource_data *data);
60
61static void
62acpi_rs_dump_address32 (
63 union acpi_resource_data *data);
64
65static void
66acpi_rs_dump_address64 (
67 union acpi_resource_data *data);
68
69static void
70acpi_rs_dump_dma (
71 union acpi_resource_data *data);
72
73static void
74acpi_rs_dump_io (
75 union acpi_resource_data *data);
76
77static void
78acpi_rs_dump_extended_irq (
79 union acpi_resource_data *data);
53 80
81static void
82acpi_rs_dump_fixed_io (
83 union acpi_resource_data *data);
84
85static void
86acpi_rs_dump_fixed_memory32 (
87 union acpi_resource_data *data);
88
89static void
90acpi_rs_dump_memory24 (
91 union acpi_resource_data *data);
92
93static void
94acpi_rs_dump_memory32 (
95 union acpi_resource_data *data);
96
97static void
98acpi_rs_dump_start_depend_fns (
99 union acpi_resource_data *data);
100
101static void
102acpi_rs_dump_vendor_specific (
103 union acpi_resource_data *data);
104
105
106#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
54/******************************************************************************* 107/*******************************************************************************
55 * 108 *
56 * FUNCTION: acpi_rs_dump_irq 109 * FUNCTION: acpi_rs_dump_irq
@@ -63,7 +116,7 @@
63 * 116 *
64 ******************************************************************************/ 117 ******************************************************************************/
65 118
66void 119static void
67acpi_rs_dump_irq ( 120acpi_rs_dump_irq (
68 union acpi_resource_data *data) 121 union acpi_resource_data *data)
69{ 122{
@@ -77,13 +130,13 @@ acpi_rs_dump_irq (
77 acpi_os_printf ("IRQ Resource\n"); 130 acpi_os_printf ("IRQ Resource\n");
78 131
79 acpi_os_printf (" %s Triggered\n", 132 acpi_os_printf (" %s Triggered\n",
80 ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge"); 133 ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge");
81 134
82 acpi_os_printf (" Active %s\n", 135 acpi_os_printf (" Active %s\n",
83 ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High"); 136 ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High");
84 137
85 acpi_os_printf (" %s\n", 138 acpi_os_printf (" %s\n",
86 ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive"); 139 ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive");
87 140
88 acpi_os_printf (" %X Interrupts ( ", irq_data->number_of_interrupts); 141 acpi_os_printf (" %X Interrupts ( ", irq_data->number_of_interrupts);
89 142
@@ -108,7 +161,7 @@ acpi_rs_dump_irq (
108 * 161 *
109 ******************************************************************************/ 162 ******************************************************************************/
110 163
111void 164static void
112acpi_rs_dump_dma ( 165acpi_rs_dump_dma (
113 union acpi_resource_data *data) 166 union acpi_resource_data *data)
114{ 167{
@@ -144,7 +197,7 @@ acpi_rs_dump_dma (
144 } 197 }
145 198
146 acpi_os_printf (" %sBus Master\n", 199 acpi_os_printf (" %sBus Master\n",
147 ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a "); 200 ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
148 201
149 202
150 switch (dma_data->transfer) { 203 switch (dma_data->transfer) {
@@ -165,7 +218,8 @@ acpi_rs_dump_dma (
165 break; 218 break;
166 } 219 }
167 220
168 acpi_os_printf (" Number of Channels: %X ( ", dma_data->number_of_channels); 221 acpi_os_printf (" Number of Channels: %X ( ",
222 dma_data->number_of_channels);
169 223
170 for (index = 0; index < dma_data->number_of_channels; index++) { 224 for (index = 0; index < dma_data->number_of_channels; index++) {
171 acpi_os_printf ("%X ", dma_data->channels[index]); 225 acpi_os_printf ("%X ", dma_data->channels[index]);
@@ -188,7 +242,7 @@ acpi_rs_dump_dma (
188 * 242 *
189 ******************************************************************************/ 243 ******************************************************************************/
190 244
191void 245static void
192acpi_rs_dump_start_depend_fns ( 246acpi_rs_dump_start_depend_fns (
193 union acpi_resource_data *data) 247 union acpi_resource_data *data)
194{ 248{
@@ -232,8 +286,7 @@ acpi_rs_dump_start_depend_fns (
232 break; 286 break;
233 287
234 default: 288 default:
235 acpi_os_printf (" Invalid performance " 289 acpi_os_printf (" Invalid performance robustness preference\n");
236 "robustness preference\n");
237 break; 290 break;
238 } 291 }
239 292
@@ -253,7 +306,7 @@ acpi_rs_dump_start_depend_fns (
253 * 306 *
254 ******************************************************************************/ 307 ******************************************************************************/
255 308
256void 309static void
257acpi_rs_dump_io ( 310acpi_rs_dump_io (
258 union acpi_resource_data *data) 311 union acpi_resource_data *data)
259{ 312{
@@ -266,19 +319,15 @@ acpi_rs_dump_io (
266 acpi_os_printf ("Io Resource\n"); 319 acpi_os_printf ("Io Resource\n");
267 320
268 acpi_os_printf (" %d bit decode\n", 321 acpi_os_printf (" %d bit decode\n",
269 ACPI_DECODE_16 == io_data->io_decode ? 16 : 10); 322 ACPI_DECODE_16 == io_data->io_decode ? 16 : 10);
270 323
271 acpi_os_printf (" Range minimum base: %08X\n", 324 acpi_os_printf (" Range minimum base: %08X\n", io_data->min_base_address);
272 io_data->min_base_address);
273 325
274 acpi_os_printf (" Range maximum base: %08X\n", 326 acpi_os_printf (" Range maximum base: %08X\n", io_data->max_base_address);
275 io_data->max_base_address);
276 327
277 acpi_os_printf (" Alignment: %08X\n", 328 acpi_os_printf (" Alignment: %08X\n", io_data->alignment);
278 io_data->alignment);
279 329
280 acpi_os_printf (" Range Length: %08X\n", 330 acpi_os_printf (" Range Length: %08X\n", io_data->range_length);
281 io_data->range_length);
282 331
283 return; 332 return;
284} 333}
@@ -296,7 +345,7 @@ acpi_rs_dump_io (
296 * 345 *
297 ******************************************************************************/ 346 ******************************************************************************/
298 347
299void 348static void
300acpi_rs_dump_fixed_io ( 349acpi_rs_dump_fixed_io (
301 union acpi_resource_data *data) 350 union acpi_resource_data *data)
302{ 351{
@@ -307,11 +356,9 @@ acpi_rs_dump_fixed_io (
307 356
308 357
309 acpi_os_printf ("Fixed Io Resource\n"); 358 acpi_os_printf ("Fixed Io Resource\n");
310 acpi_os_printf (" Range base address: %08X", 359 acpi_os_printf (" Range base address: %08X", fixed_io_data->base_address);
311 fixed_io_data->base_address);
312 360
313 acpi_os_printf (" Range length: %08X", 361 acpi_os_printf (" Range length: %08X", fixed_io_data->range_length);
314 fixed_io_data->range_length);
315 362
316 return; 363 return;
317} 364}
@@ -329,7 +376,7 @@ acpi_rs_dump_fixed_io (
329 * 376 *
330 ******************************************************************************/ 377 ******************************************************************************/
331 378
332void 379static void
333acpi_rs_dump_vendor_specific ( 380acpi_rs_dump_vendor_specific (
334 union acpi_resource_data *data) 381 union acpi_resource_data *data)
335{ 382{
@@ -346,7 +393,7 @@ acpi_rs_dump_vendor_specific (
346 393
347 for (index = 0; index < vendor_data->length; index++) { 394 for (index = 0; index < vendor_data->length; index++) {
348 acpi_os_printf (" Byte %X: %08X\n", 395 acpi_os_printf (" Byte %X: %08X\n",
349 index, vendor_data->reserved[index]); 396 index, vendor_data->reserved[index]);
350 } 397 }
351 398
352 return; 399 return;
@@ -365,7 +412,7 @@ acpi_rs_dump_vendor_specific (
365 * 412 *
366 ******************************************************************************/ 413 ******************************************************************************/
367 414
368void 415static void
369acpi_rs_dump_memory24 ( 416acpi_rs_dump_memory24 (
370 union acpi_resource_data *data) 417 union acpi_resource_data *data)
371{ 418{
@@ -378,21 +425,19 @@ acpi_rs_dump_memory24 (
378 acpi_os_printf ("24-Bit Memory Range Resource\n"); 425 acpi_os_printf ("24-Bit Memory Range Resource\n");
379 426
380 acpi_os_printf (" Read%s\n", 427 acpi_os_printf (" Read%s\n",
381 ACPI_READ_WRITE_MEMORY == 428 ACPI_READ_WRITE_MEMORY ==
382 memory24_data->read_write_attribute ? 429 memory24_data->read_write_attribute ?
383 "/Write" : " only"); 430 "/Write" : " only");
384 431
385 acpi_os_printf (" Range minimum base: %08X\n", 432 acpi_os_printf (" Range minimum base: %08X\n",
386 memory24_data->min_base_address); 433 memory24_data->min_base_address);
387 434
388 acpi_os_printf (" Range maximum base: %08X\n", 435 acpi_os_printf (" Range maximum base: %08X\n",
389 memory24_data->max_base_address); 436 memory24_data->max_base_address);
390 437
391 acpi_os_printf (" Alignment: %08X\n", 438 acpi_os_printf (" Alignment: %08X\n", memory24_data->alignment);
392 memory24_data->alignment);
393 439
394 acpi_os_printf (" Range length: %08X\n", 440 acpi_os_printf (" Range length: %08X\n", memory24_data->range_length);
395 memory24_data->range_length);
396 441
397 return; 442 return;
398} 443}
@@ -410,7 +455,7 @@ acpi_rs_dump_memory24 (
410 * 455 *
411 ******************************************************************************/ 456 ******************************************************************************/
412 457
413void 458static void
414acpi_rs_dump_memory32 ( 459acpi_rs_dump_memory32 (
415 union acpi_resource_data *data) 460 union acpi_resource_data *data)
416{ 461{
@@ -423,21 +468,19 @@ acpi_rs_dump_memory32 (
423 acpi_os_printf ("32-Bit Memory Range Resource\n"); 468 acpi_os_printf ("32-Bit Memory Range Resource\n");
424 469
425 acpi_os_printf (" Read%s\n", 470 acpi_os_printf (" Read%s\n",
426 ACPI_READ_WRITE_MEMORY == 471 ACPI_READ_WRITE_MEMORY ==
427 memory32_data->read_write_attribute ? 472 memory32_data->read_write_attribute ?
428 "/Write" : " only"); 473 "/Write" : " only");
429 474
430 acpi_os_printf (" Range minimum base: %08X\n", 475 acpi_os_printf (" Range minimum base: %08X\n",
431 memory32_data->min_base_address); 476 memory32_data->min_base_address);
432 477
433 acpi_os_printf (" Range maximum base: %08X\n", 478 acpi_os_printf (" Range maximum base: %08X\n",
434 memory32_data->max_base_address); 479 memory32_data->max_base_address);
435 480
436 acpi_os_printf (" Alignment: %08X\n", 481 acpi_os_printf (" Alignment: %08X\n", memory32_data->alignment);
437 memory32_data->alignment);
438 482
439 acpi_os_printf (" Range length: %08X\n", 483 acpi_os_printf (" Range length: %08X\n", memory32_data->range_length);
440 memory32_data->range_length);
441 484
442 return; 485 return;
443} 486}
@@ -455,11 +498,12 @@ acpi_rs_dump_memory32 (
455 * 498 *
456 ******************************************************************************/ 499 ******************************************************************************/
457 500
458void 501static void
459acpi_rs_dump_fixed_memory32 ( 502acpi_rs_dump_fixed_memory32 (
460 union acpi_resource_data *data) 503 union acpi_resource_data *data)
461{ 504{
462 struct acpi_resource_fixed_mem32 *fixed_memory32_data = (struct acpi_resource_fixed_mem32 *) data; 505 struct acpi_resource_fixed_mem32 *fixed_memory32_data =
506 (struct acpi_resource_fixed_mem32 *) data;
463 507
464 508
465 ACPI_FUNCTION_ENTRY (); 509 ACPI_FUNCTION_ENTRY ();
@@ -468,15 +512,14 @@ acpi_rs_dump_fixed_memory32 (
468 acpi_os_printf ("32-Bit Fixed Location Memory Range Resource\n"); 512 acpi_os_printf ("32-Bit Fixed Location Memory Range Resource\n");
469 513
470 acpi_os_printf (" Read%s\n", 514 acpi_os_printf (" Read%s\n",
471 ACPI_READ_WRITE_MEMORY == 515 ACPI_READ_WRITE_MEMORY ==
472 fixed_memory32_data->read_write_attribute ? 516 fixed_memory32_data->read_write_attribute ? "/Write" : " Only");
473 "/Write" : " Only");
474 517
475 acpi_os_printf (" Range base address: %08X\n", 518 acpi_os_printf (" Range base address: %08X\n",
476 fixed_memory32_data->range_base_address); 519 fixed_memory32_data->range_base_address);
477 520
478 acpi_os_printf (" Range length: %08X\n", 521 acpi_os_printf (" Range length: %08X\n",
479 fixed_memory32_data->range_length); 522 fixed_memory32_data->range_length);
480 523
481 return; 524 return;
482} 525}
@@ -494,7 +537,7 @@ acpi_rs_dump_fixed_memory32 (
494 * 537 *
495 ******************************************************************************/ 538 ******************************************************************************/
496 539
497void 540static void
498acpi_rs_dump_address16 ( 541acpi_rs_dump_address16 (
499 union acpi_resource_data *data) 542 union acpi_resource_data *data)
500{ 543{
@@ -514,35 +557,30 @@ acpi_rs_dump_address16 (
514 557
515 switch (address16_data->attribute.memory.cache_attribute) { 558 switch (address16_data->attribute.memory.cache_attribute) {
516 case ACPI_NON_CACHEABLE_MEMORY: 559 case ACPI_NON_CACHEABLE_MEMORY:
517 acpi_os_printf (" Type Specific: " 560 acpi_os_printf (" Type Specific: Noncacheable memory\n");
518 "Noncacheable memory\n");
519 break; 561 break;
520 562
521 case ACPI_CACHABLE_MEMORY: 563 case ACPI_CACHABLE_MEMORY:
522 acpi_os_printf (" Type Specific: " 564 acpi_os_printf (" Type Specific: Cacheable memory\n");
523 "Cacheable memory\n");
524 break; 565 break;
525 566
526 case ACPI_WRITE_COMBINING_MEMORY: 567 case ACPI_WRITE_COMBINING_MEMORY:
527 acpi_os_printf (" Type Specific: " 568 acpi_os_printf (" Type Specific: Write-combining memory\n");
528 "Write-combining memory\n");
529 break; 569 break;
530 570
531 case ACPI_PREFETCHABLE_MEMORY: 571 case ACPI_PREFETCHABLE_MEMORY:
532 acpi_os_printf (" Type Specific: " 572 acpi_os_printf (" Type Specific: Prefetchable memory\n");
533 "Prefetchable memory\n");
534 break; 573 break;
535 574
536 default: 575 default:
537 acpi_os_printf (" Type Specific: " 576 acpi_os_printf (" Type Specific: Invalid cache attribute\n");
538 "Invalid cache attribute\n");
539 break; 577 break;
540 } 578 }
541 579
542 acpi_os_printf (" Type Specific: Read%s\n", 580 acpi_os_printf (" Type Specific: Read%s\n",
543 ACPI_READ_WRITE_MEMORY == 581 ACPI_READ_WRITE_MEMORY ==
544 address16_data->attribute.memory.read_write_attribute ? 582 address16_data->attribute.memory.read_write_attribute ?
545 "/Write" : " Only"); 583 "/Write" : " Only");
546 break; 584 break;
547 585
548 case ACPI_IO_RANGE: 586 case ACPI_IO_RANGE:
@@ -551,30 +589,26 @@ acpi_rs_dump_address16 (
551 589
552 switch (address16_data->attribute.io.range_attribute) { 590 switch (address16_data->attribute.io.range_attribute) {
553 case ACPI_NON_ISA_ONLY_RANGES: 591 case ACPI_NON_ISA_ONLY_RANGES:
554 acpi_os_printf (" Type Specific: " 592 acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n");
555 "Non-ISA Io Addresses\n");
556 break; 593 break;
557 594
558 case ACPI_ISA_ONLY_RANGES: 595 case ACPI_ISA_ONLY_RANGES:
559 acpi_os_printf (" Type Specific: " 596 acpi_os_printf (" Type Specific: ISA Io Addresses\n");
560 "ISA Io Addresses\n");
561 break; 597 break;
562 598
563 case ACPI_ENTIRE_RANGE: 599 case ACPI_ENTIRE_RANGE:
564 acpi_os_printf (" Type Specific: " 600 acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n");
565 "ISA and non-ISA Io Addresses\n");
566 break; 601 break;
567 602
568 default: 603 default:
569 acpi_os_printf (" Type Specific: " 604 acpi_os_printf (" Type Specific: Invalid range attribute\n");
570 "Invalid range attribute\n");
571 break; 605 break;
572 } 606 }
573 607
574 acpi_os_printf (" Type Specific: %s Translation\n", 608 acpi_os_printf (" Type Specific: %s Translation\n",
575 ACPI_SPARSE_TRANSLATION == 609 ACPI_SPARSE_TRANSLATION ==
576 address16_data->attribute.io.translation_attribute ? 610 address16_data->attribute.io.translation_attribute ?
577 "Sparse" : "Dense"); 611 "Sparse" : "Dense");
578 break; 612 break;
579 613
580 case ACPI_BUS_NUMBER_RANGE: 614 case ACPI_BUS_NUMBER_RANGE:
@@ -589,41 +623,42 @@ acpi_rs_dump_address16 (
589 } 623 }
590 624
591 acpi_os_printf (" Resource %s\n", 625 acpi_os_printf (" Resource %s\n",
592 ACPI_CONSUMER == address16_data->producer_consumer ? 626 ACPI_CONSUMER == address16_data->producer_consumer ?
593 "Consumer" : "Producer"); 627 "Consumer" : "Producer");
594 628
595 acpi_os_printf (" %s decode\n", 629 acpi_os_printf (" %s decode\n",
596 ACPI_SUB_DECODE == address16_data->decode ? 630 ACPI_SUB_DECODE == address16_data->decode ?
597 "Subtractive" : "Positive"); 631 "Subtractive" : "Positive");
598 632
599 acpi_os_printf (" Min address is %s fixed\n", 633 acpi_os_printf (" Min address is %s fixed\n",
600 ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ? 634 ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ?
601 "" : "not"); 635 "" : "not");
602 636
603 acpi_os_printf (" Max address is %s fixed\n", 637 acpi_os_printf (" Max address is %s fixed\n",
604 ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ? 638 ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ?
605 "" : "not"); 639 "" : "not");
606 640
607 acpi_os_printf (" Granularity: %08X\n", 641 acpi_os_printf (" Granularity: %08X\n",
608 address16_data->granularity); 642 address16_data->granularity);
609 643
610 acpi_os_printf (" Address range min: %08X\n", 644 acpi_os_printf (" Address range min: %08X\n",
611 address16_data->min_address_range); 645 address16_data->min_address_range);
612 646
613 acpi_os_printf (" Address range max: %08X\n", 647 acpi_os_printf (" Address range max: %08X\n",
614 address16_data->max_address_range); 648 address16_data->max_address_range);
615 649
616 acpi_os_printf (" Address translation offset: %08X\n", 650 acpi_os_printf (" Address translation offset: %08X\n",
617 address16_data->address_translation_offset); 651 address16_data->address_translation_offset);
618 652
619 acpi_os_printf (" Address Length: %08X\n", 653 acpi_os_printf (" Address Length: %08X\n",
620 address16_data->address_length); 654 address16_data->address_length);
621 655
622 if (0xFF != address16_data->resource_source.index) { 656 if (0xFF != address16_data->resource_source.index) {
623 acpi_os_printf (" Resource Source Index: %X\n", 657 acpi_os_printf (" Resource Source Index: %X\n",
624 address16_data->resource_source.index); 658 address16_data->resource_source.index);
659
625 acpi_os_printf (" Resource Source: %s\n", 660 acpi_os_printf (" Resource Source: %s\n",
626 address16_data->resource_source.string_ptr); 661 address16_data->resource_source.string_ptr);
627 } 662 }
628 663
629 return; 664 return;
@@ -642,7 +677,7 @@ acpi_rs_dump_address16 (
642 * 677 *
643 ******************************************************************************/ 678 ******************************************************************************/
644 679
645void 680static void
646acpi_rs_dump_address32 ( 681acpi_rs_dump_address32 (
647 union acpi_resource_data *data) 682 union acpi_resource_data *data)
648{ 683{
@@ -661,35 +696,30 @@ acpi_rs_dump_address32 (
661 696
662 switch (address32_data->attribute.memory.cache_attribute) { 697 switch (address32_data->attribute.memory.cache_attribute) {
663 case ACPI_NON_CACHEABLE_MEMORY: 698 case ACPI_NON_CACHEABLE_MEMORY:
664 acpi_os_printf (" Type Specific: " 699 acpi_os_printf (" Type Specific: Noncacheable memory\n");
665 "Noncacheable memory\n");
666 break; 700 break;
667 701
668 case ACPI_CACHABLE_MEMORY: 702 case ACPI_CACHABLE_MEMORY:
669 acpi_os_printf (" Type Specific: " 703 acpi_os_printf (" Type Specific: Cacheable memory\n");
670 "Cacheable memory\n");
671 break; 704 break;
672 705
673 case ACPI_WRITE_COMBINING_MEMORY: 706 case ACPI_WRITE_COMBINING_MEMORY:
674 acpi_os_printf (" Type Specific: " 707 acpi_os_printf (" Type Specific: Write-combining memory\n");
675 "Write-combining memory\n");
676 break; 708 break;
677 709
678 case ACPI_PREFETCHABLE_MEMORY: 710 case ACPI_PREFETCHABLE_MEMORY:
679 acpi_os_printf (" Type Specific: " 711 acpi_os_printf (" Type Specific: Prefetchable memory\n");
680 "Prefetchable memory\n");
681 break; 712 break;
682 713
683 default: 714 default:
684 acpi_os_printf (" Type Specific: " 715 acpi_os_printf (" Type Specific: Invalid cache attribute\n");
685 "Invalid cache attribute\n");
686 break; 716 break;
687 } 717 }
688 718
689 acpi_os_printf (" Type Specific: Read%s\n", 719 acpi_os_printf (" Type Specific: Read%s\n",
690 ACPI_READ_WRITE_MEMORY == 720 ACPI_READ_WRITE_MEMORY ==
691 address32_data->attribute.memory.read_write_attribute ? 721 address32_data->attribute.memory.read_write_attribute ?
692 "/Write" : " Only"); 722 "/Write" : " Only");
693 break; 723 break;
694 724
695 case ACPI_IO_RANGE: 725 case ACPI_IO_RANGE:
@@ -698,30 +728,26 @@ acpi_rs_dump_address32 (
698 728
699 switch (address32_data->attribute.io.range_attribute) { 729 switch (address32_data->attribute.io.range_attribute) {
700 case ACPI_NON_ISA_ONLY_RANGES: 730 case ACPI_NON_ISA_ONLY_RANGES:
701 acpi_os_printf (" Type Specific: " 731 acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n");
702 "Non-ISA Io Addresses\n");
703 break; 732 break;
704 733
705 case ACPI_ISA_ONLY_RANGES: 734 case ACPI_ISA_ONLY_RANGES:
706 acpi_os_printf (" Type Specific: " 735 acpi_os_printf (" Type Specific: ISA Io Addresses\n");
707 "ISA Io Addresses\n");
708 break; 736 break;
709 737
710 case ACPI_ENTIRE_RANGE: 738 case ACPI_ENTIRE_RANGE:
711 acpi_os_printf (" Type Specific: " 739 acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n");
712 "ISA and non-ISA Io Addresses\n");
713 break; 740 break;
714 741
715 default: 742 default:
716 acpi_os_printf (" Type Specific: " 743 acpi_os_printf (" Type Specific: Invalid Range attribute");
717 "Invalid Range attribute");
718 break; 744 break;
719 } 745 }
720 746
721 acpi_os_printf (" Type Specific: %s Translation\n", 747 acpi_os_printf (" Type Specific: %s Translation\n",
722 ACPI_SPARSE_TRANSLATION == 748 ACPI_SPARSE_TRANSLATION ==
723 address32_data->attribute.io.translation_attribute ? 749 address32_data->attribute.io.translation_attribute ?
724 "Sparse" : "Dense"); 750 "Sparse" : "Dense");
725 break; 751 break;
726 752
727 case ACPI_BUS_NUMBER_RANGE: 753 case ACPI_BUS_NUMBER_RANGE:
@@ -731,46 +757,48 @@ acpi_rs_dump_address32 (
731 757
732 default: 758 default:
733 759
734 acpi_os_printf (" Resource Type: 0x%2.2X\n", address32_data->resource_type); 760 acpi_os_printf (" Resource Type: 0x%2.2X\n",
761 address32_data->resource_type);
735 break; 762 break;
736 } 763 }
737 764
738 acpi_os_printf (" Resource %s\n", 765 acpi_os_printf (" Resource %s\n",
739 ACPI_CONSUMER == address32_data->producer_consumer ? 766 ACPI_CONSUMER == address32_data->producer_consumer ?
740 "Consumer" : "Producer"); 767 "Consumer" : "Producer");
741 768
742 acpi_os_printf (" %s decode\n", 769 acpi_os_printf (" %s decode\n",
743 ACPI_SUB_DECODE == address32_data->decode ? 770 ACPI_SUB_DECODE == address32_data->decode ?
744 "Subtractive" : "Positive"); 771 "Subtractive" : "Positive");
745 772
746 acpi_os_printf (" Min address is %s fixed\n", 773 acpi_os_printf (" Min address is %s fixed\n",
747 ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ? 774 ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ?
748 "" : "not "); 775 "" : "not ");
749 776
750 acpi_os_printf (" Max address is %s fixed\n", 777 acpi_os_printf (" Max address is %s fixed\n",
751 ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ? 778 ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ?
752 "" : "not "); 779 "" : "not ");
753 780
754 acpi_os_printf (" Granularity: %08X\n", 781 acpi_os_printf (" Granularity: %08X\n",
755 address32_data->granularity); 782 address32_data->granularity);
756 783
757 acpi_os_printf (" Address range min: %08X\n", 784 acpi_os_printf (" Address range min: %08X\n",
758 address32_data->min_address_range); 785 address32_data->min_address_range);
759 786
760 acpi_os_printf (" Address range max: %08X\n", 787 acpi_os_printf (" Address range max: %08X\n",
761 address32_data->max_address_range); 788 address32_data->max_address_range);
762 789
763 acpi_os_printf (" Address translation offset: %08X\n", 790 acpi_os_printf (" Address translation offset: %08X\n",
764 address32_data->address_translation_offset); 791 address32_data->address_translation_offset);
765 792
766 acpi_os_printf (" Address Length: %08X\n", 793 acpi_os_printf (" Address Length: %08X\n",
767 address32_data->address_length); 794 address32_data->address_length);
768 795
769 if(0xFF != address32_data->resource_source.index) { 796 if(0xFF != address32_data->resource_source.index) {
770 acpi_os_printf (" Resource Source Index: %X\n", 797 acpi_os_printf (" Resource Source Index: %X\n",
771 address32_data->resource_source.index); 798 address32_data->resource_source.index);
799
772 acpi_os_printf (" Resource Source: %s\n", 800 acpi_os_printf (" Resource Source: %s\n",
773 address32_data->resource_source.string_ptr); 801 address32_data->resource_source.string_ptr);
774 } 802 }
775 803
776 return; 804 return;
@@ -789,7 +817,7 @@ acpi_rs_dump_address32 (
789 * 817 *
790 ******************************************************************************/ 818 ******************************************************************************/
791 819
792void 820static void
793acpi_rs_dump_address64 ( 821acpi_rs_dump_address64 (
794 union acpi_resource_data *data) 822 union acpi_resource_data *data)
795{ 823{
@@ -808,35 +836,30 @@ acpi_rs_dump_address64 (
808 836
809 switch (address64_data->attribute.memory.cache_attribute) { 837 switch (address64_data->attribute.memory.cache_attribute) {
810 case ACPI_NON_CACHEABLE_MEMORY: 838 case ACPI_NON_CACHEABLE_MEMORY:
811 acpi_os_printf (" Type Specific: " 839 acpi_os_printf (" Type Specific: Noncacheable memory\n");
812 "Noncacheable memory\n");
813 break; 840 break;
814 841
815 case ACPI_CACHABLE_MEMORY: 842 case ACPI_CACHABLE_MEMORY:
816 acpi_os_printf (" Type Specific: " 843 acpi_os_printf (" Type Specific: Cacheable memory\n");
817 "Cacheable memory\n");
818 break; 844 break;
819 845
820 case ACPI_WRITE_COMBINING_MEMORY: 846 case ACPI_WRITE_COMBINING_MEMORY:
821 acpi_os_printf (" Type Specific: " 847 acpi_os_printf (" Type Specific: Write-combining memory\n");
822 "Write-combining memory\n");
823 break; 848 break;
824 849
825 case ACPI_PREFETCHABLE_MEMORY: 850 case ACPI_PREFETCHABLE_MEMORY:
826 acpi_os_printf (" Type Specific: " 851 acpi_os_printf (" Type Specific: Prefetchable memory\n");
827 "Prefetchable memory\n");
828 break; 852 break;
829 853
830 default: 854 default:
831 acpi_os_printf (" Type Specific: " 855 acpi_os_printf (" Type Specific: Invalid cache attribute\n");
832 "Invalid cache attribute\n");
833 break; 856 break;
834 } 857 }
835 858
836 acpi_os_printf (" Type Specific: Read%s\n", 859 acpi_os_printf (" Type Specific: Read%s\n",
837 ACPI_READ_WRITE_MEMORY == 860 ACPI_READ_WRITE_MEMORY ==
838 address64_data->attribute.memory.read_write_attribute ? 861 address64_data->attribute.memory.read_write_attribute ?
839 "/Write" : " Only"); 862 "/Write" : " Only");
840 break; 863 break;
841 864
842 case ACPI_IO_RANGE: 865 case ACPI_IO_RANGE:
@@ -845,30 +868,26 @@ acpi_rs_dump_address64 (
845 868
846 switch (address64_data->attribute.io.range_attribute) { 869 switch (address64_data->attribute.io.range_attribute) {
847 case ACPI_NON_ISA_ONLY_RANGES: 870 case ACPI_NON_ISA_ONLY_RANGES:
848 acpi_os_printf (" Type Specific: " 871 acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n");
849 "Non-ISA Io Addresses\n");
850 break; 872 break;
851 873
852 case ACPI_ISA_ONLY_RANGES: 874 case ACPI_ISA_ONLY_RANGES:
853 acpi_os_printf (" Type Specific: " 875 acpi_os_printf (" Type Specific: ISA Io Addresses\n");
854 "ISA Io Addresses\n");
855 break; 876 break;
856 877
857 case ACPI_ENTIRE_RANGE: 878 case ACPI_ENTIRE_RANGE:
858 acpi_os_printf (" Type Specific: " 879 acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n");
859 "ISA and non-ISA Io Addresses\n");
860 break; 880 break;
861 881
862 default: 882 default:
863 acpi_os_printf (" Type Specific: " 883 acpi_os_printf (" Type Specific: Invalid Range attribute");
864 "Invalid Range attribute");
865 break; 884 break;
866 } 885 }
867 886
868 acpi_os_printf (" Type Specific: %s Translation\n", 887 acpi_os_printf (" Type Specific: %s Translation\n",
869 ACPI_SPARSE_TRANSLATION == 888 ACPI_SPARSE_TRANSLATION ==
870 address64_data->attribute.io.translation_attribute ? 889 address64_data->attribute.io.translation_attribute ?
871 "Sparse" : "Dense"); 890 "Sparse" : "Dense");
872 break; 891 break;
873 892
874 case ACPI_BUS_NUMBER_RANGE: 893 case ACPI_BUS_NUMBER_RANGE:
@@ -878,49 +897,51 @@ acpi_rs_dump_address64 (
878 897
879 default: 898 default:
880 899
881 acpi_os_printf (" Resource Type: 0x%2.2X\n", address64_data->resource_type); 900 acpi_os_printf (" Resource Type: 0x%2.2X\n",
901 address64_data->resource_type);
882 break; 902 break;
883 } 903 }
884 904
885 acpi_os_printf (" Resource %s\n", 905 acpi_os_printf (" Resource %s\n",
886 ACPI_CONSUMER == address64_data->producer_consumer ? 906 ACPI_CONSUMER == address64_data->producer_consumer ?
887 "Consumer" : "Producer"); 907 "Consumer" : "Producer");
888 908
889 acpi_os_printf (" %s decode\n", 909 acpi_os_printf (" %s decode\n",
890 ACPI_SUB_DECODE == address64_data->decode ? 910 ACPI_SUB_DECODE == address64_data->decode ?
891 "Subtractive" : "Positive"); 911 "Subtractive" : "Positive");
892 912
893 acpi_os_printf (" Min address is %s fixed\n", 913 acpi_os_printf (" Min address is %s fixed\n",
894 ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ? 914 ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ?
895 "" : "not "); 915 "" : "not ");
896 916
897 acpi_os_printf (" Max address is %s fixed\n", 917 acpi_os_printf (" Max address is %s fixed\n",
898 ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ? 918 ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ?
899 "" : "not "); 919 "" : "not ");
900 920
901 acpi_os_printf (" Granularity: %8.8X%8.8X\n", 921 acpi_os_printf (" Granularity: %8.8X%8.8X\n",
902 ACPI_FORMAT_UINT64 (address64_data->granularity)); 922 ACPI_FORMAT_UINT64 (address64_data->granularity));
903 923
904 acpi_os_printf (" Address range min: %8.8X%8.8X\n", 924 acpi_os_printf (" Address range min: %8.8X%8.8X\n",
905 ACPI_FORMAT_UINT64 (address64_data->min_address_range)); 925 ACPI_FORMAT_UINT64 (address64_data->min_address_range));
906 926
907 acpi_os_printf (" Address range max: %8.8X%8.8X\n", 927 acpi_os_printf (" Address range max: %8.8X%8.8X\n",
908 ACPI_FORMAT_UINT64 (address64_data->max_address_range)); 928 ACPI_FORMAT_UINT64 (address64_data->max_address_range));
909 929
910 acpi_os_printf (" Address translation offset: %8.8X%8.8X\n", 930 acpi_os_printf (" Address translation offset: %8.8X%8.8X\n",
911 ACPI_FORMAT_UINT64 (address64_data->address_translation_offset)); 931 ACPI_FORMAT_UINT64 (address64_data->address_translation_offset));
912 932
913 acpi_os_printf (" Address Length: %8.8X%8.8X\n", 933 acpi_os_printf (" Address Length: %8.8X%8.8X\n",
914 ACPI_FORMAT_UINT64 (address64_data->address_length)); 934 ACPI_FORMAT_UINT64 (address64_data->address_length));
915 935
916 acpi_os_printf (" Type Specific Attributes: %8.8X%8.8X\n", 936 acpi_os_printf (" Type Specific Attributes: %8.8X%8.8X\n",
917 ACPI_FORMAT_UINT64 (address64_data->type_specific_attributes)); 937 ACPI_FORMAT_UINT64 (address64_data->type_specific_attributes));
918 938
919 if (0xFF != address64_data->resource_source.index) { 939 if (0xFF != address64_data->resource_source.index) {
920 acpi_os_printf (" Resource Source Index: %X\n", 940 acpi_os_printf (" Resource Source Index: %X\n",
921 address64_data->resource_source.index); 941 address64_data->resource_source.index);
942
922 acpi_os_printf (" Resource Source: %s\n", 943 acpi_os_printf (" Resource Source: %s\n",
923 address64_data->resource_source.string_ptr); 944 address64_data->resource_source.string_ptr);
924 } 945 }
925 946
926 return; 947 return;
@@ -939,7 +960,7 @@ acpi_rs_dump_address64 (
939 * 960 *
940 ******************************************************************************/ 961 ******************************************************************************/
941 962
942void 963static void
943acpi_rs_dump_extended_irq ( 964acpi_rs_dump_extended_irq (
944 union acpi_resource_data *data) 965 union acpi_resource_data *data)
945{ 966{
@@ -953,23 +974,22 @@ acpi_rs_dump_extended_irq (
953 acpi_os_printf ("Extended IRQ Resource\n"); 974 acpi_os_printf ("Extended IRQ Resource\n");
954 975
955 acpi_os_printf (" Resource %s\n", 976 acpi_os_printf (" Resource %s\n",
956 ACPI_CONSUMER == ext_irq_data->producer_consumer ? 977 ACPI_CONSUMER == ext_irq_data->producer_consumer ?
957 "Consumer" : "Producer"); 978 "Consumer" : "Producer");
958 979
959 acpi_os_printf (" %s\n", 980 acpi_os_printf (" %s\n",
960 ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ? 981 ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ?
961 "Level" : "Edge"); 982 "Level" : "Edge");
962 983
963 acpi_os_printf (" Active %s\n", 984 acpi_os_printf (" Active %s\n",
964 ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ? 985 ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ?
965 "low" : "high"); 986 "low" : "high");
966 987
967 acpi_os_printf (" %s\n", 988 acpi_os_printf (" %s\n",
968 ACPI_SHARED == ext_irq_data->shared_exclusive ? 989 ACPI_SHARED == ext_irq_data->shared_exclusive ?
969 "Shared" : "Exclusive"); 990 "Shared" : "Exclusive");
970 991
971 acpi_os_printf (" Interrupts : %X ( ", 992 acpi_os_printf (" Interrupts : %X ( ", ext_irq_data->number_of_interrupts);
972 ext_irq_data->number_of_interrupts);
973 993
974 for (index = 0; index < ext_irq_data->number_of_interrupts; index++) { 994 for (index = 0; index < ext_irq_data->number_of_interrupts; index++) {
975 acpi_os_printf ("%X ", ext_irq_data->interrupts[index]); 995 acpi_os_printf ("%X ", ext_irq_data->interrupts[index]);
@@ -979,9 +999,10 @@ acpi_rs_dump_extended_irq (
979 999
980 if(0xFF != ext_irq_data->resource_source.index) { 1000 if(0xFF != ext_irq_data->resource_source.index) {
981 acpi_os_printf (" Resource Source Index: %X", 1001 acpi_os_printf (" Resource Source Index: %X",
982 ext_irq_data->resource_source.index); 1002 ext_irq_data->resource_source.index);
1003
983 acpi_os_printf (" Resource Source: %s", 1004 acpi_os_printf (" Resource Source: %s",
984 ext_irq_data->resource_source.string_ptr); 1005 ext_irq_data->resource_source.string_ptr);
985 } 1006 }
986 1007
987 return; 1008 return;
@@ -992,7 +1013,7 @@ acpi_rs_dump_extended_irq (
992 * 1013 *
993 * FUNCTION: acpi_rs_dump_resource_list 1014 * FUNCTION: acpi_rs_dump_resource_list
994 * 1015 *
995 * PARAMETERS: Data - pointer to the resource structure to dump. 1016 * PARAMETERS: Resource - pointer to the resource structure to dump.
996 * 1017 *
997 * RETURN: None 1018 * RETURN: None
998 * 1019 *
@@ -1096,7 +1117,7 @@ acpi_rs_dump_resource_list (
1096 * 1117 *
1097 * FUNCTION: acpi_rs_dump_irq_list 1118 * FUNCTION: acpi_rs_dump_irq_list
1098 * 1119 *
1099 * PARAMETERS: Data - pointer to the routing table to dump. 1120 * PARAMETERS: route_table - pointer to the routing table to dump.
1100 * 1121 *
1101 * RETURN: None 1122 * RETURN: None
1102 * 1123 *
@@ -1124,20 +1145,17 @@ acpi_rs_dump_irq_list (
1124 acpi_os_printf ("PCI IRQ Routing Table structure %X.\n", count++); 1145 acpi_os_printf ("PCI IRQ Routing Table structure %X.\n", count++);
1125 1146
1126 acpi_os_printf (" Address: %8.8X%8.8X\n", 1147 acpi_os_printf (" Address: %8.8X%8.8X\n",
1127 ACPI_FORMAT_UINT64 (prt_element->address)); 1148 ACPI_FORMAT_UINT64 (prt_element->address));
1128 1149
1129 acpi_os_printf (" Pin: %X\n", prt_element->pin); 1150 acpi_os_printf (" Pin: %X\n", prt_element->pin);
1130 1151
1131 acpi_os_printf (" Source: %s\n", prt_element->source); 1152 acpi_os_printf (" Source: %s\n", prt_element->source);
1132 1153
1133 acpi_os_printf (" source_index: %X\n", 1154 acpi_os_printf (" source_index: %X\n", prt_element->source_index);
1134 prt_element->source_index);
1135 1155
1136 buffer += prt_element->length; 1156 buffer += prt_element->length;
1137
1138 prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer); 1157 prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer);
1139 1158 if (0 == prt_element->length) {
1140 if(0 == prt_element->length) {
1141 done = TRUE; 1159 done = TRUE;
1142 } 1160 }
1143 } 1161 }
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c
index 972c746d37e4..23a4d149fac8 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/resources/rsio.c
@@ -81,67 +81,60 @@ acpi_rs_io_resource (
81 struct acpi_resource *output_struct = (void *) *output_buffer; 81 struct acpi_resource *output_struct = (void *) *output_buffer;
82 u16 temp16 = 0; 82 u16 temp16 = 0;
83 u8 temp8 = 0; 83 u8 temp8 = 0;
84 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io); 84 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
85 struct acpi_resource_io);
85 86
86 87
87 ACPI_FUNCTION_TRACE ("rs_io_resource"); 88 ACPI_FUNCTION_TRACE ("rs_io_resource");
88 89
89 90
90 /* 91 /* The number of bytes consumed are Constant */
91 * The number of bytes consumed are Constant 92
92 */
93 *bytes_consumed = 8; 93 *bytes_consumed = 8;
94 94
95 output_struct->id = ACPI_RSTYPE_IO; 95 output_struct->id = ACPI_RSTYPE_IO;
96 96
97 /* 97 /* Check Decode */
98 * Check Decode 98
99 */
100 buffer += 1; 99 buffer += 1;
101 temp8 = *buffer; 100 temp8 = *buffer;
102 101
103 output_struct->data.io.io_decode = temp8 & 0x01; 102 output_struct->data.io.io_decode = temp8 & 0x01;
104 103
105 /* 104 /* Check min_base Address */
106 * Check min_base Address 105
107 */
108 buffer += 1; 106 buffer += 1;
109 ACPI_MOVE_16_TO_16 (&temp16, buffer); 107 ACPI_MOVE_16_TO_16 (&temp16, buffer);
110 108
111 output_struct->data.io.min_base_address = temp16; 109 output_struct->data.io.min_base_address = temp16;
112 110
113 /* 111 /* Check max_base Address */
114 * Check max_base Address 112
115 */
116 buffer += 2; 113 buffer += 2;
117 ACPI_MOVE_16_TO_16 (&temp16, buffer); 114 ACPI_MOVE_16_TO_16 (&temp16, buffer);
118 115
119 output_struct->data.io.max_base_address = temp16; 116 output_struct->data.io.max_base_address = temp16;
120 117
121 /* 118 /* Check Base alignment */
122 * Check Base alignment 119
123 */
124 buffer += 2; 120 buffer += 2;
125 temp8 = *buffer; 121 temp8 = *buffer;
126 122
127 output_struct->data.io.alignment = temp8; 123 output_struct->data.io.alignment = temp8;
128 124
129 /* 125 /* Check range_length */
130 * Check range_length 126
131 */
132 buffer += 1; 127 buffer += 1;
133 temp8 = *buffer; 128 temp8 = *buffer;
134 129
135 output_struct->data.io.range_length = temp8; 130 output_struct->data.io.range_length = temp8;
136 131
137 /* 132 /* Set the Length parameter */
138 * Set the Length parameter 133
139 */
140 output_struct->length = (u32) struct_size; 134 output_struct->length = (u32) struct_size;
141 135
142 /* 136 /* Return the final size of the structure */
143 * Return the final size of the structure 137
144 */
145 *structure_size = struct_size; 138 *structure_size = struct_size;
146 return_ACPI_STATUS (AE_OK); 139 return_ACPI_STATUS (AE_OK);
147} 140}
@@ -179,43 +172,39 @@ acpi_rs_fixed_io_resource (
179 struct acpi_resource *output_struct = (void *) *output_buffer; 172 struct acpi_resource *output_struct = (void *) *output_buffer;
180 u16 temp16 = 0; 173 u16 temp16 = 0;
181 u8 temp8 = 0; 174 u8 temp8 = 0;
182 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_io); 175 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
176 struct acpi_resource_fixed_io);
183 177
184 178
185 ACPI_FUNCTION_TRACE ("rs_fixed_io_resource"); 179 ACPI_FUNCTION_TRACE ("rs_fixed_io_resource");
186 180
187 181
188 /* 182 /* The number of bytes consumed are Constant */
189 * The number of bytes consumed are Constant 183
190 */
191 *bytes_consumed = 4; 184 *bytes_consumed = 4;
192 185
193 output_struct->id = ACPI_RSTYPE_FIXED_IO; 186 output_struct->id = ACPI_RSTYPE_FIXED_IO;
194 187
195 /* 188 /* Check Range Base Address */
196 * Check Range Base Address 189
197 */
198 buffer += 1; 190 buffer += 1;
199 ACPI_MOVE_16_TO_16 (&temp16, buffer); 191 ACPI_MOVE_16_TO_16 (&temp16, buffer);
200 192
201 output_struct->data.fixed_io.base_address = temp16; 193 output_struct->data.fixed_io.base_address = temp16;
202 194
203 /* 195 /* Check range_length */
204 * Check range_length 196
205 */
206 buffer += 2; 197 buffer += 2;
207 temp8 = *buffer; 198 temp8 = *buffer;
208 199
209 output_struct->data.fixed_io.range_length = temp8; 200 output_struct->data.fixed_io.range_length = temp8;
210 201
211 /* 202 /* Set the Length parameter */
212 * Set the Length parameter 203
213 */
214 output_struct->length = (u32) struct_size; 204 output_struct->length = (u32) struct_size;
215 205
216 /* 206 /* Return the final size of the structure */
217 * Return the final size of the structure 207
218 */
219 *structure_size = struct_size; 208 *structure_size = struct_size;
220 return_ACPI_STATUS (AE_OK); 209 return_ACPI_STATUS (AE_OK);
221} 210}
@@ -251,55 +240,48 @@ acpi_rs_io_stream (
251 ACPI_FUNCTION_TRACE ("rs_io_stream"); 240 ACPI_FUNCTION_TRACE ("rs_io_stream");
252 241
253 242
254 /* 243 /* The descriptor field is static */
255 * The descriptor field is static 244
256 */
257 *buffer = 0x47; 245 *buffer = 0x47;
258 buffer += 1; 246 buffer += 1;
259 247
260 /* 248 /* Io Information Byte */
261 * Io Information Byte 249
262 */
263 temp8 = (u8) (linked_list->data.io.io_decode & 0x01); 250 temp8 = (u8) (linked_list->data.io.io_decode & 0x01);
264 251
265 *buffer = temp8; 252 *buffer = temp8;
266 buffer += 1; 253 buffer += 1;
267 254
268 /* 255 /* Set the Range minimum base address */
269 * Set the Range minimum base address 256
270 */
271 temp16 = (u16) linked_list->data.io.min_base_address; 257 temp16 = (u16) linked_list->data.io.min_base_address;
272 258
273 ACPI_MOVE_16_TO_16 (buffer, &temp16); 259 ACPI_MOVE_16_TO_16 (buffer, &temp16);
274 buffer += 2; 260 buffer += 2;
275 261
276 /* 262 /* Set the Range maximum base address */
277 * Set the Range maximum base address 263
278 */
279 temp16 = (u16) linked_list->data.io.max_base_address; 264 temp16 = (u16) linked_list->data.io.max_base_address;
280 265
281 ACPI_MOVE_16_TO_16 (buffer, &temp16); 266 ACPI_MOVE_16_TO_16 (buffer, &temp16);
282 buffer += 2; 267 buffer += 2;
283 268
284 /* 269 /* Set the base alignment */
285 * Set the base alignment 270
286 */
287 temp8 = (u8) linked_list->data.io.alignment; 271 temp8 = (u8) linked_list->data.io.alignment;
288 272
289 *buffer = temp8; 273 *buffer = temp8;
290 buffer += 1; 274 buffer += 1;
291 275
292 /* 276 /* Set the range length */
293 * Set the range length 277
294 */
295 temp8 = (u8) linked_list->data.io.range_length; 278 temp8 = (u8) linked_list->data.io.range_length;
296 279
297 *buffer = temp8; 280 *buffer = temp8;
298 buffer += 1; 281 buffer += 1;
299 282
300 /* 283 /* Return the number of bytes consumed in this operation */
301 * Return the number of bytes consumed in this operation 284
302 */
303 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 285 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
304 return_ACPI_STATUS (AE_OK); 286 return_ACPI_STATUS (AE_OK);
305} 287}
@@ -335,32 +317,28 @@ acpi_rs_fixed_io_stream (
335 ACPI_FUNCTION_TRACE ("rs_fixed_io_stream"); 317 ACPI_FUNCTION_TRACE ("rs_fixed_io_stream");
336 318
337 319
338 /* 320 /* The descriptor field is static */
339 * The descriptor field is static 321
340 */
341 *buffer = 0x4B; 322 *buffer = 0x4B;
342 323
343 buffer += 1; 324 buffer += 1;
344 325
345 /* 326 /* Set the Range base address */
346 * Set the Range base address 327
347 */
348 temp16 = (u16) linked_list->data.fixed_io.base_address; 328 temp16 = (u16) linked_list->data.fixed_io.base_address;
349 329
350 ACPI_MOVE_16_TO_16 (buffer, &temp16); 330 ACPI_MOVE_16_TO_16 (buffer, &temp16);
351 buffer += 2; 331 buffer += 2;
352 332
353 /* 333 /* Set the range length */
354 * Set the range length 334
355 */
356 temp8 = (u8) linked_list->data.fixed_io.range_length; 335 temp8 = (u8) linked_list->data.fixed_io.range_length;
357 336
358 *buffer = temp8; 337 *buffer = temp8;
359 buffer += 1; 338 buffer += 1;
360 339
361 /* 340 /* Return the number of bytes consumed in this operation */
362 * Return the number of bytes consumed in this operation 341
363 */
364 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 342 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
365 return_ACPI_STATUS (AE_OK); 343 return_ACPI_STATUS (AE_OK);
366} 344}
@@ -399,21 +377,20 @@ acpi_rs_dma_resource (
399 u8 temp8 = 0; 377 u8 temp8 = 0;
400 u8 index; 378 u8 index;
401 u8 i; 379 u8 i;
402 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_dma); 380 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
381 struct acpi_resource_dma);
403 382
404 383
405 ACPI_FUNCTION_TRACE ("rs_dma_resource"); 384 ACPI_FUNCTION_TRACE ("rs_dma_resource");
406 385
407 386
408 /* 387 /* The number of bytes consumed are Constant */
409 * The number of bytes consumed are Constant 388
410 */
411 *bytes_consumed = 3; 389 *bytes_consumed = 3;
412 output_struct->id = ACPI_RSTYPE_DMA; 390 output_struct->id = ACPI_RSTYPE_DMA;
413 391
414 /* 392 /* Point to the 8-bits of Byte 1 */
415 * Point to the 8-bits of Byte 1 393
416 */
417 buffer += 1; 394 buffer += 1;
418 temp8 = *buffer; 395 temp8 = *buffer;
419 396
@@ -430,46 +407,40 @@ acpi_rs_dma_resource (
430 407
431 output_struct->data.dma.number_of_channels = i; 408 output_struct->data.dma.number_of_channels = i;
432 if (i > 0) { 409 if (i > 0) {
433 /* 410 /* Calculate the structure size based upon the number of interrupts */
434 * Calculate the structure size based upon the number of interrupts 411
435 */
436 struct_size += ((acpi_size) i - 1) * 4; 412 struct_size += ((acpi_size) i - 1) * 4;
437 } 413 }
438 414
439 /* 415 /* Point to Byte 2 */
440 * Point to Byte 2 416
441 */
442 buffer += 1; 417 buffer += 1;
443 temp8 = *buffer; 418 temp8 = *buffer;
444 419
445 /* 420 /* Check for transfer preference (Bits[1:0]) */
446 * Check for transfer preference (Bits[1:0]) 421
447 */
448 output_struct->data.dma.transfer = temp8 & 0x03; 422 output_struct->data.dma.transfer = temp8 & 0x03;
449 423
450 if (0x03 == output_struct->data.dma.transfer) { 424 if (0x03 == output_struct->data.dma.transfer) {
451 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid DMA.Transfer preference (3)\n")); 425 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
426 "Invalid DMA.Transfer preference (3)\n"));
452 return_ACPI_STATUS (AE_BAD_DATA); 427 return_ACPI_STATUS (AE_BAD_DATA);
453 } 428 }
454 429
455 /* 430 /* Get bus master preference (Bit[2]) */
456 * Get bus master preference (Bit[2]) 431
457 */
458 output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01; 432 output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01;
459 433
460 /* 434 /* Get channel speed support (Bits[6:5]) */
461 * Get channel speed support (Bits[6:5]) 435
462 */
463 output_struct->data.dma.type = (temp8 >> 5) & 0x03; 436 output_struct->data.dma.type = (temp8 >> 5) & 0x03;
464 437
465 /* 438 /* Set the Length parameter */
466 * Set the Length parameter 439
467 */
468 output_struct->length = (u32) struct_size; 440 output_struct->length = (u32) struct_size;
469 441
470 /* 442 /* Return the final size of the structure */
471 * Return the final size of the structure 443
472 */
473 *structure_size = struct_size; 444 *structure_size = struct_size;
474 return_ACPI_STATUS (AE_OK); 445 return_ACPI_STATUS (AE_OK);
475} 446}
@@ -506,16 +477,14 @@ acpi_rs_dma_stream (
506 ACPI_FUNCTION_TRACE ("rs_dma_stream"); 477 ACPI_FUNCTION_TRACE ("rs_dma_stream");
507 478
508 479
509 /* 480 /* The descriptor field is static */
510 * The descriptor field is static 481
511 */
512 *buffer = 0x2A; 482 *buffer = 0x2A;
513 buffer += 1; 483 buffer += 1;
514 temp8 = 0; 484 temp8 = 0;
515 485
516 /* 486 /* Loop through all of the Channels and set the mask bits */
517 * Loop through all of the Channels and set the mask bits 487
518 */
519 for (index = 0; 488 for (index = 0;
520 index < linked_list->data.dma.number_of_channels; 489 index < linked_list->data.dma.number_of_channels;
521 index++) { 490 index++) {
@@ -526,9 +495,8 @@ acpi_rs_dma_stream (
526 *buffer = temp8; 495 *buffer = temp8;
527 buffer += 1; 496 buffer += 1;
528 497
529 /* 498 /* Set the DMA Info */
530 * Set the DMA Info 499
531 */
532 temp8 = (u8) ((linked_list->data.dma.type & 0x03) << 5); 500 temp8 = (u8) ((linked_list->data.dma.type & 0x03) << 5);
533 temp8 |= ((linked_list->data.dma.bus_master & 0x01) << 2); 501 temp8 |= ((linked_list->data.dma.bus_master & 0x01) << 2);
534 temp8 |= (linked_list->data.dma.transfer & 0x03); 502 temp8 |= (linked_list->data.dma.transfer & 0x03);
@@ -536,9 +504,8 @@ acpi_rs_dma_stream (
536 *buffer = temp8; 504 *buffer = temp8;
537 buffer += 1; 505 buffer += 1;
538 506
539 /* 507 /* Return the number of bytes consumed in this operation */
540 * Return the number of bytes consumed in this operation 508
541 */
542 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 509 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
543 return_ACPI_STATUS (AE_OK); 510 return_ACPI_STATUS (AE_OK);
544} 511}
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
index fd07a8702fbe..8a2b630be45b 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/resources/rsirq.c
@@ -83,7 +83,8 @@ acpi_rs_irq_resource (
83 u8 temp8 = 0; 83 u8 temp8 = 0;
84 u8 index; 84 u8 index;
85 u8 i; 85 u8 i;
86 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_irq); 86 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
87 struct acpi_resource_irq);
87 88
88 89
89 ACPI_FUNCTION_TRACE ("rs_irq_resource"); 90 ACPI_FUNCTION_TRACE ("rs_irq_resource");
@@ -91,15 +92,14 @@ acpi_rs_irq_resource (
91 92
92 /* 93 /*
93 * The number of bytes consumed are contained in the descriptor 94 * The number of bytes consumed are contained in the descriptor
94 * (Bits:0-1) 95 * (Bits:0-1)
95 */ 96 */
96 temp8 = *buffer; 97 temp8 = *buffer;
97 *bytes_consumed = (temp8 & 0x03) + 1; 98 *bytes_consumed = (temp8 & 0x03) + 1;
98 output_struct->id = ACPI_RSTYPE_IRQ; 99 output_struct->id = ACPI_RSTYPE_IRQ;
99 100
100 /* 101 /* Point to the 16-bits of Bytes 1 and 2 */
101 * Point to the 16-bits of Bytes 1 and 2 102
102 */
103 buffer += 1; 103 buffer += 1;
104 ACPI_MOVE_16_TO_16 (&temp16, buffer); 104 ACPI_MOVE_16_TO_16 (&temp16, buffer);
105 105
@@ -118,22 +118,19 @@ acpi_rs_irq_resource (
118 118
119 output_struct->data.irq.number_of_interrupts = i; 119 output_struct->data.irq.number_of_interrupts = i;
120 if (i > 0) { 120 if (i > 0) {
121 /* 121 /* Calculate the structure size based upon the number of interrupts */
122 * Calculate the structure size based upon the number of interrupts 122
123 */
124 struct_size += ((acpi_size) i - 1) * 4; 123 struct_size += ((acpi_size) i - 1) * 4;
125 } 124 }
126 125
127 /* 126 /* Point to Byte 3 if it is used */
128 * Point to Byte 3 if it is used 127
129 */
130 if (4 == *bytes_consumed) { 128 if (4 == *bytes_consumed) {
131 buffer += 2; 129 buffer += 2;
132 temp8 = *buffer; 130 temp8 = *buffer;
133 131
134 /* 132 /* Check for HE, LL interrupts */
135 * Check for HE, LL interrupts 133
136 */
137 switch (temp8 & 0x09) { 134 switch (temp8 & 0x09) {
138 case 0x01: /* HE */ 135 case 0x01: /* HE */
139 output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; 136 output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
@@ -152,13 +149,13 @@ acpi_rs_irq_resource (
152 * so 0x00 and 0x09 are illegal. 149 * so 0x00 and 0x09 are illegal.
153 */ 150 */
154 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 151 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
155 "Invalid interrupt polarity/trigger in resource list, %X\n", temp8)); 152 "Invalid interrupt polarity/trigger in resource list, %X\n",
153 temp8));
156 return_ACPI_STATUS (AE_BAD_DATA); 154 return_ACPI_STATUS (AE_BAD_DATA);
157 } 155 }
158 156
159 /* 157 /* Check for sharable */
160 * Check for sharable 158
161 */
162 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; 159 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01;
163 } 160 }
164 else { 161 else {
@@ -171,14 +168,12 @@ acpi_rs_irq_resource (
171 output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 168 output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
172 } 169 }
173 170
174 /* 171 /* Set the Length parameter */
175 * Set the Length parameter 172
176 */
177 output_struct->length = (u32) struct_size; 173 output_struct->length = (u32) struct_size;
178 174
179 /* 175 /* Return the final size of the structure */
180 * Return the final size of the structure 176
181 */
182 *structure_size = struct_size; 177 *structure_size = struct_size;
183 return_ACPI_STATUS (AE_OK); 178 return_ACPI_STATUS (AE_OK);
184} 179}
@@ -234,9 +229,8 @@ acpi_rs_irq_stream (
234 buffer += 1; 229 buffer += 1;
235 temp16 = 0; 230 temp16 = 0;
236 231
237 /* 232 /* Loop through all of the interrupts and set the mask bits */
238 * Loop through all of the interrupts and set the mask bits 233
239 */
240 for(index = 0; 234 for(index = 0;
241 index < linked_list->data.irq.number_of_interrupts; 235 index < linked_list->data.irq.number_of_interrupts;
242 index++) { 236 index++) {
@@ -247,9 +241,8 @@ acpi_rs_irq_stream (
247 ACPI_MOVE_16_TO_16 (buffer, &temp16); 241 ACPI_MOVE_16_TO_16 (buffer, &temp16);
248 buffer += 2; 242 buffer += 2;
249 243
250 /* 244 /* Set the IRQ Info byte if needed. */
251 * Set the IRQ Info byte if needed. 245
252 */
253 if (IRqinfo_byte_needed) { 246 if (IRqinfo_byte_needed) {
254 temp8 = 0; 247 temp8 = 0;
255 temp8 = (u8) ((linked_list->data.irq.shared_exclusive & 248 temp8 = (u8) ((linked_list->data.irq.shared_exclusive &
@@ -267,9 +260,8 @@ acpi_rs_irq_stream (
267 buffer += 1; 260 buffer += 1;
268 } 261 }
269 262
270 /* 263 /* Return the number of bytes consumed in this operation */
271 * Return the number of bytes consumed in this operation 264
272 */
273 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 265 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
274 return_ACPI_STATUS (AE_OK); 266 return_ACPI_STATUS (AE_OK);
275} 267}
@@ -309,15 +301,15 @@ acpi_rs_extended_irq_resource (
309 u8 temp8 = 0; 301 u8 temp8 = 0;
310 u8 *temp_ptr; 302 u8 *temp_ptr;
311 u8 index; 303 u8 index;
312 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq); 304 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
305 struct acpi_resource_ext_irq);
313 306
314 307
315 ACPI_FUNCTION_TRACE ("rs_extended_irq_resource"); 308 ACPI_FUNCTION_TRACE ("rs_extended_irq_resource");
316 309
317 310
318 /* 311 /* Point past the Descriptor to get the number of bytes consumed */
319 * Point past the Descriptor to get the number of bytes consumed 312
320 */
321 buffer += 1; 313 buffer += 1;
322 ACPI_MOVE_16_TO_16 (&temp16, buffer); 314 ACPI_MOVE_16_TO_16 (&temp16, buffer);
323 315
@@ -330,9 +322,8 @@ acpi_rs_extended_irq_resource (
330 *bytes_consumed = temp16 + 3; 322 *bytes_consumed = temp16 + 3;
331 output_struct->id = ACPI_RSTYPE_EXT_IRQ; 323 output_struct->id = ACPI_RSTYPE_EXT_IRQ;
332 324
333 /* 325 /* Point to the Byte3 */
334 * Point to the Byte3 326
335 */
336 buffer += 2; 327 buffer += 2;
337 temp8 = *buffer; 328 temp8 = *buffer;
338 329
@@ -347,21 +338,18 @@ acpi_rs_extended_irq_resource (
347 * - Edge/Level are defined opposite in the table vs the headers 338 * - Edge/Level are defined opposite in the table vs the headers
348 */ 339 */
349 output_struct->data.extended_irq.edge_level = 340 output_struct->data.extended_irq.edge_level =
350 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; 341 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
342
343 /* Check Interrupt Polarity */
351 344
352 /*
353 * Check Interrupt Polarity
354 */
355 output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1; 345 output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1;
356 346
357 /* 347 /* Check for sharable */
358 * Check for sharable 348
359 */
360 output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01; 349 output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01;
361 350
362 /* 351 /* Point to Byte4 (IRQ Table length) */
363 * Point to Byte4 (IRQ Table length) 352
364 */
365 buffer += 1; 353 buffer += 1;
366 temp8 = *buffer; 354 temp8 = *buffer;
367 355
@@ -379,14 +367,12 @@ acpi_rs_extended_irq_resource (
379 */ 367 */
380 struct_size += (temp8 - 1) * 4; 368 struct_size += (temp8 - 1) * 4;
381 369
382 /* 370 /* Point to Byte5 (First IRQ Number) */
383 * Point to Byte5 (First IRQ Number) 371
384 */
385 buffer += 1; 372 buffer += 1;
386 373
387 /* 374 /* Cycle through every IRQ in the table */
388 * Cycle through every IRQ in the table 375
389 */
390 for (index = 0; index < temp8; index++) { 376 for (index = 0; index < temp8; index++) {
391 ACPI_MOVE_32_TO_32 ( 377 ACPI_MOVE_32_TO_32 (
392 &output_struct->data.extended_irq.interrupts[index], buffer); 378 &output_struct->data.extended_irq.interrupts[index], buffer);
@@ -407,7 +393,8 @@ acpi_rs_extended_irq_resource (
407 * we add 1 to the length. 393 * we add 1 to the length.
408 */ 394 */
409 if (*bytes_consumed > 395 if (*bytes_consumed >
410 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) + (5 + 1)) { 396 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) +
397 (5 + 1)) {
411 /* Dereference the Index */ 398 /* Dereference the Index */
412 399
413 temp8 = *buffer; 400 temp8 = *buffer;
@@ -417,13 +404,13 @@ acpi_rs_extended_irq_resource (
417 404
418 buffer += 1; 405 buffer += 1;
419 406
420 /* 407 /* Point the String pointer to the end of this structure. */
421 * Point the String pointer to the end of this structure. 408
422 */
423 output_struct->data.extended_irq.resource_source.string_ptr = 409 output_struct->data.extended_irq.resource_source.string_ptr =
424 (char *)((char *) output_struct + struct_size); 410 (char *)((char *) output_struct + struct_size);
425 411
426 temp_ptr = (u8 *) output_struct->data.extended_irq.resource_source.string_ptr; 412 temp_ptr = (u8 *)
413 output_struct->data.extended_irq.resource_source.string_ptr;
427 414
428 /* Copy the string into the buffer */ 415 /* Copy the string into the buffer */
429 416
@@ -436,9 +423,8 @@ acpi_rs_extended_irq_resource (
436 index += 1; 423 index += 1;
437 } 424 }
438 425
439 /* 426 /* Add the terminating null */
440 * Add the terminating null 427
441 */
442 *temp_ptr = 0x00; 428 *temp_ptr = 0x00;
443 output_struct->data.extended_irq.resource_source.string_length = index + 1; 429 output_struct->data.extended_irq.resource_source.string_length = index + 1;
444 430
@@ -456,14 +442,12 @@ acpi_rs_extended_irq_resource (
456 output_struct->data.extended_irq.resource_source.string_ptr = NULL; 442 output_struct->data.extended_irq.resource_source.string_ptr = NULL;
457 } 443 }
458 444
459 /* 445 /* Set the Length parameter */
460 * Set the Length parameter 446
461 */
462 output_struct->length = (u32) struct_size; 447 output_struct->length = (u32) struct_size;
463 448
464 /* 449 /* Return the final size of the structure */
465 * Return the final size of the structure 450
466 */
467 *structure_size = struct_size; 451 *structure_size = struct_size;
468 return_ACPI_STATUS (AE_OK); 452 return_ACPI_STATUS (AE_OK);
469} 453}
@@ -501,21 +485,18 @@ acpi_rs_extended_irq_stream (
501 ACPI_FUNCTION_TRACE ("rs_extended_irq_stream"); 485 ACPI_FUNCTION_TRACE ("rs_extended_irq_stream");
502 486
503 487
504 /* 488 /* The descriptor field is static */
505 * The descriptor field is static 489
506 */
507 *buffer = 0x89; 490 *buffer = 0x89;
508 buffer += 1; 491 buffer += 1;
509 492
510 /* 493 /* Set a pointer to the Length field - to be filled in later */
511 * Set a pointer to the Length field - to be filled in later 494
512 */
513 length_field = ACPI_CAST_PTR (u16, buffer); 495 length_field = ACPI_CAST_PTR (u16, buffer);
514 buffer += 2; 496 buffer += 2;
515 497
516 /* 498 /* Set the Interrupt vector flags */
517 * Set the Interrupt vector flags 499
518 */
519 temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01); 500 temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01);
520 temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3); 501 temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
521 502
@@ -532,17 +513,15 @@ acpi_rs_extended_irq_stream (
532 temp8 |= 0x2; 513 temp8 |= 0x2;
533 } 514 }
534 515
535 /* 516 /* Set the Interrupt Polarity */
536 * Set the Interrupt Polarity 517
537 */
538 temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2); 518 temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2);
539 519
540 *buffer = temp8; 520 *buffer = temp8;
541 buffer += 1; 521 buffer += 1;
542 522
543 /* 523 /* Set the Interrupt table length */
544 * Set the Interrupt table length 524
545 */
546 temp8 = (u8) linked_list->data.extended_irq.number_of_interrupts; 525 temp8 = (u8) linked_list->data.extended_irq.number_of_interrupts;
547 526
548 *buffer = temp8; 527 *buffer = temp8;
@@ -555,18 +534,16 @@ acpi_rs_extended_irq_stream (
555 buffer += 4; 534 buffer += 4;
556 } 535 }
557 536
558 /* 537 /* Resource Source Index and Resource Source are optional */
559 * Resource Source Index and Resource Source are optional 538
560 */
561 if (0 != linked_list->data.extended_irq.resource_source.string_length) { 539 if (0 != linked_list->data.extended_irq.resource_source.string_length) {
562 *buffer = (u8) linked_list->data.extended_irq.resource_source.index; 540 *buffer = (u8) linked_list->data.extended_irq.resource_source.index;
563 buffer += 1; 541 buffer += 1;
564 542
565 temp_pointer = (char *) buffer; 543 temp_pointer = (char *) buffer;
566 544
567 /* 545 /* Copy the string */
568 * Copy the string 546
569 */
570 ACPI_STRCPY (temp_pointer, 547 ACPI_STRCPY (temp_pointer,
571 linked_list->data.extended_irq.resource_source.string_ptr); 548 linked_list->data.extended_irq.resource_source.string_ptr);
572 549
@@ -574,12 +551,12 @@ acpi_rs_extended_irq_stream (
574 * Buffer needs to be set to the length of the sting + one for the 551 * Buffer needs to be set to the length of the sting + one for the
575 * terminating null 552 * terminating null
576 */ 553 */
577 buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1); 554 buffer += (acpi_size) (ACPI_STRLEN (
555 linked_list->data.extended_irq.resource_source.string_ptr) + 1);
578 } 556 }
579 557
580 /* 558 /* Return the number of bytes consumed in this operation */
581 * Return the number of bytes consumed in this operation 559
582 */
583 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 560 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
584 561
585 /* 562 /*
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index e49c1e030f99..db7bcb4e60e3 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -55,7 +55,7 @@
55 * 55 *
56 * PARAMETERS: resource_start_byte - Byte 0 of a resource descriptor 56 * PARAMETERS: resource_start_byte - Byte 0 of a resource descriptor
57 * 57 *
58 * RETURN: The Resource Type (Name) with no extraneous bits 58 * RETURN: The Resource Type with no extraneous bits
59 * 59 *
60 * DESCRIPTION: Extract the Resource Type/Name from the first byte of 60 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
61 * a resource descriptor. 61 * a resource descriptor.
@@ -70,28 +70,25 @@ acpi_rs_get_resource_type (
70 ACPI_FUNCTION_ENTRY (); 70 ACPI_FUNCTION_ENTRY ();
71 71
72 72
73 /* 73 /* Determine if this is a small or large resource */
74 * Determine if this is a small or large resource 74
75 */
76 switch (resource_start_byte & ACPI_RDESC_TYPE_MASK) { 75 switch (resource_start_byte & ACPI_RDESC_TYPE_MASK) {
77 case ACPI_RDESC_TYPE_SMALL: 76 case ACPI_RDESC_TYPE_SMALL:
78 77
79 /* 78 /* Small Resource Type -- Only bits 6:3 are valid */
80 * Small Resource Type -- Only bits 6:3 are valid 79
81 */
82 return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK)); 80 return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK));
83 81
84 82
85 case ACPI_RDESC_TYPE_LARGE: 83 case ACPI_RDESC_TYPE_LARGE:
86 84
87 /* 85 /* Large Resource Type -- All bits are valid */
88 * Large Resource Type -- All bits are valid 86
89 */
90 return (resource_start_byte); 87 return (resource_start_byte);
91 88
92 89
93 default: 90 default:
94 /* No other types of resource descriptor */ 91 /* Invalid type */
95 break; 92 break;
96 } 93 }
97 94
@@ -135,9 +132,8 @@ acpi_rs_byte_stream_to_list (
135 132
136 while (bytes_parsed < byte_stream_buffer_length && 133 while (bytes_parsed < byte_stream_buffer_length &&
137 !end_tag_processed) { 134 !end_tag_processed) {
138 /* 135 /* The next byte in the stream is the resource type */
139 * The next byte in the stream is the resource type 136
140 */
141 resource_type = acpi_rs_get_resource_type (*byte_stream_buffer); 137 resource_type = acpi_rs_get_resource_type (*byte_stream_buffer);
142 138
143 switch (resource_type) { 139 switch (resource_type) {
@@ -299,28 +295,23 @@ acpi_rs_byte_stream_to_list (
299 return_ACPI_STATUS (status); 295 return_ACPI_STATUS (status);
300 } 296 }
301 297
302 /* 298 /* Update the return value and counter */
303 * Update the return value and counter 299
304 */
305 bytes_parsed += bytes_consumed; 300 bytes_parsed += bytes_consumed;
306 301
307 /* 302 /* Set the byte stream to point to the next resource */
308 * Set the byte stream to point to the next resource 303
309 */
310 byte_stream_buffer += bytes_consumed; 304 byte_stream_buffer += bytes_consumed;
311 305
312 /* 306 /* Set the Buffer to the next structure */
313 * Set the Buffer to the next structure 307
314 */
315 resource = ACPI_CAST_PTR (struct acpi_resource, buffer); 308 resource = ACPI_CAST_PTR (struct acpi_resource, buffer);
316 resource->length = (u32) ACPI_ALIGN_RESOURCE_SIZE (resource->length); 309 resource->length = (u32) ACPI_ALIGN_RESOURCE_SIZE (resource->length);
317 buffer += ACPI_ALIGN_RESOURCE_SIZE (structure_size); 310 buffer += ACPI_ALIGN_RESOURCE_SIZE (structure_size);
311 }
318 312
319 } /* end while */ 313 /* Check the reason for exiting the while loop */
320 314
321 /*
322 * Check the reason for exiting the while loop
323 */
324 if (!end_tag_processed) { 315 if (!end_tag_processed) {
325 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 316 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
326 } 317 }
@@ -424,9 +415,8 @@ acpi_rs_list_to_byte_stream (
424 */ 415 */
425 status = acpi_rs_end_tag_stream (linked_list, &buffer, &bytes_consumed); 416 status = acpi_rs_end_tag_stream (linked_list, &buffer, &bytes_consumed);
426 417
427 /* 418 /* An End Tag indicates the end of the Resource Template */
428 * An End Tag indicates the end of the Resource Template 419
429 */
430 done = TRUE; 420 done = TRUE;
431 break; 421 break;
432 422
@@ -488,27 +478,25 @@ acpi_rs_list_to_byte_stream (
488 default: 478 default:
489 /* 479 /*
490 * If we get here, everything is out of sync, 480 * If we get here, everything is out of sync,
491 * so exit with an error 481 * so exit with an error
492 */ 482 */
493 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n", 483 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
484 "Invalid descriptor type (%X) in resource list\n",
494 linked_list->id)); 485 linked_list->id));
495 status = AE_BAD_DATA; 486 status = AE_BAD_DATA;
496 break; 487 break;
497 488 }
498 } /* switch (linked_list->Id) */
499 489
500 if (ACPI_FAILURE (status)) { 490 if (ACPI_FAILURE (status)) {
501 return_ACPI_STATUS (status); 491 return_ACPI_STATUS (status);
502 } 492 }
503 493
504 /* 494 /* Set the Buffer to point to the open byte */
505 * Set the Buffer to point to the open byte 495
506 */
507 buffer += bytes_consumed; 496 buffer += bytes_consumed;
508 497
509 /* 498 /* Point to the next object */
510 * Point to the next object 499
511 */
512 linked_list = ACPI_PTR_ADD (struct acpi_resource, 500 linked_list = ACPI_PTR_ADD (struct acpi_resource,
513 linked_list, linked_list->length); 501 linked_list, linked_list->length);
514 } 502 }
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c
index 7c935aecf075..91d0207f01ac 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/resources/rsmemory.c
@@ -81,15 +81,15 @@ acpi_rs_memory24_resource (
81 struct acpi_resource *output_struct = (void *) *output_buffer; 81 struct acpi_resource *output_struct = (void *) *output_buffer;
82 u16 temp16 = 0; 82 u16 temp16 = 0;
83 u8 temp8 = 0; 83 u8 temp8 = 0;
84 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem24); 84 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
85 struct acpi_resource_mem24);
85 86
86 87
87 ACPI_FUNCTION_TRACE ("rs_memory24_resource"); 88 ACPI_FUNCTION_TRACE ("rs_memory24_resource");
88 89
89 90
90 /* 91 /* Point past the Descriptor to get the number of bytes consumed */
91 * Point past the Descriptor to get the number of bytes consumed 92
92 */
93 buffer += 1; 93 buffer += 1;
94 94
95 ACPI_MOVE_16_TO_16 (&temp16, buffer); 95 ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -97,48 +97,41 @@ acpi_rs_memory24_resource (
97 *bytes_consumed = (acpi_size) temp16 + 3; 97 *bytes_consumed = (acpi_size) temp16 + 3;
98 output_struct->id = ACPI_RSTYPE_MEM24; 98 output_struct->id = ACPI_RSTYPE_MEM24;
99 99
100 /* 100 /* Check Byte 3 the Read/Write bit */
101 * Check Byte 3 the Read/Write bit 101
102 */
103 temp8 = *buffer; 102 temp8 = *buffer;
104 buffer += 1; 103 buffer += 1;
105 output_struct->data.memory24.read_write_attribute = temp8 & 0x01; 104 output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
106 105
107 /* 106 /* Get min_base_address (Bytes 4-5) */
108 * Get min_base_address (Bytes 4-5) 107
109 */
110 ACPI_MOVE_16_TO_16 (&temp16, buffer); 108 ACPI_MOVE_16_TO_16 (&temp16, buffer);
111 buffer += 2; 109 buffer += 2;
112 output_struct->data.memory24.min_base_address = temp16; 110 output_struct->data.memory24.min_base_address = temp16;
113 111
114 /* 112 /* Get max_base_address (Bytes 6-7) */
115 * Get max_base_address (Bytes 6-7) 113
116 */
117 ACPI_MOVE_16_TO_16 (&temp16, buffer); 114 ACPI_MOVE_16_TO_16 (&temp16, buffer);
118 buffer += 2; 115 buffer += 2;
119 output_struct->data.memory24.max_base_address = temp16; 116 output_struct->data.memory24.max_base_address = temp16;
120 117
121 /* 118 /* Get Alignment (Bytes 8-9) */
122 * Get Alignment (Bytes 8-9) 119
123 */
124 ACPI_MOVE_16_TO_16 (&temp16, buffer); 120 ACPI_MOVE_16_TO_16 (&temp16, buffer);
125 buffer += 2; 121 buffer += 2;
126 output_struct->data.memory24.alignment = temp16; 122 output_struct->data.memory24.alignment = temp16;
127 123
128 /* 124 /* Get range_length (Bytes 10-11) */
129 * Get range_length (Bytes 10-11) 125
130 */
131 ACPI_MOVE_16_TO_16 (&temp16, buffer); 126 ACPI_MOVE_16_TO_16 (&temp16, buffer);
132 output_struct->data.memory24.range_length = temp16; 127 output_struct->data.memory24.range_length = temp16;
133 128
134 /* 129 /* Set the Length parameter */
135 * Set the Length parameter 130
136 */
137 output_struct->length = (u32) struct_size; 131 output_struct->length = (u32) struct_size;
138 132
139 /* 133 /* Return the final size of the structure */
140 * Return the final size of the structure 134
141 */
142 *structure_size = struct_size; 135 *structure_size = struct_size;
143 return_ACPI_STATUS (AE_OK); 136 return_ACPI_STATUS (AE_OK);
144} 137}
@@ -174,53 +167,45 @@ acpi_rs_memory24_stream (
174 ACPI_FUNCTION_TRACE ("rs_memory24_stream"); 167 ACPI_FUNCTION_TRACE ("rs_memory24_stream");
175 168
176 169
177 /* 170 /* The descriptor field is static */
178 * The descriptor field is static 171
179 */
180 *buffer = 0x81; 172 *buffer = 0x81;
181 buffer += 1; 173 buffer += 1;
182 174
183 /* 175 /* The length field is static */
184 * The length field is static 176
185 */
186 temp16 = 0x09; 177 temp16 = 0x09;
187 ACPI_MOVE_16_TO_16 (buffer, &temp16); 178 ACPI_MOVE_16_TO_16 (buffer, &temp16);
188 buffer += 2; 179 buffer += 2;
189 180
190 /* 181 /* Set the Information Byte */
191 * Set the Information Byte 182
192 */
193 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01); 183 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01);
194 *buffer = temp8; 184 *buffer = temp8;
195 buffer += 1; 185 buffer += 1;
196 186
197 /* 187 /* Set the Range minimum base address */
198 * Set the Range minimum base address 188
199 */
200 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address); 189 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
201 buffer += 2; 190 buffer += 2;
202 191
203 /* 192 /* Set the Range maximum base address */
204 * Set the Range maximum base address 193
205 */
206 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address); 194 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
207 buffer += 2; 195 buffer += 2;
208 196
209 /* 197 /* Set the base alignment */
210 * Set the base alignment 198
211 */
212 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment); 199 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment);
213 buffer += 2; 200 buffer += 2;
214 201
215 /* 202 /* Set the range length */
216 * Set the range length 203
217 */
218 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length); 204 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length);
219 buffer += 2; 205 buffer += 2;
220 206
221 /* 207 /* Return the number of bytes consumed in this operation */
222 * Return the number of bytes consumed in this operation 208
223 */
224 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 209 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
225 return_ACPI_STATUS (AE_OK); 210 return_ACPI_STATUS (AE_OK);
226} 211}
@@ -258,15 +243,15 @@ acpi_rs_memory32_range_resource (
258 struct acpi_resource *output_struct = (void *) *output_buffer; 243 struct acpi_resource *output_struct = (void *) *output_buffer;
259 u16 temp16 = 0; 244 u16 temp16 = 0;
260 u8 temp8 = 0; 245 u8 temp8 = 0;
261 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32); 246 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
247 struct acpi_resource_mem32);
262 248
263 249
264 ACPI_FUNCTION_TRACE ("rs_memory32_range_resource"); 250 ACPI_FUNCTION_TRACE ("rs_memory32_range_resource");
265 251
266 252
267 /* 253 /* Point past the Descriptor to get the number of bytes consumed */
268 * Point past the Descriptor to get the number of bytes consumed 254
269 */
270 buffer += 1; 255 buffer += 1;
271 256
272 ACPI_MOVE_16_TO_16 (&temp16, buffer); 257 ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -285,45 +270,38 @@ acpi_rs_memory32_range_resource (
285 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8) 270 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
286 */ 271 */
287 272
288 /* 273 /* Check Byte 3 the Read/Write bit */
289 * Check Byte 3 the Read/Write bit 274
290 */
291 temp8 = *buffer; 275 temp8 = *buffer;
292 buffer += 1; 276 buffer += 1;
293 277
294 output_struct->data.memory32.read_write_attribute = temp8 & 0x01; 278 output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
295 279
296 /* 280 /* Get min_base_address (Bytes 4-7) */
297 * Get min_base_address (Bytes 4-7) 281
298 */
299 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer); 282 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer);
300 buffer += 4; 283 buffer += 4;
301 284
302 /* 285 /* Get max_base_address (Bytes 8-11) */
303 * Get max_base_address (Bytes 8-11) 286
304 */
305 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer); 287 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer);
306 buffer += 4; 288 buffer += 4;
307 289
308 /* 290 /* Get Alignment (Bytes 12-15) */
309 * Get Alignment (Bytes 12-15) 291
310 */
311 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer); 292 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer);
312 buffer += 4; 293 buffer += 4;
313 294
314 /* 295 /* Get range_length (Bytes 16-19) */
315 * Get range_length (Bytes 16-19) 296
316 */
317 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer); 297 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer);
318 298
319 /* 299 /* Set the Length parameter */
320 * Set the Length parameter 300
321 */
322 output_struct->length = (u32) struct_size; 301 output_struct->length = (u32) struct_size;
323 302
324 /* 303 /* Return the final size of the structure */
325 * Return the final size of the structure 304
326 */
327 *structure_size = struct_size; 305 *structure_size = struct_size;
328 return_ACPI_STATUS (AE_OK); 306 return_ACPI_STATUS (AE_OK);
329} 307}
@@ -361,15 +339,15 @@ acpi_rs_fixed_memory32_resource (
361 struct acpi_resource *output_struct = (void *) *output_buffer; 339 struct acpi_resource *output_struct = (void *) *output_buffer;
362 u16 temp16 = 0; 340 u16 temp16 = 0;
363 u8 temp8 = 0; 341 u8 temp8 = 0;
364 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_mem32); 342 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
343 struct acpi_resource_fixed_mem32);
365 344
366 345
367 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource"); 346 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource");
368 347
369 348
370 /* 349 /* Point past the Descriptor to get the number of bytes consumed */
371 * Point past the Descriptor to get the number of bytes consumed 350
372 */
373 buffer += 1; 351 buffer += 1;
374 ACPI_MOVE_16_TO_16 (&temp16, buffer); 352 ACPI_MOVE_16_TO_16 (&temp16, buffer);
375 353
@@ -378,32 +356,28 @@ acpi_rs_fixed_memory32_resource (
378 356
379 output_struct->id = ACPI_RSTYPE_FIXED_MEM32; 357 output_struct->id = ACPI_RSTYPE_FIXED_MEM32;
380 358
381 /* 359 /* Check Byte 3 the Read/Write bit */
382 * Check Byte 3 the Read/Write bit 360
383 */
384 temp8 = *buffer; 361 temp8 = *buffer;
385 buffer += 1; 362 buffer += 1;
386 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01; 363 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
387 364
388 /* 365 /* Get range_base_address (Bytes 4-7) */
389 * Get range_base_address (Bytes 4-7) 366
390 */ 367 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address,
391 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, buffer); 368 buffer);
392 buffer += 4; 369 buffer += 4;
393 370
394 /* 371 /* Get range_length (Bytes 8-11) */
395 * Get range_length (Bytes 8-11) 372
396 */
397 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer); 373 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer);
398 374
399 /* 375 /* Set the Length parameter */
400 * Set the Length parameter 376
401 */
402 output_struct->length = (u32) struct_size; 377 output_struct->length = (u32) struct_size;
403 378
404 /* 379 /* Return the final size of the structure */
405 * Return the final size of the structure 380
406 */
407 *structure_size = struct_size; 381 *structure_size = struct_size;
408 return_ACPI_STATUS (AE_OK); 382 return_ACPI_STATUS (AE_OK);
409} 383}
@@ -439,54 +413,46 @@ acpi_rs_memory32_range_stream (
439 ACPI_FUNCTION_TRACE ("rs_memory32_range_stream"); 413 ACPI_FUNCTION_TRACE ("rs_memory32_range_stream");
440 414
441 415
442 /* 416 /* The descriptor field is static */
443 * The descriptor field is static 417
444 */
445 *buffer = 0x85; 418 *buffer = 0x85;
446 buffer += 1; 419 buffer += 1;
447 420
448 /* 421 /* The length field is static */
449 * The length field is static 422
450 */
451 temp16 = 0x11; 423 temp16 = 0x11;
452 424
453 ACPI_MOVE_16_TO_16 (buffer, &temp16); 425 ACPI_MOVE_16_TO_16 (buffer, &temp16);
454 buffer += 2; 426 buffer += 2;
455 427
456 /* 428 /* Set the Information Byte */
457 * Set the Information Byte 429
458 */
459 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01); 430 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
460 *buffer = temp8; 431 *buffer = temp8;
461 buffer += 1; 432 buffer += 1;
462 433
463 /* 434 /* Set the Range minimum base address */
464 * Set the Range minimum base address 435
465 */
466 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address); 436 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
467 buffer += 4; 437 buffer += 4;
468 438
469 /* 439 /* Set the Range maximum base address */
470 * Set the Range maximum base address 440
471 */
472 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address); 441 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
473 buffer += 4; 442 buffer += 4;
474 443
475 /* 444 /* Set the base alignment */
476 * Set the base alignment 445
477 */
478 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment); 446 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment);
479 buffer += 4; 447 buffer += 4;
480 448
481 /* 449 /* Set the range length */
482 * Set the range length 450
483 */
484 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length); 451 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length);
485 buffer += 4; 452 buffer += 4;
486 453
487 /* 454 /* Return the number of bytes consumed in this operation */
488 * Return the number of bytes consumed in this operation 455
489 */
490 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 456 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
491 return_ACPI_STATUS (AE_OK); 457 return_ACPI_STATUS (AE_OK);
492} 458}
@@ -522,44 +488,38 @@ acpi_rs_fixed_memory32_stream (
522 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream"); 488 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream");
523 489
524 490
525 /* 491 /* The descriptor field is static */
526 * The descriptor field is static 492
527 */
528 *buffer = 0x86; 493 *buffer = 0x86;
529 buffer += 1; 494 buffer += 1;
530 495
531 /* 496 /* The length field is static */
532 * The length field is static 497
533 */
534 temp16 = 0x09; 498 temp16 = 0x09;
535 499
536 ACPI_MOVE_16_TO_16 (buffer, &temp16); 500 ACPI_MOVE_16_TO_16 (buffer, &temp16);
537 buffer += 2; 501 buffer += 2;
538 502
539 /* 503 /* Set the Information Byte */
540 * Set the Information Byte 504
541 */
542 temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01); 505 temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
543 *buffer = temp8; 506 *buffer = temp8;
544 buffer += 1; 507 buffer += 1;
545 508
546 /* 509 /* Set the Range base address */
547 * Set the Range base address 510
548 */
549 ACPI_MOVE_32_TO_32 (buffer, 511 ACPI_MOVE_32_TO_32 (buffer,
550 &linked_list->data.fixed_memory32.range_base_address); 512 &linked_list->data.fixed_memory32.range_base_address);
551 buffer += 4; 513 buffer += 4;
552 514
553 /* 515 /* Set the range length */
554 * Set the range length 516
555 */
556 ACPI_MOVE_32_TO_32 (buffer, 517 ACPI_MOVE_32_TO_32 (buffer,
557 &linked_list->data.fixed_memory32.range_length); 518 &linked_list->data.fixed_memory32.range_length);
558 buffer += 4; 519 buffer += 4;
559 520
560 /* 521 /* Return the number of bytes consumed in this operation */
561 * Return the number of bytes consumed in this operation 522
562 */
563 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 523 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
564 return_ACPI_STATUS (AE_OK); 524 return_ACPI_STATUS (AE_OK);
565} 525}
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
index d16be44b5df7..a1f1741f0d83 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/resources/rsmisc.c
@@ -84,24 +84,20 @@ acpi_rs_end_tag_resource (
84 ACPI_FUNCTION_TRACE ("rs_end_tag_resource"); 84 ACPI_FUNCTION_TRACE ("rs_end_tag_resource");
85 85
86 86
87 /* 87 /* The number of bytes consumed is static */
88 * The number of bytes consumed is static 88
89 */
90 *bytes_consumed = 2; 89 *bytes_consumed = 2;
91 90
92 /* 91 /* Fill out the structure */
93 * Fill out the structure 92
94 */
95 output_struct->id = ACPI_RSTYPE_END_TAG; 93 output_struct->id = ACPI_RSTYPE_END_TAG;
96 94
97 /* 95 /* Set the Length parameter */
98 * Set the Length parameter 96
99 */
100 output_struct->length = 0; 97 output_struct->length = 0;
101 98
102 /* 99 /* Return the final size of the structure */
103 * Return the final size of the structure 100
104 */
105 *structure_size = struct_size; 101 *structure_size = struct_size;
106 return_ACPI_STATUS (AE_OK); 102 return_ACPI_STATUS (AE_OK);
107} 103}
@@ -136,9 +132,8 @@ acpi_rs_end_tag_stream (
136 ACPI_FUNCTION_TRACE ("rs_end_tag_stream"); 132 ACPI_FUNCTION_TRACE ("rs_end_tag_stream");
137 133
138 134
139 /* 135 /* The descriptor field is static */
140 * The descriptor field is static 136
141 */
142 *buffer = 0x79; 137 *buffer = 0x79;
143 buffer += 1; 138 buffer += 1;
144 139
@@ -151,9 +146,8 @@ acpi_rs_end_tag_stream (
151 *buffer = temp8; 146 *buffer = temp8;
152 buffer += 1; 147 buffer += 1;
153 148
154 /* 149 /* Return the number of bytes consumed in this operation */
155 * Return the number of bytes consumed in this operation 150
156 */
157 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 151 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
158 return_ACPI_STATUS (AE_OK); 152 return_ACPI_STATUS (AE_OK);
159} 153}
@@ -192,21 +186,20 @@ acpi_rs_vendor_resource (
192 u16 temp16 = 0; 186 u16 temp16 = 0;
193 u8 temp8 = 0; 187 u8 temp8 = 0;
194 u8 index; 188 u8 index;
195 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor); 189 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
190 struct acpi_resource_vendor);
196 191
197 192
198 ACPI_FUNCTION_TRACE ("rs_vendor_resource"); 193 ACPI_FUNCTION_TRACE ("rs_vendor_resource");
199 194
200 195
201 /* 196 /* Dereference the Descriptor to find if this is a large or small item. */
202 * Dereference the Descriptor to find if this is a large or small item. 197
203 */
204 temp8 = *buffer; 198 temp8 = *buffer;
205 199
206 if (temp8 & 0x80) { 200 if (temp8 & 0x80) {
207 /* 201 /* Large Item, point to the length field */
208 * Large Item, point to the length field 202
209 */
210 buffer += 1; 203 buffer += 1;
211 204
212 /* Dereference */ 205 /* Dereference */
@@ -222,9 +215,8 @@ acpi_rs_vendor_resource (
222 buffer += 2; 215 buffer += 2;
223 } 216 }
224 else { 217 else {
225 /* 218 /* Small Item, dereference the size */
226 * Small Item, dereference the size 219
227 */
228 temp16 = (u8)(*buffer & 0x07); 220 temp16 = (u8)(*buffer & 0x07);
229 221
230 /* Calculate bytes consumed */ 222 /* Calculate bytes consumed */
@@ -251,14 +243,12 @@ acpi_rs_vendor_resource (
251 */ 243 */
252 struct_size += ACPI_ROUND_UP_to_32_bITS (temp16); 244 struct_size += ACPI_ROUND_UP_to_32_bITS (temp16);
253 245
254 /* 246 /* Set the Length parameter */
255 * Set the Length parameter 247
256 */
257 output_struct->length = (u32) struct_size; 248 output_struct->length = (u32) struct_size;
258 249
259 /* 250 /* Return the final size of the structure */
260 * Return the final size of the structure 251
261 */
262 *structure_size = struct_size; 252 *structure_size = struct_size;
263 return_ACPI_STATUS (AE_OK); 253 return_ACPI_STATUS (AE_OK);
264} 254}
@@ -295,13 +285,11 @@ acpi_rs_vendor_stream (
295 ACPI_FUNCTION_TRACE ("rs_vendor_stream"); 285 ACPI_FUNCTION_TRACE ("rs_vendor_stream");
296 286
297 287
298 /* 288 /* Dereference the length to find if this is a large or small item. */
299 * Dereference the length to find if this is a large or small item. 289
300 */
301 if(linked_list->data.vendor_specific.length > 7) { 290 if(linked_list->data.vendor_specific.length > 7) {
302 /* 291 /* Large Item, Set the descriptor field and length bytes */
303 * Large Item, Set the descriptor field and length bytes 292
304 */
305 *buffer = 0x84; 293 *buffer = 0x84;
306 buffer += 1; 294 buffer += 1;
307 295
@@ -311,9 +299,8 @@ acpi_rs_vendor_stream (
311 buffer += 2; 299 buffer += 2;
312 } 300 }
313 else { 301 else {
314 /* 302 /* Small Item, Set the descriptor field */
315 * Small Item, Set the descriptor field 303
316 */
317 temp8 = 0x70; 304 temp8 = 0x70;
318 temp8 |= (u8) linked_list->data.vendor_specific.length; 305 temp8 |= (u8) linked_list->data.vendor_specific.length;
319 306
@@ -321,9 +308,8 @@ acpi_rs_vendor_stream (
321 buffer += 1; 308 buffer += 1;
322 } 309 }
323 310
324 /* 311 /* Loop through all of the Vendor Specific fields */
325 * Loop through all of the Vendor Specific fields 312
326 */
327 for (index = 0; index < linked_list->data.vendor_specific.length; index++) { 313 for (index = 0; index < linked_list->data.vendor_specific.length; index++) {
328 temp8 = linked_list->data.vendor_specific.reserved[index]; 314 temp8 = linked_list->data.vendor_specific.reserved[index];
329 315
@@ -331,9 +317,8 @@ acpi_rs_vendor_stream (
331 buffer += 1; 317 buffer += 1;
332 } 318 }
333 319
334 /* 320 /* Return the number of bytes consumed in this operation */
335 * Return the number of bytes consumed in this operation 321
336 */
337 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 322 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
338 return_ACPI_STATUS (AE_OK); 323 return_ACPI_STATUS (AE_OK);
339} 324}
@@ -370,40 +355,37 @@ acpi_rs_start_depend_fns_resource (
370 u8 *buffer = byte_stream_buffer; 355 u8 *buffer = byte_stream_buffer;
371 struct acpi_resource *output_struct = (void *) *output_buffer; 356 struct acpi_resource *output_struct = (void *) *output_buffer;
372 u8 temp8 = 0; 357 u8 temp8 = 0;
373 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_start_dpf); 358 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
359 struct acpi_resource_start_dpf);
374 360
375 361
376 ACPI_FUNCTION_TRACE ("rs_start_depend_fns_resource"); 362 ACPI_FUNCTION_TRACE ("rs_start_depend_fns_resource");
377 363
378 364
379 /* 365 /* The number of bytes consumed are found in the descriptor (Bits:0-1) */
380 * The number of bytes consumed are contained in the descriptor (Bits:0-1) 366
381 */
382 temp8 = *buffer; 367 temp8 = *buffer;
383 368
384 *bytes_consumed = (temp8 & 0x01) + 1; 369 *bytes_consumed = (temp8 & 0x01) + 1;
385 370
386 output_struct->id = ACPI_RSTYPE_START_DPF; 371 output_struct->id = ACPI_RSTYPE_START_DPF;
387 372
388 /* 373 /* Point to Byte 1 if it is used */
389 * Point to Byte 1 if it is used 374
390 */
391 if (2 == *bytes_consumed) { 375 if (2 == *bytes_consumed) {
392 buffer += 1; 376 buffer += 1;
393 temp8 = *buffer; 377 temp8 = *buffer;
394 378
395 /* 379 /* Check Compatibility priority */
396 * Check Compatibility priority 380
397 */
398 output_struct->data.start_dpf.compatibility_priority = temp8 & 0x03; 381 output_struct->data.start_dpf.compatibility_priority = temp8 & 0x03;
399 382
400 if (3 == output_struct->data.start_dpf.compatibility_priority) { 383 if (3 == output_struct->data.start_dpf.compatibility_priority) {
401 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); 384 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
402 } 385 }
403 386
404 /* 387 /* Check Performance/Robustness preference */
405 * Check Performance/Robustness preference 388
406 */
407 output_struct->data.start_dpf.performance_robustness = (temp8 >> 2) & 0x03; 389 output_struct->data.start_dpf.performance_robustness = (temp8 >> 2) & 0x03;
408 390
409 if (3 == output_struct->data.start_dpf.performance_robustness) { 391 if (3 == output_struct->data.start_dpf.performance_robustness) {
@@ -412,20 +394,18 @@ acpi_rs_start_depend_fns_resource (
412 } 394 }
413 else { 395 else {
414 output_struct->data.start_dpf.compatibility_priority = 396 output_struct->data.start_dpf.compatibility_priority =
415 ACPI_ACCEPTABLE_CONFIGURATION; 397 ACPI_ACCEPTABLE_CONFIGURATION;
416 398
417 output_struct->data.start_dpf.performance_robustness = 399 output_struct->data.start_dpf.performance_robustness =
418 ACPI_ACCEPTABLE_CONFIGURATION; 400 ACPI_ACCEPTABLE_CONFIGURATION;
419 } 401 }
420 402
421 /* 403 /* Set the Length parameter */
422 * Set the Length parameter 404
423 */
424 output_struct->length = (u32) struct_size; 405 output_struct->length = (u32) struct_size;
425 406
426 /* 407 /* Return the final size of the structure */
427 * Return the final size of the structure 408
428 */
429 *structure_size = struct_size; 409 *structure_size = struct_size;
430 return_ACPI_STATUS (AE_OK); 410 return_ACPI_STATUS (AE_OK);
431} 411}
@@ -466,24 +446,20 @@ acpi_rs_end_depend_fns_resource (
466 ACPI_FUNCTION_TRACE ("rs_end_depend_fns_resource"); 446 ACPI_FUNCTION_TRACE ("rs_end_depend_fns_resource");
467 447
468 448
469 /* 449 /* The number of bytes consumed is static */
470 * The number of bytes consumed is static 450
471 */
472 *bytes_consumed = 1; 451 *bytes_consumed = 1;
473 452
474 /* 453 /* Fill out the structure */
475 * Fill out the structure 454
476 */
477 output_struct->id = ACPI_RSTYPE_END_DPF; 455 output_struct->id = ACPI_RSTYPE_END_DPF;
478 456
479 /* 457 /* Set the Length parameter */
480 * Set the Length parameter 458
481 */
482 output_struct->length = (u32) struct_size; 459 output_struct->length = (u32) struct_size;
483 460
484 /* 461 /* Return the final size of the structure */
485 * Return the final size of the structure 462
486 */
487 *structure_size = struct_size; 463 *structure_size = struct_size;
488 return_ACPI_STATUS (AE_OK); 464 return_ACPI_STATUS (AE_OK);
489} 465}
@@ -533,9 +509,8 @@ acpi_rs_start_depend_fns_stream (
533 *buffer = 0x31; 509 *buffer = 0x31;
534 buffer += 1; 510 buffer += 1;
535 511
536 /* 512 /* Set the Priority Byte Definition */
537 * Set the Priority Byte Definition 513
538 */
539 temp8 = 0; 514 temp8 = 0;
540 temp8 = (u8) ((linked_list->data.start_dpf.performance_robustness & 515 temp8 = (u8) ((linked_list->data.start_dpf.performance_robustness &
541 0x03) << 2); 516 0x03) << 2);
@@ -546,9 +521,8 @@ acpi_rs_start_depend_fns_stream (
546 521
547 buffer += 1; 522 buffer += 1;
548 523
549 /* 524 /* Return the number of bytes consumed in this operation */
550 * Return the number of bytes consumed in this operation 525
551 */
552 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 526 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
553 return_ACPI_STATUS (AE_OK); 527 return_ACPI_STATUS (AE_OK);
554} 528}
@@ -582,15 +556,13 @@ acpi_rs_end_depend_fns_stream (
582 ACPI_FUNCTION_TRACE ("rs_end_depend_fns_stream"); 556 ACPI_FUNCTION_TRACE ("rs_end_depend_fns_stream");
583 557
584 558
585 /* 559 /* The descriptor field is static */
586 * The descriptor field is static 560
587 */
588 *buffer = 0x38; 561 *buffer = 0x38;
589 buffer += 1; 562 buffer += 1;
590 563
591 /* 564 /* Return the number of bytes consumed in this operation */
592 * Return the number of bytes consumed in this operation 565
593 */
594 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer); 566 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
595 return_ACPI_STATUS (AE_OK); 567 return_ACPI_STATUS (AE_OK);
596} 568}
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index ee9ce13c053d..700cf7d65d76 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -83,10 +83,10 @@ acpi_rs_get_prt_method_data (
83 83
84 /* Parameters guaranteed valid by caller */ 84 /* Parameters guaranteed valid by caller */
85 85
86 /* 86 /* Execute the method, no parameters */
87 * Execute the method, no parameters 87
88 */ 88 status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRT,
89 status = acpi_ut_evaluate_object (handle, "_PRT", ACPI_BTYPE_PACKAGE, &obj_desc); 89 ACPI_BTYPE_PACKAGE, &obj_desc);
90 if (ACPI_FAILURE (status)) { 90 if (ACPI_FAILURE (status)) {
91 return_ACPI_STATUS (status); 91 return_ACPI_STATUS (status);
92 } 92 }
@@ -136,10 +136,10 @@ acpi_rs_get_crs_method_data (
136 136
137 /* Parameters guaranteed valid by caller */ 137 /* Parameters guaranteed valid by caller */
138 138
139 /* 139 /* Execute the method, no parameters */
140 * Execute the method, no parameters 140
141 */ 141 status = acpi_ut_evaluate_object (handle, METHOD_NAME__CRS,
142 status = acpi_ut_evaluate_object (handle, "_CRS", ACPI_BTYPE_BUFFER, &obj_desc); 142 ACPI_BTYPE_BUFFER, &obj_desc);
143 if (ACPI_FAILURE (status)) { 143 if (ACPI_FAILURE (status)) {
144 return_ACPI_STATUS (status); 144 return_ACPI_STATUS (status);
145 } 145 }
@@ -175,6 +175,7 @@ acpi_rs_get_crs_method_data (
175 * and the contents of the callers buffer is undefined. 175 * and the contents of the callers buffer is undefined.
176 * 176 *
177 ******************************************************************************/ 177 ******************************************************************************/
178
178#ifdef ACPI_FUTURE_USAGE 179#ifdef ACPI_FUTURE_USAGE
179acpi_status 180acpi_status
180acpi_rs_get_prs_method_data ( 181acpi_rs_get_prs_method_data (
@@ -190,10 +191,10 @@ acpi_rs_get_prs_method_data (
190 191
191 /* Parameters guaranteed valid by caller */ 192 /* Parameters guaranteed valid by caller */
192 193
193 /* 194 /* Execute the method, no parameters */
194 * Execute the method, no parameters 195
195 */ 196 status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRS,
196 status = acpi_ut_evaluate_object (handle, "_PRS", ACPI_BTYPE_BUFFER, &obj_desc); 197 ACPI_BTYPE_BUFFER, &obj_desc);
197 if (ACPI_FAILURE (status)) { 198 if (ACPI_FAILURE (status)) {
198 return_ACPI_STATUS (status); 199 return_ACPI_STATUS (status);
199 } 200 }
@@ -218,6 +219,7 @@ acpi_rs_get_prs_method_data (
218 * FUNCTION: acpi_rs_get_method_data 219 * FUNCTION: acpi_rs_get_method_data
219 * 220 *
220 * PARAMETERS: Handle - a handle to the containing object 221 * PARAMETERS: Handle - a handle to the containing object
222 * Path - Path to method, relative to Handle
221 * ret_buffer - a pointer to a buffer structure for the 223 * ret_buffer - a pointer to a buffer structure for the
222 * results 224 * results
223 * 225 *
@@ -246,9 +248,8 @@ acpi_rs_get_method_data (
246 248
247 /* Parameters guaranteed valid by caller */ 249 /* Parameters guaranteed valid by caller */
248 250
249 /* 251 /* Execute the method, no parameters */
250 * Execute the method, no parameters 252
251 */
252 status = acpi_ut_evaluate_object (handle, path, ACPI_BTYPE_BUFFER, &obj_desc); 253 status = acpi_ut_evaluate_object (handle, path, ACPI_BTYPE_BUFFER, &obj_desc);
253 if (ACPI_FAILURE (status)) { 254 if (ACPI_FAILURE (status)) {
254 return_ACPI_STATUS (status); 255 return_ACPI_STATUS (status);
@@ -314,18 +315,16 @@ acpi_rs_set_srs_method_data (
314 return_ACPI_STATUS (status); 315 return_ACPI_STATUS (status);
315 } 316 }
316 317
317 /* 318 /* Init the param object */
318 * Init the param object 319
319 */
320 params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); 320 params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
321 if (!params[0]) { 321 if (!params[0]) {
322 acpi_os_free (buffer.pointer); 322 acpi_os_free (buffer.pointer);
323 return_ACPI_STATUS (AE_NO_MEMORY); 323 return_ACPI_STATUS (AE_NO_MEMORY);
324 } 324 }
325 325
326 /* 326 /* Set up the parameter object */
327 * Set up the parameter object 327
328 */
329 params[0]->buffer.length = (u32) buffer.length; 328 params[0]->buffer.length = (u32) buffer.length;
330 params[0]->buffer.pointer = buffer.pointer; 329 params[0]->buffer.pointer = buffer.pointer;
331 params[0]->common.flags = AOPOBJ_DATA_VALID; 330 params[0]->common.flags = AOPOBJ_DATA_VALID;
@@ -335,10 +334,9 @@ acpi_rs_set_srs_method_data (
335 info.parameters = params; 334 info.parameters = params;
336 info.parameter_type = ACPI_PARAM_ARGS; 335 info.parameter_type = ACPI_PARAM_ARGS;
337 336
338 /* 337 /* Execute the method, no return value */
339 * Execute the method, no return value 338
340 */ 339 status = acpi_ns_evaluate_relative (METHOD_NAME__SRS, &info);
341 status = acpi_ns_evaluate_relative ("_SRS", &info);
342 if (ACPI_SUCCESS (status)) { 340 if (ACPI_SUCCESS (status)) {
343 /* Delete any return object (especially if implicit_return is enabled) */ 341 /* Delete any return object (especially if implicit_return is enabled) */
344 342
@@ -347,9 +345,8 @@ acpi_rs_set_srs_method_data (
347 } 345 }
348 } 346 }
349 347
350 /* 348 /* Clean up and return the status from acpi_ns_evaluate_relative */
351 * Clean up and return the status from acpi_ns_evaluate_relative 349
352 */
353 acpi_ut_remove_reference (params[0]); 350 acpi_ut_remove_reference (params[0]);
354 return_ACPI_STATUS (status); 351 return_ACPI_STATUS (status);
355} 352}
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index a9cdcbeb3432..83c944b8b097 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -49,6 +49,23 @@
49#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
50 ACPI_MODULE_NAME ("rsxface") 50 ACPI_MODULE_NAME ("rsxface")
51 51
52/* Local macros for 16,32-bit to 64-bit conversion */
53
54#define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field)
55#define ACPI_COPY_ADDRESS(out, in) \
56 ACPI_COPY_FIELD(out, in, resource_type); \
57 ACPI_COPY_FIELD(out, in, producer_consumer); \
58 ACPI_COPY_FIELD(out, in, decode); \
59 ACPI_COPY_FIELD(out, in, min_address_fixed); \
60 ACPI_COPY_FIELD(out, in, max_address_fixed); \
61 ACPI_COPY_FIELD(out, in, attribute); \
62 ACPI_COPY_FIELD(out, in, granularity); \
63 ACPI_COPY_FIELD(out, in, min_address_range); \
64 ACPI_COPY_FIELD(out, in, max_address_range); \
65 ACPI_COPY_FIELD(out, in, address_translation_offset); \
66 ACPI_COPY_FIELD(out, in, address_length); \
67 ACPI_COPY_FIELD(out, in, resource_source);
68
52 69
53/******************************************************************************* 70/*******************************************************************************
54 * 71 *
@@ -180,6 +197,7 @@ EXPORT_SYMBOL(acpi_get_current_resources);
180 * and the value of ret_buffer is undefined. 197 * and the value of ret_buffer is undefined.
181 * 198 *
182 ******************************************************************************/ 199 ******************************************************************************/
200
183#ifdef ACPI_FUTURE_USAGE 201#ifdef ACPI_FUTURE_USAGE
184acpi_status 202acpi_status
185acpi_get_possible_resources ( 203acpi_get_possible_resources (
@@ -346,9 +364,8 @@ acpi_set_current_resources (
346 ACPI_FUNCTION_TRACE ("acpi_set_current_resources"); 364 ACPI_FUNCTION_TRACE ("acpi_set_current_resources");
347 365
348 366
349 /* 367 /* Must have a valid handle and buffer */
350 * Must have a valid handle and buffer 368
351 */
352 if ((!device_handle) || 369 if ((!device_handle) ||
353 (!in_buffer) || 370 (!in_buffer) ||
354 (!in_buffer->pointer) || 371 (!in_buffer->pointer) ||
@@ -362,21 +379,6 @@ acpi_set_current_resources (
362EXPORT_SYMBOL(acpi_set_current_resources); 379EXPORT_SYMBOL(acpi_set_current_resources);
363 380
364 381
365#define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field)
366#define ACPI_COPY_ADDRESS(out, in) \
367 ACPI_COPY_FIELD(out, in, resource_type); \
368 ACPI_COPY_FIELD(out, in, producer_consumer); \
369 ACPI_COPY_FIELD(out, in, decode); \
370 ACPI_COPY_FIELD(out, in, min_address_fixed); \
371 ACPI_COPY_FIELD(out, in, max_address_fixed); \
372 ACPI_COPY_FIELD(out, in, attribute); \
373 ACPI_COPY_FIELD(out, in, granularity); \
374 ACPI_COPY_FIELD(out, in, min_address_range); \
375 ACPI_COPY_FIELD(out, in, max_address_range); \
376 ACPI_COPY_FIELD(out, in, address_translation_offset); \
377 ACPI_COPY_FIELD(out, in, address_length); \
378 ACPI_COPY_FIELD(out, in, resource_source);
379
380/****************************************************************************** 382/******************************************************************************
381 * 383 *
382 * FUNCTION: acpi_resource_to_address64 384 * FUNCTION: acpi_resource_to_address64
@@ -408,14 +410,14 @@ acpi_resource_to_address64 (
408 case ACPI_RSTYPE_ADDRESS16: 410 case ACPI_RSTYPE_ADDRESS16:
409 411
410 address16 = (struct acpi_resource_address16 *) &resource->data; 412 address16 = (struct acpi_resource_address16 *) &resource->data;
411 ACPI_COPY_ADDRESS(out, address16); 413 ACPI_COPY_ADDRESS (out, address16);
412 break; 414 break;
413 415
414 416
415 case ACPI_RSTYPE_ADDRESS32: 417 case ACPI_RSTYPE_ADDRESS32:
416 418
417 address32 = (struct acpi_resource_address32 *) &resource->data; 419 address32 = (struct acpi_resource_address32 *) &resource->data;
418 ACPI_COPY_ADDRESS(out, address32); 420 ACPI_COPY_ADDRESS (out, address32);
419 break; 421 break;
420 422
421 423
@@ -434,4 +436,3 @@ acpi_resource_to_address64 (
434 return (AE_OK); 436 return (AE_OK);
435} 437}
436EXPORT_SYMBOL(acpi_resource_to_address64); 438EXPORT_SYMBOL(acpi_resource_to_address64);
437
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 337d49b5564b..cbcda30c172d 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1061,13 +1061,15 @@ acpi_add_single_object (
1061 /* 1061 /*
1062 * Status 1062 * Status
1063 * ------ 1063 * ------
1064 * See if the device is present. We always assume that non-Device() 1064 * See if the device is present. We always assume that non-Device
1065 * objects (e.g. thermal zones, power resources, processors, etc.) are 1065 * and non-Processor objects (e.g. thermal zones, power resources,
1066 * present, functioning, etc. (at least when parent object is present). 1066 * etc.) are present, functioning, etc. (at least when parent object
1067 * Note that _STA has a different meaning for some objects (e.g. 1067 * is present). Note that _STA has a different meaning for some
1068 * power resources) so we need to be careful how we use it. 1068 * objects (e.g. power resources) so we need to be careful how we use
1069 * it.
1069 */ 1070 */
1070 switch (type) { 1071 switch (type) {
1072 case ACPI_BUS_TYPE_PROCESSOR:
1071 case ACPI_BUS_TYPE_DEVICE: 1073 case ACPI_BUS_TYPE_DEVICE:
1072 result = acpi_bus_get_status(device); 1074 result = acpi_bus_get_status(device);
1073 if (ACPI_FAILURE(result) || !device->status.present) { 1075 if (ACPI_FAILURE(result) || !device->status.present) {
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 0a5d2a94131e..7249ba2b7a27 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * sleep.c - ACPI sleep support. 2 * sleep.c - ACPI sleep support.
3 * 3 *
4 * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
4 * Copyright (c) 2004 David Shaohua Li <shaohua.li@intel.com> 5 * Copyright (c) 2004 David Shaohua Li <shaohua.li@intel.com>
5 * Copyright (c) 2000-2003 Patrick Mochel 6 * Copyright (c) 2000-2003 Patrick Mochel
6 * Copyright (c) 2003 Open Source Development Lab 7 * Copyright (c) 2003 Open Source Development Lab
@@ -14,7 +15,6 @@
14#include <linux/dmi.h> 15#include <linux/dmi.h>
15#include <linux/device.h> 16#include <linux/device.h>
16#include <linux/suspend.h> 17#include <linux/suspend.h>
17#include <asm/io.h>
18#include <acpi/acpi_bus.h> 18#include <acpi/acpi_bus.h>
19#include <acpi/acpi_drivers.h> 19#include <acpi/acpi_drivers.h>
20#include "sleep.h" 20#include "sleep.h"
@@ -27,10 +27,11 @@ extern void do_suspend_lowlevel_s4bios(void);
27extern void do_suspend_lowlevel(void); 27extern void do_suspend_lowlevel(void);
28 28
29static u32 acpi_suspend_states[] = { 29static u32 acpi_suspend_states[] = {
30 [PM_SUSPEND_ON] = ACPI_STATE_S0, 30 [PM_SUSPEND_ON] = ACPI_STATE_S0,
31 [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, 31 [PM_SUSPEND_STANDBY] = ACPI_STATE_S1,
32 [PM_SUSPEND_MEM] = ACPI_STATE_S3, 32 [PM_SUSPEND_MEM] = ACPI_STATE_S3,
33 [PM_SUSPEND_DISK] = ACPI_STATE_S4, 33 [PM_SUSPEND_DISK] = ACPI_STATE_S4,
34 [PM_SUSPEND_MAX] = ACPI_STATE_S5
34}; 35};
35 36
36static int init_8259A_after_S1; 37static int init_8259A_after_S1;
@@ -44,30 +45,20 @@ static int init_8259A_after_S1;
44 * wakeup code to the waking vector. 45 * wakeup code to the waking vector.
45 */ 46 */
46 47
48extern int acpi_sleep_prepare(u32 acpi_state);
49extern void acpi_power_off(void);
50
47static int acpi_pm_prepare(suspend_state_t pm_state) 51static int acpi_pm_prepare(suspend_state_t pm_state)
48{ 52{
49 u32 acpi_state = acpi_suspend_states[pm_state]; 53 u32 acpi_state = acpi_suspend_states[pm_state];
50 54
51 if (!sleep_states[acpi_state]) 55 if (!sleep_states[acpi_state]) {
56 printk("acpi_pm_prepare does not support %d \n", pm_state);
52 return -EPERM; 57 return -EPERM;
53
54 /* do we have a wakeup address for S2 and S3? */
55 /* Here, we support only S4BIOS, those we set the wakeup address */
56 /* S4OS is only supported for now via swsusp.. */
57 if (pm_state == PM_SUSPEND_MEM || pm_state == PM_SUSPEND_DISK) {
58 if (!acpi_wakeup_address)
59 return -EFAULT;
60 acpi_set_firmware_waking_vector(
61 (acpi_physical_address) virt_to_phys(
62 (void *)acpi_wakeup_address));
63 } 58 }
64 ACPI_FLUSH_CPU_CACHE(); 59 return acpi_sleep_prepare(acpi_state);
65 acpi_enable_wakeup_device_prep(acpi_state);
66 acpi_enter_sleep_state_prep(acpi_state);
67 return 0;
68} 60}
69 61
70
71/** 62/**
72 * acpi_pm_enter - Actually enter a sleep state. 63 * acpi_pm_enter - Actually enter a sleep state.
73 * @pm_state: State we're entering. 64 * @pm_state: State we're entering.
@@ -92,11 +83,9 @@ static int acpi_pm_enter(suspend_state_t pm_state)
92 return error; 83 return error;
93 } 84 }
94 85
95
96 local_irq_save(flags); 86 local_irq_save(flags);
97 acpi_enable_wakeup_device(acpi_state); 87 acpi_enable_wakeup_device(acpi_state);
98 switch (pm_state) 88 switch (pm_state) {
99 {
100 case PM_SUSPEND_STANDBY: 89 case PM_SUSPEND_STANDBY:
101 barrier(); 90 barrier();
102 status = acpi_enter_sleep_state(acpi_state); 91 status = acpi_enter_sleep_state(acpi_state);
@@ -112,6 +101,10 @@ static int acpi_pm_enter(suspend_state_t pm_state)
112 else 101 else
113 do_suspend_lowlevel_s4bios(); 102 do_suspend_lowlevel_s4bios();
114 break; 103 break;
104 case PM_SUSPEND_MAX:
105 acpi_power_off();
106 break;
107
115 default: 108 default:
116 return -EINVAL; 109 return -EINVAL;
117 } 110 }
@@ -126,11 +119,9 @@ static int acpi_pm_enter(suspend_state_t pm_state)
126 if (pm_state > PM_SUSPEND_STANDBY) 119 if (pm_state > PM_SUSPEND_STANDBY)
127 acpi_restore_state_mem(); 120 acpi_restore_state_mem();
128 121
129
130 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 122 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
131} 123}
132 124
133
134/** 125/**
135 * acpi_pm_finish - Finish up suspend sequence. 126 * acpi_pm_finish - Finish up suspend sequence.
136 * @pm_state: State we're coming out of. 127 * @pm_state: State we're coming out of.
@@ -156,27 +147,26 @@ static int acpi_pm_finish(suspend_state_t pm_state)
156 return 0; 147 return 0;
157} 148}
158 149
159
160int acpi_suspend(u32 acpi_state) 150int acpi_suspend(u32 acpi_state)
161{ 151{
162 suspend_state_t states[] = { 152 suspend_state_t states[] = {
163 [1] = PM_SUSPEND_STANDBY, 153 [1] = PM_SUSPEND_STANDBY,
164 [3] = PM_SUSPEND_MEM, 154 [3] = PM_SUSPEND_MEM,
165 [4] = PM_SUSPEND_DISK, 155 [4] = PM_SUSPEND_DISK,
156 [5] = PM_SUSPEND_MAX
166 }; 157 };
167 158
168 if (acpi_state <= 4 && states[acpi_state]) 159 if (acpi_state < 6 && states[acpi_state])
169 return pm_suspend(states[acpi_state]); 160 return pm_suspend(states[acpi_state]);
170 return -EINVAL; 161 return -EINVAL;
171} 162}
172 163
173static struct pm_ops acpi_pm_ops = { 164static struct pm_ops acpi_pm_ops = {
174 .prepare = acpi_pm_prepare, 165 .prepare = acpi_pm_prepare,
175 .enter = acpi_pm_enter, 166 .enter = acpi_pm_enter,
176 .finish = acpi_pm_finish, 167 .finish = acpi_pm_finish,
177}; 168};
178 169
179
180/* 170/*
181 * Toshiba fails to preserve interrupts over S1, reinitialization 171 * Toshiba fails to preserve interrupts over S1, reinitialization
182 * of 8259 is needed after S1 resume. 172 * of 8259 is needed after S1 resume.
@@ -190,16 +180,16 @@ static int __init init_ints_after_s1(struct dmi_system_id *d)
190 180
191static struct dmi_system_id __initdata acpisleep_dmi_table[] = { 181static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
192 { 182 {
193 .callback = init_ints_after_s1, 183 .callback = init_ints_after_s1,
194 .ident = "Toshiba Satellite 4030cdt", 184 .ident = "Toshiba Satellite 4030cdt",
195 .matches = { DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"), }, 185 .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),},
196 }, 186 },
197 { }, 187 {},
198}; 188};
199 189
200static int __init acpi_sleep_init(void) 190static int __init acpi_sleep_init(void)
201{ 191{
202 int i = 0; 192 int i = 0;
203 193
204 dmi_check_system(acpisleep_dmi_table); 194 dmi_check_system(acpisleep_dmi_table);
205 195
@@ -207,7 +197,7 @@ static int __init acpi_sleep_init(void)
207 return 0; 197 return 0;
208 198
209 printk(KERN_INFO PREFIX "(supports"); 199 printk(KERN_INFO PREFIX "(supports");
210 for (i=0; i < ACPI_S_STATE_COUNT; i++) { 200 for (i = 0; i < ACPI_S_STATE_COUNT; i++) {
211 acpi_status status; 201 acpi_status status;
212 u8 type_a, type_b; 202 u8 type_a, type_b;
213 status = acpi_get_sleep_type_data(i, &type_a, &type_b); 203 status = acpi_get_sleep_type_data(i, &type_a, &type_b);
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
index da237754ded9..1fc86e6b5ab9 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -3,35 +3,100 @@
3 * 3 *
4 * AKA S5, but it is independent of whether or not the kernel supports 4 * AKA S5, but it is independent of whether or not the kernel supports
5 * any other sleep support in the system. 5 * any other sleep support in the system.
6 *
7 * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
8 *
9 * This file is released under the GPLv2.
6 */ 10 */
7 11
8#include <linux/pm.h> 12#include <linux/pm.h>
9#include <linux/init.h> 13#include <linux/init.h>
10#include <acpi/acpi_bus.h> 14#include <acpi/acpi_bus.h>
11#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/sysdev.h>
17#include <asm/io.h>
12#include "sleep.h" 18#include "sleep.h"
13 19
14static void 20int acpi_sleep_prepare(u32 acpi_state)
15acpi_power_off (void) 21{
22 /* Flag to do not allow second time invocation for S5 state */
23 static int shutdown_prepared = 0;
24#ifdef CONFIG_ACPI_SLEEP
25 /* do we have a wakeup address for S2 and S3? */
26 /* Here, we support only S4BIOS, those we set the wakeup address */
27 /* S4OS is only supported for now via swsusp.. */
28 if (acpi_state == ACPI_STATE_S3 || acpi_state == ACPI_STATE_S4) {
29 if (!acpi_wakeup_address) {
30 return -EFAULT;
31 }
32 acpi_set_firmware_waking_vector((acpi_physical_address)
33 virt_to_phys((void *)
34 acpi_wakeup_address));
35
36 }
37 ACPI_FLUSH_CPU_CACHE();
38 acpi_enable_wakeup_device_prep(acpi_state);
39#endif
40 if (acpi_state == ACPI_STATE_S5) {
41 /* Check if we were already called */
42 if (shutdown_prepared)
43 return 0;
44 acpi_wakeup_gpe_poweroff_prepare();
45 shutdown_prepared = 1;
46 }
47 acpi_enter_sleep_state_prep(acpi_state);
48 return 0;
49}
50
51void acpi_power_off(void)
16{ 52{
17 printk("%s called\n",__FUNCTION__); 53 printk("%s called\n", __FUNCTION__);
54 acpi_sleep_prepare(ACPI_STATE_S5);
55 local_irq_disable();
18 /* Some SMP machines only can poweroff in boot CPU */ 56 /* Some SMP machines only can poweroff in boot CPU */
19 set_cpus_allowed(current, cpumask_of_cpu(0)); 57 set_cpus_allowed(current, cpumask_of_cpu(0));
20 acpi_wakeup_gpe_poweroff_prepare();
21 acpi_enter_sleep_state_prep(ACPI_STATE_S5);
22 ACPI_DISABLE_IRQS();
23 acpi_enter_sleep_state(ACPI_STATE_S5); 58 acpi_enter_sleep_state(ACPI_STATE_S5);
24} 59}
25 60
61#ifdef CONFIG_PM
62
63static int acpi_shutdown(struct sys_device *x)
64{
65 return acpi_sleep_prepare(ACPI_STATE_S5);
66}
67
68static struct sysdev_class acpi_sysclass = {
69 set_kset_name("acpi"),
70 .shutdown = acpi_shutdown
71};
72
73static struct sys_device device_acpi = {
74 .id = 0,
75 .cls = &acpi_sysclass,
76};
77
78#endif
79
26static int acpi_poweroff_init(void) 80static int acpi_poweroff_init(void)
27{ 81{
28 if (!acpi_disabled) { 82 if (!acpi_disabled) {
29 u8 type_a, type_b; 83 u8 type_a, type_b;
30 acpi_status status; 84 acpi_status status;
31 85
32 status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); 86 status =
33 if (ACPI_SUCCESS(status)) 87 acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
88 if (ACPI_SUCCESS(status)) {
34 pm_power_off = acpi_power_off; 89 pm_power_off = acpi_power_off;
90#ifdef CONFIG_PM
91 {
92 int error;
93 error = sysdev_class_register(&acpi_sysclass);
94 if (!error)
95 error = sysdev_register(&device_acpi);
96 return error;
97 }
98#endif
99 }
35 } 100 }
36 return 0; 101 return 0;
37} 102}
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index fd7c5a0649af..1be99f0996d6 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -13,13 +13,17 @@
13 13
14#include "sleep.h" 14#include "sleep.h"
15 15
16#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
16#define ACPI_SYSTEM_FILE_SLEEP "sleep" 17#define ACPI_SYSTEM_FILE_SLEEP "sleep"
18#endif
19
17#define ACPI_SYSTEM_FILE_ALARM "alarm" 20#define ACPI_SYSTEM_FILE_ALARM "alarm"
18#define ACPI_SYSTEM_FILE_WAKEUP_DEVICE "wakeup" 21#define ACPI_SYSTEM_FILE_WAKEUP_DEVICE "wakeup"
19 22
20#define _COMPONENT ACPI_SYSTEM_COMPONENT 23#define _COMPONENT ACPI_SYSTEM_COMPONENT
21ACPI_MODULE_NAME ("sleep") 24ACPI_MODULE_NAME ("sleep")
22 25
26#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
23 27
24static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset) 28static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
25{ 29{
@@ -78,6 +82,7 @@ acpi_system_write_sleep (
78 Done: 82 Done:
79 return error ? error : count; 83 return error ? error : count;
80} 84}
85#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
81 86
82static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) 87static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
83{ 88{
@@ -452,6 +457,7 @@ static struct file_operations acpi_system_wakeup_device_fops = {
452 .release = single_release, 457 .release = single_release,
453}; 458};
454 459
460#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
455static struct file_operations acpi_system_sleep_fops = { 461static struct file_operations acpi_system_sleep_fops = {
456 .open = acpi_system_sleep_open_fs, 462 .open = acpi_system_sleep_open_fs,
457 .read = seq_read, 463 .read = seq_read,
@@ -459,6 +465,7 @@ static struct file_operations acpi_system_sleep_fops = {
459 .llseek = seq_lseek, 465 .llseek = seq_lseek,
460 .release = single_release, 466 .release = single_release,
461}; 467};
468#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
462 469
463static struct file_operations acpi_system_alarm_fops = { 470static struct file_operations acpi_system_alarm_fops = {
464 .open = acpi_system_alarm_open_fs, 471 .open = acpi_system_alarm_open_fs,
@@ -484,11 +491,13 @@ static int acpi_sleep_proc_init(void)
484 if (acpi_disabled) 491 if (acpi_disabled)
485 return 0; 492 return 0;
486 493
494#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
487 /* 'sleep' [R/W]*/ 495 /* 'sleep' [R/W]*/
488 entry = create_proc_entry(ACPI_SYSTEM_FILE_SLEEP, 496 entry = create_proc_entry(ACPI_SYSTEM_FILE_SLEEP,
489 S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 497 S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir);
490 if (entry) 498 if (entry)
491 entry->proc_fops = &acpi_system_sleep_fops; 499 entry->proc_fops = &acpi_system_sleep_fops;
500#endif
492 501
493 /* 'alarm' [R/W] */ 502 /* 'alarm' [R/W] */
494 entry = create_proc_entry(ACPI_SYSTEM_FILE_ALARM, 503 entry = create_proc_entry(ACPI_SYSTEM_FILE_ALARM,
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index 334327c1f66f..92e0c31539be 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -50,6 +50,24 @@
50#define _COMPONENT ACPI_TABLES 50#define _COMPONENT ACPI_TABLES
51 ACPI_MODULE_NAME ("tbconvrt") 51 ACPI_MODULE_NAME ("tbconvrt")
52 52
53/* Local prototypes */
54
55static void
56acpi_tb_init_generic_address (
57 struct acpi_generic_address *new_gas_struct,
58 u8 register_bit_width,
59 acpi_physical_address address);
60
61static void
62acpi_tb_convert_fadt1 (
63 struct fadt_descriptor_rev2 *local_fadt,
64 struct fadt_descriptor_rev1 *original_fadt);
65
66static void
67acpi_tb_convert_fadt2 (
68 struct fadt_descriptor_rev2 *local_fadt,
69 struct fadt_descriptor_rev2 *original_fadt);
70
53 71
54u8 acpi_fadt_is_v1; 72u8 acpi_fadt_is_v1;
55EXPORT_SYMBOL(acpi_fadt_is_v1); 73EXPORT_SYMBOL(acpi_fadt_is_v1);
@@ -142,11 +160,13 @@ acpi_tb_convert_to_xsdt (
142 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { 160 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
143 if (acpi_gbl_RSDP->revision < 2) { 161 if (acpi_gbl_RSDP->revision < 2) {
144 ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], 162 ACPI_STORE_ADDRESS (new_table->table_offset_entry[i],
145 (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, table_info->pointer))->table_offset_entry[i]); 163 (ACPI_CAST_PTR (struct rsdt_descriptor_rev1,
164 table_info->pointer))->table_offset_entry[i]);
146 } 165 }
147 else { 166 else {
148 new_table->table_offset_entry[i] = 167 new_table->table_offset_entry[i] =
149 (ACPI_CAST_PTR (XSDT_DESCRIPTOR, table_info->pointer))->table_offset_entry[i]; 168 (ACPI_CAST_PTR (XSDT_DESCRIPTOR,
169 table_info->pointer))->table_offset_entry[i];
150 } 170 }
151 } 171 }
152 172
@@ -164,7 +184,7 @@ acpi_tb_convert_to_xsdt (
164} 184}
165 185
166 186
167/****************************************************************************** 187/*******************************************************************************
168 * 188 *
169 * FUNCTION: acpi_tb_init_generic_address 189 * FUNCTION: acpi_tb_init_generic_address
170 * 190 *
@@ -201,7 +221,7 @@ acpi_tb_init_generic_address (
201 * PARAMETERS: local_fadt - Pointer to new FADT 221 * PARAMETERS: local_fadt - Pointer to new FADT
202 * original_fadt - Pointer to old FADT 222 * original_fadt - Pointer to old FADT
203 * 223 *
204 * RETURN: Populates local_fadt 224 * RETURN: None, populates local_fadt
205 * 225 *
206 * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format 226 * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format
207 * 227 *
@@ -213,7 +233,6 @@ acpi_tb_convert_fadt1 (
213 struct fadt_descriptor_rev1 *original_fadt) 233 struct fadt_descriptor_rev1 *original_fadt)
214{ 234{
215 235
216
217 /* ACPI 1.0 FACS */ 236 /* ACPI 1.0 FACS */
218 /* The BIOS stored FADT should agree with Revision 1.0 */ 237 /* The BIOS stored FADT should agree with Revision 1.0 */
219 acpi_fadt_is_v1 = 1; 238 acpi_fadt_is_v1 = 1;
@@ -232,7 +251,8 @@ acpi_tb_convert_fadt1 (
232 ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); 251 ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt);
233 252
234 /* 253 /*
235 * System Interrupt Model isn't used in ACPI 2.0 (local_fadt->Reserved1 = 0;) 254 * System Interrupt Model isn't used in ACPI 2.0
255 * (local_fadt->Reserved1 = 0;)
236 */ 256 */
237 257
238 /* 258 /*
@@ -269,7 +289,8 @@ acpi_tb_convert_fadt1 (
269 * that immediately follows. 289 * that immediately follows.
270 */ 290 */
271 ACPI_MEMCPY (&local_fadt->reset_register, 291 ACPI_MEMCPY (&local_fadt->reset_register,
272 &(ACPI_CAST_PTR (struct fadt_descriptor_rev2_minus, original_fadt))->reset_register, 292 &(ACPI_CAST_PTR (struct fadt_descriptor_rev2_minus,
293 original_fadt))->reset_register,
273 sizeof (struct acpi_generic_address) + 1); 294 sizeof (struct acpi_generic_address) + 1);
274 } 295 }
275 else { 296 else {
@@ -304,7 +325,8 @@ acpi_tb_convert_fadt1 (
304 325
305 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, 326 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable,
306 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 327 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
307 (acpi_physical_address) (local_fadt->xpm1a_evt_blk.address + 328 (acpi_physical_address)
329 (local_fadt->xpm1a_evt_blk.address +
308 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 330 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
309 331
310 /* PM1B is optional; leave null if not present */ 332 /* PM1B is optional; leave null if not present */
@@ -312,7 +334,8 @@ acpi_tb_convert_fadt1 (
312 if (local_fadt->xpm1b_evt_blk.address) { 334 if (local_fadt->xpm1b_evt_blk.address) {
313 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, 335 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable,
314 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 336 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
315 (acpi_physical_address) (local_fadt->xpm1b_evt_blk.address + 337 (acpi_physical_address)
338 (local_fadt->xpm1b_evt_blk.address +
316 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 339 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
317 } 340 }
318} 341}
@@ -325,7 +348,7 @@ acpi_tb_convert_fadt1 (
325 * PARAMETERS: local_fadt - Pointer to new FADT 348 * PARAMETERS: local_fadt - Pointer to new FADT
326 * original_fadt - Pointer to old FADT 349 * original_fadt - Pointer to old FADT
327 * 350 *
328 * RETURN: Populates local_fadt 351 * RETURN: None, populates local_fadt
329 * 352 *
330 * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format. 353 * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format.
331 * Handles optional "X" fields. 354 * Handles optional "X" fields.
@@ -348,7 +371,8 @@ acpi_tb_convert_fadt2 (
348 * is zero. 371 * is zero.
349 */ 372 */
350 if (!(local_fadt->xfirmware_ctrl)) { 373 if (!(local_fadt->xfirmware_ctrl)) {
351 ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl); 374 ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl,
375 local_fadt->V1_firmware_ctrl);
352 } 376 }
353 377
354 if (!(local_fadt->Xdsdt)) { 378 if (!(local_fadt->Xdsdt)) {
@@ -357,32 +381,38 @@ acpi_tb_convert_fadt2 (
357 381
358 if (!(local_fadt->xpm1a_evt_blk.address)) { 382 if (!(local_fadt->xpm1a_evt_blk.address)) {
359 acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, 383 acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk,
360 local_fadt->pm1_evt_len, (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); 384 local_fadt->pm1_evt_len,
385 (acpi_physical_address) local_fadt->V1_pm1a_evt_blk);
361 } 386 }
362 387
363 if (!(local_fadt->xpm1b_evt_blk.address)) { 388 if (!(local_fadt->xpm1b_evt_blk.address)) {
364 acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, 389 acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk,
365 local_fadt->pm1_evt_len, (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); 390 local_fadt->pm1_evt_len,
391 (acpi_physical_address) local_fadt->V1_pm1b_evt_blk);
366 } 392 }
367 393
368 if (!(local_fadt->xpm1a_cnt_blk.address)) { 394 if (!(local_fadt->xpm1a_cnt_blk.address)) {
369 acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, 395 acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk,
370 local_fadt->pm1_cnt_len, (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); 396 local_fadt->pm1_cnt_len,
397 (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk);
371 } 398 }
372 399
373 if (!(local_fadt->xpm1b_cnt_blk.address)) { 400 if (!(local_fadt->xpm1b_cnt_blk.address)) {
374 acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, 401 acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk,
375 local_fadt->pm1_cnt_len, (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); 402 local_fadt->pm1_cnt_len,
403 (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk);
376 } 404 }
377 405
378 if (!(local_fadt->xpm2_cnt_blk.address)) { 406 if (!(local_fadt->xpm2_cnt_blk.address)) {
379 acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, 407 acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk,
380 local_fadt->pm2_cnt_len, (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); 408 local_fadt->pm2_cnt_len,
409 (acpi_physical_address) local_fadt->V1_pm2_cnt_blk);
381 } 410 }
382 411
383 if (!(local_fadt->xpm_tmr_blk.address)) { 412 if (!(local_fadt->xpm_tmr_blk.address)) {
384 acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, 413 acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk,
385 local_fadt->pm_tm_len, (acpi_physical_address) local_fadt->V1_pm_tmr_blk); 414 local_fadt->pm_tm_len,
415 (acpi_physical_address) local_fadt->V1_pm_tmr_blk);
386 } 416 }
387 417
388 if (!(local_fadt->xgpe0_blk.address)) { 418 if (!(local_fadt->xgpe0_blk.address)) {
@@ -399,18 +429,24 @@ acpi_tb_convert_fadt2 (
399 429
400 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, 430 acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable,
401 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 431 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
402 (acpi_physical_address) (local_fadt->xpm1a_evt_blk.address + 432 (acpi_physical_address)
433 (local_fadt->xpm1a_evt_blk.address +
403 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 434 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
404 acpi_gbl_xpm1a_enable.address_space_id = local_fadt->xpm1a_evt_blk.address_space_id; 435
436 acpi_gbl_xpm1a_enable.address_space_id =
437 local_fadt->xpm1a_evt_blk.address_space_id;
405 438
406 /* PM1B is optional; leave null if not present */ 439 /* PM1B is optional; leave null if not present */
407 440
408 if (local_fadt->xpm1b_evt_blk.address) { 441 if (local_fadt->xpm1b_evt_blk.address) {
409 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, 442 acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable,
410 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), 443 (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
411 (acpi_physical_address) (local_fadt->xpm1b_evt_blk.address + 444 (acpi_physical_address)
445 (local_fadt->xpm1b_evt_blk.address +
412 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); 446 ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
413 acpi_gbl_xpm1b_enable.address_space_id = local_fadt->xpm1b_evt_blk.address_space_id; 447
448 acpi_gbl_xpm1b_enable.address_space_id =
449 local_fadt->xpm1b_evt_blk.address_space_id;
414 } 450 }
415} 451}
416 452
@@ -432,7 +468,8 @@ acpi_tb_convert_fadt2 (
432 ******************************************************************************/ 468 ******************************************************************************/
433 469
434acpi_status 470acpi_status
435acpi_tb_convert_table_fadt (void) 471acpi_tb_convert_table_fadt (
472 void)
436{ 473{
437 struct fadt_descriptor_rev2 *local_fadt; 474 struct fadt_descriptor_rev2 *local_fadt;
438 struct acpi_table_desc *table_desc; 475 struct acpi_table_desc *table_desc;
@@ -446,7 +483,8 @@ acpi_tb_convert_table_fadt (void)
446 * at least as long as the version 1.0 FADT 483 * at least as long as the version 1.0 FADT
447 */ 484 */
448 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) { 485 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) {
449 ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", acpi_gbl_FADT->length)); 486 ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n",
487 acpi_gbl_FADT->length));
450 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); 488 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
451 } 489 }
452 490
@@ -461,8 +499,9 @@ acpi_tb_convert_table_fadt (void)
461 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev2)) { 499 if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev2)) {
462 /* Length is too short to be a V2.0 table */ 500 /* Length is too short to be a V2.0 table */
463 501
464 ACPI_REPORT_WARNING (("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", 502 ACPI_REPORT_WARNING ((
465 acpi_gbl_FADT->length, acpi_gbl_FADT->revision)); 503 "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n",
504 acpi_gbl_FADT->length, acpi_gbl_FADT->revision));
466 505
467 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); 506 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT);
468 } 507 }
@@ -478,9 +517,8 @@ acpi_tb_convert_table_fadt (void)
478 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); 517 acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT);
479 } 518 }
480 519
481 /* 520 /* Global FADT pointer will point to the new common V2.0 FADT */
482 * Global FADT pointer will point to the new common V2.0 FADT 521
483 */
484 acpi_gbl_FADT = local_fadt; 522 acpi_gbl_FADT = local_fadt;
485 acpi_gbl_FADT->length = sizeof (FADT_DESCRIPTOR); 523 acpi_gbl_FADT->length = sizeof (FADT_DESCRIPTOR);
486 524
@@ -508,7 +546,7 @@ acpi_tb_convert_table_fadt (void)
508 546
509/******************************************************************************* 547/*******************************************************************************
510 * 548 *
511 * FUNCTION: acpi_tb_convert_table_facs 549 * FUNCTION: acpi_tb_build_common_facs
512 * 550 *
513 * PARAMETERS: table_info - Info for currently installed FACS 551 * PARAMETERS: table_info - Info for currently installed FACS
514 * 552 *
@@ -530,12 +568,14 @@ acpi_tb_build_common_facs (
530 /* Absolute minimum length is 24, but the ACPI spec says 64 */ 568 /* Absolute minimum length is 24, but the ACPI spec says 64 */
531 569
532 if (acpi_gbl_FACS->length < 24) { 570 if (acpi_gbl_FACS->length < 24) {
533 ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", acpi_gbl_FACS->length)); 571 ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n",
572 acpi_gbl_FACS->length));
534 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); 573 return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
535 } 574 }
536 575
537 if (acpi_gbl_FACS->length < 64) { 576 if (acpi_gbl_FACS->length < 64) {
538 ACPI_REPORT_WARNING (("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", 577 ACPI_REPORT_WARNING ((
578 "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n",
539 acpi_gbl_FACS->length)); 579 acpi_gbl_FACS->length));
540 } 580 }
541 581
@@ -548,7 +588,8 @@ acpi_tb_build_common_facs (
548 (!(acpi_gbl_FACS->xfirmware_waking_vector))) { 588 (!(acpi_gbl_FACS->xfirmware_waking_vector))) {
549 /* ACPI 1.0 FACS or short table or optional X_ field is zero */ 589 /* ACPI 1.0 FACS or short table or optional X_ field is zero */
550 590
551 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64, &(acpi_gbl_FACS->firmware_waking_vector)); 591 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64,
592 &(acpi_gbl_FACS->firmware_waking_vector));
552 acpi_gbl_common_fACS.vector_width = 32; 593 acpi_gbl_common_fACS.vector_width = 32;
553 } 594 }
554 else { 595 else {
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 896f3ddda62e..4ab2aadc6133 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -49,6 +49,19 @@
49#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbget") 50 ACPI_MODULE_NAME ("tbget")
51 51
52/* Local prototypes */
53
54static acpi_status
55acpi_tb_get_this_table (
56 struct acpi_pointer *address,
57 struct acpi_table_header *header,
58 struct acpi_table_desc *table_info);
59
60static acpi_status
61acpi_tb_table_override (
62 struct acpi_table_header *header,
63 struct acpi_table_desc *table_info);
64
52 65
53/******************************************************************************* 66/*******************************************************************************
54 * 67 *
@@ -76,9 +89,8 @@ acpi_tb_get_table (
76 ACPI_FUNCTION_TRACE ("tb_get_table"); 89 ACPI_FUNCTION_TRACE ("tb_get_table");
77 90
78 91
79 /* 92 /* Get the header in order to get signature and table size */
80 * Get the header in order to get signature and table size 93
81 */
82 status = acpi_tb_get_table_header (address, &header); 94 status = acpi_tb_get_table_header (address, &header);
83 if (ACPI_FAILURE (status)) { 95 if (ACPI_FAILURE (status)) {
84 return_ACPI_STATUS (status); 96 return_ACPI_STATUS (status);
@@ -127,8 +139,8 @@ acpi_tb_get_table_header (
127 139
128 140
129 /* 141 /*
130 * Flags contains the current processor mode (Virtual or Physical addressing) 142 * Flags contains the current processor mode (Virtual or Physical
131 * The pointer_type is either Logical or Physical 143 * addressing) The pointer_type is either Logical or Physical
132 */ 144 */
133 switch (address->pointer_type) { 145 switch (address->pointer_type) {
134 case ACPI_PHYSMODE_PHYSPTR: 146 case ACPI_PHYSMODE_PHYSPTR:
@@ -136,7 +148,8 @@ acpi_tb_get_table_header (
136 148
137 /* Pointer matches processor mode, copy the header */ 149 /* Pointer matches processor mode, copy the header */
138 150
139 ACPI_MEMCPY (return_header, address->pointer.logical, sizeof (struct acpi_table_header)); 151 ACPI_MEMCPY (return_header, address->pointer.logical,
152 sizeof (struct acpi_table_header));
140 break; 153 break;
141 154
142 155
@@ -144,10 +157,11 @@ acpi_tb_get_table_header (
144 157
145 /* Create a logical address for the physical pointer*/ 158 /* Create a logical address for the physical pointer*/
146 159
147 status = acpi_os_map_memory (address->pointer.physical, sizeof (struct acpi_table_header), 160 status = acpi_os_map_memory (address->pointer.physical,
148 (void *) &header); 161 sizeof (struct acpi_table_header), (void *) &header);
149 if (ACPI_FAILURE (status)) { 162 if (ACPI_FAILURE (status)) {
150 ACPI_REPORT_ERROR (("Could not map memory at %8.8X%8.8X for length %X\n", 163 ACPI_REPORT_ERROR ((
164 "Could not map memory at %8.8X%8.8X for length %X\n",
151 ACPI_FORMAT_UINT64 (address->pointer.physical), 165 ACPI_FORMAT_UINT64 (address->pointer.physical),
152 sizeof (struct acpi_table_header))); 166 sizeof (struct acpi_table_header)));
153 return_ACPI_STATUS (status); 167 return_ACPI_STATUS (status);
@@ -210,9 +224,8 @@ acpi_tb_get_table_body (
210 return_ACPI_STATUS (AE_BAD_PARAMETER); 224 return_ACPI_STATUS (AE_BAD_PARAMETER);
211 } 225 }
212 226
213 /* 227 /* Attempt table override. */
214 * Attempt table override. 228
215 */
216 status = acpi_tb_table_override (header, table_info); 229 status = acpi_tb_table_override (header, table_info);
217 if (ACPI_SUCCESS (status)) { 230 if (ACPI_SUCCESS (status)) {
218 /* Table was overridden by the host OS */ 231 /* Table was overridden by the host OS */
@@ -241,7 +254,7 @@ acpi_tb_get_table_body (
241 * 254 *
242 ******************************************************************************/ 255 ******************************************************************************/
243 256
244acpi_status 257static acpi_status
245acpi_tb_table_override ( 258acpi_tb_table_override (
246 struct acpi_table_header *header, 259 struct acpi_table_header *header,
247 struct acpi_table_desc *table_info) 260 struct acpi_table_desc *table_info)
@@ -315,7 +328,7 @@ acpi_tb_table_override (
315 * 328 *
316 ******************************************************************************/ 329 ******************************************************************************/
317 330
318acpi_status 331static acpi_status
319acpi_tb_get_this_table ( 332acpi_tb_get_this_table (
320 struct acpi_pointer *address, 333 struct acpi_pointer *address,
321 struct acpi_table_header *header, 334 struct acpi_table_header *header,
@@ -330,8 +343,8 @@ acpi_tb_get_this_table (
330 343
331 344
332 /* 345 /*
333 * Flags contains the current processor mode (Virtual or Physical addressing) 346 * Flags contains the current processor mode (Virtual or Physical
334 * The pointer_type is either Logical or Physical 347 * addressing) The pointer_type is either Logical or Physical
335 */ 348 */
336 switch (address->pointer_type) { 349 switch (address->pointer_type) {
337 case ACPI_PHYSMODE_PHYSPTR: 350 case ACPI_PHYSMODE_PHYSPTR:
@@ -341,7 +354,8 @@ acpi_tb_get_this_table (
341 354
342 full_table = ACPI_MEM_ALLOCATE (header->length); 355 full_table = ACPI_MEM_ALLOCATE (header->length);
343 if (!full_table) { 356 if (!full_table) {
344 ACPI_REPORT_ERROR (("Could not allocate table memory for [%4.4s] length %X\n", 357 ACPI_REPORT_ERROR ((
358 "Could not allocate table memory for [%4.4s] length %X\n",
345 header->signature, header->length)); 359 header->signature, header->length));
346 return_ACPI_STATUS (AE_NO_MEMORY); 360 return_ACPI_STATUS (AE_NO_MEMORY);
347 } 361 }
@@ -362,12 +376,14 @@ acpi_tb_get_this_table (
362 * Just map the table's physical memory 376 * Just map the table's physical memory
363 * into our address space. 377 * into our address space.
364 */ 378 */
365 status = acpi_os_map_memory (address->pointer.physical, (acpi_size) header->length, 379 status = acpi_os_map_memory (address->pointer.physical,
366 (void *) &full_table); 380 (acpi_size) header->length, (void *) &full_table);
367 if (ACPI_FAILURE (status)) { 381 if (ACPI_FAILURE (status)) {
368 ACPI_REPORT_ERROR (("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", 382 ACPI_REPORT_ERROR ((
383 "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n",
369 header->signature, 384 header->signature,
370 ACPI_FORMAT_UINT64 (address->pointer.physical), header->length)); 385 ACPI_FORMAT_UINT64 (address->pointer.physical),
386 header->length));
371 return (status); 387 return (status);
372 } 388 }
373 389
@@ -465,9 +481,8 @@ acpi_tb_get_table_ptr (
465 return_ACPI_STATUS (AE_OK); 481 return_ACPI_STATUS (AE_OK);
466 } 482 }
467 483
468 /* 484 /* Check for instance out of range */
469 * Check for instance out of range 485
470 */
471 if (instance > acpi_gbl_table_lists[table_type].count) { 486 if (instance > acpi_gbl_table_lists[table_type].count) {
472 return_ACPI_STATUS (AE_NOT_EXIST); 487 return_ACPI_STATUS (AE_NOT_EXIST);
473 } 488 }
diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c
index adc4270988bc..eea5b8cb5ebb 100644
--- a/drivers/acpi/tables/tbgetall.c
+++ b/drivers/acpi/tables/tbgetall.c
@@ -49,6 +49,19 @@
49#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbgetall") 50 ACPI_MODULE_NAME ("tbgetall")
51 51
52/* Local prototypes */
53
54static acpi_status
55acpi_tb_get_primary_table (
56 struct acpi_pointer *address,
57 struct acpi_table_desc *table_info);
58
59static acpi_status
60acpi_tb_get_secondary_table (
61 struct acpi_pointer *address,
62 acpi_string signature,
63 struct acpi_table_desc *table_info);
64
52 65
53/******************************************************************************* 66/*******************************************************************************
54 * 67 *
@@ -63,7 +76,7 @@
63 * 76 *
64 ******************************************************************************/ 77 ******************************************************************************/
65 78
66acpi_status 79static acpi_status
67acpi_tb_get_primary_table ( 80acpi_tb_get_primary_table (
68 struct acpi_pointer *address, 81 struct acpi_pointer *address,
69 struct acpi_table_desc *table_info) 82 struct acpi_table_desc *table_info)
@@ -81,9 +94,8 @@ acpi_tb_get_primary_table (
81 return_ACPI_STATUS (AE_OK); 94 return_ACPI_STATUS (AE_OK);
82 } 95 }
83 96
84 /* 97 /* Get the header in order to get signature and table size */
85 * Get the header in order to get signature and table size 98
86 */
87 status = acpi_tb_get_table_header (address, &header); 99 status = acpi_tb_get_table_header (address, &header);
88 if (ACPI_FAILURE (status)) { 100 if (ACPI_FAILURE (status)) {
89 return_ACPI_STATUS (status); 101 return_ACPI_STATUS (status);
@@ -130,7 +142,7 @@ acpi_tb_get_primary_table (
130 * 142 *
131 ******************************************************************************/ 143 ******************************************************************************/
132 144
133acpi_status 145static acpi_status
134acpi_tb_get_secondary_table ( 146acpi_tb_get_secondary_table (
135 struct acpi_pointer *address, 147 struct acpi_pointer *address,
136 acpi_string signature, 148 acpi_string signature,
@@ -153,7 +165,8 @@ acpi_tb_get_secondary_table (
153 /* Signature must match request */ 165 /* Signature must match request */
154 166
155 if (ACPI_STRNCMP (header.signature, signature, ACPI_NAME_SIZE)) { 167 if (ACPI_STRNCMP (header.signature, signature, ACPI_NAME_SIZE)) {
156 ACPI_REPORT_ERROR (("Incorrect table signature - wanted [%s] found [%4.4s]\n", 168 ACPI_REPORT_ERROR ((
169 "Incorrect table signature - wanted [%s] found [%4.4s]\n",
157 signature, header.signature)); 170 signature, header.signature));
158 return_ACPI_STATUS (AE_BAD_SIGNATURE); 171 return_ACPI_STATUS (AE_BAD_SIGNATURE);
159 } 172 }
@@ -230,7 +243,8 @@ acpi_tb_get_required_tables (
230 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { 243 for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
231 /* Get the table address from the common internal XSDT */ 244 /* Get the table address from the common internal XSDT */
232 245
233 address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i]; 246 address.pointer.value =
247 acpi_gbl_XSDT->table_offset_entry[i];
234 248
235 /* 249 /*
236 * Get the tables needed by this subsystem (FADT and any SSDTs). 250 * Get the tables needed by this subsystem (FADT and any SSDTs).
@@ -252,18 +266,18 @@ acpi_tb_get_required_tables (
252 } 266 }
253 267
254 /* 268 /*
255 * Convert the FADT to a common format. This allows earlier revisions of the 269 * Convert the FADT to a common format. This allows earlier revisions of
256 * table to coexist with newer versions, using common access code. 270 * the table to coexist with newer versions, using common access code.
257 */ 271 */
258 status = acpi_tb_convert_table_fadt (); 272 status = acpi_tb_convert_table_fadt ();
259 if (ACPI_FAILURE (status)) { 273 if (ACPI_FAILURE (status)) {
260 ACPI_REPORT_ERROR (("Could not convert FADT to internal common format\n")); 274 ACPI_REPORT_ERROR ((
275 "Could not convert FADT to internal common format\n"));
261 return_ACPI_STATUS (status); 276 return_ACPI_STATUS (status);
262 } 277 }
263 278
264 /* 279 /* Get the FACS (Pointed to by the FADT) */
265 * Get the FACS (Pointed to by the FADT) 280
266 */
267 address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl; 281 address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl;
268 282
269 status = acpi_tb_get_secondary_table (&address, FACS_SIG, &table_info); 283 status = acpi_tb_get_secondary_table (&address, FACS_SIG, &table_info);
@@ -282,9 +296,8 @@ acpi_tb_get_required_tables (
282 return_ACPI_STATUS (status); 296 return_ACPI_STATUS (status);
283 } 297 }
284 298
285 /* 299 /* Get/install the DSDT (Pointed to by the FADT) */
286 * Get/install the DSDT (Pointed to by the FADT) 300
287 */
288 address.pointer.value = acpi_gbl_FADT->Xdsdt; 301 address.pointer.value = acpi_gbl_FADT->Xdsdt;
289 302
290 status = acpi_tb_get_secondary_table (&address, DSDT_SIG, &table_info); 303 status = acpi_tb_get_secondary_table (&address, DSDT_SIG, &table_info);
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 85d5bb01022c..629b64c8193d 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -49,6 +49,14 @@
49#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbinstal") 50 ACPI_MODULE_NAME ("tbinstal")
51 51
52/* Local prototypes */
53
54static acpi_status
55acpi_tb_match_signature (
56 char *signature,
57 struct acpi_table_desc *table_info,
58 u8 search_type);
59
52 60
53/******************************************************************************* 61/*******************************************************************************
54 * 62 *
@@ -56,6 +64,7 @@
56 * 64 *
57 * PARAMETERS: Signature - Table signature to match 65 * PARAMETERS: Signature - Table signature to match
58 * table_info - Return data 66 * table_info - Return data
67 * search_type - Table type to match (primary/secondary)
59 * 68 *
60 * RETURN: Status 69 * RETURN: Status
61 * 70 *
@@ -64,7 +73,7 @@
64 * 73 *
65 ******************************************************************************/ 74 ******************************************************************************/
66 75
67acpi_status 76static acpi_status
68acpi_tb_match_signature ( 77acpi_tb_match_signature (
69 char *signature, 78 char *signature,
70 struct acpi_table_desc *table_info, 79 struct acpi_table_desc *table_info,
@@ -76,9 +85,8 @@ acpi_tb_match_signature (
76 ACPI_FUNCTION_TRACE ("tb_match_signature"); 85 ACPI_FUNCTION_TRACE ("tb_match_signature");
77 86
78 87
79 /* 88 /* Search for a signature match among the known table types */
80 * Search for a signature match among the known table types 89
81 */
82 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) { 90 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
83 if (!(acpi_gbl_table_data[i].flags & search_type)) { 91 if (!(acpi_gbl_table_data[i].flags & search_type)) {
84 continue; 92 continue;
@@ -161,6 +169,7 @@ acpi_tb_install_table (
161 * FUNCTION: acpi_tb_recognize_table 169 * FUNCTION: acpi_tb_recognize_table
162 * 170 *
163 * PARAMETERS: table_info - Return value from acpi_tb_get_table_body 171 * PARAMETERS: table_info - Return value from acpi_tb_get_table_body
172 * search_type - Table type to match (primary/secondary)
164 * 173 *
165 * RETURN: Status 174 * RETURN: Status
166 * 175 *
@@ -203,7 +212,8 @@ acpi_tb_recognize_table (
203 * This can be any one of many valid ACPI tables, it just isn't one of 212 * This can be any one of many valid ACPI tables, it just isn't one of
204 * the tables that is consumed by the core subsystem 213 * the tables that is consumed by the core subsystem
205 */ 214 */
206 status = acpi_tb_match_signature (table_header->signature, table_info, search_type); 215 status = acpi_tb_match_signature (table_header->signature,
216 table_info, search_type);
207 if (ACPI_FAILURE (status)) { 217 if (ACPI_FAILURE (status)) {
208 return_ACPI_STATUS (status); 218 return_ACPI_STATUS (status);
209 } 219 }
@@ -253,9 +263,8 @@ acpi_tb_init_table_descriptor (
253 return_ACPI_STATUS (AE_NO_MEMORY); 263 return_ACPI_STATUS (AE_NO_MEMORY);
254 } 264 }
255 265
256 /* 266 /* Install the table into the global data structure */
257 * Install the table into the global data structure 267
258 */
259 list_head = &acpi_gbl_table_lists[table_type]; 268 list_head = &acpi_gbl_table_lists[table_type];
260 269
261 /* 270 /*
@@ -316,7 +325,8 @@ acpi_tb_init_table_descriptor (
316 table_desc->aml_start = (u8 *) (table_desc->pointer + 1), 325 table_desc->aml_start = (u8 *) (table_desc->pointer + 1),
317 table_desc->aml_length = (u32) (table_desc->length - 326 table_desc->aml_length = (u32) (table_desc->length -
318 (u32) sizeof (struct acpi_table_header)); 327 (u32) sizeof (struct acpi_table_header));
319 table_desc->table_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_TABLE); 328 table_desc->table_id = acpi_ut_allocate_owner_id (
329 ACPI_OWNER_TYPE_TABLE);
320 table_desc->loaded_into_namespace = FALSE; 330 table_desc->loaded_into_namespace = FALSE;
321 331
322 /* 332 /*
@@ -349,7 +359,8 @@ acpi_tb_init_table_descriptor (
349 ******************************************************************************/ 359 ******************************************************************************/
350 360
351void 361void
352acpi_tb_delete_all_tables (void) 362acpi_tb_delete_all_tables (
363 void)
353{ 364{
354 acpi_table_type type; 365 acpi_table_type type;
355 366
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index 9c6913238d52..b7ffe39c3626 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -84,8 +84,9 @@ acpi_tb_verify_rsdp (
84 /* 84 /*
85 * Obtain access to the RSDP structure 85 * Obtain access to the RSDP structure
86 */ 86 */
87 status = acpi_os_map_memory (address->pointer.physical, sizeof (struct rsdp_descriptor), 87 status = acpi_os_map_memory (address->pointer.physical,
88 (void *) &rsdp); 88 sizeof (struct rsdp_descriptor),
89 (void *) &rsdp);
89 if (ACPI_FAILURE (status)) { 90 if (ACPI_FAILURE (status)) {
90 return_ACPI_STATUS (status); 91 return_ACPI_STATUS (status);
91 } 92 }
@@ -154,9 +155,9 @@ cleanup:
154 * 155 *
155 * FUNCTION: acpi_tb_get_rsdt_address 156 * FUNCTION: acpi_tb_get_rsdt_address
156 * 157 *
157 * PARAMETERS: None 158 * PARAMETERS: out_address - Where the address is returned
158 * 159 *
159 * RETURN: RSDT physical address 160 * RETURN: None, Address
160 * 161 *
161 * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the 162 * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the
162 * version of the RSDP 163 * version of the RSDP
@@ -181,7 +182,8 @@ acpi_tb_get_rsdt_address (
181 out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address; 182 out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
182 } 183 }
183 else { 184 else {
184 out_address->pointer.value = acpi_gbl_RSDP->xsdt_physical_address; 185 out_address->pointer.value =
186 acpi_gbl_RSDP->xsdt_physical_address;
185 } 187 }
186} 188}
187 189
@@ -224,7 +226,8 @@ acpi_tb_validate_rsdt (
224 if (no_match) { 226 if (no_match) {
225 /* Invalid RSDT or XSDT signature */ 227 /* Invalid RSDT or XSDT signature */
226 228
227 ACPI_REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); 229 ACPI_REPORT_ERROR ((
230 "Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
228 231
229 ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20); 232 ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20);
230 233
@@ -282,6 +285,7 @@ acpi_tb_get_table_rsdt (
282 if (ACPI_FAILURE (status)) { 285 if (ACPI_FAILURE (status)) {
283 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n", 286 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n",
284 acpi_format_exception (status))); 287 acpi_format_exception (status)));
288
285 return_ACPI_STATUS (status); 289 return_ACPI_STATUS (status);
286 } 290 }
287 291
@@ -299,7 +303,8 @@ acpi_tb_get_table_rsdt (
299 303
300 /* Get the number of tables defined in the RSDT or XSDT */ 304 /* Get the number of tables defined in the RSDT or XSDT */
301 305
302 acpi_gbl_rsdt_table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, table_info.pointer); 306 acpi_gbl_rsdt_table_count = acpi_tb_get_table_count (acpi_gbl_RSDP,
307 table_info.pointer);
303 308
304 /* Convert and/or copy to an XSDT structure */ 309 /* Convert and/or copy to an XSDT structure */
305 310
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index fede5804c783..e69d01d443d2 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -49,48 +49,14 @@
49#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbutils") 50 ACPI_MODULE_NAME ("tbutils")
51 51
52/* Local prototypes */
52 53
53/******************************************************************************* 54#ifdef ACPI_OBSOLETE_FUNCTIONS
54 *
55 * FUNCTION: acpi_tb_handle_to_object
56 *
57 * PARAMETERS: table_id - Id for which the function is searching
58 * table_desc - Pointer to return the matching table
59 * descriptor.
60 *
61 * RETURN: Search the tables to find one with a matching table_id and
62 * return a pointer to that table descriptor.
63 *
64 ******************************************************************************/
65#ifdef ACPI_FUTURE_USAGE
66acpi_status 55acpi_status
67acpi_tb_handle_to_object ( 56acpi_tb_handle_to_object (
68 u16 table_id, 57 u16 table_id,
69 struct acpi_table_desc **return_table_desc) 58 struct acpi_table_desc **table_desc);
70{ 59#endif
71 u32 i;
72 struct acpi_table_desc *table_desc;
73
74
75 ACPI_FUNCTION_NAME ("tb_handle_to_object");
76
77
78 for (i = 0; i < ACPI_TABLE_MAX; i++) {
79 table_desc = acpi_gbl_table_lists[i].next;
80 while (table_desc) {
81 if (table_desc->table_id == table_id) {
82 *return_table_desc = table_desc;
83 return (AE_OK);
84 }
85
86 table_desc = table_desc->next;
87 }
88 }
89
90 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id));
91 return (AE_BAD_PARAMETER);
92}
93#endif /* ACPI_FUTURE_USAGE */
94 60
95 61
96/******************************************************************************* 62/*******************************************************************************
@@ -128,6 +94,7 @@ acpi_tb_validate_table_header (
128 if (!acpi_os_readable (table_header, sizeof (struct acpi_table_header))) { 94 if (!acpi_os_readable (table_header, sizeof (struct acpi_table_header))) {
129 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 95 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
130 "Cannot read table header at %p\n", table_header)); 96 "Cannot read table header at %p\n", table_header));
97
131 return (AE_BAD_ADDRESS); 98 return (AE_BAD_ADDRESS);
132 } 99 }
133 100
@@ -141,6 +108,7 @@ acpi_tb_validate_table_header (
141 108
142 ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n", 109 ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n",
143 (char *) &signature)); 110 (char *) &signature));
111
144 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); 112 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header));
145 return (AE_BAD_SIGNATURE); 113 return (AE_BAD_SIGNATURE);
146 } 114 }
@@ -154,6 +122,7 @@ acpi_tb_validate_table_header (
154 122
155 ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n", 123 ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n",
156 (u32) table_header->length)); 124 (u32) table_header->length));
125
157 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header)); 126 ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header));
158 return (AE_BAD_HEADER); 127 return (AE_BAD_HEADER);
159 } 128 }
@@ -193,8 +162,10 @@ acpi_tb_verify_table_checksum (
193 /* Return the appropriate exception */ 162 /* Return the appropriate exception */
194 163
195 if (checksum) { 164 if (checksum) {
196 ACPI_REPORT_WARNING (("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", 165 ACPI_REPORT_WARNING ((
197 table_header->signature, (u32) table_header->checksum, (u32) checksum)); 166 "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n",
167 table_header->signature, (u32) table_header->checksum,
168 (u32) checksum));
198 169
199 status = AE_BAD_CHECKSUM; 170 status = AE_BAD_CHECKSUM;
200 } 171 }
@@ -209,7 +180,7 @@ acpi_tb_verify_table_checksum (
209 * PARAMETERS: Buffer - Buffer to checksum 180 * PARAMETERS: Buffer - Buffer to checksum
210 * Length - Size of the buffer 181 * Length - Size of the buffer
211 * 182 *
212 * RETURNS 8 bit checksum of buffer 183 * RETURN: 8 bit checksum of buffer
213 * 184 *
214 * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. 185 * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it.
215 * 186 *
@@ -238,3 +209,47 @@ acpi_tb_checksum (
238} 209}
239 210
240 211
212#ifdef ACPI_OBSOLETE_FUNCTIONS
213/*******************************************************************************
214 *
215 * FUNCTION: acpi_tb_handle_to_object
216 *
217 * PARAMETERS: table_id - Id for which the function is searching
218 * table_desc - Pointer to return the matching table
219 * descriptor.
220 *
221 * RETURN: Search the tables to find one with a matching table_id and
222 * return a pointer to that table descriptor.
223 *
224 ******************************************************************************/
225
226acpi_status
227acpi_tb_handle_to_object (
228 u16 table_id,
229 struct acpi_table_desc **return_table_desc)
230{
231 u32 i;
232 struct acpi_table_desc *table_desc;
233
234
235 ACPI_FUNCTION_NAME ("tb_handle_to_object");
236
237
238 for (i = 0; i < ACPI_TABLE_MAX; i++) {
239 table_desc = acpi_gbl_table_lists[i].next;
240 while (table_desc) {
241 if (table_desc->table_id == table_id) {
242 *return_table_desc = table_desc;
243 return (AE_OK);
244 }
245
246 table_desc = table_desc->next;
247 }
248 }
249
250 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id));
251 return (AE_BAD_PARAMETER);
252}
253#endif
254
255
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 7715043461c4..0c0b9085dbeb 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -67,7 +67,8 @@
67 ******************************************************************************/ 67 ******************************************************************************/
68 68
69acpi_status 69acpi_status
70acpi_load_tables (void) 70acpi_load_tables (
71 void)
71{ 72{
72 struct acpi_pointer rsdp_address; 73 struct acpi_pointer rsdp_address;
73 acpi_status status; 74 acpi_status status;
@@ -82,7 +83,7 @@ acpi_load_tables (void)
82 &rsdp_address); 83 &rsdp_address);
83 if (ACPI_FAILURE (status)) { 84 if (ACPI_FAILURE (status)) {
84 ACPI_REPORT_ERROR (("acpi_load_tables: Could not get RSDP, %s\n", 85 ACPI_REPORT_ERROR (("acpi_load_tables: Could not get RSDP, %s\n",
85 acpi_format_exception (status))); 86 acpi_format_exception (status)));
86 goto error_exit; 87 goto error_exit;
87 } 88 }
88 89
@@ -93,7 +94,7 @@ acpi_load_tables (void)
93 status = acpi_tb_verify_rsdp (&rsdp_address); 94 status = acpi_tb_verify_rsdp (&rsdp_address);
94 if (ACPI_FAILURE (status)) { 95 if (ACPI_FAILURE (status)) {
95 ACPI_REPORT_ERROR (("acpi_load_tables: RSDP Failed validation: %s\n", 96 ACPI_REPORT_ERROR (("acpi_load_tables: RSDP Failed validation: %s\n",
96 acpi_format_exception (status))); 97 acpi_format_exception (status)));
97 goto error_exit; 98 goto error_exit;
98 } 99 }
99 100
@@ -102,7 +103,7 @@ acpi_load_tables (void)
102 status = acpi_tb_get_table_rsdt (); 103 status = acpi_tb_get_table_rsdt ();
103 if (ACPI_FAILURE (status)) { 104 if (ACPI_FAILURE (status)) {
104 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load RSDT: %s\n", 105 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load RSDT: %s\n",
105 acpi_format_exception (status))); 106 acpi_format_exception (status)));
106 goto error_exit; 107 goto error_exit;
107 } 108 }
108 109
@@ -110,20 +111,20 @@ acpi_load_tables (void)
110 111
111 status = acpi_tb_get_required_tables (); 112 status = acpi_tb_get_required_tables ();
112 if (ACPI_FAILURE (status)) { 113 if (ACPI_FAILURE (status)) {
113 ACPI_REPORT_ERROR (("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", 114 ACPI_REPORT_ERROR ((
114 acpi_format_exception (status))); 115 "acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
116 acpi_format_exception (status)));
115 goto error_exit; 117 goto error_exit;
116 } 118 }
117 119
118 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); 120 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
119 121
120
121 /* Load the namespace from the tables */ 122 /* Load the namespace from the tables */
122 123
123 status = acpi_ns_load_namespace (); 124 status = acpi_ns_load_namespace ();
124 if (ACPI_FAILURE (status)) { 125 if (ACPI_FAILURE (status)) {
125 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load namespace: %s\n", 126 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load namespace: %s\n",
126 acpi_format_exception (status))); 127 acpi_format_exception (status)));
127 goto error_exit; 128 goto error_exit;
128 } 129 }
129 130
@@ -139,7 +140,6 @@ error_exit:
139 140
140 141
141#ifdef ACPI_FUTURE_USAGE 142#ifdef ACPI_FUTURE_USAGE
142
143/******************************************************************************* 143/*******************************************************************************
144 * 144 *
145 * FUNCTION: acpi_load_table 145 * FUNCTION: acpi_load_table
@@ -250,7 +250,6 @@ acpi_unload_table (
250 return_ACPI_STATUS (AE_BAD_PARAMETER); 250 return_ACPI_STATUS (AE_BAD_PARAMETER);
251 } 251 }
252 252
253
254 /* Find all tables of the requested type */ 253 /* Find all tables of the requested type */
255 254
256 table_desc = acpi_gbl_table_lists[table_type].next; 255 table_desc = acpi_gbl_table_lists[table_type].next;
@@ -321,7 +320,6 @@ acpi_get_table_header (
321 return_ACPI_STATUS (AE_BAD_PARAMETER); 320 return_ACPI_STATUS (AE_BAD_PARAMETER);
322 } 321 }
323 322
324
325 /* Get a pointer to the entire table */ 323 /* Get a pointer to the entire table */
326 324
327 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 325 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr);
@@ -329,23 +327,20 @@ acpi_get_table_header (
329 return_ACPI_STATUS (status); 327 return_ACPI_STATUS (status);
330 } 328 }
331 329
332 /* 330 /* The function will return a NULL pointer if the table is not loaded */
333 * The function will return a NULL pointer if the table is not loaded 331
334 */
335 if (tbl_ptr == NULL) { 332 if (tbl_ptr == NULL) {
336 return_ACPI_STATUS (AE_NOT_EXIST); 333 return_ACPI_STATUS (AE_NOT_EXIST);
337 } 334 }
338 335
339 /* 336 /* Copy the header to the caller's buffer */
340 * Copy the header to the caller's buffer 337
341 */
342 ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr, 338 ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr,
343 sizeof (struct acpi_table_header)); 339 sizeof (struct acpi_table_header));
344 340
345 return_ACPI_STATUS (status); 341 return_ACPI_STATUS (status);
346} 342}
347 343
348
349#endif /* ACPI_FUTURE_USAGE */ 344#endif /* ACPI_FUTURE_USAGE */
350 345
351/******************************************************************************* 346/*******************************************************************************
@@ -404,7 +399,6 @@ acpi_get_table (
404 return_ACPI_STATUS (AE_BAD_PARAMETER); 399 return_ACPI_STATUS (AE_BAD_PARAMETER);
405 } 400 }
406 401
407
408 /* Get a pointer to the entire table */ 402 /* Get a pointer to the entire table */
409 403
410 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 404 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr);
@@ -423,9 +417,8 @@ acpi_get_table (
423 /* Get the table length */ 417 /* Get the table length */
424 418
425 if (table_type == ACPI_TABLE_RSDP) { 419 if (table_type == ACPI_TABLE_RSDP) {
426 /* 420 /* RSD PTR is the only "table" without a header */
427 * RSD PTR is the only "table" without a header 421
428 */
429 table_length = sizeof (struct rsdp_descriptor); 422 table_length = sizeof (struct rsdp_descriptor);
430 } 423 }
431 else { 424 else {
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index 6e8072ebbac6..dc3c3f6a9f62 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -50,6 +50,18 @@
50#define _COMPONENT ACPI_TABLES 50#define _COMPONENT ACPI_TABLES
51 ACPI_MODULE_NAME ("tbxfroot") 51 ACPI_MODULE_NAME ("tbxfroot")
52 52
53/* Local prototypes */
54
55static acpi_status
56acpi_tb_find_rsdp (
57 struct acpi_table_desc *table_info,
58 u32 flags);
59
60static u8 *
61acpi_tb_scan_memory_for_rsdp (
62 u8 *start_address,
63 u32 length);
64
53 65
54/******************************************************************************* 66/*******************************************************************************
55 * 67 *
@@ -57,7 +69,8 @@
57 * 69 *
58 * PARAMETERS: Signature - String with ACPI table signature 70 * PARAMETERS: Signature - String with ACPI table signature
59 * oem_id - String with the table OEM ID 71 * oem_id - String with the table OEM ID
60 * oem_table_id - String with the OEM Table ID. 72 * oem_table_id - String with the OEM Table ID
73 * table_ptr - Where the table pointer is returned
61 * 74 *
62 * RETURN: Status 75 * RETURN: Status
63 * 76 *
@@ -99,14 +112,13 @@ acpi_tb_find_table (
99 if (!acpi_gbl_DSDT) { 112 if (!acpi_gbl_DSDT) {
100 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 113 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
101 } 114 }
102
103 table = acpi_gbl_DSDT; 115 table = acpi_gbl_DSDT;
104 } 116 }
105 else { 117 else {
106 /* Find the table */ 118 /* Find the table */
107 119
108 status = acpi_get_firmware_table (signature, 1, 120 status = acpi_get_firmware_table (signature, 1,
109 ACPI_LOGICAL_ADDRESSING, &table); 121 ACPI_LOGICAL_ADDRESSING, &table);
110 if (ACPI_FAILURE (status)) { 122 if (ACPI_FAILURE (status)) {
111 return_ACPI_STATUS (status); 123 return_ACPI_STATUS (status);
112 } 124 }
@@ -114,14 +126,19 @@ acpi_tb_find_table (
114 126
115 /* Check oem_id and oem_table_id */ 127 /* Check oem_id and oem_table_id */
116 128
117 if ((oem_id[0] && ACPI_STRNCMP ( 129 if ((oem_id[0] && ACPI_STRNCMP (
118 oem_id, table->oem_id, sizeof (table->oem_id))) || 130 oem_id, table->oem_id,
131 sizeof (table->oem_id))) ||
132
119 (oem_table_id[0] && ACPI_STRNCMP ( 133 (oem_table_id[0] && ACPI_STRNCMP (
120 oem_table_id, table->oem_table_id, sizeof (table->oem_table_id)))) { 134 oem_table_id, table->oem_table_id,
135 sizeof (table->oem_table_id)))) {
121 return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND); 136 return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
122 } 137 }
123 138
124 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", table->signature)); 139 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n",
140 table->signature));
141
125 *table_ptr = table; 142 *table_ptr = table;
126 return_ACPI_STATUS (AE_OK); 143 return_ACPI_STATUS (AE_OK);
127} 144}
@@ -191,8 +208,8 @@ acpi_get_firmware_table (
191 /* Map and validate the RSDP */ 208 /* Map and validate the RSDP */
192 209
193 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { 210 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
194 status = acpi_os_map_memory (address.pointer.physical, sizeof (struct rsdp_descriptor), 211 status = acpi_os_map_memory (address.pointer.physical,
195 (void *) &acpi_gbl_RSDP); 212 sizeof (struct rsdp_descriptor), (void *) &acpi_gbl_RSDP);
196 if (ACPI_FAILURE (status)) { 213 if (ACPI_FAILURE (status)) {
197 return_ACPI_STATUS (status); 214 return_ACPI_STATUS (status);
198 } 215 }
@@ -203,7 +220,8 @@ acpi_get_firmware_table (
203 220
204 /* The signature and checksum must both be correct */ 221 /* The signature and checksum must both be correct */
205 222
206 if (ACPI_STRNCMP ((char *) acpi_gbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { 223 if (ACPI_STRNCMP ((char *) acpi_gbl_RSDP, RSDP_SIG,
224 sizeof (RSDP_SIG)-1) != 0) {
207 /* Nope, BAD Signature */ 225 /* Nope, BAD Signature */
208 226
209 return_ACPI_STATUS (AE_BAD_SIGNATURE); 227 return_ACPI_STATUS (AE_BAD_SIGNATURE);
@@ -313,7 +331,8 @@ acpi_get_firmware_table (
313 331
314 332
315cleanup: 333cleanup:
316 acpi_os_unmap_memory (rsdt_info->pointer, (acpi_size) rsdt_info->pointer->length); 334 acpi_os_unmap_memory (rsdt_info->pointer,
335 (acpi_size) rsdt_info->pointer->length);
317 ACPI_MEM_FREE (rsdt_info); 336 ACPI_MEM_FREE (rsdt_info);
318 337
319 if (header) { 338 if (header) {
@@ -335,8 +354,8 @@ EXPORT_SYMBOL(acpi_get_firmware_table);
335 * 354 *
336 * FUNCTION: acpi_find_root_pointer 355 * FUNCTION: acpi_find_root_pointer
337 * 356 *
338 * PARAMETERS: **rsdp_address - Where to place the RSDP address 357 * PARAMETERS: Flags - Logical/Physical addressing
339 * Flags - Logical/Physical addressing 358 * rsdp_address - Where to place the RSDP address
340 * 359 *
341 * RETURN: Status, Physical address of the RSDP 360 * RETURN: Status, Physical address of the RSDP
342 * 361 *
@@ -363,6 +382,7 @@ acpi_find_root_pointer (
363 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 382 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
364 "RSDP structure not found, %s Flags=%X\n", 383 "RSDP structure not found, %s Flags=%X\n",
365 acpi_format_exception (status), flags)); 384 acpi_format_exception (status), flags));
385
366 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 386 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
367 } 387 }
368 388
@@ -385,7 +405,7 @@ acpi_find_root_pointer (
385 * 405 *
386 ******************************************************************************/ 406 ******************************************************************************/
387 407
388u8 * 408static u8 *
389acpi_tb_scan_memory_for_rsdp ( 409acpi_tb_scan_memory_for_rsdp (
390 u8 *start_address, 410 u8 *start_address,
391 u32 length) 411 u32 length)
@@ -406,7 +426,8 @@ acpi_tb_scan_memory_for_rsdp (
406 mem_rover += ACPI_RSDP_SCAN_STEP) { 426 mem_rover += ACPI_RSDP_SCAN_STEP) {
407 /* The signature and checksum must both be correct */ 427 /* The signature and checksum must both be correct */
408 428
409 if (ACPI_STRNCMP ((char *) mem_rover, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { 429 if (ACPI_STRNCMP ((char *) mem_rover,
430 RSDP_SIG, sizeof (RSDP_SIG) - 1) != 0) {
410 /* No signature match, keep looking */ 431 /* No signature match, keep looking */
411 432
412 continue; 433 continue;
@@ -450,7 +471,7 @@ acpi_tb_scan_memory_for_rsdp (
450 * 471 *
451 * FUNCTION: acpi_tb_find_rsdp 472 * FUNCTION: acpi_tb_find_rsdp
452 * 473 *
453 * PARAMETERS: *table_info - Where the table info is returned 474 * PARAMETERS: table_info - Where the table info is returned
454 * Flags - Current memory mode (logical vs. 475 * Flags - Current memory mode (logical vs.
455 * physical addressing) 476 * physical addressing)
456 * 477 *
@@ -468,7 +489,7 @@ acpi_tb_scan_memory_for_rsdp (
468 * 489 *
469 ******************************************************************************/ 490 ******************************************************************************/
470 491
471acpi_status 492static acpi_status
472acpi_tb_find_rsdp ( 493acpi_tb_find_rsdp (
473 struct acpi_table_desc *table_info, 494 struct acpi_table_desc *table_info,
474 u32 flags) 495 u32 flags)
@@ -483,43 +504,49 @@ acpi_tb_find_rsdp (
483 504
484 505
485 /* 506 /*
486 * Scan supports either 1) Logical addressing or 2) Physical addressing 507 * Scan supports either logical addressing or physical addressing
487 */ 508 */
488 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { 509 if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
489 /* 510 /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
490 * 1a) Get the location of the EBDA 511
491 */ 512 status = acpi_os_map_memory (
492 status = acpi_os_map_memory ((acpi_physical_address) ACPI_EBDA_PTR_LOCATION, 513 (acpi_physical_address) ACPI_EBDA_PTR_LOCATION,
493 ACPI_EBDA_PTR_LENGTH, 514 ACPI_EBDA_PTR_LENGTH, (void *) &table_ptr);
494 (void *) &table_ptr);
495 if (ACPI_FAILURE (status)) { 515 if (ACPI_FAILURE (status)) {
496 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
497 "Could not map memory at %8.8X for length %X\n", 517 "Could not map memory at %8.8X for length %X\n",
498 ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); 518 ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
519
499 return_ACPI_STATUS (status); 520 return_ACPI_STATUS (status);
500 } 521 }
501 522
502 ACPI_MOVE_16_TO_32 (&physical_address, table_ptr); 523 ACPI_MOVE_16_TO_32 (&physical_address, table_ptr);
503 physical_address <<= 4; /* Convert segment to physical address */ 524
525 /* Convert segment part to physical address */
526
527 physical_address <<= 4;
504 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_PTR_LENGTH); 528 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_PTR_LENGTH);
505 529
506 /* EBDA present? */ 530 /* EBDA present? */
507 531
508 if (physical_address > 0x400) { 532 if (physical_address > 0x400) {
509 /* 533 /*
510 * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of 1_k length) 534 * 1b) Search EBDA paragraphs (EBDa is required to be a
535 * minimum of 1_k length)
511 */ 536 */
512 status = acpi_os_map_memory ((acpi_physical_address) physical_address, 537 status = acpi_os_map_memory (
513 ACPI_EBDA_WINDOW_SIZE, 538 (acpi_physical_address) physical_address,
514 (void *) &table_ptr); 539 ACPI_EBDA_WINDOW_SIZE, (void *) &table_ptr);
515 if (ACPI_FAILURE (status)) { 540 if (ACPI_FAILURE (status)) {
516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 541 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
517 "Could not map memory at %8.8X for length %X\n", 542 "Could not map memory at %8.8X for length %X\n",
518 physical_address, ACPI_EBDA_WINDOW_SIZE)); 543 physical_address, ACPI_EBDA_WINDOW_SIZE));
544
519 return_ACPI_STATUS (status); 545 return_ACPI_STATUS (status);
520 } 546 }
521 547
522 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, ACPI_EBDA_WINDOW_SIZE); 548 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr,
549 ACPI_EBDA_WINDOW_SIZE);
523 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE); 550 acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE);
524 551
525 if (mem_rover) { 552 if (mem_rover) {
@@ -527,7 +554,8 @@ acpi_tb_find_rsdp (
527 554
528 physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr); 555 physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr);
529 556
530 table_info->physical_address = (acpi_physical_address) physical_address; 557 table_info->physical_address =
558 (acpi_physical_address) physical_address;
531 return_ACPI_STATUS (AE_OK); 559 return_ACPI_STATUS (AE_OK);
532 } 560 }
533 } 561 }
@@ -535,13 +563,15 @@ acpi_tb_find_rsdp (
535 /* 563 /*
536 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh 564 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
537 */ 565 */
538 status = acpi_os_map_memory ((acpi_physical_address) ACPI_HI_RSDP_WINDOW_BASE, 566 status = acpi_os_map_memory (
539 ACPI_HI_RSDP_WINDOW_SIZE, 567 (acpi_physical_address) ACPI_HI_RSDP_WINDOW_BASE,
540 (void *) &table_ptr); 568 ACPI_HI_RSDP_WINDOW_SIZE, (void *) &table_ptr);
569
541 if (ACPI_FAILURE (status)) { 570 if (ACPI_FAILURE (status)) {
542 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 571 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
543 "Could not map memory at %8.8X for length %X\n", 572 "Could not map memory at %8.8X for length %X\n",
544 ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); 573 ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
574
545 return_ACPI_STATUS (status); 575 return_ACPI_STATUS (status);
546 } 576 }
547 577
@@ -551,9 +581,11 @@ acpi_tb_find_rsdp (
551 if (mem_rover) { 581 if (mem_rover) {
552 /* Found it, return the physical address */ 582 /* Found it, return the physical address */
553 583
554 physical_address = ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr); 584 physical_address =
585 ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr);
555 586
556 table_info->physical_address = (acpi_physical_address) physical_address; 587 table_info->physical_address =
588 (acpi_physical_address) physical_address;
557 return_ACPI_STATUS (AE_OK); 589 return_ACPI_STATUS (AE_OK);
558 } 590 }
559 } 591 }
@@ -562,9 +594,8 @@ acpi_tb_find_rsdp (
562 * Physical addressing 594 * Physical addressing
563 */ 595 */
564 else { 596 else {
565 /* 597 /* 1a) Get the location of the EBDA */
566 * 1a) Get the location of the EBDA 598
567 */
568 ACPI_MOVE_16_TO_32 (&physical_address, ACPI_EBDA_PTR_LOCATION); 599 ACPI_MOVE_16_TO_32 (&physical_address, ACPI_EBDA_PTR_LOCATION);
569 physical_address <<= 4; /* Convert segment to physical address */ 600 physical_address <<= 4; /* Convert segment to physical address */
570 601
@@ -572,9 +603,11 @@ acpi_tb_find_rsdp (
572 603
573 if (physical_address > 0x400) { 604 if (physical_address > 0x400) {
574 /* 605 /*
575 * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of 1_k length) 606 * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of
607 * 1_k length)
576 */ 608 */
577 mem_rover = acpi_tb_scan_memory_for_rsdp (ACPI_PHYSADDR_TO_PTR (physical_address), 609 mem_rover = acpi_tb_scan_memory_for_rsdp (
610 ACPI_PHYSADDR_TO_PTR (physical_address),
578 ACPI_EBDA_WINDOW_SIZE); 611 ACPI_EBDA_WINDOW_SIZE);
579 if (mem_rover) { 612 if (mem_rover) {
580 /* Found it, return the physical address */ 613 /* Found it, return the physical address */
@@ -584,10 +617,10 @@ acpi_tb_find_rsdp (
584 } 617 }
585 } 618 }
586 619
587 /* 620 /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */
588 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh 621
589 */ 622 mem_rover = acpi_tb_scan_memory_for_rsdp (
590 mem_rover = acpi_tb_scan_memory_for_rsdp (ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), 623 ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE),
591 ACPI_HI_RSDP_WINDOW_SIZE); 624 ACPI_HI_RSDP_WINDOW_SIZE);
592 if (mem_rover) { 625 if (mem_rover) {
593 /* Found it, return the physical address */ 626 /* Found it, return the physical address */
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c
index c84997c9f964..73b1d8aeae9d 100644
--- a/drivers/acpi/toshiba_acpi.c
+++ b/drivers/acpi/toshiba_acpi.c
@@ -263,6 +263,9 @@ dispatch_write(struct file* file, const char __user * buffer,
263 * destination so that sscanf can be used on it safely. 263 * destination so that sscanf can be used on it safely.
264 */ 264 */
265 tmp_buffer = kmalloc(count + 1, GFP_KERNEL); 265 tmp_buffer = kmalloc(count + 1, GFP_KERNEL);
266 if(!tmp_buffer)
267 return -ENOMEM;
268
266 if (copy_from_user(tmp_buffer, buffer, count)) { 269 if (copy_from_user(tmp_buffer, buffer, count)) {
267 result = -EFAULT; 270 result = -EFAULT;
268 } 271 }
@@ -529,6 +532,11 @@ toshiba_acpi_init(void)
529 532
530 if (acpi_disabled) 533 if (acpi_disabled)
531 return -ENODEV; 534 return -ENODEV;
535
536 if (!acpi_specific_hotkey_enabled){
537 printk(MY_INFO "Using generic hotkey driver\n");
538 return -ENODEV;
539 }
532 /* simple device detection: look for HCI method */ 540 /* simple device detection: look for HCI method */
533 if (is_valid_acpi_path(METHOD_HCI_1)) 541 if (is_valid_acpi_path(METHOD_HCI_1))
534 method_hci = METHOD_HCI_1; 542 method_hci = METHOD_HCI_1;
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 3313439c4bc7..c4e7f989a2bd 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -47,8 +47,35 @@
47#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utalloc") 48 ACPI_MODULE_NAME ("utalloc")
49 49
50/* Local prototypes */
50 51
51/****************************************************************************** 52#ifdef ACPI_DBG_TRACK_ALLOCATIONS
53static struct acpi_debug_mem_block *
54acpi_ut_find_allocation (
55 u32 list_id,
56 void *allocation);
57
58static acpi_status
59acpi_ut_track_allocation (
60 u32 list_id,
61 struct acpi_debug_mem_block *address,
62 acpi_size size,
63 u8 alloc_type,
64 u32 component,
65 char *module,
66 u32 line);
67
68static acpi_status
69acpi_ut_remove_allocation (
70 u32 list_id,
71 struct acpi_debug_mem_block *address,
72 u32 component,
73 char *module,
74 u32 line);
75#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
76
77
78/*******************************************************************************
52 * 79 *
53 * FUNCTION: acpi_ut_release_to_cache 80 * FUNCTION: acpi_ut_release_to_cache
54 * 81 *
@@ -98,7 +125,8 @@ acpi_ut_release_to_cache (
98 125
99 /* Put the object at the head of the cache list */ 126 /* Put the object at the head of the cache list */
100 127
101 * (ACPI_CAST_INDIRECT_PTR (char, &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head; 128 * (ACPI_CAST_INDIRECT_PTR (char,
129 &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head;
102 cache_info->list_head = object; 130 cache_info->list_head = object;
103 cache_info->cache_depth++; 131 cache_info->cache_depth++;
104 132
@@ -115,7 +143,7 @@ acpi_ut_release_to_cache (
115} 143}
116 144
117 145
118/****************************************************************************** 146/*******************************************************************************
119 * 147 *
120 * FUNCTION: acpi_ut_acquire_from_cache 148 * FUNCTION: acpi_ut_acquire_from_cache
121 * 149 *
@@ -156,7 +184,8 @@ acpi_ut_acquire_from_cache (
156 /* There is an object available, use it */ 184 /* There is an object available, use it */
157 185
158 object = cache_info->list_head; 186 object = cache_info->list_head;
159 cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) object)[cache_info->link_offset]))); 187 cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char,
188 &(((char *) object)[cache_info->link_offset])));
160 189
161 ACPI_MEM_TRACKING (cache_info->cache_hits++); 190 ACPI_MEM_TRACKING (cache_info->cache_hits++);
162 cache_info->cache_depth--; 191 cache_info->cache_depth--;
@@ -201,7 +230,7 @@ acpi_ut_acquire_from_cache (
201 230
202 231
203#ifdef ACPI_ENABLE_OBJECT_CACHE 232#ifdef ACPI_ENABLE_OBJECT_CACHE
204/****************************************************************************** 233/*******************************************************************************
205 * 234 *
206 * FUNCTION: acpi_ut_delete_generic_cache 235 * FUNCTION: acpi_ut_delete_generic_cache
207 * 236 *
@@ -228,7 +257,8 @@ acpi_ut_delete_generic_cache (
228 while (cache_info->list_head) { 257 while (cache_info->list_head) {
229 /* Delete one cached state object */ 258 /* Delete one cached state object */
230 259
231 next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) cache_info->list_head)[cache_info->link_offset]))); 260 next = *(ACPI_CAST_INDIRECT_PTR (char,
261 &(((char *) cache_info->list_head)[cache_info->link_offset])));
232 ACPI_MEM_FREE (cache_info->list_head); 262 ACPI_MEM_FREE (cache_info->list_head);
233 263
234 cache_info->list_head = next; 264 cache_info->list_head = next;
@@ -497,8 +527,8 @@ acpi_ut_allocate_and_track (
497 acpi_status status; 527 acpi_status status;
498 528
499 529
500 allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header), component, 530 allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header),
501 module, line); 531 component, module, line);
502 if (!allocation) { 532 if (!allocation) {
503 return (NULL); 533 return (NULL);
504 } 534 }
@@ -543,8 +573,8 @@ acpi_ut_callocate_and_track (
543 acpi_status status; 573 acpi_status status;
544 574
545 575
546 allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header), component, 576 allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header),
547 module, line); 577 component, module, line);
548 if (!allocation) { 578 if (!allocation) {
549 /* Report allocation error */ 579 /* Report allocation error */
550 580
@@ -637,7 +667,7 @@ acpi_ut_free_and_track (
637 * 667 *
638 ******************************************************************************/ 668 ******************************************************************************/
639 669
640struct acpi_debug_mem_block * 670static struct acpi_debug_mem_block *
641acpi_ut_find_allocation ( 671acpi_ut_find_allocation (
642 u32 list_id, 672 u32 list_id,
643 void *allocation) 673 void *allocation)
@@ -686,7 +716,7 @@ acpi_ut_find_allocation (
686 * 716 *
687 ******************************************************************************/ 717 ******************************************************************************/
688 718
689acpi_status 719static acpi_status
690acpi_ut_track_allocation ( 720acpi_ut_track_allocation (
691 u32 list_id, 721 u32 list_id,
692 struct acpi_debug_mem_block *allocation, 722 struct acpi_debug_mem_block *allocation,
@@ -721,10 +751,12 @@ acpi_ut_track_allocation (
721 751
722 element = acpi_ut_find_allocation (list_id, allocation); 752 element = acpi_ut_find_allocation (list_id, allocation);
723 if (element) { 753 if (element) {
724 ACPI_REPORT_ERROR (("ut_track_allocation: Allocation already present in list! (%p)\n", 754 ACPI_REPORT_ERROR ((
755 "ut_track_allocation: Allocation already present in list! (%p)\n",
725 allocation)); 756 allocation));
726 757
727 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", element, allocation)); 758 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n",
759 element, allocation));
728 760
729 goto unlock_and_exit; 761 goto unlock_and_exit;
730 } 762 }
@@ -773,7 +805,7 @@ unlock_and_exit:
773 * 805 *
774 ******************************************************************************/ 806 ******************************************************************************/
775 807
776acpi_status 808static acpi_status
777acpi_ut_remove_allocation ( 809acpi_ut_remove_allocation (
778 u32 list_id, 810 u32 list_id,
779 struct acpi_debug_mem_block *allocation, 811 struct acpi_debug_mem_block *allocation,
@@ -797,7 +829,7 @@ acpi_ut_remove_allocation (
797 /* No allocations! */ 829 /* No allocations! */
798 830
799 _ACPI_REPORT_ERROR (module, line, component, 831 _ACPI_REPORT_ERROR (module, line, component,
800 ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); 832 ("ut_remove_allocation: Empty allocation list, nothing to free!\n"));
801 833
802 return_ACPI_STATUS (AE_OK); 834 return_ACPI_STATUS (AE_OK);
803 } 835 }
@@ -824,7 +856,8 @@ acpi_ut_remove_allocation (
824 856
825 ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size); 857 ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size);
826 858
827 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", allocation->size)); 859 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
860 allocation->size));
828 861
829 status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); 862 status = acpi_ut_release_mutex (ACPI_MTX_MEMORY);
830 return_ACPI_STATUS (status); 863 return_ACPI_STATUS (status);
@@ -842,6 +875,7 @@ acpi_ut_remove_allocation (
842 * DESCRIPTION: Print some info about the outstanding allocations. 875 * DESCRIPTION: Print some info about the outstanding allocations.
843 * 876 *
844 ******************************************************************************/ 877 ******************************************************************************/
878
845#ifdef ACPI_FUTURE_USAGE 879#ifdef ACPI_FUTURE_USAGE
846void 880void
847acpi_ut_dump_allocation_info ( 881acpi_ut_dump_allocation_info (
@@ -884,7 +918,8 @@ acpi_ut_dump_allocation_info (
884 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 918 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
885 ("%30s: %4d (%3d Kb)\n", "Max Nodes", 919 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
886 acpi_gbl_max_concurrent_node_count, 920 acpi_gbl_max_concurrent_node_count,
887 ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count * sizeof (struct acpi_namespace_node))))); 921 ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count *
922 sizeof (struct acpi_namespace_node)))));
888*/ 923*/
889 return_VOID; 924 return_VOID;
890} 925}
@@ -933,26 +968,26 @@ acpi_ut_dump_allocations (
933 descriptor = ACPI_CAST_PTR (union acpi_descriptor, &element->user_space); 968 descriptor = ACPI_CAST_PTR (union acpi_descriptor, &element->user_space);
934 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) { 969 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) {
935 acpi_os_printf ("%p Len %04X %9.9s-%d [%s] ", 970 acpi_os_printf ("%p Len %04X %9.9s-%d [%s] ",
936 descriptor, element->size, element->module, 971 descriptor, element->size, element->module,
937 element->line, acpi_ut_get_descriptor_name (descriptor)); 972 element->line, acpi_ut_get_descriptor_name (descriptor));
938 973
939 /* Most of the elements will be Operand objects. */ 974 /* Most of the elements will be Operand objects. */
940 975
941 switch (ACPI_GET_DESCRIPTOR_TYPE (descriptor)) { 976 switch (ACPI_GET_DESCRIPTOR_TYPE (descriptor)) {
942 case ACPI_DESC_TYPE_OPERAND: 977 case ACPI_DESC_TYPE_OPERAND:
943 acpi_os_printf ("%12.12s R%hd", 978 acpi_os_printf ("%12.12s R%hd",
944 acpi_ut_get_type_name (descriptor->object.common.type), 979 acpi_ut_get_type_name (descriptor->object.common.type),
945 descriptor->object.common.reference_count); 980 descriptor->object.common.reference_count);
946 break; 981 break;
947 982
948 case ACPI_DESC_TYPE_PARSER: 983 case ACPI_DESC_TYPE_PARSER:
949 acpi_os_printf ("aml_opcode %04hX", 984 acpi_os_printf ("aml_opcode %04hX",
950 descriptor->op.asl.aml_opcode); 985 descriptor->op.asl.aml_opcode);
951 break; 986 break;
952 987
953 case ACPI_DESC_TYPE_NAMED: 988 case ACPI_DESC_TYPE_NAMED:
954 acpi_os_printf ("%4.4s", 989 acpi_os_printf ("%4.4s",
955 acpi_ut_get_node_name (&descriptor->node)); 990 acpi_ut_get_node_name (&descriptor->node));
956 break; 991 break;
957 992
958 default: 993 default:
@@ -983,6 +1018,5 @@ acpi_ut_dump_allocations (
983 return_VOID; 1018 return_VOID;
984} 1019}
985 1020
986
987#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ 1021#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
988 1022
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 0fcd98bde0d1..11e884957162 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -49,21 +49,69 @@
49#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utcopy") 50 ACPI_MODULE_NAME ("utcopy")
51 51
52/* Local prototypes */
53
54static acpi_status
55acpi_ut_copy_isimple_to_esimple (
56 union acpi_operand_object *internal_object,
57 union acpi_object *external_object,
58 u8 *data_space,
59 acpi_size *buffer_space_used);
60
61static acpi_status
62acpi_ut_copy_ielement_to_ielement (
63 u8 object_type,
64 union acpi_operand_object *source_object,
65 union acpi_generic_state *state,
66 void *context);
67
68static acpi_status
69acpi_ut_copy_ipackage_to_epackage (
70 union acpi_operand_object *internal_object,
71 u8 *buffer,
72 acpi_size *space_used);
73
74static acpi_status
75acpi_ut_copy_esimple_to_isimple(
76 union acpi_object *user_obj,
77 union acpi_operand_object **return_obj);
78
79static acpi_status
80acpi_ut_copy_simple_object (
81 union acpi_operand_object *source_desc,
82 union acpi_operand_object *dest_desc);
83
84static acpi_status
85acpi_ut_copy_ielement_to_eelement (
86 u8 object_type,
87 union acpi_operand_object *source_object,
88 union acpi_generic_state *state,
89 void *context);
90
91static acpi_status
92acpi_ut_copy_ipackage_to_ipackage (
93 union acpi_operand_object *source_obj,
94 union acpi_operand_object *dest_obj,
95 struct acpi_walk_state *walk_state);
96
52 97
53/******************************************************************************* 98/*******************************************************************************
54 * 99 *
55 * FUNCTION: acpi_ut_copy_isimple_to_esimple 100 * FUNCTION: acpi_ut_copy_isimple_to_esimple
56 * 101 *
57 * PARAMETERS: *internal_object - Pointer to the object we are examining 102 * PARAMETERS: internal_object - Source object to be copied
58 * *Buffer - Where the object is returned 103 * external_object - Where to return the copied object
59 * *space_used - Where the data length is returned 104 * data_space - Where object data is returned (such as
105 * buffer and string data)
106 * buffer_space_used - Length of data_space that was used
60 * 107 *
61 * RETURN: Status 108 * RETURN: Status
62 * 109 *
63 * DESCRIPTION: This function is called to place a simple object in a user 110 * DESCRIPTION: This function is called to copy a simple internal object to
64 * buffer. 111 * an external object.
65 * 112 *
66 * The buffer is assumed to have sufficient space for the object. 113 * The data_space buffer is assumed to have sufficient space for
114 * the object.
67 * 115 *
68 ******************************************************************************/ 116 ******************************************************************************/
69 117
@@ -107,10 +155,12 @@ acpi_ut_copy_isimple_to_esimple (
107 155
108 external_object->string.pointer = (char *) data_space; 156 external_object->string.pointer = (char *) data_space;
109 external_object->string.length = internal_object->string.length; 157 external_object->string.length = internal_object->string.length;
110 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ((acpi_size) internal_object->string.length + 1); 158 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (
159 (acpi_size) internal_object->string.length + 1);
111 160
112 ACPI_MEMCPY ((void *) data_space, (void *) internal_object->string.pointer, 161 ACPI_MEMCPY ((void *) data_space,
113 (acpi_size) internal_object->string.length + 1); 162 (void *) internal_object->string.pointer,
163 (acpi_size) internal_object->string.length + 1);
114 break; 164 break;
115 165
116 166
@@ -118,10 +168,12 @@ acpi_ut_copy_isimple_to_esimple (
118 168
119 external_object->buffer.pointer = data_space; 169 external_object->buffer.pointer = data_space;
120 external_object->buffer.length = internal_object->buffer.length; 170 external_object->buffer.length = internal_object->buffer.length;
121 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (internal_object->string.length); 171 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (
172 internal_object->string.length);
122 173
123 ACPI_MEMCPY ((void *) data_space, (void *) internal_object->buffer.pointer, 174 ACPI_MEMCPY ((void *) data_space,
124 internal_object->buffer.length); 175 (void *) internal_object->buffer.pointer,
176 internal_object->buffer.length);
125 break; 177 break;
126 178
127 179
@@ -194,7 +246,7 @@ acpi_ut_copy_isimple_to_esimple (
194 * 246 *
195 ******************************************************************************/ 247 ******************************************************************************/
196 248
197acpi_status 249static acpi_status
198acpi_ut_copy_ielement_to_eelement ( 250acpi_ut_copy_ielement_to_eelement (
199 u8 object_type, 251 u8 object_type,
200 union acpi_operand_object *source_object, 252 union acpi_operand_object *source_object,
@@ -213,7 +265,7 @@ acpi_ut_copy_ielement_to_eelement (
213 265
214 this_index = state->pkg.index; 266 this_index = state->pkg.index;
215 target_object = (union acpi_object *) 267 target_object = (union acpi_object *)
216 &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index]; 268 &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index];
217 269
218 switch (object_type) { 270 switch (object_type) {
219 case ACPI_COPY_TYPE_SIMPLE: 271 case ACPI_COPY_TYPE_SIMPLE:
@@ -236,7 +288,8 @@ acpi_ut_copy_ielement_to_eelement (
236 */ 288 */
237 target_object->type = ACPI_TYPE_PACKAGE; 289 target_object->type = ACPI_TYPE_PACKAGE;
238 target_object->package.count = source_object->package.count; 290 target_object->package.count = source_object->package.count;
239 target_object->package.elements = ACPI_CAST_PTR (union acpi_object, info->free_space); 291 target_object->package.elements =
292 ACPI_CAST_PTR (union acpi_object, info->free_space);
240 293
241 /* 294 /*
242 * Pass the new package object back to the package walk routine 295 * Pass the new package object back to the package walk routine
@@ -248,7 +301,8 @@ acpi_ut_copy_ielement_to_eelement (
248 * update the buffer length counter 301 * update the buffer length counter
249 */ 302 */
250 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD ( 303 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD (
251 (acpi_size) target_object->package.count * sizeof (union acpi_object)); 304 (acpi_size) target_object->package.count *
305 sizeof (union acpi_object));
252 break; 306 break;
253 307
254 308
@@ -266,9 +320,9 @@ acpi_ut_copy_ielement_to_eelement (
266 * 320 *
267 * FUNCTION: acpi_ut_copy_ipackage_to_epackage 321 * FUNCTION: acpi_ut_copy_ipackage_to_epackage
268 * 322 *
269 * PARAMETERS: *internal_object - Pointer to the object we are returning 323 * PARAMETERS: internal_object - Pointer to the object we are returning
270 * *Buffer - Where the object is returned 324 * Buffer - Where the object is returned
271 * *space_used - Where the object length is returned 325 * space_used - Where the object length is returned
272 * 326 *
273 * RETURN: Status 327 * RETURN: Status
274 * 328 *
@@ -304,13 +358,15 @@ acpi_ut_copy_ipackage_to_epackage (
304 * Free space begins right after the first package 358 * Free space begins right after the first package
305 */ 359 */
306 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 360 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
307 info.free_space = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 361 info.free_space = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (
362 sizeof (union acpi_object));
308 info.object_space = 0; 363 info.object_space = 0;
309 info.num_packages = 1; 364 info.num_packages = 1;
310 365
311 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 366 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object);
312 external_object->package.count = internal_object->package.count; 367 external_object->package.count = internal_object->package.count;
313 external_object->package.elements = ACPI_CAST_PTR (union acpi_object, info.free_space); 368 external_object->package.elements = ACPI_CAST_PTR (union acpi_object,
369 info.free_space);
314 370
315 /* 371 /*
316 * Leave room for an array of ACPI_OBJECTS in the buffer 372 * Leave room for an array of ACPI_OBJECTS in the buffer
@@ -333,8 +389,8 @@ acpi_ut_copy_ipackage_to_epackage (
333 * 389 *
334 * FUNCTION: acpi_ut_copy_iobject_to_eobject 390 * FUNCTION: acpi_ut_copy_iobject_to_eobject
335 * 391 *
336 * PARAMETERS: *internal_object - The internal object to be converted 392 * PARAMETERS: internal_object - The internal object to be converted
337 * *buffer_ptr - Where the object is returned 393 * buffer_ptr - Where the object is returned
338 * 394 *
339 * RETURN: Status 395 * RETURN: Status
340 * 396 *
@@ -367,10 +423,10 @@ acpi_ut_copy_iobject_to_eobject (
367 * Build a simple object (no nested objects) 423 * Build a simple object (no nested objects)
368 */ 424 */
369 status = acpi_ut_copy_isimple_to_esimple (internal_object, 425 status = acpi_ut_copy_isimple_to_esimple (internal_object,
370 (union acpi_object *) ret_buffer->pointer, 426 (union acpi_object *) ret_buffer->pointer,
371 ((u8 *) ret_buffer->pointer + 427 ((u8 *) ret_buffer->pointer +
372 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))), 428 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))),
373 &ret_buffer->length); 429 &ret_buffer->length);
374 /* 430 /*
375 * build simple does not include the object size in the length 431 * build simple does not include the object size in the length
376 * so we add it in here 432 * so we add it in here
@@ -386,8 +442,8 @@ acpi_ut_copy_iobject_to_eobject (
386 * 442 *
387 * FUNCTION: acpi_ut_copy_esimple_to_isimple 443 * FUNCTION: acpi_ut_copy_esimple_to_isimple
388 * 444 *
389 * PARAMETERS: *external_object - The external object to be converted 445 * PARAMETERS: external_object - The external object to be converted
390 * *internal_object - Where the internal object is returned 446 * ret_internal_object - Where the internal object is returned
391 * 447 *
392 * RETURN: Status 448 * RETURN: Status
393 * 449 *
@@ -398,7 +454,7 @@ acpi_ut_copy_iobject_to_eobject (
398 * 454 *
399 ******************************************************************************/ 455 ******************************************************************************/
400 456
401acpi_status 457static acpi_status
402acpi_ut_copy_esimple_to_isimple ( 458acpi_ut_copy_esimple_to_isimple (
403 union acpi_object *external_object, 459 union acpi_object *external_object,
404 union acpi_operand_object **ret_internal_object) 460 union acpi_operand_object **ret_internal_object)
@@ -417,7 +473,8 @@ acpi_ut_copy_esimple_to_isimple (
417 case ACPI_TYPE_BUFFER: 473 case ACPI_TYPE_BUFFER:
418 case ACPI_TYPE_INTEGER: 474 case ACPI_TYPE_INTEGER:
419 475
420 internal_object = acpi_ut_create_internal_object ((u8) external_object->type); 476 internal_object = acpi_ut_create_internal_object (
477 (u8) external_object->type);
421 if (!internal_object) { 478 if (!internal_object) {
422 return_ACPI_STATUS (AE_NO_MEMORY); 479 return_ACPI_STATUS (AE_NO_MEMORY);
423 } 480 }
@@ -486,7 +543,6 @@ error_exit:
486 543
487 544
488#ifdef ACPI_FUTURE_IMPLEMENTATION 545#ifdef ACPI_FUTURE_IMPLEMENTATION
489
490/* Code to convert packages that are parameters to control methods */ 546/* Code to convert packages that are parameters to control methods */
491 547
492/******************************************************************************* 548/*******************************************************************************
@@ -614,7 +670,7 @@ acpi_ut_copy_eobject_to_iobject (
614 * 670 *
615 ******************************************************************************/ 671 ******************************************************************************/
616 672
617acpi_status 673static acpi_status
618acpi_ut_copy_simple_object ( 674acpi_ut_copy_simple_object (
619 union acpi_operand_object *source_desc, 675 union acpi_operand_object *source_desc,
620 union acpi_operand_object *dest_desc) 676 union acpi_operand_object *dest_desc)
@@ -724,7 +780,7 @@ acpi_ut_copy_simple_object (
724 * 780 *
725 ******************************************************************************/ 781 ******************************************************************************/
726 782
727acpi_status 783static acpi_status
728acpi_ut_copy_ielement_to_ielement ( 784acpi_ut_copy_ielement_to_ielement (
729 u8 object_type, 785 u8 object_type,
730 union acpi_operand_object *source_object, 786 union acpi_operand_object *source_object,
@@ -837,7 +893,7 @@ error_exit:
837 * 893 *
838 ******************************************************************************/ 894 ******************************************************************************/
839 895
840acpi_status 896static acpi_status
841acpi_ut_copy_ipackage_to_ipackage ( 897acpi_ut_copy_ipackage_to_ipackage (
842 union acpi_operand_object *source_obj, 898 union acpi_operand_object *source_obj,
843 union acpi_operand_object *dest_obj, 899 union acpi_operand_object *dest_obj,
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index 985c5d045b78..794c7df3f2ad 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -56,7 +56,7 @@ static char *acpi_gbl_fn_entry_str = "----Entry";
56static char *acpi_gbl_fn_exit_str = "----Exit-"; 56static char *acpi_gbl_fn_exit_str = "----Exit-";
57 57
58 58
59/***************************************************************************** 59/*******************************************************************************
60 * 60 *
61 * FUNCTION: acpi_ut_init_stack_ptr_trace 61 * FUNCTION: acpi_ut_init_stack_ptr_trace
62 * 62 *
@@ -64,9 +64,9 @@ static char *acpi_gbl_fn_exit_str = "----Exit-";
64 * 64 *
65 * RETURN: None 65 * RETURN: None
66 * 66 *
67 * DESCRIPTION: Save the current stack pointer 67 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
68 * 68 *
69 ****************************************************************************/ 69 ******************************************************************************/
70 70
71void 71void
72acpi_ut_init_stack_ptr_trace ( 72acpi_ut_init_stack_ptr_trace (
@@ -79,7 +79,7 @@ acpi_ut_init_stack_ptr_trace (
79} 79}
80 80
81 81
82/***************************************************************************** 82/*******************************************************************************
83 * 83 *
84 * FUNCTION: acpi_ut_track_stack_ptr 84 * FUNCTION: acpi_ut_track_stack_ptr
85 * 85 *
@@ -87,9 +87,9 @@ acpi_ut_init_stack_ptr_trace (
87 * 87 *
88 * RETURN: None 88 * RETURN: None
89 * 89 *
90 * DESCRIPTION: Save the current stack pointer 90 * DESCRIPTION: Save the current CPU stack pointer
91 * 91 *
92 ****************************************************************************/ 92 ******************************************************************************/
93 93
94void 94void
95acpi_ut_track_stack_ptr ( 95acpi_ut_track_stack_ptr (
@@ -110,16 +110,16 @@ acpi_ut_track_stack_ptr (
110} 110}
111 111
112 112
113/***************************************************************************** 113/*******************************************************************************
114 * 114 *
115 * FUNCTION: acpi_ut_debug_print 115 * FUNCTION: acpi_ut_debug_print
116 * 116 *
117 * PARAMETERS: debug_level - Requested debug print level 117 * PARAMETERS: requested_debug_level - Requested debug print level
118 * proc_name - Caller's procedure name
119 * module_name - Caller's module name (for error output)
120 * line_number - Caller's line number (for error output) 118 * line_number - Caller's line number (for error output)
121 * component_id - Caller's component ID (for error output) 119 * dbg_info - Contains:
122 * 120 * proc_name - Caller's procedure name
121 * module_name - Caller's module name
122 * component_id - Caller's component ID
123 * Format - Printf format field 123 * Format - Printf format field
124 * ... - Optional printf arguments 124 * ... - Optional printf arguments
125 * 125 *
@@ -128,7 +128,7 @@ acpi_ut_track_stack_ptr (
128 * DESCRIPTION: Print error message with prefix consisting of the module name, 128 * DESCRIPTION: Print error message with prefix consisting of the module name,
129 * line number, and component ID. 129 * line number, and component ID.
130 * 130 *
131 ****************************************************************************/ 131 ******************************************************************************/
132 132
133void ACPI_INTERNAL_VAR_XFACE 133void ACPI_INTERNAL_VAR_XFACE
134acpi_ut_debug_print ( 134acpi_ut_debug_print (
@@ -157,7 +157,8 @@ acpi_ut_debug_print (
157 157
158 if (thread_id != acpi_gbl_prev_thread_id) { 158 if (thread_id != acpi_gbl_prev_thread_id) {
159 if (ACPI_LV_THREADS & acpi_dbg_level) { 159 if (ACPI_LV_THREADS & acpi_dbg_level) {
160 acpi_os_printf ("\n**** Context Switch from TID %X to TID %X ****\n\n", 160 acpi_os_printf (
161 "\n**** Context Switch from TID %X to TID %X ****\n\n",
161 acpi_gbl_prev_thread_id, thread_id); 162 acpi_gbl_prev_thread_id, thread_id);
162 } 163 }
163 164
@@ -174,15 +175,16 @@ acpi_ut_debug_print (
174 acpi_os_printf ("[%04lX] ", thread_id); 175 acpi_os_printf ("[%04lX] ", thread_id);
175 } 176 }
176 177
177 acpi_os_printf ("[%02ld] %-22.22s: ", acpi_gbl_nesting_level, dbg_info->proc_name); 178 acpi_os_printf ("[%02ld] %-22.22s: ",
179 acpi_gbl_nesting_level, dbg_info->proc_name);
178 180
179 va_start (args, format); 181 va_start (args, format);
180 acpi_os_vprintf (format, args); 182 acpi_os_vprintf (format, args);
181} 183}
182EXPORT_SYMBOL(acpi_ut_debug_print);
183 184
185EXPORT_SYMBOL(acpi_ut_debug_print);
184 186
185/***************************************************************************** 187/*******************************************************************************
186 * 188 *
187 * FUNCTION: acpi_ut_debug_print_raw 189 * FUNCTION: acpi_ut_debug_print_raw
188 * 190 *
@@ -200,7 +202,7 @@ EXPORT_SYMBOL(acpi_ut_debug_print);
200 * DESCRIPTION: Print message with no headers. Has same interface as 202 * DESCRIPTION: Print message with no headers. Has same interface as
201 * debug_print so that the same macros can be used. 203 * debug_print so that the same macros can be used.
202 * 204 *
203 ****************************************************************************/ 205 ******************************************************************************/
204 206
205void ACPI_INTERNAL_VAR_XFACE 207void ACPI_INTERNAL_VAR_XFACE
206acpi_ut_debug_print_raw ( 208acpi_ut_debug_print_raw (
@@ -224,7 +226,7 @@ acpi_ut_debug_print_raw (
224EXPORT_SYMBOL(acpi_ut_debug_print_raw); 226EXPORT_SYMBOL(acpi_ut_debug_print_raw);
225 227
226 228
227/***************************************************************************** 229/*******************************************************************************
228 * 230 *
229 * FUNCTION: acpi_ut_trace 231 * FUNCTION: acpi_ut_trace
230 * 232 *
@@ -239,7 +241,7 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw);
239 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 241 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
240 * set in debug_level 242 * set in debug_level
241 * 243 *
242 ****************************************************************************/ 244 ******************************************************************************/
243 245
244void 246void
245acpi_ut_trace ( 247acpi_ut_trace (
@@ -256,7 +258,7 @@ acpi_ut_trace (
256EXPORT_SYMBOL(acpi_ut_trace); 258EXPORT_SYMBOL(acpi_ut_trace);
257 259
258 260
259/***************************************************************************** 261/*******************************************************************************
260 * 262 *
261 * FUNCTION: acpi_ut_trace_ptr 263 * FUNCTION: acpi_ut_trace_ptr
262 * 264 *
@@ -272,7 +274,7 @@ EXPORT_SYMBOL(acpi_ut_trace);
272 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 274 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
273 * set in debug_level 275 * set in debug_level
274 * 276 *
275 ****************************************************************************/ 277 ******************************************************************************/
276 278
277void 279void
278acpi_ut_trace_ptr ( 280acpi_ut_trace_ptr (
@@ -288,7 +290,7 @@ acpi_ut_trace_ptr (
288} 290}
289 291
290 292
291/***************************************************************************** 293/*******************************************************************************
292 * 294 *
293 * FUNCTION: acpi_ut_trace_str 295 * FUNCTION: acpi_ut_trace_str
294 * 296 *
@@ -304,7 +306,7 @@ acpi_ut_trace_ptr (
304 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 306 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
305 * set in debug_level 307 * set in debug_level
306 * 308 *
307 ****************************************************************************/ 309 ******************************************************************************/
308 310
309void 311void
310acpi_ut_trace_str ( 312acpi_ut_trace_str (
@@ -321,7 +323,7 @@ acpi_ut_trace_str (
321} 323}
322 324
323 325
324/***************************************************************************** 326/*******************************************************************************
325 * 327 *
326 * FUNCTION: acpi_ut_trace_u32 328 * FUNCTION: acpi_ut_trace_u32
327 * 329 *
@@ -337,7 +339,7 @@ acpi_ut_trace_str (
337 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 339 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
338 * set in debug_level 340 * set in debug_level
339 * 341 *
340 ****************************************************************************/ 342 ******************************************************************************/
341 343
342void 344void
343acpi_ut_trace_u32 ( 345acpi_ut_trace_u32 (
@@ -354,7 +356,7 @@ acpi_ut_trace_u32 (
354} 356}
355 357
356 358
357/***************************************************************************** 359/*******************************************************************************
358 * 360 *
359 * FUNCTION: acpi_ut_exit 361 * FUNCTION: acpi_ut_exit
360 * 362 *
@@ -369,7 +371,7 @@ acpi_ut_trace_u32 (
369 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 371 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
370 * set in debug_level 372 * set in debug_level
371 * 373 *
372 ****************************************************************************/ 374 ******************************************************************************/
373 375
374void 376void
375acpi_ut_exit ( 377acpi_ut_exit (
@@ -385,7 +387,7 @@ acpi_ut_exit (
385EXPORT_SYMBOL(acpi_ut_exit); 387EXPORT_SYMBOL(acpi_ut_exit);
386 388
387 389
388/***************************************************************************** 390/*******************************************************************************
389 * 391 *
390 * FUNCTION: acpi_ut_status_exit 392 * FUNCTION: acpi_ut_status_exit
391 * 393 *
@@ -401,7 +403,7 @@ EXPORT_SYMBOL(acpi_ut_exit);
401 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 403 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
402 * set in debug_level. Prints exit status also. 404 * set in debug_level. Prints exit status also.
403 * 405 *
404 ****************************************************************************/ 406 ******************************************************************************/
405 407
406void 408void
407acpi_ut_status_exit ( 409acpi_ut_status_exit (
@@ -426,7 +428,7 @@ acpi_ut_status_exit (
426EXPORT_SYMBOL(acpi_ut_status_exit); 428EXPORT_SYMBOL(acpi_ut_status_exit);
427 429
428 430
429/***************************************************************************** 431/*******************************************************************************
430 * 432 *
431 * FUNCTION: acpi_ut_value_exit 433 * FUNCTION: acpi_ut_value_exit
432 * 434 *
@@ -442,7 +444,7 @@ EXPORT_SYMBOL(acpi_ut_status_exit);
442 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 444 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
443 * set in debug_level. Prints exit value also. 445 * set in debug_level. Prints exit value also.
444 * 446 *
445 ****************************************************************************/ 447 ******************************************************************************/
446 448
447void 449void
448acpi_ut_value_exit ( 450acpi_ut_value_exit (
@@ -460,7 +462,7 @@ acpi_ut_value_exit (
460EXPORT_SYMBOL(acpi_ut_value_exit); 462EXPORT_SYMBOL(acpi_ut_value_exit);
461 463
462 464
463/***************************************************************************** 465/*******************************************************************************
464 * 466 *
465 * FUNCTION: acpi_ut_ptr_exit 467 * FUNCTION: acpi_ut_ptr_exit
466 * 468 *
@@ -469,14 +471,14 @@ EXPORT_SYMBOL(acpi_ut_value_exit);
469 * proc_name - Caller's procedure name 471 * proc_name - Caller's procedure name
470 * module_name - Caller's module name 472 * module_name - Caller's module name
471 * component_id - Caller's component ID 473 * component_id - Caller's component ID
472 * Value - Value to be printed with exit msg 474 * Ptr - Pointer to display
473 * 475 *
474 * RETURN: None 476 * RETURN: None
475 * 477 *
476 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 478 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
477 * set in debug_level. Prints exit value also. 479 * set in debug_level. Prints exit value also.
478 * 480 *
479 ****************************************************************************/ 481 ******************************************************************************/
480 482
481void 483void
482acpi_ut_ptr_exit ( 484acpi_ut_ptr_exit (
@@ -494,7 +496,7 @@ acpi_ut_ptr_exit (
494#endif 496#endif
495 497
496 498
497/***************************************************************************** 499/*******************************************************************************
498 * 500 *
499 * FUNCTION: acpi_ut_dump_buffer 501 * FUNCTION: acpi_ut_dump_buffer
500 * 502 *
@@ -507,7 +509,7 @@ acpi_ut_ptr_exit (
507 * 509 *
508 * DESCRIPTION: Generic dump buffer in both hex and ascii. 510 * DESCRIPTION: Generic dump buffer in both hex and ascii.
509 * 511 *
510 ****************************************************************************/ 512 ******************************************************************************/
511 513
512void 514void
513acpi_ut_dump_buffer ( 515acpi_ut_dump_buffer (
@@ -533,34 +535,28 @@ acpi_ut_dump_buffer (
533 display = DB_BYTE_DISPLAY; 535 display = DB_BYTE_DISPLAY;
534 } 536 }
535 537
536 acpi_os_printf ("\nOffset Value\n"); 538 /* Nasty little dump buffer routine! */
537 539
538 /*
539 * Nasty little dump buffer routine!
540 */
541 while (i < count) { 540 while (i < count) {
542 /* Print current offset */ 541 /* Print current offset */
543 542
544 acpi_os_printf ("%05X ", (u32) i); 543 acpi_os_printf ("%6.4X: ", (u32) i);
545 544
546 /* Print 16 hex chars */ 545 /* Print 16 hex chars */
547 546
548 for (j = 0; j < 16;) { 547 for (j = 0; j < 16;) {
549 if (i + j >= count) { 548 if (i + j >= count) {
550 acpi_os_printf ("\n"); 549 /* Dump fill spaces */
551 return;
552 }
553 550
554 /* Make sure that the s8 doesn't get sign-extended! */ 551 acpi_os_printf ("%*s", ((display * 2) + 1), " ");
552 j += display;
553 continue;
554 }
555 555
556 switch (display) { 556 switch (display) {
557 /* Default is BYTE display */ 557 default: /* Default is BYTE display */
558 558
559 default: 559 acpi_os_printf ("%02X ", buffer[i + j]);
560
561 acpi_os_printf ("%02X ",
562 *((u8 *) &buffer[i + j]));
563 j += 1;
564 break; 560 break;
565 561
566 562
@@ -568,7 +564,6 @@ acpi_ut_dump_buffer (
568 564
569 ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]); 565 ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]);
570 acpi_os_printf ("%04X ", temp32); 566 acpi_os_printf ("%04X ", temp32);
571 j += 2;
572 break; 567 break;
573 568
574 569
@@ -576,7 +571,6 @@ acpi_ut_dump_buffer (
576 571
577 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); 572 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]);
578 acpi_os_printf ("%08X ", temp32); 573 acpi_os_printf ("%08X ", temp32);
579 j += 4;
580 break; 574 break;
581 575
582 576
@@ -587,15 +581,17 @@ acpi_ut_dump_buffer (
587 581
588 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]); 582 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]);
589 acpi_os_printf ("%08X ", temp32); 583 acpi_os_printf ("%08X ", temp32);
590 j += 8;
591 break; 584 break;
592 } 585 }
586
587 j += display;
593 } 588 }
594 589
595 /* 590 /*
596 * Print the ASCII equivalent characters 591 * Print the ASCII equivalent characters
597 * But watch out for the bad unprintable ones... 592 * But watch out for the bad unprintable ones...
598 */ 593 */
594 acpi_os_printf (" ");
599 for (j = 0; j < 16; j++) { 595 for (j = 0; j < 16; j++) {
600 if (i + j >= count) { 596 if (i + j >= count) {
601 acpi_os_printf ("\n"); 597 acpi_os_printf ("\n");
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 9a52ad52a23a..bc5403022681 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -51,12 +51,23 @@
51#define _COMPONENT ACPI_UTILITIES 51#define _COMPONENT ACPI_UTILITIES
52 ACPI_MODULE_NAME ("utdelete") 52 ACPI_MODULE_NAME ("utdelete")
53 53
54/* Local prototypes */
55
56static void
57acpi_ut_delete_internal_obj (
58 union acpi_operand_object *object);
59
60static void
61acpi_ut_update_ref_count (
62 union acpi_operand_object *object,
63 u32 action);
64
54 65
55/******************************************************************************* 66/*******************************************************************************
56 * 67 *
57 * FUNCTION: acpi_ut_delete_internal_obj 68 * FUNCTION: acpi_ut_delete_internal_obj
58 * 69 *
59 * PARAMETERS: *Object - Pointer to the list to be deleted 70 * PARAMETERS: Object - Object to be deleted
60 * 71 *
61 * RETURN: None 72 * RETURN: None
62 * 73 *
@@ -65,7 +76,7 @@
65 * 76 *
66 ******************************************************************************/ 77 ******************************************************************************/
67 78
68void 79static void
69acpi_ut_delete_internal_obj ( 80acpi_ut_delete_internal_obj (
70 union acpi_operand_object *object) 81 union acpi_operand_object *object)
71{ 82{
@@ -152,7 +163,8 @@ acpi_ut_delete_internal_obj (
152 163
153 case ACPI_TYPE_MUTEX: 164 case ACPI_TYPE_MUTEX:
154 165
155 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Mutex %p, Semaphore %p\n", 166 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
167 "***** Mutex %p, Semaphore %p\n",
156 object, object->mutex.semaphore)); 168 object, object->mutex.semaphore));
157 169
158 acpi_ex_unlink_mutex (object); 170 acpi_ex_unlink_mutex (object);
@@ -162,7 +174,8 @@ acpi_ut_delete_internal_obj (
162 174
163 case ACPI_TYPE_EVENT: 175 case ACPI_TYPE_EVENT:
164 176
165 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Event %p, Semaphore %p\n", 177 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
178 "***** Event %p, Semaphore %p\n",
166 object, object->event.semaphore)); 179 object, object->event.semaphore));
167 180
168 (void) acpi_os_delete_semaphore (object->event.semaphore); 181 (void) acpi_os_delete_semaphore (object->event.semaphore);
@@ -172,7 +185,8 @@ acpi_ut_delete_internal_obj (
172 185
173 case ACPI_TYPE_METHOD: 186 case ACPI_TYPE_METHOD:
174 187
175 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Method %p\n", object)); 188 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
189 "***** Method %p\n", object));
176 190
177 /* Delete the method semaphore if it exists */ 191 /* Delete the method semaphore if it exists */
178 192
@@ -185,7 +199,8 @@ acpi_ut_delete_internal_obj (
185 199
186 case ACPI_TYPE_REGION: 200 case ACPI_TYPE_REGION:
187 201
188 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Region %p\n", object)); 202 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
203 "***** Region %p\n", object));
189 204
190 second_desc = acpi_ns_get_secondary_object (object); 205 second_desc = acpi_ns_get_secondary_object (object);
191 if (second_desc) { 206 if (second_desc) {
@@ -212,7 +227,8 @@ acpi_ut_delete_internal_obj (
212 227
213 case ACPI_TYPE_BUFFER_FIELD: 228 case ACPI_TYPE_BUFFER_FIELD:
214 229
215 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Buffer Field %p\n", object)); 230 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
231 "***** Buffer Field %p\n", object));
216 232
217 second_desc = acpi_ns_get_secondary_object (object); 233 second_desc = acpi_ns_get_secondary_object (object);
218 if (second_desc) { 234 if (second_desc) {
@@ -247,7 +263,7 @@ acpi_ut_delete_internal_obj (
247 * 263 *
248 * FUNCTION: acpi_ut_delete_internal_object_list 264 * FUNCTION: acpi_ut_delete_internal_object_list
249 * 265 *
250 * PARAMETERS: *obj_list - Pointer to the list to be deleted 266 * PARAMETERS: obj_list - Pointer to the list to be deleted
251 * 267 *
252 * RETURN: None 268 * RETURN: None
253 * 269 *
@@ -283,7 +299,7 @@ acpi_ut_delete_internal_object_list (
283 * 299 *
284 * FUNCTION: acpi_ut_update_ref_count 300 * FUNCTION: acpi_ut_update_ref_count
285 * 301 *
286 * PARAMETERS: *Object - Object whose ref count is to be updated 302 * PARAMETERS: Object - Object whose ref count is to be updated
287 * Action - What to do 303 * Action - What to do
288 * 304 *
289 * RETURN: New ref count 305 * RETURN: New ref count
@@ -312,7 +328,8 @@ acpi_ut_update_ref_count (
312 new_count = count; 328 new_count = count;
313 329
314 /* 330 /*
315 * Perform the reference count action (increment, decrement, or force delete) 331 * Perform the reference count action
332 * (increment, decrement, or force delete)
316 */ 333 */
317 switch (action) { 334 switch (action) {
318 335
@@ -321,7 +338,8 @@ acpi_ut_update_ref_count (
321 new_count++; 338 new_count++;
322 object->common.reference_count = new_count; 339 object->common.reference_count = new_count;
323 340
324 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Incremented]\n", 341 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
342 "Obj %p Refs=%X, [Incremented]\n",
325 object, new_count)); 343 object, new_count));
326 break; 344 break;
327 345
@@ -329,7 +347,8 @@ acpi_ut_update_ref_count (
329 case REF_DECREMENT: 347 case REF_DECREMENT:
330 348
331 if (count < 1) { 349 if (count < 1) {
332 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, can't decrement! (Set to 0)\n", 350 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
351 "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
333 object, new_count)); 352 object, new_count));
334 353
335 new_count = 0; 354 new_count = 0;
@@ -337,12 +356,14 @@ acpi_ut_update_ref_count (
337 else { 356 else {
338 new_count--; 357 new_count--;
339 358
340 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Decremented]\n", 359 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
360 "Obj %p Refs=%X, [Decremented]\n",
341 object, new_count)); 361 object, new_count));
342 } 362 }
343 363
344 if (ACPI_GET_OBJECT_TYPE (object) == ACPI_TYPE_METHOD) { 364 if (ACPI_GET_OBJECT_TYPE (object) == ACPI_TYPE_METHOD) {
345 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Method Obj %p Refs=%X, [Decremented]\n", 365 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
366 "Method Obj %p Refs=%X, [Decremented]\n",
346 object, new_count)); 367 object, new_count));
347 } 368 }
348 369
@@ -356,7 +377,8 @@ acpi_ut_update_ref_count (
356 377
357 case REF_FORCE_DELETE: 378 case REF_FORCE_DELETE:
358 379
359 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, Force delete! (Set to 0)\n", 380 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
381 "Obj %p Refs=%X, Force delete! (Set to 0)\n",
360 object, count)); 382 object, count));
361 383
362 new_count = 0; 384 new_count = 0;
@@ -390,7 +412,7 @@ acpi_ut_update_ref_count (
390 * 412 *
391 * FUNCTION: acpi_ut_update_object_reference 413 * FUNCTION: acpi_ut_update_object_reference
392 * 414 *
393 * PARAMETERS: *Object - Increment ref count for this object 415 * PARAMETERS: Object - Increment ref count for this object
394 * and all sub-objects 416 * and all sub-objects
395 * Action - Either REF_INCREMENT or REF_DECREMENT or 417 * Action - Either REF_INCREMENT or REF_DECREMENT or
396 * REF_FORCE_DELETE 418 * REF_FORCE_DELETE
@@ -431,7 +453,8 @@ acpi_ut_update_object_reference (
431 /* Make sure that this isn't a namespace handle */ 453 /* Make sure that this isn't a namespace handle */
432 454
433 if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { 455 if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) {
434 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p is NS handle\n", object)); 456 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
457 "Object %p is NS handle\n", object));
435 return_ACPI_STATUS (AE_OK); 458 return_ACPI_STATUS (AE_OK);
436 } 459 }
437 460
@@ -614,8 +637,8 @@ error_exit:
614 * 637 *
615 * FUNCTION: acpi_ut_add_reference 638 * FUNCTION: acpi_ut_add_reference
616 * 639 *
617 * PARAMETERS: *Object - Object whose reference count is to be 640 * PARAMETERS: Object - Object whose reference count is to be
618 * incremented 641 * incremented
619 * 642 *
620 * RETURN: None 643 * RETURN: None
621 * 644 *
@@ -652,7 +675,7 @@ acpi_ut_add_reference (
652 * 675 *
653 * FUNCTION: acpi_ut_remove_reference 676 * FUNCTION: acpi_ut_remove_reference
654 * 677 *
655 * PARAMETERS: *Object - Object whose ref count will be decremented 678 * PARAMETERS: Object - Object whose ref count will be decremented
656 * 679 *
657 * RETURN: None 680 * RETURN: None
658 * 681 *
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index ead27d2c4d18..00046dd5d925 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -50,6 +50,19 @@
50#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("uteval") 51 ACPI_MODULE_NAME ("uteval")
52 52
53/* Local prototypes */
54
55static void
56acpi_ut_copy_id_string (
57 char *destination,
58 char *source,
59 acpi_size max_length);
60
61static acpi_status
62acpi_ut_translate_one_cid (
63 union acpi_operand_object *obj_desc,
64 struct acpi_compatible_id *one_cid);
65
53 66
54/******************************************************************************* 67/*******************************************************************************
55 * 68 *
@@ -237,9 +250,9 @@ acpi_ut_evaluate_object (
237 * 250 *
238 * FUNCTION: acpi_ut_evaluate_numeric_object 251 * FUNCTION: acpi_ut_evaluate_numeric_object
239 * 252 *
240 * PARAMETERS: *object_name - Object name to be evaluated 253 * PARAMETERS: object_name - Object name to be evaluated
241 * device_node - Node for the device 254 * device_node - Node for the device
242 * *Address - Where the value is returned 255 * Address - Where the value is returned
243 * 256 *
244 * RETURN: Status 257 * RETURN: Status
245 * 258 *
@@ -303,7 +316,6 @@ acpi_ut_copy_id_string (
303 acpi_size max_length) 316 acpi_size max_length)
304{ 317{
305 318
306
307 /* 319 /*
308 * Workaround for ID strings that have a leading asterisk. This construct 320 * Workaround for ID strings that have a leading asterisk. This construct
309 * is not allowed by the ACPI specification (ID strings must be 321 * is not allowed by the ACPI specification (ID strings must be
@@ -325,7 +337,7 @@ acpi_ut_copy_id_string (
325 * FUNCTION: acpi_ut_execute_HID 337 * FUNCTION: acpi_ut_execute_HID
326 * 338 *
327 * PARAMETERS: device_node - Node for the device 339 * PARAMETERS: device_node - Node for the device
328 * *Hid - Where the HID is returned 340 * Hid - Where the HID is returned
329 * 341 *
330 * RETURN: Status 342 * RETURN: Status
331 * 343 *
@@ -429,7 +441,7 @@ acpi_ut_translate_one_cid (
429 * FUNCTION: acpi_ut_execute_CID 441 * FUNCTION: acpi_ut_execute_CID
430 * 442 *
431 * PARAMETERS: device_node - Node for the device 443 * PARAMETERS: device_node - Node for the device
432 * *Cid - Where the CID is returned 444 * return_cid_list - Where the CID list is returned
433 * 445 *
434 * RETURN: Status 446 * RETURN: Status
435 * 447 *
@@ -488,10 +500,10 @@ acpi_ut_execute_CID (
488 cid_list->size = size; 500 cid_list->size = size;
489 501
490 /* 502 /*
491 * A _CID can return either a single compatible ID or a package of compatible 503 * A _CID can return either a single compatible ID or a package of
492 * IDs. Each compatible ID can be one of the following: 504 * compatible IDs. Each compatible ID can be one of the following:
493 * -- Number (32 bit compressed EISA ID) or 505 * 1) Integer (32 bit compressed EISA ID) or
494 * -- String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss"). 506 * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
495 */ 507 */
496 508
497 /* The _CID object can be either a single CID or a package (list) of CIDs */ 509 /* The _CID object can be either a single CID or a package (list) of CIDs */
@@ -534,7 +546,7 @@ acpi_ut_execute_CID (
534 * FUNCTION: acpi_ut_execute_UID 546 * FUNCTION: acpi_ut_execute_UID
535 * 547 *
536 * PARAMETERS: device_node - Node for the device 548 * PARAMETERS: device_node - Node for the device
537 * *Uid - Where the UID is returned 549 * Uid - Where the UID is returned
538 * 550 *
539 * RETURN: Status 551 * RETURN: Status
540 * 552 *
@@ -587,7 +599,7 @@ acpi_ut_execute_UID (
587 * FUNCTION: acpi_ut_execute_STA 599 * FUNCTION: acpi_ut_execute_STA
588 * 600 *
589 * PARAMETERS: device_node - Node for the device 601 * PARAMETERS: device_node - Node for the device
590 * *Flags - Where the status flags are returned 602 * Flags - Where the status flags are returned
591 * 603 *
592 * RETURN: Status 604 * RETURN: Status
593 * 605 *
@@ -641,7 +653,7 @@ acpi_ut_execute_STA (
641 * FUNCTION: acpi_ut_execute_Sxds 653 * FUNCTION: acpi_ut_execute_Sxds
642 * 654 *
643 * PARAMETERS: device_node - Node for the device 655 * PARAMETERS: device_node - Node for the device
644 * *Flags - Where the status flags are returned 656 * Flags - Where the status flags are returned
645 * 657 *
646 * RETURN: Status 658 * RETURN: Status
647 * 659 *
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 25b0f8ae1bc6..4146019b543f 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -44,7 +44,6 @@
44#define DEFINE_ACPI_GLOBALS 44#define DEFINE_ACPI_GLOBALS
45 45
46#include <linux/module.h> 46#include <linux/module.h>
47
48#include <acpi/acpi.h> 47#include <acpi/acpi.h>
49#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
50 49
@@ -52,13 +51,14 @@
52 ACPI_MODULE_NAME ("utglobal") 51 ACPI_MODULE_NAME ("utglobal")
53 52
54 53
55/****************************************************************************** 54/*******************************************************************************
56 * 55 *
57 * FUNCTION: acpi_format_exception 56 * FUNCTION: acpi_format_exception
58 * 57 *
59 * PARAMETERS: Status - The acpi_status code to be formatted 58 * PARAMETERS: Status - The acpi_status code to be formatted
60 * 59 *
61 * RETURN: A string containing the exception text 60 * RETURN: A string containing the exception text. A valid pointer is
61 * always returned.
62 * 62 *
63 * DESCRIPTION: This function translates an ACPI exception into an ASCII string. 63 * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
64 * 64 *
@@ -68,8 +68,8 @@ const char *
68acpi_format_exception ( 68acpi_format_exception (
69 acpi_status status) 69 acpi_status status)
70{ 70{
71 const char *exception = "UNKNOWN_STATUS_CODE";
72 acpi_status sub_status; 71 acpi_status sub_status;
72 const char *exception = NULL;
73 73
74 74
75 ACPI_FUNCTION_NAME ("format_exception"); 75 ACPI_FUNCTION_NAME ("format_exception");
@@ -82,57 +82,55 @@ acpi_format_exception (
82 82
83 if (sub_status <= AE_CODE_ENV_MAX) { 83 if (sub_status <= AE_CODE_ENV_MAX) {
84 exception = acpi_gbl_exception_names_env [sub_status]; 84 exception = acpi_gbl_exception_names_env [sub_status];
85 break;
86 } 85 }
87 goto unknown; 86 break;
88 87
89 case AE_CODE_PROGRAMMER: 88 case AE_CODE_PROGRAMMER:
90 89
91 if (sub_status <= AE_CODE_PGM_MAX) { 90 if (sub_status <= AE_CODE_PGM_MAX) {
92 exception = acpi_gbl_exception_names_pgm [sub_status -1]; 91 exception = acpi_gbl_exception_names_pgm [sub_status -1];
93 break;
94 } 92 }
95 goto unknown; 93 break;
96 94
97 case AE_CODE_ACPI_TABLES: 95 case AE_CODE_ACPI_TABLES:
98 96
99 if (sub_status <= AE_CODE_TBL_MAX) { 97 if (sub_status <= AE_CODE_TBL_MAX) {
100 exception = acpi_gbl_exception_names_tbl [sub_status -1]; 98 exception = acpi_gbl_exception_names_tbl [sub_status -1];
101 break;
102 } 99 }
103 goto unknown; 100 break;
104 101
105 case AE_CODE_AML: 102 case AE_CODE_AML:
106 103
107 if (sub_status <= AE_CODE_AML_MAX) { 104 if (sub_status <= AE_CODE_AML_MAX) {
108 exception = acpi_gbl_exception_names_aml [sub_status -1]; 105 exception = acpi_gbl_exception_names_aml [sub_status -1];
109 break;
110 } 106 }
111 goto unknown; 107 break;
112 108
113 case AE_CODE_CONTROL: 109 case AE_CODE_CONTROL:
114 110
115 if (sub_status <= AE_CODE_CTRL_MAX) { 111 if (sub_status <= AE_CODE_CTRL_MAX) {
116 exception = acpi_gbl_exception_names_ctrl [sub_status -1]; 112 exception = acpi_gbl_exception_names_ctrl [sub_status -1];
117 break;
118 } 113 }
119 goto unknown; 114 break;
120 115
121 default: 116 default:
122 goto unknown; 117 break;
123 } 118 }
124 119
120 if (!exception) {
121 /* Exception code was not recognized */
125 122
126 return ((const char *) exception); 123 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
124 "Unknown exception code: 0x%8.8X\n", status));
127 125
128unknown: 126 return ((const char *) "UNKNOWN_STATUS_CODE");
127 }
129 128
130 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", status));
131 return ((const char *) exception); 129 return ((const char *) exception);
132} 130}
133 131
134 132
135/****************************************************************************** 133/*******************************************************************************
136 * 134 *
137 * Static global variable initialization. 135 * Static global variable initialization.
138 * 136 *
@@ -212,13 +210,12 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR
212}; 210};
213 211
214 212
215/****************************************************************************** 213/*******************************************************************************
216 * 214 *
217 * Namespace globals 215 * Namespace globals
218 * 216 *
219 ******************************************************************************/ 217 ******************************************************************************/
220 218
221
222/* 219/*
223 * Predefined ACPI Names (Built-in to the Interpreter) 220 * Predefined ACPI Names (Built-in to the Interpreter)
224 * 221 *
@@ -241,9 +238,11 @@ const struct acpi_predefined_names acpi_gbl_pre_defined_names[] =
241#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 238#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
242 {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, 239 {"_OSI", ACPI_TYPE_METHOD, (char *) 1},
243#endif 240#endif
244 {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */
245};
246 241
242 /* Table terminator */
243
244 {NULL, ACPI_TYPE_ANY, NULL}
245};
247 246
248/* 247/*
249 * Properties of the ACPI Object Types, both internal and external. 248 * Properties of the ACPI Object Types, both internal and external.
@@ -288,22 +287,25 @@ const u8 acpi_gbl_ns_properties[] =
288/* Hex to ASCII conversion table */ 287/* Hex to ASCII conversion table */
289 288
290static const char acpi_gbl_hex_to_ascii[] = 289static const char acpi_gbl_hex_to_ascii[] =
291 {'0','1','2','3','4','5','6','7', 290{
292 '8','9','A','B','C','D','E','F'}; 291 '0','1','2','3','4','5','6','7',
292 '8','9','A','B','C','D','E','F'
293};
294
293 295
294/***************************************************************************** 296/*******************************************************************************
295 * 297 *
296 * FUNCTION: acpi_ut_hex_to_ascii_char 298 * FUNCTION: acpi_ut_hex_to_ascii_char
297 * 299 *
298 * PARAMETERS: Integer - Contains the hex digit 300 * PARAMETERS: Integer - Contains the hex digit
299 * Position - bit position of the digit within the 301 * Position - bit position of the digit within the
300 * integer 302 * integer (multiple of 4)
301 * 303 *
302 * RETURN: Ascii character 304 * RETURN: The converted Ascii character
303 * 305 *
304 * DESCRIPTION: Convert a hex digit to an ascii character 306 * DESCRIPTION: Convert a hex digit to an Ascii character
305 * 307 *
306 ****************************************************************************/ 308 ******************************************************************************/
307 309
308char 310char
309acpi_ut_hex_to_ascii_char ( 311acpi_ut_hex_to_ascii_char (
@@ -315,7 +317,7 @@ acpi_ut_hex_to_ascii_char (
315} 317}
316 318
317 319
318/****************************************************************************** 320/*******************************************************************************
319 * 321 *
320 * Table name globals 322 * Table name globals
321 * 323 *
@@ -324,7 +326,7 @@ acpi_ut_hex_to_ascii_char (
324 * that are not used by the subsystem are simply ignored. 326 * that are not used by the subsystem are simply ignored.
325 * 327 *
326 * Do NOT add any table to this list that is not consumed directly by this 328 * Do NOT add any table to this list that is not consumed directly by this
327 * subsystem. 329 * subsystem (No MADT, ECDT, SBST, etc.)
328 * 330 *
329 ******************************************************************************/ 331 ******************************************************************************/
330 332
@@ -391,7 +393,7 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVE
391 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, 393 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE},
392}; 394};
393 395
394/***************************************************************************** 396/*******************************************************************************
395 * 397 *
396 * FUNCTION: acpi_ut_get_region_name 398 * FUNCTION: acpi_ut_get_region_name
397 * 399 *
@@ -401,7 +403,7 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVE
401 * 403 *
402 * DESCRIPTION: Translate a Space ID into a name string (Debug only) 404 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
403 * 405 *
404 ****************************************************************************/ 406 ******************************************************************************/
405 407
406/* Region type decoding */ 408/* Region type decoding */
407 409
@@ -429,7 +431,6 @@ acpi_ut_get_region_name (
429 { 431 {
430 return ("user_defined_region"); 432 return ("user_defined_region");
431 } 433 }
432
433 else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) 434 else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS)
434 { 435 {
435 return ("invalid_space_id"); 436 return ("invalid_space_id");
@@ -439,7 +440,7 @@ acpi_ut_get_region_name (
439} 440}
440 441
441 442
442/***************************************************************************** 443/*******************************************************************************
443 * 444 *
444 * FUNCTION: acpi_ut_get_event_name 445 * FUNCTION: acpi_ut_get_event_name
445 * 446 *
@@ -449,7 +450,7 @@ acpi_ut_get_region_name (
449 * 450 *
450 * DESCRIPTION: Translate a Event ID into a name string (Debug only) 451 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
451 * 452 *
452 ****************************************************************************/ 453 ******************************************************************************/
453 454
454/* Event type decoding */ 455/* Event type decoding */
455 456
@@ -477,7 +478,7 @@ acpi_ut_get_event_name (
477} 478}
478 479
479 480
480/***************************************************************************** 481/*******************************************************************************
481 * 482 *
482 * FUNCTION: acpi_ut_get_type_name 483 * FUNCTION: acpi_ut_get_type_name
483 * 484 *
@@ -487,20 +488,21 @@ acpi_ut_get_event_name (
487 * 488 *
488 * DESCRIPTION: Translate a Type ID into a name string (Debug only) 489 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
489 * 490 *
490 ****************************************************************************/ 491 ******************************************************************************/
491 492
492/* 493/*
493 * Elements of acpi_gbl_ns_type_names below must match 494 * Elements of acpi_gbl_ns_type_names below must match
494 * one-to-one with values of acpi_object_type 495 * one-to-one with values of acpi_object_type
495 * 496 *
496 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when 497 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
497 * stored in a table it really means that we have thus far seen no evidence to 498 * when stored in a table it really means that we have thus far seen no
498 * indicate what type is actually going to be stored for this entry. 499 * evidence to indicate what type is actually going to be stored for this entry.
499 */ 500 */
500static const char acpi_gbl_bad_type[] = "UNDEFINED"; 501static const char acpi_gbl_bad_type[] = "UNDEFINED";
501#define TYPE_NAME_LENGTH 12 /* Maximum length of each string */
502 502
503static const char *acpi_gbl_ns_type_names[] = /* printable names of ACPI types */ 503/* Printable names of the ACPI object types */
504
505static const char *acpi_gbl_ns_type_names[] =
504{ 506{
505 /* 00 */ "Untyped", 507 /* 00 */ "Untyped",
506 /* 01 */ "Integer", 508 /* 01 */ "Integer",
@@ -564,7 +566,7 @@ acpi_ut_get_object_type_name (
564} 566}
565 567
566 568
567/***************************************************************************** 569/*******************************************************************************
568 * 570 *
569 * FUNCTION: acpi_ut_get_node_name 571 * FUNCTION: acpi_ut_get_node_name
570 * 572 *
@@ -574,7 +576,7 @@ acpi_ut_get_object_type_name (
574 * 576 *
575 * DESCRIPTION: Validate the node and return the node's ACPI name. 577 * DESCRIPTION: Validate the node and return the node's ACPI name.
576 * 578 *
577 ****************************************************************************/ 579 ******************************************************************************/
578 580
579char * 581char *
580acpi_ut_get_node_name ( 582acpi_ut_get_node_name (
@@ -618,7 +620,7 @@ acpi_ut_get_node_name (
618} 620}
619 621
620 622
621/***************************************************************************** 623/*******************************************************************************
622 * 624 *
623 * FUNCTION: acpi_ut_get_descriptor_name 625 * FUNCTION: acpi_ut_get_descriptor_name
624 * 626 *
@@ -628,9 +630,11 @@ acpi_ut_get_node_name (
628 * 630 *
629 * DESCRIPTION: Validate object and return the descriptor type 631 * DESCRIPTION: Validate object and return the descriptor type
630 * 632 *
631 ****************************************************************************/ 633 ******************************************************************************/
634
635/* Printable names of object descriptor types */
632 636
633static const char *acpi_gbl_desc_type_names[] = /* printable names of descriptor types */ 637static const char *acpi_gbl_desc_type_names[] =
634{ 638{
635 /* 00 */ "Invalid", 639 /* 00 */ "Invalid",
636 /* 01 */ "Cached", 640 /* 01 */ "Cached",
@@ -676,17 +680,18 @@ acpi_ut_get_descriptor_name (
676 * Strings and procedures used for debug only 680 * Strings and procedures used for debug only
677 */ 681 */
678 682
679/***************************************************************************** 683/*******************************************************************************
680 * 684 *
681 * FUNCTION: acpi_ut_get_mutex_name 685 * FUNCTION: acpi_ut_get_mutex_name
682 * 686 *
683 * PARAMETERS: None. 687 * PARAMETERS: mutex_id - The predefined ID for this mutex.
684 * 688 *
685 * RETURN: Status 689 * RETURN: String containing the name of the mutex. Always returns a valid
690 * pointer.
686 * 691 *
687 * DESCRIPTION: Translate a mutex ID into a name string (Debug only) 692 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
688 * 693 *
689 ****************************************************************************/ 694 ******************************************************************************/
690 695
691char * 696char *
692acpi_ut_get_mutex_name ( 697acpi_ut_get_mutex_name (
@@ -700,21 +705,20 @@ acpi_ut_get_mutex_name (
700 705
701 return (acpi_gbl_mutex_names[mutex_id]); 706 return (acpi_gbl_mutex_names[mutex_id]);
702} 707}
703
704#endif 708#endif
705 709
706 710
707/***************************************************************************** 711/*******************************************************************************
708 * 712 *
709 * FUNCTION: acpi_ut_valid_object_type 713 * FUNCTION: acpi_ut_valid_object_type
710 * 714 *
711 * PARAMETERS: Type - Object type to be validated 715 * PARAMETERS: Type - Object type to be validated
712 * 716 *
713 * RETURN: TRUE if valid object type 717 * RETURN: TRUE if valid object type, FALSE otherwise
714 * 718 *
715 * DESCRIPTION: Validate an object type 719 * DESCRIPTION: Validate an object type
716 * 720 *
717 ****************************************************************************/ 721 ******************************************************************************/
718 722
719u8 723u8
720acpi_ut_valid_object_type ( 724acpi_ut_valid_object_type (
@@ -732,7 +736,7 @@ acpi_ut_valid_object_type (
732} 736}
733 737
734 738
735/**************************************************************************** 739/*******************************************************************************
736 * 740 *
737 * FUNCTION: acpi_ut_allocate_owner_id 741 * FUNCTION: acpi_ut_allocate_owner_id
738 * 742 *
@@ -740,7 +744,10 @@ acpi_ut_valid_object_type (
740 * 744 *
741 * DESCRIPTION: Allocate a table or method owner id 745 * DESCRIPTION: Allocate a table or method owner id
742 * 746 *
743 ***************************************************************************/ 747 * NOTE: this algorithm has a wraparound problem at 64_k method invocations, and
748 * should be revisited (TBD)
749 *
750 ******************************************************************************/
744 751
745acpi_owner_id 752acpi_owner_id
746acpi_ut_allocate_owner_id ( 753acpi_ut_allocate_owner_id (
@@ -796,16 +803,18 @@ acpi_ut_allocate_owner_id (
796} 803}
797 804
798 805
799/**************************************************************************** 806/*******************************************************************************
800 * 807 *
801 * FUNCTION: acpi_ut_init_globals 808 * FUNCTION: acpi_ut_init_globals
802 * 809 *
803 * PARAMETERS: none 810 * PARAMETERS: None
811 *
812 * RETURN: None
804 * 813 *
805 * DESCRIPTION: Init library globals. All globals that require specific 814 * DESCRIPTION: Init library globals. All globals that require specific
806 * initialization should be initialized here! 815 * initialization should be initialized here!
807 * 816 *
808 ***************************************************************************/ 817 ******************************************************************************/
809 818
810void 819void
811acpi_ut_init_globals ( 820acpi_ut_init_globals (
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c
index bdbadaf48d29..7f3713889ff0 100644
--- a/drivers/acpi/utilities/utinit.c
+++ b/drivers/acpi/utilities/utinit.c
@@ -49,19 +49,29 @@
49#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utinit") 50 ACPI_MODULE_NAME ("utinit")
51 51
52/* Local prototypes */
53
54static void
55acpi_ut_fadt_register_error (
56 char *register_name,
57 u32 value,
58 acpi_size offset);
59
60static void acpi_ut_terminate (
61 void);
62
52 63
53/******************************************************************************* 64/*******************************************************************************
54 * 65 *
55 * FUNCTION: acpi_ut_fadt_register_error 66 * FUNCTION: acpi_ut_fadt_register_error
56 * 67 *
57 * PARAMETERS: *register_name - Pointer to string identifying register 68 * PARAMETERS: register_name - Pointer to string identifying register
58 * Value - Actual register contents value 69 * Value - Actual register contents value
59 * acpi_test_spec_section - TDS section containing assertion 70 * Offset - Byte offset in the FADT
60 * acpi_assertion - Assertion number being tested
61 * 71 *
62 * RETURN: AE_BAD_VALUE 72 * RETURN: AE_BAD_VALUE
63 * 73 *
64 * DESCRIPTION: Display failure message and link failure to TDS assertion 74 * DESCRIPTION: Display failure message
65 * 75 *
66 ******************************************************************************/ 76 ******************************************************************************/
67 77
@@ -166,12 +176,13 @@ acpi_ut_validate_fadt (
166 * 176 *
167 * RETURN: none 177 * RETURN: none
168 * 178 *
169 * DESCRIPTION: free global memory 179 * DESCRIPTION: Free global memory
170 * 180 *
171 ******************************************************************************/ 181 ******************************************************************************/
172 182
173void 183static void
174acpi_ut_terminate (void) 184acpi_ut_terminate (
185 void)
175{ 186{
176 struct acpi_gpe_block_info *gpe_block; 187 struct acpi_gpe_block_info *gpe_block;
177 struct acpi_gpe_block_info *next_gpe_block; 188 struct acpi_gpe_block_info *next_gpe_block;
@@ -183,8 +194,6 @@ acpi_ut_terminate (void)
183 194
184 195
185 /* Free global tables, etc. */ 196 /* Free global tables, etc. */
186
187
188 /* Free global GPE blocks and related info structures */ 197 /* Free global GPE blocks and related info structures */
189 198
190 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; 199 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
@@ -221,7 +230,8 @@ acpi_ut_terminate (void)
221 ******************************************************************************/ 230 ******************************************************************************/
222 231
223void 232void
224acpi_ut_subsystem_shutdown (void) 233acpi_ut_subsystem_shutdown (
234 void)
225{ 235{
226 236
227 ACPI_FUNCTION_TRACE ("ut_subsystem_shutdown"); 237 ACPI_FUNCTION_TRACE ("ut_subsystem_shutdown");
@@ -229,14 +239,16 @@ acpi_ut_subsystem_shutdown (void)
229 /* Just exit if subsystem is already shutdown */ 239 /* Just exit if subsystem is already shutdown */
230 240
231 if (acpi_gbl_shutdown) { 241 if (acpi_gbl_shutdown) {
232 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "ACPI Subsystem is already terminated\n")); 242 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
243 "ACPI Subsystem is already terminated\n"));
233 return_VOID; 244 return_VOID;
234 } 245 }
235 246
236 /* Subsystem appears active, go ahead and shut it down */ 247 /* Subsystem appears active, go ahead and shut it down */
237 248
238 acpi_gbl_shutdown = TRUE; 249 acpi_gbl_shutdown = TRUE;
239 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n")); 250 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
251 "Shutting down ACPI Subsystem...\n"));
240 252
241 /* Close the acpi_event Handling */ 253 /* Close the acpi_event Handling */
242 254
diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c
index 2525c1a93547..0d527c91543c 100644
--- a/drivers/acpi/utilities/utmath.c
+++ b/drivers/acpi/utilities/utmath.c
@@ -259,6 +259,8 @@ acpi_ut_divide (
259 * 259 *
260 * FUNCTION: acpi_ut_short_divide, acpi_ut_divide 260 * FUNCTION: acpi_ut_short_divide, acpi_ut_divide
261 * 261 *
262 * PARAMETERS: See function headers above
263 *
262 * DESCRIPTION: Native versions of the ut_divide functions. Use these if either 264 * DESCRIPTION: Native versions of the ut_divide functions. Use these if either
263 * 1) The target is a 64-bit platform and therefore 64-bit 265 * 1) The target is a 64-bit platform and therefore 64-bit
264 * integer math is supported directly by the machine. 266 * integer math is supported directly by the machine.
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index f6598547389b..f6de4ed3d527 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -49,12 +49,57 @@
49#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utmisc") 50 ACPI_MODULE_NAME ("utmisc")
51 51
52/* Local prototypes */
53
54static acpi_status
55acpi_ut_create_mutex (
56 acpi_mutex_handle mutex_id);
57
58static acpi_status
59acpi_ut_delete_mutex (
60 acpi_mutex_handle mutex_id);
61
62
63/*******************************************************************************
64 *
65 * FUNCTION: acpi_ut_strupr (strupr)
66 *
67 * PARAMETERS: src_string - The source string to convert
68 *
69 * RETURN: Converted src_string (same as input pointer)
70 *
71 * DESCRIPTION: Convert string to uppercase
72 *
73 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
74 *
75 ******************************************************************************/
76
77char *
78acpi_ut_strupr (
79 char *src_string)
80{
81 char *string;
82
83
84 ACPI_FUNCTION_ENTRY ();
85
86
87 /* Walk entire string, uppercasing the letters */
88
89 for (string = src_string; *string; string++) {
90 *string = (char) ACPI_TOUPPER (*string);
91 }
92
93 return (src_string);
94}
95
52 96
53/******************************************************************************* 97/*******************************************************************************
54 * 98 *
55 * FUNCTION: acpi_ut_print_string 99 * FUNCTION: acpi_ut_print_string
56 * 100 *
57 * PARAMETERS: String - Null terminated ASCII string 101 * PARAMETERS: String - Null terminated ASCII string
102 * max_length - Maximum output length
58 * 103 *
59 * RETURN: None 104 * RETURN: None
60 * 105 *
@@ -148,6 +193,8 @@ acpi_ut_print_string (
148 * 193 *
149 * PARAMETERS: Value - Value to be converted 194 * PARAMETERS: Value - Value to be converted
150 * 195 *
196 * RETURN: u32 integer with bytes swapped
197 *
151 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) 198 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
152 * 199 *
153 ******************************************************************************/ 200 ******************************************************************************/
@@ -160,7 +207,6 @@ acpi_ut_dword_byte_swap (
160 u32 value; 207 u32 value;
161 u8 bytes[4]; 208 u8 bytes[4];
162 } out; 209 } out;
163
164 union { 210 union {
165 u32 value; 211 u32 value;
166 u8 bytes[4]; 212 u8 bytes[4];
@@ -219,7 +265,8 @@ acpi_ut_set_integer_width (
219 * 265 *
220 * FUNCTION: acpi_ut_display_init_pathname 266 * FUNCTION: acpi_ut_display_init_pathname
221 * 267 *
222 * PARAMETERS: obj_handle - Handle whose pathname will be displayed 268 * PARAMETERS: Type - Object type of the node
269 * obj_handle - Handle whose pathname will be displayed
223 * Path - Additional path string to be appended. 270 * Path - Additional path string to be appended.
224 * (NULL if no extra path) 271 * (NULL if no extra path)
225 * 272 *
@@ -270,7 +317,8 @@ acpi_ut_display_init_pathname (
270 317
271 /* Print the object type and pathname */ 318 /* Print the object type and pathname */
272 319
273 acpi_os_printf ("%-12s %s", acpi_ut_get_type_name (type), (char *) buffer.pointer); 320 acpi_os_printf ("%-12s %s",
321 acpi_ut_get_type_name (type), (char *) buffer.pointer);
274 322
275 /* Extra path is used to append names like _STA, _INI, etc. */ 323 /* Extra path is used to append names like _STA, _INI, etc. */
276 324
@@ -288,9 +336,9 @@ acpi_ut_display_init_pathname (
288 * 336 *
289 * FUNCTION: acpi_ut_valid_acpi_name 337 * FUNCTION: acpi_ut_valid_acpi_name
290 * 338 *
291 * PARAMETERS: Character - The character to be examined 339 * PARAMETERS: Name - The name to be examined
292 * 340 *
293 * RETURN: 1 if Character may appear in a name, else 0 341 * RETURN: TRUE if the name is valid, FALSE otherwise
294 * 342 *
295 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: 343 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
296 * 1) Upper case alpha 344 * 1) Upper case alpha
@@ -495,40 +543,6 @@ error_exit:
495 543
496/******************************************************************************* 544/*******************************************************************************
497 * 545 *
498 * FUNCTION: acpi_ut_strupr
499 *
500 * PARAMETERS: src_string - The source string to convert to
501 *
502 * RETURN: src_string
503 *
504 * DESCRIPTION: Convert string to uppercase
505 *
506 ******************************************************************************/
507#ifdef ACPI_FUTURE_USAGE
508char *
509acpi_ut_strupr (
510 char *src_string)
511{
512 char *string;
513
514
515 ACPI_FUNCTION_ENTRY ();
516
517
518 /* Walk entire string, uppercasing the letters */
519
520 for (string = src_string; *string; ) {
521 *string = (char) ACPI_TOUPPER (*string);
522 string++;
523 }
524
525 return (src_string);
526}
527#endif /* ACPI_FUTURE_USAGE */
528
529
530/*******************************************************************************
531 *
532 * FUNCTION: acpi_ut_mutex_initialize 546 * FUNCTION: acpi_ut_mutex_initialize
533 * 547 *
534 * PARAMETERS: None. 548 * PARAMETERS: None.
@@ -611,7 +625,7 @@ acpi_ut_mutex_terminate (
611 * 625 *
612 ******************************************************************************/ 626 ******************************************************************************/
613 627
614acpi_status 628static acpi_status
615acpi_ut_create_mutex ( 629acpi_ut_create_mutex (
616 acpi_mutex_handle mutex_id) 630 acpi_mutex_handle mutex_id)
617{ 631{
@@ -648,7 +662,7 @@ acpi_ut_create_mutex (
648 * 662 *
649 ******************************************************************************/ 663 ******************************************************************************/
650 664
651acpi_status 665static acpi_status
652acpi_ut_delete_mutex ( 666acpi_ut_delete_mutex (
653 acpi_mutex_handle mutex_id) 667 acpi_mutex_handle mutex_id)
654{ 668{
@@ -715,16 +729,16 @@ acpi_ut_acquire_mutex (
715 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { 729 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
716 if (i == mutex_id) { 730 if (i == mutex_id) {
717 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 731 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
718 "Mutex [%s] already acquired by this thread [%X]\n", 732 "Mutex [%s] already acquired by this thread [%X]\n",
719 acpi_ut_get_mutex_name (mutex_id), this_thread_id)); 733 acpi_ut_get_mutex_name (mutex_id), this_thread_id));
720 734
721 return (AE_ALREADY_ACQUIRED); 735 return (AE_ALREADY_ACQUIRED);
722 } 736 }
723 737
724 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 738 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
725 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", 739 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
726 this_thread_id, acpi_ut_get_mutex_name (i), 740 this_thread_id, acpi_ut_get_mutex_name (i),
727 acpi_ut_get_mutex_name (mutex_id))); 741 acpi_ut_get_mutex_name (mutex_id)));
728 742
729 return (AE_ACQUIRE_DEADLOCK); 743 return (AE_ACQUIRE_DEADLOCK);
730 } 744 }
@@ -733,22 +747,23 @@ acpi_ut_acquire_mutex (
733#endif 747#endif
734 748
735 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 749 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
736 "Thread %X attempting to acquire Mutex [%s]\n", 750 "Thread %X attempting to acquire Mutex [%s]\n",
737 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 751 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
738 752
739 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 753 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex,
740 1, ACPI_WAIT_FOREVER); 754 1, ACPI_WAIT_FOREVER);
741 if (ACPI_SUCCESS (status)) { 755 if (ACPI_SUCCESS (status)) {
742 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", 756 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
743 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 757 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
744 758
745 acpi_gbl_mutex_info[mutex_id].use_count++; 759 acpi_gbl_mutex_info[mutex_id].use_count++;
746 acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id; 760 acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id;
747 } 761 }
748 else { 762 else {
749 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not acquire Mutex [%s] %s\n", 763 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
750 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 764 "Thread %X could not acquire Mutex [%s] %s\n",
751 acpi_format_exception (status))); 765 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
766 acpi_format_exception (status)));
752 } 767 }
753 768
754 return (status); 769 return (status);
@@ -793,8 +808,8 @@ acpi_ut_release_mutex (
793 */ 808 */
794 if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) { 809 if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
795 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 810 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
796 "Mutex [%s] is not acquired, cannot release\n", 811 "Mutex [%s] is not acquired, cannot release\n",
797 acpi_ut_get_mutex_name (mutex_id))); 812 acpi_ut_get_mutex_name (mutex_id)));
798 813
799 return (AE_NOT_ACQUIRED); 814 return (AE_NOT_ACQUIRED);
800 } 815 }
@@ -812,8 +827,8 @@ acpi_ut_release_mutex (
812 } 827 }
813 828
814 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 829 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
815 "Invalid release order: owns [%s], releasing [%s]\n", 830 "Invalid release order: owns [%s], releasing [%s]\n",
816 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); 831 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));
817 832
818 return (AE_RELEASE_DEADLOCK); 833 return (AE_RELEASE_DEADLOCK);
819 } 834 }
@@ -826,13 +841,14 @@ acpi_ut_release_mutex (
826 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); 841 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);
827 842
828 if (ACPI_FAILURE (status)) { 843 if (ACPI_FAILURE (status)) {
829 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not release Mutex [%s] %s\n", 844 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
830 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 845 "Thread %X could not release Mutex [%s] %s\n",
831 acpi_format_exception (status))); 846 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
847 acpi_format_exception (status)));
832 } 848 }
833 else { 849 else {
834 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", 850 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n",
835 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 851 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
836 } 852 }
837 853
838 return (status); 854 return (status);
@@ -843,11 +859,11 @@ acpi_ut_release_mutex (
843 * 859 *
844 * FUNCTION: acpi_ut_create_update_state_and_push 860 * FUNCTION: acpi_ut_create_update_state_and_push
845 * 861 *
846 * PARAMETERS: *Object - Object to be added to the new state 862 * PARAMETERS: Object - Object to be added to the new state
847 * Action - Increment/Decrement 863 * Action - Increment/Decrement
848 * state_list - List the state will be added to 864 * state_list - List the state will be added to
849 * 865 *
850 * RETURN: None 866 * RETURN: Status
851 * 867 *
852 * DESCRIPTION: Create a new state and push it 868 * DESCRIPTION: Create a new state and push it
853 * 869 *
@@ -885,15 +901,16 @@ acpi_ut_create_update_state_and_push (
885 * 901 *
886 * FUNCTION: acpi_ut_create_pkg_state_and_push 902 * FUNCTION: acpi_ut_create_pkg_state_and_push
887 * 903 *
888 * PARAMETERS: *Object - Object to be added to the new state 904 * PARAMETERS: Object - Object to be added to the new state
889 * Action - Increment/Decrement 905 * Action - Increment/Decrement
890 * state_list - List the state will be added to 906 * state_list - List the state will be added to
891 * 907 *
892 * RETURN: None 908 * RETURN: Status
893 * 909 *
894 * DESCRIPTION: Create a new state and push it 910 * DESCRIPTION: Create a new state and push it
895 * 911 *
896 ******************************************************************************/ 912 ******************************************************************************/
913
897#ifdef ACPI_FUTURE_USAGE 914#ifdef ACPI_FUTURE_USAGE
898acpi_status 915acpi_status
899acpi_ut_create_pkg_state_and_push ( 916acpi_ut_create_pkg_state_and_push (
@@ -925,7 +942,7 @@ acpi_ut_create_pkg_state_and_push (
925 * PARAMETERS: list_head - Head of the state stack 942 * PARAMETERS: list_head - Head of the state stack
926 * State - State object to push 943 * State - State object to push
927 * 944 *
928 * RETURN: Status 945 * RETURN: None
929 * 946 *
930 * DESCRIPTION: Push a state object onto a state stack 947 * DESCRIPTION: Push a state object onto a state stack
931 * 948 *
@@ -954,7 +971,7 @@ acpi_ut_push_generic_state (
954 * 971 *
955 * PARAMETERS: list_head - Head of the state stack 972 * PARAMETERS: list_head - Head of the state stack
956 * 973 *
957 * RETURN: Status 974 * RETURN: The popped state object
958 * 975 *
959 * DESCRIPTION: Pop a state object from a state stack 976 * DESCRIPTION: Pop a state object from a state stack
960 * 977 *
@@ -989,7 +1006,7 @@ acpi_ut_pop_generic_state (
989 * 1006 *
990 * PARAMETERS: None 1007 * PARAMETERS: None
991 * 1008 *
992 * RETURN: Status 1009 * RETURN: The new state object. NULL on failure.
993 * 1010 *
994 * DESCRIPTION: Create a generic state object. Attempt to obtain one from 1011 * DESCRIPTION: Create a generic state object. Attempt to obtain one from
995 * the global state cache; If none available, create a new one. 1012 * the global state cache; If none available, create a new one.
@@ -997,7 +1014,8 @@ acpi_ut_pop_generic_state (
997 ******************************************************************************/ 1014 ******************************************************************************/
998 1015
999union acpi_generic_state * 1016union acpi_generic_state *
1000acpi_ut_create_generic_state (void) 1017acpi_ut_create_generic_state (
1018 void)
1001{ 1019{
1002 union acpi_generic_state *state; 1020 union acpi_generic_state *state;
1003 1021
@@ -1023,7 +1041,7 @@ acpi_ut_create_generic_state (void)
1023 * 1041 *
1024 * PARAMETERS: None 1042 * PARAMETERS: None
1025 * 1043 *
1026 * RETURN: Thread State 1044 * RETURN: New Thread State. NULL on failure
1027 * 1045 *
1028 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used 1046 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
1029 * to track per-thread info during method execution 1047 * to track per-thread info during method execution
@@ -1060,11 +1078,10 @@ acpi_ut_create_thread_state (
1060 * 1078 *
1061 * FUNCTION: acpi_ut_create_update_state 1079 * FUNCTION: acpi_ut_create_update_state
1062 * 1080 *
1063 * PARAMETERS: Object - Initial Object to be installed in the 1081 * PARAMETERS: Object - Initial Object to be installed in the state
1064 * state 1082 * Action - Update action to be performed
1065 * Action - Update action to be performed
1066 * 1083 *
1067 * RETURN: Status 1084 * RETURN: New state object, null on failure
1068 * 1085 *
1069 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used 1086 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
1070 * to update reference counts and delete complex objects such 1087 * to update reference counts and delete complex objects such
@@ -1104,11 +1121,10 @@ acpi_ut_create_update_state (
1104 * 1121 *
1105 * FUNCTION: acpi_ut_create_pkg_state 1122 * FUNCTION: acpi_ut_create_pkg_state
1106 * 1123 *
1107 * PARAMETERS: Object - Initial Object to be installed in the 1124 * PARAMETERS: Object - Initial Object to be installed in the state
1108 * state 1125 * Action - Update action to be performed
1109 * Action - Update action to be performed
1110 * 1126 *
1111 * RETURN: Status 1127 * RETURN: New state object, null on failure
1112 * 1128 *
1113 * DESCRIPTION: Create a "Package State" 1129 * DESCRIPTION: Create a "Package State"
1114 * 1130 *
@@ -1151,7 +1167,7 @@ acpi_ut_create_pkg_state (
1151 * 1167 *
1152 * PARAMETERS: None 1168 * PARAMETERS: None
1153 * 1169 *
1154 * RETURN: Status 1170 * RETURN: New state object, null on failure
1155 * 1171 *
1156 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used 1172 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
1157 * to support nested IF/WHILE constructs in the AML. 1173 * to support nested IF/WHILE constructs in the AML.
@@ -1190,7 +1206,7 @@ acpi_ut_create_control_state (
1190 * 1206 *
1191 * PARAMETERS: State - The state object to be deleted 1207 * PARAMETERS: State - The state object to be deleted
1192 * 1208 *
1193 * RETURN: Status 1209 * RETURN: None
1194 * 1210 *
1195 * DESCRIPTION: Put a state object back into the global state cache. The object 1211 * DESCRIPTION: Put a state object back into the global state cache. The object
1196 * is not actually freed at this time. 1212 * is not actually freed at this time.
@@ -1216,7 +1232,7 @@ acpi_ut_delete_generic_state (
1216 * 1232 *
1217 * PARAMETERS: None 1233 * PARAMETERS: None
1218 * 1234 *
1219 * RETURN: Status 1235 * RETURN: None
1220 * 1236 *
1221 * DESCRIPTION: Purge the global state object cache. Used during subsystem 1237 * DESCRIPTION: Purge the global state object cache. Used during subsystem
1222 * termination. 1238 * termination.
@@ -1240,7 +1256,10 @@ acpi_ut_delete_generic_state_cache (
1240 * 1256 *
1241 * FUNCTION: acpi_ut_walk_package_tree 1257 * FUNCTION: acpi_ut_walk_package_tree
1242 * 1258 *
1243 * PARAMETERS: obj_desc - The Package object on which to resolve refs 1259 * PARAMETERS: source_object - The package to walk
1260 * target_object - Target object (if package is being copied)
1261 * walk_callback - Called once for each package element
1262 * Context - Passed to the callback function
1244 * 1263 *
1245 * RETURN: Status 1264 * RETURN: Status
1246 * 1265 *
@@ -1359,7 +1378,7 @@ acpi_ut_walk_package_tree (
1359 * PARAMETERS: Buffer - Buffer to be scanned 1378 * PARAMETERS: Buffer - Buffer to be scanned
1360 * Length - number of bytes to examine 1379 * Length - number of bytes to examine
1361 * 1380 *
1362 * RETURN: checksum 1381 * RETURN: The generated checksum
1363 * 1382 *
1364 * DESCRIPTION: Generate a checksum on a raw buffer 1383 * DESCRIPTION: Generate a checksum on a raw buffer
1365 * 1384 *
@@ -1442,7 +1461,6 @@ acpi_ut_get_resource_end_tag (
1442 * PARAMETERS: module_name - Caller's module name (for error output) 1461 * PARAMETERS: module_name - Caller's module name (for error output)
1443 * line_number - Caller's line number (for error output) 1462 * line_number - Caller's line number (for error output)
1444 * component_id - Caller's component ID (for error output) 1463 * component_id - Caller's component ID (for error output)
1445 * Message - Error message to use on failure
1446 * 1464 *
1447 * RETURN: None 1465 * RETURN: None
1448 * 1466 *
@@ -1457,7 +1475,6 @@ acpi_ut_report_error (
1457 u32 component_id) 1475 u32 component_id)
1458{ 1476{
1459 1477
1460
1461 acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); 1478 acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number);
1462} 1479}
1463 1480
@@ -1469,7 +1486,6 @@ acpi_ut_report_error (
1469 * PARAMETERS: module_name - Caller's module name (for error output) 1486 * PARAMETERS: module_name - Caller's module name (for error output)
1470 * line_number - Caller's line number (for error output) 1487 * line_number - Caller's line number (for error output)
1471 * component_id - Caller's component ID (for error output) 1488 * component_id - Caller's component ID (for error output)
1472 * Message - Error message to use on failure
1473 * 1489 *
1474 * RETURN: None 1490 * RETURN: None
1475 * 1491 *
@@ -1495,7 +1511,6 @@ acpi_ut_report_warning (
1495 * PARAMETERS: module_name - Caller's module name (for error output) 1511 * PARAMETERS: module_name - Caller's module name (for error output)
1496 * line_number - Caller's line number (for error output) 1512 * line_number - Caller's line number (for error output)
1497 * component_id - Caller's component ID (for error output) 1513 * component_id - Caller's component ID (for error output)
1498 * Message - Error message to use on failure
1499 * 1514 *
1500 * RETURN: None 1515 * RETURN: None
1501 * 1516 *
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index 9ee40a484e07..cd3899b9cc5a 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/utilities/utobject.c
@@ -50,6 +50,25 @@
50#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utobject") 51 ACPI_MODULE_NAME ("utobject")
52 52
53/* Local prototypes */
54
55static acpi_status
56acpi_ut_get_simple_object_size (
57 union acpi_operand_object *obj,
58 acpi_size *obj_length);
59
60static acpi_status
61acpi_ut_get_package_object_size (
62 union acpi_operand_object *obj,
63 acpi_size *obj_length);
64
65static acpi_status
66acpi_ut_get_element_length (
67 u8 object_type,
68 union acpi_operand_object *source_object,
69 union acpi_generic_state *state,
70 void *context);
71
53 72
54/******************************************************************************* 73/*******************************************************************************
55 * 74 *
@@ -60,7 +79,7 @@
60 * component_id - Component type of caller 79 * component_id - Component type of caller
61 * Type - ACPI Type of the new object 80 * Type - ACPI Type of the new object
62 * 81 *
63 * RETURN: Object - The new object. Null on failure 82 * RETURN: A new internal object, null on failure
64 * 83 *
65 * DESCRIPTION: Create and initialize a new internal object. 84 * DESCRIPTION: Create and initialize a new internal object.
66 * 85 *
@@ -83,7 +102,8 @@ acpi_ut_create_internal_object_dbg (
83 union acpi_operand_object *second_object; 102 union acpi_operand_object *second_object;
84 103
85 104
86 ACPI_FUNCTION_TRACE_STR ("ut_create_internal_object_dbg", acpi_ut_get_type_name (type)); 105 ACPI_FUNCTION_TRACE_STR ("ut_create_internal_object_dbg",
106 acpi_ut_get_type_name (type));
87 107
88 108
89 /* Allocate the raw object descriptor */ 109 /* Allocate the raw object descriptor */
@@ -99,7 +119,8 @@ acpi_ut_create_internal_object_dbg (
99 119
100 /* These types require a secondary object */ 120 /* These types require a secondary object */
101 121
102 second_object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id); 122 second_object = acpi_ut_allocate_object_desc_dbg (module_name,
123 line_number, component_id);
103 if (!second_object) { 124 if (!second_object) {
104 acpi_ut_delete_object_desc (object); 125 acpi_ut_delete_object_desc (object);
105 return_PTR (NULL); 126 return_PTR (NULL);
@@ -138,7 +159,7 @@ acpi_ut_create_internal_object_dbg (
138 * 159 *
139 * PARAMETERS: buffer_size - Size of buffer to be created 160 * PARAMETERS: buffer_size - Size of buffer to be created
140 * 161 *
141 * RETURN: Pointer to a new Buffer object 162 * RETURN: Pointer to a new Buffer object, null on failure
142 * 163 *
143 * DESCRIPTION: Create a fully initialized buffer object 164 * DESCRIPTION: Create a fully initialized buffer object
144 * 165 *
@@ -192,9 +213,9 @@ acpi_ut_create_buffer_object (
192 * 213 *
193 * FUNCTION: acpi_ut_create_string_object 214 * FUNCTION: acpi_ut_create_string_object
194 * 215 *
195 * PARAMETERS: string_size - Size of string to be created. Does not 216 * PARAMETERS: string_size - Size of string to be created. Does not
196 * include NULL terminator, this is added 217 * include NULL terminator, this is added
197 * automatically. 218 * automatically.
198 * 219 *
199 * RETURN: Pointer to a new String object 220 * RETURN: Pointer to a new String object
200 * 221 *
@@ -249,7 +270,9 @@ acpi_ut_create_string_object (
249 * 270 *
250 * PARAMETERS: Object - Object to be validated 271 * PARAMETERS: Object - Object to be validated
251 * 272 *
252 * RETURN: Validate a pointer to be an union acpi_operand_object 273 * RETURN: TRUE if object is valid, FALSE otherwise
274 *
275 * DESCRIPTION: Validate a pointer to be an union acpi_operand_object
253 * 276 *
254 ******************************************************************************/ 277 ******************************************************************************/
255 278
@@ -399,8 +422,8 @@ acpi_ut_delete_object_cache (
399 * 422 *
400 * FUNCTION: acpi_ut_get_simple_object_size 423 * FUNCTION: acpi_ut_get_simple_object_size
401 * 424 *
402 * PARAMETERS: *internal_object - Pointer to the object we are examining 425 * PARAMETERS: internal_object - An ACPI operand object
403 * *obj_length - Where the length is returned 426 * obj_length - Where the length is returned
404 * 427 *
405 * RETURN: Status 428 * RETURN: Status
406 * 429 *
@@ -412,7 +435,7 @@ acpi_ut_delete_object_cache (
412 * 435 *
413 ******************************************************************************/ 436 ******************************************************************************/
414 437
415acpi_status 438static acpi_status
416acpi_ut_get_simple_object_size ( 439acpi_ut_get_simple_object_size (
417 union acpi_operand_object *internal_object, 440 union acpi_operand_object *internal_object,
418 acpi_size *obj_length) 441 acpi_size *obj_length)
@@ -424,8 +447,10 @@ acpi_ut_get_simple_object_size (
424 ACPI_FUNCTION_TRACE_PTR ("ut_get_simple_object_size", internal_object); 447 ACPI_FUNCTION_TRACE_PTR ("ut_get_simple_object_size", internal_object);
425 448
426 449
427 /* Handle a null object (Could be a uninitialized package element -- which is legal) */ 450 /*
428 451 * Handle a null object (Could be a uninitialized package
452 * element -- which is legal)
453 */
429 if (!internal_object) { 454 if (!internal_object) {
430 *obj_length = 0; 455 *obj_length = 0;
431 return_ACPI_STATUS (AE_OK); 456 return_ACPI_STATUS (AE_OK);
@@ -480,7 +505,8 @@ acpi_ut_get_simple_object_size (
480 * Get the actual length of the full pathname to this object. 505 * Get the actual length of the full pathname to this object.
481 * The reference will be converted to the pathname to the object 506 * The reference will be converted to the pathname to the object
482 */ 507 */
483 length += ACPI_ROUND_UP_TO_NATIVE_WORD (acpi_ns_get_pathname_length (internal_object->reference.node)); 508 length += ACPI_ROUND_UP_TO_NATIVE_WORD (
509 acpi_ns_get_pathname_length (internal_object->reference.node));
484 break; 510 break;
485 511
486 default: 512 default:
@@ -530,7 +556,7 @@ acpi_ut_get_simple_object_size (
530 * 556 *
531 ******************************************************************************/ 557 ******************************************************************************/
532 558
533acpi_status 559static acpi_status
534acpi_ut_get_element_length ( 560acpi_ut_get_element_length (
535 u8 object_type, 561 u8 object_type,
536 union acpi_operand_object *source_object, 562 union acpi_operand_object *source_object,
@@ -582,8 +608,8 @@ acpi_ut_get_element_length (
582 * 608 *
583 * FUNCTION: acpi_ut_get_package_object_size 609 * FUNCTION: acpi_ut_get_package_object_size
584 * 610 *
585 * PARAMETERS: *internal_object - Pointer to the object we are examining 611 * PARAMETERS: internal_object - An ACPI internal object
586 * *obj_length - Where the length is returned 612 * obj_length - Where the length is returned
587 * 613 *
588 * RETURN: Status 614 * RETURN: Status
589 * 615 *
@@ -595,7 +621,7 @@ acpi_ut_get_element_length (
595 * 621 *
596 ******************************************************************************/ 622 ******************************************************************************/
597 623
598acpi_status 624static acpi_status
599acpi_ut_get_package_object_size ( 625acpi_ut_get_package_object_size (
600 union acpi_operand_object *internal_object, 626 union acpi_operand_object *internal_object,
601 acpi_size *obj_length) 627 acpi_size *obj_length)
@@ -636,8 +662,8 @@ acpi_ut_get_package_object_size (
636 * 662 *
637 * FUNCTION: acpi_ut_get_object_size 663 * FUNCTION: acpi_ut_get_object_size
638 * 664 *
639 * PARAMETERS: *internal_object - Pointer to the object we are examining 665 * PARAMETERS: internal_object - An ACPI internal object
640 * *obj_length - Where the length will be returned 666 * obj_length - Where the length will be returned
641 * 667 *
642 * RETURN: Status 668 * RETURN: Status
643 * 669 *
@@ -647,7 +673,7 @@ acpi_ut_get_package_object_size (
647 ******************************************************************************/ 673 ******************************************************************************/
648 674
649acpi_status 675acpi_status
650acpi_ut_get_object_size( 676acpi_ut_get_object_size (
651 union acpi_operand_object *internal_object, 677 union acpi_operand_object *internal_object,
652 acpi_size *obj_length) 678 acpi_size *obj_length)
653{ 679{
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index 97a91f3f06f0..e8803d810656 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -73,6 +73,7 @@ acpi_initialize_subsystem (
73{ 73{
74 acpi_status status; 74 acpi_status status;
75 75
76
76 ACPI_FUNCTION_TRACE ("acpi_initialize_subsystem"); 77 ACPI_FUNCTION_TRACE ("acpi_initialize_subsystem");
77 78
78 79
@@ -105,7 +106,6 @@ acpi_initialize_subsystem (
105 * Initialize the namespace manager and 106 * Initialize the namespace manager and
106 * the root of the namespace tree 107 * the root of the namespace tree
107 */ 108 */
108
109 status = acpi_ns_root_initialize (); 109 status = acpi_ns_root_initialize ();
110 if (ACPI_FAILURE (status)) { 110 if (ACPI_FAILURE (status)) {
111 ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n", 111 ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n",
@@ -113,7 +113,6 @@ acpi_initialize_subsystem (
113 return_ACPI_STATUS (status); 113 return_ACPI_STATUS (status);
114 } 114 }
115 115
116
117 /* If configured, initialize the AML debugger */ 116 /* If configured, initialize the AML debugger */
118 117
119 ACPI_DEBUGGER_EXEC (status = acpi_db_initialize ()); 118 ACPI_DEBUGGER_EXEC (status = acpi_db_initialize ());
@@ -150,7 +149,8 @@ acpi_enable_subsystem (
150 * The values from the FADT are validated here. 149 * The values from the FADT are validated here.
151 */ 150 */
152 if (!(flags & ACPI_NO_HARDWARE_INIT)) { 151 if (!(flags & ACPI_NO_HARDWARE_INIT)) {
153 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI hardware\n")); 152 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
153 "[Init] Initializing ACPI hardware\n"));
154 154
155 status = acpi_hw_initialize (); 155 status = acpi_hw_initialize ();
156 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE (status)) {
@@ -178,7 +178,8 @@ acpi_enable_subsystem (
178 * install_address_space_handler interface. 178 * install_address_space_handler interface.
179 */ 179 */
180 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 180 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
181 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n")); 181 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
182 "[Init] Installing default address space handlers\n"));
182 183
183 status = acpi_ev_install_region_handlers (); 184 status = acpi_ev_install_region_handlers ();
184 if (ACPI_FAILURE (status)) { 185 if (ACPI_FAILURE (status)) {
@@ -189,12 +190,14 @@ acpi_enable_subsystem (
189 /* 190 /*
190 * Initialize ACPI Event handling (Fixed and General Purpose) 191 * Initialize ACPI Event handling (Fixed and General Purpose)
191 * 192 *
192 * NOTE: We must have the hardware AND events initialized before we can execute 193 * NOTE: We must have the hardware AND events initialized before we can
193 * ANY control methods SAFELY. Any control method can require ACPI hardware 194 * execute ANY control methods SAFELY. Any control method can require
194 * support, so the hardware MUST be initialized before execution! 195 * ACPI hardware support, so the hardware MUST be initialized before
196 * execution!
195 */ 197 */
196 if (!(flags & ACPI_NO_EVENT_INIT)) { 198 if (!(flags & ACPI_NO_EVENT_INIT)) {
197 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n")); 199 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
200 "[Init] Initializing ACPI events\n"));
198 201
199 status = acpi_ev_initialize_events (); 202 status = acpi_ev_initialize_events ();
200 if (ACPI_FAILURE (status)) { 203 if (ACPI_FAILURE (status)) {
@@ -205,7 +208,8 @@ acpi_enable_subsystem (
205 /* Install the SCI handler and Global Lock handler */ 208 /* Install the SCI handler and Global Lock handler */
206 209
207 if (!(flags & ACPI_NO_HANDLER_INIT)) { 210 if (!(flags & ACPI_NO_HANDLER_INIT)) {
208 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n")); 211 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
212 "[Init] Installing SCI/GL handlers\n"));
209 213
210 status = acpi_ev_install_xrupt_handlers (); 214 status = acpi_ev_install_xrupt_handlers ();
211 if (ACPI_FAILURE (status)) { 215 if (ACPI_FAILURE (status)) {
@@ -247,7 +251,8 @@ acpi_initialize_objects (
247 * contain executable AML (see call to acpi_ns_initialize_objects below). 251 * contain executable AML (see call to acpi_ns_initialize_objects below).
248 */ 252 */
249 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 253 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
250 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Executing _REG op_region methods\n")); 254 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
255 "[Init] Executing _REG op_region methods\n"));
251 256
252 status = acpi_ev_initialize_op_regions (); 257 status = acpi_ev_initialize_op_regions ();
253 if (ACPI_FAILURE (status)) { 258 if (ACPI_FAILURE (status)) {
@@ -261,7 +266,8 @@ acpi_initialize_objects (
261 * objects: operation_regions, buffer_fields, Buffers, and Packages. 266 * objects: operation_regions, buffer_fields, Buffers, and Packages.
262 */ 267 */
263 if (!(flags & ACPI_NO_OBJECT_INIT)) { 268 if (!(flags & ACPI_NO_OBJECT_INIT)) {
264 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Completing Initialization of ACPI Objects\n")); 269 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
270 "[Init] Completing Initialization of ACPI Objects\n"));
265 271
266 status = acpi_ns_initialize_objects (); 272 status = acpi_ns_initialize_objects ();
267 if (ACPI_FAILURE (status)) { 273 if (ACPI_FAILURE (status)) {
@@ -274,7 +280,8 @@ acpi_initialize_objects (
274 * This runs the _STA and _INI methods. 280 * This runs the _STA and _INI methods.
275 */ 281 */
276 if (!(flags & ACPI_NO_DEVICE_INIT)) { 282 if (!(flags & ACPI_NO_DEVICE_INIT)) {
277 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Devices\n")); 283 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
284 "[Init] Initializing ACPI Devices\n"));
278 285
279 status = acpi_ns_initialize_devices (); 286 status = acpi_ns_initialize_devices ();
280 if (ACPI_FAILURE (status)) { 287 if (ACPI_FAILURE (status)) {
@@ -307,7 +314,8 @@ acpi_initialize_objects (
307 ******************************************************************************/ 314 ******************************************************************************/
308 315
309acpi_status 316acpi_status
310acpi_terminate (void) 317acpi_terminate (
318 void)
311{ 319{
312 acpi_status status; 320 acpi_status status;
313 321
@@ -344,8 +352,7 @@ acpi_terminate (void)
344 352
345 353
346#ifdef ACPI_FUTURE_USAGE 354#ifdef ACPI_FUTURE_USAGE
347 355/*******************************************************************************
348/*****************************************************************************
349 * 356 *
350 * FUNCTION: acpi_subsystem_status 357 * FUNCTION: acpi_subsystem_status
351 * 358 *
@@ -354,14 +361,16 @@ acpi_terminate (void)
354 * RETURN: Status of the ACPI subsystem 361 * RETURN: Status of the ACPI subsystem
355 * 362 *
356 * DESCRIPTION: Other drivers that use the ACPI subsystem should call this 363 * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
357 * before making any other calls, to ensure the subsystem initial- 364 * before making any other calls, to ensure the subsystem
358 * ized successfully. 365 * initialized successfully.
359 * 366 *
360 ****************************************************************************/ 367 ******************************************************************************/
361 368
362acpi_status 369acpi_status
363acpi_subsystem_status (void) 370acpi_subsystem_status (
371 void)
364{ 372{
373
365 if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) { 374 if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) {
366 return (AE_OK); 375 return (AE_OK);
367 } 376 }
@@ -371,13 +380,12 @@ acpi_subsystem_status (void)
371} 380}
372 381
373 382
374/****************************************************************************** 383/*******************************************************************************
375 * 384 *
376 * FUNCTION: acpi_get_system_info 385 * FUNCTION: acpi_get_system_info
377 * 386 *
378 * PARAMETERS: out_buffer - a pointer to a buffer to receive the 387 * PARAMETERS: out_buffer - A buffer to receive the resources for the
379 * resources for the device 388 * device
380 * buffer_length - the number of bytes available in the buffer
381 * 389 *
382 * RETURN: Status - the status of the call 390 * RETURN: Status - the status of the call
383 * 391 *
@@ -395,8 +403,8 @@ acpi_get_system_info (
395 struct acpi_buffer *out_buffer) 403 struct acpi_buffer *out_buffer)
396{ 404{
397 struct acpi_system_info *info_ptr; 405 struct acpi_system_info *info_ptr;
398 u32 i;
399 acpi_status status; 406 acpi_status status;
407 u32 i;
400 408
401 409
402 ACPI_FUNCTION_TRACE ("acpi_get_system_info"); 410 ACPI_FUNCTION_TRACE ("acpi_get_system_info");
@@ -466,6 +474,7 @@ EXPORT_SYMBOL(acpi_get_system_info);
466 * FUNCTION: acpi_install_initialization_handler 474 * FUNCTION: acpi_install_initialization_handler
467 * 475 *
468 * PARAMETERS: Handler - Callback procedure 476 * PARAMETERS: Handler - Callback procedure
477 * Function - Not (currently) used, see below
469 * 478 *
470 * RETURN: Status 479 * RETURN: Status
471 * 480 *
@@ -495,7 +504,6 @@ acpi_install_initialization_handler (
495 504
496#endif /* ACPI_FUTURE_USAGE */ 505#endif /* ACPI_FUTURE_USAGE */
497 506
498
499/***************************************************************************** 507/*****************************************************************************
500 * 508 *
501 * FUNCTION: acpi_purge_cached_objects 509 * FUNCTION: acpi_purge_cached_objects
@@ -509,7 +517,8 @@ acpi_install_initialization_handler (
509 ****************************************************************************/ 517 ****************************************************************************/
510 518
511acpi_status 519acpi_status
512acpi_purge_cached_objects (void) 520acpi_purge_cached_objects (
521 void)
513{ 522{
514 ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); 523 ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects");
515 524
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 71fa1011715f..2cf264fd52e0 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -564,12 +564,13 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
564 int count = 0; 564 int count = 0;
565 union acpi_object *o; 565 union acpi_object *o;
566 566
567 br = kmalloc(sizeof &br, GFP_KERNEL); 567 br = kmalloc(sizeof(*br), GFP_KERNEL);
568 if (!br) { 568 if (!br) {
569 printk(KERN_ERR "can't allocate memory\n"); 569 printk(KERN_ERR "can't allocate memory\n");
570 } else { 570 } else {
571 memset(br, 0, sizeof &br); 571 memset(br, 0, sizeof(*br));
572 br->levels = kmalloc(obj->package.count * sizeof &br->levels, GFP_KERNEL); 572 br->levels = kmalloc(obj->package.count *
573 sizeof *(br->levels), GFP_KERNEL);
573 if (!br->levels) 574 if (!br->levels)
574 goto out; 575 goto out;
575 576
@@ -584,8 +585,7 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
584 } 585 }
585out: 586out:
586 if (count < 2) { 587 if (count < 2) {
587 if (br->levels) 588 kfree(br->levels);
588 kfree(br->levels);
589 kfree(br); 589 kfree(br);
590 } else { 590 } else {
591 br->count = count; 591 br->count = count;
@@ -595,8 +595,7 @@ out:
595 } 595 }
596 } 596 }
597 597
598 if (obj) 598 kfree(obj);
599 kfree(obj);
600 599
601 return_VOID; 600 return_VOID;
602} 601}
@@ -1585,7 +1584,7 @@ acpi_video_switch_output(
1585 ACPI_FUNCTION_TRACE("acpi_video_switch_output"); 1584 ACPI_FUNCTION_TRACE("acpi_video_switch_output");
1586 1585
1587 list_for_each_safe(node, next, &video->video_device_list) { 1586 list_for_each_safe(node, next, &video->video_device_list) {
1588 struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry); 1587 dev = container_of(node, struct acpi_video_device, entry);
1589 status = acpi_video_device_get_state(dev, &state); 1588 status = acpi_video_device_get_state(dev, &state);
1590 if (state & 0x2){ 1589 if (state & 0x2){
1591 dev_next = container_of(node->next, struct acpi_video_device, entry); 1590 dev_next = container_of(node->next, struct acpi_video_device, entry);
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 645f62692920..783752b68a9a 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -5,6 +5,7 @@ extern int bus_add_driver(struct device_driver *);
5extern void bus_remove_driver(struct device_driver *); 5extern void bus_remove_driver(struct device_driver *);
6 6
7extern void driver_detach(struct device_driver * drv); 7extern void driver_detach(struct device_driver * drv);
8extern int driver_probe_device(struct device_driver *, struct device *);
8 9
9static inline struct class_device *to_class_dev(struct kobject *obj) 10static inline struct class_device *to_class_dev(struct kobject *obj)
10{ 11{
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index c3fac7fd555e..96fe2f956754 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -133,6 +133,58 @@ static struct kobj_type ktype_bus = {
133decl_subsys(bus, &ktype_bus, NULL); 133decl_subsys(bus, &ktype_bus, NULL);
134 134
135 135
136/* Manually detach a device from it's associated driver. */
137static int driver_helper(struct device *dev, void *data)
138{
139 const char *name = data;
140
141 if (strcmp(name, dev->bus_id) == 0)
142 return 1;
143 return 0;
144}
145
146static ssize_t driver_unbind(struct device_driver *drv,
147 const char *buf, size_t count)
148{
149 struct bus_type *bus = get_bus(drv->bus);
150 struct device *dev;
151 int err = -ENODEV;
152
153 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
154 if ((dev) &&
155 (dev->driver == drv)) {
156 device_release_driver(dev);
157 err = count;
158 }
159 return err;
160}
161static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind);
162
163/*
164 * Manually attach a device to a driver.
165 * Note: the driver must want to bind to the device,
166 * it is not possible to override the driver's id table.
167 */
168static ssize_t driver_bind(struct device_driver *drv,
169 const char *buf, size_t count)
170{
171 struct bus_type *bus = get_bus(drv->bus);
172 struct device *dev;
173 int err = -ENODEV;
174
175 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
176 if ((dev) &&
177 (dev->driver == NULL)) {
178 down(&dev->sem);
179 err = driver_probe_device(drv, dev);
180 up(&dev->sem);
181 put_device(dev);
182 }
183 return err;
184}
185static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind);
186
187
136static struct device * next_device(struct klist_iter * i) 188static struct device * next_device(struct klist_iter * i)
137{ 189{
138 struct klist_node * n = klist_next(i); 190 struct klist_node * n = klist_next(i);
@@ -177,6 +229,39 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start,
177 return error; 229 return error;
178} 230}
179 231
232/**
233 * bus_find_device - device iterator for locating a particular device.
234 * @bus: bus type
235 * @start: Device to begin with
236 * @data: Data to pass to match function
237 * @match: Callback function to check device
238 *
239 * This is similar to the bus_for_each_dev() function above, but it
240 * returns a reference to a device that is 'found' for later use, as
241 * determined by the @match callback.
242 *
243 * The callback should return 0 if the device doesn't match and non-zero
244 * if it does. If the callback returns non-zero, this function will
245 * return to the caller and not iterate over any more devices.
246 */
247struct device * bus_find_device(struct bus_type *bus,
248 struct device *start, void *data,
249 int (*match)(struct device *, void *))
250{
251 struct klist_iter i;
252 struct device *dev;
253
254 if (!bus)
255 return NULL;
256
257 klist_iter_init_node(&bus->klist_devices, &i,
258 (start ? &start->knode_bus : NULL));
259 while ((dev = next_device(&i)))
260 if (match(dev, data) && get_device(dev))
261 break;
262 klist_iter_exit(&i);
263 return dev;
264}
180 265
181 266
182static struct device_driver * next_driver(struct klist_iter * i) 267static struct device_driver * next_driver(struct klist_iter * i)
@@ -363,6 +448,8 @@ int bus_add_driver(struct device_driver * drv)
363 module_add_driver(drv->owner, drv); 448 module_add_driver(drv->owner, drv);
364 449
365 driver_add_attrs(bus, drv); 450 driver_add_attrs(bus, drv);
451 driver_create_file(drv, &driver_attr_unbind);
452 driver_create_file(drv, &driver_attr_bind);
366 } 453 }
367 return error; 454 return error;
368} 455}
@@ -380,6 +467,8 @@ int bus_add_driver(struct device_driver * drv)
380void bus_remove_driver(struct device_driver * drv) 467void bus_remove_driver(struct device_driver * drv)
381{ 468{
382 if (drv->bus) { 469 if (drv->bus) {
470 driver_remove_file(drv, &driver_attr_bind);
471 driver_remove_file(drv, &driver_attr_unbind);
383 driver_remove_attrs(drv->bus, drv); 472 driver_remove_attrs(drv->bus, drv);
384 klist_remove(&drv->knode_bus); 473 klist_remove(&drv->knode_bus);
385 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); 474 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
@@ -394,31 +483,22 @@ void bus_remove_driver(struct device_driver * drv)
394/* Helper for bus_rescan_devices's iter */ 483/* Helper for bus_rescan_devices's iter */
395static int bus_rescan_devices_helper(struct device *dev, void *data) 484static int bus_rescan_devices_helper(struct device *dev, void *data)
396{ 485{
397 int *count = data; 486 if (!dev->driver)
398 487 device_attach(dev);
399 if (!dev->driver && (device_attach(dev) > 0))
400 (*count)++;
401
402 return 0; 488 return 0;
403} 489}
404 490
405
406/** 491/**
407 * bus_rescan_devices - rescan devices on the bus for possible drivers 492 * bus_rescan_devices - rescan devices on the bus for possible drivers
408 * @bus: the bus to scan. 493 * @bus: the bus to scan.
409 * 494 *
410 * This function will look for devices on the bus with no driver 495 * This function will look for devices on the bus with no driver
411 * attached and rescan it against existing drivers to see if it 496 * attached and rescan it against existing drivers to see if it matches
412 * matches any. Calls device_attach(). Returns the number of devices 497 * any by calling device_attach() for the unbound devices.
413 * that were sucessfully bound to a driver.
414 */ 498 */
415int bus_rescan_devices(struct bus_type * bus) 499void bus_rescan_devices(struct bus_type * bus)
416{ 500{
417 int count = 0; 501 bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper);
418
419 bus_for_each_dev(bus, NULL, &count, bus_rescan_devices_helper);
420
421 return count;
422} 502}
423 503
424 504
@@ -557,6 +637,7 @@ int __init buses_init(void)
557 637
558 638
559EXPORT_SYMBOL_GPL(bus_for_each_dev); 639EXPORT_SYMBOL_GPL(bus_for_each_dev);
640EXPORT_SYMBOL_GPL(bus_find_device);
560EXPORT_SYMBOL_GPL(bus_for_each_drv); 641EXPORT_SYMBOL_GPL(bus_for_each_drv);
561 642
562EXPORT_SYMBOL_GPL(bus_add_device); 643EXPORT_SYMBOL_GPL(bus_add_device);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 86d79755fbfb..efe03a024a5b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -333,7 +333,7 @@ void device_del(struct device * dev)
333 struct device * parent = dev->parent; 333 struct device * parent = dev->parent;
334 334
335 if (parent) 335 if (parent)
336 klist_remove(&dev->knode_parent); 336 klist_del(&dev->knode_parent);
337 337
338 /* Notify the platform of the removal, in case they 338 /* Notify the platform of the removal, in case they
339 * need to do anything... 339 * need to do anything...
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 6db3a789c54f..16323f9cbff0 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -65,7 +65,7 @@ void device_bind_driver(struct device * dev)
65 * 65 *
66 * This function must be called with @dev->sem held. 66 * This function must be called with @dev->sem held.
67 */ 67 */
68static int driver_probe_device(struct device_driver * drv, struct device * dev) 68int driver_probe_device(struct device_driver * drv, struct device * dev)
69{ 69{
70 int ret = 0; 70 int ret = 0;
71 71
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 1b645886e9eb..291c5954a3af 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -56,6 +56,41 @@ EXPORT_SYMBOL_GPL(driver_for_each_device);
56 56
57 57
58/** 58/**
59 * driver_find_device - device iterator for locating a particular device.
60 * @driver: The device's driver
61 * @start: Device to begin with
62 * @data: Data to pass to match function
63 * @match: Callback function to check device
64 *
65 * This is similar to the driver_for_each_device() function above, but
66 * it returns a reference to a device that is 'found' for later use, as
67 * determined by the @match callback.
68 *
69 * The callback should return 0 if the device doesn't match and non-zero
70 * if it does. If the callback returns non-zero, this function will
71 * return to the caller and not iterate over any more devices.
72 */
73struct device * driver_find_device(struct device_driver *drv,
74 struct device * start, void * data,
75 int (*match)(struct device *, void *))
76{
77 struct klist_iter i;
78 struct device *dev;
79
80 if (!drv)
81 return NULL;
82
83 klist_iter_init_node(&drv->klist_devices, &i,
84 (start ? &start->knode_driver : NULL));
85 while ((dev = next_device(&i)))
86 if (match(dev, data) && get_device(dev))
87 break;
88 klist_iter_exit(&i);
89 return dev;
90}
91EXPORT_SYMBOL_GPL(driver_find_device);
92
93/**
59 * driver_create_file - create sysfs file for driver. 94 * driver_create_file - create sysfs file for driver.
60 * @drv: driver. 95 * @drv: driver.
61 * @attr: driver attribute descriptor. 96 * @attr: driver attribute descriptor.
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index f37a13de804a..214b96435409 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -22,7 +22,6 @@
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/pm.h> 23#include <linux/pm.h>
24 24
25
26extern struct subsystem devices_subsys; 25extern struct subsystem devices_subsys;
27 26
28#define to_sysdev(k) container_of(k, struct sys_device, kobj) 27#define to_sysdev(k) container_of(k, struct sys_device, kobj)
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 5ef9adb9fe73..bd2ec7e284cc 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -40,7 +40,6 @@
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <asm/io.h> 41#include <asm/io.h>
42 42
43#include <pcmcia/version.h>
44#include <pcmcia/cs_types.h> 43#include <pcmcia/cs_types.h>
45#include <pcmcia/cs.h> 44#include <pcmcia/cs.h>
46#include <pcmcia/cistpl.h> 45#include <pcmcia/cistpl.h>
@@ -895,11 +894,6 @@ static dev_link_t *bluecard_attach(void)
895 link->next = dev_list; 894 link->next = dev_list;
896 dev_list = link; 895 dev_list = link;
897 client_reg.dev_info = &dev_info; 896 client_reg.dev_info = &dev_info;
898 client_reg.EventMask =
899 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
900 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
901 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
902 client_reg.event_handler = &bluecard_event;
903 client_reg.Version = 0x0210; 897 client_reg.Version = 0x0210;
904 client_reg.event_callback_args.client_data = link; 898 client_reg.event_callback_args.client_data = link;
905 899
@@ -1103,6 +1097,7 @@ static struct pcmcia_driver bluecard_driver = {
1103 .name = "bluecard_cs", 1097 .name = "bluecard_cs",
1104 }, 1098 },
1105 .attach = bluecard_attach, 1099 .attach = bluecard_attach,
1100 .event = bluecard_event,
1106 .detach = bluecard_detach, 1101 .detach = bluecard_detach,
1107 .id_table = bluecard_ids, 1102 .id_table = bluecard_ids,
1108}; 1103};
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 9013cd759afb..adf1750ea58d 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -47,7 +47,6 @@
47#include <linux/device.h> 47#include <linux/device.h>
48#include <linux/firmware.h> 48#include <linux/firmware.h>
49 49
50#include <pcmcia/version.h>
51#include <pcmcia/cs_types.h> 50#include <pcmcia/cs_types.h>
52#include <pcmcia/cs.h> 51#include <pcmcia/cs.h>
53#include <pcmcia/cistpl.h> 52#include <pcmcia/cistpl.h>
@@ -696,11 +695,6 @@ static dev_link_t *bt3c_attach(void)
696 link->next = dev_list; 695 link->next = dev_list;
697 dev_list = link; 696 dev_list = link;
698 client_reg.dev_info = &dev_info; 697 client_reg.dev_info = &dev_info;
699 client_reg.EventMask =
700 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
701 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
702 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
703 client_reg.event_handler = &bt3c_event;
704 client_reg.Version = 0x0210; 698 client_reg.Version = 0x0210;
705 client_reg.event_callback_args.client_data = link; 699 client_reg.event_callback_args.client_data = link;
706 700
@@ -947,6 +941,7 @@ static struct pcmcia_driver bt3c_driver = {
947 .name = "bt3c_cs", 941 .name = "bt3c_cs",
948 }, 942 },
949 .attach = bt3c_attach, 943 .attach = bt3c_attach,
944 .event = bt3c_event,
950 .detach = bt3c_detach, 945 .detach = bt3c_detach,
951 .id_table = bt3c_ids, 946 .id_table = bt3c_ids,
952}; 947};
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index c479484a1f7f..e4c59fdc0e12 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -43,7 +43,6 @@
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/io.h> 44#include <asm/io.h>
45 45
46#include <pcmcia/version.h>
47#include <pcmcia/cs_types.h> 46#include <pcmcia/cs_types.h>
48#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
@@ -615,11 +614,6 @@ static dev_link_t *btuart_attach(void)
615 link->next = dev_list; 614 link->next = dev_list;
616 dev_list = link; 615 dev_list = link;
617 client_reg.dev_info = &dev_info; 616 client_reg.dev_info = &dev_info;
618 client_reg.EventMask =
619 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
620 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
621 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
622 client_reg.event_handler = &btuart_event;
623 client_reg.Version = 0x0210; 617 client_reg.Version = 0x0210;
624 client_reg.event_callback_args.client_data = link; 618 client_reg.event_callback_args.client_data = link;
625 619
@@ -867,6 +861,7 @@ static struct pcmcia_driver btuart_driver = {
867 .name = "btuart_cs", 861 .name = "btuart_cs",
868 }, 862 },
869 .attach = btuart_attach, 863 .attach = btuart_attach,
864 .event = btuart_event,
870 .detach = btuart_detach, 865 .detach = btuart_detach,
871 .id_table = btuart_ids, 866 .id_table = btuart_ids,
872}; 867};
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index bb12f7daeb91..e39868c3da48 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -43,7 +43,6 @@
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/io.h> 44#include <asm/io.h>
45 45
46#include <pcmcia/version.h>
47#include <pcmcia/cs_types.h> 46#include <pcmcia/cs_types.h>
48#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
@@ -594,11 +593,6 @@ static dev_link_t *dtl1_attach(void)
594 link->next = dev_list; 593 link->next = dev_list;
595 dev_list = link; 594 dev_list = link;
596 client_reg.dev_info = &dev_info; 595 client_reg.dev_info = &dev_info;
597 client_reg.EventMask =
598 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
599 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
600 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
601 client_reg.event_handler = &dtl1_event;
602 client_reg.Version = 0x0210; 596 client_reg.Version = 0x0210;
603 client_reg.event_callback_args.client_data = link; 597 client_reg.event_callback_args.client_data = link;
604 598
@@ -820,6 +814,7 @@ static struct pcmcia_driver dtl1_driver = {
820 .name = "dtl1_cs", 814 .name = "dtl1_cs",
821 }, 815 },
822 .attach = dtl1_attach, 816 .attach = dtl1_attach,
817 .event = dtl1_event,
823 .detach = dtl1_detach, 818 .detach = dtl1_detach,
824 .id_table = dtl1_ids, 819 .id_table = dtl1_ids,
825}; 820};
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 3256192dcde8..f9b956fb2b8b 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -120,7 +120,7 @@ static unsigned int hci_vhci_chr_poll(struct file *file, poll_table * wait)
120 120
121 poll_wait(file, &hci_vhci->read_wait, wait); 121 poll_wait(file, &hci_vhci->read_wait, wait);
122 122
123 if (skb_queue_len(&hci_vhci->readq)) 123 if (!skb_queue_empty(&hci_vhci->readq))
124 return POLLIN | POLLRDNORM; 124 return POLLIN | POLLRDNORM;
125 125
126 return POLLOUT | POLLWRNORM; 126 return POLLOUT | POLLWRNORM;
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 1aff819f3832..08f69287ea36 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -40,7 +40,7 @@ obj-$(CONFIG_N_HDLC) += n_hdlc.o
40obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o 40obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
41obj-$(CONFIG_SX) += sx.o generic_serial.o 41obj-$(CONFIG_SX) += sx.o generic_serial.o
42obj-$(CONFIG_RIO) += rio/ generic_serial.o 42obj-$(CONFIG_RIO) += rio/ generic_serial.o
43obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o hvsi.o 43obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o hvc_vio.o hvsi.o
44obj-$(CONFIG_RAW_DRIVER) += raw.o 44obj-$(CONFIG_RAW_DRIVER) += raw.o
45obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o 45obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
46obj-$(CONFIG_MMTIMER) += mmtimer.o 46obj-$(CONFIG_MMTIMER) += mmtimer.o
diff --git a/drivers/char/drm/Kconfig b/drivers/char/drm/Kconfig
index c2b12eab67c9..123417e43040 100644
--- a/drivers/char/drm/Kconfig
+++ b/drivers/char/drm/Kconfig
@@ -96,3 +96,10 @@ config DRM_SIS
96 chipset. If M is selected the module will be called sis. AGP 96 chipset. If M is selected the module will be called sis. AGP
97 support is required for this driver to work. 97 support is required for this driver to work.
98 98
99config DRM_VIA
100 tristate "Via unichrome video cards"
101 depends on DRM
102 help
103 Choose this option if you have a Via unichrome or compatible video
104 chipset. If M is selected the module will be called via.
105
diff --git a/drivers/char/drm/Makefile b/drivers/char/drm/Makefile
index 7444dec40b94..ddd941045b1f 100644
--- a/drivers/char/drm/Makefile
+++ b/drivers/char/drm/Makefile
@@ -18,10 +18,14 @@ i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o
18radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o 18radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o
19ffb-objs := ffb_drv.o ffb_context.o 19ffb-objs := ffb_drv.o ffb_context.o
20sis-objs := sis_drv.o sis_ds.o sis_mm.o 20sis-objs := sis_drv.o sis_ds.o sis_mm.o
21via-objs := via_irq.o via_drv.o via_ds.o via_map.o via_mm.o via_dma.o via_verifier.o via_video.o
21 22
22ifeq ($(CONFIG_COMPAT),y) 23ifeq ($(CONFIG_COMPAT),y)
23drm-objs += drm_ioc32.o 24drm-objs += drm_ioc32.o
24radeon-objs += radeon_ioc32.o 25radeon-objs += radeon_ioc32.o
26mga-objs += mga_ioc32.o
27r128-objs += r128_ioc32.o
28i915-objs += i915_ioc32.o
25endif 29endif
26 30
27obj-$(CONFIG_DRM) += drm.o 31obj-$(CONFIG_DRM) += drm.o
@@ -35,4 +39,5 @@ obj-$(CONFIG_DRM_I830) += i830.o
35obj-$(CONFIG_DRM_I915) += i915.o 39obj-$(CONFIG_DRM_I915) += i915.o
36obj-$(CONFIG_DRM_FFB) += ffb.o 40obj-$(CONFIG_DRM_FFB) += ffb.o
37obj-$(CONFIG_DRM_SIS) += sis.o 41obj-$(CONFIG_DRM_SIS) += sis.o
42obj-$(CONFIG_DRM_VIA) +=via.o
38 43
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index fdca1876ecd5..0aec5ef481b8 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -52,7 +52,7 @@
52# define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */ 52# define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */
53# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ 53# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */
54 54
55unsigned long drm_ati_alloc_pcigart_table( void ) 55static unsigned long drm_ati_alloc_pcigart_table( void )
56{ 56{
57 unsigned long address; 57 unsigned long address;
58 struct page *page; 58 struct page *page;
diff --git a/drivers/char/drm/drm.h b/drivers/char/drm/drm.h
index 587305282ea8..e8371dd87fbc 100644
--- a/drivers/char/drm/drm.h
+++ b/drivers/char/drm/drm.h
@@ -38,7 +38,9 @@
38#define _DRM_H_ 38#define _DRM_H_
39 39
40#if defined(__linux__) 40#if defined(__linux__)
41#if defined(__KERNEL__)
41#include <linux/config.h> 42#include <linux/config.h>
43#endif
42#include <asm/ioctl.h> /* For _IO* macros */ 44#include <asm/ioctl.h> /* For _IO* macros */
43#define DRM_IOCTL_NR(n) _IOC_NR(n) 45#define DRM_IOCTL_NR(n) _IOC_NR(n)
44#define DRM_IOC_VOID _IOC_NONE 46#define DRM_IOC_VOID _IOC_NONE
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index b04ddf12a0ff..5df09cc8c6db 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -774,8 +774,6 @@ extern int drm_cpu_valid( void );
774 /* Driver support (drm_drv.h) */ 774 /* Driver support (drm_drv.h) */
775extern int drm_init(struct drm_driver *driver); 775extern int drm_init(struct drm_driver *driver);
776extern void drm_exit(struct drm_driver *driver); 776extern void drm_exit(struct drm_driver *driver);
777extern int drm_version(struct inode *inode, struct file *filp,
778 unsigned int cmd, unsigned long arg);
779extern int drm_ioctl(struct inode *inode, struct file *filp, 777extern int drm_ioctl(struct inode *inode, struct file *filp,
780 unsigned int cmd, unsigned long arg); 778 unsigned int cmd, unsigned long arg);
781extern long drm_compat_ioctl(struct file *filp, 779extern long drm_compat_ioctl(struct file *filp,
@@ -785,28 +783,19 @@ extern int drm_takedown(drm_device_t * dev);
785 /* Device support (drm_fops.h) */ 783 /* Device support (drm_fops.h) */
786extern int drm_open(struct inode *inode, struct file *filp); 784extern int drm_open(struct inode *inode, struct file *filp);
787extern int drm_stub_open(struct inode *inode, struct file *filp); 785extern int drm_stub_open(struct inode *inode, struct file *filp);
788extern int drm_open_helper(struct inode *inode, struct file *filp,
789 drm_device_t *dev);
790extern int drm_flush(struct file *filp); 786extern int drm_flush(struct file *filp);
791extern int drm_fasync(int fd, struct file *filp, int on); 787extern int drm_fasync(int fd, struct file *filp, int on);
792extern int drm_release(struct inode *inode, struct file *filp); 788extern int drm_release(struct inode *inode, struct file *filp);
793 789
794 /* Mapping support (drm_vm.h) */ 790 /* Mapping support (drm_vm.h) */
795extern void drm_vm_open(struct vm_area_struct *vma);
796extern void drm_vm_close(struct vm_area_struct *vma);
797extern void drm_vm_shm_close(struct vm_area_struct *vma);
798extern int drm_mmap_dma(struct file *filp,
799 struct vm_area_struct *vma);
800extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); 791extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
801extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); 792extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
802extern ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off);
803 793
804 /* Memory management support (drm_memory.h) */ 794 /* Memory management support (drm_memory.h) */
805#include "drm_memory.h" 795#include "drm_memory.h"
806extern void drm_mem_init(void); 796extern void drm_mem_init(void);
807extern int drm_mem_info(char *buf, char **start, off_t offset, 797extern int drm_mem_info(char *buf, char **start, off_t offset,
808 int request, int *eof, void *data); 798 int request, int *eof, void *data);
809extern void *drm_calloc(size_t nmemb, size_t size, int area);
810extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, 799extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size,
811 int area); 800 int area);
812extern unsigned long drm_alloc_pages(int order, int area); 801extern unsigned long drm_alloc_pages(int order, int area);
@@ -854,9 +843,6 @@ extern int drm_newctx( struct inode *inode, struct file *filp,
854extern int drm_rmctx( struct inode *inode, struct file *filp, 843extern int drm_rmctx( struct inode *inode, struct file *filp,
855 unsigned int cmd, unsigned long arg ); 844 unsigned int cmd, unsigned long arg );
856 845
857extern int drm_context_switch(drm_device_t *dev, int old, int new);
858extern int drm_context_switch_complete(drm_device_t *dev, int new);
859
860extern int drm_ctxbitmap_init( drm_device_t *dev ); 846extern int drm_ctxbitmap_init( drm_device_t *dev );
861extern void drm_ctxbitmap_cleanup( drm_device_t *dev ); 847extern void drm_ctxbitmap_cleanup( drm_device_t *dev );
862extern void drm_ctxbitmap_free( drm_device_t *dev, int ctx_handle ); 848extern void drm_ctxbitmap_free( drm_device_t *dev, int ctx_handle );
@@ -874,9 +860,6 @@ extern int drm_rmdraw(struct inode *inode, struct file *filp,
874 860
875 861
876 /* Authentication IOCTL support (drm_auth.h) */ 862 /* Authentication IOCTL support (drm_auth.h) */
877extern int drm_add_magic(drm_device_t *dev, drm_file_t *priv,
878 drm_magic_t magic);
879extern int drm_remove_magic(drm_device_t *dev, drm_magic_t magic);
880extern int drm_getmagic(struct inode *inode, struct file *filp, 863extern int drm_getmagic(struct inode *inode, struct file *filp,
881 unsigned int cmd, unsigned long arg); 864 unsigned int cmd, unsigned long arg);
882extern int drm_authmagic(struct inode *inode, struct file *filp, 865extern int drm_authmagic(struct inode *inode, struct file *filp,
@@ -893,13 +876,9 @@ extern int drm_unlock(struct inode *inode, struct file *filp,
893 unsigned int cmd, unsigned long arg); 876 unsigned int cmd, unsigned long arg);
894extern int drm_lock_take(__volatile__ unsigned int *lock, 877extern int drm_lock_take(__volatile__ unsigned int *lock,
895 unsigned int context); 878 unsigned int context);
896extern int drm_lock_transfer(drm_device_t *dev,
897 __volatile__ unsigned int *lock,
898 unsigned int context);
899extern int drm_lock_free(drm_device_t *dev, 879extern int drm_lock_free(drm_device_t *dev,
900 __volatile__ unsigned int *lock, 880 __volatile__ unsigned int *lock,
901 unsigned int context); 881 unsigned int context);
902extern int drm_notifier(void *priv);
903 882
904 /* Buffer management support (drm_bufs.h) */ 883 /* Buffer management support (drm_bufs.h) */
905extern int drm_order( unsigned long size ); 884extern int drm_order( unsigned long size );
@@ -927,7 +906,6 @@ extern void drm_core_reclaim_buffers(drm_device_t *dev, struct file *filp);
927 /* IRQ support (drm_irq.h) */ 906 /* IRQ support (drm_irq.h) */
928extern int drm_control( struct inode *inode, struct file *filp, 907extern int drm_control( struct inode *inode, struct file *filp,
929 unsigned int cmd, unsigned long arg ); 908 unsigned int cmd, unsigned long arg );
930extern int drm_irq_install( drm_device_t *dev );
931extern int drm_irq_uninstall( drm_device_t *dev ); 909extern int drm_irq_uninstall( drm_device_t *dev );
932extern irqreturn_t drm_irq_handler( DRM_IRQ_ARGS ); 910extern irqreturn_t drm_irq_handler( DRM_IRQ_ARGS );
933extern void drm_driver_irq_preinstall( drm_device_t *dev ); 911extern void drm_driver_irq_preinstall( drm_device_t *dev );
@@ -967,7 +945,6 @@ extern int drm_agp_unbind_memory(DRM_AGP_MEM *handle);
967extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, 945extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
968 struct drm_driver *driver); 946 struct drm_driver *driver);
969extern int drm_put_dev(drm_device_t * dev); 947extern int drm_put_dev(drm_device_t * dev);
970extern int drm_get_head(drm_device_t * dev, drm_head_t *head);
971extern int drm_put_head(drm_head_t * head); 948extern int drm_put_head(drm_head_t * head);
972extern unsigned int drm_debug; 949extern unsigned int drm_debug;
973extern unsigned int drm_cards_limit; 950extern unsigned int drm_cards_limit;
@@ -1064,9 +1041,16 @@ static __inline__ void drm_free(void *pt, size_t size, int area)
1064{ 1041{
1065 kfree(pt); 1042 kfree(pt);
1066} 1043}
1044
1045/** Wrapper around kcalloc() */
1046static __inline__ void *drm_calloc(size_t nmemb, size_t size, int area)
1047{
1048 return kcalloc(nmemb, size, GFP_KERNEL);
1049}
1067#else 1050#else
1068extern void *drm_alloc(size_t size, int area); 1051extern void *drm_alloc(size_t size, int area);
1069extern void drm_free(void *pt, size_t size, int area); 1052extern void drm_free(void *pt, size_t size, int area);
1053extern void *drm_calloc(size_t nmemb, size_t size, int area);
1070#endif 1054#endif
1071 1055
1072/*@}*/ 1056/*@}*/
diff --git a/drivers/char/drm/drm_auth.c b/drivers/char/drm/drm_auth.c
index b428761c4e91..dd140bca8f71 100644
--- a/drivers/char/drm/drm_auth.c
+++ b/drivers/char/drm/drm_auth.c
@@ -87,7 +87,7 @@ static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic)
87 * associated the magic number hash key in drm_device::magiclist, while holding 87 * associated the magic number hash key in drm_device::magiclist, while holding
88 * the drm_device::struct_sem lock. 88 * the drm_device::struct_sem lock.
89 */ 89 */
90int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) 90static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
91{ 91{
92 int hash; 92 int hash;
93 drm_magic_entry_t *entry; 93 drm_magic_entry_t *entry;
@@ -124,7 +124,7 @@ int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
124 * Searches and unlinks the entry in drm_device::magiclist with the magic 124 * Searches and unlinks the entry in drm_device::magiclist with the magic
125 * number hash key, while holding the drm_device::struct_sem lock. 125 * number hash key, while holding the drm_device::struct_sem lock.
126 */ 126 */
127int drm_remove_magic(drm_device_t *dev, drm_magic_t magic) 127static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic)
128{ 128{
129 drm_magic_entry_t *prev = NULL; 129 drm_magic_entry_t *prev = NULL;
130 drm_magic_entry_t *pt; 130 drm_magic_entry_t *pt;
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 3407380b865a..4c6191d231b8 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -356,8 +356,8 @@ static void drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry)
356 * reallocates the buffer list of the same size order to accommodate the new 356 * reallocates the buffer list of the same size order to accommodate the new
357 * buffers. 357 * buffers.
358 */ 358 */
359int drm_addbufs_agp( struct inode *inode, struct file *filp, 359static int drm_addbufs_agp( struct inode *inode, struct file *filp,
360 unsigned int cmd, unsigned long arg ) 360 unsigned int cmd, unsigned long arg )
361{ 361{
362 drm_file_t *priv = filp->private_data; 362 drm_file_t *priv = filp->private_data;
363 drm_device_t *dev = priv->head->dev; 363 drm_device_t *dev = priv->head->dev;
@@ -521,8 +521,8 @@ int drm_addbufs_agp( struct inode *inode, struct file *filp,
521} 521}
522#endif /* __OS_HAS_AGP */ 522#endif /* __OS_HAS_AGP */
523 523
524int drm_addbufs_pci( struct inode *inode, struct file *filp, 524static int drm_addbufs_pci( struct inode *inode, struct file *filp,
525 unsigned int cmd, unsigned long arg ) 525 unsigned int cmd, unsigned long arg )
526{ 526{
527 drm_file_t *priv = filp->private_data; 527 drm_file_t *priv = filp->private_data;
528 drm_device_t *dev = priv->head->dev; 528 drm_device_t *dev = priv->head->dev;
@@ -751,8 +751,8 @@ int drm_addbufs_pci( struct inode *inode, struct file *filp,
751 751
752} 752}
753 753
754int drm_addbufs_sg( struct inode *inode, struct file *filp, 754static int drm_addbufs_sg( struct inode *inode, struct file *filp,
755 unsigned int cmd, unsigned long arg ) 755 unsigned int cmd, unsigned long arg )
756{ 756{
757 drm_file_t *priv = filp->private_data; 757 drm_file_t *priv = filp->private_data;
758 drm_device_t *dev = priv->head->dev; 758 drm_device_t *dev = priv->head->dev;
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index fdf661f234ed..a7cfabd1ca2e 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -84,7 +84,7 @@ failed:
84 * drm_device::context_sareas to accommodate the new entry while holding the 84 * drm_device::context_sareas to accommodate the new entry while holding the
85 * drm_device::struct_sem lock. 85 * drm_device::struct_sem lock.
86 */ 86 */
87int drm_ctxbitmap_next( drm_device_t *dev ) 87static int drm_ctxbitmap_next( drm_device_t *dev )
88{ 88{
89 int bit; 89 int bit;
90 90
@@ -326,7 +326,7 @@ int drm_context_switch( drm_device_t *dev, int old, int new )
326 * hardware lock is held, clears the drm_device::context_flag and wakes up 326 * hardware lock is held, clears the drm_device::context_flag and wakes up
327 * drm_device::context_wait. 327 * drm_device::context_wait.
328 */ 328 */
329int drm_context_switch_complete( drm_device_t *dev, int new ) 329static int drm_context_switch_complete( drm_device_t *dev, int new )
330{ 330{
331 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ 331 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
332 dev->last_switch = jiffies; 332 dev->last_switch = jiffies;
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index 1e37ed0c6b8d..3333c250c4d9 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -51,8 +51,11 @@
51#include "drmP.h" 51#include "drmP.h"
52#include "drm_core.h" 52#include "drm_core.h"
53 53
54static int drm_version(struct inode *inode, struct file *filp,
55 unsigned int cmd, unsigned long arg);
56
54/** Ioctl table */ 57/** Ioctl table */
55drm_ioctl_desc_t drm_ioctls[] = { 58static drm_ioctl_desc_t drm_ioctls[] = {
56 [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { drm_version, 0, 0 }, 59 [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { drm_version, 0, 0 },
57 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 }, 60 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 },
58 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 }, 61 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 },
@@ -447,8 +450,8 @@ module_exit( drm_core_exit );
447 * 450 *
448 * Fills in the version information in \p arg. 451 * Fills in the version information in \p arg.
449 */ 452 */
450int drm_version( struct inode *inode, struct file *filp, 453static int drm_version( struct inode *inode, struct file *filp,
451 unsigned int cmd, unsigned long arg ) 454 unsigned int cmd, unsigned long arg )
452{ 455{
453 drm_file_t *priv = filp->private_data; 456 drm_file_t *priv = filp->private_data;
454 drm_device_t *dev = priv->head->dev; 457 drm_device_t *dev = priv->head->dev;
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 906794247aeb..10e64fde8d78 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -37,6 +37,8 @@
37#include "drmP.h" 37#include "drmP.h"
38#include <linux/poll.h> 38#include <linux/poll.h>
39 39
40static int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t *dev);
41
40static int drm_setup( drm_device_t *dev ) 42static int drm_setup( drm_device_t *dev )
41{ 43{
42 int i; 44 int i;
@@ -251,7 +253,7 @@ int drm_release( struct inode *inode, struct file *filp )
251 } 253 }
252 } 254 }
253 255
254 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) 256 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) && !dev->driver->release)
255 { 257 {
256 dev->driver->reclaim_buffers(dev, filp); 258 dev->driver->reclaim_buffers(dev, filp);
257 } 259 }
@@ -259,7 +261,7 @@ int drm_release( struct inode *inode, struct file *filp )
259 drm_fasync( -1, filp, 0 ); 261 drm_fasync( -1, filp, 0 );
260 262
261 down( &dev->ctxlist_sem ); 263 down( &dev->ctxlist_sem );
262 if ( !list_empty( &dev->ctxlist->head ) ) { 264 if ( dev->ctxlist && (!list_empty(&dev->ctxlist->head))) {
263 drm_ctx_list_t *pos, *n; 265 drm_ctx_list_t *pos, *n;
264 266
265 list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) { 267 list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) {
@@ -341,7 +343,7 @@ EXPORT_SYMBOL(drm_release);
341 * Creates and initializes a drm_file structure for the file private data in \p 343 * Creates and initializes a drm_file structure for the file private data in \p
342 * filp and add it into the double linked list in \p dev. 344 * filp and add it into the double linked list in \p dev.
343 */ 345 */
344int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t *dev) 346static int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t *dev)
345{ 347{
346 int minor = iminor(inode); 348 int minor = iminor(inode);
347 drm_file_t *priv; 349 drm_file_t *priv;
@@ -443,9 +445,3 @@ unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait)
443} 445}
444EXPORT_SYMBOL(drm_poll); 446EXPORT_SYMBOL(drm_poll);
445 447
446
447/** No-op. */
448ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off)
449{
450 return 0;
451}
diff --git a/drivers/char/drm/drm_irq.c b/drivers/char/drm/drm_irq.c
index 2e236ebcf27b..cdd4aecd25e2 100644
--- a/drivers/char/drm/drm_irq.c
+++ b/drivers/char/drm/drm_irq.c
@@ -89,7 +89,7 @@ int drm_irq_by_busid(struct inode *inode, struct file *filp,
89 * \c drm_driver_irq_preinstall() and \c drm_driver_irq_postinstall() functions 89 * \c drm_driver_irq_preinstall() and \c drm_driver_irq_postinstall() functions
90 * before and after the installation. 90 * before and after the installation.
91 */ 91 */
92int drm_irq_install( drm_device_t *dev ) 92static int drm_irq_install( drm_device_t *dev )
93{ 93{
94 int ret; 94 int ret;
95 unsigned long sh_flags=0; 95 unsigned long sh_flags=0;
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c
index d0d6fc661625..4702d863bcc6 100644
--- a/drivers/char/drm/drm_lock.c
+++ b/drivers/char/drm/drm_lock.c
@@ -35,6 +35,11 @@
35 35
36#include "drmP.h" 36#include "drmP.h"
37 37
38static int drm_lock_transfer(drm_device_t *dev,
39 __volatile__ unsigned int *lock,
40 unsigned int context);
41static int drm_notifier(void *priv);
42
38/** 43/**
39 * Lock ioctl. 44 * Lock ioctl.
40 * 45 *
@@ -225,8 +230,9 @@ int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context)
225 * Resets the lock file pointer. 230 * Resets the lock file pointer.
226 * Marks the lock as held by the given context, via the \p cmpxchg instruction. 231 * Marks the lock as held by the given context, via the \p cmpxchg instruction.
227 */ 232 */
228int drm_lock_transfer(drm_device_t *dev, 233static int drm_lock_transfer(drm_device_t *dev,
229 __volatile__ unsigned int *lock, unsigned int context) 234 __volatile__ unsigned int *lock,
235 unsigned int context)
230{ 236{
231 unsigned int old, new, prev; 237 unsigned int old, new, prev;
232 238
@@ -282,7 +288,7 @@ int drm_lock_free(drm_device_t *dev,
282 * \return one if the signal should be delivered normally, or zero if the 288 * \return one if the signal should be delivered normally, or zero if the
283 * signal should be blocked. 289 * signal should be blocked.
284 */ 290 */
285int drm_notifier(void *priv) 291static int drm_notifier(void *priv)
286{ 292{
287 drm_sigdata_t *s = (drm_sigdata_t *)priv; 293 drm_sigdata_t *s = (drm_sigdata_t *)priv;
288 unsigned int old, new, prev; 294 unsigned int old, new, prev;
diff --git a/drivers/char/drm/drm_memory.c b/drivers/char/drm/drm_memory.c
index 7f53f756c052..ace3d42f4407 100644
--- a/drivers/char/drm/drm_memory.c
+++ b/drivers/char/drm/drm_memory.c
@@ -65,19 +65,6 @@ int drm_mem_info(char *buf, char **start, off_t offset,
65 return 0; 65 return 0;
66} 66}
67 67
68/** Wrapper around kmalloc() */
69void *drm_calloc(size_t nmemb, size_t size, int area)
70{
71 void *addr;
72
73 addr = kmalloc(size * nmemb, GFP_KERNEL);
74 if (addr != NULL)
75 memset((void *)addr, 0, size * nmemb);
76
77 return addr;
78}
79EXPORT_SYMBOL(drm_calloc);
80
81/** Wrapper around kmalloc() and kfree() */ 68/** Wrapper around kmalloc() and kfree() */
82void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) 69void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
83{ 70{
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index 11c6950158b3..70ca4fa55c9d 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -223,3 +223,10 @@
223 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 223 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
224 {0, 0, 0} 224 {0, 0, 0}
225 225
226#define viadrv_PCI_IDS \
227 {0x1106, 0x3022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
228 {0x1106, 0x3122, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
229 {0x1106, 0x7205, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
230 {0x1106, 0x7204, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
231 {0, 0, 0}
232
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c
index 6e06e8c6a516..4774087d2e9e 100644
--- a/drivers/char/drm/drm_proc.c
+++ b/drivers/char/drm/drm_proc.c
@@ -57,7 +57,7 @@ static int drm_vma_info(char *buf, char **start, off_t offset,
57/** 57/**
58 * Proc file list. 58 * Proc file list.
59 */ 59 */
60struct drm_proc_list { 60static struct drm_proc_list {
61 const char *name; /**< file name */ 61 const char *name; /**< file name */
62 int (*f)(char *, char **, off_t, int, int *, void *); /**< proc callback*/ 62 int (*f)(char *, char **, off_t, int, int *, void *); /**< proc callback*/
63} drm_proc_list[] = { 63} drm_proc_list[] = {
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
index 8ccbdef7bb3e..48829a1a086a 100644
--- a/drivers/char/drm/drm_stub.c
+++ b/drivers/char/drm/drm_stub.c
@@ -157,52 +157,6 @@ int drm_stub_open(struct inode *inode, struct file *filp)
157 return err; 157 return err;
158} 158}
159 159
160
161/**
162 * Register.
163 *
164 * \param pdev - PCI device structure
165 * \param ent entry from the PCI ID table with device type flags
166 * \return zero on success or a negative number on failure.
167 *
168 * Attempt to gets inter module "drm" information. If we are first
169 * then register the character device and inter module information.
170 * Try and register, if we fail to register, backout previous work.
171 */
172int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
173 struct drm_driver *driver)
174{
175 drm_device_t *dev;
176 int ret;
177
178 DRM_DEBUG("\n");
179
180 dev = drm_calloc(1, sizeof(*dev), DRM_MEM_STUB);
181 if (!dev)
182 return -ENOMEM;
183
184 pci_enable_device(pdev);
185
186 if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
187 printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
188 goto err_g1;
189 }
190 if ((ret = drm_get_head(dev, &dev->primary)))
191 goto err_g1;
192
193 /* postinit is a required function to display the signon banner */
194 /* drivers add secondary heads here if needed */
195 if ((ret = dev->driver->postinit(dev, ent->driver_data)))
196 goto err_g1;
197
198 return 0;
199
200err_g1:
201 drm_free(dev, sizeof(*dev), DRM_MEM_STUB);
202 return ret;
203}
204EXPORT_SYMBOL(drm_get_dev);
205
206/** 160/**
207 * Get a secondary minor number. 161 * Get a secondary minor number.
208 * 162 *
@@ -214,7 +168,7 @@ EXPORT_SYMBOL(drm_get_dev);
214 * create the proc init entry via proc_init(). This routines assigns 168 * create the proc init entry via proc_init(). This routines assigns
215 * minor numbers to secondary heads of multi-headed cards 169 * minor numbers to secondary heads of multi-headed cards
216 */ 170 */
217int drm_get_head(drm_device_t *dev, drm_head_t *head) 171static int drm_get_head(drm_device_t *dev, drm_head_t *head)
218{ 172{
219 drm_head_t **heads = drm_heads; 173 drm_head_t **heads = drm_heads;
220 int ret; 174 int ret;
@@ -262,6 +216,50 @@ err_g1:
262 return ret; 216 return ret;
263} 217}
264 218
219/**
220 * Register.
221 *
222 * \param pdev - PCI device structure
223 * \param ent entry from the PCI ID table with device type flags
224 * \return zero on success or a negative number on failure.
225 *
226 * Attempt to gets inter module "drm" information. If we are first
227 * then register the character device and inter module information.
228 * Try and register, if we fail to register, backout previous work.
229 */
230int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
231 struct drm_driver *driver)
232{
233 drm_device_t *dev;
234 int ret;
235
236 DRM_DEBUG("\n");
237
238 dev = drm_calloc(1, sizeof(*dev), DRM_MEM_STUB);
239 if (!dev)
240 return -ENOMEM;
241
242 pci_enable_device(pdev);
243
244 if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
245 printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
246 goto err_g1;
247 }
248 if ((ret = drm_get_head(dev, &dev->primary)))
249 goto err_g1;
250
251 /* postinit is a required function to display the signon banner */
252 /* drivers add secondary heads here if needed */
253 if ((ret = dev->driver->postinit(dev, ent->driver_data)))
254 goto err_g1;
255
256 return 0;
257
258err_g1:
259 drm_free(dev, sizeof(*dev), DRM_MEM_STUB);
260 return ret;
261}
262EXPORT_SYMBOL(drm_get_dev);
265 263
266/** 264/**
267 * Put a device minor number. 265 * Put a device minor number.
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index fc72f30f312b..621220f3f372 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -38,6 +38,8 @@
38#include <linux/efi.h> 38#include <linux/efi.h>
39#endif 39#endif
40 40
41static void drm_vm_open(struct vm_area_struct *vma);
42static void drm_vm_close(struct vm_area_struct *vma);
41 43
42/** 44/**
43 * \c nopage method for AGP virtual memory. 45 * \c nopage method for AGP virtual memory.
@@ -163,7 +165,7 @@ static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
163 * Deletes map information if we are the last 165 * Deletes map information if we are the last
164 * person to close a mapping and it's not in the global maplist. 166 * person to close a mapping and it's not in the global maplist.
165 */ 167 */
166void drm_vm_shm_close(struct vm_area_struct *vma) 168static void drm_vm_shm_close(struct vm_area_struct *vma)
167{ 169{
168 drm_file_t *priv = vma->vm_file->private_data; 170 drm_file_t *priv = vma->vm_file->private_data;
169 drm_device_t *dev = priv->head->dev; 171 drm_device_t *dev = priv->head->dev;
@@ -399,7 +401,7 @@ static struct vm_operations_struct drm_vm_sg_ops = {
399 * Create a new drm_vma_entry structure as the \p vma private data entry and 401 * Create a new drm_vma_entry structure as the \p vma private data entry and
400 * add it to drm_device::vmalist. 402 * add it to drm_device::vmalist.
401 */ 403 */
402void drm_vm_open(struct vm_area_struct *vma) 404static void drm_vm_open(struct vm_area_struct *vma)
403{ 405{
404 drm_file_t *priv = vma->vm_file->private_data; 406 drm_file_t *priv = vma->vm_file->private_data;
405 drm_device_t *dev = priv->head->dev; 407 drm_device_t *dev = priv->head->dev;
@@ -428,7 +430,7 @@ void drm_vm_open(struct vm_area_struct *vma)
428 * Search the \p vma private data entry in drm_device::vmalist, unlink it, and 430 * Search the \p vma private data entry in drm_device::vmalist, unlink it, and
429 * free it. 431 * free it.
430 */ 432 */
431void drm_vm_close(struct vm_area_struct *vma) 433static void drm_vm_close(struct vm_area_struct *vma)
432{ 434{
433 drm_file_t *priv = vma->vm_file->private_data; 435 drm_file_t *priv = vma->vm_file->private_data;
434 drm_device_t *dev = priv->head->dev; 436 drm_device_t *dev = priv->head->dev;
@@ -463,7 +465,7 @@ void drm_vm_close(struct vm_area_struct *vma)
463 * Sets the virtual memory area operations structure to vm_dma_ops, the file 465 * Sets the virtual memory area operations structure to vm_dma_ops, the file
464 * pointer, and calls vm_open(). 466 * pointer, and calls vm_open().
465 */ 467 */
466int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) 468static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma)
467{ 469{
468 drm_file_t *priv = filp->private_data; 470 drm_file_t *priv = filp->private_data;
469 drm_device_t *dev; 471 drm_device_t *dev;
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index 24857cc6c23b..18e0b7622893 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -90,16 +90,7 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf)
90 return 0; 90 return 0;
91} 91}
92 92
93static struct file_operations i810_buffer_fops = { 93static int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
94 .open = drm_open,
95 .flush = drm_flush,
96 .release = drm_release,
97 .ioctl = drm_ioctl,
98 .mmap = i810_mmap_buffers,
99 .fasync = drm_fasync,
100};
101
102int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
103{ 94{
104 drm_file_t *priv = filp->private_data; 95 drm_file_t *priv = filp->private_data;
105 drm_device_t *dev; 96 drm_device_t *dev;
@@ -126,6 +117,15 @@ int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
126 return 0; 117 return 0;
127} 118}
128 119
120static struct file_operations i810_buffer_fops = {
121 .open = drm_open,
122 .flush = drm_flush,
123 .release = drm_release,
124 .ioctl = drm_ioctl,
125 .mmap = i810_mmap_buffers,
126 .fasync = drm_fasync,
127};
128
129static int i810_map_buffer(drm_buf_t *buf, struct file *filp) 129static int i810_map_buffer(drm_buf_t *buf, struct file *filp)
130{ 130{
131 drm_file_t *priv = filp->private_data; 131 drm_file_t *priv = filp->private_data;
@@ -1003,8 +1003,8 @@ void i810_reclaim_buffers(drm_device_t *dev, struct file *filp)
1003 } 1003 }
1004} 1004}
1005 1005
1006int i810_flush_ioctl(struct inode *inode, struct file *filp, 1006static int i810_flush_ioctl(struct inode *inode, struct file *filp,
1007 unsigned int cmd, unsigned long arg) 1007 unsigned int cmd, unsigned long arg)
1008{ 1008{
1009 drm_file_t *priv = filp->private_data; 1009 drm_file_t *priv = filp->private_data;
1010 drm_device_t *dev = priv->head->dev; 1010 drm_device_t *dev = priv->head->dev;
diff --git a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h
index fa23ca454e57..1b40538d1725 100644
--- a/drivers/char/drm/i810_drv.h
+++ b/drivers/char/drm/i810_drv.h
@@ -115,7 +115,6 @@ typedef struct drm_i810_private {
115 115
116 /* i810_dma.c */ 116 /* i810_dma.c */
117extern void i810_reclaim_buffers(drm_device_t *dev, struct file *filp); 117extern void i810_reclaim_buffers(drm_device_t *dev, struct file *filp);
118extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
119 118
120extern int i810_driver_dma_quiescent(drm_device_t *dev); 119extern int i810_driver_dma_quiescent(drm_device_t *dev);
121extern void i810_driver_release(drm_device_t *dev, struct file *filp); 120extern void i810_driver_release(drm_device_t *dev, struct file *filp);
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index 98adccf8e434..dc7733035864 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -92,16 +92,7 @@ static int i830_freelist_put(drm_device_t *dev, drm_buf_t *buf)
92 return 0; 92 return 0;
93} 93}
94 94
95static struct file_operations i830_buffer_fops = { 95static int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
96 .open = drm_open,
97 .flush = drm_flush,
98 .release = drm_release,
99 .ioctl = drm_ioctl,
100 .mmap = i830_mmap_buffers,
101 .fasync = drm_fasync,
102};
103
104int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
105{ 96{
106 drm_file_t *priv = filp->private_data; 97 drm_file_t *priv = filp->private_data;
107 drm_device_t *dev; 98 drm_device_t *dev;
@@ -128,6 +119,15 @@ int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
128 return 0; 119 return 0;
129} 120}
130 121
122static struct file_operations i830_buffer_fops = {
123 .open = drm_open,
124 .flush = drm_flush,
125 .release = drm_release,
126 .ioctl = drm_ioctl,
127 .mmap = i830_mmap_buffers,
128 .fasync = drm_fasync,
129};
130
131static int i830_map_buffer(drm_buf_t *buf, struct file *filp) 131static int i830_map_buffer(drm_buf_t *buf, struct file *filp)
132{ 132{
133 drm_file_t *priv = filp->private_data; 133 drm_file_t *priv = filp->private_data;
diff --git a/drivers/char/drm/i830_drv.c b/drivers/char/drm/i830_drv.c
index aa80ad6a5ee0..bc36be76b8b2 100644
--- a/drivers/char/drm/i830_drv.c
+++ b/drivers/char/drm/i830_drv.c
@@ -40,7 +40,7 @@
40 40
41#include "drm_pciids.h" 41#include "drm_pciids.h"
42 42
43int postinit( struct drm_device *dev, unsigned long flags ) 43static int postinit( struct drm_device *dev, unsigned long flags )
44{ 44{
45 dev->counters += 4; 45 dev->counters += 4;
46 dev->types[6] = _DRM_STAT_IRQ; 46 dev->types[6] = _DRM_STAT_IRQ;
diff --git a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
index d4b2d093d6ab..df7746131dea 100644
--- a/drivers/char/drm/i830_drv.h
+++ b/drivers/char/drm/i830_drv.h
@@ -123,8 +123,6 @@ typedef struct drm_i830_private {
123/* i830_dma.c */ 123/* i830_dma.c */
124extern void i830_reclaim_buffers(drm_device_t *dev, struct file *filp); 124extern void i830_reclaim_buffers(drm_device_t *dev, struct file *filp);
125 125
126extern int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
127
128/* i830_irq.c */ 126/* i830_irq.c */
129extern int i830_irq_emit( struct inode *inode, struct file *filp, 127extern int i830_irq_emit( struct inode *inode, struct file *filp,
130 unsigned int cmd, unsigned long arg ); 128 unsigned int cmd, unsigned long arg );
diff --git a/drivers/char/drm/i830_irq.c b/drivers/char/drm/i830_irq.c
index 6d7729ffe2dc..a5923e5d0a77 100644
--- a/drivers/char/drm/i830_irq.c
+++ b/drivers/char/drm/i830_irq.c
@@ -54,8 +54,7 @@ irqreturn_t i830_driver_irq_handler( DRM_IRQ_ARGS )
54 return IRQ_HANDLED; 54 return IRQ_HANDLED;
55} 55}
56 56
57 57static int i830_emit_irq(drm_device_t *dev)
58int i830_emit_irq(drm_device_t *dev)
59{ 58{
60 drm_i830_private_t *dev_priv = dev->dev_private; 59 drm_i830_private_t *dev_priv = dev->dev_private;
61 RING_LOCALS; 60 RING_LOCALS;
@@ -73,7 +72,7 @@ int i830_emit_irq(drm_device_t *dev)
73} 72}
74 73
75 74
76int i830_wait_irq(drm_device_t *dev, int irq_nr) 75static int i830_wait_irq(drm_device_t *dev, int irq_nr)
77{ 76{
78 drm_i830_private_t *dev_priv = 77 drm_i830_private_t *dev_priv =
79 (drm_i830_private_t *)dev->dev_private; 78 (drm_i830_private_t *)dev->dev_private;
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index b5903f9f1423..acf9e52a9507 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -32,23 +32,6 @@
32#include "i915_drm.h" 32#include "i915_drm.h"
33#include "i915_drv.h" 33#include "i915_drv.h"
34 34
35drm_ioctl_desc_t i915_ioctls[] = {
36 [DRM_IOCTL_NR(DRM_I915_INIT)] = {i915_dma_init, 1, 1},
37 [DRM_IOCTL_NR(DRM_I915_FLUSH)] = {i915_flush_ioctl, 1, 0},
38 [DRM_IOCTL_NR(DRM_I915_FLIP)] = {i915_flip_bufs, 1, 0},
39 [DRM_IOCTL_NR(DRM_I915_BATCHBUFFER)] = {i915_batchbuffer, 1, 0},
40 [DRM_IOCTL_NR(DRM_I915_IRQ_EMIT)] = {i915_irq_emit, 1, 0},
41 [DRM_IOCTL_NR(DRM_I915_IRQ_WAIT)] = {i915_irq_wait, 1, 0},
42 [DRM_IOCTL_NR(DRM_I915_GETPARAM)] = {i915_getparam, 1, 0},
43 [DRM_IOCTL_NR(DRM_I915_SETPARAM)] = {i915_setparam, 1, 1},
44 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, 1, 0},
45 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, 1, 0},
46 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, 1, 1},
47 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, 1, 0}
48};
49
50int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
51
52/* Really want an OS-independent resettable timer. Would like to have 35/* Really want an OS-independent resettable timer. Would like to have
53 * this loop run for (eg) 3 sec, but have the timer reset every time 36 * this loop run for (eg) 3 sec, but have the timer reset every time
54 * the head pointer changes, so that EBUSY only happens if the ring 37 * the head pointer changes, so that EBUSY only happens if the ring
@@ -95,7 +78,7 @@ void i915_kernel_lost_context(drm_device_t * dev)
95 dev_priv->sarea_priv->perf_boxes |= I915_BOX_RING_EMPTY; 78 dev_priv->sarea_priv->perf_boxes |= I915_BOX_RING_EMPTY;
96} 79}
97 80
98int i915_dma_cleanup(drm_device_t * dev) 81static int i915_dma_cleanup(drm_device_t * dev)
99{ 82{
100 /* Make sure interrupts are disabled here because the uninstall ioctl 83 /* Make sure interrupts are disabled here because the uninstall ioctl
101 * may not have been called from userspace and after dev_private 84 * may not have been called from userspace and after dev_private
@@ -247,7 +230,7 @@ static int i915_resume(drm_device_t * dev)
247 return 0; 230 return 0;
248} 231}
249 232
250int i915_dma_init(DRM_IOCTL_ARGS) 233static int i915_dma_init(DRM_IOCTL_ARGS)
251{ 234{
252 DRM_DEVICE; 235 DRM_DEVICE;
253 drm_i915_private_t *dev_priv; 236 drm_i915_private_t *dev_priv;
@@ -558,7 +541,7 @@ static int i915_quiescent(drm_device_t * dev)
558 return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); 541 return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__);
559} 542}
560 543
561int i915_flush_ioctl(DRM_IOCTL_ARGS) 544static int i915_flush_ioctl(DRM_IOCTL_ARGS)
562{ 545{
563 DRM_DEVICE; 546 DRM_DEVICE;
564 547
@@ -567,7 +550,7 @@ int i915_flush_ioctl(DRM_IOCTL_ARGS)
567 return i915_quiescent(dev); 550 return i915_quiescent(dev);
568} 551}
569 552
570int i915_batchbuffer(DRM_IOCTL_ARGS) 553static int i915_batchbuffer(DRM_IOCTL_ARGS)
571{ 554{
572 DRM_DEVICE; 555 DRM_DEVICE;
573 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 556 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
@@ -601,7 +584,7 @@ int i915_batchbuffer(DRM_IOCTL_ARGS)
601 return ret; 584 return ret;
602} 585}
603 586
604int i915_cmdbuffer(DRM_IOCTL_ARGS) 587static int i915_cmdbuffer(DRM_IOCTL_ARGS)
605{ 588{
606 DRM_DEVICE; 589 DRM_DEVICE;
607 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 590 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
@@ -637,18 +620,7 @@ int i915_cmdbuffer(DRM_IOCTL_ARGS)
637 return 0; 620 return 0;
638} 621}
639 622
640int i915_do_cleanup_pageflip(drm_device_t * dev) 623static int i915_flip_bufs(DRM_IOCTL_ARGS)
641{
642 drm_i915_private_t *dev_priv = dev->dev_private;
643
644 DRM_DEBUG("%s\n", __FUNCTION__);
645 if (dev_priv->current_page != 0)
646 i915_dispatch_flip(dev);
647
648 return 0;
649}
650
651int i915_flip_bufs(DRM_IOCTL_ARGS)
652{ 624{
653 DRM_DEVICE; 625 DRM_DEVICE;
654 626
@@ -659,7 +631,7 @@ int i915_flip_bufs(DRM_IOCTL_ARGS)
659 return i915_dispatch_flip(dev); 631 return i915_dispatch_flip(dev);
660} 632}
661 633
662int i915_getparam(DRM_IOCTL_ARGS) 634static int i915_getparam(DRM_IOCTL_ARGS)
663{ 635{
664 DRM_DEVICE; 636 DRM_DEVICE;
665 drm_i915_private_t *dev_priv = dev->dev_private; 637 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -694,7 +666,7 @@ int i915_getparam(DRM_IOCTL_ARGS)
694 return 0; 666 return 0;
695} 667}
696 668
697int i915_setparam(DRM_IOCTL_ARGS) 669static int i915_setparam(DRM_IOCTL_ARGS)
698{ 670{
699 DRM_DEVICE; 671 DRM_DEVICE;
700 drm_i915_private_t *dev_priv = dev->dev_private; 672 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -743,3 +715,19 @@ void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
743 } 715 }
744} 716}
745 717
718drm_ioctl_desc_t i915_ioctls[] = {
719 [DRM_IOCTL_NR(DRM_I915_INIT)] = {i915_dma_init, 1, 1},
720 [DRM_IOCTL_NR(DRM_I915_FLUSH)] = {i915_flush_ioctl, 1, 0},
721 [DRM_IOCTL_NR(DRM_I915_FLIP)] = {i915_flip_bufs, 1, 0},
722 [DRM_IOCTL_NR(DRM_I915_BATCHBUFFER)] = {i915_batchbuffer, 1, 0},
723 [DRM_IOCTL_NR(DRM_I915_IRQ_EMIT)] = {i915_irq_emit, 1, 0},
724 [DRM_IOCTL_NR(DRM_I915_IRQ_WAIT)] = {i915_irq_wait, 1, 0},
725 [DRM_IOCTL_NR(DRM_I915_GETPARAM)] = {i915_getparam, 1, 0},
726 [DRM_IOCTL_NR(DRM_I915_SETPARAM)] = {i915_setparam, 1, 1},
727 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, 1, 0},
728 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, 1, 0},
729 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, 1, 1},
730 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, 1, 0}
731};
732
733int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/char/drm/i915_drv.c b/drivers/char/drm/i915_drv.c
index e6a9e1d1d283..1f59d3fc79bc 100644
--- a/drivers/char/drm/i915_drv.c
+++ b/drivers/char/drm/i915_drv.c
@@ -34,7 +34,7 @@
34 34
35#include "drm_pciids.h" 35#include "drm_pciids.h"
36 36
37int postinit( struct drm_device *dev, unsigned long flags ) 37static int postinit( struct drm_device *dev, unsigned long flags )
38{ 38{
39 dev->counters += 4; 39 dev->counters += 4;
40 dev->types[6] = _DRM_STAT_IRQ; 40 dev->types[6] = _DRM_STAT_IRQ;
@@ -97,6 +97,9 @@ static struct drm_driver driver = {
97 .mmap = drm_mmap, 97 .mmap = drm_mmap,
98 .poll = drm_poll, 98 .poll = drm_poll,
99 .fasync = drm_fasync, 99 .fasync = drm_fasync,
100#ifdef CONFIG_COMPAT
101 .compat_ioctl = i915_compat_ioctl,
102#endif
100 }, 103 },
101 .pci_driver = { 104 .pci_driver = {
102 .name = DRIVER_NAME, 105 .name = DRIVER_NAME,
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index fa940d64b85d..9c37d2367dd5 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -99,14 +99,6 @@ typedef struct drm_i915_private {
99} drm_i915_private_t; 99} drm_i915_private_t;
100 100
101 /* i915_dma.c */ 101 /* i915_dma.c */
102extern int i915_dma_init(DRM_IOCTL_ARGS);
103extern int i915_dma_cleanup(drm_device_t * dev);
104extern int i915_flush_ioctl(DRM_IOCTL_ARGS);
105extern int i915_batchbuffer(DRM_IOCTL_ARGS);
106extern int i915_flip_bufs(DRM_IOCTL_ARGS);
107extern int i915_getparam(DRM_IOCTL_ARGS);
108extern int i915_setparam(DRM_IOCTL_ARGS);
109extern int i915_cmdbuffer(DRM_IOCTL_ARGS);
110extern void i915_kernel_lost_context(drm_device_t * dev); 102extern void i915_kernel_lost_context(drm_device_t * dev);
111extern void i915_driver_pretakedown(drm_device_t *dev); 103extern void i915_driver_pretakedown(drm_device_t *dev);
112extern void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp); 104extern void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp);
@@ -114,8 +106,6 @@ extern void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp);
114/* i915_irq.c */ 106/* i915_irq.c */
115extern int i915_irq_emit(DRM_IOCTL_ARGS); 107extern int i915_irq_emit(DRM_IOCTL_ARGS);
116extern int i915_irq_wait(DRM_IOCTL_ARGS); 108extern int i915_irq_wait(DRM_IOCTL_ARGS);
117extern int i915_wait_irq(drm_device_t * dev, int irq_nr);
118extern int i915_emit_irq(drm_device_t * dev);
119 109
120extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS); 110extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
121extern void i915_driver_irq_preinstall(drm_device_t *dev); 111extern void i915_driver_irq_preinstall(drm_device_t *dev);
@@ -130,6 +120,10 @@ extern void i915_mem_takedown(struct mem_block **heap);
130extern void i915_mem_release(drm_device_t * dev, 120extern void i915_mem_release(drm_device_t * dev,
131 DRMFILE filp, struct mem_block *heap); 121 DRMFILE filp, struct mem_block *heap);
132 122
123extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
124 unsigned long arg);
125
126
133#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, reg) 127#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, reg)
134#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, reg, val) 128#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, reg, val)
135#define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, reg) 129#define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, reg)
diff --git a/drivers/char/drm/i915_ioc32.c b/drivers/char/drm/i915_ioc32.c
new file mode 100644
index 000000000000..fe009e1b3a3f
--- /dev/null
+++ b/drivers/char/drm/i915_ioc32.c
@@ -0,0 +1,221 @@
1/**
2 * \file i915_ioc32.c
3 *
4 * 32-bit ioctl compatibility routines for the i915 DRM.
5 *
6 * \author Alan Hourihane <alanh@fairlite.demon.co.uk>
7 *
8 *
9 * Copyright (C) Paul Mackerras 2005
10 * Copyright (C) Alan Hourihane 2005
11 * All Rights Reserved.
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice (including the next
21 * paragraph) shall be included in all copies or substantial portions of the
22 * Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 * IN THE SOFTWARE.
31 */
32#include <linux/compat.h>
33#include <linux/ioctl32.h>
34
35#include "drmP.h"
36#include "drm.h"
37#include "i915_drm.h"
38
39typedef struct _drm_i915_batchbuffer32 {
40 int start; /* agp offset */
41 int used; /* nr bytes in use */
42 int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
43 int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
44 int num_cliprects; /* mulitpass with multiple cliprects? */
45 u32 cliprects; /* pointer to userspace cliprects */
46} drm_i915_batchbuffer32_t;
47
48static int compat_i915_batchbuffer(struct file *file, unsigned int cmd,
49 unsigned long arg)
50{
51 drm_i915_batchbuffer32_t batchbuffer32;
52 drm_i915_batchbuffer_t __user *batchbuffer;
53
54 if (copy_from_user(&batchbuffer32, (void __user *)arg, sizeof(batchbuffer32)))
55 return -EFAULT;
56
57 batchbuffer = compat_alloc_user_space(sizeof(*batchbuffer));
58 if (!access_ok(VERIFY_WRITE, batchbuffer, sizeof(*batchbuffer))
59 || __put_user(batchbuffer32.start, &batchbuffer->start)
60 || __put_user(batchbuffer32.used, &batchbuffer->used)
61 || __put_user(batchbuffer32.DR1, &batchbuffer->DR1)
62 || __put_user(batchbuffer32.DR4, &batchbuffer->DR4)
63 || __put_user(batchbuffer32.num_cliprects, &batchbuffer->num_cliprects)
64 || __put_user((int __user *)(unsigned long)batchbuffer32.cliprects,
65 &batchbuffer->cliprects))
66 return -EFAULT;
67
68 return drm_ioctl(file->f_dentry->d_inode, file,
69 DRM_IOCTL_I915_BATCHBUFFER, (unsigned long) batchbuffer);
70}
71
72typedef struct _drm_i915_cmdbuffer32 {
73 u32 buf; /* pointer to userspace command buffer */
74 int sz; /* nr bytes in buf */
75 int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
76 int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
77 int num_cliprects; /* mulitpass with multiple cliprects? */
78 u32 cliprects; /* pointer to userspace cliprects */
79} drm_i915_cmdbuffer32_t;
80
81static int compat_i915_cmdbuffer(struct file *file, unsigned int cmd,
82 unsigned long arg)
83{
84 drm_i915_cmdbuffer32_t cmdbuffer32;
85 drm_i915_cmdbuffer_t __user *cmdbuffer;
86
87 if (copy_from_user(&cmdbuffer32, (void __user *)arg, sizeof(cmdbuffer32)))
88 return -EFAULT;
89
90 cmdbuffer = compat_alloc_user_space(sizeof(*cmdbuffer));
91 if (!access_ok(VERIFY_WRITE, cmdbuffer, sizeof(*cmdbuffer))
92 || __put_user((int __user *)(unsigned long)cmdbuffer32.buf,
93 &cmdbuffer->buf)
94 || __put_user(cmdbuffer32.sz, &cmdbuffer->sz)
95 || __put_user(cmdbuffer32.DR1, &cmdbuffer->DR1)
96 || __put_user(cmdbuffer32.DR4, &cmdbuffer->DR4)
97 || __put_user(cmdbuffer32.num_cliprects, &cmdbuffer->num_cliprects)
98 || __put_user((int __user *)(unsigned long)cmdbuffer32.cliprects,
99 &cmdbuffer->cliprects))
100 return -EFAULT;
101
102 return drm_ioctl(file->f_dentry->d_inode, file,
103 DRM_IOCTL_I915_CMDBUFFER, (unsigned long) cmdbuffer);
104}
105
106typedef struct drm_i915_irq_emit32 {
107 u32 irq_seq;
108} drm_i915_irq_emit32_t;
109
110static int compat_i915_irq_emit(struct file *file, unsigned int cmd,
111 unsigned long arg)
112{
113 drm_i915_irq_emit32_t req32;
114 drm_i915_irq_emit_t __user *request;
115
116 if (copy_from_user(&req32, (void __user *) arg, sizeof(req32)))
117 return -EFAULT;
118
119 request = compat_alloc_user_space(sizeof(*request));
120 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
121 || __put_user((int __user *)(unsigned long)req32.irq_seq,
122 &request->irq_seq))
123 return -EFAULT;
124
125 return drm_ioctl(file->f_dentry->d_inode, file,
126 DRM_IOCTL_I915_IRQ_EMIT, (unsigned long) request);
127}
128typedef struct drm_i915_getparam32 {
129 int param;
130 u32 value;
131} drm_i915_getparam32_t;
132
133static int compat_i915_getparam(struct file *file, unsigned int cmd,
134 unsigned long arg)
135{
136 drm_i915_getparam32_t req32;
137 drm_i915_getparam_t __user *request;
138
139 if (copy_from_user(&req32, (void __user *) arg, sizeof(req32)))
140 return -EFAULT;
141
142 request = compat_alloc_user_space(sizeof(*request));
143 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
144 || __put_user(req32.param, &request->param)
145 || __put_user((void __user *)(unsigned long)req32.value,
146 &request->value))
147 return -EFAULT;
148
149 return drm_ioctl(file->f_dentry->d_inode, file,
150 DRM_IOCTL_I915_GETPARAM, (unsigned long) request);
151}
152
153typedef struct drm_i915_mem_alloc32 {
154 int region;
155 int alignment;
156 int size;
157 u32 region_offset; /* offset from start of fb or agp */
158} drm_i915_mem_alloc32_t;
159
160static int compat_i915_alloc(struct file *file, unsigned int cmd,
161 unsigned long arg)
162{
163 drm_i915_mem_alloc32_t req32;
164 drm_i915_mem_alloc_t __user *request;
165
166 if (copy_from_user(&req32, (void __user *) arg, sizeof(req32)))
167 return -EFAULT;
168
169 request = compat_alloc_user_space(sizeof(*request));
170 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
171 || __put_user(req32.region, &request->region)
172 || __put_user(req32.alignment, &request->alignment)
173 || __put_user(req32.size, &request->size)
174 || __put_user((void __user *)(unsigned long)req32.region_offset,
175 &request->region_offset))
176 return -EFAULT;
177
178 return drm_ioctl(file->f_dentry->d_inode, file,
179 DRM_IOCTL_I915_ALLOC, (unsigned long) request);
180}
181
182
183drm_ioctl_compat_t *i915_compat_ioctls[] = {
184 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
185 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
186 [DRM_I915_GETPARAM] = compat_i915_getparam,
187 [DRM_I915_IRQ_EMIT] = compat_i915_irq_emit,
188 [DRM_I915_ALLOC] = compat_i915_alloc
189};
190
191/**
192 * Called whenever a 32-bit process running under a 64-bit kernel
193 * performs an ioctl on /dev/dri/card<n>.
194 *
195 * \param filp file pointer.
196 * \param cmd command.
197 * \param arg user argument.
198 * \return zero on success or negative number on failure.
199 */
200long i915_compat_ioctl(struct file *filp, unsigned int cmd,
201 unsigned long arg)
202{
203 unsigned int nr = DRM_IOCTL_NR(cmd);
204 drm_ioctl_compat_t *fn = NULL;
205 int ret;
206
207 if (nr < DRM_COMMAND_BASE)
208 return drm_compat_ioctl(filp, cmd, arg);
209
210 if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
211 fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
212
213 lock_kernel(); /* XXX for now */
214 if (fn != NULL)
215 ret = (*fn)(filp, cmd, arg);
216 else
217 ret = drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
218 unlock_kernel();
219
220 return ret;
221}
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c
index a101cc9cfd7e..4fa448ee846b 100644
--- a/drivers/char/drm/i915_irq.c
+++ b/drivers/char/drm/i915_irq.c
@@ -56,7 +56,7 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
56 return IRQ_HANDLED; 56 return IRQ_HANDLED;
57} 57}
58 58
59int i915_emit_irq(drm_device_t * dev) 59static int i915_emit_irq(drm_device_t * dev)
60{ 60{
61 drm_i915_private_t *dev_priv = dev->dev_private; 61 drm_i915_private_t *dev_priv = dev->dev_private;
62 u32 ret; 62 u32 ret;
@@ -76,7 +76,7 @@ int i915_emit_irq(drm_device_t * dev)
76 return ret; 76 return ret;
77} 77}
78 78
79int i915_wait_irq(drm_device_t * dev, int irq_nr) 79static int i915_wait_irq(drm_device_t * dev, int irq_nr)
80{ 80{
81 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 81 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
82 int ret = 0; 82 int ret = 0;
diff --git a/drivers/char/drm/mga_drv.c b/drivers/char/drm/mga_drv.c
index 22dab3e9d92a..844cca9cb29d 100644
--- a/drivers/char/drm/mga_drv.c
+++ b/drivers/char/drm/mga_drv.c
@@ -101,6 +101,9 @@ static struct drm_driver driver = {
101 .mmap = drm_mmap, 101 .mmap = drm_mmap,
102 .poll = drm_poll, 102 .poll = drm_poll,
103 .fasync = drm_fasync, 103 .fasync = drm_fasync,
104#ifdef CONFIG_COMPAT
105 .compat_ioctl = mga_compat_ioctl,
106#endif
104 }, 107 },
105 .pci_driver = { 108 .pci_driver = {
106 .name = DRIVER_NAME, 109 .name = DRIVER_NAME,
diff --git a/drivers/char/drm/mga_drv.h b/drivers/char/drm/mga_drv.h
index 1d84a1eb34db..9412e2816eb7 100644
--- a/drivers/char/drm/mga_drv.h
+++ b/drivers/char/drm/mga_drv.h
@@ -137,6 +137,8 @@ extern irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS );
137extern void mga_driver_irq_preinstall( drm_device_t *dev ); 137extern void mga_driver_irq_preinstall( drm_device_t *dev );
138extern void mga_driver_irq_postinstall( drm_device_t *dev ); 138extern void mga_driver_irq_postinstall( drm_device_t *dev );
139extern void mga_driver_irq_uninstall( drm_device_t *dev ); 139extern void mga_driver_irq_uninstall( drm_device_t *dev );
140extern long mga_compat_ioctl(struct file *filp, unsigned int cmd,
141 unsigned long arg);
140 142
141#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER() 143#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER()
142 144
diff --git a/drivers/char/drm/mga_ioc32.c b/drivers/char/drm/mga_ioc32.c
new file mode 100644
index 000000000000..bc745cfa2095
--- /dev/null
+++ b/drivers/char/drm/mga_ioc32.c
@@ -0,0 +1,167 @@
1/**
2 * \file mga_ioc32.c
3 *
4 * 32-bit ioctl compatibility routines for the MGA DRM.
5 *
6 * \author Dave Airlie <airlied@linux.ie> with code from patches by Egbert Eich
7 *
8 *
9 * Copyright (C) Paul Mackerras 2005
10 * Copyright (C) Egbert Eich 2003,2004
11 * Copyright (C) Dave Airlie 2005
12 * All Rights Reserved.
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
20 *
21 * The above copyright notice and this permission notice (including the next
22 * paragraph) shall be included in all copies or substantial portions of the
23 * Software.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 * IN THE SOFTWARE.
32 */
33#include <linux/compat.h>
34#include <linux/ioctl32.h>
35
36#include "drmP.h"
37#include "drm.h"
38#include "mga_drm.h"
39
40typedef struct drm32_mga_init {
41 int func;
42 u32 sarea_priv_offset;
43 int chipset;
44 int sgram;
45 unsigned int maccess;
46 unsigned int fb_cpp;
47 unsigned int front_offset, front_pitch;
48 unsigned int back_offset, back_pitch;
49 unsigned int depth_cpp;
50 unsigned int depth_offset, depth_pitch;
51 unsigned int texture_offset[MGA_NR_TEX_HEAPS];
52 unsigned int texture_size[MGA_NR_TEX_HEAPS];
53 u32 fb_offset;
54 u32 mmio_offset;
55 u32 status_offset;
56 u32 warp_offset;
57 u32 primary_offset;
58 u32 buffers_offset;
59} drm_mga_init32_t;
60
61static int compat_mga_init(struct file *file, unsigned int cmd,
62 unsigned long arg)
63{
64 drm_mga_init32_t init32;
65 drm_mga_init_t __user *init;
66 int err = 0, i;
67
68 if (copy_from_user(&init32, (void __user *)arg, sizeof(init32)))
69 return -EFAULT;
70
71 init = compat_alloc_user_space(sizeof(*init));
72 if (!access_ok(VERIFY_WRITE, init, sizeof(*init))
73 || __put_user(init32.func, &init->func)
74 || __put_user(init32.sarea_priv_offset, &init->sarea_priv_offset)
75 || __put_user(init32.chipset, &init->chipset)
76 || __put_user(init32.sgram, &init->sgram)
77 || __put_user(init32.maccess, &init->maccess)
78 || __put_user(init32.fb_cpp, &init->fb_cpp)
79 || __put_user(init32.front_offset, &init->front_offset)
80 || __put_user(init32.front_pitch, &init->front_pitch)
81 || __put_user(init32.back_offset, &init->back_offset)
82 || __put_user(init32.back_pitch, &init->back_pitch)
83 || __put_user(init32.depth_cpp, &init->depth_cpp)
84 || __put_user(init32.depth_offset, &init->depth_offset)
85 || __put_user(init32.depth_pitch, &init->depth_pitch)
86 || __put_user(init32.fb_offset, &init->fb_offset)
87 || __put_user(init32.mmio_offset, &init->mmio_offset)
88 || __put_user(init32.status_offset, &init->status_offset)
89 || __put_user(init32.warp_offset, &init->warp_offset)
90 || __put_user(init32.primary_offset, &init->primary_offset)
91 || __put_user(init32.buffers_offset, &init->buffers_offset))
92 return -EFAULT;
93
94 for (i=0; i<MGA_NR_TEX_HEAPS; i++)
95 {
96 err |= __put_user(init32.texture_offset[i], &init->texture_offset[i]);
97 err |= __put_user(init32.texture_size[i], &init->texture_size[i]);
98 }
99 if (err)
100 return -EFAULT;
101
102 return drm_ioctl(file->f_dentry->d_inode, file,
103 DRM_IOCTL_MGA_INIT, (unsigned long) init);
104}
105
106
107typedef struct drm_mga_getparam32 {
108 int param;
109 u32 value;
110} drm_mga_getparam32_t;
111
112
113static int compat_mga_getparam(struct file *file, unsigned int cmd,
114 unsigned long arg)
115{
116 drm_mga_getparam32_t getparam32;
117 drm_mga_getparam_t __user *getparam;
118
119 if (copy_from_user(&getparam32, (void __user *)arg, sizeof(getparam32)))
120 return -EFAULT;
121
122 getparam = compat_alloc_user_space(sizeof(*getparam));
123 if (!access_ok(VERIFY_WRITE, getparam, sizeof(*getparam))
124 || __put_user(getparam32.param, &getparam->param)
125 || __put_user((void __user *)(unsigned long)getparam32.value, &getparam->value))
126 return -EFAULT;
127
128 return drm_ioctl(file->f_dentry->d_inode, file,
129 DRM_IOCTL_MGA_GETPARAM, (unsigned long)getparam);
130}
131
132drm_ioctl_compat_t *mga_compat_ioctls[] = {
133 [DRM_MGA_INIT] = compat_mga_init,
134 [DRM_MGA_GETPARAM] = compat_mga_getparam,
135};
136
137/**
138 * Called whenever a 32-bit process running under a 64-bit kernel
139 * performs an ioctl on /dev/dri/card<n>.
140 *
141 * \param filp file pointer.
142 * \param cmd command.
143 * \param arg user argument.
144 * \return zero on success or negative number on failure.
145 */
146long mga_compat_ioctl(struct file *filp, unsigned int cmd,
147 unsigned long arg)
148{
149 unsigned int nr = DRM_IOCTL_NR(cmd);
150 drm_ioctl_compat_t *fn = NULL;
151 int ret;
152
153 if (nr < DRM_COMMAND_BASE)
154 return drm_compat_ioctl(filp, cmd, arg);
155
156 if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
157 fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
158
159 lock_kernel(); /* XXX for now */
160 if (fn != NULL)
161 ret = (*fn)(filp, cmd, arg);
162 else
163 ret = drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
164 unlock_kernel();
165
166 return ret;
167}
diff --git a/drivers/char/drm/r128_drv.c b/drivers/char/drm/r128_drv.c
index ced63810237b..bc446da1b210 100644
--- a/drivers/char/drm/r128_drv.c
+++ b/drivers/char/drm/r128_drv.c
@@ -96,6 +96,9 @@ static struct drm_driver driver = {
96 .mmap = drm_mmap, 96 .mmap = drm_mmap,
97 .poll = drm_poll, 97 .poll = drm_poll,
98 .fasync = drm_fasync, 98 .fasync = drm_fasync,
99#ifdef CONFIG_COMPAT
100 .compat_ioctl = r128_compat_ioctl,
101#endif
99 }, 102 },
100 .pci_driver = { 103 .pci_driver = {
101 .name = DRIVER_NAME, 104 .name = DRIVER_NAME,
diff --git a/drivers/char/drm/r128_drv.h b/drivers/char/drm/r128_drv.h
index cf1aa5df459e..0fb687c9505e 100644
--- a/drivers/char/drm/r128_drv.h
+++ b/drivers/char/drm/r128_drv.h
@@ -156,6 +156,9 @@ extern void r128_driver_irq_uninstall( drm_device_t *dev );
156extern void r128_driver_pretakedown(drm_device_t *dev); 156extern void r128_driver_pretakedown(drm_device_t *dev);
157extern void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp); 157extern void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp);
158 158
159extern long r128_compat_ioctl(struct file *filp, unsigned int cmd,
160 unsigned long arg);
161
159/* Register definitions, register access macros and drmAddMap constants 162/* Register definitions, register access macros and drmAddMap constants
160 * for Rage 128 kernel driver. 163 * for Rage 128 kernel driver.
161 */ 164 */
diff --git a/drivers/char/drm/r128_ioc32.c b/drivers/char/drm/r128_ioc32.c
new file mode 100644
index 000000000000..60598ef9475a
--- /dev/null
+++ b/drivers/char/drm/r128_ioc32.c
@@ -0,0 +1,219 @@
1/**
2 * \file r128_ioc32.c
3 *
4 * 32-bit ioctl compatibility routines for the R128 DRM.
5 *
6 * \author Dave Airlie <airlied@linux.ie> with code from patches by Egbert Eich
7 *
8 * Copyright (C) Paul Mackerras 2005
9 * Copyright (C) Egbert Eich 2003,2004
10 * Copyright (C) Dave Airlie 2005
11 * All Rights Reserved.
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice (including the next
21 * paragraph) shall be included in all copies or substantial portions of the
22 * Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 * IN THE SOFTWARE.
31 */
32#include <linux/compat.h>
33#include <linux/ioctl32.h>
34
35#include "drmP.h"
36#include "drm.h"
37#include "r128_drm.h"
38
39typedef struct drm_r128_init32 {
40 int func;
41 unsigned int sarea_priv_offset;
42 int is_pci;
43 int cce_mode;
44 int cce_secure;
45 int ring_size;
46 int usec_timeout;
47
48 unsigned int fb_bpp;
49 unsigned int front_offset, front_pitch;
50 unsigned int back_offset, back_pitch;
51 unsigned int depth_bpp;
52 unsigned int depth_offset, depth_pitch;
53 unsigned int span_offset;
54
55 unsigned int fb_offset;
56 unsigned int mmio_offset;
57 unsigned int ring_offset;
58 unsigned int ring_rptr_offset;
59 unsigned int buffers_offset;
60 unsigned int agp_textures_offset;
61} drm_r128_init32_t;
62
63static int compat_r128_init(struct file *file, unsigned int cmd,
64 unsigned long arg)
65{
66 drm_r128_init32_t init32;
67 drm_r128_init_t __user *init;
68
69 if (copy_from_user(&init32, (void __user *)arg, sizeof(init32)))
70 return -EFAULT;
71
72 init = compat_alloc_user_space(sizeof(*init));
73 if (!access_ok(VERIFY_WRITE, init, sizeof(*init))
74 || __put_user(init32.func, &init->func)
75 || __put_user(init32.sarea_priv_offset, &init->sarea_priv_offset)
76 || __put_user(init32.is_pci, &init->is_pci)
77 || __put_user(init32.cce_mode, &init->cce_mode)
78 || __put_user(init32.cce_secure, &init->cce_secure)
79 || __put_user(init32.ring_size, &init->ring_size)
80 || __put_user(init32.usec_timeout, &init->usec_timeout)
81 || __put_user(init32.fb_bpp, &init->fb_bpp)
82 || __put_user(init32.front_offset, &init->front_offset)
83 || __put_user(init32.front_pitch, &init->front_pitch)
84 || __put_user(init32.back_offset, &init->back_offset)
85 || __put_user(init32.back_pitch, &init->back_pitch)
86 || __put_user(init32.depth_bpp, &init->depth_bpp)
87 || __put_user(init32.depth_offset, &init->depth_offset)
88 || __put_user(init32.depth_pitch, &init->depth_pitch)
89 || __put_user(init32.span_offset, &init->span_offset)
90 || __put_user(init32.fb_offset, &init->fb_offset)
91 || __put_user(init32.mmio_offset, &init->mmio_offset)
92 || __put_user(init32.ring_offset, &init->ring_offset)
93 || __put_user(init32.ring_rptr_offset, &init->ring_rptr_offset)
94 || __put_user(init32.buffers_offset, &init->buffers_offset)
95 || __put_user(init32.agp_textures_offset, &init->agp_textures_offset))
96 return -EFAULT;
97
98 return drm_ioctl(file->f_dentry->d_inode, file,
99 DRM_IOCTL_R128_INIT, (unsigned long)init);
100}
101
102
103typedef struct drm_r128_depth32 {
104 int func;
105 int n;
106 u32 x;
107 u32 y;
108 u32 buffer;
109 u32 mask;
110} drm_r128_depth32_t;
111
112static int compat_r128_depth(struct file *file, unsigned int cmd,
113 unsigned long arg)
114{
115 drm_r128_depth32_t depth32;
116 drm_r128_depth_t __user *depth;
117
118 if (copy_from_user(&depth32, (void __user *)arg, sizeof(depth32)))
119 return -EFAULT;
120
121 depth = compat_alloc_user_space(sizeof(*depth));
122 if (!access_ok(VERIFY_WRITE, depth, sizeof(*depth))
123 || __put_user(depth32.func, &depth->func)
124 || __put_user(depth32.n, &depth->n)
125 || __put_user((int __user *)(unsigned long)depth32.x, &depth->x)
126 || __put_user((int __user *)(unsigned long)depth32.y, &depth->y)
127 || __put_user((unsigned int __user *)(unsigned long)depth32.buffer, &depth->buffer)
128 || __put_user((unsigned char __user *)(unsigned long)depth32.mask, &depth->mask))
129 return -EFAULT;
130
131 return drm_ioctl(file->f_dentry->d_inode, file,
132 DRM_IOCTL_R128_DEPTH, (unsigned long)depth);
133
134}
135
136typedef struct drm_r128_stipple32 {
137 u32 mask;
138} drm_r128_stipple32_t;
139
140static int compat_r128_stipple(struct file *file, unsigned int cmd,
141 unsigned long arg)
142{
143 drm_r128_stipple32_t stipple32;
144 drm_r128_stipple_t __user *stipple;
145
146 if (copy_from_user(&stipple32, (void __user *)arg, sizeof(stipple32)))
147 return -EFAULT;
148
149 stipple = compat_alloc_user_space(sizeof(*stipple));
150 if (!access_ok(VERIFY_WRITE, stipple, sizeof(*stipple))
151 || __put_user((unsigned int __user *)(unsigned long)stipple32.mask, &stipple->mask))
152 return -EFAULT;
153
154 return drm_ioctl(file->f_dentry->d_inode, file,
155 DRM_IOCTL_R128_STIPPLE, (unsigned long)stipple);
156}
157
158typedef struct drm_r128_getparam32 {
159 int param;
160 u32 value;
161} drm_r128_getparam32_t;
162
163static int compat_r128_getparam(struct file *file, unsigned int cmd,
164 unsigned long arg)
165{
166 drm_r128_getparam32_t getparam32;
167 drm_r128_getparam_t __user *getparam;
168
169 if (copy_from_user(&getparam32, (void __user *)arg, sizeof(getparam32)))
170 return -EFAULT;
171
172 getparam = compat_alloc_user_space(sizeof(*getparam));
173 if (!access_ok(VERIFY_WRITE, getparam, sizeof(*getparam))
174 || __put_user(getparam32.param, &getparam->param)
175 || __put_user((void __user *)(unsigned long)getparam32.value, &getparam->value))
176 return -EFAULT;
177
178 return drm_ioctl(file->f_dentry->d_inode, file,
179 DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
180}
181
182drm_ioctl_compat_t *r128_compat_ioctls[] = {
183 [DRM_R128_INIT] = compat_r128_init,
184 [DRM_R128_DEPTH] = compat_r128_depth,
185 [DRM_R128_STIPPLE] = compat_r128_stipple,
186 [DRM_R128_GETPARAM] = compat_r128_getparam,
187};
188
189/**
190 * Called whenever a 32-bit process running under a 64-bit kernel
191 * performs an ioctl on /dev/dri/card<n>.
192 *
193 * \param filp file pointer.
194 * \param cmd command.
195 * \param arg user argument.
196 * \return zero on success or negative number on failure.
197 */
198long r128_compat_ioctl(struct file *filp, unsigned int cmd,
199 unsigned long arg)
200{
201 unsigned int nr = DRM_IOCTL_NR(cmd);
202 drm_ioctl_compat_t *fn = NULL;
203 int ret;
204
205 if (nr < DRM_COMMAND_BASE)
206 return drm_compat_ioctl(filp, cmd, arg);
207
208 if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
209 fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
210
211 lock_kernel(); /* XXX for now */
212 if (fn != NULL)
213 ret = (*fn)(filp, cmd, arg);
214 else
215 ret = drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
216 unlock_kernel();
217
218 return ret;
219}
diff --git a/drivers/char/drm/r128_state.c b/drivers/char/drm/r128_state.c
index 53af69162829..426a71c049d9 100644
--- a/drivers/char/drm/r128_state.c
+++ b/drivers/char/drm/r128_state.c
@@ -1307,7 +1307,7 @@ static int r128_do_init_pageflip( drm_device_t *dev )
1307 return 0; 1307 return 0;
1308} 1308}
1309 1309
1310int r128_do_cleanup_pageflip( drm_device_t *dev ) 1310static int r128_do_cleanup_pageflip( drm_device_t *dev )
1311{ 1311{
1312 drm_r128_private_t *dev_priv = dev->dev_private; 1312 drm_r128_private_t *dev_priv = dev->dev_private;
1313 DRM_DEBUG( "\n" ); 1313 DRM_DEBUG( "\n" );
diff --git a/drivers/char/drm/via_3d_reg.h b/drivers/char/drm/via_3d_reg.h
new file mode 100644
index 000000000000..cf61bb514db1
--- /dev/null
+++ b/drivers/char/drm/via_3d_reg.h
@@ -0,0 +1,1651 @@
1/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef VIA_3D_REG_H
26#define VIA_3D_REG_H
27#define HC_REG_BASE 0x0400
28
29#define HC_REG_TRANS_SPACE 0x0040
30
31#define HC_ParaN_MASK 0xffffffff
32#define HC_Para_MASK 0x00ffffff
33#define HC_SubA_MASK 0xff000000
34#define HC_SubA_SHIFT 24
35/* Transmission Setting
36 */
37#define HC_REG_TRANS_SET 0x003c
38#define HC_ParaSubType_MASK 0xff000000
39#define HC_ParaType_MASK 0x00ff0000
40#define HC_ParaOS_MASK 0x0000ff00
41#define HC_ParaAdr_MASK 0x000000ff
42#define HC_ParaSubType_SHIFT 24
43#define HC_ParaType_SHIFT 16
44#define HC_ParaOS_SHIFT 8
45#define HC_ParaAdr_SHIFT 0
46
47#define HC_ParaType_CmdVdata 0x0000
48#define HC_ParaType_NotTex 0x0001
49#define HC_ParaType_Tex 0x0002
50#define HC_ParaType_Palette 0x0003
51#define HC_ParaType_PreCR 0x0010
52#define HC_ParaType_Auto 0x00fe
53
54/* Transmission Space
55 */
56#define HC_REG_Hpara0 0x0040
57#define HC_REG_HpataAF 0x02fc
58
59/* Read
60 */
61#define HC_REG_HREngSt 0x0000
62#define HC_REG_HRFIFOempty 0x0004
63#define HC_REG_HRFIFOfull 0x0008
64#define HC_REG_HRErr 0x000c
65#define HC_REG_FIFOstatus 0x0010
66/* HC_REG_HREngSt 0x0000
67 */
68#define HC_HDASZC_MASK 0x00010000
69#define HC_HSGEMI_MASK 0x0000f000
70#define HC_HLGEMISt_MASK 0x00000f00
71#define HC_HCRSt_MASK 0x00000080
72#define HC_HSE0St_MASK 0x00000040
73#define HC_HSE1St_MASK 0x00000020
74#define HC_HPESt_MASK 0x00000010
75#define HC_HXESt_MASK 0x00000008
76#define HC_HBESt_MASK 0x00000004
77#define HC_HE2St_MASK 0x00000002
78#define HC_HE3St_MASK 0x00000001
79/* HC_REG_HRFIFOempty 0x0004
80 */
81#define HC_HRZDempty_MASK 0x00000010
82#define HC_HRTXAempty_MASK 0x00000008
83#define HC_HRTXDempty_MASK 0x00000004
84#define HC_HWZDempty_MASK 0x00000002
85#define HC_HWCDempty_MASK 0x00000001
86/* HC_REG_HRFIFOfull 0x0008
87 */
88#define HC_HRZDfull_MASK 0x00000010
89#define HC_HRTXAfull_MASK 0x00000008
90#define HC_HRTXDfull_MASK 0x00000004
91#define HC_HWZDfull_MASK 0x00000002
92#define HC_HWCDfull_MASK 0x00000001
93/* HC_REG_HRErr 0x000c
94 */
95#define HC_HAGPCMErr_MASK 0x80000000
96#define HC_HAGPCMErrC_MASK 0x70000000
97/* HC_REG_FIFOstatus 0x0010
98 */
99#define HC_HRFIFOATall_MASK 0x80000000
100#define HC_HRFIFOATbusy_MASK 0x40000000
101#define HC_HRATFGMDo_MASK 0x00000100
102#define HC_HRATFGMDi_MASK 0x00000080
103#define HC_HRATFRZD_MASK 0x00000040
104#define HC_HRATFRTXA_MASK 0x00000020
105#define HC_HRATFRTXD_MASK 0x00000010
106#define HC_HRATFWZD_MASK 0x00000008
107#define HC_HRATFWCD_MASK 0x00000004
108#define HC_HRATTXTAG_MASK 0x00000002
109#define HC_HRATTXCH_MASK 0x00000001
110
111/* AGP Command Setting
112 */
113#define HC_SubA_HAGPBstL 0x0060
114#define HC_SubA_HAGPBendL 0x0061
115#define HC_SubA_HAGPCMNT 0x0062
116#define HC_SubA_HAGPBpL 0x0063
117#define HC_SubA_HAGPBpH 0x0064
118/* HC_SubA_HAGPCMNT 0x0062
119 */
120#define HC_HAGPCMNT_MASK 0x00800000
121#define HC_HCmdErrClr_MASK 0x00400000
122#define HC_HAGPBendH_MASK 0x0000ff00
123#define HC_HAGPBstH_MASK 0x000000ff
124#define HC_HAGPBendH_SHIFT 8
125#define HC_HAGPBstH_SHIFT 0
126/* HC_SubA_HAGPBpL 0x0063
127 */
128#define HC_HAGPBpL_MASK 0x00fffffc
129#define HC_HAGPBpID_MASK 0x00000003
130#define HC_HAGPBpID_PAUSE 0x00000000
131#define HC_HAGPBpID_JUMP 0x00000001
132#define HC_HAGPBpID_STOP 0x00000002
133/* HC_SubA_HAGPBpH 0x0064
134 */
135#define HC_HAGPBpH_MASK 0x00ffffff
136
137/* Miscellaneous Settings
138 */
139#define HC_SubA_HClipTB 0x0070
140#define HC_SubA_HClipLR 0x0071
141#define HC_SubA_HFPClipTL 0x0072
142#define HC_SubA_HFPClipBL 0x0073
143#define HC_SubA_HFPClipLL 0x0074
144#define HC_SubA_HFPClipRL 0x0075
145#define HC_SubA_HFPClipTBH 0x0076
146#define HC_SubA_HFPClipLRH 0x0077
147#define HC_SubA_HLP 0x0078
148#define HC_SubA_HLPRF 0x0079
149#define HC_SubA_HSolidCL 0x007a
150#define HC_SubA_HPixGC 0x007b
151#define HC_SubA_HSPXYOS 0x007c
152#define HC_SubA_HVertexCNT 0x007d
153
154#define HC_HClipT_MASK 0x00fff000
155#define HC_HClipT_SHIFT 12
156#define HC_HClipB_MASK 0x00000fff
157#define HC_HClipB_SHIFT 0
158#define HC_HClipL_MASK 0x00fff000
159#define HC_HClipL_SHIFT 12
160#define HC_HClipR_MASK 0x00000fff
161#define HC_HClipR_SHIFT 0
162#define HC_HFPClipBH_MASK 0x0000ff00
163#define HC_HFPClipBH_SHIFT 8
164#define HC_HFPClipTH_MASK 0x000000ff
165#define HC_HFPClipTH_SHIFT 0
166#define HC_HFPClipRH_MASK 0x0000ff00
167#define HC_HFPClipRH_SHIFT 8
168#define HC_HFPClipLH_MASK 0x000000ff
169#define HC_HFPClipLH_SHIFT 0
170#define HC_HSolidCH_MASK 0x000000ff
171#define HC_HPixGC_MASK 0x00800000
172#define HC_HSPXOS_MASK 0x00fff000
173#define HC_HSPXOS_SHIFT 12
174#define HC_HSPYOS_MASK 0x00000fff
175
176/* Command
177 * Command A
178 */
179#define HC_HCmdHeader_MASK 0xfe000000 /*0xffe00000 */
180#define HC_HE3Fire_MASK 0x00100000
181#define HC_HPMType_MASK 0x000f0000
182#define HC_HEFlag_MASK 0x0000e000
183#define HC_HShading_MASK 0x00001c00
184#define HC_HPMValidN_MASK 0x00000200
185#define HC_HPLEND_MASK 0x00000100
186#define HC_HVCycle_MASK 0x000000ff
187#define HC_HVCycle_Style_MASK 0x000000c0
188#define HC_HVCycle_ChgA_MASK 0x00000030
189#define HC_HVCycle_ChgB_MASK 0x0000000c
190#define HC_HVCycle_ChgC_MASK 0x00000003
191#define HC_HPMType_Point 0x00000000
192#define HC_HPMType_Line 0x00010000
193#define HC_HPMType_Tri 0x00020000
194#define HC_HPMType_TriWF 0x00040000
195#define HC_HEFlag_NoAA 0x00000000
196#define HC_HEFlag_ab 0x00008000
197#define HC_HEFlag_bc 0x00004000
198#define HC_HEFlag_ca 0x00002000
199#define HC_HShading_Solid 0x00000000
200#define HC_HShading_FlatA 0x00000400
201#define HC_HShading_FlatB 0x00000800
202#define HC_HShading_FlatC 0x00000c00
203#define HC_HShading_Gouraud 0x00001000
204#define HC_HVCycle_Full 0x00000000
205#define HC_HVCycle_AFP 0x00000040
206#define HC_HVCycle_One 0x000000c0
207#define HC_HVCycle_NewA 0x00000000
208#define HC_HVCycle_AA 0x00000010
209#define HC_HVCycle_AB 0x00000020
210#define HC_HVCycle_AC 0x00000030
211#define HC_HVCycle_NewB 0x00000000
212#define HC_HVCycle_BA 0x00000004
213#define HC_HVCycle_BB 0x00000008
214#define HC_HVCycle_BC 0x0000000c
215#define HC_HVCycle_NewC 0x00000000
216#define HC_HVCycle_CA 0x00000001
217#define HC_HVCycle_CB 0x00000002
218#define HC_HVCycle_CC 0x00000003
219
220/* Command B
221 */
222#define HC_HLPrst_MASK 0x00010000
223#define HC_HLLastP_MASK 0x00008000
224#define HC_HVPMSK_MASK 0x00007f80
225#define HC_HBFace_MASK 0x00000040
226#define HC_H2nd1VT_MASK 0x0000003f
227#define HC_HVPMSK_X 0x00004000
228#define HC_HVPMSK_Y 0x00002000
229#define HC_HVPMSK_Z 0x00001000
230#define HC_HVPMSK_W 0x00000800
231#define HC_HVPMSK_Cd 0x00000400
232#define HC_HVPMSK_Cs 0x00000200
233#define HC_HVPMSK_S 0x00000100
234#define HC_HVPMSK_T 0x00000080
235
236/* Enable Setting
237 */
238#define HC_SubA_HEnable 0x0000
239#define HC_HenTXEnvMap_MASK 0x00200000
240#define HC_HenVertexCNT_MASK 0x00100000
241#define HC_HenCPUDAZ_MASK 0x00080000
242#define HC_HenDASZWC_MASK 0x00040000
243#define HC_HenFBCull_MASK 0x00020000
244#define HC_HenCW_MASK 0x00010000
245#define HC_HenAA_MASK 0x00008000
246#define HC_HenST_MASK 0x00004000
247#define HC_HenZT_MASK 0x00002000
248#define HC_HenZW_MASK 0x00001000
249#define HC_HenAT_MASK 0x00000800
250#define HC_HenAW_MASK 0x00000400
251#define HC_HenSP_MASK 0x00000200
252#define HC_HenLP_MASK 0x00000100
253#define HC_HenTXCH_MASK 0x00000080
254#define HC_HenTXMP_MASK 0x00000040
255#define HC_HenTXPP_MASK 0x00000020
256#define HC_HenTXTR_MASK 0x00000010
257#define HC_HenCS_MASK 0x00000008
258#define HC_HenFOG_MASK 0x00000004
259#define HC_HenABL_MASK 0x00000002
260#define HC_HenDT_MASK 0x00000001
261
262/* Z Setting
263 */
264#define HC_SubA_HZWBBasL 0x0010
265#define HC_SubA_HZWBBasH 0x0011
266#define HC_SubA_HZWBType 0x0012
267#define HC_SubA_HZBiasL 0x0013
268#define HC_SubA_HZWBend 0x0014
269#define HC_SubA_HZWTMD 0x0015
270#define HC_SubA_HZWCDL 0x0016
271#define HC_SubA_HZWCTAGnum 0x0017
272#define HC_SubA_HZCYNum 0x0018
273#define HC_SubA_HZWCFire 0x0019
274/* HC_SubA_HZWBType
275 */
276#define HC_HZWBType_MASK 0x00800000
277#define HC_HZBiasedWB_MASK 0x00400000
278#define HC_HZONEasFF_MASK 0x00200000
279#define HC_HZOONEasFF_MASK 0x00100000
280#define HC_HZWBFM_MASK 0x00030000
281#define HC_HZWBLoc_MASK 0x0000c000
282#define HC_HZWBPit_MASK 0x00003fff
283#define HC_HZWBFM_16 0x00000000
284#define HC_HZWBFM_32 0x00020000
285#define HC_HZWBFM_24 0x00030000
286#define HC_HZWBLoc_Local 0x00000000
287#define HC_HZWBLoc_SyS 0x00004000
288/* HC_SubA_HZWBend
289 */
290#define HC_HZWBend_MASK 0x00ffe000
291#define HC_HZBiasH_MASK 0x000000ff
292#define HC_HZWBend_SHIFT 10
293/* HC_SubA_HZWTMD
294 */
295#define HC_HZWTMD_MASK 0x00070000
296#define HC_HEBEBias_MASK 0x00007f00
297#define HC_HZNF_MASK 0x000000ff
298#define HC_HZWTMD_NeverPass 0x00000000
299#define HC_HZWTMD_LT 0x00010000
300#define HC_HZWTMD_EQ 0x00020000
301#define HC_HZWTMD_LE 0x00030000
302#define HC_HZWTMD_GT 0x00040000
303#define HC_HZWTMD_NE 0x00050000
304#define HC_HZWTMD_GE 0x00060000
305#define HC_HZWTMD_AllPass 0x00070000
306#define HC_HEBEBias_SHIFT 8
307/* HC_SubA_HZWCDL 0x0016
308 */
309#define HC_HZWCDL_MASK 0x00ffffff
310/* HC_SubA_HZWCTAGnum 0x0017
311 */
312#define HC_HZWCTAGnum_MASK 0x00ff0000
313#define HC_HZWCTAGnum_SHIFT 16
314#define HC_HZWCDH_MASK 0x000000ff
315#define HC_HZWCDH_SHIFT 0
316/* HC_SubA_HZCYNum 0x0018
317 */
318#define HC_HZCYNum_MASK 0x00030000
319#define HC_HZCYNum_SHIFT 16
320#define HC_HZWCQWnum_MASK 0x00003fff
321#define HC_HZWCQWnum_SHIFT 0
322/* HC_SubA_HZWCFire 0x0019
323 */
324#define HC_ZWCFire_MASK 0x00010000
325#define HC_HZWCQWnumLast_MASK 0x00003fff
326#define HC_HZWCQWnumLast_SHIFT 0
327
328/* Stencil Setting
329 */
330#define HC_SubA_HSTREF 0x0023
331#define HC_SubA_HSTMD 0x0024
332/* HC_SubA_HSBFM
333 */
334#define HC_HSBFM_MASK 0x00030000
335#define HC_HSBLoc_MASK 0x0000c000
336#define HC_HSBPit_MASK 0x00003fff
337/* HC_SubA_HSTREF
338 */
339#define HC_HSTREF_MASK 0x00ff0000
340#define HC_HSTOPMSK_MASK 0x0000ff00
341#define HC_HSTBMSK_MASK 0x000000ff
342#define HC_HSTREF_SHIFT 16
343#define HC_HSTOPMSK_SHIFT 8
344/* HC_SubA_HSTMD
345 */
346#define HC_HSTMD_MASK 0x00070000
347#define HC_HSTOPSF_MASK 0x000001c0
348#define HC_HSTOPSPZF_MASK 0x00000038
349#define HC_HSTOPSPZP_MASK 0x00000007
350#define HC_HSTMD_NeverPass 0x00000000
351#define HC_HSTMD_LT 0x00010000
352#define HC_HSTMD_EQ 0x00020000
353#define HC_HSTMD_LE 0x00030000
354#define HC_HSTMD_GT 0x00040000
355#define HC_HSTMD_NE 0x00050000
356#define HC_HSTMD_GE 0x00060000
357#define HC_HSTMD_AllPass 0x00070000
358#define HC_HSTOPSF_KEEP 0x00000000
359#define HC_HSTOPSF_ZERO 0x00000040
360#define HC_HSTOPSF_REPLACE 0x00000080
361#define HC_HSTOPSF_INCRSAT 0x000000c0
362#define HC_HSTOPSF_DECRSAT 0x00000100
363#define HC_HSTOPSF_INVERT 0x00000140
364#define HC_HSTOPSF_INCR 0x00000180
365#define HC_HSTOPSF_DECR 0x000001c0
366#define HC_HSTOPSPZF_KEEP 0x00000000
367#define HC_HSTOPSPZF_ZERO 0x00000008
368#define HC_HSTOPSPZF_REPLACE 0x00000010
369#define HC_HSTOPSPZF_INCRSAT 0x00000018
370#define HC_HSTOPSPZF_DECRSAT 0x00000020
371#define HC_HSTOPSPZF_INVERT 0x00000028
372#define HC_HSTOPSPZF_INCR 0x00000030
373#define HC_HSTOPSPZF_DECR 0x00000038
374#define HC_HSTOPSPZP_KEEP 0x00000000
375#define HC_HSTOPSPZP_ZERO 0x00000001
376#define HC_HSTOPSPZP_REPLACE 0x00000002
377#define HC_HSTOPSPZP_INCRSAT 0x00000003
378#define HC_HSTOPSPZP_DECRSAT 0x00000004
379#define HC_HSTOPSPZP_INVERT 0x00000005
380#define HC_HSTOPSPZP_INCR 0x00000006
381#define HC_HSTOPSPZP_DECR 0x00000007
382
383/* Alpha Setting
384 */
385#define HC_SubA_HABBasL 0x0030
386#define HC_SubA_HABBasH 0x0031
387#define HC_SubA_HABFM 0x0032
388#define HC_SubA_HATMD 0x0033
389#define HC_SubA_HABLCsat 0x0034
390#define HC_SubA_HABLCop 0x0035
391#define HC_SubA_HABLAsat 0x0036
392#define HC_SubA_HABLAop 0x0037
393#define HC_SubA_HABLRCa 0x0038
394#define HC_SubA_HABLRFCa 0x0039
395#define HC_SubA_HABLRCbias 0x003a
396#define HC_SubA_HABLRCb 0x003b
397#define HC_SubA_HABLRFCb 0x003c
398#define HC_SubA_HABLRAa 0x003d
399#define HC_SubA_HABLRAb 0x003e
400/* HC_SubA_HABFM
401 */
402#define HC_HABFM_MASK 0x00030000
403#define HC_HABLoc_MASK 0x0000c000
404#define HC_HABPit_MASK 0x000007ff
405/* HC_SubA_HATMD
406 */
407#define HC_HATMD_MASK 0x00000700
408#define HC_HATREF_MASK 0x000000ff
409#define HC_HATMD_NeverPass 0x00000000
410#define HC_HATMD_LT 0x00000100
411#define HC_HATMD_EQ 0x00000200
412#define HC_HATMD_LE 0x00000300
413#define HC_HATMD_GT 0x00000400
414#define HC_HATMD_NE 0x00000500
415#define HC_HATMD_GE 0x00000600
416#define HC_HATMD_AllPass 0x00000700
417/* HC_SubA_HABLCsat
418 */
419#define HC_HABLCsat_MASK 0x00010000
420#define HC_HABLCa_MASK 0x0000fc00
421#define HC_HABLCa_C_MASK 0x0000c000
422#define HC_HABLCa_OPC_MASK 0x00003c00
423#define HC_HABLFCa_MASK 0x000003f0
424#define HC_HABLFCa_C_MASK 0x00000300
425#define HC_HABLFCa_OPC_MASK 0x000000f0
426#define HC_HABLCbias_MASK 0x0000000f
427#define HC_HABLCbias_C_MASK 0x00000008
428#define HC_HABLCbias_OPC_MASK 0x00000007
429/*-- Define the input color.
430 */
431#define HC_XC_Csrc 0x00000000
432#define HC_XC_Cdst 0x00000001
433#define HC_XC_Asrc 0x00000002
434#define HC_XC_Adst 0x00000003
435#define HC_XC_Fog 0x00000004
436#define HC_XC_HABLRC 0x00000005
437#define HC_XC_minSrcDst 0x00000006
438#define HC_XC_maxSrcDst 0x00000007
439#define HC_XC_mimAsrcInvAdst 0x00000008
440#define HC_XC_OPC 0x00000000
441#define HC_XC_InvOPC 0x00000010
442#define HC_XC_OPCp5 0x00000020
443/*-- Define the input Alpha
444 */
445#define HC_XA_OPA 0x00000000
446#define HC_XA_InvOPA 0x00000010
447#define HC_XA_OPAp5 0x00000020
448#define HC_XA_0 0x00000000
449#define HC_XA_Asrc 0x00000001
450#define HC_XA_Adst 0x00000002
451#define HC_XA_Fog 0x00000003
452#define HC_XA_minAsrcFog 0x00000004
453#define HC_XA_minAsrcAdst 0x00000005
454#define HC_XA_maxAsrcFog 0x00000006
455#define HC_XA_maxAsrcAdst 0x00000007
456#define HC_XA_HABLRA 0x00000008
457#define HC_XA_minAsrcInvAdst 0x00000008
458#define HC_XA_HABLFRA 0x00000009
459/*--
460 */
461#define HC_HABLCa_OPC (HC_XC_OPC << 10)
462#define HC_HABLCa_InvOPC (HC_XC_InvOPC << 10)
463#define HC_HABLCa_OPCp5 (HC_XC_OPCp5 << 10)
464#define HC_HABLCa_Csrc (HC_XC_Csrc << 10)
465#define HC_HABLCa_Cdst (HC_XC_Cdst << 10)
466#define HC_HABLCa_Asrc (HC_XC_Asrc << 10)
467#define HC_HABLCa_Adst (HC_XC_Adst << 10)
468#define HC_HABLCa_Fog (HC_XC_Fog << 10)
469#define HC_HABLCa_HABLRCa (HC_XC_HABLRC << 10)
470#define HC_HABLCa_minSrcDst (HC_XC_minSrcDst << 10)
471#define HC_HABLCa_maxSrcDst (HC_XC_maxSrcDst << 10)
472#define HC_HABLFCa_OPC (HC_XC_OPC << 4)
473#define HC_HABLFCa_InvOPC (HC_XC_InvOPC << 4)
474#define HC_HABLFCa_OPCp5 (HC_XC_OPCp5 << 4)
475#define HC_HABLFCa_Csrc (HC_XC_Csrc << 4)
476#define HC_HABLFCa_Cdst (HC_XC_Cdst << 4)
477#define HC_HABLFCa_Asrc (HC_XC_Asrc << 4)
478#define HC_HABLFCa_Adst (HC_XC_Adst << 4)
479#define HC_HABLFCa_Fog (HC_XC_Fog << 4)
480#define HC_HABLFCa_HABLRCa (HC_XC_HABLRC << 4)
481#define HC_HABLFCa_minSrcDst (HC_XC_minSrcDst << 4)
482#define HC_HABLFCa_maxSrcDst (HC_XC_maxSrcDst << 4)
483#define HC_HABLFCa_mimAsrcInvAdst (HC_XC_mimAsrcInvAdst << 4)
484#define HC_HABLCbias_HABLRCbias 0x00000000
485#define HC_HABLCbias_Asrc 0x00000001
486#define HC_HABLCbias_Adst 0x00000002
487#define HC_HABLCbias_Fog 0x00000003
488#define HC_HABLCbias_Cin 0x00000004
489/* HC_SubA_HABLCop 0x0035
490 */
491#define HC_HABLdot_MASK 0x00010000
492#define HC_HABLCop_MASK 0x00004000
493#define HC_HABLCb_MASK 0x00003f00
494#define HC_HABLCb_C_MASK 0x00003000
495#define HC_HABLCb_OPC_MASK 0x00000f00
496#define HC_HABLFCb_MASK 0x000000fc
497#define HC_HABLFCb_C_MASK 0x000000c0
498#define HC_HABLFCb_OPC_MASK 0x0000003c
499#define HC_HABLCshift_MASK 0x00000003
500#define HC_HABLCb_OPC (HC_XC_OPC << 8)
501#define HC_HABLCb_InvOPC (HC_XC_InvOPC << 8)
502#define HC_HABLCb_OPCp5 (HC_XC_OPCp5 << 8)
503#define HC_HABLCb_Csrc (HC_XC_Csrc << 8)
504#define HC_HABLCb_Cdst (HC_XC_Cdst << 8)
505#define HC_HABLCb_Asrc (HC_XC_Asrc << 8)
506#define HC_HABLCb_Adst (HC_XC_Adst << 8)
507#define HC_HABLCb_Fog (HC_XC_Fog << 8)
508#define HC_HABLCb_HABLRCa (HC_XC_HABLRC << 8)
509#define HC_HABLCb_minSrcDst (HC_XC_minSrcDst << 8)
510#define HC_HABLCb_maxSrcDst (HC_XC_maxSrcDst << 8)
511#define HC_HABLFCb_OPC (HC_XC_OPC << 2)
512#define HC_HABLFCb_InvOPC (HC_XC_InvOPC << 2)
513#define HC_HABLFCb_OPCp5 (HC_XC_OPCp5 << 2)
514#define HC_HABLFCb_Csrc (HC_XC_Csrc << 2)
515#define HC_HABLFCb_Cdst (HC_XC_Cdst << 2)
516#define HC_HABLFCb_Asrc (HC_XC_Asrc << 2)
517#define HC_HABLFCb_Adst (HC_XC_Adst << 2)
518#define HC_HABLFCb_Fog (HC_XC_Fog << 2)
519#define HC_HABLFCb_HABLRCb (HC_XC_HABLRC << 2)
520#define HC_HABLFCb_minSrcDst (HC_XC_minSrcDst << 2)
521#define HC_HABLFCb_maxSrcDst (HC_XC_maxSrcDst << 2)
522#define HC_HABLFCb_mimAsrcInvAdst (HC_XC_mimAsrcInvAdst << 2)
523/* HC_SubA_HABLAsat 0x0036
524 */
525#define HC_HABLAsat_MASK 0x00010000
526#define HC_HABLAa_MASK 0x0000fc00
527#define HC_HABLAa_A_MASK 0x0000c000
528#define HC_HABLAa_OPA_MASK 0x00003c00
529#define HC_HABLFAa_MASK 0x000003f0
530#define HC_HABLFAa_A_MASK 0x00000300
531#define HC_HABLFAa_OPA_MASK 0x000000f0
532#define HC_HABLAbias_MASK 0x0000000f
533#define HC_HABLAbias_A_MASK 0x00000008
534#define HC_HABLAbias_OPA_MASK 0x00000007
535#define HC_HABLAa_OPA (HC_XA_OPA << 10)
536#define HC_HABLAa_InvOPA (HC_XA_InvOPA << 10)
537#define HC_HABLAa_OPAp5 (HC_XA_OPAp5 << 10)
538#define HC_HABLAa_0 (HC_XA_0 << 10)
539#define HC_HABLAa_Asrc (HC_XA_Asrc << 10)
540#define HC_HABLAa_Adst (HC_XA_Adst << 10)
541#define HC_HABLAa_Fog (HC_XA_Fog << 10)
542#define HC_HABLAa_minAsrcFog (HC_XA_minAsrcFog << 10)
543#define HC_HABLAa_minAsrcAdst (HC_XA_minAsrcAdst << 10)
544#define HC_HABLAa_maxAsrcFog (HC_XA_maxAsrcFog << 10)
545#define HC_HABLAa_maxAsrcAdst (HC_XA_maxAsrcAdst << 10)
546#define HC_HABLAa_HABLRA (HC_XA_HABLRA << 10)
547#define HC_HABLFAa_OPA (HC_XA_OPA << 4)
548#define HC_HABLFAa_InvOPA (HC_XA_InvOPA << 4)
549#define HC_HABLFAa_OPAp5 (HC_XA_OPAp5 << 4)
550#define HC_HABLFAa_0 (HC_XA_0 << 4)
551#define HC_HABLFAa_Asrc (HC_XA_Asrc << 4)
552#define HC_HABLFAa_Adst (HC_XA_Adst << 4)
553#define HC_HABLFAa_Fog (HC_XA_Fog << 4)
554#define HC_HABLFAa_minAsrcFog (HC_XA_minAsrcFog << 4)
555#define HC_HABLFAa_minAsrcAdst (HC_XA_minAsrcAdst << 4)
556#define HC_HABLFAa_maxAsrcFog (HC_XA_maxAsrcFog << 4)
557#define HC_HABLFAa_maxAsrcAdst (HC_XA_maxAsrcAdst << 4)
558#define HC_HABLFAa_minAsrcInvAdst (HC_XA_minAsrcInvAdst << 4)
559#define HC_HABLFAa_HABLFRA (HC_XA_HABLFRA << 4)
560#define HC_HABLAbias_HABLRAbias 0x00000000
561#define HC_HABLAbias_Asrc 0x00000001
562#define HC_HABLAbias_Adst 0x00000002
563#define HC_HABLAbias_Fog 0x00000003
564#define HC_HABLAbias_Aaa 0x00000004
565/* HC_SubA_HABLAop 0x0037
566 */
567#define HC_HABLAop_MASK 0x00004000
568#define HC_HABLAb_MASK 0x00003f00
569#define HC_HABLAb_OPA_MASK 0x00000f00
570#define HC_HABLFAb_MASK 0x000000fc
571#define HC_HABLFAb_OPA_MASK 0x0000003c
572#define HC_HABLAshift_MASK 0x00000003
573#define HC_HABLAb_OPA (HC_XA_OPA << 8)
574#define HC_HABLAb_InvOPA (HC_XA_InvOPA << 8)
575#define HC_HABLAb_OPAp5 (HC_XA_OPAp5 << 8)
576#define HC_HABLAb_0 (HC_XA_0 << 8)
577#define HC_HABLAb_Asrc (HC_XA_Asrc << 8)
578#define HC_HABLAb_Adst (HC_XA_Adst << 8)
579#define HC_HABLAb_Fog (HC_XA_Fog << 8)
580#define HC_HABLAb_minAsrcFog (HC_XA_minAsrcFog << 8)
581#define HC_HABLAb_minAsrcAdst (HC_XA_minAsrcAdst << 8)
582#define HC_HABLAb_maxAsrcFog (HC_XA_maxAsrcFog << 8)
583#define HC_HABLAb_maxAsrcAdst (HC_XA_maxAsrcAdst << 8)
584#define HC_HABLAb_HABLRA (HC_XA_HABLRA << 8)
585#define HC_HABLFAb_OPA (HC_XA_OPA << 2)
586#define HC_HABLFAb_InvOPA (HC_XA_InvOPA << 2)
587#define HC_HABLFAb_OPAp5 (HC_XA_OPAp5 << 2)
588#define HC_HABLFAb_0 (HC_XA_0 << 2)
589#define HC_HABLFAb_Asrc (HC_XA_Asrc << 2)
590#define HC_HABLFAb_Adst (HC_XA_Adst << 2)
591#define HC_HABLFAb_Fog (HC_XA_Fog << 2)
592#define HC_HABLFAb_minAsrcFog (HC_XA_minAsrcFog << 2)
593#define HC_HABLFAb_minAsrcAdst (HC_XA_minAsrcAdst << 2)
594#define HC_HABLFAb_maxAsrcFog (HC_XA_maxAsrcFog << 2)
595#define HC_HABLFAb_maxAsrcAdst (HC_XA_maxAsrcAdst << 2)
596#define HC_HABLFAb_minAsrcInvAdst (HC_XA_minAsrcInvAdst << 2)
597#define HC_HABLFAb_HABLFRA (HC_XA_HABLFRA << 2)
598/* HC_SubA_HABLRAa 0x003d
599 */
600#define HC_HABLRAa_MASK 0x00ff0000
601#define HC_HABLRFAa_MASK 0x0000ff00
602#define HC_HABLRAbias_MASK 0x000000ff
603#define HC_HABLRAa_SHIFT 16
604#define HC_HABLRFAa_SHIFT 8
605/* HC_SubA_HABLRAb 0x003e
606 */
607#define HC_HABLRAb_MASK 0x0000ff00
608#define HC_HABLRFAb_MASK 0x000000ff
609#define HC_HABLRAb_SHIFT 8
610
611/* Destination Setting
612 */
613#define HC_SubA_HDBBasL 0x0040
614#define HC_SubA_HDBBasH 0x0041
615#define HC_SubA_HDBFM 0x0042
616#define HC_SubA_HFBBMSKL 0x0043
617#define HC_SubA_HROP 0x0044
618/* HC_SubA_HDBFM 0x0042
619 */
620#define HC_HDBFM_MASK 0x001f0000
621#define HC_HDBLoc_MASK 0x0000c000
622#define HC_HDBPit_MASK 0x00003fff
623#define HC_HDBFM_RGB555 0x00000000
624#define HC_HDBFM_RGB565 0x00010000
625#define HC_HDBFM_ARGB4444 0x00020000
626#define HC_HDBFM_ARGB1555 0x00030000
627#define HC_HDBFM_BGR555 0x00040000
628#define HC_HDBFM_BGR565 0x00050000
629#define HC_HDBFM_ABGR4444 0x00060000
630#define HC_HDBFM_ABGR1555 0x00070000
631#define HC_HDBFM_ARGB0888 0x00080000
632#define HC_HDBFM_ARGB8888 0x00090000
633#define HC_HDBFM_ABGR0888 0x000a0000
634#define HC_HDBFM_ABGR8888 0x000b0000
635#define HC_HDBLoc_Local 0x00000000
636#define HC_HDBLoc_Sys 0x00004000
637/* HC_SubA_HROP 0x0044
638 */
639#define HC_HROP_MASK 0x00000f00
640#define HC_HFBBMSKH_MASK 0x000000ff
641#define HC_HROP_BLACK 0x00000000
642#define HC_HROP_DPon 0x00000100
643#define HC_HROP_DPna 0x00000200
644#define HC_HROP_Pn 0x00000300
645#define HC_HROP_PDna 0x00000400
646#define HC_HROP_Dn 0x00000500
647#define HC_HROP_DPx 0x00000600
648#define HC_HROP_DPan 0x00000700
649#define HC_HROP_DPa 0x00000800
650#define HC_HROP_DPxn 0x00000900
651#define HC_HROP_D 0x00000a00
652#define HC_HROP_DPno 0x00000b00
653#define HC_HROP_P 0x00000c00
654#define HC_HROP_PDno 0x00000d00
655#define HC_HROP_DPo 0x00000e00
656#define HC_HROP_WHITE 0x00000f00
657
658/* Fog Setting
659 */
660#define HC_SubA_HFogLF 0x0050
661#define HC_SubA_HFogCL 0x0051
662#define HC_SubA_HFogCH 0x0052
663#define HC_SubA_HFogStL 0x0053
664#define HC_SubA_HFogStH 0x0054
665#define HC_SubA_HFogOOdMF 0x0055
666#define HC_SubA_HFogOOdEF 0x0056
667#define HC_SubA_HFogEndL 0x0057
668#define HC_SubA_HFogDenst 0x0058
669/* HC_SubA_FogLF 0x0050
670 */
671#define HC_FogLF_MASK 0x00000010
672#define HC_FogEq_MASK 0x00000008
673#define HC_FogMD_MASK 0x00000007
674#define HC_FogMD_LocalFog 0x00000000
675#define HC_FogMD_LinearFog 0x00000002
676#define HC_FogMD_ExponentialFog 0x00000004
677#define HC_FogMD_Exponential2Fog 0x00000005
678/* #define HC_FogMD_FogTable 0x00000003 */
679
680/* HC_SubA_HFogDenst 0x0058
681 */
682#define HC_FogDenst_MASK 0x001fff00
683#define HC_FogEndL_MASK 0x000000ff
684
685/* Texture subtype definitions
686 */
687#define HC_SubType_Tex0 0x00000000
688#define HC_SubType_Tex1 0x00000001
689#define HC_SubType_TexGeneral 0x000000fe
690
691/* Attribute of texture n
692 */
693#define HC_SubA_HTXnL0BasL 0x0000
694#define HC_SubA_HTXnL1BasL 0x0001
695#define HC_SubA_HTXnL2BasL 0x0002
696#define HC_SubA_HTXnL3BasL 0x0003
697#define HC_SubA_HTXnL4BasL 0x0004
698#define HC_SubA_HTXnL5BasL 0x0005
699#define HC_SubA_HTXnL6BasL 0x0006
700#define HC_SubA_HTXnL7BasL 0x0007
701#define HC_SubA_HTXnL8BasL 0x0008
702#define HC_SubA_HTXnL9BasL 0x0009
703#define HC_SubA_HTXnLaBasL 0x000a
704#define HC_SubA_HTXnLbBasL 0x000b
705#define HC_SubA_HTXnLcBasL 0x000c
706#define HC_SubA_HTXnLdBasL 0x000d
707#define HC_SubA_HTXnLeBasL 0x000e
708#define HC_SubA_HTXnLfBasL 0x000f
709#define HC_SubA_HTXnL10BasL 0x0010
710#define HC_SubA_HTXnL11BasL 0x0011
711#define HC_SubA_HTXnL012BasH 0x0020
712#define HC_SubA_HTXnL345BasH 0x0021
713#define HC_SubA_HTXnL678BasH 0x0022
714#define HC_SubA_HTXnL9abBasH 0x0023
715#define HC_SubA_HTXnLcdeBasH 0x0024
716#define HC_SubA_HTXnLf1011BasH 0x0025
717#define HC_SubA_HTXnL0Pit 0x002b
718#define HC_SubA_HTXnL1Pit 0x002c
719#define HC_SubA_HTXnL2Pit 0x002d
720#define HC_SubA_HTXnL3Pit 0x002e
721#define HC_SubA_HTXnL4Pit 0x002f
722#define HC_SubA_HTXnL5Pit 0x0030
723#define HC_SubA_HTXnL6Pit 0x0031
724#define HC_SubA_HTXnL7Pit 0x0032
725#define HC_SubA_HTXnL8Pit 0x0033
726#define HC_SubA_HTXnL9Pit 0x0034
727#define HC_SubA_HTXnLaPit 0x0035
728#define HC_SubA_HTXnLbPit 0x0036
729#define HC_SubA_HTXnLcPit 0x0037
730#define HC_SubA_HTXnLdPit 0x0038
731#define HC_SubA_HTXnLePit 0x0039
732#define HC_SubA_HTXnLfPit 0x003a
733#define HC_SubA_HTXnL10Pit 0x003b
734#define HC_SubA_HTXnL11Pit 0x003c
735#define HC_SubA_HTXnL0_5WE 0x004b
736#define HC_SubA_HTXnL6_bWE 0x004c
737#define HC_SubA_HTXnLc_11WE 0x004d
738#define HC_SubA_HTXnL0_5HE 0x0051
739#define HC_SubA_HTXnL6_bHE 0x0052
740#define HC_SubA_HTXnLc_11HE 0x0053
741#define HC_SubA_HTXnL0OS 0x0077
742#define HC_SubA_HTXnTB 0x0078
743#define HC_SubA_HTXnMPMD 0x0079
744#define HC_SubA_HTXnCLODu 0x007a
745#define HC_SubA_HTXnFM 0x007b
746#define HC_SubA_HTXnTRCH 0x007c
747#define HC_SubA_HTXnTRCL 0x007d
748#define HC_SubA_HTXnTBC 0x007e
749#define HC_SubA_HTXnTRAH 0x007f
750#define HC_SubA_HTXnTBLCsat 0x0080
751#define HC_SubA_HTXnTBLCop 0x0081
752#define HC_SubA_HTXnTBLMPfog 0x0082
753#define HC_SubA_HTXnTBLAsat 0x0083
754#define HC_SubA_HTXnTBLRCa 0x0085
755#define HC_SubA_HTXnTBLRCb 0x0086
756#define HC_SubA_HTXnTBLRCc 0x0087
757#define HC_SubA_HTXnTBLRCbias 0x0088
758#define HC_SubA_HTXnTBLRAa 0x0089
759#define HC_SubA_HTXnTBLRFog 0x008a
760#define HC_SubA_HTXnBumpM00 0x0090
761#define HC_SubA_HTXnBumpM01 0x0091
762#define HC_SubA_HTXnBumpM10 0x0092
763#define HC_SubA_HTXnBumpM11 0x0093
764#define HC_SubA_HTXnLScale 0x0094
765#define HC_SubA_HTXSMD 0x0000
766/* HC_SubA_HTXnL012BasH 0x0020
767 */
768#define HC_HTXnL0BasH_MASK 0x000000ff
769#define HC_HTXnL1BasH_MASK 0x0000ff00
770#define HC_HTXnL2BasH_MASK 0x00ff0000
771#define HC_HTXnL1BasH_SHIFT 8
772#define HC_HTXnL2BasH_SHIFT 16
773/* HC_SubA_HTXnL345BasH 0x0021
774 */
775#define HC_HTXnL3BasH_MASK 0x000000ff
776#define HC_HTXnL4BasH_MASK 0x0000ff00
777#define HC_HTXnL5BasH_MASK 0x00ff0000
778#define HC_HTXnL4BasH_SHIFT 8
779#define HC_HTXnL5BasH_SHIFT 16
780/* HC_SubA_HTXnL678BasH 0x0022
781 */
782#define HC_HTXnL6BasH_MASK 0x000000ff
783#define HC_HTXnL7BasH_MASK 0x0000ff00
784#define HC_HTXnL8BasH_MASK 0x00ff0000
785#define HC_HTXnL7BasH_SHIFT 8
786#define HC_HTXnL8BasH_SHIFT 16
787/* HC_SubA_HTXnL9abBasH 0x0023
788 */
789#define HC_HTXnL9BasH_MASK 0x000000ff
790#define HC_HTXnLaBasH_MASK 0x0000ff00
791#define HC_HTXnLbBasH_MASK 0x00ff0000
792#define HC_HTXnLaBasH_SHIFT 8
793#define HC_HTXnLbBasH_SHIFT 16
794/* HC_SubA_HTXnLcdeBasH 0x0024
795 */
796#define HC_HTXnLcBasH_MASK 0x000000ff
797#define HC_HTXnLdBasH_MASK 0x0000ff00
798#define HC_HTXnLeBasH_MASK 0x00ff0000
799#define HC_HTXnLdBasH_SHIFT 8
800#define HC_HTXnLeBasH_SHIFT 16
801/* HC_SubA_HTXnLcdeBasH 0x0025
802 */
803#define HC_HTXnLfBasH_MASK 0x000000ff
804#define HC_HTXnL10BasH_MASK 0x0000ff00
805#define HC_HTXnL11BasH_MASK 0x00ff0000
806#define HC_HTXnL10BasH_SHIFT 8
807#define HC_HTXnL11BasH_SHIFT 16
808/* HC_SubA_HTXnL0Pit 0x002b
809 */
810#define HC_HTXnLnPit_MASK 0x00003fff
811#define HC_HTXnEnPit_MASK 0x00080000
812#define HC_HTXnLnPitE_MASK 0x00f00000
813#define HC_HTXnLnPitE_SHIFT 20
814/* HC_SubA_HTXnL0_5WE 0x004b
815 */
816#define HC_HTXnL0WE_MASK 0x0000000f
817#define HC_HTXnL1WE_MASK 0x000000f0
818#define HC_HTXnL2WE_MASK 0x00000f00
819#define HC_HTXnL3WE_MASK 0x0000f000
820#define HC_HTXnL4WE_MASK 0x000f0000
821#define HC_HTXnL5WE_MASK 0x00f00000
822#define HC_HTXnL1WE_SHIFT 4
823#define HC_HTXnL2WE_SHIFT 8
824#define HC_HTXnL3WE_SHIFT 12
825#define HC_HTXnL4WE_SHIFT 16
826#define HC_HTXnL5WE_SHIFT 20
827/* HC_SubA_HTXnL6_bWE 0x004c
828 */
829#define HC_HTXnL6WE_MASK 0x0000000f
830#define HC_HTXnL7WE_MASK 0x000000f0
831#define HC_HTXnL8WE_MASK 0x00000f00
832#define HC_HTXnL9WE_MASK 0x0000f000
833#define HC_HTXnLaWE_MASK 0x000f0000
834#define HC_HTXnLbWE_MASK 0x00f00000
835#define HC_HTXnL7WE_SHIFT 4
836#define HC_HTXnL8WE_SHIFT 8
837#define HC_HTXnL9WE_SHIFT 12
838#define HC_HTXnLaWE_SHIFT 16
839#define HC_HTXnLbWE_SHIFT 20
840/* HC_SubA_HTXnLc_11WE 0x004d
841 */
842#define HC_HTXnLcWE_MASK 0x0000000f
843#define HC_HTXnLdWE_MASK 0x000000f0
844#define HC_HTXnLeWE_MASK 0x00000f00
845#define HC_HTXnLfWE_MASK 0x0000f000
846#define HC_HTXnL10WE_MASK 0x000f0000
847#define HC_HTXnL11WE_MASK 0x00f00000
848#define HC_HTXnLdWE_SHIFT 4
849#define HC_HTXnLeWE_SHIFT 8
850#define HC_HTXnLfWE_SHIFT 12
851#define HC_HTXnL10WE_SHIFT 16
852#define HC_HTXnL11WE_SHIFT 20
853/* HC_SubA_HTXnL0_5HE 0x0051
854 */
855#define HC_HTXnL0HE_MASK 0x0000000f
856#define HC_HTXnL1HE_MASK 0x000000f0
857#define HC_HTXnL2HE_MASK 0x00000f00
858#define HC_HTXnL3HE_MASK 0x0000f000
859#define HC_HTXnL4HE_MASK 0x000f0000
860#define HC_HTXnL5HE_MASK 0x00f00000
861#define HC_HTXnL1HE_SHIFT 4
862#define HC_HTXnL2HE_SHIFT 8
863#define HC_HTXnL3HE_SHIFT 12
864#define HC_HTXnL4HE_SHIFT 16
865#define HC_HTXnL5HE_SHIFT 20
866/* HC_SubA_HTXnL6_bHE 0x0052
867 */
868#define HC_HTXnL6HE_MASK 0x0000000f
869#define HC_HTXnL7HE_MASK 0x000000f0
870#define HC_HTXnL8HE_MASK 0x00000f00
871#define HC_HTXnL9HE_MASK 0x0000f000
872#define HC_HTXnLaHE_MASK 0x000f0000
873#define HC_HTXnLbHE_MASK 0x00f00000
874#define HC_HTXnL7HE_SHIFT 4
875#define HC_HTXnL8HE_SHIFT 8
876#define HC_HTXnL9HE_SHIFT 12
877#define HC_HTXnLaHE_SHIFT 16
878#define HC_HTXnLbHE_SHIFT 20
879/* HC_SubA_HTXnLc_11HE 0x0053
880 */
881#define HC_HTXnLcHE_MASK 0x0000000f
882#define HC_HTXnLdHE_MASK 0x000000f0
883#define HC_HTXnLeHE_MASK 0x00000f00
884#define HC_HTXnLfHE_MASK 0x0000f000
885#define HC_HTXnL10HE_MASK 0x000f0000
886#define HC_HTXnL11HE_MASK 0x00f00000
887#define HC_HTXnLdHE_SHIFT 4
888#define HC_HTXnLeHE_SHIFT 8
889#define HC_HTXnLfHE_SHIFT 12
890#define HC_HTXnL10HE_SHIFT 16
891#define HC_HTXnL11HE_SHIFT 20
892/* HC_SubA_HTXnL0OS 0x0077
893 */
894#define HC_HTXnL0OS_MASK 0x003ff000
895#define HC_HTXnLVmax_MASK 0x00000fc0
896#define HC_HTXnLVmin_MASK 0x0000003f
897#define HC_HTXnL0OS_SHIFT 12
898#define HC_HTXnLVmax_SHIFT 6
899/* HC_SubA_HTXnTB 0x0078
900 */
901#define HC_HTXnTB_MASK 0x00f00000
902#define HC_HTXnFLSe_MASK 0x0000e000
903#define HC_HTXnFLSs_MASK 0x00001c00
904#define HC_HTXnFLTe_MASK 0x00000380
905#define HC_HTXnFLTs_MASK 0x00000070
906#define HC_HTXnFLDs_MASK 0x0000000f
907#define HC_HTXnTB_NoTB 0x00000000
908#define HC_HTXnTB_TBC_S 0x00100000
909#define HC_HTXnTB_TBC_T 0x00200000
910#define HC_HTXnTB_TB_S 0x00400000
911#define HC_HTXnTB_TB_T 0x00800000
912#define HC_HTXnFLSe_Nearest 0x00000000
913#define HC_HTXnFLSe_Linear 0x00002000
914#define HC_HTXnFLSe_NonLinear 0x00004000
915#define HC_HTXnFLSe_Sharp 0x00008000
916#define HC_HTXnFLSe_Flat_Gaussian_Cubic 0x0000c000
917#define HC_HTXnFLSs_Nearest 0x00000000
918#define HC_HTXnFLSs_Linear 0x00000400
919#define HC_HTXnFLSs_NonLinear 0x00000800
920#define HC_HTXnFLSs_Flat_Gaussian_Cubic 0x00001800
921#define HC_HTXnFLTe_Nearest 0x00000000
922#define HC_HTXnFLTe_Linear 0x00000080
923#define HC_HTXnFLTe_NonLinear 0x00000100
924#define HC_HTXnFLTe_Sharp 0x00000180
925#define HC_HTXnFLTe_Flat_Gaussian_Cubic 0x00000300
926#define HC_HTXnFLTs_Nearest 0x00000000
927#define HC_HTXnFLTs_Linear 0x00000010
928#define HC_HTXnFLTs_NonLinear 0x00000020
929#define HC_HTXnFLTs_Flat_Gaussian_Cubic 0x00000060
930#define HC_HTXnFLDs_Tex0 0x00000000
931#define HC_HTXnFLDs_Nearest 0x00000001
932#define HC_HTXnFLDs_Linear 0x00000002
933#define HC_HTXnFLDs_NonLinear 0x00000003
934#define HC_HTXnFLDs_Dither 0x00000004
935#define HC_HTXnFLDs_ConstLOD 0x00000005
936#define HC_HTXnFLDs_Ani 0x00000006
937#define HC_HTXnFLDs_AniDither 0x00000007
938/* HC_SubA_HTXnMPMD 0x0079
939 */
940#define HC_HTXnMPMD_SMASK 0x00070000
941#define HC_HTXnMPMD_TMASK 0x00380000
942#define HC_HTXnLODDTf_MASK 0x00000007
943#define HC_HTXnXY2ST_MASK 0x00000008
944#define HC_HTXnMPMD_Tsingle 0x00000000
945#define HC_HTXnMPMD_Tclamp 0x00080000
946#define HC_HTXnMPMD_Trepeat 0x00100000
947#define HC_HTXnMPMD_Tmirror 0x00180000
948#define HC_HTXnMPMD_Twrap 0x00200000
949#define HC_HTXnMPMD_Ssingle 0x00000000
950#define HC_HTXnMPMD_Sclamp 0x00010000
951#define HC_HTXnMPMD_Srepeat 0x00020000
952#define HC_HTXnMPMD_Smirror 0x00030000
953#define HC_HTXnMPMD_Swrap 0x00040000
954/* HC_SubA_HTXnCLODu 0x007a
955 */
956#define HC_HTXnCLODu_MASK 0x000ffc00
957#define HC_HTXnCLODd_MASK 0x000003ff
958#define HC_HTXnCLODu_SHIFT 10
959/* HC_SubA_HTXnFM 0x007b
960 */
961#define HC_HTXnFM_MASK 0x00ff0000
962#define HC_HTXnLoc_MASK 0x00000003
963#define HC_HTXnFM_INDEX 0x00000000
964#define HC_HTXnFM_Intensity 0x00080000
965#define HC_HTXnFM_Lum 0x00100000
966#define HC_HTXnFM_Alpha 0x00180000
967#define HC_HTXnFM_DX 0x00280000
968#define HC_HTXnFM_ARGB16 0x00880000
969#define HC_HTXnFM_ARGB32 0x00980000
970#define HC_HTXnFM_ABGR16 0x00a80000
971#define HC_HTXnFM_ABGR32 0x00b80000
972#define HC_HTXnFM_RGBA16 0x00c80000
973#define HC_HTXnFM_RGBA32 0x00d80000
974#define HC_HTXnFM_BGRA16 0x00e80000
975#define HC_HTXnFM_BGRA32 0x00f80000
976#define HC_HTXnFM_BUMPMAP 0x00380000
977#define HC_HTXnFM_Index1 (HC_HTXnFM_INDEX | 0x00000000)
978#define HC_HTXnFM_Index2 (HC_HTXnFM_INDEX | 0x00010000)
979#define HC_HTXnFM_Index4 (HC_HTXnFM_INDEX | 0x00020000)
980#define HC_HTXnFM_Index8 (HC_HTXnFM_INDEX | 0x00030000)
981#define HC_HTXnFM_T1 (HC_HTXnFM_Intensity | 0x00000000)
982#define HC_HTXnFM_T2 (HC_HTXnFM_Intensity | 0x00010000)
983#define HC_HTXnFM_T4 (HC_HTXnFM_Intensity | 0x00020000)
984#define HC_HTXnFM_T8 (HC_HTXnFM_Intensity | 0x00030000)
985#define HC_HTXnFM_L1 (HC_HTXnFM_Lum | 0x00000000)
986#define HC_HTXnFM_L2 (HC_HTXnFM_Lum | 0x00010000)
987#define HC_HTXnFM_L4 (HC_HTXnFM_Lum | 0x00020000)
988#define HC_HTXnFM_L8 (HC_HTXnFM_Lum | 0x00030000)
989#define HC_HTXnFM_AL44 (HC_HTXnFM_Lum | 0x00040000)
990#define HC_HTXnFM_AL88 (HC_HTXnFM_Lum | 0x00050000)
991#define HC_HTXnFM_A1 (HC_HTXnFM_Alpha | 0x00000000)
992#define HC_HTXnFM_A2 (HC_HTXnFM_Alpha | 0x00010000)
993#define HC_HTXnFM_A4 (HC_HTXnFM_Alpha | 0x00020000)
994#define HC_HTXnFM_A8 (HC_HTXnFM_Alpha | 0x00030000)
995#define HC_HTXnFM_DX1 (HC_HTXnFM_DX | 0x00010000)
996#define HC_HTXnFM_DX23 (HC_HTXnFM_DX | 0x00020000)
997#define HC_HTXnFM_DX45 (HC_HTXnFM_DX | 0x00030000)
998#define HC_HTXnFM_RGB555 (HC_HTXnFM_ARGB16 | 0x00000000)
999#define HC_HTXnFM_RGB565 (HC_HTXnFM_ARGB16 | 0x00010000)
1000#define HC_HTXnFM_ARGB1555 (HC_HTXnFM_ARGB16 | 0x00020000)
1001#define HC_HTXnFM_ARGB4444 (HC_HTXnFM_ARGB16 | 0x00030000)
1002#define HC_HTXnFM_ARGB0888 (HC_HTXnFM_ARGB32 | 0x00000000)
1003#define HC_HTXnFM_ARGB8888 (HC_HTXnFM_ARGB32 | 0x00010000)
1004#define HC_HTXnFM_BGR555 (HC_HTXnFM_ABGR16 | 0x00000000)
1005#define HC_HTXnFM_BGR565 (HC_HTXnFM_ABGR16 | 0x00010000)
1006#define HC_HTXnFM_ABGR1555 (HC_HTXnFM_ABGR16 | 0x00020000)
1007#define HC_HTXnFM_ABGR4444 (HC_HTXnFM_ABGR16 | 0x00030000)
1008#define HC_HTXnFM_ABGR0888 (HC_HTXnFM_ABGR32 | 0x00000000)
1009#define HC_HTXnFM_ABGR8888 (HC_HTXnFM_ABGR32 | 0x00010000)
1010#define HC_HTXnFM_RGBA5550 (HC_HTXnFM_RGBA16 | 0x00000000)
1011#define HC_HTXnFM_RGBA5551 (HC_HTXnFM_RGBA16 | 0x00020000)
1012#define HC_HTXnFM_RGBA4444 (HC_HTXnFM_RGBA16 | 0x00030000)
1013#define HC_HTXnFM_RGBA8880 (HC_HTXnFM_RGBA32 | 0x00000000)
1014#define HC_HTXnFM_RGBA8888 (HC_HTXnFM_RGBA32 | 0x00010000)
1015#define HC_HTXnFM_BGRA5550 (HC_HTXnFM_BGRA16 | 0x00000000)
1016#define HC_HTXnFM_BGRA5551 (HC_HTXnFM_BGRA16 | 0x00020000)
1017#define HC_HTXnFM_BGRA4444 (HC_HTXnFM_BGRA16 | 0x00030000)
1018#define HC_HTXnFM_BGRA8880 (HC_HTXnFM_BGRA32 | 0x00000000)
1019#define HC_HTXnFM_BGRA8888 (HC_HTXnFM_BGRA32 | 0x00010000)
1020#define HC_HTXnFM_VU88 (HC_HTXnFM_BUMPMAP | 0x00000000)
1021#define HC_HTXnFM_LVU655 (HC_HTXnFM_BUMPMAP | 0x00010000)
1022#define HC_HTXnFM_LVU888 (HC_HTXnFM_BUMPMAP | 0x00020000)
1023#define HC_HTXnLoc_Local 0x00000000
1024#define HC_HTXnLoc_Sys 0x00000002
1025#define HC_HTXnLoc_AGP 0x00000003
1026/* HC_SubA_HTXnTRAH 0x007f
1027 */
1028#define HC_HTXnTRAH_MASK 0x00ff0000
1029#define HC_HTXnTRAL_MASK 0x0000ff00
1030#define HC_HTXnTBA_MASK 0x000000ff
1031#define HC_HTXnTRAH_SHIFT 16
1032#define HC_HTXnTRAL_SHIFT 8
1033/* HC_SubA_HTXnTBLCsat 0x0080
1034 *-- Define the input texture.
1035 */
1036#define HC_XTC_TOPC 0x00000000
1037#define HC_XTC_InvTOPC 0x00000010
1038#define HC_XTC_TOPCp5 0x00000020
1039#define HC_XTC_Cbias 0x00000000
1040#define HC_XTC_InvCbias 0x00000010
1041#define HC_XTC_0 0x00000000
1042#define HC_XTC_Dif 0x00000001
1043#define HC_XTC_Spec 0x00000002
1044#define HC_XTC_Tex 0x00000003
1045#define HC_XTC_Cur 0x00000004
1046#define HC_XTC_Adif 0x00000005
1047#define HC_XTC_Fog 0x00000006
1048#define HC_XTC_Atex 0x00000007
1049#define HC_XTC_Acur 0x00000008
1050#define HC_XTC_HTXnTBLRC 0x00000009
1051#define HC_XTC_Ctexnext 0x0000000a
1052/*--
1053 */
1054#define HC_HTXnTBLCsat_MASK 0x00800000
1055#define HC_HTXnTBLCa_MASK 0x000fc000
1056#define HC_HTXnTBLCb_MASK 0x00001f80
1057#define HC_HTXnTBLCc_MASK 0x0000003f
1058#define HC_HTXnTBLCa_TOPC (HC_XTC_TOPC << 14)
1059#define HC_HTXnTBLCa_InvTOPC (HC_XTC_InvTOPC << 14)
1060#define HC_HTXnTBLCa_TOPCp5 (HC_XTC_TOPCp5 << 14)
1061#define HC_HTXnTBLCa_0 (HC_XTC_0 << 14)
1062#define HC_HTXnTBLCa_Dif (HC_XTC_Dif << 14)
1063#define HC_HTXnTBLCa_Spec (HC_XTC_Spec << 14)
1064#define HC_HTXnTBLCa_Tex (HC_XTC_Tex << 14)
1065#define HC_HTXnTBLCa_Cur (HC_XTC_Cur << 14)
1066#define HC_HTXnTBLCa_Adif (HC_XTC_Adif << 14)
1067#define HC_HTXnTBLCa_Fog (HC_XTC_Fog << 14)
1068#define HC_HTXnTBLCa_Atex (HC_XTC_Atex << 14)
1069#define HC_HTXnTBLCa_Acur (HC_XTC_Acur << 14)
1070#define HC_HTXnTBLCa_HTXnTBLRC (HC_XTC_HTXnTBLRC << 14)
1071#define HC_HTXnTBLCa_Ctexnext (HC_XTC_Ctexnext << 14)
1072#define HC_HTXnTBLCb_TOPC (HC_XTC_TOPC << 7)
1073#define HC_HTXnTBLCb_InvTOPC (HC_XTC_InvTOPC << 7)
1074#define HC_HTXnTBLCb_TOPCp5 (HC_XTC_TOPCp5 << 7)
1075#define HC_HTXnTBLCb_0 (HC_XTC_0 << 7)
1076#define HC_HTXnTBLCb_Dif (HC_XTC_Dif << 7)
1077#define HC_HTXnTBLCb_Spec (HC_XTC_Spec << 7)
1078#define HC_HTXnTBLCb_Tex (HC_XTC_Tex << 7)
1079#define HC_HTXnTBLCb_Cur (HC_XTC_Cur << 7)
1080#define HC_HTXnTBLCb_Adif (HC_XTC_Adif << 7)
1081#define HC_HTXnTBLCb_Fog (HC_XTC_Fog << 7)
1082#define HC_HTXnTBLCb_Atex (HC_XTC_Atex << 7)
1083#define HC_HTXnTBLCb_Acur (HC_XTC_Acur << 7)
1084#define HC_HTXnTBLCb_HTXnTBLRC (HC_XTC_HTXnTBLRC << 7)
1085#define HC_HTXnTBLCb_Ctexnext (HC_XTC_Ctexnext << 7)
1086#define HC_HTXnTBLCc_TOPC (HC_XTC_TOPC << 0)
1087#define HC_HTXnTBLCc_InvTOPC (HC_XTC_InvTOPC << 0)
1088#define HC_HTXnTBLCc_TOPCp5 (HC_XTC_TOPCp5 << 0)
1089#define HC_HTXnTBLCc_0 (HC_XTC_0 << 0)
1090#define HC_HTXnTBLCc_Dif (HC_XTC_Dif << 0)
1091#define HC_HTXnTBLCc_Spec (HC_XTC_Spec << 0)
1092#define HC_HTXnTBLCc_Tex (HC_XTC_Tex << 0)
1093#define HC_HTXnTBLCc_Cur (HC_XTC_Cur << 0)
1094#define HC_HTXnTBLCc_Adif (HC_XTC_Adif << 0)
1095#define HC_HTXnTBLCc_Fog (HC_XTC_Fog << 0)
1096#define HC_HTXnTBLCc_Atex (HC_XTC_Atex << 0)
1097#define HC_HTXnTBLCc_Acur (HC_XTC_Acur << 0)
1098#define HC_HTXnTBLCc_HTXnTBLRC (HC_XTC_HTXnTBLRC << 0)
1099#define HC_HTXnTBLCc_Ctexnext (HC_XTC_Ctexnext << 0)
1100/* HC_SubA_HTXnTBLCop 0x0081
1101 */
1102#define HC_HTXnTBLdot_MASK 0x00c00000
1103#define HC_HTXnTBLCop_MASK 0x00380000
1104#define HC_HTXnTBLCbias_MASK 0x0007c000
1105#define HC_HTXnTBLCshift_MASK 0x00001800
1106#define HC_HTXnTBLAop_MASK 0x00000380
1107#define HC_HTXnTBLAbias_MASK 0x00000078
1108#define HC_HTXnTBLAshift_MASK 0x00000003
1109#define HC_HTXnTBLCop_Add 0x00000000
1110#define HC_HTXnTBLCop_Sub 0x00080000
1111#define HC_HTXnTBLCop_Min 0x00100000
1112#define HC_HTXnTBLCop_Max 0x00180000
1113#define HC_HTXnTBLCop_Mask 0x00200000
1114#define HC_HTXnTBLCbias_Cbias (HC_XTC_Cbias << 14)
1115#define HC_HTXnTBLCbias_InvCbias (HC_XTC_InvCbias << 14)
1116#define HC_HTXnTBLCbias_0 (HC_XTC_0 << 14)
1117#define HC_HTXnTBLCbias_Dif (HC_XTC_Dif << 14)
1118#define HC_HTXnTBLCbias_Spec (HC_XTC_Spec << 14)
1119#define HC_HTXnTBLCbias_Tex (HC_XTC_Tex << 14)
1120#define HC_HTXnTBLCbias_Cur (HC_XTC_Cur << 14)
1121#define HC_HTXnTBLCbias_Adif (HC_XTC_Adif << 14)
1122#define HC_HTXnTBLCbias_Fog (HC_XTC_Fog << 14)
1123#define HC_HTXnTBLCbias_Atex (HC_XTC_Atex << 14)
1124#define HC_HTXnTBLCbias_Acur (HC_XTC_Acur << 14)
1125#define HC_HTXnTBLCbias_HTXnTBLRC (HC_XTC_HTXnTBLRC << 14)
1126#define HC_HTXnTBLCshift_1 0x00000000
1127#define HC_HTXnTBLCshift_2 0x00000800
1128#define HC_HTXnTBLCshift_No 0x00001000
1129#define HC_HTXnTBLCshift_DotP 0x00001800
1130/*=* John Sheng [2003.7.18] texture combine *=*/
1131#define HC_HTXnTBLDOT3 0x00080000
1132#define HC_HTXnTBLDOT4 0x000C0000
1133
1134#define HC_HTXnTBLAop_Add 0x00000000
1135#define HC_HTXnTBLAop_Sub 0x00000080
1136#define HC_HTXnTBLAop_Min 0x00000100
1137#define HC_HTXnTBLAop_Max 0x00000180
1138#define HC_HTXnTBLAop_Mask 0x00000200
1139#define HC_HTXnTBLAbias_Inv 0x00000040
1140#define HC_HTXnTBLAbias_Adif 0x00000000
1141#define HC_HTXnTBLAbias_Fog 0x00000008
1142#define HC_HTXnTBLAbias_Acur 0x00000010
1143#define HC_HTXnTBLAbias_HTXnTBLRAbias 0x00000018
1144#define HC_HTXnTBLAbias_Atex 0x00000020
1145#define HC_HTXnTBLAshift_1 0x00000000
1146#define HC_HTXnTBLAshift_2 0x00000001
1147#define HC_HTXnTBLAshift_No 0x00000002
1148/* #define HC_HTXnTBLAshift_DotP 0x00000003 */
1149/* HC_SubA_HTXnTBLMPFog 0x0082
1150 */
1151#define HC_HTXnTBLMPfog_MASK 0x00e00000
1152#define HC_HTXnTBLMPfog_0 0x00000000
1153#define HC_HTXnTBLMPfog_Adif 0x00200000
1154#define HC_HTXnTBLMPfog_Fog 0x00400000
1155#define HC_HTXnTBLMPfog_Atex 0x00600000
1156#define HC_HTXnTBLMPfog_Acur 0x00800000
1157#define HC_HTXnTBLMPfog_GHTXnTBLRFog 0x00a00000
1158/* HC_SubA_HTXnTBLAsat 0x0083
1159 *-- Define the texture alpha input.
1160 */
1161#define HC_XTA_TOPA 0x00000000
1162#define HC_XTA_InvTOPA 0x00000008
1163#define HC_XTA_TOPAp5 0x00000010
1164#define HC_XTA_Adif 0x00000000
1165#define HC_XTA_Fog 0x00000001
1166#define HC_XTA_Acur 0x00000002
1167#define HC_XTA_HTXnTBLRA 0x00000003
1168#define HC_XTA_Atex 0x00000004
1169#define HC_XTA_Atexnext 0x00000005
1170/*--
1171 */
1172#define HC_HTXnTBLAsat_MASK 0x00800000
1173#define HC_HTXnTBLAMB_MASK 0x00700000
1174#define HC_HTXnTBLAa_MASK 0x0007c000
1175#define HC_HTXnTBLAb_MASK 0x00000f80
1176#define HC_HTXnTBLAc_MASK 0x0000001f
1177#define HC_HTXnTBLAMB_SHIFT 20
1178#define HC_HTXnTBLAa_TOPA (HC_XTA_TOPA << 14)
1179#define HC_HTXnTBLAa_InvTOPA (HC_XTA_InvTOPA << 14)
1180#define HC_HTXnTBLAa_TOPAp5 (HC_XTA_TOPAp5 << 14)
1181#define HC_HTXnTBLAa_Adif (HC_XTA_Adif << 14)
1182#define HC_HTXnTBLAa_Fog (HC_XTA_Fog << 14)
1183#define HC_HTXnTBLAa_Acur (HC_XTA_Acur << 14)
1184#define HC_HTXnTBLAa_HTXnTBLRA (HC_XTA_HTXnTBLRA << 14)
1185#define HC_HTXnTBLAa_Atex (HC_XTA_Atex << 14)
1186#define HC_HTXnTBLAa_Atexnext (HC_XTA_Atexnext << 14)
1187#define HC_HTXnTBLAb_TOPA (HC_XTA_TOPA << 7)
1188#define HC_HTXnTBLAb_InvTOPA (HC_XTA_InvTOPA << 7)
1189#define HC_HTXnTBLAb_TOPAp5 (HC_XTA_TOPAp5 << 7)
1190#define HC_HTXnTBLAb_Adif (HC_XTA_Adif << 7)
1191#define HC_HTXnTBLAb_Fog (HC_XTA_Fog << 7)
1192#define HC_HTXnTBLAb_Acur (HC_XTA_Acur << 7)
1193#define HC_HTXnTBLAb_HTXnTBLRA (HC_XTA_HTXnTBLRA << 7)
1194#define HC_HTXnTBLAb_Atex (HC_XTA_Atex << 7)
1195#define HC_HTXnTBLAb_Atexnext (HC_XTA_Atexnext << 7)
1196#define HC_HTXnTBLAc_TOPA (HC_XTA_TOPA << 0)
1197#define HC_HTXnTBLAc_InvTOPA (HC_XTA_InvTOPA << 0)
1198#define HC_HTXnTBLAc_TOPAp5 (HC_XTA_TOPAp5 << 0)
1199#define HC_HTXnTBLAc_Adif (HC_XTA_Adif << 0)
1200#define HC_HTXnTBLAc_Fog (HC_XTA_Fog << 0)
1201#define HC_HTXnTBLAc_Acur (HC_XTA_Acur << 0)
1202#define HC_HTXnTBLAc_HTXnTBLRA (HC_XTA_HTXnTBLRA << 0)
1203#define HC_HTXnTBLAc_Atex (HC_XTA_Atex << 0)
1204#define HC_HTXnTBLAc_Atexnext (HC_XTA_Atexnext << 0)
1205/* HC_SubA_HTXnTBLRAa 0x0089
1206 */
1207#define HC_HTXnTBLRAa_MASK 0x00ff0000
1208#define HC_HTXnTBLRAb_MASK 0x0000ff00
1209#define HC_HTXnTBLRAc_MASK 0x000000ff
1210#define HC_HTXnTBLRAa_SHIFT 16
1211#define HC_HTXnTBLRAb_SHIFT 8
1212#define HC_HTXnTBLRAc_SHIFT 0
1213/* HC_SubA_HTXnTBLRFog 0x008a
1214 */
1215#define HC_HTXnTBLRFog_MASK 0x0000ff00
1216#define HC_HTXnTBLRAbias_MASK 0x000000ff
1217#define HC_HTXnTBLRFog_SHIFT 8
1218#define HC_HTXnTBLRAbias_SHIFT 0
1219/* HC_SubA_HTXnLScale 0x0094
1220 */
1221#define HC_HTXnLScale_MASK 0x0007fc00
1222#define HC_HTXnLOff_MASK 0x000001ff
1223#define HC_HTXnLScale_SHIFT 10
1224/* HC_SubA_HTXSMD 0x0000
1225 */
1226#define HC_HTXSMD_MASK 0x00000080
1227#define HC_HTXTMD_MASK 0x00000040
1228#define HC_HTXNum_MASK 0x00000038
1229#define HC_HTXTRMD_MASK 0x00000006
1230#define HC_HTXCHCLR_MASK 0x00000001
1231#define HC_HTXNum_SHIFT 3
1232
1233/* Texture Palette n
1234 */
1235#define HC_SubType_TexPalette0 0x00000000
1236#define HC_SubType_TexPalette1 0x00000001
1237#define HC_SubType_FogTable 0x00000010
1238#define HC_SubType_Stipple 0x00000014
1239/* HC_SubA_TexPalette0 0x0000
1240 */
1241#define HC_HTPnA_MASK 0xff000000
1242#define HC_HTPnR_MASK 0x00ff0000
1243#define HC_HTPnG_MASK 0x0000ff00
1244#define HC_HTPnB_MASK 0x000000ff
1245/* HC_SubA_FogTable 0x0010
1246 */
1247#define HC_HFPn3_MASK 0xff000000
1248#define HC_HFPn2_MASK 0x00ff0000
1249#define HC_HFPn1_MASK 0x0000ff00
1250#define HC_HFPn_MASK 0x000000ff
1251#define HC_HFPn3_SHIFT 24
1252#define HC_HFPn2_SHIFT 16
1253#define HC_HFPn1_SHIFT 8
1254
1255/* Auto Testing & Security
1256 */
1257#define HC_SubA_HenFIFOAT 0x0000
1258#define HC_SubA_HFBDrawFirst 0x0004
1259#define HC_SubA_HFBBasL 0x0005
1260#define HC_SubA_HFBDst 0x0006
1261/* HC_SubA_HenFIFOAT 0x0000
1262 */
1263#define HC_HenFIFOAT_MASK 0x00000020
1264#define HC_HenGEMILock_MASK 0x00000010
1265#define HC_HenFBASwap_MASK 0x00000008
1266#define HC_HenOT_MASK 0x00000004
1267#define HC_HenCMDQ_MASK 0x00000002
1268#define HC_HenTXCTSU_MASK 0x00000001
1269/* HC_SubA_HFBDrawFirst 0x0004
1270 */
1271#define HC_HFBDrawFirst_MASK 0x00000800
1272#define HC_HFBQueue_MASK 0x00000400
1273#define HC_HFBLock_MASK 0x00000200
1274#define HC_HEOF_MASK 0x00000100
1275#define HC_HFBBasH_MASK 0x000000ff
1276
1277/* GEMI Setting
1278 */
1279#define HC_SubA_HTArbRCM 0x0008
1280#define HC_SubA_HTArbRZ 0x000a
1281#define HC_SubA_HTArbWZ 0x000b
1282#define HC_SubA_HTArbRTX 0x000c
1283#define HC_SubA_HTArbRCW 0x000d
1284#define HC_SubA_HTArbE2 0x000e
1285#define HC_SubA_HArbRQCM 0x0010
1286#define HC_SubA_HArbWQCM 0x0011
1287#define HC_SubA_HGEMITout 0x0020
1288#define HC_SubA_HFthRTXD 0x0040
1289#define HC_SubA_HFthRTXA 0x0044
1290#define HC_SubA_HCMDQstL 0x0050
1291#define HC_SubA_HCMDQendL 0x0051
1292#define HC_SubA_HCMDQLen 0x0052
1293/* HC_SubA_HTArbRCM 0x0008
1294 */
1295#define HC_HTArbRCM_MASK 0x0000ffff
1296/* HC_SubA_HTArbRZ 0x000a
1297 */
1298#define HC_HTArbRZ_MASK 0x0000ffff
1299/* HC_SubA_HTArbWZ 0x000b
1300 */
1301#define HC_HTArbWZ_MASK 0x0000ffff
1302/* HC_SubA_HTArbRTX 0x000c
1303 */
1304#define HC_HTArbRTX_MASK 0x0000ffff
1305/* HC_SubA_HTArbRCW 0x000d
1306 */
1307#define HC_HTArbRCW_MASK 0x0000ffff
1308/* HC_SubA_HTArbE2 0x000e
1309 */
1310#define HC_HTArbE2_MASK 0x0000ffff
1311/* HC_SubA_HArbRQCM 0x0010
1312 */
1313#define HC_HTArbRQCM_MASK 0x0000ffff
1314/* HC_SubA_HArbWQCM 0x0011
1315 */
1316#define HC_HArbWQCM_MASK 0x0000ffff
1317/* HC_SubA_HGEMITout 0x0020
1318 */
1319#define HC_HGEMITout_MASK 0x000f0000
1320#define HC_HNPArbZC_MASK 0x0000ffff
1321#define HC_HGEMITout_SHIFT 16
1322/* HC_SubA_HFthRTXD 0x0040
1323 */
1324#define HC_HFthRTXD_MASK 0x00ff0000
1325#define HC_HFthRZD_MASK 0x0000ff00
1326#define HC_HFthWZD_MASK 0x000000ff
1327#define HC_HFthRTXD_SHIFT 16
1328#define HC_HFthRZD_SHIFT 8
1329/* HC_SubA_HFthRTXA 0x0044
1330 */
1331#define HC_HFthRTXA_MASK 0x000000ff
1332
1333/******************************************************************************
1334** Define the Halcyon Internal register access constants. For simulator only.
1335******************************************************************************/
1336#define HC_SIMA_HAGPBstL 0x0000
1337#define HC_SIMA_HAGPBendL 0x0001
1338#define HC_SIMA_HAGPCMNT 0x0002
1339#define HC_SIMA_HAGPBpL 0x0003
1340#define HC_SIMA_HAGPBpH 0x0004
1341#define HC_SIMA_HClipTB 0x0005
1342#define HC_SIMA_HClipLR 0x0006
1343#define HC_SIMA_HFPClipTL 0x0007
1344#define HC_SIMA_HFPClipBL 0x0008
1345#define HC_SIMA_HFPClipLL 0x0009
1346#define HC_SIMA_HFPClipRL 0x000a
1347#define HC_SIMA_HFPClipTBH 0x000b
1348#define HC_SIMA_HFPClipLRH 0x000c
1349#define HC_SIMA_HLP 0x000d
1350#define HC_SIMA_HLPRF 0x000e
1351#define HC_SIMA_HSolidCL 0x000f
1352#define HC_SIMA_HPixGC 0x0010
1353#define HC_SIMA_HSPXYOS 0x0011
1354#define HC_SIMA_HCmdA 0x0012
1355#define HC_SIMA_HCmdB 0x0013
1356#define HC_SIMA_HEnable 0x0014
1357#define HC_SIMA_HZWBBasL 0x0015
1358#define HC_SIMA_HZWBBasH 0x0016
1359#define HC_SIMA_HZWBType 0x0017
1360#define HC_SIMA_HZBiasL 0x0018
1361#define HC_SIMA_HZWBend 0x0019
1362#define HC_SIMA_HZWTMD 0x001a
1363#define HC_SIMA_HZWCDL 0x001b
1364#define HC_SIMA_HZWCTAGnum 0x001c
1365#define HC_SIMA_HZCYNum 0x001d
1366#define HC_SIMA_HZWCFire 0x001e
1367/* #define HC_SIMA_HSBBasL 0x001d */
1368/* #define HC_SIMA_HSBBasH 0x001e */
1369/* #define HC_SIMA_HSBFM 0x001f */
1370#define HC_SIMA_HSTREF 0x0020
1371#define HC_SIMA_HSTMD 0x0021
1372#define HC_SIMA_HABBasL 0x0022
1373#define HC_SIMA_HABBasH 0x0023
1374#define HC_SIMA_HABFM 0x0024
1375#define HC_SIMA_HATMD 0x0025
1376#define HC_SIMA_HABLCsat 0x0026
1377#define HC_SIMA_HABLCop 0x0027
1378#define HC_SIMA_HABLAsat 0x0028
1379#define HC_SIMA_HABLAop 0x0029
1380#define HC_SIMA_HABLRCa 0x002a
1381#define HC_SIMA_HABLRFCa 0x002b
1382#define HC_SIMA_HABLRCbias 0x002c
1383#define HC_SIMA_HABLRCb 0x002d
1384#define HC_SIMA_HABLRFCb 0x002e
1385#define HC_SIMA_HABLRAa 0x002f
1386#define HC_SIMA_HABLRAb 0x0030
1387#define HC_SIMA_HDBBasL 0x0031
1388#define HC_SIMA_HDBBasH 0x0032
1389#define HC_SIMA_HDBFM 0x0033
1390#define HC_SIMA_HFBBMSKL 0x0034
1391#define HC_SIMA_HROP 0x0035
1392#define HC_SIMA_HFogLF 0x0036
1393#define HC_SIMA_HFogCL 0x0037
1394#define HC_SIMA_HFogCH 0x0038
1395#define HC_SIMA_HFogStL 0x0039
1396#define HC_SIMA_HFogStH 0x003a
1397#define HC_SIMA_HFogOOdMF 0x003b
1398#define HC_SIMA_HFogOOdEF 0x003c
1399#define HC_SIMA_HFogEndL 0x003d
1400#define HC_SIMA_HFogDenst 0x003e
1401/*---- start of texture 0 setting ----
1402 */
1403#define HC_SIMA_HTX0L0BasL 0x0040
1404#define HC_SIMA_HTX0L1BasL 0x0041
1405#define HC_SIMA_HTX0L2BasL 0x0042
1406#define HC_SIMA_HTX0L3BasL 0x0043
1407#define HC_SIMA_HTX0L4BasL 0x0044
1408#define HC_SIMA_HTX0L5BasL 0x0045
1409#define HC_SIMA_HTX0L6BasL 0x0046
1410#define HC_SIMA_HTX0L7BasL 0x0047
1411#define HC_SIMA_HTX0L8BasL 0x0048
1412#define HC_SIMA_HTX0L9BasL 0x0049
1413#define HC_SIMA_HTX0LaBasL 0x004a
1414#define HC_SIMA_HTX0LbBasL 0x004b
1415#define HC_SIMA_HTX0LcBasL 0x004c
1416#define HC_SIMA_HTX0LdBasL 0x004d
1417#define HC_SIMA_HTX0LeBasL 0x004e
1418#define HC_SIMA_HTX0LfBasL 0x004f
1419#define HC_SIMA_HTX0L10BasL 0x0050
1420#define HC_SIMA_HTX0L11BasL 0x0051
1421#define HC_SIMA_HTX0L012BasH 0x0052
1422#define HC_SIMA_HTX0L345BasH 0x0053
1423#define HC_SIMA_HTX0L678BasH 0x0054
1424#define HC_SIMA_HTX0L9abBasH 0x0055
1425#define HC_SIMA_HTX0LcdeBasH 0x0056
1426#define HC_SIMA_HTX0Lf1011BasH 0x0057
1427#define HC_SIMA_HTX0L0Pit 0x0058
1428#define HC_SIMA_HTX0L1Pit 0x0059
1429#define HC_SIMA_HTX0L2Pit 0x005a
1430#define HC_SIMA_HTX0L3Pit 0x005b
1431#define HC_SIMA_HTX0L4Pit 0x005c
1432#define HC_SIMA_HTX0L5Pit 0x005d
1433#define HC_SIMA_HTX0L6Pit 0x005e
1434#define HC_SIMA_HTX0L7Pit 0x005f
1435#define HC_SIMA_HTX0L8Pit 0x0060
1436#define HC_SIMA_HTX0L9Pit 0x0061
1437#define HC_SIMA_HTX0LaPit 0x0062
1438#define HC_SIMA_HTX0LbPit 0x0063
1439#define HC_SIMA_HTX0LcPit 0x0064
1440#define HC_SIMA_HTX0LdPit 0x0065
1441#define HC_SIMA_HTX0LePit 0x0066
1442#define HC_SIMA_HTX0LfPit 0x0067
1443#define HC_SIMA_HTX0L10Pit 0x0068
1444#define HC_SIMA_HTX0L11Pit 0x0069
1445#define HC_SIMA_HTX0L0_5WE 0x006a
1446#define HC_SIMA_HTX0L6_bWE 0x006b
1447#define HC_SIMA_HTX0Lc_11WE 0x006c
1448#define HC_SIMA_HTX0L0_5HE 0x006d
1449#define HC_SIMA_HTX0L6_bHE 0x006e
1450#define HC_SIMA_HTX0Lc_11HE 0x006f
1451#define HC_SIMA_HTX0L0OS 0x0070
1452#define HC_SIMA_HTX0TB 0x0071
1453#define HC_SIMA_HTX0MPMD 0x0072
1454#define HC_SIMA_HTX0CLODu 0x0073
1455#define HC_SIMA_HTX0FM 0x0074
1456#define HC_SIMA_HTX0TRCH 0x0075
1457#define HC_SIMA_HTX0TRCL 0x0076
1458#define HC_SIMA_HTX0TBC 0x0077
1459#define HC_SIMA_HTX0TRAH 0x0078
1460#define HC_SIMA_HTX0TBLCsat 0x0079
1461#define HC_SIMA_HTX0TBLCop 0x007a
1462#define HC_SIMA_HTX0TBLMPfog 0x007b
1463#define HC_SIMA_HTX0TBLAsat 0x007c
1464#define HC_SIMA_HTX0TBLRCa 0x007d
1465#define HC_SIMA_HTX0TBLRCb 0x007e
1466#define HC_SIMA_HTX0TBLRCc 0x007f
1467#define HC_SIMA_HTX0TBLRCbias 0x0080
1468#define HC_SIMA_HTX0TBLRAa 0x0081
1469#define HC_SIMA_HTX0TBLRFog 0x0082
1470#define HC_SIMA_HTX0BumpM00 0x0083
1471#define HC_SIMA_HTX0BumpM01 0x0084
1472#define HC_SIMA_HTX0BumpM10 0x0085
1473#define HC_SIMA_HTX0BumpM11 0x0086
1474#define HC_SIMA_HTX0LScale 0x0087
1475/*---- end of texture 0 setting ---- 0x008f
1476 */
1477#define HC_SIMA_TX0TX1_OFF 0x0050
1478/*---- start of texture 1 setting ----
1479 */
1480#define HC_SIMA_HTX1L0BasL (HC_SIMA_HTX0L0BasL + HC_SIMA_TX0TX1_OFF)
1481#define HC_SIMA_HTX1L1BasL (HC_SIMA_HTX0L1BasL + HC_SIMA_TX0TX1_OFF)
1482#define HC_SIMA_HTX1L2BasL (HC_SIMA_HTX0L2BasL + HC_SIMA_TX0TX1_OFF)
1483#define HC_SIMA_HTX1L3BasL (HC_SIMA_HTX0L3BasL + HC_SIMA_TX0TX1_OFF)
1484#define HC_SIMA_HTX1L4BasL (HC_SIMA_HTX0L4BasL + HC_SIMA_TX0TX1_OFF)
1485#define HC_SIMA_HTX1L5BasL (HC_SIMA_HTX0L5BasL + HC_SIMA_TX0TX1_OFF)
1486#define HC_SIMA_HTX1L6BasL (HC_SIMA_HTX0L6BasL + HC_SIMA_TX0TX1_OFF)
1487#define HC_SIMA_HTX1L7BasL (HC_SIMA_HTX0L7BasL + HC_SIMA_TX0TX1_OFF)
1488#define HC_SIMA_HTX1L8BasL (HC_SIMA_HTX0L8BasL + HC_SIMA_TX0TX1_OFF)
1489#define HC_SIMA_HTX1L9BasL (HC_SIMA_HTX0L9BasL + HC_SIMA_TX0TX1_OFF)
1490#define HC_SIMA_HTX1LaBasL (HC_SIMA_HTX0LaBasL + HC_SIMA_TX0TX1_OFF)
1491#define HC_SIMA_HTX1LbBasL (HC_SIMA_HTX0LbBasL + HC_SIMA_TX0TX1_OFF)
1492#define HC_SIMA_HTX1LcBasL (HC_SIMA_HTX0LcBasL + HC_SIMA_TX0TX1_OFF)
1493#define HC_SIMA_HTX1LdBasL (HC_SIMA_HTX0LdBasL + HC_SIMA_TX0TX1_OFF)
1494#define HC_SIMA_HTX1LeBasL (HC_SIMA_HTX0LeBasL + HC_SIMA_TX0TX1_OFF)
1495#define HC_SIMA_HTX1LfBasL (HC_SIMA_HTX0LfBasL + HC_SIMA_TX0TX1_OFF)
1496#define HC_SIMA_HTX1L10BasL (HC_SIMA_HTX0L10BasL + HC_SIMA_TX0TX1_OFF)
1497#define HC_SIMA_HTX1L11BasL (HC_SIMA_HTX0L11BasL + HC_SIMA_TX0TX1_OFF)
1498#define HC_SIMA_HTX1L012BasH (HC_SIMA_HTX0L012BasH + HC_SIMA_TX0TX1_OFF)
1499#define HC_SIMA_HTX1L345BasH (HC_SIMA_HTX0L345BasH + HC_SIMA_TX0TX1_OFF)
1500#define HC_SIMA_HTX1L678BasH (HC_SIMA_HTX0L678BasH + HC_SIMA_TX0TX1_OFF)
1501#define HC_SIMA_HTX1L9abBasH (HC_SIMA_HTX0L9abBasH + HC_SIMA_TX0TX1_OFF)
1502#define HC_SIMA_HTX1LcdeBasH (HC_SIMA_HTX0LcdeBasH + HC_SIMA_TX0TX1_OFF)
1503#define HC_SIMA_HTX1Lf1011BasH (HC_SIMA_HTX0Lf1011BasH + HC_SIMA_TX0TX1_OFF)
1504#define HC_SIMA_HTX1L0Pit (HC_SIMA_HTX0L0Pit + HC_SIMA_TX0TX1_OFF)
1505#define HC_SIMA_HTX1L1Pit (HC_SIMA_HTX0L1Pit + HC_SIMA_TX0TX1_OFF)
1506#define HC_SIMA_HTX1L2Pit (HC_SIMA_HTX0L2Pit + HC_SIMA_TX0TX1_OFF)
1507#define HC_SIMA_HTX1L3Pit (HC_SIMA_HTX0L3Pit + HC_SIMA_TX0TX1_OFF)
1508#define HC_SIMA_HTX1L4Pit (HC_SIMA_HTX0L4Pit + HC_SIMA_TX0TX1_OFF)
1509#define HC_SIMA_HTX1L5Pit (HC_SIMA_HTX0L5Pit + HC_SIMA_TX0TX1_OFF)
1510#define HC_SIMA_HTX1L6Pit (HC_SIMA_HTX0L6Pit + HC_SIMA_TX0TX1_OFF)
1511#define HC_SIMA_HTX1L7Pit (HC_SIMA_HTX0L7Pit + HC_SIMA_TX0TX1_OFF)
1512#define HC_SIMA_HTX1L8Pit (HC_SIMA_HTX0L8Pit + HC_SIMA_TX0TX1_OFF)
1513#define HC_SIMA_HTX1L9Pit (HC_SIMA_HTX0L9Pit + HC_SIMA_TX0TX1_OFF)
1514#define HC_SIMA_HTX1LaPit (HC_SIMA_HTX0LaPit + HC_SIMA_TX0TX1_OFF)
1515#define HC_SIMA_HTX1LbPit (HC_SIMA_HTX0LbPit + HC_SIMA_TX0TX1_OFF)
1516#define HC_SIMA_HTX1LcPit (HC_SIMA_HTX0LcPit + HC_SIMA_TX0TX1_OFF)
1517#define HC_SIMA_HTX1LdPit (HC_SIMA_HTX0LdPit + HC_SIMA_TX0TX1_OFF)
1518#define HC_SIMA_HTX1LePit (HC_SIMA_HTX0LePit + HC_SIMA_TX0TX1_OFF)
1519#define HC_SIMA_HTX1LfPit (HC_SIMA_HTX0LfPit + HC_SIMA_TX0TX1_OFF)
1520#define HC_SIMA_HTX1L10Pit (HC_SIMA_HTX0L10Pit + HC_SIMA_TX0TX1_OFF)
1521#define HC_SIMA_HTX1L11Pit (HC_SIMA_HTX0L11Pit + HC_SIMA_TX0TX1_OFF)
1522#define HC_SIMA_HTX1L0_5WE (HC_SIMA_HTX0L0_5WE + HC_SIMA_TX0TX1_OFF)
1523#define HC_SIMA_HTX1L6_bWE (HC_SIMA_HTX0L6_bWE + HC_SIMA_TX0TX1_OFF)
1524#define HC_SIMA_HTX1Lc_11WE (HC_SIMA_HTX0Lc_11WE + HC_SIMA_TX0TX1_OFF)
1525#define HC_SIMA_HTX1L0_5HE (HC_SIMA_HTX0L0_5HE + HC_SIMA_TX0TX1_OFF)
1526#define HC_SIMA_HTX1L6_bHE (HC_SIMA_HTX0L6_bHE + HC_SIMA_TX0TX1_OFF)
1527#define HC_SIMA_HTX1Lc_11HE (HC_SIMA_HTX0Lc_11HE + HC_SIMA_TX0TX1_OFF)
1528#define HC_SIMA_HTX1L0OS (HC_SIMA_HTX0L0OS + HC_SIMA_TX0TX1_OFF)
1529#define HC_SIMA_HTX1TB (HC_SIMA_HTX0TB + HC_SIMA_TX0TX1_OFF)
1530#define HC_SIMA_HTX1MPMD (HC_SIMA_HTX0MPMD + HC_SIMA_TX0TX1_OFF)
1531#define HC_SIMA_HTX1CLODu (HC_SIMA_HTX0CLODu + HC_SIMA_TX0TX1_OFF)
1532#define HC_SIMA_HTX1FM (HC_SIMA_HTX0FM + HC_SIMA_TX0TX1_OFF)
1533#define HC_SIMA_HTX1TRCH (HC_SIMA_HTX0TRCH + HC_SIMA_TX0TX1_OFF)
1534#define HC_SIMA_HTX1TRCL (HC_SIMA_HTX0TRCL + HC_SIMA_TX0TX1_OFF)
1535#define HC_SIMA_HTX1TBC (HC_SIMA_HTX0TBC + HC_SIMA_TX0TX1_OFF)
1536#define HC_SIMA_HTX1TRAH (HC_SIMA_HTX0TRAH + HC_SIMA_TX0TX1_OFF)
1537#define HC_SIMA_HTX1LTC (HC_SIMA_HTX0LTC + HC_SIMA_TX0TX1_OFF)
1538#define HC_SIMA_HTX1LTA (HC_SIMA_HTX0LTA + HC_SIMA_TX0TX1_OFF)
1539#define HC_SIMA_HTX1TBLCsat (HC_SIMA_HTX0TBLCsat + HC_SIMA_TX0TX1_OFF)
1540#define HC_SIMA_HTX1TBLCop (HC_SIMA_HTX0TBLCop + HC_SIMA_TX0TX1_OFF)
1541#define HC_SIMA_HTX1TBLMPfog (HC_SIMA_HTX0TBLMPfog + HC_SIMA_TX0TX1_OFF)
1542#define HC_SIMA_HTX1TBLAsat (HC_SIMA_HTX0TBLAsat + HC_SIMA_TX0TX1_OFF)
1543#define HC_SIMA_HTX1TBLRCa (HC_SIMA_HTX0TBLRCa + HC_SIMA_TX0TX1_OFF)
1544#define HC_SIMA_HTX1TBLRCb (HC_SIMA_HTX0TBLRCb + HC_SIMA_TX0TX1_OFF)
1545#define HC_SIMA_HTX1TBLRCc (HC_SIMA_HTX0TBLRCc + HC_SIMA_TX0TX1_OFF)
1546#define HC_SIMA_HTX1TBLRCbias (HC_SIMA_HTX0TBLRCbias + HC_SIMA_TX0TX1_OFF)
1547#define HC_SIMA_HTX1TBLRAa (HC_SIMA_HTX0TBLRAa + HC_SIMA_TX0TX1_OFF)
1548#define HC_SIMA_HTX1TBLRFog (HC_SIMA_HTX0TBLRFog + HC_SIMA_TX0TX1_OFF)
1549#define HC_SIMA_HTX1BumpM00 (HC_SIMA_HTX0BumpM00 + HC_SIMA_TX0TX1_OFF)
1550#define HC_SIMA_HTX1BumpM01 (HC_SIMA_HTX0BumpM01 + HC_SIMA_TX0TX1_OFF)
1551#define HC_SIMA_HTX1BumpM10 (HC_SIMA_HTX0BumpM10 + HC_SIMA_TX0TX1_OFF)
1552#define HC_SIMA_HTX1BumpM11 (HC_SIMA_HTX0BumpM11 + HC_SIMA_TX0TX1_OFF)
1553#define HC_SIMA_HTX1LScale (HC_SIMA_HTX0LScale + HC_SIMA_TX0TX1_OFF)
1554/*---- end of texture 1 setting ---- 0xaf
1555 */
1556#define HC_SIMA_HTXSMD 0x00b0
1557#define HC_SIMA_HenFIFOAT 0x00b1
1558#define HC_SIMA_HFBDrawFirst 0x00b2
1559#define HC_SIMA_HFBBasL 0x00b3
1560#define HC_SIMA_HTArbRCM 0x00b4
1561#define HC_SIMA_HTArbRZ 0x00b5
1562#define HC_SIMA_HTArbWZ 0x00b6
1563#define HC_SIMA_HTArbRTX 0x00b7
1564#define HC_SIMA_HTArbRCW 0x00b8
1565#define HC_SIMA_HTArbE2 0x00b9
1566#define HC_SIMA_HGEMITout 0x00ba
1567#define HC_SIMA_HFthRTXD 0x00bb
1568#define HC_SIMA_HFthRTXA 0x00bc
1569/* Define the texture palette 0
1570 */
1571#define HC_SIMA_HTP0 0x0100
1572#define HC_SIMA_HTP1 0x0200
1573#define HC_SIMA_FOGTABLE 0x0300
1574#define HC_SIMA_STIPPLE 0x0400
1575#define HC_SIMA_HE3Fire 0x0440
1576#define HC_SIMA_TRANS_SET 0x0441
1577#define HC_SIMA_HREngSt 0x0442
1578#define HC_SIMA_HRFIFOempty 0x0443
1579#define HC_SIMA_HRFIFOfull 0x0444
1580#define HC_SIMA_HRErr 0x0445
1581#define HC_SIMA_FIFOstatus 0x0446
1582
1583/******************************************************************************
1584** Define the AGP command header.
1585******************************************************************************/
1586#define HC_ACMD_MASK 0xfe000000
1587#define HC_ACMD_SUB_MASK 0x0c000000
1588#define HC_ACMD_HCmdA 0xee000000
1589#define HC_ACMD_HCmdB 0xec000000
1590#define HC_ACMD_HCmdC 0xea000000
1591#define HC_ACMD_H1 0xf0000000
1592#define HC_ACMD_H2 0xf2000000
1593#define HC_ACMD_H3 0xf4000000
1594#define HC_ACMD_H4 0xf6000000
1595
1596#define HC_ACMD_H1IO_MASK 0x000001ff
1597#define HC_ACMD_H2IO1_MASK 0x001ff000
1598#define HC_ACMD_H2IO2_MASK 0x000001ff
1599#define HC_ACMD_H2IO1_SHIFT 12
1600#define HC_ACMD_H2IO2_SHIFT 0
1601#define HC_ACMD_H3IO_MASK 0x000001ff
1602#define HC_ACMD_H3COUNT_MASK 0x01fff000
1603#define HC_ACMD_H3COUNT_SHIFT 12
1604#define HC_ACMD_H4ID_MASK 0x000001ff
1605#define HC_ACMD_H4COUNT_MASK 0x01fffe00
1606#define HC_ACMD_H4COUNT_SHIFT 9
1607
1608/********************************************************************************
1609** Define Header
1610********************************************************************************/
1611#define HC_HEADER2 0xF210F110
1612
1613/********************************************************************************
1614** Define Dummy Value
1615********************************************************************************/
1616#define HC_DUMMY 0xCCCCCCCC
1617/********************************************************************************
1618** Define for DMA use
1619********************************************************************************/
1620#define HALCYON_HEADER2 0XF210F110
1621#define HALCYON_FIRECMD 0XEE100000
1622#define HALCYON_FIREMASK 0XFFF00000
1623#define HALCYON_CMDB 0XEC000000
1624#define HALCYON_CMDBMASK 0XFFFE0000
1625#define HALCYON_SUB_ADDR0 0X00000000
1626#define HALCYON_HEADER1MASK 0XFFFFFC00
1627#define HALCYON_HEADER1 0XF0000000
1628#define HC_SubA_HAGPBstL 0x0060
1629#define HC_SubA_HAGPBendL 0x0061
1630#define HC_SubA_HAGPCMNT 0x0062
1631#define HC_SubA_HAGPBpL 0x0063
1632#define HC_SubA_HAGPBpH 0x0064
1633#define HC_HAGPCMNT_MASK 0x00800000
1634#define HC_HCmdErrClr_MASK 0x00400000
1635#define HC_HAGPBendH_MASK 0x0000ff00
1636#define HC_HAGPBstH_MASK 0x000000ff
1637#define HC_HAGPBendH_SHIFT 8
1638#define HC_HAGPBstH_SHIFT 0
1639#define HC_HAGPBpL_MASK 0x00fffffc
1640#define HC_HAGPBpID_MASK 0x00000003
1641#define HC_HAGPBpID_PAUSE 0x00000000
1642#define HC_HAGPBpID_JUMP 0x00000001
1643#define HC_HAGPBpID_STOP 0x00000002
1644#define HC_HAGPBpH_MASK 0x00ffffff
1645
1646
1647#define VIA_VIDEO_HEADER5 0xFE040000
1648#define VIA_VIDEO_HEADER6 0xFE050000
1649#define VIA_VIDEO_HEADER7 0xFE060000
1650#define VIA_VIDEOMASK 0xFFFF0000
1651#endif
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c
new file mode 100644
index 000000000000..82f839451622
--- /dev/null
+++ b/drivers/char/drm/via_dma.c
@@ -0,0 +1,741 @@
1/* via_dma.c -- DMA support for the VIA Unichrome/Pro
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Copyright 2004 Digeo, Inc., Palo Alto, CA, U.S.A.
7 * All Rights Reserved.
8 *
9 * Copyright 2004 The Unichrome project.
10 * All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sub license,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice (including the
20 * next paragraph) shall be included in all copies or substantial portions
21 * of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
26 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
27 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
28 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
29 * USE OR OTHER DEALINGS IN THE SOFTWARE.
30 *
31 * Authors:
32 * Tungsten Graphics,
33 * Erdi Chen,
34 * Thomas Hellstrom.
35 */
36
37#include "drmP.h"
38#include "drm.h"
39#include "via_drm.h"
40#include "via_drv.h"
41#include "via_3d_reg.h"
42
43#define CMDBUF_ALIGNMENT_SIZE (0x100)
44#define CMDBUF_ALIGNMENT_MASK (0x0ff)
45
46/* defines for VIA 3D registers */
47#define VIA_REG_STATUS 0x400
48#define VIA_REG_TRANSET 0x43C
49#define VIA_REG_TRANSPACE 0x440
50
51/* VIA_REG_STATUS(0x400): Engine Status */
52#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */
53#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */
54#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */
55#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */
56
57#define SetReg2DAGP(nReg, nData) { \
58 *((uint32_t *)(vb)) = ((nReg) >> 2) | HALCYON_HEADER1; \
59 *((uint32_t *)(vb) + 1) = (nData); \
60 vb = ((uint32_t *)vb) + 2; \
61 dev_priv->dma_low +=8; \
62}
63
64#define via_flush_write_combine() DRM_MEMORYBARRIER()
65
66#define VIA_OUT_RING_QW(w1,w2) \
67 *vb++ = (w1); \
68 *vb++ = (w2); \
69 dev_priv->dma_low += 8;
70
71static void via_cmdbuf_start(drm_via_private_t * dev_priv);
72static void via_cmdbuf_pause(drm_via_private_t * dev_priv);
73static void via_cmdbuf_reset(drm_via_private_t * dev_priv);
74static void via_cmdbuf_rewind(drm_via_private_t * dev_priv);
75static int via_wait_idle(drm_via_private_t * dev_priv);
76static void via_pad_cache(drm_via_private_t *dev_priv, int qwords);
77
78
79/*
80 * Free space in command buffer.
81 */
82
83static uint32_t
84via_cmdbuf_space(drm_via_private_t *dev_priv)
85{
86 uint32_t agp_base = dev_priv->dma_offset +
87 (uint32_t) dev_priv->agpAddr;
88 uint32_t hw_addr = *(dev_priv->hw_addr_ptr) - agp_base;
89
90 return ((hw_addr <= dev_priv->dma_low) ?
91 (dev_priv->dma_high + hw_addr - dev_priv->dma_low) :
92 (hw_addr - dev_priv->dma_low));
93}
94
95/*
96 * How much does the command regulator lag behind?
97 */
98
99static uint32_t
100via_cmdbuf_lag(drm_via_private_t *dev_priv)
101{
102 uint32_t agp_base = dev_priv->dma_offset +
103 (uint32_t) dev_priv->agpAddr;
104 uint32_t hw_addr = *(dev_priv->hw_addr_ptr) - agp_base;
105
106 return ((hw_addr <= dev_priv->dma_low) ?
107 (dev_priv->dma_low - hw_addr) :
108 (dev_priv->dma_wrap + dev_priv->dma_low - hw_addr));
109}
110
111/*
112 * Check that the given size fits in the buffer, otherwise wait.
113 */
114
115static inline int
116via_cmdbuf_wait(drm_via_private_t * dev_priv, unsigned int size)
117{
118 uint32_t agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
119 uint32_t cur_addr, hw_addr, next_addr;
120 volatile uint32_t *hw_addr_ptr;
121 uint32_t count;
122 hw_addr_ptr = dev_priv->hw_addr_ptr;
123 cur_addr = dev_priv->dma_low;
124 next_addr = cur_addr + size + 512*1024;
125 count = 1000000;
126 do {
127 hw_addr = *hw_addr_ptr - agp_base;
128 if (count-- == 0) {
129 DRM_ERROR("via_cmdbuf_wait timed out hw %x cur_addr %x next_addr %x\n",
130 hw_addr, cur_addr, next_addr);
131 return -1;
132 }
133 } while ((cur_addr < hw_addr) && (next_addr >= hw_addr));
134 return 0;
135}
136
137
138/*
139 * Checks whether buffer head has reach the end. Rewind the ring buffer
140 * when necessary.
141 *
142 * Returns virtual pointer to ring buffer.
143 */
144
145static inline uint32_t *via_check_dma(drm_via_private_t * dev_priv,
146 unsigned int size)
147{
148 if ((dev_priv->dma_low + size + 4*CMDBUF_ALIGNMENT_SIZE) > dev_priv->dma_high) {
149 via_cmdbuf_rewind(dev_priv);
150 }
151 if (via_cmdbuf_wait(dev_priv, size) != 0) {
152 return NULL;
153 }
154
155 return (uint32_t *) (dev_priv->dma_ptr + dev_priv->dma_low);
156}
157
158int via_dma_cleanup(drm_device_t * dev)
159{
160 if (dev->dev_private) {
161 drm_via_private_t *dev_priv =
162 (drm_via_private_t *) dev->dev_private;
163
164 if (dev_priv->ring.virtual_start) {
165 via_cmdbuf_reset(dev_priv);
166
167 drm_core_ioremapfree(&dev_priv->ring.map, dev);
168 dev_priv->ring.virtual_start = NULL;
169 }
170
171 }
172
173 return 0;
174}
175
176static int via_initialize(drm_device_t * dev,
177 drm_via_private_t * dev_priv,
178 drm_via_dma_init_t * init)
179{
180 if (!dev_priv || !dev_priv->mmio) {
181 DRM_ERROR("via_dma_init called before via_map_init\n");
182 return DRM_ERR(EFAULT);
183 }
184
185 if (dev_priv->ring.virtual_start != NULL) {
186 DRM_ERROR("%s called again without calling cleanup\n",
187 __FUNCTION__);
188 return DRM_ERR(EFAULT);
189 }
190
191 if (!dev->agp || !dev->agp->base) {
192 DRM_ERROR("%s called with no agp memory available\n",
193 __FUNCTION__);
194 return DRM_ERR(EFAULT);
195 }
196
197 dev_priv->ring.map.offset = dev->agp->base + init->offset;
198 dev_priv->ring.map.size = init->size;
199 dev_priv->ring.map.type = 0;
200 dev_priv->ring.map.flags = 0;
201 dev_priv->ring.map.mtrr = 0;
202
203 drm_core_ioremap(&dev_priv->ring.map, dev);
204
205 if (dev_priv->ring.map.handle == NULL) {
206 via_dma_cleanup(dev);
207 DRM_ERROR("can not ioremap virtual address for"
208 " ring buffer\n");
209 return DRM_ERR(ENOMEM);
210 }
211
212 dev_priv->ring.virtual_start = dev_priv->ring.map.handle;
213
214 dev_priv->dma_ptr = dev_priv->ring.virtual_start;
215 dev_priv->dma_low = 0;
216 dev_priv->dma_high = init->size;
217 dev_priv->dma_wrap = init->size;
218 dev_priv->dma_offset = init->offset;
219 dev_priv->last_pause_ptr = NULL;
220 dev_priv->hw_addr_ptr = dev_priv->mmio->handle + init->reg_pause_addr;
221
222 via_cmdbuf_start(dev_priv);
223
224 return 0;
225}
226
227int via_dma_init(DRM_IOCTL_ARGS)
228{
229 DRM_DEVICE;
230 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
231 drm_via_dma_init_t init;
232 int retcode = 0;
233
234 DRM_COPY_FROM_USER_IOCTL(init, (drm_via_dma_init_t *) data,
235 sizeof(init));
236
237 switch (init.func) {
238 case VIA_INIT_DMA:
239 if (!capable(CAP_SYS_ADMIN))
240 retcode = DRM_ERR(EPERM);
241 else
242 retcode = via_initialize(dev, dev_priv, &init);
243 break;
244 case VIA_CLEANUP_DMA:
245 if (!capable(CAP_SYS_ADMIN))
246 retcode = DRM_ERR(EPERM);
247 else
248 retcode = via_dma_cleanup(dev);
249 break;
250 case VIA_DMA_INITIALIZED:
251 retcode = (dev_priv->ring.virtual_start != NULL) ?
252 0: DRM_ERR( EFAULT );
253 break;
254 default:
255 retcode = DRM_ERR(EINVAL);
256 break;
257 }
258
259 return retcode;
260}
261
262
263
264static int via_dispatch_cmdbuffer(drm_device_t * dev, drm_via_cmdbuffer_t * cmd)
265{
266 drm_via_private_t *dev_priv;
267 uint32_t *vb;
268 int ret;
269
270 dev_priv = (drm_via_private_t *) dev->dev_private;
271
272 if (dev_priv->ring.virtual_start == NULL) {
273 DRM_ERROR("%s called without initializing AGP ring buffer.\n",
274 __FUNCTION__);
275 return DRM_ERR(EFAULT);
276 }
277
278 if (cmd->size > VIA_PCI_BUF_SIZE) {
279 return DRM_ERR(ENOMEM);
280 }
281
282
283 if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size))
284 return DRM_ERR(EFAULT);
285
286 /*
287 * Running this function on AGP memory is dead slow. Therefore
288 * we run it on a temporary cacheable system memory buffer and
289 * copy it to AGP memory when ready.
290 */
291
292
293 if ((ret = via_verify_command_stream((uint32_t *)dev_priv->pci_buf, cmd->size, dev, 1))) {
294 return ret;
295 }
296
297
298 vb = via_check_dma(dev_priv, (cmd->size < 0x100) ? 0x102 : cmd->size);
299 if (vb == NULL) {
300 return DRM_ERR(EAGAIN);
301 }
302
303 memcpy(vb, dev_priv->pci_buf, cmd->size);
304
305 dev_priv->dma_low += cmd->size;
306
307 /*
308 * Small submissions somehow stalls the CPU. (AGP cache effects?)
309 * pad to greater size.
310 */
311
312 if (cmd->size < 0x100)
313 via_pad_cache(dev_priv,(0x100 - cmd->size) >> 3);
314 via_cmdbuf_pause(dev_priv);
315
316 return 0;
317}
318
319int via_driver_dma_quiescent(drm_device_t * dev)
320{
321 drm_via_private_t *dev_priv = dev->dev_private;
322
323 if (!via_wait_idle(dev_priv)) {
324 return DRM_ERR(EBUSY);
325 }
326 return 0;
327}
328
329int via_flush_ioctl(DRM_IOCTL_ARGS)
330{
331 DRM_DEVICE;
332
333 LOCK_TEST_WITH_RETURN( dev, filp );
334
335 return via_driver_dma_quiescent(dev);
336}
337
338int via_cmdbuffer(DRM_IOCTL_ARGS)
339{
340 DRM_DEVICE;
341 drm_via_cmdbuffer_t cmdbuf;
342 int ret;
343
344 LOCK_TEST_WITH_RETURN( dev, filp );
345
346 DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t *) data,
347 sizeof(cmdbuf));
348
349 DRM_DEBUG("via cmdbuffer, buf %p size %lu\n", cmdbuf.buf, cmdbuf.size);
350
351 ret = via_dispatch_cmdbuffer(dev, &cmdbuf);
352 if (ret) {
353 return ret;
354 }
355
356 return 0;
357}
358
359extern int
360via_parse_command_stream(drm_device_t *dev, const uint32_t * buf, unsigned int size);
361static int via_dispatch_pci_cmdbuffer(drm_device_t * dev,
362 drm_via_cmdbuffer_t * cmd)
363{
364 drm_via_private_t *dev_priv = dev->dev_private;
365 int ret;
366
367 if (cmd->size > VIA_PCI_BUF_SIZE) {
368 return DRM_ERR(ENOMEM);
369 }
370 if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size))
371 return DRM_ERR(EFAULT);
372
373 if ((ret = via_verify_command_stream((uint32_t *)dev_priv->pci_buf, cmd->size, dev, 0))) {
374 return ret;
375 }
376
377 ret = via_parse_command_stream(dev, (const uint32_t *)dev_priv->pci_buf, cmd->size);
378 return ret;
379}
380
381int via_pci_cmdbuffer(DRM_IOCTL_ARGS)
382{
383 DRM_DEVICE;
384 drm_via_cmdbuffer_t cmdbuf;
385 int ret;
386
387 LOCK_TEST_WITH_RETURN( dev, filp );
388
389 DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t *) data,
390 sizeof(cmdbuf));
391
392 DRM_DEBUG("via_pci_cmdbuffer, buf %p size %lu\n", cmdbuf.buf,
393 cmdbuf.size);
394
395 ret = via_dispatch_pci_cmdbuffer(dev, &cmdbuf);
396 if (ret) {
397 return ret;
398 }
399
400 return 0;
401}
402
403
404static inline uint32_t *via_align_buffer(drm_via_private_t * dev_priv,
405 uint32_t * vb, int qw_count)
406{
407 for (; qw_count > 0; --qw_count) {
408 VIA_OUT_RING_QW(HC_DUMMY, HC_DUMMY);
409 }
410 return vb;
411}
412
413
414/*
415 * This function is used internally by ring buffer mangement code.
416 *
417 * Returns virtual pointer to ring buffer.
418 */
419static inline uint32_t *via_get_dma(drm_via_private_t * dev_priv)
420{
421 return (uint32_t *) (dev_priv->dma_ptr + dev_priv->dma_low);
422}
423
424/*
425 * Hooks a segment of data into the tail of the ring-buffer by
426 * modifying the pause address stored in the buffer itself. If
427 * the regulator has already paused, restart it.
428 */
429static int via_hook_segment(drm_via_private_t *dev_priv,
430 uint32_t pause_addr_hi, uint32_t pause_addr_lo,
431 int no_pci_fire)
432{
433 int paused, count;
434 volatile uint32_t *paused_at = dev_priv->last_pause_ptr;
435
436 via_flush_write_combine();
437 while(! *(via_get_dma(dev_priv)-1));
438 *dev_priv->last_pause_ptr = pause_addr_lo;
439 via_flush_write_combine();
440
441 /*
442 * The below statement is inserted to really force the flush.
443 * Not sure it is needed.
444 */
445
446 while(! *dev_priv->last_pause_ptr);
447 dev_priv->last_pause_ptr = via_get_dma(dev_priv) - 1;
448 while(! *dev_priv->last_pause_ptr);
449
450
451 paused = 0;
452 count = 20;
453
454 while (!(paused = (VIA_READ(0x41c) & 0x80000000)) && count--);
455 if ((count <= 8) && (count >= 0)) {
456 uint32_t rgtr, ptr;
457 rgtr = *(dev_priv->hw_addr_ptr);
458 ptr = ((char *)dev_priv->last_pause_ptr - dev_priv->dma_ptr) +
459 dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4 -
460 CMDBUF_ALIGNMENT_SIZE;
461 if (rgtr <= ptr) {
462 DRM_ERROR("Command regulator\npaused at count %d, address %x, "
463 "while current pause address is %x.\n"
464 "Please mail this message to "
465 "<unichrome-devel@lists.sourceforge.net>\n",
466 count, rgtr, ptr);
467 }
468 }
469
470 if (paused && !no_pci_fire) {
471 uint32_t rgtr,ptr;
472 uint32_t ptr_low;
473
474 count = 1000000;
475 while ((VIA_READ(VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY) && count--);
476
477 rgtr = *(dev_priv->hw_addr_ptr);
478 ptr = ((char *)paused_at - dev_priv->dma_ptr) +
479 dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4;
480
481
482 ptr_low = (ptr > 3*CMDBUF_ALIGNMENT_SIZE) ?
483 ptr - 3*CMDBUF_ALIGNMENT_SIZE : 0;
484 if (rgtr <= ptr && rgtr >= ptr_low) {
485 VIA_WRITE(VIA_REG_TRANSET, (HC_ParaType_PreCR << 16));
486 VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_hi);
487 VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_lo);
488 }
489 }
490 return paused;
491}
492
493
494
495static int via_wait_idle(drm_via_private_t * dev_priv)
496{
497 int count = 10000000;
498 while (count-- && (VIA_READ(VIA_REG_STATUS) &
499 (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY |
500 VIA_3D_ENG_BUSY))) ;
501 return count;
502}
503
504static uint32_t *via_align_cmd(drm_via_private_t * dev_priv, uint32_t cmd_type,
505 uint32_t addr, uint32_t *cmd_addr_hi,
506 uint32_t *cmd_addr_lo,
507 int skip_wait)
508{
509 uint32_t agp_base;
510 uint32_t cmd_addr, addr_lo, addr_hi;
511 uint32_t *vb;
512 uint32_t qw_pad_count;
513
514 if (!skip_wait)
515 via_cmdbuf_wait(dev_priv, 2*CMDBUF_ALIGNMENT_SIZE);
516
517 vb = via_get_dma(dev_priv);
518 VIA_OUT_RING_QW( HC_HEADER2 | ((VIA_REG_TRANSET >> 2) << 12) |
519 (VIA_REG_TRANSPACE >> 2), HC_ParaType_PreCR << 16);
520 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
521 qw_pad_count = (CMDBUF_ALIGNMENT_SIZE >> 3) -
522 ((dev_priv->dma_low & CMDBUF_ALIGNMENT_MASK) >> 3);
523
524
525 cmd_addr = (addr) ? addr :
526 agp_base + dev_priv->dma_low - 8 + (qw_pad_count << 3);
527 addr_lo = ((HC_SubA_HAGPBpL << 24) | (cmd_type & HC_HAGPBpID_MASK) |
528 (cmd_addr & HC_HAGPBpL_MASK));
529 addr_hi = ((HC_SubA_HAGPBpH << 24) | (cmd_addr >> 24));
530
531 vb = via_align_buffer(dev_priv, vb, qw_pad_count - 1);
532 VIA_OUT_RING_QW(*cmd_addr_hi = addr_hi,
533 *cmd_addr_lo = addr_lo);
534 return vb;
535}
536
537
538
539
540static void via_cmdbuf_start(drm_via_private_t * dev_priv)
541{
542 uint32_t pause_addr_lo, pause_addr_hi;
543 uint32_t start_addr, start_addr_lo;
544 uint32_t end_addr, end_addr_lo;
545 uint32_t command;
546 uint32_t agp_base;
547
548
549 dev_priv->dma_low = 0;
550
551 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
552 start_addr = agp_base;
553 end_addr = agp_base + dev_priv->dma_high;
554
555 start_addr_lo = ((HC_SubA_HAGPBstL << 24) | (start_addr & 0xFFFFFF));
556 end_addr_lo = ((HC_SubA_HAGPBendL << 24) | (end_addr & 0xFFFFFF));
557 command = ((HC_SubA_HAGPCMNT << 24) | (start_addr >> 24) |
558 ((end_addr & 0xff000000) >> 16));
559
560 dev_priv->last_pause_ptr =
561 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0,
562 &pause_addr_hi, & pause_addr_lo, 1) - 1;
563
564 via_flush_write_combine();
565 while(! *dev_priv->last_pause_ptr);
566
567 VIA_WRITE(VIA_REG_TRANSET, (HC_ParaType_PreCR << 16));
568 VIA_WRITE(VIA_REG_TRANSPACE, command);
569 VIA_WRITE(VIA_REG_TRANSPACE, start_addr_lo);
570 VIA_WRITE(VIA_REG_TRANSPACE, end_addr_lo);
571
572 VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_hi);
573 VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_lo);
574
575 VIA_WRITE(VIA_REG_TRANSPACE, command | HC_HAGPCMNT_MASK);
576}
577
578static void via_pad_cache(drm_via_private_t *dev_priv, int qwords)
579{
580 uint32_t *vb;
581
582 via_cmdbuf_wait(dev_priv, qwords + 2);
583 vb = via_get_dma(dev_priv);
584 VIA_OUT_RING_QW( HC_HEADER2, HC_ParaType_NotTex << 16);
585 via_align_buffer(dev_priv,vb,qwords);
586}
587
588static inline void via_dummy_bitblt(drm_via_private_t * dev_priv)
589{
590 uint32_t *vb = via_get_dma(dev_priv);
591 SetReg2DAGP(0x0C, (0 | (0 << 16)));
592 SetReg2DAGP(0x10, 0 | (0 << 16));
593 SetReg2DAGP(0x0, 0x1 | 0x2000 | 0xAA000000);
594}
595
596
597static void via_cmdbuf_jump(drm_via_private_t * dev_priv)
598{
599 uint32_t agp_base;
600 uint32_t pause_addr_lo, pause_addr_hi;
601 uint32_t jump_addr_lo, jump_addr_hi;
602 volatile uint32_t *last_pause_ptr;
603 uint32_t dma_low_save1, dma_low_save2;
604
605 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
606 via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi,
607 &jump_addr_lo, 0);
608
609 dev_priv->dma_wrap = dev_priv->dma_low;
610
611
612 /*
613 * Wrap command buffer to the beginning.
614 */
615
616 dev_priv->dma_low = 0;
617 if (via_cmdbuf_wait(dev_priv, CMDBUF_ALIGNMENT_SIZE) != 0) {
618 DRM_ERROR("via_cmdbuf_jump failed\n");
619 }
620
621 via_dummy_bitblt(dev_priv);
622 via_dummy_bitblt(dev_priv);
623
624 last_pause_ptr = via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
625 &pause_addr_lo, 0) -1;
626 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
627 &pause_addr_lo, 0);
628
629 *last_pause_ptr = pause_addr_lo;
630 dma_low_save1 = dev_priv->dma_low;
631
632 /*
633 * Now, set a trap that will pause the regulator if it tries to rerun the old
634 * command buffer. (Which may happen if via_hook_segment detecs a command regulator pause
635 * and reissues the jump command over PCI, while the regulator has already taken the jump
636 * and actually paused at the current buffer end).
637 * There appears to be no other way to detect this condition, since the hw_addr_pointer
638 * does not seem to get updated immediately when a jump occurs.
639 */
640
641 last_pause_ptr = via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
642 &pause_addr_lo, 0) -1;
643 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
644 &pause_addr_lo, 0);
645 *last_pause_ptr = pause_addr_lo;
646
647 dma_low_save2 = dev_priv->dma_low;
648 dev_priv->dma_low = dma_low_save1;
649 via_hook_segment( dev_priv, jump_addr_hi, jump_addr_lo, 0);
650 dev_priv->dma_low = dma_low_save2;
651 via_hook_segment( dev_priv, pause_addr_hi, pause_addr_lo, 0);
652}
653
654
655static void via_cmdbuf_rewind(drm_via_private_t * dev_priv)
656{
657 via_cmdbuf_jump(dev_priv);
658}
659
660static void via_cmdbuf_flush(drm_via_private_t * dev_priv, uint32_t cmd_type)
661{
662 uint32_t pause_addr_lo, pause_addr_hi;
663
664 via_align_cmd(dev_priv, cmd_type, 0, &pause_addr_hi, &pause_addr_lo, 0);
665 via_hook_segment( dev_priv, pause_addr_hi, pause_addr_lo, 0);
666}
667
668
669static void via_cmdbuf_pause(drm_via_private_t * dev_priv)
670{
671 via_cmdbuf_flush(dev_priv, HC_HAGPBpID_PAUSE);
672}
673
674static void via_cmdbuf_reset(drm_via_private_t * dev_priv)
675{
676 via_cmdbuf_flush(dev_priv, HC_HAGPBpID_STOP);
677 via_wait_idle(dev_priv);
678}
679
680/*
681 * User interface to the space and lag functions.
682 */
683
684int
685via_cmdbuf_size(DRM_IOCTL_ARGS)
686{
687 DRM_DEVICE;
688 drm_via_cmdbuf_size_t d_siz;
689 int ret = 0;
690 uint32_t tmp_size, count;
691 drm_via_private_t *dev_priv;
692
693 DRM_DEBUG("via cmdbuf_size\n");
694 LOCK_TEST_WITH_RETURN( dev, filp );
695
696 dev_priv = (drm_via_private_t *) dev->dev_private;
697
698 if (dev_priv->ring.virtual_start == NULL) {
699 DRM_ERROR("%s called without initializing AGP ring buffer.\n",
700 __FUNCTION__);
701 return DRM_ERR(EFAULT);
702 }
703
704 DRM_COPY_FROM_USER_IOCTL(d_siz, (drm_via_cmdbuf_size_t *) data,
705 sizeof(d_siz));
706
707
708 count = 1000000;
709 tmp_size = d_siz.size;
710 switch(d_siz.func) {
711 case VIA_CMDBUF_SPACE:
712 while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz.size) && count--) {
713 if (!d_siz.wait) {
714 break;
715 }
716 }
717 if (!count) {
718 DRM_ERROR("VIA_CMDBUF_SPACE timed out.\n");
719 ret = DRM_ERR(EAGAIN);
720 }
721 break;
722 case VIA_CMDBUF_LAG:
723 while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz.size) && count--) {
724 if (!d_siz.wait) {
725 break;
726 }
727 }
728 if (!count) {
729 DRM_ERROR("VIA_CMDBUF_LAG timed out.\n");
730 ret = DRM_ERR(EAGAIN);
731 }
732 break;
733 default:
734 ret = DRM_ERR(EFAULT);
735 }
736 d_siz.size = tmp_size;
737
738 DRM_COPY_TO_USER_IOCTL((drm_via_cmdbuf_size_t *) data, d_siz,
739 sizeof(d_siz));
740 return ret;
741}
diff --git a/drivers/char/drm/via_drm.h b/drivers/char/drm/via_drm.h
new file mode 100644
index 000000000000..4588c9bd1816
--- /dev/null
+++ b/drivers/char/drm/via_drm.h
@@ -0,0 +1,243 @@
1/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24#ifndef _VIA_DRM_H_
25#define _VIA_DRM_H_
26
27/* WARNING: These defines must be the same as what the Xserver uses.
28 * if you change them, you must change the defines in the Xserver.
29 */
30
31#ifndef _VIA_DEFINES_
32#define _VIA_DEFINES_
33
34#ifndef __KERNEL__
35#include "via_drmclient.h"
36#endif
37
38#define VIA_NR_SAREA_CLIPRECTS 8
39#define VIA_NR_XVMC_PORTS 10
40#define VIA_NR_XVMC_LOCKS 5
41#define VIA_MAX_CACHELINE_SIZE 64
42#define XVMCLOCKPTR(saPriv,lockNo) \
43 ((volatile drm_hw_lock_t *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
44 (VIA_MAX_CACHELINE_SIZE - 1)) & \
45 ~(VIA_MAX_CACHELINE_SIZE - 1)) + \
46 VIA_MAX_CACHELINE_SIZE*(lockNo)))
47
48/* Each region is a minimum of 64k, and there are at most 64 of them.
49 */
50#define VIA_NR_TEX_REGIONS 64
51#define VIA_LOG_MIN_TEX_REGION_SIZE 16
52#endif
53
54#define VIA_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
55#define VIA_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
56#define VIA_UPLOAD_CTX 0x4
57#define VIA_UPLOAD_BUFFERS 0x8
58#define VIA_UPLOAD_TEX0 0x10
59#define VIA_UPLOAD_TEX1 0x20
60#define VIA_UPLOAD_CLIPRECTS 0x40
61#define VIA_UPLOAD_ALL 0xff
62
63/* VIA specific ioctls */
64#define DRM_VIA_ALLOCMEM 0x00
65#define DRM_VIA_FREEMEM 0x01
66#define DRM_VIA_AGP_INIT 0x02
67#define DRM_VIA_FB_INIT 0x03
68#define DRM_VIA_MAP_INIT 0x04
69#define DRM_VIA_DEC_FUTEX 0x05
70#define NOT_USED
71#define DRM_VIA_DMA_INIT 0x07
72#define DRM_VIA_CMDBUFFER 0x08
73#define DRM_VIA_FLUSH 0x09
74#define DRM_VIA_PCICMD 0x0a
75#define DRM_VIA_CMDBUF_SIZE 0x0b
76#define NOT_USED
77#define DRM_VIA_WAIT_IRQ 0x0d
78
79#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
80#define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
81#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
82#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
83#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
84#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
85#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
86#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
87#define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH)
88#define DRM_IOCTL_VIA_PCICMD DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
89#define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \
90 drm_via_cmdbuf_size_t)
91#define DRM_IOCTL_VIA_WAIT_IRQ DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t)
92
93/* Indices into buf.Setup where various bits of state are mirrored per
94 * context and per buffer. These can be fired at the card as a unit,
95 * or in a piecewise fashion as required.
96 */
97
98#define VIA_TEX_SETUP_SIZE 8
99
100/* Flags for clear ioctl
101 */
102#define VIA_FRONT 0x1
103#define VIA_BACK 0x2
104#define VIA_DEPTH 0x4
105#define VIA_STENCIL 0x8
106#define VIDEO 0
107#define AGP 1
108typedef struct {
109 uint32_t offset;
110 uint32_t size;
111} drm_via_agp_t;
112
113typedef struct {
114 uint32_t offset;
115 uint32_t size;
116} drm_via_fb_t;
117
118typedef struct {
119 uint32_t context;
120 uint32_t type;
121 uint32_t size;
122 unsigned long index;
123 unsigned long offset;
124} drm_via_mem_t;
125
126typedef struct _drm_via_init {
127 enum {
128 VIA_INIT_MAP = 0x01,
129 VIA_CLEANUP_MAP = 0x02
130 } func;
131
132 unsigned long sarea_priv_offset;
133 unsigned long fb_offset;
134 unsigned long mmio_offset;
135 unsigned long agpAddr;
136} drm_via_init_t;
137
138typedef struct _drm_via_futex {
139 enum {
140 VIA_FUTEX_WAIT = 0x00,
141 VIA_FUTEX_WAKE = 0X01
142 } func;
143 uint32_t ms;
144 uint32_t lock;
145 uint32_t val;
146} drm_via_futex_t;
147
148typedef struct _drm_via_dma_init {
149 enum {
150 VIA_INIT_DMA = 0x01,
151 VIA_CLEANUP_DMA = 0x02,
152 VIA_DMA_INITIALIZED = 0x03
153 } func;
154
155 unsigned long offset;
156 unsigned long size;
157 unsigned long reg_pause_addr;
158} drm_via_dma_init_t;
159
160typedef struct _drm_via_cmdbuffer {
161 char *buf;
162 unsigned long size;
163} drm_via_cmdbuffer_t;
164
165/* Warning: If you change the SAREA structure you must change the Xserver
166 * structure as well */
167
168typedef struct _drm_via_tex_region {
169 unsigned char next, prev; /* indices to form a circular LRU */
170 unsigned char inUse; /* owned by a client, or free? */
171 int age; /* tracked by clients to update local LRU's */
172} drm_via_tex_region_t;
173
174typedef struct _drm_via_sarea {
175 unsigned int dirty;
176 unsigned int nbox;
177 drm_clip_rect_t boxes[VIA_NR_SAREA_CLIPRECTS];
178 drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
179 int texAge; /* last time texture was uploaded */
180 int ctxOwner; /* last context to upload state */
181 int vertexPrim;
182
183 /*
184 * Below is for XvMC.
185 * We want the lock integers alone on, and aligned to, a cache line.
186 * Therefore this somewhat strange construct.
187 */
188
189 char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
190
191 unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
192 unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
193 unsigned int XvMCCtxNoGrabbed; /* Last context to hold decoder */
194
195} drm_via_sarea_t;
196
197typedef struct _drm_via_cmdbuf_size {
198 enum {
199 VIA_CMDBUF_SPACE = 0x01,
200 VIA_CMDBUF_LAG = 0x02
201 } func;
202 int wait;
203 uint32_t size;
204} drm_via_cmdbuf_size_t;
205
206typedef enum {
207 VIA_IRQ_ABSOLUTE = 0x0,
208 VIA_IRQ_RELATIVE = 0x1,
209 VIA_IRQ_SIGNAL = 0x10000000,
210 VIA_IRQ_FORCE_SEQUENCE = 0x20000000
211} via_irq_seq_type_t;
212
213#define VIA_IRQ_FLAGS_MASK 0xF0000000
214
215struct drm_via_wait_irq_request{
216 unsigned irq;
217 via_irq_seq_type_t type;
218 uint32_t sequence;
219 uint32_t signal;
220};
221
222typedef union drm_via_irqwait {
223 struct drm_via_wait_irq_request request;
224 struct drm_wait_vblank_reply reply;
225} drm_via_irqwait_t;
226
227#ifdef __KERNEL__
228
229int via_fb_init(DRM_IOCTL_ARGS);
230int via_mem_alloc(DRM_IOCTL_ARGS);
231int via_mem_free(DRM_IOCTL_ARGS);
232int via_agp_init(DRM_IOCTL_ARGS);
233int via_map_init(DRM_IOCTL_ARGS);
234int via_decoder_futex(DRM_IOCTL_ARGS);
235int via_dma_init(DRM_IOCTL_ARGS);
236int via_cmdbuffer(DRM_IOCTL_ARGS);
237int via_flush_ioctl(DRM_IOCTL_ARGS);
238int via_pci_cmdbuffer(DRM_IOCTL_ARGS);
239int via_cmdbuf_size(DRM_IOCTL_ARGS);
240int via_wait_irq(DRM_IOCTL_ARGS);
241
242#endif
243#endif /* _VIA_DRM_H_ */
diff --git a/drivers/char/drm/via_drv.c b/drivers/char/drm/via_drv.c
new file mode 100644
index 000000000000..275eefc79221
--- /dev/null
+++ b/drivers/char/drm/via_drv.c
@@ -0,0 +1,126 @@
1/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#include <linux/config.h>
26#include "drmP.h"
27#include "via_drm.h"
28#include "via_drv.h"
29
30#include "drm_pciids.h"
31
32static int postinit(struct drm_device *dev, unsigned long flags)
33{
34 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
35 DRIVER_NAME,
36 DRIVER_MAJOR,
37 DRIVER_MINOR,
38 DRIVER_PATCHLEVEL,
39 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
40 );
41 return 0;
42}
43
44static int version(drm_version_t * version)
45{
46 int len;
47
48 version->version_major = DRIVER_MAJOR;
49 version->version_minor = DRIVER_MINOR;
50 version->version_patchlevel = DRIVER_PATCHLEVEL;
51 DRM_COPY(version->name, DRIVER_NAME);
52 DRM_COPY(version->date, DRIVER_DATE);
53 DRM_COPY(version->desc, DRIVER_DESC);
54 return 0;
55}
56
57static struct pci_device_id pciidlist[] = {
58 viadrv_PCI_IDS
59};
60
61static drm_ioctl_desc_t ioctls[] = {
62 [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = {via_mem_alloc, 1, 0},
63 [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = {via_mem_free, 1, 0},
64 [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = {via_agp_init, 1, 0},
65 [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = {via_fb_init, 1, 0},
66 [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = {via_map_init, 1, 0},
67 [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = {via_decoder_futex, 1, 0},
68 [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = {via_dma_init, 1, 0},
69 [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = {via_cmdbuffer, 1, 0},
70 [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = {via_flush_ioctl, 1, 0},
71 [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = {via_pci_cmdbuffer, 1, 0},
72 [DRM_IOCTL_NR(DRM_VIA_CMDBUF_SIZE)] = {via_cmdbuf_size, 1, 0},
73 [DRM_IOCTL_NR(DRM_VIA_WAIT_IRQ)] = {via_wait_irq, 1, 0}
74};
75
76static struct drm_driver driver = {
77 .driver_features =
78 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ |
79 DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
80 .context_ctor = via_init_context,
81 .context_dtor = via_final_context,
82 .vblank_wait = via_driver_vblank_wait,
83 .irq_preinstall = via_driver_irq_preinstall,
84 .irq_postinstall = via_driver_irq_postinstall,
85 .irq_uninstall = via_driver_irq_uninstall,
86 .irq_handler = via_driver_irq_handler,
87 .dma_quiescent = via_driver_dma_quiescent,
88 .reclaim_buffers = drm_core_reclaim_buffers,
89 .get_map_ofs = drm_core_get_map_ofs,
90 .get_reg_ofs = drm_core_get_reg_ofs,
91 .postinit = postinit,
92 .version = version,
93 .ioctls = ioctls,
94 .num_ioctls = DRM_ARRAY_SIZE(ioctls),
95 .fops = {
96 .owner = THIS_MODULE,
97 .open = drm_open,
98 .release = drm_release,
99 .ioctl = drm_ioctl,
100 .mmap = drm_mmap,
101 .poll = drm_poll,
102 .fasync = drm_fasync,
103 },
104 .pci_driver = {
105 .name = DRIVER_NAME,
106 .id_table = pciidlist,
107 }
108};
109
110static int __init via_init(void)
111{
112 via_init_command_verifier();
113 return drm_init(&driver);
114}
115
116static void __exit via_exit(void)
117{
118 drm_exit(&driver);
119}
120
121module_init(via_init);
122module_exit(via_exit);
123
124MODULE_AUTHOR(DRIVER_AUTHOR);
125MODULE_DESCRIPTION(DRIVER_DESC);
126MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/char/drm/via_drv.h b/drivers/char/drm/via_drv.h
new file mode 100644
index 000000000000..4eaa8b7c4c96
--- /dev/null
+++ b/drivers/char/drm/via_drv.h
@@ -0,0 +1,118 @@
1/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24#ifndef _VIA_DRV_H_
25#define _VIA_DRV_H_
26
27#define DRIVER_AUTHOR "VIA"
28
29#define DRIVER_NAME "via"
30#define DRIVER_DESC "VIA Unichrome / Pro"
31#define DRIVER_DATE "20050523"
32
33#define DRIVER_MAJOR 2
34#define DRIVER_MINOR 6
35#define DRIVER_PATCHLEVEL 3
36
37#include "via_verifier.h"
38
39#define VIA_PCI_BUF_SIZE 60000
40#define VIA_FIRE_BUF_SIZE 1024
41#define VIA_NUM_IRQS 2
42
43
44
45typedef struct drm_via_ring_buffer {
46 drm_map_t map;
47 char *virtual_start;
48} drm_via_ring_buffer_t;
49
50typedef uint32_t maskarray_t[5];
51
52typedef struct drm_via_irq {
53 atomic_t irq_received;
54 uint32_t pending_mask;
55 uint32_t enable_mask;
56 wait_queue_head_t irq_queue;
57} drm_via_irq_t;
58
59typedef struct drm_via_private {
60 drm_via_sarea_t *sarea_priv;
61 drm_map_t *sarea;
62 drm_map_t *fb;
63 drm_map_t *mmio;
64 unsigned long agpAddr;
65 wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS];
66 char *dma_ptr;
67 unsigned int dma_low;
68 unsigned int dma_high;
69 unsigned int dma_offset;
70 uint32_t dma_wrap;
71 volatile uint32_t *last_pause_ptr;
72 volatile uint32_t *hw_addr_ptr;
73 drm_via_ring_buffer_t ring;
74 struct timeval last_vblank;
75 int last_vblank_valid;
76 unsigned usec_per_vblank;
77 drm_via_state_t hc_state;
78 char pci_buf[VIA_PCI_BUF_SIZE];
79 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
80 uint32_t num_fire_offsets;
81 int pro_group_a;
82 drm_via_irq_t via_irqs[VIA_NUM_IRQS];
83 unsigned num_irqs;
84 maskarray_t *irq_masks;
85 uint32_t irq_enable_mask;
86 uint32_t irq_pending_mask;
87} drm_via_private_t;
88
89/* VIA MMIO register access */
90#define VIA_BASE ((dev_priv->mmio))
91
92#define VIA_READ(reg) DRM_READ32(VIA_BASE, reg)
93#define VIA_WRITE(reg,val) DRM_WRITE32(VIA_BASE, reg, val)
94#define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg)
95#define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val)
96
97extern int via_init_context(drm_device_t * dev, int context);
98extern int via_final_context(drm_device_t * dev, int context);
99
100extern int via_do_cleanup_map(drm_device_t * dev);
101extern int via_map_init(struct inode *inode, struct file *filp,
102 unsigned int cmd, unsigned long arg);
103extern int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence);
104
105extern irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS);
106extern void via_driver_irq_preinstall(drm_device_t * dev);
107extern void via_driver_irq_postinstall(drm_device_t * dev);
108extern void via_driver_irq_uninstall(drm_device_t * dev);
109
110extern int via_dma_cleanup(drm_device_t * dev);
111extern void via_init_command_verifier(void);
112extern int via_driver_dma_quiescent(drm_device_t * dev);
113extern void via_init_futex(drm_via_private_t *dev_priv);
114extern void via_cleanup_futex(drm_via_private_t *dev_priv);
115extern void via_release_futex(drm_via_private_t *dev_priv, int context);
116
117
118#endif
diff --git a/drivers/char/drm/via_ds.c b/drivers/char/drm/via_ds.c
new file mode 100644
index 000000000000..daf3df75a20e
--- /dev/null
+++ b/drivers/char/drm/via_ds.c
@@ -0,0 +1,280 @@
1/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sub license,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25#include <linux/module.h>
26#include <linux/delay.h>
27#include <linux/errno.h>
28#include <linux/kernel.h>
29#include <linux/slab.h>
30#include <linux/poll.h>
31#include <linux/pci.h>
32#include <asm/io.h>
33
34#include "via_ds.h"
35extern unsigned int VIA_DEBUG;
36
37set_t *via_setInit(void)
38{
39 int i;
40 set_t *set;
41 set = (set_t *) drm_alloc(sizeof(set_t), DRM_MEM_DRIVER);
42 for (i = 0; i < SET_SIZE; i++) {
43 set->list[i].free_next = i + 1;
44 set->list[i].alloc_next = -1;
45 }
46 set->list[SET_SIZE - 1].free_next = -1;
47 set->free = 0;
48 set->alloc = -1;
49 set->trace = -1;
50 return set;
51}
52
53int via_setAdd(set_t * set, ITEM_TYPE item)
54{
55 int free = set->free;
56 if (free != -1) {
57 set->list[free].val = item;
58 set->free = set->list[free].free_next;
59 } else {
60 return 0;
61 }
62 set->list[free].alloc_next = set->alloc;
63 set->alloc = free;
64 set->list[free].free_next = -1;
65 return 1;
66}
67
68int via_setDel(set_t * set, ITEM_TYPE item)
69{
70 int alloc = set->alloc;
71 int prev = -1;
72
73 while (alloc != -1) {
74 if (set->list[alloc].val == item) {
75 if (prev != -1)
76 set->list[prev].alloc_next =
77 set->list[alloc].alloc_next;
78 else
79 set->alloc = set->list[alloc].alloc_next;
80 break;
81 }
82 prev = alloc;
83 alloc = set->list[alloc].alloc_next;
84 }
85
86 if (alloc == -1)
87 return 0;
88
89 set->list[alloc].free_next = set->free;
90 set->free = alloc;
91 set->list[alloc].alloc_next = -1;
92
93 return 1;
94}
95
96/* setFirst -> setAdd -> setNext is wrong */
97
98int via_setFirst(set_t * set, ITEM_TYPE * item)
99{
100 if (set->alloc == -1)
101 return 0;
102
103 *item = set->list[set->alloc].val;
104 set->trace = set->list[set->alloc].alloc_next;
105
106 return 1;
107}
108
109int via_setNext(set_t * set, ITEM_TYPE * item)
110{
111 if (set->trace == -1)
112 return 0;
113
114 *item = set->list[set->trace].val;
115 set->trace = set->list[set->trace].alloc_next;
116
117 return 1;
118}
119
120int via_setDestroy(set_t * set)
121{
122 drm_free(set, sizeof(set_t), DRM_MEM_DRIVER);
123
124 return 1;
125}
126
127#define ISFREE(bptr) ((bptr)->free)
128
129#define fprintf(fmt, arg...) do{}while(0)
130
131memHeap_t *via_mmInit(int ofs, int size)
132{
133 PMemBlock blocks;
134
135 if (size <= 0)
136 return 0;
137
138 blocks = (TMemBlock *) drm_calloc(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
139
140 if (blocks) {
141 blocks->ofs = ofs;
142 blocks->size = size;
143 blocks->free = 1;
144 return (memHeap_t *) blocks;
145 } else
146 return 0;
147}
148
149static TMemBlock *SliceBlock(TMemBlock * p,
150 int startofs, int size,
151 int reserved, int alignment)
152{
153 TMemBlock *newblock;
154
155 /* break left */
156 if (startofs > p->ofs) {
157 newblock =
158 (TMemBlock *) drm_calloc(1, sizeof(TMemBlock),
159 DRM_MEM_DRIVER);
160 newblock->ofs = startofs;
161 newblock->size = p->size - (startofs - p->ofs);
162 newblock->free = 1;
163 newblock->next = p->next;
164 p->size -= newblock->size;
165 p->next = newblock;
166 p = newblock;
167 }
168
169 /* break right */
170 if (size < p->size) {
171 newblock =
172 (TMemBlock *) drm_calloc(1, sizeof(TMemBlock),
173 DRM_MEM_DRIVER);
174 newblock->ofs = startofs + size;
175 newblock->size = p->size - size;
176 newblock->free = 1;
177 newblock->next = p->next;
178 p->size = size;
179 p->next = newblock;
180 }
181
182 /* p = middle block */
183 p->align = alignment;
184 p->free = 0;
185 p->reserved = reserved;
186 return p;
187}
188
189PMemBlock via_mmAllocMem(memHeap_t * heap, int size, int align2,
190 int startSearch)
191{
192 int mask, startofs, endofs;
193 TMemBlock *p;
194
195 if (!heap || align2 < 0 || size <= 0)
196 return NULL;
197
198 mask = (1 << align2) - 1;
199 startofs = 0;
200 p = (TMemBlock *) heap;
201
202 while (p) {
203 if (ISFREE(p)) {
204 startofs = (p->ofs + mask) & ~mask;
205
206 if (startofs < startSearch)
207 startofs = startSearch;
208
209 endofs = startofs + size;
210
211 if (endofs <= (p->ofs + p->size))
212 break;
213 }
214
215 p = p->next;
216 }
217
218 if (!p)
219 return NULL;
220
221 p = SliceBlock(p, startofs, size, 0, mask + 1);
222 p->heap = heap;
223
224 return p;
225}
226
227static __inline__ int Join2Blocks(TMemBlock * p)
228{
229 if (p->free && p->next && p->next->free) {
230 TMemBlock *q = p->next;
231 p->size += q->size;
232 p->next = q->next;
233 drm_free(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
234
235 return 1;
236 }
237
238 return 0;
239}
240
241int via_mmFreeMem(PMemBlock b)
242{
243 TMemBlock *p, *prev;
244
245 if (!b)
246 return 0;
247
248 if (!b->heap) {
249 fprintf(stderr, "no heap\n");
250
251 return -1;
252 }
253
254 p = b->heap;
255 prev = NULL;
256
257 while (p && p != b) {
258 prev = p;
259 p = p->next;
260 }
261
262 if (!p || p->free || p->reserved) {
263 if (!p)
264 fprintf(stderr, "block not found in heap\n");
265 else if (p->free)
266 fprintf(stderr, "block already free\n");
267 else
268 fprintf(stderr, "block is reserved\n");
269
270 return -1;
271 }
272
273 p->free = 1;
274 Join2Blocks(p);
275
276 if (prev)
277 Join2Blocks(prev);
278
279 return 0;
280}
diff --git a/drivers/char/drm/via_ds.h b/drivers/char/drm/via_ds.h
new file mode 100644
index 000000000000..be9c7f9f1aee
--- /dev/null
+++ b/drivers/char/drm/via_ds.h
@@ -0,0 +1,104 @@
1/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
5 * All rights reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sub license,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 */
26#ifndef _via_ds_h_
27#define _via_ds_h_
28
29#include "drmP.h"
30
31/* Set Data Structure */
32#define SET_SIZE 5000
33typedef unsigned long ITEM_TYPE;
34
35typedef struct {
36 ITEM_TYPE val;
37 int alloc_next, free_next;
38} list_item_t;
39
40typedef struct {
41 int alloc;
42 int free;
43 int trace;
44 list_item_t list[SET_SIZE];
45} set_t;
46
47set_t *via_setInit(void);
48int via_setAdd(set_t * set, ITEM_TYPE item);
49int via_setDel(set_t * set, ITEM_TYPE item);
50int via_setFirst(set_t * set, ITEM_TYPE * item);
51int via_setNext(set_t * set, ITEM_TYPE * item);
52int via_setDestroy(set_t * set);
53
54#endif
55
56#ifndef MM_INC
57#define MM_INC
58
59struct mem_block_t {
60 struct mem_block_t *next;
61 struct mem_block_t *heap;
62 int ofs, size;
63 int align;
64 int free:1;
65 int reserved:1;
66};
67typedef struct mem_block_t TMemBlock;
68typedef struct mem_block_t *PMemBlock;
69
70/* a heap is just the first block in a chain */
71typedef struct mem_block_t memHeap_t;
72
73static __inline__ int mmBlockSize(PMemBlock b)
74{
75 return b->size;
76}
77
78static __inline__ int mmOffset(PMemBlock b)
79{
80 return b->ofs;
81}
82
83static __inline__ void mmMarkReserved(PMemBlock b)
84{
85 b->reserved = 1;
86}
87
88/*
89 * input: total size in bytes
90 * return: a heap pointer if OK, NULL if error
91 */
92memHeap_t *via_mmInit(int ofs, int size);
93
94PMemBlock via_mmAllocMem(memHeap_t * heap, int size, int align2,
95 int startSearch);
96
97/*
98 * Free block starts at offset
99 * input: pointer to a block
100 * return: 0 if OK, -1 if error
101 */
102int via_mmFreeMem(PMemBlock b);
103
104#endif
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c
new file mode 100644
index 000000000000..e8027f3a93b0
--- /dev/null
+++ b/drivers/char/drm/via_irq.c
@@ -0,0 +1,339 @@
1/* via_irq.c
2 *
3 * Copyright 2004 BEAM Ltd.
4 * Copyright 2002 Tungsten Graphics, Inc.
5 * Copyright 2005 Thomas Hellstrom.
6 * All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
17 * Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BEAM LTD, TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 *
28 * Authors:
29 * Terry Barnaby <terry1@beam.ltd.uk>
30 * Keith Whitwell <keith@tungstengraphics.com>
31 * Thomas Hellstrom <unichrome@shipmail.org>
32 *
33 * This code provides standard DRM access to the Via Unichrome / Pro Vertical blank
34 * interrupt, as well as an infrastructure to handle other interrupts of the chip.
35 * The refresh rate is also calculated for video playback sync purposes.
36 */
37
38#include "drmP.h"
39#include "drm.h"
40#include "via_drm.h"
41#include "via_drv.h"
42
43#define VIA_REG_INTERRUPT 0x200
44
45/* VIA_REG_INTERRUPT */
46#define VIA_IRQ_GLOBAL (1 << 31)
47#define VIA_IRQ_VBLANK_ENABLE (1 << 19)
48#define VIA_IRQ_VBLANK_PENDING (1 << 3)
49#define VIA_IRQ_HQV0_ENABLE (1 << 11)
50#define VIA_IRQ_HQV1_ENABLE (1 << 25)
51#define VIA_IRQ_HQV0_PENDING (1 << 9)
52#define VIA_IRQ_HQV1_PENDING (1 << 10)
53
54/*
55 * Device-specific IRQs go here. This type might need to be extended with
56 * the register if there are multiple IRQ control registers.
57 * Currently we activate the HQV interrupts of Unichrome Pro group A.
58 */
59
60static maskarray_t via_pro_group_a_irqs[] = {
61 {VIA_IRQ_HQV0_ENABLE, VIA_IRQ_HQV0_PENDING, 0x000003D0, 0x00008010, 0x00000000 },
62 {VIA_IRQ_HQV1_ENABLE, VIA_IRQ_HQV1_PENDING, 0x000013D0, 0x00008010, 0x00000000 }};
63static int via_num_pro_group_a = sizeof(via_pro_group_a_irqs)/sizeof(maskarray_t);
64
65static maskarray_t via_unichrome_irqs[] = {};
66static int via_num_unichrome = sizeof(via_unichrome_irqs)/sizeof(maskarray_t);
67
68
69static unsigned time_diff(struct timeval *now,struct timeval *then)
70{
71 return (now->tv_usec >= then->tv_usec) ?
72 now->tv_usec - then->tv_usec :
73 1000000 - (then->tv_usec - now->tv_usec);
74}
75
76irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
77{
78 drm_device_t *dev = (drm_device_t *) arg;
79 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
80 u32 status;
81 int handled = 0;
82 struct timeval cur_vblank;
83 drm_via_irq_t *cur_irq = dev_priv->via_irqs;
84 int i;
85
86 status = VIA_READ(VIA_REG_INTERRUPT);
87 if (status & VIA_IRQ_VBLANK_PENDING) {
88 atomic_inc(&dev->vbl_received);
89 if (!(atomic_read(&dev->vbl_received) & 0x0F)) {
90 do_gettimeofday(&cur_vblank);
91 if (dev_priv->last_vblank_valid) {
92 dev_priv->usec_per_vblank =
93 time_diff( &cur_vblank,&dev_priv->last_vblank) >> 4;
94 }
95 dev_priv->last_vblank = cur_vblank;
96 dev_priv->last_vblank_valid = 1;
97 }
98 if (!(atomic_read(&dev->vbl_received) & 0xFF)) {
99 DRM_DEBUG("US per vblank is: %u\n",
100 dev_priv->usec_per_vblank);
101 }
102 DRM_WAKEUP(&dev->vbl_queue);
103 drm_vbl_send_signals(dev);
104 handled = 1;
105 }
106
107
108 for (i=0; i<dev_priv->num_irqs; ++i) {
109 if (status & cur_irq->pending_mask) {
110 atomic_inc( &cur_irq->irq_received );
111 DRM_WAKEUP( &cur_irq->irq_queue );
112 handled = 1;
113 }
114 cur_irq++;
115 }
116
117 /* Acknowlege interrupts */
118 VIA_WRITE(VIA_REG_INTERRUPT, status);
119
120
121 if (handled)
122 return IRQ_HANDLED;
123 else
124 return IRQ_NONE;
125}
126
127static __inline__ void viadrv_acknowledge_irqs(drm_via_private_t * dev_priv)
128{
129 u32 status;
130
131 if (dev_priv) {
132 /* Acknowlege interrupts */
133 status = VIA_READ(VIA_REG_INTERRUPT);
134 VIA_WRITE(VIA_REG_INTERRUPT, status |
135 dev_priv->irq_pending_mask);
136 }
137}
138
139int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
140{
141 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
142 unsigned int cur_vblank;
143 int ret = 0;
144
145 DRM_DEBUG("viadrv_vblank_wait\n");
146 if (!dev_priv) {
147 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
148 return -EINVAL;
149 }
150
151 viadrv_acknowledge_irqs(dev_priv);
152
153 /* Assume that the user has missed the current sequence number
154 * by about a day rather than she wants to wait for years
155 * using vertical blanks...
156 */
157
158 DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
159 (((cur_vblank = atomic_read(&dev->vbl_received)) -
160 *sequence) <= (1 << 23)));
161
162 *sequence = cur_vblank;
163 return ret;
164}
165
166static int
167via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence,
168 unsigned int *sequence)
169{
170 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
171 unsigned int cur_irq_sequence;
172 drm_via_irq_t *cur_irq = dev_priv->via_irqs;
173 int ret = 0;
174 maskarray_t *masks = dev_priv->irq_masks;
175
176 DRM_DEBUG("%s\n", __FUNCTION__);
177
178 if (!dev_priv) {
179 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
180 return DRM_ERR(EINVAL);
181 }
182
183 if (irq >= dev_priv->num_irqs ) {
184 DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__, irq);
185 return DRM_ERR(EINVAL);
186 }
187
188 cur_irq += irq;
189
190 if (masks[irq][2] && !force_sequence) {
191 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
192 ((VIA_READ(masks[irq][2]) & masks[irq][3]) == masks[irq][4]));
193 cur_irq_sequence = atomic_read(&cur_irq->irq_received);
194 } else {
195 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
196 (((cur_irq_sequence = atomic_read(&cur_irq->irq_received)) -
197 *sequence) <= (1 << 23)));
198 }
199 *sequence = cur_irq_sequence;
200 return ret;
201}
202
203
204/*
205 * drm_dma.h hooks
206 */
207
208void via_driver_irq_preinstall(drm_device_t * dev)
209{
210 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
211 u32 status;
212 drm_via_irq_t *cur_irq = dev_priv->via_irqs;
213 int i;
214
215 DRM_DEBUG("driver_irq_preinstall: dev_priv: %p\n", dev_priv);
216 if (dev_priv) {
217
218 dev_priv->irq_enable_mask = VIA_IRQ_VBLANK_ENABLE;
219 dev_priv->irq_pending_mask = VIA_IRQ_VBLANK_PENDING;
220
221 dev_priv->irq_masks = (dev_priv->pro_group_a) ?
222 via_pro_group_a_irqs : via_unichrome_irqs;
223 dev_priv->num_irqs = (dev_priv->pro_group_a) ?
224 via_num_pro_group_a : via_num_unichrome;
225
226 for(i=0; i < dev_priv->num_irqs; ++i) {
227 atomic_set(&cur_irq->irq_received, 0);
228 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
229 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
230 DRM_INIT_WAITQUEUE( &cur_irq->irq_queue );
231 dev_priv->irq_enable_mask |= cur_irq->enable_mask;
232 dev_priv->irq_pending_mask |= cur_irq->pending_mask;
233 cur_irq++;
234
235 DRM_DEBUG("Initializing IRQ %d\n", i);
236 }
237
238 dev_priv->last_vblank_valid = 0;
239
240 // Clear VSync interrupt regs
241 status = VIA_READ(VIA_REG_INTERRUPT);
242 VIA_WRITE(VIA_REG_INTERRUPT, status &
243 ~(dev_priv->irq_enable_mask));
244
245 /* Clear bits if they're already high */
246 viadrv_acknowledge_irqs(dev_priv);
247 }
248}
249
250void via_driver_irq_postinstall(drm_device_t * dev)
251{
252 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
253 u32 status;
254
255 DRM_DEBUG("via_driver_irq_postinstall\n");
256 if (dev_priv) {
257 status = VIA_READ(VIA_REG_INTERRUPT);
258 VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_GLOBAL
259 | dev_priv->irq_enable_mask);
260
261 /* Some magic, oh for some data sheets ! */
262
263 VIA_WRITE8(0x83d4, 0x11);
264 VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) | 0x30);
265
266 }
267}
268
269void via_driver_irq_uninstall(drm_device_t * dev)
270{
271 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
272 u32 status;
273
274 DRM_DEBUG("driver_irq_uninstall)\n");
275 if (dev_priv) {
276
277 /* Some more magic, oh for some data sheets ! */
278
279 VIA_WRITE8(0x83d4, 0x11);
280 VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) & ~0x30);
281
282 status = VIA_READ(VIA_REG_INTERRUPT);
283 VIA_WRITE(VIA_REG_INTERRUPT, status &
284 ~(VIA_IRQ_VBLANK_ENABLE | dev_priv->irq_enable_mask));
285 }
286}
287
288int via_wait_irq(DRM_IOCTL_ARGS)
289{
290 drm_file_t *priv = filp->private_data;
291 drm_device_t *dev = priv->head->dev;
292 drm_via_irqwait_t __user *argp = (void __user *)data;
293 drm_via_irqwait_t irqwait;
294 struct timeval now;
295 int ret = 0;
296 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
297 drm_via_irq_t *cur_irq = dev_priv->via_irqs;
298 int force_sequence;
299
300 if (!dev->irq)
301 return DRM_ERR(EINVAL);
302
303 DRM_COPY_FROM_USER_IOCTL(irqwait, argp, sizeof(irqwait));
304 if (irqwait.request.irq >= dev_priv->num_irqs) {
305 DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__,
306 irqwait.request.irq);
307 return DRM_ERR(EINVAL);
308 }
309
310 cur_irq += irqwait.request.irq;
311
312 switch (irqwait.request.type & ~VIA_IRQ_FLAGS_MASK) {
313 case VIA_IRQ_RELATIVE:
314 irqwait.request.sequence += atomic_read(&cur_irq->irq_received);
315 irqwait.request.type &= ~_DRM_VBLANK_RELATIVE;
316 case VIA_IRQ_ABSOLUTE:
317 break;
318 default:
319 return DRM_ERR(EINVAL);
320 }
321
322 if (irqwait.request.type & VIA_IRQ_SIGNAL) {
323 DRM_ERROR("%s Signals on Via IRQs not implemented yet.\n",
324 __FUNCTION__);
325 return DRM_ERR(EINVAL);
326 }
327
328 force_sequence = (irqwait.request.type & VIA_IRQ_FORCE_SEQUENCE);
329
330 ret = via_driver_irq_wait(dev, irqwait.request.irq, force_sequence,
331 &irqwait.request.sequence);
332 do_gettimeofday(&now);
333 irqwait.reply.tval_sec = now.tv_sec;
334 irqwait.reply.tval_usec = now.tv_usec;
335
336 DRM_COPY_TO_USER_IOCTL(argp, irqwait, sizeof(irqwait));
337
338 return ret;
339}
diff --git a/drivers/char/drm/via_map.c b/drivers/char/drm/via_map.c
new file mode 100644
index 000000000000..0be829b6ec65
--- /dev/null
+++ b/drivers/char/drm/via_map.c
@@ -0,0 +1,110 @@
1/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24#include "drmP.h"
25#include "via_drm.h"
26#include "via_drv.h"
27
28static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init)
29{
30 drm_via_private_t *dev_priv;
31
32 DRM_DEBUG("%s\n", __FUNCTION__);
33
34 dev_priv = drm_alloc(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
35 if (dev_priv == NULL)
36 return -ENOMEM;
37
38 memset(dev_priv, 0, sizeof(drm_via_private_t));
39
40 DRM_GETSAREA();
41 if (!dev_priv->sarea) {
42 DRM_ERROR("could not find sarea!\n");
43 dev->dev_private = (void *)dev_priv;
44 via_do_cleanup_map(dev);
45 return -EINVAL;
46 }
47
48 dev_priv->fb = drm_core_findmap(dev, init->fb_offset);
49 if (!dev_priv->fb) {
50 DRM_ERROR("could not find framebuffer!\n");
51 dev->dev_private = (void *)dev_priv;
52 via_do_cleanup_map(dev);
53 return -EINVAL;
54 }
55 dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset);
56 if (!dev_priv->mmio) {
57 DRM_ERROR("could not find mmio region!\n");
58 dev->dev_private = (void *)dev_priv;
59 via_do_cleanup_map(dev);
60 return -EINVAL;
61 }
62
63 dev_priv->sarea_priv =
64 (drm_via_sarea_t *) ((u8 *) dev_priv->sarea->handle +
65 init->sarea_priv_offset);
66
67 dev_priv->agpAddr = init->agpAddr;
68
69 via_init_futex( dev_priv );
70 dev_priv->pro_group_a = (dev->pdev->device == 0x3118);
71
72 dev->dev_private = (void *)dev_priv;
73 return 0;
74}
75
76int via_do_cleanup_map(drm_device_t * dev)
77{
78 if (dev->dev_private) {
79
80 drm_via_private_t *dev_priv = dev->dev_private;
81
82 via_dma_cleanup(dev);
83
84 drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER);
85 dev->dev_private = NULL;
86 }
87
88 return 0;
89}
90
91int via_map_init(DRM_IOCTL_ARGS)
92{
93 DRM_DEVICE;
94 drm_via_init_t init;
95
96 DRM_DEBUG("%s\n", __FUNCTION__);
97
98 DRM_COPY_FROM_USER_IOCTL(init, (drm_via_init_t *) data, sizeof(init));
99
100 switch (init.func) {
101 case VIA_INIT_MAP:
102 return via_do_init_map(dev, &init);
103 case VIA_CLEANUP_MAP:
104 return via_do_cleanup_map(dev);
105 }
106
107 return -EINVAL;
108}
109
110
diff --git a/drivers/char/drm/via_mm.c b/drivers/char/drm/via_mm.c
new file mode 100644
index 000000000000..c22712f44d42
--- /dev/null
+++ b/drivers/char/drm/via_mm.c
@@ -0,0 +1,358 @@
1/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24#include "drmP.h"
25#include "via_drm.h"
26#include "via_drv.h"
27#include "via_ds.h"
28#include "via_mm.h"
29
30#define MAX_CONTEXT 100
31
32typedef struct {
33 int used;
34 int context;
35 set_t *sets[2]; /* 0 for frame buffer, 1 for AGP , 2 for System */
36} via_context_t;
37
38static via_context_t global_ppriv[MAX_CONTEXT];
39
40static int via_agp_alloc(drm_via_mem_t * mem);
41static int via_agp_free(drm_via_mem_t * mem);
42static int via_fb_alloc(drm_via_mem_t * mem);
43static int via_fb_free(drm_via_mem_t * mem);
44
45static int add_alloc_set(int context, int type, unsigned int val)
46{
47 int i, retval = 0;
48
49 for (i = 0; i < MAX_CONTEXT; i++) {
50 if (global_ppriv[i].used && global_ppriv[i].context == context) {
51 retval = via_setAdd(global_ppriv[i].sets[type], val);
52 break;
53 }
54 }
55
56 return retval;
57}
58
59static int del_alloc_set(int context, int type, unsigned int val)
60{
61 int i, retval = 0;
62
63 for (i = 0; i < MAX_CONTEXT; i++)
64 if (global_ppriv[i].used && global_ppriv[i].context == context) {
65 retval = via_setDel(global_ppriv[i].sets[type], val);
66 break;
67 }
68
69 return retval;
70}
71
72/* agp memory management */
73static memHeap_t *AgpHeap = NULL;
74
75int via_agp_init(DRM_IOCTL_ARGS)
76{
77 drm_via_agp_t agp;
78
79 DRM_COPY_FROM_USER_IOCTL(agp, (drm_via_agp_t *) data, sizeof(agp));
80
81 AgpHeap = via_mmInit(agp.offset, agp.size);
82
83 DRM_DEBUG("offset = %lu, size = %lu", (unsigned long)agp.offset, (unsigned long)agp.size);
84
85 return 0;
86}
87
88/* fb memory management */
89static memHeap_t *FBHeap = NULL;
90
91int via_fb_init(DRM_IOCTL_ARGS)
92{
93 drm_via_fb_t fb;
94
95 DRM_COPY_FROM_USER_IOCTL(fb, (drm_via_fb_t *) data, sizeof(fb));
96
97 FBHeap = via_mmInit(fb.offset, fb.size);
98
99 DRM_DEBUG("offset = %lu, size = %lu", (unsigned long)fb.offset, (unsigned long)fb.size);
100
101 return 0;
102}
103
104int via_init_context(struct drm_device *dev, int context)
105{
106 int i;
107
108 for (i = 0; i < MAX_CONTEXT; i++)
109 if (global_ppriv[i].used &&
110 (global_ppriv[i].context == context))
111 break;
112
113 if (i >= MAX_CONTEXT) {
114 for (i = 0; i < MAX_CONTEXT; i++) {
115 if (!global_ppriv[i].used) {
116 global_ppriv[i].context = context;
117 global_ppriv[i].used = 1;
118 global_ppriv[i].sets[0] = via_setInit();
119 global_ppriv[i].sets[1] = via_setInit();
120 DRM_DEBUG("init allocation set, socket=%d,"
121 " context = %d\n", i, context);
122 break;
123 }
124 }
125
126 if ((i >= MAX_CONTEXT) || (global_ppriv[i].sets[0] == NULL) ||
127 (global_ppriv[i].sets[1] == NULL)) {
128 return 0;
129 }
130 }
131
132 return 1;
133}
134
135int via_final_context(struct drm_device *dev, int context)
136{
137 int i;
138 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
139
140 for (i = 0; i < MAX_CONTEXT; i++)
141 if (global_ppriv[i].used &&
142 (global_ppriv[i].context == context))
143 break;
144
145 if (i < MAX_CONTEXT) {
146 set_t *set;
147 ITEM_TYPE item;
148 int retval;
149
150 DRM_DEBUG("find socket %d, context = %d\n", i, context);
151
152 /* Video Memory */
153 set = global_ppriv[i].sets[0];
154 retval = via_setFirst(set, &item);
155 while (retval) {
156 DRM_DEBUG("free video memory 0x%lx\n", item);
157 via_mmFreeMem((PMemBlock) item);
158 retval = via_setNext(set, &item);
159 }
160 via_setDestroy(set);
161
162 /* AGP Memory */
163 set = global_ppriv[i].sets[1];
164 retval = via_setFirst(set, &item);
165 while (retval) {
166 DRM_DEBUG("free agp memory 0x%lx\n", item);
167 via_mmFreeMem((PMemBlock) item);
168 retval = via_setNext(set, &item);
169 }
170 via_setDestroy(set);
171 global_ppriv[i].used = 0;
172 }
173 via_release_futex(dev_priv, context);
174
175
176#if defined(__linux__)
177 /* Linux specific until context tracking code gets ported to BSD */
178 /* Last context, perform cleanup */
179 if (dev->ctx_count == 1 && dev->dev_private) {
180 DRM_DEBUG("Last Context\n");
181 if (dev->irq)
182 drm_irq_uninstall(dev);
183
184 via_cleanup_futex(dev_priv);
185 via_do_cleanup_map(dev);
186 }
187#endif
188
189 return 1;
190}
191
192int via_mem_alloc(DRM_IOCTL_ARGS)
193{
194 drm_via_mem_t mem;
195
196 DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t *) data, sizeof(mem));
197
198 switch (mem.type) {
199 case VIDEO:
200 if (via_fb_alloc(&mem) < 0)
201 return -EFAULT;
202 DRM_COPY_TO_USER_IOCTL((drm_via_mem_t *) data, mem,
203 sizeof(mem));
204 return 0;
205 case AGP:
206 if (via_agp_alloc(&mem) < 0)
207 return -EFAULT;
208 DRM_COPY_TO_USER_IOCTL((drm_via_mem_t *) data, mem,
209 sizeof(mem));
210 return 0;
211 }
212
213 return -EFAULT;
214}
215
216static int via_fb_alloc(drm_via_mem_t * mem)
217{
218 drm_via_mm_t fb;
219 PMemBlock block;
220 int retval = 0;
221
222 if (!FBHeap)
223 return -1;
224
225 fb.size = mem->size;
226 fb.context = mem->context;
227
228 block = via_mmAllocMem(FBHeap, fb.size, 5, 0);
229 if (block) {
230 fb.offset = block->ofs;
231 fb.free = (unsigned long)block;
232 if (!add_alloc_set(fb.context, VIDEO, fb.free)) {
233 DRM_DEBUG("adding to allocation set fails\n");
234 via_mmFreeMem((PMemBlock) fb.free);
235 retval = -1;
236 }
237 } else {
238 fb.offset = 0;
239 fb.size = 0;
240 fb.free = 0;
241 retval = -1;
242 }
243
244 mem->offset = fb.offset;
245 mem->index = fb.free;
246
247 DRM_DEBUG("alloc fb, size = %d, offset = %d\n", fb.size,
248 (int)fb.offset);
249
250 return retval;
251}
252
253static int via_agp_alloc(drm_via_mem_t * mem)
254{
255 drm_via_mm_t agp;
256 PMemBlock block;
257 int retval = 0;
258
259 if (!AgpHeap)
260 return -1;
261
262 agp.size = mem->size;
263 agp.context = mem->context;
264
265 block = via_mmAllocMem(AgpHeap, agp.size, 5, 0);
266 if (block) {
267 agp.offset = block->ofs;
268 agp.free = (unsigned long)block;
269 if (!add_alloc_set(agp.context, AGP, agp.free)) {
270 DRM_DEBUG("adding to allocation set fails\n");
271 via_mmFreeMem((PMemBlock) agp.free);
272 retval = -1;
273 }
274 } else {
275 agp.offset = 0;
276 agp.size = 0;
277 agp.free = 0;
278 }
279
280 mem->offset = agp.offset;
281 mem->index = agp.free;
282
283 DRM_DEBUG("alloc agp, size = %d, offset = %d\n", agp.size,
284 (unsigned int)agp.offset);
285 return retval;
286}
287
288int via_mem_free(DRM_IOCTL_ARGS)
289{
290 drm_via_mem_t mem;
291
292 DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t *) data, sizeof(mem));
293
294 switch (mem.type) {
295
296 case VIDEO:
297 if (via_fb_free(&mem) == 0)
298 return 0;
299 break;
300 case AGP:
301 if (via_agp_free(&mem) == 0)
302 return 0;
303 break;
304 }
305
306 return -EFAULT;
307}
308
309static int via_fb_free(drm_via_mem_t * mem)
310{
311 drm_via_mm_t fb;
312 int retval = 0;
313
314 if (!FBHeap) {
315 return -1;
316 }
317
318 fb.free = mem->index;
319 fb.context = mem->context;
320
321 if (!fb.free) {
322 return -1;
323
324 }
325
326 via_mmFreeMem((PMemBlock) fb.free);
327
328 if (!del_alloc_set(fb.context, VIDEO, fb.free)) {
329 retval = -1;
330 }
331
332 DRM_DEBUG("free fb, free = %ld\n", fb.free);
333
334 return retval;
335}
336
337static int via_agp_free(drm_via_mem_t * mem)
338{
339 drm_via_mm_t agp;
340
341 int retval = 0;
342
343 agp.free = mem->index;
344 agp.context = mem->context;
345
346 if (!agp.free)
347 return -1;
348
349 via_mmFreeMem((PMemBlock) agp.free);
350
351 if (!del_alloc_set(agp.context, AGP, agp.free)) {
352 retval = -1;
353 }
354
355 DRM_DEBUG("free agp, free = %ld\n", agp.free);
356
357 return retval;
358}
diff --git a/drivers/char/drm/via_mm.h b/drivers/char/drm/via_mm.h
new file mode 100644
index 000000000000..d57efda57c76
--- /dev/null
+++ b/drivers/char/drm/via_mm.h
@@ -0,0 +1,40 @@
1/*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24#ifndef _via_drm_mm_h_
25#define _via_drm_mm_h_
26
27typedef struct {
28 unsigned int context;
29 unsigned int size;
30 unsigned long offset;
31 unsigned long free;
32} drm_via_mm_t;
33
34typedef struct {
35 unsigned int size;
36 unsigned long handle;
37 void *virtual;
38} drm_via_dma_t;
39
40#endif
diff --git a/drivers/char/drm/via_verifier.c b/drivers/char/drm/via_verifier.c
new file mode 100644
index 000000000000..07923b0c7a97
--- /dev/null
+++ b/drivers/char/drm/via_verifier.c
@@ -0,0 +1,1061 @@
1/*
2 * Copyright 2004 The Unichrome Project. All Rights Reserved.
3 * Copyright 2005 Thomas Hellstrom. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHOR(S), AND/OR THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Author: Thomas Hellstrom 2004, 2005.
25 * This code was written using docs obtained under NDA from VIA Inc.
26 *
27 * Don't run this code directly on an AGP buffer. Due to cache problems it will
28 * be very slow.
29 */
30
31
32#include "via_3d_reg.h"
33#include "drmP.h"
34#include "drm.h"
35#include "via_drm.h"
36#include "via_verifier.h"
37#include "via_drv.h"
38
39typedef enum{
40 state_command,
41 state_header2,
42 state_header1,
43 state_vheader5,
44 state_vheader6,
45 state_error
46} verifier_state_t;
47
48
49typedef enum{
50 no_check = 0,
51 check_for_header2,
52 check_for_header1,
53 check_for_header2_err,
54 check_for_header1_err,
55 check_for_fire,
56 check_z_buffer_addr0,
57 check_z_buffer_addr1,
58 check_z_buffer_addr_mode,
59 check_destination_addr0,
60 check_destination_addr1,
61 check_destination_addr_mode,
62 check_for_dummy,
63 check_for_dd,
64 check_texture_addr0,
65 check_texture_addr1,
66 check_texture_addr2,
67 check_texture_addr3,
68 check_texture_addr4,
69 check_texture_addr5,
70 check_texture_addr6,
71 check_texture_addr7,
72 check_texture_addr8,
73 check_texture_addr_mode,
74 check_for_vertex_count,
75 check_number_texunits,
76 forbidden_command
77}hazard_t;
78
79/*
80 * Associates each hazard above with a possible multi-command
81 * sequence. For example an address that is split over multiple
82 * commands and that needs to be checked at the first command
83 * that does not include any part of the address.
84 */
85
86static drm_via_sequence_t seqs[] = {
87 no_sequence,
88 no_sequence,
89 no_sequence,
90 no_sequence,
91 no_sequence,
92 no_sequence,
93 z_address,
94 z_address,
95 z_address,
96 dest_address,
97 dest_address,
98 dest_address,
99 no_sequence,
100 no_sequence,
101 tex_address,
102 tex_address,
103 tex_address,
104 tex_address,
105 tex_address,
106 tex_address,
107 tex_address,
108 tex_address,
109 tex_address,
110 tex_address,
111 no_sequence
112};
113
114typedef struct{
115 unsigned int code;
116 hazard_t hz;
117} hz_init_t;
118
119
120
121static hz_init_t init_table1[] = {
122 {0xf2, check_for_header2_err},
123 {0xf0, check_for_header1_err},
124 {0xee, check_for_fire},
125 {0xcc, check_for_dummy},
126 {0xdd, check_for_dd},
127 {0x00, no_check},
128 {0x10, check_z_buffer_addr0},
129 {0x11, check_z_buffer_addr1},
130 {0x12, check_z_buffer_addr_mode},
131 {0x13, no_check},
132 {0x14, no_check},
133 {0x15, no_check},
134 {0x23, no_check},
135 {0x24, no_check},
136 {0x33, no_check},
137 {0x34, no_check},
138 {0x35, no_check},
139 {0x36, no_check},
140 {0x37, no_check},
141 {0x38, no_check},
142 {0x39, no_check},
143 {0x3A, no_check},
144 {0x3B, no_check},
145 {0x3C, no_check},
146 {0x3D, no_check},
147 {0x3E, no_check},
148 {0x40, check_destination_addr0},
149 {0x41, check_destination_addr1},
150 {0x42, check_destination_addr_mode},
151 {0x43, no_check},
152 {0x44, no_check},
153 {0x50, no_check},
154 {0x51, no_check},
155 {0x52, no_check},
156 {0x53, no_check},
157 {0x54, no_check},
158 {0x55, no_check},
159 {0x56, no_check},
160 {0x57, no_check},
161 {0x58, no_check},
162 {0x70, no_check},
163 {0x71, no_check},
164 {0x78, no_check},
165 {0x79, no_check},
166 {0x7A, no_check},
167 {0x7B, no_check},
168 {0x7C, no_check},
169 {0x7D, check_for_vertex_count}
170};
171
172
173
174static hz_init_t init_table2[] = {
175 {0xf2, check_for_header2_err},
176 {0xf0, check_for_header1_err},
177 {0xee, check_for_fire},
178 {0xcc, check_for_dummy},
179 {0x00, check_texture_addr0},
180 {0x01, check_texture_addr0},
181 {0x02, check_texture_addr0},
182 {0x03, check_texture_addr0},
183 {0x04, check_texture_addr0},
184 {0x05, check_texture_addr0},
185 {0x06, check_texture_addr0},
186 {0x07, check_texture_addr0},
187 {0x08, check_texture_addr0},
188 {0x09, check_texture_addr0},
189 {0x20, check_texture_addr1},
190 {0x21, check_texture_addr1},
191 {0x22, check_texture_addr1},
192 {0x23, check_texture_addr4},
193 {0x2B, check_texture_addr3},
194 {0x2C, check_texture_addr3},
195 {0x2D, check_texture_addr3},
196 {0x2E, check_texture_addr3},
197 {0x2F, check_texture_addr3},
198 {0x30, check_texture_addr3},
199 {0x31, check_texture_addr3},
200 {0x32, check_texture_addr3},
201 {0x33, check_texture_addr3},
202 {0x34, check_texture_addr3},
203 {0x4B, check_texture_addr5},
204 {0x4C, check_texture_addr6},
205 {0x51, check_texture_addr7},
206 {0x52, check_texture_addr8},
207 {0x77, check_texture_addr2},
208 {0x78, no_check},
209 {0x79, no_check},
210 {0x7A, no_check},
211 {0x7B, check_texture_addr_mode},
212 {0x7C, no_check},
213 {0x7D, no_check},
214 {0x7E, no_check},
215 {0x7F, no_check},
216 {0x80, no_check},
217 {0x81, no_check},
218 {0x82, no_check},
219 {0x83, no_check},
220 {0x85, no_check},
221 {0x86, no_check},
222 {0x87, no_check},
223 {0x88, no_check},
224 {0x89, no_check},
225 {0x8A, no_check},
226 {0x90, no_check},
227 {0x91, no_check},
228 {0x92, no_check},
229 {0x93, no_check}
230};
231
232static hz_init_t init_table3[] = {
233 {0xf2, check_for_header2_err},
234 {0xf0, check_for_header1_err},
235 {0xcc, check_for_dummy},
236 {0x00, check_number_texunits}
237};
238
239
240static hazard_t table1[256];
241static hazard_t table2[256];
242static hazard_t table3[256];
243
244
245
246static __inline__ int
247eat_words(const uint32_t **buf, const uint32_t *buf_end, unsigned num_words)
248{
249 if ((*buf - buf_end) >= num_words) {
250 *buf += num_words;
251 return 0;
252 }
253 DRM_ERROR("Illegal termination of DMA command buffer\n");
254 return 1;
255}
256
257
258/*
259 * Partially stolen from drm_memory.h
260 */
261
262static __inline__ drm_map_t *
263via_drm_lookup_agp_map (drm_via_state_t *seq, unsigned long offset, unsigned long size,
264 drm_device_t *dev)
265{
266 struct list_head *list;
267 drm_map_list_t *r_list;
268 drm_map_t *map = seq->map_cache;
269
270 if (map && map->offset <= offset && (offset + size) <= (map->offset + map->size)) {
271 return map;
272 }
273
274 list_for_each(list, &dev->maplist->head) {
275 r_list = (drm_map_list_t *) list;
276 map = r_list->map;
277 if (!map)
278 continue;
279 if (map->offset <= offset && (offset + size) <= (map->offset + map->size) &&
280 !(map->flags & _DRM_RESTRICTED) && (map->type == _DRM_AGP)) {
281 seq->map_cache = map;
282 return map;
283 }
284 }
285 return NULL;
286}
287
288
289/*
290 * Require that all AGP texture levels reside in the same AGP map which should
291 * be mappable by the client. This is not a big restriction.
292 * FIXME: To actually enforce this security policy strictly, drm_rmmap
293 * would have to wait for dma quiescent before removing an AGP map.
294 * The via_drm_lookup_agp_map call in reality seems to take
295 * very little CPU time.
296 */
297
298
299static __inline__ int
300finish_current_sequence(drm_via_state_t *cur_seq)
301{
302 switch(cur_seq->unfinished) {
303 case z_address:
304 DRM_DEBUG("Z Buffer start address is 0x%x\n", cur_seq->z_addr);
305 break;
306 case dest_address:
307 DRM_DEBUG("Destination start address is 0x%x\n", cur_seq->d_addr);
308 break;
309 case tex_address:
310 if (cur_seq->agp_texture) {
311 unsigned start = cur_seq->tex_level_lo[cur_seq->texture];
312 unsigned end = cur_seq->tex_level_hi[cur_seq->texture];
313 unsigned long lo=~0, hi=0, tmp;
314 uint32_t *addr, *pitch, *height, tex;
315 unsigned i;
316
317 if (end > 9) end = 9;
318 if (start > 9) start = 9;
319
320 addr =&(cur_seq->t_addr[tex = cur_seq->texture][start]);
321 pitch = &(cur_seq->pitch[tex][start]);
322 height = &(cur_seq->height[tex][start]);
323
324 for (i=start; i<= end; ++i) {
325 tmp = *addr++;
326 if (tmp < lo) lo = tmp;
327 tmp += (*height++ << *pitch++);
328 if (tmp > hi) hi = tmp;
329 }
330
331 if (! via_drm_lookup_agp_map (cur_seq, lo, hi - lo, cur_seq->dev)) {
332 DRM_ERROR("AGP texture is not in allowed map\n");
333 return 2;
334 }
335 }
336 break;
337 default:
338 break;
339 }
340 cur_seq->unfinished = no_sequence;
341 return 0;
342}
343
344static __inline__ int
345investigate_hazard( uint32_t cmd, hazard_t hz, drm_via_state_t *cur_seq)
346{
347 register uint32_t tmp, *tmp_addr;
348
349 if (cur_seq->unfinished && (cur_seq->unfinished != seqs[hz])) {
350 int ret;
351 if ((ret = finish_current_sequence(cur_seq))) return ret;
352 }
353
354 switch(hz) {
355 case check_for_header2:
356 if (cmd == HALCYON_HEADER2) return 1;
357 return 0;
358 case check_for_header1:
359 if ((cmd & HALCYON_HEADER1MASK) == HALCYON_HEADER1) return 1;
360 return 0;
361 case check_for_header2_err:
362 if (cmd == HALCYON_HEADER2) return 1;
363 DRM_ERROR("Illegal DMA HALCYON_HEADER2 command\n");
364 break;
365 case check_for_header1_err:
366 if ((cmd & HALCYON_HEADER1MASK) == HALCYON_HEADER1) return 1;
367 DRM_ERROR("Illegal DMA HALCYON_HEADER1 command\n");
368 break;
369 case check_for_fire:
370 if ((cmd & HALCYON_FIREMASK) == HALCYON_FIRECMD) return 1;
371 DRM_ERROR("Illegal DMA HALCYON_FIRECMD command\n");
372 break;
373 case check_for_dummy:
374 if (HC_DUMMY == cmd) return 0;
375 DRM_ERROR("Illegal DMA HC_DUMMY command\n");
376 break;
377 case check_for_dd:
378 if (0xdddddddd == cmd) return 0;
379 DRM_ERROR("Illegal DMA 0xdddddddd command\n");
380 break;
381 case check_z_buffer_addr0:
382 cur_seq->unfinished = z_address;
383 cur_seq->z_addr = (cur_seq->z_addr & 0xFF000000) |
384 (cmd & 0x00FFFFFF);
385 return 0;
386 case check_z_buffer_addr1:
387 cur_seq->unfinished = z_address;
388 cur_seq->z_addr = (cur_seq->z_addr & 0x00FFFFFF) |
389 ((cmd & 0xFF) << 24);
390 return 0;
391 case check_z_buffer_addr_mode:
392 cur_seq->unfinished = z_address;
393 if ((cmd & 0x0000C000) == 0) return 0;
394 DRM_ERROR("Attempt to place Z buffer in system memory\n");
395 return 2;
396 case check_destination_addr0:
397 cur_seq->unfinished = dest_address;
398 cur_seq->d_addr = (cur_seq->d_addr & 0xFF000000) |
399 (cmd & 0x00FFFFFF);
400 return 0;
401 case check_destination_addr1:
402 cur_seq->unfinished = dest_address;
403 cur_seq->d_addr = (cur_seq->d_addr & 0x00FFFFFF) |
404 ((cmd & 0xFF) << 24);
405 return 0;
406 case check_destination_addr_mode:
407 cur_seq->unfinished = dest_address;
408 if ((cmd & 0x0000C000) == 0) return 0;
409 DRM_ERROR("Attempt to place 3D drawing buffer in system memory\n");
410 return 2;
411 case check_texture_addr0:
412 cur_seq->unfinished = tex_address;
413 tmp = (cmd >> 24);
414 tmp_addr = &cur_seq->t_addr[cur_seq->texture][tmp];
415 *tmp_addr = (*tmp_addr & 0xFF000000) | (cmd & 0x00FFFFFF);
416 return 0;
417 case check_texture_addr1:
418 cur_seq->unfinished = tex_address;
419 tmp = ((cmd >> 24) - 0x20);
420 tmp += tmp << 1;
421 tmp_addr = &cur_seq->t_addr[cur_seq->texture][tmp];
422 *tmp_addr = (*tmp_addr & 0x00FFFFFF) | ((cmd & 0xFF) << 24);
423 tmp_addr++;
424 *tmp_addr = (*tmp_addr & 0x00FFFFFF) | ((cmd & 0xFF00) << 16);
425 tmp_addr++;
426 *tmp_addr = (*tmp_addr & 0x00FFFFFF) | ((cmd & 0xFF0000) << 8);
427 return 0;
428 case check_texture_addr2:
429 cur_seq->unfinished = tex_address;
430 cur_seq->tex_level_lo[tmp = cur_seq->texture] = cmd & 0x3F;
431 cur_seq->tex_level_hi[tmp] = (cmd & 0xFC0) >> 6;
432 return 0;
433 case check_texture_addr3:
434 cur_seq->unfinished = tex_address;
435 tmp = ((cmd >> 24) - 0x2B);
436 cur_seq->pitch[cur_seq->texture][tmp] = (cmd & 0x00F00000) >> 20;
437 if (!tmp && (cmd & 0x000FFFFF)) {
438 DRM_ERROR("Unimplemented texture level 0 pitch mode.\n");
439 return 2;
440 }
441 return 0;
442 case check_texture_addr4:
443 cur_seq->unfinished = tex_address;
444 tmp_addr = &cur_seq->t_addr[cur_seq->texture][9];
445 *tmp_addr = (*tmp_addr & 0x00FFFFFF) | ((cmd & 0xFF) << 24);
446 return 0;
447 case check_texture_addr5:
448 case check_texture_addr6:
449 cur_seq->unfinished = tex_address;
450 /*
451 * Texture width. We don't care since we have the pitch.
452 */
453 return 0;
454 case check_texture_addr7:
455 cur_seq->unfinished = tex_address;
456 tmp_addr = &(cur_seq->height[cur_seq->texture][0]);
457 tmp_addr[5] = 1 << ((cmd & 0x00F00000) >> 20);
458 tmp_addr[4] = 1 << ((cmd & 0x000F0000) >> 16);
459 tmp_addr[3] = 1 << ((cmd & 0x0000F000) >> 12);
460 tmp_addr[2] = 1 << ((cmd & 0x00000F00) >> 8);
461 tmp_addr[1] = 1 << ((cmd & 0x000000F0) >> 4);
462 tmp_addr[0] = 1 << (cmd & 0x0000000F);
463 return 0;
464 case check_texture_addr8:
465 cur_seq->unfinished = tex_address;
466 tmp_addr = &(cur_seq->height[cur_seq->texture][0]);
467 tmp_addr[9] = 1 << ((cmd & 0x0000F000) >> 12);
468 tmp_addr[8] = 1 << ((cmd & 0x00000F00) >> 8);
469 tmp_addr[7] = 1 << ((cmd & 0x000000F0) >> 4);
470 tmp_addr[6] = 1 << (cmd & 0x0000000F);
471 return 0;
472 case check_texture_addr_mode:
473 cur_seq->unfinished = tex_address;
474 if ( 2 == (tmp = cmd & 0x00000003)) {
475 DRM_ERROR("Attempt to fetch texture from system memory.\n");
476 return 2;
477 }
478 cur_seq->agp_texture = (tmp == 3);
479 cur_seq->tex_palette_size[cur_seq->texture] =
480 (cmd >> 16) & 0x000000007;
481 return 0;
482 case check_for_vertex_count:
483 cur_seq->vertex_count = cmd & 0x0000FFFF;
484 return 0;
485 case check_number_texunits:
486 cur_seq->multitex = (cmd >> 3) & 1;
487 return 0;
488 default:
489 DRM_ERROR("Illegal DMA data: 0x%x\n", cmd);
490 return 2;
491 }
492 return 2;
493}
494
495
496static __inline__ int
497via_check_prim_list(uint32_t const **buffer, const uint32_t *buf_end,
498 drm_via_state_t *cur_seq)
499{
500 drm_via_private_t *dev_priv = (drm_via_private_t *) cur_seq->dev->dev_private;
501 uint32_t a_fire, bcmd , dw_count;
502 int ret = 0;
503 int have_fire;
504 const uint32_t *buf = *buffer;
505
506 while(buf < buf_end) {
507 have_fire = 0;
508 if ((buf_end - buf) < 2) {
509 DRM_ERROR("Unexpected termination of primitive list.\n");
510 ret = 1;
511 break;
512 }
513 if ((*buf & HC_ACMD_MASK) != HC_ACMD_HCmdB) break;
514 bcmd = *buf++;
515 if ((*buf & HC_ACMD_MASK) != HC_ACMD_HCmdA) {
516 DRM_ERROR("Expected Vertex List A command, got 0x%x\n",
517 *buf);
518 ret = 1;
519 break;
520 }
521 a_fire = *buf++ | HC_HPLEND_MASK | HC_HPMValidN_MASK | HC_HE3Fire_MASK;
522
523 /*
524 * How many dwords per vertex ?
525 */
526
527 if (cur_seq->agp && ((bcmd & (0xF << 11)) == 0)) {
528 DRM_ERROR("Illegal B command vertex data for AGP.\n");
529 ret = 1;
530 break;
531 }
532
533 dw_count = 0;
534 if (bcmd & (1 << 7)) dw_count += (cur_seq->multitex) ? 2:1;
535 if (bcmd & (1 << 8)) dw_count += (cur_seq->multitex) ? 2:1;
536 if (bcmd & (1 << 9)) dw_count++;
537 if (bcmd & (1 << 10)) dw_count++;
538 if (bcmd & (1 << 11)) dw_count++;
539 if (bcmd & (1 << 12)) dw_count++;
540 if (bcmd & (1 << 13)) dw_count++;
541 if (bcmd & (1 << 14)) dw_count++;
542
543 while(buf < buf_end) {
544 if (*buf == a_fire) {
545 if (dev_priv->num_fire_offsets >= VIA_FIRE_BUF_SIZE) {
546 DRM_ERROR("Fire offset buffer full.\n");
547 ret = 1;
548 break;
549 }
550 dev_priv->fire_offsets[dev_priv->num_fire_offsets++] = buf;
551 have_fire = 1;
552 buf++;
553 if (buf < buf_end && *buf == a_fire)
554 buf++;
555 break;
556 }
557 if ((*buf == HALCYON_HEADER2) ||
558 ((*buf & HALCYON_FIREMASK) == HALCYON_FIRECMD)) {
559 DRM_ERROR("Missing Vertex Fire command, "
560 "Stray Vertex Fire command or verifier "
561 "lost sync.\n");
562 ret = 1;
563 break;
564 }
565 if ((ret = eat_words(&buf, buf_end, dw_count)))
566 break;
567 }
568 if (buf >= buf_end && !have_fire) {
569 DRM_ERROR("Missing Vertex Fire command or verifier "
570 "lost sync.\n");
571 ret = 1;
572 break;
573 }
574 if (cur_seq->agp && ((buf - cur_seq->buf_start) & 0x01)) {
575 DRM_ERROR("AGP Primitive list end misaligned.\n");
576 ret = 1;
577 break;
578 }
579 }
580 *buffer = buf;
581 return ret;
582}
583
584
585
586
587
588static __inline__ verifier_state_t
589via_check_header2( uint32_t const **buffer, const uint32_t *buf_end,
590 drm_via_state_t *hc_state)
591{
592 uint32_t cmd;
593 int hz_mode;
594 hazard_t hz;
595 const uint32_t *buf = *buffer;
596 const hazard_t *hz_table;
597
598
599 if ((buf_end - buf) < 2) {
600 DRM_ERROR("Illegal termination of DMA HALCYON_HEADER2 sequence.\n");
601 return state_error;
602 }
603 buf++;
604 cmd = (*buf++ & 0xFFFF0000) >> 16;
605
606 switch(cmd) {
607 case HC_ParaType_CmdVdata:
608 if (via_check_prim_list(&buf, buf_end, hc_state ))
609 return state_error;
610 *buffer = buf;
611 return state_command;
612 case HC_ParaType_NotTex:
613 hz_table = table1;
614 break;
615 case HC_ParaType_Tex:
616 hc_state->texture = 0;
617 hz_table = table2;
618 break;
619 case (HC_ParaType_Tex | (HC_SubType_Tex1 << 8)):
620 hc_state->texture = 1;
621 hz_table = table2;
622 break;
623 case (HC_ParaType_Tex | (HC_SubType_TexGeneral << 8)):
624 hz_table = table3;
625 break;
626 case HC_ParaType_Auto:
627 if (eat_words(&buf, buf_end, 2))
628 return state_error;
629 *buffer = buf;
630 return state_command;
631 case (HC_ParaType_Palette | (HC_SubType_Stipple << 8)):
632 if (eat_words(&buf, buf_end, 32))
633 return state_error;
634 *buffer = buf;
635 return state_command;
636 case (HC_ParaType_Palette | (HC_SubType_TexPalette0 << 8)):
637 case (HC_ParaType_Palette | (HC_SubType_TexPalette1 << 8)):
638 DRM_ERROR("Texture palettes are rejected because of "
639 "lack of info how to determine their size.\n");
640 return state_error;
641 case (HC_ParaType_Palette | (HC_SubType_FogTable << 8)):
642 DRM_ERROR("Fog factor palettes are rejected because of "
643 "lack of info how to determine their size.\n");
644 return state_error;
645 default:
646
647 /*
648 * There are some unimplemented HC_ParaTypes here, that
649 * need to be implemented if the Mesa driver is extended.
650 */
651
652 DRM_ERROR("Invalid or unimplemented HALCYON_HEADER2 "
653 "DMA subcommand: 0x%x. Previous dword: 0x%x\n",
654 cmd, *(buf -2));
655 *buffer = buf;
656 return state_error;
657 }
658
659 while(buf < buf_end) {
660 cmd = *buf++;
661 if ((hz = hz_table[cmd >> 24])) {
662 if ((hz_mode = investigate_hazard(cmd, hz, hc_state))) {
663 if (hz_mode == 1) {
664 buf--;
665 break;
666 }
667 return state_error;
668 }
669 } else if (hc_state->unfinished &&
670 finish_current_sequence(hc_state)) {
671 return state_error;
672 }
673 }
674 if (hc_state->unfinished && finish_current_sequence(hc_state)) {
675 return state_error;
676 }
677 *buffer = buf;
678 return state_command;
679}
680
681static __inline__ verifier_state_t
682via_parse_header2( drm_via_private_t *dev_priv, uint32_t const **buffer, const uint32_t *buf_end,
683 int *fire_count)
684{
685 uint32_t cmd;
686 const uint32_t *buf = *buffer;
687 const uint32_t *next_fire;
688 int burst = 0;
689
690 next_fire = dev_priv->fire_offsets[*fire_count];
691 buf++;
692 cmd = (*buf & 0xFFFF0000) >> 16;
693 VIA_WRITE(HC_REG_TRANS_SET + HC_REG_BASE, *buf++);
694 switch(cmd) {
695 case HC_ParaType_CmdVdata:
696 while ((buf < buf_end) &&
697 (*fire_count < dev_priv->num_fire_offsets) &&
698 (*buf & HC_ACMD_MASK) == HC_ACMD_HCmdB ) {
699 while(buf <= next_fire) {
700 VIA_WRITE(HC_REG_TRANS_SPACE + HC_REG_BASE + (burst & 63), *buf++);
701 burst += 4;
702 }
703 if ( ( buf < buf_end ) && ((*buf & HALCYON_FIREMASK) == HALCYON_FIRECMD))
704 buf++;
705
706 if (++(*fire_count) < dev_priv->num_fire_offsets)
707 next_fire = dev_priv->fire_offsets[*fire_count];
708 }
709 break;
710 default:
711 while(buf < buf_end) {
712
713 if ( *buf == HC_HEADER2 ||
714 (*buf & HALCYON_HEADER1MASK) == HALCYON_HEADER1 ||
715 (*buf & VIA_VIDEOMASK) == VIA_VIDEO_HEADER5 ||
716 (*buf & VIA_VIDEOMASK) == VIA_VIDEO_HEADER6 ) break;
717
718 VIA_WRITE(HC_REG_TRANS_SPACE + HC_REG_BASE + (burst & 63), *buf++);
719 burst +=4;
720 }
721 }
722 *buffer = buf;
723 return state_command;
724}
725
726
727
728static __inline__ int
729verify_mmio_address( uint32_t address)
730{
731 if ((address > 0x3FF) && (address < 0xC00 )) {
732 DRM_ERROR("Invalid VIDEO DMA command. "
733 "Attempt to access 3D- or command burst area.\n");
734 return 1;
735 } else if ((address > 0xCFF) && (address < 0x1300)) {
736 DRM_ERROR("Invalid VIDEO DMA command. "
737 "Attempt to access PCI DMA area.\n");
738 return 1;
739 } else if (address > 0x13FF ) {
740 DRM_ERROR("Invalid VIDEO DMA command. "
741 "Attempt to access VGA registers.\n");
742 return 1;
743 }
744 return 0;
745}
746
747static __inline__ int
748verify_video_tail( uint32_t const **buffer, const uint32_t *buf_end, uint32_t dwords)
749{
750 const uint32_t *buf = *buffer;
751
752 if (buf_end - buf < dwords) {
753 DRM_ERROR("Illegal termination of video command.\n");
754 return 1;
755 }
756 while (dwords--) {
757 if (*buf++) {
758 DRM_ERROR("Illegal video command tail.\n");
759 return 1;
760 }
761 }
762 *buffer = buf;
763 return 0;
764}
765
766
767static __inline__ verifier_state_t
768via_check_header1( uint32_t const **buffer, const uint32_t *buf_end )
769{
770 uint32_t cmd;
771 const uint32_t *buf = *buffer;
772 verifier_state_t ret = state_command;
773
774 while (buf < buf_end) {
775 cmd = *buf;
776 if ((cmd > ((0x3FF >> 2) | HALCYON_HEADER1)) &&
777 (cmd < ((0xC00 >> 2) | HALCYON_HEADER1))) {
778 if ((cmd & HALCYON_HEADER1MASK) != HALCYON_HEADER1)
779 break;
780 DRM_ERROR("Invalid HALCYON_HEADER1 command. "
781 "Attempt to access 3D- or command burst area.\n");
782 ret = state_error;
783 break;
784 } else if (cmd > ((0xCFF >> 2) | HALCYON_HEADER1)) {
785 if ((cmd & HALCYON_HEADER1MASK) != HALCYON_HEADER1)
786 break;
787 DRM_ERROR("Invalid HALCYON_HEADER1 command. "
788 "Attempt to access VGA registers.\n");
789 ret = state_error;
790 break;
791 } else {
792 buf += 2;
793 }
794 }
795 *buffer = buf;
796 return ret;
797}
798
799static __inline__ verifier_state_t
800via_parse_header1( drm_via_private_t *dev_priv, uint32_t const **buffer, const uint32_t *buf_end )
801{
802 register uint32_t cmd;
803 const uint32_t *buf = *buffer;
804
805 while (buf < buf_end) {
806 cmd = *buf;
807 if ((cmd & HALCYON_HEADER1MASK) != HALCYON_HEADER1) break;
808 VIA_WRITE( (cmd & ~HALCYON_HEADER1MASK) << 2, *++buf);
809 buf++;
810 }
811 *buffer = buf;
812 return state_command;
813}
814
815static __inline__ verifier_state_t
816via_check_vheader5( uint32_t const **buffer, const uint32_t *buf_end )
817{
818 uint32_t data;
819 const uint32_t *buf = *buffer;
820
821 if (buf_end - buf < 4) {
822 DRM_ERROR("Illegal termination of video header5 command\n");
823 return state_error;
824 }
825
826 data = *buf++ & ~VIA_VIDEOMASK;
827 if (verify_mmio_address(data))
828 return state_error;
829
830 data = *buf++;
831 if (*buf++ != 0x00F50000) {
832 DRM_ERROR("Illegal header5 header data\n");
833 return state_error;
834 }
835 if (*buf++ != 0x00000000) {
836 DRM_ERROR("Illegal header5 header data\n");
837 return state_error;
838 }
839 if (eat_words(&buf, buf_end, data))
840 return state_error;
841 if ((data & 3) && verify_video_tail(&buf, buf_end, 4 - (data & 3)))
842 return state_error;
843 *buffer = buf;
844 return state_command;
845
846}
847
848static __inline__ verifier_state_t
849via_parse_vheader5( drm_via_private_t *dev_priv, uint32_t const **buffer, const uint32_t *buf_end )
850{
851 uint32_t addr, count, i;
852 const uint32_t *buf = *buffer;
853
854 addr = *buf++ & ~VIA_VIDEOMASK;
855 i = count = *buf;
856 buf += 3;
857 while(i--) {
858 VIA_WRITE(addr, *buf++);
859 }
860 if (count & 3) buf += 4 - (count & 3);
861 *buffer = buf;
862 return state_command;
863}
864
865
866static __inline__ verifier_state_t
867via_check_vheader6( uint32_t const **buffer, const uint32_t *buf_end )
868{
869 uint32_t data;
870 const uint32_t *buf = *buffer;
871 uint32_t i;
872
873
874 if (buf_end - buf < 4) {
875 DRM_ERROR("Illegal termination of video header6 command\n");
876 return state_error;
877 }
878 buf++;
879 data = *buf++;
880 if (*buf++ != 0x00F60000) {
881 DRM_ERROR("Illegal header6 header data\n");
882 return state_error;
883 }
884 if (*buf++ != 0x00000000) {
885 DRM_ERROR("Illegal header6 header data\n");
886 return state_error;
887 }
888 if ((buf_end - buf) < (data << 1)) {
889 DRM_ERROR("Illegal termination of video header6 command\n");
890 return state_error;
891 }
892 for (i=0; i<data; ++i) {
893 if (verify_mmio_address(*buf++))
894 return state_error;
895 buf++;
896 }
897 data <<= 1;
898 if ((data & 3) && verify_video_tail(&buf, buf_end, 4 - (data & 3)))
899 return state_error;
900 *buffer = buf;
901 return state_command;
902}
903
904static __inline__ verifier_state_t
905via_parse_vheader6( drm_via_private_t *dev_priv, uint32_t const **buffer, const uint32_t *buf_end )
906{
907
908 uint32_t addr, count, i;
909 const uint32_t *buf = *buffer;
910
911 i = count = *++buf;
912 buf += 3;
913 while(i--) {
914 addr = *buf++;
915 VIA_WRITE(addr, *buf++);
916 }
917 count <<= 1;
918 if (count & 3) buf += 4 - (count & 3);
919 *buffer = buf;
920 return state_command;
921}
922
923
924
925int
926via_verify_command_stream(const uint32_t * buf, unsigned int size, drm_device_t *dev,
927 int agp)
928{
929
930 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
931 drm_via_state_t *hc_state = &dev_priv->hc_state;
932 drm_via_state_t saved_state = *hc_state;
933 uint32_t cmd;
934 const uint32_t *buf_end = buf + ( size >> 2 );
935 verifier_state_t state = state_command;
936 int pro_group_a = dev_priv->pro_group_a;
937
938 hc_state->dev = dev;
939 hc_state->unfinished = no_sequence;
940 hc_state->map_cache = NULL;
941 hc_state->agp = agp;
942 hc_state->buf_start = buf;
943 dev_priv->num_fire_offsets = 0;
944
945 while (buf < buf_end) {
946
947 switch (state) {
948 case state_header2:
949 state = via_check_header2( &buf, buf_end, hc_state );
950 break;
951 case state_header1:
952 state = via_check_header1( &buf, buf_end );
953 break;
954 case state_vheader5:
955 state = via_check_vheader5( &buf, buf_end );
956 break;
957 case state_vheader6:
958 state = via_check_vheader6( &buf, buf_end );
959 break;
960 case state_command:
961 if (HALCYON_HEADER2 == (cmd = *buf))
962 state = state_header2;
963 else if ((cmd & HALCYON_HEADER1MASK) == HALCYON_HEADER1)
964 state = state_header1;
965 else if (pro_group_a && (cmd & VIA_VIDEOMASK) == VIA_VIDEO_HEADER5)
966 state = state_vheader5;
967 else if (pro_group_a && (cmd & VIA_VIDEOMASK) == VIA_VIDEO_HEADER6)
968 state = state_vheader6;
969 else {
970 DRM_ERROR("Invalid / Unimplemented DMA HEADER command. 0x%x\n",
971 cmd);
972 state = state_error;
973 }
974 break;
975 case state_error:
976 default:
977 *hc_state = saved_state;
978 return DRM_ERR(EINVAL);
979 }
980 }
981 if (state == state_error) {
982 *hc_state = saved_state;
983 return DRM_ERR(EINVAL);
984 }
985 return 0;
986}
987
988int
989via_parse_command_stream(drm_device_t *dev, const uint32_t * buf, unsigned int size)
990{
991
992 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
993 uint32_t cmd;
994 const uint32_t *buf_end = buf + ( size >> 2 );
995 verifier_state_t state = state_command;
996 int fire_count = 0;
997
998 while (buf < buf_end) {
999
1000 switch (state) {
1001 case state_header2:
1002 state = via_parse_header2( dev_priv, &buf, buf_end, &fire_count );
1003 break;
1004 case state_header1:
1005 state = via_parse_header1( dev_priv, &buf, buf_end );
1006 break;
1007 case state_vheader5:
1008 state = via_parse_vheader5( dev_priv, &buf, buf_end );
1009 break;
1010 case state_vheader6:
1011 state = via_parse_vheader6( dev_priv, &buf, buf_end );
1012 break;
1013 case state_command:
1014 if (HALCYON_HEADER2 == (cmd = *buf))
1015 state = state_header2;
1016 else if ((cmd & HALCYON_HEADER1MASK) == HALCYON_HEADER1)
1017 state = state_header1;
1018 else if ((cmd & VIA_VIDEOMASK) == VIA_VIDEO_HEADER5)
1019 state = state_vheader5;
1020 else if ((cmd & VIA_VIDEOMASK) == VIA_VIDEO_HEADER6)
1021 state = state_vheader6;
1022 else {
1023 DRM_ERROR("Invalid / Unimplemented DMA HEADER command. 0x%x\n",
1024 cmd);
1025 state = state_error;
1026 }
1027 break;
1028 case state_error:
1029 default:
1030 return DRM_ERR(EINVAL);
1031 }
1032 }
1033 if (state == state_error) {
1034 return DRM_ERR(EINVAL);
1035 }
1036 return 0;
1037}
1038
1039
1040
1041static void
1042setup_hazard_table(hz_init_t init_table[], hazard_t table[], int size)
1043{
1044 int i;
1045
1046 for(i=0; i<256; ++i) {
1047 table[i] = forbidden_command;
1048 }
1049
1050 for(i=0; i<size; ++i) {
1051 table[init_table[i].code] = init_table[i].hz;
1052 }
1053}
1054
1055void
1056via_init_command_verifier( void )
1057{
1058 setup_hazard_table(init_table1, table1, sizeof(init_table1) / sizeof(hz_init_t));
1059 setup_hazard_table(init_table2, table2, sizeof(init_table2) / sizeof(hz_init_t));
1060 setup_hazard_table(init_table3, table3, sizeof(init_table3) / sizeof(hz_init_t));
1061}
diff --git a/drivers/char/drm/via_verifier.h b/drivers/char/drm/via_verifier.h
new file mode 100644
index 000000000000..a8e13592620f
--- /dev/null
+++ b/drivers/char/drm/via_verifier.h
@@ -0,0 +1,61 @@
1/*
2 * Copyright 2004 The Unichrome Project. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE UNICHROME PROJECT, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Author: Thomas Hellström 2004.
24 */
25
26#ifndef _VIA_VERIFIER_H_
27#define _VIA_VERIFIER_H_
28
29typedef enum{
30 no_sequence = 0,
31 z_address,
32 dest_address,
33 tex_address
34}drm_via_sequence_t;
35
36
37
38typedef struct{
39 unsigned texture;
40 uint32_t z_addr;
41 uint32_t d_addr;
42 uint32_t t_addr[2][10];
43 uint32_t pitch[2][10];
44 uint32_t height[2][10];
45 uint32_t tex_level_lo[2];
46 uint32_t tex_level_hi[2];
47 uint32_t tex_palette_size[2];
48 drm_via_sequence_t unfinished;
49 int agp_texture;
50 int multitex;
51 drm_device_t *dev;
52 drm_map_t *map_cache;
53 uint32_t vertex_count;
54 int agp;
55 const uint32_t *buf_start;
56} drm_via_state_t;
57
58extern int via_verify_command_stream(const uint32_t * buf, unsigned int size,
59 drm_device_t *dev, int agp);
60
61#endif
diff --git a/drivers/char/drm/via_video.c b/drivers/char/drm/via_video.c
new file mode 100644
index 000000000000..37a61c67b292
--- /dev/null
+++ b/drivers/char/drm/via_video.c
@@ -0,0 +1,97 @@
1/*
2 * Copyright 2005 Thomas Hellstrom. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S), AND/OR THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Author: Thomas Hellstrom 2005.
24 *
25 * Video and XvMC related functions.
26 */
27
28#include "drmP.h"
29#include "via_drm.h"
30#include "via_drv.h"
31
32void
33via_init_futex(drm_via_private_t *dev_priv)
34{
35 unsigned int i;
36
37 DRM_DEBUG("%s\n", __FUNCTION__);
38
39 for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
40 DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i]));
41 XVMCLOCKPTR(dev_priv->sarea_priv, i)->lock = 0;
42 }
43}
44
45void
46via_cleanup_futex(drm_via_private_t *dev_priv)
47{
48}
49
50void
51via_release_futex(drm_via_private_t *dev_priv, int context)
52{
53 unsigned int i;
54 volatile int *lock;
55
56 for (i=0; i < VIA_NR_XVMC_LOCKS; ++i) {
57 lock = (int *) XVMCLOCKPTR(dev_priv->sarea_priv, i);
58 if ( (_DRM_LOCKING_CONTEXT( *lock ) == context)) {
59 if (_DRM_LOCK_IS_HELD( *lock ) && (*lock & _DRM_LOCK_CONT)) {
60 DRM_WAKEUP( &(dev_priv->decoder_queue[i]));
61 }
62 *lock = 0;
63 }
64 }
65}
66
67int
68via_decoder_futex(DRM_IOCTL_ARGS)
69{
70 DRM_DEVICE;
71 drm_via_futex_t fx;
72 volatile int *lock;
73 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
74 drm_via_sarea_t *sAPriv = dev_priv->sarea_priv;
75 int ret = 0;
76
77 DRM_DEBUG("%s\n", __FUNCTION__);
78
79 DRM_COPY_FROM_USER_IOCTL(fx, (drm_via_futex_t *) data, sizeof(fx));
80
81 if (fx.lock > VIA_NR_XVMC_LOCKS)
82 return -EFAULT;
83
84 lock = (int *)XVMCLOCKPTR(sAPriv, fx.lock);
85
86 switch (fx.func) {
87 case VIA_FUTEX_WAIT:
88 DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx.lock],
89 (fx.ms / 10) * (DRM_HZ / 100), *lock != fx.val);
90 return ret;
91 case VIA_FUTEX_WAKE:
92 DRM_WAKEUP(&(dev_priv->decoder_queue[fx.lock]));
93 return 0;
94 }
95 return 0;
96}
97
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 88cd858f74d0..cddb789902db 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -22,6 +22,7 @@
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */ 23 */
24 24
25#include <linux/config.h>
25#include <linux/console.h> 26#include <linux/console.h>
26#include <linux/cpumask.h> 27#include <linux/cpumask.h>
27#include <linux/init.h> 28#include <linux/init.h>
@@ -40,7 +41,6 @@
40#include <linux/delay.h> 41#include <linux/delay.h>
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/hvconsole.h> 43#include <asm/hvconsole.h>
43#include <asm/vio.h>
44 44
45#define HVC_MAJOR 229 45#define HVC_MAJOR 229
46#define HVC_MINOR 0 46#define HVC_MINOR 0
@@ -61,16 +61,21 @@
61 */ 61 */
62#define HVC_ALLOC_TTY_ADAPTERS 8 62#define HVC_ALLOC_TTY_ADAPTERS 8
63 63
64static struct tty_driver *hvc_driver;
65#ifdef CONFIG_MAGIC_SYSRQ
66static int sysrq_pressed;
67#endif
68
69#define N_OUTBUF 16 64#define N_OUTBUF 16
70#define N_INBUF 16 65#define N_INBUF 16
71 66
72#define __ALIGNED__ __attribute__((__aligned__(8))) 67#define __ALIGNED__ __attribute__((__aligned__(8)))
73 68
69static struct tty_driver *hvc_driver;
70static struct task_struct *hvc_task;
71
72/* Picks up late kicks after list walk but before schedule() */
73static int hvc_kicked;
74
75#ifdef CONFIG_MAGIC_SYSRQ
76static int sysrq_pressed;
77#endif
78
74struct hvc_struct { 79struct hvc_struct {
75 spinlock_t lock; 80 spinlock_t lock;
76 int index; 81 int index;
@@ -80,11 +85,11 @@ struct hvc_struct {
80 char outbuf[N_OUTBUF] __ALIGNED__; 85 char outbuf[N_OUTBUF] __ALIGNED__;
81 int n_outbuf; 86 int n_outbuf;
82 uint32_t vtermno; 87 uint32_t vtermno;
88 struct hv_ops *ops;
83 int irq_requested; 89 int irq_requested;
84 int irq; 90 int irq;
85 struct list_head next; 91 struct list_head next;
86 struct kobject kobj; /* ref count & hvc_struct lifetime */ 92 struct kobject kobj; /* ref count & hvc_struct lifetime */
87 struct vio_dev *vdev;
88}; 93};
89 94
90/* dynamic list of hvc_struct instances */ 95/* dynamic list of hvc_struct instances */
@@ -97,26 +102,185 @@ static struct list_head hvc_structs = LIST_HEAD_INIT(hvc_structs);
97static DEFINE_SPINLOCK(hvc_structs_lock); 102static DEFINE_SPINLOCK(hvc_structs_lock);
98 103
99/* 104/*
105 * This value is used to assign a tty->index value to a hvc_struct based
106 * upon order of exposure via hvc_probe(), when we can not match it to
107 * a console canidate registered with hvc_instantiate().
108 */
109static int last_hvc = -1;
110
111/*
112 * Do not call this function with either the hvc_strucst_lock or the hvc_struct
113 * lock held. If successful, this function increments the kobject reference
114 * count against the target hvc_struct so it should be released when finished.
115 */
116struct hvc_struct *hvc_get_by_index(int index)
117{
118 struct hvc_struct *hp;
119 unsigned long flags;
120
121 spin_lock(&hvc_structs_lock);
122
123 list_for_each_entry(hp, &hvc_structs, next) {
124 spin_lock_irqsave(&hp->lock, flags);
125 if (hp->index == index) {
126 kobject_get(&hp->kobj);
127 spin_unlock_irqrestore(&hp->lock, flags);
128 spin_unlock(&hvc_structs_lock);
129 return hp;
130 }
131 spin_unlock_irqrestore(&hp->lock, flags);
132 }
133 hp = NULL;
134
135 spin_unlock(&hvc_structs_lock);
136 return hp;
137}
138
139
140/*
100 * Initial console vtermnos for console API usage prior to full console 141 * Initial console vtermnos for console API usage prior to full console
101 * initialization. Any vty adapter outside this range will not have usable 142 * initialization. Any vty adapter outside this range will not have usable
102 * console interfaces but can still be used as a tty device. This has to be 143 * console interfaces but can still be used as a tty device. This has to be
103 * static because kmalloc will not work during early console init. 144 * static because kmalloc will not work during early console init.
104 */ 145 */
105static uint32_t vtermnos[MAX_NR_HVC_CONSOLES]; 146static struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES];
147static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
148 {[0 ... MAX_NR_HVC_CONSOLES - 1] = -1};
106 149
107/* Used for accounting purposes */ 150/*
108static int num_vterms = 0; 151 * Console APIs, NOT TTY. These APIs are available immediately when
152 * hvc_console_setup() finds adapters.
153 */
109 154
110static struct task_struct *hvc_task; 155void hvc_console_print(struct console *co, const char *b, unsigned count)
156{
157 char c[16] __ALIGNED__;
158 unsigned i = 0, n = 0;
159 int r, donecr = 0, index = co->index;
160
161 /* Console access attempt outside of acceptable console range. */
162 if (index >= MAX_NR_HVC_CONSOLES)
163 return;
164
165 /* This console adapter was removed so it is not useable. */
166 if (vtermnos[index] < 0)
167 return;
168
169 while (count > 0 || i > 0) {
170 if (count > 0 && i < sizeof(c)) {
171 if (b[n] == '\n' && !donecr) {
172 c[i++] = '\r';
173 donecr = 1;
174 } else {
175 c[i++] = b[n++];
176 donecr = 0;
177 --count;
178 }
179 } else {
180 r = cons_ops[index]->put_chars(vtermnos[index], c, i);
181 if (r < 0) {
182 /* throw away chars on error */
183 i = 0;
184 } else if (r > 0) {
185 i -= r;
186 if (i > 0)
187 memmove(c, c+r, i);
188 }
189 }
190 }
191}
192
193static struct tty_driver *hvc_console_device(struct console *c, int *index)
194{
195 if (vtermnos[c->index] == -1)
196 return NULL;
197
198 *index = c->index;
199 return hvc_driver;
200}
201
202static int __init hvc_console_setup(struct console *co, char *options)
203{
204 if (co->index < 0 || co->index >= MAX_NR_HVC_CONSOLES)
205 return -ENODEV;
206
207 if (vtermnos[co->index] == -1)
208 return -ENODEV;
209
210 return 0;
211}
212
213struct console hvc_con_driver = {
214 .name = "hvc",
215 .write = hvc_console_print,
216 .device = hvc_console_device,
217 .setup = hvc_console_setup,
218 .flags = CON_PRINTBUFFER,
219 .index = -1,
220};
111 221
112/* 222/*
113 * This value is used to associate a tty->index value to a hvc_struct based 223 * Early console initialization. Preceeds driver initialization.
114 * upon order of exposure via hvc_probe(). 224 *
225 * (1) we are first, and the user specified another driver
226 * -- index will remain -1
227 * (2) we are first and the user specified no driver
228 * -- index will be set to 0, then we will fail setup.
229 * (3) we are first and the user specified our driver
230 * -- index will be set to user specified driver, and we will fail
231 * (4) we are after driver, and this initcall will register us
232 * -- if the user didn't specify a driver then the console will match
233 *
234 * Note that for cases 2 and 3, we will match later when the io driver
235 * calls hvc_instantiate() and call register again.
115 */ 236 */
116static int hvc_count = -1; 237static int __init hvc_console_init(void)
238{
239 register_console(&hvc_con_driver);
240 return 0;
241}
242console_initcall(hvc_console_init);
117 243
118/* Picks up late kicks after list walk but before schedule() */ 244/*
119static int hvc_kicked; 245 * hvc_instantiate() is an early console discovery method which locates
246 * consoles * prior to the vio subsystem discovering them. Hotplugged
247 * vty adapters do NOT get an hvc_instantiate() callback since they
248 * appear after early console init.
249 */
250int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops)
251{
252 struct hvc_struct *hp;
253
254 if (index < 0 || index >= MAX_NR_HVC_CONSOLES)
255 return -1;
256
257 if (vtermnos[index] != -1)
258 return -1;
259
260 /* make sure no no tty has been registerd in this index */
261 hp = hvc_get_by_index(index);
262 if (hp) {
263 kobject_put(&hp->kobj);
264 return -1;
265 }
266
267 vtermnos[index] = vtermno;
268 cons_ops[index] = ops;
269
270 /* reserve all indices upto and including this index */
271 if (last_hvc < index)
272 last_hvc = index;
273
274 /* if this index is what the user requested, then register
275 * now (setup won't fail at this point). It's ok to just
276 * call register again if previously .setup failed.
277 */
278 if (index == hvc_con_driver.index)
279 register_console(&hvc_con_driver);
280
281 return 0;
282}
283EXPORT_SYMBOL(hvc_instantiate);
120 284
121/* Wake the sleeping khvcd */ 285/* Wake the sleeping khvcd */
122static void hvc_kick(void) 286static void hvc_kick(void)
@@ -125,13 +289,17 @@ static void hvc_kick(void)
125 wake_up_process(hvc_task); 289 wake_up_process(hvc_task);
126} 290}
127 291
292static int hvc_poll(struct hvc_struct *hp);
293
128/* 294/*
129 * NOTE: This API isn't used if the console adapter doesn't support interrupts. 295 * NOTE: This API isn't used if the console adapter doesn't support interrupts.
130 * In this case the console is poll driven. 296 * In this case the console is poll driven.
131 */ 297 */
132static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance, struct pt_regs *regs) 298static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
133{ 299{
134 hvc_kick(); 300 /* if hvc_poll request a repoll, then kick the hvcd thread */
301 if (hvc_poll(dev_instance))
302 hvc_kick();
135 return IRQ_HANDLED; 303 return IRQ_HANDLED;
136} 304}
137 305
@@ -141,34 +309,6 @@ static void hvc_unthrottle(struct tty_struct *tty)
141} 309}
142 310
143/* 311/*
144 * Do not call this function with either the hvc_strucst_lock or the hvc_struct
145 * lock held. If successful, this function increments the kobject reference
146 * count against the target hvc_struct so it should be released when finished.
147 */
148struct hvc_struct *hvc_get_by_index(int index)
149{
150 struct hvc_struct *hp;
151 unsigned long flags;
152
153 spin_lock(&hvc_structs_lock);
154
155 list_for_each_entry(hp, &hvc_structs, next) {
156 spin_lock_irqsave(&hp->lock, flags);
157 if (hp->index == index) {
158 kobject_get(&hp->kobj);
159 spin_unlock_irqrestore(&hp->lock, flags);
160 spin_unlock(&hvc_structs_lock);
161 return hp;
162 }
163 spin_unlock_irqrestore(&hp->lock, flags);
164 }
165 hp = NULL;
166
167 spin_unlock(&hvc_structs_lock);
168 return hp;
169}
170
171/*
172 * The TTY interface won't be used until after the vio layer has exposed the vty 312 * The TTY interface won't be used until after the vio layer has exposed the vty
173 * adapter to the kernel. 313 * adapter to the kernel.
174 */ 314 */
@@ -329,7 +469,7 @@ static void hvc_push(struct hvc_struct *hp)
329{ 469{
330 int n; 470 int n;
331 471
332 n = hvc_put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); 472 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf);
333 if (n <= 0) { 473 if (n <= 0) {
334 if (n == 0) 474 if (n == 0)
335 return; 475 return;
@@ -467,7 +607,7 @@ static int hvc_poll(struct hvc_struct *hp)
467 break; 607 break;
468 } 608 }
469 609
470 n = hvc_get_chars(hp->vtermno, buf, count); 610 n = hp->ops->get_chars(hp->vtermno, buf, count);
471 if (n <= 0) { 611 if (n <= 0) {
472 /* Hangup the tty when disconnected from host */ 612 /* Hangup the tty when disconnected from host */
473 if (n == -EPIPE) { 613 if (n == -EPIPE) {
@@ -479,14 +619,17 @@ static int hvc_poll(struct hvc_struct *hp)
479 } 619 }
480 for (i = 0; i < n; ++i) { 620 for (i = 0; i < n; ++i) {
481#ifdef CONFIG_MAGIC_SYSRQ 621#ifdef CONFIG_MAGIC_SYSRQ
482 /* Handle the SysRq Hack */ 622 if (hp->index == hvc_con_driver.index) {
483 if (buf[i] == '\x0f') { /* ^O -- should support a sequence */ 623 /* Handle the SysRq Hack */
484 sysrq_pressed = 1; 624 /* XXX should support a sequence */
485 continue; 625 if (buf[i] == '\x0f') { /* ^O */
486 } else if (sysrq_pressed) { 626 sysrq_pressed = 1;
487 handle_sysrq(buf[i], NULL, tty); 627 continue;
488 sysrq_pressed = 0; 628 } else if (sysrq_pressed) {
489 continue; 629 handle_sysrq(buf[i], NULL, tty);
630 sysrq_pressed = 0;
631 continue;
632 }
490 } 633 }
491#endif /* CONFIG_MAGIC_SYSRQ */ 634#endif /* CONFIG_MAGIC_SYSRQ */
492 tty_insert_flip_char(tty, buf[i], 0); 635 tty_insert_flip_char(tty, buf[i], 0);
@@ -497,8 +640,8 @@ static int hvc_poll(struct hvc_struct *hp)
497 640
498 /* 641 /*
499 * Account for the total amount read in one loop, and if above 642 * Account for the total amount read in one loop, and if above
500 * 64 bytes, we do a quick schedule loop to let the tty grok the 643 * 64 bytes, we do a quick schedule loop to let the tty grok
501 * data and eventually throttle us. 644 * the data and eventually throttle us.
502 */ 645 */
503 read_total += n; 646 read_total += n;
504 if (read_total >= 64) { 647 if (read_total >= 64) {
@@ -542,7 +685,6 @@ int khvcd(void *unused)
542 if (cpus_empty(cpus_in_xmon)) { 685 if (cpus_empty(cpus_in_xmon)) {
543 spin_lock(&hvc_structs_lock); 686 spin_lock(&hvc_structs_lock);
544 list_for_each_entry(hp, &hvc_structs, next) { 687 list_for_each_entry(hp, &hvc_structs, next) {
545 /*hp = list_entry(node, struct hvc_struct, * next); */
546 poll_mask |= hvc_poll(hp); 688 poll_mask |= hvc_poll(hp);
547 } 689 }
548 spin_unlock(&hvc_structs_lock); 690 spin_unlock(&hvc_structs_lock);
@@ -577,14 +719,6 @@ static struct tty_operations hvc_ops = {
577 .chars_in_buffer = hvc_chars_in_buffer, 719 .chars_in_buffer = hvc_chars_in_buffer,
578}; 720};
579 721
580char hvc_driver_name[] = "hvc_console";
581
582static struct vio_device_id hvc_driver_table[] __devinitdata= {
583 {"serial", "hvterm1"},
584 { NULL, }
585};
586MODULE_DEVICE_TABLE(vio, hvc_driver_table);
587
588/* callback when the kboject ref count reaches zero. */ 722/* callback when the kboject ref count reaches zero. */
589static void destroy_hvc_struct(struct kobject *kobj) 723static void destroy_hvc_struct(struct kobject *kobj)
590{ 724{
@@ -606,41 +740,51 @@ static struct kobj_type hvc_kobj_type = {
606 .release = destroy_hvc_struct, 740 .release = destroy_hvc_struct,
607}; 741};
608 742
609static int __devinit hvc_probe( 743struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq,
610 struct vio_dev *dev, 744 struct hv_ops *ops)
611 const struct vio_device_id *id)
612{ 745{
613 struct hvc_struct *hp; 746 struct hvc_struct *hp;
614 747 int i;
615 /* probed with invalid parameters. */
616 if (!dev || !id)
617 return -EPERM;
618 748
619 hp = kmalloc(sizeof(*hp), GFP_KERNEL); 749 hp = kmalloc(sizeof(*hp), GFP_KERNEL);
620 if (!hp) 750 if (!hp)
621 return -ENOMEM; 751 return ERR_PTR(-ENOMEM);
622 752
623 memset(hp, 0x00, sizeof(*hp)); 753 memset(hp, 0x00, sizeof(*hp));
624 hp->vtermno = dev->unit_address; 754
625 hp->vdev = dev; 755 hp->vtermno = vtermno;
626 hp->vdev->dev.driver_data = hp; 756 hp->irq = irq;
627 hp->irq = dev->irq; 757 hp->ops = ops;
628 758
629 kobject_init(&hp->kobj); 759 kobject_init(&hp->kobj);
630 hp->kobj.ktype = &hvc_kobj_type; 760 hp->kobj.ktype = &hvc_kobj_type;
631 761
632 spin_lock_init(&hp->lock); 762 spin_lock_init(&hp->lock);
633 spin_lock(&hvc_structs_lock); 763 spin_lock(&hvc_structs_lock);
634 hp->index = ++hvc_count; 764
765 /*
766 * find index to use:
767 * see if this vterm id matches one registered for console.
768 */
769 for (i=0; i < MAX_NR_HVC_CONSOLES; i++)
770 if (vtermnos[i] == hp->vtermno)
771 break;
772
773 /* no matching slot, just use a counter */
774 if (i >= MAX_NR_HVC_CONSOLES)
775 i = ++last_hvc;
776
777 hp->index = i;
778
635 list_add_tail(&(hp->next), &hvc_structs); 779 list_add_tail(&(hp->next), &hvc_structs);
636 spin_unlock(&hvc_structs_lock); 780 spin_unlock(&hvc_structs_lock);
637 781
638 return 0; 782 return hp;
639} 783}
784EXPORT_SYMBOL(hvc_alloc);
640 785
641static int __devexit hvc_remove(struct vio_dev *dev) 786int __devexit hvc_remove(struct hvc_struct *hp)
642{ 787{
643 struct hvc_struct *hp = dev->dev.driver_data;
644 unsigned long flags; 788 unsigned long flags;
645 struct kobject *kobjp; 789 struct kobject *kobjp;
646 struct tty_struct *tty; 790 struct tty_struct *tty;
@@ -673,23 +817,14 @@ static int __devexit hvc_remove(struct vio_dev *dev)
673 tty_hangup(tty); 817 tty_hangup(tty);
674 return 0; 818 return 0;
675} 819}
676 820EXPORT_SYMBOL(hvc_remove);
677static struct vio_driver hvc_vio_driver = {
678 .name = hvc_driver_name,
679 .id_table = hvc_driver_table,
680 .probe = hvc_probe,
681 .remove = hvc_remove,
682};
683 821
684/* Driver initialization. Follow console initialization. This is where the TTY 822/* Driver initialization. Follow console initialization. This is where the TTY
685 * interfaces start to become available. */ 823 * interfaces start to become available. */
686int __init hvc_init(void) 824int __init hvc_init(void)
687{ 825{
688 int rc; 826 /* We need more than hvc_count adapters due to hotplug additions. */
689
690 /* We need more than num_vterms adapters due to hotplug additions. */
691 hvc_driver = alloc_tty_driver(HVC_ALLOC_TTY_ADAPTERS); 827 hvc_driver = alloc_tty_driver(HVC_ALLOC_TTY_ADAPTERS);
692 /* hvc_driver = alloc_tty_driver(num_vterms); */
693 if (!hvc_driver) 828 if (!hvc_driver)
694 return -ENOMEM; 829 return -ENOMEM;
695 830
@@ -716,116 +851,20 @@ int __init hvc_init(void)
716 return -EIO; 851 return -EIO;
717 } 852 }
718 853
719 /* Register as a vio device to receive callbacks */ 854 return 0;
720 rc = vio_register_driver(&hvc_vio_driver);
721
722 return rc;
723} 855}
856module_init(hvc_init);
724 857
725/* This isn't particularily necessary due to this being a console driver but it 858/* This isn't particularily necessary due to this being a console driver
726 * is nice to be thorough */ 859 * but it is nice to be thorough.
860 */
727static void __exit hvc_exit(void) 861static void __exit hvc_exit(void)
728{ 862{
729 kthread_stop(hvc_task); 863 kthread_stop(hvc_task);
730 864
731 vio_unregister_driver(&hvc_vio_driver);
732 tty_unregister_driver(hvc_driver); 865 tty_unregister_driver(hvc_driver);
733 /* return tty_struct instances allocated in hvc_init(). */ 866 /* return tty_struct instances allocated in hvc_init(). */
734 put_tty_driver(hvc_driver); 867 put_tty_driver(hvc_driver);
868 unregister_console(&hvc_con_driver);
735} 869}
736
737/*
738 * Console APIs, NOT TTY. These APIs are available immediately when
739 * hvc_console_setup() finds adapters.
740 */
741
742/*
743 * hvc_instantiate() is an early console discovery method which locates consoles
744 * prior to the vio subsystem discovering them. Hotplugged vty adapters do NOT
745 * get an hvc_instantiate() callback since the appear after early console init.
746 */
747int hvc_instantiate(uint32_t vtermno, int index)
748{
749 if (index < 0 || index >= MAX_NR_HVC_CONSOLES)
750 return -1;
751
752 if (vtermnos[index] != -1)
753 return -1;
754
755 vtermnos[index] = vtermno;
756 return 0;
757}
758
759void hvc_console_print(struct console *co, const char *b, unsigned count)
760{
761 char c[16] __ALIGNED__;
762 unsigned i = 0, n = 0;
763 int r, donecr = 0;
764
765 /* Console access attempt outside of acceptable console range. */
766 if (co->index >= MAX_NR_HVC_CONSOLES)
767 return;
768
769 /* This console adapter was removed so it is not useable. */
770 if (vtermnos[co->index] < 0)
771 return;
772
773 while (count > 0 || i > 0) {
774 if (count > 0 && i < sizeof(c)) {
775 if (b[n] == '\n' && !donecr) {
776 c[i++] = '\r';
777 donecr = 1;
778 } else {
779 c[i++] = b[n++];
780 donecr = 0;
781 --count;
782 }
783 } else {
784 r = hvc_put_chars(vtermnos[co->index], c, i);
785 if (r < 0) {
786 /* throw away chars on error */
787 i = 0;
788 } else if (r > 0) {
789 i -= r;
790 if (i > 0)
791 memmove(c, c+r, i);
792 }
793 }
794 }
795}
796
797static struct tty_driver *hvc_console_device(struct console *c, int *index)
798{
799 *index = c->index;
800 return hvc_driver;
801}
802
803static int __init hvc_console_setup(struct console *co, char *options)
804{
805 return 0;
806}
807
808struct console hvc_con_driver = {
809 .name = "hvc",
810 .write = hvc_console_print,
811 .device = hvc_console_device,
812 .setup = hvc_console_setup,
813 .flags = CON_PRINTBUFFER,
814 .index = -1,
815};
816
817/* Early console initialization. Preceeds driver initialization. */
818static int __init hvc_console_init(void)
819{
820 int i;
821
822 for (i=0; i<MAX_NR_HVC_CONSOLES; i++)
823 vtermnos[i] = -1;
824 num_vterms = hvc_find_vtys();
825 register_console(&hvc_con_driver);
826 return 0;
827}
828console_initcall(hvc_console_init);
829
830module_init(hvc_init);
831module_exit(hvc_exit); 870module_exit(hvc_exit);
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c
new file mode 100644
index 000000000000..60bb9152b832
--- /dev/null
+++ b/drivers/char/hvc_vio.c
@@ -0,0 +1,152 @@
1/*
2 * vio driver interface to hvc_console.c
3 *
4 * This code was moved here to allow the remaing code to be reused as a
5 * generic polling mode with semi-reliable transport driver core to the
6 * console and tty subsystems.
7 *
8 *
9 * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
10 * Copyright (C) 2001 Paul Mackerras <paulus@au.ibm.com>, IBM
11 * Copyright (C) 2004 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
12 * Copyright (C) 2004 IBM Corporation
13 *
14 * Additional Author(s):
15 * Ryan S. Arnold <rsa@us.ibm.com>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 */
31
32#include <linux/types.h>
33#include <linux/init.h>
34#include <asm/hvconsole.h>
35#include <asm/vio.h>
36#include <asm/prom.h>
37
38char hvc_driver_name[] = "hvc_console";
39
40static struct vio_device_id hvc_driver_table[] __devinitdata = {
41 {"serial", "hvterm1"},
42 { NULL, }
43};
44MODULE_DEVICE_TABLE(vio, hvc_driver_table);
45
46static int filtered_get_chars(uint32_t vtermno, char *buf, int count)
47{
48 unsigned long got;
49 int i;
50
51 got = hvc_get_chars(vtermno, buf, count);
52
53 /*
54 * Work around a HV bug where it gives us a null
55 * after every \r. -- paulus
56 */
57 for (i = 1; i < got; ++i) {
58 if (buf[i] == 0 && buf[i-1] == '\r') {
59 --got;
60 if (i < got)
61 memmove(&buf[i], &buf[i+1],
62 got - i);
63 }
64 }
65 return got;
66}
67
68static struct hv_ops hvc_get_put_ops = {
69 .get_chars = filtered_get_chars,
70 .put_chars = hvc_put_chars,
71};
72
73static int __devinit hvc_vio_probe(struct vio_dev *vdev,
74 const struct vio_device_id *id)
75{
76 struct hvc_struct *hp;
77
78 /* probed with invalid parameters. */
79 if (!vdev || !id)
80 return -EPERM;
81
82 hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops);
83 if (IS_ERR(hp))
84 return PTR_ERR(hp);
85 dev_set_drvdata(&vdev->dev, hp);
86
87 return 0;
88}
89
90static int __devexit hvc_vio_remove(struct vio_dev *vdev)
91{
92 struct hvc_struct *hp = dev_get_drvdata(&vdev->dev);
93
94 return hvc_remove(hp);
95}
96
97static struct vio_driver hvc_vio_driver = {
98 .name = hvc_driver_name,
99 .id_table = hvc_driver_table,
100 .probe = hvc_vio_probe,
101 .remove = hvc_vio_remove,
102 .driver = {
103 .owner = THIS_MODULE,
104 }
105};
106
107static int hvc_vio_init(void)
108{
109 int rc;
110
111 /* Register as a vio device to receive callbacks */
112 rc = vio_register_driver(&hvc_vio_driver);
113
114 return rc;
115}
116module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */
117
118static void hvc_vio_exit(void)
119{
120 vio_unregister_driver(&hvc_vio_driver);
121}
122module_exit(hvc_vio_exit);
123
124/* the device tree order defines our numbering */
125static int hvc_find_vtys(void)
126{
127 struct device_node *vty;
128 int num_found = 0;
129
130 for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL;
131 vty = of_find_node_by_name(vty, "vty")) {
132 uint32_t *vtermno;
133
134 /* We have statically defined space for only a certain number
135 * of console adapters.
136 */
137 if (num_found >= MAX_NR_HVC_CONSOLES)
138 break;
139
140 vtermno = (uint32_t *)get_property(vty, "reg", NULL);
141 if (!vtermno)
142 continue;
143
144 if (device_is_compatible(vty, "hvterm1")) {
145 hvc_instantiate(*vtermno, num_found, &hvc_get_put_ops);
146 ++num_found;
147 }
148 }
149
150 return num_found;
151}
152console_initcall(hvc_find_vtys);
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index f1f1192ba2b5..a22aa940e01e 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -291,15 +291,13 @@ static void dump_packet(uint8_t *packet)
291 dump_hex(packet, header->len); 291 dump_hex(packet, header->len);
292} 292}
293 293
294/* can't use hvc_get_chars because that strips CRs */
295static int hvsi_read(struct hvsi_struct *hp, char *buf, int count) 294static int hvsi_read(struct hvsi_struct *hp, char *buf, int count)
296{ 295{
297 unsigned long got; 296 unsigned long got;
298 297
299 if (plpar_hcall(H_GET_TERM_CHAR, hp->vtermno, 0, 0, 0, &got, 298 got = hvc_get_chars(hp->vtermno, buf, count);
300 (unsigned long *)buf, (unsigned long *)buf+1) == H_Success) 299
301 return got; 300 return got;
302 return 0;
303} 301}
304 302
305static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet, 303static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet,
diff --git a/drivers/char/hw_random.c b/drivers/char/hw_random.c
index 7e6ac14c2450..3480535a09c5 100644
--- a/drivers/char/hw_random.c
+++ b/drivers/char/hw_random.c
@@ -579,7 +579,7 @@ static int __init rng_init (void)
579 579
580 /* Probe for Intel, AMD RNGs */ 580 /* Probe for Intel, AMD RNGs */
581 for_each_pci_dev(pdev) { 581 for_each_pci_dev(pdev) {
582 ent = pci_match_device (rng_pci_tbl, pdev); 582 ent = pci_match_id(rng_pci_tbl, pdev);
583 if (ent) { 583 if (ent) {
584 rng_ops = &rng_vendor_ops[ent->driver_data]; 584 rng_ops = &rng_vendor_ops[ent->driver_data];
585 goto match; 585 goto match;
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index edba5a35bf21..09103b3d8f05 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -770,10 +770,8 @@ send_signal:
770 } 770 }
771 if (c == '\n') { 771 if (c == '\n') {
772 if (L_ECHO(tty) || L_ECHONL(tty)) { 772 if (L_ECHO(tty) || L_ECHONL(tty)) {
773 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { 773 if (tty->read_cnt >= N_TTY_BUF_SIZE-1)
774 put_char('\a', tty); 774 put_char('\a', tty);
775 return;
776 }
777 opost('\n', tty); 775 opost('\n', tty);
778 } 776 }
779 goto handle_newline; 777 goto handle_newline;
@@ -790,10 +788,8 @@ send_signal:
790 * XXX are EOL_CHAR and EOL2_CHAR echoed?!? 788 * XXX are EOL_CHAR and EOL2_CHAR echoed?!?
791 */ 789 */
792 if (L_ECHO(tty)) { 790 if (L_ECHO(tty)) {
793 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { 791 if (tty->read_cnt >= N_TTY_BUF_SIZE-1)
794 put_char('\a', tty); 792 put_char('\a', tty);
795 return;
796 }
797 /* Record the column of first canon char. */ 793 /* Record the column of first canon char. */
798 if (tty->canon_head == tty->read_head) 794 if (tty->canon_head == tty->read_head)
799 tty->canon_column = tty->column; 795 tty->canon_column = tty->column;
@@ -862,12 +858,9 @@ static int n_tty_receive_room(struct tty_struct *tty)
862 * that erase characters will be handled. Other excess 858 * that erase characters will be handled. Other excess
863 * characters will be beeped. 859 * characters will be beeped.
864 */ 860 */
865 if (tty->icanon && !tty->canon_data) 861 if (left <= 0)
866 return N_TTY_BUF_SIZE; 862 left = tty->icanon && !tty->canon_data;
867 863 return left;
868 if (left > 0)
869 return left;
870 return 0;
871} 864}
872 865
873/** 866/**
@@ -1473,13 +1466,17 @@ static ssize_t write_chan(struct tty_struct * tty, struct file * file,
1473 if (tty->driver->flush_chars) 1466 if (tty->driver->flush_chars)
1474 tty->driver->flush_chars(tty); 1467 tty->driver->flush_chars(tty);
1475 } else { 1468 } else {
1476 c = tty->driver->write(tty, b, nr); 1469 while (nr > 0) {
1477 if (c < 0) { 1470 c = tty->driver->write(tty, b, nr);
1478 retval = c; 1471 if (c < 0) {
1479 goto break_out; 1472 retval = c;
1473 goto break_out;
1474 }
1475 if (!c)
1476 break;
1477 b += c;
1478 nr -= c;
1480 } 1479 }
1481 b += c;
1482 nr -= c;
1483 } 1480 }
1484 if (!nr) 1481 if (!nr)
1485 break; 1482 break;
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 8f36b1758eb6..7a0c74648124 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -71,7 +71,6 @@
71#include <linux/workqueue.h> 71#include <linux/workqueue.h>
72#include <linux/hdlc.h> 72#include <linux/hdlc.h>
73 73
74#include <pcmcia/version.h>
75#include <pcmcia/cs_types.h> 74#include <pcmcia/cs_types.h>
76#include <pcmcia/cs.h> 75#include <pcmcia/cs.h>
77#include <pcmcia/cistpl.h> 76#include <pcmcia/cistpl.h>
@@ -593,11 +592,6 @@ static dev_link_t *mgslpc_attach(void)
593 dev_list = link; 592 dev_list = link;
594 593
595 client_reg.dev_info = &dev_info; 594 client_reg.dev_info = &dev_info;
596 client_reg.EventMask =
597 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
598 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
599 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
600 client_reg.event_handler = &mgslpc_event;
601 client_reg.Version = 0x0210; 595 client_reg.Version = 0x0210;
602 client_reg.event_callback_args.client_data = link; 596 client_reg.event_callback_args.client_data = link;
603 597
@@ -3093,6 +3087,7 @@ static struct pcmcia_driver mgslpc_driver = {
3093 .name = "synclink_cs", 3087 .name = "synclink_cs",
3094 }, 3088 },
3095 .attach = mgslpc_attach, 3089 .attach = mgslpc_attach,
3090 .event = mgslpc_event,
3096 .detach = mgslpc_detach, 3091 .detach = mgslpc_detach,
3097 .id_table = mgslpc_ids, 3092 .id_table = mgslpc_ids,
3098}; 3093};
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 460b5d475edd..6b11d6b2129f 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -271,7 +271,7 @@ static int random_write_wakeup_thresh = 128;
271 * samples to avoid wasting CPU time and reduce lock contention. 271 * samples to avoid wasting CPU time and reduce lock contention.
272 */ 272 */
273 273
274static int trickle_thresh = INPUT_POOL_WORDS * 28; 274static int trickle_thresh __read_mostly = INPUT_POOL_WORDS * 28;
275 275
276static DEFINE_PER_CPU(int, trickle_count) = 0; 276static DEFINE_PER_CPU(int, trickle_count) = 0;
277 277
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index af79805b5576..12d563c648f7 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -228,7 +228,7 @@ static struct sysrq_key_op sysrq_term_op = {
228 228
229static void moom_callback(void *ignored) 229static void moom_callback(void *ignored)
230{ 230{
231 out_of_memory(GFP_KERNEL); 231 out_of_memory(GFP_KERNEL, 0);
232} 232}
233 233
234static DECLARE_WORK(moom_work, moom_callback, NULL); 234static DECLARE_WORK(moom_work, moom_callback, NULL);
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c
index 5413f2908859..eb7058cbf015 100644
--- a/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -24,6 +24,8 @@
24 24
25#include <asm/io.h> 25#include <asm/io.h>
26#include <asm/reboot.h> 26#include <asm/reboot.h>
27#include <asm/vr41xx/giu.h>
28#include <asm/vr41xx/tb0219.h>
27 29
28MODULE_AUTHOR("Yoichi Yuasa <yuasa@hh.iij4u.or.jp>"); 30MODULE_AUTHOR("Yoichi Yuasa <yuasa@hh.iij4u.or.jp>");
29MODULE_DESCRIPTION("TANBAC TB0219 base board driver"); 31MODULE_DESCRIPTION("TANBAC TB0219 base board driver");
@@ -266,6 +268,21 @@ static void tb0219_restart(char *command)
266 tb0219_write(TB0219_RESET, 0); 268 tb0219_write(TB0219_RESET, 0);
267} 269}
268 270
271static void tb0219_pci_irq_init(void)
272{
273 /* PCI Slot 1 */
274 vr41xx_set_irq_trigger(TB0219_PCI_SLOT1_PIN, IRQ_TRIGGER_LEVEL, IRQ_SIGNAL_THROUGH);
275 vr41xx_set_irq_level(TB0219_PCI_SLOT1_PIN, IRQ_LEVEL_LOW);
276
277 /* PCI Slot 2 */
278 vr41xx_set_irq_trigger(TB0219_PCI_SLOT2_PIN, IRQ_TRIGGER_LEVEL, IRQ_SIGNAL_THROUGH);
279 vr41xx_set_irq_level(TB0219_PCI_SLOT2_PIN, IRQ_LEVEL_LOW);
280
281 /* PCI Slot 3 */
282 vr41xx_set_irq_trigger(TB0219_PCI_SLOT3_PIN, IRQ_TRIGGER_LEVEL, IRQ_SIGNAL_THROUGH);
283 vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN, IRQ_LEVEL_LOW);
284}
285
269static int tb0219_probe(struct device *dev) 286static int tb0219_probe(struct device *dev)
270{ 287{
271 int retval; 288 int retval;
@@ -292,6 +309,8 @@ static int tb0219_probe(struct device *dev)
292 old_machine_restart = _machine_restart; 309 old_machine_restart = _machine_restart;
293 _machine_restart = tb0219_restart; 310 _machine_restart = tb0219_restart;
294 311
312 tb0219_pci_irq_init();
313
295 if (major == 0) { 314 if (major == 0) {
296 major = retval; 315 major = retval;
297 printk(KERN_INFO "TB0219: major number %d\n", major); 316 printk(KERN_INFO "TB0219: major number %d\n", major);
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 854475c54f0e..049d128ae7f0 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -464,7 +464,7 @@ void __devexit tpm_remove(struct pci_dev *pci_dev)
464 464
465 pci_set_drvdata(pci_dev, NULL); 465 pci_set_drvdata(pci_dev, NULL);
466 misc_deregister(&chip->vendor->miscdev); 466 misc_deregister(&chip->vendor->miscdev);
467 kfree(&chip->vendor->miscdev.name); 467 kfree(chip->vendor->miscdev.name);
468 468
469 sysfs_remove_group(&pci_dev->dev.kobj, chip->vendor->attr_group); 469 sysfs_remove_group(&pci_dev->dev.kobj, chip->vendor->attr_group);
470 470
diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c
index b14d642439ed..5d07ee59679d 100644
--- a/drivers/char/watchdog/i8xx_tco.c
+++ b/drivers/char/watchdog/i8xx_tco.c
@@ -401,7 +401,7 @@ static unsigned char __init i8xx_tco_getdevice (void)
401 */ 401 */
402 402
403 while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 403 while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
404 if (pci_match_device(i8xx_tco_pci_tbl, dev)) { 404 if (pci_match_id(i8xx_tco_pci_tbl, dev)) {
405 i8xx_tco_pci = dev; 405 i8xx_tco_pci = dev;
406 break; 406 break;
407 } 407 }
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index bf62dfe4976a..7a7859dd0d98 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -869,7 +869,7 @@ EXPORT_SYMBOL(cpufreq_get);
869 * cpufreq_suspend - let the low level driver prepare for suspend 869 * cpufreq_suspend - let the low level driver prepare for suspend
870 */ 870 */
871 871
872static int cpufreq_suspend(struct sys_device * sysdev, u32 state) 872static int cpufreq_suspend(struct sys_device * sysdev, pm_message_t pmsg)
873{ 873{
874 int cpu = sysdev->id; 874 int cpu = sysdev->id;
875 unsigned int ret = 0; 875 unsigned int ret = 0;
@@ -897,7 +897,7 @@ static int cpufreq_suspend(struct sys_device * sysdev, u32 state)
897 } 897 }
898 898
899 if (cpufreq_driver->suspend) { 899 if (cpufreq_driver->suspend) {
900 ret = cpufreq_driver->suspend(cpu_policy, state); 900 ret = cpufreq_driver->suspend(cpu_policy, pmsg);
901 if (ret) { 901 if (ret) {
902 printk(KERN_ERR "cpufreq: suspend failed in ->suspend " 902 printk(KERN_ERR "cpufreq: suspend failed in ->suspend "
903 "step on CPU %u\n", cpu_policy->cpu); 903 "step on CPU %u\n", cpu_policy->cpu);
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index ed708b4427b0..71407c578afe 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -49,6 +49,7 @@
49#include <linux/errno.h> 49#include <linux/errno.h>
50#include <linux/crypto.h> 50#include <linux/crypto.h>
51#include <linux/interrupt.h> 51#include <linux/interrupt.h>
52#include <linux/kernel.h>
52#include <asm/byteorder.h> 53#include <asm/byteorder.h>
53#include "padlock.h" 54#include "padlock.h"
54 55
@@ -59,8 +60,12 @@
59#define AES_EXTENDED_KEY_SIZE_B (AES_EXTENDED_KEY_SIZE * sizeof(uint32_t)) 60#define AES_EXTENDED_KEY_SIZE_B (AES_EXTENDED_KEY_SIZE * sizeof(uint32_t))
60 61
61struct aes_ctx { 62struct aes_ctx {
62 uint32_t e_data[AES_EXTENDED_KEY_SIZE+4]; 63 uint32_t e_data[AES_EXTENDED_KEY_SIZE];
63 uint32_t d_data[AES_EXTENDED_KEY_SIZE+4]; 64 uint32_t d_data[AES_EXTENDED_KEY_SIZE];
65 struct {
66 struct cword encrypt;
67 struct cword decrypt;
68 } cword;
64 uint32_t *E; 69 uint32_t *E;
65 uint32_t *D; 70 uint32_t *D;
66 int key_length; 71 int key_length;
@@ -280,10 +285,15 @@ aes_hw_extkey_available(uint8_t key_len)
280 return 0; 285 return 0;
281} 286}
282 287
288static inline struct aes_ctx *aes_ctx(void *ctx)
289{
290 return (struct aes_ctx *)ALIGN((unsigned long)ctx, PADLOCK_ALIGNMENT);
291}
292
283static int 293static int
284aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t *flags) 294aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t *flags)
285{ 295{
286 struct aes_ctx *ctx = ctx_arg; 296 struct aes_ctx *ctx = aes_ctx(ctx_arg);
287 uint32_t i, t, u, v, w; 297 uint32_t i, t, u, v, w;
288 uint32_t P[AES_EXTENDED_KEY_SIZE]; 298 uint32_t P[AES_EXTENDED_KEY_SIZE];
289 uint32_t rounds; 299 uint32_t rounds;
@@ -295,25 +305,36 @@ aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t
295 305
296 ctx->key_length = key_len; 306 ctx->key_length = key_len;
297 307
308 /*
309 * If the hardware is capable of generating the extended key
310 * itself we must supply the plain key for both encryption
311 * and decryption.
312 */
298 ctx->E = ctx->e_data; 313 ctx->E = ctx->e_data;
299 ctx->D = ctx->d_data; 314 ctx->D = ctx->e_data;
300
301 /* Ensure 16-Bytes alignmentation of keys for VIA PadLock. */
302 if ((int)(ctx->e_data) & 0x0F)
303 ctx->E += 4 - (((int)(ctx->e_data) & 0x0F) / sizeof (ctx->e_data[0]));
304
305 if ((int)(ctx->d_data) & 0x0F)
306 ctx->D += 4 - (((int)(ctx->d_data) & 0x0F) / sizeof (ctx->d_data[0]));
307 315
308 E_KEY[0] = uint32_t_in (in_key); 316 E_KEY[0] = uint32_t_in (in_key);
309 E_KEY[1] = uint32_t_in (in_key + 4); 317 E_KEY[1] = uint32_t_in (in_key + 4);
310 E_KEY[2] = uint32_t_in (in_key + 8); 318 E_KEY[2] = uint32_t_in (in_key + 8);
311 E_KEY[3] = uint32_t_in (in_key + 12); 319 E_KEY[3] = uint32_t_in (in_key + 12);
312 320
321 /* Prepare control words. */
322 memset(&ctx->cword, 0, sizeof(ctx->cword));
323
324 ctx->cword.decrypt.encdec = 1;
325 ctx->cword.encrypt.rounds = 10 + (key_len - 16) / 4;
326 ctx->cword.decrypt.rounds = ctx->cword.encrypt.rounds;
327 ctx->cword.encrypt.ksize = (key_len - 16) / 8;
328 ctx->cword.decrypt.ksize = ctx->cword.encrypt.ksize;
329
313 /* Don't generate extended keys if the hardware can do it. */ 330 /* Don't generate extended keys if the hardware can do it. */
314 if (aes_hw_extkey_available(key_len)) 331 if (aes_hw_extkey_available(key_len))
315 return 0; 332 return 0;
316 333
334 ctx->D = ctx->d_data;
335 ctx->cword.encrypt.keygen = 1;
336 ctx->cword.decrypt.keygen = 1;
337
317 switch (key_len) { 338 switch (key_len) {
318 case 16: 339 case 16:
319 t = E_KEY[3]; 340 t = E_KEY[3];
@@ -369,10 +390,9 @@ aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t
369 390
370/* ====== Encryption/decryption routines ====== */ 391/* ====== Encryption/decryption routines ====== */
371 392
372/* This is the real call to PadLock. */ 393/* These are the real call to PadLock. */
373static inline void 394static inline void padlock_xcrypt_ecb(const u8 *input, u8 *output, void *key,
374padlock_xcrypt_ecb(uint8_t *input, uint8_t *output, uint8_t *key, 395 void *control_word, u32 count)
375 void *control_word, uint32_t count)
376{ 396{
377 asm volatile ("pushfl; popfl"); /* enforce key reload. */ 397 asm volatile ("pushfl; popfl"); /* enforce key reload. */
378 asm volatile (".byte 0xf3,0x0f,0xa7,0xc8" /* rep xcryptecb */ 398 asm volatile (".byte 0xf3,0x0f,0xa7,0xc8" /* rep xcryptecb */
@@ -380,60 +400,70 @@ padlock_xcrypt_ecb(uint8_t *input, uint8_t *output, uint8_t *key,
380 : "d"(control_word), "b"(key), "c"(count)); 400 : "d"(control_word), "b"(key), "c"(count));
381} 401}
382 402
383static void 403static inline u8 *padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key,
384aes_padlock(void *ctx_arg, uint8_t *out_arg, const uint8_t *in_arg, int encdec) 404 u8 *iv, void *control_word, u32 count)
385{ 405{
386 /* Don't blindly modify this structure - the items must 406 /* Enforce key reload. */
387 fit on 16-Bytes boundaries! */ 407 asm volatile ("pushfl; popfl");
388 struct padlock_xcrypt_data { 408 /* rep xcryptcbc */
389 uint8_t buf[AES_BLOCK_SIZE]; 409 asm volatile (".byte 0xf3,0x0f,0xa7,0xd0"
390 union cword cword; 410 : "+S" (input), "+D" (output), "+a" (iv)
391 }; 411 : "d" (control_word), "b" (key), "c" (count));
392 412 return iv;
393 struct aes_ctx *ctx = ctx_arg;
394 char bigbuf[sizeof(struct padlock_xcrypt_data) + 16];
395 struct padlock_xcrypt_data *data;
396 void *key;
397
398 /* Place 'data' at the first 16-Bytes aligned address in 'bigbuf'. */
399 if (((long)bigbuf) & 0x0F)
400 data = (void*)(bigbuf + 16 - ((long)bigbuf & 0x0F));
401 else
402 data = (void*)bigbuf;
403
404 /* Prepare Control word. */
405 memset (data, 0, sizeof(struct padlock_xcrypt_data));
406 data->cword.b.encdec = !encdec; /* in the rest of cryptoapi ENC=1/DEC=0 */
407 data->cword.b.rounds = 10 + (ctx->key_length - 16) / 4;
408 data->cword.b.ksize = (ctx->key_length - 16) / 8;
409
410 /* Is the hardware capable to generate the extended key? */
411 if (!aes_hw_extkey_available(ctx->key_length))
412 data->cword.b.keygen = 1;
413
414 /* ctx->E starts with a plain key - if the hardware is capable
415 to generate the extended key itself we must supply
416 the plain key for both Encryption and Decryption. */
417 if (encdec == CRYPTO_DIR_ENCRYPT || data->cword.b.keygen == 0)
418 key = ctx->E;
419 else
420 key = ctx->D;
421
422 memcpy(data->buf, in_arg, AES_BLOCK_SIZE);
423 padlock_xcrypt_ecb(data->buf, data->buf, key, &data->cword, 1);
424 memcpy(out_arg, data->buf, AES_BLOCK_SIZE);
425} 413}
426 414
427static void 415static void
428aes_encrypt(void *ctx_arg, uint8_t *out, const uint8_t *in) 416aes_encrypt(void *ctx_arg, uint8_t *out, const uint8_t *in)
429{ 417{
430 aes_padlock(ctx_arg, out, in, CRYPTO_DIR_ENCRYPT); 418 struct aes_ctx *ctx = aes_ctx(ctx_arg);
419 padlock_xcrypt_ecb(in, out, ctx->E, &ctx->cword.encrypt, 1);
431} 420}
432 421
433static void 422static void
434aes_decrypt(void *ctx_arg, uint8_t *out, const uint8_t *in) 423aes_decrypt(void *ctx_arg, uint8_t *out, const uint8_t *in)
435{ 424{
436 aes_padlock(ctx_arg, out, in, CRYPTO_DIR_DECRYPT); 425 struct aes_ctx *ctx = aes_ctx(ctx_arg);
426 padlock_xcrypt_ecb(in, out, ctx->D, &ctx->cword.decrypt, 1);
427}
428
429static unsigned int aes_encrypt_ecb(const struct cipher_desc *desc, u8 *out,
430 const u8 *in, unsigned int nbytes)
431{
432 struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm));
433 padlock_xcrypt_ecb(in, out, ctx->E, &ctx->cword.encrypt,
434 nbytes / AES_BLOCK_SIZE);
435 return nbytes & ~(AES_BLOCK_SIZE - 1);
436}
437
438static unsigned int aes_decrypt_ecb(const struct cipher_desc *desc, u8 *out,
439 const u8 *in, unsigned int nbytes)
440{
441 struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm));
442 padlock_xcrypt_ecb(in, out, ctx->D, &ctx->cword.decrypt,
443 nbytes / AES_BLOCK_SIZE);
444 return nbytes & ~(AES_BLOCK_SIZE - 1);
445}
446
447static unsigned int aes_encrypt_cbc(const struct cipher_desc *desc, u8 *out,
448 const u8 *in, unsigned int nbytes)
449{
450 struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm));
451 u8 *iv;
452
453 iv = padlock_xcrypt_cbc(in, out, ctx->E, desc->info,
454 &ctx->cword.encrypt, nbytes / AES_BLOCK_SIZE);
455 memcpy(desc->info, iv, AES_BLOCK_SIZE);
456
457 return nbytes & ~(AES_BLOCK_SIZE - 1);
458}
459
460static unsigned int aes_decrypt_cbc(const struct cipher_desc *desc, u8 *out,
461 const u8 *in, unsigned int nbytes)
462{
463 struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm));
464 padlock_xcrypt_cbc(in, out, ctx->D, desc->info, &ctx->cword.decrypt,
465 nbytes / AES_BLOCK_SIZE);
466 return nbytes & ~(AES_BLOCK_SIZE - 1);
437} 467}
438 468
439static struct crypto_alg aes_alg = { 469static struct crypto_alg aes_alg = {
@@ -441,6 +471,7 @@ static struct crypto_alg aes_alg = {
441 .cra_flags = CRYPTO_ALG_TYPE_CIPHER, 471 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
442 .cra_blocksize = AES_BLOCK_SIZE, 472 .cra_blocksize = AES_BLOCK_SIZE,
443 .cra_ctxsize = sizeof(struct aes_ctx), 473 .cra_ctxsize = sizeof(struct aes_ctx),
474 .cra_alignmask = PADLOCK_ALIGNMENT - 1,
444 .cra_module = THIS_MODULE, 475 .cra_module = THIS_MODULE,
445 .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), 476 .cra_list = LIST_HEAD_INIT(aes_alg.cra_list),
446 .cra_u = { 477 .cra_u = {
@@ -449,7 +480,11 @@ static struct crypto_alg aes_alg = {
449 .cia_max_keysize = AES_MAX_KEY_SIZE, 480 .cia_max_keysize = AES_MAX_KEY_SIZE,
450 .cia_setkey = aes_set_key, 481 .cia_setkey = aes_set_key,
451 .cia_encrypt = aes_encrypt, 482 .cia_encrypt = aes_encrypt,
452 .cia_decrypt = aes_decrypt 483 .cia_decrypt = aes_decrypt,
484 .cia_encrypt_ecb = aes_encrypt_ecb,
485 .cia_decrypt_ecb = aes_decrypt_ecb,
486 .cia_encrypt_cbc = aes_encrypt_cbc,
487 .cia_decrypt_cbc = aes_decrypt_cbc,
453 } 488 }
454 } 489 }
455}; 490};
diff --git a/drivers/crypto/padlock.h b/drivers/crypto/padlock.h
index 7a500605e449..3cf2b7a12348 100644
--- a/drivers/crypto/padlock.h
+++ b/drivers/crypto/padlock.h
@@ -13,18 +13,18 @@
13#ifndef _CRYPTO_PADLOCK_H 13#ifndef _CRYPTO_PADLOCK_H
14#define _CRYPTO_PADLOCK_H 14#define _CRYPTO_PADLOCK_H
15 15
16#define PADLOCK_ALIGNMENT 16
17
16/* Control word. */ 18/* Control word. */
17union cword { 19struct cword {
18 uint32_t cword[4]; 20 int __attribute__ ((__packed__))
19 struct { 21 rounds:4,
20 int rounds:4; 22 algo:3,
21 int algo:3; 23 keygen:1,
22 int keygen:1; 24 interm:1,
23 int interm:1; 25 encdec:1,
24 int encdec:1; 26 ksize:2;
25 int ksize:2; 27} __attribute__ ((__aligned__(PADLOCK_ALIGNMENT)));
26 } b;
27};
28 28
29#define PFX "padlock: " 29#define PFX "padlock: "
30 30
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
new file mode 100644
index 000000000000..140d5f851a5b
--- /dev/null
+++ b/drivers/hwmon/Kconfig
@@ -0,0 +1,420 @@
1#
2# I2C Sensor chip drivers configuration
3#
4
5menu "Hardware Monitoring support"
6
7config HWMON
8 tristate "Hardware Monitoring support"
9 default y
10 help
11 Hardware monitoring devices let you monitor the hardware health
12 of a system. Most modern motherboards include such a device. It
13 can include temperature sensors, voltage sensors, fan speed
14 sensors and various additional features such as the ability to
15 control the speed of the fans.
16
17config SENSORS_ADM1021
18 tristate "Analog Devices ADM1021 and compatibles"
19 depends on HWMON && I2C
20 select I2C_SENSOR
21 help
22 If you say yes here you get support for Analog Devices ADM1021
23 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
24 Genesys Logic GL523SM, National Semiconductor LM84, TI THMC10,
25 and the XEON processor built-in sensor.
26
27 This driver can also be built as a module. If so, the module
28 will be called adm1021.
29
30config SENSORS_ADM1025
31 tristate "Analog Devices ADM1025 and compatibles"
32 depends on HWMON && I2C && EXPERIMENTAL
33 select I2C_SENSOR
34 help
35 If you say yes here you get support for Analog Devices ADM1025
36 and Philips NE1619 sensor chips.
37
38 This driver can also be built as a module. If so, the module
39 will be called adm1025.
40
41config SENSORS_ADM1026
42 tristate "Analog Devices ADM1026 and compatibles"
43 depends on HWMON && I2C && EXPERIMENTAL
44 select I2C_SENSOR
45 help
46 If you say yes here you get support for Analog Devices ADM1026
47 sensor chip.
48
49 This driver can also be built as a module. If so, the module
50 will be called adm1026.
51
52config SENSORS_ADM1031
53 tristate "Analog Devices ADM1031 and compatibles"
54 depends on HWMON && I2C && EXPERIMENTAL
55 select I2C_SENSOR
56 help
57 If you say yes here you get support for Analog Devices ADM1031
58 and ADM1030 sensor chips.
59
60 This driver can also be built as a module. If so, the module
61 will be called adm1031.
62
63config SENSORS_ADM9240
64 tristate "Analog Devices ADM9240 and compatibles"
65 depends on HWMON && I2C && EXPERIMENTAL
66 select I2C_SENSOR
67 help
68 If you say yes here you get support for Analog Devices ADM9240,
69 Dallas DS1780, National Semiconductor LM81 sensor chips.
70
71 This driver can also be built as a module. If so, the module
72 will be called adm9240.
73
74config SENSORS_ASB100
75 tristate "Asus ASB100 Bach"
76 depends on HWMON && I2C && EXPERIMENTAL
77 select I2C_SENSOR
78 help
79 If you say yes here you get support for the ASB100 Bach sensor
80 chip found on some Asus mainboards.
81
82 This driver can also be built as a module. If so, the module
83 will be called asb100.
84
85config SENSORS_ATXP1
86 tristate "Attansic ATXP1 VID controller"
87 depends on HWMON && I2C && EXPERIMENTAL
88 select I2C_SENSOR
89 help
90 If you say yes here you get support for the Attansic ATXP1 VID
91 controller.
92
93 If your board have such a chip, you are able to control your CPU
94 core and other voltages.
95
96 This driver can also be built as a module. If so, the module
97 will be called atxp1.
98
99config SENSORS_DS1621
100 tristate "Dallas Semiconductor DS1621 and DS1625"
101 depends on HWMON && I2C && EXPERIMENTAL
102 select I2C_SENSOR
103 help
104 If you say yes here you get support for Dallas Semiconductor
105 DS1621 and DS1625 sensor chips.
106
107 This driver can also be built as a module. If so, the module
108 will be called ds1621.
109
110config SENSORS_FSCHER
111 tristate "FSC Hermes"
112 depends on HWMON && I2C && EXPERIMENTAL
113 select I2C_SENSOR
114 help
115 If you say yes here you get support for Fujitsu Siemens
116 Computers Hermes sensor chips.
117
118 This driver can also be built as a module. If so, the module
119 will be called fscher.
120
121config SENSORS_FSCPOS
122 tristate "FSC Poseidon"
123 depends on HWMON && I2C && EXPERIMENTAL
124 select I2C_SENSOR
125 help
126 If you say yes here you get support for Fujitsu Siemens
127 Computers Poseidon sensor chips.
128
129 This driver can also be built as a module. If so, the module
130 will be called fscpos.
131
132config SENSORS_GL518SM
133 tristate "Genesys Logic GL518SM"
134 depends on HWMON && I2C
135 select I2C_SENSOR
136 help
137 If you say yes here you get support for Genesys Logic GL518SM
138 sensor chips.
139
140 This driver can also be built as a module. If so, the module
141 will be called gl518sm.
142
143config SENSORS_GL520SM
144 tristate "Genesys Logic GL520SM"
145 depends on HWMON && I2C && EXPERIMENTAL
146 select I2C_SENSOR
147 help
148 If you say yes here you get support for Genesys Logic GL520SM
149 sensor chips.
150
151 This driver can also be built as a module. If so, the module
152 will be called gl520sm.
153
154config SENSORS_IT87
155 tristate "ITE IT87xx and compatibles"
156 depends on HWMON && I2C
157 select I2C_SENSOR
158 help
159 If you say yes here you get support for ITE IT87xx sensor chips
160 and clones: SiS960.
161
162 This driver can also be built as a module. If so, the module
163 will be called it87.
164
165config SENSORS_LM63
166 tristate "National Semiconductor LM63"
167 depends on HWMON && I2C && EXPERIMENTAL
168 select I2C_SENSOR
169 help
170 If you say yes here you get support for the National Semiconductor
171 LM63 remote diode digital temperature sensor with integrated fan
172 control. Such chips are found on the Tyan S4882 (Thunder K8QS Pro)
173 motherboard, among others.
174
175 This driver can also be built as a module. If so, the module
176 will be called lm63.
177
178config SENSORS_LM75
179 tristate "National Semiconductor LM75 and compatibles"
180 depends on HWMON && I2C
181 select I2C_SENSOR
182 help
183 If you say yes here you get support for National Semiconductor LM75
184 sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in
185 9-bit precision mode), and TelCom (now Microchip) TCN75.
186
187 The DS75 and DS1775 in 10- to 12-bit precision modes will require
188 a force module parameter. The driver will not handle the extra
189 precision anyhow.
190
191 This driver can also be built as a module. If so, the module
192 will be called lm75.
193
194config SENSORS_LM77
195 tristate "National Semiconductor LM77"
196 depends on HWMON && I2C && EXPERIMENTAL
197 select I2C_SENSOR
198 help
199 If you say yes here you get support for National Semiconductor LM77
200 sensor chips.
201
202 This driver can also be built as a module. If so, the module
203 will be called lm77.
204
205config SENSORS_LM78
206 tristate "National Semiconductor LM78 and compatibles"
207 depends on HWMON && I2C && EXPERIMENTAL
208 select I2C_SENSOR
209 help
210 If you say yes here you get support for National Semiconductor LM78,
211 LM78-J and LM79.
212
213 This driver can also be built as a module. If so, the module
214 will be called lm78.
215
216config SENSORS_LM80
217 tristate "National Semiconductor LM80"
218 depends on HWMON && I2C && EXPERIMENTAL
219 select I2C_SENSOR
220 help
221 If you say yes here you get support for National Semiconductor
222 LM80 sensor chips.
223
224 This driver can also be built as a module. If so, the module
225 will be called lm80.
226
227config SENSORS_LM83
228 tristate "National Semiconductor LM83"
229 depends on HWMON && I2C
230 select I2C_SENSOR
231 help
232 If you say yes here you get support for National Semiconductor
233 LM83 sensor chips.
234
235 This driver can also be built as a module. If so, the module
236 will be called lm83.
237
238config SENSORS_LM85
239 tristate "National Semiconductor LM85 and compatibles"
240 depends on HWMON && I2C && EXPERIMENTAL
241 select I2C_SENSOR
242 help
243 If you say yes here you get support for National Semiconductor LM85
244 sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027.
245
246 This driver can also be built as a module. If so, the module
247 will be called lm85.
248
249config SENSORS_LM87
250 tristate "National Semiconductor LM87"
251 depends on HWMON && I2C && EXPERIMENTAL
252 select I2C_SENSOR
253 help
254 If you say yes here you get support for National Semiconductor LM87
255 sensor chips.
256
257 This driver can also be built as a module. If so, the module
258 will be called lm87.
259
260config SENSORS_LM90
261 tristate "National Semiconductor LM90 and compatibles"
262 depends on HWMON && I2C
263 select I2C_SENSOR
264 help
265 If you say yes here you get support for National Semiconductor LM90,
266 LM86, LM89 and LM99, Analog Devices ADM1032 and Maxim MAX6657 and
267 MAX6658 sensor chips.
268
269 The Analog Devices ADT7461 sensor chip is also supported, but only
270 if found in ADM1032 compatibility mode.
271
272 This driver can also be built as a module. If so, the module
273 will be called lm90.
274
275config SENSORS_LM92
276 tristate "National Semiconductor LM92 and compatibles"
277 depends on HWMON && I2C && EXPERIMENTAL
278 select I2C_SENSOR
279 help
280 If you say yes here you get support for National Semiconductor LM92
281 and Maxim MAX6635 sensor chips.
282
283 This driver can also be built as a module. If so, the module
284 will be called lm92.
285
286config SENSORS_MAX1619
287 tristate "Maxim MAX1619 sensor chip"
288 depends on HWMON && I2C && EXPERIMENTAL
289 select I2C_SENSOR
290 help
291 If you say yes here you get support for MAX1619 sensor chip.
292
293 This driver can also be built as a module. If so, the module
294 will be called max1619.
295
296config SENSORS_PC87360
297 tristate "National Semiconductor PC87360 family"
298 depends on HWMON && I2C && EXPERIMENTAL
299 select I2C_SENSOR
300 select I2C_ISA
301 help
302 If you say yes here you get access to the hardware monitoring
303 functions of the National Semiconductor PC8736x Super-I/O chips.
304 The PC87360, PC87363 and PC87364 only have fan monitoring and
305 control. The PC87365 and PC87366 additionally have voltage and
306 temperature monitoring.
307
308 This driver can also be built as a module. If so, the module
309 will be called pc87360.
310
311config SENSORS_SIS5595
312 tristate "Silicon Integrated Systems Corp. SiS5595"
313 depends on HWMON && I2C && PCI && EXPERIMENTAL
314 select I2C_SENSOR
315 select I2C_ISA
316 help
317 If you say yes here you get support for the integrated sensors in
318 SiS5595 South Bridges.
319
320 This driver can also be built as a module. If so, the module
321 will be called sis5595.
322
323config SENSORS_SMSC47M1
324 tristate "SMSC LPC47M10x and compatibles"
325 depends on HWMON && I2C && EXPERIMENTAL
326 select I2C_SENSOR
327 select I2C_ISA
328 help
329 If you say yes here you get support for the integrated fan
330 monitoring and control capabilities of the SMSC LPC47B27x,
331 LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips.
332
333 This driver can also be built as a module. If so, the module
334 will be called smsc47m1.
335
336config SENSORS_SMSC47B397
337 tristate "SMSC LPC47B397-NC"
338 depends on HWMON && I2C && EXPERIMENTAL
339 select I2C_SENSOR
340 select I2C_ISA
341 help
342 If you say yes here you get support for the SMSC LPC47B397-NC
343 sensor chip.
344
345 This driver can also be built as a module. If so, the module
346 will be called smsc47b397.
347
348config SENSORS_VIA686A
349 tristate "VIA686A"
350 depends on HWMON && I2C && PCI
351 select I2C_SENSOR
352 select I2C_ISA
353 help
354 If you say yes here you get support for the integrated sensors in
355 Via 686A/B South Bridges.
356
357 This driver can also be built as a module. If so, the module
358 will be called via686a.
359
360config SENSORS_W83781D
361 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
362 depends on HWMON && I2C
363 select I2C_SENSOR
364 help
365 If you say yes here you get support for the Winbond W8378x series
366 of sensor chips: the W83781D, W83782D, W83783S and W83627HF,
367 and the similar Asus AS99127F.
368
369 This driver can also be built as a module. If so, the module
370 will be called w83781d.
371
372config SENSORS_W83L785TS
373 tristate "Winbond W83L785TS-S"
374 depends on HWMON && I2C && EXPERIMENTAL
375 select I2C_SENSOR
376 help
377 If you say yes here you get support for the Winbond W83L785TS-S
378 sensor chip, which is used on the Asus A7N8X, among other
379 motherboards.
380
381 This driver can also be built as a module. If so, the module
382 will be called w83l785ts.
383
384config SENSORS_W83627HF
385 tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
386 depends on HWMON && I2C && EXPERIMENTAL
387 select I2C_SENSOR
388 select I2C_ISA
389 help
390 If you say yes here you get support for the Winbond W836X7 series
391 of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
392
393 This driver can also be built as a module. If so, the module
394 will be called w83627hf.
395
396config SENSORS_W83627EHF
397 tristate "Winbond W83627EHF"
398 depends on HWMON && I2C && EXPERIMENTAL
399 select I2C_SENSOR
400 select I2C_ISA
401 help
402 If you say yes here you get preliminary support for the hardware
403 monitoring functionality of the Winbond W83627EHF Super-I/O chip.
404 Only fan and temperature inputs are supported at the moment, while
405 the chip does much more than that.
406
407 This driver can also be built as a module. If so, the module
408 will be called w83627ehf.
409
410config HWMON_DEBUG_CHIP
411 bool "Hardware Monitoring Chip debugging messages"
412 depends on HWMON
413 default n
414 help
415 Say Y here if you want the I2C chip drivers to produce a bunch of
416 debug messages to the system log. Select this if you are having
417 a problem with I2C support and want to see more of what is going
418 on.
419
420endmenu
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
new file mode 100644
index 000000000000..2781403a0236
--- /dev/null
+++ b/drivers/hwmon/Makefile
@@ -0,0 +1,44 @@
1#
2# Makefile for sensor chip drivers.
3#
4
5# asb100, then w83781d go first, as they can override other drivers' addresses.
6obj-$(CONFIG_SENSORS_ASB100) += asb100.o
7obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o
8obj-$(CONFIG_SENSORS_W83781D) += w83781d.o
9
10obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o
11obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o
12obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
13obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
14obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
15obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
16obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
17obj-$(CONFIG_SENSORS_FSCHER) += fscher.o
18obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
19obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
20obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
21obj-$(CONFIG_SENSORS_IT87) += it87.o
22obj-$(CONFIG_SENSORS_LM63) += lm63.o
23obj-$(CONFIG_SENSORS_LM75) += lm75.o
24obj-$(CONFIG_SENSORS_LM77) += lm77.o
25obj-$(CONFIG_SENSORS_LM78) += lm78.o
26obj-$(CONFIG_SENSORS_LM80) += lm80.o
27obj-$(CONFIG_SENSORS_LM83) += lm83.o
28obj-$(CONFIG_SENSORS_LM85) += lm85.o
29obj-$(CONFIG_SENSORS_LM87) += lm87.o
30obj-$(CONFIG_SENSORS_LM90) += lm90.o
31obj-$(CONFIG_SENSORS_LM92) += lm92.o
32obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
33obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
34obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
35obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
36obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
37obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
38obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o
39obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
40
41ifeq ($(CONFIG_HWMON_DEBUG_CHIP),y)
42EXTRA_CFLAGS += -DDEBUG
43endif
44
diff --git a/drivers/i2c/chips/adm1021.c b/drivers/hwmon/adm1021.c
index d2c774c32f45..d2c774c32f45 100644
--- a/drivers/i2c/chips/adm1021.c
+++ b/drivers/hwmon/adm1021.c
diff --git a/drivers/i2c/chips/adm1025.c b/drivers/hwmon/adm1025.c
index e452d0daf906..e452d0daf906 100644
--- a/drivers/i2c/chips/adm1025.c
+++ b/drivers/hwmon/adm1025.c
diff --git a/drivers/i2c/chips/adm1026.c b/drivers/hwmon/adm1026.c
index 3c85fe150cd7..3c85fe150cd7 100644
--- a/drivers/i2c/chips/adm1026.c
+++ b/drivers/hwmon/adm1026.c
diff --git a/drivers/i2c/chips/adm1031.c b/drivers/hwmon/adm1031.c
index 9168e983ca1d..9168e983ca1d 100644
--- a/drivers/i2c/chips/adm1031.c
+++ b/drivers/hwmon/adm1031.c
diff --git a/drivers/i2c/chips/adm9240.c b/drivers/hwmon/adm9240.c
index 5c68e9c311aa..5c68e9c311aa 100644
--- a/drivers/i2c/chips/adm9240.c
+++ b/drivers/hwmon/adm9240.c
diff --git a/drivers/i2c/chips/asb100.c b/drivers/hwmon/asb100.c
index 70d996d6fe0a..70d996d6fe0a 100644
--- a/drivers/i2c/chips/asb100.c
+++ b/drivers/hwmon/asb100.c
diff --git a/drivers/i2c/chips/atxp1.c b/drivers/hwmon/atxp1.c
index 0bcf82b4c07b..0bcf82b4c07b 100644
--- a/drivers/i2c/chips/atxp1.c
+++ b/drivers/hwmon/atxp1.c
diff --git a/drivers/i2c/chips/ds1621.c b/drivers/hwmon/ds1621.c
index 5360d58804f6..5360d58804f6 100644
--- a/drivers/i2c/chips/ds1621.c
+++ b/drivers/hwmon/ds1621.c
diff --git a/drivers/i2c/chips/fscher.c b/drivers/hwmon/fscher.c
index da411741c2c5..da411741c2c5 100644
--- a/drivers/i2c/chips/fscher.c
+++ b/drivers/hwmon/fscher.c
diff --git a/drivers/i2c/chips/fscpos.c b/drivers/hwmon/fscpos.c
index 3beaa6191ef4..3beaa6191ef4 100644
--- a/drivers/i2c/chips/fscpos.c
+++ b/drivers/hwmon/fscpos.c
diff --git a/drivers/i2c/chips/gl518sm.c b/drivers/hwmon/gl518sm.c
index 6bedf729dcf5..6bedf729dcf5 100644
--- a/drivers/i2c/chips/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
diff --git a/drivers/i2c/chips/gl520sm.c b/drivers/hwmon/gl520sm.c
index a13a504f5bfa..a13a504f5bfa 100644
--- a/drivers/i2c/chips/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
diff --git a/drivers/i2c/chips/it87.c b/drivers/hwmon/it87.c
index db20c9e47393..db20c9e47393 100644
--- a/drivers/i2c/chips/it87.c
+++ b/drivers/hwmon/it87.c
diff --git a/drivers/i2c/chips/lm63.c b/drivers/hwmon/lm63.c
index 7c6f9ea5a254..7c6f9ea5a254 100644
--- a/drivers/i2c/chips/lm63.c
+++ b/drivers/hwmon/lm63.c
diff --git a/drivers/i2c/chips/lm75.c b/drivers/hwmon/lm75.c
index 5be164ed278e..5be164ed278e 100644
--- a/drivers/i2c/chips/lm75.c
+++ b/drivers/hwmon/lm75.c
diff --git a/drivers/i2c/chips/lm75.h b/drivers/hwmon/lm75.h
index 63e3f2fb4c21..63e3f2fb4c21 100644
--- a/drivers/i2c/chips/lm75.h
+++ b/drivers/hwmon/lm75.h
diff --git a/drivers/i2c/chips/lm77.c b/drivers/hwmon/lm77.c
index b98f44952997..b98f44952997 100644
--- a/drivers/i2c/chips/lm77.c
+++ b/drivers/hwmon/lm77.c
diff --git a/drivers/i2c/chips/lm78.c b/drivers/hwmon/lm78.c
index 29241469dcba..29241469dcba 100644
--- a/drivers/i2c/chips/lm78.c
+++ b/drivers/hwmon/lm78.c
diff --git a/drivers/i2c/chips/lm80.c b/drivers/hwmon/lm80.c
index 8100595feb44..8100595feb44 100644
--- a/drivers/i2c/chips/lm80.c
+++ b/drivers/hwmon/lm80.c
diff --git a/drivers/i2c/chips/lm83.c b/drivers/hwmon/lm83.c
index a49008b444c8..a49008b444c8 100644
--- a/drivers/i2c/chips/lm83.c
+++ b/drivers/hwmon/lm83.c
diff --git a/drivers/i2c/chips/lm85.c b/drivers/hwmon/lm85.c
index b4d7fd418264..b4d7fd418264 100644
--- a/drivers/i2c/chips/lm85.c
+++ b/drivers/hwmon/lm85.c
diff --git a/drivers/i2c/chips/lm87.c b/drivers/hwmon/lm87.c
index 1921ed1af182..1921ed1af182 100644
--- a/drivers/i2c/chips/lm87.c
+++ b/drivers/hwmon/lm87.c
diff --git a/drivers/i2c/chips/lm90.c b/drivers/hwmon/lm90.c
index a67dcadf7cb0..a67dcadf7cb0 100644
--- a/drivers/i2c/chips/lm90.c
+++ b/drivers/hwmon/lm90.c
diff --git a/drivers/i2c/chips/lm92.c b/drivers/hwmon/lm92.c
index 215c8e40ffdd..215c8e40ffdd 100644
--- a/drivers/i2c/chips/lm92.c
+++ b/drivers/hwmon/lm92.c
diff --git a/drivers/i2c/chips/max1619.c b/drivers/hwmon/max1619.c
index bf553dcd97d6..bf553dcd97d6 100644
--- a/drivers/i2c/chips/max1619.c
+++ b/drivers/hwmon/max1619.c
diff --git a/drivers/i2c/chips/pc87360.c b/drivers/hwmon/pc87360.c
index 876c68f3af31..876c68f3af31 100644
--- a/drivers/i2c/chips/pc87360.c
+++ b/drivers/hwmon/pc87360.c
diff --git a/drivers/i2c/chips/sis5595.c b/drivers/hwmon/sis5595.c
index 6bbfc8fb4f13..6bbfc8fb4f13 100644
--- a/drivers/i2c/chips/sis5595.c
+++ b/drivers/hwmon/sis5595.c
diff --git a/drivers/i2c/chips/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index 251ac2659554..251ac2659554 100644
--- a/drivers/i2c/chips/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
diff --git a/drivers/i2c/chips/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 897117a7213f..897117a7213f 100644
--- a/drivers/i2c/chips/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
diff --git a/drivers/i2c/chips/via686a.c b/drivers/hwmon/via686a.c
index 137d9b7cacd4..164d47948390 100644
--- a/drivers/i2c/chips/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -1,9 +1,9 @@
1/* 1/*
2 via686a.c - Part of lm_sensors, Linux kernel modules 2 via686a.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring 3 for hardware monitoring
4 4
5 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, 5 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
6 Kyösti Mälkki <kmalkki@cc.hut.fi>, 6 Kyösti Mälkki <kmalkki@cc.hut.fi>,
7 Mark Studebaker <mdsxyz123@yahoo.com>, 7 Mark Studebaker <mdsxyz123@yahoo.com>,
8 and Bob Dougherty <bobd@stanford.edu> 8 and Bob Dougherty <bobd@stanford.edu>
9 (Some conversion-factor data were contributed by Jonathan Teh Soon Yew 9 (Some conversion-factor data were contributed by Jonathan Teh Soon Yew
@@ -171,18 +171,18 @@ static inline u8 FAN_TO_REG(long rpm, int div)
171/******** TEMP CONVERSIONS (Bob Dougherty) *********/ 171/******** TEMP CONVERSIONS (Bob Dougherty) *********/
172/* linear fits from HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew) 172/* linear fits from HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew)
173 if(temp<169) 173 if(temp<169)
174 return double(temp)*0.427-32.08; 174 return double(temp)*0.427-32.08;
175 else if(temp>=169 && temp<=202) 175 else if(temp>=169 && temp<=202)
176 return double(temp)*0.582-58.16; 176 return double(temp)*0.582-58.16;
177 else 177 else
178 return double(temp)*0.924-127.33; 178 return double(temp)*0.924-127.33;
179 179
180 A fifth-order polynomial fits the unofficial data (provided by Alex van 180 A fifth-order polynomial fits the unofficial data (provided by Alex van
181 Kaam <darkside@chello.nl>) a bit better. It also give more reasonable 181 Kaam <darkside@chello.nl>) a bit better. It also give more reasonable
182 numbers on my machine (ie. they agree with what my BIOS tells me). 182 numbers on my machine (ie. they agree with what my BIOS tells me).
183 Here's the fifth-order fit to the 8-bit data: 183 Here's the fifth-order fit to the 8-bit data:
184 temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - 184 temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 -
185 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0. 185 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0.
186 186
187 (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for 187 (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for
188 finding my typos in this formula!) 188 finding my typos in this formula!)
diff --git a/drivers/i2c/chips/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 8a40b6976e1a..8a40b6976e1a 100644
--- a/drivers/i2c/chips/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
diff --git a/drivers/i2c/chips/w83627hf.c b/drivers/hwmon/w83627hf.c
index bd87a42e068a..bd87a42e068a 100644
--- a/drivers/i2c/chips/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
diff --git a/drivers/i2c/chips/w83781d.c b/drivers/hwmon/w83781d.c
index 0bb131ce09eb..0bb131ce09eb 100644
--- a/drivers/i2c/chips/w83781d.c
+++ b/drivers/hwmon/w83781d.c
diff --git a/drivers/i2c/chips/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 4469d52aba4c..4469d52aba4c 100644
--- a/drivers/i2c/chips/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
diff --git a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c
index 68e9e6832ca0..e6cae39f47aa 100644
--- a/drivers/i2c/algos/i2c-algo-ite.c
+++ b/drivers/i2c/algos/i2c-algo-ite.c
@@ -208,7 +208,7 @@ static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
208 goto bailout; 208 goto bailout;
209 } 209 }
210 sdalo(adap); 210 sdalo(adap);
211 printk("test_bus:1 scl: %d sda: %d \n",getscl(adap), 211 printk("test_bus:1 scl: %d sda: %d\n", getscl(adap),
212 getsda(adap)); 212 getsda(adap));
213 if ( 0 != getsda(adap) ) { 213 if ( 0 != getsda(adap) ) {
214 printk("test_bus: %s SDA stuck high!\n",name); 214 printk("test_bus: %s SDA stuck high!\n",name);
@@ -221,7 +221,7 @@ static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
221 goto bailout; 221 goto bailout;
222 } 222 }
223 sdahi(adap); 223 sdahi(adap);
224 printk("test_bus:2 scl: %d sda: %d \n",getscl(adap), 224 printk("test_bus:2 scl: %d sda: %d\n", getscl(adap),
225 getsda(adap)); 225 getsda(adap));
226 if ( 0 == getsda(adap) ) { 226 if ( 0 == getsda(adap) ) {
227 printk("test_bus: %s SDA stuck low!\n",name); 227 printk("test_bus: %s SDA stuck low!\n",name);
@@ -234,7 +234,7 @@ static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
234 goto bailout; 234 goto bailout;
235 } 235 }
236 scllo(adap); 236 scllo(adap);
237 printk("test_bus:3 scl: %d sda: %d \n",getscl(adap), 237 printk("test_bus:3 scl: %d sda: %d\n", getscl(adap),
238 getsda(adap)); 238 getsda(adap));
239 if ( 0 != getscl(adap) ) { 239 if ( 0 != getscl(adap) ) {
240 240
@@ -247,7 +247,7 @@ static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
247 goto bailout; 247 goto bailout;
248 } 248 }
249 sclhi(adap); 249 sclhi(adap);
250 printk("test_bus:4 scl: %d sda: %d \n",getscl(adap), 250 printk("test_bus:4 scl: %d sda: %d\n", getscl(adap),
251 getsda(adap)); 251 getsda(adap));
252 if ( 0 == getscl(adap) ) { 252 if ( 0 == getscl(adap) ) {
253 printk("test_bus: %s SCL stuck low!\n",name); 253 printk("test_bus: %s SCL stuck low!\n",name);
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 45e6efb1dcd1..0ab7e37f5b00 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -194,7 +194,7 @@ static int i801_transaction(void)
194 /* Make sure the SMBus host is ready to start transmitting */ 194 /* Make sure the SMBus host is ready to start transmitting */
195 /* 0x1f = Failed, Bus_Err, Dev_Err, Intr, Host_Busy */ 195 /* 0x1f = Failed, Bus_Err, Dev_Err, Intr, Host_Busy */
196 if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { 196 if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) {
197 dev_dbg(&I801_dev->dev, "SMBus busy (%02x). Resetting... \n", 197 dev_dbg(&I801_dev->dev, "SMBus busy (%02x). Resetting...\n",
198 temp); 198 temp);
199 outb_p(temp, SMBHSTSTS); 199 outb_p(temp, SMBHSTSTS);
200 if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { 200 if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) {
@@ -315,7 +315,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
315 } 315 }
316 if (temp & errmask) { 316 if (temp & errmask) {
317 dev_dbg(&I801_dev->dev, "SMBus busy (%02x). " 317 dev_dbg(&I801_dev->dev, "SMBus busy (%02x). "
318 "Resetting... \n", temp); 318 "Resetting...\n", temp);
319 outb_p(temp, SMBHSTSTS); 319 outb_p(temp, SMBHSTSTS);
320 if (((temp = inb_p(SMBHSTSTS)) & errmask) != 0x00) { 320 if (((temp = inb_p(SMBHSTSTS)) & errmask) != 0x00) {
321 dev_err(&I801_dev->dev, 321 dev_err(&I801_dev->dev,
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c
index 363e545fc01f..94ae808314f7 100644
--- a/drivers/i2c/busses/i2c-keywest.c
+++ b/drivers/i2c/busses/i2c-keywest.c
@@ -698,7 +698,7 @@ dispose_iface(struct device *dev)
698} 698}
699 699
700static int 700static int
701create_iface_macio(struct macio_dev* dev, const struct of_match *match) 701create_iface_macio(struct macio_dev* dev, const struct of_device_id *match)
702{ 702{
703 return create_iface(dev->ofdev.node, &dev->ofdev.dev); 703 return create_iface(dev->ofdev.node, &dev->ofdev.dev);
704} 704}
@@ -710,7 +710,7 @@ dispose_iface_macio(struct macio_dev* dev)
710} 710}
711 711
712static int 712static int
713create_iface_of_platform(struct of_device* dev, const struct of_match *match) 713create_iface_of_platform(struct of_device* dev, const struct of_device_id *match)
714{ 714{
715 return create_iface(dev->node, &dev->dev); 715 return create_iface(dev->node, &dev->dev);
716} 716}
@@ -721,10 +721,9 @@ dispose_iface_of_platform(struct of_device* dev)
721 return dispose_iface(&dev->dev); 721 return dispose_iface(&dev->dev);
722} 722}
723 723
724static struct of_match i2c_keywest_match[] = 724static struct of_device_id i2c_keywest_match[] =
725{ 725{
726 { 726 {
727 .name = OF_ANY_MATCH,
728 .type = "i2c", 727 .type = "i2c",
729 .compatible = "keywest" 728 .compatible = "keywest"
730 }, 729 },
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 1f80ba9da6f1..6d34ee381ce1 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -243,7 +243,7 @@ static int piix4_transaction(void)
243 /* Make sure the SMBus host is ready to start transmitting */ 243 /* Make sure the SMBus host is ready to start transmitting */
244 if ((temp = inb_p(SMBHSTSTS)) != 0x00) { 244 if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
245 dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). " 245 dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). "
246 "Resetting... \n", temp); 246 "Resetting...\n", temp);
247 outb_p(temp, SMBHSTSTS); 247 outb_p(temp, SMBHSTSTS);
248 if ((temp = inb_p(SMBHSTSTS)) != 0x00) { 248 if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
249 dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp); 249 dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 2b5911cfb7b5..bbd5e4e52f09 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -228,7 +228,7 @@ static int sis5595_transaction(struct i2c_adapter *adap)
228 /* Make sure the SMBus host is ready to start transmitting */ 228 /* Make sure the SMBus host is ready to start transmitting */
229 temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8); 229 temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8);
230 if (temp != 0x00) { 230 if (temp != 0x00) {
231 dev_dbg(&adap->dev, "SMBus busy (%04x). Resetting... \n", temp); 231 dev_dbg(&adap->dev, "SMBus busy (%04x). Resetting...\n", temp);
232 sis5595_write(SMB_STS_LO, temp & 0xff); 232 sis5595_write(SMB_STS_LO, temp & 0xff);
233 sis5595_write(SMB_STS_HI, temp >> 8); 233 sis5595_write(SMB_STS_HI, temp >> 8);
234 if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) { 234 if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) {
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index a0982da09803..43f70dbfc03f 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -1,409 +1,12 @@
1# 1#
2# I2C Sensor and "other" chip configuration 2# Miscellaneous I2C chip drivers configuration
3# 3#
4 4
5menu "Hardware Sensors Chip support"
6 depends on I2C
7
8config I2C_SENSOR 5config I2C_SENSOR
9 tristate 6 tristate
10 default n 7 default n
11 8
12config SENSORS_ADM1021 9menu "Miscellaneous I2C Chip support"
13 tristate "Analog Devices ADM1021 and compatibles"
14 depends on I2C
15 select I2C_SENSOR
16 help
17 If you say yes here you get support for Analog Devices ADM1021
18 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
19 Genesys Logic GL523SM, National Semiconductor LM84, TI THMC10,
20 and the XEON processor built-in sensor.
21
22 This driver can also be built as a module. If so, the module
23 will be called adm1021.
24
25config SENSORS_ADM1025
26 tristate "Analog Devices ADM1025 and compatibles"
27 depends on I2C && EXPERIMENTAL
28 select I2C_SENSOR
29 help
30 If you say yes here you get support for Analog Devices ADM1025
31 and Philips NE1619 sensor chips.
32
33 This driver can also be built as a module. If so, the module
34 will be called adm1025.
35
36config SENSORS_ADM1026
37 tristate "Analog Devices ADM1026 and compatibles"
38 depends on I2C && EXPERIMENTAL
39 select I2C_SENSOR
40 help
41 If you say yes here you get support for Analog Devices ADM1026
42 sensor chip.
43
44 This driver can also be built as a module. If so, the module
45 will be called adm1026.
46
47config SENSORS_ADM1031
48 tristate "Analog Devices ADM1031 and compatibles"
49 depends on I2C && EXPERIMENTAL
50 select I2C_SENSOR
51 help
52 If you say yes here you get support for Analog Devices ADM1031
53 and ADM1030 sensor chips.
54
55 This driver can also be built as a module. If so, the module
56 will be called adm1031.
57
58config SENSORS_ADM9240
59 tristate "Analog Devices ADM9240 and compatibles"
60 depends on I2C && EXPERIMENTAL
61 select I2C_SENSOR
62 help
63 If you say yes here you get support for Analog Devices ADM9240,
64 Dallas DS1780, National Semiconductor LM81 sensor chips.
65
66 This driver can also be built as a module. If so, the module
67 will be called adm9240.
68
69config SENSORS_ASB100
70 tristate "Asus ASB100 Bach"
71 depends on I2C && EXPERIMENTAL
72 select I2C_SENSOR
73 help
74 If you say yes here you get support for the ASB100 Bach sensor
75 chip found on some Asus mainboards.
76
77 This driver can also be built as a module. If so, the module
78 will be called asb100.
79
80config SENSORS_ATXP1
81 tristate "Attansic ATXP1 VID controller"
82 depends on I2C && EXPERIMENTAL
83 help
84 If you say yes here you get support for the Attansic ATXP1 VID
85 controller.
86
87 If your board have such a chip, you are able to control your CPU
88 core and other voltages.
89
90 This driver can also be built as a module. If so, the module
91 will be called atxp1.
92
93config SENSORS_DS1621
94 tristate "Dallas Semiconductor DS1621 and DS1625"
95 depends on I2C && EXPERIMENTAL
96 select I2C_SENSOR
97 help
98 If you say yes here you get support for Dallas Semiconductor
99 DS1621 and DS1625 sensor chips.
100
101 This driver can also be built as a module. If so, the module
102 will be called ds1621.
103
104config SENSORS_FSCHER
105 tristate "FSC Hermes"
106 depends on I2C && EXPERIMENTAL
107 select I2C_SENSOR
108 help
109 If you say yes here you get support for Fujitsu Siemens
110 Computers Hermes sensor chips.
111
112 This driver can also be built as a module. If so, the module
113 will be called fscher.
114
115config SENSORS_FSCPOS
116 tristate "FSC Poseidon"
117 depends on I2C && EXPERIMENTAL
118 select I2C_SENSOR
119 help
120 If you say yes here you get support for Fujitsu Siemens
121 Computers Poseidon sensor chips.
122
123 This driver can also be built as a module. If so, the module
124 will be called fscpos.
125
126config SENSORS_GL518SM
127 tristate "Genesys Logic GL518SM"
128 depends on I2C
129 select I2C_SENSOR
130 help
131 If you say yes here you get support for Genesys Logic GL518SM
132 sensor chips.
133
134 This driver can also be built as a module. If so, the module
135 will be called gl518sm.
136
137config SENSORS_GL520SM
138 tristate "Genesys Logic GL520SM"
139 depends on I2C && EXPERIMENTAL
140 select I2C_SENSOR
141 help
142 If you say yes here you get support for Genesys Logic GL520SM
143 sensor chips.
144
145 This driver can also be built as a module. If so, the module
146 will be called gl520sm.
147
148config SENSORS_IT87
149 tristate "ITE IT87xx and compatibles"
150 depends on I2C
151 select I2C_SENSOR
152 help
153 If you say yes here you get support for ITE IT87xx sensor chips
154 and clones: SiS960.
155
156 This driver can also be built as a module. If so, the module
157 will be called it87.
158
159config SENSORS_LM63
160 tristate "National Semiconductor LM63"
161 depends on I2C && EXPERIMENTAL
162 select I2C_SENSOR
163 help
164 If you say yes here you get support for the National Semiconductor
165 LM63 remote diode digital temperature sensor with integrated fan
166 control. Such chips are found on the Tyan S4882 (Thunder K8QS Pro)
167 motherboard, among others.
168
169 This driver can also be built as a module. If so, the module
170 will be called lm63.
171
172config SENSORS_LM75
173 tristate "National Semiconductor LM75 and compatibles"
174 depends on I2C
175 select I2C_SENSOR
176 help
177 If you say yes here you get support for National Semiconductor LM75
178 sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in
179 9-bit precision mode), and TelCom (now Microchip) TCN75.
180
181 The DS75 and DS1775 in 10- to 12-bit precision modes will require
182 a force module parameter. The driver will not handle the extra
183 precision anyhow.
184
185 This driver can also be built as a module. If so, the module
186 will be called lm75.
187
188config SENSORS_LM77
189 tristate "National Semiconductor LM77"
190 depends on I2C && EXPERIMENTAL
191 select I2C_SENSOR
192 help
193 If you say yes here you get support for National Semiconductor LM77
194 sensor chips.
195
196 This driver can also be built as a module. If so, the module
197 will be called lm77.
198
199config SENSORS_LM78
200 tristate "National Semiconductor LM78 and compatibles"
201 depends on I2C && EXPERIMENTAL
202 select I2C_SENSOR
203 help
204 If you say yes here you get support for National Semiconductor LM78,
205 LM78-J and LM79.
206
207 This driver can also be built as a module. If so, the module
208 will be called lm78.
209
210config SENSORS_LM80
211 tristate "National Semiconductor LM80"
212 depends on I2C && EXPERIMENTAL
213 select I2C_SENSOR
214 help
215 If you say yes here you get support for National Semiconductor
216 LM80 sensor chips.
217
218 This driver can also be built as a module. If so, the module
219 will be called lm80.
220
221config SENSORS_LM83
222 tristate "National Semiconductor LM83"
223 depends on I2C
224 select I2C_SENSOR
225 help
226 If you say yes here you get support for National Semiconductor
227 LM83 sensor chips.
228
229 This driver can also be built as a module. If so, the module
230 will be called lm83.
231
232config SENSORS_LM85
233 tristate "National Semiconductor LM85 and compatibles"
234 depends on I2C && EXPERIMENTAL
235 select I2C_SENSOR
236 help
237 If you say yes here you get support for National Semiconductor LM85
238 sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027.
239
240 This driver can also be built as a module. If so, the module
241 will be called lm85.
242
243config SENSORS_LM87
244 tristate "National Semiconductor LM87"
245 depends on I2C && EXPERIMENTAL
246 select I2C_SENSOR
247 help
248 If you say yes here you get support for National Semiconductor LM87
249 sensor chips.
250
251 This driver can also be built as a module. If so, the module
252 will be called lm87.
253
254config SENSORS_LM90
255 tristate "National Semiconductor LM90 and compatibles"
256 depends on I2C
257 select I2C_SENSOR
258 help
259 If you say yes here you get support for National Semiconductor LM90,
260 LM86, LM89 and LM99, Analog Devices ADM1032 and Maxim MAX6657 and
261 MAX6658 sensor chips.
262
263 The Analog Devices ADT7461 sensor chip is also supported, but only
264 if found in ADM1032 compatibility mode.
265
266 This driver can also be built as a module. If so, the module
267 will be called lm90.
268
269config SENSORS_LM92
270 tristate "National Semiconductor LM92 and compatibles"
271 depends on I2C && EXPERIMENTAL
272 select I2C_SENSOR
273 help
274 If you say yes here you get support for National Semiconductor LM92
275 and Maxim MAX6635 sensor chips.
276
277 This driver can also be built as a module. If so, the module
278 will be called lm92.
279
280config SENSORS_MAX1619
281 tristate "Maxim MAX1619 sensor chip"
282 depends on I2C && EXPERIMENTAL
283 select I2C_SENSOR
284 help
285 If you say yes here you get support for MAX1619 sensor chip.
286
287 This driver can also be built as a module. If so, the module
288 will be called max1619.
289
290config SENSORS_PC87360
291 tristate "National Semiconductor PC87360 family"
292 depends on I2C && EXPERIMENTAL
293 select I2C_SENSOR
294 select I2C_ISA
295 help
296 If you say yes here you get access to the hardware monitoring
297 functions of the National Semiconductor PC8736x Super-I/O chips.
298 The PC87360, PC87363 and PC87364 only have fan monitoring and
299 control. The PC87365 and PC87366 additionally have voltage and
300 temperature monitoring.
301
302 This driver can also be built as a module. If so, the module
303 will be called pc87360.
304
305config SENSORS_SMSC47B397
306 tristate "SMSC LPC47B397-NC"
307 depends on I2C && EXPERIMENTAL
308 select I2C_SENSOR
309 select I2C_ISA
310 help
311 If you say yes here you get support for the SMSC LPC47B397-NC
312 sensor chip.
313
314 This driver can also be built as a module. If so, the module
315 will be called smsc47b397.
316
317config SENSORS_SIS5595
318 tristate "Silicon Integrated Systems Corp. SiS5595"
319 depends on I2C && PCI && EXPERIMENTAL
320 select I2C_SENSOR
321 select I2C_ISA
322 help
323 If you say yes here you get support for the integrated sensors in
324 SiS5595 South Bridges.
325
326 This driver can also be built as a module. If so, the module
327 will be called sis5595.
328
329config SENSORS_SMSC47M1
330 tristate "SMSC LPC47M10x and compatibles"
331 depends on I2C && EXPERIMENTAL
332 select I2C_SENSOR
333 select I2C_ISA
334 help
335 If you say yes here you get support for the integrated fan
336 monitoring and control capabilities of the SMSC LPC47B27x,
337 LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips.
338
339 This driver can also be built as a module. If so, the module
340 will be called smsc47m1.
341
342config SENSORS_VIA686A
343 tristate "VIA686A"
344 depends on I2C && PCI
345 select I2C_SENSOR
346 select I2C_ISA
347 help
348 If you say yes here you get support for the integrated sensors in
349 Via 686A/B South Bridges.
350
351 This driver can also be built as a module. If so, the module
352 will be called via686a.
353
354config SENSORS_W83781D
355 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
356 depends on I2C
357 select I2C_SENSOR
358 help
359 If you say yes here you get support for the Winbond W8378x series
360 of sensor chips: the W83781D, W83782D, W83783S and W83627HF,
361 and the similar Asus AS99127F.
362
363 This driver can also be built as a module. If so, the module
364 will be called w83781d.
365
366config SENSORS_W83L785TS
367 tristate "Winbond W83L785TS-S"
368 depends on I2C && EXPERIMENTAL
369 select I2C_SENSOR
370 help
371 If you say yes here you get support for the Winbond W83L785TS-S
372 sensor chip, which is used on the Asus A7N8X, among other
373 motherboards.
374
375 This driver can also be built as a module. If so, the module
376 will be called w83l785ts.
377
378config SENSORS_W83627HF
379 tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
380 depends on I2C && EXPERIMENTAL
381 select I2C_SENSOR
382 select I2C_ISA
383 help
384 If you say yes here you get support for the Winbond W836X7 series
385 of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
386
387 This driver can also be built as a module. If so, the module
388 will be called w83627hf.
389
390config SENSORS_W83627EHF
391 tristate "Winbond W83627EHF"
392 depends on I2C && EXPERIMENTAL
393 select I2C_SENSOR
394 select I2C_ISA
395 help
396 If you say yes here you get preliminary support for the hardware
397 monitoring functionality of the Winbond W83627EHF Super-I/O chip.
398 Only fan and temperature inputs are supported at the moment, while
399 the chip does much more than that.
400
401 This driver can also be built as a module. If so, the module
402 will be called w83627ehf.
403
404endmenu
405
406menu "Other I2C Chip support"
407 depends on I2C 10 depends on I2C
408 11
409config SENSORS_DS1337 12config SENSORS_DS1337
@@ -509,7 +112,6 @@ config TPS65010
509 This driver can also be built as a module. If so, the module 112 This driver can also be built as a module. If so, the module
510 will be called tps65010. 113 will be called tps65010.
511 114
512
513config SENSORS_M41T00 115config SENSORS_M41T00
514 tristate "ST M41T00 RTC chip" 116 tristate "ST M41T00 RTC chip"
515 depends on I2C && PPC32 117 depends on I2C && PPC32
@@ -520,13 +122,16 @@ config SENSORS_M41T00
520 will be called m41t00. 122 will be called m41t00.
521 123
522config SENSORS_MAX6875 124config SENSORS_MAX6875
523 tristate "MAXIM MAX6875 Power supply supervisor" 125 tristate "Maxim MAX6875 Power supply supervisor"
524 depends on I2C && EXPERIMENTAL 126 depends on I2C && EXPERIMENTAL
525 help 127 help
526 If you say yes here you get support for the MAX6875 128 If you say yes here you get support for the Maxim MAX6875
527 EEPROM-Programmable, Hex/Quad, Power-Suppy Sequencers/Supervisors. 129 EEPROM-programmable, quad power-supply sequencer/supervisor.
130
131 This provides an interface to program the EEPROM and reset the chip.
528 132
529 This provides a interface to program the EEPROM and reset the chip. 133 This driver also supports the Maxim MAX6874 hex power-supply
134 sequencer/supervisor if found at a compatible address.
530 135
531 This driver can also be built as a module. If so, the module 136 This driver can also be built as a module. If so, the module
532 will be called max6875. 137 will be called max6875.
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index b5e6d2f84f97..a876dd42b860 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -1,52 +1,16 @@
1# 1#
2# Makefile for sensor and "other" I2C chip drivers. 2# Makefile for miscellaneous I2C chip drivers.
3# 3#
4 4
5# asb100, then w83781d go first, as they can override other drivers' addresses.
6obj-$(CONFIG_SENSORS_ASB100) += asb100.o
7obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o
8obj-$(CONFIG_SENSORS_W83781D) += w83781d.o
9
10obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o
11obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o
12obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
13obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
14obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
15obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
16obj-$(CONFIG_SENSORS_DS1337) += ds1337.o 5obj-$(CONFIG_SENSORS_DS1337) += ds1337.o
17obj-$(CONFIG_SENSORS_DS1374) += ds1374.o 6obj-$(CONFIG_SENSORS_DS1374) += ds1374.o
18obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
19obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o 7obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o
20obj-$(CONFIG_SENSORS_FSCHER) += fscher.o
21obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
22obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
23obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
24obj-$(CONFIG_SENSORS_IT87) += it87.o
25obj-$(CONFIG_SENSORS_LM63) += lm63.o
26obj-$(CONFIG_SENSORS_LM75) += lm75.o
27obj-$(CONFIG_SENSORS_LM77) += lm77.o
28obj-$(CONFIG_SENSORS_LM78) += lm78.o
29obj-$(CONFIG_SENSORS_LM80) += lm80.o
30obj-$(CONFIG_SENSORS_LM83) += lm83.o
31obj-$(CONFIG_SENSORS_LM85) += lm85.o
32obj-$(CONFIG_SENSORS_LM87) += lm87.o
33obj-$(CONFIG_SENSORS_LM90) += lm90.o
34obj-$(CONFIG_SENSORS_LM92) += lm92.o
35obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
36obj-$(CONFIG_SENSORS_MAX6875) += max6875.o 8obj-$(CONFIG_SENSORS_MAX6875) += max6875.o
37obj-$(CONFIG_SENSORS_M41T00) += m41t00.o 9obj-$(CONFIG_SENSORS_M41T00) += m41t00.o
38obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
39obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o 10obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
40obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o 11obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
41obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 12obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
42obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o 13obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
43obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
44obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
45obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
46obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
47obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o
48obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
49
50obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 14obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
51obj-$(CONFIG_TPS65010) += tps65010.o 15obj-$(CONFIG_TPS65010) += tps65010.o
52 16
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index addf0adc24d4..6ea413f6d5e5 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -173,9 +173,6 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
173 | I2C_FUNC_SMBUS_BYTE)) 173 | I2C_FUNC_SMBUS_BYTE))
174 goto exit; 174 goto exit;
175 175
176 /* OK. For now, we presume we have a valid client. We now create the
177 client structure, even though we cannot fill it completely yet.
178 But it allows us to access eeprom_{read,write}_value. */
179 if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { 176 if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) {
180 err = -ENOMEM; 177 err = -ENOMEM;
181 goto exit; 178 goto exit;
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 5e463c47bfbc..778d7e12859d 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -207,7 +207,7 @@ m41t00_detach(struct i2c_client *client)
207 int rc; 207 int rc;
208 208
209 if ((rc = i2c_detach_client(client)) == 0) { 209 if ((rc = i2c_detach_client(client)) == 0) {
210 kfree(i2c_get_clientdata(client)); 210 kfree(client);
211 tasklet_kill(&m41t00_tasklet); 211 tasklet_kill(&m41t00_tasklet);
212 } 212 }
213 return rc; 213 return rc;
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index fe6b150ec4c2..c4f14d9623c4 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -37,7 +37,8 @@
37#include <linux/i2c-sensor.h> 37#include <linux/i2c-sensor.h>
38 38
39/* Addresses to scan */ 39/* Addresses to scan */
40static unsigned short normal_i2c[] = {0x50, 0x52, I2C_CLIENT_END}; 40/* No address scanned by default, as this could corrupt standard EEPROMS. */
41static unsigned short normal_i2c[] = {I2C_CLIENT_END};
41static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; 42static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
42 43
43/* Insmod parameters */ 44/* Insmod parameters */
@@ -369,6 +370,9 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
369 new_client->driver = &max6875_driver; 370 new_client->driver = &max6875_driver;
370 new_client->flags = 0; 371 new_client->flags = 0;
371 372
373 /* Prevent 24RF08 corruption */
374 i2c_smbus_write_quick(new_client, 0);
375
372 /* Setup the user section */ 376 /* Setup the user section */
373 data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; 377 data->blocks[max6875_eeprom_user].type = max6875_eeprom_user;
374 data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; 378 data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES;
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index c0ac01b60039..280e9638c0f8 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -18,7 +18,6 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21#undef DEBUG
22 21
23#include <linux/config.h> 22#include <linux/config.h>
24#include <linux/kernel.h> 23#include <linux/kernel.h>
@@ -49,11 +48,7 @@
49MODULE_DESCRIPTION("TPS6501x Power Management Driver"); 48MODULE_DESCRIPTION("TPS6501x Power Management Driver");
50MODULE_LICENSE("GPL"); 49MODULE_LICENSE("GPL");
51 50
52/* only two addresses possible */ 51static unsigned short normal_i2c[] = { 0x48, /* 0x49, */ I2C_CLIENT_END };
53#define TPS_BASE 0x48
54static unsigned short normal_i2c[] = {
55 TPS_BASE,
56 I2C_CLIENT_END };
57static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 52static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
58 53
59I2C_CLIENT_INSMOD; 54I2C_CLIENT_INSMOD;
@@ -102,7 +97,7 @@ struct tps65010 {
102 u8 chgstatus, regstatus, chgconf; 97 u8 chgstatus, regstatus, chgconf;
103 u8 nmask1, nmask2; 98 u8 nmask1, nmask2;
104 99
105 /* plus four GPIOs, probably used to switch power */ 100 /* not currently tracking GPIO state */
106}; 101};
107 102
108#define POWER_POLL_DELAY msecs_to_jiffies(800) 103#define POWER_POLL_DELAY msecs_to_jiffies(800)
@@ -135,7 +130,7 @@ static void dbg_regstat(char *buf, size_t len, u8 regstatus)
135 (regstatus & TPS_REG_COVER) ? " uncover" : "", 130 (regstatus & TPS_REG_COVER) ? " uncover" : "",
136 (regstatus & TPS_REG_UVLO) ? " UVLO" : "", 131 (regstatus & TPS_REG_UVLO) ? " UVLO" : "",
137 (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "", 132 (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "",
138 (regstatus & TPS_REG_PG_LD02) ? " ld01_bad" : "", 133 (regstatus & TPS_REG_PG_LD02) ? " ld02_bad" : "",
139 (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "", 134 (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "",
140 (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "", 135 (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "",
141 (regstatus & TPS_REG_PG_CORE) ? " core_bad" : ""); 136 (regstatus & TPS_REG_PG_CORE) ? " core_bad" : "");
@@ -143,7 +138,7 @@ static void dbg_regstat(char *buf, size_t len, u8 regstatus)
143 138
144static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig) 139static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig)
145{ 140{
146 char *hibit; 141 const char *hibit;
147 142
148 if (por) 143 if (por)
149 hibit = (chgconfig & TPS_CHARGE_POR) 144 hibit = (chgconfig & TPS_CHARGE_POR)
@@ -295,7 +290,7 @@ static int dbg_show(struct seq_file *s, void *_)
295 seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2); 290 seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2);
296 291
297 for (i = 0; i < 4; i++) { 292 for (i = 0; i < 4; i++) {
298 if (value & (1 << (4 +i))) 293 if (value & (1 << (4 + i)))
299 seq_printf(s, " gpio%d-out %s\n", i + 1, 294 seq_printf(s, " gpio%d-out %s\n", i + 1,
300 (value & (1 << i)) ? "low" : "hi "); 295 (value & (1 << i)) ? "low" : "hi ");
301 else 296 else
@@ -481,7 +476,7 @@ static int __exit tps65010_detach_client(struct i2c_client *client)
481 debugfs_remove(tps->file); 476 debugfs_remove(tps->file);
482 if (i2c_detach_client(client) == 0) 477 if (i2c_detach_client(client) == 0)
483 kfree(tps); 478 kfree(tps);
484 the_tps = 0; 479 the_tps = NULL;
485 return 0; 480 return 0;
486} 481}
487 482
@@ -514,7 +509,6 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
514 INIT_WORK(&tps->work, tps65010_work, tps); 509 INIT_WORK(&tps->work, tps65010_work, tps);
515 tps->irq = -1; 510 tps->irq = -1;
516 tps->client.addr = address; 511 tps->client.addr = address;
517 i2c_set_clientdata(&tps->client, tps);
518 tps->client.adapter = bus; 512 tps->client.adapter = bus;
519 tps->client.driver = &tps65010_driver; 513 tps->client.driver = &tps65010_driver;
520 strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE); 514 strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE);
@@ -523,9 +517,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
523 if (status < 0) { 517 if (status < 0) {
524 dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", 518 dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n",
525 DRIVER_NAME, address, status); 519 DRIVER_NAME, address, status);
526fail1: 520 goto fail1;
527 kfree(tps);
528 return 0;
529 } 521 }
530 522
531#ifdef CONFIG_ARM 523#ifdef CONFIG_ARM
@@ -535,7 +527,7 @@ fail1:
535 tps->irq = OMAP_GPIO_IRQ(58); 527 tps->irq = OMAP_GPIO_IRQ(58);
536 omap_request_gpio(58); 528 omap_request_gpio(58);
537 omap_set_gpio_direction(58, 1); 529 omap_set_gpio_direction(58, 1);
538 omap_set_gpio_edge_ctrl(58, OMAP_GPIO_FALLING_EDGE); 530 set_irq_type(tps->irq, IRQT_FALLING);
539 } 531 }
540 if (machine_is_omap_osk()) { 532 if (machine_is_omap_osk()) {
541 tps->model = TPS65010; 533 tps->model = TPS65010;
@@ -543,7 +535,7 @@ fail1:
543 tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)); 535 tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1));
544 omap_request_gpio(OMAP_MPUIO(1)); 536 omap_request_gpio(OMAP_MPUIO(1));
545 omap_set_gpio_direction(OMAP_MPUIO(1), 1); 537 omap_set_gpio_direction(OMAP_MPUIO(1), 1);
546 omap_set_gpio_edge_ctrl(OMAP_MPUIO(1), OMAP_GPIO_FALLING_EDGE); 538 set_irq_type(tps->irq, IRQT_FALLING);
547 } 539 }
548 if (machine_is_omap_h3()) { 540 if (machine_is_omap_h3()) {
549 tps->model = TPS65013; 541 tps->model = TPS65013;
@@ -633,6 +625,9 @@ fail1:
633 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, 625 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL,
634 tps, DEBUG_FOPS); 626 tps, DEBUG_FOPS);
635 return 0; 627 return 0;
628fail1:
629 kfree(tps);
630 return 0;
636} 631}
637 632
638static int __init tps65010_scan_bus(struct i2c_adapter *bus) 633static int __init tps65010_scan_bus(struct i2c_adapter *bus)
@@ -645,7 +640,6 @@ static int __init tps65010_scan_bus(struct i2c_adapter *bus)
645static struct i2c_driver tps65010_driver = { 640static struct i2c_driver tps65010_driver = {
646 .owner = THIS_MODULE, 641 .owner = THIS_MODULE,
647 .name = "tps65010", 642 .name = "tps65010",
648 .id = 888, /* FIXME assign "official" value */
649 .flags = I2C_DF_NOTIFY, 643 .flags = I2C_DF_NOTIFY,
650 .attach_adapter = tps65010_scan_bus, 644 .attach_adapter = tps65010_scan_bus,
651 .detach_client = __exit_p(tps65010_detach_client), 645 .detach_client = __exit_p(tps65010_detach_client),
@@ -744,7 +738,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
744 if (!the_tps) 738 if (!the_tps)
745 return -ENODEV; 739 return -ENODEV;
746 740
747 if(led == LED1) 741 if (led == LED1)
748 offs = 0; 742 offs = 0;
749 else { 743 else {
750 offs = 2; 744 offs = 2;
@@ -753,11 +747,13 @@ int tps65010_set_led(unsigned led, unsigned mode)
753 747
754 down(&the_tps->lock); 748 down(&the_tps->lock);
755 749
756 dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, 750 pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led,
757 i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); 751 i2c_smbus_read_byte_data(&the_tps->client,
752 TPS_LED1_ON + offs));
758 753
759 dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, 754 pr_debug("%s: led%i_per 0x%02x\n", DRIVER_NAME, led,
760 i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); 755 i2c_smbus_read_byte_data(&the_tps->client,
756 TPS_LED1_PER + offs));
761 757
762 switch (mode) { 758 switch (mode) {
763 case OFF: 759 case OFF:
@@ -773,7 +769,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
773 led_per = 0x08 | (1 << 7); 769 led_per = 0x08 | (1 << 7);
774 break; 770 break;
775 default: 771 default:
776 printk(KERN_ERR "%s: Wrong mode parameter for tps65010_set_led()\n", 772 printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n",
777 DRIVER_NAME); 773 DRIVER_NAME);
778 up(&the_tps->lock); 774 up(&the_tps->lock);
779 return -EINVAL; 775 return -EINVAL;
@@ -789,7 +785,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
789 return status; 785 return status;
790 } 786 }
791 787
792 dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, 788 pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led,
793 i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); 789 i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs));
794 790
795 status = i2c_smbus_write_byte_data(&the_tps->client, 791 status = i2c_smbus_write_byte_data(&the_tps->client,
@@ -802,8 +798,9 @@ int tps65010_set_led(unsigned led, unsigned mode)
802 return status; 798 return status;
803 } 799 }
804 800
805 dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, 801 pr_debug("%s: led%i_per 0x%02x\n", DRIVER_NAME, led,
806 i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); 802 i2c_smbus_read_byte_data(&the_tps->client,
803 TPS_LED1_PER + offs));
807 804
808 up(&the_tps->lock); 805 up(&the_tps->lock);
809 806
@@ -874,7 +871,7 @@ int tps65010_set_low_pwr(unsigned mode)
874 871
875 if (status != 0) 872 if (status != 0)
876 printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", 873 printk(KERN_ERR "%s: Failed to write vdcdc1 register\n",
877 DRIVER_NAME); 874 DRIVER_NAME);
878 else 875 else
879 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, 876 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
880 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); 877 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
@@ -900,14 +897,14 @@ int tps65010_config_vregs1(unsigned value)
900 down(&the_tps->lock); 897 down(&the_tps->lock);
901 898
902 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, 899 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
903 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); 900 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
904 901
905 status = i2c_smbus_write_byte_data(&the_tps->client, 902 status = i2c_smbus_write_byte_data(&the_tps->client,
906 TPS_VREGS1, value); 903 TPS_VREGS1, value);
907 904
908 if (status != 0) 905 if (status != 0)
909 printk(KERN_ERR "%s: Failed to write vregs1 register\n", 906 printk(KERN_ERR "%s: Failed to write vregs1 register\n",
910 DRIVER_NAME); 907 DRIVER_NAME);
911 else 908 else
912 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, 909 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
913 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); 910 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
@@ -1009,7 +1006,7 @@ static int __init tps_init(void)
1009 msleep(10); 1006 msleep(10);
1010 } 1007 }
1011 1008
1012#if defined(CONFIG_ARM) 1009#ifdef CONFIG_ARM
1013 if (machine_is_omap_osk()) { 1010 if (machine_is_omap_osk()) {
1014 1011
1015 // FIXME: More should be placed in the initialization code 1012 // FIXME: More should be placed in the initialization code
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 51ce268998cd..4fd4f52c8e9b 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -156,7 +156,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
156 goto out_unlock; 156 goto out_unlock;
157 } 157 }
158 158
159 res = idr_get_new(&i2c_adapter_idr, NULL, &id); 159 res = idr_get_new(&i2c_adapter_idr, adap, &id);
160 if (res < 0) { 160 if (res < 0) {
161 if (res == -EAGAIN) 161 if (res == -EAGAIN)
162 res = -ENOMEM; 162 res = -ENOMEM;
@@ -765,20 +765,15 @@ int i2c_adapter_id(struct i2c_adapter *adap)
765 765
766struct i2c_adapter* i2c_get_adapter(int id) 766struct i2c_adapter* i2c_get_adapter(int id)
767{ 767{
768 struct list_head *item;
769 struct i2c_adapter *adapter; 768 struct i2c_adapter *adapter;
770 769
771 down(&core_lists); 770 down(&core_lists);
772 list_for_each(item,&adapters) { 771 adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
773 adapter = list_entry(item, struct i2c_adapter, list); 772 if (adapter && !try_module_get(adapter->owner))
774 if (id == adapter->nr && 773 adapter = NULL;
775 try_module_get(adapter->owner)) { 774
776 up(&core_lists);
777 return adapter;
778 }
779 }
780 up(&core_lists); 775 up(&core_lists);
781 return NULL; 776 return adapter;
782} 777}
783 778
784void i2c_put_adapter(struct i2c_adapter *adap) 779void i2c_put_adapter(struct i2c_adapter *adap)
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index 5be8ad6dc9ed..cca9c075966d 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -20,7 +20,6 @@ ide-core-$(CONFIG_BLK_DEV_CMD640) += pci/cmd640.o
20# Core IDE code - must come before legacy 20# Core IDE code - must come before legacy
21ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o 21ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o
22ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o 22ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o
23ide-core-$(CONFIG_BLK_DEV_IDE_TCQ) += ide-tcq.o
24ide-core-$(CONFIG_PROC_FS) += ide-proc.o 23ide-core-$(CONFIG_PROC_FS) += ide-proc.o
25ide-core-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o 24ide-core-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o
26 25
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 0a31cfda08a0..74af7e074868 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -431,7 +431,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
431#if VERBOSE_IDE_CD_ERRORS 431#if VERBOSE_IDE_CD_ERRORS
432 { 432 {
433 int i; 433 int i;
434 const char *s; 434 const char *s = "bad sense key!";
435 char buf[80]; 435 char buf[80];
436 436
437 printk ("ATAPI device %s:\n", drive->name); 437 printk ("ATAPI device %s:\n", drive->name);
@@ -446,8 +446,6 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
446 446
447 if (sense->sense_key < ARY_LEN(sense_key_texts)) 447 if (sense->sense_key < ARY_LEN(sense_key_texts))
448 s = sense_key_texts[sense->sense_key]; 448 s = sense_key_texts[sense->sense_key];
449 else
450 s = "bad sense key!";
451 449
452 printk("%s -- (Sense key=0x%02x)\n", s, sense->sense_key); 450 printk("%s -- (Sense key=0x%02x)\n", s, sense->sense_key);
453 451
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 6806d407e9c1..b09a6537c7a8 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -487,8 +487,7 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat)
487 u8 err = 0; 487 u8 err = 0;
488 488
489 local_irq_set(flags); 489 local_irq_set(flags);
490 printk("%s: %s: status=0x%02x", drive->name, msg, stat); 490 printk("%s: %s: status=0x%02x { ", drive->name, msg, stat);
491 printk(" { ");
492 if (stat & BUSY_STAT) 491 if (stat & BUSY_STAT)
493 printk("Busy "); 492 printk("Busy ");
494 else { 493 else {
@@ -500,15 +499,13 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat)
500 if (stat & INDEX_STAT) printk("Index "); 499 if (stat & INDEX_STAT) printk("Index ");
501 if (stat & ERR_STAT) printk("Error "); 500 if (stat & ERR_STAT) printk("Error ");
502 } 501 }
503 printk("}"); 502 printk("}\n");
504 printk("\n");
505 if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { 503 if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) {
506 err = hwif->INB(IDE_ERROR_REG); 504 err = hwif->INB(IDE_ERROR_REG);
507 printk("%s: %s: error=0x%02x", drive->name, msg, err); 505 printk("%s: %s: error=0x%02x { ", drive->name, msg, err);
508 printk(" { ");
509 if (err & ABRT_ERR) printk("DriveStatusError "); 506 if (err & ABRT_ERR) printk("DriveStatusError ");
510 if (err & ICRC_ERR) 507 if (err & ICRC_ERR)
511 printk("Bad%s ", (err & ABRT_ERR) ? "CRC" : "Sector"); 508 printk((err & ABRT_ERR) ? "BadCRC " : "BadSector ");
512 if (err & ECC_ERR) printk("UncorrectableError "); 509 if (err & ECC_ERR) printk("UncorrectableError ");
513 if (err & ID_ERR) printk("SectorIdNotFound "); 510 if (err & ID_ERR) printk("SectorIdNotFound ");
514 if (err & TRK0_ERR) printk("TrackZeroNotFound "); 511 if (err & TRK0_ERR) printk("TrackZeroNotFound ");
@@ -546,8 +543,8 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat)
546 printk(", sector=%llu", 543 printk(", sector=%llu",
547 (unsigned long long)HWGROUP(drive)->rq->sector); 544 (unsigned long long)HWGROUP(drive)->rq->sector);
548 } 545 }
546 printk("\n");
549 } 547 }
550 printk("\n");
551 ide_dump_opcode(drive); 548 ide_dump_opcode(drive);
552 local_irq_restore(flags); 549 local_irq_restore(flags);
553 return err; 550 return err;
diff --git a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c
index e884cd4b22fd..242029c9c0ca 100644
--- a/drivers/ide/legacy/hd.c
+++ b/drivers/ide/legacy/hd.c
@@ -156,11 +156,13 @@ else \
156 156
157 157
158#if (HD_DELAY > 0) 158#if (HD_DELAY > 0)
159
160#include <asm/i8253.h>
161
159unsigned long last_req; 162unsigned long last_req;
160 163
161unsigned long read_timer(void) 164unsigned long read_timer(void)
162{ 165{
163 extern spinlock_t i8253_lock;
164 unsigned long t, flags; 166 unsigned long t, flags;
165 int i; 167 int i;
166 168
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 978d27d6452d..aac59751e1b4 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -46,7 +46,6 @@
46#include <asm/io.h> 46#include <asm/io.h>
47#include <asm/system.h> 47#include <asm/system.h>
48 48
49#include <pcmcia/version.h>
50#include <pcmcia/cs_types.h> 49#include <pcmcia/cs_types.h>
51#include <pcmcia/cs.h> 50#include <pcmcia/cs.h>
52#include <pcmcia/cistpl.h> 51#include <pcmcia/cistpl.h>
@@ -134,11 +133,6 @@ static dev_link_t *ide_attach(void)
134 link->next = dev_list; 133 link->next = dev_list;
135 dev_list = link; 134 dev_list = link;
136 client_reg.dev_info = &dev_info; 135 client_reg.dev_info = &dev_info;
137 client_reg.EventMask =
138 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
139 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
140 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
141 client_reg.event_handler = &ide_event;
142 client_reg.Version = 0x0210; 136 client_reg.Version = 0x0210;
143 client_reg.event_callback_args.client_data = link; 137 client_reg.event_callback_args.client_data = link;
144 ret = pcmcia_register_client(&link->handle, &client_reg); 138 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -497,6 +491,7 @@ static struct pcmcia_driver ide_cs_driver = {
497 .name = "ide-cs", 491 .name = "ide-cs",
498 }, 492 },
499 .attach = ide_attach, 493 .attach = ide_attach,
494 .event = ide_event,
500 .detach = ide_detach, 495 .detach = ide_detach,
501 .id_table = ide_ids, 496 .id_table = ide_ids,
502}; 497};
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 67efb38a9f6c..6cf49394a80f 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -583,7 +583,7 @@ static int ali15x3_dma_setup(ide_drive_t *drive)
583 * appropriate also sets up the 1533 southbridge. 583 * appropriate also sets up the 1533 southbridge.
584 */ 584 */
585 585
586static unsigned int __init init_chipset_ali15x3 (struct pci_dev *dev, const char *name) 586static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const char *name)
587{ 587{
588 unsigned long flags; 588 unsigned long flags;
589 u8 tmpbyte; 589 u8 tmpbyte;
@@ -677,7 +677,7 @@ static unsigned int __init init_chipset_ali15x3 (struct pci_dev *dev, const char
677 * FIXME: frobs bits that are not defined on newer ALi devicea 677 * FIXME: frobs bits that are not defined on newer ALi devicea
678 */ 678 */
679 679
680static unsigned int __init ata66_ali15x3 (ide_hwif_t *hwif) 680static unsigned int __devinit ata66_ali15x3 (ide_hwif_t *hwif)
681{ 681{
682 struct pci_dev *dev = hwif->pci_dev; 682 struct pci_dev *dev = hwif->pci_dev;
683 unsigned int ata66 = 0; 683 unsigned int ata66 = 0;
@@ -748,7 +748,7 @@ static unsigned int __init ata66_ali15x3 (ide_hwif_t *hwif)
748 * Initialize the IDE structure side of the ALi 15x3 driver. 748 * Initialize the IDE structure side of the ALi 15x3 driver.
749 */ 749 */
750 750
751static void __init init_hwif_common_ali15x3 (ide_hwif_t *hwif) 751static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
752{ 752{
753 hwif->autodma = 0; 753 hwif->autodma = 0;
754 hwif->tuneproc = &ali15x3_tune_drive; 754 hwif->tuneproc = &ali15x3_tune_drive;
@@ -794,7 +794,7 @@ static void __init init_hwif_common_ali15x3 (ide_hwif_t *hwif)
794 * Sparc systems 794 * Sparc systems
795 */ 795 */
796 796
797static void __init init_hwif_ali15x3 (ide_hwif_t *hwif) 797static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif)
798{ 798{
799 u8 ideic, inmir; 799 u8 ideic, inmir;
800 s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6, 800 s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6,
@@ -847,7 +847,7 @@ static void __init init_hwif_ali15x3 (ide_hwif_t *hwif)
847 * the actual work. 847 * the actual work.
848 */ 848 */
849 849
850static void __init init_dma_ali15x3 (ide_hwif_t *hwif, unsigned long dmabase) 850static void __devinit init_dma_ali15x3 (ide_hwif_t *hwif, unsigned long dmabase)
851{ 851{
852 if (m5229_revision < 0x20) 852 if (m5229_revision < 0x20)
853 return; 853 return;
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index 4e0f13d1d060..844a6c9fb949 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -73,6 +73,7 @@ static struct amd_ide_chip {
73 { PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, 0x50, AMD_UDMA_133 }, 73 { PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, 0x50, AMD_UDMA_133 },
74 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, 0x50, AMD_UDMA_133 }, 74 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, 0x50, AMD_UDMA_133 },
75 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, 0x50, AMD_UDMA_133 }, 75 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, 0x50, AMD_UDMA_133 },
76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, AMD_UDMA_133 },
76 { 0 } 77 { 0 }
77}; 78};
78 79
@@ -309,7 +310,7 @@ static int amd74xx_ide_dma_check(ide_drive_t *drive)
309 * and initialize its drive independent registers. 310 * and initialize its drive independent registers.
310 */ 311 */
311 312
312static unsigned int __init init_chipset_amd74xx(struct pci_dev *dev, const char *name) 313static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, const char *name)
313{ 314{
314 unsigned char t; 315 unsigned char t;
315 unsigned int u; 316 unsigned int u;
@@ -413,7 +414,7 @@ static unsigned int __init init_chipset_amd74xx(struct pci_dev *dev, const char
413 return dev->irq; 414 return dev->irq;
414} 415}
415 416
416static void __init init_hwif_amd74xx(ide_hwif_t *hwif) 417static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
417{ 418{
418 int i; 419 int i;
419 420
@@ -489,6 +490,7 @@ static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
489 /* 13 */ DECLARE_NV_DEV("NFORCE-CK804"), 490 /* 13 */ DECLARE_NV_DEV("NFORCE-CK804"),
490 /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04"), 491 /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04"),
491 /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51"), 492 /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51"),
493 /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55"),
492}; 494};
493 495
494static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 496static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -524,6 +526,7 @@ static struct pci_device_id amd74xx_pci_tbl[] = {
524 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 }, 526 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 },
525 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 }, 527 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 },
526 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 }, 528 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 },
529 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 },
527 { 0, }, 530 { 0, },
528}; 531};
529MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 532MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
index 0381961db263..09269e574b3e 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/pci/cs5530.c
@@ -217,7 +217,7 @@ static int cs5530_config_dma (ide_drive_t *drive)
217 * Initialize the cs5530 bridge for reliable IDE DMA operation. 217 * Initialize the cs5530 bridge for reliable IDE DMA operation.
218 */ 218 */
219 219
220static unsigned int __init init_chipset_cs5530 (struct pci_dev *dev, const char *name) 220static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const char *name)
221{ 221{
222 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; 222 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL;
223 unsigned long flags; 223 unsigned long flags;
@@ -308,7 +308,7 @@ static unsigned int __init init_chipset_cs5530 (struct pci_dev *dev, const char
308 * performs channel-specific pre-initialization before drive probing. 308 * performs channel-specific pre-initialization before drive probing.
309 */ 309 */
310 310
311static void __init init_hwif_cs5530 (ide_hwif_t *hwif) 311static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif)
312{ 312{
313 unsigned long basereg; 313 unsigned long basereg;
314 u32 d0_timings; 314 u32 d0_timings;
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index 80d67e99ccb5..5a33513f3dd1 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -391,7 +391,7 @@ static void cy82c693_tune_drive (ide_drive_t *drive, u8 pio)
391/* 391/*
392 * this function is called during init and is used to setup the cy82c693 chip 392 * this function is called during init and is used to setup the cy82c693 chip
393 */ 393 */
394static unsigned int __init init_chipset_cy82c693(struct pci_dev *dev, const char *name) 394static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const char *name)
395{ 395{
396 if (PCI_FUNC(dev->devfn) != 1) 396 if (PCI_FUNC(dev->devfn) != 1)
397 return 0; 397 return 0;
@@ -443,7 +443,7 @@ static unsigned int __init init_chipset_cy82c693(struct pci_dev *dev, const char
443/* 443/*
444 * the init function - called for each ide channel once 444 * the init function - called for each ide channel once
445 */ 445 */
446static void __init init_hwif_cy82c693(ide_hwif_t *hwif) 446static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif)
447{ 447{
448 hwif->autodma = 0; 448 hwif->autodma = 0;
449 449
@@ -467,9 +467,9 @@ static void __init init_hwif_cy82c693(ide_hwif_t *hwif)
467 hwif->drives[1].autodma = hwif->autodma; 467 hwif->drives[1].autodma = hwif->autodma;
468} 468}
469 469
470static __initdata ide_hwif_t *primary; 470static __devinitdata ide_hwif_t *primary;
471 471
472void __init init_iops_cy82c693(ide_hwif_t *hwif) 472void __devinit init_iops_cy82c693(ide_hwif_t *hwif)
473{ 473{
474 if (PCI_FUNC(hwif->pci_dev->devfn) == 1) 474 if (PCI_FUNC(hwif->pci_dev->devfn) == 1)
475 primary = hwif; 475 primary = hwif;
diff --git a/drivers/ide/pci/it8172.c b/drivers/ide/pci/it8172.c
index 631927cf17d4..93462926b9d5 100644
--- a/drivers/ide/pci/it8172.c
+++ b/drivers/ide/pci/it8172.c
@@ -216,7 +216,7 @@ fast_ata_pio:
216 return 0; 216 return 0;
217} 217}
218 218
219static unsigned int __init init_chipset_it8172 (struct pci_dev *dev, const char *name) 219static unsigned int __devinit init_chipset_it8172 (struct pci_dev *dev, const char *name)
220{ 220{
221 unsigned char progif; 221 unsigned char progif;
222 222
@@ -230,7 +230,7 @@ static unsigned int __init init_chipset_it8172 (struct pci_dev *dev, const char
230} 230}
231 231
232 232
233static void __init init_hwif_it8172 (ide_hwif_t *hwif) 233static void __devinit init_hwif_it8172 (ide_hwif_t *hwif)
234{ 234{
235 struct pci_dev* dev = hwif->pci_dev; 235 struct pci_dev* dev = hwif->pci_dev;
236 unsigned long cmdBase, ctrlBase; 236 unsigned long cmdBase, ctrlBase;
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index 205a32fbc2f0..fcd5142f5cfe 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -195,7 +195,7 @@ static int ns87415_ide_dma_check (ide_drive_t *drive)
195 return __ide_dma_check(drive); 195 return __ide_dma_check(drive);
196} 196}
197 197
198static void __init init_hwif_ns87415 (ide_hwif_t *hwif) 198static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
199{ 199{
200 struct pci_dev *dev = hwif->pci_dev; 200 struct pci_dev *dev = hwif->pci_dev;
201 unsigned int ctrl, using_inta; 201 unsigned int ctrl, using_inta;
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
index cf4fd91d396a..7a7c2ef78ac2 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -326,7 +326,7 @@ static void opti621_tune_drive (ide_drive_t *drive, u8 pio)
326/* 326/*
327 * init_hwif_opti621() is called once for each hwif found at boot. 327 * init_hwif_opti621() is called once for each hwif found at boot.
328 */ 328 */
329static void __init init_hwif_opti621 (ide_hwif_t *hwif) 329static void __devinit init_hwif_opti621 (ide_hwif_t *hwif)
330{ 330{
331 hwif->autodma = 0; 331 hwif->autodma = 0;
332 hwif->drives[0].drive_data = PIO_DONT_KNOW; 332 hwif->drives[0].drive_data = PIO_DONT_KNOW;
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index 3bc3bf1be49b..10592cec6c43 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -459,7 +459,7 @@ printk("%s: SC1200: resume\n", hwif->name);
459 * This gets invoked by the IDE driver once for each channel, 459 * This gets invoked by the IDE driver once for each channel,
460 * and performs channel-specific pre-initialization before drive probing. 460 * and performs channel-specific pre-initialization before drive probing.
461 */ 461 */
462static void __init init_hwif_sc1200 (ide_hwif_t *hwif) 462static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif)
463{ 463{
464 if (hwif->mate) 464 if (hwif->mate)
465 hwif->serialized = hwif->mate->serialized = 1; 465 hwif->serialized = hwif->mate->serialized = 1;
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index 1d970a0de21a..ea0806c82be0 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -386,7 +386,7 @@ static unsigned int sl82c105_bridge_revision(struct pci_dev *dev)
386 * channel 0 here at least, but channel 1 has to be enabled by 386 * channel 0 here at least, but channel 1 has to be enabled by
387 * firmware or arch code. We still set both to 16 bits mode. 387 * firmware or arch code. We still set both to 16 bits mode.
388 */ 388 */
389static unsigned int __init init_chipset_sl82c105(struct pci_dev *dev, const char *msg) 389static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const char *msg)
390{ 390{
391 u32 val; 391 u32 val;
392 392
@@ -399,7 +399,7 @@ static unsigned int __init init_chipset_sl82c105(struct pci_dev *dev, const char
399 return dev->irq; 399 return dev->irq;
400} 400}
401 401
402static void __init init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base) 402static void __devinit init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base)
403{ 403{
404 unsigned int rev; 404 unsigned int rev;
405 u8 dma_state; 405 u8 dma_state;
@@ -431,7 +431,7 @@ static void __init init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base)
431 * Initialise the chip 431 * Initialise the chip
432 */ 432 */
433 433
434static void __init init_hwif_sl82c105(ide_hwif_t *hwif) 434static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
435{ 435{
436 struct pci_dev *dev = hwif->pci_dev; 436 struct pci_dev *dev = hwif->pci_dev;
437 u32 val; 437 u32 val;
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index 7fbf36342f73..5112c726633b 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -196,7 +196,7 @@ fast_ata_pio:
196} 196}
197#endif /* CONFIG_BLK_DEV_IDEDMA */ 197#endif /* CONFIG_BLK_DEV_IDEDMA */
198 198
199static void __init init_hwif_slc90e66 (ide_hwif_t *hwif) 199static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
200{ 200{
201 u8 reg47 = 0; 201 u8 reg47 = 0;
202 u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */ 202 u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index a1df2bfe3631..f96b56838f33 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -130,7 +130,7 @@ static int triflex_config_drive_xfer_rate(ide_drive_t *drive)
130 return hwif->ide_dma_off_quietly(drive); 130 return hwif->ide_dma_off_quietly(drive);
131} 131}
132 132
133static void __init init_hwif_triflex(ide_hwif_t *hwif) 133static void __devinit init_hwif_triflex(ide_hwif_t *hwif)
134{ 134{
135 hwif->tuneproc = &triflex_tune_drive; 135 hwif->tuneproc = &triflex_tune_drive;
136 hwif->speedproc = &triflex_tune_chipset; 136 hwif->speedproc = &triflex_tune_chipset;
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index 069dbffe2116..a4d099c937ff 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -415,7 +415,7 @@ static int via82cxxx_ide_dma_check (ide_drive_t *drive)
415 * and initialize its drive independent registers. 415 * and initialize its drive independent registers.
416 */ 416 */
417 417
418static unsigned int __init init_chipset_via82cxxx(struct pci_dev *dev, const char *name) 418static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name)
419{ 419{
420 struct pci_dev *isa = NULL; 420 struct pci_dev *isa = NULL;
421 u8 t, v; 421 u8 t, v;
@@ -576,7 +576,7 @@ static unsigned int __init init_chipset_via82cxxx(struct pci_dev *dev, const cha
576 return 0; 576 return 0;
577} 577}
578 578
579static void __init init_hwif_via82cxxx(ide_hwif_t *hwif) 579static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
580{ 580{
581 int i; 581 int i;
582 582
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 818380b5fd27..be0fcc8f4b15 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1419,7 +1419,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1419 * Attach to a macio probed interface 1419 * Attach to a macio probed interface
1420 */ 1420 */
1421static int __devinit 1421static int __devinit
1422pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_match *match) 1422pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1423{ 1423{
1424 void __iomem *base; 1424 void __iomem *base;
1425 unsigned long regbase; 1425 unsigned long regbase;
@@ -1637,27 +1637,19 @@ pmac_ide_pci_resume(struct pci_dev *pdev)
1637 return rc; 1637 return rc;
1638} 1638}
1639 1639
1640static struct of_match pmac_ide_macio_match[] = 1640static struct of_device_id pmac_ide_macio_match[] =
1641{ 1641{
1642 { 1642 {
1643 .name = "IDE", 1643 .name = "IDE",
1644 .type = OF_ANY_MATCH,
1645 .compatible = OF_ANY_MATCH
1646 }, 1644 },
1647 { 1645 {
1648 .name = "ATA", 1646 .name = "ATA",
1649 .type = OF_ANY_MATCH,
1650 .compatible = OF_ANY_MATCH
1651 }, 1647 },
1652 { 1648 {
1653 .name = OF_ANY_MATCH,
1654 .type = "ide", 1649 .type = "ide",
1655 .compatible = OF_ANY_MATCH
1656 }, 1650 },
1657 { 1651 {
1658 .name = OF_ANY_MATCH,
1659 .type = "ata", 1652 .type = "ata",
1660 .compatible = OF_ANY_MATCH
1661 }, 1653 },
1662 {}, 1654 {},
1663}; 1655};
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index e501675ad72e..77da827b2898 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -847,7 +847,7 @@ static int __init ide_scan_pcidev(struct pci_dev *dev)
847 d = list_entry(l, struct pci_driver, node); 847 d = list_entry(l, struct pci_driver, node);
848 if(d->id_table) 848 if(d->id_table)
849 { 849 {
850 const struct pci_device_id *id = pci_match_device(d->id_table, dev); 850 const struct pci_device_id *id = pci_match_id(d->id_table, dev);
851 if(id != NULL) 851 if(id != NULL)
852 { 852 {
853 if(d->probe(dev, id) >= 0) 853 if(d->probe(dev, id) >= 0)
diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig
index 7d58af1ae306..25103a0ef9b3 100644
--- a/drivers/ieee1394/Kconfig
+++ b/drivers/ieee1394/Kconfig
@@ -66,6 +66,18 @@ config IEEE1394_CONFIG_ROM_IP1394
66 with MacOSX and WinXP IP-over-1394), enable this option and the 66 with MacOSX and WinXP IP-over-1394), enable this option and the
67 eth1394 option below. 67 eth1394 option below.
68 68
69config IEEE1394_EXPORT_FULL_API
70 bool "Export all symbols of ieee1394's API"
71 depends on IEEE1394
72 default n
73 help
74 Export all symbols of ieee1394's driver programming interface, even
75 those that are not currently used by the standard IEEE 1394 drivers.
76
77 This option does not affect the interface to userspace applications.
78 Say Y here if you want to compile externally developed drivers that
79 make extended use of ieee1394's API. It is otherwise safe to say N.
80
69comment "Device Drivers" 81comment "Device Drivers"
70 depends on IEEE1394 82 depends on IEEE1394
71 83
diff --git a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c
index 1b98684aebcd..149573db91c5 100644
--- a/drivers/ieee1394/csr.c
+++ b/drivers/ieee1394/csr.c
@@ -28,6 +28,7 @@
28#include "hosts.h" 28#include "hosts.h"
29#include "ieee1394.h" 29#include "ieee1394.h"
30#include "highlevel.h" 30#include "highlevel.h"
31#include "ieee1394_core.h"
31 32
32/* Module Parameters */ 33/* Module Parameters */
33/* this module parameter can be used to disable mapping of the FCP registers */ 34/* this module parameter can be used to disable mapping of the FCP registers */
@@ -232,7 +233,7 @@ static void add_host(struct hpsb_host *host)
232 host->csr.generation = 2; 233 host->csr.generation = 2;
233 234
234 bus_info[1] = __constant_cpu_to_be32(0x31333934); 235 bus_info[1] = __constant_cpu_to_be32(0x31333934);
235 bus_info[2] = cpu_to_be32((1 << CSR_IRMC_SHIFT) | 236 bus_info[2] = cpu_to_be32((hpsb_disable_irm ? 0 : 1 << CSR_IRMC_SHIFT) |
236 (1 << CSR_CMC_SHIFT) | 237 (1 << CSR_CMC_SHIFT) |
237 (1 << CSR_ISC_SHIFT) | 238 (1 << CSR_ISC_SHIFT) |
238 (0 << CSR_BMC_SHIFT) | 239 (0 << CSR_BMC_SHIFT) |
diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c
index 7c4330e2e875..61ddd5d37eff 100644
--- a/drivers/ieee1394/csr1212.c
+++ b/drivers/ieee1394/csr1212.c
@@ -209,7 +209,15 @@ void csr1212_init_local_csr(struct csr1212_csr *csr,
209{ 209{
210 static const int mr_map[] = { 4, 64, 1024, 0 }; 210 static const int mr_map[] = { 4, 64, 1024, 0 };
211 211
212#ifdef __KERNEL__
213 BUG_ON(max_rom & ~0x3);
212 csr->max_rom = mr_map[max_rom]; 214 csr->max_rom = mr_map[max_rom];
215#else
216 if (max_rom & ~0x3) /* caller supplied invalid argument */
217 csr->max_rom = 0;
218 else
219 csr->max_rom = mr_map[max_rom];
220#endif
213 memcpy(csr->bus_info_data, bus_info_data, csr->bus_info_len); 221 memcpy(csr->bus_info_data, bus_info_data, csr->bus_info_len);
214} 222}
215 223
@@ -533,12 +541,15 @@ struct csr1212_keyval *csr1212_new_icon_descriptor_leaf(u_int32_t version,
533 static const int pd[4] = { 0, 4, 16, 256 }; 541 static const int pd[4] = { 0, 4, 16, 256 };
534 static const int cs[16] = { 4, 2 }; 542 static const int cs[16] = { 4, 2 };
535 struct csr1212_keyval *kv; 543 struct csr1212_keyval *kv;
536 int palette_size = pd[palette_depth] * cs[color_space]; 544 int palette_size;
537 int pixel_size = (hscan * vscan + 3) & ~0x3; 545 int pixel_size = (hscan * vscan + 3) & ~0x3;
538 546
539 if ((palette_depth && !palette) || !pixels) 547 if (!pixels || (!palette && palette_depth) ||
548 (palette_depth & ~0x3) || (color_space & ~0xf))
540 return NULL; 549 return NULL;
541 550
551 palette_size = pd[palette_depth] * cs[color_space];
552
542 kv = csr1212_new_descriptor_leaf(1, 0, NULL, 553 kv = csr1212_new_descriptor_leaf(1, 0, NULL,
543 palette_size + pixel_size + 554 palette_size + pixel_size +
544 CSR1212_ICON_DESCRIPTOR_LEAF_OVERHEAD); 555 CSR1212_ICON_DESCRIPTOR_LEAF_OVERHEAD);
@@ -760,9 +771,9 @@ static int csr1212_append_new_cache(struct csr1212_csr *csr, size_t romsize)
760 struct csr1212_csr_rom_cache *cache; 771 struct csr1212_csr_rom_cache *cache;
761 u_int64_t csr_addr; 772 u_int64_t csr_addr;
762 773
763 if (!csr || !csr->ops->allocate_addr_range || 774 if (!csr || !csr->ops || !csr->ops->allocate_addr_range ||
764 !csr->ops->release_addr) 775 !csr->ops->release_addr || csr->max_rom < 1)
765 return CSR1212_ENOMEM; 776 return CSR1212_EINVAL;
766 777
767 /* ROM size must be a multiple of csr->max_rom */ 778 /* ROM size must be a multiple of csr->max_rom */
768 romsize = (romsize + (csr->max_rom - 1)) & ~(csr->max_rom - 1); 779 romsize = (romsize + (csr->max_rom - 1)) & ~(csr->max_rom - 1);
@@ -1145,6 +1156,8 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr)
1145 1156
1146 /* Make sure the Extended ROM leaf is a multiple of 1157 /* Make sure the Extended ROM leaf is a multiple of
1147 * max_rom in size. */ 1158 * max_rom in size. */
1159 if (csr->max_rom < 1)
1160 return CSR1212_EINVAL;
1148 leaf_size = (cache->len + (csr->max_rom - 1)) & 1161 leaf_size = (cache->len + (csr->max_rom - 1)) &
1149 ~(csr->max_rom - 1); 1162 ~(csr->max_rom - 1);
1150 1163
@@ -1409,7 +1422,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1409 u_int32_t *cache_ptr; 1422 u_int32_t *cache_ptr;
1410 u_int16_t kv_len = 0; 1423 u_int16_t kv_len = 0;
1411 1424
1412 if (!csr || !kv) 1425 if (!csr || !kv || csr->max_rom < 1)
1413 return CSR1212_EINVAL; 1426 return CSR1212_EINVAL;
1414 1427
1415 /* First find which cache the data should be in (or go in if not read 1428 /* First find which cache the data should be in (or go in if not read
@@ -1572,7 +1585,7 @@ int csr1212_parse_csr(struct csr1212_csr *csr)
1572 struct csr1212_dentry *dentry; 1585 struct csr1212_dentry *dentry;
1573 int ret; 1586 int ret;
1574 1587
1575 if (!csr || !csr->ops->bus_read) 1588 if (!csr || !csr->ops || !csr->ops->bus_read)
1576 return CSR1212_EINVAL; 1589 return CSR1212_EINVAL;
1577 1590
1578 ret = csr1212_parse_bus_info_block(csr); 1591 ret = csr1212_parse_bus_info_block(csr);
@@ -1581,9 +1594,13 @@ int csr1212_parse_csr(struct csr1212_csr *csr)
1581 1594
1582 if (!csr->ops->get_max_rom) 1595 if (!csr->ops->get_max_rom)
1583 csr->max_rom = mr_map[0]; /* default value */ 1596 csr->max_rom = mr_map[0]; /* default value */
1584 else 1597 else {
1585 csr->max_rom = mr_map[csr->ops->get_max_rom(csr->bus_info_data, 1598 int i = csr->ops->get_max_rom(csr->bus_info_data,
1586 csr->private)]; 1599 csr->private);
1600 if (i & ~0x3)
1601 return CSR1212_EINVAL;
1602 csr->max_rom = mr_map[i];
1603 }
1587 1604
1588 csr->cache_head->layout_head = csr->root_kv; 1605 csr->cache_head->layout_head = csr->root_kv;
1589 csr->cache_head->layout_tail = csr->root_kv; 1606 csr->cache_head->layout_tail = csr->root_kv;
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c
index 758819d1999d..b79ddb43e746 100644
--- a/drivers/ieee1394/dma.c
+++ b/drivers/ieee1394/dma.c
@@ -158,7 +158,7 @@ static inline int dma_region_find(struct dma_region *dma, unsigned long offset,
158 158
159dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset) 159dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset)
160{ 160{
161 unsigned long rem; 161 unsigned long rem = 0;
162 162
163 struct scatterlist *sg = &dma->sglist[dma_region_find(dma, offset, &rem)]; 163 struct scatterlist *sg = &dma->sglist[dma_region_find(dma, offset, &rem)];
164 return sg_dma_address(sg) + rem; 164 return sg_dma_address(sg) + rem;
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 654da76bf811..cd53c174ced1 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -89,7 +89,7 @@
89#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__) 89#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
90 90
91static char version[] __devinitdata = 91static char version[] __devinitdata =
92 "$Rev: 1247 $ Ben Collins <bcollins@debian.org>"; 92 "$Rev: 1264 $ Ben Collins <bcollins@debian.org>";
93 93
94struct fragment_info { 94struct fragment_info {
95 struct list_head list; 95 struct list_head list;
@@ -706,7 +706,7 @@ static void ether1394_host_reset (struct hpsb_host *host)
706 return; 706 return;
707 707
708 dev = hi->dev; 708 dev = hi->dev;
709 priv = netdev_priv(dev); 709 priv = (struct eth1394_priv *)netdev_priv(dev);
710 710
711 /* Reset our private host data, but not our mtu */ 711 /* Reset our private host data, but not our mtu */
712 netif_stop_queue (dev); 712 netif_stop_queue (dev);
@@ -1770,7 +1770,7 @@ fail:
1770static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1770static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1771{ 1771{
1772 strcpy (info->driver, driver_name); 1772 strcpy (info->driver, driver_name);
1773 strcpy (info->version, "$Rev: 1247 $"); 1773 strcpy (info->version, "$Rev: 1264 $");
1774 /* FIXME XXX provide sane businfo */ 1774 /* FIXME XXX provide sane businfo */
1775 strcpy (info->bus_info, "ieee1394"); 1775 strcpy (info->bus_info, "ieee1394");
1776} 1776}
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 629070b83a33..b248d89de8b4 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -52,7 +52,7 @@
52/* 52/*
53 * Disable the nodemgr detection and config rom reading functionality. 53 * Disable the nodemgr detection and config rom reading functionality.
54 */ 54 */
55static int disable_nodemgr = 0; 55static int disable_nodemgr;
56module_param(disable_nodemgr, int, 0444); 56module_param(disable_nodemgr, int, 0444);
57MODULE_PARM_DESC(disable_nodemgr, "Disable nodemgr functionality."); 57MODULE_PARM_DESC(disable_nodemgr, "Disable nodemgr functionality.");
58 58
@@ -520,6 +520,9 @@ int hpsb_send_packet(struct hpsb_packet *packet)
520 520
521 if (!packet->no_waiter || packet->expect_response) { 521 if (!packet->no_waiter || packet->expect_response) {
522 atomic_inc(&packet->refcnt); 522 atomic_inc(&packet->refcnt);
523 /* Set the initial "sendtime" to 10 seconds from now, to
524 prevent premature expiry. If a packet takes more than
525 10 seconds to hit the wire, we have bigger problems :) */
523 packet->sendtime = jiffies + 10 * HZ; 526 packet->sendtime = jiffies + 10 * HZ;
524 skb_queue_tail(&host->pending_packet_queue, packet->skb); 527 skb_queue_tail(&host->pending_packet_queue, packet->skb);
525 } 528 }
@@ -1223,9 +1226,7 @@ EXPORT_SYMBOL(hpsb_protocol_class);
1223EXPORT_SYMBOL(hpsb_set_packet_complete_task); 1226EXPORT_SYMBOL(hpsb_set_packet_complete_task);
1224EXPORT_SYMBOL(hpsb_alloc_packet); 1227EXPORT_SYMBOL(hpsb_alloc_packet);
1225EXPORT_SYMBOL(hpsb_free_packet); 1228EXPORT_SYMBOL(hpsb_free_packet);
1226EXPORT_SYMBOL(hpsb_send_phy_config);
1227EXPORT_SYMBOL(hpsb_send_packet); 1229EXPORT_SYMBOL(hpsb_send_packet);
1228EXPORT_SYMBOL(hpsb_send_packet_and_wait);
1229EXPORT_SYMBOL(hpsb_reset_bus); 1230EXPORT_SYMBOL(hpsb_reset_bus);
1230EXPORT_SYMBOL(hpsb_bus_reset); 1231EXPORT_SYMBOL(hpsb_bus_reset);
1231EXPORT_SYMBOL(hpsb_selfid_received); 1232EXPORT_SYMBOL(hpsb_selfid_received);
@@ -1233,6 +1234,10 @@ EXPORT_SYMBOL(hpsb_selfid_complete);
1233EXPORT_SYMBOL(hpsb_packet_sent); 1234EXPORT_SYMBOL(hpsb_packet_sent);
1234EXPORT_SYMBOL(hpsb_packet_received); 1235EXPORT_SYMBOL(hpsb_packet_received);
1235EXPORT_SYMBOL_GPL(hpsb_disable_irm); 1236EXPORT_SYMBOL_GPL(hpsb_disable_irm);
1237#ifdef CONFIG_IEEE1394_EXPORT_FULL_API
1238EXPORT_SYMBOL(hpsb_send_phy_config);
1239EXPORT_SYMBOL(hpsb_send_packet_and_wait);
1240#endif
1236 1241
1237/** ieee1394_transactions.c **/ 1242/** ieee1394_transactions.c **/
1238EXPORT_SYMBOL(hpsb_get_tlabel); 1243EXPORT_SYMBOL(hpsb_get_tlabel);
@@ -1262,9 +1267,11 @@ EXPORT_SYMBOL(hpsb_destroy_hostinfo);
1262EXPORT_SYMBOL(hpsb_set_hostinfo_key); 1267EXPORT_SYMBOL(hpsb_set_hostinfo_key);
1263EXPORT_SYMBOL(hpsb_get_hostinfo_bykey); 1268EXPORT_SYMBOL(hpsb_get_hostinfo_bykey);
1264EXPORT_SYMBOL(hpsb_set_hostinfo); 1269EXPORT_SYMBOL(hpsb_set_hostinfo);
1270EXPORT_SYMBOL(highlevel_host_reset);
1271#ifdef CONFIG_IEEE1394_EXPORT_FULL_API
1265EXPORT_SYMBOL(highlevel_add_host); 1272EXPORT_SYMBOL(highlevel_add_host);
1266EXPORT_SYMBOL(highlevel_remove_host); 1273EXPORT_SYMBOL(highlevel_remove_host);
1267EXPORT_SYMBOL(highlevel_host_reset); 1274#endif
1268 1275
1269/** nodemgr.c **/ 1276/** nodemgr.c **/
1270EXPORT_SYMBOL(hpsb_node_fill_packet); 1277EXPORT_SYMBOL(hpsb_node_fill_packet);
@@ -1272,7 +1279,9 @@ EXPORT_SYMBOL(hpsb_node_write);
1272EXPORT_SYMBOL(hpsb_register_protocol); 1279EXPORT_SYMBOL(hpsb_register_protocol);
1273EXPORT_SYMBOL(hpsb_unregister_protocol); 1280EXPORT_SYMBOL(hpsb_unregister_protocol);
1274EXPORT_SYMBOL(ieee1394_bus_type); 1281EXPORT_SYMBOL(ieee1394_bus_type);
1282#ifdef CONFIG_IEEE1394_EXPORT_FULL_API
1275EXPORT_SYMBOL(nodemgr_for_each_host); 1283EXPORT_SYMBOL(nodemgr_for_each_host);
1284#endif
1276 1285
1277/** csr.c **/ 1286/** csr.c **/
1278EXPORT_SYMBOL(hpsb_update_config_rom); 1287EXPORT_SYMBOL(hpsb_update_config_rom);
@@ -1309,19 +1318,21 @@ EXPORT_SYMBOL(hpsb_iso_wake);
1309EXPORT_SYMBOL(hpsb_iso_recv_flush); 1318EXPORT_SYMBOL(hpsb_iso_recv_flush);
1310 1319
1311/** csr1212.c **/ 1320/** csr1212.c **/
1312EXPORT_SYMBOL(csr1212_create_csr);
1313EXPORT_SYMBOL(csr1212_init_local_csr);
1314EXPORT_SYMBOL(csr1212_new_immediate);
1315EXPORT_SYMBOL(csr1212_new_directory); 1321EXPORT_SYMBOL(csr1212_new_directory);
1316EXPORT_SYMBOL(csr1212_associate_keyval);
1317EXPORT_SYMBOL(csr1212_attach_keyval_to_directory); 1322EXPORT_SYMBOL(csr1212_attach_keyval_to_directory);
1318EXPORT_SYMBOL(csr1212_new_string_descriptor_leaf);
1319EXPORT_SYMBOL(csr1212_detach_keyval_from_directory); 1323EXPORT_SYMBOL(csr1212_detach_keyval_from_directory);
1320EXPORT_SYMBOL(csr1212_release_keyval); 1324EXPORT_SYMBOL(csr1212_release_keyval);
1321EXPORT_SYMBOL(csr1212_destroy_csr);
1322EXPORT_SYMBOL(csr1212_read); 1325EXPORT_SYMBOL(csr1212_read);
1323EXPORT_SYMBOL(csr1212_generate_csr_image);
1324EXPORT_SYMBOL(csr1212_parse_keyval); 1326EXPORT_SYMBOL(csr1212_parse_keyval);
1325EXPORT_SYMBOL(csr1212_parse_csr);
1326EXPORT_SYMBOL(_csr1212_read_keyval); 1327EXPORT_SYMBOL(_csr1212_read_keyval);
1327EXPORT_SYMBOL(_csr1212_destroy_keyval); 1328EXPORT_SYMBOL(_csr1212_destroy_keyval);
1329#ifdef CONFIG_IEEE1394_EXPORT_FULL_API
1330EXPORT_SYMBOL(csr1212_create_csr);
1331EXPORT_SYMBOL(csr1212_init_local_csr);
1332EXPORT_SYMBOL(csr1212_new_immediate);
1333EXPORT_SYMBOL(csr1212_associate_keyval);
1334EXPORT_SYMBOL(csr1212_new_string_descriptor_leaf);
1335EXPORT_SYMBOL(csr1212_destroy_csr);
1336EXPORT_SYMBOL(csr1212_generate_csr_image);
1337EXPORT_SYMBOL(csr1212_parse_csr);
1338#endif
diff --git a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h
index 73bd8efd2b6c..0b31429d0a68 100644
--- a/drivers/ieee1394/ieee1394_core.h
+++ b/drivers/ieee1394/ieee1394_core.h
@@ -38,8 +38,8 @@ struct hpsb_packet {
38 38
39 /* These are core internal. */ 39 /* These are core internal. */
40 signed char tlabel; 40 signed char tlabel;
41 char ack_code; 41 signed char ack_code;
42 char tcode; 42 unsigned char tcode;
43 43
44 unsigned expect_response:1; 44 unsigned expect_response:1;
45 unsigned no_waiter:1; 45 unsigned no_waiter:1;
diff --git a/drivers/ieee1394/iso.c b/drivers/ieee1394/iso.c
index f05759107f7e..615541b8b90f 100644
--- a/drivers/ieee1394/iso.c
+++ b/drivers/ieee1394/iso.c
@@ -62,10 +62,10 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i
62 if ((dma_mode < HPSB_ISO_DMA_DEFAULT) || (dma_mode > HPSB_ISO_DMA_PACKET_PER_BUFFER)) 62 if ((dma_mode < HPSB_ISO_DMA_DEFAULT) || (dma_mode > HPSB_ISO_DMA_PACKET_PER_BUFFER))
63 dma_mode=HPSB_ISO_DMA_DEFAULT; 63 dma_mode=HPSB_ISO_DMA_DEFAULT;
64 64
65 if ((irq_interval < 0) || (irq_interval > buf_packets / 4))
66 irq_interval = buf_packets / 4;
65 if (irq_interval == 0) /* really interrupt for each packet*/ 67 if (irq_interval == 0) /* really interrupt for each packet*/
66 irq_interval = 1; 68 irq_interval = 1;
67 else if ((irq_interval < 0) || (irq_interval > buf_packets / 4))
68 irq_interval = buf_packets / 4;
69 69
70 if (channel < -1 || channel >= 64) 70 if (channel < -1 || channel >= 64)
71 return NULL; 71 return NULL;
@@ -106,6 +106,7 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i
106 } 106 }
107 107
108 atomic_set(&iso->overflows, 0); 108 atomic_set(&iso->overflows, 0);
109 iso->bytes_discarded = 0;
109 iso->flags = 0; 110 iso->flags = 0;
110 iso->prebuffer = 0; 111 iso->prebuffer = 0;
111 112
@@ -241,12 +242,12 @@ int hpsb_iso_xmit_start(struct hpsb_iso *iso, int cycle, int prebuffer)
241 iso->xmit_cycle = cycle; 242 iso->xmit_cycle = cycle;
242 243
243 if (prebuffer < 0) 244 if (prebuffer < 0)
244 prebuffer = iso->buf_packets; 245 prebuffer = iso->buf_packets - 1;
245 else if (prebuffer == 0) 246 else if (prebuffer == 0)
246 prebuffer = 1; 247 prebuffer = 1;
247 248
248 if (prebuffer > iso->buf_packets) 249 if (prebuffer >= iso->buf_packets)
249 prebuffer = iso->buf_packets; 250 prebuffer = iso->buf_packets - 1;
250 251
251 iso->prebuffer = prebuffer; 252 iso->prebuffer = prebuffer;
252 253
@@ -395,7 +396,7 @@ void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error)
395} 396}
396 397
397void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len, 398void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len,
398 u16 cycle, u8 channel, u8 tag, u8 sy) 399 u16 total_len, u16 cycle, u8 channel, u8 tag, u8 sy)
399{ 400{
400 unsigned long flags; 401 unsigned long flags;
401 spin_lock_irqsave(&iso->lock, flags); 402 spin_lock_irqsave(&iso->lock, flags);
@@ -403,10 +404,13 @@ void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len,
403 if (iso->n_ready_packets == iso->buf_packets) { 404 if (iso->n_ready_packets == iso->buf_packets) {
404 /* overflow! */ 405 /* overflow! */
405 atomic_inc(&iso->overflows); 406 atomic_inc(&iso->overflows);
407 /* Record size of this discarded packet */
408 iso->bytes_discarded += total_len;
406 } else { 409 } else {
407 struct hpsb_iso_packet_info *info = &iso->infos[iso->pkt_dma]; 410 struct hpsb_iso_packet_info *info = &iso->infos[iso->pkt_dma];
408 info->offset = offset; 411 info->offset = offset;
409 info->len = len; 412 info->len = len;
413 info->total_len = total_len;
410 info->cycle = cycle; 414 info->cycle = cycle;
411 info->channel = channel; 415 info->channel = channel;
412 info->tag = tag; 416 info->tag = tag;
@@ -437,6 +441,17 @@ int hpsb_iso_recv_release_packets(struct hpsb_iso *iso, unsigned int n_packets)
437 441
438 iso->first_packet = (iso->first_packet+1) % iso->buf_packets; 442 iso->first_packet = (iso->first_packet+1) % iso->buf_packets;
439 iso->n_ready_packets--; 443 iso->n_ready_packets--;
444
445 /* release memory from packets discarded when queue was full */
446 if (iso->n_ready_packets == 0) { /* Release only after all prior packets handled */
447 if (iso->bytes_discarded != 0) {
448 struct hpsb_iso_packet_info inf;
449 inf.total_len = iso->bytes_discarded;
450 iso->host->driver->isoctl(iso, RECV_RELEASE,
451 (unsigned long) &inf);
452 iso->bytes_discarded = 0;
453 }
454 }
440 } 455 }
441 spin_unlock_irqrestore(&iso->lock, flags); 456 spin_unlock_irqrestore(&iso->lock, flags);
442 return rv; 457 return rv;
diff --git a/drivers/ieee1394/iso.h b/drivers/ieee1394/iso.h
index fb654d9639a7..3efc60b33a88 100644
--- a/drivers/ieee1394/iso.h
+++ b/drivers/ieee1394/iso.h
@@ -47,6 +47,14 @@ struct hpsb_iso_packet_info {
47 /* 2-bit 'tag' and 4-bit 'sy' fields of the isochronous header */ 47 /* 2-bit 'tag' and 4-bit 'sy' fields of the isochronous header */
48 __u8 tag; 48 __u8 tag;
49 __u8 sy; 49 __u8 sy;
50
51 /*
52 * length in bytes of the packet including header/trailer.
53 * MUST be at structure end, since the first part of this structure is also
54 * defined in raw1394.h (i.e. struct raw1394_iso_packet_info), is copied to
55 * userspace and is accessed there through libraw1394.
56 */
57 __u16 total_len;
50}; 58};
51 59
52enum hpsb_iso_type { HPSB_ISO_RECV = 0, HPSB_ISO_XMIT = 1 }; 60enum hpsb_iso_type { HPSB_ISO_RECV = 0, HPSB_ISO_XMIT = 1 };
@@ -111,6 +119,9 @@ struct hpsb_iso {
111 /* how many times the buffer has overflowed or underflowed */ 119 /* how many times the buffer has overflowed or underflowed */
112 atomic_t overflows; 120 atomic_t overflows;
113 121
122 /* Current number of bytes lost in discarded packets */
123 int bytes_discarded;
124
114 /* private flags to track initialization progress */ 125 /* private flags to track initialization progress */
115#define HPSB_ISO_DRIVER_INIT (1<<0) 126#define HPSB_ISO_DRIVER_INIT (1<<0)
116#define HPSB_ISO_DRIVER_STARTED (1<<1) 127#define HPSB_ISO_DRIVER_STARTED (1<<1)
@@ -193,7 +204,7 @@ void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error);
193 204
194/* call after a packet has been received (interrupt context OK) */ 205/* call after a packet has been received (interrupt context OK) */
195void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len, 206void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len,
196 u16 cycle, u8 channel, u8 tag, u8 sy); 207 u16 total_len, u16 cycle, u8 channel, u8 tag, u8 sy);
197 208
198/* call to wake waiting processes after buffer space has opened up. */ 209/* call to wake waiting processes after buffer space has opened up. */
199void hpsb_iso_wake(struct hpsb_iso *iso); 210void hpsb_iso_wake(struct hpsb_iso *iso);
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 9a46c3b44bf8..bebcc47ab06c 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -30,7 +30,7 @@
30#include "csr.h" 30#include "csr.h"
31#include "nodemgr.h" 31#include "nodemgr.h"
32 32
33static int ignore_drivers = 0; 33static int ignore_drivers;
34module_param(ignore_drivers, int, 0444); 34module_param(ignore_drivers, int, 0444);
35MODULE_PARM_DESC(ignore_drivers, "Disable automatic probing for drivers."); 35MODULE_PARM_DESC(ignore_drivers, "Disable automatic probing for drivers.");
36 36
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index b3d3d22fde64..a485f47bb21e 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -162,7 +162,7 @@ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args)
162printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args) 162printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args)
163 163
164static char version[] __devinitdata = 164static char version[] __devinitdata =
165 "$Rev: 1250 $ Ben Collins <bcollins@debian.org>"; 165 "$Rev: 1299 $ Ben Collins <bcollins@debian.org>";
166 166
167/* Module Parameters */ 167/* Module Parameters */
168static int phys_dma = 1; 168static int phys_dma = 1;
@@ -483,7 +483,9 @@ static void ohci_initialize(struct ti_ohci *ohci)
483 /* Put some defaults to these undefined bus options */ 483 /* Put some defaults to these undefined bus options */
484 buf = reg_read(ohci, OHCI1394_BusOptions); 484 buf = reg_read(ohci, OHCI1394_BusOptions);
485 buf |= 0x60000000; /* Enable CMC and ISC */ 485 buf |= 0x60000000; /* Enable CMC and ISC */
486 if (!hpsb_disable_irm) 486 if (hpsb_disable_irm)
487 buf &= ~0x80000000;
488 else
487 buf |= 0x80000000; /* Enable IRMC */ 489 buf |= 0x80000000; /* Enable IRMC */
488 buf &= ~0x00ff0000; /* XXX: Set cyc_clk_acc to zero for now */ 490 buf &= ~0x00ff0000; /* XXX: Set cyc_clk_acc to zero for now */
489 buf &= ~0x18000000; /* Disable PMC and BMC */ 491 buf &= ~0x18000000; /* Disable PMC and BMC */
@@ -503,8 +505,12 @@ static void ohci_initialize(struct ti_ohci *ohci)
503 reg_write(ohci, OHCI1394_LinkControlSet, 505 reg_write(ohci, OHCI1394_LinkControlSet,
504 OHCI1394_LinkControl_CycleTimerEnable | 506 OHCI1394_LinkControl_CycleTimerEnable |
505 OHCI1394_LinkControl_CycleMaster); 507 OHCI1394_LinkControl_CycleMaster);
506 set_phy_reg_mask(ohci, 4, PHY_04_LCTRL | 508 i = get_phy_reg(ohci, 4) | PHY_04_LCTRL;
507 (hpsb_disable_irm ? 0 : PHY_04_CONTENDER)); 509 if (hpsb_disable_irm)
510 i &= ~PHY_04_CONTENDER;
511 else
512 i |= PHY_04_CONTENDER;
513 set_phy_reg(ohci, 4, i);
508 514
509 /* Set up self-id dma buffer */ 515 /* Set up self-id dma buffer */
510 reg_write(ohci, OHCI1394_SelfIDBuffer, ohci->selfid_buf_bus); 516 reg_write(ohci, OHCI1394_SelfIDBuffer, ohci->selfid_buf_bus);
@@ -1566,6 +1572,10 @@ static void ohci_iso_recv_release_block(struct ohci_iso_recv *recv, int block)
1566 1572
1567 struct dma_cmd *next = &recv->block[next_i]; 1573 struct dma_cmd *next = &recv->block[next_i];
1568 struct dma_cmd *prev = &recv->block[prev_i]; 1574 struct dma_cmd *prev = &recv->block[prev_i];
1575
1576 /* ignore out-of-range requests */
1577 if ((block < 0) || (block > recv->nblocks))
1578 return;
1569 1579
1570 /* 'next' becomes the new end of the DMA chain, 1580 /* 'next' becomes the new end of the DMA chain,
1571 so disable branch and enable interrupt */ 1581 so disable branch and enable interrupt */
@@ -1593,19 +1603,8 @@ static void ohci_iso_recv_release_block(struct ohci_iso_recv *recv, int block)
1593static void ohci_iso_recv_bufferfill_release(struct ohci_iso_recv *recv, 1603static void ohci_iso_recv_bufferfill_release(struct ohci_iso_recv *recv,
1594 struct hpsb_iso_packet_info *info) 1604 struct hpsb_iso_packet_info *info)
1595{ 1605{
1596 int len;
1597
1598 /* release the memory where the packet was */ 1606 /* release the memory where the packet was */
1599 len = info->len; 1607 recv->released_bytes += info->total_len;
1600
1601 /* add the wasted space for padding to 4 bytes */
1602 if (len % 4)
1603 len += 4 - (len % 4);
1604
1605 /* add 8 bytes for the OHCI DMA data format overhead */
1606 len += 8;
1607
1608 recv->released_bytes += len;
1609 1608
1610 /* have we released enough memory for one block? */ 1609 /* have we released enough memory for one block? */
1611 while (recv->released_bytes > recv->buf_stride) { 1610 while (recv->released_bytes > recv->buf_stride) {
@@ -1637,7 +1636,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
1637 /* note: packet layout is as shown in section 10.6.1.1 of the OHCI spec */ 1636 /* note: packet layout is as shown in section 10.6.1.1 of the OHCI spec */
1638 1637
1639 unsigned int offset; 1638 unsigned int offset;
1640 unsigned short len, cycle; 1639 unsigned short len, cycle, total_len;
1641 unsigned char channel, tag, sy; 1640 unsigned char channel, tag, sy;
1642 1641
1643 unsigned char *p = iso->data_buf.kvirt; 1642 unsigned char *p = iso->data_buf.kvirt;
@@ -1688,9 +1687,11 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
1688 /* advance to xferStatus/timeStamp */ 1687 /* advance to xferStatus/timeStamp */
1689 recv->dma_offset += len; 1688 recv->dma_offset += len;
1690 1689
1690 total_len = len + 8; /* 8 bytes header+trailer in OHCI packet */
1691 /* payload is padded to 4 bytes */ 1691 /* payload is padded to 4 bytes */
1692 if (len % 4) { 1692 if (len % 4) {
1693 recv->dma_offset += 4 - (len%4); 1693 recv->dma_offset += 4 - (len%4);
1694 total_len += 4 - (len%4);
1694 } 1695 }
1695 1696
1696 /* check for wrap-around */ 1697 /* check for wrap-around */
@@ -1724,7 +1725,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
1724 recv->dma_offset -= recv->buf_stride*recv->nblocks; 1725 recv->dma_offset -= recv->buf_stride*recv->nblocks;
1725 } 1726 }
1726 1727
1727 hpsb_iso_packet_received(iso, offset, len, cycle, channel, tag, sy); 1728 hpsb_iso_packet_received(iso, offset, len, total_len, cycle, channel, tag, sy);
1728 } 1729 }
1729 1730
1730 if (wake) 1731 if (wake)
@@ -1850,7 +1851,8 @@ static void ohci_iso_recv_packetperbuf_task(struct hpsb_iso *iso, struct ohci_is
1850 tag = hdr[5] >> 6; 1851 tag = hdr[5] >> 6;
1851 sy = hdr[4] & 0xF; 1852 sy = hdr[4] & 0xF;
1852 1853
1853 hpsb_iso_packet_received(iso, offset, packet_len, cycle, channel, tag, sy); 1854 hpsb_iso_packet_received(iso, offset, packet_len,
1855 recv->buf_stride, cycle, channel, tag, sy);
1854 } 1856 }
1855 1857
1856 /* reset the DMA descriptor */ 1858 /* reset the DMA descriptor */
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index bdb3a85cafa6..36074e6eeebb 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -76,7 +76,7 @@
76 76
77 77
78/* Module Parameters */ 78/* Module Parameters */
79static int skip_eeprom = 0; 79static int skip_eeprom;
80module_param(skip_eeprom, int, 0444); 80module_param(skip_eeprom, int, 0444);
81MODULE_PARM_DESC(skip_eeprom, "Use generic bus info block instead of serial eeprom (default = 0)."); 81MODULE_PARM_DESC(skip_eeprom, "Use generic bus info block instead of serial eeprom (default = 0).");
82 82
@@ -1422,7 +1422,7 @@ static int __devinit add_card(struct pci_dev *dev,
1422 i = get_phy_reg(lynx, 4); 1422 i = get_phy_reg(lynx, 4);
1423 i |= PHY_04_LCTRL; 1423 i |= PHY_04_LCTRL;
1424 if (hpsb_disable_irm) 1424 if (hpsb_disable_irm)
1425 i &= !PHY_04_CONTENDER; 1425 i &= ~PHY_04_CONTENDER;
1426 else 1426 else
1427 i |= PHY_04_CONTENDER; 1427 i |= PHY_04_CONTENDER;
1428 if (i != -1) set_phy_reg(lynx, 4, i); 1428 if (i != -1) set_phy_reg(lynx, 4, i);
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 7419af450bd1..b4fa14793fe5 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -98,7 +98,7 @@ static struct hpsb_address_ops arm_ops = {
98 98
99static void queue_complete_cb(struct pending_request *req); 99static void queue_complete_cb(struct pending_request *req);
100 100
101static struct pending_request *__alloc_pending_request(int flags) 101static struct pending_request *__alloc_pending_request(unsigned int __nocast flags)
102{ 102{
103 struct pending_request *req; 103 struct pending_request *req;
104 104
@@ -2506,9 +2506,12 @@ static int raw1394_iso_send_packets(struct file_info *fi, void __user * uaddr)
2506 if (copy_from_user(&upackets, uaddr, sizeof(upackets))) 2506 if (copy_from_user(&upackets, uaddr, sizeof(upackets)))
2507 return -EFAULT; 2507 return -EFAULT;
2508 2508
2509 if (upackets.n_packets > hpsb_iso_n_ready(fi->iso_handle)) 2509 if (upackets.n_packets >= fi->iso_handle->buf_packets)
2510 return -EINVAL; 2510 return -EINVAL;
2511 2511
2512 if (upackets.n_packets >= hpsb_iso_n_ready(fi->iso_handle))
2513 return -EAGAIN;
2514
2512 /* ensure user-supplied buffer is accessible and big enough */ 2515 /* ensure user-supplied buffer is accessible and big enough */
2513 if (!access_ok(VERIFY_READ, upackets.infos, 2516 if (!access_ok(VERIFY_READ, upackets.infos,
2514 upackets.n_packets * 2517 upackets.n_packets *
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 32368f3428ec..fe3e1703fa61 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -81,7 +81,7 @@
81#include "sbp2.h" 81#include "sbp2.h"
82 82
83static char version[] __devinitdata = 83static char version[] __devinitdata =
84 "$Rev: 1219 $ Ben Collins <bcollins@debian.org>"; 84 "$Rev: 1306 $ Ben Collins <bcollins@debian.org>";
85 85
86/* 86/*
87 * Module load parameter definitions 87 * Module load parameter definitions
@@ -104,7 +104,7 @@ MODULE_PARM_DESC(max_speed, "Force max speed (3 = 800mb, 2 = 400mb default, 1 =
104 * down to us at a time (debugging). This might be necessary for very 104 * down to us at a time (debugging). This might be necessary for very
105 * badly behaved sbp2 devices. 105 * badly behaved sbp2 devices.
106 */ 106 */
107static int serialize_io = 0; 107static int serialize_io;
108module_param(serialize_io, int, 0444); 108module_param(serialize_io, int, 0444);
109MODULE_PARM_DESC(serialize_io, "Serialize all I/O coming down from the scsi drivers (default = 0)"); 109MODULE_PARM_DESC(serialize_io, "Serialize all I/O coming down from the scsi drivers (default = 0)");
110 110
@@ -145,7 +145,7 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device (default = 1)"
145 * please submit the logged sbp2_firmware_revision value of this device to 145 * please submit the logged sbp2_firmware_revision value of this device to
146 * the linux1394-devel mailing list. 146 * the linux1394-devel mailing list.
147 */ 147 */
148static int force_inquiry_hack = 0; 148static int force_inquiry_hack;
149module_param(force_inquiry_hack, int, 0444); 149module_param(force_inquiry_hack, int, 0444);
150MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); 150MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)");
151 151
@@ -2112,6 +2112,102 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2112 */ 2112 */
2113static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd) 2113static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd)
2114{ 2114{
2115 unchar new_cmd[16];
2116 u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun);
2117
2118 SBP2_DEBUG("sbp2_check_sbp2_command");
2119
2120 switch (*cmd) {
2121
2122 case READ_6:
2123
2124 if (sbp2_command_conversion_device_type(device_type)) {
2125
2126 SBP2_DEBUG("Convert READ_6 to READ_10");
2127
2128 /*
2129 * Need to turn read_6 into read_10
2130 */
2131 new_cmd[0] = 0x28;
2132 new_cmd[1] = (cmd[1] & 0xe0);
2133 new_cmd[2] = 0x0;
2134 new_cmd[3] = (cmd[1] & 0x1f);
2135 new_cmd[4] = cmd[2];
2136 new_cmd[5] = cmd[3];
2137 new_cmd[6] = 0x0;
2138 new_cmd[7] = 0x0;
2139 new_cmd[8] = cmd[4];
2140 new_cmd[9] = cmd[5];
2141
2142 memcpy(cmd, new_cmd, 10);
2143
2144 }
2145
2146 break;
2147
2148 case WRITE_6:
2149
2150 if (sbp2_command_conversion_device_type(device_type)) {
2151
2152 SBP2_DEBUG("Convert WRITE_6 to WRITE_10");
2153
2154 /*
2155 * Need to turn write_6 into write_10
2156 */
2157 new_cmd[0] = 0x2a;
2158 new_cmd[1] = (cmd[1] & 0xe0);
2159 new_cmd[2] = 0x0;
2160 new_cmd[3] = (cmd[1] & 0x1f);
2161 new_cmd[4] = cmd[2];
2162 new_cmd[5] = cmd[3];
2163 new_cmd[6] = 0x0;
2164 new_cmd[7] = 0x0;
2165 new_cmd[8] = cmd[4];
2166 new_cmd[9] = cmd[5];
2167
2168 memcpy(cmd, new_cmd, 10);
2169
2170 }
2171
2172 break;
2173
2174 case MODE_SENSE:
2175
2176 if (sbp2_command_conversion_device_type(device_type)) {
2177
2178 SBP2_DEBUG("Convert MODE_SENSE_6 to MODE_SENSE_10");
2179
2180 /*
2181 * Need to turn mode_sense_6 into mode_sense_10
2182 */
2183 new_cmd[0] = 0x5a;
2184 new_cmd[1] = cmd[1];
2185 new_cmd[2] = cmd[2];
2186 new_cmd[3] = 0x0;
2187 new_cmd[4] = 0x0;
2188 new_cmd[5] = 0x0;
2189 new_cmd[6] = 0x0;
2190 new_cmd[7] = 0x0;
2191 new_cmd[8] = cmd[4];
2192 new_cmd[9] = cmd[5];
2193
2194 memcpy(cmd, new_cmd, 10);
2195
2196 }
2197
2198 break;
2199
2200 case MODE_SELECT:
2201
2202 /*
2203 * TODO. Probably need to change mode select to 10 byte version
2204 */
2205
2206 default:
2207 break;
2208 }
2209
2210 return;
2115} 2211}
2116 2212
2117/* 2213/*
@@ -2152,6 +2248,7 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
2152 struct scsi_cmnd *SCpnt) 2248 struct scsi_cmnd *SCpnt)
2153{ 2249{
2154 u8 *scsi_buf = SCpnt->request_buffer; 2250 u8 *scsi_buf = SCpnt->request_buffer;
2251 u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun);
2155 2252
2156 SBP2_DEBUG("sbp2_check_sbp2_response"); 2253 SBP2_DEBUG("sbp2_check_sbp2_response");
2157 2254
@@ -2176,6 +2273,14 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
2176 } 2273 }
2177 2274
2178 /* 2275 /*
2276 * Check for Simple Direct Access Device and change it to TYPE_DISK
2277 */
2278 if ((scsi_buf[0] & 0x1f) == TYPE_RBC) {
2279 SBP2_DEBUG("Changing TYPE_RBC to TYPE_DISK");
2280 scsi_buf[0] &= 0xe0;
2281 }
2282
2283 /*
2179 * Fix ansi revision and response data format 2284 * Fix ansi revision and response data format
2180 */ 2285 */
2181 scsi_buf[2] |= 2; 2286 scsi_buf[2] |= 2;
@@ -2183,6 +2288,27 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
2183 2288
2184 break; 2289 break;
2185 2290
2291 case MODE_SENSE:
2292
2293 if (sbp2_command_conversion_device_type(device_type)) {
2294
2295 SBP2_DEBUG("Modify mode sense response (10 byte version)");
2296
2297 scsi_buf[0] = scsi_buf[1]; /* Mode data length */
2298 scsi_buf[1] = scsi_buf[2]; /* Medium type */
2299 scsi_buf[2] = scsi_buf[3]; /* Device specific parameter */
2300 scsi_buf[3] = scsi_buf[7]; /* Block descriptor length */
2301 memcpy(scsi_buf + 4, scsi_buf + 8, scsi_buf[0]);
2302 }
2303
2304 break;
2305
2306 case MODE_SELECT:
2307
2308 /*
2309 * TODO. Probably need to change mode select to 10 byte version
2310 */
2311
2186 default: 2312 default:
2187 break; 2313 break;
2188 } 2314 }
@@ -2559,8 +2685,7 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2559static int sbp2scsi_slave_configure (struct scsi_device *sdev) 2685static int sbp2scsi_slave_configure (struct scsi_device *sdev)
2560{ 2686{
2561 blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); 2687 blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
2562 sdev->use_10_for_rw = 1; 2688
2563 sdev->use_10_for_ms = 1;
2564 return 0; 2689 return 0;
2565} 2690}
2566 2691
diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig
index 3cc3ff0cccb1..79c8e2dd9c33 100644
--- a/drivers/infiniband/Kconfig
+++ b/drivers/infiniband/Kconfig
@@ -7,6 +7,16 @@ config INFINIBAND
7 any protocols you wish to use as well as drivers for your 7 any protocols you wish to use as well as drivers for your
8 InfiniBand hardware. 8 InfiniBand hardware.
9 9
10config INFINIBAND_USER_VERBS
11 tristate "InfiniBand userspace verbs support"
12 depends on INFINIBAND
13 ---help---
14 Userspace InfiniBand verbs support. This is the kernel side
15 of userspace verbs, which allows userspace processes to
16 directly access InfiniBand hardware for fast-path
17 operations. You will also need libibverbs and a hardware
18 driver library from <http://www.openib.org>.
19
10source "drivers/infiniband/hw/mthca/Kconfig" 20source "drivers/infiniband/hw/mthca/Kconfig"
11 21
12source "drivers/infiniband/ulp/ipoib/Kconfig" 22source "drivers/infiniband/ulp/ipoib/Kconfig"
diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile
index d2dbfb52c0a3..e1a7cf3e8636 100644
--- a/drivers/infiniband/core/Makefile
+++ b/drivers/infiniband/core/Makefile
@@ -1,6 +1,7 @@
1EXTRA_CFLAGS += -Idrivers/infiniband/include 1EXTRA_CFLAGS += -Idrivers/infiniband/include
2 2
3obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o ib_umad.o 3obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o ib_umad.o
4obj-$(CONFIG_INFINIBAND_USER_VERBS) += ib_uverbs.o
4 5
5ib_core-y := packer.o ud_header.o verbs.o sysfs.o \ 6ib_core-y := packer.o ud_header.o verbs.o sysfs.o \
6 device.o fmr_pool.o cache.o 7 device.o fmr_pool.o cache.o
@@ -10,3 +11,5 @@ ib_mad-y := mad.o smi.o agent.o
10ib_sa-y := sa_query.o 11ib_sa-y := sa_query.o
11 12
12ib_umad-y := user_mad.o 13ib_umad-y := user_mad.o
14
15ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_mem.o
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
new file mode 100644
index 000000000000..57347f1e82c1
--- /dev/null
+++ b/drivers/infiniband/core/uverbs.h
@@ -0,0 +1,132 @@
1/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 *
33 * $Id: uverbs.h 2559 2005-06-06 19:43:16Z roland $
34 */
35
36#ifndef UVERBS_H
37#define UVERBS_H
38
39/* Include device.h and fs.h until cdev.h is self-sufficient */
40#include <linux/fs.h>
41#include <linux/device.h>
42#include <linux/cdev.h>
43#include <linux/kref.h>
44#include <linux/idr.h>
45
46#include <ib_verbs.h>
47#include <ib_user_verbs.h>
48
49struct ib_uverbs_device {
50 int devnum;
51 struct cdev dev;
52 struct class_device class_dev;
53 struct ib_device *ib_dev;
54 int num_comp;
55};
56
57struct ib_uverbs_event_file {
58 struct kref ref;
59 struct ib_uverbs_file *uverbs_file;
60 spinlock_t lock;
61 int fd;
62 int is_async;
63 wait_queue_head_t poll_wait;
64 struct list_head event_list;
65};
66
67struct ib_uverbs_file {
68 struct kref ref;
69 struct ib_uverbs_device *device;
70 struct ib_ucontext *ucontext;
71 struct ib_event_handler event_handler;
72 struct ib_uverbs_event_file async_file;
73 struct ib_uverbs_event_file comp_file[1];
74};
75
76struct ib_uverbs_async_event {
77 struct ib_uverbs_async_event_desc desc;
78 struct list_head list;
79};
80
81struct ib_uverbs_comp_event {
82 struct ib_uverbs_comp_event_desc desc;
83 struct list_head list;
84};
85
86struct ib_uobject_mr {
87 struct ib_uobject uobj;
88 struct page *page_list;
89 struct scatterlist *sg_list;
90};
91
92extern struct semaphore ib_uverbs_idr_mutex;
93extern struct idr ib_uverbs_pd_idr;
94extern struct idr ib_uverbs_mr_idr;
95extern struct idr ib_uverbs_mw_idr;
96extern struct idr ib_uverbs_ah_idr;
97extern struct idr ib_uverbs_cq_idr;
98extern struct idr ib_uverbs_qp_idr;
99
100void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context);
101void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);
102void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr);
103
104int ib_umem_get(struct ib_device *dev, struct ib_umem *mem,
105 void *addr, size_t size, int write);
106void ib_umem_release(struct ib_device *dev, struct ib_umem *umem);
107void ib_umem_release_on_close(struct ib_device *dev, struct ib_umem *umem);
108
109#define IB_UVERBS_DECLARE_CMD(name) \
110 ssize_t ib_uverbs_##name(struct ib_uverbs_file *file, \
111 const char __user *buf, int in_len, \
112 int out_len)
113
114IB_UVERBS_DECLARE_CMD(query_params);
115IB_UVERBS_DECLARE_CMD(get_context);
116IB_UVERBS_DECLARE_CMD(query_device);
117IB_UVERBS_DECLARE_CMD(query_port);
118IB_UVERBS_DECLARE_CMD(query_gid);
119IB_UVERBS_DECLARE_CMD(query_pkey);
120IB_UVERBS_DECLARE_CMD(alloc_pd);
121IB_UVERBS_DECLARE_CMD(dealloc_pd);
122IB_UVERBS_DECLARE_CMD(reg_mr);
123IB_UVERBS_DECLARE_CMD(dereg_mr);
124IB_UVERBS_DECLARE_CMD(create_cq);
125IB_UVERBS_DECLARE_CMD(destroy_cq);
126IB_UVERBS_DECLARE_CMD(create_qp);
127IB_UVERBS_DECLARE_CMD(modify_qp);
128IB_UVERBS_DECLARE_CMD(destroy_qp);
129IB_UVERBS_DECLARE_CMD(attach_mcast);
130IB_UVERBS_DECLARE_CMD(detach_mcast);
131
132#endif /* UVERBS_H */
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
new file mode 100644
index 000000000000..5f2bbcda4c73
--- /dev/null
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -0,0 +1,1006 @@
1/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 *
33 * $Id: uverbs_cmd.c 2708 2005-06-24 17:27:21Z roland $
34 */
35
36#include <asm/uaccess.h>
37
38#include "uverbs.h"
39
40#define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \
41 do { \
42 (udata)->inbuf = (void __user *) (ibuf); \
43 (udata)->outbuf = (void __user *) (obuf); \
44 (udata)->inlen = (ilen); \
45 (udata)->outlen = (olen); \
46 } while (0)
47
48ssize_t ib_uverbs_query_params(struct ib_uverbs_file *file,
49 const char __user *buf,
50 int in_len, int out_len)
51{
52 struct ib_uverbs_query_params cmd;
53 struct ib_uverbs_query_params_resp resp;
54
55 if (out_len < sizeof resp)
56 return -ENOSPC;
57
58 if (copy_from_user(&cmd, buf, sizeof cmd))
59 return -EFAULT;
60
61 memset(&resp, 0, sizeof resp);
62
63 resp.num_cq_events = file->device->num_comp;
64
65 if (copy_to_user((void __user *) (unsigned long) cmd.response, &resp, sizeof resp))
66 return -EFAULT;
67
68 return in_len;
69}
70
71ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
72 const char __user *buf,
73 int in_len, int out_len)
74{
75 struct ib_uverbs_get_context cmd;
76 struct ib_uverbs_get_context_resp resp;
77 struct ib_udata udata;
78 struct ib_device *ibdev = file->device->ib_dev;
79 int i;
80 int ret = in_len;
81
82 if (out_len < sizeof resp)
83 return -ENOSPC;
84
85 if (copy_from_user(&cmd, buf, sizeof cmd))
86 return -EFAULT;
87
88 INIT_UDATA(&udata, buf + sizeof cmd,
89 (unsigned long) cmd.response + sizeof resp,
90 in_len - sizeof cmd, out_len - sizeof resp);
91
92 file->ucontext = ibdev->alloc_ucontext(ibdev, &udata);
93 if (IS_ERR(file->ucontext)) {
94 ret = PTR_ERR(file->ucontext);
95 file->ucontext = NULL;
96 return ret;
97 }
98
99 file->ucontext->device = ibdev;
100 INIT_LIST_HEAD(&file->ucontext->pd_list);
101 INIT_LIST_HEAD(&file->ucontext->mr_list);
102 INIT_LIST_HEAD(&file->ucontext->mw_list);
103 INIT_LIST_HEAD(&file->ucontext->cq_list);
104 INIT_LIST_HEAD(&file->ucontext->qp_list);
105 INIT_LIST_HEAD(&file->ucontext->srq_list);
106 INIT_LIST_HEAD(&file->ucontext->ah_list);
107 spin_lock_init(&file->ucontext->lock);
108
109 resp.async_fd = file->async_file.fd;
110 for (i = 0; i < file->device->num_comp; ++i)
111 if (copy_to_user((void __user *) (unsigned long) cmd.cq_fd_tab +
112 i * sizeof (__u32),
113 &file->comp_file[i].fd, sizeof (__u32)))
114 goto err;
115
116 if (copy_to_user((void __user *) (unsigned long) cmd.response,
117 &resp, sizeof resp))
118 goto err;
119
120 return in_len;
121
122err:
123 ibdev->dealloc_ucontext(file->ucontext);
124 file->ucontext = NULL;
125
126 return -EFAULT;
127}
128
129ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file,
130 const char __user *buf,
131 int in_len, int out_len)
132{
133 struct ib_uverbs_query_device cmd;
134 struct ib_uverbs_query_device_resp resp;
135 struct ib_device_attr attr;
136 int ret;
137
138 if (out_len < sizeof resp)
139 return -ENOSPC;
140
141 if (copy_from_user(&cmd, buf, sizeof cmd))
142 return -EFAULT;
143
144 ret = ib_query_device(file->device->ib_dev, &attr);
145 if (ret)
146 return ret;
147
148 memset(&resp, 0, sizeof resp);
149
150 resp.fw_ver = attr.fw_ver;
151 resp.node_guid = attr.node_guid;
152 resp.sys_image_guid = attr.sys_image_guid;
153 resp.max_mr_size = attr.max_mr_size;
154 resp.page_size_cap = attr.page_size_cap;
155 resp.vendor_id = attr.vendor_id;
156 resp.vendor_part_id = attr.vendor_part_id;
157 resp.hw_ver = attr.hw_ver;
158 resp.max_qp = attr.max_qp;
159 resp.max_qp_wr = attr.max_qp_wr;
160 resp.device_cap_flags = attr.device_cap_flags;
161 resp.max_sge = attr.max_sge;
162 resp.max_sge_rd = attr.max_sge_rd;
163 resp.max_cq = attr.max_cq;
164 resp.max_cqe = attr.max_cqe;
165 resp.max_mr = attr.max_mr;
166 resp.max_pd = attr.max_pd;
167 resp.max_qp_rd_atom = attr.max_qp_rd_atom;
168 resp.max_ee_rd_atom = attr.max_ee_rd_atom;
169 resp.max_res_rd_atom = attr.max_res_rd_atom;
170 resp.max_qp_init_rd_atom = attr.max_qp_init_rd_atom;
171 resp.max_ee_init_rd_atom = attr.max_ee_init_rd_atom;
172 resp.atomic_cap = attr.atomic_cap;
173 resp.max_ee = attr.max_ee;
174 resp.max_rdd = attr.max_rdd;
175 resp.max_mw = attr.max_mw;
176 resp.max_raw_ipv6_qp = attr.max_raw_ipv6_qp;
177 resp.max_raw_ethy_qp = attr.max_raw_ethy_qp;
178 resp.max_mcast_grp = attr.max_mcast_grp;
179 resp.max_mcast_qp_attach = attr.max_mcast_qp_attach;
180 resp.max_total_mcast_qp_attach = attr.max_total_mcast_qp_attach;
181 resp.max_ah = attr.max_ah;
182 resp.max_fmr = attr.max_fmr;
183 resp.max_map_per_fmr = attr.max_map_per_fmr;
184 resp.max_srq = attr.max_srq;
185 resp.max_srq_wr = attr.max_srq_wr;
186 resp.max_srq_sge = attr.max_srq_sge;
187 resp.max_pkeys = attr.max_pkeys;
188 resp.local_ca_ack_delay = attr.local_ca_ack_delay;
189 resp.phys_port_cnt = file->device->ib_dev->phys_port_cnt;
190
191 if (copy_to_user((void __user *) (unsigned long) cmd.response,
192 &resp, sizeof resp))
193 return -EFAULT;
194
195 return in_len;
196}
197
198ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file,
199 const char __user *buf,
200 int in_len, int out_len)
201{
202 struct ib_uverbs_query_port cmd;
203 struct ib_uverbs_query_port_resp resp;
204 struct ib_port_attr attr;
205 int ret;
206
207 if (out_len < sizeof resp)
208 return -ENOSPC;
209
210 if (copy_from_user(&cmd, buf, sizeof cmd))
211 return -EFAULT;
212
213 ret = ib_query_port(file->device->ib_dev, cmd.port_num, &attr);
214 if (ret)
215 return ret;
216
217 memset(&resp, 0, sizeof resp);
218
219 resp.state = attr.state;
220 resp.max_mtu = attr.max_mtu;
221 resp.active_mtu = attr.active_mtu;
222 resp.gid_tbl_len = attr.gid_tbl_len;
223 resp.port_cap_flags = attr.port_cap_flags;
224 resp.max_msg_sz = attr.max_msg_sz;
225 resp.bad_pkey_cntr = attr.bad_pkey_cntr;
226 resp.qkey_viol_cntr = attr.qkey_viol_cntr;
227 resp.pkey_tbl_len = attr.pkey_tbl_len;
228 resp.lid = attr.lid;
229 resp.sm_lid = attr.sm_lid;
230 resp.lmc = attr.lmc;
231 resp.max_vl_num = attr.max_vl_num;
232 resp.sm_sl = attr.sm_sl;
233 resp.subnet_timeout = attr.subnet_timeout;
234 resp.init_type_reply = attr.init_type_reply;
235 resp.active_width = attr.active_width;
236 resp.active_speed = attr.active_speed;
237 resp.phys_state = attr.phys_state;
238
239 if (copy_to_user((void __user *) (unsigned long) cmd.response,
240 &resp, sizeof resp))
241 return -EFAULT;
242
243 return in_len;
244}
245
246ssize_t ib_uverbs_query_gid(struct ib_uverbs_file *file,
247 const char __user *buf,
248 int in_len, int out_len)
249{
250 struct ib_uverbs_query_gid cmd;
251 struct ib_uverbs_query_gid_resp resp;
252 int ret;
253
254 if (out_len < sizeof resp)
255 return -ENOSPC;
256
257 if (copy_from_user(&cmd, buf, sizeof cmd))
258 return -EFAULT;
259
260 memset(&resp, 0, sizeof resp);
261
262 ret = ib_query_gid(file->device->ib_dev, cmd.port_num, cmd.index,
263 (union ib_gid *) resp.gid);
264 if (ret)
265 return ret;
266
267 if (copy_to_user((void __user *) (unsigned long) cmd.response,
268 &resp, sizeof resp))
269 return -EFAULT;
270
271 return in_len;
272}
273
274ssize_t ib_uverbs_query_pkey(struct ib_uverbs_file *file,
275 const char __user *buf,
276 int in_len, int out_len)
277{
278 struct ib_uverbs_query_pkey cmd;
279 struct ib_uverbs_query_pkey_resp resp;
280 int ret;
281
282 if (out_len < sizeof resp)
283 return -ENOSPC;
284
285 if (copy_from_user(&cmd, buf, sizeof cmd))
286 return -EFAULT;
287
288 memset(&resp, 0, sizeof resp);
289
290 ret = ib_query_pkey(file->device->ib_dev, cmd.port_num, cmd.index,
291 &resp.pkey);
292 if (ret)
293 return ret;
294
295 if (copy_to_user((void __user *) (unsigned long) cmd.response,
296 &resp, sizeof resp))
297 return -EFAULT;
298
299 return in_len;
300}
301
302ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
303 const char __user *buf,
304 int in_len, int out_len)
305{
306 struct ib_uverbs_alloc_pd cmd;
307 struct ib_uverbs_alloc_pd_resp resp;
308 struct ib_udata udata;
309 struct ib_uobject *uobj;
310 struct ib_pd *pd;
311 int ret;
312
313 if (out_len < sizeof resp)
314 return -ENOSPC;
315
316 if (copy_from_user(&cmd, buf, sizeof cmd))
317 return -EFAULT;
318
319 INIT_UDATA(&udata, buf + sizeof cmd,
320 (unsigned long) cmd.response + sizeof resp,
321 in_len - sizeof cmd, out_len - sizeof resp);
322
323 uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
324 if (!uobj)
325 return -ENOMEM;
326
327 uobj->context = file->ucontext;
328
329 pd = file->device->ib_dev->alloc_pd(file->device->ib_dev,
330 file->ucontext, &udata);
331 if (IS_ERR(pd)) {
332 ret = PTR_ERR(pd);
333 goto err;
334 }
335
336 pd->device = file->device->ib_dev;
337 pd->uobject = uobj;
338 atomic_set(&pd->usecnt, 0);
339
340retry:
341 if (!idr_pre_get(&ib_uverbs_pd_idr, GFP_KERNEL)) {
342 ret = -ENOMEM;
343 goto err_pd;
344 }
345
346 down(&ib_uverbs_idr_mutex);
347 ret = idr_get_new(&ib_uverbs_pd_idr, pd, &uobj->id);
348 up(&ib_uverbs_idr_mutex);
349
350 if (ret == -EAGAIN)
351 goto retry;
352 if (ret)
353 goto err_pd;
354
355 spin_lock_irq(&file->ucontext->lock);
356 list_add_tail(&uobj->list, &file->ucontext->pd_list);
357 spin_unlock_irq(&file->ucontext->lock);
358
359 memset(&resp, 0, sizeof resp);
360 resp.pd_handle = uobj->id;
361
362 if (copy_to_user((void __user *) (unsigned long) cmd.response,
363 &resp, sizeof resp)) {
364 ret = -EFAULT;
365 goto err_list;
366 }
367
368 return in_len;
369
370err_list:
371 spin_lock_irq(&file->ucontext->lock);
372 list_del(&uobj->list);
373 spin_unlock_irq(&file->ucontext->lock);
374
375 down(&ib_uverbs_idr_mutex);
376 idr_remove(&ib_uverbs_pd_idr, uobj->id);
377 up(&ib_uverbs_idr_mutex);
378
379err_pd:
380 ib_dealloc_pd(pd);
381
382err:
383 kfree(uobj);
384 return ret;
385}
386
387ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
388 const char __user *buf,
389 int in_len, int out_len)
390{
391 struct ib_uverbs_dealloc_pd cmd;
392 struct ib_pd *pd;
393 struct ib_uobject *uobj;
394 int ret = -EINVAL;
395
396 if (copy_from_user(&cmd, buf, sizeof cmd))
397 return -EFAULT;
398
399 down(&ib_uverbs_idr_mutex);
400
401 pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
402 if (!pd || pd->uobject->context != file->ucontext)
403 goto out;
404
405 uobj = pd->uobject;
406
407 ret = ib_dealloc_pd(pd);
408 if (ret)
409 goto out;
410
411 idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle);
412
413 spin_lock_irq(&file->ucontext->lock);
414 list_del(&uobj->list);
415 spin_unlock_irq(&file->ucontext->lock);
416
417 kfree(uobj);
418
419out:
420 up(&ib_uverbs_idr_mutex);
421
422 return ret ? ret : in_len;
423}
424
425ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
426 const char __user *buf, int in_len,
427 int out_len)
428{
429 struct ib_uverbs_reg_mr cmd;
430 struct ib_uverbs_reg_mr_resp resp;
431 struct ib_udata udata;
432 struct ib_umem_object *obj;
433 struct ib_pd *pd;
434 struct ib_mr *mr;
435 int ret;
436
437 if (out_len < sizeof resp)
438 return -ENOSPC;
439
440 if (copy_from_user(&cmd, buf, sizeof cmd))
441 return -EFAULT;
442
443 INIT_UDATA(&udata, buf + sizeof cmd,
444 (unsigned long) cmd.response + sizeof resp,
445 in_len - sizeof cmd, out_len - sizeof resp);
446
447 if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK))
448 return -EINVAL;
449
450 obj = kmalloc(sizeof *obj, GFP_KERNEL);
451 if (!obj)
452 return -ENOMEM;
453
454 obj->uobject.context = file->ucontext;
455
456 /*
457 * We ask for writable memory if any access flags other than
458 * "remote read" are set. "Local write" and "remote write"
459 * obviously require write access. "Remote atomic" can do
460 * things like fetch and add, which will modify memory, and
461 * "MW bind" can change permissions by binding a window.
462 */
463 ret = ib_umem_get(file->device->ib_dev, &obj->umem,
464 (void *) (unsigned long) cmd.start, cmd.length,
465 !!(cmd.access_flags & ~IB_ACCESS_REMOTE_READ));
466 if (ret)
467 goto err_free;
468
469 obj->umem.virt_base = cmd.hca_va;
470
471 down(&ib_uverbs_idr_mutex);
472
473 pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
474 if (!pd || pd->uobject->context != file->ucontext) {
475 ret = -EINVAL;
476 goto err_up;
477 }
478
479 if (!pd->device->reg_user_mr) {
480 ret = -ENOSYS;
481 goto err_up;
482 }
483
484 mr = pd->device->reg_user_mr(pd, &obj->umem, cmd.access_flags, &udata);
485 if (IS_ERR(mr)) {
486 ret = PTR_ERR(mr);
487 goto err_up;
488 }
489
490 mr->device = pd->device;
491 mr->pd = pd;
492 mr->uobject = &obj->uobject;
493 atomic_inc(&pd->usecnt);
494 atomic_set(&mr->usecnt, 0);
495
496 memset(&resp, 0, sizeof resp);
497 resp.lkey = mr->lkey;
498 resp.rkey = mr->rkey;
499
500retry:
501 if (!idr_pre_get(&ib_uverbs_mr_idr, GFP_KERNEL)) {
502 ret = -ENOMEM;
503 goto err_unreg;
504 }
505
506 ret = idr_get_new(&ib_uverbs_mr_idr, mr, &obj->uobject.id);
507
508 if (ret == -EAGAIN)
509 goto retry;
510 if (ret)
511 goto err_unreg;
512
513 resp.mr_handle = obj->uobject.id;
514
515 spin_lock_irq(&file->ucontext->lock);
516 list_add_tail(&obj->uobject.list, &file->ucontext->mr_list);
517 spin_unlock_irq(&file->ucontext->lock);
518
519 if (copy_to_user((void __user *) (unsigned long) cmd.response,
520 &resp, sizeof resp)) {
521 ret = -EFAULT;
522 goto err_list;
523 }
524
525 up(&ib_uverbs_idr_mutex);
526
527 return in_len;
528
529err_list:
530 spin_lock_irq(&file->ucontext->lock);
531 list_del(&obj->uobject.list);
532 spin_unlock_irq(&file->ucontext->lock);
533
534err_unreg:
535 ib_dereg_mr(mr);
536
537err_up:
538 up(&ib_uverbs_idr_mutex);
539
540 ib_umem_release(file->device->ib_dev, &obj->umem);
541
542err_free:
543 kfree(obj);
544 return ret;
545}
546
547ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
548 const char __user *buf, int in_len,
549 int out_len)
550{
551 struct ib_uverbs_dereg_mr cmd;
552 struct ib_mr *mr;
553 struct ib_umem_object *memobj;
554 int ret = -EINVAL;
555
556 if (copy_from_user(&cmd, buf, sizeof cmd))
557 return -EFAULT;
558
559 down(&ib_uverbs_idr_mutex);
560
561 mr = idr_find(&ib_uverbs_mr_idr, cmd.mr_handle);
562 if (!mr || mr->uobject->context != file->ucontext)
563 goto out;
564
565 memobj = container_of(mr->uobject, struct ib_umem_object, uobject);
566
567 ret = ib_dereg_mr(mr);
568 if (ret)
569 goto out;
570
571 idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle);
572
573 spin_lock_irq(&file->ucontext->lock);
574 list_del(&memobj->uobject.list);
575 spin_unlock_irq(&file->ucontext->lock);
576
577 ib_umem_release(file->device->ib_dev, &memobj->umem);
578 kfree(memobj);
579
580out:
581 up(&ib_uverbs_idr_mutex);
582
583 return ret ? ret : in_len;
584}
585
586ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
587 const char __user *buf, int in_len,
588 int out_len)
589{
590 struct ib_uverbs_create_cq cmd;
591 struct ib_uverbs_create_cq_resp resp;
592 struct ib_udata udata;
593 struct ib_uobject *uobj;
594 struct ib_cq *cq;
595 int ret;
596
597 if (out_len < sizeof resp)
598 return -ENOSPC;
599
600 if (copy_from_user(&cmd, buf, sizeof cmd))
601 return -EFAULT;
602
603 INIT_UDATA(&udata, buf + sizeof cmd,
604 (unsigned long) cmd.response + sizeof resp,
605 in_len - sizeof cmd, out_len - sizeof resp);
606
607 if (cmd.event_handler >= file->device->num_comp)
608 return -EINVAL;
609
610 uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
611 if (!uobj)
612 return -ENOMEM;
613
614 uobj->user_handle = cmd.user_handle;
615 uobj->context = file->ucontext;
616
617 cq = file->device->ib_dev->create_cq(file->device->ib_dev, cmd.cqe,
618 file->ucontext, &udata);
619 if (IS_ERR(cq)) {
620 ret = PTR_ERR(cq);
621 goto err;
622 }
623
624 cq->device = file->device->ib_dev;
625 cq->uobject = uobj;
626 cq->comp_handler = ib_uverbs_comp_handler;
627 cq->event_handler = ib_uverbs_cq_event_handler;
628 cq->cq_context = file;
629 atomic_set(&cq->usecnt, 0);
630
631retry:
632 if (!idr_pre_get(&ib_uverbs_cq_idr, GFP_KERNEL)) {
633 ret = -ENOMEM;
634 goto err_cq;
635 }
636
637 down(&ib_uverbs_idr_mutex);
638 ret = idr_get_new(&ib_uverbs_cq_idr, cq, &uobj->id);
639 up(&ib_uverbs_idr_mutex);
640
641 if (ret == -EAGAIN)
642 goto retry;
643 if (ret)
644 goto err_cq;
645
646 spin_lock_irq(&file->ucontext->lock);
647 list_add_tail(&uobj->list, &file->ucontext->cq_list);
648 spin_unlock_irq(&file->ucontext->lock);
649
650 memset(&resp, 0, sizeof resp);
651 resp.cq_handle = uobj->id;
652 resp.cqe = cq->cqe;
653
654 if (copy_to_user((void __user *) (unsigned long) cmd.response,
655 &resp, sizeof resp)) {
656 ret = -EFAULT;
657 goto err_list;
658 }
659
660 return in_len;
661
662err_list:
663 spin_lock_irq(&file->ucontext->lock);
664 list_del(&uobj->list);
665 spin_unlock_irq(&file->ucontext->lock);
666
667 down(&ib_uverbs_idr_mutex);
668 idr_remove(&ib_uverbs_cq_idr, uobj->id);
669 up(&ib_uverbs_idr_mutex);
670
671err_cq:
672 ib_destroy_cq(cq);
673
674err:
675 kfree(uobj);
676 return ret;
677}
678
679ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
680 const char __user *buf, int in_len,
681 int out_len)
682{
683 struct ib_uverbs_destroy_cq cmd;
684 struct ib_cq *cq;
685 struct ib_uobject *uobj;
686 int ret = -EINVAL;
687
688 if (copy_from_user(&cmd, buf, sizeof cmd))
689 return -EFAULT;
690
691 down(&ib_uverbs_idr_mutex);
692
693 cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle);
694 if (!cq || cq->uobject->context != file->ucontext)
695 goto out;
696
697 uobj = cq->uobject;
698
699 ret = ib_destroy_cq(cq);
700 if (ret)
701 goto out;
702
703 idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle);
704
705 spin_lock_irq(&file->ucontext->lock);
706 list_del(&uobj->list);
707 spin_unlock_irq(&file->ucontext->lock);
708
709 kfree(uobj);
710
711out:
712 up(&ib_uverbs_idr_mutex);
713
714 return ret ? ret : in_len;
715}
716
717ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
718 const char __user *buf, int in_len,
719 int out_len)
720{
721 struct ib_uverbs_create_qp cmd;
722 struct ib_uverbs_create_qp_resp resp;
723 struct ib_udata udata;
724 struct ib_uobject *uobj;
725 struct ib_pd *pd;
726 struct ib_cq *scq, *rcq;
727 struct ib_qp *qp;
728 struct ib_qp_init_attr attr;
729 int ret;
730
731 if (out_len < sizeof resp)
732 return -ENOSPC;
733
734 if (copy_from_user(&cmd, buf, sizeof cmd))
735 return -EFAULT;
736
737 INIT_UDATA(&udata, buf + sizeof cmd,
738 (unsigned long) cmd.response + sizeof resp,
739 in_len - sizeof cmd, out_len - sizeof resp);
740
741 uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
742 if (!uobj)
743 return -ENOMEM;
744
745 down(&ib_uverbs_idr_mutex);
746
747 pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
748 scq = idr_find(&ib_uverbs_cq_idr, cmd.send_cq_handle);
749 rcq = idr_find(&ib_uverbs_cq_idr, cmd.recv_cq_handle);
750
751 if (!pd || pd->uobject->context != file->ucontext ||
752 !scq || scq->uobject->context != file->ucontext ||
753 !rcq || rcq->uobject->context != file->ucontext) {
754 ret = -EINVAL;
755 goto err_up;
756 }
757
758 attr.event_handler = ib_uverbs_qp_event_handler;
759 attr.qp_context = file;
760 attr.send_cq = scq;
761 attr.recv_cq = rcq;
762 attr.srq = NULL;
763 attr.sq_sig_type = cmd.sq_sig_all ? IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR;
764 attr.qp_type = cmd.qp_type;
765
766 attr.cap.max_send_wr = cmd.max_send_wr;
767 attr.cap.max_recv_wr = cmd.max_recv_wr;
768 attr.cap.max_send_sge = cmd.max_send_sge;
769 attr.cap.max_recv_sge = cmd.max_recv_sge;
770 attr.cap.max_inline_data = cmd.max_inline_data;
771
772 uobj->user_handle = cmd.user_handle;
773 uobj->context = file->ucontext;
774
775 qp = pd->device->create_qp(pd, &attr, &udata);
776 if (IS_ERR(qp)) {
777 ret = PTR_ERR(qp);
778 goto err_up;
779 }
780
781 qp->device = pd->device;
782 qp->pd = pd;
783 qp->send_cq = attr.send_cq;
784 qp->recv_cq = attr.recv_cq;
785 qp->srq = attr.srq;
786 qp->uobject = uobj;
787 qp->event_handler = attr.event_handler;
788 qp->qp_context = attr.qp_context;
789 qp->qp_type = attr.qp_type;
790 atomic_inc(&pd->usecnt);
791 atomic_inc(&attr.send_cq->usecnt);
792 atomic_inc(&attr.recv_cq->usecnt);
793 if (attr.srq)
794 atomic_inc(&attr.srq->usecnt);
795
796 memset(&resp, 0, sizeof resp);
797 resp.qpn = qp->qp_num;
798
799retry:
800 if (!idr_pre_get(&ib_uverbs_qp_idr, GFP_KERNEL)) {
801 ret = -ENOMEM;
802 goto err_destroy;
803 }
804
805 ret = idr_get_new(&ib_uverbs_qp_idr, qp, &uobj->id);
806
807 if (ret == -EAGAIN)
808 goto retry;
809 if (ret)
810 goto err_destroy;
811
812 resp.qp_handle = uobj->id;
813
814 spin_lock_irq(&file->ucontext->lock);
815 list_add_tail(&uobj->list, &file->ucontext->qp_list);
816 spin_unlock_irq(&file->ucontext->lock);
817
818 if (copy_to_user((void __user *) (unsigned long) cmd.response,
819 &resp, sizeof resp)) {
820 ret = -EFAULT;
821 goto err_list;
822 }
823
824 up(&ib_uverbs_idr_mutex);
825
826 return in_len;
827
828err_list:
829 spin_lock_irq(&file->ucontext->lock);
830 list_del(&uobj->list);
831 spin_unlock_irq(&file->ucontext->lock);
832
833err_destroy:
834 ib_destroy_qp(qp);
835
836err_up:
837 up(&ib_uverbs_idr_mutex);
838
839 kfree(uobj);
840 return ret;
841}
842
843ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
844 const char __user *buf, int in_len,
845 int out_len)
846{
847 struct ib_uverbs_modify_qp cmd;
848 struct ib_qp *qp;
849 struct ib_qp_attr *attr;
850 int ret;
851
852 if (copy_from_user(&cmd, buf, sizeof cmd))
853 return -EFAULT;
854
855 attr = kmalloc(sizeof *attr, GFP_KERNEL);
856 if (!attr)
857 return -ENOMEM;
858
859 down(&ib_uverbs_idr_mutex);
860
861 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
862 if (!qp || qp->uobject->context != file->ucontext) {
863 ret = -EINVAL;
864 goto out;
865 }
866
867 attr->qp_state = cmd.qp_state;
868 attr->cur_qp_state = cmd.cur_qp_state;
869 attr->path_mtu = cmd.path_mtu;
870 attr->path_mig_state = cmd.path_mig_state;
871 attr->qkey = cmd.qkey;
872 attr->rq_psn = cmd.rq_psn;
873 attr->sq_psn = cmd.sq_psn;
874 attr->dest_qp_num = cmd.dest_qp_num;
875 attr->qp_access_flags = cmd.qp_access_flags;
876 attr->pkey_index = cmd.pkey_index;
877 attr->alt_pkey_index = cmd.pkey_index;
878 attr->en_sqd_async_notify = cmd.en_sqd_async_notify;
879 attr->max_rd_atomic = cmd.max_rd_atomic;
880 attr->max_dest_rd_atomic = cmd.max_dest_rd_atomic;
881 attr->min_rnr_timer = cmd.min_rnr_timer;
882 attr->port_num = cmd.port_num;
883 attr->timeout = cmd.timeout;
884 attr->retry_cnt = cmd.retry_cnt;
885 attr->rnr_retry = cmd.rnr_retry;
886 attr->alt_port_num = cmd.alt_port_num;
887 attr->alt_timeout = cmd.alt_timeout;
888
889 memcpy(attr->ah_attr.grh.dgid.raw, cmd.dest.dgid, 16);
890 attr->ah_attr.grh.flow_label = cmd.dest.flow_label;
891 attr->ah_attr.grh.sgid_index = cmd.dest.sgid_index;
892 attr->ah_attr.grh.hop_limit = cmd.dest.hop_limit;
893 attr->ah_attr.grh.traffic_class = cmd.dest.traffic_class;
894 attr->ah_attr.dlid = cmd.dest.dlid;
895 attr->ah_attr.sl = cmd.dest.sl;
896 attr->ah_attr.src_path_bits = cmd.dest.src_path_bits;
897 attr->ah_attr.static_rate = cmd.dest.static_rate;
898 attr->ah_attr.ah_flags = cmd.dest.is_global ? IB_AH_GRH : 0;
899 attr->ah_attr.port_num = cmd.dest.port_num;
900
901 memcpy(attr->alt_ah_attr.grh.dgid.raw, cmd.alt_dest.dgid, 16);
902 attr->alt_ah_attr.grh.flow_label = cmd.alt_dest.flow_label;
903 attr->alt_ah_attr.grh.sgid_index = cmd.alt_dest.sgid_index;
904 attr->alt_ah_attr.grh.hop_limit = cmd.alt_dest.hop_limit;
905 attr->alt_ah_attr.grh.traffic_class = cmd.alt_dest.traffic_class;
906 attr->alt_ah_attr.dlid = cmd.alt_dest.dlid;
907 attr->alt_ah_attr.sl = cmd.alt_dest.sl;
908 attr->alt_ah_attr.src_path_bits = cmd.alt_dest.src_path_bits;
909 attr->alt_ah_attr.static_rate = cmd.alt_dest.static_rate;
910 attr->alt_ah_attr.ah_flags = cmd.alt_dest.is_global ? IB_AH_GRH : 0;
911 attr->alt_ah_attr.port_num = cmd.alt_dest.port_num;
912
913 ret = ib_modify_qp(qp, attr, cmd.attr_mask);
914 if (ret)
915 goto out;
916
917 ret = in_len;
918
919out:
920 up(&ib_uverbs_idr_mutex);
921 kfree(attr);
922
923 return ret;
924}
925
926ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
927 const char __user *buf, int in_len,
928 int out_len)
929{
930 struct ib_uverbs_destroy_qp cmd;
931 struct ib_qp *qp;
932 struct ib_uobject *uobj;
933 int ret = -EINVAL;
934
935 if (copy_from_user(&cmd, buf, sizeof cmd))
936 return -EFAULT;
937
938 down(&ib_uverbs_idr_mutex);
939
940 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
941 if (!qp || qp->uobject->context != file->ucontext)
942 goto out;
943
944 uobj = qp->uobject;
945
946 ret = ib_destroy_qp(qp);
947 if (ret)
948 goto out;
949
950 idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle);
951
952 spin_lock_irq(&file->ucontext->lock);
953 list_del(&uobj->list);
954 spin_unlock_irq(&file->ucontext->lock);
955
956 kfree(uobj);
957
958out:
959 up(&ib_uverbs_idr_mutex);
960
961 return ret ? ret : in_len;
962}
963
964ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
965 const char __user *buf, int in_len,
966 int out_len)
967{
968 struct ib_uverbs_attach_mcast cmd;
969 struct ib_qp *qp;
970 int ret = -EINVAL;
971
972 if (copy_from_user(&cmd, buf, sizeof cmd))
973 return -EFAULT;
974
975 down(&ib_uverbs_idr_mutex);
976
977 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
978 if (qp && qp->uobject->context == file->ucontext)
979 ret = ib_attach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
980
981 up(&ib_uverbs_idr_mutex);
982
983 return ret ? ret : in_len;
984}
985
986ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
987 const char __user *buf, int in_len,
988 int out_len)
989{
990 struct ib_uverbs_detach_mcast cmd;
991 struct ib_qp *qp;
992 int ret = -EINVAL;
993
994 if (copy_from_user(&cmd, buf, sizeof cmd))
995 return -EFAULT;
996
997 down(&ib_uverbs_idr_mutex);
998
999 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1000 if (qp && qp->uobject->context == file->ucontext)
1001 ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
1002
1003 up(&ib_uverbs_idr_mutex);
1004
1005 return ret ? ret : in_len;
1006}
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
new file mode 100644
index 000000000000..fbbe03d8c901
--- /dev/null
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -0,0 +1,698 @@
1/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 *
33 * $Id: uverbs_main.c 2733 2005-06-28 19:14:34Z roland $
34 */
35
36#include <linux/module.h>
37#include <linux/init.h>
38#include <linux/device.h>
39#include <linux/err.h>
40#include <linux/fs.h>
41#include <linux/poll.h>
42#include <linux/file.h>
43#include <linux/mount.h>
44
45#include <asm/uaccess.h>
46
47#include "uverbs.h"
48
49MODULE_AUTHOR("Roland Dreier");
50MODULE_DESCRIPTION("InfiniBand userspace verbs access");
51MODULE_LICENSE("Dual BSD/GPL");
52
53#define INFINIBANDEVENTFS_MAGIC 0x49426576 /* "IBev" */
54
55enum {
56 IB_UVERBS_MAJOR = 231,
57 IB_UVERBS_BASE_MINOR = 192,
58 IB_UVERBS_MAX_DEVICES = 32
59};
60
61#define IB_UVERBS_BASE_DEV MKDEV(IB_UVERBS_MAJOR, IB_UVERBS_BASE_MINOR)
62
63DECLARE_MUTEX(ib_uverbs_idr_mutex);
64DEFINE_IDR(ib_uverbs_pd_idr);
65DEFINE_IDR(ib_uverbs_mr_idr);
66DEFINE_IDR(ib_uverbs_mw_idr);
67DEFINE_IDR(ib_uverbs_ah_idr);
68DEFINE_IDR(ib_uverbs_cq_idr);
69DEFINE_IDR(ib_uverbs_qp_idr);
70
71static spinlock_t map_lock;
72static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES);
73
74static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
75 const char __user *buf, int in_len,
76 int out_len) = {
77 [IB_USER_VERBS_CMD_QUERY_PARAMS] = ib_uverbs_query_params,
78 [IB_USER_VERBS_CMD_GET_CONTEXT] = ib_uverbs_get_context,
79 [IB_USER_VERBS_CMD_QUERY_DEVICE] = ib_uverbs_query_device,
80 [IB_USER_VERBS_CMD_QUERY_PORT] = ib_uverbs_query_port,
81 [IB_USER_VERBS_CMD_QUERY_GID] = ib_uverbs_query_gid,
82 [IB_USER_VERBS_CMD_QUERY_PKEY] = ib_uverbs_query_pkey,
83 [IB_USER_VERBS_CMD_ALLOC_PD] = ib_uverbs_alloc_pd,
84 [IB_USER_VERBS_CMD_DEALLOC_PD] = ib_uverbs_dealloc_pd,
85 [IB_USER_VERBS_CMD_REG_MR] = ib_uverbs_reg_mr,
86 [IB_USER_VERBS_CMD_DEREG_MR] = ib_uverbs_dereg_mr,
87 [IB_USER_VERBS_CMD_CREATE_CQ] = ib_uverbs_create_cq,
88 [IB_USER_VERBS_CMD_DESTROY_CQ] = ib_uverbs_destroy_cq,
89 [IB_USER_VERBS_CMD_CREATE_QP] = ib_uverbs_create_qp,
90 [IB_USER_VERBS_CMD_MODIFY_QP] = ib_uverbs_modify_qp,
91 [IB_USER_VERBS_CMD_DESTROY_QP] = ib_uverbs_destroy_qp,
92 [IB_USER_VERBS_CMD_ATTACH_MCAST] = ib_uverbs_attach_mcast,
93 [IB_USER_VERBS_CMD_DETACH_MCAST] = ib_uverbs_detach_mcast,
94};
95
96static struct vfsmount *uverbs_event_mnt;
97
98static void ib_uverbs_add_one(struct ib_device *device);
99static void ib_uverbs_remove_one(struct ib_device *device);
100
101static int ib_dealloc_ucontext(struct ib_ucontext *context)
102{
103 struct ib_uobject *uobj, *tmp;
104
105 if (!context)
106 return 0;
107
108 down(&ib_uverbs_idr_mutex);
109
110 /* XXX Free AHs */
111
112 list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) {
113 struct ib_qp *qp = idr_find(&ib_uverbs_qp_idr, uobj->id);
114 idr_remove(&ib_uverbs_qp_idr, uobj->id);
115 ib_destroy_qp(qp);
116 list_del(&uobj->list);
117 kfree(uobj);
118 }
119
120 list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) {
121 struct ib_cq *cq = idr_find(&ib_uverbs_cq_idr, uobj->id);
122 idr_remove(&ib_uverbs_cq_idr, uobj->id);
123 ib_destroy_cq(cq);
124 list_del(&uobj->list);
125 kfree(uobj);
126 }
127
128 /* XXX Free SRQs */
129 /* XXX Free MWs */
130
131 list_for_each_entry_safe(uobj, tmp, &context->mr_list, list) {
132 struct ib_mr *mr = idr_find(&ib_uverbs_mr_idr, uobj->id);
133 struct ib_umem_object *memobj;
134
135 idr_remove(&ib_uverbs_mr_idr, uobj->id);
136 ib_dereg_mr(mr);
137
138 memobj = container_of(uobj, struct ib_umem_object, uobject);
139 ib_umem_release_on_close(mr->device, &memobj->umem);
140
141 list_del(&uobj->list);
142 kfree(memobj);
143 }
144
145 list_for_each_entry_safe(uobj, tmp, &context->pd_list, list) {
146 struct ib_pd *pd = idr_find(&ib_uverbs_pd_idr, uobj->id);
147 idr_remove(&ib_uverbs_pd_idr, uobj->id);
148 ib_dealloc_pd(pd);
149 list_del(&uobj->list);
150 kfree(uobj);
151 }
152
153 up(&ib_uverbs_idr_mutex);
154
155 return context->device->dealloc_ucontext(context);
156}
157
158static void ib_uverbs_release_file(struct kref *ref)
159{
160 struct ib_uverbs_file *file =
161 container_of(ref, struct ib_uverbs_file, ref);
162
163 module_put(file->device->ib_dev->owner);
164 kfree(file);
165}
166
167static ssize_t ib_uverbs_event_read(struct file *filp, char __user *buf,
168 size_t count, loff_t *pos)
169{
170 struct ib_uverbs_event_file *file = filp->private_data;
171 void *event;
172 int eventsz;
173 int ret = 0;
174
175 spin_lock_irq(&file->lock);
176
177 while (list_empty(&file->event_list) && file->fd >= 0) {
178 spin_unlock_irq(&file->lock);
179
180 if (filp->f_flags & O_NONBLOCK)
181 return -EAGAIN;
182
183 if (wait_event_interruptible(file->poll_wait,
184 !list_empty(&file->event_list) ||
185 file->fd < 0))
186 return -ERESTARTSYS;
187
188 spin_lock_irq(&file->lock);
189 }
190
191 if (file->fd < 0) {
192 spin_unlock_irq(&file->lock);
193 return -ENODEV;
194 }
195
196 if (file->is_async) {
197 event = list_entry(file->event_list.next,
198 struct ib_uverbs_async_event, list);
199 eventsz = sizeof (struct ib_uverbs_async_event_desc);
200 } else {
201 event = list_entry(file->event_list.next,
202 struct ib_uverbs_comp_event, list);
203 eventsz = sizeof (struct ib_uverbs_comp_event_desc);
204 }
205
206 if (eventsz > count) {
207 ret = -EINVAL;
208 event = NULL;
209 } else
210 list_del(file->event_list.next);
211
212 spin_unlock_irq(&file->lock);
213
214 if (event) {
215 if (copy_to_user(buf, event, eventsz))
216 ret = -EFAULT;
217 else
218 ret = eventsz;
219 }
220
221 kfree(event);
222
223 return ret;
224}
225
226static unsigned int ib_uverbs_event_poll(struct file *filp,
227 struct poll_table_struct *wait)
228{
229 unsigned int pollflags = 0;
230 struct ib_uverbs_event_file *file = filp->private_data;
231
232 poll_wait(filp, &file->poll_wait, wait);
233
234 spin_lock_irq(&file->lock);
235 if (file->fd < 0)
236 pollflags = POLLERR;
237 else if (!list_empty(&file->event_list))
238 pollflags = POLLIN | POLLRDNORM;
239 spin_unlock_irq(&file->lock);
240
241 return pollflags;
242}
243
244static void ib_uverbs_event_release(struct ib_uverbs_event_file *file)
245{
246 struct list_head *entry, *tmp;
247
248 spin_lock_irq(&file->lock);
249 if (file->fd != -1) {
250 file->fd = -1;
251 list_for_each_safe(entry, tmp, &file->event_list)
252 if (file->is_async)
253 kfree(list_entry(entry, struct ib_uverbs_async_event, list));
254 else
255 kfree(list_entry(entry, struct ib_uverbs_comp_event, list));
256 }
257 spin_unlock_irq(&file->lock);
258}
259
260static int ib_uverbs_event_close(struct inode *inode, struct file *filp)
261{
262 struct ib_uverbs_event_file *file = filp->private_data;
263
264 ib_uverbs_event_release(file);
265 kref_put(&file->uverbs_file->ref, ib_uverbs_release_file);
266
267 return 0;
268}
269
270static struct file_operations uverbs_event_fops = {
271 /*
272 * No .owner field since we artificially create event files,
273 * so there is no increment to the module reference count in
274 * the open path. All event files come from a uverbs command
275 * file, which already takes a module reference, so this is OK.
276 */
277 .read = ib_uverbs_event_read,
278 .poll = ib_uverbs_event_poll,
279 .release = ib_uverbs_event_close
280};
281
282void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
283{
284 struct ib_uverbs_file *file = cq_context;
285 struct ib_uverbs_comp_event *entry;
286 unsigned long flags;
287
288 entry = kmalloc(sizeof *entry, GFP_ATOMIC);
289 if (!entry)
290 return;
291
292 entry->desc.cq_handle = cq->uobject->user_handle;
293
294 spin_lock_irqsave(&file->comp_file[0].lock, flags);
295 list_add_tail(&entry->list, &file->comp_file[0].event_list);
296 spin_unlock_irqrestore(&file->comp_file[0].lock, flags);
297
298 wake_up_interruptible(&file->comp_file[0].poll_wait);
299}
300
301static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
302 __u64 element, __u64 event)
303{
304 struct ib_uverbs_async_event *entry;
305 unsigned long flags;
306
307 entry = kmalloc(sizeof *entry, GFP_ATOMIC);
308 if (!entry)
309 return;
310
311 entry->desc.element = element;
312 entry->desc.event_type = event;
313
314 spin_lock_irqsave(&file->async_file.lock, flags);
315 list_add_tail(&entry->list, &file->async_file.event_list);
316 spin_unlock_irqrestore(&file->async_file.lock, flags);
317
318 wake_up_interruptible(&file->async_file.poll_wait);
319}
320
321void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
322{
323 ib_uverbs_async_handler(context_ptr,
324 event->element.cq->uobject->user_handle,
325 event->event);
326}
327
328void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr)
329{
330 ib_uverbs_async_handler(context_ptr,
331 event->element.qp->uobject->user_handle,
332 event->event);
333}
334
335static void ib_uverbs_event_handler(struct ib_event_handler *handler,
336 struct ib_event *event)
337{
338 struct ib_uverbs_file *file =
339 container_of(handler, struct ib_uverbs_file, event_handler);
340
341 ib_uverbs_async_handler(file, event->element.port_num, event->event);
342}
343
344static int ib_uverbs_event_init(struct ib_uverbs_event_file *file,
345 struct ib_uverbs_file *uverbs_file)
346{
347 struct file *filp;
348
349 spin_lock_init(&file->lock);
350 INIT_LIST_HEAD(&file->event_list);
351 init_waitqueue_head(&file->poll_wait);
352 file->uverbs_file = uverbs_file;
353
354 file->fd = get_unused_fd();
355 if (file->fd < 0)
356 return file->fd;
357
358 filp = get_empty_filp();
359 if (!filp) {
360 put_unused_fd(file->fd);
361 return -ENFILE;
362 }
363
364 filp->f_op = &uverbs_event_fops;
365 filp->f_vfsmnt = mntget(uverbs_event_mnt);
366 filp->f_dentry = dget(uverbs_event_mnt->mnt_root);
367 filp->f_mapping = filp->f_dentry->d_inode->i_mapping;
368 filp->f_flags = O_RDONLY;
369 filp->f_mode = FMODE_READ;
370 filp->private_data = file;
371
372 fd_install(file->fd, filp);
373
374 return 0;
375}
376
377static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
378 size_t count, loff_t *pos)
379{
380 struct ib_uverbs_file *file = filp->private_data;
381 struct ib_uverbs_cmd_hdr hdr;
382
383 if (count < sizeof hdr)
384 return -EINVAL;
385
386 if (copy_from_user(&hdr, buf, sizeof hdr))
387 return -EFAULT;
388
389 if (hdr.in_words * 4 != count)
390 return -EINVAL;
391
392 if (hdr.command < 0 || hdr.command >= ARRAY_SIZE(uverbs_cmd_table))
393 return -EINVAL;
394
395 if (!file->ucontext &&
396 hdr.command != IB_USER_VERBS_CMD_QUERY_PARAMS &&
397 hdr.command != IB_USER_VERBS_CMD_GET_CONTEXT)
398 return -EINVAL;
399
400 return uverbs_cmd_table[hdr.command](file, buf + sizeof hdr,
401 hdr.in_words * 4, hdr.out_words * 4);
402}
403
404static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
405{
406 struct ib_uverbs_file *file = filp->private_data;
407
408 if (!file->ucontext)
409 return -ENODEV;
410 else
411 return file->device->ib_dev->mmap(file->ucontext, vma);
412}
413
414static int ib_uverbs_open(struct inode *inode, struct file *filp)
415{
416 struct ib_uverbs_device *dev =
417 container_of(inode->i_cdev, struct ib_uverbs_device, dev);
418 struct ib_uverbs_file *file;
419 int i = 0;
420 int ret;
421
422 if (!try_module_get(dev->ib_dev->owner))
423 return -ENODEV;
424
425 file = kmalloc(sizeof *file +
426 (dev->num_comp - 1) * sizeof (struct ib_uverbs_event_file),
427 GFP_KERNEL);
428 if (!file)
429 return -ENOMEM;
430
431 file->device = dev;
432 kref_init(&file->ref);
433
434 file->ucontext = NULL;
435
436 ret = ib_uverbs_event_init(&file->async_file, file);
437 if (ret)
438 goto err;
439
440 file->async_file.is_async = 1;
441
442 kref_get(&file->ref);
443
444 for (i = 0; i < dev->num_comp; ++i) {
445 ret = ib_uverbs_event_init(&file->comp_file[i], file);
446 if (ret)
447 goto err_async;
448 kref_get(&file->ref);
449 file->comp_file[i].is_async = 0;
450 }
451
452
453 filp->private_data = file;
454
455 INIT_IB_EVENT_HANDLER(&file->event_handler, dev->ib_dev,
456 ib_uverbs_event_handler);
457 if (ib_register_event_handler(&file->event_handler))
458 goto err_async;
459
460 return 0;
461
462err_async:
463 while (i--)
464 ib_uverbs_event_release(&file->comp_file[i]);
465
466 ib_uverbs_event_release(&file->async_file);
467
468err:
469 kref_put(&file->ref, ib_uverbs_release_file);
470
471 return ret;
472}
473
474static int ib_uverbs_close(struct inode *inode, struct file *filp)
475{
476 struct ib_uverbs_file *file = filp->private_data;
477 int i;
478
479 ib_unregister_event_handler(&file->event_handler);
480 ib_uverbs_event_release(&file->async_file);
481 ib_dealloc_ucontext(file->ucontext);
482
483 for (i = 0; i < file->device->num_comp; ++i)
484 ib_uverbs_event_release(&file->comp_file[i]);
485
486 kref_put(&file->ref, ib_uverbs_release_file);
487
488 return 0;
489}
490
491static struct file_operations uverbs_fops = {
492 .owner = THIS_MODULE,
493 .write = ib_uverbs_write,
494 .open = ib_uverbs_open,
495 .release = ib_uverbs_close
496};
497
498static struct file_operations uverbs_mmap_fops = {
499 .owner = THIS_MODULE,
500 .write = ib_uverbs_write,
501 .mmap = ib_uverbs_mmap,
502 .open = ib_uverbs_open,
503 .release = ib_uverbs_close
504};
505
506static struct ib_client uverbs_client = {
507 .name = "uverbs",
508 .add = ib_uverbs_add_one,
509 .remove = ib_uverbs_remove_one
510};
511
512static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
513{
514 struct ib_uverbs_device *dev =
515 container_of(class_dev, struct ib_uverbs_device, class_dev);
516
517 return sprintf(buf, "%s\n", dev->ib_dev->name);
518}
519static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
520
521static void ib_uverbs_release_class_dev(struct class_device *class_dev)
522{
523 struct ib_uverbs_device *dev =
524 container_of(class_dev, struct ib_uverbs_device, class_dev);
525
526 cdev_del(&dev->dev);
527 clear_bit(dev->devnum, dev_map);
528 kfree(dev);
529}
530
531static struct class uverbs_class = {
532 .name = "infiniband_verbs",
533 .release = ib_uverbs_release_class_dev
534};
535
536static ssize_t show_abi_version(struct class *class, char *buf)
537{
538 return sprintf(buf, "%d\n", IB_USER_VERBS_ABI_VERSION);
539}
540static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
541
542static void ib_uverbs_add_one(struct ib_device *device)
543{
544 struct ib_uverbs_device *uverbs_dev;
545
546 if (!device->alloc_ucontext)
547 return;
548
549 uverbs_dev = kmalloc(sizeof *uverbs_dev, GFP_KERNEL);
550 if (!uverbs_dev)
551 return;
552
553 memset(uverbs_dev, 0, sizeof *uverbs_dev);
554
555 spin_lock(&map_lock);
556 uverbs_dev->devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES);
557 if (uverbs_dev->devnum >= IB_UVERBS_MAX_DEVICES) {
558 spin_unlock(&map_lock);
559 goto err;
560 }
561 set_bit(uverbs_dev->devnum, dev_map);
562 spin_unlock(&map_lock);
563
564 uverbs_dev->ib_dev = device;
565 uverbs_dev->num_comp = 1;
566
567 if (device->mmap)
568 cdev_init(&uverbs_dev->dev, &uverbs_mmap_fops);
569 else
570 cdev_init(&uverbs_dev->dev, &uverbs_fops);
571 uverbs_dev->dev.owner = THIS_MODULE;
572 kobject_set_name(&uverbs_dev->dev.kobj, "uverbs%d", uverbs_dev->devnum);
573 if (cdev_add(&uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
574 goto err;
575
576 uverbs_dev->class_dev.class = &uverbs_class;
577 uverbs_dev->class_dev.dev = device->dma_device;
578 uverbs_dev->class_dev.devt = uverbs_dev->dev.dev;
579 snprintf(uverbs_dev->class_dev.class_id, BUS_ID_SIZE, "uverbs%d", uverbs_dev->devnum);
580 if (class_device_register(&uverbs_dev->class_dev))
581 goto err_cdev;
582
583 if (class_device_create_file(&uverbs_dev->class_dev, &class_device_attr_ibdev))
584 goto err_class;
585
586 ib_set_client_data(device, &uverbs_client, uverbs_dev);
587
588 return;
589
590err_class:
591 class_device_unregister(&uverbs_dev->class_dev);
592
593err_cdev:
594 cdev_del(&uverbs_dev->dev);
595 clear_bit(uverbs_dev->devnum, dev_map);
596
597err:
598 kfree(uverbs_dev);
599 return;
600}
601
602static void ib_uverbs_remove_one(struct ib_device *device)
603{
604 struct ib_uverbs_device *uverbs_dev = ib_get_client_data(device, &uverbs_client);
605
606 if (!uverbs_dev)
607 return;
608
609 class_device_unregister(&uverbs_dev->class_dev);
610}
611
612static struct super_block *uverbs_event_get_sb(struct file_system_type *fs_type, int flags,
613 const char *dev_name, void *data)
614{
615 return get_sb_pseudo(fs_type, "infinibandevent:", NULL,
616 INFINIBANDEVENTFS_MAGIC);
617}
618
619static struct file_system_type uverbs_event_fs = {
620 /* No owner field so module can be unloaded */
621 .name = "infinibandeventfs",
622 .get_sb = uverbs_event_get_sb,
623 .kill_sb = kill_litter_super
624};
625
626static int __init ib_uverbs_init(void)
627{
628 int ret;
629
630 spin_lock_init(&map_lock);
631
632 ret = register_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES,
633 "infiniband_verbs");
634 if (ret) {
635 printk(KERN_ERR "user_verbs: couldn't register device number\n");
636 goto out;
637 }
638
639 ret = class_register(&uverbs_class);
640 if (ret) {
641 printk(KERN_ERR "user_verbs: couldn't create class infiniband_verbs\n");
642 goto out_chrdev;
643 }
644
645 ret = class_create_file(&uverbs_class, &class_attr_abi_version);
646 if (ret) {
647 printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n");
648 goto out_class;
649 }
650
651 ret = register_filesystem(&uverbs_event_fs);
652 if (ret) {
653 printk(KERN_ERR "user_verbs: couldn't register infinibandeventfs\n");
654 goto out_class;
655 }
656
657 uverbs_event_mnt = kern_mount(&uverbs_event_fs);
658 if (IS_ERR(uverbs_event_mnt)) {
659 ret = PTR_ERR(uverbs_event_mnt);
660 printk(KERN_ERR "user_verbs: couldn't mount infinibandeventfs\n");
661 goto out_fs;
662 }
663
664 ret = ib_register_client(&uverbs_client);
665 if (ret) {
666 printk(KERN_ERR "user_verbs: couldn't register client\n");
667 goto out_mnt;
668 }
669
670 return 0;
671
672out_mnt:
673 mntput(uverbs_event_mnt);
674
675out_fs:
676 unregister_filesystem(&uverbs_event_fs);
677
678out_class:
679 class_unregister(&uverbs_class);
680
681out_chrdev:
682 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
683
684out:
685 return ret;
686}
687
688static void __exit ib_uverbs_cleanup(void)
689{
690 ib_unregister_client(&uverbs_client);
691 mntput(uverbs_event_mnt);
692 unregister_filesystem(&uverbs_event_fs);
693 class_unregister(&uverbs_class);
694 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
695}
696
697module_init(ib_uverbs_init);
698module_exit(ib_uverbs_cleanup);
diff --git a/drivers/infiniband/core/uverbs_mem.c b/drivers/infiniband/core/uverbs_mem.c
new file mode 100644
index 000000000000..ed550f6595bd
--- /dev/null
+++ b/drivers/infiniband/core/uverbs_mem.c
@@ -0,0 +1,221 @@
1/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 *
33 * $Id: uverbs_mem.c 2743 2005-06-28 22:27:59Z roland $
34 */
35
36#include <linux/mm.h>
37#include <linux/dma-mapping.h>
38
39#include "uverbs.h"
40
41struct ib_umem_account_work {
42 struct work_struct work;
43 struct mm_struct *mm;
44 unsigned long diff;
45};
46
47
48static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int dirty)
49{
50 struct ib_umem_chunk *chunk, *tmp;
51 int i;
52
53 list_for_each_entry_safe(chunk, tmp, &umem->chunk_list, list) {
54 dma_unmap_sg(dev->dma_device, chunk->page_list,
55 chunk->nents, DMA_BIDIRECTIONAL);
56 for (i = 0; i < chunk->nents; ++i) {
57 if (umem->writable && dirty)
58 set_page_dirty_lock(chunk->page_list[i].page);
59 put_page(chunk->page_list[i].page);
60 }
61
62 kfree(chunk);
63 }
64}
65
66int ib_umem_get(struct ib_device *dev, struct ib_umem *mem,
67 void *addr, size_t size, int write)
68{
69 struct page **page_list;
70 struct ib_umem_chunk *chunk;
71 unsigned long locked;
72 unsigned long lock_limit;
73 unsigned long cur_base;
74 unsigned long npages;
75 int ret = 0;
76 int off;
77 int i;
78
79 if (!can_do_mlock())
80 return -EPERM;
81
82 page_list = (struct page **) __get_free_page(GFP_KERNEL);
83 if (!page_list)
84 return -ENOMEM;
85
86 mem->user_base = (unsigned long) addr;
87 mem->length = size;
88 mem->offset = (unsigned long) addr & ~PAGE_MASK;
89 mem->page_size = PAGE_SIZE;
90 mem->writable = write;
91
92 INIT_LIST_HEAD(&mem->chunk_list);
93
94 npages = PAGE_ALIGN(size + mem->offset) >> PAGE_SHIFT;
95
96 down_write(&current->mm->mmap_sem);
97
98 locked = npages + current->mm->locked_vm;
99 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
100
101 if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
102 ret = -ENOMEM;
103 goto out;
104 }
105
106 cur_base = (unsigned long) addr & PAGE_MASK;
107
108 while (npages) {
109 ret = get_user_pages(current, current->mm, cur_base,
110 min_t(int, npages,
111 PAGE_SIZE / sizeof (struct page *)),
112 1, !write, page_list, NULL);
113
114 if (ret < 0)
115 goto out;
116
117 cur_base += ret * PAGE_SIZE;
118 npages -= ret;
119
120 off = 0;
121
122 while (ret) {
123 chunk = kmalloc(sizeof *chunk + sizeof (struct scatterlist) *
124 min_t(int, ret, IB_UMEM_MAX_PAGE_CHUNK),
125 GFP_KERNEL);
126 if (!chunk) {
127 ret = -ENOMEM;
128 goto out;
129 }
130
131 chunk->nents = min_t(int, ret, IB_UMEM_MAX_PAGE_CHUNK);
132 for (i = 0; i < chunk->nents; ++i) {
133 chunk->page_list[i].page = page_list[i + off];
134 chunk->page_list[i].offset = 0;
135 chunk->page_list[i].length = PAGE_SIZE;
136 }
137
138 chunk->nmap = dma_map_sg(dev->dma_device,
139 &chunk->page_list[0],
140 chunk->nents,
141 DMA_BIDIRECTIONAL);
142 if (chunk->nmap <= 0) {
143 for (i = 0; i < chunk->nents; ++i)
144 put_page(chunk->page_list[i].page);
145 kfree(chunk);
146
147 ret = -ENOMEM;
148 goto out;
149 }
150
151 ret -= chunk->nents;
152 off += chunk->nents;
153 list_add_tail(&chunk->list, &mem->chunk_list);
154 }
155
156 ret = 0;
157 }
158
159out:
160 if (ret < 0)
161 __ib_umem_release(dev, mem, 0);
162 else
163 current->mm->locked_vm = locked;
164
165 up_write(&current->mm->mmap_sem);
166 free_page((unsigned long) page_list);
167
168 return ret;
169}
170
171void ib_umem_release(struct ib_device *dev, struct ib_umem *umem)
172{
173 __ib_umem_release(dev, umem, 1);
174
175 down_write(&current->mm->mmap_sem);
176 current->mm->locked_vm -=
177 PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT;
178 up_write(&current->mm->mmap_sem);
179}
180
181static void ib_umem_account(void *work_ptr)
182{
183 struct ib_umem_account_work *work = work_ptr;
184
185 down_write(&work->mm->mmap_sem);
186 work->mm->locked_vm -= work->diff;
187 up_write(&work->mm->mmap_sem);
188 mmput(work->mm);
189 kfree(work);
190}
191
192void ib_umem_release_on_close(struct ib_device *dev, struct ib_umem *umem)
193{
194 struct ib_umem_account_work *work;
195 struct mm_struct *mm;
196
197 __ib_umem_release(dev, umem, 1);
198
199 mm = get_task_mm(current);
200 if (!mm)
201 return;
202
203 /*
204 * We may be called with the mm's mmap_sem already held. This
205 * can happen when a userspace munmap() is the call that drops
206 * the last reference to our file and calls our release
207 * method. If there are memory regions to destroy, we'll end
208 * up here and not be able to take the mmap_sem. Therefore we
209 * defer the vm_locked accounting to the system workqueue.
210 */
211
212 work = kmalloc(sizeof *work, GFP_KERNEL);
213 if (!work)
214 return;
215
216 INIT_WORK(&work->work, ib_umem_account, work);
217 work->mm = mm;
218 work->diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT;
219
220 schedule_work(&work->work);
221}
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 7c08ed0cd7dd..2516f9646515 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -4,6 +4,7 @@
4 * Copyright (c) 2004 Intel Corporation. All rights reserved. 4 * Copyright (c) 2004 Intel Corporation. All rights reserved.
5 * Copyright (c) 2004 Topspin Corporation. All rights reserved. 5 * Copyright (c) 2004 Topspin Corporation. All rights reserved.
6 * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 6 * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
7 * Copyright (c) 2005 Cisco Systems. All rights reserved.
7 * 8 *
8 * This software is available to you under a choice of one of two 9 * This software is available to you under a choice of one of two
9 * licenses. You may choose to be licensed under the terms of the GNU 10 * licenses. You may choose to be licensed under the terms of the GNU
@@ -47,10 +48,11 @@ struct ib_pd *ib_alloc_pd(struct ib_device *device)
47{ 48{
48 struct ib_pd *pd; 49 struct ib_pd *pd;
49 50
50 pd = device->alloc_pd(device); 51 pd = device->alloc_pd(device, NULL, NULL);
51 52
52 if (!IS_ERR(pd)) { 53 if (!IS_ERR(pd)) {
53 pd->device = device; 54 pd->device = device;
55 pd->uobject = NULL;
54 atomic_set(&pd->usecnt, 0); 56 atomic_set(&pd->usecnt, 0);
55 } 57 }
56 58
@@ -76,8 +78,9 @@ struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
76 ah = pd->device->create_ah(pd, ah_attr); 78 ah = pd->device->create_ah(pd, ah_attr);
77 79
78 if (!IS_ERR(ah)) { 80 if (!IS_ERR(ah)) {
79 ah->device = pd->device; 81 ah->device = pd->device;
80 ah->pd = pd; 82 ah->pd = pd;
83 ah->uobject = NULL;
81 atomic_inc(&pd->usecnt); 84 atomic_inc(&pd->usecnt);
82 } 85 }
83 86
@@ -122,7 +125,7 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
122{ 125{
123 struct ib_qp *qp; 126 struct ib_qp *qp;
124 127
125 qp = pd->device->create_qp(pd, qp_init_attr); 128 qp = pd->device->create_qp(pd, qp_init_attr, NULL);
126 129
127 if (!IS_ERR(qp)) { 130 if (!IS_ERR(qp)) {
128 qp->device = pd->device; 131 qp->device = pd->device;
@@ -130,6 +133,7 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
130 qp->send_cq = qp_init_attr->send_cq; 133 qp->send_cq = qp_init_attr->send_cq;
131 qp->recv_cq = qp_init_attr->recv_cq; 134 qp->recv_cq = qp_init_attr->recv_cq;
132 qp->srq = qp_init_attr->srq; 135 qp->srq = qp_init_attr->srq;
136 qp->uobject = NULL;
133 qp->event_handler = qp_init_attr->event_handler; 137 qp->event_handler = qp_init_attr->event_handler;
134 qp->qp_context = qp_init_attr->qp_context; 138 qp->qp_context = qp_init_attr->qp_context;
135 qp->qp_type = qp_init_attr->qp_type; 139 qp->qp_type = qp_init_attr->qp_type;
@@ -197,10 +201,11 @@ struct ib_cq *ib_create_cq(struct ib_device *device,
197{ 201{
198 struct ib_cq *cq; 202 struct ib_cq *cq;
199 203
200 cq = device->create_cq(device, cqe); 204 cq = device->create_cq(device, cqe, NULL, NULL);
201 205
202 if (!IS_ERR(cq)) { 206 if (!IS_ERR(cq)) {
203 cq->device = device; 207 cq->device = device;
208 cq->uobject = NULL;
204 cq->comp_handler = comp_handler; 209 cq->comp_handler = comp_handler;
205 cq->event_handler = event_handler; 210 cq->event_handler = event_handler;
206 cq->cq_context = cq_context; 211 cq->cq_context = cq_context;
@@ -245,8 +250,9 @@ struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags)
245 mr = pd->device->get_dma_mr(pd, mr_access_flags); 250 mr = pd->device->get_dma_mr(pd, mr_access_flags);
246 251
247 if (!IS_ERR(mr)) { 252 if (!IS_ERR(mr)) {
248 mr->device = pd->device; 253 mr->device = pd->device;
249 mr->pd = pd; 254 mr->pd = pd;
255 mr->uobject = NULL;
250 atomic_inc(&pd->usecnt); 256 atomic_inc(&pd->usecnt);
251 atomic_set(&mr->usecnt, 0); 257 atomic_set(&mr->usecnt, 0);
252 } 258 }
@@ -267,8 +273,9 @@ struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
267 mr_access_flags, iova_start); 273 mr_access_flags, iova_start);
268 274
269 if (!IS_ERR(mr)) { 275 if (!IS_ERR(mr)) {
270 mr->device = pd->device; 276 mr->device = pd->device;
271 mr->pd = pd; 277 mr->pd = pd;
278 mr->uobject = NULL;
272 atomic_inc(&pd->usecnt); 279 atomic_inc(&pd->usecnt);
273 atomic_set(&mr->usecnt, 0); 280 atomic_set(&mr->usecnt, 0);
274 } 281 }
@@ -344,8 +351,9 @@ struct ib_mw *ib_alloc_mw(struct ib_pd *pd)
344 351
345 mw = pd->device->alloc_mw(pd); 352 mw = pd->device->alloc_mw(pd);
346 if (!IS_ERR(mw)) { 353 if (!IS_ERR(mw)) {
347 mw->device = pd->device; 354 mw->device = pd->device;
348 mw->pd = pd; 355 mw->pd = pd;
356 mw->uobject = NULL;
349 atomic_inc(&pd->usecnt); 357 atomic_inc(&pd->usecnt);
350 } 358 }
351 359
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 766e9031ec45..b5aea7b869f6 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
4 * Copyright (c) 2005 Cisco Systems, Inc. All rights reserved.
4 * 5 *
5 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU 7 * licenses. You may choose to be licensed under the terms of the GNU
@@ -742,6 +743,7 @@ err_out:
742} 743}
743 744
744int mthca_init_cq(struct mthca_dev *dev, int nent, 745int mthca_init_cq(struct mthca_dev *dev, int nent,
746 struct mthca_ucontext *ctx, u32 pdn,
745 struct mthca_cq *cq) 747 struct mthca_cq *cq)
746{ 748{
747 int size = nent * MTHCA_CQ_ENTRY_SIZE; 749 int size = nent * MTHCA_CQ_ENTRY_SIZE;
@@ -753,30 +755,33 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
753 755
754 might_sleep(); 756 might_sleep();
755 757
756 cq->ibcq.cqe = nent - 1; 758 cq->ibcq.cqe = nent - 1;
759 cq->is_kernel = !ctx;
757 760
758 cq->cqn = mthca_alloc(&dev->cq_table.alloc); 761 cq->cqn = mthca_alloc(&dev->cq_table.alloc);
759 if (cq->cqn == -1) 762 if (cq->cqn == -1)
760 return -ENOMEM; 763 return -ENOMEM;
761 764
762 if (mthca_is_memfree(dev)) { 765 if (mthca_is_memfree(dev)) {
763 cq->arm_sn = 1;
764
765 err = mthca_table_get(dev, dev->cq_table.table, cq->cqn); 766 err = mthca_table_get(dev, dev->cq_table.table, cq->cqn);
766 if (err) 767 if (err)
767 goto err_out; 768 goto err_out;
768 769
769 err = -ENOMEM; 770 if (cq->is_kernel) {
771 cq->arm_sn = 1;
772
773 err = -ENOMEM;
770 774
771 cq->set_ci_db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, 775 cq->set_ci_db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_CQ_SET_CI,
772 cq->cqn, &cq->set_ci_db); 776 cq->cqn, &cq->set_ci_db);
773 if (cq->set_ci_db_index < 0) 777 if (cq->set_ci_db_index < 0)
774 goto err_out_icm; 778 goto err_out_icm;
775 779
776 cq->arm_db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_CQ_ARM, 780 cq->arm_db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_CQ_ARM,
777 cq->cqn, &cq->arm_db); 781 cq->cqn, &cq->arm_db);
778 if (cq->arm_db_index < 0) 782 if (cq->arm_db_index < 0)
779 goto err_out_ci; 783 goto err_out_ci;
784 }
780 } 785 }
781 786
782 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); 787 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
@@ -785,12 +790,14 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
785 790
786 cq_context = mailbox->buf; 791 cq_context = mailbox->buf;
787 792
788 err = mthca_alloc_cq_buf(dev, size, cq); 793 if (cq->is_kernel) {
789 if (err) 794 err = mthca_alloc_cq_buf(dev, size, cq);
790 goto err_out_mailbox; 795 if (err)
796 goto err_out_mailbox;
791 797
792 for (i = 0; i < nent; ++i) 798 for (i = 0; i < nent; ++i)
793 set_cqe_hw(get_cqe(cq, i)); 799 set_cqe_hw(get_cqe(cq, i));
800 }
794 801
795 spin_lock_init(&cq->lock); 802 spin_lock_init(&cq->lock);
796 atomic_set(&cq->refcount, 1); 803 atomic_set(&cq->refcount, 1);
@@ -801,11 +808,14 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
801 MTHCA_CQ_STATE_DISARMED | 808 MTHCA_CQ_STATE_DISARMED |
802 MTHCA_CQ_FLAG_TR); 809 MTHCA_CQ_FLAG_TR);
803 cq_context->start = cpu_to_be64(0); 810 cq_context->start = cpu_to_be64(0);
804 cq_context->logsize_usrpage = cpu_to_be32((ffs(nent) - 1) << 24 | 811 cq_context->logsize_usrpage = cpu_to_be32((ffs(nent) - 1) << 24);
805 dev->driver_uar.index); 812 if (ctx)
813 cq_context->logsize_usrpage |= cpu_to_be32(ctx->uar.index);
814 else
815 cq_context->logsize_usrpage |= cpu_to_be32(dev->driver_uar.index);
806 cq_context->error_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn); 816 cq_context->error_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn);
807 cq_context->comp_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_COMP].eqn); 817 cq_context->comp_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_COMP].eqn);
808 cq_context->pd = cpu_to_be32(dev->driver_pd.pd_num); 818 cq_context->pd = cpu_to_be32(pdn);
809 cq_context->lkey = cpu_to_be32(cq->mr.ibmr.lkey); 819 cq_context->lkey = cpu_to_be32(cq->mr.ibmr.lkey);
810 cq_context->cqn = cpu_to_be32(cq->cqn); 820 cq_context->cqn = cpu_to_be32(cq->cqn);
811 821
@@ -843,18 +853,20 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
843 return 0; 853 return 0;
844 854
845err_out_free_mr: 855err_out_free_mr:
846 mthca_free_mr(dev, &cq->mr); 856 if (cq->is_kernel) {
847 mthca_free_cq_buf(dev, cq); 857 mthca_free_mr(dev, &cq->mr);
858 mthca_free_cq_buf(dev, cq);
859 }
848 860
849err_out_mailbox: 861err_out_mailbox:
850 mthca_free_mailbox(dev, mailbox); 862 mthca_free_mailbox(dev, mailbox);
851 863
852err_out_arm: 864err_out_arm:
853 if (mthca_is_memfree(dev)) 865 if (cq->is_kernel && mthca_is_memfree(dev))
854 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index); 866 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index);
855 867
856err_out_ci: 868err_out_ci:
857 if (mthca_is_memfree(dev)) 869 if (cq->is_kernel && mthca_is_memfree(dev))
858 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index); 870 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index);
859 871
860err_out_icm: 872err_out_icm:
@@ -892,7 +904,8 @@ void mthca_free_cq(struct mthca_dev *dev,
892 int j; 904 int j;
893 905
894 printk(KERN_ERR "context for CQN %x (cons index %x, next sw %d)\n", 906 printk(KERN_ERR "context for CQN %x (cons index %x, next sw %d)\n",
895 cq->cqn, cq->cons_index, !!next_cqe_sw(cq)); 907 cq->cqn, cq->cons_index,
908 cq->is_kernel ? !!next_cqe_sw(cq) : 0);
896 for (j = 0; j < 16; ++j) 909 for (j = 0; j < 16; ++j)
897 printk(KERN_ERR "[%2x] %08x\n", j * 4, be32_to_cpu(ctx[j])); 910 printk(KERN_ERR "[%2x] %08x\n", j * 4, be32_to_cpu(ctx[j]));
898 } 911 }
@@ -910,12 +923,13 @@ void mthca_free_cq(struct mthca_dev *dev,
910 atomic_dec(&cq->refcount); 923 atomic_dec(&cq->refcount);
911 wait_event(cq->wait, !atomic_read(&cq->refcount)); 924 wait_event(cq->wait, !atomic_read(&cq->refcount));
912 925
913 mthca_free_mr(dev, &cq->mr); 926 if (cq->is_kernel) {
914 mthca_free_cq_buf(dev, cq); 927 mthca_free_mr(dev, &cq->mr);
915 928 mthca_free_cq_buf(dev, cq);
916 if (mthca_is_memfree(dev)) { 929 if (mthca_is_memfree(dev)) {
917 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index); 930 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index);
918 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index); 931 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index);
932 }
919 } 933 }
920 934
921 mthca_table_put(dev, dev->cq_table.table, cq->cqn); 935 mthca_table_put(dev, dev->cq_table.table, cq->cqn);
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index 4127f09dc5ec..5ecdd2eeeb0f 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
4 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 * 5 *
5 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU 7 * licenses. You may choose to be licensed under the terms of the GNU
@@ -378,7 +379,7 @@ void mthca_unregister_device(struct mthca_dev *dev);
378int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar); 379int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar);
379void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar); 380void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar);
380 381
381int mthca_pd_alloc(struct mthca_dev *dev, struct mthca_pd *pd); 382int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd);
382void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd); 383void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd);
383 384
384struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size); 385struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size);
@@ -413,6 +414,7 @@ int mthca_poll_cq(struct ib_cq *ibcq, int num_entries,
413int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify); 414int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify);
414int mthca_arbel_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify); 415int mthca_arbel_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify);
415int mthca_init_cq(struct mthca_dev *dev, int nent, 416int mthca_init_cq(struct mthca_dev *dev, int nent,
417 struct mthca_ucontext *ctx, u32 pdn,
416 struct mthca_cq *cq); 418 struct mthca_cq *cq);
417void mthca_free_cq(struct mthca_dev *dev, 419void mthca_free_cq(struct mthca_dev *dev,
418 struct mthca_cq *cq); 420 struct mthca_cq *cq);
@@ -438,12 +440,14 @@ int mthca_alloc_qp(struct mthca_dev *dev,
438 struct mthca_cq *recv_cq, 440 struct mthca_cq *recv_cq,
439 enum ib_qp_type type, 441 enum ib_qp_type type,
440 enum ib_sig_type send_policy, 442 enum ib_sig_type send_policy,
443 struct ib_qp_cap *cap,
441 struct mthca_qp *qp); 444 struct mthca_qp *qp);
442int mthca_alloc_sqp(struct mthca_dev *dev, 445int mthca_alloc_sqp(struct mthca_dev *dev,
443 struct mthca_pd *pd, 446 struct mthca_pd *pd,
444 struct mthca_cq *send_cq, 447 struct mthca_cq *send_cq,
445 struct mthca_cq *recv_cq, 448 struct mthca_cq *recv_cq,
446 enum ib_sig_type send_policy, 449 enum ib_sig_type send_policy,
450 struct ib_qp_cap *cap,
447 int qpn, 451 int qpn,
448 int port, 452 int port,
449 struct mthca_sqp *sqp); 453 struct mthca_sqp *sqp);
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 09519b604c08..2ef916859e17 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -665,7 +665,7 @@ static int __devinit mthca_setup_hca(struct mthca_dev *dev)
665 goto err_pd_table_free; 665 goto err_pd_table_free;
666 } 666 }
667 667
668 err = mthca_pd_alloc(dev, &dev->driver_pd); 668 err = mthca_pd_alloc(dev, 1, &dev->driver_pd);
669 if (err) { 669 if (err) {
670 mthca_err(dev, "Failed to create driver PD, " 670 mthca_err(dev, "Failed to create driver PD, "
671 "aborting.\n"); 671 "aborting.\n");
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 6d3b05dd9e3f..2a8646150355 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
@@ -47,6 +48,15 @@ enum {
47 MTHCA_TABLE_CHUNK_SIZE = 1 << 18 48 MTHCA_TABLE_CHUNK_SIZE = 1 << 18
48}; 49};
49 50
51struct mthca_user_db_table {
52 struct semaphore mutex;
53 struct {
54 u64 uvirt;
55 struct scatterlist mem;
56 int refcount;
57 } page[0];
58};
59
50void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm) 60void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm)
51{ 61{
52 struct mthca_icm_chunk *chunk, *tmp; 62 struct mthca_icm_chunk *chunk, *tmp;
@@ -344,13 +354,133 @@ void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table)
344 kfree(table); 354 kfree(table);
345} 355}
346 356
347static u64 mthca_uarc_virt(struct mthca_dev *dev, int page) 357static u64 mthca_uarc_virt(struct mthca_dev *dev, struct mthca_uar *uar, int page)
348{ 358{
349 return dev->uar_table.uarc_base + 359 return dev->uar_table.uarc_base +
350 dev->driver_uar.index * dev->uar_table.uarc_size + 360 uar->index * dev->uar_table.uarc_size +
351 page * 4096; 361 page * 4096;
352} 362}
353 363
364int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
365 struct mthca_user_db_table *db_tab, int index, u64 uaddr)
366{
367 int ret = 0;
368 u8 status;
369 int i;
370
371 if (!mthca_is_memfree(dev))
372 return 0;
373
374 if (index < 0 || index > dev->uar_table.uarc_size / 8)
375 return -EINVAL;
376
377 down(&db_tab->mutex);
378
379 i = index / MTHCA_DB_REC_PER_PAGE;
380
381 if ((db_tab->page[i].refcount >= MTHCA_DB_REC_PER_PAGE) ||
382 (db_tab->page[i].uvirt && db_tab->page[i].uvirt != uaddr) ||
383 (uaddr & 4095)) {
384 ret = -EINVAL;
385 goto out;
386 }
387
388 if (db_tab->page[i].refcount) {
389 ++db_tab->page[i].refcount;
390 goto out;
391 }
392
393 ret = get_user_pages(current, current->mm, uaddr & PAGE_MASK, 1, 1, 0,
394 &db_tab->page[i].mem.page, NULL);
395 if (ret < 0)
396 goto out;
397
398 db_tab->page[i].mem.length = 4096;
399 db_tab->page[i].mem.offset = uaddr & ~PAGE_MASK;
400
401 ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
402 if (ret < 0) {
403 put_page(db_tab->page[i].mem.page);
404 goto out;
405 }
406
407 ret = mthca_MAP_ICM_page(dev, sg_dma_address(&db_tab->page[i].mem),
408 mthca_uarc_virt(dev, uar, i), &status);
409 if (!ret && status)
410 ret = -EINVAL;
411 if (ret) {
412 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
413 put_page(db_tab->page[i].mem.page);
414 goto out;
415 }
416
417 db_tab->page[i].uvirt = uaddr;
418 db_tab->page[i].refcount = 1;
419
420out:
421 up(&db_tab->mutex);
422 return ret;
423}
424
425void mthca_unmap_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
426 struct mthca_user_db_table *db_tab, int index)
427{
428 if (!mthca_is_memfree(dev))
429 return;
430
431 /*
432 * To make our bookkeeping simpler, we don't unmap DB
433 * pages until we clean up the whole db table.
434 */
435
436 down(&db_tab->mutex);
437
438 --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount;
439
440 up(&db_tab->mutex);
441}
442
443struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev)
444{
445 struct mthca_user_db_table *db_tab;
446 int npages;
447 int i;
448
449 if (!mthca_is_memfree(dev))
450 return NULL;
451
452 npages = dev->uar_table.uarc_size / 4096;
453 db_tab = kmalloc(sizeof *db_tab + npages * sizeof *db_tab->page, GFP_KERNEL);
454 if (!db_tab)
455 return ERR_PTR(-ENOMEM);
456
457 init_MUTEX(&db_tab->mutex);
458 for (i = 0; i < npages; ++i) {
459 db_tab->page[i].refcount = 0;
460 db_tab->page[i].uvirt = 0;
461 }
462
463 return db_tab;
464}
465
466void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar,
467 struct mthca_user_db_table *db_tab)
468{
469 int i;
470 u8 status;
471
472 if (!mthca_is_memfree(dev))
473 return;
474
475 for (i = 0; i < dev->uar_table.uarc_size / 4096; ++i) {
476 if (db_tab->page[i].uvirt) {
477 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1, &status);
478 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
479 put_page(db_tab->page[i].mem.page);
480 }
481 }
482}
483
354int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, u32 **db) 484int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, u32 **db)
355{ 485{
356 int group; 486 int group;
@@ -407,7 +537,8 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, u32 **db)
407 } 537 }
408 memset(page->db_rec, 0, 4096); 538 memset(page->db_rec, 0, 4096);
409 539
410 ret = mthca_MAP_ICM_page(dev, page->mapping, mthca_uarc_virt(dev, i), &status); 540 ret = mthca_MAP_ICM_page(dev, page->mapping,
541 mthca_uarc_virt(dev, &dev->driver_uar, i), &status);
411 if (!ret && status) 542 if (!ret && status)
412 ret = -EINVAL; 543 ret = -EINVAL;
413 if (ret) { 544 if (ret) {
@@ -461,7 +592,7 @@ void mthca_free_db(struct mthca_dev *dev, int type, int db_index)
461 592
462 if (bitmap_empty(page->used, MTHCA_DB_REC_PER_PAGE) && 593 if (bitmap_empty(page->used, MTHCA_DB_REC_PER_PAGE) &&
463 i >= dev->db_tab->max_group1 - 1) { 594 i >= dev->db_tab->max_group1 - 1) {
464 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, i), 1, &status); 595 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1, &status);
465 596
466 dma_free_coherent(&dev->pdev->dev, 4096, 597 dma_free_coherent(&dev->pdev->dev, 4096,
467 page->db_rec, page->mapping); 598 page->db_rec, page->mapping);
@@ -530,7 +661,7 @@ void mthca_cleanup_db_tab(struct mthca_dev *dev)
530 if (!bitmap_empty(dev->db_tab->page[i].used, MTHCA_DB_REC_PER_PAGE)) 661 if (!bitmap_empty(dev->db_tab->page[i].used, MTHCA_DB_REC_PER_PAGE))
531 mthca_warn(dev, "Kernel UARC page %d not empty\n", i); 662 mthca_warn(dev, "Kernel UARC page %d not empty\n", i);
532 663
533 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, i), 1, &status); 664 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1, &status);
534 665
535 dma_free_coherent(&dev->pdev->dev, 4096, 666 dma_free_coherent(&dev->pdev->dev, 4096,
536 dev->db_tab->page[i].db_rec, 667 dev->db_tab->page[i].db_rec,
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.h b/drivers/infiniband/hw/mthca/mthca_memfree.h
index fe7be2a6bc4a..4761d844cb5f 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.h
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.h
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
@@ -148,7 +149,7 @@ struct mthca_db_table {
148 struct semaphore mutex; 149 struct semaphore mutex;
149}; 150};
150 151
151enum { 152enum mthca_db_type {
152 MTHCA_DB_TYPE_INVALID = 0x0, 153 MTHCA_DB_TYPE_INVALID = 0x0,
153 MTHCA_DB_TYPE_CQ_SET_CI = 0x1, 154 MTHCA_DB_TYPE_CQ_SET_CI = 0x1,
154 MTHCA_DB_TYPE_CQ_ARM = 0x2, 155 MTHCA_DB_TYPE_CQ_ARM = 0x2,
@@ -158,6 +159,17 @@ enum {
158 MTHCA_DB_TYPE_GROUP_SEP = 0x7 159 MTHCA_DB_TYPE_GROUP_SEP = 0x7
159}; 160};
160 161
162struct mthca_user_db_table;
163struct mthca_uar;
164
165int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
166 struct mthca_user_db_table *db_tab, int index, u64 uaddr);
167void mthca_unmap_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
168 struct mthca_user_db_table *db_tab, int index);
169struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev);
170void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar,
171 struct mthca_user_db_table *db_tab);
172
161int mthca_init_db_tab(struct mthca_dev *dev); 173int mthca_init_db_tab(struct mthca_dev *dev);
162void mthca_cleanup_db_tab(struct mthca_dev *dev); 174void mthca_cleanup_db_tab(struct mthca_dev *dev);
163int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, u32 **db); 175int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, u32 **db);
diff --git a/drivers/infiniband/hw/mthca/mthca_pd.c b/drivers/infiniband/hw/mthca/mthca_pd.c
index ea66847e4ea3..c2c899844e98 100644
--- a/drivers/infiniband/hw/mthca/mthca_pd.c
+++ b/drivers/infiniband/hw/mthca/mthca_pd.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
@@ -37,23 +38,27 @@
37 38
38#include "mthca_dev.h" 39#include "mthca_dev.h"
39 40
40int mthca_pd_alloc(struct mthca_dev *dev, struct mthca_pd *pd) 41int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd)
41{ 42{
42 int err; 43 int err = 0;
43 44
44 might_sleep(); 45 might_sleep();
45 46
47 pd->privileged = privileged;
48
46 atomic_set(&pd->sqp_count, 0); 49 atomic_set(&pd->sqp_count, 0);
47 pd->pd_num = mthca_alloc(&dev->pd_table.alloc); 50 pd->pd_num = mthca_alloc(&dev->pd_table.alloc);
48 if (pd->pd_num == -1) 51 if (pd->pd_num == -1)
49 return -ENOMEM; 52 return -ENOMEM;
50 53
51 err = mthca_mr_alloc_notrans(dev, pd->pd_num, 54 if (privileged) {
52 MTHCA_MPT_FLAG_LOCAL_READ | 55 err = mthca_mr_alloc_notrans(dev, pd->pd_num,
53 MTHCA_MPT_FLAG_LOCAL_WRITE, 56 MTHCA_MPT_FLAG_LOCAL_READ |
54 &pd->ntmr); 57 MTHCA_MPT_FLAG_LOCAL_WRITE,
55 if (err) 58 &pd->ntmr);
56 mthca_free(&dev->pd_table.alloc, pd->pd_num); 59 if (err)
60 mthca_free(&dev->pd_table.alloc, pd->pd_num);
61 }
57 62
58 return err; 63 return err;
59} 64}
@@ -61,7 +66,8 @@ int mthca_pd_alloc(struct mthca_dev *dev, struct mthca_pd *pd)
61void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd) 66void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd)
62{ 67{
63 might_sleep(); 68 might_sleep();
64 mthca_free_mr(dev, &pd->ntmr); 69 if (pd->privileged)
70 mthca_free_mr(dev, &pd->ntmr);
65 mthca_free(&dev->pd_table.alloc, pd->pd_num); 71 mthca_free(&dev->pd_table.alloc, pd->pd_num);
66} 72}
67 73
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 0b5adfd91597..7a58ce90e179 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
4 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 * 5 *
5 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU 7 * licenses. You may choose to be licensed under the terms of the GNU
@@ -34,9 +35,12 @@
34 */ 35 */
35 36
36#include <ib_smi.h> 37#include <ib_smi.h>
38#include <linux/mm.h>
37 39
38#include "mthca_dev.h" 40#include "mthca_dev.h"
39#include "mthca_cmd.h" 41#include "mthca_cmd.h"
42#include "mthca_user.h"
43#include "mthca_memfree.h"
40 44
41static int mthca_query_device(struct ib_device *ibdev, 45static int mthca_query_device(struct ib_device *ibdev,
42 struct ib_device_attr *props) 46 struct ib_device_attr *props)
@@ -284,7 +288,78 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
284 return err; 288 return err;
285} 289}
286 290
287static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev) 291static struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev,
292 struct ib_udata *udata)
293{
294 struct mthca_alloc_ucontext_resp uresp;
295 struct mthca_ucontext *context;
296 int err;
297
298 memset(&uresp, 0, sizeof uresp);
299
300 uresp.qp_tab_size = to_mdev(ibdev)->limits.num_qps;
301 if (mthca_is_memfree(to_mdev(ibdev)))
302 uresp.uarc_size = to_mdev(ibdev)->uar_table.uarc_size;
303 else
304 uresp.uarc_size = 0;
305
306 context = kmalloc(sizeof *context, GFP_KERNEL);
307 if (!context)
308 return ERR_PTR(-ENOMEM);
309
310 err = mthca_uar_alloc(to_mdev(ibdev), &context->uar);
311 if (err) {
312 kfree(context);
313 return ERR_PTR(err);
314 }
315
316 context->db_tab = mthca_init_user_db_tab(to_mdev(ibdev));
317 if (IS_ERR(context->db_tab)) {
318 err = PTR_ERR(context->db_tab);
319 mthca_uar_free(to_mdev(ibdev), &context->uar);
320 kfree(context);
321 return ERR_PTR(err);
322 }
323
324 if (ib_copy_to_udata(udata, &uresp, sizeof uresp)) {
325 mthca_cleanup_user_db_tab(to_mdev(ibdev), &context->uar, context->db_tab);
326 mthca_uar_free(to_mdev(ibdev), &context->uar);
327 kfree(context);
328 return ERR_PTR(-EFAULT);
329 }
330
331 return &context->ibucontext;
332}
333
334static int mthca_dealloc_ucontext(struct ib_ucontext *context)
335{
336 mthca_cleanup_user_db_tab(to_mdev(context->device), &to_mucontext(context)->uar,
337 to_mucontext(context)->db_tab);
338 mthca_uar_free(to_mdev(context->device), &to_mucontext(context)->uar);
339 kfree(to_mucontext(context));
340
341 return 0;
342}
343
344static int mthca_mmap_uar(struct ib_ucontext *context,
345 struct vm_area_struct *vma)
346{
347 if (vma->vm_end - vma->vm_start != PAGE_SIZE)
348 return -EINVAL;
349
350 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
351
352 if (remap_pfn_range(vma, vma->vm_start,
353 to_mucontext(context)->uar.pfn,
354 PAGE_SIZE, vma->vm_page_prot))
355 return -EAGAIN;
356
357 return 0;
358}
359
360static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev,
361 struct ib_ucontext *context,
362 struct ib_udata *udata)
288{ 363{
289 struct mthca_pd *pd; 364 struct mthca_pd *pd;
290 int err; 365 int err;
@@ -293,12 +368,20 @@ static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev)
293 if (!pd) 368 if (!pd)
294 return ERR_PTR(-ENOMEM); 369 return ERR_PTR(-ENOMEM);
295 370
296 err = mthca_pd_alloc(to_mdev(ibdev), pd); 371 err = mthca_pd_alloc(to_mdev(ibdev), !context, pd);
297 if (err) { 372 if (err) {
298 kfree(pd); 373 kfree(pd);
299 return ERR_PTR(err); 374 return ERR_PTR(err);
300 } 375 }
301 376
377 if (context) {
378 if (ib_copy_to_udata(udata, &pd->pd_num, sizeof (__u32))) {
379 mthca_pd_free(to_mdev(ibdev), pd);
380 kfree(pd);
381 return ERR_PTR(-EFAULT);
382 }
383 }
384
302 return &pd->ibpd; 385 return &pd->ibpd;
303} 386}
304 387
@@ -338,8 +421,10 @@ static int mthca_ah_destroy(struct ib_ah *ah)
338} 421}
339 422
340static struct ib_qp *mthca_create_qp(struct ib_pd *pd, 423static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
341 struct ib_qp_init_attr *init_attr) 424 struct ib_qp_init_attr *init_attr,
425 struct ib_udata *udata)
342{ 426{
427 struct mthca_create_qp ucmd;
343 struct mthca_qp *qp; 428 struct mthca_qp *qp;
344 int err; 429 int err;
345 430
@@ -348,41 +433,82 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
348 case IB_QPT_UC: 433 case IB_QPT_UC:
349 case IB_QPT_UD: 434 case IB_QPT_UD:
350 { 435 {
436 struct mthca_ucontext *context;
437
351 qp = kmalloc(sizeof *qp, GFP_KERNEL); 438 qp = kmalloc(sizeof *qp, GFP_KERNEL);
352 if (!qp) 439 if (!qp)
353 return ERR_PTR(-ENOMEM); 440 return ERR_PTR(-ENOMEM);
354 441
355 qp->sq.max = init_attr->cap.max_send_wr; 442 if (pd->uobject) {
356 qp->rq.max = init_attr->cap.max_recv_wr; 443 context = to_mucontext(pd->uobject->context);
357 qp->sq.max_gs = init_attr->cap.max_send_sge; 444
358 qp->rq.max_gs = init_attr->cap.max_recv_sge; 445 if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
446 return ERR_PTR(-EFAULT);
447
448 err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
449 context->db_tab,
450 ucmd.sq_db_index, ucmd.sq_db_page);
451 if (err) {
452 kfree(qp);
453 return ERR_PTR(err);
454 }
455
456 err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
457 context->db_tab,
458 ucmd.rq_db_index, ucmd.rq_db_page);
459 if (err) {
460 mthca_unmap_user_db(to_mdev(pd->device),
461 &context->uar,
462 context->db_tab,
463 ucmd.sq_db_index);
464 kfree(qp);
465 return ERR_PTR(err);
466 }
467
468 qp->mr.ibmr.lkey = ucmd.lkey;
469 qp->sq.db_index = ucmd.sq_db_index;
470 qp->rq.db_index = ucmd.rq_db_index;
471 }
359 472
360 err = mthca_alloc_qp(to_mdev(pd->device), to_mpd(pd), 473 err = mthca_alloc_qp(to_mdev(pd->device), to_mpd(pd),
361 to_mcq(init_attr->send_cq), 474 to_mcq(init_attr->send_cq),
362 to_mcq(init_attr->recv_cq), 475 to_mcq(init_attr->recv_cq),
363 init_attr->qp_type, init_attr->sq_sig_type, 476 init_attr->qp_type, init_attr->sq_sig_type,
364 qp); 477 &init_attr->cap, qp);
478
479 if (err && pd->uobject) {
480 context = to_mucontext(pd->uobject->context);
481
482 mthca_unmap_user_db(to_mdev(pd->device),
483 &context->uar,
484 context->db_tab,
485 ucmd.sq_db_index);
486 mthca_unmap_user_db(to_mdev(pd->device),
487 &context->uar,
488 context->db_tab,
489 ucmd.rq_db_index);
490 }
491
365 qp->ibqp.qp_num = qp->qpn; 492 qp->ibqp.qp_num = qp->qpn;
366 break; 493 break;
367 } 494 }
368 case IB_QPT_SMI: 495 case IB_QPT_SMI:
369 case IB_QPT_GSI: 496 case IB_QPT_GSI:
370 { 497 {
498 /* Don't allow userspace to create special QPs */
499 if (pd->uobject)
500 return ERR_PTR(-EINVAL);
501
371 qp = kmalloc(sizeof (struct mthca_sqp), GFP_KERNEL); 502 qp = kmalloc(sizeof (struct mthca_sqp), GFP_KERNEL);
372 if (!qp) 503 if (!qp)
373 return ERR_PTR(-ENOMEM); 504 return ERR_PTR(-ENOMEM);
374 505
375 qp->sq.max = init_attr->cap.max_send_wr;
376 qp->rq.max = init_attr->cap.max_recv_wr;
377 qp->sq.max_gs = init_attr->cap.max_send_sge;
378 qp->rq.max_gs = init_attr->cap.max_recv_sge;
379
380 qp->ibqp.qp_num = init_attr->qp_type == IB_QPT_SMI ? 0 : 1; 506 qp->ibqp.qp_num = init_attr->qp_type == IB_QPT_SMI ? 0 : 1;
381 507
382 err = mthca_alloc_sqp(to_mdev(pd->device), to_mpd(pd), 508 err = mthca_alloc_sqp(to_mdev(pd->device), to_mpd(pd),
383 to_mcq(init_attr->send_cq), 509 to_mcq(init_attr->send_cq),
384 to_mcq(init_attr->recv_cq), 510 to_mcq(init_attr->recv_cq),
385 init_attr->sq_sig_type, 511 init_attr->sq_sig_type, &init_attr->cap,
386 qp->ibqp.qp_num, init_attr->port_num, 512 qp->ibqp.qp_num, init_attr->port_num,
387 to_msqp(qp)); 513 to_msqp(qp));
388 break; 514 break;
@@ -397,42 +523,115 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
397 return ERR_PTR(err); 523 return ERR_PTR(err);
398 } 524 }
399 525
400 init_attr->cap.max_inline_data = 0; 526 init_attr->cap.max_inline_data = 0;
527 init_attr->cap.max_send_wr = qp->sq.max;
528 init_attr->cap.max_recv_wr = qp->rq.max;
529 init_attr->cap.max_send_sge = qp->sq.max_gs;
530 init_attr->cap.max_recv_sge = qp->rq.max_gs;
401 531
402 return &qp->ibqp; 532 return &qp->ibqp;
403} 533}
404 534
405static int mthca_destroy_qp(struct ib_qp *qp) 535static int mthca_destroy_qp(struct ib_qp *qp)
406{ 536{
537 if (qp->uobject) {
538 mthca_unmap_user_db(to_mdev(qp->device),
539 &to_mucontext(qp->uobject->context)->uar,
540 to_mucontext(qp->uobject->context)->db_tab,
541 to_mqp(qp)->sq.db_index);
542 mthca_unmap_user_db(to_mdev(qp->device),
543 &to_mucontext(qp->uobject->context)->uar,
544 to_mucontext(qp->uobject->context)->db_tab,
545 to_mqp(qp)->rq.db_index);
546 }
407 mthca_free_qp(to_mdev(qp->device), to_mqp(qp)); 547 mthca_free_qp(to_mdev(qp->device), to_mqp(qp));
408 kfree(qp); 548 kfree(qp);
409 return 0; 549 return 0;
410} 550}
411 551
412static struct ib_cq *mthca_create_cq(struct ib_device *ibdev, int entries) 552static struct ib_cq *mthca_create_cq(struct ib_device *ibdev, int entries,
553 struct ib_ucontext *context,
554 struct ib_udata *udata)
413{ 555{
556 struct mthca_create_cq ucmd;
414 struct mthca_cq *cq; 557 struct mthca_cq *cq;
415 int nent; 558 int nent;
416 int err; 559 int err;
417 560
561 if (context) {
562 if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
563 return ERR_PTR(-EFAULT);
564
565 err = mthca_map_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
566 to_mucontext(context)->db_tab,
567 ucmd.set_db_index, ucmd.set_db_page);
568 if (err)
569 return ERR_PTR(err);
570
571 err = mthca_map_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
572 to_mucontext(context)->db_tab,
573 ucmd.arm_db_index, ucmd.arm_db_page);
574 if (err)
575 goto err_unmap_set;
576 }
577
418 cq = kmalloc(sizeof *cq, GFP_KERNEL); 578 cq = kmalloc(sizeof *cq, GFP_KERNEL);
419 if (!cq) 579 if (!cq) {
420 return ERR_PTR(-ENOMEM); 580 err = -ENOMEM;
581 goto err_unmap_arm;
582 }
583
584 if (context) {
585 cq->mr.ibmr.lkey = ucmd.lkey;
586 cq->set_ci_db_index = ucmd.set_db_index;
587 cq->arm_db_index = ucmd.arm_db_index;
588 }
421 589
422 for (nent = 1; nent <= entries; nent <<= 1) 590 for (nent = 1; nent <= entries; nent <<= 1)
423 ; /* nothing */ 591 ; /* nothing */
424 592
425 err = mthca_init_cq(to_mdev(ibdev), nent, cq); 593 err = mthca_init_cq(to_mdev(ibdev), nent,
426 if (err) { 594 context ? to_mucontext(context) : NULL,
427 kfree(cq); 595 context ? ucmd.pdn : to_mdev(ibdev)->driver_pd.pd_num,
428 cq = ERR_PTR(err); 596 cq);
597 if (err)
598 goto err_free;
599
600 if (context && ib_copy_to_udata(udata, &cq->cqn, sizeof (__u32))) {
601 mthca_free_cq(to_mdev(ibdev), cq);
602 goto err_free;
429 } 603 }
430 604
431 return &cq->ibcq; 605 return &cq->ibcq;
606
607err_free:
608 kfree(cq);
609
610err_unmap_arm:
611 if (context)
612 mthca_unmap_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
613 to_mucontext(context)->db_tab, ucmd.arm_db_index);
614
615err_unmap_set:
616 if (context)
617 mthca_unmap_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
618 to_mucontext(context)->db_tab, ucmd.set_db_index);
619
620 return ERR_PTR(err);
432} 621}
433 622
434static int mthca_destroy_cq(struct ib_cq *cq) 623static int mthca_destroy_cq(struct ib_cq *cq)
435{ 624{
625 if (cq->uobject) {
626 mthca_unmap_user_db(to_mdev(cq->device),
627 &to_mucontext(cq->uobject->context)->uar,
628 to_mucontext(cq->uobject->context)->db_tab,
629 to_mcq(cq)->arm_db_index);
630 mthca_unmap_user_db(to_mdev(cq->device),
631 &to_mucontext(cq->uobject->context)->uar,
632 to_mucontext(cq->uobject->context)->db_tab,
633 to_mcq(cq)->set_ci_db_index);
634 }
436 mthca_free_cq(to_mdev(cq->device), to_mcq(cq)); 635 mthca_free_cq(to_mdev(cq->device), to_mcq(cq));
437 kfree(cq); 636 kfree(cq);
438 637
@@ -568,6 +767,87 @@ static struct ib_mr *mthca_reg_phys_mr(struct ib_pd *pd,
568 return &mr->ibmr; 767 return &mr->ibmr;
569} 768}
570 769
770static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, struct ib_umem *region,
771 int acc, struct ib_udata *udata)
772{
773 struct mthca_dev *dev = to_mdev(pd->device);
774 struct ib_umem_chunk *chunk;
775 struct mthca_mr *mr;
776 u64 *pages;
777 int shift, n, len;
778 int i, j, k;
779 int err = 0;
780
781 shift = ffs(region->page_size) - 1;
782
783 mr = kmalloc(sizeof *mr, GFP_KERNEL);
784 if (!mr)
785 return ERR_PTR(-ENOMEM);
786
787 n = 0;
788 list_for_each_entry(chunk, &region->chunk_list, list)
789 n += chunk->nents;
790
791 mr->mtt = mthca_alloc_mtt(dev, n);
792 if (IS_ERR(mr->mtt)) {
793 err = PTR_ERR(mr->mtt);
794 goto err;
795 }
796
797 pages = (u64 *) __get_free_page(GFP_KERNEL);
798 if (!pages) {
799 err = -ENOMEM;
800 goto err_mtt;
801 }
802
803 i = n = 0;
804
805 list_for_each_entry(chunk, &region->chunk_list, list)
806 for (j = 0; j < chunk->nmap; ++j) {
807 len = sg_dma_len(&chunk->page_list[j]) >> shift;
808 for (k = 0; k < len; ++k) {
809 pages[i++] = sg_dma_address(&chunk->page_list[j]) +
810 region->page_size * k;
811 /*
812 * Be friendly to WRITE_MTT command
813 * and leave two empty slots for the
814 * index and reserved fields of the
815 * mailbox.
816 */
817 if (i == PAGE_SIZE / sizeof (u64) - 2) {
818 err = mthca_write_mtt(dev, mr->mtt,
819 n, pages, i);
820 if (err)
821 goto mtt_done;
822 n += i;
823 i = 0;
824 }
825 }
826 }
827
828 if (i)
829 err = mthca_write_mtt(dev, mr->mtt, n, pages, i);
830mtt_done:
831 free_page((unsigned long) pages);
832 if (err)
833 goto err_mtt;
834
835 err = mthca_mr_alloc(dev, to_mpd(pd)->pd_num, shift, region->virt_base,
836 region->length, convert_access(acc), mr);
837
838 if (err)
839 goto err_mtt;
840
841 return &mr->ibmr;
842
843err_mtt:
844 mthca_free_mtt(dev, mr->mtt);
845
846err:
847 kfree(mr);
848 return ERR_PTR(err);
849}
850
571static int mthca_dereg_mr(struct ib_mr *mr) 851static int mthca_dereg_mr(struct ib_mr *mr)
572{ 852{
573 struct mthca_mr *mmr = to_mmr(mr); 853 struct mthca_mr *mmr = to_mmr(mr);
@@ -692,6 +972,8 @@ int mthca_register_device(struct mthca_dev *dev)
692 int i; 972 int i;
693 973
694 strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX); 974 strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX);
975 dev->ib_dev.owner = THIS_MODULE;
976
695 dev->ib_dev.node_type = IB_NODE_CA; 977 dev->ib_dev.node_type = IB_NODE_CA;
696 dev->ib_dev.phys_port_cnt = dev->limits.num_ports; 978 dev->ib_dev.phys_port_cnt = dev->limits.num_ports;
697 dev->ib_dev.dma_device = &dev->pdev->dev; 979 dev->ib_dev.dma_device = &dev->pdev->dev;
@@ -701,6 +983,9 @@ int mthca_register_device(struct mthca_dev *dev)
701 dev->ib_dev.modify_port = mthca_modify_port; 983 dev->ib_dev.modify_port = mthca_modify_port;
702 dev->ib_dev.query_pkey = mthca_query_pkey; 984 dev->ib_dev.query_pkey = mthca_query_pkey;
703 dev->ib_dev.query_gid = mthca_query_gid; 985 dev->ib_dev.query_gid = mthca_query_gid;
986 dev->ib_dev.alloc_ucontext = mthca_alloc_ucontext;
987 dev->ib_dev.dealloc_ucontext = mthca_dealloc_ucontext;
988 dev->ib_dev.mmap = mthca_mmap_uar;
704 dev->ib_dev.alloc_pd = mthca_alloc_pd; 989 dev->ib_dev.alloc_pd = mthca_alloc_pd;
705 dev->ib_dev.dealloc_pd = mthca_dealloc_pd; 990 dev->ib_dev.dealloc_pd = mthca_dealloc_pd;
706 dev->ib_dev.create_ah = mthca_ah_create; 991 dev->ib_dev.create_ah = mthca_ah_create;
@@ -713,6 +998,7 @@ int mthca_register_device(struct mthca_dev *dev)
713 dev->ib_dev.poll_cq = mthca_poll_cq; 998 dev->ib_dev.poll_cq = mthca_poll_cq;
714 dev->ib_dev.get_dma_mr = mthca_get_dma_mr; 999 dev->ib_dev.get_dma_mr = mthca_get_dma_mr;
715 dev->ib_dev.reg_phys_mr = mthca_reg_phys_mr; 1000 dev->ib_dev.reg_phys_mr = mthca_reg_phys_mr;
1001 dev->ib_dev.reg_user_mr = mthca_reg_user_mr;
716 dev->ib_dev.dereg_mr = mthca_dereg_mr; 1002 dev->ib_dev.dereg_mr = mthca_dereg_mr;
717 1003
718 if (dev->mthca_flags & MTHCA_FLAG_FMR) { 1004 if (dev->mthca_flags & MTHCA_FLAG_FMR) {
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h
index 4d976cccb1a8..1d032791cc8b 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.h
+++ b/drivers/infiniband/hw/mthca/mthca_provider.h
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
@@ -54,6 +55,14 @@ struct mthca_uar {
54 int index; 55 int index;
55}; 56};
56 57
58struct mthca_user_db_table;
59
60struct mthca_ucontext {
61 struct ib_ucontext ibucontext;
62 struct mthca_uar uar;
63 struct mthca_user_db_table *db_tab;
64};
65
57struct mthca_mtt; 66struct mthca_mtt;
58 67
59struct mthca_mr { 68struct mthca_mr {
@@ -83,6 +92,7 @@ struct mthca_pd {
83 u32 pd_num; 92 u32 pd_num;
84 atomic_t sqp_count; 93 atomic_t sqp_count;
85 struct mthca_mr ntmr; 94 struct mthca_mr ntmr;
95 int privileged;
86}; 96};
87 97
88struct mthca_eq { 98struct mthca_eq {
@@ -167,6 +177,7 @@ struct mthca_cq {
167 int cqn; 177 int cqn;
168 u32 cons_index; 178 u32 cons_index;
169 int is_direct; 179 int is_direct;
180 int is_kernel;
170 181
171 /* Next fields are Arbel only */ 182 /* Next fields are Arbel only */
172 int set_ci_db_index; 183 int set_ci_db_index;
@@ -236,6 +247,11 @@ struct mthca_sqp {
236 dma_addr_t header_dma; 247 dma_addr_t header_dma;
237}; 248};
238 249
250static inline struct mthca_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
251{
252 return container_of(ibucontext, struct mthca_ucontext, ibucontext);
253}
254
239static inline struct mthca_fmr *to_mfmr(struct ib_fmr *ibmr) 255static inline struct mthca_fmr *to_mfmr(struct ib_fmr *ibmr)
240{ 256{
241 return container_of(ibmr, struct mthca_fmr, ibmr); 257 return container_of(ibmr, struct mthca_fmr, ibmr);
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 163a8ef4186f..f7126b14d5ae 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
@@ -46,7 +47,9 @@ enum {
46 MTHCA_MAX_DIRECT_QP_SIZE = 4 * PAGE_SIZE, 47 MTHCA_MAX_DIRECT_QP_SIZE = 4 * PAGE_SIZE,
47 MTHCA_ACK_REQ_FREQ = 10, 48 MTHCA_ACK_REQ_FREQ = 10,
48 MTHCA_FLIGHT_LIMIT = 9, 49 MTHCA_FLIGHT_LIMIT = 9,
49 MTHCA_UD_HEADER_SIZE = 72 /* largest UD header possible */ 50 MTHCA_UD_HEADER_SIZE = 72, /* largest UD header possible */
51 MTHCA_INLINE_HEADER_SIZE = 4, /* data segment overhead for inline */
52 MTHCA_INLINE_CHUNK_SIZE = 16 /* inline data segment chunk */
50}; 53};
51 54
52enum { 55enum {
@@ -689,7 +692,11 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
689 692
690 /* leave arbel_sched_queue as 0 */ 693 /* leave arbel_sched_queue as 0 */
691 694
692 qp_context->usr_page = cpu_to_be32(dev->driver_uar.index); 695 if (qp->ibqp.uobject)
696 qp_context->usr_page =
697 cpu_to_be32(to_mucontext(qp->ibqp.uobject->context)->uar.index);
698 else
699 qp_context->usr_page = cpu_to_be32(dev->driver_uar.index);
693 qp_context->local_qpn = cpu_to_be32(qp->qpn); 700 qp_context->local_qpn = cpu_to_be32(qp->qpn);
694 if (attr_mask & IB_QP_DEST_QPN) { 701 if (attr_mask & IB_QP_DEST_QPN) {
695 qp_context->remote_qpn = cpu_to_be32(attr->dest_qp_num); 702 qp_context->remote_qpn = cpu_to_be32(attr->dest_qp_num);
@@ -954,6 +961,15 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
954 961
955 qp->send_wqe_offset = ALIGN(qp->rq.max << qp->rq.wqe_shift, 962 qp->send_wqe_offset = ALIGN(qp->rq.max << qp->rq.wqe_shift,
956 1 << qp->sq.wqe_shift); 963 1 << qp->sq.wqe_shift);
964
965 /*
966 * If this is a userspace QP, we don't actually have to
967 * allocate anything. All we need is to calculate the WQE
968 * sizes and the send_wqe_offset, so we're done now.
969 */
970 if (pd->ibpd.uobject)
971 return 0;
972
957 size = PAGE_ALIGN(qp->send_wqe_offset + 973 size = PAGE_ALIGN(qp->send_wqe_offset +
958 (qp->sq.max << qp->sq.wqe_shift)); 974 (qp->sq.max << qp->sq.wqe_shift));
959 975
@@ -1053,10 +1069,32 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
1053 return err; 1069 return err;
1054} 1070}
1055 1071
1056static int mthca_alloc_memfree(struct mthca_dev *dev, 1072static void mthca_free_wqe_buf(struct mthca_dev *dev,
1057 struct mthca_qp *qp) 1073 struct mthca_qp *qp)
1058{ 1074{
1059 int ret = 0; 1075 int i;
1076 int size = PAGE_ALIGN(qp->send_wqe_offset +
1077 (qp->sq.max << qp->sq.wqe_shift));
1078
1079 if (qp->is_direct) {
1080 dma_free_coherent(&dev->pdev->dev, size, qp->queue.direct.buf,
1081 pci_unmap_addr(&qp->queue.direct, mapping));
1082 } else {
1083 for (i = 0; i < size / PAGE_SIZE; ++i) {
1084 dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
1085 qp->queue.page_list[i].buf,
1086 pci_unmap_addr(&qp->queue.page_list[i],
1087 mapping));
1088 }
1089 }
1090
1091 kfree(qp->wrid);
1092}
1093
1094static int mthca_map_memfree(struct mthca_dev *dev,
1095 struct mthca_qp *qp)
1096{
1097 int ret;
1060 1098
1061 if (mthca_is_memfree(dev)) { 1099 if (mthca_is_memfree(dev)) {
1062 ret = mthca_table_get(dev, dev->qp_table.qp_table, qp->qpn); 1100 ret = mthca_table_get(dev, dev->qp_table.qp_table, qp->qpn);
@@ -1067,35 +1105,15 @@ static int mthca_alloc_memfree(struct mthca_dev *dev,
1067 if (ret) 1105 if (ret)
1068 goto err_qpc; 1106 goto err_qpc;
1069 1107
1070 ret = mthca_table_get(dev, dev->qp_table.rdb_table, 1108 ret = mthca_table_get(dev, dev->qp_table.rdb_table,
1071 qp->qpn << dev->qp_table.rdb_shift); 1109 qp->qpn << dev->qp_table.rdb_shift);
1072 if (ret) 1110 if (ret)
1073 goto err_eqpc; 1111 goto err_eqpc;
1074
1075 qp->rq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_RQ,
1076 qp->qpn, &qp->rq.db);
1077 if (qp->rq.db_index < 0) {
1078 ret = -ENOMEM;
1079 goto err_rdb;
1080 }
1081 1112
1082 qp->sq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SQ,
1083 qp->qpn, &qp->sq.db);
1084 if (qp->sq.db_index < 0) {
1085 ret = -ENOMEM;
1086 goto err_rq_db;
1087 }
1088 } 1113 }
1089 1114
1090 return 0; 1115 return 0;
1091 1116
1092err_rq_db:
1093 mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
1094
1095err_rdb:
1096 mthca_table_put(dev, dev->qp_table.rdb_table,
1097 qp->qpn << dev->qp_table.rdb_shift);
1098
1099err_eqpc: 1117err_eqpc:
1100 mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn); 1118 mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
1101 1119
@@ -1105,6 +1123,35 @@ err_qpc:
1105 return ret; 1123 return ret;
1106} 1124}
1107 1125
1126static void mthca_unmap_memfree(struct mthca_dev *dev,
1127 struct mthca_qp *qp)
1128{
1129 mthca_table_put(dev, dev->qp_table.rdb_table,
1130 qp->qpn << dev->qp_table.rdb_shift);
1131 mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
1132 mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn);
1133}
1134
1135static int mthca_alloc_memfree(struct mthca_dev *dev,
1136 struct mthca_qp *qp)
1137{
1138 int ret = 0;
1139
1140 if (mthca_is_memfree(dev)) {
1141 qp->rq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_RQ,
1142 qp->qpn, &qp->rq.db);
1143 if (qp->rq.db_index < 0)
1144 return ret;
1145
1146 qp->sq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SQ,
1147 qp->qpn, &qp->sq.db);
1148 if (qp->sq.db_index < 0)
1149 mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
1150 }
1151
1152 return ret;
1153}
1154
1108static void mthca_free_memfree(struct mthca_dev *dev, 1155static void mthca_free_memfree(struct mthca_dev *dev,
1109 struct mthca_qp *qp) 1156 struct mthca_qp *qp)
1110{ 1157{
@@ -1112,11 +1159,6 @@ static void mthca_free_memfree(struct mthca_dev *dev,
1112 mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index); 1159 mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index);
1113 mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index); 1160 mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
1114 } 1161 }
1115
1116 mthca_table_put(dev, dev->qp_table.rdb_table,
1117 qp->qpn << dev->qp_table.rdb_shift);
1118 mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
1119 mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn);
1120} 1162}
1121 1163
1122static void mthca_wq_init(struct mthca_wq* wq) 1164static void mthca_wq_init(struct mthca_wq* wq)
@@ -1147,13 +1189,28 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev,
1147 mthca_wq_init(&qp->sq); 1189 mthca_wq_init(&qp->sq);
1148 mthca_wq_init(&qp->rq); 1190 mthca_wq_init(&qp->rq);
1149 1191
1150 ret = mthca_alloc_memfree(dev, qp); 1192 ret = mthca_map_memfree(dev, qp);
1151 if (ret) 1193 if (ret)
1152 return ret; 1194 return ret;
1153 1195
1154 ret = mthca_alloc_wqe_buf(dev, pd, qp); 1196 ret = mthca_alloc_wqe_buf(dev, pd, qp);
1155 if (ret) { 1197 if (ret) {
1156 mthca_free_memfree(dev, qp); 1198 mthca_unmap_memfree(dev, qp);
1199 return ret;
1200 }
1201
1202 /*
1203 * If this is a userspace QP, we're done now. The doorbells
1204 * will be allocated and buffers will be initialized in
1205 * userspace.
1206 */
1207 if (pd->ibpd.uobject)
1208 return 0;
1209
1210 ret = mthca_alloc_memfree(dev, qp);
1211 if (ret) {
1212 mthca_free_wqe_buf(dev, qp);
1213 mthca_unmap_memfree(dev, qp);
1157 return ret; 1214 return ret;
1158 } 1215 }
1159 1216
@@ -1186,22 +1243,39 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev,
1186 return 0; 1243 return 0;
1187} 1244}
1188 1245
1189static void mthca_align_qp_size(struct mthca_dev *dev, struct mthca_qp *qp) 1246static int mthca_set_qp_size(struct mthca_dev *dev, struct ib_qp_cap *cap,
1247 struct mthca_qp *qp)
1190{ 1248{
1191 int i; 1249 /* Sanity check QP size before proceeding */
1192 1250 if (cap->max_send_wr > 65536 || cap->max_recv_wr > 65536 ||
1193 if (!mthca_is_memfree(dev)) 1251 cap->max_send_sge > 64 || cap->max_recv_sge > 64)
1194 return; 1252 return -EINVAL;
1195 1253
1196 for (i = 0; 1 << i < qp->rq.max; ++i) 1254 if (mthca_is_memfree(dev)) {
1197 ; /* nothing */ 1255 qp->rq.max = cap->max_recv_wr ?
1256 roundup_pow_of_two(cap->max_recv_wr) : 0;
1257 qp->sq.max = cap->max_send_wr ?
1258 roundup_pow_of_two(cap->max_send_wr) : 0;
1259 } else {
1260 qp->rq.max = cap->max_recv_wr;
1261 qp->sq.max = cap->max_send_wr;
1262 }
1198 1263
1199 qp->rq.max = 1 << i; 1264 qp->rq.max_gs = cap->max_recv_sge;
1265 qp->sq.max_gs = max_t(int, cap->max_send_sge,
1266 ALIGN(cap->max_inline_data + MTHCA_INLINE_HEADER_SIZE,
1267 MTHCA_INLINE_CHUNK_SIZE) /
1268 sizeof (struct mthca_data_seg));
1200 1269
1201 for (i = 0; 1 << i < qp->sq.max; ++i) 1270 /*
1202 ; /* nothing */ 1271 * For MLX transport we need 2 extra S/G entries:
1272 * one for the header and one for the checksum at the end
1273 */
1274 if ((qp->transport == MLX && qp->sq.max_gs + 2 > dev->limits.max_sg) ||
1275 qp->sq.max_gs > dev->limits.max_sg || qp->rq.max_gs > dev->limits.max_sg)
1276 return -EINVAL;
1203 1277
1204 qp->sq.max = 1 << i; 1278 return 0;
1205} 1279}
1206 1280
1207int mthca_alloc_qp(struct mthca_dev *dev, 1281int mthca_alloc_qp(struct mthca_dev *dev,
@@ -1210,11 +1284,14 @@ int mthca_alloc_qp(struct mthca_dev *dev,
1210 struct mthca_cq *recv_cq, 1284 struct mthca_cq *recv_cq,
1211 enum ib_qp_type type, 1285 enum ib_qp_type type,
1212 enum ib_sig_type send_policy, 1286 enum ib_sig_type send_policy,
1287 struct ib_qp_cap *cap,
1213 struct mthca_qp *qp) 1288 struct mthca_qp *qp)
1214{ 1289{
1215 int err; 1290 int err;
1216 1291
1217 mthca_align_qp_size(dev, qp); 1292 err = mthca_set_qp_size(dev, cap, qp);
1293 if (err)
1294 return err;
1218 1295
1219 switch (type) { 1296 switch (type) {
1220 case IB_QPT_RC: qp->transport = RC; break; 1297 case IB_QPT_RC: qp->transport = RC; break;
@@ -1247,14 +1324,17 @@ int mthca_alloc_sqp(struct mthca_dev *dev,
1247 struct mthca_cq *send_cq, 1324 struct mthca_cq *send_cq,
1248 struct mthca_cq *recv_cq, 1325 struct mthca_cq *recv_cq,
1249 enum ib_sig_type send_policy, 1326 enum ib_sig_type send_policy,
1327 struct ib_qp_cap *cap,
1250 int qpn, 1328 int qpn,
1251 int port, 1329 int port,
1252 struct mthca_sqp *sqp) 1330 struct mthca_sqp *sqp)
1253{ 1331{
1254 int err = 0;
1255 u32 mqpn = qpn * 2 + dev->qp_table.sqp_start + port - 1; 1332 u32 mqpn = qpn * 2 + dev->qp_table.sqp_start + port - 1;
1333 int err;
1256 1334
1257 mthca_align_qp_size(dev, &sqp->qp); 1335 err = mthca_set_qp_size(dev, cap, &sqp->qp);
1336 if (err)
1337 return err;
1258 1338
1259 sqp->header_buf_size = sqp->qp.sq.max * MTHCA_UD_HEADER_SIZE; 1339 sqp->header_buf_size = sqp->qp.sq.max * MTHCA_UD_HEADER_SIZE;
1260 sqp->header_buf = dma_alloc_coherent(&dev->pdev->dev, sqp->header_buf_size, 1340 sqp->header_buf = dma_alloc_coherent(&dev->pdev->dev, sqp->header_buf_size,
@@ -1313,8 +1393,6 @@ void mthca_free_qp(struct mthca_dev *dev,
1313 struct mthca_qp *qp) 1393 struct mthca_qp *qp)
1314{ 1394{
1315 u8 status; 1395 u8 status;
1316 int size;
1317 int i;
1318 struct mthca_cq *send_cq; 1396 struct mthca_cq *send_cq;
1319 struct mthca_cq *recv_cq; 1397 struct mthca_cq *recv_cq;
1320 1398
@@ -1344,31 +1422,22 @@ void mthca_free_qp(struct mthca_dev *dev,
1344 if (qp->state != IB_QPS_RESET) 1422 if (qp->state != IB_QPS_RESET)
1345 mthca_MODIFY_QP(dev, MTHCA_TRANS_ANY2RST, qp->qpn, 0, NULL, 0, &status); 1423 mthca_MODIFY_QP(dev, MTHCA_TRANS_ANY2RST, qp->qpn, 0, NULL, 0, &status);
1346 1424
1347 mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn); 1425 /*
1348 if (qp->ibqp.send_cq != qp->ibqp.recv_cq) 1426 * If this is a userspace QP, the buffers, MR, CQs and so on
1349 mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq)->cqn, qp->qpn); 1427 * will be cleaned up in userspace, so all we have to do is
1350 1428 * unref the mem-free tables and free the QPN in our table.
1351 mthca_free_mr(dev, &qp->mr); 1429 */
1352 1430 if (!qp->ibqp.uobject) {
1353 size = PAGE_ALIGN(qp->send_wqe_offset + 1431 mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn);
1354 (qp->sq.max << qp->sq.wqe_shift)); 1432 if (qp->ibqp.send_cq != qp->ibqp.recv_cq)
1433 mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq)->cqn, qp->qpn);
1355 1434
1356 if (qp->is_direct) { 1435 mthca_free_mr(dev, &qp->mr);
1357 pci_free_consistent(dev->pdev, size, 1436 mthca_free_memfree(dev, qp);
1358 qp->queue.direct.buf, 1437 mthca_free_wqe_buf(dev, qp);
1359 pci_unmap_addr(&qp->queue.direct, mapping));
1360 } else {
1361 for (i = 0; i < size / PAGE_SIZE; ++i) {
1362 pci_free_consistent(dev->pdev, PAGE_SIZE,
1363 qp->queue.page_list[i].buf,
1364 pci_unmap_addr(&qp->queue.page_list[i],
1365 mapping));
1366 }
1367 } 1438 }
1368 1439
1369 kfree(qp->wrid); 1440 mthca_unmap_memfree(dev, qp);
1370
1371 mthca_free_memfree(dev, qp);
1372 1441
1373 if (is_sqp(dev, qp)) { 1442 if (is_sqp(dev, qp)) {
1374 atomic_dec(&(to_mpd(qp->ibqp.pd)->sqp_count)); 1443 atomic_dec(&(to_mpd(qp->ibqp.pd)->sqp_count));
diff --git a/drivers/infiniband/hw/mthca/mthca_user.h b/drivers/infiniband/hw/mthca/mthca_user.h
new file mode 100644
index 000000000000..3024c1b4547d
--- /dev/null
+++ b/drivers/infiniband/hw/mthca/mthca_user.h
@@ -0,0 +1,81 @@
1/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 *
33 */
34
35#ifndef MTHCA_USER_H
36#define MTHCA_USER_H
37
38#include <linux/types.h>
39
40/*
41 * Make sure that all structs defined in this file remain laid out so
42 * that they pack the same way on 32-bit and 64-bit architectures (to
43 * avoid incompatibility between 32-bit userspace and 64-bit kernels).
44 * In particular do not use pointer types -- pass pointers in __u64
45 * instead.
46 */
47
48struct mthca_alloc_ucontext_resp {
49 __u32 qp_tab_size;
50 __u32 uarc_size;
51};
52
53struct mthca_alloc_pd_resp {
54 __u32 pdn;
55 __u32 reserved;
56};
57
58struct mthca_create_cq {
59 __u32 lkey;
60 __u32 pdn;
61 __u64 arm_db_page;
62 __u64 set_db_page;
63 __u32 arm_db_index;
64 __u32 set_db_index;
65};
66
67struct mthca_create_cq_resp {
68 __u32 cqn;
69 __u32 reserved;
70};
71
72struct mthca_create_qp {
73 __u32 lkey;
74 __u32 reserved;
75 __u64 sq_db_page;
76 __u64 rq_db_page;
77 __u32 sq_db_index;
78 __u32 rq_db_index;
79};
80
81#endif /* MTHCA_USER_H */
diff --git a/drivers/infiniband/include/ib_user_verbs.h b/drivers/infiniband/include/ib_user_verbs.h
new file mode 100644
index 000000000000..7c613706af72
--- /dev/null
+++ b/drivers/infiniband/include/ib_user_verbs.h
@@ -0,0 +1,389 @@
1/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 *
33 * $Id: ib_user_verbs.h 2708 2005-06-24 17:27:21Z roland $
34 */
35
36#ifndef IB_USER_VERBS_H
37#define IB_USER_VERBS_H
38
39#include <linux/types.h>
40
41/*
42 * Increment this value if any changes that break userspace ABI
43 * compatibility are made.
44 */
45#define IB_USER_VERBS_ABI_VERSION 1
46
47enum {
48 IB_USER_VERBS_CMD_QUERY_PARAMS,
49 IB_USER_VERBS_CMD_GET_CONTEXT,
50 IB_USER_VERBS_CMD_QUERY_DEVICE,
51 IB_USER_VERBS_CMD_QUERY_PORT,
52 IB_USER_VERBS_CMD_QUERY_GID,
53 IB_USER_VERBS_CMD_QUERY_PKEY,
54 IB_USER_VERBS_CMD_ALLOC_PD,
55 IB_USER_VERBS_CMD_DEALLOC_PD,
56 IB_USER_VERBS_CMD_CREATE_AH,
57 IB_USER_VERBS_CMD_MODIFY_AH,
58 IB_USER_VERBS_CMD_QUERY_AH,
59 IB_USER_VERBS_CMD_DESTROY_AH,
60 IB_USER_VERBS_CMD_REG_MR,
61 IB_USER_VERBS_CMD_REG_SMR,
62 IB_USER_VERBS_CMD_REREG_MR,
63 IB_USER_VERBS_CMD_QUERY_MR,
64 IB_USER_VERBS_CMD_DEREG_MR,
65 IB_USER_VERBS_CMD_ALLOC_MW,
66 IB_USER_VERBS_CMD_BIND_MW,
67 IB_USER_VERBS_CMD_DEALLOC_MW,
68 IB_USER_VERBS_CMD_CREATE_CQ,
69 IB_USER_VERBS_CMD_RESIZE_CQ,
70 IB_USER_VERBS_CMD_DESTROY_CQ,
71 IB_USER_VERBS_CMD_POLL_CQ,
72 IB_USER_VERBS_CMD_PEEK_CQ,
73 IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
74 IB_USER_VERBS_CMD_CREATE_QP,
75 IB_USER_VERBS_CMD_QUERY_QP,
76 IB_USER_VERBS_CMD_MODIFY_QP,
77 IB_USER_VERBS_CMD_DESTROY_QP,
78 IB_USER_VERBS_CMD_POST_SEND,
79 IB_USER_VERBS_CMD_POST_RECV,
80 IB_USER_VERBS_CMD_ATTACH_MCAST,
81 IB_USER_VERBS_CMD_DETACH_MCAST
82};
83
84/*
85 * Make sure that all structs defined in this file remain laid out so
86 * that they pack the same way on 32-bit and 64-bit architectures (to
87 * avoid incompatibility between 32-bit userspace and 64-bit kernels).
88 * In particular do not use pointer types -- pass pointers in __u64
89 * instead.
90 */
91
92struct ib_uverbs_async_event_desc {
93 __u64 element;
94 __u32 event_type; /* enum ib_event_type */
95 __u32 reserved;
96};
97
98struct ib_uverbs_comp_event_desc {
99 __u64 cq_handle;
100};
101
102/*
103 * All commands from userspace should start with a __u32 command field
104 * followed by __u16 in_words and out_words fields (which give the
105 * length of the command block and response buffer if any in 32-bit
106 * words). The kernel driver will read these fields first and read
107 * the rest of the command struct based on these value.
108 */
109
110struct ib_uverbs_cmd_hdr {
111 __u32 command;
112 __u16 in_words;
113 __u16 out_words;
114};
115
116/*
117 * No driver_data for "query params" command, since this is intended
118 * to be a core function with no possible device dependence.
119 */
120struct ib_uverbs_query_params {
121 __u64 response;
122};
123
124struct ib_uverbs_query_params_resp {
125 __u32 num_cq_events;
126};
127
128struct ib_uverbs_get_context {
129 __u64 response;
130 __u64 cq_fd_tab;
131 __u64 driver_data[0];
132};
133
134struct ib_uverbs_get_context_resp {
135 __u32 async_fd;
136 __u32 reserved;
137};
138
139struct ib_uverbs_query_device {
140 __u64 response;
141 __u64 driver_data[0];
142};
143
144struct ib_uverbs_query_device_resp {
145 __u64 fw_ver;
146 __u64 node_guid;
147 __u64 sys_image_guid;
148 __u64 max_mr_size;
149 __u64 page_size_cap;
150 __u32 vendor_id;
151 __u32 vendor_part_id;
152 __u32 hw_ver;
153 __u32 max_qp;
154 __u32 max_qp_wr;
155 __u32 device_cap_flags;
156 __u32 max_sge;
157 __u32 max_sge_rd;
158 __u32 max_cq;
159 __u32 max_cqe;
160 __u32 max_mr;
161 __u32 max_pd;
162 __u32 max_qp_rd_atom;
163 __u32 max_ee_rd_atom;
164 __u32 max_res_rd_atom;
165 __u32 max_qp_init_rd_atom;
166 __u32 max_ee_init_rd_atom;
167 __u32 atomic_cap;
168 __u32 max_ee;
169 __u32 max_rdd;
170 __u32 max_mw;
171 __u32 max_raw_ipv6_qp;
172 __u32 max_raw_ethy_qp;
173 __u32 max_mcast_grp;
174 __u32 max_mcast_qp_attach;
175 __u32 max_total_mcast_qp_attach;
176 __u32 max_ah;
177 __u32 max_fmr;
178 __u32 max_map_per_fmr;
179 __u32 max_srq;
180 __u32 max_srq_wr;
181 __u32 max_srq_sge;
182 __u16 max_pkeys;
183 __u8 local_ca_ack_delay;
184 __u8 phys_port_cnt;
185 __u8 reserved[4];
186};
187
188struct ib_uverbs_query_port {
189 __u64 response;
190 __u8 port_num;
191 __u8 reserved[7];
192 __u64 driver_data[0];
193};
194
195struct ib_uverbs_query_port_resp {
196 __u32 port_cap_flags;
197 __u32 max_msg_sz;
198 __u32 bad_pkey_cntr;
199 __u32 qkey_viol_cntr;
200 __u32 gid_tbl_len;
201 __u16 pkey_tbl_len;
202 __u16 lid;
203 __u16 sm_lid;
204 __u8 state;
205 __u8 max_mtu;
206 __u8 active_mtu;
207 __u8 lmc;
208 __u8 max_vl_num;
209 __u8 sm_sl;
210 __u8 subnet_timeout;
211 __u8 init_type_reply;
212 __u8 active_width;
213 __u8 active_speed;
214 __u8 phys_state;
215 __u8 reserved[3];
216};
217
218struct ib_uverbs_query_gid {
219 __u64 response;
220 __u8 port_num;
221 __u8 index;
222 __u8 reserved[6];
223 __u64 driver_data[0];
224};
225
226struct ib_uverbs_query_gid_resp {
227 __u8 gid[16];
228};
229
230struct ib_uverbs_query_pkey {
231 __u64 response;
232 __u8 port_num;
233 __u8 index;
234 __u8 reserved[6];
235 __u64 driver_data[0];
236};
237
238struct ib_uverbs_query_pkey_resp {
239 __u16 pkey;
240 __u16 reserved;
241};
242
243struct ib_uverbs_alloc_pd {
244 __u64 response;
245 __u64 driver_data[0];
246};
247
248struct ib_uverbs_alloc_pd_resp {
249 __u32 pd_handle;
250};
251
252struct ib_uverbs_dealloc_pd {
253 __u32 pd_handle;
254};
255
256struct ib_uverbs_reg_mr {
257 __u64 response;
258 __u64 start;
259 __u64 length;
260 __u64 hca_va;
261 __u32 pd_handle;
262 __u32 access_flags;
263 __u64 driver_data[0];
264};
265
266struct ib_uverbs_reg_mr_resp {
267 __u32 mr_handle;
268 __u32 lkey;
269 __u32 rkey;
270};
271
272struct ib_uverbs_dereg_mr {
273 __u32 mr_handle;
274};
275
276struct ib_uverbs_create_cq {
277 __u64 response;
278 __u64 user_handle;
279 __u32 cqe;
280 __u32 event_handler;
281 __u64 driver_data[0];
282};
283
284struct ib_uverbs_create_cq_resp {
285 __u32 cq_handle;
286 __u32 cqe;
287};
288
289struct ib_uverbs_destroy_cq {
290 __u32 cq_handle;
291};
292
293struct ib_uverbs_create_qp {
294 __u64 response;
295 __u64 user_handle;
296 __u32 pd_handle;
297 __u32 send_cq_handle;
298 __u32 recv_cq_handle;
299 __u32 srq_handle;
300 __u32 max_send_wr;
301 __u32 max_recv_wr;
302 __u32 max_send_sge;
303 __u32 max_recv_sge;
304 __u32 max_inline_data;
305 __u8 sq_sig_all;
306 __u8 qp_type;
307 __u8 is_srq;
308 __u8 reserved;
309 __u64 driver_data[0];
310};
311
312struct ib_uverbs_create_qp_resp {
313 __u32 qp_handle;
314 __u32 qpn;
315};
316
317/*
318 * This struct needs to remain a multiple of 8 bytes to keep the
319 * alignment of the modify QP parameters.
320 */
321struct ib_uverbs_qp_dest {
322 __u8 dgid[16];
323 __u32 flow_label;
324 __u16 dlid;
325 __u16 reserved;
326 __u8 sgid_index;
327 __u8 hop_limit;
328 __u8 traffic_class;
329 __u8 sl;
330 __u8 src_path_bits;
331 __u8 static_rate;
332 __u8 is_global;
333 __u8 port_num;
334};
335
336struct ib_uverbs_modify_qp {
337 struct ib_uverbs_qp_dest dest;
338 struct ib_uverbs_qp_dest alt_dest;
339 __u32 qp_handle;
340 __u32 attr_mask;
341 __u32 qkey;
342 __u32 rq_psn;
343 __u32 sq_psn;
344 __u32 dest_qp_num;
345 __u32 qp_access_flags;
346 __u16 pkey_index;
347 __u16 alt_pkey_index;
348 __u8 qp_state;
349 __u8 cur_qp_state;
350 __u8 path_mtu;
351 __u8 path_mig_state;
352 __u8 en_sqd_async_notify;
353 __u8 max_rd_atomic;
354 __u8 max_dest_rd_atomic;
355 __u8 min_rnr_timer;
356 __u8 port_num;
357 __u8 timeout;
358 __u8 retry_cnt;
359 __u8 rnr_retry;
360 __u8 alt_port_num;
361 __u8 alt_timeout;
362 __u8 reserved[2];
363 __u64 driver_data[0];
364};
365
366struct ib_uverbs_modify_qp_resp {
367};
368
369struct ib_uverbs_destroy_qp {
370 __u32 qp_handle;
371};
372
373struct ib_uverbs_attach_mcast {
374 __u8 gid[16];
375 __u32 qp_handle;
376 __u16 mlid;
377 __u16 reserved;
378 __u64 driver_data[0];
379};
380
381struct ib_uverbs_detach_mcast {
382 __u8 gid[16];
383 __u32 qp_handle;
384 __u16 mlid;
385 __u16 reserved;
386 __u64 driver_data[0];
387};
388
389#endif /* IB_USER_VERBS_H */
diff --git a/drivers/infiniband/include/ib_verbs.h b/drivers/infiniband/include/ib_verbs.h
index cf01f044a223..e5bd9a10c201 100644
--- a/drivers/infiniband/include/ib_verbs.h
+++ b/drivers/infiniband/include/ib_verbs.h
@@ -4,6 +4,7 @@
4 * Copyright (c) 2004 Intel Corporation. All rights reserved. 4 * Copyright (c) 2004 Intel Corporation. All rights reserved.
5 * Copyright (c) 2004 Topspin Corporation. All rights reserved. 5 * Copyright (c) 2004 Topspin Corporation. All rights reserved.
6 * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 6 * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
7 * Copyright (c) 2005 Cisco Systems. All rights reserved.
7 * 8 *
8 * This software is available to you under a choice of one of two 9 * This software is available to you under a choice of one of two
9 * licenses. You may choose to be licensed under the terms of the GNU 10 * licenses. You may choose to be licensed under the terms of the GNU
@@ -41,7 +42,10 @@
41 42
42#include <linux/types.h> 43#include <linux/types.h>
43#include <linux/device.h> 44#include <linux/device.h>
45
44#include <asm/atomic.h> 46#include <asm/atomic.h>
47#include <asm/scatterlist.h>
48#include <asm/uaccess.h>
45 49
46union ib_gid { 50union ib_gid {
47 u8 raw[16]; 51 u8 raw[16];
@@ -544,7 +548,7 @@ struct ib_send_wr {
544 int num_sge; 548 int num_sge;
545 enum ib_wr_opcode opcode; 549 enum ib_wr_opcode opcode;
546 int send_flags; 550 int send_flags;
547 u32 imm_data; 551 __be32 imm_data;
548 union { 552 union {
549 struct { 553 struct {
550 u64 remote_addr; 554 u64 remote_addr;
@@ -618,29 +622,86 @@ struct ib_fmr_attr {
618 u8 page_size; 622 u8 page_size;
619}; 623};
620 624
625struct ib_ucontext {
626 struct ib_device *device;
627 struct list_head pd_list;
628 struct list_head mr_list;
629 struct list_head mw_list;
630 struct list_head cq_list;
631 struct list_head qp_list;
632 struct list_head srq_list;
633 struct list_head ah_list;
634 spinlock_t lock;
635};
636
637struct ib_uobject {
638 u64 user_handle; /* handle given to us by userspace */
639 struct ib_ucontext *context; /* associated user context */
640 struct list_head list; /* link to context's list */
641 u32 id; /* index into kernel idr */
642};
643
644struct ib_umem {
645 unsigned long user_base;
646 unsigned long virt_base;
647 size_t length;
648 int offset;
649 int page_size;
650 int writable;
651 struct list_head chunk_list;
652};
653
654struct ib_umem_chunk {
655 struct list_head list;
656 int nents;
657 int nmap;
658 struct scatterlist page_list[0];
659};
660
661struct ib_udata {
662 void __user *inbuf;
663 void __user *outbuf;
664 size_t inlen;
665 size_t outlen;
666};
667
668#define IB_UMEM_MAX_PAGE_CHUNK \
669 ((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) / \
670 ((void *) &((struct ib_umem_chunk *) 0)->page_list[1] - \
671 (void *) &((struct ib_umem_chunk *) 0)->page_list[0]))
672
673struct ib_umem_object {
674 struct ib_uobject uobject;
675 struct ib_umem umem;
676};
677
621struct ib_pd { 678struct ib_pd {
622 struct ib_device *device; 679 struct ib_device *device;
623 atomic_t usecnt; /* count all resources */ 680 struct ib_uobject *uobject;
681 atomic_t usecnt; /* count all resources */
624}; 682};
625 683
626struct ib_ah { 684struct ib_ah {
627 struct ib_device *device; 685 struct ib_device *device;
628 struct ib_pd *pd; 686 struct ib_pd *pd;
687 struct ib_uobject *uobject;
629}; 688};
630 689
631typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); 690typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
632 691
633struct ib_cq { 692struct ib_cq {
634 struct ib_device *device; 693 struct ib_device *device;
635 ib_comp_handler comp_handler; 694 struct ib_uobject *uobject;
636 void (*event_handler)(struct ib_event *, void *); 695 ib_comp_handler comp_handler;
637 void * cq_context; 696 void (*event_handler)(struct ib_event *, void *);
638 int cqe; 697 void * cq_context;
639 atomic_t usecnt; /* count number of work queues */ 698 int cqe;
699 atomic_t usecnt; /* count number of work queues */
640}; 700};
641 701
642struct ib_srq { 702struct ib_srq {
643 struct ib_device *device; 703 struct ib_device *device;
704 struct ib_uobject *uobject;
644 struct ib_pd *pd; 705 struct ib_pd *pd;
645 void *srq_context; 706 void *srq_context;
646 atomic_t usecnt; 707 atomic_t usecnt;
@@ -652,6 +713,7 @@ struct ib_qp {
652 struct ib_cq *send_cq; 713 struct ib_cq *send_cq;
653 struct ib_cq *recv_cq; 714 struct ib_cq *recv_cq;
654 struct ib_srq *srq; 715 struct ib_srq *srq;
716 struct ib_uobject *uobject;
655 void (*event_handler)(struct ib_event *, void *); 717 void (*event_handler)(struct ib_event *, void *);
656 void *qp_context; 718 void *qp_context;
657 u32 qp_num; 719 u32 qp_num;
@@ -659,16 +721,18 @@ struct ib_qp {
659}; 721};
660 722
661struct ib_mr { 723struct ib_mr {
662 struct ib_device *device; 724 struct ib_device *device;
663 struct ib_pd *pd; 725 struct ib_pd *pd;
664 u32 lkey; 726 struct ib_uobject *uobject;
665 u32 rkey; 727 u32 lkey;
666 atomic_t usecnt; /* count number of MWs */ 728 u32 rkey;
729 atomic_t usecnt; /* count number of MWs */
667}; 730};
668 731
669struct ib_mw { 732struct ib_mw {
670 struct ib_device *device; 733 struct ib_device *device;
671 struct ib_pd *pd; 734 struct ib_pd *pd;
735 struct ib_uobject *uobject;
672 u32 rkey; 736 u32 rkey;
673}; 737};
674 738
@@ -737,7 +801,14 @@ struct ib_device {
737 int (*modify_port)(struct ib_device *device, 801 int (*modify_port)(struct ib_device *device,
738 u8 port_num, int port_modify_mask, 802 u8 port_num, int port_modify_mask,
739 struct ib_port_modify *port_modify); 803 struct ib_port_modify *port_modify);
740 struct ib_pd * (*alloc_pd)(struct ib_device *device); 804 struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device,
805 struct ib_udata *udata);
806 int (*dealloc_ucontext)(struct ib_ucontext *context);
807 int (*mmap)(struct ib_ucontext *context,
808 struct vm_area_struct *vma);
809 struct ib_pd * (*alloc_pd)(struct ib_device *device,
810 struct ib_ucontext *context,
811 struct ib_udata *udata);
741 int (*dealloc_pd)(struct ib_pd *pd); 812 int (*dealloc_pd)(struct ib_pd *pd);
742 struct ib_ah * (*create_ah)(struct ib_pd *pd, 813 struct ib_ah * (*create_ah)(struct ib_pd *pd,
743 struct ib_ah_attr *ah_attr); 814 struct ib_ah_attr *ah_attr);
@@ -747,7 +818,8 @@ struct ib_device {
747 struct ib_ah_attr *ah_attr); 818 struct ib_ah_attr *ah_attr);
748 int (*destroy_ah)(struct ib_ah *ah); 819 int (*destroy_ah)(struct ib_ah *ah);
749 struct ib_qp * (*create_qp)(struct ib_pd *pd, 820 struct ib_qp * (*create_qp)(struct ib_pd *pd,
750 struct ib_qp_init_attr *qp_init_attr); 821 struct ib_qp_init_attr *qp_init_attr,
822 struct ib_udata *udata);
751 int (*modify_qp)(struct ib_qp *qp, 823 int (*modify_qp)(struct ib_qp *qp,
752 struct ib_qp_attr *qp_attr, 824 struct ib_qp_attr *qp_attr,
753 int qp_attr_mask); 825 int qp_attr_mask);
@@ -762,8 +834,9 @@ struct ib_device {
762 int (*post_recv)(struct ib_qp *qp, 834 int (*post_recv)(struct ib_qp *qp,
763 struct ib_recv_wr *recv_wr, 835 struct ib_recv_wr *recv_wr,
764 struct ib_recv_wr **bad_recv_wr); 836 struct ib_recv_wr **bad_recv_wr);
765 struct ib_cq * (*create_cq)(struct ib_device *device, 837 struct ib_cq * (*create_cq)(struct ib_device *device, int cqe,
766 int cqe); 838 struct ib_ucontext *context,
839 struct ib_udata *udata);
767 int (*destroy_cq)(struct ib_cq *cq); 840 int (*destroy_cq)(struct ib_cq *cq);
768 int (*resize_cq)(struct ib_cq *cq, int *cqe); 841 int (*resize_cq)(struct ib_cq *cq, int *cqe);
769 int (*poll_cq)(struct ib_cq *cq, int num_entries, 842 int (*poll_cq)(struct ib_cq *cq, int num_entries,
@@ -780,6 +853,10 @@ struct ib_device {
780 int num_phys_buf, 853 int num_phys_buf,
781 int mr_access_flags, 854 int mr_access_flags,
782 u64 *iova_start); 855 u64 *iova_start);
856 struct ib_mr * (*reg_user_mr)(struct ib_pd *pd,
857 struct ib_umem *region,
858 int mr_access_flags,
859 struct ib_udata *udata);
783 int (*query_mr)(struct ib_mr *mr, 860 int (*query_mr)(struct ib_mr *mr,
784 struct ib_mr_attr *mr_attr); 861 struct ib_mr_attr *mr_attr);
785 int (*dereg_mr)(struct ib_mr *mr); 862 int (*dereg_mr)(struct ib_mr *mr);
@@ -817,6 +894,7 @@ struct ib_device {
817 struct ib_mad *in_mad, 894 struct ib_mad *in_mad,
818 struct ib_mad *out_mad); 895 struct ib_mad *out_mad);
819 896
897 struct module *owner;
820 struct class_device class_dev; 898 struct class_device class_dev;
821 struct kobject ports_parent; 899 struct kobject ports_parent;
822 struct list_head port_list; 900 struct list_head port_list;
@@ -852,6 +930,16 @@ void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
852void ib_set_client_data(struct ib_device *device, struct ib_client *client, 930void ib_set_client_data(struct ib_device *device, struct ib_client *client,
853 void *data); 931 void *data);
854 932
933static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
934{
935 return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0;
936}
937
938static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
939{
940 return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0;
941}
942
855int ib_register_event_handler (struct ib_event_handler *event_handler); 943int ib_register_event_handler (struct ib_event_handler *event_handler);
856int ib_unregister_event_handler(struct ib_event_handler *event_handler); 944int ib_unregister_event_handler(struct ib_event_handler *event_handler);
857void ib_dispatch_event(struct ib_event *event); 945void ib_dispatch_event(struct ib_event *event);
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 3e72c9b1461e..ab09cf4093e3 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -60,12 +60,13 @@ static void gameport_disconnect_port(struct gameport *gameport);
60 60
61#if defined(__i386__) 61#if defined(__i386__)
62 62
63#include <asm/i8253.h>
64
63#define DELTA(x,y) ((y)-(x)+((y)<(x)?1193182/HZ:0)) 65#define DELTA(x,y) ((y)-(x)+((y)<(x)?1193182/HZ:0))
64#define GET_TIME(x) do { x = get_time_pit(); } while (0) 66#define GET_TIME(x) do { x = get_time_pit(); } while (0)
65 67
66static unsigned int get_time_pit(void) 68static unsigned int get_time_pit(void)
67{ 69{
68 extern spinlock_t i8253_lock;
69 unsigned long flags; 70 unsigned long flags;
70 unsigned int count; 71 unsigned int count;
71 72
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index 504b7d550567..c3a5739030c3 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -140,12 +140,14 @@ struct analog_port {
140 */ 140 */
141 141
142#ifdef __i386__ 142#ifdef __i386__
143
144#include <asm/i8253.h>
145
143#define GET_TIME(x) do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0) 146#define GET_TIME(x) do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0)
144#define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0))) 147#define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0)))
145#define TIME_NAME (cpu_has_tsc?"TSC":"PIT") 148#define TIME_NAME (cpu_has_tsc?"TSC":"PIT")
146static unsigned int get_time_pit(void) 149static unsigned int get_time_pit(void)
147{ 150{
148 extern spinlock_t i8253_lock;
149 unsigned long flags; 151 unsigned long flags;
150 unsigned int count; 152 unsigned int count;
151 153
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index ee750e9456dd..db9bad2b3d16 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -22,7 +22,6 @@
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/system.h> 23#include <asm/system.h>
24 24
25#include <pcmcia/version.h>
26#include <pcmcia/cs_types.h> 25#include <pcmcia/cs_types.h>
27#include <pcmcia/cs.h> 26#include <pcmcia/cs.h>
28#include <pcmcia/cistpl.h> 27#include <pcmcia/cistpl.h>
@@ -161,11 +160,6 @@ static dev_link_t *avmcs_attach(void)
161 link->next = dev_list; 160 link->next = dev_list;
162 dev_list = link; 161 dev_list = link;
163 client_reg.dev_info = &dev_info; 162 client_reg.dev_info = &dev_info;
164 client_reg.EventMask =
165 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
166 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
167 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
168 client_reg.event_handler = &avmcs_event;
169 client_reg.Version = 0x0210; 163 client_reg.Version = 0x0210;
170 client_reg.event_callback_args.client_data = link; 164 client_reg.event_callback_args.client_data = link;
171 ret = pcmcia_register_client(&link->handle, &client_reg); 165 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -500,6 +494,7 @@ static struct pcmcia_driver avmcs_driver = {
500 .name = "avm_cs", 494 .name = "avm_cs",
501 }, 495 },
502 .attach = avmcs_attach, 496 .attach = avmcs_attach,
497 .event = avmcs_event,
503 .detach = avmcs_detach, 498 .detach = avmcs_detach,
504 .id_table = avmcs_ids, 499 .id_table = avmcs_ids,
505}; 500};
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index 67c60e04a37b..0e22991635e7 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -21,7 +21,6 @@
21#include <asm/io.h> 21#include <asm/io.h>
22#include <asm/system.h> 22#include <asm/system.h>
23 23
24#include <pcmcia/version.h>
25#include <pcmcia/cs_types.h> 24#include <pcmcia/cs_types.h>
26#include <pcmcia/cs.h> 25#include <pcmcia/cs.h>
27#include <pcmcia/cistpl.h> 26#include <pcmcia/cistpl.h>
@@ -183,11 +182,6 @@ static dev_link_t *avma1cs_attach(void)
183 link->next = dev_list; 182 link->next = dev_list;
184 dev_list = link; 183 dev_list = link;
185 client_reg.dev_info = &dev_info; 184 client_reg.dev_info = &dev_info;
186 client_reg.EventMask =
187 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
188 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
189 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
190 client_reg.event_handler = &avma1cs_event;
191 client_reg.Version = 0x0210; 185 client_reg.Version = 0x0210;
192 client_reg.event_callback_args.client_data = link; 186 client_reg.event_callback_args.client_data = link;
193 ret = pcmcia_register_client(&link->handle, &client_reg); 187 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -514,6 +508,7 @@ static struct pcmcia_driver avma1cs_driver = {
514 .name = "avma1_cs", 508 .name = "avma1_cs",
515 }, 509 },
516 .attach = avma1cs_attach, 510 .attach = avma1cs_attach,
511 .event = avma1cs_event,
517 .detach = avma1cs_detach, 512 .detach = avma1cs_detach,
518 .id_table = avma1cs_ids, 513 .id_table = avma1cs_ids,
519}; 514};
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index 9146be547044..6fc6868de0b0 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -47,7 +47,6 @@
47#include <asm/io.h> 47#include <asm/io.h>
48#include <asm/system.h> 48#include <asm/system.h>
49 49
50#include <pcmcia/version.h>
51#include <pcmcia/cs_types.h> 50#include <pcmcia/cs_types.h>
52#include <pcmcia/cs.h> 51#include <pcmcia/cs.h>
53#include <pcmcia/cistpl.h> 52#include <pcmcia/cistpl.h>
@@ -212,11 +211,6 @@ static dev_link_t *elsa_cs_attach(void)
212 link->next = dev_list; 211 link->next = dev_list;
213 dev_list = link; 212 dev_list = link;
214 client_reg.dev_info = &dev_info; 213 client_reg.dev_info = &dev_info;
215 client_reg.EventMask =
216 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
217 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
218 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
219 client_reg.event_handler = &elsa_cs_event;
220 client_reg.Version = 0x0210; 214 client_reg.Version = 0x0210;
221 client_reg.event_callback_args.client_data = link; 215 client_reg.event_callback_args.client_data = link;
222 ret = pcmcia_register_client(&link->handle, &client_reg); 216 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -521,6 +515,7 @@ static struct pcmcia_driver elsa_cs_driver = {
521 .name = "elsa_cs", 515 .name = "elsa_cs",
522 }, 516 },
523 .attach = elsa_cs_attach, 517 .attach = elsa_cs_attach,
518 .event = elsa_cs_event,
524 .detach = elsa_cs_detach, 519 .detach = elsa_cs_detach,
525 .id_table = elsa_ids, 520 .id_table = elsa_ids,
526}; 521};
diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c
index ac899503a74f..bab356886483 100644
--- a/drivers/isdn/hisax/isdnl1.c
+++ b/drivers/isdn/hisax/isdnl1.c
@@ -279,7 +279,8 @@ BChannel_proc_xmt(struct BCState *bcs)
279 if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) 279 if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags))
280 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); 280 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
281 if (!test_bit(BC_FLG_ACTIV, &bcs->Flag)) { 281 if (!test_bit(BC_FLG_ACTIV, &bcs->Flag)) {
282 if (!test_bit(BC_FLG_BUSY, &bcs->Flag) && (!skb_queue_len(&bcs->squeue))) { 282 if (!test_bit(BC_FLG_BUSY, &bcs->Flag) &&
283 skb_queue_empty(&bcs->squeue)) {
283 st->l2.l2l1(st, PH_DEACTIVATE | CONFIRM, NULL); 284 st->l2.l2l1(st, PH_DEACTIVATE | CONFIRM, NULL);
284 } 285 }
285 } 286 }
diff --git a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c
index 9022583fd6a0..1615c1a76ab8 100644
--- a/drivers/isdn/hisax/isdnl2.c
+++ b/drivers/isdn/hisax/isdnl2.c
@@ -108,7 +108,8 @@ static int l2addrsize(struct Layer2 *l2);
108static void 108static void
109set_peer_busy(struct Layer2 *l2) { 109set_peer_busy(struct Layer2 *l2) {
110 test_and_set_bit(FLG_PEER_BUSY, &l2->flag); 110 test_and_set_bit(FLG_PEER_BUSY, &l2->flag);
111 if (skb_queue_len(&l2->i_queue) || skb_queue_len(&l2->ui_queue)) 111 if (!skb_queue_empty(&l2->i_queue) ||
112 !skb_queue_empty(&l2->ui_queue))
112 test_and_set_bit(FLG_L2BLOCK, &l2->flag); 113 test_and_set_bit(FLG_L2BLOCK, &l2->flag);
113} 114}
114 115
@@ -754,7 +755,7 @@ l2_restart_multi(struct FsmInst *fi, int event, void *arg)
754 st->l2.l2l3(st, DL_ESTABLISH | INDICATION, NULL); 755 st->l2.l2l3(st, DL_ESTABLISH | INDICATION, NULL);
755 756
756 if ((ST_L2_7==state) || (ST_L2_8 == state)) 757 if ((ST_L2_7==state) || (ST_L2_8 == state))
757 if (skb_queue_len(&st->l2.i_queue) && cansend(st)) 758 if (!skb_queue_empty(&st->l2.i_queue) && cansend(st))
758 st->l2.l2l1(st, PH_PULL | REQUEST, NULL); 759 st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
759} 760}
760 761
@@ -810,7 +811,7 @@ l2_connected(struct FsmInst *fi, int event, void *arg)
810 if (pr != -1) 811 if (pr != -1)
811 st->l2.l2l3(st, pr, NULL); 812 st->l2.l2l3(st, pr, NULL);
812 813
813 if (skb_queue_len(&st->l2.i_queue) && cansend(st)) 814 if (!skb_queue_empty(&st->l2.i_queue) && cansend(st))
814 st->l2.l2l1(st, PH_PULL | REQUEST, NULL); 815 st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
815} 816}
816 817
@@ -1014,7 +1015,7 @@ l2_st7_got_super(struct FsmInst *fi, int event, void *arg)
1014 if(typ != RR) FsmDelTimer(&st->l2.t203, 9); 1015 if(typ != RR) FsmDelTimer(&st->l2.t203, 9);
1015 restart_t200(st, 12); 1016 restart_t200(st, 12);
1016 } 1017 }
1017 if (skb_queue_len(&st->l2.i_queue) && (typ == RR)) 1018 if (!skb_queue_empty(&st->l2.i_queue) && (typ == RR))
1018 st->l2.l2l1(st, PH_PULL | REQUEST, NULL); 1019 st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
1019 } else 1020 } else
1020 nrerrorrecovery(fi); 1021 nrerrorrecovery(fi);
@@ -1120,7 +1121,7 @@ l2_got_iframe(struct FsmInst *fi, int event, void *arg)
1120 return; 1121 return;
1121 } 1122 }
1122 1123
1123 if (skb_queue_len(&st->l2.i_queue) && (fi->state == ST_L2_7)) 1124 if (!skb_queue_empty(&st->l2.i_queue) && (fi->state == ST_L2_7))
1124 st->l2.l2l1(st, PH_PULL | REQUEST, NULL); 1125 st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
1125 if (test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag)) 1126 if (test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag))
1126 enquiry_cr(st, RR, RSP, 0); 1127 enquiry_cr(st, RR, RSP, 0);
@@ -1138,7 +1139,7 @@ l2_got_tei(struct FsmInst *fi, int event, void *arg)
1138 test_and_set_bit(FLG_L3_INIT, &st->l2.flag); 1139 test_and_set_bit(FLG_L3_INIT, &st->l2.flag);
1139 } else 1140 } else
1140 FsmChangeState(fi, ST_L2_4); 1141 FsmChangeState(fi, ST_L2_4);
1141 if (skb_queue_len(&st->l2.ui_queue)) 1142 if (!skb_queue_empty(&st->l2.ui_queue))
1142 tx_ui(st); 1143 tx_ui(st);
1143} 1144}
1144 1145
@@ -1301,7 +1302,7 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
1301 FsmDelTimer(&st->l2.t203, 13); 1302 FsmDelTimer(&st->l2.t203, 13);
1302 FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 11); 1303 FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 11);
1303 } 1304 }
1304 if (skb_queue_len(&l2->i_queue) && cansend(st)) 1305 if (!skb_queue_empty(&l2->i_queue) && cansend(st))
1305 st->l2.l2l1(st, PH_PULL | REQUEST, NULL); 1306 st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
1306} 1307}
1307 1308
@@ -1347,7 +1348,7 @@ l2_st8_got_super(struct FsmInst *fi, int event, void *arg)
1347 } 1348 }
1348 invoke_retransmission(st, nr); 1349 invoke_retransmission(st, nr);
1349 FsmChangeState(fi, ST_L2_7); 1350 FsmChangeState(fi, ST_L2_7);
1350 if (skb_queue_len(&l2->i_queue) && cansend(st)) 1351 if (!skb_queue_empty(&l2->i_queue) && cansend(st))
1351 st->l2.l2l1(st, PH_PULL | REQUEST, NULL); 1352 st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
1352 } else 1353 } else
1353 nrerrorrecovery(fi); 1354 nrerrorrecovery(fi);
diff --git a/drivers/isdn/hisax/isdnl3.c b/drivers/isdn/hisax/isdnl3.c
index abcc9530eb34..c9917cd2132b 100644
--- a/drivers/isdn/hisax/isdnl3.c
+++ b/drivers/isdn/hisax/isdnl3.c
@@ -302,7 +302,7 @@ release_l3_process(struct l3_process *p)
302 !test_bit(FLG_PTP, &p->st->l2.flag)) { 302 !test_bit(FLG_PTP, &p->st->l2.flag)) {
303 if (p->debug) 303 if (p->debug)
304 l3_debug(p->st, "release_l3_process: last process"); 304 l3_debug(p->st, "release_l3_process: last process");
305 if (!skb_queue_len(&p->st->l3.squeue)) { 305 if (skb_queue_empty(&p->st->l3.squeue)) {
306 if (p->debug) 306 if (p->debug)
307 l3_debug(p->st, "release_l3_process: release link"); 307 l3_debug(p->st, "release_l3_process: release link");
308 if (p->st->protocol != ISDN_PTYPE_NI1) 308 if (p->st->protocol != ISDN_PTYPE_NI1)
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index 058147a69576..c6b5bf7d2aca 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -47,7 +47,6 @@
47#include <asm/io.h> 47#include <asm/io.h>
48#include <asm/system.h> 48#include <asm/system.h>
49 49
50#include <pcmcia/version.h>
51#include <pcmcia/cs_types.h> 50#include <pcmcia/cs_types.h>
52#include <pcmcia/cs.h> 51#include <pcmcia/cs.h>
53#include <pcmcia/cistpl.h> 52#include <pcmcia/cistpl.h>
@@ -226,11 +225,6 @@ static dev_link_t *sedlbauer_attach(void)
226 link->next = dev_list; 225 link->next = dev_list;
227 dev_list = link; 226 dev_list = link;
228 client_reg.dev_info = &dev_info; 227 client_reg.dev_info = &dev_info;
229 client_reg.EventMask =
230 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
231 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
232 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
233 client_reg.event_handler = &sedlbauer_event;
234 client_reg.Version = 0x0210; 228 client_reg.Version = 0x0210;
235 client_reg.event_callback_args.client_data = link; 229 client_reg.event_callback_args.client_data = link;
236 ret = pcmcia_register_client(&link->handle, &client_reg); 230 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -634,6 +628,7 @@ static struct pcmcia_driver sedlbauer_driver = {
634 .name = "sedlbauer_cs", 628 .name = "sedlbauer_cs",
635 }, 629 },
636 .attach = sedlbauer_attach, 630 .attach = sedlbauer_attach,
631 .event = sedlbauer_event,
637 .detach = sedlbauer_detach, 632 .detach = sedlbauer_detach,
638 .id_table = sedlbauer_ids, 633 .id_table = sedlbauer_ids,
639}; 634};
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index 107376ff5b9b..0ddef1bf778b 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -28,7 +28,6 @@
28#include <asm/io.h> 28#include <asm/io.h>
29#include <asm/system.h> 29#include <asm/system.h>
30 30
31#include <pcmcia/version.h>
32#include <pcmcia/cs_types.h> 31#include <pcmcia/cs_types.h>
33#include <pcmcia/cs.h> 32#include <pcmcia/cs.h>
34#include <pcmcia/cistpl.h> 33#include <pcmcia/cistpl.h>
@@ -193,11 +192,6 @@ static dev_link_t *teles_attach(void)
193 link->next = dev_list; 192 link->next = dev_list;
194 dev_list = link; 193 dev_list = link;
195 client_reg.dev_info = &dev_info; 194 client_reg.dev_info = &dev_info;
196 client_reg.EventMask =
197 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
198 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
199 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
200 client_reg.event_handler = &teles_cs_event;
201 client_reg.Version = 0x0210; 195 client_reg.Version = 0x0210;
202 client_reg.event_callback_args.client_data = link; 196 client_reg.event_callback_args.client_data = link;
203 ret = pcmcia_register_client(&link->handle, &client_reg); 197 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -501,6 +495,7 @@ static struct pcmcia_driver teles_cs_driver = {
501 .name = "teles_cs", 495 .name = "teles_cs",
502 }, 496 },
503 .attach = teles_attach, 497 .attach = teles_attach,
498 .event = teles_cs_event,
504 .detach = teles_detach, 499 .detach = teles_detach,
505 .id_table = teles_ids, 500 .id_table = teles_ids,
506}; 501};
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index ad5aa38fb5a6..b37ef1f06b3d 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1223,7 +1223,7 @@ isdn_tty_write(struct tty_struct *tty, const u_char * buf, int count)
1223 total += c; 1223 total += c;
1224 } 1224 }
1225 atomic_dec(&info->xmit_lock); 1225 atomic_dec(&info->xmit_lock);
1226 if ((info->xmit_count) || (skb_queue_len(&info->xmit_queue))) { 1226 if ((info->xmit_count) || !skb_queue_empty(&info->xmit_queue)) {
1227 if (m->mdmreg[REG_DXMT] & BIT_DXMT) { 1227 if (m->mdmreg[REG_DXMT] & BIT_DXMT) {
1228 isdn_tty_senddown(info); 1228 isdn_tty_senddown(info);
1229 isdn_tty_tint(info); 1229 isdn_tty_tint(info);
@@ -1284,7 +1284,7 @@ isdn_tty_flush_chars(struct tty_struct *tty)
1284 1284
1285 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_flush_chars")) 1285 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_flush_chars"))
1286 return; 1286 return;
1287 if ((info->xmit_count) || (skb_queue_len(&info->xmit_queue))) 1287 if ((info->xmit_count) || !skb_queue_empty(&info->xmit_queue))
1288 isdn_timer_ctrl(ISDN_TIMER_MODEMXMIT, 1); 1288 isdn_timer_ctrl(ISDN_TIMER_MODEMXMIT, 1);
1289} 1289}
1290 1290
diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
index 9fc0c1e03732..e0d1b01cc74c 100644
--- a/drivers/isdn/icn/icn.c
+++ b/drivers/isdn/icn/icn.c
@@ -304,12 +304,12 @@ icn_pollbchan_send(int channel, icn_card * card)
304 isdn_ctrl cmd; 304 isdn_ctrl cmd;
305 305
306 if (!(card->sndcount[channel] || card->xskb[channel] || 306 if (!(card->sndcount[channel] || card->xskb[channel] ||
307 skb_queue_len(&card->spqueue[channel]))) 307 !skb_queue_empty(&card->spqueue[channel])))
308 return; 308 return;
309 if (icn_trymaplock_channel(card, mch)) { 309 if (icn_trymaplock_channel(card, mch)) {
310 while (sbfree && 310 while (sbfree &&
311 (card->sndcount[channel] || 311 (card->sndcount[channel] ||
312 skb_queue_len(&card->spqueue[channel]) || 312 !skb_queue_empty(&card->spqueue[channel]) ||
313 card->xskb[channel])) { 313 card->xskb[channel])) {
314 spin_lock_irqsave(&card->lock, flags); 314 spin_lock_irqsave(&card->lock, flags);
315 if (card->xmit_lock[channel]) { 315 if (card->xmit_lock[channel]) {
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index f5ae171dbfef..236291bd48a4 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -4,7 +4,7 @@
4 4
5# Each configuration option enables a list of files. 5# Each configuration option enables a list of files.
6 6
7obj-$(CONFIG_PPC_PMAC) += macio_asic.o 7obj-$(CONFIG_PPC_PMAC) += macio_asic.o macio_sysfs.o
8 8
9obj-$(CONFIG_PMAC_MEDIABAY) += mediabay.o 9obj-$(CONFIG_PMAC_MEDIABAY) += mediabay.o
10obj-$(CONFIG_MAC_EMUMOUSEBTN) += mac_hid.o 10obj-$(CONFIG_MAC_EMUMOUSEBTN) += mac_hid.o
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index d0bda7e3e6aa..1ee003346923 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -33,7 +33,7 @@ static int macio_bus_match(struct device *dev, struct device_driver *drv)
33{ 33{
34 struct macio_dev * macio_dev = to_macio_device(dev); 34 struct macio_dev * macio_dev = to_macio_device(dev);
35 struct macio_driver * macio_drv = to_macio_driver(drv); 35 struct macio_driver * macio_drv = to_macio_driver(drv);
36 const struct of_match * matches = macio_drv->match_table; 36 const struct of_device_id * matches = macio_drv->match_table;
37 37
38 if (!matches) 38 if (!matches)
39 return 0; 39 return 0;
@@ -66,7 +66,7 @@ static int macio_device_probe(struct device *dev)
66 int error = -ENODEV; 66 int error = -ENODEV;
67 struct macio_driver *drv; 67 struct macio_driver *drv;
68 struct macio_dev *macio_dev; 68 struct macio_dev *macio_dev;
69 const struct of_match *match; 69 const struct of_device_id *match;
70 70
71 drv = to_macio_driver(dev->driver); 71 drv = to_macio_driver(dev->driver);
72 macio_dev = to_macio_device(dev); 72 macio_dev = to_macio_device(dev);
@@ -126,11 +126,85 @@ static int macio_device_resume(struct device * dev)
126 return 0; 126 return 0;
127} 127}
128 128
129static int macio_hotplug (struct device *dev, char **envp, int num_envp,
130 char *buffer, int buffer_size)
131{
132 struct macio_dev * macio_dev;
133 struct of_device * of;
134 char *scratch, *compat;
135 int i = 0;
136 int length = 0;
137 int cplen, seen = 0;
138
139 if (!dev)
140 return -ENODEV;
141
142 macio_dev = to_macio_device(dev);
143 if (!macio_dev)
144 return -ENODEV;
145
146 of = &macio_dev->ofdev;
147 scratch = buffer;
148
149 /* stuff we want to pass to /sbin/hotplug */
150 envp[i++] = scratch;
151 length += scnprintf (scratch, buffer_size - length, "OF_NAME=%s",
152 of->node->name);
153 if ((buffer_size - length <= 0) || (i >= num_envp))
154 return -ENOMEM;
155 ++length;
156 scratch += length;
157
158 envp[i++] = scratch;
159 length += scnprintf (scratch, buffer_size - length, "OF_TYPE=%s",
160 of->node->type);
161 if ((buffer_size - length <= 0) || (i >= num_envp))
162 return -ENOMEM;
163 ++length;
164 scratch += length;
165
166 /* Since the compatible field can contain pretty much anything
167 * it's not really legal to split it out with commas. We split it
168 * up using a number of environment variables instead. */
169
170 compat = (char *) get_property(of->node, "compatible", &cplen);
171 while (compat && cplen > 0) {
172 int l;
173 envp[i++] = scratch;
174 length += scnprintf (scratch, buffer_size - length,
175 "OF_COMPATIBLE_%d=%s", seen, compat);
176 if ((buffer_size - length <= 0) || (i >= num_envp))
177 return -ENOMEM;
178 length++;
179 scratch += length;
180 l = strlen (compat) + 1;
181 compat += l;
182 cplen -= l;
183 seen++;
184 }
185
186 envp[i++] = scratch;
187 length += scnprintf (scratch, buffer_size - length,
188 "OF_COMPATIBLE_N=%d", seen);
189 if ((buffer_size - length <= 0) || (i >= num_envp))
190 return -ENOMEM;
191 ++length;
192 scratch += length;
193
194 envp[i] = NULL;
195
196 return 0;
197}
198
199extern struct device_attribute macio_dev_attrs[];
200
129struct bus_type macio_bus_type = { 201struct bus_type macio_bus_type = {
130 .name = "macio", 202 .name = "macio",
131 .match = macio_bus_match, 203 .match = macio_bus_match,
204 .hotplug = macio_hotplug,
132 .suspend = macio_device_suspend, 205 .suspend = macio_device_suspend,
133 .resume = macio_device_resume, 206 .resume = macio_device_resume,
207 .dev_attrs = macio_dev_attrs,
134}; 208};
135 209
136static int __init macio_bus_driver_init(void) 210static int __init macio_bus_driver_init(void)
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
new file mode 100644
index 000000000000..97d22bb4516a
--- /dev/null
+++ b/drivers/macintosh/macio_sysfs.c
@@ -0,0 +1,50 @@
1#include <linux/config.h>
2#include <linux/kernel.h>
3#include <linux/stat.h>
4#include <asm/macio.h>
5
6
7#define macio_config_of_attr(field, format_string) \
8static ssize_t \
9field##_show (struct device *dev, struct device_attribute *attr, \
10 char *buf) \
11{ \
12 struct macio_dev *mdev = to_macio_device (dev); \
13 return sprintf (buf, format_string, mdev->ofdev.node->field); \
14}
15
16static ssize_t
17compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
18{
19 struct of_device *of;
20 char *compat;
21 int cplen;
22 int length = 0;
23
24 of = &to_macio_device (dev)->ofdev;
25 compat = (char *) get_property(of->node, "compatible", &cplen);
26 if (!compat) {
27 *buf = '\0';
28 return 0;
29 }
30 while (cplen > 0) {
31 int l;
32 length += sprintf (buf, "%s\n", compat);
33 buf += length;
34 l = strlen (compat) + 1;
35 compat += l;
36 cplen -= l;
37 }
38
39 return length;
40}
41
42macio_config_of_attr (name, "%s\n");
43macio_config_of_attr (type, "%s\n");
44
45struct device_attribute macio_dev_attrs[] = {
46 __ATTR_RO(name),
47 __ATTR_RO(type),
48 __ATTR_RO(compatible),
49 __ATTR_NULL
50};
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
index 4be709e13eec..7c16c25fc5d4 100644
--- a/drivers/macintosh/mediabay.c
+++ b/drivers/macintosh/mediabay.c
@@ -642,7 +642,7 @@ static int __pmac media_bay_task(void *x)
642 } 642 }
643} 643}
644 644
645static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_match *match) 645static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_device_id *match)
646{ 646{
647 struct media_bay_info* bay; 647 struct media_bay_info* bay;
648 u32 __iomem *regbase; 648 u32 __iomem *regbase;
@@ -797,23 +797,20 @@ static struct mb_ops keylargo_mb_ops __pmacdata = {
797 * Therefore we do it all by polling the media bay once each tick. 797 * Therefore we do it all by polling the media bay once each tick.
798 */ 798 */
799 799
800static struct of_match media_bay_match[] = 800static struct of_device_id media_bay_match[] =
801{ 801{
802 { 802 {
803 .name = "media-bay", 803 .name = "media-bay",
804 .type = OF_ANY_MATCH,
805 .compatible = "keylargo-media-bay", 804 .compatible = "keylargo-media-bay",
806 .data = &keylargo_mb_ops, 805 .data = &keylargo_mb_ops,
807 }, 806 },
808 { 807 {
809 .name = "media-bay", 808 .name = "media-bay",
810 .type = OF_ANY_MATCH,
811 .compatible = "heathrow-media-bay", 809 .compatible = "heathrow-media-bay",
812 .data = &heathrow_mb_ops, 810 .data = &heathrow_mb_ops,
813 }, 811 },
814 { 812 {
815 .name = "media-bay", 813 .name = "media-bay",
816 .type = OF_ANY_MATCH,
817 .compatible = "ohare-media-bay", 814 .compatible = "ohare-media-bay",
818 .data = &ohare_mb_ops, 815 .data = &ohare_mb_ops,
819 }, 816 },
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index feb4e2413858..703e31973314 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -120,6 +120,7 @@
120#include <asm/system.h> 120#include <asm/system.h>
121#include <asm/sections.h> 121#include <asm/sections.h>
122#include <asm/of_device.h> 122#include <asm/of_device.h>
123#include <asm/macio.h>
123 124
124#include "therm_pm72.h" 125#include "therm_pm72.h"
125 126
@@ -1986,7 +1987,7 @@ static void fcu_lookup_fans(struct device_node *fcu_node)
1986 } 1987 }
1987} 1988}
1988 1989
1989static int fcu_of_probe(struct of_device* dev, const struct of_match *match) 1990static int fcu_of_probe(struct of_device* dev, const struct of_device_id *match)
1990{ 1991{
1991 int rc; 1992 int rc;
1992 1993
@@ -2009,12 +2010,10 @@ static int fcu_of_remove(struct of_device* dev)
2009 return 0; 2010 return 0;
2010} 2011}
2011 2012
2012static struct of_match fcu_of_match[] = 2013static struct of_device_id fcu_match[] =
2013{ 2014{
2014 { 2015 {
2015 .name = OF_ANY_MATCH,
2016 .type = "fcu", 2016 .type = "fcu",
2017 .compatible = OF_ANY_MATCH
2018 }, 2017 },
2019 {}, 2018 {},
2020}; 2019};
@@ -2022,7 +2021,7 @@ static struct of_match fcu_of_match[] =
2022static struct of_platform_driver fcu_of_platform_driver = 2021static struct of_platform_driver fcu_of_platform_driver =
2023{ 2022{
2024 .name = "temperature", 2023 .name = "temperature",
2025 .match_table = fcu_of_match, 2024 .match_table = fcu_match,
2026 .probe = fcu_of_probe, 2025 .probe = fcu_of_probe,
2027 .remove = fcu_of_remove 2026 .remove = fcu_of_remove
2028}; 2027};
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 61400f04015e..cbb72eb0426d 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -43,6 +43,7 @@
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/sections.h> 44#include <asm/sections.h>
45#include <asm/of_device.h> 45#include <asm/of_device.h>
46#include <asm/macio.h>
46 47
47#define LOG_TEMP 0 /* continously log temperature */ 48#define LOG_TEMP 0 /* continously log temperature */
48 49
@@ -450,7 +451,7 @@ do_probe( struct i2c_adapter *adapter, int addr, int kind )
450/************************************************************************/ 451/************************************************************************/
451 452
452static int 453static int
453therm_of_probe( struct of_device *dev, const struct of_match *match ) 454therm_of_probe( struct of_device *dev, const struct of_device_id *match )
454{ 455{
455 return i2c_add_driver( &g4fan_driver ); 456 return i2c_add_driver( &g4fan_driver );
456} 457}
@@ -461,9 +462,8 @@ therm_of_remove( struct of_device *dev )
461 return i2c_del_driver( &g4fan_driver ); 462 return i2c_del_driver( &g4fan_driver );
462} 463}
463 464
464static struct of_match therm_of_match[] = {{ 465static struct of_device_id therm_of_match[] = {{
465 .name = "fan", 466 .name = "fan",
466 .type = OF_ANY_MATCH,
467 .compatible = "adm1030" 467 .compatible = "adm1030"
468 }, {} 468 }, {}
469}; 469};
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 0c1b8520ef86..785806bdb248 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -63,6 +63,7 @@ struct multipath {
63 unsigned nr_priority_groups; 63 unsigned nr_priority_groups;
64 struct list_head priority_groups; 64 struct list_head priority_groups;
65 unsigned pg_init_required; /* pg_init needs calling? */ 65 unsigned pg_init_required; /* pg_init needs calling? */
66 unsigned pg_init_in_progress; /* Only one pg_init allowed at once */
66 67
67 unsigned nr_valid_paths; /* Total number of usable paths */ 68 unsigned nr_valid_paths; /* Total number of usable paths */
68 struct pgpath *current_pgpath; 69 struct pgpath *current_pgpath;
@@ -72,7 +73,7 @@ struct multipath {
72 73
73 unsigned queue_io; /* Must we queue all I/O? */ 74 unsigned queue_io; /* Must we queue all I/O? */
74 unsigned queue_if_no_path; /* Queue I/O if last path fails? */ 75 unsigned queue_if_no_path; /* Queue I/O if last path fails? */
75 unsigned suspended; /* Has dm core suspended our I/O? */ 76 unsigned saved_queue_if_no_path;/* Saved state during suspension */
76 77
77 struct work_struct process_queued_ios; 78 struct work_struct process_queued_ios;
78 struct bio_list queued_ios; 79 struct bio_list queued_ios;
@@ -304,11 +305,12 @@ static int map_io(struct multipath *m, struct bio *bio, struct mpath_io *mpio,
304 m->queue_size--; 305 m->queue_size--;
305 306
306 if ((pgpath && m->queue_io) || 307 if ((pgpath && m->queue_io) ||
307 (!pgpath && m->queue_if_no_path && !m->suspended)) { 308 (!pgpath && m->queue_if_no_path)) {
308 /* Queue for the daemon to resubmit */ 309 /* Queue for the daemon to resubmit */
309 bio_list_add(&m->queued_ios, bio); 310 bio_list_add(&m->queued_ios, bio);
310 m->queue_size++; 311 m->queue_size++;
311 if (m->pg_init_required || !m->queue_io) 312 if ((m->pg_init_required && !m->pg_init_in_progress) ||
313 !m->queue_io)
312 queue_work(kmultipathd, &m->process_queued_ios); 314 queue_work(kmultipathd, &m->process_queued_ios);
313 pgpath = NULL; 315 pgpath = NULL;
314 r = 0; 316 r = 0;
@@ -333,8 +335,9 @@ static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path)
333 335
334 spin_lock_irqsave(&m->lock, flags); 336 spin_lock_irqsave(&m->lock, flags);
335 337
338 m->saved_queue_if_no_path = m->queue_if_no_path;
336 m->queue_if_no_path = queue_if_no_path; 339 m->queue_if_no_path = queue_if_no_path;
337 if (!m->queue_if_no_path) 340 if (!m->queue_if_no_path && m->queue_size)
338 queue_work(kmultipathd, &m->process_queued_ios); 341 queue_work(kmultipathd, &m->process_queued_ios);
339 342
340 spin_unlock_irqrestore(&m->lock, flags); 343 spin_unlock_irqrestore(&m->lock, flags);
@@ -379,25 +382,31 @@ static void process_queued_ios(void *data)
379{ 382{
380 struct multipath *m = (struct multipath *) data; 383 struct multipath *m = (struct multipath *) data;
381 struct hw_handler *hwh = &m->hw_handler; 384 struct hw_handler *hwh = &m->hw_handler;
382 struct pgpath *pgpath; 385 struct pgpath *pgpath = NULL;
383 unsigned init_required, must_queue = 0; 386 unsigned init_required = 0, must_queue = 1;
384 unsigned long flags; 387 unsigned long flags;
385 388
386 spin_lock_irqsave(&m->lock, flags); 389 spin_lock_irqsave(&m->lock, flags);
387 390
391 if (!m->queue_size)
392 goto out;
393
388 if (!m->current_pgpath) 394 if (!m->current_pgpath)
389 __choose_pgpath(m); 395 __choose_pgpath(m);
390 396
391 pgpath = m->current_pgpath; 397 pgpath = m->current_pgpath;
392 398
393 if ((pgpath && m->queue_io) || 399 if ((pgpath && !m->queue_io) ||
394 (!pgpath && m->queue_if_no_path && !m->suspended)) 400 (!pgpath && !m->queue_if_no_path))
395 must_queue = 1; 401 must_queue = 0;
396 402
397 init_required = m->pg_init_required; 403 if (m->pg_init_required && !m->pg_init_in_progress) {
398 if (init_required)
399 m->pg_init_required = 0; 404 m->pg_init_required = 0;
405 m->pg_init_in_progress = 1;
406 init_required = 1;
407 }
400 408
409out:
401 spin_unlock_irqrestore(&m->lock, flags); 410 spin_unlock_irqrestore(&m->lock, flags);
402 411
403 if (init_required) 412 if (init_required)
@@ -752,6 +761,8 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc,
752static void multipath_dtr(struct dm_target *ti) 761static void multipath_dtr(struct dm_target *ti)
753{ 762{
754 struct multipath *m = (struct multipath *) ti->private; 763 struct multipath *m = (struct multipath *) ti->private;
764
765 flush_workqueue(kmultipathd);
755 free_multipath(m); 766 free_multipath(m);
756} 767}
757 768
@@ -765,6 +776,9 @@ static int multipath_map(struct dm_target *ti, struct bio *bio,
765 struct mpath_io *mpio; 776 struct mpath_io *mpio;
766 struct multipath *m = (struct multipath *) ti->private; 777 struct multipath *m = (struct multipath *) ti->private;
767 778
779 if (bio_barrier(bio))
780 return -EOPNOTSUPP;
781
768 mpio = mempool_alloc(m->mpio_pool, GFP_NOIO); 782 mpio = mempool_alloc(m->mpio_pool, GFP_NOIO);
769 dm_bio_record(&mpio->details, bio); 783 dm_bio_record(&mpio->details, bio);
770 784
@@ -837,7 +851,7 @@ static int reinstate_path(struct pgpath *pgpath)
837 pgpath->path.is_active = 1; 851 pgpath->path.is_active = 1;
838 852
839 m->current_pgpath = NULL; 853 m->current_pgpath = NULL;
840 if (!m->nr_valid_paths++) 854 if (!m->nr_valid_paths++ && m->queue_size)
841 queue_work(kmultipathd, &m->process_queued_ios); 855 queue_work(kmultipathd, &m->process_queued_ios);
842 856
843 queue_work(kmultipathd, &m->trigger_event); 857 queue_work(kmultipathd, &m->trigger_event);
@@ -963,12 +977,13 @@ void dm_pg_init_complete(struct path *path, unsigned err_flags)
963 bypass_pg(m, pg, 1); 977 bypass_pg(m, pg, 1);
964 978
965 spin_lock_irqsave(&m->lock, flags); 979 spin_lock_irqsave(&m->lock, flags);
966 if (!err_flags) 980 if (err_flags) {
967 m->queue_io = 0;
968 else {
969 m->current_pgpath = NULL; 981 m->current_pgpath = NULL;
970 m->current_pg = NULL; 982 m->current_pg = NULL;
971 } 983 } else if (!m->pg_init_required)
984 m->queue_io = 0;
985
986 m->pg_init_in_progress = 0;
972 queue_work(kmultipathd, &m->process_queued_ios); 987 queue_work(kmultipathd, &m->process_queued_ios);
973 spin_unlock_irqrestore(&m->lock, flags); 988 spin_unlock_irqrestore(&m->lock, flags);
974} 989}
@@ -988,9 +1003,12 @@ static int do_end_io(struct multipath *m, struct bio *bio,
988 if ((error == -EWOULDBLOCK) && bio_rw_ahead(bio)) 1003 if ((error == -EWOULDBLOCK) && bio_rw_ahead(bio))
989 return error; 1004 return error;
990 1005
1006 if (error == -EOPNOTSUPP)
1007 return error;
1008
991 spin_lock(&m->lock); 1009 spin_lock(&m->lock);
992 if (!m->nr_valid_paths) { 1010 if (!m->nr_valid_paths) {
993 if (!m->queue_if_no_path || m->suspended) { 1011 if (!m->queue_if_no_path) {
994 spin_unlock(&m->lock); 1012 spin_unlock(&m->lock);
995 return -EIO; 1013 return -EIO;
996 } else { 1014 } else {
@@ -1051,27 +1069,27 @@ static int multipath_end_io(struct dm_target *ti, struct bio *bio,
1051 1069
1052/* 1070/*
1053 * Suspend can't complete until all the I/O is processed so if 1071 * Suspend can't complete until all the I/O is processed so if
1054 * the last path failed we will now error any queued I/O. 1072 * the last path fails we must error any remaining I/O.
1073 * Note that if the freeze_bdev fails while suspending, the
1074 * queue_if_no_path state is lost - userspace should reset it.
1055 */ 1075 */
1056static void multipath_presuspend(struct dm_target *ti) 1076static void multipath_presuspend(struct dm_target *ti)
1057{ 1077{
1058 struct multipath *m = (struct multipath *) ti->private; 1078 struct multipath *m = (struct multipath *) ti->private;
1059 unsigned long flags;
1060 1079
1061 spin_lock_irqsave(&m->lock, flags); 1080 queue_if_no_path(m, 0);
1062 m->suspended = 1;
1063 if (m->queue_if_no_path)
1064 queue_work(kmultipathd, &m->process_queued_ios);
1065 spin_unlock_irqrestore(&m->lock, flags);
1066} 1081}
1067 1082
1083/*
1084 * Restore the queue_if_no_path setting.
1085 */
1068static void multipath_resume(struct dm_target *ti) 1086static void multipath_resume(struct dm_target *ti)
1069{ 1087{
1070 struct multipath *m = (struct multipath *) ti->private; 1088 struct multipath *m = (struct multipath *) ti->private;
1071 unsigned long flags; 1089 unsigned long flags;
1072 1090
1073 spin_lock_irqsave(&m->lock, flags); 1091 spin_lock_irqsave(&m->lock, flags);
1074 m->suspended = 0; 1092 m->queue_if_no_path = m->saved_queue_if_no_path;
1075 spin_unlock_irqrestore(&m->lock, flags); 1093 spin_unlock_irqrestore(&m->lock, flags);
1076} 1094}
1077 1095
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 6e3cf7e13451..12031c9d3f1e 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1060,6 +1060,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1060 } 1060 }
1061 1061
1062 ti->private = ms; 1062 ti->private = ms;
1063 ti->split_io = ms->rh.region_size;
1063 1064
1064 r = kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client); 1065 r = kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client);
1065 if (r) { 1066 if (r) {
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 7e691ab9a748..ab54f99b7c3b 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -777,7 +777,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
777 777
778 /* Full snapshots are not usable */ 778 /* Full snapshots are not usable */
779 if (!s->valid) 779 if (!s->valid)
780 return -1; 780 return -EIO;
781 781
782 /* 782 /*
783 * Write to snapshot - higher level takes care of RW/RO 783 * Write to snapshot - higher level takes care of RW/RO
@@ -931,6 +931,10 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
931 if (!snap->valid) 931 if (!snap->valid)
932 continue; 932 continue;
933 933
934 /* Nothing to do if writing beyond end of snapshot */
935 if (bio->bi_sector >= dm_table_get_size(snap->table))
936 continue;
937
934 down_write(&snap->lock); 938 down_write(&snap->lock);
935 939
936 /* 940 /*
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 18e9b9953fcd..a5a4c0ed8a14 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -943,6 +943,7 @@ EXPORT_SYMBOL(dm_vcalloc);
943EXPORT_SYMBOL(dm_get_device); 943EXPORT_SYMBOL(dm_get_device);
944EXPORT_SYMBOL(dm_put_device); 944EXPORT_SYMBOL(dm_put_device);
945EXPORT_SYMBOL(dm_table_event); 945EXPORT_SYMBOL(dm_table_event);
946EXPORT_SYMBOL(dm_table_get_size);
946EXPORT_SYMBOL(dm_table_get_mode); 947EXPORT_SYMBOL(dm_table_get_mode);
947EXPORT_SYMBOL(dm_table_put); 948EXPORT_SYMBOL(dm_table_put);
948EXPORT_SYMBOL(dm_table_get); 949EXPORT_SYMBOL(dm_table_get);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index f6b03957efc7..54fabbf06678 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -384,7 +384,7 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
384 /* error the io and bail out */ 384 /* error the io and bail out */
385 struct dm_io *io = tio->io; 385 struct dm_io *io = tio->io;
386 free_tio(tio->io->md, tio); 386 free_tio(tio->io->md, tio);
387 dec_pending(io, -EIO); 387 dec_pending(io, r);
388 bio_put(clone); 388 bio_put(clone);
389 } 389 }
390} 390}
@@ -966,23 +966,20 @@ static void __flush_deferred_io(struct mapped_device *md, struct bio *c)
966 */ 966 */
967int dm_swap_table(struct mapped_device *md, struct dm_table *table) 967int dm_swap_table(struct mapped_device *md, struct dm_table *table)
968{ 968{
969 int r; 969 int r = -EINVAL;
970 970
971 down_write(&md->lock); 971 down_write(&md->lock);
972 972
973 /* device must be suspended */ 973 /* device must be suspended */
974 if (!test_bit(DMF_SUSPENDED, &md->flags)) { 974 if (!test_bit(DMF_SUSPENDED, &md->flags))
975 up_write(&md->lock); 975 goto out;
976 return -EPERM;
977 }
978 976
979 __unbind(md); 977 __unbind(md);
980 r = __bind(md, table); 978 r = __bind(md, table);
981 if (r)
982 return r;
983 979
980out:
984 up_write(&md->lock); 981 up_write(&md->lock);
985 return 0; 982 return r;
986} 983}
987 984
988/* 985/*
@@ -1055,14 +1052,17 @@ int dm_suspend(struct mapped_device *md)
1055 if (test_bit(DMF_BLOCK_IO, &md->flags)) 1052 if (test_bit(DMF_BLOCK_IO, &md->flags))
1056 goto out_read_unlock; 1053 goto out_read_unlock;
1057 1054
1058 error = __lock_fs(md);
1059 if (error)
1060 goto out_read_unlock;
1061
1062 map = dm_get_table(md); 1055 map = dm_get_table(md);
1063 if (map) 1056 if (map)
1057 /* This does not get reverted if there's an error later. */
1064 dm_table_presuspend_targets(map); 1058 dm_table_presuspend_targets(map);
1065 1059
1060 error = __lock_fs(md);
1061 if (error) {
1062 dm_table_put(map);
1063 goto out_read_unlock;
1064 }
1065
1066 up_read(&md->lock); 1066 up_read(&md->lock);
1067 1067
1068 /* 1068 /*
@@ -1121,7 +1121,6 @@ int dm_suspend(struct mapped_device *md)
1121 return 0; 1121 return 0;
1122 1122
1123out_unfreeze: 1123out_unfreeze:
1124 /* FIXME Undo dm_table_presuspend_targets */
1125 __unlock_fs(md); 1124 __unlock_fs(md);
1126 clear_bit(DMF_BLOCK_IO, &md->flags); 1125 clear_bit(DMF_BLOCK_IO, &md->flags);
1127out_write_unlock: 1126out_write_unlock:
diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c
index 4adb2843f8be..ab7a1fba4427 100644
--- a/drivers/media/common/ir-common.c
+++ b/drivers/media/common/ir-common.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ir-common.c,v 1.10 2005/05/22 19:23:39 nsh Exp $ 2 * $Id: ir-common.c,v 1.11 2005/07/07 14:44:43 mchehab Exp $
3 * 3 *
4 * some common structs and functions to handle infrared remotes via 4 * some common structs and functions to handle infrared remotes via
5 * input layer ... 5 * input layer ...
@@ -46,79 +46,49 @@ module_param(debug, int, 0644);
46/* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */ 46/* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */
47/* used by old (black) Hauppauge remotes */ 47/* used by old (black) Hauppauge remotes */
48IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE] = { 48IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE] = {
49 [ 0x00 ] = KEY_KP0, // 0 49 /* Keys 0 to 9 */
50 [ 0x01 ] = KEY_KP1, // 1 50 [ 0x00 ] = KEY_KP0,
51 [ 0x02 ] = KEY_KP2, // 2 51 [ 0x01 ] = KEY_KP1,
52 [ 0x03 ] = KEY_KP3, // 3 52 [ 0x02 ] = KEY_KP2,
53 [ 0x04 ] = KEY_KP4, // 4 53 [ 0x03 ] = KEY_KP3,
54 [ 0x05 ] = KEY_KP5, // 5 54 [ 0x04 ] = KEY_KP4,
55 [ 0x06 ] = KEY_KP6, // 6 55 [ 0x05 ] = KEY_KP5,
56 [ 0x07 ] = KEY_KP7, // 7 56 [ 0x06 ] = KEY_KP6,
57 [ 0x08 ] = KEY_KP8, // 8 57 [ 0x07 ] = KEY_KP7,
58 [ 0x09 ] = KEY_KP9, // 9 58 [ 0x08 ] = KEY_KP8,
59 59 [ 0x09 ] = KEY_KP9,
60 [ 0x0b ] = KEY_CHANNEL, // channel / program (japan: 11) 60
61 [ 0x0c ] = KEY_POWER, // standby 61 [ 0x0b ] = KEY_CHANNEL, /* channel / program (japan: 11) */
62 [ 0x0d ] = KEY_MUTE, // mute / demute 62 [ 0x0c ] = KEY_POWER, /* standby */
63 [ 0x0f ] = KEY_TV, // display 63 [ 0x0d ] = KEY_MUTE, /* mute / demute */
64 [ 0x10 ] = KEY_VOLUMEUP, // volume + 64 [ 0x0f ] = KEY_TV, /* display */
65 [ 0x11 ] = KEY_VOLUMEDOWN, // volume - 65 [ 0x10 ] = KEY_VOLUMEUP,
66 [ 0x12 ] = KEY_BRIGHTNESSUP, // brightness + 66 [ 0x11 ] = KEY_VOLUMEDOWN,
67 [ 0x13 ] = KEY_BRIGHTNESSDOWN, // brightness - 67 [ 0x12 ] = KEY_BRIGHTNESSUP,
68 [ 0x1e ] = KEY_SEARCH, // search + 68 [ 0x13 ] = KEY_BRIGHTNESSDOWN,
69 [ 0x20 ] = KEY_CHANNELUP, // channel / program + 69 [ 0x1e ] = KEY_SEARCH, /* search + */
70 [ 0x21 ] = KEY_CHANNELDOWN, // channel / program - 70 [ 0x20 ] = KEY_CHANNELUP, /* channel / program + */
71 [ 0x22 ] = KEY_CHANNEL, // alt / channel 71 [ 0x21 ] = KEY_CHANNELDOWN, /* channel / program - */
72 [ 0x23 ] = KEY_LANGUAGE, // 1st / 2nd language 72 [ 0x22 ] = KEY_CHANNEL, /* alt / channel */
73 [ 0x26 ] = KEY_SLEEP, // sleeptimer 73 [ 0x23 ] = KEY_LANGUAGE, /* 1st / 2nd language */
74 [ 0x2e ] = KEY_MENU, // 2nd controls (USA: menu) 74 [ 0x26 ] = KEY_SLEEP, /* sleeptimer */
75 [ 0x30 ] = KEY_PAUSE, // pause 75 [ 0x2e ] = KEY_MENU, /* 2nd controls (USA: menu) */
76 [ 0x32 ] = KEY_REWIND, // rewind 76 [ 0x30 ] = KEY_PAUSE,
77 [ 0x33 ] = KEY_GOTO, // go to 77 [ 0x32 ] = KEY_REWIND,
78 [ 0x35 ] = KEY_PLAY, // play 78 [ 0x33 ] = KEY_GOTO,
79 [ 0x36 ] = KEY_STOP, // stop 79 [ 0x35 ] = KEY_PLAY,
80 [ 0x37 ] = KEY_RECORD, // recording 80 [ 0x36 ] = KEY_STOP,
81 [ 0x3c ] = KEY_TEXT, // teletext submode (Japan: 12) 81 [ 0x37 ] = KEY_RECORD, /* recording */
82 [ 0x3d ] = KEY_SUSPEND, // system standby 82 [ 0x3c ] = KEY_TEXT, /* teletext submode (Japan: 12) */
83 83 [ 0x3d ] = KEY_SUSPEND, /* system standby */
84#if 0 /* FIXME */ 84
85 [ 0x0a ] = KEY_RESERVED, // 1/2/3 digits (japan: 10)
86 [ 0x0e ] = KEY_RESERVED, // P.P. (personal preference)
87 [ 0x14 ] = KEY_RESERVED, // colour saturation +
88 [ 0x15 ] = KEY_RESERVED, // colour saturation -
89 [ 0x16 ] = KEY_RESERVED, // bass +
90 [ 0x17 ] = KEY_RESERVED, // bass -
91 [ 0x18 ] = KEY_RESERVED, // treble +
92 [ 0x19 ] = KEY_RESERVED, // treble -
93 [ 0x1a ] = KEY_RESERVED, // balance right
94 [ 0x1b ] = KEY_RESERVED, // balance left
95 [ 0x1c ] = KEY_RESERVED, // contrast +
96 [ 0x1d ] = KEY_RESERVED, // contrast -
97 [ 0x1f ] = KEY_RESERVED, // tint/hue +
98 [ 0x24 ] = KEY_RESERVED, // spacial stereo on/off
99 [ 0x25 ] = KEY_RESERVED, // mono / stereo (USA)
100 [ 0x27 ] = KEY_RESERVED, // tint / hue -
101 [ 0x28 ] = KEY_RESERVED, // RF switch/PIP select
102 [ 0x29 ] = KEY_RESERVED, // vote
103 [ 0x2a ] = KEY_RESERVED, // timed page/channel clck
104 [ 0x2b ] = KEY_RESERVED, // increment (USA)
105 [ 0x2c ] = KEY_RESERVED, // decrement (USA)
106 [ 0x2d ] = KEY_RESERVED, //
107 [ 0x2f ] = KEY_RESERVED, // PIP shift
108 [ 0x31 ] = KEY_RESERVED, // erase
109 [ 0x34 ] = KEY_RESERVED, // wind
110 [ 0x38 ] = KEY_RESERVED, // external 1
111 [ 0x39 ] = KEY_RESERVED, // external 2
112 [ 0x3a ] = KEY_RESERVED, // PIP display mode
113 [ 0x3b ] = KEY_RESERVED, // view data mode / advance
114 [ 0x3e ] = KEY_RESERVED, // crispener on/off
115 [ 0x3f ] = KEY_RESERVED, // system select
116#endif
117}; 85};
118EXPORT_SYMBOL_GPL(ir_codes_rc5_tv); 86EXPORT_SYMBOL_GPL(ir_codes_rc5_tv);
119 87
120/* Table for Leadtek Winfast Remote Controls - used by both bttv and cx88 */ 88/* Table for Leadtek Winfast Remote Controls - used by both bttv and cx88 */
121IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = { 89IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
90 /* Keys 0 to 9 */
91 [ 18 ] = KEY_KP0,
122 [ 5 ] = KEY_KP1, 92 [ 5 ] = KEY_KP1,
123 [ 6 ] = KEY_KP2, 93 [ 6 ] = KEY_KP2,
124 [ 7 ] = KEY_KP3, 94 [ 7 ] = KEY_KP3,
@@ -128,39 +98,31 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
128 [ 13 ] = KEY_KP7, 98 [ 13 ] = KEY_KP7,
129 [ 14 ] = KEY_KP8, 99 [ 14 ] = KEY_KP8,
130 [ 15 ] = KEY_KP9, 100 [ 15 ] = KEY_KP9,
131 [ 18 ] = KEY_KP0,
132 101
133 [ 0 ] = KEY_POWER, 102 [ 0 ] = KEY_POWER,
134// [ 27 ] = MTS button 103 [ 2 ] = KEY_TUNER, /* TV/FM */
135 [ 2 ] = KEY_TUNER, // TV/FM
136 [ 30 ] = KEY_VIDEO, 104 [ 30 ] = KEY_VIDEO,
137// [ 22 ] = display button
138 [ 4 ] = KEY_VOLUMEUP, 105 [ 4 ] = KEY_VOLUMEUP,
139 [ 8 ] = KEY_VOLUMEDOWN, 106 [ 8 ] = KEY_VOLUMEDOWN,
140 [ 12 ] = KEY_CHANNELUP, 107 [ 12 ] = KEY_CHANNELUP,
141 [ 16 ] = KEY_CHANNELDOWN, 108 [ 16 ] = KEY_CHANNELDOWN,
142 [ 3 ] = KEY_ZOOM, // fullscreen 109 [ 3 ] = KEY_ZOOM, /* fullscreen */
143 [ 31 ] = KEY_SUBTITLE, // closed caption/teletext 110 [ 31 ] = KEY_SUBTITLE, /* closed caption/teletext */
144 [ 32 ] = KEY_SLEEP, 111 [ 32 ] = KEY_SLEEP,
145// [ 41 ] = boss key
146 [ 20 ] = KEY_MUTE, 112 [ 20 ] = KEY_MUTE,
147 [ 43 ] = KEY_RED, 113 [ 43 ] = KEY_RED,
148 [ 44 ] = KEY_GREEN, 114 [ 44 ] = KEY_GREEN,
149 [ 45 ] = KEY_YELLOW, 115 [ 45 ] = KEY_YELLOW,
150 [ 46 ] = KEY_BLUE, 116 [ 46 ] = KEY_BLUE,
151 [ 24 ] = KEY_KPPLUS, //fine tune + 117 [ 24 ] = KEY_KPPLUS, /* fine tune + */
152 [ 25 ] = KEY_KPMINUS, //fine tune - 118 [ 25 ] = KEY_KPMINUS, /* fine tune - */
153// [ 42 ] = picture in picture
154 [ 33 ] = KEY_KPDOT, 119 [ 33 ] = KEY_KPDOT,
155 [ 19 ] = KEY_KPENTER, 120 [ 19 ] = KEY_KPENTER,
156// [ 17 ] = recall
157 [ 34 ] = KEY_BACK, 121 [ 34 ] = KEY_BACK,
158 [ 35 ] = KEY_PLAYPAUSE, 122 [ 35 ] = KEY_PLAYPAUSE,
159 [ 36 ] = KEY_NEXT, 123 [ 36 ] = KEY_NEXT,
160// [ 37 ] = time shifting
161 [ 38 ] = KEY_STOP, 124 [ 38 ] = KEY_STOP,
162 [ 39 ] = KEY_RECORD 125 [ 39 ] = KEY_RECORD
163// [ 40 ] = snapshot
164}; 126};
165EXPORT_SYMBOL_GPL(ir_codes_winfast); 127EXPORT_SYMBOL_GPL(ir_codes_winfast);
166 128
@@ -174,54 +136,61 @@ EXPORT_SYMBOL_GPL(ir_codes_empty);
174 * slightly different versions), shipped with cx88+ivtv cards. 136 * slightly different versions), shipped with cx88+ivtv cards.
175 * almost rc5 coding, but some non-standard keys */ 137 * almost rc5 coding, but some non-standard keys */
176IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE] = { 138IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE] = {
177 [ 0x00 ] = KEY_KP0, // 0 139 /* Keys 0 to 9 */
178 [ 0x01 ] = KEY_KP1, // 1 140 [ 0x00 ] = KEY_KP0,
179 [ 0x02 ] = KEY_KP2, // 2 141 [ 0x01 ] = KEY_KP1,
180 [ 0x03 ] = KEY_KP3, // 3 142 [ 0x02 ] = KEY_KP2,
181 [ 0x04 ] = KEY_KP4, // 4 143 [ 0x03 ] = KEY_KP3,
182 [ 0x05 ] = KEY_KP5, // 5 144 [ 0x04 ] = KEY_KP4,
183 [ 0x06 ] = KEY_KP6, // 6 145 [ 0x05 ] = KEY_KP5,
184 [ 0x07 ] = KEY_KP7, // 7 146 [ 0x06 ] = KEY_KP6,
185 [ 0x08 ] = KEY_KP8, // 8 147 [ 0x07 ] = KEY_KP7,
186 [ 0x09 ] = KEY_KP9, // 9 148 [ 0x08 ] = KEY_KP8,
187 [ 0x0a ] = KEY_TEXT, // keypad asterisk as well 149 [ 0x09 ] = KEY_KP9,
188 [ 0x0b ] = KEY_RED, // red button 150
189 [ 0x0c ] = KEY_RADIO, // radio 151 [ 0x0a ] = KEY_TEXT, /* keypad asterisk as well */
190 [ 0x0d ] = KEY_MENU, // menu 152 [ 0x0b ] = KEY_RED, /* red button */
191 [ 0x0e ] = KEY_SUBTITLE, // also the # key 153 [ 0x0c ] = KEY_RADIO,
192 [ 0x0f ] = KEY_MUTE, // mute 154 [ 0x0d ] = KEY_MENU,
193 [ 0x10 ] = KEY_VOLUMEUP, // volume + 155 [ 0x0e ] = KEY_SUBTITLE, /* also the # key */
194 [ 0x11 ] = KEY_VOLUMEDOWN, // volume - 156 [ 0x0f ] = KEY_MUTE,
195 [ 0x12 ] = KEY_PREVIOUS, // previous channel 157 [ 0x10 ] = KEY_VOLUMEUP,
196 [ 0x14 ] = KEY_UP, // up 158 [ 0x11 ] = KEY_VOLUMEDOWN,
197 [ 0x15 ] = KEY_DOWN, // down 159 [ 0x12 ] = KEY_PREVIOUS, /* previous channel */
198 [ 0x16 ] = KEY_LEFT, // left 160 [ 0x14 ] = KEY_UP,
199 [ 0x17 ] = KEY_RIGHT, // right 161 [ 0x15 ] = KEY_DOWN,
200 [ 0x18 ] = KEY_VIDEO, // Videos 162 [ 0x16 ] = KEY_LEFT,
201 [ 0x19 ] = KEY_AUDIO, // Music 163 [ 0x17 ] = KEY_RIGHT,
202 [ 0x1a ] = KEY_MHP, // Pictures - presume this means "Multimedia Home Platform"- no "PICTURES" key in input.h 164 [ 0x18 ] = KEY_VIDEO, /* Videos */
203 [ 0x1b ] = KEY_EPG, // Guide 165 [ 0x19 ] = KEY_AUDIO, /* Music */
204 [ 0x1c ] = KEY_TV, // TV 166 /* 0x1a: Pictures - presume this means
205 [ 0x1e ] = KEY_NEXTSONG, // skip >| 167 "Multimedia Home Platform" -
206 [ 0x1f ] = KEY_EXIT, // back/exit 168 no "PICTURES" key in input.h
207 [ 0x20 ] = KEY_CHANNELUP, // channel / program + 169 */
208 [ 0x21 ] = KEY_CHANNELDOWN, // channel / program - 170 [ 0x1a ] = KEY_MHP,
209 [ 0x22 ] = KEY_CHANNEL, // source (old black remote) 171
210 [ 0x24 ] = KEY_PREVIOUSSONG, // replay |< 172 [ 0x1b ] = KEY_EPG, /* Guide */
211 [ 0x25 ] = KEY_ENTER, // OK 173 [ 0x1c ] = KEY_TV,
212 [ 0x26 ] = KEY_SLEEP, // minimize (old black remote) 174 [ 0x1e ] = KEY_NEXTSONG, /* skip >| */
213 [ 0x29 ] = KEY_BLUE, // blue key 175 [ 0x1f ] = KEY_EXIT, /* back/exit */
214 [ 0x2e ] = KEY_GREEN, // green button 176 [ 0x20 ] = KEY_CHANNELUP, /* channel / program + */
215 [ 0x30 ] = KEY_PAUSE, // pause 177 [ 0x21 ] = KEY_CHANNELDOWN, /* channel / program - */
216 [ 0x32 ] = KEY_REWIND, // backward << 178 [ 0x22 ] = KEY_CHANNEL, /* source (old black remote) */
217 [ 0x34 ] = KEY_FASTFORWARD, // forward >> 179 [ 0x24 ] = KEY_PREVIOUSSONG, /* replay |< */
218 [ 0x35 ] = KEY_PLAY, // play 180 [ 0x25 ] = KEY_ENTER, /* OK */
219 [ 0x36 ] = KEY_STOP, // stop 181 [ 0x26 ] = KEY_SLEEP, /* minimize (old black remote) */
220 [ 0x37 ] = KEY_RECORD, // recording 182 [ 0x29 ] = KEY_BLUE, /* blue key */
221 [ 0x38 ] = KEY_YELLOW, // yellow key 183 [ 0x2e ] = KEY_GREEN, /* green button */
222 [ 0x3b ] = KEY_SELECT, // top right button 184 [ 0x30 ] = KEY_PAUSE, /* pause */
223 [ 0x3c ] = KEY_ZOOM, // full 185 [ 0x32 ] = KEY_REWIND, /* backward << */
224 [ 0x3d ] = KEY_POWER, // system power (green button) 186 [ 0x34 ] = KEY_FASTFORWARD, /* forward >> */
187 [ 0x35 ] = KEY_PLAY,
188 [ 0x36 ] = KEY_STOP,
189 [ 0x37 ] = KEY_RECORD, /* recording */
190 [ 0x38 ] = KEY_YELLOW, /* yellow key */
191 [ 0x3b ] = KEY_SELECT, /* top right button */
192 [ 0x3c ] = KEY_ZOOM, /* full */
193 [ 0x3d ] = KEY_POWER, /* system power (green button) */
225}; 194};
226EXPORT_SYMBOL(ir_codes_hauppauge_new); 195EXPORT_SYMBOL(ir_codes_hauppauge_new);
227 196
@@ -237,9 +206,9 @@ IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = {
237 [ 10 ] = KEY_KP8, 206 [ 10 ] = KEY_KP8,
238 [ 18 ] = KEY_KP9, 207 [ 18 ] = KEY_KP9,
239 208
240 [ 3 ] = KEY_TUNER, // TV/FM 209 [ 3 ] = KEY_TUNER, /* TV/FM */
241 [ 7 ] = KEY_SEARCH, // scan 210 [ 7 ] = KEY_SEARCH, /* scan */
242 [ 28 ] = KEY_ZOOM, // full screen 211 [ 28 ] = KEY_ZOOM, /* full screen */
243 [ 30 ] = KEY_POWER, 212 [ 30 ] = KEY_POWER,
244 [ 23 ] = KEY_VOLUMEDOWN, 213 [ 23 ] = KEY_VOLUMEDOWN,
245 [ 31 ] = KEY_VOLUMEUP, 214 [ 31 ] = KEY_VOLUMEUP,
@@ -247,14 +216,14 @@ IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = {
247 [ 22 ] = KEY_CHANNELUP, 216 [ 22 ] = KEY_CHANNELUP,
248 [ 24 ] = KEY_MUTE, 217 [ 24 ] = KEY_MUTE,
249 218
250 [ 0 ] = KEY_LIST, // source 219 [ 0 ] = KEY_LIST, /* source */
251 [ 19 ] = KEY_INFO, // loop 220 [ 19 ] = KEY_INFO, /* loop */
252 [ 16 ] = KEY_LAST, // +100 221 [ 16 ] = KEY_LAST, /* +100 */
253 [ 13 ] = KEY_CLEAR, // reset 222 [ 13 ] = KEY_CLEAR, /* reset */
254 [ 12 ] = BTN_RIGHT, // fun++ 223 [ 12 ] = BTN_RIGHT, /* fun++ */
255 [ 4 ] = BTN_LEFT, // fun-- 224 [ 4 ] = BTN_LEFT, /* fun-- */
256 [ 14 ] = KEY_GOTO, // function 225 [ 14 ] = KEY_GOTO, /* function */
257 [ 15 ] = KEY_STOP, // freeze 226 [ 15 ] = KEY_STOP, /* freeze */
258}; 227};
259EXPORT_SYMBOL(ir_codes_pixelview); 228EXPORT_SYMBOL(ir_codes_pixelview);
260 229
@@ -321,10 +290,6 @@ void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
321 ir->keypressed = 1; 290 ir->keypressed = 1;
322 ir_input_key_event(dev,ir); 291 ir_input_key_event(dev,ir);
323 } 292 }
324#if 0
325 /* maybe do something like this ??? */
326 input_event(a, EV_IR, ir->ir_type, ir->ir_raw);
327#endif
328} 293}
329 294
330/* -------------------------------------------------------------------------- */ 295/* -------------------------------------------------------------------------- */
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 50e8b8654018..cd5828b5e9e3 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -62,13 +62,15 @@ void saa7146_setgpio(struct saa7146_dev *dev, int port, u32 data)
62int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop) 62int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop)
63{ 63{
64 unsigned long start; 64 unsigned long start;
65 int err;
65 66
66 /* wait for registers to be programmed */ 67 /* wait for registers to be programmed */
67 start = jiffies; 68 start = jiffies;
68 while (1) { 69 while (1) {
69 if (saa7146_read(dev, MC2) & 2) 70 err = time_after(jiffies, start + HZ/20);
70 break; 71 if (saa7146_read(dev, MC2) & 2)
71 if (time_after(jiffies, start + HZ/20)) { 72 break;
73 if (err) {
72 DEB_S(("timed out while waiting for registers getting programmed\n")); 74 DEB_S(("timed out while waiting for registers getting programmed\n"));
73 return -ETIMEDOUT; 75 return -ETIMEDOUT;
74 } 76 }
@@ -79,10 +81,11 @@ int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop)
79 /* wait for transfer to complete */ 81 /* wait for transfer to complete */
80 start = jiffies; 82 start = jiffies;
81 while (1) { 83 while (1) {
84 err = time_after(jiffies, start + HZ/4);
82 if (!(saa7146_read(dev, PSR) & SPCI_DEBI_S)) 85 if (!(saa7146_read(dev, PSR) & SPCI_DEBI_S))
83 break; 86 break;
84 saa7146_read(dev, MC2); 87 saa7146_read(dev, MC2);
85 if (time_after(jiffies, start + HZ/4)) { 88 if (err) {
86 DEB_S(("timed out while waiting for transfer completion\n")); 89 DEB_S(("timed out while waiting for transfer completion\n"));
87 return -ETIMEDOUT; 90 return -ETIMEDOUT;
88 } 91 }
@@ -512,7 +515,7 @@ int saa7146_register_extension(struct saa7146_extension* ext)
512 ext->driver.remove = saa7146_remove_one; 515 ext->driver.remove = saa7146_remove_one;
513 516
514 printk("saa7146: register extension '%s'.\n",ext->name); 517 printk("saa7146: register extension '%s'.\n",ext->name);
515 return pci_module_init(&ext->driver); 518 return pci_register_driver(&ext->driver);
516} 519}
517 520
518int saa7146_unregister_extension(struct saa7146_extension* ext) 521int saa7146_unregister_extension(struct saa7146_extension* ext)
diff --git a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig
index 01387f883cdf..3f0ec6be03ae 100644
--- a/drivers/media/dvb/Kconfig
+++ b/drivers/media/dvb/Kconfig
@@ -40,6 +40,10 @@ comment "Supported BT878 Adapters"
40 depends on DVB_CORE && PCI 40 depends on DVB_CORE && PCI
41source "drivers/media/dvb/bt8xx/Kconfig" 41source "drivers/media/dvb/bt8xx/Kconfig"
42 42
43comment "Supported Pluto2 Adapters"
44 depends on DVB_CORE && PCI
45source "drivers/media/dvb/pluto2/Kconfig"
46
43comment "Supported DVB Frontends" 47comment "Supported DVB Frontends"
44 depends on DVB_CORE 48 depends on DVB_CORE
45source "drivers/media/dvb/frontends/Kconfig" 49source "drivers/media/dvb/frontends/Kconfig"
diff --git a/drivers/media/dvb/Makefile b/drivers/media/dvb/Makefile
index 3c6ff1619103..a7ad0841e6fc 100644
--- a/drivers/media/dvb/Makefile
+++ b/drivers/media/dvb/Makefile
@@ -2,4 +2,4 @@
2# Makefile for the kernel multimedia device drivers. 2# Makefile for the kernel multimedia device drivers.
3# 3#
4 4
5obj-y := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ cinergyT2/ dvb-usb/ 5obj-y := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ cinergyT2/ dvb-usb/ pluto2/
diff --git a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig
index fafd0ab3a28f..d7417eac2aba 100644
--- a/drivers/media/dvb/b2c2/Kconfig
+++ b/drivers/media/dvb/b2c2/Kconfig
@@ -35,17 +35,3 @@ config DVB_B2C2_FLEXCOP_DEBUG
35 help 35 help
36 Say Y if you want to enable the module option to control debug messages 36 Say Y if you want to enable the module option to control debug messages
37 of all B2C2 FlexCop drivers. 37 of all B2C2 FlexCop drivers.
38
39config DVB_B2C2_SKYSTAR
40 tristate "B2C2/Technisat Air/Sky/CableStar 2 PCI"
41 depends on DVB_CORE && PCI
42 select DVB_STV0299
43 select DVB_MT352
44 select DVB_MT312
45 select DVB_NXT2002
46 help
47 Support for the Skystar2 PCI DVB card by Technisat, which
48 is equipped with the FlexCopII chipset by B2C2, and
49 for the B2C2/BBTI Air2PC-ATSC card.
50
51 Say Y if you own such a device and want to use it.
diff --git a/drivers/media/dvb/b2c2/Makefile b/drivers/media/dvb/b2c2/Makefile
index 7703812af34f..1a1c3bca55fa 100644
--- a/drivers/media/dvb/b2c2/Makefile
+++ b/drivers/media/dvb/b2c2/Makefile
@@ -9,6 +9,4 @@ obj-$(CONFIG_DVB_B2C2_FLEXCOP_PCI) += b2c2-flexcop-pci.o
9b2c2-flexcop-usb-objs = flexcop-usb.o 9b2c2-flexcop-usb-objs = flexcop-usb.o
10obj-$(CONFIG_DVB_B2C2_FLEXCOP_USB) += b2c2-flexcop-usb.o 10obj-$(CONFIG_DVB_B2C2_FLEXCOP_USB) += b2c2-flexcop-usb.o
11 11
12obj-$(CONFIG_DVB_B2C2_SKYSTAR) += skystar2.o
13
14EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 12EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h
index 773d158032df..a94912ac1872 100644
--- a/drivers/media/dvb/b2c2/flexcop-common.h
+++ b/drivers/media/dvb/b2c2/flexcop-common.h
@@ -108,6 +108,8 @@ void flexcop_device_kfree(struct flexcop_device*);
108int flexcop_device_initialize(struct flexcop_device*); 108int flexcop_device_initialize(struct flexcop_device*);
109void flexcop_device_exit(struct flexcop_device *fc); 109void flexcop_device_exit(struct flexcop_device *fc);
110 110
111void flexcop_reset_block_300(struct flexcop_device *fc);
112
111/* from flexcop-dma.c */ 113/* from flexcop-dma.c */
112int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size); 114int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size);
113void flexcop_dma_free(struct flexcop_dma *dma); 115void flexcop_dma_free(struct flexcop_dma *dma);
@@ -115,7 +117,8 @@ void flexcop_dma_free(struct flexcop_dma *dma);
115int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 117int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
116int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 118int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
117int flexcop_dma_control_packet_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 119int flexcop_dma_control_packet_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
118int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx,flexcop_dma_addr_index_t index); 120int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx);
121int flexcop_dma_xfer_control(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, flexcop_dma_addr_index_t index, int onoff);
119int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles); 122int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles);
120int flexcop_dma_config_packet_count(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 packets); 123int flexcop_dma_config_packet_count(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 packets);
121 124
@@ -151,6 +154,7 @@ int flexcop_sram_init(struct flexcop_device *fc);
151/* from flexcop-misc.c */ 154/* from flexcop-misc.c */
152void flexcop_determine_revision(struct flexcop_device *fc); 155void flexcop_determine_revision(struct flexcop_device *fc);
153void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const char *suffix); 156void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const char *suffix);
157void flexcop_dump_reg(struct flexcop_device *fc, flexcop_ibi_register reg, int num);
154 158
155/* from flexcop-hw-filter.c */ 159/* from flexcop-hw-filter.c */
156int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff); 160int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff);
diff --git a/drivers/media/dvb/b2c2/flexcop-dma.c b/drivers/media/dvb/b2c2/flexcop-dma.c
index 8d2706075360..cf4ed1df6086 100644
--- a/drivers/media/dvb/b2c2/flexcop-dma.c
+++ b/drivers/media/dvb/b2c2/flexcop-dma.c
@@ -37,22 +37,90 @@ void flexcop_dma_free(struct flexcop_dma *dma)
37} 37}
38EXPORT_SYMBOL(flexcop_dma_free); 38EXPORT_SYMBOL(flexcop_dma_free);
39 39
40int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff) 40int flexcop_dma_config(struct flexcop_device *fc,
41 struct flexcop_dma *dma,
42 flexcop_dma_index_t dma_idx)
41{ 43{
42 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208); 44 flexcop_ibi_value v0x0,v0x4,v0xc;
45 v0x0.raw = v0x4.raw = v0xc.raw = 0;
43 46
44 if (no & FC_DMA_1) 47 v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2;
45 v.ctrl_208.DMA1_Timer_Enable_sig = onoff; 48 v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2;
49 v0x4.dma_0x4_write.dma_addr_size = dma->size / 4;
46 50
47 if (no & FC_DMA_2) 51 if ((dma_idx & FC_DMA_1) == dma_idx) {
48 v.ctrl_208.DMA2_Timer_Enable_sig = onoff; 52 fc->write_ibi_reg(fc,dma1_000,v0x0);
53 fc->write_ibi_reg(fc,dma1_004,v0x4);
54 fc->write_ibi_reg(fc,dma1_00c,v0xc);
55 } else if ((dma_idx & FC_DMA_2) == dma_idx) {
56 fc->write_ibi_reg(fc,dma2_010,v0x0);
57 fc->write_ibi_reg(fc,dma2_014,v0x4);
58 fc->write_ibi_reg(fc,dma2_01c,v0xc);
59 } else {
60 err("either DMA1 or DMA2 can be configured at the within one flexcop_dma_config call.");
61 return -EINVAL;
62 }
49 63
50 fc->write_ibi_reg(fc,ctrl_208,v);
51 return 0; 64 return 0;
52} 65}
53EXPORT_SYMBOL(flexcop_dma_control_timer_irq); 66EXPORT_SYMBOL(flexcop_dma_config);
67
68/* start the DMA transfers, but not the DMA IRQs */
69int flexcop_dma_xfer_control(struct flexcop_device *fc,
70 flexcop_dma_index_t dma_idx,
71 flexcop_dma_addr_index_t index,
72 int onoff)
73{
74 flexcop_ibi_value v0x0,v0xc;
75 flexcop_ibi_register r0x0,r0xc;
76
77 if ((dma_idx & FC_DMA_1) == dma_idx) {
78 r0x0 = dma1_000;
79 r0xc = dma1_00c;
80 } else if ((dma_idx & FC_DMA_2) == dma_idx) {
81 r0x0 = dma2_010;
82 r0xc = dma2_01c;
83 } else {
84 err("either transfer DMA1 or DMA2 can be started within one flexcop_dma_xfer_control call.");
85 return -EINVAL;
86 }
87
88 v0x0 = fc->read_ibi_reg(fc,r0x0);
89 v0xc = fc->read_ibi_reg(fc,r0xc);
90
91 deb_rdump("reg: %03x: %x\n",r0x0,v0x0.raw);
92 deb_rdump("reg: %03x: %x\n",r0xc,v0xc.raw);
93
94 if (index & FC_DMA_SUBADDR_0)
95 v0x0.dma_0x0.dma_0start = onoff;
96
97 if (index & FC_DMA_SUBADDR_1)
98 v0xc.dma_0xc.dma_1start = onoff;
99
100 fc->write_ibi_reg(fc,r0x0,v0x0);
101 fc->write_ibi_reg(fc,r0xc,v0xc);
102
103 deb_rdump("reg: %03x: %x\n",r0x0,v0x0.raw);
104 deb_rdump("reg: %03x: %x\n",r0xc,v0xc.raw);
105 return 0;
106}
107EXPORT_SYMBOL(flexcop_dma_xfer_control);
108
109static int flexcop_dma_remap(struct flexcop_device *fc,
110 flexcop_dma_index_t dma_idx,
111 int onoff)
112{
113 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c;
114 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
115 deb_info("%s\n",__FUNCTION__);
116 v.dma_0xc.remap_enable = onoff;
117 fc->write_ibi_reg(fc,r,v);
118 return 0;
119}
54 120
55int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff) 121int flexcop_dma_control_size_irq(struct flexcop_device *fc,
122 flexcop_dma_index_t no,
123 int onoff)
56{ 124{
57 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208); 125 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
58 126
@@ -67,75 +135,64 @@ int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t
67} 135}
68EXPORT_SYMBOL(flexcop_dma_control_size_irq); 136EXPORT_SYMBOL(flexcop_dma_control_size_irq);
69 137
70int flexcop_dma_control_packet_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff) 138int flexcop_dma_control_timer_irq(struct flexcop_device *fc,
139 flexcop_dma_index_t no,
140 int onoff)
71{ 141{
72 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208); 142 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
73 143
74 if (no & FC_DMA_1) 144 if (no & FC_DMA_1)
75 v.ctrl_208.DMA1_Size_IRQ_Enable_sig = onoff; 145 v.ctrl_208.DMA1_Timer_Enable_sig = onoff;
76 146
77 if (no & FC_DMA_2) 147 if (no & FC_DMA_2)
78 v.ctrl_208.DMA2_Size_IRQ_Enable_sig = onoff; 148 v.ctrl_208.DMA2_Timer_Enable_sig = onoff;
79 149
80 fc->write_ibi_reg(fc,ctrl_208,v); 150 fc->write_ibi_reg(fc,ctrl_208,v);
81 return 0; 151 return 0;
82} 152}
83EXPORT_SYMBOL(flexcop_dma_control_packet_irq); 153EXPORT_SYMBOL(flexcop_dma_control_timer_irq);
84 154
85int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx,flexcop_dma_addr_index_t index) 155/* 1 cycles = 1.97 msec */
156int flexcop_dma_config_timer(struct flexcop_device *fc,
157 flexcop_dma_index_t dma_idx,
158 u8 cycles)
86{ 159{
160 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
161 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
87 162
88 flexcop_ibi_value v0x0,v0x4,v0xc; 163 flexcop_dma_remap(fc,dma_idx,0);
89 v0x0.raw = v0x4.raw = v0xc.raw = 0;
90
91 v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2;
92 v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2;
93 v0x4.dma_0x4_write.dma_addr_size = dma->size / 4;
94
95 if (index & FC_DMA_SUBADDR_0)
96 v0x0.dma_0x0.dma_0start = 1;
97
98 if (index & FC_DMA_SUBADDR_1)
99 v0xc.dma_0xc.dma_1start = 1;
100
101 if (dma_idx & FC_DMA_1) {
102 fc->write_ibi_reg(fc,dma1_000,v0x0);
103 fc->write_ibi_reg(fc,dma1_004,v0x4);
104 fc->write_ibi_reg(fc,dma1_00c,v0xc);
105 } else { /* (dma_idx & FC_DMA_2) */
106 fc->write_ibi_reg(fc,dma2_010,v0x0);
107 fc->write_ibi_reg(fc,dma2_014,v0x4);
108 fc->write_ibi_reg(fc,dma2_01c,v0xc);
109 }
110
111 return 0;
112}
113EXPORT_SYMBOL(flexcop_dma_config);
114 164
115static int flexcop_dma_remap(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, int onoff) 165 deb_info("%s\n",__FUNCTION__);
116{ 166 v.dma_0x4_write.dmatimer = cycles;
117 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c;
118 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
119 v.dma_0xc.remap_enable = onoff;
120 fc->write_ibi_reg(fc,r,v); 167 fc->write_ibi_reg(fc,r,v);
121 return 0; 168 return 0;
122} 169}
170EXPORT_SYMBOL(flexcop_dma_config_timer);
123 171
124/* 1 cycles = 1.97 msec */ 172/* packet IRQ does not exist in FCII or FCIIb - according to data book and tests */
125int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles) 173int flexcop_dma_control_packet_irq(struct flexcop_device *fc,
174 flexcop_dma_index_t no,
175 int onoff)
126{ 176{
127 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014; 177 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
128 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
129 178
130 flexcop_dma_remap(fc,dma_idx,0); 179 deb_rdump("reg: %03x: %x\n",ctrl_208,v.raw);
180 if (no & FC_DMA_1)
181 v.ctrl_208.DMA1_Size_IRQ_Enable_sig = onoff;
182
183 if (no & FC_DMA_2)
184 v.ctrl_208.DMA2_Size_IRQ_Enable_sig = onoff;
185
186 fc->write_ibi_reg(fc,ctrl_208,v);
187 deb_rdump("reg: %03x: %x\n",ctrl_208,v.raw);
131 188
132 v.dma_0x4_write.dmatimer = cycles >> 1;
133 fc->write_ibi_reg(fc,r,v);
134 return 0; 189 return 0;
135} 190}
136EXPORT_SYMBOL(flexcop_dma_config_timer); 191EXPORT_SYMBOL(flexcop_dma_control_packet_irq);
137 192
138int flexcop_dma_config_packet_count(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 packets) 193int flexcop_dma_config_packet_count(struct flexcop_device *fc,
194 flexcop_dma_index_t dma_idx,
195 u8 packets)
139{ 196{
140 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014; 197 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
141 flexcop_ibi_value v = fc->read_ibi_reg(fc,r); 198 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
diff --git a/drivers/media/dvb/b2c2/flexcop-hw-filter.c b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
index 2baf43d3ce8f..75cf237196eb 100644
--- a/drivers/media/dvb/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
@@ -10,6 +10,8 @@
10static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff) 10static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff)
11{ 11{
12 flexcop_set_ibi_value(ctrl_208,Rcv_Data_sig,onoff); 12 flexcop_set_ibi_value(ctrl_208,Rcv_Data_sig,onoff);
13
14 deb_ts("rcv_data is now: '%s'\n",onoff ? "on" : "off");
13} 15}
14 16
15void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff) 17void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
@@ -151,7 +153,7 @@ int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *d
151{ 153{
152 int max_pid_filter = 6 + fc->has_32_hw_pid_filter*32; 154 int max_pid_filter = 6 + fc->has_32_hw_pid_filter*32;
153 155
154 fc->feedcount += onoff ? 1 : -1; 156 fc->feedcount += onoff ? 1 : -1; /* the number of PIDs/Feed currently requested */
155 if (dvbdmxfeed->index >= max_pid_filter) 157 if (dvbdmxfeed->index >= max_pid_filter)
156 fc->extra_feedcount += onoff ? 1 : -1; 158 fc->extra_feedcount += onoff ? 1 : -1;
157 159
@@ -178,8 +180,14 @@ int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *d
178 /* if it was the first or last feed request change the stream-status */ 180 /* if it was the first or last feed request change the stream-status */
179 if (fc->feedcount == onoff) { 181 if (fc->feedcount == onoff) {
180 flexcop_rcv_data_ctrl(fc,onoff); 182 flexcop_rcv_data_ctrl(fc,onoff);
181 if (fc->stream_control) 183 if (fc->stream_control) /* device specific stream control */
182 fc->stream_control(fc,onoff); 184 fc->stream_control(fc,onoff);
185
186 /* feeding stopped -> reset the flexcop filter*/
187 if (onoff == 0) {
188 flexcop_reset_block_300(fc);
189 flexcop_hw_filter_init(fc);
190 }
183 } 191 }
184 192
185 return 0; 193 return 0;
diff --git a/drivers/media/dvb/b2c2/flexcop-misc.c b/drivers/media/dvb/b2c2/flexcop-misc.c
index 23082545651f..3a08d38b318a 100644
--- a/drivers/media/dvb/b2c2/flexcop-misc.c
+++ b/drivers/media/dvb/b2c2/flexcop-misc.c
@@ -65,3 +65,15 @@ void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const
65 flexcop_device_names[fc->dev_type],flexcop_bus_names[fc->bus_type], 65 flexcop_device_names[fc->dev_type],flexcop_bus_names[fc->bus_type],
66 flexcop_revision_names[fc->rev],suffix); 66 flexcop_revision_names[fc->rev],suffix);
67} 67}
68
69void flexcop_dump_reg(struct flexcop_device *fc, flexcop_ibi_register reg, int num)
70{
71 flexcop_ibi_value v;
72 int i;
73 for (i = 0; i < num; i++) {
74 v = fc->read_ibi_reg(fc,reg+4*i);
75 deb_rdump("0x%03x: %08x, ",reg+4*i, v.raw);
76 }
77 deb_rdump("\n");
78}
79EXPORT_SYMBOL(flexcop_dump_reg);
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
index ed717c0073d5..2f76eb3fea40 100644
--- a/drivers/media/dvb/b2c2/flexcop-pci.c
+++ b/drivers/media/dvb/b2c2/flexcop-pci.c
@@ -13,6 +13,10 @@ static int enable_pid_filtering = 1;
13module_param(enable_pid_filtering, int, 0444); 13module_param(enable_pid_filtering, int, 0444);
14MODULE_PARM_DESC(enable_pid_filtering, "enable hardware pid filtering: supported values: 0 (fullts), 1"); 14MODULE_PARM_DESC(enable_pid_filtering, "enable hardware pid filtering: supported values: 0 (fullts), 1");
15 15
16static int irq_chk_intv;
17module_param(irq_chk_intv, int, 0644);
18MODULE_PARM_DESC(irq_chk_intv, "set the interval for IRQ watchdog (currently just debugging).");
19
16#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG 20#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
17#define dprintk(level,args...) \ 21#define dprintk(level,args...) \
18 do { if ((debug & level)) printk(args); } while (0) 22 do { if ((debug & level)) printk(args); } while (0)
@@ -26,6 +30,7 @@ MODULE_PARM_DESC(enable_pid_filtering, "enable hardware pid filtering: supported
26#define deb_reg(args...) dprintk(0x02,args) 30#define deb_reg(args...) dprintk(0x02,args)
27#define deb_ts(args...) dprintk(0x04,args) 31#define deb_ts(args...) dprintk(0x04,args)
28#define deb_irq(args...) dprintk(0x08,args) 32#define deb_irq(args...) dprintk(0x08,args)
33#define deb_chk(args...) dprintk(0x10,args)
29 34
30static int debug = 0; 35static int debug = 0;
31module_param(debug, int, 0644); 36module_param(debug, int, 0644);
@@ -56,6 +61,10 @@ struct flexcop_pci {
56 61
57 spinlock_t irq_lock; 62 spinlock_t irq_lock;
58 63
64 unsigned long last_irq;
65
66 struct work_struct irq_check_work;
67
59 struct flexcop_device *fc_dev; 68 struct flexcop_device *fc_dev;
60}; 69};
61 70
@@ -88,18 +97,55 @@ static int flexcop_pci_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_regi
88 return 0; 97 return 0;
89} 98}
90 99
100static void flexcop_pci_irq_check_work(void *data)
101{
102 struct flexcop_pci *fc_pci = data;
103 struct flexcop_device *fc = fc_pci->fc_dev;
104
105 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714);
106
107 flexcop_dump_reg(fc_pci->fc_dev,dma1_000,4);
108
109 if (v.sram_dest_reg_714.net_ovflow_error)
110 deb_chk("sram net_ovflow_error\n");
111 if (v.sram_dest_reg_714.media_ovflow_error)
112 deb_chk("sram media_ovflow_error\n");
113 if (v.sram_dest_reg_714.cai_ovflow_error)
114 deb_chk("sram cai_ovflow_error\n");
115 if (v.sram_dest_reg_714.cai_ovflow_error)
116 deb_chk("sram cai_ovflow_error\n");
117
118 schedule_delayed_work(&fc_pci->irq_check_work,
119 msecs_to_jiffies(irq_chk_intv < 100 ? 100 : irq_chk_intv));
120}
121
91/* When PID filtering is turned on, we use the timer IRQ, because small amounts 122/* When PID filtering is turned on, we use the timer IRQ, because small amounts
92 * of data need to be passed to the user space instantly as well. When PID 123 * of data need to be passed to the user space instantly as well. When PID
93 * filtering is turned off, we use the page-change-IRQ */ 124 * filtering is turned off, we use the page-change-IRQ */
94static irqreturn_t flexcop_pci_irq(int irq, void *dev_id, struct pt_regs *regs) 125static irqreturn_t flexcop_pci_isr(int irq, void *dev_id, struct pt_regs *regs)
95{ 126{
96 struct flexcop_pci *fc_pci = dev_id; 127 struct flexcop_pci *fc_pci = dev_id;
97 struct flexcop_device *fc = fc_pci->fc_dev; 128 struct flexcop_device *fc = fc_pci->fc_dev;
98 flexcop_ibi_value v = fc->read_ibi_reg(fc,irq_20c); 129 flexcop_ibi_value v;
99 irqreturn_t ret = IRQ_HANDLED; 130 irqreturn_t ret = IRQ_HANDLED;
100 131
101 spin_lock_irq(&fc_pci->irq_lock); 132 spin_lock_irq(&fc_pci->irq_lock);
102 133
134 v = fc->read_ibi_reg(fc,irq_20c);
135
136 /* errors */
137 if (v.irq_20c.Data_receiver_error)
138 deb_chk("data receiver error\n");
139 if (v.irq_20c.Continuity_error_flag)
140 deb_chk("Contunuity error flag is set\n");
141 if (v.irq_20c.LLC_SNAP_FLAG_set)
142 deb_chk("LLC_SNAP_FLAG_set is set\n");
143 if (v.irq_20c.Transport_Error)
144 deb_chk("Transport error\n");
145
146 if ((fc_pci->count % 1000) == 0)
147 deb_chk("%d valid irq took place so far\n",fc_pci->count);
148
103 if (v.irq_20c.DMA1_IRQ_Status == 1) { 149 if (v.irq_20c.DMA1_IRQ_Status == 1) {
104 if (fc_pci->active_dma1_addr == 0) 150 if (fc_pci->active_dma1_addr == 0)
105 flexcop_pass_dmx_packets(fc_pci->fc_dev,fc_pci->dma[0].cpu_addr0,fc_pci->dma[0].size / 188); 151 flexcop_pass_dmx_packets(fc_pci->fc_dev,fc_pci->dma[0].cpu_addr0,fc_pci->dma[0].size / 188);
@@ -115,8 +161,9 @@ static irqreturn_t flexcop_pci_irq(int irq, void *dev_id, struct pt_regs *regs)
115 fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2; 161 fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2;
116 u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0; 162 u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0;
117 163
118 deb_irq("irq: %08x cur_addr: %08x: cur_pos: %08x, last_cur_pos: %08x ", 164 deb_irq("%u irq: %08x cur_addr: %08x: cur_pos: %08x, last_cur_pos: %08x ",
119 v.raw,cur_addr,cur_pos,fc_pci->last_dma1_cur_pos); 165 jiffies_to_usecs(jiffies - fc_pci->last_irq),v.raw,cur_addr,cur_pos,fc_pci->last_dma1_cur_pos);
166 fc_pci->last_irq = jiffies;
120 167
121 /* buffer end was reached, restarted from the beginning 168 /* buffer end was reached, restarted from the beginning
122 * pass the data from last_cur_pos to the buffer end to the demux 169 * pass the data from last_cur_pos to the buffer end to the demux
@@ -127,7 +174,6 @@ static irqreturn_t flexcop_pci_irq(int irq, void *dev_id, struct pt_regs *regs)
127 fc_pci->dma[0].cpu_addr0 + fc_pci->last_dma1_cur_pos, 174 fc_pci->dma[0].cpu_addr0 + fc_pci->last_dma1_cur_pos,
128 (fc_pci->dma[0].size*2) - fc_pci->last_dma1_cur_pos); 175 (fc_pci->dma[0].size*2) - fc_pci->last_dma1_cur_pos);
129 fc_pci->last_dma1_cur_pos = 0; 176 fc_pci->last_dma1_cur_pos = 0;
130 fc_pci->count = 0;
131 } 177 }
132 178
133 if (cur_pos > fc_pci->last_dma1_cur_pos) { 179 if (cur_pos > fc_pci->last_dma1_cur_pos) {
@@ -139,16 +185,14 @@ static irqreturn_t flexcop_pci_irq(int irq, void *dev_id, struct pt_regs *regs)
139 deb_irq("\n"); 185 deb_irq("\n");
140 186
141 fc_pci->last_dma1_cur_pos = cur_pos; 187 fc_pci->last_dma1_cur_pos = cur_pos;
142 } else 188 fc_pci->count++;
189 } else {
190 deb_irq("isr for flexcop called, apparently without reason (%08x)\n",v.raw);
143 ret = IRQ_NONE; 191 ret = IRQ_NONE;
192 }
144 193
145 spin_unlock_irq(&fc_pci->irq_lock); 194 spin_unlock_irq(&fc_pci->irq_lock);
146 195
147/* packet count would be ideal for hw filtering, but it isn't working. Either
148 * the data book is wrong, or I'm unable to read it correctly */
149
150/* if (v.irq_20c.DMA1_Size_IRQ_Status == 1) { packet counter */
151
152 return ret; 196 return ret;
153} 197}
154 198
@@ -156,30 +200,35 @@ static int flexcop_pci_stream_control(struct flexcop_device *fc, int onoff)
156{ 200{
157 struct flexcop_pci *fc_pci = fc->bus_specific; 201 struct flexcop_pci *fc_pci = fc->bus_specific;
158 if (onoff) { 202 if (onoff) {
159 flexcop_dma_config(fc,&fc_pci->dma[0],FC_DMA_1,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1); 203 flexcop_dma_config(fc,&fc_pci->dma[0],FC_DMA_1);
160 flexcop_dma_config(fc,&fc_pci->dma[1],FC_DMA_2,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1); 204 flexcop_dma_config(fc,&fc_pci->dma[1],FC_DMA_2);
161 flexcop_dma_config_timer(fc,FC_DMA_1,1);
162 205
163 if (fc_pci->fc_dev->pid_filtering) { 206 flexcop_dma_config_timer(fc,FC_DMA_1,0);
164 fc_pci->last_dma1_cur_pos = 0;
165 flexcop_dma_control_timer_irq(fc,FC_DMA_1,1);
166 } else {
167 fc_pci->active_dma1_addr = 0;
168 flexcop_dma_control_size_irq(fc,FC_DMA_1,1);
169 }
170 207
171/* flexcop_dma_config_packet_count(fc,FC_DMA_1,0xc0); 208 flexcop_dma_xfer_control(fc,FC_DMA_1,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1,1);
172 flexcop_dma_control_packet_irq(fc,FC_DMA_1,1); */ 209 deb_irq("DMA xfer enabled\n");
173 210
174 deb_irq("irqs enabled\n"); 211 fc_pci->last_dma1_cur_pos = 0;
212 flexcop_dma_control_timer_irq(fc,FC_DMA_1,1);
213 deb_irq("IRQ enabled\n");
214
215// fc_pci->active_dma1_addr = 0;
216// flexcop_dma_control_size_irq(fc,FC_DMA_1,1);
217
218 if (irq_chk_intv > 0)
219 schedule_delayed_work(&fc_pci->irq_check_work,
220 msecs_to_jiffies(irq_chk_intv < 100 ? 100 : irq_chk_intv));
175 } else { 221 } else {
176 if (fc_pci->fc_dev->pid_filtering) 222 if (irq_chk_intv > 0)
177 flexcop_dma_control_timer_irq(fc,FC_DMA_1,0); 223 cancel_delayed_work(&fc_pci->irq_check_work);
178 else 224
179 flexcop_dma_control_size_irq(fc,FC_DMA_1,0); 225 flexcop_dma_control_timer_irq(fc,FC_DMA_1,0);
226 deb_irq("IRQ disabled\n");
180 227
181// flexcop_dma_control_packet_irq(fc,FC_DMA_1,0); 228// flexcop_dma_control_size_irq(fc,FC_DMA_1,0);
182 deb_irq("irqs disabled\n"); 229
230 flexcop_dma_xfer_control(fc,FC_DMA_1,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1,0);
231 deb_irq("DMA xfer disabled\n");
183 } 232 }
184 233
185 return 0; 234 return 0;
@@ -198,6 +247,7 @@ static int flexcop_pci_dma_init(struct flexcop_pci *fc_pci)
198 flexcop_sram_set_dest(fc_pci->fc_dev,FC_SRAM_DEST_CAO | FC_SRAM_DEST_CAI, FC_SRAM_DEST_TARGET_DMA2); 247 flexcop_sram_set_dest(fc_pci->fc_dev,FC_SRAM_DEST_CAO | FC_SRAM_DEST_CAI, FC_SRAM_DEST_TARGET_DMA2);
199 248
200 fc_pci->init_state |= FC_PCI_DMA_INIT; 249 fc_pci->init_state |= FC_PCI_DMA_INIT;
250
201 goto success; 251 goto success;
202dma1_free: 252dma1_free:
203 flexcop_dma_free(&fc_pci->dma[0]); 253 flexcop_dma_free(&fc_pci->dma[0]);
@@ -244,7 +294,7 @@ static int flexcop_pci_init(struct flexcop_pci *fc_pci)
244 294
245 pci_set_drvdata(fc_pci->pdev, fc_pci); 295 pci_set_drvdata(fc_pci->pdev, fc_pci);
246 296
247 if ((ret = request_irq(fc_pci->pdev->irq, flexcop_pci_irq, 297 if ((ret = request_irq(fc_pci->pdev->irq, flexcop_pci_isr,
248 SA_SHIRQ, DRIVER_NAME, fc_pci)) != 0) 298 SA_SHIRQ, DRIVER_NAME, fc_pci)) != 0)
249 goto err_pci_iounmap; 299 goto err_pci_iounmap;
250 300
@@ -324,6 +374,8 @@ static int flexcop_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
324 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0) 374 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0)
325 goto err_fc_exit; 375 goto err_fc_exit;
326 376
377 INIT_WORK(&fc_pci->irq_check_work, flexcop_pci_irq_check_work, fc_pci);
378
327 goto success; 379 goto success;
328err_fc_exit: 380err_fc_exit:
329 flexcop_device_exit(fc); 381 flexcop_device_exit(fc);
@@ -350,17 +402,17 @@ static void flexcop_pci_remove(struct pci_dev *pdev)
350 402
351static struct pci_device_id flexcop_pci_tbl[] = { 403static struct pci_device_id flexcop_pci_tbl[] = {
352 { PCI_DEVICE(0x13d0, 0x2103) }, 404 { PCI_DEVICE(0x13d0, 0x2103) },
353/* { PCI_DEVICE(0x13d0, 0x2200) }, PCI FlexCopIII ? */ 405/* { PCI_DEVICE(0x13d0, 0x2200) }, ? */
354 { }, 406 { },
355}; 407};
356 408
357MODULE_DEVICE_TABLE(pci, flexcop_pci_tbl); 409MODULE_DEVICE_TABLE(pci, flexcop_pci_tbl);
358 410
359static struct pci_driver flexcop_pci_driver = { 411static struct pci_driver flexcop_pci_driver = {
360 .name = "Technisat/B2C2 FlexCop II/IIb/III PCI", 412 .name = "b2c2_flexcop_pci",
361 .id_table = flexcop_pci_tbl, 413 .id_table = flexcop_pci_tbl,
362 .probe = flexcop_pci_probe, 414 .probe = flexcop_pci_probe,
363 .remove = flexcop_pci_remove, 415 .remove = flexcop_pci_remove,
364}; 416};
365 417
366static int __init flexcop_pci_module_init(void) 418static int __init flexcop_pci_module_init(void)
diff --git a/drivers/media/dvb/b2c2/flexcop-reg.h b/drivers/media/dvb/b2c2/flexcop-reg.h
index 75b50f21afe6..4ae1eb5bfe98 100644
--- a/drivers/media/dvb/b2c2/flexcop-reg.h
+++ b/drivers/media/dvb/b2c2/flexcop-reg.h
@@ -36,555 +36,21 @@ typedef enum {
36extern const char *flexcop_device_names[]; 36extern const char *flexcop_device_names[];
37 37
38/* FlexCop IBI Registers */ 38/* FlexCop IBI Registers */
39#if defined(__LITTLE_ENDIAN)
40 #include "flexcop_ibi_value_le.h"
41#elif defined(__BIG_ENDIAN)
42 #include "flexcop_ibi_value_be.h"
43#else
44 #error no endian defined
45#endif
39 46
40/* flexcop_ibi_reg - a huge union representing the register structure */
41typedef union {
42 u32 raw;
43
44/* DMA 0x000 to 0x01c
45 * DMA1 0x000 to 0x00c
46 * DMA2 0x010 to 0x01c
47 */
48 struct {
49 u32 dma_0start : 1; /* set: data will be delivered to dma1_address0 */
50 u32 dma_0No_update : 1; /* set: dma1_cur_address will be updated, unset: no update */
51 u32 dma_address0 :30; /* physical/virtual host memory address0 DMA */
52 } dma_0x0;
53
54 struct {
55 u32 DMA_maxpackets : 8; /* (remapped) PCI DMA1 Packet Count Interrupt. This variable
56 is able to be read and written while bit(1) of register
57 0x00c (remap_enable) is set. This variable represents
58 the number of packets that will be transmitted to the PCI
59 host using PCI DMA1 before an interrupt to the PCI is
60 asserted. This functionality may be enabled using bit(20)
61 of register 0x208. N=0 disables the IRQ. */
62 u32 dma_addr_size :24; /* size of memory buffer in DWORDs (bytesize / 4) for DMA */
63 } dma_0x4_remap;
64
65 struct {
66 u32 dma1timer : 7; /* reading PCI DMA1 timer ... when remap_enable is 0 */
67 u32 unused : 1;
68 u32 dma_addr_size :24;
69 } dma_0x4_read;
70
71 struct {
72 u32 unused : 1;
73 u32 dmatimer : 7; /* writing PCI DMA1 timer ... when remap_enable is 0 */
74 u32 dma_addr_size :24;
75 } dma_0x4_write;
76
77 struct {
78 u32 unused : 2;
79 u32 dma_cur_addr :30; /* current physical host memory address pointer for DMA */
80 } dma_0x8;
81
82 struct {
83 u32 dma_1start : 1; /* set: data will be delivered to dma_address1, when dma_address0 is full */
84 u32 remap_enable : 1; /* remap enable for 0x0x4(7:0) */
85 u32 dma_address1 :30; /* Physical/virtual address 1 on DMA */
86 } dma_0xc;
87
88/* Two-wire Serial Master and Clock 0x100-0x110 */
89 struct {
90// u32 slave_transmitter : 1; /* ???*/
91 u32 chipaddr : 7; /* two-line serial address of the target slave */
92 u32 reserved1 : 1;
93 u32 baseaddr : 8; /* address of the location of the read/write operation */
94 u32 data1_reg : 8; /* first byte in two-line serial read/write operation */
95 u32 working_start : 1; /* when doing a write operation this indicator is 0 when ready
96 * set to 1 when doing a write operation */
97 u32 twoWS_rw : 1; /* read/write indicator (1 = read, 0 write) */
98 u32 total_bytes : 2; /* number of data bytes in each two-line serial transaction (0 = 1 byte, 11 = 4byte)*/
99 u32 twoWS_port_reg : 2; /* port selection: 01 - Front End/Demod, 10 - EEPROM, 11 - Tuner */
100 u32 no_base_addr_ack_error : 1; /* writing: write-req: frame is produced w/o baseaddr, read-req: read-cycles w/o
101 * preceding address assignment write frame
102 * ACK_ERROR = 1 when no ACK from slave in the last transaction */
103 u32 st_done : 1; /* indicator for transaction is done */
104 } tw_sm_c_100;
105
106 struct {
107 u32 data2_reg : 8; /* 2nd data byte */
108 u32 data3_reg : 8; /* 3rd data byte */
109 u32 data4_reg : 8; /* 4th data byte */
110 u32 exlicit_stops : 1; /* when set, transactions are produced w/o trailing STOP flag, then send isolated STOP flags */
111 u32 force_stop : 1; /* isolated stop flag */
112 u32 unused : 6;
113 } tw_sm_c_104;
114
115/* Clock. The register allows the FCIII to convert an incoming Master clock
116 * (MCLK) signal into a lower frequency clock through the use of a LowCounter
117 * (TLO) and a High- Counter (THI). The time counts for THI and TLO are
118 * measured in MCLK; each count represents 4 MCLK input clock cycles.
119 *
120 * The default output for port #1 is set for Front End Demod communication. (0x108)
121 * The default output for port #2 is set for EEPROM communication. (0x10c)
122 * The default output for port #3 is set for Tuner communication. (0x110)
123 */
124 struct {
125 u32 thi1 : 6; /* Thi for port #1 (def: 100110b; 38) */
126 u32 reserved1 : 2;
127 u32 tlo1 : 5; /* Tlo for port #1 (def: 11100b; 28) */
128 u32 reserved2 :19;
129 } tw_sm_c_108;
130
131 struct {
132 u32 thi1 : 6; /* Thi for port #2 (def: 111001b; 57) */
133 u32 reserved1 : 2;
134 u32 tlo1 : 5; /* Tlo for port #2 (def: 11100b; 28) */
135 u32 reserved2 :19;
136 } tw_sm_c_10c;
137
138 struct {
139 u32 thi1 : 6; /* Thi for port #3 (def: 111001b; 57) */
140 u32 reserved1 : 2;
141 u32 tlo1 : 5; /* Tlo for port #3 (def: 11100b; 28) */
142 u32 reserved2 :19;
143 } tw_sm_c_110;
144
145/* LNB Switch Frequency 0x200
146 * Clock that creates the LNB switch tone. The default is set to have a fixed
147 * low output (not oscillating) to the LNB_CTL line.
148 */
149 struct {
150 u32 LNB_CTLHighCount_sig :15; /* It is the number of pre-scaled clock cycles that will be low. */
151 u32 LNB_CTLLowCount_sig :15; /* For example, to obtain a 22KHz output given a 45 Mhz Master
152 Clock signal (MCLK), set PreScalar=01 and LowCounter value to 0x1ff. */
153 u32 LNB_CTLPrescaler_sig : 2; /* pre-scaler divides MCLK: 00 (no division), 01 by 2, 10 by 4, 11 by 12 */
154 } lnb_switch_freq_200;
155
156/* ACPI, Peripheral Reset, LNB Polarity
157 * ACPI power conservation mode, LNB polarity selection (low or high voltage),
158 * and peripheral reset.
159 */
160 struct {
161 u32 ACPI1_sig : 1; /* turn of the power of tuner and LNB, not implemented in FCIII */
162 u32 ACPI3_sig : 1; /* turn of power of the complete satelite receiver board (except FCIII) */
163 u32 LNB_L_H_sig : 1; /* low or high voltage for LNB. (0 = low, 1 = high) */
164 u32 Per_reset_sig : 1; /* misc. init reset (default: 1), to reset set to low and back to high */
165 u32 reserved :20;
166 u32 Rev_N_sig_revision_hi : 4;/* 0xc in case of FCIII */
167 u32 Rev_N_sig_reserved1 : 2;
168 u32 Rev_N_sig_caps : 1; /* if 1, FCIII has 32 PID- and MAC-filters and is capable of IP multicast */
169 u32 Rev_N_sig_reserved2 : 1;
170 } misc_204;
171
172/* Control and Status 0x208 to 0x21c */
173/* Gross enable and disable control */
174 struct {
175 u32 Stream1_filter_sig : 1; /* Stream1 PID filtering */
176 u32 Stream2_filter_sig : 1; /* Stream2 PID filtering */
177 u32 PCR_filter_sig : 1; /* PCR PID filter */
178 u32 PMT_filter_sig : 1; /* PMT PID filter */
179
180 u32 EMM_filter_sig : 1; /* EMM PID filter */
181 u32 ECM_filter_sig : 1; /* ECM PID filter */
182 u32 Null_filter_sig : 1; /* Filters null packets, PID=0x1fff. */
183 u32 Mask_filter_sig : 1; /* mask PID filter */
184
185 u32 WAN_Enable_sig : 1; /* WAN output line through V8 memory space is activated. */
186 u32 WAN_CA_Enable_sig : 1; /* not in FCIII */
187 u32 CA_Enable_sig : 1; /* not in FCIII */
188 u32 SMC_Enable_sig : 1; /* CI stream data (CAI) goes directly to the smart card intf (opposed IBI 0x600 or SC-cmd buf). */
189
190 u32 Per_CA_Enable_sig : 1; /* not in FCIII */
191 u32 Multi2_Enable_sig : 1; /* ? */
192 u32 MAC_filter_Mode_sig : 1; /* (MAC_filter_enable) Globally enables MAC filters for Net PID filteres. */
193 u32 Rcv_Data_sig : 1; /* PID filtering module enable. When this bit is a one, the PID filter will
194 examine and process packets according to all other (individual) PID
195 filtering controls. If it a zero, no packet processing of any kind will
196 take place. All data from the tuner will be thrown away. */
197
198 u32 DMA1_IRQ_Enable_sig : 1; /* When set, a DWORD counter is enabled on PCI DMA1 that asserts the PCI
199 * interrupt after the specified count for filling the buffer. */
200 u32 DMA1_Timer_Enable_sig : 1; /* When set, a timer is enabled on PCI DMA1 that asserts the PCI interrupt
201 after a specified amount of time. */
202 u32 DMA2_IRQ_Enable_sig : 1; /* same as DMA1_IRQ_Enable_sig but for DMA2 */
203 u32 DMA2_Timer_Enable_sig : 1; /* same as DMA1_Timer_Enable_sig but for DMA2 */
204
205 u32 DMA1_Size_IRQ_Enable_sig : 1; /* When set, a packet count detector is enabled on PCI DMA1 that asserts the PCI interrupt. */
206 u32 DMA2_Size_IRQ_Enable_sig : 1; /* When set, a packet count detector is enabled on PCI DMA2 that asserts the PCI interrupt. */
207 u32 Mailbox_from_V8_Enable_sig: 1; /* When set, writes to the mailbox register produce an interrupt to the
208 PCI host to indicate that mailbox data is available. */
209
210 u32 unused : 9;
211 } ctrl_208;
212
213/* General status. When a PCI interrupt occurs, this register is read to
214 * discover the reason for the interrupt.
215 */
216 struct {
217 u32 DMA1_IRQ_Status : 1; /* When set(1) the DMA1 counter had generated an IRQ. Read Only. */
218 u32 DMA1_Timer_Status : 1; /* When set(1) the DMA1 timer had generated an IRQ. Read Only. */
219 u32 DMA2_IRQ_Status : 1; /* When set(1) the DMA2 counter had generated an IRQ. Read Only. */
220 u32 DMA2_Timer_Status : 1; /* When set(1) the DMA2 timer had generated an IRQ. Read Only. */
221 u32 DMA1_Size_IRQ_Status : 1; /* (Read only). This register is read after an interrupt to */
222 u32 DMA2_Size_IRQ_Status : 1; /* find out why we had an IRQ. Reading this register will clear this bit. Packet count*/
223 u32 Mailbox_from_V8_Status_sig: 1; /* Same as above. Reading this register will clear this bit. */
224 u32 Data_receiver_error : 1; /* 1 indicate an error in the receiver Front End (Tuner module) */
225 u32 Continuity_error_flag : 1; /* 1 indicates a continuity error in the TS stream. */
226 u32 LLC_SNAP_FLAG_set : 1; /* 1 indicates that the LCC_SNAP_FLAG was set. */
227 u32 Transport_Error : 1; /* When set indicates that an unexpected packet was received. */
228 u32 reserved :21;
229 } irq_20c;
230
231
232/* Software reset register */
233 struct {
234 u32 reset_blocks : 8; /* Enabled when Block_reset_enable = 0xB2 and 0x208 bits 15:8 = 0x00.
235 Each bit location represents a 0x100 block of registers. Writing
236 a one in a bit location resets that block of registers and the logic
237 that it controls. */
238 u32 Block_reset_enable : 8; /* This variable is set to 0xB2 when the register is written. */
239 u32 Special_controls :16; /* Asserts Reset_V8 => 0xC258; Turns on pci encryption => 0xC25A;
240 Turns off pci encryption => 0xC259 Note: pci_encryption default
241 at power-up is ON. */
242 } sw_reset_210;
243
244 struct {
245 u32 vuart_oe_sig : 1; /* When clear, the V8 processor has sole control of the serial UART
246 (RS-232 Smart Card interface). When set, the IBI interface
247 defined by register 0x600 controls the serial UART. */
248 u32 v2WS_oe_sig : 1; /* When clear, the V8 processor has direct control of the Two-line
249 Serial Master EEPROM target. When set, the Two-line Serial Master
250 EEPROM target interface is controlled by IBI register 0x100. */
251 u32 halt_V8_sig : 1; /* When set, contiguous wait states are applied to the V8-space
252 bus masters. Once this signal is cleared, normal V8-space
253 operations resume. */
254 u32 section_pkg_enable_sig: 1; /* When set, this signal enables the front end translation circuitry
255 to process section packed transport streams. */
256 u32 s2p_sel_sig : 1; /* Serial to parallel conversion. When set, polarized transport data
257 within the FlexCop3 front end circuitry is converted from a serial
258 stream into parallel data before downstream processing otherwise
259 interprets the data. */
260 u32 unused1 : 3;
261 u32 polarity_PS_CLK_sig: 1; /* This signal is used to invert the input polarity of the tranport
262 stream CLOCK signal before any processing occurs on the transport
263 stream within FlexCop3. */
264 u32 polarity_PS_VALID_sig: 1; /* This signal is used to invert the input polarity of the tranport
265 stream VALID signal before any processing occurs on the transport
266 stream within FlexCop3. */
267 u32 polarity_PS_SYNC_sig: 1; /* This signal is used to invert the input polarity of the tranport
268 stream SYNC signal before any processing occurs on the transport
269 stream within FlexCop3. */
270 u32 polarity_PS_ERR_sig: 1; /* This signal is used to invert the input polarity of the tranport
271 stream ERROR signal before any processing occurs on the transport
272 stream within FlexCop3. */
273 u32 unused2 :20;
274 } misc_214;
275
276/* Mailbox from V8 to host */
277 struct {
278 u32 Mailbox_from_V8 :32; /* When this register is written by either the V8 processor or by an
279 end host, an interrupt is generated to the PCI host to indicate
280 that mailbox data is available. Reading register 20c will clear
281 the IRQ. */
282 } mbox_v8_to_host_218;
283
284/* Mailbox from host to v8 Mailbox_to_V8
285 * Mailbox_to_V8 mailbox storage register
286 * used to send messages from PCI to V8. Writing to this register will send an
287 * IRQ to the V8. Then it can read the data from here. Reading this register
288 * will clear the IRQ. If the V8 is halted and bit 31 of this register is set,
289 * then this register is used instead as a direct interface to access the
290 * V8space memory.
291 */
292 struct {
293 u32 sysramaccess_data : 8; /* Data byte written or read from the specified address in V8 SysRAM. */
294 u32 sysramaccess_addr :15; /* 15 bit address used to access V8 Sys-RAM. */
295 u32 unused : 7;
296 u32 sysramaccess_write: 1; /* Write flag used to latch data into the V8 SysRAM. */
297 u32 sysramaccess_busmuster: 1; /* Setting this bit when the V8 is halted at 0x214 Bit(2) allows
298 this IBI register interface to directly drive the V8-space memory. */
299 } mbox_host_to_v8_21c;
300
301
302/* PIDs, Translation Bit, SMC Filter Select 0x300 to 0x31c */
303 struct {
304 u32 Stream1_PID :13; /* Primary use is receiving Net data, so these 13 bits normally
305 hold the PID value for the desired network stream. */
306 u32 Stream1_trans : 1; /* When set, Net translation will take place for Net data ferried in TS packets. */
307 u32 MAC_Multicast_filter : 1; /* When clear, multicast MAC filtering is not allowed for Stream1 and PID_n filters. */
308 u32 debug_flag_pid_saved : 1;
309 u32 Stream2_PID :13; /* 13 bits for Stream 2 PID filter value. General use. */
310 u32 Stream2_trans : 1; /* When set Tables/CAI translation will take place for the data ferried in
311 Stream2_PID TS packets. */
312 u32 debug_flag_write_status00 : 1;
313 u32 debug_fifo_problem : 1;
314 } pid_filter_300;
315
316 struct {
317 u32 PCR_PID :13; /* PCR stream PID filter value. Primary use is Program Clock Reference stream filtering. */
318 u32 PCR_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
319 u32 debug_overrun3 : 1;
320 u32 debug_overrun2 : 1;
321 u32 PMT_PID :13; /* stream PID filter value. Primary use is Program Management Table segment filtering. */
322 u32 PMT_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
323 u32 reserved : 2;
324 } pid_filter_304;
325
326 struct {
327 u32 EMM_PID :13; /* EMM PID filter value. Primary use is Entitlement Management Messaging for
328 conditional access-related data. */
329 u32 EMM_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
330 u32 EMM_filter_4 : 1; /* When set will pass only EMM data possessing the same ID code as the
331 first four bytes (32 bits) of the end-user s 6-byte Smart Card ID number Select */
332 u32 EMM_filter_6 : 1; /* When set will pass only EMM data possessing the same 6-byte code as the end-users
333 complete 6-byte Smart Card ID number. */
334 u32 ECM_PID :13; /* ECM PID filter value. Primary use is Entitlement Control Messaging for conditional
335 access-related data. */
336 u32 ECM_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
337 u32 reserved : 2;
338 } pid_filter_308;
339
340 struct {
341 u32 Group_PID :13; /* PID value for group filtering. */
342 u32 Group_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
343 u32 unused1 : 2;
344 u32 Group_mask :13; /* Mask value used in logical "and" equation that defines group filtering */
345 u32 unused2 : 3;
346 } pid_filter_30c_ext_ind_0_7;
347
348 struct {
349 u32 net_master_read :17;
350 u32 unused :15;
351 } pid_filter_30c_ext_ind_1;
352
353 struct {
354 u32 net_master_write :17;
355 u32 unused :15;
356 } pid_filter_30c_ext_ind_2;
357
358 struct {
359 u32 next_net_master_write :17;
360 u32 unused :15;
361 } pid_filter_30c_ext_ind_3;
362
363 struct {
364 u32 unused1 : 1;
365 u32 state_write :10;
366 u32 reserved1 : 6; /* default: 000100 */
367 u32 stack_read :10;
368 u32 reserved2 : 5; /* default: 00100 */
369 } pid_filter_30c_ext_ind_4;
370
371 struct {
372 u32 stack_cnt :10;
373 u32 unused :22;
374 } pid_filter_30c_ext_ind_5;
375
376 struct {
377 u32 pid_fsm_save_reg0 : 2;
378 u32 pid_fsm_save_reg1 : 2;
379 u32 pid_fsm_save_reg2 : 2;
380 u32 pid_fsm_save_reg3 : 2;
381 u32 pid_fsm_save_reg4 : 2;
382 u32 pid_fsm_save_reg300 : 2;
383 u32 write_status1 : 2;
384 u32 write_status4 : 2;
385 u32 data_size_reg :12;
386 u32 unused : 4;
387 } pid_filter_30c_ext_ind_6;
388
389 struct {
390 u32 index_reg : 5; /* (Index pointer) Points at an internal PIDn register. A binary code
391 representing one of 32 internal PIDn registers as well as its
392 corresponding internal MAC_lown register. */
393 u32 extra_index_reg : 3; /* This vector is used to select between sets of debug signals routed to register 0x30c. */
394 u32 AB_select : 1; /* Used in conjunction with 0x31c. read/write to the MAC_highA or MAC_highB register
395 0=MAC_highB register, 1=MAC_highA */
396 u32 pass_alltables : 1; /* 1=Net packets are not filtered against the Network Table ID found in register 0x400.
397 All types of networks (DVB, ATSC, ISDB) are passed. */
398 u32 unused :22;
399 } index_reg_310;
400
401 struct {
402 u32 PID :13; /* PID value */
403 u32 PID_trans : 1; /* translation will take place for packets filtered */
404 u32 PID_enable_bit : 1; /* When set this PID filter is enabled */
405 u32 reserved :17;
406 } pid_n_reg_314;
407
408 struct {
409 u32 A4_byte : 8;
410 u32 A5_byte : 8;
411 u32 A6_byte : 8;
412 u32 Enable_bit : 1; /* enabled (1) or disabled (1) */
413 u32 HighAB_bit : 1; /* use MAC_highA (1) or MAC_highB (0) as MSB */
414 u32 reserved : 6;
415 } mac_low_reg_318;
416
417 struct {
418 u32 A1_byte : 8;
419 u32 A2_byte : 8;
420 u32 A3_byte : 8;
421 u32 reserved : 8;
422 } mac_high_reg_31c;
423
424/* Table, SMCID,MACDestination Filters 0x400 to 0x41c */
425 struct {
426 u32 reserved :16;
427#define fc_data_Tag_ID_DVB 0x3e 47#define fc_data_Tag_ID_DVB 0x3e
428#define fc_data_Tag_ID_ATSC 0x3f 48#define fc_data_Tag_ID_ATSC 0x3f
429#define fc_data_Tag_ID_IDSB 0x8b 49#define fc_data_Tag_ID_IDSB 0x8b
430 u32 data_Tag_ID :16;
431 } data_tag_400;
432
433 struct {
434 u32 Card_IDbyte6 : 8;
435 u32 Card_IDbyte5 : 8;
436 u32 Card_IDbyte4 : 8;
437 u32 Card_IDbyte3 : 8;
438 } card_id_408;
439
440 struct {
441 u32 Card_IDbyte2 : 8;
442 u32 Card_IDbyte1 : 8;
443 } card_id_40c;
444
445 /* holding the unique mac address of the receiver which houses the FlexCopIII */
446 struct {
447 u32 MAC1 : 8;
448 u32 MAC2 : 8;
449 u32 MAC3 : 8;
450 u32 MAC6 : 8;
451 } mac_address_418;
452
453 struct {
454 u32 MAC7 : 8;
455 u32 MAC8 : 8;
456 u32 reserved : 16;
457 } mac_address_41c;
458
459 struct {
460 u32 transmitter_data_byte : 8;
461 u32 ReceiveDataReady : 1;
462 u32 ReceiveByteFrameError: 1;
463 u32 txbuffempty : 1;
464 u32 reserved :21;
465 } ci_600;
466
467 struct {
468 u32 pi_d : 8;
469 u32 pi_ha :20;
470 u32 pi_rw : 1;
471 u32 pi_component_reg : 3;
472 } pi_604;
473
474 struct {
475 u32 serialReset : 1;
476 u32 oncecycle_read : 1;
477 u32 Timer_Read_req : 1;
478 u32 Timer_Load_req : 1;
479 u32 timer_data : 7;
480 u32 unused : 1; /* ??? not mentioned in data book */
481 u32 Timer_addr : 5;
482 u32 reserved : 3;
483 u32 pcmcia_a_mod_pwr_n : 1;
484 u32 pcmcia_b_mod_pwr_n : 1;
485 u32 config_Done_stat : 1;
486 u32 config_Init_stat : 1;
487 u32 config_Prog_n : 1;
488 u32 config_wr_n : 1;
489 u32 config_cs_n : 1;
490 u32 config_cclk : 1;
491 u32 pi_CiMax_IRQ_n : 1;
492 u32 pi_timeout_status : 1;
493 u32 pi_wait_n : 1;
494 u32 pi_busy_n : 1;
495 } pi_608;
496 50
497 struct {
498 u32 PID :13;
499 u32 key_enable : 1;
500#define fc_key_code_default 0x1 51#define fc_key_code_default 0x1
501#define fc_key_code_even 0x2 52#define fc_key_code_even 0x2
502#define fc_key_code_odd 0x3 53#define fc_key_code_odd 0x3
503 u32 key_code : 2;
504 u32 key_array_col : 3;
505 u32 key_array_row : 5;
506 u32 dvb_en : 1; /* 0=TS bypasses the Descrambler */
507 u32 rw_flag : 1;
508 u32 reserved : 6;
509 } dvb_reg_60c;
510
511/* SRAM and Output Destination 0x700 to 0x714 */
512 struct {
513 u32 sram_addr :15;
514 u32 sram_rw : 1; /* 0=write, 1=read */
515 u32 sram_data : 8;
516 u32 sc_xfer_bit : 1;
517 u32 reserved1 : 3;
518 u32 oe_pin_reg : 1;
519 u32 ce_pin_reg : 1;
520 u32 reserved2 : 1;
521 u32 start_sram_ibi : 1;
522 } sram_ctrl_reg_700;
523
524 struct {
525 u32 net_addr_read :16;
526 u32 net_addr_write :16;
527 } net_buf_reg_704;
528
529 struct {
530 u32 cai_read :11;
531 u32 reserved1 : 5;
532 u32 cai_write :11;
533 u32 reserved2 : 6;
534 u32 cai_cnt : 4;
535 } cai_buf_reg_708;
536
537 struct {
538 u32 cao_read :11;
539 u32 reserved1 : 5;
540 u32 cap_write :11;
541 u32 reserved2 : 6;
542 u32 cao_cnt : 4;
543 } cao_buf_reg_70c;
544
545 struct {
546 u32 media_read :11;
547 u32 reserved1 : 5;
548 u32 media_write :11;
549 u32 reserved2 : 6;
550 u32 media_cnt : 4;
551 } media_buf_reg_710;
552
553 struct {
554 u32 NET_Dest : 2;
555 u32 CAI_Dest : 2;
556 u32 CAO_Dest : 2;
557 u32 MEDIA_Dest : 2;
558 u32 net_ovflow_error : 1;
559 u32 media_ovflow_error : 1;
560 u32 cai_ovflow_error : 1;
561 u32 cao_ovflow_error : 1;
562 u32 ctrl_usb_wan : 1;
563 u32 ctrl_sramdma : 1;
564 u32 ctrl_maximumfill : 1;
565 u32 reserved :17;
566 } sram_dest_reg_714;
567
568 struct {
569 u32 net_cnt :12;
570 u32 reserved1 : 4;
571 u32 net_addr_read : 1;
572 u32 reserved2 : 3;
573 u32 net_addr_write : 1;
574 u32 reserved3 :11;
575 } net_buf_reg_718;
576
577 struct {
578 u32 wan_speed_sig : 2;
579 u32 reserved1 : 6;
580 u32 wan_wait_state : 8;
581 u32 sram_chip : 2;
582 u32 sram_memmap : 2;
583 u32 reserved2 : 4;
584 u32 wan_pkt_frame : 4;
585 u32 reserved3 : 4;
586 } wan_ctrl_reg_71c;
587} flexcop_ibi_value;
588 54
589extern flexcop_ibi_value ibi_zero; 55extern flexcop_ibi_value ibi_zero;
590 56
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c
index 0113449abd15..0a78ba3737a5 100644
--- a/drivers/media/dvb/b2c2/flexcop-usb.c
+++ b/drivers/media/dvb/b2c2/flexcop-usb.c
@@ -545,7 +545,7 @@ static struct usb_device_id flexcop_usb_table [] = {
545/* usb specific object needed to register this driver with the usb subsystem */ 545/* usb specific object needed to register this driver with the usb subsystem */
546static struct usb_driver flexcop_usb_driver = { 546static struct usb_driver flexcop_usb_driver = {
547 .owner = THIS_MODULE, 547 .owner = THIS_MODULE,
548 .name = "Technisat/B2C2 FlexCop II/IIb/III USB", 548 .name = "b2c2_flexcop_usb",
549 .probe = flexcop_usb_probe, 549 .probe = flexcop_usb_probe,
550 .disconnect = flexcop_usb_disconnect, 550 .disconnect = flexcop_usb_disconnect,
551 .id_table = flexcop_usb_table, 551 .id_table = flexcop_usb_table,
diff --git a/drivers/media/dvb/b2c2/flexcop.c b/drivers/media/dvb/b2c2/flexcop.c
index 8b5d14dd36e3..12873d435406 100644
--- a/drivers/media/dvb/b2c2/flexcop.c
+++ b/drivers/media/dvb/b2c2/flexcop.c
@@ -46,7 +46,7 @@
46 46
47int b2c2_flexcop_debug; 47int b2c2_flexcop_debug;
48module_param_named(debug, b2c2_flexcop_debug, int, 0644); 48module_param_named(debug, b2c2_flexcop_debug, int, 0644);
49MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram (|-able))." DEBSTATUS); 49MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram,32=reg (|-able))." DEBSTATUS);
50#undef DEBSTATUS 50#undef DEBSTATUS
51 51
52/* global zero for ibi values */ 52/* global zero for ibi values */
@@ -173,9 +173,20 @@ static void flexcop_reset(struct flexcop_device *fc)
173 fc->write_ibi_reg(fc,ctrl_208,ibi_zero); 173 fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
174 174
175 v210.raw = 0; 175 v210.raw = 0;
176 v210.sw_reset_210.reset_blocks = 0xff; 176 v210.sw_reset_210.reset_block_000 = 1;
177 v210.sw_reset_210.reset_block_100 = 1;
178 v210.sw_reset_210.reset_block_200 = 1;
179 v210.sw_reset_210.reset_block_300 = 1;
180 v210.sw_reset_210.reset_block_400 = 1;
181 v210.sw_reset_210.reset_block_500 = 1;
182 v210.sw_reset_210.reset_block_600 = 1;
183 v210.sw_reset_210.reset_block_700 = 1;
177 v210.sw_reset_210.Block_reset_enable = 0xb2; 184 v210.sw_reset_210.Block_reset_enable = 0xb2;
185
186 v210.sw_reset_210.Special_controls = 0xc259;
187
178 fc->write_ibi_reg(fc,sw_reset_210,v210); 188 fc->write_ibi_reg(fc,sw_reset_210,v210);
189 msleep(1);
179 190
180/* reset the periphical devices */ 191/* reset the periphical devices */
181 192
@@ -186,6 +197,25 @@ static void flexcop_reset(struct flexcop_device *fc)
186 fc->write_ibi_reg(fc,misc_204,v204); 197 fc->write_ibi_reg(fc,misc_204,v204);
187} 198}
188 199
200void flexcop_reset_block_300(struct flexcop_device *fc)
201{
202 flexcop_ibi_value v208_save = fc->read_ibi_reg(fc,ctrl_208),
203 v210 = fc->read_ibi_reg(fc,sw_reset_210);
204
205 deb_rdump("208: %08x, 210: %08x\n",v208_save.raw,v210.raw);
206
207 fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
208
209 v210.sw_reset_210.reset_block_300 = 1;
210 v210.sw_reset_210.Block_reset_enable = 0xb2;
211
212 fc->write_ibi_reg(fc,sw_reset_210,v210);
213 msleep(1);
214
215 fc->write_ibi_reg(fc,ctrl_208,v208_save);
216}
217EXPORT_SYMBOL(flexcop_reset_block_300);
218
189struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len) 219struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len)
190{ 220{
191 void *bus; 221 void *bus;
diff --git a/drivers/media/dvb/b2c2/flexcop.h b/drivers/media/dvb/b2c2/flexcop.h
index caa343a97bdc..0cebe1d92e0b 100644
--- a/drivers/media/dvb/b2c2/flexcop.h
+++ b/drivers/media/dvb/b2c2/flexcop.h
@@ -26,5 +26,6 @@ extern int b2c2_flexcop_debug;
26#define deb_i2c(args...) dprintk(0x04,args) 26#define deb_i2c(args...) dprintk(0x04,args)
27#define deb_ts(args...) dprintk(0x08,args) 27#define deb_ts(args...) dprintk(0x08,args)
28#define deb_sram(args...) dprintk(0x10,args) 28#define deb_sram(args...) dprintk(0x10,args)
29#define deb_rdump(args...) dprintk(0x20,args)
29 30
30#endif 31#endif
diff --git a/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h b/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
new file mode 100644
index 000000000000..ed9a6756b194
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
@@ -0,0 +1,458 @@
1/* This file is part of linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
2 *
3 * register descriptions
4 *
5 * see flexcop.c for copyright information.
6 */
7
8/* This file is automatically generated, do not edit things here. */
9#ifndef __FLEXCOP_IBI_VALUE_INCLUDED__
10#define __FLEXCOP_IBI_VALUE_INCLUDED__
11
12typedef union {
13 u32 raw;
14
15 struct {
16 u32 dma_address0 :30;
17 u32 dma_0No_update : 1;
18 u32 dma_0start : 1;
19 } dma_0x0;
20
21 struct {
22 u32 dma_addr_size :24;
23 u32 DMA_maxpackets : 8;
24 } dma_0x4_remap;
25
26 struct {
27 u32 dma_addr_size :24;
28 u32 unused : 1;
29 u32 dma1timer : 7;
30 } dma_0x4_read;
31
32 struct {
33 u32 dma_addr_size :24;
34 u32 dmatimer : 7;
35 u32 unused : 1;
36 } dma_0x4_write;
37
38 struct {
39 u32 dma_cur_addr :30;
40 u32 unused : 2;
41 } dma_0x8;
42
43 struct {
44 u32 dma_address1 :30;
45 u32 remap_enable : 1;
46 u32 dma_1start : 1;
47 } dma_0xc;
48
49 struct {
50 u32 st_done : 1;
51 u32 no_base_addr_ack_error : 1;
52 u32 twoWS_port_reg : 2;
53 u32 total_bytes : 2;
54 u32 twoWS_rw : 1;
55 u32 working_start : 1;
56 u32 data1_reg : 8;
57 u32 baseaddr : 8;
58 u32 reserved1 : 1;
59 u32 chipaddr : 7;
60 } tw_sm_c_100;
61
62 struct {
63 u32 unused : 6;
64 u32 force_stop : 1;
65 u32 exlicit_stops : 1;
66 u32 data4_reg : 8;
67 u32 data3_reg : 8;
68 u32 data2_reg : 8;
69 } tw_sm_c_104;
70
71 struct {
72 u32 reserved2 :19;
73 u32 tlo1 : 5;
74 u32 reserved1 : 2;
75 u32 thi1 : 6;
76 } tw_sm_c_108;
77
78 struct {
79 u32 reserved2 :19;
80 u32 tlo1 : 5;
81 u32 reserved1 : 2;
82 u32 thi1 : 6;
83 } tw_sm_c_10c;
84
85 struct {
86 u32 reserved2 :19;
87 u32 tlo1 : 5;
88 u32 reserved1 : 2;
89 u32 thi1 : 6;
90 } tw_sm_c_110;
91
92 struct {
93 u32 LNB_CTLPrescaler_sig : 2;
94 u32 LNB_CTLLowCount_sig :15;
95 u32 LNB_CTLHighCount_sig :15;
96 } lnb_switch_freq_200;
97
98 struct {
99 u32 Rev_N_sig_reserved2 : 1;
100 u32 Rev_N_sig_caps : 1;
101 u32 Rev_N_sig_reserved1 : 2;
102 u32 Rev_N_sig_revision_hi : 4;
103 u32 reserved :20;
104 u32 Per_reset_sig : 1;
105 u32 LNB_L_H_sig : 1;
106 u32 ACPI3_sig : 1;
107 u32 ACPI1_sig : 1;
108 } misc_204;
109
110 struct {
111 u32 unused : 9;
112 u32 Mailbox_from_V8_Enable_sig : 1;
113 u32 DMA2_Size_IRQ_Enable_sig : 1;
114 u32 DMA1_Size_IRQ_Enable_sig : 1;
115 u32 DMA2_Timer_Enable_sig : 1;
116 u32 DMA2_IRQ_Enable_sig : 1;
117 u32 DMA1_Timer_Enable_sig : 1;
118 u32 DMA1_IRQ_Enable_sig : 1;
119 u32 Rcv_Data_sig : 1;
120 u32 MAC_filter_Mode_sig : 1;
121 u32 Multi2_Enable_sig : 1;
122 u32 Per_CA_Enable_sig : 1;
123 u32 SMC_Enable_sig : 1;
124 u32 CA_Enable_sig : 1;
125 u32 WAN_CA_Enable_sig : 1;
126 u32 WAN_Enable_sig : 1;
127 u32 Mask_filter_sig : 1;
128 u32 Null_filter_sig : 1;
129 u32 ECM_filter_sig : 1;
130 u32 EMM_filter_sig : 1;
131 u32 PMT_filter_sig : 1;
132 u32 PCR_filter_sig : 1;
133 u32 Stream2_filter_sig : 1;
134 u32 Stream1_filter_sig : 1;
135 } ctrl_208;
136
137 struct {
138 u32 reserved :21;
139 u32 Transport_Error : 1;
140 u32 LLC_SNAP_FLAG_set : 1;
141 u32 Continuity_error_flag : 1;
142 u32 Data_receiver_error : 1;
143 u32 Mailbox_from_V8_Status_sig : 1;
144 u32 DMA2_Size_IRQ_Status : 1;
145 u32 DMA1_Size_IRQ_Status : 1;
146 u32 DMA2_Timer_Status : 1;
147 u32 DMA2_IRQ_Status : 1;
148 u32 DMA1_Timer_Status : 1;
149 u32 DMA1_IRQ_Status : 1;
150 } irq_20c;
151
152 struct {
153 u32 Special_controls :16;
154 u32 Block_reset_enable : 8;
155 u32 reset_block_700 : 1;
156 u32 reset_block_600 : 1;
157 u32 reset_block_500 : 1;
158 u32 reset_block_400 : 1;
159 u32 reset_block_300 : 1;
160 u32 reset_block_200 : 1;
161 u32 reset_block_100 : 1;
162 u32 reset_block_000 : 1;
163 } sw_reset_210;
164
165 struct {
166 u32 unused2 :20;
167 u32 polarity_PS_ERR_sig : 1;
168 u32 polarity_PS_SYNC_sig : 1;
169 u32 polarity_PS_VALID_sig : 1;
170 u32 polarity_PS_CLK_sig : 1;
171 u32 unused1 : 3;
172 u32 s2p_sel_sig : 1;
173 u32 section_pkg_enable_sig : 1;
174 u32 halt_V8_sig : 1;
175 u32 v2WS_oe_sig : 1;
176 u32 vuart_oe_sig : 1;
177 } misc_214;
178
179 struct {
180 u32 Mailbox_from_V8 :32;
181 } mbox_v8_to_host_218;
182
183 struct {
184 u32 sysramaccess_busmuster : 1;
185 u32 sysramaccess_write : 1;
186 u32 unused : 7;
187 u32 sysramaccess_addr :15;
188 u32 sysramaccess_data : 8;
189 } mbox_host_to_v8_21c;
190
191 struct {
192 u32 debug_fifo_problem : 1;
193 u32 debug_flag_write_status00 : 1;
194 u32 Stream2_trans : 1;
195 u32 Stream2_PID :13;
196 u32 debug_flag_pid_saved : 1;
197 u32 MAC_Multicast_filter : 1;
198 u32 Stream1_trans : 1;
199 u32 Stream1_PID :13;
200 } pid_filter_300;
201
202 struct {
203 u32 reserved : 2;
204 u32 PMT_trans : 1;
205 u32 PMT_PID :13;
206 u32 debug_overrun2 : 1;
207 u32 debug_overrun3 : 1;
208 u32 PCR_trans : 1;
209 u32 PCR_PID :13;
210 } pid_filter_304;
211
212 struct {
213 u32 reserved : 2;
214 u32 ECM_trans : 1;
215 u32 ECM_PID :13;
216 u32 EMM_filter_6 : 1;
217 u32 EMM_filter_4 : 1;
218 u32 EMM_trans : 1;
219 u32 EMM_PID :13;
220 } pid_filter_308;
221
222 struct {
223 u32 unused2 : 3;
224 u32 Group_mask :13;
225 u32 unused1 : 2;
226 u32 Group_trans : 1;
227 u32 Group_PID :13;
228 } pid_filter_30c_ext_ind_0_7;
229
230 struct {
231 u32 unused :15;
232 u32 net_master_read :17;
233 } pid_filter_30c_ext_ind_1;
234
235 struct {
236 u32 unused :15;
237 u32 net_master_write :17;
238 } pid_filter_30c_ext_ind_2;
239
240 struct {
241 u32 unused :15;
242 u32 next_net_master_write :17;
243 } pid_filter_30c_ext_ind_3;
244
245 struct {
246 u32 reserved2 : 5;
247 u32 stack_read :10;
248 u32 reserved1 : 6;
249 u32 state_write :10;
250 u32 unused1 : 1;
251 } pid_filter_30c_ext_ind_4;
252
253 struct {
254 u32 unused :22;
255 u32 stack_cnt :10;
256 } pid_filter_30c_ext_ind_5;
257
258 struct {
259 u32 unused : 4;
260 u32 data_size_reg :12;
261 u32 write_status4 : 2;
262 u32 write_status1 : 2;
263 u32 pid_fsm_save_reg300 : 2;
264 u32 pid_fsm_save_reg4 : 2;
265 u32 pid_fsm_save_reg3 : 2;
266 u32 pid_fsm_save_reg2 : 2;
267 u32 pid_fsm_save_reg1 : 2;
268 u32 pid_fsm_save_reg0 : 2;
269 } pid_filter_30c_ext_ind_6;
270
271 struct {
272 u32 unused :22;
273 u32 pass_alltables : 1;
274 u32 AB_select : 1;
275 u32 extra_index_reg : 3;
276 u32 index_reg : 5;
277 } index_reg_310;
278
279 struct {
280 u32 reserved :17;
281 u32 PID_enable_bit : 1;
282 u32 PID_trans : 1;
283 u32 PID :13;
284 } pid_n_reg_314;
285
286 struct {
287 u32 reserved : 6;
288 u32 HighAB_bit : 1;
289 u32 Enable_bit : 1;
290 u32 A6_byte : 8;
291 u32 A5_byte : 8;
292 u32 A4_byte : 8;
293 } mac_low_reg_318;
294
295 struct {
296 u32 reserved : 8;
297 u32 A3_byte : 8;
298 u32 A2_byte : 8;
299 u32 A1_byte : 8;
300 } mac_high_reg_31c;
301
302 struct {
303 u32 data_Tag_ID :16;
304 u32 reserved :16;
305 } data_tag_400;
306
307 struct {
308 u32 Card_IDbyte3 : 8;
309 u32 Card_IDbyte4 : 8;
310 u32 Card_IDbyte5 : 8;
311 u32 Card_IDbyte6 : 8;
312 } card_id_408;
313
314 struct {
315 u32 Card_IDbyte1 : 8;
316 u32 Card_IDbyte2 : 8;
317 } card_id_40c;
318
319 struct {
320 u32 MAC6 : 8;
321 u32 MAC3 : 8;
322 u32 MAC2 : 8;
323 u32 MAC1 : 8;
324 } mac_address_418;
325
326 struct {
327 u32 reserved :16;
328 u32 MAC8 : 8;
329 u32 MAC7 : 8;
330 } mac_address_41c;
331
332 struct {
333 u32 reserved :21;
334 u32 txbuffempty : 1;
335 u32 ReceiveByteFrameError : 1;
336 u32 ReceiveDataReady : 1;
337 u32 transmitter_data_byte : 8;
338 } ci_600;
339
340 struct {
341 u32 pi_component_reg : 3;
342 u32 pi_rw : 1;
343 u32 pi_ha :20;
344 u32 pi_d : 8;
345 } pi_604;
346
347 struct {
348 u32 pi_busy_n : 1;
349 u32 pi_wait_n : 1;
350 u32 pi_timeout_status : 1;
351 u32 pi_CiMax_IRQ_n : 1;
352 u32 config_cclk : 1;
353 u32 config_cs_n : 1;
354 u32 config_wr_n : 1;
355 u32 config_Prog_n : 1;
356 u32 config_Init_stat : 1;
357 u32 config_Done_stat : 1;
358 u32 pcmcia_b_mod_pwr_n : 1;
359 u32 pcmcia_a_mod_pwr_n : 1;
360 u32 reserved : 3;
361 u32 Timer_addr : 5;
362 u32 unused : 1;
363 u32 timer_data : 7;
364 u32 Timer_Load_req : 1;
365 u32 Timer_Read_req : 1;
366 u32 oncecycle_read : 1;
367 u32 serialReset : 1;
368 } pi_608;
369
370 struct {
371 u32 reserved : 6;
372 u32 rw_flag : 1;
373 u32 dvb_en : 1;
374 u32 key_array_row : 5;
375 u32 key_array_col : 3;
376 u32 key_code : 2;
377 u32 key_enable : 1;
378 u32 PID :13;
379 } dvb_reg_60c;
380
381 struct {
382 u32 start_sram_ibi : 1;
383 u32 reserved2 : 1;
384 u32 ce_pin_reg : 1;
385 u32 oe_pin_reg : 1;
386 u32 reserved1 : 3;
387 u32 sc_xfer_bit : 1;
388 u32 sram_data : 8;
389 u32 sram_rw : 1;
390 u32 sram_addr :15;
391 } sram_ctrl_reg_700;
392
393 struct {
394 u32 net_addr_write :16;
395 u32 net_addr_read :16;
396 } net_buf_reg_704;
397
398 struct {
399 u32 cai_cnt : 4;
400 u32 reserved2 : 6;
401 u32 cai_write :11;
402 u32 reserved1 : 5;
403 u32 cai_read :11;
404 } cai_buf_reg_708;
405
406 struct {
407 u32 cao_cnt : 4;
408 u32 reserved2 : 6;
409 u32 cap_write :11;
410 u32 reserved1 : 5;
411 u32 cao_read :11;
412 } cao_buf_reg_70c;
413
414 struct {
415 u32 media_cnt : 4;
416 u32 reserved2 : 6;
417 u32 media_write :11;
418 u32 reserved1 : 5;
419 u32 media_read :11;
420 } media_buf_reg_710;
421
422 struct {
423 u32 reserved :17;
424 u32 ctrl_maximumfill : 1;
425 u32 ctrl_sramdma : 1;
426 u32 ctrl_usb_wan : 1;
427 u32 cao_ovflow_error : 1;
428 u32 cai_ovflow_error : 1;
429 u32 media_ovflow_error : 1;
430 u32 net_ovflow_error : 1;
431 u32 MEDIA_Dest : 2;
432 u32 CAO_Dest : 2;
433 u32 CAI_Dest : 2;
434 u32 NET_Dest : 2;
435 } sram_dest_reg_714;
436
437 struct {
438 u32 reserved3 :11;
439 u32 net_addr_write : 1;
440 u32 reserved2 : 3;
441 u32 net_addr_read : 1;
442 u32 reserved1 : 4;
443 u32 net_cnt :12;
444 } net_buf_reg_718;
445
446 struct {
447 u32 reserved3 : 4;
448 u32 wan_pkt_frame : 4;
449 u32 reserved2 : 4;
450 u32 sram_memmap : 2;
451 u32 sram_chip : 2;
452 u32 wan_wait_state : 8;
453 u32 reserved1 : 6;
454 u32 wan_speed_sig : 2;
455 } wan_ctrl_reg_71c;
456} flexcop_ibi_value;
457
458#endif
diff --git a/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h b/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
new file mode 100644
index 000000000000..49f2315b6e58
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
@@ -0,0 +1,458 @@
1/* This file is part of linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
2 *
3 * register descriptions
4 *
5 * see flexcop.c for copyright information.
6 */
7
8/* This file is automatically generated, do not edit things here. */
9#ifndef __FLEXCOP_IBI_VALUE_INCLUDED__
10#define __FLEXCOP_IBI_VALUE_INCLUDED__
11
12typedef union {
13 u32 raw;
14
15 struct {
16 u32 dma_0start : 1;
17 u32 dma_0No_update : 1;
18 u32 dma_address0 :30;
19 } dma_0x0;
20
21 struct {
22 u32 DMA_maxpackets : 8;
23 u32 dma_addr_size :24;
24 } dma_0x4_remap;
25
26 struct {
27 u32 dma1timer : 7;
28 u32 unused : 1;
29 u32 dma_addr_size :24;
30 } dma_0x4_read;
31
32 struct {
33 u32 unused : 1;
34 u32 dmatimer : 7;
35 u32 dma_addr_size :24;
36 } dma_0x4_write;
37
38 struct {
39 u32 unused : 2;
40 u32 dma_cur_addr :30;
41 } dma_0x8;
42
43 struct {
44 u32 dma_1start : 1;
45 u32 remap_enable : 1;
46 u32 dma_address1 :30;
47 } dma_0xc;
48
49 struct {
50 u32 chipaddr : 7;
51 u32 reserved1 : 1;
52 u32 baseaddr : 8;
53 u32 data1_reg : 8;
54 u32 working_start : 1;
55 u32 twoWS_rw : 1;
56 u32 total_bytes : 2;
57 u32 twoWS_port_reg : 2;
58 u32 no_base_addr_ack_error : 1;
59 u32 st_done : 1;
60 } tw_sm_c_100;
61
62 struct {
63 u32 data2_reg : 8;
64 u32 data3_reg : 8;
65 u32 data4_reg : 8;
66 u32 exlicit_stops : 1;
67 u32 force_stop : 1;
68 u32 unused : 6;
69 } tw_sm_c_104;
70
71 struct {
72 u32 thi1 : 6;
73 u32 reserved1 : 2;
74 u32 tlo1 : 5;
75 u32 reserved2 :19;
76 } tw_sm_c_108;
77
78 struct {
79 u32 thi1 : 6;
80 u32 reserved1 : 2;
81 u32 tlo1 : 5;
82 u32 reserved2 :19;
83 } tw_sm_c_10c;
84
85 struct {
86 u32 thi1 : 6;
87 u32 reserved1 : 2;
88 u32 tlo1 : 5;
89 u32 reserved2 :19;
90 } tw_sm_c_110;
91
92 struct {
93 u32 LNB_CTLHighCount_sig :15;
94 u32 LNB_CTLLowCount_sig :15;
95 u32 LNB_CTLPrescaler_sig : 2;
96 } lnb_switch_freq_200;
97
98 struct {
99 u32 ACPI1_sig : 1;
100 u32 ACPI3_sig : 1;
101 u32 LNB_L_H_sig : 1;
102 u32 Per_reset_sig : 1;
103 u32 reserved :20;
104 u32 Rev_N_sig_revision_hi : 4;
105 u32 Rev_N_sig_reserved1 : 2;
106 u32 Rev_N_sig_caps : 1;
107 u32 Rev_N_sig_reserved2 : 1;
108 } misc_204;
109
110 struct {
111 u32 Stream1_filter_sig : 1;
112 u32 Stream2_filter_sig : 1;
113 u32 PCR_filter_sig : 1;
114 u32 PMT_filter_sig : 1;
115 u32 EMM_filter_sig : 1;
116 u32 ECM_filter_sig : 1;
117 u32 Null_filter_sig : 1;
118 u32 Mask_filter_sig : 1;
119 u32 WAN_Enable_sig : 1;
120 u32 WAN_CA_Enable_sig : 1;
121 u32 CA_Enable_sig : 1;
122 u32 SMC_Enable_sig : 1;
123 u32 Per_CA_Enable_sig : 1;
124 u32 Multi2_Enable_sig : 1;
125 u32 MAC_filter_Mode_sig : 1;
126 u32 Rcv_Data_sig : 1;
127 u32 DMA1_IRQ_Enable_sig : 1;
128 u32 DMA1_Timer_Enable_sig : 1;
129 u32 DMA2_IRQ_Enable_sig : 1;
130 u32 DMA2_Timer_Enable_sig : 1;
131 u32 DMA1_Size_IRQ_Enable_sig : 1;
132 u32 DMA2_Size_IRQ_Enable_sig : 1;
133 u32 Mailbox_from_V8_Enable_sig : 1;
134 u32 unused : 9;
135 } ctrl_208;
136
137 struct {
138 u32 DMA1_IRQ_Status : 1;
139 u32 DMA1_Timer_Status : 1;
140 u32 DMA2_IRQ_Status : 1;
141 u32 DMA2_Timer_Status : 1;
142 u32 DMA1_Size_IRQ_Status : 1;
143 u32 DMA2_Size_IRQ_Status : 1;
144 u32 Mailbox_from_V8_Status_sig : 1;
145 u32 Data_receiver_error : 1;
146 u32 Continuity_error_flag : 1;
147 u32 LLC_SNAP_FLAG_set : 1;
148 u32 Transport_Error : 1;
149 u32 reserved :21;
150 } irq_20c;
151
152 struct {
153 u32 reset_block_000 : 1;
154 u32 reset_block_100 : 1;
155 u32 reset_block_200 : 1;
156 u32 reset_block_300 : 1;
157 u32 reset_block_400 : 1;
158 u32 reset_block_500 : 1;
159 u32 reset_block_600 : 1;
160 u32 reset_block_700 : 1;
161 u32 Block_reset_enable : 8;
162 u32 Special_controls :16;
163 } sw_reset_210;
164
165 struct {
166 u32 vuart_oe_sig : 1;
167 u32 v2WS_oe_sig : 1;
168 u32 halt_V8_sig : 1;
169 u32 section_pkg_enable_sig : 1;
170 u32 s2p_sel_sig : 1;
171 u32 unused1 : 3;
172 u32 polarity_PS_CLK_sig : 1;
173 u32 polarity_PS_VALID_sig : 1;
174 u32 polarity_PS_SYNC_sig : 1;
175 u32 polarity_PS_ERR_sig : 1;
176 u32 unused2 :20;
177 } misc_214;
178
179 struct {
180 u32 Mailbox_from_V8 :32;
181 } mbox_v8_to_host_218;
182
183 struct {
184 u32 sysramaccess_data : 8;
185 u32 sysramaccess_addr :15;
186 u32 unused : 7;
187 u32 sysramaccess_write : 1;
188 u32 sysramaccess_busmuster : 1;
189 } mbox_host_to_v8_21c;
190
191 struct {
192 u32 Stream1_PID :13;
193 u32 Stream1_trans : 1;
194 u32 MAC_Multicast_filter : 1;
195 u32 debug_flag_pid_saved : 1;
196 u32 Stream2_PID :13;
197 u32 Stream2_trans : 1;
198 u32 debug_flag_write_status00 : 1;
199 u32 debug_fifo_problem : 1;
200 } pid_filter_300;
201
202 struct {
203 u32 PCR_PID :13;
204 u32 PCR_trans : 1;
205 u32 debug_overrun3 : 1;
206 u32 debug_overrun2 : 1;
207 u32 PMT_PID :13;
208 u32 PMT_trans : 1;
209 u32 reserved : 2;
210 } pid_filter_304;
211
212 struct {
213 u32 EMM_PID :13;
214 u32 EMM_trans : 1;
215 u32 EMM_filter_4 : 1;
216 u32 EMM_filter_6 : 1;
217 u32 ECM_PID :13;
218 u32 ECM_trans : 1;
219 u32 reserved : 2;
220 } pid_filter_308;
221
222 struct {
223 u32 Group_PID :13;
224 u32 Group_trans : 1;
225 u32 unused1 : 2;
226 u32 Group_mask :13;
227 u32 unused2 : 3;
228 } pid_filter_30c_ext_ind_0_7;
229
230 struct {
231 u32 net_master_read :17;
232 u32 unused :15;
233 } pid_filter_30c_ext_ind_1;
234
235 struct {
236 u32 net_master_write :17;
237 u32 unused :15;
238 } pid_filter_30c_ext_ind_2;
239
240 struct {
241 u32 next_net_master_write :17;
242 u32 unused :15;
243 } pid_filter_30c_ext_ind_3;
244
245 struct {
246 u32 unused1 : 1;
247 u32 state_write :10;
248 u32 reserved1 : 6;
249 u32 stack_read :10;
250 u32 reserved2 : 5;
251 } pid_filter_30c_ext_ind_4;
252
253 struct {
254 u32 stack_cnt :10;
255 u32 unused :22;
256 } pid_filter_30c_ext_ind_5;
257
258 struct {
259 u32 pid_fsm_save_reg0 : 2;
260 u32 pid_fsm_save_reg1 : 2;
261 u32 pid_fsm_save_reg2 : 2;
262 u32 pid_fsm_save_reg3 : 2;
263 u32 pid_fsm_save_reg4 : 2;
264 u32 pid_fsm_save_reg300 : 2;
265 u32 write_status1 : 2;
266 u32 write_status4 : 2;
267 u32 data_size_reg :12;
268 u32 unused : 4;
269 } pid_filter_30c_ext_ind_6;
270
271 struct {
272 u32 index_reg : 5;
273 u32 extra_index_reg : 3;
274 u32 AB_select : 1;
275 u32 pass_alltables : 1;
276 u32 unused :22;
277 } index_reg_310;
278
279 struct {
280 u32 PID :13;
281 u32 PID_trans : 1;
282 u32 PID_enable_bit : 1;
283 u32 reserved :17;
284 } pid_n_reg_314;
285
286 struct {
287 u32 A4_byte : 8;
288 u32 A5_byte : 8;
289 u32 A6_byte : 8;
290 u32 Enable_bit : 1;
291 u32 HighAB_bit : 1;
292 u32 reserved : 6;
293 } mac_low_reg_318;
294
295 struct {
296 u32 A1_byte : 8;
297 u32 A2_byte : 8;
298 u32 A3_byte : 8;
299 u32 reserved : 8;
300 } mac_high_reg_31c;
301
302 struct {
303 u32 reserved :16;
304 u32 data_Tag_ID :16;
305 } data_tag_400;
306
307 struct {
308 u32 Card_IDbyte6 : 8;
309 u32 Card_IDbyte5 : 8;
310 u32 Card_IDbyte4 : 8;
311 u32 Card_IDbyte3 : 8;
312 } card_id_408;
313
314 struct {
315 u32 Card_IDbyte2 : 8;
316 u32 Card_IDbyte1 : 8;
317 } card_id_40c;
318
319 struct {
320 u32 MAC1 : 8;
321 u32 MAC2 : 8;
322 u32 MAC3 : 8;
323 u32 MAC6 : 8;
324 } mac_address_418;
325
326 struct {
327 u32 MAC7 : 8;
328 u32 MAC8 : 8;
329 u32 reserved :16;
330 } mac_address_41c;
331
332 struct {
333 u32 transmitter_data_byte : 8;
334 u32 ReceiveDataReady : 1;
335 u32 ReceiveByteFrameError : 1;
336 u32 txbuffempty : 1;
337 u32 reserved :21;
338 } ci_600;
339
340 struct {
341 u32 pi_d : 8;
342 u32 pi_ha :20;
343 u32 pi_rw : 1;
344 u32 pi_component_reg : 3;
345 } pi_604;
346
347 struct {
348 u32 serialReset : 1;
349 u32 oncecycle_read : 1;
350 u32 Timer_Read_req : 1;
351 u32 Timer_Load_req : 1;
352 u32 timer_data : 7;
353 u32 unused : 1;
354 u32 Timer_addr : 5;
355 u32 reserved : 3;
356 u32 pcmcia_a_mod_pwr_n : 1;
357 u32 pcmcia_b_mod_pwr_n : 1;
358 u32 config_Done_stat : 1;
359 u32 config_Init_stat : 1;
360 u32 config_Prog_n : 1;
361 u32 config_wr_n : 1;
362 u32 config_cs_n : 1;
363 u32 config_cclk : 1;
364 u32 pi_CiMax_IRQ_n : 1;
365 u32 pi_timeout_status : 1;
366 u32 pi_wait_n : 1;
367 u32 pi_busy_n : 1;
368 } pi_608;
369
370 struct {
371 u32 PID :13;
372 u32 key_enable : 1;
373 u32 key_code : 2;
374 u32 key_array_col : 3;
375 u32 key_array_row : 5;
376 u32 dvb_en : 1;
377 u32 rw_flag : 1;
378 u32 reserved : 6;
379 } dvb_reg_60c;
380
381 struct {
382 u32 sram_addr :15;
383 u32 sram_rw : 1;
384 u32 sram_data : 8;
385 u32 sc_xfer_bit : 1;
386 u32 reserved1 : 3;
387 u32 oe_pin_reg : 1;
388 u32 ce_pin_reg : 1;
389 u32 reserved2 : 1;
390 u32 start_sram_ibi : 1;
391 } sram_ctrl_reg_700;
392
393 struct {
394 u32 net_addr_read :16;
395 u32 net_addr_write :16;
396 } net_buf_reg_704;
397
398 struct {
399 u32 cai_read :11;
400 u32 reserved1 : 5;
401 u32 cai_write :11;
402 u32 reserved2 : 6;
403 u32 cai_cnt : 4;
404 } cai_buf_reg_708;
405
406 struct {
407 u32 cao_read :11;
408 u32 reserved1 : 5;
409 u32 cap_write :11;
410 u32 reserved2 : 6;
411 u32 cao_cnt : 4;
412 } cao_buf_reg_70c;
413
414 struct {
415 u32 media_read :11;
416 u32 reserved1 : 5;
417 u32 media_write :11;
418 u32 reserved2 : 6;
419 u32 media_cnt : 4;
420 } media_buf_reg_710;
421
422 struct {
423 u32 NET_Dest : 2;
424 u32 CAI_Dest : 2;
425 u32 CAO_Dest : 2;
426 u32 MEDIA_Dest : 2;
427 u32 net_ovflow_error : 1;
428 u32 media_ovflow_error : 1;
429 u32 cai_ovflow_error : 1;
430 u32 cao_ovflow_error : 1;
431 u32 ctrl_usb_wan : 1;
432 u32 ctrl_sramdma : 1;
433 u32 ctrl_maximumfill : 1;
434 u32 reserved :17;
435 } sram_dest_reg_714;
436
437 struct {
438 u32 net_cnt :12;
439 u32 reserved1 : 4;
440 u32 net_addr_read : 1;
441 u32 reserved2 : 3;
442 u32 net_addr_write : 1;
443 u32 reserved3 :11;
444 } net_buf_reg_718;
445
446 struct {
447 u32 wan_speed_sig : 2;
448 u32 reserved1 : 6;
449 u32 wan_wait_state : 8;
450 u32 sram_chip : 2;
451 u32 sram_memmap : 2;
452 u32 reserved2 : 4;
453 u32 wan_pkt_frame : 4;
454 u32 reserved3 : 4;
455 } wan_ctrl_reg_71c;
456} flexcop_ibi_value;
457
458#endif
diff --git a/drivers/media/dvb/b2c2/skystar2.c b/drivers/media/dvb/b2c2/skystar2.c
deleted file mode 100644
index acbc4c34f72a..000000000000
--- a/drivers/media/dvb/b2c2/skystar2.c
+++ /dev/null
@@ -1,2644 +0,0 @@
1/*
2 * skystar2.c - driver for the Technisat SkyStar2 PCI DVB card
3 * based on the FlexCopII by B2C2,Inc.
4 *
5 * Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
6 *
7 * FIX: DISEQC Tone Burst in flexcop_diseqc_ioctl()
8 * FIX: FULL soft DiSEqC for skystar2 (FlexCopII rev 130) VP310 equipped
9 * Vincenzo Di Massa, hawk.it at tiscalinet.it
10 *
11 * Converted to Linux coding style
12 * Misc reorganization, polishing, restyling
13 * Roberto Ragusa, skystar2-c5b8 at robertoragusa dot it
14 *
15 * Added hardware filtering support,
16 * Niklas Peinecke, peinecke at gdv.uni-hannover.de
17 *
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU Lesser General Public License
21 * as published by the Free Software Foundation; either version 2.1
22 * of the License, or (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU Lesser General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 */
33
34#include <linux/module.h>
35#include <linux/moduleparam.h>
36#include <linux/delay.h>
37#include <linux/pci.h>
38#include <linux/init.h>
39#include <linux/version.h>
40
41#include <asm/io.h>
42
43#include "dvb_frontend.h"
44
45#include <linux/dvb/frontend.h>
46#include <linux/dvb/dmx.h>
47#include "dvb_demux.h"
48#include "dmxdev.h"
49#include "dvb_filter.h"
50#include "dvbdev.h"
51#include "demux.h"
52#include "dvb_net.h"
53#include "stv0299.h"
54#include "mt352.h"
55#include "mt312.h"
56#include "nxt2002.h"
57
58static int debug;
59static int enable_hw_filters = 2;
60
61module_param(debug, int, 0644);
62MODULE_PARM_DESC(debug, "Set debugging level (0 = default, 1 = most messages, 2 = all messages).");
63module_param(enable_hw_filters, int, 0444);
64MODULE_PARM_DESC(enable_hw_filters, "enable hardware filters: supported values: 0 (none), 1, 2");
65
66#define dprintk(x...) do { if (debug>=1) printk(x); } while (0)
67#define ddprintk(x...) do { if (debug>=2) printk(x); } while (0)
68
69#define SIZE_OF_BUF_DMA1 0x3ac00
70#define SIZE_OF_BUF_DMA2 0x758
71
72#define MAX_N_HW_FILTERS (6+32)
73#define N_PID_SLOTS 256
74
75struct dmaq {
76 u32 bus_addr;
77 u32 head;
78 u32 tail;
79 u32 buffer_size;
80 u8 *buffer;
81};
82
83#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
84#define __iomem
85#endif
86
87struct adapter {
88 struct pci_dev *pdev;
89
90 u8 card_revision;
91 u32 b2c2_revision;
92 u32 pid_filter_max;
93 u32 mac_filter_max;
94 u32 irq;
95 void __iomem *io_mem;
96 unsigned long io_port;
97 u8 mac_addr[8];
98 u32 dw_sram_type;
99
100 struct dvb_adapter dvb_adapter;
101 struct dvb_demux demux;
102 struct dmxdev dmxdev;
103 struct dmx_frontend hw_frontend;
104 struct dmx_frontend mem_frontend;
105 struct i2c_adapter i2c_adap;
106 struct dvb_net dvbnet;
107
108 struct semaphore i2c_sem;
109
110 struct dmaq dmaq1;
111 struct dmaq dmaq2;
112
113 u32 dma_ctrl;
114 u32 dma_status;
115
116 int capturing;
117
118 spinlock_t lock;
119
120 int useable_hw_filters;
121 u16 hw_pids[MAX_N_HW_FILTERS];
122 u16 pid_list[N_PID_SLOTS];
123 int pid_rc[N_PID_SLOTS]; // ref counters for the pids
124 int pid_count;
125 int whole_bandwidth_count;
126 u32 mac_filter;
127
128 struct dvb_frontend* fe;
129 int (*fe_sleep)(struct dvb_frontend* fe);
130};
131
132#define write_reg_dw(adapter,reg,value) writel(value, adapter->io_mem + reg)
133#define read_reg_dw(adapter,reg) readl(adapter->io_mem + reg)
134
135static void write_reg_bitfield(struct adapter *adapter, u32 reg, u32 zeromask, u32 orvalue)
136{
137 u32 tmp;
138
139 tmp = read_reg_dw(adapter, reg);
140 tmp = (tmp & ~zeromask) | orvalue;
141 write_reg_dw(adapter, reg, tmp);
142}
143
144/* i2c functions */
145static int i2c_main_write_for_flex2(struct adapter *adapter, u32 command, u8 *buf, int retries)
146{
147 int i;
148 u32 value;
149
150 write_reg_dw(adapter, 0x100, 0);
151 write_reg_dw(adapter, 0x100, command);
152
153 for (i = 0; i < retries; i++) {
154 value = read_reg_dw(adapter, 0x100);
155
156 if ((value & 0x40000000) == 0) {
157 if ((value & 0x81000000) == 0x80000000) {
158 if (buf != 0)
159 *buf = (value >> 0x10) & 0xff;
160
161 return 1;
162 }
163 } else {
164 write_reg_dw(adapter, 0x100, 0);
165 write_reg_dw(adapter, 0x100, command);
166 }
167 }
168
169 return 0;
170}
171
172/* device = 0x10000000 for tuner, 0x20000000 for eeprom */
173static void i2c_main_setup(u32 device, u32 chip_addr, u8 op, u8 addr, u32 value, u32 len, u32 *command)
174{
175 *command = device | ((len - 1) << 26) | (value << 16) | (addr << 8) | chip_addr;
176
177 if (op != 0)
178 *command = *command | 0x03000000;
179 else
180 *command = *command | 0x01000000;
181}
182
183static int flex_i2c_read4(struct adapter *adapter, u32 device, u32 chip_addr, u16 addr, u8 *buf, u8 len)
184{
185 u32 command;
186 u32 value;
187
188 int result, i;
189
190 i2c_main_setup(device, chip_addr, 1, addr, 0, len, &command);
191
192 result = i2c_main_write_for_flex2(adapter, command, buf, 100000);
193
194 if ((result & 0xff) != 0) {
195 if (len > 1) {
196 value = read_reg_dw(adapter, 0x104);
197
198 for (i = 1; i < len; i++) {
199 buf[i] = value & 0xff;
200 value = value >> 8;
201 }
202 }
203 }
204
205 return result;
206}
207
208static int flex_i2c_write4(struct adapter *adapter, u32 device, u32 chip_addr, u32 addr, u8 *buf, u8 len)
209{
210 u32 command;
211 u32 value;
212 int i;
213
214 if (len > 1) {
215 value = 0;
216
217 for (i = len; i > 1; i--) {
218 value = value << 8;
219 value = value | buf[i - 1];
220 }
221
222 write_reg_dw(adapter, 0x104, value);
223 }
224
225 i2c_main_setup(device, chip_addr, 0, addr, buf[0], len, &command);
226
227 return i2c_main_write_for_flex2(adapter, command, NULL, 100000);
228}
229
230static void fixchipaddr(u32 device, u32 bus, u32 addr, u32 *ret)
231{
232 if (device == 0x20000000)
233 *ret = bus | ((addr >> 8) & 3);
234 else
235 *ret = bus;
236}
237
238static u32 flex_i2c_read(struct adapter *adapter, u32 device, u32 bus, u32 addr, u8 *buf, u32 len)
239{
240 u32 chipaddr;
241 u32 bytes_to_transfer;
242 u8 *start;
243
244 ddprintk("%s:\n", __FUNCTION__);
245
246 start = buf;
247
248 while (len != 0) {
249 bytes_to_transfer = len;
250
251 if (bytes_to_transfer > 4)
252 bytes_to_transfer = 4;
253
254 fixchipaddr(device, bus, addr, &chipaddr);
255
256 if (flex_i2c_read4(adapter, device, chipaddr, addr, buf, bytes_to_transfer) == 0)
257 return buf - start;
258
259 buf = buf + bytes_to_transfer;
260 addr = addr + bytes_to_transfer;
261 len = len - bytes_to_transfer;
262 };
263
264 return buf - start;
265}
266
267static u32 flex_i2c_write(struct adapter *adapter, u32 device, u32 bus, u32 addr, u8 *buf, u32 len)
268{
269 u32 chipaddr;
270 u32 bytes_to_transfer;
271 u8 *start;
272
273 ddprintk("%s:\n", __FUNCTION__);
274
275 start = buf;
276
277 while (len != 0) {
278 bytes_to_transfer = len;
279
280 if (bytes_to_transfer > 4)
281 bytes_to_transfer = 4;
282
283 fixchipaddr(device, bus, addr, &chipaddr);
284
285 if (flex_i2c_write4(adapter, device, chipaddr, addr, buf, bytes_to_transfer) == 0)
286 return buf - start;
287
288 buf = buf + bytes_to_transfer;
289 addr = addr + bytes_to_transfer;
290 len = len - bytes_to_transfer;
291 }
292
293 return buf - start;
294}
295
296static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msgs, int num)
297{
298 struct adapter *tmp = i2c_get_adapdata(adapter);
299 int i, ret = 0;
300
301 if (down_interruptible(&tmp->i2c_sem))
302 return -ERESTARTSYS;
303
304 ddprintk("%s: %d messages to transfer\n", __FUNCTION__, num);
305
306 for (i = 0; i < num; i++) {
307 ddprintk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
308 msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
309 }
310
311 // read command
312 if ((num == 2) && (msgs[0].flags == 0) && (msgs[1].flags == I2C_M_RD) && (msgs[0].buf != NULL) && (msgs[1].buf != NULL)) {
313
314 ret = flex_i2c_read(tmp, 0x10000000, msgs[0].addr, msgs[0].buf[0], msgs[1].buf, msgs[1].len);
315
316 up(&tmp->i2c_sem);
317
318 if (ret != msgs[1].len) {
319 dprintk("%s: read error !\n", __FUNCTION__);
320
321 for (i = 0; i < 2; i++) {
322 dprintk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
323 msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
324 }
325
326 return -EREMOTEIO;
327 }
328
329 return num;
330 }
331 // write command
332 for (i = 0; i < num; i++) {
333
334 if ((msgs[i].flags != 0) || (msgs[i].buf == NULL) || (msgs[i].len < 2))
335 return -EINVAL;
336
337 ret = flex_i2c_write(tmp, 0x10000000, msgs[i].addr, msgs[i].buf[0], &msgs[i].buf[1], msgs[i].len - 1);
338
339 up(&tmp->i2c_sem);
340
341 if (ret != msgs[0].len - 1) {
342 dprintk("%s: write error %i !\n", __FUNCTION__, ret);
343
344 dprintk("message %d: flags=0x%x, addr=0x%x, buf[0]=0x%x, len=%d \n", i,
345 msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
346
347 return -EREMOTEIO;
348 }
349
350 return num;
351 }
352
353 printk("%s: unknown command format !\n", __FUNCTION__);
354
355 return -EINVAL;
356}
357
358/* SRAM (Skystar2 rev2.3 has one "ISSI IS61LV256" chip on board,
359 but it seems that FlexCopII can work with more than one chip) */
360static void sram_set_net_dest(struct adapter *adapter, u8 dest)
361{
362 u32 tmp;
363
364 udelay(1000);
365
366 tmp = (read_reg_dw(adapter, 0x714) & 0xfffffffc) | (dest & 3);
367
368 udelay(1000);
369
370 write_reg_dw(adapter, 0x714, tmp);
371 write_reg_dw(adapter, 0x714, tmp);
372
373 udelay(1000);
374
375 /* return value is never used? */
376/* return tmp; */
377}
378
379static void sram_set_cai_dest(struct adapter *adapter, u8 dest)
380{
381 u32 tmp;
382
383 udelay(1000);
384
385 tmp = (read_reg_dw(adapter, 0x714) & 0xfffffff3) | ((dest & 3) << 2);
386
387 udelay(1000);
388 udelay(1000);
389
390 write_reg_dw(adapter, 0x714, tmp);
391 write_reg_dw(adapter, 0x714, tmp);
392
393 udelay(1000);
394
395 /* return value is never used? */
396/* return tmp; */
397}
398
399static void sram_set_cao_dest(struct adapter *adapter, u8 dest)
400{
401 u32 tmp;
402
403 udelay(1000);
404
405 tmp = (read_reg_dw(adapter, 0x714) & 0xffffffcf) | ((dest & 3) << 4);
406
407 udelay(1000);
408 udelay(1000);
409
410 write_reg_dw(adapter, 0x714, tmp);
411 write_reg_dw(adapter, 0x714, tmp);
412
413 udelay(1000);
414
415 /* return value is never used? */
416/* return tmp; */
417}
418
419static void sram_set_media_dest(struct adapter *adapter, u8 dest)
420{
421 u32 tmp;
422
423 udelay(1000);
424
425 tmp = (read_reg_dw(adapter, 0x714) & 0xffffff3f) | ((dest & 3) << 6);
426
427 udelay(1000);
428 udelay(1000);
429
430 write_reg_dw(adapter, 0x714, tmp);
431 write_reg_dw(adapter, 0x714, tmp);
432
433 udelay(1000);
434
435 /* return value is never used? */
436/* return tmp; */
437}
438
439/* SRAM memory is accessed through a buffer register in the FlexCop
440 chip (0x700). This register has the following structure:
441 bits 0-14 : address
442 bit 15 : read/write flag
443 bits 16-23 : 8-bit word to write
444 bits 24-27 : = 4
445 bits 28-29 : memory bank selector
446 bit 31 : busy flag
447*/
448static void flex_sram_write(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, u32 len)
449{
450 int i, retries;
451 u32 command;
452
453 for (i = 0; i < len; i++) {
454 command = bank | addr | 0x04000000 | (*buf << 0x10);
455
456 retries = 2;
457
458 while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
459 mdelay(1);
460 retries--;
461 };
462
463 if (retries == 0)
464 printk("%s: SRAM timeout\n", __FUNCTION__);
465
466 write_reg_dw(adapter, 0x700, command);
467
468 buf++;
469 addr++;
470 }
471}
472
473static void flex_sram_read(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, u32 len)
474{
475 int i, retries;
476 u32 command, value;
477
478 for (i = 0; i < len; i++) {
479 command = bank | addr | 0x04008000;
480
481 retries = 10000;
482
483 while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
484 mdelay(1);
485 retries--;
486 };
487
488 if (retries == 0)
489 printk("%s: SRAM timeout\n", __FUNCTION__);
490
491 write_reg_dw(adapter, 0x700, command);
492
493 retries = 10000;
494
495 while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
496 mdelay(1);
497 retries--;
498 };
499
500 if (retries == 0)
501 printk("%s: SRAM timeout\n", __FUNCTION__);
502
503 value = read_reg_dw(adapter, 0x700) >> 0x10;
504
505 *buf = (value & 0xff);
506
507 addr++;
508 buf++;
509 }
510}
511
512static void sram_write_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
513{
514 u32 bank;
515
516 bank = 0;
517
518 if (adapter->dw_sram_type == 0x20000) {
519 bank = (addr & 0x18000) << 0x0d;
520 }
521
522 if (adapter->dw_sram_type == 0x00000) {
523 if ((addr >> 0x0f) == 0)
524 bank = 0x20000000;
525 else
526 bank = 0x10000000;
527 }
528
529 flex_sram_write(adapter, bank, addr & 0x7fff, buf, len);
530}
531
532static void sram_read_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
533{
534 u32 bank;
535
536 bank = 0;
537
538 if (adapter->dw_sram_type == 0x20000) {
539 bank = (addr & 0x18000) << 0x0d;
540 }
541
542 if (adapter->dw_sram_type == 0x00000) {
543 if ((addr >> 0x0f) == 0)
544 bank = 0x20000000;
545 else
546 bank = 0x10000000;
547 }
548
549 flex_sram_read(adapter, bank, addr & 0x7fff, buf, len);
550}
551
552static void sram_read(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
553{
554 u32 length;
555
556 while (len != 0) {
557 length = len;
558
559 // check if the address range belongs to the same
560 // 32K memory chip. If not, the data is read from
561 // one chip at a time.
562 if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
563 length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
564 }
565
566 sram_read_chunk(adapter, addr, buf, length);
567
568 addr = addr + length;
569 buf = buf + length;
570 len = len - length;
571 }
572}
573
574static void sram_write(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
575{
576 u32 length;
577
578 while (len != 0) {
579 length = len;
580
581 // check if the address range belongs to the same
582 // 32K memory chip. If not, the data is written to
583 // one chip at a time.
584 if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
585 length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
586 }
587
588 sram_write_chunk(adapter, addr, buf, length);
589
590 addr = addr + length;
591 buf = buf + length;
592 len = len - length;
593 }
594}
595
596static void sram_set_size(struct adapter *adapter, u32 mask)
597{
598 write_reg_dw(adapter, 0x71c, (mask | (~0x30000 & read_reg_dw(adapter, 0x71c))));
599}
600
601static void sram_init(struct adapter *adapter)
602{
603 u32 tmp;
604
605 tmp = read_reg_dw(adapter, 0x71c);
606
607 write_reg_dw(adapter, 0x71c, 1);
608
609 if (read_reg_dw(adapter, 0x71c) != 0) {
610 write_reg_dw(adapter, 0x71c, tmp);
611
612 adapter->dw_sram_type = tmp & 0x30000;
613
614 ddprintk("%s: dw_sram_type = %x\n", __FUNCTION__, adapter->dw_sram_type);
615
616 } else {
617
618 adapter->dw_sram_type = 0x10000;
619
620 ddprintk("%s: dw_sram_type = %x\n", __FUNCTION__, adapter->dw_sram_type);
621 }
622
623 /* return value is never used? */
624/* return adapter->dw_sram_type; */
625}
626
627static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr)
628{
629 u8 tmp1, tmp2;
630
631 dprintk("%s: mask = %x, addr = %x\n", __FUNCTION__, mask, addr);
632
633 sram_set_size(adapter, mask);
634 sram_init(adapter);
635
636 tmp2 = 0xa5;
637 tmp1 = 0x4f;
638
639 sram_write(adapter, addr, &tmp2, 1);
640 sram_write(adapter, addr + 4, &tmp1, 1);
641
642 tmp2 = 0;
643
644 mdelay(20);
645
646 sram_read(adapter, addr, &tmp2, 1);
647 sram_read(adapter, addr, &tmp2, 1);
648
649 dprintk("%s: wrote 0xa5, read 0x%2x\n", __FUNCTION__, tmp2);
650
651 if (tmp2 != 0xa5)
652 return 0;
653
654 tmp2 = 0x5a;
655 tmp1 = 0xf4;
656
657 sram_write(adapter, addr, &tmp2, 1);
658 sram_write(adapter, addr + 4, &tmp1, 1);
659
660 tmp2 = 0;
661
662 mdelay(20);
663
664 sram_read(adapter, addr, &tmp2, 1);
665 sram_read(adapter, addr, &tmp2, 1);
666
667 dprintk("%s: wrote 0x5a, read 0x%2x\n", __FUNCTION__, tmp2);
668
669 if (tmp2 != 0x5a)
670 return 0;
671
672 return 1;
673}
674
675static u32 sram_length(struct adapter *adapter)
676{
677 if (adapter->dw_sram_type == 0x10000)
678 return 32768; // 32K
679 if (adapter->dw_sram_type == 0x00000)
680 return 65536; // 64K
681 if (adapter->dw_sram_type == 0x20000)
682 return 131072; // 128K
683
684 return 32768; // 32K
685}
686
687/* FlexcopII can work with 32K, 64K or 128K of external SRAM memory.
688 - for 128K there are 4x32K chips at bank 0,1,2,3.
689 - for 64K there are 2x32K chips at bank 1,2.
690 - for 32K there is one 32K chip at bank 0.
691
692 FlexCop works only with one bank at a time. The bank is selected
693 by bits 28-29 of the 0x700 register.
694
695 bank 0 covers addresses 0x00000-0x07fff
696 bank 1 covers addresses 0x08000-0x0ffff
697 bank 2 covers addresses 0x10000-0x17fff
698 bank 3 covers addresses 0x18000-0x1ffff
699*/
700static int sram_detect_for_flex2(struct adapter *adapter)
701{
702 u32 tmp, tmp2, tmp3;
703
704 dprintk("%s:\n", __FUNCTION__);
705
706 tmp = read_reg_dw(adapter, 0x208);
707 write_reg_dw(adapter, 0x208, 0);
708
709 tmp2 = read_reg_dw(adapter, 0x71c);
710
711 dprintk("%s: tmp2 = %x\n", __FUNCTION__, tmp2);
712
713 write_reg_dw(adapter, 0x71c, 1);
714
715 tmp3 = read_reg_dw(adapter, 0x71c);
716
717 dprintk("%s: tmp3 = %x\n", __FUNCTION__, tmp3);
718
719 write_reg_dw(adapter, 0x71c, tmp2);
720
721 // check for internal SRAM ???
722 tmp3--;
723 if (tmp3 != 0) {
724 sram_set_size(adapter, 0x10000);
725 sram_init(adapter);
726 write_reg_dw(adapter, 0x208, tmp);
727
728 dprintk("%s: sram size = 32K\n", __FUNCTION__);
729
730 return 32;
731 }
732
733 if (sram_test_location(adapter, 0x20000, 0x18000) != 0) {
734 sram_set_size(adapter, 0x20000);
735 sram_init(adapter);
736 write_reg_dw(adapter, 0x208, tmp);
737
738 dprintk("%s: sram size = 128K\n", __FUNCTION__);
739
740 return 128;
741 }
742
743 if (sram_test_location(adapter, 0x00000, 0x10000) != 0) {
744 sram_set_size(adapter, 0x00000);
745 sram_init(adapter);
746 write_reg_dw(adapter, 0x208, tmp);
747
748 dprintk("%s: sram size = 64K\n", __FUNCTION__);
749
750 return 64;
751 }
752
753 if (sram_test_location(adapter, 0x10000, 0x00000) != 0) {
754 sram_set_size(adapter, 0x10000);
755 sram_init(adapter);
756 write_reg_dw(adapter, 0x208, tmp);
757
758 dprintk("%s: sram size = 32K\n", __FUNCTION__);
759
760 return 32;
761 }
762
763 sram_set_size(adapter, 0x10000);
764 sram_init(adapter);
765 write_reg_dw(adapter, 0x208, tmp);
766
767 dprintk("%s: SRAM detection failed. Set to 32K \n", __FUNCTION__);
768
769 return 0;
770}
771
772static void sll_detect_sram_size(struct adapter *adapter)
773{
774 sram_detect_for_flex2(adapter);
775}
776
777/* EEPROM (Skystar2 has one "24LC08B" chip on board) */
778/*
779static int eeprom_write(struct adapter *adapter, u16 addr, u8 *buf, u16 len)
780{
781 return flex_i2c_write(adapter, 0x20000000, 0x50, addr, buf, len);
782}
783*/
784
785static int eeprom_read(struct adapter *adapter, u16 addr, u8 *buf, u16 len)
786{
787 return flex_i2c_read(adapter, 0x20000000, 0x50, addr, buf, len);
788}
789
790static u8 calc_lrc(u8 *buf, int len)
791{
792 int i;
793 u8 sum;
794
795 sum = 0;
796
797 for (i = 0; i < len; i++)
798 sum = sum ^ buf[i];
799
800 return sum;
801}
802
803static int eeprom_lrc_read(struct adapter *adapter, u32 addr, u32 len, u8 *buf, int retries)
804{
805 int i;
806
807 for (i = 0; i < retries; i++) {
808 if (eeprom_read(adapter, addr, buf, len) == len) {
809 if (calc_lrc(buf, len - 1) == buf[len - 1])
810 return 1;
811 }
812 }
813
814 return 0;
815}
816
817/*
818static int eeprom_lrc_write(struct adapter *adapter, u32 addr, u32 len, u8 *wbuf, u8 *rbuf, int retries)
819{
820 int i;
821
822 for (i = 0; i < retries; i++) {
823 if (eeprom_write(adapter, addr, wbuf, len) == len) {
824 if (eeprom_lrc_read(adapter, addr, len, rbuf, retries) == 1)
825 return 1;
826 }
827 }
828
829 return 0;
830}
831*/
832
833
834/* These functions could be used to unlock SkyStar2 cards. */
835
836/*
837static int eeprom_writeKey(struct adapter *adapter, u8 *key, u32 len)
838{
839 u8 rbuf[20];
840 u8 wbuf[20];
841
842 if (len != 16)
843 return 0;
844
845 memcpy(wbuf, key, len);
846
847 wbuf[16] = 0;
848 wbuf[17] = 0;
849 wbuf[18] = 0;
850 wbuf[19] = calc_lrc(wbuf, 19);
851
852 return eeprom_lrc_write(adapter, 0x3e4, 20, wbuf, rbuf, 4);
853}
854
855static int eeprom_readKey(struct adapter *adapter, u8 *key, u32 len)
856{
857 u8 buf[20];
858
859 if (len != 16)
860 return 0;
861
862 if (eeprom_lrc_read(adapter, 0x3e4, 20, buf, 4) == 0)
863 return 0;
864
865 memcpy(key, buf, len);
866
867 return 1;
868}
869*/
870
871static int eeprom_get_mac_addr(struct adapter *adapter, char type, u8 *mac)
872{
873 u8 tmp[8];
874
875 if (eeprom_lrc_read(adapter, 0x3f8, 8, tmp, 4) != 0) {
876 if (type != 0) {
877 mac[0] = tmp[0];
878 mac[1] = tmp[1];
879 mac[2] = tmp[2];
880 mac[3] = 0xfe;
881 mac[4] = 0xff;
882 mac[5] = tmp[3];
883 mac[6] = tmp[4];
884 mac[7] = tmp[5];
885
886 } else {
887
888 mac[0] = tmp[0];
889 mac[1] = tmp[1];
890 mac[2] = tmp[2];
891 mac[3] = tmp[3];
892 mac[4] = tmp[4];
893 mac[5] = tmp[5];
894 }
895
896 return 1;
897
898 } else {
899
900 if (type == 0) {
901 memset(mac, 0, 6);
902
903 } else {
904
905 memset(mac, 0, 8);
906 }
907
908 return 0;
909 }
910}
911
912/*
913static char eeprom_set_mac_addr(struct adapter *adapter, char type, u8 *mac)
914{
915 u8 tmp[8];
916
917 if (type != 0) {
918 tmp[0] = mac[0];
919 tmp[1] = mac[1];
920 tmp[2] = mac[2];
921 tmp[3] = mac[5];
922 tmp[4] = mac[6];
923 tmp[5] = mac[7];
924
925 } else {
926
927 tmp[0] = mac[0];
928 tmp[1] = mac[1];
929 tmp[2] = mac[2];
930 tmp[3] = mac[3];
931 tmp[4] = mac[4];
932 tmp[5] = mac[5];
933 }
934
935 tmp[6] = 0;
936 tmp[7] = calc_lrc(tmp, 7);
937
938 if (eeprom_write(adapter, 0x3f8, tmp, 8) == 8)
939 return 1;
940
941 return 0;
942}
943*/
944
945/* PID filter */
946
947/* every flexcop has 6 "lower" hw PID filters */
948/* these are enabled by setting bits 0-5 of 0x208 */
949/* for the 32 additional filters we have to select one */
950/* of them through 0x310 and modify through 0x314 */
951/* op: 0=disable, 1=enable */
952static void filter_enable_hw_filter(struct adapter *adapter, int id, u8 op)
953{
954 dprintk("%s: id=%d op=%d\n", __FUNCTION__, id, op);
955 if (id <= 5) {
956 u32 mask = (0x00000001 << id);
957 write_reg_bitfield(adapter, 0x208, mask, op ? mask : 0);
958 } else {
959 /* select */
960 write_reg_bitfield(adapter, 0x310, 0x1f, (id - 6) & 0x1f);
961 /* modify */
962 write_reg_bitfield(adapter, 0x314, 0x00006000, op ? 0x00004000 : 0);
963 }
964}
965
966/* this sets the PID that should pass the specified filter */
967static void pid_set_hw_pid(struct adapter *adapter, int id, u16 pid)
968{
969 dprintk("%s: id=%d pid=%d\n", __FUNCTION__, id, pid);
970 if (id <= 5) {
971 u32 adr = 0x300 + ((id & 6) << 1);
972 int shift = (id & 1) ? 16 : 0;
973 dprintk("%s: id=%d addr=%x %c pid=%d\n", __FUNCTION__, id, adr, (id & 1) ? 'h' : 'l', pid);
974 write_reg_bitfield(adapter, adr, (0x7fff) << shift, (pid & 0x1fff) << shift);
975 } else {
976 /* select */
977 write_reg_bitfield(adapter, 0x310, 0x1f, (id - 6) & 0x1f);
978 /* modify */
979 write_reg_bitfield(adapter, 0x314, 0x1fff, pid & 0x1fff);
980 }
981}
982
983
984/*
985static void filter_enable_null_filter(struct adapter *adapter, u32 op)
986{
987 dprintk("%s: op=%x\n", __FUNCTION__, op);
988
989 write_reg_bitfield(adapter, 0x208, 0x00000040, op?0x00000040:0);
990}
991*/
992
993static void filter_enable_mask_filter(struct adapter *adapter, u32 op)
994{
995 dprintk("%s: op=%x\n", __FUNCTION__, op);
996
997 write_reg_bitfield(adapter, 0x208, 0x00000080, op ? 0x00000080 : 0);
998}
999
1000
1001static void ctrl_enable_mac(struct adapter *adapter, u32 op)
1002{
1003 write_reg_bitfield(adapter, 0x208, 0x00004000, op ? 0x00004000 : 0);
1004}
1005
1006static int ca_set_mac_dst_addr_filter(struct adapter *adapter, u8 *mac)
1007{
1008 u32 tmp1, tmp2;
1009
1010 tmp1 = (mac[3] << 0x18) | (mac[2] << 0x10) | (mac[1] << 0x08) | mac[0];
1011 tmp2 = (mac[5] << 0x08) | mac[4];
1012
1013 write_reg_dw(adapter, 0x418, tmp1);
1014 write_reg_dw(adapter, 0x41c, tmp2);
1015
1016 return 0;
1017}
1018
1019/*
1020static void set_ignore_mac_filter(struct adapter *adapter, u8 op)
1021{
1022 if (op != 0) {
1023 write_reg_bitfield(adapter, 0x208, 0x00004000, 0);
1024 adapter->mac_filter = 1;
1025 } else {
1026 if (adapter->mac_filter != 0) {
1027 adapter->mac_filter = 0;
1028 write_reg_bitfield(adapter, 0x208, 0x00004000, 0x00004000);
1029 }
1030 }
1031}
1032*/
1033
1034/*
1035static void check_null_filter_enable(struct adapter *adapter)
1036{
1037 filter_enable_null_filter(adapter, 1);
1038 filter_enable_mask_filter(adapter, 1);
1039}
1040*/
1041
1042static void pid_set_group_pid(struct adapter *adapter, u16 pid)
1043{
1044 u32 value;
1045
1046 dprintk("%s: pid=%x\n", __FUNCTION__, pid);
1047 value = (pid & 0x3fff) | (read_reg_dw(adapter, 0x30c) & 0xffff0000);
1048 write_reg_dw(adapter, 0x30c, value);
1049}
1050
1051static void pid_set_group_mask(struct adapter *adapter, u16 pid)
1052{
1053 u32 value;
1054
1055 dprintk("%s: pid=%x\n", __FUNCTION__, pid);
1056 value = ((pid & 0x3fff) << 0x10) | (read_reg_dw(adapter, 0x30c) & 0xffff);
1057 write_reg_dw(adapter, 0x30c, value);
1058}
1059
1060/*
1061static int pid_get_group_pid(struct adapter *adapter)
1062{
1063 return read_reg_dw(adapter, 0x30c) & 0x00001fff;
1064}
1065
1066static int pid_get_group_mask(struct adapter *adapter)
1067{
1068 return (read_reg_dw(adapter, 0x30c) >> 0x10)& 0x00001fff;
1069}
1070*/
1071
1072/*
1073static void reset_hardware_pid_filter(struct adapter *adapter)
1074{
1075 pid_set_stream1_pid(adapter, 0x1fff);
1076
1077 pid_set_stream2_pid(adapter, 0x1fff);
1078 filter_enable_stream2_filter(adapter, 0);
1079
1080 pid_set_pcr_pid(adapter, 0x1fff);
1081 filter_enable_pcr_filter(adapter, 0);
1082
1083 pid_set_pmt_pid(adapter, 0x1fff);
1084 filter_enable_pmt_filter(adapter, 0);
1085
1086 pid_set_ecm_pid(adapter, 0x1fff);
1087 filter_enable_ecm_filter(adapter, 0);
1088
1089 pid_set_emm_pid(adapter, 0x1fff);
1090 filter_enable_emm_filter(adapter, 0);
1091}
1092*/
1093
1094static void init_pids(struct adapter *adapter)
1095{
1096 int i;
1097
1098 adapter->pid_count = 0;
1099 adapter->whole_bandwidth_count = 0;
1100 for (i = 0; i < adapter->useable_hw_filters; i++) {
1101 dprintk("%s: setting filter %d to 0x1fff\n", __FUNCTION__, i);
1102 adapter->hw_pids[i] = 0x1fff;
1103 pid_set_hw_pid(adapter, i, 0x1fff);
1104}
1105
1106 pid_set_group_pid(adapter, 0);
1107 pid_set_group_mask(adapter, 0x1fe0);
1108}
1109
1110static void open_whole_bandwidth(struct adapter *adapter)
1111{
1112 dprintk("%s:\n", __FUNCTION__);
1113 pid_set_group_pid(adapter, 0);
1114 pid_set_group_mask(adapter, 0);
1115/*
1116 filter_enable_mask_filter(adapter, 1);
1117*/
1118}
1119
1120static void close_whole_bandwidth(struct adapter *adapter)
1121{
1122 dprintk("%s:\n", __FUNCTION__);
1123 pid_set_group_pid(adapter, 0);
1124 pid_set_group_mask(adapter, 0x1fe0);
1125/*
1126 filter_enable_mask_filter(adapter, 1);
1127*/
1128}
1129
1130static void whole_bandwidth_inc(struct adapter *adapter)
1131{
1132 if (adapter->whole_bandwidth_count++ == 0)
1133 open_whole_bandwidth(adapter);
1134}
1135
1136static void whole_bandwidth_dec(struct adapter *adapter)
1137{
1138 if (--adapter->whole_bandwidth_count <= 0)
1139 close_whole_bandwidth(adapter);
1140}
1141
1142/* The specified PID has to be let through the
1143 hw filters.
1144 We try to allocate an hardware filter and open whole
1145 bandwidth when allocation is impossible.
1146 All pids<=0x1f pass through the group filter.
1147 Returns 1 on success, -1 on error */
1148static int add_hw_pid(struct adapter *adapter, u16 pid)
1149{
1150 int i;
1151
1152 dprintk("%s: pid=%d\n", __FUNCTION__, pid);
1153
1154 if (pid <= 0x1f)
1155 return 1;
1156
1157 /* we can't use a filter for 0x2000, so no search */
1158 if (pid != 0x2000) {
1159 /* find an unused hardware filter */
1160 for (i = 0; i < adapter->useable_hw_filters; i++) {
1161 dprintk("%s: pid=%d searching slot=%d\n", __FUNCTION__, pid, i);
1162 if (adapter->hw_pids[i] == 0x1fff) {
1163 dprintk("%s: pid=%d slot=%d\n", __FUNCTION__, pid, i);
1164 adapter->hw_pids[i] = pid;
1165 pid_set_hw_pid(adapter, i, pid);
1166 filter_enable_hw_filter(adapter, i, 1);
1167 return 1;
1168 }
1169 }
1170 }
1171 /* if we have not used a filter, this pid depends on whole bandwidth */
1172 dprintk("%s: pid=%d whole_bandwidth\n", __FUNCTION__, pid);
1173 whole_bandwidth_inc(adapter);
1174 return 1;
1175 }
1176
1177/* returns -1 if the pid was not present in the filters */
1178static int remove_hw_pid(struct adapter *adapter, u16 pid)
1179{
1180 int i;
1181
1182 dprintk("%s: pid=%d\n", __FUNCTION__, pid);
1183
1184 if (pid <= 0x1f)
1185 return 1;
1186
1187 /* we can't use a filter for 0x2000, so no search */
1188 if (pid != 0x2000) {
1189 for (i = 0; i < adapter->useable_hw_filters; i++) {
1190 dprintk("%s: pid=%d searching slot=%d\n", __FUNCTION__, pid, i);
1191 if (adapter->hw_pids[i] == pid) { // find the pid slot
1192 dprintk("%s: pid=%d slot=%d\n", __FUNCTION__, pid, i);
1193 adapter->hw_pids[i] = 0x1fff;
1194 pid_set_hw_pid(adapter, i, 0x1fff);
1195 filter_enable_hw_filter(adapter, i, 0);
1196 return 1;
1197 }
1198 }
1199 }
1200 /* if we have not used a filter, this pid depended on whole bandwith */
1201 dprintk("%s: pid=%d whole_bandwidth\n", __FUNCTION__, pid);
1202 whole_bandwidth_dec(adapter);
1203 return 1;
1204 }
1205
1206/* Adds a PID to the filters.
1207 Adding a pid more than once is possible, we keep reference counts.
1208 Whole stream available through pid==0x2000.
1209 Returns 1 on success, -1 on error */
1210static int add_pid(struct adapter *adapter, u16 pid)
1211{
1212 int i;
1213
1214 dprintk("%s: pid=%d\n", __FUNCTION__, pid);
1215
1216 if (pid > 0x1ffe && pid != 0x2000)
1217 return -1;
1218
1219 // check if the pid is already present
1220 for (i = 0; i < adapter->pid_count; i++)
1221 if (adapter->pid_list[i] == pid) {
1222 adapter->pid_rc[i]++; // increment ref counter
1223 return 1;
1224 }
1225
1226 if (adapter->pid_count == N_PID_SLOTS)
1227 return -1; // no more pids can be added
1228 adapter->pid_list[adapter->pid_count] = pid; // register pid
1229 adapter->pid_rc[adapter->pid_count] = 1;
1230 adapter->pid_count++;
1231 // hardware setting
1232 add_hw_pid(adapter, pid);
1233
1234 return 1;
1235 }
1236
1237/* Removes a PID from the filters. */
1238static int remove_pid(struct adapter *adapter, u16 pid)
1239{
1240 int i;
1241
1242 dprintk("%s: pid=%d\n", __FUNCTION__, pid);
1243
1244 if (pid > 0x1ffe && pid != 0x2000)
1245 return -1;
1246
1247 // check if the pid is present (it must be!)
1248 for (i = 0; i < adapter->pid_count; i++) {
1249 if (adapter->pid_list[i] == pid) {
1250 adapter->pid_rc[i]--;
1251 if (adapter->pid_rc[i] <= 0) {
1252 // remove from the list
1253 adapter->pid_count--;
1254 adapter->pid_list[i]=adapter->pid_list[adapter->pid_count];
1255 adapter->pid_rc[i] = adapter->pid_rc[adapter->pid_count];
1256 // hardware setting
1257 remove_hw_pid(adapter, pid);
1258 }
1259 return 1;
1260 }
1261 }
1262
1263 return -1;
1264}
1265
1266
1267/* dma & irq */
1268static void ctrl_enable_smc(struct adapter *adapter, u32 op)
1269{
1270 write_reg_bitfield(adapter, 0x208, 0x00000800, op ? 0x00000800 : 0);
1271}
1272
1273static void dma_enable_disable_irq(struct adapter *adapter, u32 flag1, u32 flag2, u32 flag3)
1274{
1275 adapter->dma_ctrl = adapter->dma_ctrl & 0x000f0000;
1276
1277 if (flag1 == 0) {
1278 if (flag2 == 0)
1279 adapter->dma_ctrl = adapter->dma_ctrl & ~0x00010000;
1280 else
1281 adapter->dma_ctrl = adapter->dma_ctrl | 0x00010000;
1282
1283 if (flag3 == 0)
1284 adapter->dma_ctrl = adapter->dma_ctrl & ~0x00020000;
1285 else
1286 adapter->dma_ctrl = adapter->dma_ctrl | 0x00020000;
1287
1288 } else {
1289
1290 if (flag2 == 0)
1291 adapter->dma_ctrl = adapter->dma_ctrl & ~0x00040000;
1292 else
1293 adapter->dma_ctrl = adapter->dma_ctrl | 0x00040000;
1294
1295 if (flag3 == 0)
1296 adapter->dma_ctrl = adapter->dma_ctrl & ~0x00080000;
1297 else
1298 adapter->dma_ctrl = adapter->dma_ctrl | 0x00080000;
1299 }
1300}
1301
1302static void irq_dma_enable_disable_irq(struct adapter *adapter, u32 op)
1303{
1304 u32 value;
1305
1306 value = read_reg_dw(adapter, 0x208) & 0xfff0ffff;
1307
1308 if (op != 0)
1309 value = value | (adapter->dma_ctrl & 0x000f0000);
1310
1311 write_reg_dw(adapter, 0x208, value);
1312}
1313
1314/* FlexCopII has 2 dma channels. DMA1 is used to transfer TS data to
1315 system memory.
1316
1317 The DMA1 buffer is divided in 2 subbuffers of equal size.
1318 FlexCopII will transfer TS data to one subbuffer, signal an interrupt
1319 when the subbuffer is full and continue fillig the second subbuffer.
1320
1321 For DMA1:
1322 subbuffer size in 32-bit words is stored in the first 24 bits of
1323 register 0x004. The last 8 bits of register 0x004 contain the number
1324 of subbuffers.
1325
1326 the first 30 bits of register 0x000 contain the address of the first
1327 subbuffer. The last 2 bits contain 0, when dma1 is disabled and 1,
1328 when dma1 is enabled.
1329
1330 the first 30 bits of register 0x00c contain the address of the second
1331 subbuffer. the last 2 bits contain 1.
1332
1333 register 0x008 will contain the address of the subbuffer that was filled
1334 with TS data, when FlexCopII will generate an interrupt.
1335
1336 For DMA2:
1337 subbuffer size in 32-bit words is stored in the first 24 bits of
1338 register 0x014. The last 8 bits of register 0x014 contain the number
1339 of subbuffers.
1340
1341 the first 30 bits of register 0x010 contain the address of the first
1342 subbuffer. The last 2 bits contain 0, when dma1 is disabled and 1,
1343 when dma1 is enabled.
1344
1345 the first 30 bits of register 0x01c contain the address of the second
1346 subbuffer. the last 2 bits contain 1.
1347
1348 register 0x018 contains the address of the subbuffer that was filled
1349 with TS data, when FlexCopII generates an interrupt.
1350*/
1351static int dma_init_dma(struct adapter *adapter, u32 dma_channel)
1352{
1353 u32 subbuffers, subbufsize, subbuf0, subbuf1;
1354
1355 if (dma_channel == 0) {
1356 dprintk("%s: Initializing DMA1 channel\n", __FUNCTION__);
1357
1358 subbuffers = 2;
1359
1360 subbufsize = (((adapter->dmaq1.buffer_size / 2) / 4) << 8) | subbuffers;
1361
1362 subbuf0 = adapter->dmaq1.bus_addr & 0xfffffffc;
1363
1364 subbuf1 = ((adapter->dmaq1.bus_addr + adapter->dmaq1.buffer_size / 2) & 0xfffffffc) | 1;
1365
1366 dprintk("%s: first subbuffer address = 0x%x\n", __FUNCTION__, subbuf0);
1367 udelay(1000);
1368 write_reg_dw(adapter, 0x000, subbuf0);
1369
1370 dprintk("%s: subbuffer size = 0x%x\n", __FUNCTION__, (subbufsize >> 8) * 4);
1371 udelay(1000);
1372 write_reg_dw(adapter, 0x004, subbufsize);
1373
1374 dprintk("%s: second subbuffer address = 0x%x\n", __FUNCTION__, subbuf1);
1375 udelay(1000);
1376 write_reg_dw(adapter, 0x00c, subbuf1);
1377
1378 dprintk("%s: counter = 0x%x\n", __FUNCTION__, adapter->dmaq1.bus_addr & 0xfffffffc);
1379 write_reg_dw(adapter, 0x008, adapter->dmaq1.bus_addr & 0xfffffffc);
1380 udelay(1000);
1381
1382 dma_enable_disable_irq(adapter, 0, 1, subbuffers ? 1 : 0);
1383
1384 irq_dma_enable_disable_irq(adapter, 1);
1385
1386 sram_set_media_dest(adapter, 1);
1387 sram_set_net_dest(adapter, 1);
1388 sram_set_cai_dest(adapter, 2);
1389 sram_set_cao_dest(adapter, 2);
1390 }
1391
1392 if (dma_channel == 1) {
1393 dprintk("%s: Initializing DMA2 channel\n", __FUNCTION__);
1394
1395 subbuffers = 2;
1396
1397 subbufsize = (((adapter->dmaq2.buffer_size / 2) / 4) << 8) | subbuffers;
1398
1399 subbuf0 = adapter->dmaq2.bus_addr & 0xfffffffc;
1400
1401 subbuf1 = ((adapter->dmaq2.bus_addr + adapter->dmaq2.buffer_size / 2) & 0xfffffffc) | 1;
1402
1403 dprintk("%s: first subbuffer address = 0x%x\n", __FUNCTION__, subbuf0);
1404 udelay(1000);
1405 write_reg_dw(adapter, 0x010, subbuf0);
1406
1407 dprintk("%s: subbuffer size = 0x%x\n", __FUNCTION__, (subbufsize >> 8) * 4);
1408 udelay(1000);
1409 write_reg_dw(adapter, 0x014, subbufsize);
1410
1411 dprintk("%s: second buffer address = 0x%x\n", __FUNCTION__, subbuf1);
1412 udelay(1000);
1413 write_reg_dw(adapter, 0x01c, subbuf1);
1414
1415 sram_set_cai_dest(adapter, 2);
1416 }
1417
1418 return 0;
1419}
1420
1421static void ctrl_enable_receive_data(struct adapter *adapter, u32 op)
1422{
1423 if (op == 0) {
1424 write_reg_bitfield(adapter, 0x208, 0x00008000, 0);
1425 adapter->dma_status = adapter->dma_status & ~0x00000004;
1426 } else {
1427 write_reg_bitfield(adapter, 0x208, 0x00008000, 0x00008000);
1428 adapter->dma_status = adapter->dma_status | 0x00000004;
1429 }
1430}
1431
1432/* bit 0 of dma_mask is set to 1 if dma1 channel has to be enabled/disabled
1433 bit 1 of dma_mask is set to 1 if dma2 channel has to be enabled/disabled
1434*/
1435static void dma_start_stop(struct adapter *adapter, u32 dma_mask, int start_stop)
1436{
1437 u32 dma_enable, dma1_enable, dma2_enable;
1438
1439 dprintk("%s: dma_mask=%x\n", __FUNCTION__, dma_mask);
1440
1441 if (start_stop == 1) {
1442 dprintk("%s: starting dma\n", __FUNCTION__);
1443
1444 dma1_enable = 0;
1445 dma2_enable = 0;
1446
1447 if (((dma_mask & 1) != 0) && ((adapter->dma_status & 1) == 0) && (adapter->dmaq1.bus_addr != 0)) {
1448 adapter->dma_status = adapter->dma_status | 1;
1449 dma1_enable = 1;
1450 }
1451
1452 if (((dma_mask & 2) != 0) && ((adapter->dma_status & 2) == 0) && (adapter->dmaq2.bus_addr != 0)) {
1453 adapter->dma_status = adapter->dma_status | 2;
1454 dma2_enable = 1;
1455 }
1456 // enable dma1 and dma2
1457 if ((dma1_enable == 1) && (dma2_enable == 1)) {
1458 write_reg_dw(adapter, 0x000, adapter->dmaq1.bus_addr | 1);
1459 write_reg_dw(adapter, 0x00c, (adapter->dmaq1.bus_addr + adapter->dmaq1.buffer_size / 2) | 1);
1460 write_reg_dw(adapter, 0x010, adapter->dmaq2.bus_addr | 1);
1461
1462 ctrl_enable_receive_data(adapter, 1);
1463
1464 return;
1465 }
1466 // enable dma1
1467 if ((dma1_enable == 1) && (dma2_enable == 0)) {
1468 write_reg_dw(adapter, 0x000, adapter->dmaq1.bus_addr | 1);
1469 write_reg_dw(adapter, 0x00c, (adapter->dmaq1.bus_addr + adapter->dmaq1.buffer_size / 2) | 1);
1470
1471 ctrl_enable_receive_data(adapter, 1);
1472
1473 return;
1474 }
1475 // enable dma2
1476 if ((dma1_enable == 0) && (dma2_enable == 1)) {
1477 write_reg_dw(adapter, 0x010, adapter->dmaq2.bus_addr | 1);
1478
1479 ctrl_enable_receive_data(adapter, 1);
1480
1481 return;
1482 }
1483 // start dma
1484 if ((dma1_enable == 0) && (dma2_enable == 0)) {
1485 ctrl_enable_receive_data(adapter, 1);
1486
1487 return;
1488 }
1489
1490 } else {
1491
1492 dprintk("%s: stopping dma\n", __FUNCTION__);
1493
1494 dma_enable = adapter->dma_status & 0x00000003;
1495
1496 if (((dma_mask & 1) != 0) && ((adapter->dma_status & 1) != 0)) {
1497 dma_enable = dma_enable & 0xfffffffe;
1498 }
1499
1500 if (((dma_mask & 2) != 0) && ((adapter->dma_status & 2) != 0)) {
1501 dma_enable = dma_enable & 0xfffffffd;
1502 }
1503 //stop dma
1504 if ((dma_enable == 0) && ((adapter->dma_status & 4) != 0)) {
1505 ctrl_enable_receive_data(adapter, 0);
1506
1507 udelay(3000);
1508 }
1509 //disable dma1
1510 if (((dma_mask & 1) != 0) && ((adapter->dma_status & 1) != 0) && (adapter->dmaq1.bus_addr != 0)) {
1511 write_reg_dw(adapter, 0x000, adapter->dmaq1.bus_addr);
1512 write_reg_dw(adapter, 0x00c, (adapter->dmaq1.bus_addr + adapter->dmaq1.buffer_size / 2) | 1);
1513
1514 adapter->dma_status = adapter->dma_status & ~0x00000001;
1515 }
1516 //disable dma2
1517 if (((dma_mask & 2) != 0) && ((adapter->dma_status & 2) != 0) && (adapter->dmaq2.bus_addr != 0)) {
1518 write_reg_dw(adapter, 0x010, adapter->dmaq2.bus_addr);
1519
1520 adapter->dma_status = adapter->dma_status & ~0x00000002;
1521 }
1522 }
1523}
1524
1525static void open_stream(struct adapter *adapter, u16 pid)
1526{
1527 u32 dma_mask;
1528
1529 ++adapter->capturing;
1530
1531 filter_enable_mask_filter(adapter, 1);
1532
1533 add_pid(adapter, pid);
1534
1535 dprintk("%s: adapter->dma_status=%x\n", __FUNCTION__, adapter->dma_status);
1536
1537 if ((adapter->dma_status & 7) != 7) {
1538 dma_mask = 0;
1539
1540 if (((adapter->dma_status & 0x10000000) != 0) && ((adapter->dma_status & 1) == 0)) {
1541 dma_mask = dma_mask | 1;
1542
1543 adapter->dmaq1.head = 0;
1544 adapter->dmaq1.tail = 0;
1545
1546 memset(adapter->dmaq1.buffer, 0, adapter->dmaq1.buffer_size);
1547 }
1548
1549 if (((adapter->dma_status & 0x20000000) != 0) && ((adapter->dma_status & 2) == 0)) {
1550 dma_mask = dma_mask | 2;
1551
1552 adapter->dmaq2.head = 0;
1553 adapter->dmaq2.tail = 0;
1554 }
1555
1556 if (dma_mask != 0) {
1557 irq_dma_enable_disable_irq(adapter, 1);
1558
1559 dma_start_stop(adapter, dma_mask, 1);
1560 }
1561 }
1562}
1563
1564static void close_stream(struct adapter *adapter, u16 pid)
1565{
1566 if (adapter->capturing > 0)
1567 --adapter->capturing;
1568
1569 dprintk("%s: dma_status=%x\n", __FUNCTION__, adapter->dma_status);
1570
1571 if (adapter->capturing == 0) {
1572 u32 dma_mask = 0;
1573
1574 if ((adapter->dma_status & 1) != 0)
1575 dma_mask = dma_mask | 0x00000001;
1576 if ((adapter->dma_status & 2) != 0)
1577 dma_mask = dma_mask | 0x00000002;
1578
1579 if (dma_mask != 0) {
1580 dma_start_stop(adapter, dma_mask, 0);
1581 }
1582 }
1583 remove_pid(adapter, pid);
1584}
1585
1586static void interrupt_service_dma1(struct adapter *adapter)
1587{
1588 struct dvb_demux *dvbdmx = &adapter->demux;
1589
1590 int n_cur_dma_counter;
1591 u32 n_num_bytes_parsed;
1592 u32 n_num_new_bytes_transferred;
1593 u32 dw_default_packet_size = 188;
1594 u8 gb_tmp_buffer[188];
1595 u8 *pb_dma_buf_cur_pos;
1596
1597 n_cur_dma_counter = readl(adapter->io_mem + 0x008) - adapter->dmaq1.bus_addr;
1598 n_cur_dma_counter = (n_cur_dma_counter / dw_default_packet_size) * dw_default_packet_size;
1599
1600 if ((n_cur_dma_counter < 0) || (n_cur_dma_counter > adapter->dmaq1.buffer_size)) {
1601 dprintk("%s: dma counter outside dma buffer\n", __FUNCTION__);
1602 return;
1603 }
1604
1605 adapter->dmaq1.head = n_cur_dma_counter;
1606
1607 if (adapter->dmaq1.tail <= n_cur_dma_counter) {
1608 n_num_new_bytes_transferred = n_cur_dma_counter - adapter->dmaq1.tail;
1609
1610 } else {
1611
1612 n_num_new_bytes_transferred = (adapter->dmaq1.buffer_size - adapter->dmaq1.tail) + n_cur_dma_counter;
1613 }
1614
1615 ddprintk("%s: n_cur_dma_counter = %d\n", __FUNCTION__, n_cur_dma_counter);
1616 ddprintk("%s: dmaq1.tail = %d\n", __FUNCTION__, adapter->dmaq1.tail);
1617 ddprintk("%s: bytes_transferred = %d\n", __FUNCTION__, n_num_new_bytes_transferred);
1618
1619 if (n_num_new_bytes_transferred < dw_default_packet_size)
1620 return;
1621
1622 n_num_bytes_parsed = 0;
1623
1624 while (n_num_bytes_parsed < n_num_new_bytes_transferred) {
1625 pb_dma_buf_cur_pos = adapter->dmaq1.buffer + adapter->dmaq1.tail;
1626
1627 if (adapter->dmaq1.buffer + adapter->dmaq1.buffer_size < adapter->dmaq1.buffer + adapter->dmaq1.tail + 188) {
1628 memcpy(gb_tmp_buffer, adapter->dmaq1.buffer + adapter->dmaq1.tail,
1629 adapter->dmaq1.buffer_size - adapter->dmaq1.tail);
1630 memcpy(gb_tmp_buffer + (adapter->dmaq1.buffer_size - adapter->dmaq1.tail), adapter->dmaq1.buffer,
1631 (188 - (adapter->dmaq1.buffer_size - adapter->dmaq1.tail)));
1632
1633 pb_dma_buf_cur_pos = gb_tmp_buffer;
1634 }
1635
1636 if (adapter->capturing != 0) {
1637 dvb_dmx_swfilter_packets(dvbdmx, pb_dma_buf_cur_pos, dw_default_packet_size / 188);
1638 }
1639
1640 n_num_bytes_parsed = n_num_bytes_parsed + dw_default_packet_size;
1641
1642 adapter->dmaq1.tail = adapter->dmaq1.tail + dw_default_packet_size;
1643
1644 if (adapter->dmaq1.tail >= adapter->dmaq1.buffer_size)
1645 adapter->dmaq1.tail = adapter->dmaq1.tail - adapter->dmaq1.buffer_size;
1646 };
1647}
1648
1649static void interrupt_service_dma2(struct adapter *adapter)
1650{
1651 printk("%s:\n", __FUNCTION__);
1652}
1653
1654static irqreturn_t isr(int irq, void *dev_id, struct pt_regs *regs)
1655{
1656 struct adapter *tmp = dev_id;
1657
1658 u32 value;
1659
1660 ddprintk("%s:\n", __FUNCTION__);
1661
1662 spin_lock_irq(&tmp->lock);
1663
1664 if (0 == ((value = read_reg_dw(tmp, 0x20c)) & 0x0f)) {
1665 spin_unlock_irq(&tmp->lock);
1666 return IRQ_NONE;
1667 }
1668
1669 while (value != 0) {
1670 if ((value & 0x03) != 0)
1671 interrupt_service_dma1(tmp);
1672 if ((value & 0x0c) != 0)
1673 interrupt_service_dma2(tmp);
1674 value = read_reg_dw(tmp, 0x20c) & 0x0f;
1675 }
1676
1677 spin_unlock_irq(&tmp->lock);
1678 return IRQ_HANDLED;
1679}
1680
1681static int init_dma_queue_one(struct adapter *adapter, struct dmaq *dmaq,
1682 int size, int dmaq_offset)
1683{
1684 struct pci_dev *pdev = adapter->pdev;
1685 dma_addr_t dma_addr;
1686
1687 dmaq->head = 0;
1688 dmaq->tail = 0;
1689
1690 dmaq->buffer = pci_alloc_consistent(pdev, size + 0x80, &dma_addr);
1691 if (!dmaq->buffer)
1692 return -ENOMEM;
1693
1694 dmaq->bus_addr = dma_addr;
1695 dmaq->buffer_size = size;
1696
1697 dma_init_dma(adapter, dmaq_offset);
1698
1699 ddprintk("%s: allocated dma buffer at 0x%p, length=%d\n",
1700 __FUNCTION__, dmaq->buffer, size);
1701
1702 return 0;
1703 }
1704
1705static int init_dma_queue(struct adapter *adapter)
1706{
1707 struct {
1708 struct dmaq *dmaq;
1709 u32 dma_status;
1710 int size;
1711 } dmaq_desc[] = {
1712 { &adapter->dmaq1, 0x10000000, SIZE_OF_BUF_DMA1 },
1713 { &adapter->dmaq2, 0x20000000, SIZE_OF_BUF_DMA2 }
1714 }, *p = dmaq_desc;
1715 int i;
1716
1717 for (i = 0; i < 2; i++, p++) {
1718 if (init_dma_queue_one(adapter, p->dmaq, p->size, i) < 0)
1719 adapter->dma_status &= ~p->dma_status;
1720 else
1721 adapter->dma_status |= p->dma_status;
1722 }
1723 return (adapter->dma_status & 0x30000000) ? 0 : -ENOMEM;
1724}
1725
1726static void free_dma_queue_one(struct adapter *adapter, struct dmaq *dmaq)
1727{
1728 if (dmaq->buffer) {
1729 pci_free_consistent(adapter->pdev, dmaq->buffer_size + 0x80,
1730 dmaq->buffer, dmaq->bus_addr);
1731 memset(dmaq, 0, sizeof(*dmaq));
1732 }
1733}
1734
1735static void free_dma_queue(struct adapter *adapter)
1736{
1737 struct dmaq *dmaq[] = {
1738 &adapter->dmaq1,
1739 &adapter->dmaq2,
1740 NULL
1741 }, **p;
1742
1743 for (p = dmaq; *p; p++)
1744 free_dma_queue_one(adapter, *p);
1745 }
1746
1747static void release_adapter(struct adapter *adapter)
1748{
1749 struct pci_dev *pdev = adapter->pdev;
1750
1751 iounmap(adapter->io_mem);
1752 pci_disable_device(pdev);
1753 pci_release_region(pdev, 0);
1754 pci_release_region(pdev, 1);
1755}
1756
1757static void free_adapter_object(struct adapter *adapter)
1758{
1759 dprintk("%s:\n", __FUNCTION__);
1760
1761 close_stream(adapter, 0);
1762 free_irq(adapter->irq, adapter);
1763 free_dma_queue(adapter);
1764 release_adapter(adapter);
1765 kfree(adapter);
1766}
1767
1768static struct pci_driver skystar2_pci_driver;
1769
1770static int claim_adapter(struct adapter *adapter)
1771{
1772 struct pci_dev *pdev = adapter->pdev;
1773 u16 var;
1774 int ret;
1775
1776 ret = pci_request_region(pdev, 1, skystar2_pci_driver.name);
1777 if (ret < 0)
1778 goto out;
1779
1780 ret = pci_request_region(pdev, 0, skystar2_pci_driver.name);
1781 if (ret < 0)
1782 goto err_pci_release_1;
1783
1784 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &adapter->card_revision);
1785
1786 dprintk("%s: card revision %x \n", __FUNCTION__, adapter->card_revision);
1787
1788 ret = pci_enable_device(pdev);
1789 if (ret < 0)
1790 goto err_pci_release_0;
1791
1792 pci_read_config_word(pdev, 4, &var);
1793
1794 if ((var & 4) == 0)
1795 pci_set_master(pdev);
1796
1797 adapter->io_port = pdev->resource[1].start;
1798
1799 adapter->io_mem = ioremap(pdev->resource[0].start, 0x800);
1800
1801 if (!adapter->io_mem) {
1802 dprintk("%s: can not map io memory\n", __FUNCTION__);
1803 ret = -EIO;
1804 goto err_pci_disable;
1805 }
1806
1807 dprintk("%s: io memory maped at %p\n", __FUNCTION__, adapter->io_mem);
1808
1809 ret = 1;
1810out:
1811 return ret;
1812
1813err_pci_disable:
1814 pci_disable_device(pdev);
1815err_pci_release_0:
1816 pci_release_region(pdev, 0);
1817err_pci_release_1:
1818 pci_release_region(pdev, 1);
1819 goto out;
1820}
1821
1822/*
1823static int sll_reset_flexcop(struct adapter *adapter)
1824{
1825 write_reg_dw(adapter, 0x208, 0);
1826 write_reg_dw(adapter, 0x210, 0xb2ff);
1827
1828 return 0;
1829}
1830*/
1831
1832static void decide_how_many_hw_filters(struct adapter *adapter)
1833{
1834 int hw_filters;
1835 int mod_option_hw_filters;
1836
1837 // FlexCop IIb & III have 6+32 hw filters
1838 // FlexCop II has 6 hw filters, every other should have at least 6
1839 switch (adapter->b2c2_revision) {
1840 case 0x82: /* II */
1841 hw_filters = 6;
1842 break;
1843 case 0xc3: /* IIB */
1844 hw_filters = 6 + 32;
1845 break;
1846 case 0xc0: /* III */
1847 hw_filters = 6 + 32;
1848 break;
1849 default:
1850 hw_filters = 6;
1851 break;
1852 }
1853 printk("%s: the chip has %i hardware filters", __FILE__, hw_filters);
1854
1855 mod_option_hw_filters = 0;
1856 if (enable_hw_filters >= 1)
1857 mod_option_hw_filters += 6;
1858 if (enable_hw_filters >= 2)
1859 mod_option_hw_filters += 32;
1860
1861 if (mod_option_hw_filters >= hw_filters) {
1862 adapter->useable_hw_filters = hw_filters;
1863 } else {
1864 adapter->useable_hw_filters = mod_option_hw_filters;
1865 printk(", but only %d will be used because of module option", mod_option_hw_filters);
1866 }
1867 printk("\n");
1868 dprintk("%s: useable_hardware_filters set to %i\n", __FILE__, adapter->useable_hw_filters);
1869}
1870
1871static int driver_initialize(struct pci_dev *pdev)
1872{
1873 struct adapter *adapter;
1874 u32 tmp;
1875 int ret = -ENOMEM;
1876
1877 adapter = kmalloc(sizeof(struct adapter), GFP_KERNEL);
1878 if (!adapter) {
1879 dprintk("%s: out of memory!\n", __FUNCTION__);
1880 goto out;
1881 }
1882
1883 memset(adapter, 0, sizeof(struct adapter));
1884
1885 pci_set_drvdata(pdev,adapter);
1886
1887 adapter->pdev = pdev;
1888 adapter->irq = pdev->irq;
1889
1890 ret = claim_adapter(adapter);
1891 if (ret < 0)
1892 goto err_kfree;
1893
1894 irq_dma_enable_disable_irq(adapter, 0);
1895
1896 ret = request_irq(pdev->irq, isr, 0x4000000, "Skystar2", adapter);
1897 if (ret < 0) {
1898 dprintk("%s: unable to allocate irq=%d !\n", __FUNCTION__, pdev->irq);
1899 goto err_release_adapter;
1900 }
1901
1902 read_reg_dw(adapter, 0x208);
1903 write_reg_dw(adapter, 0x208, 0);
1904 write_reg_dw(adapter, 0x210, 0xb2ff);
1905 write_reg_dw(adapter, 0x208, 0x40);
1906
1907 ret = init_dma_queue(adapter);
1908 if (ret < 0)
1909 goto err_free_irq;
1910
1911 adapter->b2c2_revision = (read_reg_dw(adapter, 0x204) >> 0x18);
1912
1913 switch (adapter->b2c2_revision) {
1914 case 0x82:
1915 printk("%s: FlexCopII(rev.130) chip found\n", __FILE__);
1916 break;
1917 case 0xc3:
1918 printk("%s: FlexCopIIB(rev.195) chip found\n", __FILE__);
1919 break;
1920 case 0xc0:
1921 printk("%s: FlexCopIII(rev.192) chip found\n", __FILE__);
1922 break;
1923 default:
1924 printk("%s: The revision of the FlexCop chip on your card is %d\n", __FILE__, adapter->b2c2_revision);
1925 printk("%s: This driver works only with FlexCopII(rev.130), FlexCopIIB(rev.195) and FlexCopIII(rev.192).\n", __FILE__);
1926 ret = -ENODEV;
1927 goto err_free_dma_queue;
1928 }
1929
1930 decide_how_many_hw_filters(adapter);
1931
1932 init_pids(adapter);
1933
1934 tmp = read_reg_dw(adapter, 0x204);
1935
1936 write_reg_dw(adapter, 0x204, 0);
1937 mdelay(20);
1938
1939 write_reg_dw(adapter, 0x204, tmp);
1940 mdelay(10);
1941
1942 tmp = read_reg_dw(adapter, 0x308);
1943 write_reg_dw(adapter, 0x308, 0x4000 | tmp);
1944
1945 adapter->dw_sram_type = 0x10000;
1946
1947 sll_detect_sram_size(adapter);
1948
1949 dprintk("%s sram length = %d, sram type= %x\n", __FUNCTION__, sram_length(adapter), adapter->dw_sram_type);
1950
1951 sram_set_media_dest(adapter, 1);
1952 sram_set_net_dest(adapter, 1);
1953
1954 ctrl_enable_smc(adapter, 0);
1955
1956 sram_set_cai_dest(adapter, 2);
1957 sram_set_cao_dest(adapter, 2);
1958
1959 dma_enable_disable_irq(adapter, 1, 0, 0);
1960
1961 if (eeprom_get_mac_addr(adapter, 0, adapter->mac_addr) != 0) {
1962 printk("%s MAC address = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x \n", __FUNCTION__, adapter->mac_addr[0],
1963 adapter->mac_addr[1], adapter->mac_addr[2], adapter->mac_addr[3], adapter->mac_addr[4], adapter->mac_addr[5],
1964 adapter->mac_addr[6], adapter->mac_addr[7]
1965 );
1966
1967 ca_set_mac_dst_addr_filter(adapter, adapter->mac_addr);
1968 ctrl_enable_mac(adapter, 1);
1969 }
1970
1971 spin_lock_init(&adapter->lock);
1972
1973out:
1974 return ret;
1975
1976err_free_dma_queue:
1977 free_dma_queue(adapter);
1978err_free_irq:
1979 free_irq(pdev->irq, adapter);
1980err_release_adapter:
1981 release_adapter(adapter);
1982err_kfree:
1983 pci_set_drvdata(pdev, NULL);
1984 kfree(adapter);
1985 goto out;
1986}
1987
1988static void driver_halt(struct pci_dev *pdev)
1989{
1990 struct adapter *adapter = pci_get_drvdata(pdev);
1991
1992 irq_dma_enable_disable_irq(adapter, 0);
1993
1994 ctrl_enable_receive_data(adapter, 0);
1995
1996 free_adapter_object(adapter);
1997
1998 pci_set_drvdata(pdev, NULL);
1999}
2000
2001static int dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
2002{
2003 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
2004 struct adapter *adapter = (struct adapter *) dvbdmx->priv;
2005
2006 dprintk("%s: PID=%d, type=%d\n", __FUNCTION__, dvbdmxfeed->pid, dvbdmxfeed->type);
2007
2008 open_stream(adapter, dvbdmxfeed->pid);
2009
2010 return 0;
2011}
2012
2013static int dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
2014{
2015 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
2016 struct adapter *adapter = (struct adapter *) dvbdmx->priv;
2017
2018 dprintk("%s: PID=%d, type=%d\n", __FUNCTION__, dvbdmxfeed->pid, dvbdmxfeed->type);
2019
2020 close_stream(adapter, dvbdmxfeed->pid);
2021
2022 return 0;
2023}
2024
2025/* lnb control */
2026static void set_tuner_tone(struct adapter *adapter, u8 tone)
2027{
2028 u16 wz_half_period_for_45_mhz[] = { 0x01ff, 0x0154, 0x00ff, 0x00cc };
2029 u16 ax;
2030
2031 dprintk("%s: %u\n", __FUNCTION__, tone);
2032
2033 switch (tone) {
2034 case 1:
2035 ax = wz_half_period_for_45_mhz[0];
2036 break;
2037 case 2:
2038 ax = wz_half_period_for_45_mhz[1];
2039 break;
2040 case 3:
2041 ax = wz_half_period_for_45_mhz[2];
2042 break;
2043 case 4:
2044 ax = wz_half_period_for_45_mhz[3];
2045 break;
2046
2047 default:
2048 ax = 0;
2049 }
2050
2051 if (ax != 0) {
2052 write_reg_dw(adapter, 0x200, ((ax << 0x0f) + (ax & 0x7fff)) | 0x40000000);
2053
2054 } else {
2055
2056 write_reg_dw(adapter, 0x200, 0x40ff8000);
2057 }
2058}
2059
2060static void set_tuner_polarity(struct adapter *adapter, u8 polarity)
2061{
2062 u32 var;
2063
2064 dprintk("%s : polarity = %u \n", __FUNCTION__, polarity);
2065
2066 var = read_reg_dw(adapter, 0x204);
2067
2068 if (polarity == 0) {
2069 dprintk("%s: LNB power off\n", __FUNCTION__);
2070 var = var | 1;
2071 };
2072
2073 if (polarity == 1) {
2074 var = var & ~1;
2075 var = var & ~4;
2076 };
2077
2078 if (polarity == 2) {
2079 var = var & ~1;
2080 var = var | 4;
2081 }
2082
2083 write_reg_dw(adapter, 0x204, var);
2084}
2085
2086static void diseqc_send_bit(struct adapter *adapter, int data)
2087{
2088 set_tuner_tone(adapter, 1);
2089 udelay(data ? 500 : 1000);
2090 set_tuner_tone(adapter, 0);
2091 udelay(data ? 1000 : 500);
2092}
2093
2094
2095static void diseqc_send_byte(struct adapter *adapter, int data)
2096 {
2097 int i, par = 1, d;
2098
2099 for (i = 7; i >= 0; i--) {
2100 d = (data >> i) & 1;
2101 par ^= d;
2102 diseqc_send_bit(adapter, d);
2103 }
2104
2105 diseqc_send_bit(adapter, par);
2106 }
2107
2108
2109static int send_diseqc_msg(struct adapter *adapter, int len, u8 *msg, unsigned long burst)
2110{
2111 int i;
2112
2113 set_tuner_tone(adapter, 0);
2114 mdelay(16);
2115
2116 for (i = 0; i < len; i++)
2117 diseqc_send_byte(adapter, msg[i]);
2118
2119 mdelay(16);
2120
2121 if (burst != -1) {
2122 if (burst)
2123 diseqc_send_byte(adapter, 0xff);
2124 else {
2125 set_tuner_tone(adapter, 1);
2126 udelay(12500);
2127 set_tuner_tone(adapter, 0);
2128 }
2129 msleep(20);
2130 }
2131
2132 return 0;
2133}
2134
2135static int flexcop_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
2136{
2137 struct adapter* adapter = (struct adapter*) fe->dvb->priv;
2138
2139 switch(tone) {
2140 case SEC_TONE_ON:
2141 set_tuner_tone(adapter, 1);
2142 break;
2143 case SEC_TONE_OFF:
2144 set_tuner_tone(adapter, 0);
2145 break;
2146 default:
2147 return -EINVAL;
2148 };
2149
2150 return 0;
2151}
2152
2153static int flexcop_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
2154 {
2155 struct adapter* adapter = (struct adapter*) fe->dvb->priv;
2156
2157 send_diseqc_msg(adapter, cmd->msg_len, cmd->msg, 0);
2158
2159 return 0;
2160 }
2161
2162static int flexcop_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
2163{
2164 struct adapter* adapter = (struct adapter*) fe->dvb->priv;
2165
2166 send_diseqc_msg(adapter, 0, NULL, minicmd);
2167
2168 return 0;
2169}
2170
2171static int flexcop_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
2172 {
2173 struct adapter* adapter = (struct adapter*) fe->dvb->priv;
2174
2175 dprintk("%s: FE_SET_VOLTAGE\n", __FUNCTION__);
2176
2177 switch (voltage) {
2178 case SEC_VOLTAGE_13:
2179 dprintk("%s: SEC_VOLTAGE_13, %x\n", __FUNCTION__, SEC_VOLTAGE_13);
2180 set_tuner_polarity(adapter, 1);
2181 return 0;
2182
2183 case SEC_VOLTAGE_18:
2184 dprintk("%s: SEC_VOLTAGE_18, %x\n", __FUNCTION__, SEC_VOLTAGE_18);
2185 set_tuner_polarity(adapter, 2);
2186 return 0;
2187
2188 default:
2189 return -EINVAL;
2190 }
2191 }
2192
2193static int flexcop_sleep(struct dvb_frontend* fe)
2194 {
2195 struct adapter* adapter = (struct adapter*) fe->dvb->priv;
2196
2197 dprintk("%s: FE_SLEEP\n", __FUNCTION__);
2198 set_tuner_polarity(adapter, 0);
2199
2200 if (adapter->fe_sleep) return adapter->fe_sleep(fe);
2201 return 0;
2202 }
2203
2204static u32 flexcop_i2c_func(struct i2c_adapter *adapter)
2205 {
2206 printk("flexcop_i2c_func\n");
2207
2208 return I2C_FUNC_I2C;
2209}
2210
2211static struct i2c_algorithm flexcop_algo = {
2212 .name = "flexcop i2c algorithm",
2213 .id = I2C_ALGO_BIT,
2214 .master_xfer = master_xfer,
2215 .functionality = flexcop_i2c_func,
2216};
2217
2218
2219
2220
2221static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
2222{
2223 u8 aclk = 0;
2224 u8 bclk = 0;
2225
2226 if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
2227 else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
2228 else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
2229 else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
2230 else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
2231 else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
2232
2233 stv0299_writereg (fe, 0x13, aclk);
2234 stv0299_writereg (fe, 0x14, bclk);
2235 stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
2236 stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
2237 stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
2238
2239 return 0;
2240}
2241
2242static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
2243{
2244 u8 buf[4];
2245 u32 div;
2246 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
2247 struct adapter* adapter = (struct adapter*) fe->dvb->priv;
2248
2249 div = params->frequency / 125;
2250
2251 buf[0] = (div >> 8) & 0x7f;
2252 buf[1] = div & 0xff;
2253 buf[2] = 0x84; // 0xC4
2254 buf[3] = 0x08;
2255
2256 if (params->frequency < 1500000) buf[3] |= 0x10;
2257
2258 if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
2259 return 0;
2260}
2261
2262static u8 samsung_tbmu24112_inittab[] = {
2263 0x01, 0x15,
2264 0x02, 0x30,
2265 0x03, 0x00,
2266 0x04, 0x7D,
2267 0x05, 0x35,
2268 0x06, 0x02,
2269 0x07, 0x00,
2270 0x08, 0xC3,
2271 0x0C, 0x00,
2272 0x0D, 0x81,
2273 0x0E, 0x23,
2274 0x0F, 0x12,
2275 0x10, 0x7E,
2276 0x11, 0x84,
2277 0x12, 0xB9,
2278 0x13, 0x88,
2279 0x14, 0x89,
2280 0x15, 0xC9,
2281 0x16, 0x00,
2282 0x17, 0x5C,
2283 0x18, 0x00,
2284 0x19, 0x00,
2285 0x1A, 0x00,
2286 0x1C, 0x00,
2287 0x1D, 0x00,
2288 0x1E, 0x00,
2289 0x1F, 0x3A,
2290 0x20, 0x2E,
2291 0x21, 0x80,
2292 0x22, 0xFF,
2293 0x23, 0xC1,
2294 0x28, 0x00,
2295 0x29, 0x1E,
2296 0x2A, 0x14,
2297 0x2B, 0x0F,
2298 0x2C, 0x09,
2299 0x2D, 0x05,
2300 0x31, 0x1F,
2301 0x32, 0x19,
2302 0x33, 0xFE,
2303 0x34, 0x93,
2304 0xff, 0xff,
2305 };
2306
2307static struct stv0299_config samsung_tbmu24112_config = {
2308 .demod_address = 0x68,
2309 .inittab = samsung_tbmu24112_inittab,
2310 .mclk = 88000000UL,
2311 .invert = 0,
2312 .enhanced_tuning = 0,
2313 .skip_reinit = 0,
2314 .lock_output = STV0229_LOCKOUTPUT_LK,
2315 .volt13_op0_op1 = STV0299_VOLT13_OP1,
2316 .min_delay_ms = 100,
2317 .set_symbol_rate = samsung_tbmu24112_set_symbol_rate,
2318 .pll_set = samsung_tbmu24112_pll_set,
2319};
2320
2321
2322
2323static int nxt2002_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
2324{
2325 struct adapter* adapter = (struct adapter*) fe->dvb->priv;
2326
2327 return request_firmware(fw, name, &adapter->pdev->dev);
2328}
2329
2330
2331static struct nxt2002_config samsung_tbmv_config = {
2332 .demod_address = 0x0A,
2333 .request_firmware = nxt2002_request_firmware,
2334};
2335
2336static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
2337{
2338 static u8 mt352_clock_config [] = { 0x89, 0x18, 0x2d };
2339 static u8 mt352_reset [] = { 0x50, 0x80 };
2340 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
2341 static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0xa1 };
2342 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
2343
2344 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
2345 udelay(2000);
2346 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
2347 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
2348
2349 mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
2350 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
2351
2352 return 0;
2353}
2354
2355static int samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
2356{
2357 u32 div;
2358 unsigned char bs = 0;
2359
2360 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
2361 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
2362
2363 if (params->frequency >= 48000000 && params->frequency <= 154000000) bs = 0x09;
2364 if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a;
2365 if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08;
2366
2367 pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
2368 pllbuf[1] = div >> 8;
2369 pllbuf[2] = div & 0xff;
2370 pllbuf[3] = 0xcc;
2371 pllbuf[4] = bs;
2372
2373 return 0;
2374}
2375
2376static struct mt352_config samsung_tdtc9251dh0_config = {
2377
2378 .demod_address = 0x0f,
2379 .demod_init = samsung_tdtc9251dh0_demod_init,
2380 .pll_set = samsung_tdtc9251dh0_pll_set,
2381};
2382
2383static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
2384{
2385 u8 buf[4];
2386 u32 div;
2387 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
2388 struct adapter* adapter = (struct adapter*) fe->dvb->priv;
2389
2390 div = (params->frequency + (125/2)) / 125;
2391
2392 buf[0] = (div >> 8) & 0x7f;
2393 buf[1] = (div >> 0) & 0xff;
2394 buf[2] = 0x84 | ((div >> 10) & 0x60);
2395 buf[3] = 0x80;
2396
2397 if (params->frequency < 1550000)
2398 buf[3] |= 0x02;
2399
2400 if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
2401 return 0;
2402}
2403
2404static struct mt312_config skystar23_samsung_tbdu18132_config = {
2405
2406 .demod_address = 0x0e,
2407 .pll_set = skystar23_samsung_tbdu18132_pll_set,
2408};
2409
2410
2411
2412
2413static void frontend_init(struct adapter *skystar2)
2414{
2415 switch(skystar2->pdev->device) {
2416 case 0x2103: // Technisat Skystar2 OR Technisat Airstar2 (DVB-T or ATSC)
2417
2418 // Attempt to load the Nextwave nxt2002 for ATSC support
2419 skystar2->fe = nxt2002_attach(&samsung_tbmv_config, &skystar2->i2c_adap);
2420 if (skystar2->fe != NULL) {
2421 skystar2->fe_sleep = skystar2->fe->ops->sleep;
2422 skystar2->fe->ops->sleep = flexcop_sleep;
2423 break;
2424 }
2425
2426 // try the skystar2 v2.6 first (stv0299/Samsung tbmu24112(sl1935))
2427 skystar2->fe = stv0299_attach(&samsung_tbmu24112_config, &skystar2->i2c_adap);
2428 if (skystar2->fe != NULL) {
2429 skystar2->fe->ops->set_voltage = flexcop_set_voltage;
2430 skystar2->fe_sleep = skystar2->fe->ops->sleep;
2431 skystar2->fe->ops->sleep = flexcop_sleep;
2432 break;
2433}
2434
2435 // try the airstar2 (mt352/Samsung tdtc9251dh0(??))
2436 skystar2->fe = mt352_attach(&samsung_tdtc9251dh0_config, &skystar2->i2c_adap);
2437 if (skystar2->fe != NULL) {
2438 skystar2->fe->ops->info.frequency_min = 474000000;
2439 skystar2->fe->ops->info.frequency_max = 858000000;
2440 break;
2441 }
2442
2443 // try the skystar2 v2.3 (vp310/Samsung tbdu18132(tsa5059))
2444 skystar2->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &skystar2->i2c_adap);
2445 if (skystar2->fe != NULL) {
2446 skystar2->fe->ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
2447 skystar2->fe->ops->diseqc_send_burst = flexcop_diseqc_send_burst;
2448 skystar2->fe->ops->set_tone = flexcop_set_tone;
2449 skystar2->fe->ops->set_voltage = flexcop_set_voltage;
2450 skystar2->fe_sleep = skystar2->fe->ops->sleep;
2451 skystar2->fe->ops->sleep = flexcop_sleep;
2452 break;
2453 }
2454 break;
2455 }
2456
2457 if (skystar2->fe == NULL) {
2458 printk("skystar2: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
2459 skystar2->pdev->vendor,
2460 skystar2->pdev->device,
2461 skystar2->pdev->subsystem_vendor,
2462 skystar2->pdev->subsystem_device);
2463 } else {
2464 if (dvb_register_frontend(&skystar2->dvb_adapter, skystar2->fe)) {
2465 printk("skystar2: Frontend registration failed!\n");
2466 if (skystar2->fe->ops->release)
2467 skystar2->fe->ops->release(skystar2->fe);
2468 skystar2->fe = NULL;
2469 }
2470 }
2471}
2472
2473
2474static int skystar2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2475{
2476 struct adapter *adapter;
2477 struct dvb_adapter *dvb_adapter;
2478 struct dvb_demux *dvbdemux;
2479 struct dmx_demux *dmx;
2480 int ret = -ENODEV;
2481
2482 if (!pdev)
2483 goto out;
2484
2485 ret = driver_initialize(pdev);
2486 if (ret < 0)
2487 goto out;
2488
2489 adapter = pci_get_drvdata(pdev);
2490 dvb_adapter = &adapter->dvb_adapter;
2491
2492 ret = dvb_register_adapter(dvb_adapter, skystar2_pci_driver.name,
2493 THIS_MODULE);
2494 if (ret < 0) {
2495 printk("%s: Error registering DVB adapter\n", __FUNCTION__);
2496 goto err_halt;
2497 }
2498
2499 dvb_adapter->priv = adapter;
2500
2501
2502 init_MUTEX(&adapter->i2c_sem);
2503
2504
2505 memset(&adapter->i2c_adap, 0, sizeof(struct i2c_adapter));
2506 strcpy(adapter->i2c_adap.name, "SkyStar2");
2507
2508 i2c_set_adapdata(&adapter->i2c_adap, adapter);
2509
2510#ifdef I2C_ADAP_CLASS_TV_DIGITAL
2511 adapter->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
2512#else
2513 adapter->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
2514#endif
2515 adapter->i2c_adap.algo = &flexcop_algo;
2516 adapter->i2c_adap.algo_data = NULL;
2517 adapter->i2c_adap.id = I2C_ALGO_BIT;
2518
2519 ret = i2c_add_adapter(&adapter->i2c_adap);
2520 if (ret < 0)
2521 goto err_dvb_unregister;
2522
2523 dvbdemux = &adapter->demux;
2524
2525 dvbdemux->priv = adapter;
2526 dvbdemux->filternum = N_PID_SLOTS;
2527 dvbdemux->feednum = N_PID_SLOTS;
2528 dvbdemux->start_feed = dvb_start_feed;
2529 dvbdemux->stop_feed = dvb_stop_feed;
2530 dvbdemux->write_to_decoder = NULL;
2531 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING);
2532
2533 ret = dvb_dmx_init(&adapter->demux);
2534 if (ret < 0)
2535 goto err_i2c_del;
2536
2537 dmx = &dvbdemux->dmx;
2538
2539 adapter->hw_frontend.source = DMX_FRONTEND_0;
2540 adapter->dmxdev.filternum = N_PID_SLOTS;
2541 adapter->dmxdev.demux = dmx;
2542 adapter->dmxdev.capabilities = 0;
2543
2544 ret = dvb_dmxdev_init(&adapter->dmxdev, &adapter->dvb_adapter);
2545 if (ret < 0)
2546 goto err_dmx_release;
2547
2548 ret = dmx->add_frontend(dmx, &adapter->hw_frontend);
2549 if (ret < 0)
2550 goto err_dmxdev_release;
2551
2552 adapter->mem_frontend.source = DMX_MEMORY_FE;
2553
2554 ret = dmx->add_frontend(dmx, &adapter->mem_frontend);
2555 if (ret < 0)
2556 goto err_remove_hw_frontend;
2557
2558 ret = dmx->connect_frontend(dmx, &adapter->hw_frontend);
2559 if (ret < 0)
2560 goto err_remove_mem_frontend;
2561
2562 dvb_net_init(&adapter->dvb_adapter, &adapter->dvbnet, &dvbdemux->dmx);
2563
2564 frontend_init(adapter);
2565out:
2566 return ret;
2567
2568err_remove_mem_frontend:
2569 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &adapter->mem_frontend);
2570err_remove_hw_frontend:
2571 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &adapter->hw_frontend);
2572err_dmxdev_release:
2573 dvb_dmxdev_release(&adapter->dmxdev);
2574err_dmx_release:
2575 dvb_dmx_release(&adapter->demux);
2576err_i2c_del:
2577 i2c_del_adapter(&adapter->i2c_adap);
2578err_dvb_unregister:
2579 dvb_unregister_adapter(&adapter->dvb_adapter);
2580err_halt:
2581 driver_halt(pdev);
2582 goto out;
2583}
2584
2585static void skystar2_remove(struct pci_dev *pdev)
2586{
2587 struct adapter *adapter = pci_get_drvdata(pdev);
2588 struct dvb_demux *dvbdemux;
2589 struct dmx_demux *dmx;
2590
2591 if (!adapter)
2592 return;
2593
2594 dvb_net_release(&adapter->dvbnet);
2595 dvbdemux = &adapter->demux;
2596 dmx = &dvbdemux->dmx;
2597
2598 dmx->close(dmx);
2599 dmx->remove_frontend(dmx, &adapter->hw_frontend);
2600 dmx->remove_frontend(dmx, &adapter->mem_frontend);
2601
2602 dvb_dmxdev_release(&adapter->dmxdev);
2603 dvb_dmx_release(dvbdemux);
2604
2605 if (adapter->fe != NULL)
2606 dvb_unregister_frontend(adapter->fe);
2607
2608 dvb_unregister_adapter(&adapter->dvb_adapter);
2609
2610 i2c_del_adapter(&adapter->i2c_adap);
2611
2612 driver_halt(pdev);
2613 }
2614
2615static struct pci_device_id skystar2_pci_tbl[] = {
2616 {0x000013d0, 0x00002103, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000},
2617/* {0x000013d0, 0x00002200, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000}, UNDEFINED HARDWARE - mail linuxtv.org list */ //FCIII
2618 {0,},
2619};
2620
2621MODULE_DEVICE_TABLE(pci, skystar2_pci_tbl);
2622
2623static struct pci_driver skystar2_pci_driver = {
2624 .name = "SkyStar2",
2625 .id_table = skystar2_pci_tbl,
2626 .probe = skystar2_probe,
2627 .remove = skystar2_remove,
2628};
2629
2630static int skystar2_init(void)
2631{
2632 return pci_register_driver(&skystar2_pci_driver);
2633}
2634
2635static void skystar2_cleanup(void)
2636{
2637 pci_unregister_driver(&skystar2_pci_driver);
2638}
2639
2640module_init(skystar2_init);
2641module_exit(skystar2_cleanup);
2642
2643MODULE_DESCRIPTION("Technisat SkyStar2 DVB PCI Driver");
2644MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 1339912c308b..07a0b0a968a6 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -258,10 +258,10 @@ int write_dst(struct dst_state *state, u8 *data, u8 len)
258 if (debug && (verbose > 4)) { 258 if (debug && (verbose > 4)) {
259 u8 i; 259 u8 i;
260 if (verbose > 4) { 260 if (verbose > 4) {
261 dprintk("%s writing", __FUNCTION__); 261 dprintk("%s writing [ ", __FUNCTION__);
262 for (i = 0; i < len; i++) 262 for (i = 0; i < len; i++)
263 dprintk(" %02x", data[i]); 263 dprintk("%02x ", data[i]);
264 dprintk("\n"); 264 dprintk("]\n");
265 } 265 }
266 } 266 }
267 for (cnt = 0; cnt < 2; cnt++) { 267 for (cnt = 0; cnt < 2; cnt++) {
@@ -320,10 +320,29 @@ int read_dst(struct dst_state *state, u8 * ret, u8 len)
320} 320}
321EXPORT_SYMBOL(read_dst); 321EXPORT_SYMBOL(read_dst);
322 322
323static int dst_set_freq(struct dst_state *state, u32 freq) 323static int dst_set_polarization(struct dst_state *state)
324{ 324{
325 u8 *val; 325 switch (state->voltage) {
326 case SEC_VOLTAGE_13: // vertical
327 printk("%s: Polarization=[Vertical]\n", __FUNCTION__);
328 state->tx_tuna[8] &= ~0x40; //1
329 break;
330
331 case SEC_VOLTAGE_18: // horizontal
332 printk("%s: Polarization=[Horizontal]\n", __FUNCTION__);
333 state->tx_tuna[8] |= 0x40; // 0
334 break;
335
336 case SEC_VOLTAGE_OFF:
337
338 break;
339 }
340
341 return 0;
342}
326 343
344static int dst_set_freq(struct dst_state *state, u32 freq)
345{
327 state->frequency = freq; 346 state->frequency = freq;
328 if (debug > 4) 347 if (debug > 4)
329 dprintk("%s: set Frequency %u\n", __FUNCTION__, freq); 348 dprintk("%s: set Frequency %u\n", __FUNCTION__, freq);
@@ -332,46 +351,30 @@ static int dst_set_freq(struct dst_state *state, u32 freq)
332 freq = freq / 1000; 351 freq = freq / 1000;
333 if (freq < 950 || freq > 2150) 352 if (freq < 950 || freq > 2150)
334 return -EINVAL; 353 return -EINVAL;
335 val = &state->tx_tuna[0]; 354
336 val[2] = (freq >> 8) & 0x7f; 355 state->tx_tuna[2] = (freq >> 8);
337 val[3] = (u8) freq; 356 state->tx_tuna[3] = (u8) freq;
338 val[4] = 1; 357 state->tx_tuna[4] = 0x01;
339 val[8] &= ~4; 358 state->tx_tuna[8] &= ~0x04;
340 if (freq < 1531) 359 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) {
341 val[8] |= 4; 360 if (freq < 1531)
361 state->tx_tuna[8] |= 0x04;
362 }
363
342 } else if (state->dst_type == DST_TYPE_IS_TERR) { 364 } else if (state->dst_type == DST_TYPE_IS_TERR) {
343 freq = freq / 1000; 365 freq = freq / 1000;
344 if (freq < 137000 || freq > 858000) 366 if (freq < 137000 || freq > 858000)
345 return -EINVAL; 367 return -EINVAL;
346 val = &state->tx_tuna[0];
347 val[2] = (freq >> 16) & 0xff;
348 val[3] = (freq >> 8) & 0xff;
349 val[4] = (u8) freq;
350 val[5] = 0;
351 switch (state->bandwidth) {
352 case BANDWIDTH_6_MHZ:
353 val[6] = 6;
354 break;
355 368
356 case BANDWIDTH_7_MHZ: 369 state->tx_tuna[2] = (freq >> 16) & 0xff;
357 case BANDWIDTH_AUTO: 370 state->tx_tuna[3] = (freq >> 8) & 0xff;
358 val[6] = 7; 371 state->tx_tuna[4] = (u8) freq;
359 break;
360 372
361 case BANDWIDTH_8_MHZ:
362 val[6] = 8;
363 break;
364 }
365
366 val[7] = 0;
367 val[8] = 0;
368 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 373 } else if (state->dst_type == DST_TYPE_IS_CABLE) {
369 /* guess till will get one */ 374 state->tx_tuna[2] = (freq >> 16) & 0xff;
370 freq = freq / 1000; 375 state->tx_tuna[3] = (freq >> 8) & 0xff;
371 val = &state->tx_tuna[0]; 376 state->tx_tuna[4] = (u8) freq;
372 val[2] = (freq >> 16) & 0xff; 377
373 val[3] = (freq >> 8) & 0xff;
374 val[4] = (u8) freq;
375 } else 378 } else
376 return -EINVAL; 379 return -EINVAL;
377 return 0; 380 return 0;
@@ -379,51 +382,58 @@ static int dst_set_freq(struct dst_state *state, u32 freq)
379 382
380static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) 383static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth)
381{ 384{
382 u8 *val;
383
384 state->bandwidth = bandwidth; 385 state->bandwidth = bandwidth;
385 386
386 if (state->dst_type != DST_TYPE_IS_TERR) 387 if (state->dst_type != DST_TYPE_IS_TERR)
387 return 0; 388 return 0;
388 389
389 val = &state->tx_tuna[0];
390 switch (bandwidth) { 390 switch (bandwidth) {
391 case BANDWIDTH_6_MHZ: 391 case BANDWIDTH_6_MHZ:
392 val[6] = 6; 392 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
393 break; 393 state->tx_tuna[7] = 0x06;
394 else {
395 state->tx_tuna[6] = 0x06;
396 state->tx_tuna[7] = 0x00;
397 }
398 break;
394 399
395 case BANDWIDTH_7_MHZ: 400 case BANDWIDTH_7_MHZ:
396 val[6] = 7; 401 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
397 break; 402 state->tx_tuna[7] = 0x07;
403 else {
404 state->tx_tuna[6] = 0x07;
405 state->tx_tuna[7] = 0x00;
406 }
407 break;
398 408
399 case BANDWIDTH_8_MHZ: 409 case BANDWIDTH_8_MHZ:
400 val[6] = 8; 410 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
401 break; 411 state->tx_tuna[7] = 0x08;
412 else {
413 state->tx_tuna[6] = 0x08;
414 state->tx_tuna[7] = 0x00;
415 }
416 break;
402 417
403 default: 418 default:
404 return -EINVAL; 419 return -EINVAL;
405 } 420 }
406 return 0; 421 return 0;
407} 422}
408 423
409static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion) 424static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion)
410{ 425{
411 u8 *val;
412
413 state->inversion = inversion; 426 state->inversion = inversion;
414
415 val = &state->tx_tuna[0];
416
417 val[8] &= ~0x80;
418
419 switch (inversion) { 427 switch (inversion) {
420 case INVERSION_OFF: 428 case INVERSION_OFF: // Inversion = Normal
421 break; 429 state->tx_tuna[8] &= ~0x80;
422 case INVERSION_ON: 430 break;
423 val[8] |= 0x80; 431
424 break; 432 case INVERSION_ON:
425 default: 433 state->tx_tuna[8] |= 0x80;
426 return -EINVAL; 434 break;
435 default:
436 return -EINVAL;
427 } 437 }
428 return 0; 438 return 0;
429} 439}
@@ -478,6 +488,52 @@ static int dst_set_symbolrate(struct dst_state* state, u32 srate)
478 return 0; 488 return 0;
479} 489}
480 490
491
492static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulation)
493{
494 if (state->dst_type != DST_TYPE_IS_CABLE)
495 return 0;
496
497 state->modulation = modulation;
498 switch (modulation) {
499 case QAM_16:
500 state->tx_tuna[8] = 0x10;
501 break;
502
503 case QAM_32:
504 state->tx_tuna[8] = 0x20;
505 break;
506
507 case QAM_64:
508 state->tx_tuna[8] = 0x40;
509 break;
510
511 case QAM_128:
512 state->tx_tuna[8] = 0x80;
513 break;
514
515 case QAM_256:
516 state->tx_tuna[8] = 0x00;
517 break;
518
519 case QPSK:
520 case QAM_AUTO:
521 case VSB_8:
522 case VSB_16:
523 default:
524 return -EINVAL;
525
526 }
527
528 return 0;
529}
530
531static fe_modulation_t dst_get_modulation(struct dst_state *state)
532{
533 return state->modulation;
534}
535
536
481u8 dst_check_sum(u8 * buf, u32 len) 537u8 dst_check_sum(u8 * buf, u32 len)
482{ 538{
483 u32 i; 539 u32 i;
@@ -577,7 +633,7 @@ struct dst_types dst_tlist[] = {
577 .device_id = "200103A", 633 .device_id = "200103A",
578 .offset = 0, 634 .offset = 0,
579 .dst_type = DST_TYPE_IS_SAT, 635 .dst_type = DST_TYPE_IS_SAT,
580 .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1, 636 .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1 | DST_TYPE_HAS_OBS_REGS,
581 .dst_feature = 0 637 .dst_feature = 0
582 }, /* obsolete */ 638 }, /* obsolete */
583 639
@@ -626,7 +682,7 @@ struct dst_types dst_tlist[] = {
626 .device_id = "DSTMCI", 682 .device_id = "DSTMCI",
627 .offset = 1, 683 .offset = 1,
628 .dst_type = DST_TYPE_IS_SAT, 684 .dst_type = DST_TYPE_IS_SAT,
629 .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, 685 .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD | DST_TYPE_HAS_INC_COUNT,
630 .dst_feature = DST_TYPE_HAS_CA | DST_TYPE_HAS_DISEQC3 | DST_TYPE_HAS_DISEQC4 686 .dst_feature = DST_TYPE_HAS_CA | DST_TYPE_HAS_DISEQC3 | DST_TYPE_HAS_DISEQC4
631 | DST_TYPE_HAS_MOTO | DST_TYPE_HAS_MAC 687 | DST_TYPE_HAS_MOTO | DST_TYPE_HAS_MAC
632 }, 688 },
@@ -872,7 +928,7 @@ static int dst_get_signal(struct dst_state* state)
872{ 928{
873 int retval; 929 int retval;
874 u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; 930 u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb };
875 931 dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__);
876 if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { 932 if ((state->diseq_flags & ATTEMPT_TUNE) == 0) {
877 state->decode_lock = state->decode_strength = state->decode_snr = 0; 933 state->decode_lock = state->decode_strength = state->decode_snr = 0;
878 return 0; 934 return 0;
@@ -954,15 +1010,8 @@ static int dst_get_tuna(struct dst_state* state)
954 state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; 1010 state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3];
955 1011
956 state->decode_lock = 1; 1012 state->decode_lock = 1;
957 /*
958 dst->decode_n1 = (dst->rx_tuna[4] << 8) +
959 (dst->rx_tuna[5]);
960
961 dst->decode_n2 = (dst->rx_tuna[8] << 8) +
962 (dst->rx_tuna[7]);
963 */
964 state->diseq_flags |= HAS_LOCK; 1013 state->diseq_flags |= HAS_LOCK;
965 /* dst->cur_jiff = jiffies; */ 1014
966 return 1; 1015 return 1;
967} 1016}
968 1017
@@ -1098,7 +1147,11 @@ static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
1098 1147
1099 switch (tone) { 1148 switch (tone) {
1100 case SEC_TONE_OFF: 1149 case SEC_TONE_OFF:
1101 state->tx_tuna[2] = 0xff; 1150 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
1151 state->tx_tuna[2] = 0x00;
1152 else
1153 state->tx_tuna[2] = 0xff;
1154
1102 break; 1155 break;
1103 1156
1104 case SEC_TONE_ON: 1157 case SEC_TONE_ON:
@@ -1145,7 +1198,8 @@ static int dst_init(struct dvb_frontend* fe)
1145 static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; 1198 static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
1146 static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; 1199 static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
1147 static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; 1200 static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
1148 state->inversion = INVERSION_ON; 1201// state->inversion = INVERSION_ON;
1202 state->inversion = INVERSION_OFF;
1149 state->voltage = SEC_VOLTAGE_13; 1203 state->voltage = SEC_VOLTAGE_13;
1150 state->tone = SEC_TONE_OFF; 1204 state->tone = SEC_TONE_OFF;
1151 state->symbol_rate = 29473000; 1205 state->symbol_rate = 29473000;
@@ -1174,7 +1228,7 @@ static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status)
1174 1228
1175 *status = 0; 1229 *status = 0;
1176 if (state->diseq_flags & HAS_LOCK) { 1230 if (state->diseq_flags & HAS_LOCK) {
1177 dst_get_signal(state); 1231// dst_get_signal(state); // don't require(?) to ask MCU
1178 if (state->decode_lock) 1232 if (state->decode_lock)
1179 *status |= FE_HAS_LOCK | FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_SYNC | FE_HAS_VITERBI; 1233 *status |= FE_HAS_LOCK | FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_SYNC | FE_HAS_VITERBI;
1180 } 1234 }
@@ -1208,20 +1262,25 @@ static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet
1208 1262
1209 dst_set_freq(state, p->frequency); 1263 dst_set_freq(state, p->frequency);
1210 if (verbose > 4) 1264 if (verbose > 4)
1211 dprintk("Set Frequency = [%d]\n", p->frequency); 1265 dprintk("Set Frequency=[%d]\n", p->frequency);
1212 1266
1213 dst_set_inversion(state, p->inversion); 1267// dst_set_inversion(state, p->inversion);
1214 if (state->dst_type == DST_TYPE_IS_SAT) { 1268 if (state->dst_type == DST_TYPE_IS_SAT) {
1269 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
1270 dst_set_inversion(state, p->inversion);
1271
1215 dst_set_fec(state, p->u.qpsk.fec_inner); 1272 dst_set_fec(state, p->u.qpsk.fec_inner);
1216 dst_set_symbolrate(state, p->u.qpsk.symbol_rate); 1273 dst_set_symbolrate(state, p->u.qpsk.symbol_rate);
1274 dst_set_polarization(state);
1217 if (verbose > 4) 1275 if (verbose > 4)
1218 dprintk("Set Symbolrate = [%d]\n", p->u.qpsk.symbol_rate); 1276 dprintk("Set Symbolrate=[%d]\n", p->u.qpsk.symbol_rate);
1219 1277
1220 } else if (state->dst_type == DST_TYPE_IS_TERR) { 1278 } else if (state->dst_type == DST_TYPE_IS_TERR) {
1221 dst_set_bandwidth(state, p->u.ofdm.bandwidth); 1279 dst_set_bandwidth(state, p->u.ofdm.bandwidth);
1222 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 1280 } else if (state->dst_type == DST_TYPE_IS_CABLE) {
1223 dst_set_fec(state, p->u.qam.fec_inner); 1281 dst_set_fec(state, p->u.qam.fec_inner);
1224 dst_set_symbolrate(state, p->u.qam.symbol_rate); 1282 dst_set_symbolrate(state, p->u.qam.symbol_rate);
1283 dst_set_modulation(state, p->u.qam.modulation);
1225 } 1284 }
1226 dst_write_tuna(fe); 1285 dst_write_tuna(fe);
1227 1286
@@ -1233,8 +1292,11 @@ static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet
1233 struct dst_state* state = fe->demodulator_priv; 1292 struct dst_state* state = fe->demodulator_priv;
1234 1293
1235 p->frequency = state->decode_freq; 1294 p->frequency = state->decode_freq;
1236 p->inversion = state->inversion; 1295// p->inversion = state->inversion;
1237 if (state->dst_type == DST_TYPE_IS_SAT) { 1296 if (state->dst_type == DST_TYPE_IS_SAT) {
1297 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
1298 p->inversion = state->inversion;
1299
1238 p->u.qpsk.symbol_rate = state->symbol_rate; 1300 p->u.qpsk.symbol_rate = state->symbol_rate;
1239 p->u.qpsk.fec_inner = dst_get_fec(state); 1301 p->u.qpsk.fec_inner = dst_get_fec(state);
1240 } else if (state->dst_type == DST_TYPE_IS_TERR) { 1302 } else if (state->dst_type == DST_TYPE_IS_TERR) {
@@ -1242,7 +1304,8 @@ static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet
1242 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 1304 } else if (state->dst_type == DST_TYPE_IS_CABLE) {
1243 p->u.qam.symbol_rate = state->symbol_rate; 1305 p->u.qam.symbol_rate = state->symbol_rate;
1244 p->u.qam.fec_inner = dst_get_fec(state); 1306 p->u.qam.fec_inner = dst_get_fec(state);
1245 p->u.qam.modulation = QAM_AUTO; 1307// p->u.qam.modulation = QAM_AUTO;
1308 p->u.qam.modulation = dst_get_modulation(state);
1246 } 1309 }
1247 1310
1248 return 0; 1311 return 0;
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index d781504cc2fa..bfaacd5fc20f 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -32,7 +32,7 @@
32#include "dst_ca.h" 32#include "dst_ca.h"
33#include "dst_common.h" 33#include "dst_common.h"
34 34
35static unsigned int verbose = 1; 35static unsigned int verbose = 5;
36module_param(verbose, int, 0644); 36module_param(verbose, int, 0644);
37MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); 37MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
38 38
@@ -295,34 +295,28 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message,
295 return 0; 295 return 0;
296} 296}
297 297
298static int handle_en50221_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer) 298static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length)
299{ 299{
300 if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) { 300 if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) {
301 hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ 301 hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */
302 hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ 302 hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */
303 } 303 }
304 else { 304 else {
305 hw_buffer->msg[0] = (length & 0xff) + 7;
306 hw_buffer->msg[1] = 0x40;
305 hw_buffer->msg[2] = 0x03; 307 hw_buffer->msg[2] = 0x03;
306 hw_buffer->msg[3] = 0x00; 308 hw_buffer->msg[3] = 0x00;
309 hw_buffer->msg[4] = 0x03;
310 hw_buffer->msg[5] = length & 0xff;
311 hw_buffer->msg[6] = 0x00;
307 } 312 }
308 return 0; 313 return 0;
309} 314}
310 315
311static int debug_8820_buffer(struct ca_msg *hw_buffer)
312{
313 unsigned int i;
314
315 dprintk("%s:Debug=[", __FUNCTION__);
316 for (i = 0; i < (hw_buffer->msg[0] + 1); i++)
317 dprintk(" %02x", hw_buffer->msg[i]);
318 dprintk("]\n");
319
320 return 0;
321}
322 316
323static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 reply) 317static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply)
324{ 318{
325 if ((dst_put_ci(state, hw_buffer->msg, (hw_buffer->length + 1), hw_buffer->msg, reply)) < 0) { 319 if ((dst_put_ci(state, hw_buffer->msg, length, hw_buffer->msg, reply)) < 0) {
326 dprintk("%s: DST-CI Command failed.\n", __FUNCTION__); 320 dprintk("%s: DST-CI Command failed.\n", __FUNCTION__);
327 dprintk("%s: Resetting DST.\n", __FUNCTION__); 321 dprintk("%s: Resetting DST.\n", __FUNCTION__);
328 rdc_reset_state(state); 322 rdc_reset_state(state);
@@ -334,234 +328,141 @@ static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 r
334 return 0; 328 return 0;
335} 329}
336 330
337 331u32 asn_1_decode(u8 *asn_1_array)
338static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query)
339{ 332{
340 u32 hw_offset, buf_offset, i, k; 333 u8 length_field = 0, word_count = 0, count = 0;
341 u32 program_info_length = 0, es_info_length = 0, length = 0, words = 0; 334 u32 length = 0;
342 u8 found_prog_ca_desc = 0, found_stream_ca_desc = 0, error_condition = 0, hw_buffer_length = 0; 335
343 336 length_field = asn_1_array[0];
344 if (verbose > 3) 337 dprintk("%s: Length field=[%02x]\n", __FUNCTION__, length_field);
345 dprintk("%s, p_ca_message length %d (0x%x)\n", __FUNCTION__,p_ca_message->length,p_ca_message->length ); 338 if (length_field < 0x80) {
346 339 length = length_field & 0x7f;
347 handle_en50221_tag(state, p_ca_message, hw_buffer); /* EN50221 tag */ 340 dprintk("%s: Length=[%02x]\n", __FUNCTION__, length);
348 341 } else {
349 /* Handle the length field (variable) */ 342 word_count = length_field & 0x7f;
350 if (!(p_ca_message->msg[3] & 0x80)) { /* Length = 1 */ 343 for (count = 0; count < word_count; count++) {
351 length = p_ca_message->msg[3] & 0x7f; 344 length = (length | asn_1_array[count + 1]) << 8;
352 words = 0; /* domi's suggestion */ 345 dprintk("%s: Length=[%04x]\n", __FUNCTION__, length);
353 }
354 else { /* Length = words */
355 words = p_ca_message->msg[3] & 0x7f;
356 for (i = 0; i < words; i++) {
357 length = length << 8;
358 length = length | p_ca_message->msg[4 + i];
359 } 346 }
360 } 347 }
361 if (verbose > 4) { 348 return length;
362 dprintk("%s:Length=[%d (0x%x)], Words=[%d]\n", __FUNCTION__, length,length, words); 349}
363
364 /* Debug Input string */
365 for (i = 0; i < length; i++)
366 dprintk(" %02x", p_ca_message->msg[i]);
367 dprintk("]\n");
368 }
369
370 hw_offset = 7;
371 buf_offset = words + 4;
372
373 /* Program Header */
374 if (verbose > 4)
375 dprintk("\n%s:Program Header=[", __FUNCTION__);
376 for (i = 0; i < 6; i++) {
377 hw_buffer->msg[hw_offset] = p_ca_message->msg[buf_offset];
378 if (verbose > 4)
379 dprintk(" %02x", p_ca_message->msg[buf_offset]);
380 hw_offset++, buf_offset++, hw_buffer_length++;
381 }
382 if (verbose > 4)
383 dprintk("]\n");
384 350
385 program_info_length = 0; 351static int init_buffer(u8 *buffer, u32 length)
386 program_info_length = (((program_info_length | p_ca_message->msg[words + 8]) & 0x0f) << 8) | p_ca_message->msg[words + 9]; 352{
387 if (verbose > 4) 353 u32 i;
388 dprintk("%s:Program info Length=[%d][%02x], hw_offset=[%d], buf_offset=[%d] \n", 354 for (i = 0; i < length; i++)
389 __FUNCTION__, program_info_length, program_info_length, hw_offset, buf_offset); 355 buffer[i] = 0;
390 356
391 if (program_info_length && (program_info_length < 256)) { /* If program_info_length */ 357 return 0;
392 hw_buffer->msg[11] = hw_buffer->msg[11] & 0x0f; /* req only 4 bits */ 358}
393 hw_buffer->msg[12] = hw_buffer->msg[12] + 1; /* increment! ASIC bug! */
394 359
395 if (p_ca_message->msg[buf_offset + 1] == 0x09) { /* Check CA descriptor */ 360static int debug_string(u8 *msg, u32 length, u32 offset)
396 found_prog_ca_desc = 1; 361{
397 if (verbose > 4) 362 u32 i;
398 dprintk("%s: Found CA descriptor @ Program level\n", __FUNCTION__);
399 }
400 363
401 if (found_prog_ca_desc) { /* Command only if CA descriptor */ 364 dprintk(" String=[ ");
402 hw_buffer->msg[13] = p_ca_message->msg[buf_offset]; /* CA PMT command ID */ 365 for (i = offset; i < length; i++)
403 hw_offset++, buf_offset++, hw_buffer_length++; 366 dprintk("%02x ", msg[i]);
404 } 367 dprintk("]\n");
405 368
406 /* Program descriptors */ 369 return 0;
407 if (verbose > 4) { 370}
408 dprintk("%s:**********>buf_offset=[%d], hw_offset=[%d]\n", __FUNCTION__, buf_offset, hw_offset);
409 dprintk("%s:Program descriptors=[", __FUNCTION__);
410 }
411 while (program_info_length && !error_condition) { /* Copy prog descriptors */
412 if (program_info_length > p_ca_message->length) { /* Error situation */
413 dprintk ("%s:\"WARNING\" Length error, line=[%d], prog_info_length=[%d]\n",
414 __FUNCTION__, __LINE__, program_info_length);
415 dprintk("%s:\"WARNING\" Bailing out of possible loop\n", __FUNCTION__);
416 error_condition = 1;
417 break;
418 }
419 371
420 hw_buffer->msg[hw_offset] = p_ca_message->msg[buf_offset]; 372static int copy_string(u8 *destination, u8 *source, u32 dest_offset, u32 source_offset, u32 length)
421 dprintk(" %02x", p_ca_message->msg[buf_offset]); 373{
422 hw_offset++, buf_offset++, hw_buffer_length++, program_info_length--; 374 u32 i;
423 } 375 dprintk("%s: Copying [", __FUNCTION__);
424 if (verbose > 4) { 376 for (i = 0; i < length; i++) {
425 dprintk("]\n"); 377 destination[i + dest_offset] = source[i + source_offset];
426 dprintk("%s:**********>buf_offset=[%d], hw_offset=[%d]\n", __FUNCTION__, buf_offset, hw_offset); 378 dprintk(" %02x", source[i + source_offset]);
427 }
428 if (found_prog_ca_desc) {
429 if (!reply) {
430 hw_buffer->msg[13] = 0x01; /* OK descrambling */
431 if (verbose > 1)
432 dprintk("CA PMT Command = OK Descrambling\n");
433 }
434 else {
435 hw_buffer->msg[13] = 0x02; /* Ok MMI */
436 if (verbose > 1)
437 dprintk("CA PMT Command = Ok MMI\n");
438 }
439 if (query) {
440 hw_buffer->msg[13] = 0x03; /* Query */
441 if (verbose > 1)
442 dprintk("CA PMT Command = CA PMT query\n");
443 }
444 }
445 }
446 else {
447 hw_buffer->msg[11] = hw_buffer->msg[11] & 0xf0; /* Don't write to ASIC */
448 hw_buffer->msg[12] = hw_buffer->msg[12] = 0x00;
449 } 379 }
450 if (verbose > 4) 380 dprintk("]\n");
451 dprintk("%s:**********>p_ca_message->length=[%d], buf_offset=[%d], hw_offset=[%d]\n",
452 __FUNCTION__, p_ca_message->length, buf_offset, hw_offset);
453
454 while ((buf_offset < p_ca_message->length) && !error_condition) {
455 /* Bail out in case of an indefinite loop */
456 if ((es_info_length > p_ca_message->length) || (buf_offset > p_ca_message->length)) {
457 dprintk("%s:\"WARNING\" Length error, line=[%d], prog_info_length=[%d], buf_offset=[%d]\n",
458 __FUNCTION__, __LINE__, program_info_length, buf_offset);
459
460 dprintk("%s:\"WARNING\" Bailing out of possible loop\n", __FUNCTION__);
461 error_condition = 1;
462 break;
463 }
464
465 /* Stream Header */
466
467 for (k = 0; k < 5; k++) {
468 hw_buffer->msg[hw_offset + k] = p_ca_message->msg[buf_offset + k];
469 }
470 381
471 es_info_length = 0; 382 return i;
472 es_info_length = (es_info_length | (p_ca_message->msg[buf_offset + 3] & 0x0f)) << 8 | p_ca_message->msg[buf_offset + 4]; 383}
473 384
474 if (verbose > 4) { 385static int modify_4_bits(u8 *message, u32 pos)
475 dprintk("\n%s:----->Stream header=[%02x %02x %02x %02x %02x]\n", __FUNCTION__, 386{
476 p_ca_message->msg[buf_offset + 0], p_ca_message->msg[buf_offset + 1], 387 message[pos] &= 0x0f;
477 p_ca_message->msg[buf_offset + 2], p_ca_message->msg[buf_offset + 3],
478 p_ca_message->msg[buf_offset + 4]);
479 388
480 dprintk("%s:----->Stream type=[%02x], es length=[%d (0x%x)], Chars=[%02x] [%02x], buf_offset=[%d]\n", __FUNCTION__, 389 return 0;
481 p_ca_message->msg[buf_offset + 0], es_info_length, es_info_length, 390}
482 p_ca_message->msg[buf_offset + 3], p_ca_message->msg[buf_offset + 4], buf_offset);
483 }
484 391
485 hw_buffer->msg[hw_offset + 3] &= 0x0f; /* req only 4 bits */
486 392
487 if (found_prog_ca_desc) {
488 hw_buffer->msg[hw_offset + 3] = 0x00;
489 hw_buffer->msg[hw_offset + 4] = 0x00;
490 }
491 393
492 hw_offset += 5, buf_offset += 5, hw_buffer_length += 5; 394static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query)
395{
396 u32 length = 0, count = 0;
397 u8 asn_1_words, program_header_length;
398 u16 program_info_length = 0, es_info_length = 0;
399 u32 hw_offset = 0, buf_offset = 0, i;
400 u8 dst_tag_length;
493 401
494 /* Check for CA descriptor */ 402 length = asn_1_decode(&p_ca_message->msg[3]);
495 if (p_ca_message->msg[buf_offset + 1] == 0x09) { 403 dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length);
496 if (verbose > 4) 404 dprintk("%s: ASN.1 ", __FUNCTION__);
497 dprintk("%s:Found CA descriptor @ Stream level\n", __FUNCTION__); 405 debug_string(&p_ca_message->msg[4], length, 0); // length does not include tag and length
498 found_stream_ca_desc = 1;
499 }
500 406
501 /* ES descriptors */ 407 init_buffer(hw_buffer->msg, length);
502 408 handle_dst_tag(state, p_ca_message, hw_buffer, length);
503 if (es_info_length && !error_condition && !found_prog_ca_desc && found_stream_ca_desc) {
504// if (!ca_pmt_done) {
505 hw_buffer->msg[hw_offset] = p_ca_message->msg[buf_offset]; /* CA PMT cmd(es) */
506 if (verbose > 4)
507 printk("%s:----->CA PMT Command ID=[%02x]\n", __FUNCTION__, p_ca_message->msg[buf_offset]);
508// hw_offset++, buf_offset++, hw_buffer_length++, es_info_length--, ca_pmt_done = 1;
509 hw_offset++, buf_offset++, hw_buffer_length++, es_info_length--;
510// }
511 if (verbose > 4)
512 dprintk("%s:----->ES descriptors=[", __FUNCTION__);
513
514 while (es_info_length && !error_condition) { /* ES descriptors */
515 if ((es_info_length > p_ca_message->length) || (buf_offset > p_ca_message->length)) {
516 if (verbose > 4) {
517 dprintk("%s:\"WARNING\" ES Length error, line=[%d], es_info_length=[%d], buf_offset=[%d]\n",
518 __FUNCTION__, __LINE__, es_info_length, buf_offset);
519
520 dprintk("%s:\"WARNING\" Bailing out of possible loop\n", __FUNCTION__);
521 }
522 error_condition = 1;
523 break;
524 }
525 409
526 hw_buffer->msg[hw_offset] = p_ca_message->msg[buf_offset]; 410 hw_offset = 7;
527 if (verbose > 3) 411 asn_1_words = 1; // just a hack to test, should compute this one
528 dprintk("%02x ", hw_buffer->msg[hw_offset]); 412 buf_offset = 3;
529 hw_offset++, buf_offset++, hw_buffer_length++, es_info_length--; 413 program_header_length = 6;
530 } 414 dst_tag_length = 7;
531 found_stream_ca_desc = 0; /* unset for new streams */ 415
532 dprintk("]\n"); 416// debug_twinhan_ca_params(state, p_ca_message, hw_buffer, reply, query, length, hw_offset, buf_offset);
417// dprintk("%s: Program Header(BUF)", __FUNCTION__);
418// debug_string(&p_ca_message->msg[4], program_header_length, 0);
419// dprintk("%s: Copying Program header\n", __FUNCTION__);
420 copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + asn_1_words), program_header_length);
421 buf_offset += program_header_length, hw_offset += program_header_length;
422 modify_4_bits(hw_buffer->msg, (hw_offset - 2));
423 if (state->type_flags & DST_TYPE_HAS_INC_COUNT) { // workaround
424 dprintk("%s: Probably an ASIC bug !!!\n", __FUNCTION__);
425 debug_string(hw_buffer->msg, (hw_offset + program_header_length), 0);
426 hw_buffer->msg[hw_offset - 1] += 1;
427 }
428
429// dprintk("%s: Program Header(HW), Count=[%d]", __FUNCTION__, count);
430// debug_string(hw_buffer->msg, hw_offset, 0);
431
432 program_info_length = ((program_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset];
433 dprintk("%s: Program info length=[%02x]\n", __FUNCTION__, program_info_length);
434 if (program_info_length) {
435 count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + 1), (program_info_length + 1) ); // copy next elem, not current
436 buf_offset += count, hw_offset += count;
437// dprintk("%s: Program level ", __FUNCTION__);
438// debug_string(hw_buffer->msg, hw_offset, 0);
439 }
440
441 buf_offset += 1;// hw_offset += 1;
442 for (i = buf_offset; i < length; i++) {
443// dprintk("%s: Stream Header ", __FUNCTION__);
444 count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, buf_offset, 5);
445 modify_4_bits(hw_buffer->msg, (hw_offset + 3));
446
447 hw_offset += 5, buf_offset += 5, i += 4;
448// debug_string(hw_buffer->msg, hw_offset, (hw_offset - 5));
449 es_info_length = ((es_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset];
450 dprintk("%s: ES info length=[%02x]\n", __FUNCTION__, es_info_length);
451 if (es_info_length) {
452 // copy descriptors @ STREAM level
453 dprintk("%s: Descriptors @ STREAM level...!!! \n", __FUNCTION__);
533 } 454 }
534 }
535
536 /* MCU Magic words */
537
538 hw_buffer_length += 7;
539 hw_buffer->msg[0] = hw_buffer_length;
540 hw_buffer->msg[1] = 64;
541 hw_buffer->msg[4] = 3;
542 hw_buffer->msg[5] = hw_buffer->msg[0] - 7;
543 hw_buffer->msg[6] = 0;
544
545 455
546 /* Fix length */
547 hw_buffer->length = hw_buffer->msg[0];
548
549 put_checksum(&hw_buffer->msg[0], hw_buffer->msg[0]);
550 /* Do the actual write */
551 if (verbose > 4) {
552 dprintk("%s:======================DEBUGGING================================\n", __FUNCTION__);
553 dprintk("%s: Actual Length=[%d]\n", __FUNCTION__, hw_buffer_length);
554 } 456 }
555 /* Only for debugging! */ 457 hw_buffer->msg[length + dst_tag_length] = dst_check_sum(hw_buffer->msg, (length + dst_tag_length));
556 if (verbose > 2) 458// dprintk("%s: Total length=[%d], Checksum=[%02x]\n", __FUNCTION__, (length + dst_tag_length), hw_buffer->msg[length + dst_tag_length]);
557 debug_8820_buffer(hw_buffer); 459 debug_string(hw_buffer->msg, (length + dst_tag_length + 1), 0); // dst tags also
558 if (verbose > 3) 460 write_to_8820(state, hw_buffer, (length + dst_tag_length + 1), reply); // checksum
559 dprintk("%s: Reply = [%d]\n", __FUNCTION__, reply);
560 write_to_8820(state, hw_buffer, reply);
561 461
562 return 0; 462 return 0;
563} 463}
564 464
465
565/* Board supports CA PMT reply ? */ 466/* Board supports CA PMT reply ? */
566static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer) 467static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer)
567{ 468{
@@ -605,7 +506,7 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message,
605 struct ca_msg *hw_buffer; 506 struct ca_msg *hw_buffer;
606 507
607 if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { 508 if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) {
608 printk("%s: Memory allocation failure\n", __FUNCTION__); 509 dprintk("%s: Memory allocation failure\n", __FUNCTION__);
609 return -ENOMEM; 510 return -ENOMEM;
610 } 511 }
611 if (verbose > 3) 512 if (verbose > 3)
@@ -630,8 +531,10 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message,
630 switch (command) { 531 switch (command) {
631 case CA_PMT: 532 case CA_PMT:
632 if (verbose > 3) 533 if (verbose > 3)
534// dprintk("Command = SEND_CA_PMT\n");
633 dprintk("Command = SEND_CA_PMT\n"); 535 dprintk("Command = SEND_CA_PMT\n");
634 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { 536// if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) {
537 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started
635 dprintk("%s: -->CA_PMT Failed !\n", __FUNCTION__); 538 dprintk("%s: -->CA_PMT Failed !\n", __FUNCTION__);
636 return -1; 539 return -1;
637 } 540 }
@@ -664,7 +567,7 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message,
664 return -1; 567 return -1;
665 } 568 }
666 if (verbose > 3) 569 if (verbose > 3)
667 printk("%s: -->CA_APP_INFO_ENQUIRY Success !\n", __FUNCTION__); 570 dprintk("%s: -->CA_APP_INFO_ENQUIRY Success !\n", __FUNCTION__);
668 571
669 break; 572 break;
670 } 573 }
@@ -681,17 +584,17 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd
681 struct ca_msg *p_ca_message; 584 struct ca_msg *p_ca_message;
682 585
683 if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { 586 if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) {
684 printk("%s: Memory allocation failure\n", __FUNCTION__); 587 dprintk("%s: Memory allocation failure\n", __FUNCTION__);
685 return -ENOMEM; 588 return -ENOMEM;
686 } 589 }
687 590
688 if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) { 591 if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) {
689 printk("%s: Memory allocation failure\n", __FUNCTION__); 592 dprintk("%s: Memory allocation failure\n", __FUNCTION__);
690 return -ENOMEM; 593 return -ENOMEM;
691 } 594 }
692 595
693 if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) { 596 if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) {
694 printk("%s: Memory allocation failure\n", __FUNCTION__); 597 dprintk("%s: Memory allocation failure\n", __FUNCTION__);
695 return -ENOMEM; 598 return -ENOMEM;
696 } 599 }
697 600
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h
index 0b3da29245fb..ef532a6aceaa 100644
--- a/drivers/media/dvb/bt8xx/dst_common.h
+++ b/drivers/media/dvb/bt8xx/dst_common.h
@@ -47,6 +47,8 @@
47#define DST_TYPE_HAS_FW_2 16 47#define DST_TYPE_HAS_FW_2 16
48#define DST_TYPE_HAS_FW_3 32 48#define DST_TYPE_HAS_FW_3 32
49#define DST_TYPE_HAS_FW_BUILD 64 49#define DST_TYPE_HAS_FW_BUILD 64
50#define DST_TYPE_HAS_OBS_REGS 128
51#define DST_TYPE_HAS_INC_COUNT 256
50 52
51/* Card capability list */ 53/* Card capability list */
52 54
@@ -110,6 +112,7 @@ struct dst_state {
110 u32 dst_hw_cap; 112 u32 dst_hw_cap;
111 u8 dst_fw_version; 113 u8 dst_fw_version;
112 fe_sec_mini_cmd_t minicmd; 114 fe_sec_mini_cmd_t minicmd;
115 fe_modulation_t modulation;
113 u8 messages[256]; 116 u8 messages[256];
114}; 117};
115 118
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 96c57fde95a0..7d8b3cad350b 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -699,6 +699,8 @@ static void cinergyt2_query_rc (void *data)
699 for (n=0; len>0 && n<(len/sizeof(rc_events[0])); n++) { 699 for (n=0; len>0 && n<(len/sizeof(rc_events[0])); n++) {
700 int i; 700 int i;
701 701
702/* dprintk(1,"rc_events[%d].value = %x, type=%x\n",n,le32_to_cpu(rc_events[n].value),rc_events[n].type);*/
703
702 if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC && 704 if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC &&
703 rc_events[n].value == ~0) 705 rc_events[n].value == ~0)
704 { 706 {
@@ -714,7 +716,7 @@ static void cinergyt2_query_rc (void *data)
714 cinergyt2->rc_input_event = KEY_MAX; 716 cinergyt2->rc_input_event = KEY_MAX;
715 for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i+=3) { 717 for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i+=3) {
716 if (rc_keys[i+0] == rc_events[n].type && 718 if (rc_keys[i+0] == rc_events[n].type &&
717 rc_keys[i+1] == rc_events[n].value) 719 rc_keys[i+1] == le32_to_cpu(rc_events[n].value))
718 { 720 {
719 cinergyt2->rc_input_event = rc_keys[i+2]; 721 cinergyt2->rc_input_event = rc_keys[i+2];
720 break; 722 break;
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index c225de7ffd82..68050cd527cb 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -42,12 +42,6 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
42 42
43#define dprintk if (debug) printk 43#define dprintk if (debug) printk
44 44
45static inline struct dmxdev_filter *
46dvb_dmxdev_file_to_filter(struct file *file)
47{
48 return (struct dmxdev_filter *) file->private_data;
49}
50
51static inline void dvb_dmxdev_buffer_init(struct dmxdev_buffer *buffer) 45static inline void dvb_dmxdev_buffer_init(struct dmxdev_buffer *buffer)
52{ 46{
53 buffer->data=NULL; 47 buffer->data=NULL;
@@ -669,8 +663,10 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
669 663
670 ret = filter->feed.ts->start_filtering(filter->feed.ts); 664 ret = filter->feed.ts->start_filtering(filter->feed.ts);
671 665
672 if (ret < 0) 666 if (ret < 0) {
667 dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed);
673 return ret; 668 return ret;
669 }
674 670
675 break; 671 break;
676 } 672 }
@@ -842,7 +838,7 @@ static ssize_t dvb_dmxdev_read_sec(struct dmxdev_filter *dfil,
842static ssize_t 838static ssize_t
843dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 839dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
844{ 840{
845 struct dmxdev_filter *dmxdevfilter=dvb_dmxdev_file_to_filter(file); 841 struct dmxdev_filter *dmxdevfilter= file->private_data;
846 int ret=0; 842 int ret=0;
847 843
848 if (down_interruptible(&dmxdevfilter->mutex)) 844 if (down_interruptible(&dmxdevfilter->mutex))
@@ -863,7 +859,7 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
863static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, 859static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
864 unsigned int cmd, void *parg) 860 unsigned int cmd, void *parg)
865{ 861{
866 struct dmxdev_filter *dmxdevfilter=dvb_dmxdev_file_to_filter(file); 862 struct dmxdev_filter *dmxdevfilter = file->private_data;
867 struct dmxdev *dmxdev=dmxdevfilter->dev; 863 struct dmxdev *dmxdev=dmxdevfilter->dev;
868 unsigned long arg=(unsigned long) parg; 864 unsigned long arg=(unsigned long) parg;
869 int ret=0; 865 int ret=0;
@@ -960,7 +956,7 @@ static int dvb_demux_ioctl(struct inode *inode, struct file *file,
960 956
961static unsigned int dvb_demux_poll (struct file *file, poll_table *wait) 957static unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
962{ 958{
963 struct dmxdev_filter *dmxdevfilter = dvb_dmxdev_file_to_filter(file); 959 struct dmxdev_filter *dmxdevfilter = file->private_data;
964 unsigned int mask = 0; 960 unsigned int mask = 0;
965 961
966 if (!dmxdevfilter) 962 if (!dmxdevfilter)
@@ -985,7 +981,7 @@ static unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
985 981
986static int dvb_demux_release(struct inode *inode, struct file *file) 982static int dvb_demux_release(struct inode *inode, struct file *file)
987{ 983{
988 struct dmxdev_filter *dmxdevfilter = dvb_dmxdev_file_to_filter(file); 984 struct dmxdev_filter *dmxdevfilter = file->private_data;
989 struct dmxdev *dmxdev = dmxdevfilter->dev; 985 struct dmxdev *dmxdev = dmxdevfilter->dev;
990 986
991 return dvb_dmxdev_filter_free(dmxdev, dmxdevfilter); 987 return dvb_dmxdev_filter_free(dmxdev, dmxdevfilter);
@@ -1109,7 +1105,6 @@ dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
1109 dvb_dmxdev_filter_state_set(&dmxdev->filter[i], DMXDEV_STATE_FREE); 1105 dvb_dmxdev_filter_state_set(&dmxdev->filter[i], DMXDEV_STATE_FREE);
1110 dmxdev->dvr[i].dev=dmxdev; 1106 dmxdev->dvr[i].dev=dmxdev;
1111 dmxdev->dvr[i].buffer.data=NULL; 1107 dmxdev->dvr[i].buffer.data=NULL;
1112 dvb_dmxdev_filter_state_set(&dmxdev->filter[i], DMXDEV_STATE_FREE);
1113 dvb_dmxdev_dvr_state_set(&dmxdev->dvr[i], DMXDEV_STATE_FREE); 1108 dvb_dmxdev_dvr_state_set(&dmxdev->dvr[i], DMXDEV_STATE_FREE);
1114 } 1109 }
1115 1110
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index f11daae91cd4..a8bc84240b50 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -42,6 +42,8 @@
42#include "dvb_frontend.h" 42#include "dvb_frontend.h"
43#include "dvbdev.h" 43#include "dvbdev.h"
44 44
45// #define DEBUG_LOCKLOSS 1
46
45static int dvb_frontend_debug; 47static int dvb_frontend_debug;
46static int dvb_shutdown_timeout = 5; 48static int dvb_shutdown_timeout = 5;
47static int dvb_force_auto_inversion; 49static int dvb_force_auto_inversion;
@@ -113,6 +115,7 @@ struct dvb_frontend_private {
113 int exit; 115 int exit;
114 int wakeup; 116 int wakeup;
115 fe_status_t status; 117 fe_status_t status;
118 fe_sec_tone_mode_t tone;
116}; 119};
117 120
118 121
@@ -434,9 +437,26 @@ static int dvb_frontend_thread(void *data)
434 /* we're tuned, and the lock is still good... */ 437 /* we're tuned, and the lock is still good... */
435 if (s & FE_HAS_LOCK) 438 if (s & FE_HAS_LOCK)
436 continue; 439 continue;
437 else { 440 else { /* if we _WERE_ tuned, but now don't have a lock */
438 /* if we _WERE_ tuned, but now don't have a lock, 441#ifdef DEBUG_LOCKLOSS
439 * need to zigzag */ 442 /* first of all try setting the tone again if it was on - this
443 * sometimes works around problems with noisy power supplies */
444 if (fe->ops->set_tone && (fepriv->tone == SEC_TONE_ON)) {
445 fe->ops->set_tone(fe, fepriv->tone);
446 mdelay(100);
447 s = 0;
448 fe->ops->read_status(fe, &s);
449 if (s & FE_HAS_LOCK) {
450 printk("DVB%i: Lock was lost, but regained by setting "
451 "the tone. This may indicate your power supply "
452 "is noisy/slightly incompatable with this DVB-S "
453 "adapter\n", fe->dvb->num);
454 fepriv->state = FESTATE_TUNED;
455 continue;
456 }
457 }
458#endif
459 /* some other reason for losing the lock - start zigzagging */
440 fepriv->state = FESTATE_ZIGZAG_FAST; 460 fepriv->state = FESTATE_ZIGZAG_FAST;
441 fepriv->started_auto_step = fepriv->auto_step; 461 fepriv->started_auto_step = fepriv->auto_step;
442 check_wrapped = 0; 462 check_wrapped = 0;
@@ -626,11 +646,21 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
626 break; 646 break;
627 } 647 }
628 648
629 case FE_READ_STATUS: 649 case FE_READ_STATUS: {
650 fe_status_t* status = parg;
651
652 /* if retune was requested but hasn't occured yet, prevent
653 * that user get signal state from previous tuning */
654 if(fepriv->state == FESTATE_RETUNE) {
655 err=0;
656 *status = 0;
657 break;
658 }
659
630 if (fe->ops->read_status) 660 if (fe->ops->read_status)
631 err = fe->ops->read_status(fe, (fe_status_t*) parg); 661 err = fe->ops->read_status(fe, status);
632 break; 662 break;
633 663 }
634 case FE_READ_BER: 664 case FE_READ_BER:
635 if (fe->ops->read_ber) 665 if (fe->ops->read_ber)
636 err = fe->ops->read_ber(fe, (__u32*) parg); 666 err = fe->ops->read_ber(fe, (__u32*) parg);
@@ -681,6 +711,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
681 err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg); 711 err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg);
682 fepriv->state = FESTATE_DISEQC; 712 fepriv->state = FESTATE_DISEQC;
683 fepriv->status = 0; 713 fepriv->status = 0;
714 fepriv->tone = (fe_sec_tone_mode_t) parg;
684 } 715 }
685 break; 716 break;
686 717
@@ -883,6 +914,7 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
883 init_MUTEX (&fepriv->events.sem); 914 init_MUTEX (&fepriv->events.sem);
884 fe->dvb = dvb; 915 fe->dvb = dvb;
885 fepriv->inversion = INVERSION_OFF; 916 fepriv->inversion = INVERSION_OFF;
917 fepriv->tone = SEC_TONE_OFF;
886 918
887 printk ("DVB: registering frontend %i (%s)...\n", 919 printk ("DVB: registering frontend %i (%s)...\n",
888 fe->dvb->num, 920 fe->dvb->num,
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
index d2b021792791..9c2c1d1136bd 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -40,28 +40,6 @@
40 40
41#include "dvbdev.h" 41#include "dvbdev.h"
42 42
43/* FIXME: Move to i2c-id.h */
44#define I2C_DRIVERID_DVBFE_SP8870 I2C_DRIVERID_EXP2
45#define I2C_DRIVERID_DVBFE_CX22700 I2C_DRIVERID_EXP2
46#define I2C_DRIVERID_DVBFE_AT76C651 I2C_DRIVERID_EXP2
47#define I2C_DRIVERID_DVBFE_CX24110 I2C_DRIVERID_EXP2
48#define I2C_DRIVERID_DVBFE_CX22702 I2C_DRIVERID_EXP2
49#define I2C_DRIVERID_DVBFE_DIB3000MB I2C_DRIVERID_EXP2
50#define I2C_DRIVERID_DVBFE_DST I2C_DRIVERID_EXP2
51#define I2C_DRIVERID_DVBFE_DUMMY I2C_DRIVERID_EXP2
52#define I2C_DRIVERID_DVBFE_L64781 I2C_DRIVERID_EXP2
53#define I2C_DRIVERID_DVBFE_MT312 I2C_DRIVERID_EXP2
54#define I2C_DRIVERID_DVBFE_MT352 I2C_DRIVERID_EXP2
55#define I2C_DRIVERID_DVBFE_NXT6000 I2C_DRIVERID_EXP2
56#define I2C_DRIVERID_DVBFE_SP887X I2C_DRIVERID_EXP2
57#define I2C_DRIVERID_DVBFE_STV0299 I2C_DRIVERID_EXP2
58#define I2C_DRIVERID_DVBFE_TDA1004X I2C_DRIVERID_EXP2
59#define I2C_DRIVERID_DVBFE_TDA8083 I2C_DRIVERID_EXP2
60#define I2C_DRIVERID_DVBFE_VES1820 I2C_DRIVERID_EXP2
61#define I2C_DRIVERID_DVBFE_VES1X93 I2C_DRIVERID_EXP2
62#define I2C_DRIVERID_DVBFE_TDA80XX I2C_DRIVERID_EXP2
63
64
65struct dvb_frontend_tune_settings { 43struct dvb_frontend_tune_settings {
66 int min_delay_ms; 44 int min_delay_ms;
67 int step_size; 45 int step_size;
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 8aa32f6e447b..612e5b087b1c 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -3,30 +3,35 @@ config DVB_USB
3 depends on DVB_CORE && USB 3 depends on DVB_CORE && USB
4 select FW_LOADER 4 select FW_LOADER
5 help 5 help
6 By enabling this you will be able to choose the various USB 1.1 and 6 By enabling this you will be able to choose the various supported
7 USB2.0 DVB devices. 7 USB1.1 and USB2.0 DVB devices.
8 8
9 Almost every USB device needs a firmware, please look into 9 Almost every USB device needs a firmware, please look into
10 <file:Documentation/dvb/README.dvb-usb> 10 <file:Documentation/dvb/README.dvb-usb>.
11 11
12 Say Y if you own an USB DVB device. 12 For a complete list of supported USB devices see the LinuxTV DVB Wiki:
13 <http://www.linuxtv.org/wiki/index.php/DVB_USB>
14
15 Say Y if you own a USB DVB device.
13 16
14config DVB_USB_DEBUG 17config DVB_USB_DEBUG
15 bool "Enable extended debug support for all DVB-USB devices" 18 bool "Enable extended debug support for all DVB-USB devices"
16 depends on DVB_USB 19 depends on DVB_USB
17 help 20 help
18 Say Y if you want to enable debuging. See modinfo dvb-usb (and the 21 Say Y if you want to enable debugging. See modinfo dvb-usb (and the
19 appropriate drivers) for debug levels. 22 appropriate drivers) for debug levels.
20 23
21config DVB_USB_A800 24config DVB_USB_A800
22 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)" 25 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)"
23 depends on DVB_USB 26 depends on DVB_USB
27 select DVB_DIB3000MC
24 help 28 help
25 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver. 29 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver.
26 30
27config DVB_USB_DIBUSB_MB 31config DVB_USB_DIBUSB_MB
28 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)" 32 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)"
29 depends on DVB_USB 33 depends on DVB_USB
34 select DVB_DIB3000MB
30 help 35 help
31 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by 36 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by
32 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator. 37 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator.
@@ -52,6 +57,7 @@ config DVB_USB_DIBUSB_MB
52config DVB_USB_DIBUSB_MC 57config DVB_USB_DIBUSB_MC
53 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)" 58 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)"
54 depends on DVB_USB 59 depends on DVB_USB
60 select DVB_DIB3000MC
55 help 61 help
56 Support for 2.0 DVB-T receivers based on reference designs made by 62 Support for 2.0 DVB-T receivers based on reference designs made by
57 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator. 63 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator.
@@ -66,12 +72,23 @@ config DVB_USB_DIBUSB_MC
66config DVB_USB_UMT_010 72config DVB_USB_UMT_010
67 tristate "HanfTek UMT-010 DVB-T USB2.0 support" 73 tristate "HanfTek UMT-010 DVB-T USB2.0 support"
68 depends on DVB_USB 74 depends on DVB_USB
75 select DVB_DIB3000MC
69 help 76 help
70 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver. 77 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver.
71 78
79config DVB_USB_CXUSB
80 tristate "Medion MD95700 hybrid USB2.0 (Conexant) support"
81 depends on DVB_USB
82 select DVB_CX22702
83 help
84 Say Y here to support the Medion MD95700 hybrid USB2.0 device. Currently
85 only the DVB-T part is supported.
86
72config DVB_USB_DIGITV 87config DVB_USB_DIGITV
73 tristate "Nebula Electronics uDigiTV DVB-T USB2.0 support" 88 tristate "Nebula Electronics uDigiTV DVB-T USB2.0 support"
74 depends on DVB_USB 89 depends on DVB_USB
90 select DVB_NXT6000
91 select DVB_MT352
75 help 92 help
76 Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver. 93 Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver.
77 94
@@ -87,13 +104,16 @@ config DVB_USB_VP7045
87config DVB_USB_NOVA_T_USB2 104config DVB_USB_NOVA_T_USB2
88 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" 105 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support"
89 depends on DVB_USB 106 depends on DVB_USB
107 select DVB_DIB3000MC
90 help 108 help
91 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver. 109 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver.
92 110
93config DVB_USB_DTT200U 111config DVB_USB_DTT200U
94 tristate "Yakumo/Hama/Typhoon/Yuan DVB-T USB2.0 support" 112 tristate "WideView WT-200U and WT-220U (pen) DVB-T USB2.0 support (Yakumo/Hama/Typhoon/Yuan)"
95 depends on DVB_USB 113 depends on DVB_USB
96 help 114 help
97 Say Y here to support the Yakumo/Hama/Typhoon/Yuan DVB-T USB2.0 receiver. 115 Say Y here to support the WideView/Yakumo/Hama/Typhoon/Yuan DVB-T USB2.0 receiver.
98 116
99 The receivers are also known as DTT200U (Yakumo) and UB300 (Yuan). 117 The receivers are also known as DTT200U (Yakumo) and UB300 (Yuan).
118
119 The WT-220U and its clones are pen-sized.
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index d65b50f9abb0..746d87ed6f32 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -27,4 +27,7 @@ obj-$(CONFIG_DVB_USB_UMT_010) += dvb-usb-dibusb-common.o dvb-usb-umt-010.o
27dvb-usb-digitv-objs = digitv.o 27dvb-usb-digitv-objs = digitv.o
28obj-$(CONFIG_DVB_USB_DIGITV) += dvb-usb-digitv.o 28obj-$(CONFIG_DVB_USB_DIGITV) += dvb-usb-digitv.o
29 29
30dvb-usb-cxusb-objs = cxusb.o
31obj-$(CONFIG_DVB_USB_CXUSB) += dvb-usb-cxusb.o
32
30EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 33EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c
index a3542935604f..f2fcc2f1f846 100644
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ b/drivers/media/dvb/dvb-usb/a800.c
@@ -61,6 +61,12 @@ static struct dvb_usb_rc_key a800_rc_keys[] = {
61 { 0x02, 0x00, KEY_LAST }, /* >>| / BLUE */ 61 { 0x02, 0x00, KEY_LAST }, /* >>| / BLUE */
62 { 0x02, 0x04, KEY_EPG }, /* EPG */ 62 { 0x02, 0x04, KEY_EPG }, /* EPG */
63 { 0x02, 0x15, KEY_MENU }, /* MENU */ 63 { 0x02, 0x15, KEY_MENU }, /* MENU */
64
65 { 0x03, 0x03, KEY_CHANNELUP }, /* CH UP */
66 { 0x03, 0x02, KEY_CHANNELDOWN }, /* CH DOWN */
67 { 0x03, 0x01, KEY_FIRST }, /* |<< / GREEN */
68 { 0x03, 0x00, KEY_LAST }, /* >>| / BLUE */
69
64}; 70};
65 71
66int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 72int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
@@ -68,7 +74,7 @@ int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
68 u8 key[5]; 74 u8 key[5];
69 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0), 75 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
70 0x04, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, key, 5, 76 0x04, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, key, 5,
71 2*HZ) != 5) 77 2000) != 5)
72 return -ENODEV; 78 return -ENODEV;
73 79
74 /* call the universal NEC remote processor, to find out the key's state and event */ 80 /* call the universal NEC remote processor, to find out the key's state and event */
@@ -143,7 +149,7 @@ static struct dvb_usb_properties a800_properties = {
143 149
144static struct usb_driver a800_driver = { 150static struct usb_driver a800_driver = {
145 .owner = THIS_MODULE, 151 .owner = THIS_MODULE,
146 .name = "AVerMedia AverTV DVB-T USB 2.0 (A800)", 152 .name = "dvb_usb_a800",
147 .probe = a800_probe, 153 .probe = a800_probe,
148 .disconnect = dvb_usb_device_exit, 154 .disconnect = dvb_usb_device_exit,
149 .id_table = a800_table, 155 .id_table = a800_table,
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
new file mode 100644
index 000000000000..c3e1b661aae6
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -0,0 +1,295 @@
1/* DVB USB compliant linux driver for Conexant USB reference design.
2 *
3 * The Conexant reference design I saw on their website was only for analogue
4 * capturing (using the cx25842). The box I took to write this driver (reverse
5 * engineered) is the one labeled Medion MD95700. In addition to the cx25842
6 * for analogue capturing it also has a cx22702 DVB-T demodulator on the main
7 * board. Besides it has a atiremote (X10) and a USB2.0 hub onboard.
8 *
9 * Maybe it is a little bit premature to call this driver cxusb, but I assume
10 * the USB protocol is identical or at least inherited from the reference
11 * design, so it can be reused for the "analogue-only" device (if it will
12 * appear at all).
13 *
14 * TODO: check if the cx25840-driver (from ivtv) can be used for the analogue
15 * part
16 *
17 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
18 *
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the Free
21 * Software Foundation, version 2.
22 *
23 * see Documentation/dvb/README.dvb-usb for more information
24 */
25#include "cxusb.h"
26
27#include "cx22702.h"
28
29/* debug */
30int dvb_usb_cxusb_debug;
31module_param_named(debug,dvb_usb_cxusb_debug, int, 0644);
32MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
33
34static int cxusb_ctrl_msg(struct dvb_usb_device *d,
35 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
36{
37 int wo = (rbuf == NULL || rlen == 0); /* write-only */
38 u8 sndbuf[1+wlen];
39 memset(sndbuf,0,1+wlen);
40
41 sndbuf[0] = cmd;
42 memcpy(&sndbuf[1],wbuf,wlen);
43 if (wo)
44 dvb_usb_generic_write(d,sndbuf,1+wlen);
45 else
46 dvb_usb_generic_rw(d,sndbuf,1+wlen,rbuf,rlen,0);
47
48 return 0;
49}
50
51/* I2C */
52static void cxusb_set_i2c_path(struct dvb_usb_device *d, enum cxusb_i2c_pathes path)
53{
54 struct cxusb_state *st = d->priv;
55 u8 o[2],i;
56
57 if (path == st->cur_i2c_path)
58 return;
59
60 o[0] = IOCTL_SET_I2C_PATH;
61 switch (path) {
62 case PATH_CX22702:
63 o[1] = 0;
64 break;
65 case PATH_TUNER_OTHER:
66 o[1] = 1;
67 break;
68 default:
69 err("unkown i2c path");
70 return;
71 }
72 cxusb_ctrl_msg(d,CMD_IOCTL,o,2,&i,1);
73
74 if (i != 0x01)
75 deb_info("i2c_path setting failed.\n");
76
77 st->cur_i2c_path = path;
78}
79
80static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
81{
82 struct dvb_usb_device *d = i2c_get_adapdata(adap);
83 int i;
84
85 if (down_interruptible(&d->i2c_sem) < 0)
86 return -EAGAIN;
87
88 if (num > 2)
89 warn("more than 2 i2c messages at a time is not handled yet. TODO.");
90
91 for (i = 0; i < num; i++) {
92
93 switch (msg[i].addr) {
94 case 0x63:
95 cxusb_set_i2c_path(d,PATH_CX22702);
96 break;
97 default:
98 cxusb_set_i2c_path(d,PATH_TUNER_OTHER);
99 break;
100 }
101
102 /* read request */
103 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
104 u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
105 obuf[0] = msg[i].len;
106 obuf[1] = msg[i+1].len;
107 obuf[2] = msg[i].addr;
108 memcpy(&obuf[3],msg[i].buf,msg[i].len);
109
110 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
111 obuf, 3+msg[i].len,
112 ibuf, 1+msg[i+1].len) < 0)
113 break;
114
115 if (ibuf[0] != 0x08)
116 deb_info("i2c read could have been failed\n");
117
118 memcpy(msg[i+1].buf,&ibuf[1],msg[i+1].len);
119
120 i++;
121 } else { /* write */
122 u8 obuf[2+msg[i].len], ibuf;
123 obuf[0] = msg[i].addr;
124 obuf[1] = msg[i].len;
125 memcpy(&obuf[2],msg[i].buf,msg[i].len);
126
127 if (cxusb_ctrl_msg(d,CMD_I2C_WRITE, obuf, 2+msg[i].len, &ibuf,1) < 0)
128 break;
129 if (ibuf != 0x08)
130 deb_info("i2c write could have been failed\n");
131 }
132 }
133
134 up(&d->i2c_sem);
135 return i;
136}
137
138static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
139{
140 return I2C_FUNC_I2C;
141}
142
143static struct i2c_algorithm cxusb_i2c_algo = {
144 .name = "Conexant USB I2C algorithm",
145 .id = I2C_ALGO_BIT,
146 .master_xfer = cxusb_i2c_xfer,
147 .functionality = cxusb_i2c_func,
148};
149
150static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
151{
152 return 0;
153}
154
155static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff)
156{
157 u8 buf[2] = { 0x03, 0x00 };
158 if (onoff)
159 cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0);
160 else
161 cxusb_ctrl_msg(d,0x37, NULL, 0, NULL, 0);
162
163 return 0;
164}
165
166struct cx22702_config cxusb_cx22702_config = {
167 .demod_address = 0x63,
168
169 .output_mode = CX22702_PARALLEL_OUTPUT,
170
171 .pll_init = dvb_usb_pll_init_i2c,
172 .pll_set = dvb_usb_pll_set_i2c,
173};
174
175/* Callbacks for DVB USB */
176static int cxusb_tuner_attach(struct dvb_usb_device *d)
177{
178 u8 bpll[4] = { 0x0b, 0xdc, 0x9c, 0xa0 };
179 d->pll_addr = 0x61;
180 memcpy(d->pll_init,bpll,4);
181 d->pll_desc = &dvb_pll_fmd1216me;
182 return 0;
183}
184
185static int cxusb_frontend_attach(struct dvb_usb_device *d)
186{
187 u8 buf[2] = { 0x03, 0x00 };
188 u8 b = 0;
189
190 if (usb_set_interface(d->udev,0,0) < 0)
191 err("set interface to alts=0 failed");
192
193 cxusb_ctrl_msg(d,0xde,&b,0,NULL,0);
194 cxusb_set_i2c_path(d,PATH_TUNER_OTHER);
195 cxusb_ctrl_msg(d,CMD_POWER_OFF, NULL, 0, &b, 1);
196
197 if (usb_set_interface(d->udev,0,6) < 0)
198 err("set interface failed");
199
200 cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0);
201 cxusb_set_i2c_path(d,PATH_CX22702);
202 cxusb_ctrl_msg(d,CMD_POWER_ON, NULL, 0, &b, 1);
203
204 if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL)
205 return 0;
206
207 return -EIO;
208}
209
210/* DVB USB Driver stuff */
211static struct dvb_usb_properties cxusb_properties;
212
213static int cxusb_probe(struct usb_interface *intf,
214 const struct usb_device_id *id)
215{
216 return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE);
217}
218
219static struct usb_device_id cxusb_table [] = {
220 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
221 {} /* Terminating entry */
222};
223MODULE_DEVICE_TABLE (usb, cxusb_table);
224
225static struct dvb_usb_properties cxusb_properties = {
226 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
227
228 .usb_ctrl = CYPRESS_FX2,
229
230 .size_of_priv = sizeof(struct cxusb_state),
231
232 .streaming_ctrl = cxusb_streaming_ctrl,
233 .power_ctrl = cxusb_power_ctrl,
234 .frontend_attach = cxusb_frontend_attach,
235 .tuner_attach = cxusb_tuner_attach,
236
237 .i2c_algo = &cxusb_i2c_algo,
238
239 .generic_bulk_ctrl_endpoint = 0x01,
240 /* parameter for the MPEG2-data transfer */
241 .urb = {
242 .type = DVB_USB_ISOC,
243 .count = 5,
244 .endpoint = 0x02,
245 .u = {
246 .isoc = {
247 .framesperurb = 32,
248 .framesize = 940,
249 .interval = 5,
250 }
251 }
252 },
253
254 .num_device_descs = 1,
255 .devices = {
256 { "Medion MD95700 (MDUSBTV-HYBRID)",
257 { NULL },
258 { &cxusb_table[0], NULL },
259 },
260 }
261};
262
263static struct usb_driver cxusb_driver = {
264 .owner = THIS_MODULE,
265 .name = "dvb_usb_cxusb",
266 .probe = cxusb_probe,
267 .disconnect = dvb_usb_device_exit,
268 .id_table = cxusb_table,
269};
270
271/* module stuff */
272static int __init cxusb_module_init(void)
273{
274 int result;
275 if ((result = usb_register(&cxusb_driver))) {
276 err("usb_register failed. Error number %d",result);
277 return result;
278 }
279
280 return 0;
281}
282
283static void __exit cxusb_module_exit(void)
284{
285 /* deregister this driver from the USB subsystem */
286 usb_deregister(&cxusb_driver);
287}
288
289module_init (cxusb_module_init);
290module_exit (cxusb_module_exit);
291
292MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
293MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
294MODULE_VERSION("1.0-alpha");
295MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/cxusb.h b/drivers/media/dvb/dvb-usb/cxusb.h
new file mode 100644
index 000000000000..1d79016e3195
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/cxusb.h
@@ -0,0 +1,30 @@
1#ifndef _DVB_USB_CXUSB_H_
2#define _DVB_USB_CXUSB_H_
3
4#define DVB_USB_LOG_PREFIX "digitv"
5#include "dvb-usb.h"
6
7extern int dvb_usb_cxusb_debug;
8#define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
9
10/* usb commands - some of it are guesses, don't have a reference yet */
11#define CMD_I2C_WRITE 0x08
12#define CMD_I2C_READ 0x09
13
14#define CMD_IOCTL 0x0e
15#define IOCTL_SET_I2C_PATH 0x02
16
17#define CMD_POWER_OFF 0x50
18#define CMD_POWER_ON 0x51
19
20enum cxusb_i2c_pathes {
21 PATH_UNDEF = 0x00,
22 PATH_CX22702 = 0x01,
23 PATH_TUNER_OTHER = 0x02,
24};
25
26struct cxusb_state {
27 enum cxusb_i2c_pathes cur_i2c_path;
28};
29
30#endif
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c
index a0ffbb59fa14..828b5182e16c 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mb.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c
@@ -31,10 +31,17 @@ static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_device *d)
31 return 0; 31 return 0;
32} 32}
33 33
34/* some of the dibusb 1.1 device aren't equipped with the default tuner 34static int dibusb_thomson_tuner_attach(struct dvb_usb_device *d)
35{
36 d->pll_addr = 0x61;
37 d->pll_desc = &dvb_pll_tua6010xs;
38 return 0;
39}
40
41/* Some of the Artec 1.1 device aren't equipped with the default tuner
35 * (Thomson Cable), but with a Panasonic ENV77H11D5. This function figures 42 * (Thomson Cable), but with a Panasonic ENV77H11D5. This function figures
36 * this out. */ 43 * this out. */
37static int dibusb_dib3000mb_tuner_attach (struct dvb_usb_device *d) 44static int dibusb_tuner_probe_and_attach(struct dvb_usb_device *d)
38{ 45{
39 u8 b[2] = { 0,0 }, b2[1]; 46 u8 b[2] = { 0,0 }, b2[1];
40 int ret = 0; 47 int ret = 0;
@@ -59,8 +66,7 @@ static int dibusb_dib3000mb_tuner_attach (struct dvb_usb_device *d)
59 66
60 if (b2[0] == 0xfe) { 67 if (b2[0] == 0xfe) {
61 info("this device has the Thomson Cable onboard. Which is default."); 68 info("this device has the Thomson Cable onboard. Which is default.");
62 d->pll_addr = 0x61; 69 dibusb_thomson_tuner_attach(d);
63 d->pll_desc = &dvb_pll_tua6010xs;
64 } else { 70 } else {
65 u8 bpll[4] = { 0x0b, 0xf5, 0x85, 0xab }; 71 u8 bpll[4] = { 0x0b, 0xf5, 0x85, 0xab };
66 info("this device has the Panasonic ENV77H11D5 onboard."); 72 info("this device has the Panasonic ENV77H11D5 onboard.");
@@ -90,8 +96,8 @@ static int dibusb_probe(struct usb_interface *intf,
90 96
91/* do not change the order of the ID table */ 97/* do not change the order of the ID table */
92static struct usb_device_id dibusb_dib3000mb_table [] = { 98static struct usb_device_id dibusb_dib3000mb_table [] = {
93/* 00 */ { USB_DEVICE(USB_VID_AVERMEDIA_UNK, USB_PID_AVERMEDIA_DVBT_USB_COLD)}, 99/* 00 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_COLD)},
94/* 01 */ { USB_DEVICE(USB_VID_AVERMEDIA_UNK, USB_PID_AVERMEDIA_DVBT_USB_WARM)}, 100/* 01 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_WARM)},
95/* 02 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_COLD) }, 101/* 02 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_COLD) },
96/* 03 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_WARM) }, 102/* 03 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_WARM) },
97/* 04 */ { USB_DEVICE(USB_VID_COMPRO_UNK, USB_PID_COMPRO_DVBU2000_UNK_COLD) }, 103/* 04 */ { USB_DEVICE(USB_VID_COMPRO_UNK, USB_PID_COMPRO_DVBU2000_UNK_COLD) },
@@ -114,7 +120,17 @@ static struct usb_device_id dibusb_dib3000mb_table [] = {
114/* 21 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_COLD) }, 120/* 21 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_COLD) },
115/* 22 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_WARM) }, 121/* 22 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_WARM) },
116/* 23 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_COLD) }, 122/* 23 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_COLD) },
123
124/* device ID with default DIBUSB2_0-firmware and with the hacked firmware */
117/* 24 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_WARM) }, 125/* 24 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_WARM) },
126/* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) },
127/* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) },
128
129// #define DVB_USB_DIBUSB_MB_FAULTY_USB_IDs
130
131#ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs
132/* 27 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) },
133#endif
118 { } /* Terminating entry */ 134 { } /* Terminating entry */
119}; 135};
120MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table); 136MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table);
@@ -134,7 +150,7 @@ static struct dvb_usb_properties dibusb1_1_properties = {
134 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 150 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
135 .power_ctrl = dibusb_power_ctrl, 151 .power_ctrl = dibusb_power_ctrl,
136 .frontend_attach = dibusb_dib3000mb_frontend_attach, 152 .frontend_attach = dibusb_dib3000mb_frontend_attach,
137 .tuner_attach = dibusb_dib3000mb_tuner_attach, 153 .tuner_attach = dibusb_tuner_probe_and_attach,
138 154
139 .rc_interval = DEFAULT_RC_INTERVAL, 155 .rc_interval = DEFAULT_RC_INTERVAL,
140 .rc_key_map = dibusb_rc_keys, 156 .rc_key_map = dibusb_rc_keys,
@@ -156,7 +172,7 @@ static struct dvb_usb_properties dibusb1_1_properties = {
156 } 172 }
157 }, 173 },
158 174
159 .num_device_descs = 8, 175 .num_device_descs = 9,
160 .devices = { 176 .devices = {
161 { "AVerMedia AverTV DVBT USB1.1", 177 { "AVerMedia AverTV DVBT USB1.1",
162 { &dibusb_dib3000mb_table[0], NULL }, 178 { &dibusb_dib3000mb_table[0], NULL },
@@ -190,11 +206,17 @@ static struct dvb_usb_properties dibusb1_1_properties = {
190 { &dibusb_dib3000mb_table[19], NULL }, 206 { &dibusb_dib3000mb_table[19], NULL },
191 { &dibusb_dib3000mb_table[20], NULL }, 207 { &dibusb_dib3000mb_table[20], NULL },
192 }, 208 },
209 { "VideoWalker DVB-T USB",
210 { &dibusb_dib3000mb_table[25], NULL },
211 { &dibusb_dib3000mb_table[26], NULL },
212 },
193 } 213 }
194}; 214};
195 215
196static struct dvb_usb_properties dibusb1_1_an2235_properties = { 216static struct dvb_usb_properties dibusb1_1_an2235_properties = {
197 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, 217 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER,
218 .pid_filter_count = 16,
219
198 .usb_ctrl = CYPRESS_AN2235, 220 .usb_ctrl = CYPRESS_AN2235,
199 221
200 .firmware = "dvb-usb-dibusb-an2235-01.fw", 222 .firmware = "dvb-usb-dibusb-an2235-01.fw",
@@ -206,7 +228,7 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = {
206 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 228 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
207 .power_ctrl = dibusb_power_ctrl, 229 .power_ctrl = dibusb_power_ctrl,
208 .frontend_attach = dibusb_dib3000mb_frontend_attach, 230 .frontend_attach = dibusb_dib3000mb_frontend_attach,
209 .tuner_attach = dibusb_dib3000mb_tuner_attach, 231 .tuner_attach = dibusb_tuner_probe_and_attach,
210 232
211 .rc_interval = DEFAULT_RC_INTERVAL, 233 .rc_interval = DEFAULT_RC_INTERVAL,
212 .rc_key_map = dibusb_rc_keys, 234 .rc_key_map = dibusb_rc_keys,
@@ -228,20 +250,32 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = {
228 } 250 }
229 }, 251 },
230 252
253#ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs
254 .num_device_descs = 2,
255#else
231 .num_device_descs = 1, 256 .num_device_descs = 1,
257#endif
232 .devices = { 258 .devices = {
233 { "Artec T1 USB1.1 TVBOX with AN2235", 259 { "Artec T1 USB1.1 TVBOX with AN2235",
234 { &dibusb_dib3000mb_table[20], NULL }, 260 { &dibusb_dib3000mb_table[20], NULL },
235 { &dibusb_dib3000mb_table[21], NULL }, 261 { &dibusb_dib3000mb_table[21], NULL },
236 }, 262 },
263#ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs
264 { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)",
265 { &dibusb_dib3000mb_table[27], NULL },
266 { NULL },
267 },
268#endif
237 } 269 }
238}; 270};
239 271
240static struct dvb_usb_properties dibusb2_0b_properties = { 272static struct dvb_usb_properties dibusb2_0b_properties = {
241 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, 273 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER,
274 .pid_filter_count = 32,
275
242 .usb_ctrl = CYPRESS_FX2, 276 .usb_ctrl = CYPRESS_FX2,
243 277
244 .firmware = "dvb-usb-adstech-usb2-01.fw", 278 .firmware = "dvb-usb-adstech-usb2-02.fw",
245 279
246 .size_of_priv = sizeof(struct dibusb_state), 280 .size_of_priv = sizeof(struct dibusb_state),
247 281
@@ -250,7 +284,7 @@ static struct dvb_usb_properties dibusb2_0b_properties = {
250 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 284 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
251 .power_ctrl = dibusb2_0_power_ctrl, 285 .power_ctrl = dibusb2_0_power_ctrl,
252 .frontend_attach = dibusb_dib3000mb_frontend_attach, 286 .frontend_attach = dibusb_dib3000mb_frontend_attach,
253 .tuner_attach = dibusb_dib3000mb_tuner_attach, 287 .tuner_attach = dibusb_thomson_tuner_attach,
254 288
255 .rc_interval = DEFAULT_RC_INTERVAL, 289 .rc_interval = DEFAULT_RC_INTERVAL,
256 .rc_key_map = dibusb_rc_keys, 290 .rc_key_map = dibusb_rc_keys,
@@ -272,18 +306,18 @@ static struct dvb_usb_properties dibusb2_0b_properties = {
272 } 306 }
273 }, 307 },
274 308
275 .num_device_descs = 2, 309 .num_device_descs = 1,
276 .devices = { 310 .devices = {
277 { "KWorld/ADSTech Instant DVB-T USB 2.0", 311 { "KWorld/ADSTech Instant DVB-T USB 2.0",
278 { &dibusb_dib3000mb_table[23], NULL }, 312 { &dibusb_dib3000mb_table[23], NULL },
279 { &dibusb_dib3000mb_table[24], NULL }, /* device ID with default DIBUSB2_0-firmware */ 313 { &dibusb_dib3000mb_table[24], NULL },
280 }, 314 },
281 } 315 }
282}; 316};
283 317
284static struct usb_driver dibusb_driver = { 318static struct usb_driver dibusb_driver = {
285 .owner = THIS_MODULE, 319 .owner = THIS_MODULE,
286 .name = "DiBcom based USB DVB-T devices (DiB3000M-B based)", 320 .name = "dvb_usb_dibusb_mb",
287 .probe = dibusb_probe, 321 .probe = dibusb_probe,
288 .disconnect = dvb_usb_device_exit, 322 .disconnect = dvb_usb_device_exit,
289 .id_table = dibusb_dib3000mb_table, 323 .id_table = dibusb_dib3000mb_table,
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c
index aad8ed3fe005..e9dac430f37d 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mc.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c
@@ -83,7 +83,7 @@ static struct dvb_usb_properties dibusb_mc_properties = {
83 83
84static struct usb_driver dibusb_mc_driver = { 84static struct usb_driver dibusb_mc_driver = {
85 .owner = THIS_MODULE, 85 .owner = THIS_MODULE,
86 .name = "DiBcom based USB2.0 DVB-T (DiB3000M-C/P based) devices", 86 .name = "dvb_usb_dibusb_mc",
87 .probe = dibusb_mc_probe, 87 .probe = dibusb_mc_probe,
88 .disconnect = dvb_usb_device_exit, 88 .disconnect = dvb_usb_device_exit,
89 .id_table = dibusb_dib3000mc_table, 89 .id_table = dibusb_dib3000mc_table,
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index 5acf3fde9522..9a676afc1d6e 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -1,10 +1,9 @@
1/* DVB USB compliant linux driver for Nebula Electronics uDigiTV DVB-T USB2.0 1/* DVB USB compliant linux driver for Nebula Electronics uDigiTV DVB-T USB2.0
2 * receiver 2 * receiver
3 * 3 *
4 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de) and 4 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
5 * Allan Third (allan.third@cs.man.ac.uk)
6 * 5 *
7 * partly based on the SDK published by Nebula Electronics (TODO do we want this line ?) 6 * partly based on the SDK published by Nebula Electronics
8 * 7 *
9 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free 9 * under the terms of the GNU General Public License as published by the Free
@@ -38,7 +37,7 @@ static int digitv_ctrl_msg(struct dvb_usb_device *d,
38 dvb_usb_generic_write(d,sndbuf,7); 37 dvb_usb_generic_write(d,sndbuf,7);
39 } else { 38 } else {
40 dvb_usb_generic_rw(d,sndbuf,7,rcvbuf,7,10); 39 dvb_usb_generic_rw(d,sndbuf,7,rcvbuf,7,10);
41 memcpy(&rbuf,&rcvbuf[3],rlen); 40 memcpy(rbuf,&rcvbuf[3],rlen);
42 } 41 }
43 return 0; 42 return 0;
44} 43}
@@ -95,41 +94,20 @@ static int digitv_identify_state (struct usb_device *udev, struct
95 94
96static int digitv_mt352_demod_init(struct dvb_frontend *fe) 95static int digitv_mt352_demod_init(struct dvb_frontend *fe)
97{ 96{
98 static u8 mt352_clock_config[] = { 0x89, 0x38, 0x2d }; 97 static u8 reset_buf[] = { 0x89, 0x38, 0x8a, 0x2d, 0x50, 0x80 };
99 static u8 mt352_reset[] = { 0x50, 0x80 }; 98 static u8 init_buf[] = { 0x68, 0xa0, 0x8e, 0x40, 0x53, 0x50,
100 static u8 mt352_mclk_ratio[] = { 0x8b, 0x00 }; 99 0x67, 0x20, 0x7d, 0x01, 0x7c, 0x00, 0x7a, 0x00,
101 100 0x79, 0x20, 0x57, 0x05, 0x56, 0x31, 0x88, 0x0f,
102 static u8 mt352_agc_cfg[] = { 0x68, 0xa0 }; 101 0x75, 0x32 };
103 static u8 mt352_adc_ctl_1_cfg[] = { 0x8E, 0xa0 }; 102 int i;
104 static u8 mt352_acq_ctl[] = { 0x53, 0x50 };
105 static u8 mt352_agc_target[] = { 0x67, 0x20 };
106
107 static u8 mt352_rs_err_per[] = { 0x7c, 0x00, 0x01 };
108 static u8 mt352_snr_select[] = { 0x79, 0x00, 0x20 };
109
110 static u8 mt352_input_freq_1[] = { 0x56, 0x31, 0x05 };
111 103
112 static u8 mt352_scan_ctl[] = { 0x88, 0x0f }; 104 for (i = 0; i < ARRAY_SIZE(reset_buf); i += 2)
113 static u8 mt352_capt_range[] = { 0x75, 0x32 }; 105 mt352_write(fe, &reset_buf[i], 2);
114 106
115 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
116 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
117 msleep(1); 107 msleep(1);
118 mt352_write(fe, mt352_mclk_ratio, sizeof(mt352_mclk_ratio));
119
120 mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
121 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
122 mt352_write(fe, mt352_acq_ctl, sizeof(mt352_acq_ctl));
123 mt352_write(fe, mt352_agc_target, sizeof(mt352_agc_target));
124
125
126 mt352_write(fe, mt352_rs_err_per, sizeof(mt352_rs_err_per));
127 mt352_write(fe, mt352_snr_select, sizeof(mt352_snr_select));
128 108
129 mt352_write(fe, mt352_input_freq_1, sizeof(mt352_input_freq_1)); 109 for (i = 0; i < ARRAY_SIZE(init_buf); i += 2)
130 110 mt352_write(fe, &init_buf[i], 2);
131 mt352_write(fe, mt352_scan_ctl, sizeof(mt352_scan_ctl));
132 mt352_write(fe, mt352_capt_range, sizeof(mt352_capt_range));
133 111
134 return 0; 112 return 0;
135} 113}
@@ -137,7 +115,7 @@ static int digitv_mt352_demod_init(struct dvb_frontend *fe)
137static struct mt352_config digitv_mt352_config = { 115static struct mt352_config digitv_mt352_config = {
138 .demod_address = 0x0, /* ignored by the digitv anyway */ 116 .demod_address = 0x0, /* ignored by the digitv anyway */
139 .demod_init = digitv_mt352_demod_init, 117 .demod_init = digitv_mt352_demod_init,
140 .pll_set = NULL, /* TODO */ 118 .pll_set = dvb_usb_pll_set,
141}; 119};
142 120
143static struct nxt6000_config digitv_nxt6000_config = { 121static struct nxt6000_config digitv_nxt6000_config = {
@@ -150,9 +128,9 @@ static struct nxt6000_config digitv_nxt6000_config = {
150 128
151static int digitv_frontend_attach(struct dvb_usb_device *d) 129static int digitv_frontend_attach(struct dvb_usb_device *d)
152{ 130{
153 if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) == NULL) 131 if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL)
154 return 0; 132 return 0;
155 if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) == NULL) { 133 if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) {
156 134
157 warn("nxt6000 support is not done yet, in fact you are one of the first " 135 warn("nxt6000 support is not done yet, in fact you are one of the first "
158 "person who wants to use this device in Linux. Please report to " 136 "person who wants to use this device in Linux. Please report to "
@@ -163,6 +141,13 @@ static int digitv_frontend_attach(struct dvb_usb_device *d)
163 return -EIO; 141 return -EIO;
164} 142}
165 143
144static int digitv_tuner_attach(struct dvb_usb_device *d)
145{
146 d->pll_addr = 0x60;
147 d->pll_desc = &dvb_pll_tded4;
148 return 0;
149}
150
166static struct dvb_usb_rc_key digitv_rc_keys[] = { 151static struct dvb_usb_rc_key digitv_rc_keys[] = {
167 { 0x00, 0x16, KEY_POWER }, /* dummy key */ 152 { 0x00, 0x16, KEY_POWER }, /* dummy key */
168}; 153};
@@ -184,7 +169,6 @@ int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
184 return 0; 169 return 0;
185} 170}
186 171
187
188/* DVB USB Driver stuff */ 172/* DVB USB Driver stuff */
189static struct dvb_usb_properties digitv_properties; 173static struct dvb_usb_properties digitv_properties;
190 174
@@ -208,13 +192,8 @@ static struct dvb_usb_properties digitv_properties = {
208 192
209 .size_of_priv = 0, 193 .size_of_priv = 0,
210 194
211 .streaming_ctrl = NULL,
212 .pid_filter = NULL,
213 .pid_filter_ctrl = NULL,
214 .power_ctrl = NULL,
215 .frontend_attach = digitv_frontend_attach, 195 .frontend_attach = digitv_frontend_attach,
216 .tuner_attach = NULL, // digitv_tuner_attach, 196 .tuner_attach = digitv_tuner_attach,
217 .read_mac_address = NULL,
218 197
219 .rc_interval = 1000, 198 .rc_interval = 1000,
220 .rc_key_map = digitv_rc_keys, 199 .rc_key_map = digitv_rc_keys,
@@ -238,7 +217,7 @@ static struct dvb_usb_properties digitv_properties = {
238 } 217 }
239 }, 218 },
240 219
241 .num_device_descs = 2, 220 .num_device_descs = 1,
242 .devices = { 221 .devices = {
243 { "Nebula Electronics uDigiTV DVB-T USB2.0)", 222 { "Nebula Electronics uDigiTV DVB-T USB2.0)",
244 { &digitv_table[0], NULL }, 223 { &digitv_table[0], NULL },
@@ -249,7 +228,7 @@ static struct dvb_usb_properties digitv_properties = {
249 228
250static struct usb_driver digitv_driver = { 229static struct usb_driver digitv_driver = {
251 .owner = THIS_MODULE, 230 .owner = THIS_MODULE,
252 .name = "Nebula Electronics uDigiTV DVB-T USB2.0 device", 231 .name = "dvb_usb_digitv",
253 .probe = digitv_probe, 232 .probe = digitv_probe,
254 .disconnect = dvb_usb_device_exit, 233 .disconnect = dvb_usb_device_exit,
255 .id_table = digitv_table, 234 .id_table = digitv_table,
diff --git a/drivers/media/dvb/dvb-usb/dtt200u-fe.c b/drivers/media/dvb/dvb-usb/dtt200u-fe.c
index d17d768038c6..b032523b07bc 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u-fe.c
+++ b/drivers/media/dvb/dvb-usb/dtt200u-fe.c
@@ -1,5 +1,5 @@
1/* Frontend part of the Linux driver for the Yakumo/Hama/Typhoon DVB-T 1/* Frontend part of the Linux driver for the WideView/ Yakumo/ Hama/
2 * USB2.0 receiver. 2 * Typhoon/ Yuan DVB-T USB2.0 receiver.
3 * 3 *
4 * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de> 4 * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de>
5 * 5 *
@@ -14,61 +14,58 @@
14struct dtt200u_fe_state { 14struct dtt200u_fe_state {
15 struct dvb_usb_device *d; 15 struct dvb_usb_device *d;
16 16
17 fe_status_t stat;
18
17 struct dvb_frontend_parameters fep; 19 struct dvb_frontend_parameters fep;
18 struct dvb_frontend frontend; 20 struct dvb_frontend frontend;
19}; 21};
20 22
21#define moan(which,what) info("unexpected value in '%s' for cmd '%02x' - please report to linux-dvb@linuxtv.org",which,what)
22
23static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat) 23static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat)
24{ 24{
25 struct dtt200u_fe_state *state = fe->demodulator_priv; 25 struct dtt200u_fe_state *state = fe->demodulator_priv;
26 u8 bw = GET_TUNE_STAT; 26 u8 st = GET_TUNE_STATUS, b[3];
27 u8 br[3] = { 0 }; 27
28// u8 bdeb[5] = { 0 }; 28 dvb_usb_generic_rw(state->d,&st,1,b,3,0);
29 29
30 dvb_usb_generic_rw(state->d,&bw,1,br,3,0); 30 switch (b[0]) {
31 switch (br[0]) {
32 case 0x01: 31 case 0x01:
33 *stat = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; 32 *stat = FE_HAS_SIGNAL | FE_HAS_CARRIER |
33 FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
34 break; 34 break;
35 case 0x00: 35 case 0x00: /* pending */
36 *stat = 0; 36 *stat = FE_TIMEDOUT; /* during set_frontend */
37 break; 37 break;
38 default: 38 default:
39 moan("br[0]",GET_TUNE_STAT); 39 case 0x02: /* failed */
40 *stat = 0;
40 break; 41 break;
41 } 42 }
42
43// bw[0] = 0x88;
44// dvb_usb_generic_rw(state->d,bw,1,bdeb,5,0);
45
46// deb_info("%02x: %02x %02x %02x %02x %02x\n",bw[0],bdeb[0],bdeb[1],bdeb[2],bdeb[3],bdeb[4]);
47
48 return 0; 43 return 0;
49} 44}
45
50static int dtt200u_fe_read_ber(struct dvb_frontend* fe, u32 *ber) 46static int dtt200u_fe_read_ber(struct dvb_frontend* fe, u32 *ber)
51{ 47{
52 struct dtt200u_fe_state *state = fe->demodulator_priv; 48 struct dtt200u_fe_state *state = fe->demodulator_priv;
53 u8 bw = GET_BER; 49 u8 bw = GET_VIT_ERR_CNT,b[3];
54 *ber = 0; 50 dvb_usb_generic_rw(state->d,&bw,1,b,3,0);
55 dvb_usb_generic_rw(state->d,&bw,1,(u8*) ber,3,0); 51 *ber = (b[0] << 16) | (b[1] << 8) | b[2];
56 return 0; 52 return 0;
57} 53}
58 54
59static int dtt200u_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) 55static int dtt200u_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
60{ 56{
61 struct dtt200u_fe_state *state = fe->demodulator_priv; 57 struct dtt200u_fe_state *state = fe->demodulator_priv;
62 u8 bw = GET_UNK; 58 u8 bw = GET_RS_UNCOR_BLK_CNT,b[2];
63 *unc = 0; 59
64 dvb_usb_generic_rw(state->d,&bw,1,(u8*) unc,3,0); 60 dvb_usb_generic_rw(state->d,&bw,1,b,2,0);
61 *unc = (b[0] << 8) | b[1];
65 return 0; 62 return 0;
66} 63}
67 64
68static int dtt200u_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength) 65static int dtt200u_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
69{ 66{
70 struct dtt200u_fe_state *state = fe->demodulator_priv; 67 struct dtt200u_fe_state *state = fe->demodulator_priv;
71 u8 bw = GET_SIG_STRENGTH, b; 68 u8 bw = GET_AGC, b;
72 dvb_usb_generic_rw(state->d,&bw,1,&b,1,0); 69 dvb_usb_generic_rw(state->d,&bw,1,&b,1,0);
73 *strength = (b << 8) | b; 70 *strength = (b << 8) | b;
74 return 0; 71 return 0;
@@ -86,7 +83,7 @@ static int dtt200u_fe_read_snr(struct dvb_frontend* fe, u16 *snr)
86static int dtt200u_fe_init(struct dvb_frontend* fe) 83static int dtt200u_fe_init(struct dvb_frontend* fe)
87{ 84{
88 struct dtt200u_fe_state *state = fe->demodulator_priv; 85 struct dtt200u_fe_state *state = fe->demodulator_priv;
89 u8 b = RESET_DEMOD; 86 u8 b = SET_INIT;
90 return dvb_usb_generic_write(state->d,&b,1); 87 return dvb_usb_generic_write(state->d,&b,1);
91} 88}
92 89
@@ -98,8 +95,8 @@ static int dtt200u_fe_sleep(struct dvb_frontend* fe)
98static int dtt200u_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) 95static int dtt200u_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
99{ 96{
100 tune->min_delay_ms = 1500; 97 tune->min_delay_ms = 1500;
101 tune->step_size = 166667; 98 tune->step_size = 0;
102 tune->max_drift = 166667 * 2; 99 tune->max_drift = 0;
103 return 0; 100 return 0;
104} 101}
105 102
@@ -107,27 +104,32 @@ static int dtt200u_fe_set_frontend(struct dvb_frontend* fe,
107 struct dvb_frontend_parameters *fep) 104 struct dvb_frontend_parameters *fep)
108{ 105{
109 struct dtt200u_fe_state *state = fe->demodulator_priv; 106 struct dtt200u_fe_state *state = fe->demodulator_priv;
107 int i;
108 fe_status_t st;
110 u16 freq = fep->frequency / 250000; 109 u16 freq = fep->frequency / 250000;
111 u8 bw,bwbuf[2] = { SET_BANDWIDTH, 0 }, freqbuf[3] = { SET_FREQUENCY, 0, 0 }; 110 u8 bwbuf[2] = { SET_BANDWIDTH, 0 },freqbuf[3] = { SET_RF_FREQ, 0, 0 };
112 111
113 switch (fep->u.ofdm.bandwidth) { 112 switch (fep->u.ofdm.bandwidth) {
114 case BANDWIDTH_8_MHZ: bw = 8; break; 113 case BANDWIDTH_8_MHZ: bwbuf[1] = 8; break;
115 case BANDWIDTH_7_MHZ: bw = 7; break; 114 case BANDWIDTH_7_MHZ: bwbuf[1] = 7; break;
116 case BANDWIDTH_6_MHZ: bw = 6; break; 115 case BANDWIDTH_6_MHZ: bwbuf[1] = 6; break;
117 case BANDWIDTH_AUTO: return -EOPNOTSUPP; 116 case BANDWIDTH_AUTO: return -EOPNOTSUPP;
118 default: 117 default:
119 return -EINVAL; 118 return -EINVAL;
120 } 119 }
121 deb_info("set_frontend\n");
122 120
123 bwbuf[1] = bw;
124 dvb_usb_generic_write(state->d,bwbuf,2); 121 dvb_usb_generic_write(state->d,bwbuf,2);
125 122
126 freqbuf[1] = freq & 0xff; 123 freqbuf[1] = freq & 0xff;
127 freqbuf[2] = (freq >> 8) & 0xff; 124 freqbuf[2] = (freq >> 8) & 0xff;
128 dvb_usb_generic_write(state->d,freqbuf,3); 125 dvb_usb_generic_write(state->d,freqbuf,3);
129 126
130 memcpy(&state->fep,fep,sizeof(struct dvb_frontend_parameters)); 127 for (i = 0; i < 30; i++) {
128 msleep(20);
129 dtt200u_fe_read_status(fe, &st);
130 if (st & FE_TIMEDOUT)
131 continue;
132 }
131 133
132 return 0; 134 return 0;
133} 135}
@@ -174,7 +176,7 @@ success:
174 176
175static struct dvb_frontend_ops dtt200u_fe_ops = { 177static struct dvb_frontend_ops dtt200u_fe_ops = {
176 .info = { 178 .info = {
177 .name = "DTT200U (Yakumo/Typhoon/Hama) DVB-T", 179 .name = "WideView USB DVB-T",
178 .type = FE_OFDM, 180 .type = FE_OFDM,
179 .frequency_min = 44250000, 181 .frequency_min = 44250000,
180 .frequency_max = 867250000, 182 .frequency_max = 867250000,
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c
index fb2b5a2da137..47dba6e45968 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u.c
+++ b/drivers/media/dvb/dvb-usb/dtt200u.c
@@ -1,8 +1,10 @@
1/* DVB USB library compliant Linux driver for the Yakumo/Hama/Typhoon DVB-T 1/* DVB USB library compliant Linux driver for the WideView/ Yakumo/ Hama/
2 * USB2.0 receiver. 2 * Typhoon/ Yuan DVB-T USB2.0 receiver.
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
5 * 5 *
6 * Thanks to Steve Chang from WideView for providing support for the WT-220U.
7 *
6 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free 9 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, version 2. 10 * Software Foundation, version 2.
@@ -16,14 +18,24 @@ int dvb_usb_dtt200u_debug;
16module_param_named(debug,dvb_usb_dtt200u_debug, int, 0644); 18module_param_named(debug,dvb_usb_dtt200u_debug, int, 0644);
17MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS); 19MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS);
18 20
21static int dtt200u_power_ctrl(struct dvb_usb_device *d, int onoff)
22{
23 u8 b = SET_INIT;
24
25 if (onoff)
26 dvb_usb_generic_write(d,&b,2);
27
28 return 0;
29}
30
19static int dtt200u_streaming_ctrl(struct dvb_usb_device *d, int onoff) 31static int dtt200u_streaming_ctrl(struct dvb_usb_device *d, int onoff)
20{ 32{
21 u8 b_streaming[2] = { SET_TS_CTRL, onoff }; 33 u8 b_streaming[2] = { SET_STREAMING, onoff };
22 u8 b_rst_pid = RESET_PID_FILTER; 34 u8 b_rst_pid = RESET_PID_FILTER;
23 35
24 dvb_usb_generic_write(d,b_streaming,2); 36 dvb_usb_generic_write(d,b_streaming,2);
25 37
26 if (!onoff) 38 if (onoff == 0)
27 dvb_usb_generic_write(d,&b_rst_pid,1); 39 dvb_usb_generic_write(d,&b_rst_pid,1);
28 return 0; 40 return 0;
29} 41}
@@ -36,7 +48,7 @@ static int dtt200u_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int
36 b_pid[0] = SET_PID_FILTER; 48 b_pid[0] = SET_PID_FILTER;
37 b_pid[1] = index; 49 b_pid[1] = index;
38 b_pid[2] = pid & 0xff; 50 b_pid[2] = pid & 0xff;
39 b_pid[3] = (pid >> 8) & 0xff; 51 b_pid[3] = (pid >> 8) & 0x1f;
40 52
41 return dvb_usb_generic_write(d,b_pid,4); 53 return dvb_usb_generic_write(d,b_pid,4);
42} 54}
@@ -54,9 +66,9 @@ static struct dvb_usb_rc_key dtt200u_rc_keys[] = {
54 { 0x80, 0x08, KEY_5 }, 66 { 0x80, 0x08, KEY_5 },
55 { 0x80, 0x09, KEY_6 }, 67 { 0x80, 0x09, KEY_6 },
56 { 0x80, 0x0a, KEY_7 }, 68 { 0x80, 0x0a, KEY_7 },
57 { 0x00, 0x0c, KEY_ZOOM }, 69 { 0x80, 0x0c, KEY_ZOOM },
58 { 0x80, 0x0d, KEY_0 }, 70 { 0x80, 0x0d, KEY_0 },
59 { 0x00, 0x0e, KEY_SELECT }, 71 { 0x80, 0x0e, KEY_SELECT },
60 { 0x80, 0x12, KEY_POWER }, 72 { 0x80, 0x12, KEY_POWER },
61 { 0x80, 0x1a, KEY_CHANNELUP }, 73 { 0x80, 0x1a, KEY_CHANNELUP },
62 { 0x80, 0x1b, KEY_8 }, 74 { 0x80, 0x1b, KEY_8 },
@@ -66,7 +78,7 @@ static struct dvb_usb_rc_key dtt200u_rc_keys[] = {
66 78
67static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 79static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
68{ 80{
69 u8 key[5],cmd = GET_RC_KEY; 81 u8 key[5],cmd = GET_RC_CODE;
70 dvb_usb_generic_rw(d,&cmd,1,key,5,0); 82 dvb_usb_generic_rw(d,&cmd,1,key,5,0);
71 dvb_usb_nec_rc_key_to_event(d,key,event,state); 83 dvb_usb_nec_rc_key_to_event(d,key,event,state);
72 if (key[0] != 0) 84 if (key[0] != 0)
@@ -81,32 +93,41 @@ static int dtt200u_frontend_attach(struct dvb_usb_device *d)
81} 93}
82 94
83static struct dvb_usb_properties dtt200u_properties; 95static struct dvb_usb_properties dtt200u_properties;
96static struct dvb_usb_properties wt220u_properties;
84 97
85static int dtt200u_usb_probe(struct usb_interface *intf, 98static int dtt200u_usb_probe(struct usb_interface *intf,
86 const struct usb_device_id *id) 99 const struct usb_device_id *id)
87{ 100{
88 return dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE); 101 if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE) == 0 ||
102 dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE) == 0)
103 return 0;
104
105 return -ENODEV;
89} 106}
90 107
91static struct usb_device_id dtt200u_usb_table [] = { 108static struct usb_device_id dtt200u_usb_table [] = {
92 { USB_DEVICE(USB_VID_AVERMEDIA_UNK, USB_PID_DTT200U_COLD) }, 109// { USB_DEVICE(0x04b4,0x8613) },
93 { USB_DEVICE(USB_VID_AVERMEDIA_UNK, USB_PID_DTT200U_WARM) }, 110 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) },
111 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) },
112 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) },
113 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) },
94 { 0 }, 114 { 0 },
95}; 115};
96MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); 116MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
97 117
98static struct dvb_usb_properties dtt200u_properties = { 118static struct dvb_usb_properties dtt200u_properties = {
99 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, 119 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
100 .pid_filter_count = 255, /* It is a guess, but there are at least 10 */ 120 .pid_filter_count = 15,
101 121
102 .usb_ctrl = CYPRESS_FX2, 122 .usb_ctrl = CYPRESS_FX2,
103 .firmware = "dvb-usb-dtt200u-01.fw", 123 .firmware = "dvb-usb-dtt200u-01.fw",
104 124
125 .power_ctrl = dtt200u_power_ctrl,
105 .streaming_ctrl = dtt200u_streaming_ctrl, 126 .streaming_ctrl = dtt200u_streaming_ctrl,
106 .pid_filter = dtt200u_pid_filter, 127 .pid_filter = dtt200u_pid_filter,
107 .frontend_attach = dtt200u_frontend_attach, 128 .frontend_attach = dtt200u_frontend_attach,
108 129
109 .rc_interval = 200, 130 .rc_interval = 300,
110 .rc_key_map = dtt200u_rc_keys, 131 .rc_key_map = dtt200u_rc_keys,
111 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), 132 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
112 .rc_query = dtt200u_rc_query, 133 .rc_query = dtt200u_rc_query,
@@ -127,18 +148,59 @@ static struct dvb_usb_properties dtt200u_properties = {
127 148
128 .num_device_descs = 1, 149 .num_device_descs = 1,
129 .devices = { 150 .devices = {
130 { .name = "Yakumo/Hama/Typhoon DVB-T USB2.0)", 151 { .name = "WideView/Yuan/Yakumo/Hama/Typhoon DVB-T USB2.0 (WT-200U)",
131 .cold_ids = { &dtt200u_usb_table[0], &dtt200u_usb_table[2] }, 152 .cold_ids = { &dtt200u_usb_table[0], NULL },
132 .warm_ids = { &dtt200u_usb_table[1], NULL }, 153 .warm_ids = { &dtt200u_usb_table[1], NULL },
133 }, 154 },
134 { 0 }, 155 { 0 },
135 } 156 }
136}; 157};
137 158
159static struct dvb_usb_properties wt220u_properties = {
160 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
161 .pid_filter_count = 15,
162
163 .usb_ctrl = CYPRESS_FX2,
164 .firmware = "dvb-usb-wt220u-01.fw",
165
166 .power_ctrl = dtt200u_power_ctrl,
167 .streaming_ctrl = dtt200u_streaming_ctrl,
168 .pid_filter = dtt200u_pid_filter,
169 .frontend_attach = dtt200u_frontend_attach,
170
171 .rc_interval = 300,
172 .rc_key_map = dtt200u_rc_keys,
173 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
174 .rc_query = dtt200u_rc_query,
175
176 .generic_bulk_ctrl_endpoint = 0x01,
177
178 /* parameter for the MPEG2-data transfer */
179 .urb = {
180 .type = DVB_USB_BULK,
181 .count = 7,
182 .endpoint = 0x02,
183 .u = {
184 .bulk = {
185 .buffersize = 4096,
186 }
187 }
188 },
189
190 .num_device_descs = 1,
191 .devices = {
192 { .name = "WideView WT-220U PenType Receiver (and clones)",
193 .cold_ids = { &dtt200u_usb_table[2], NULL },
194 .warm_ids = { &dtt200u_usb_table[3], NULL },
195 },
196 { 0 },
197 }
198};
199
138/* usb specific object needed to register this driver with the usb subsystem */ 200/* usb specific object needed to register this driver with the usb subsystem */
139static struct usb_driver dtt200u_usb_driver = { 201static struct usb_driver dtt200u_usb_driver = {
140 .owner = THIS_MODULE, 202 .owner = THIS_MODULE,
141 .name = "Yakumo/Hama/Typhoon DVB-T USB2.0", 203 .name = "dvb_usb_dtt200u",
142 .probe = dtt200u_usb_probe, 204 .probe = dtt200u_usb_probe,
143 .disconnect = dvb_usb_device_exit, 205 .disconnect = dvb_usb_device_exit,
144 .id_table = dtt200u_usb_table, 206 .id_table = dtt200u_usb_table,
@@ -166,6 +228,6 @@ module_init(dtt200u_usb_module_init);
166module_exit(dtt200u_usb_module_exit); 228module_exit(dtt200u_usb_module_exit);
167 229
168MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 230MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
169MODULE_DESCRIPTION("Driver for the Yakumo/Hama/Typhoon DVB-T USB2.0 device"); 231MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon DVB-T USB2.0 devices");
170MODULE_VERSION("1.0"); 232MODULE_VERSION("1.0");
171MODULE_LICENSE("GPL"); 233MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.h b/drivers/media/dvb/dvb-usb/dtt200u.h
index ed4142071518..6f1f3042e21a 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u.h
+++ b/drivers/media/dvb/dvb-usb/dtt200u.h
@@ -1,5 +1,5 @@
1/* Common header file of Linux driver for the Yakumo/Hama/Typhoon DVB-T 1/* Common header file of Linux driver for the WideView/ Yakumo/ Hama/
2 * USB2.0 receiver. 2 * Typhoon/ Yuan DVB-T USB2.0 receiver.
3 * 3 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
5 * 5 *
@@ -22,44 +22,34 @@ extern int dvb_usb_dtt200u_debug;
22/* guessed protocol description (reverse engineered): 22/* guessed protocol description (reverse engineered):
23 * read 23 * read
24 * 00 - USB type 0x02 for usb2.0, 0x01 for usb1.1 24 * 00 - USB type 0x02 for usb2.0, 0x01 for usb1.1
25 * 81 - <TS_LOCK> <current frequency divided by 250000>
26 * 82 - crash - do not touch
27 * 83 - crash - do not touch
28 * 84 - remote control
29 * 85 - crash - do not touch (OK, stop testing here)
30 * 88 - locking 2 bytes (0x80 0x40 == no signal, 0x89 0x20 == nice signal) 25 * 88 - locking 2 bytes (0x80 0x40 == no signal, 0x89 0x20 == nice signal)
31 * 89 - noise-to-signal
32 * 8a - unkown 1 byte - signal_strength
33 * 8c - ber ???
34 * 8d - ber
35 * 8e - unc
36 */ 26 */
37 27
38#define GET_SPEED 0x00 28#define GET_SPEED 0x00
39#define GET_TUNE_STAT 0x81 29#define GET_TUNE_STATUS 0x81
40#define GET_RC_KEY 0x84 30#define GET_RC_CODE 0x84
41#define GET_STATUS 0x88 31#define GET_CONFIGURATION 0x88
42#define GET_SNR 0x89 32#define GET_AGC 0x89
43#define GET_SIG_STRENGTH 0x8a 33#define GET_SNR 0x8a
44#define GET_UNK 0x8c 34#define GET_VIT_ERR_CNT 0x8c
45#define GET_BER 0x8d 35#define GET_RS_ERR_CNT 0x8d
46#define GET_UNC 0x8e 36#define GET_RS_UNCOR_BLK_CNT 0x8e
47 37
48/* write 38/* write
49 * 01 - reset the demod 39 * 01 - init
50 * 02 - frequency (divided by 250000) 40 * 02 - frequency (divided by 250000)
51 * 03 - bandwidth 41 * 03 - bandwidth
52 * 04 - pid table (index pid(7:0) pid(12:8)) 42 * 04 - pid table (index pid(7:0) pid(12:8))
53 * 05 - reset the pid table 43 * 05 - reset the pid table
54 * 08 - demod transfer enabled or not (FX2 transfer is enabled by default) 44 * 08 - transfer switch
55 */ 45 */
56 46
57#define RESET_DEMOD 0x01 47#define SET_INIT 0x01
58#define SET_FREQUENCY 0x02 48#define SET_RF_FREQ 0x02
59#define SET_BANDWIDTH 0x03 49#define SET_BANDWIDTH 0x03
60#define SET_PID_FILTER 0x04 50#define SET_PID_FILTER 0x04
61#define RESET_PID_FILTER 0x05 51#define RESET_PID_FILTER 0x05
62#define SET_TS_CTRL 0x08 52#define SET_STREAMING 0x08
63 53
64extern struct dvb_frontend * dtt200u_fe_attach(struct dvb_usb_device *d); 54extern struct dvb_frontend * dtt200u_fe_attach(struct dvb_usb_device *d);
65 55
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-common.h b/drivers/media/dvb/dvb-usb/dvb-usb-common.h
index 67e0d73fbceb..7300489d3e24 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-common.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-common.h
@@ -12,14 +12,16 @@
12#include "dvb-usb.h" 12#include "dvb-usb.h"
13 13
14extern int dvb_usb_debug; 14extern int dvb_usb_debug;
15extern int dvb_usb_disable_rc_polling;
15 16
16#define deb_info(args...) dprintk(dvb_usb_debug,0x01,args) 17#define deb_info(args...) dprintk(dvb_usb_debug,0x01,args)
17#define deb_xfer(args...) dprintk(dvb_usb_debug,0x02,args) 18#define deb_xfer(args...) dprintk(dvb_usb_debug,0x02,args)
18#define deb_pll(args...) dprintk(dvb_usb_debug,0x04,args) 19#define deb_pll(args...) dprintk(dvb_usb_debug,0x04,args)
19#define deb_ts(args...) dprintk(dvb_usb_debug,0x08,args) 20#define deb_ts(args...) dprintk(dvb_usb_debug,0x08,args)
20#define deb_err(args...) dprintk(dvb_usb_debug,0x10,args) 21#define deb_err(args...) dprintk(dvb_usb_debug,0x10,args)
21#define deb_rc(args...) dprintk(dvb_usb_debug,0x20,args) 22#define deb_rc(args...) dprintk(dvb_usb_debug,0x20,args)
22#define deb_fw(args...) dprintk(dvb_usb_debug,0x40,args) 23#define deb_fw(args...) dprintk(dvb_usb_debug,0x40,args)
24#define deb_mem(args...) dprintk(dvb_usb_debug,0x80,args)
23 25
24/* commonly used methods */ 26/* commonly used methods */
25extern int usb_cypress_load_firmware(struct usb_device *, const char *, int); 27extern int usb_cypress_load_firmware(struct usb_device *, const char *, int);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
index bdd72f779707..3491ff40885c 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
@@ -175,7 +175,7 @@ static int dvb_usb_fe_sleep(struct dvb_frontend *fe)
175int dvb_usb_fe_init(struct dvb_usb_device* d) 175int dvb_usb_fe_init(struct dvb_usb_device* d)
176{ 176{
177 if (d->props.frontend_attach == NULL) { 177 if (d->props.frontend_attach == NULL) {
178 err("strange '%s' don't want to attach a frontend.",d->desc->name); 178 err("strange '%s' doesn't want to attach a frontend.",d->desc->name);
179 return 0; 179 return 0;
180 } 180 }
181 181
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index bcb34191868b..794d513a8480 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -12,7 +12,7 @@
12/* Vendor IDs */ 12/* Vendor IDs */
13#define USB_VID_ADSTECH 0x06e1 13#define USB_VID_ADSTECH 0x06e1
14#define USB_VID_ANCHOR 0x0547 14#define USB_VID_ANCHOR 0x0547
15#define USB_VID_AVERMEDIA_UNK 0x14aa 15#define USB_VID_WIDEVIEW 0x14aa
16#define USB_VID_AVERMEDIA 0x07ca 16#define USB_VID_AVERMEDIA 0x07ca
17#define USB_VID_COMPRO 0x185b 17#define USB_VID_COMPRO 0x185b
18#define USB_VID_COMPRO_UNK 0x145f 18#define USB_VID_COMPRO_UNK 0x145f
@@ -24,6 +24,8 @@
24#define USB_VID_HANFTEK 0x15f4 24#define USB_VID_HANFTEK 0x15f4
25#define USB_VID_HAUPPAUGE 0x2040 25#define USB_VID_HAUPPAUGE 0x2040
26#define USB_VID_HYPER_PALTEK 0x1025 26#define USB_VID_HYPER_PALTEK 0x1025
27#define USB_VID_KYE 0x0458
28#define USB_VID_MEDION 0x1660
27#define USB_VID_VISIONPLUS 0x13d3 29#define USB_VID_VISIONPLUS 0x13d3
28#define USB_VID_TWINHAN 0x1822 30#define USB_VID_TWINHAN 0x1822
29#define USB_VID_ULTIMA_ELECTRONIC 0x05d8 31#define USB_VID_ULTIMA_ELECTRONIC 0x05d8
@@ -70,6 +72,8 @@
70#define USB_PID_HANFTEK_UMT_010_WARM 0x0015 72#define USB_PID_HANFTEK_UMT_010_WARM 0x0015
71#define USB_PID_DTT200U_COLD 0x0201 73#define USB_PID_DTT200U_COLD 0x0201
72#define USB_PID_DTT200U_WARM 0x0301 74#define USB_PID_DTT200U_WARM 0x0301
75#define USB_PID_WT220U_COLD 0x0222
76#define USB_PID_WT220U_WARM 0x0221
73#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300 77#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300
74#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301 78#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301
75#define USB_PID_NEBULA_DIGITV 0x0201 79#define USB_PID_NEBULA_DIGITV 0x0201
@@ -78,6 +82,8 @@
78#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820 82#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820
79#define USB_PID_DVICO_BLUEBIRD_LGZ201_1 0xdb01 83#define USB_PID_DVICO_BLUEBIRD_LGZ201_1 0xdb01
80#define USB_PID_DVICO_BLUEBIRD_TH7579_2 0xdb11 84#define USB_PID_DVICO_BLUEBIRD_TH7579_2 0xdb11
81 85#define USB_PID_MEDION_MD95700 0x0932
86#define USB_PID_KYE_DVB_T_COLD 0x701e
87#define USB_PID_KYE_DVB_T_WARM 0x701f
82 88
83#endif 89#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index 3aadec974cf1..65f0c095abc9 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -18,6 +18,10 @@ int dvb_usb_debug;
18module_param_named(debug,dvb_usb_debug, int, 0644); 18module_param_named(debug,dvb_usb_debug, int, 0644);
19MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))." DVB_USB_DEBUG_STATUS); 19MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))." DVB_USB_DEBUG_STATUS);
20 20
21int dvb_usb_disable_rc_polling;
22module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644);
23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0).");
24
21/* general initialization functions */ 25/* general initialization functions */
22int dvb_usb_exit(struct dvb_usb_device *d) 26int dvb_usb_exit(struct dvb_usb_device *d)
23{ 27{
@@ -47,17 +51,17 @@ static int dvb_usb_init(struct dvb_usb_device *d)
47 51
48/* speed - when running at FULL speed we need a HW PID filter */ 52/* speed - when running at FULL speed we need a HW PID filter */
49 if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) { 53 if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) {
50 err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a HW PID filter)"); 54 err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)");
51 return -ENODEV; 55 return -ENODEV;
52 } 56 }
53 57
54 if ((d->udev->speed == USB_SPEED_FULL && d->props.caps & DVB_USB_HAS_PID_FILTER) || 58 if ((d->udev->speed == USB_SPEED_FULL && d->props.caps & DVB_USB_HAS_PID_FILTER) ||
55 (d->props.caps & DVB_USB_NEED_PID_FILTERING)) { 59 (d->props.caps & DVB_USB_NEED_PID_FILTERING)) {
56 info("will use the device's hw PID filter."); 60 info("will use the device's hardware PID filter (table count: %d).",d->props.pid_filter_count);
57 d->pid_filtering = 1; 61 d->pid_filtering = 1;
58 d->max_feed_count = d->props.pid_filter_count; 62 d->max_feed_count = d->props.pid_filter_count;
59 } else { 63 } else {
60 info("will pass the complete MPEG2 transport stream to the demuxer."); 64 info("will pass the complete MPEG2 transport stream to the software demuxer.");
61 d->pid_filtering = 0; 65 d->pid_filtering = 0;
62 d->max_feed_count = 255; 66 d->max_feed_count = 255;
63 } 67 }
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index 9f1e23f82bae..fc7800f1743e 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -21,6 +21,10 @@ static void dvb_usb_read_remote_control(void *data)
21 /* TODO: need a lock here. We can simply skip checking for the remote control 21 /* TODO: need a lock here. We can simply skip checking for the remote control
22 if we're busy. */ 22 if we're busy. */
23 23
24 /* when the parameter has been set to 1 via sysfs while the driver was running */
25 if (dvb_usb_disable_rc_polling)
26 return;
27
24 if (d->props.rc_query(d,&event,&state)) { 28 if (d->props.rc_query(d,&event,&state)) {
25 err("error while querying for an remote control event."); 29 err("error while querying for an remote control event.");
26 goto schedule; 30 goto schedule;
@@ -35,7 +39,7 @@ static void dvb_usb_read_remote_control(void *data)
35 d->last_event = event; 39 d->last_event = event;
36 case REMOTE_KEY_REPEAT: 40 case REMOTE_KEY_REPEAT:
37 deb_rc("key repeated\n"); 41 deb_rc("key repeated\n");
38 input_event(&d->rc_input_dev, EV_KEY, event, 1); 42 input_event(&d->rc_input_dev, EV_KEY, d->last_event, 1);
39 input_event(&d->rc_input_dev, EV_KEY, d->last_event, 0); 43 input_event(&d->rc_input_dev, EV_KEY, d->last_event, 0);
40 input_sync(&d->rc_input_dev); 44 input_sync(&d->rc_input_dev);
41 break; 45 break;
@@ -85,7 +89,9 @@ schedule:
85int dvb_usb_remote_init(struct dvb_usb_device *d) 89int dvb_usb_remote_init(struct dvb_usb_device *d)
86{ 90{
87 int i; 91 int i;
88 if (d->props.rc_key_map == NULL) 92 if (d->props.rc_key_map == NULL ||
93 d->props.rc_query == NULL ||
94 dvb_usb_disable_rc_polling)
89 return 0; 95 return 0;
90 96
91 /* Initialise the remote-control structures.*/ 97 /* Initialise the remote-control structures.*/
@@ -154,12 +160,12 @@ int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *d,
154 break; 160 break;
155 } 161 }
156 /* See if we can match the raw key code. */ 162 /* See if we can match the raw key code. */
157 for (i = 0; i < sizeof(keymap)/sizeof(struct dvb_usb_rc_key); i++) 163 for (i = 0; i < d->props.rc_key_map_size; i++)
158 if (keymap[i].custom == keybuf[1] && 164 if (keymap[i].custom == keybuf[1] &&
159 keymap[i].data == keybuf[3]) { 165 keymap[i].data == keybuf[3]) {
160 *event = keymap[i].event; 166 *event = keymap[i].event;
161 *state = REMOTE_KEY_PRESSED; 167 *state = REMOTE_KEY_PRESSED;
162 break; 168 return 0;
163 } 169 }
164 deb_err("key mapping failed - no appropriate key found in keymapping\n"); 170 deb_err("key mapping failed - no appropriate key found in keymapping\n");
165 break; 171 break;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
index 83d476fb410a..f5799a4c228e 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
@@ -24,11 +24,12 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
24 if ((ret = down_interruptible(&d->usb_sem))) 24 if ((ret = down_interruptible(&d->usb_sem)))
25 return ret; 25 return ret;
26 26
27 deb_xfer(">>> ");
27 debug_dump(wbuf,wlen,deb_xfer); 28 debug_dump(wbuf,wlen,deb_xfer);
28 29
29 ret = usb_bulk_msg(d->udev,usb_sndbulkpipe(d->udev, 30 ret = usb_bulk_msg(d->udev,usb_sndbulkpipe(d->udev,
30 d->props.generic_bulk_ctrl_endpoint), wbuf,wlen,&actlen, 31 d->props.generic_bulk_ctrl_endpoint), wbuf,wlen,&actlen,
31 2*HZ); 32 2000);
32 33
33 if (ret) 34 if (ret)
34 err("bulk message failed: %d (%d/%d)",ret,wlen,actlen); 35 err("bulk message failed: %d (%d/%d)",ret,wlen,actlen);
@@ -42,12 +43,14 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
42 43
43 ret = usb_bulk_msg(d->udev,usb_rcvbulkpipe(d->udev, 44 ret = usb_bulk_msg(d->udev,usb_rcvbulkpipe(d->udev,
44 d->props.generic_bulk_ctrl_endpoint),rbuf,rlen,&actlen, 45 d->props.generic_bulk_ctrl_endpoint),rbuf,rlen,&actlen,
45 2*HZ); 46 2000);
46 47
47 if (ret) 48 if (ret)
48 err("recv bulk message failed: %d",ret); 49 err("recv bulk message failed: %d",ret);
49 else 50 else {
51 deb_xfer("<<< ");
50 debug_dump(rbuf,actlen,deb_xfer); 52 debug_dump(rbuf,actlen,deb_xfer);
53 }
51 } 54 }
52 55
53 up(&d->usb_sem); 56 up(&d->usb_sem);
@@ -61,12 +64,19 @@ int dvb_usb_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len)
61} 64}
62EXPORT_SYMBOL(dvb_usb_generic_write); 65EXPORT_SYMBOL(dvb_usb_generic_write);
63 66
64static void dvb_usb_bulk_urb_complete(struct urb *urb, struct pt_regs *ptregs) 67
68/* URB stuff for streaming */
69static void dvb_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
65{ 70{
66 struct dvb_usb_device *d = urb->context; 71 struct dvb_usb_device *d = urb->context;
72 int ptype = usb_pipetype(urb->pipe);
73 int i;
74 u8 *b;
67 75
68 deb_ts("bulk urb completed. feedcount: %d, status: %d, length: %d\n",d->feedcount,urb->status, 76 deb_ts("'%s' urb completed. feedcount: %d, status: %d, length: %d/%d, pack_num: %d, errors: %d\n",
69 urb->actual_length); 77 ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", d->feedcount,
78 urb->status,urb->actual_length,urb->transfer_buffer_length,
79 urb->number_of_packets,urb->error_count);
70 80
71 switch (urb->status) { 81 switch (urb->status) {
72 case 0: /* success */ 82 case 0: /* success */
@@ -81,11 +91,33 @@ static void dvb_usb_bulk_urb_complete(struct urb *urb, struct pt_regs *ptregs)
81 break; 91 break;
82 } 92 }
83 93
84 if (d->feedcount > 0 && urb->actual_length > 0) { 94 if (d->feedcount > 0) {
85 if (d->state & DVB_USB_STATE_DVB) 95 if (d->state & DVB_USB_STATE_DVB) {
86 dvb_dmx_swfilter(&d->demux, (u8*) urb->transfer_buffer,urb->actual_length); 96 switch (ptype) {
87 } else 97 case PIPE_ISOCHRONOUS:
88 deb_ts("URB dropped because of feedcount.\n"); 98 b = (u8 *) urb->transfer_buffer;
99 for (i = 0; i < urb->number_of_packets; i++) {
100 if (urb->iso_frame_desc[i].status != 0)
101 deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status);
102 else if (urb->iso_frame_desc[i].actual_length > 0) {
103 dvb_dmx_swfilter(&d->demux,b + urb->iso_frame_desc[i].offset,
104 urb->iso_frame_desc[i].actual_length);
105 }
106 urb->iso_frame_desc[i].status = 0;
107 urb->iso_frame_desc[i].actual_length = 0;
108 }
109 debug_dump(b,20,deb_ts);
110 break;
111 case PIPE_BULK:
112 if (urb->actual_length > 0)
113 dvb_dmx_swfilter(&d->demux, (u8 *) urb->transfer_buffer,urb->actual_length);
114 break;
115 default:
116 err("unkown endpoint type in completition handler.");
117 return;
118 }
119 }
120 }
89 121
90 usb_submit_urb(urb,GFP_ATOMIC); 122 usb_submit_urb(urb,GFP_ATOMIC);
91} 123}
@@ -94,7 +126,7 @@ int dvb_usb_urb_kill(struct dvb_usb_device *d)
94{ 126{
95 int i; 127 int i;
96 for (i = 0; i < d->urbs_submitted; i++) { 128 for (i = 0; i < d->urbs_submitted; i++) {
97 deb_info("killing URB no. %d.\n",i); 129 deb_ts("killing URB no. %d.\n",i);
98 130
99 /* stop the URB */ 131 /* stop the URB */
100 usb_kill_urb(d->urb_list[i]); 132 usb_kill_urb(d->urb_list[i]);
@@ -107,9 +139,9 @@ int dvb_usb_urb_submit(struct dvb_usb_device *d)
107{ 139{
108 int i,ret; 140 int i,ret;
109 for (i = 0; i < d->urbs_initialized; i++) { 141 for (i = 0; i < d->urbs_initialized; i++) {
110 deb_info("submitting URB no. %d\n",i); 142 deb_ts("submitting URB no. %d\n",i);
111 if ((ret = usb_submit_urb(d->urb_list[i],GFP_ATOMIC))) { 143 if ((ret = usb_submit_urb(d->urb_list[i],GFP_ATOMIC))) {
112 err("could not submit URB no. %d - get them all back\n",i); 144 err("could not submit URB no. %d - get them all back",i);
113 dvb_usb_urb_kill(d); 145 dvb_usb_urb_kill(d);
114 return ret; 146 return ret;
115 } 147 }
@@ -118,32 +150,78 @@ int dvb_usb_urb_submit(struct dvb_usb_device *d)
118 return 0; 150 return 0;
119} 151}
120 152
121static int dvb_usb_bulk_urb_init(struct dvb_usb_device *d) 153static int dvb_usb_free_stream_buffers(struct dvb_usb_device *d)
122{ 154{
123 int i,bufsize = d->props.urb.count * d->props.urb.u.bulk.buffersize; 155 if (d->state & DVB_USB_STATE_URB_BUF) {
156 while (d->buf_num) {
157 d->buf_num--;
158 deb_mem("freeing buffer %d\n",d->buf_num);
159 usb_buffer_free(d->udev, d->buf_size,
160 d->buf_list[d->buf_num], d->dma_addr[d->buf_num]);
161 }
162 kfree(d->buf_list);
163 kfree(d->dma_addr);
164 }
165
166 d->state &= ~DVB_USB_STATE_URB_BUF;
124 167
125 deb_info("allocate %d bytes as buffersize for all URBs\n",bufsize); 168 return 0;
126 /* allocate the actual buffer for the URBs */ 169}
127 if ((d->buffer = usb_buffer_alloc(d->udev, bufsize, SLAB_ATOMIC, &d->dma_handle)) == NULL) { 170
128 deb_info("not enough memory for urb-buffer allocation.\n"); 171static int dvb_usb_allocate_stream_buffers(struct dvb_usb_device *d, int num, unsigned long size)
172{
173 d->buf_num = 0;
174 d->buf_size = size;
175
176 deb_mem("all in all I will use %lu bytes for streaming\n",num*size);
177
178 if ((d->buf_list = kmalloc(num*sizeof(u8 *), GFP_ATOMIC)) == NULL)
179 return -ENOMEM;
180
181 if ((d->dma_addr = kmalloc(num*sizeof(dma_addr_t), GFP_ATOMIC)) == NULL) {
182 kfree(d->buf_list);
129 return -ENOMEM; 183 return -ENOMEM;
130 } 184 }
131 deb_info("allocation successful\n"); 185 memset(d->buf_list,0,num*sizeof(u8 *));
132 memset(d->buffer,0,bufsize); 186 memset(d->dma_addr,0,num*sizeof(dma_addr_t));
133 187
134 d->state |= DVB_USB_STATE_URB_BUF; 188 d->state |= DVB_USB_STATE_URB_BUF;
135 189
190 for (d->buf_num = 0; d->buf_num < num; d->buf_num++) {
191 deb_mem("allocating buffer %d\n",d->buf_num);
192 if (( d->buf_list[d->buf_num] =
193 usb_buffer_alloc(d->udev, size, SLAB_ATOMIC,
194 &d->dma_addr[d->buf_num]) ) == NULL) {
195 deb_mem("not enough memory for urb-buffer allocation.\n");
196 dvb_usb_free_stream_buffers(d);
197 return -ENOMEM;
198 }
199 deb_mem("buffer %d: %p (dma: %d)\n",d->buf_num,d->buf_list[d->buf_num],d->dma_addr[d->buf_num]);
200 memset(d->buf_list[d->buf_num],0,size);
201 }
202 deb_mem("allocation successful\n");
203
204 return 0;
205}
206
207static int dvb_usb_bulk_urb_init(struct dvb_usb_device *d)
208{
209 int i;
210
211 if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count,
212 d->props.urb.u.bulk.buffersize)) < 0)
213 return i;
214
136 /* allocate the URBs */ 215 /* allocate the URBs */
137 for (i = 0; i < d->props.urb.count; i++) { 216 for (i = 0; i < d->props.urb.count; i++) {
138 if (!(d->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC))) { 217 if ((d->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL)
139 return -ENOMEM; 218 return -ENOMEM;
140 }
141 219
142 usb_fill_bulk_urb( d->urb_list[i], d->udev, 220 usb_fill_bulk_urb( d->urb_list[i], d->udev,
143 usb_rcvbulkpipe(d->udev,d->props.urb.endpoint), 221 usb_rcvbulkpipe(d->udev,d->props.urb.endpoint),
144 &d->buffer[i*d->props.urb.u.bulk.buffersize], 222 d->buf_list[i],
145 d->props.urb.u.bulk.buffersize, 223 d->props.urb.u.bulk.buffersize,
146 dvb_usb_bulk_urb_complete, d); 224 dvb_usb_urb_complete, d);
147 225
148 d->urb_list[i]->transfer_flags = 0; 226 d->urb_list[i]->transfer_flags = 0;
149 d->urbs_initialized++; 227 d->urbs_initialized++;
@@ -151,6 +229,47 @@ static int dvb_usb_bulk_urb_init(struct dvb_usb_device *d)
151 return 0; 229 return 0;
152} 230}
153 231
232static int dvb_usb_isoc_urb_init(struct dvb_usb_device *d)
233{
234 int i,j;
235
236 if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count,
237 d->props.urb.u.isoc.framesize*d->props.urb.u.isoc.framesperurb)) < 0)
238 return i;
239
240 /* allocate the URBs */
241 for (i = 0; i < d->props.urb.count; i++) {
242 struct urb *urb;
243 int frame_offset = 0;
244 if ((d->urb_list[i] =
245 usb_alloc_urb(d->props.urb.u.isoc.framesperurb,GFP_ATOMIC)) == NULL)
246 return -ENOMEM;
247
248 urb = d->urb_list[i];
249
250 urb->dev = d->udev;
251 urb->context = d;
252 urb->complete = dvb_usb_urb_complete;
253 urb->pipe = usb_rcvisocpipe(d->udev,d->props.urb.endpoint);
254 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
255 urb->interval = d->props.urb.u.isoc.interval;
256 urb->number_of_packets = d->props.urb.u.isoc.framesperurb;
257 urb->transfer_buffer_length = d->buf_size;
258 urb->transfer_buffer = d->buf_list[i];
259 urb->transfer_dma = d->dma_addr[i];
260
261 for (j = 0; j < d->props.urb.u.isoc.framesperurb; j++) {
262 urb->iso_frame_desc[j].offset = frame_offset;
263 urb->iso_frame_desc[j].length = d->props.urb.u.isoc.framesize;
264 frame_offset += d->props.urb.u.isoc.framesize;
265 }
266
267 d->urbs_initialized++;
268 }
269 return 0;
270
271}
272
154int dvb_usb_urb_init(struct dvb_usb_device *d) 273int dvb_usb_urb_init(struct dvb_usb_device *d)
155{ 274{
156 /* 275 /*
@@ -174,8 +293,7 @@ int dvb_usb_urb_init(struct dvb_usb_device *d)
174 case DVB_USB_BULK: 293 case DVB_USB_BULK:
175 return dvb_usb_bulk_urb_init(d); 294 return dvb_usb_bulk_urb_init(d);
176 case DVB_USB_ISOC: 295 case DVB_USB_ISOC:
177 err("isochronous transfer not yet implemented in dvb-usb."); 296 return dvb_usb_isoc_urb_init(d);
178 return -EINVAL;
179 default: 297 default:
180 err("unkown URB-type for data transfer."); 298 err("unkown URB-type for data transfer.");
181 return -EINVAL; 299 return -EINVAL;
@@ -191,7 +309,7 @@ int dvb_usb_urb_exit(struct dvb_usb_device *d)
191 if (d->state & DVB_USB_STATE_URB_LIST) { 309 if (d->state & DVB_USB_STATE_URB_LIST) {
192 for (i = 0; i < d->urbs_initialized; i++) { 310 for (i = 0; i < d->urbs_initialized; i++) {
193 if (d->urb_list[i] != NULL) { 311 if (d->urb_list[i] != NULL) {
194 deb_info("freeing URB no. %d.\n",i); 312 deb_mem("freeing URB no. %d.\n",i);
195 /* free the URBs */ 313 /* free the URBs */
196 usb_free_urb(d->urb_list[i]); 314 usb_free_urb(d->urb_list[i]);
197 } 315 }
@@ -202,10 +320,6 @@ int dvb_usb_urb_exit(struct dvb_usb_device *d)
202 d->state &= ~DVB_USB_STATE_URB_LIST; 320 d->state &= ~DVB_USB_STATE_URB_LIST;
203 } 321 }
204 322
205 if (d->state & DVB_USB_STATE_URB_BUF) 323 dvb_usb_free_stream_buffers(d);
206 usb_buffer_free(d->udev, d->props.urb.u.bulk.buffersize * d->props.urb.count,
207 d->buffer, d->dma_handle);
208
209 d->state &= ~DVB_USB_STATE_URB_BUF;
210 return 0; 324 return 0;
211} 325}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index abcee1943f64..a80567caf508 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -189,12 +189,13 @@ struct dvb_usb_properties {
189 struct { 189 struct {
190 int framesperurb; 190 int framesperurb;
191 int framesize; 191 int framesize;
192 int interval;
192 } isoc; 193 } isoc;
193 } u; 194 } u;
194 } urb; 195 } urb;
195 196
196 int num_device_descs; 197 int num_device_descs;
197 struct dvb_usb_device_description devices[8]; 198 struct dvb_usb_device_description devices[9];
198}; 199};
199 200
200 201
@@ -207,19 +208,28 @@ struct dvb_usb_properties {
207 * @udev: pointer to the device's struct usb_device. 208 * @udev: pointer to the device's struct usb_device.
208 * @urb_list: array of dynamically allocated struct urb for the MPEG2-TS- 209 * @urb_list: array of dynamically allocated struct urb for the MPEG2-TS-
209 * streaming. 210 * streaming.
210 * @buffer: buffer used to streaming. 211 *
211 * @dma_handle: dma_addr_t for buffer. 212 * @buf_num: number of buffer allocated.
213 * @buf_size: size of each buffer in buf_list.
214 * @buf_list: array containing all allocate buffers for streaming.
215 * @dma_addr: list of dma_addr_t for each buffer in buf_list.
216 *
212 * @urbs_initialized: number of URBs initialized. 217 * @urbs_initialized: number of URBs initialized.
213 * @urbs_submitted: number of URBs submitted. 218 * @urbs_submitted: number of URBs submitted.
219 *
214 * @feedcount: number of reqested feeds (used for streaming-activation) 220 * @feedcount: number of reqested feeds (used for streaming-activation)
215 * @pid_filtering: is hardware pid_filtering used or not. 221 * @pid_filtering: is hardware pid_filtering used or not.
222 *
216 * @usb_sem: semaphore of USB control messages (reading needs two messages) 223 * @usb_sem: semaphore of USB control messages (reading needs two messages)
217 * @i2c_sem: semaphore for i2c-transfers 224 * @i2c_sem: semaphore for i2c-transfers
225 *
218 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB 226 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
219 * @pll_addr: I2C address of the tuner for programming 227 * @pll_addr: I2C address of the tuner for programming
220 * @pll_init: array containing the initialization buffer 228 * @pll_init: array containing the initialization buffer
221 * @pll_desc: pointer to the appropriate struct dvb_pll_desc 229 * @pll_desc: pointer to the appropriate struct dvb_pll_desc
222 * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod 230 *
231 * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board
232 *
223 * @dvb_adap: device's dvb_adapter. 233 * @dvb_adap: device's dvb_adapter.
224 * @dmxdev: device's dmxdev. 234 * @dmxdev: device's dmxdev.
225 * @demux: device's software demuxer. 235 * @demux: device's software demuxer.
@@ -253,8 +263,12 @@ struct dvb_usb_device {
253 /* usb */ 263 /* usb */
254 struct usb_device *udev; 264 struct usb_device *udev;
255 struct urb **urb_list; 265 struct urb **urb_list;
256 u8 *buffer; 266
257 dma_addr_t dma_handle; 267 int buf_num;
268 unsigned long buf_size;
269 u8 **buf_list;
270 dma_addr_t *dma_addr;
271
258 int urbs_initialized; 272 int urbs_initialized;
259 int urbs_submitted; 273 int urbs_submitted;
260 274
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index 9d83781aef95..258a92bfbcc7 100644
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
@@ -203,7 +203,7 @@ static struct dvb_usb_properties nova_t_properties = {
203 203
204static struct usb_driver nova_t_driver = { 204static struct usb_driver nova_t_driver = {
205 .owner = THIS_MODULE, 205 .owner = THIS_MODULE,
206 .name = "Hauppauge WinTV-NOVA-T usb2", 206 .name = "dvb_usb_nova_t_usb2",
207 .probe = nova_t_probe, 207 .probe = nova_t_probe,
208 .disconnect = dvb_usb_device_exit, 208 .disconnect = dvb_usb_device_exit,
209 .id_table = nova_t_table, 209 .id_table = nova_t_table,
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c
index aa560422ce7c..2112ac3cf5e2 100644
--- a/drivers/media/dvb/dvb-usb/umt-010.c
+++ b/drivers/media/dvb/dvb-usb/umt-010.c
@@ -129,7 +129,7 @@ static struct dvb_usb_properties umt_properties = {
129 129
130static struct usb_driver umt_driver = { 130static struct usb_driver umt_driver = {
131 .owner = THIS_MODULE, 131 .owner = THIS_MODULE,
132 .name = "HanfTek UMT-010 USB2.0 DVB-T devices", 132 .name = "dvb_usb_umt_010",
133 .probe = umt_probe, 133 .probe = umt_probe,
134 .disconnect = dvb_usb_device_exit, 134 .disconnect = dvb_usb_device_exit,
135 .id_table = umt_table, 135 .id_table = umt_table,
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
index 02ecc9a8e3b6..9ac95f54f9fc 100644
--- a/drivers/media/dvb/dvb-usb/vp7045.c
+++ b/drivers/media/dvb/dvb-usb/vp7045.c
@@ -44,7 +44,7 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in,
44 if (usb_control_msg(d->udev, 44 if (usb_control_msg(d->udev,
45 usb_sndctrlpipe(d->udev,0), 45 usb_sndctrlpipe(d->udev,0),
46 TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, 46 TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0,
47 outbuf, 20, 2*HZ) != 20) { 47 outbuf, 20, 2000) != 20) {
48 err("USB control message 'out' went wrong."); 48 err("USB control message 'out' went wrong.");
49 ret = -EIO; 49 ret = -EIO;
50 goto unlock; 50 goto unlock;
@@ -55,7 +55,7 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in,
55 if (usb_control_msg(d->udev, 55 if (usb_control_msg(d->udev,
56 usb_rcvctrlpipe(d->udev,0), 56 usb_rcvctrlpipe(d->udev,0),
57 TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, 57 TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
58 inbuf, 12, 2*HZ) != 12) { 58 inbuf, 12, 2000) != 12) {
59 err("USB control message 'in' went wrong."); 59 err("USB control message 'in' went wrong.");
60 ret = -EIO; 60 ret = -EIO;
61 goto unlock; 61 goto unlock;
@@ -94,16 +94,41 @@ static int vp7045_power_ctrl(struct dvb_usb_device *d, int onoff)
94/* The keymapping struct. Somehow this should be loaded to the driver, but 94/* The keymapping struct. Somehow this should be loaded to the driver, but
95 * currently it is hardcoded. */ 95 * currently it is hardcoded. */
96static struct dvb_usb_rc_key vp7045_rc_keys[] = { 96static struct dvb_usb_rc_key vp7045_rc_keys[] = {
97 /* insert the keys like this. to make the raw keys visible, enable 97 { 0x00, 0x16, KEY_POWER },
98 * debug=0x04 when loading dvb-usb-vp7045. */ 98 { 0x00, 0x10, KEY_MUTE },
99 99 { 0x00, 0x03, KEY_1 },
100 /* these keys are probably wrong. I don't have a working IR-receiver on my 100 { 0x00, 0x01, KEY_2 },
101 * vp7045, so I can't test it. Patches are welcome. */ 101 { 0x00, 0x06, KEY_3 },
102 { 0x00, 0x01, KEY_1 }, 102 { 0x00, 0x09, KEY_4 },
103 { 0x00, 0x02, KEY_2 }, 103 { 0x00, 0x1d, KEY_5 },
104 { 0x00, 0x1f, KEY_6 },
105 { 0x00, 0x0d, KEY_7 },
106 { 0x00, 0x19, KEY_8 },
107 { 0x00, 0x1b, KEY_9 },
108 { 0x00, 0x15, KEY_0 },
109 { 0x00, 0x05, KEY_CHANNELUP },
110 { 0x00, 0x02, KEY_CHANNELDOWN },
111 { 0x00, 0x1e, KEY_VOLUMEUP },
112 { 0x00, 0x0a, KEY_VOLUMEDOWN },
113 { 0x00, 0x11, KEY_RECORD },
114 { 0x00, 0x17, KEY_FAVORITES }, /* Heart symbol - Channel list. */
115 { 0x00, 0x14, KEY_PLAY },
116 { 0x00, 0x1a, KEY_STOP },
117 { 0x00, 0x40, KEY_REWIND },
118 { 0x00, 0x12, KEY_FASTFORWARD },
119 { 0x00, 0x0e, KEY_PREVIOUS }, /* Recall - Previous channel. */
120 { 0x00, 0x4c, KEY_PAUSE },
121 { 0x00, 0x4d, KEY_SCREEN }, /* Full screen mode. */
122 { 0x00, 0x54, KEY_AUDIO }, /* MTS - Switch to secondary audio. */
123 { 0x00, 0x0c, KEY_CANCEL }, /* Cancel */
124 { 0x00, 0x1c, KEY_EPG }, /* EPG */
125 { 0x00, 0x00, KEY_TAB }, /* Tab */
126 { 0x00, 0x48, KEY_INFO }, /* Preview */
127 { 0x00, 0x04, KEY_LIST }, /* RecordList */
128 { 0x00, 0x0f, KEY_TEXT } /* Teletext */
104}; 129};
105 130
106static int vp7045_rc_query(struct dvb_usb_device *d, u32 *key_buf, int *state) 131static int vp7045_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
107{ 132{
108 u8 key; 133 u8 key;
109 int i; 134 int i;
@@ -119,7 +144,7 @@ static int vp7045_rc_query(struct dvb_usb_device *d, u32 *key_buf, int *state)
119 for (i = 0; i < sizeof(vp7045_rc_keys)/sizeof(struct dvb_usb_rc_key); i++) 144 for (i = 0; i < sizeof(vp7045_rc_keys)/sizeof(struct dvb_usb_rc_key); i++)
120 if (vp7045_rc_keys[i].data == key) { 145 if (vp7045_rc_keys[i].data == key) {
121 *state = REMOTE_KEY_PRESSED; 146 *state = REMOTE_KEY_PRESSED;
122 *key_buf = vp7045_rc_keys[i].event; 147 *event = vp7045_rc_keys[i].event;
123 break; 148 break;
124 } 149 }
125 return 0; 150 return 0;
@@ -230,7 +255,7 @@ static struct dvb_usb_properties vp7045_properties = {
230/* usb specific object needed to register this driver with the usb subsystem */ 255/* usb specific object needed to register this driver with the usb subsystem */
231static struct usb_driver vp7045_usb_driver = { 256static struct usb_driver vp7045_usb_driver = {
232 .owner = THIS_MODULE, 257 .owner = THIS_MODULE,
233 .name = "dvb-usb-vp7045", 258 .name = "dvb_usb_vp7045",
234 .probe = vp7045_usb_probe, 259 .probe = vp7045_usb_probe,
235 .disconnect = dvb_usb_device_exit, 260 .disconnect = dvb_usb_device_exit,
236 .id_table = vp7045_usb_table, 261 .id_table = vp7045_usb_table,
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index b4fddf513ebe..d847c62bd837 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -40,6 +40,12 @@ config DVB_VES1X93
40 help 40 help
41 A DVB-S tuner module. Say Y when you want to support this frontend. 41 A DVB-S tuner module. Say Y when you want to support this frontend.
42 42
43config DVB_S5H1420
44 tristate "Samsung S5H1420 based"
45 depends on DVB_CORE
46 help
47 A DVB-S tuner module. Say Y when you want to support this frontend.
48
43comment "DVB-T (terrestrial) frontends" 49comment "DVB-T (terrestrial) frontends"
44 depends on DVB_CORE 50 depends on DVB_CORE
45 51
@@ -181,4 +187,11 @@ config DVB_BCM3510
181 An ATSC 8VSB/16VSB and QAM64/256 tuner module. Say Y when you want to 187 An ATSC 8VSB/16VSB and QAM64/256 tuner module. Say Y when you want to
182 support this frontend. 188 support this frontend.
183 189
190config DVB_LGDT3302
191 tristate "LGDT3302 based (DViCO FusionHDTV3 Gold)"
192 depends on DVB_CORE
193 help
194 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
195 to support this frontend.
196
184endmenu 197endmenu
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
index 91d6d3576d3d..de5e240cba7f 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -29,3 +29,5 @@ obj-$(CONFIG_DVB_NXT2002) += nxt2002.o
29obj-$(CONFIG_DVB_OR51211) += or51211.o 29obj-$(CONFIG_DVB_OR51211) += or51211.o
30obj-$(CONFIG_DVB_OR51132) += or51132.o 30obj-$(CONFIG_DVB_OR51132) += or51132.o
31obj-$(CONFIG_DVB_BCM3510) += bcm3510.o 31obj-$(CONFIG_DVB_BCM3510) += bcm3510.o
32obj-$(CONFIG_DVB_S5H1420) += s5h1420.o
33obj-$(CONFIG_DVB_LGDT3302) += lgdt3302.o
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index f4aa44136c7c..9f639297a9f2 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -76,7 +76,6 @@ static u8 init_tab [] = {
76 0x49, 0x56, 76 0x49, 0x56,
77 0x6b, 0x1e, 77 0x6b, 0x1e,
78 0xc8, 0x02, 78 0xc8, 0x02,
79 0xf8, 0x02,
80 0xf9, 0x00, 79 0xf9, 0x00,
81 0xfa, 0x00, 80 0xfa, 0x00,
82 0xfb, 0x00, 81 0xfb, 0x00,
@@ -203,7 +202,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet
203 struct cx22702_state* state = fe->demodulator_priv; 202 struct cx22702_state* state = fe->demodulator_priv;
204 203
205 /* set PLL */ 204 /* set PLL */
206 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe); 205 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe);
207 if (state->config->pll_set) { 206 if (state->config->pll_set) {
208 state->config->pll_set(fe, p); 207 state->config->pll_set(fe, p);
209 } else if (state->config->pll_desc) { 208 } else if (state->config->pll_desc) {
@@ -217,7 +216,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet
217 } else { 216 } else {
218 BUG(); 217 BUG();
219 } 218 }
220 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1); 219 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);
221 220
222 /* set inversion */ 221 /* set inversion */
223 cx22702_set_inversion (state, p->inversion); 222 cx22702_set_inversion (state, p->inversion);
@@ -256,7 +255,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet
256 cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc ); 255 cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc );
257 cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 ); 256 cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 );
258 cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */ 257 cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */
259 printk("%s: Autodetecting\n",__FUNCTION__); 258 dprintk("%s: Autodetecting\n",__FUNCTION__);
260 return 0; 259 return 0;
261 } 260 }
262 261
@@ -347,10 +346,11 @@ static int cx22702_init (struct dvb_frontend* fe)
347 for (i=0; i<sizeof(init_tab); i+=2) 346 for (i=0; i<sizeof(init_tab); i+=2)
348 cx22702_writereg (state, init_tab[i], init_tab[i+1]); 347 cx22702_writereg (state, init_tab[i], init_tab[i+1]);
349 348
349 cx22702_writereg (state, 0xf8, (state->config->output_mode << 1) & 0x02);
350 350
351 /* init PLL */ 351 /* init PLL */
352 if (state->config->pll_init) { 352 if (state->config->pll_init) {
353 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe); 353 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) & 0xfe);
354 state->config->pll_init(fe); 354 state->config->pll_init(fe);
355 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1); 355 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);
356 } 356 }
@@ -440,8 +440,10 @@ static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
440 440
441 /* RS Uncorrectable Packet Count then reset */ 441 /* RS Uncorrectable Packet Count then reset */
442 _ucblocks = cx22702_readreg (state, 0xE3); 442 _ucblocks = cx22702_readreg (state, 0xE3);
443 if (state->prevUCBlocks < _ucblocks) *ucblocks = (_ucblocks - state->prevUCBlocks); 443 if (state->prevUCBlocks < _ucblocks)
444 else *ucblocks = state->prevUCBlocks - _ucblocks; 444 *ucblocks = (_ucblocks - state->prevUCBlocks);
445 else
446 *ucblocks = state->prevUCBlocks - _ucblocks;
445 state->prevUCBlocks = _ucblocks; 447 state->prevUCBlocks = _ucblocks;
446 448
447 return 0; 449 return 0;
@@ -457,6 +459,12 @@ static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
457 return cx22702_get_tps (state, &p->u.ofdm); 459 return cx22702_get_tps (state, &p->u.ofdm);
458} 460}
459 461
462static int cx22702_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
463{
464 tune->min_delay_ms = 1000;
465 return 0;
466}
467
460static void cx22702_release(struct dvb_frontend* fe) 468static void cx22702_release(struct dvb_frontend* fe)
461{ 469{
462 struct cx22702_state* state = fe->demodulator_priv; 470 struct cx22702_state* state = fe->demodulator_priv;
@@ -472,7 +480,8 @@ struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
472 480
473 /* allocate memory for the internal state */ 481 /* allocate memory for the internal state */
474 state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); 482 state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL);
475 if (state == NULL) goto error; 483 if (state == NULL)
484 goto error;
476 485
477 /* setup the state */ 486 /* setup the state */
478 state->config = config; 487 state->config = config;
@@ -481,7 +490,8 @@ struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
481 state->prevUCBlocks = 0; 490 state->prevUCBlocks = 0;
482 491
483 /* check if the demod is there */ 492 /* check if the demod is there */
484 if (cx22702_readreg(state, 0x1f) != 0x3) goto error; 493 if (cx22702_readreg(state, 0x1f) != 0x3)
494 goto error;
485 495
486 /* create dvb_frontend */ 496 /* create dvb_frontend */
487 state->frontend.ops = &state->ops; 497 state->frontend.ops = &state->ops;
@@ -514,6 +524,7 @@ static struct dvb_frontend_ops cx22702_ops = {
514 524
515 .set_frontend = cx22702_set_tps, 525 .set_frontend = cx22702_set_tps,
516 .get_frontend = cx22702_get_frontend, 526 .get_frontend = cx22702_get_frontend,
527 .get_tune_settings = cx22702_get_tune_settings,
517 528
518 .read_status = cx22702_read_status, 529 .read_status = cx22702_read_status,
519 .read_ber = cx22702_read_ber, 530 .read_ber = cx22702_read_ber,
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index 559fdb906669..11f86806756e 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -35,6 +35,11 @@ struct cx22702_config
35 /* the demodulator's i2c address */ 35 /* the demodulator's i2c address */
36 u8 demod_address; 36 u8 demod_address;
37 37
38 /* serial/parallel output */
39#define CX22702_PARALLEL_OUTPUT 0
40#define CX22702_SERIAL_OUTPUT 1
41 u8 output_mode;
42
38 /* PLL maintenance */ 43 /* PLL maintenance */
39 u8 pll_address; 44 u8 pll_address;
40 struct dvb_pll_desc *pll_desc; 45 struct dvb_pll_desc *pll_desc;
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index f73b5f48e235..5afeaa9b43b4 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -55,7 +55,7 @@ struct dvb_pll_desc dvb_pll_thomson_dtt7610 = {
55}; 55};
56EXPORT_SYMBOL(dvb_pll_thomson_dtt7610); 56EXPORT_SYMBOL(dvb_pll_thomson_dtt7610);
57 57
58static void thomson_dtt759x_bw(u8 *buf, int bandwidth) 58static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth)
59{ 59{
60 if (BANDWIDTH_7_MHZ == bandwidth) 60 if (BANDWIDTH_7_MHZ == bandwidth)
61 buf[3] |= 0x10; 61 buf[3] |= 0x10;
@@ -93,6 +93,32 @@ struct dvb_pll_desc dvb_pll_lg_z201 = {
93}; 93};
94EXPORT_SYMBOL(dvb_pll_lg_z201); 94EXPORT_SYMBOL(dvb_pll_lg_z201);
95 95
96struct dvb_pll_desc dvb_pll_microtune_4042 = {
97 .name = "Microtune 4042 FI5",
98 .min = 57000000,
99 .max = 858000000,
100 .count = 3,
101 .entries = {
102 { 162000000, 44000000, 62500, 0x8e, 0xa1 },
103 { 457000000, 44000000, 62500, 0x8e, 0x91 },
104 { 999999999, 44000000, 62500, 0x8e, 0x31 },
105 },
106};
107EXPORT_SYMBOL(dvb_pll_microtune_4042);
108
109struct dvb_pll_desc dvb_pll_thomson_dtt7611 = {
110 .name = "Thomson dtt7611",
111 .min = 44000000,
112 .max = 958000000,
113 .count = 3,
114 .entries = {
115 { 157250000, 44000000, 62500, 0x8e, 0x39 },
116 { 454000000, 44000000, 62500, 0x8e, 0x3a },
117 { 999999999, 44000000, 62500, 0x8e, 0x3c },
118 },
119};
120EXPORT_SYMBOL(dvb_pll_thomson_dtt7611);
121
96struct dvb_pll_desc dvb_pll_unknown_1 = { 122struct dvb_pll_desc dvb_pll_unknown_1 = {
97 .name = "unknown 1", /* used by dntv live dvb-t */ 123 .name = "unknown 1", /* used by dntv live dvb-t */
98 .min = 174000000, 124 .min = 174000000,
@@ -146,7 +172,7 @@ EXPORT_SYMBOL(dvb_pll_env57h1xd5);
146/* Philips TDA6650/TDA6651 172/* Philips TDA6650/TDA6651
147 * used in Panasonic ENV77H11D5 173 * used in Panasonic ENV77H11D5
148 */ 174 */
149static void tda665x_bw(u8 *buf, int bandwidth) 175static void tda665x_bw(u8 *buf, u32 freq, int bandwidth)
150{ 176{
151 if (bandwidth == BANDWIDTH_8_MHZ) 177 if (bandwidth == BANDWIDTH_8_MHZ)
152 buf[3] |= 0x08; 178 buf[3] |= 0x08;
@@ -178,7 +204,7 @@ EXPORT_SYMBOL(dvb_pll_tda665x);
178/* Infineon TUA6034 204/* Infineon TUA6034
179 * used in LG TDTP E102P 205 * used in LG TDTP E102P
180 */ 206 */
181static void tua6034_bw(u8 *buf, int bandwidth) 207static void tua6034_bw(u8 *buf, u32 freq, int bandwidth)
182{ 208{
183 if (BANDWIDTH_7_MHZ != bandwidth) 209 if (BANDWIDTH_7_MHZ != bandwidth)
184 buf[3] |= 0x08; 210 buf[3] |= 0x08;
@@ -198,6 +224,57 @@ struct dvb_pll_desc dvb_pll_tua6034 = {
198}; 224};
199EXPORT_SYMBOL(dvb_pll_tua6034); 225EXPORT_SYMBOL(dvb_pll_tua6034);
200 226
227/* Philips FMD1216ME
228 * used in Medion Hybrid PCMCIA card and USB Box
229 */
230static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth)
231{
232 if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000)
233 buf[3] |= 0x08;
234}
235
236struct dvb_pll_desc dvb_pll_fmd1216me = {
237 .name = "Philips FMD1216ME",
238 .min = 50870000,
239 .max = 858000000,
240 .setbw = fmd1216me_bw,
241 .count = 7,
242 .entries = {
243 { 143870000, 36213333, 166667, 0xbc, 0x41 },
244 { 158870000, 36213333, 166667, 0xf4, 0x41 },
245 { 329870000, 36213333, 166667, 0xbc, 0x42 },
246 { 441870000, 36213333, 166667, 0xf4, 0x42 },
247 { 625870000, 36213333, 166667, 0xbc, 0x44 },
248 { 803870000, 36213333, 166667, 0xf4, 0x44 },
249 { 999999999, 36213333, 166667, 0xfc, 0x44 },
250 }
251};
252EXPORT_SYMBOL(dvb_pll_fmd1216me);
253
254/* ALPS TDED4
255 * used in Nebula-Cards and USB boxes
256 */
257static void tded4_bw(u8 *buf, u32 freq, int bandwidth)
258{
259 if (bandwidth == BANDWIDTH_8_MHZ)
260 buf[3] |= 0x04;
261}
262
263struct dvb_pll_desc dvb_pll_tded4 = {
264 .name = "ALPS TDED4",
265 .min = 47000000,
266 .max = 863000000,
267 .setbw = tded4_bw,
268 .count = 4,
269 .entries = {
270 { 153000000, 36166667, 166667, 0x85, 0x01 },
271 { 470000000, 36166667, 166667, 0x85, 0x02 },
272 { 823000000, 36166667, 166667, 0x85, 0x08 },
273 { 999999999, 36166667, 166667, 0x85, 0x88 },
274 }
275};
276EXPORT_SYMBOL(dvb_pll_tded4);
277
201/* ----------------------------------------------------------- */ 278/* ----------------------------------------------------------- */
202/* code */ 279/* code */
203 280
@@ -231,7 +308,7 @@ int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
231 buf[3] = desc->entries[i].cb2; 308 buf[3] = desc->entries[i].cb2;
232 309
233 if (desc->setbw) 310 if (desc->setbw)
234 desc->setbw(buf, bandwidth); 311 desc->setbw(buf, freq, bandwidth);
235 312
236 if (debug) 313 if (debug)
237 printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", 314 printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h
index b796778624b6..cb794759d89e 100644
--- a/drivers/media/dvb/frontends/dvb-pll.h
+++ b/drivers/media/dvb/frontends/dvb-pll.h
@@ -9,7 +9,7 @@ struct dvb_pll_desc {
9 char *name; 9 char *name;
10 u32 min; 10 u32 min;
11 u32 max; 11 u32 max;
12 void (*setbw)(u8 *buf, int bandwidth); 12 void (*setbw)(u8 *buf, u32 freq, int bandwidth);
13 int count; 13 int count;
14 struct { 14 struct {
15 u32 limit; 15 u32 limit;
@@ -24,12 +24,16 @@ extern struct dvb_pll_desc dvb_pll_thomson_dtt7579;
24extern struct dvb_pll_desc dvb_pll_thomson_dtt759x; 24extern struct dvb_pll_desc dvb_pll_thomson_dtt759x;
25extern struct dvb_pll_desc dvb_pll_thomson_dtt7610; 25extern struct dvb_pll_desc dvb_pll_thomson_dtt7610;
26extern struct dvb_pll_desc dvb_pll_lg_z201; 26extern struct dvb_pll_desc dvb_pll_lg_z201;
27extern struct dvb_pll_desc dvb_pll_microtune_4042;
28extern struct dvb_pll_desc dvb_pll_thomson_dtt7611;
27extern struct dvb_pll_desc dvb_pll_unknown_1; 29extern struct dvb_pll_desc dvb_pll_unknown_1;
28 30
29extern struct dvb_pll_desc dvb_pll_tua6010xs; 31extern struct dvb_pll_desc dvb_pll_tua6010xs;
30extern struct dvb_pll_desc dvb_pll_env57h1xd5; 32extern struct dvb_pll_desc dvb_pll_env57h1xd5;
31extern struct dvb_pll_desc dvb_pll_tua6034; 33extern struct dvb_pll_desc dvb_pll_tua6034;
32extern struct dvb_pll_desc dvb_pll_tda665x; 34extern struct dvb_pll_desc dvb_pll_tda665x;
35extern struct dvb_pll_desc dvb_pll_fmd1216me;
36extern struct dvb_pll_desc dvb_pll_tded4;
33 37
34int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, 38int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
35 u32 freq, int bandwidth); 39 u32 freq, int bandwidth);
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
index 031a1ddc7d11..faaad1ae8559 100644
--- a/drivers/media/dvb/frontends/l64781.c
+++ b/drivers/media/dvb/frontends/l64781.c
@@ -474,11 +474,12 @@ static int l64781_init(struct dvb_frontend* fe)
474 return 0; 474 return 0;
475} 475}
476 476
477static int l64781_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) 477static int l64781_get_tune_settings(struct dvb_frontend* fe,
478 struct dvb_frontend_tune_settings* fesettings)
478{ 479{
479 fesettings->min_delay_ms = 200; 480 fesettings->min_delay_ms = 4000;
480 fesettings->step_size = 166667; 481 fesettings->step_size = 0;
481 fesettings->max_drift = 166667*2; 482 fesettings->max_drift = 0;
482 return 0; 483 return 0;
483} 484}
484 485
diff --git a/drivers/media/dvb/frontends/lgdt3302.c b/drivers/media/dvb/frontends/lgdt3302.c
new file mode 100644
index 000000000000..2eea03d218cd
--- /dev/null
+++ b/drivers/media/dvb/frontends/lgdt3302.c
@@ -0,0 +1,609 @@
1/*
2 * Support for LGDT3302 (DViCO FustionHDTV 3 Gold) - VSB/QAM
3 *
4 * Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net>
5 *
6 * Based on code from Kirk Lapray <kirk_lapray@bigfoot.com>
7 * Copyright (C) 2005
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25/*
26 * NOTES ABOUT THIS DRIVER
27 *
28 * This driver supports DViCO FusionHDTV 3 Gold under Linux.
29 *
30 * TODO:
31 * BER and signal strength always return 0.
32 *
33 */
34
35#include <linux/kernel.h>
36#include <linux/module.h>
37#include <linux/moduleparam.h>
38#include <linux/init.h>
39#include <linux/delay.h>
40#include <asm/byteorder.h>
41
42#include "dvb_frontend.h"
43#include "dvb-pll.h"
44#include "lgdt3302_priv.h"
45#include "lgdt3302.h"
46
47static int debug = 0;
48module_param(debug, int, 0644);
49MODULE_PARM_DESC(debug,"Turn on/off lgdt3302 frontend debugging (default:off).");
50#define dprintk(args...) \
51do { \
52if (debug) printk(KERN_DEBUG "lgdt3302: " args); \
53} while (0)
54
55struct lgdt3302_state
56{
57 struct i2c_adapter* i2c;
58 struct dvb_frontend_ops ops;
59
60 /* Configuration settings */
61 const struct lgdt3302_config* config;
62
63 struct dvb_frontend frontend;
64
65 /* Demodulator private data */
66 fe_modulation_t current_modulation;
67
68 /* Tuner private data */
69 u32 current_frequency;
70};
71
72static int i2c_writebytes (struct lgdt3302_state* state,
73 u8 addr, /* demod_address or pll_address */
74 u8 *buf, /* data bytes to send */
75 int len /* number of bytes to send */ )
76{
77 if (addr == state->config->pll_address) {
78 struct i2c_msg msg =
79 { .addr = addr, .flags = 0, .buf = buf, .len = len };
80 int err;
81
82 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
83 printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err);
84 if (err < 0)
85 return err;
86 else
87 return -EREMOTEIO;
88 }
89 } else {
90 u8 tmp[] = { buf[0], buf[1] };
91 struct i2c_msg msg =
92 { .addr = addr, .flags = 0, .buf = tmp, .len = 2 };
93 int err;
94 int i;
95
96 for (i=1; i<len; i++) {
97 tmp[1] = buf[i];
98 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
99 printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err);
100 if (err < 0)
101 return err;
102 else
103 return -EREMOTEIO;
104 }
105 tmp[0]++;
106 }
107 }
108 return 0;
109}
110static int i2c_readbytes (struct lgdt3302_state* state,
111 u8 addr, /* demod_address or pll_address */
112 u8 *buf, /* holds data bytes read */
113 int len /* number of bytes to read */ )
114{
115 struct i2c_msg msg =
116 { .addr = addr, .flags = I2C_M_RD, .buf = buf, .len = len };
117 int err;
118
119 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
120 printk(KERN_WARNING "lgdt3302: %s error (addr %02x, err == %i)\n", __FUNCTION__, addr, err);
121 return -EREMOTEIO;
122 }
123 return 0;
124}
125
126/*
127 * This routine writes the register (reg) to the demod bus
128 * then reads the data returned for (len) bytes.
129 */
130
131static u8 i2c_selectreadbytes (struct lgdt3302_state* state,
132 enum I2C_REG reg, u8* buf, int len)
133{
134 u8 wr [] = { reg };
135 struct i2c_msg msg [] = {
136 { .addr = state->config->demod_address,
137 .flags = 0, .buf = wr, .len = 1 },
138 { .addr = state->config->demod_address,
139 .flags = I2C_M_RD, .buf = buf, .len = len },
140 };
141 int ret;
142 ret = i2c_transfer(state->i2c, msg, 2);
143 if (ret != 2) {
144 printk(KERN_WARNING "lgdt3302: %s: addr 0x%02x select 0x%02x error (ret == %i)\n", __FUNCTION__, state->config->demod_address, reg, ret);
145 } else {
146 ret = 0;
147 }
148 return ret;
149}
150
151/* Software reset */
152int lgdt3302_SwReset(struct lgdt3302_state* state)
153{
154 u8 ret;
155 u8 reset[] = {
156 IRQ_MASK,
157 0x00 /* bit 6 is active low software reset
158 * bits 5-0 are 1 to mask interrupts */
159 };
160
161 ret = i2c_writebytes(state,
162 state->config->demod_address,
163 reset, sizeof(reset));
164 if (ret == 0) {
165 /* spec says reset takes 100 ns why wait */
166 /* mdelay(100); */ /* keep low for 100mS */
167 reset[1] = 0x7f; /* force reset high (inactive)
168 * and unmask interrupts */
169 ret = i2c_writebytes(state,
170 state->config->demod_address,
171 reset, sizeof(reset));
172 }
173 /* Spec does not indicate a need for this either */
174 /*mdelay(5); */ /* wait 5 msec before doing more */
175 return ret;
176}
177
178static int lgdt3302_init(struct dvb_frontend* fe)
179{
180 /* Hardware reset is done using gpio[0] of cx23880x chip.
181 * I'd like to do it here, but don't know how to find chip address.
182 * cx88-cards.c arranges for the reset bit to be inactive (high).
183 * Maybe there needs to be a callable function in cx88-core or
184 * the caller of this function needs to do it. */
185
186 dprintk("%s entered\n", __FUNCTION__);
187 return lgdt3302_SwReset((struct lgdt3302_state*) fe->demodulator_priv);
188}
189
190static int lgdt3302_read_ber(struct dvb_frontend* fe, u32* ber)
191{
192 *ber = 0; /* Dummy out for now */
193 return 0;
194}
195
196static int lgdt3302_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
197{
198 struct lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
199 u8 buf[2];
200
201 i2c_selectreadbytes(state, PACKET_ERR_COUNTER1, buf, sizeof(buf));
202
203 *ucblocks = (buf[0] << 8) | buf[1];
204 return 0;
205}
206
207static int lgdt3302_set_parameters(struct dvb_frontend* fe,
208 struct dvb_frontend_parameters *param)
209{
210 u8 buf[4];
211 struct lgdt3302_state* state =
212 (struct lgdt3302_state*) fe->demodulator_priv;
213
214 /* Use 50MHz parameter values from spec sheet since xtal is 50 */
215 static u8 top_ctrl_cfg[] = { TOP_CONTROL, 0x03 };
216 static u8 vsb_freq_cfg[] = { VSB_CARRIER_FREQ0, 0x00, 0x87, 0x8e, 0x01 };
217 static u8 demux_ctrl_cfg[] = { DEMUX_CONTROL, 0xfb };
218 static u8 agc_rf_cfg[] = { AGC_RF_BANDWIDTH0, 0x40, 0x93, 0x00 };
219 static u8 agc_ctrl_cfg[] = { AGC_FUNC_CTRL2, 0xc6, 0x40 };
220 static u8 agc_delay_cfg[] = { AGC_DELAY0, 0x00, 0x00, 0x00 };
221 static u8 agc_loop_cfg[] = { AGC_LOOP_BANDWIDTH0, 0x08, 0x9a };
222
223 /* Change only if we are actually changing the modulation */
224 if (state->current_modulation != param->u.vsb.modulation) {
225 int value;
226
227 switch(param->u.vsb.modulation) {
228 case VSB_8:
229 dprintk("%s: VSB_8 MODE\n", __FUNCTION__);
230
231 /* Select VSB mode and serial MPEG interface */
232 top_ctrl_cfg[1] = 0x07;
233 break;
234
235 case QAM_64:
236 dprintk("%s: QAM_64 MODE\n", __FUNCTION__);
237
238 /* Select QAM_64 mode and serial MPEG interface */
239 top_ctrl_cfg[1] = 0x04;
240 break;
241
242 case QAM_256:
243 dprintk("%s: QAM_256 MODE\n", __FUNCTION__);
244
245 /* Select QAM_256 mode and serial MPEG interface */
246 top_ctrl_cfg[1] = 0x05;
247 break;
248 default:
249 printk(KERN_WARNING "lgdt3302: %s: Modulation type(%d) UNSUPPORTED\n", __FUNCTION__, param->u.vsb.modulation);
250 return -1;
251 }
252 /* Initializations common to all modes */
253
254 /* Select the requested mode */
255 i2c_writebytes(state, state->config->demod_address,
256 top_ctrl_cfg, sizeof(top_ctrl_cfg));
257
258 /* Change the value of IFBW[11:0]
259 of AGC IF/RF loop filter bandwidth register */
260 i2c_writebytes(state, state->config->demod_address,
261 agc_rf_cfg, sizeof(agc_rf_cfg));
262
263 /* Change the value of bit 6, 'nINAGCBY' and
264 'NSSEL[1:0] of ACG function control register 2 */
265 /* Change the value of bit 6 'RFFIX'
266 of AGC function control register 3 */
267 i2c_writebytes(state, state->config->demod_address,
268 agc_ctrl_cfg, sizeof(agc_ctrl_cfg));
269
270 /* Change the TPCLK pin polarity
271 data is valid on falling clock */
272 i2c_writebytes(state, state->config->demod_address,
273 demux_ctrl_cfg, sizeof(demux_ctrl_cfg));
274
275 /* Change the value of NCOCTFV[25:0] of carrier
276 recovery center frequency register */
277 i2c_writebytes(state, state->config->demod_address,
278 vsb_freq_cfg, sizeof(vsb_freq_cfg));
279 /* Set the value of 'INLVTHD' register 0x2a/0x2c
280 to value from 'IFACC' register 0x39/0x3b -1 */
281 i2c_selectreadbytes(state, AGC_RFIF_ACC0,
282 &agc_delay_cfg[1], 3);
283 value = ((agc_delay_cfg[1] & 0x0f) << 8) | agc_delay_cfg[3];
284 value = value -1;
285 dprintk("%s IFACC -1 = 0x%03x\n", __FUNCTION__, value);
286 agc_delay_cfg[1] = (value >> 8) & 0x0f;
287 agc_delay_cfg[2] = 0x00;
288 agc_delay_cfg[3] = value & 0xff;
289 i2c_writebytes(state, state->config->demod_address,
290 agc_delay_cfg, sizeof(agc_delay_cfg));
291
292 /* Change the value of IAGCBW[15:8]
293 of inner AGC loop filter bandwith */
294 i2c_writebytes(state, state->config->demod_address,
295 agc_loop_cfg, sizeof(agc_loop_cfg));
296
297 state->config->set_ts_params(fe, 0);
298 state->current_modulation = param->u.vsb.modulation;
299 }
300
301 /* Change only if we are actually changing the channel */
302 if (state->current_frequency != param->frequency) {
303 dvb_pll_configure(state->config->pll_desc, buf,
304 param->frequency, 0);
305 dprintk("%s: tuner bytes: 0x%02x 0x%02x "
306 "0x%02x 0x%02x\n", __FUNCTION__, buf[0],buf[1],buf[2],buf[3]);
307 i2c_writebytes(state, state->config->pll_address ,buf, 4);
308
309 /* Check the status of the tuner pll */
310 i2c_readbytes(state, state->config->pll_address, buf, 1);
311 dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[0]);
312
313 /* Update current frequency */
314 state->current_frequency = param->frequency;
315 }
316 lgdt3302_SwReset(state);
317 return 0;
318}
319
320static int lgdt3302_get_frontend(struct dvb_frontend* fe,
321 struct dvb_frontend_parameters* param)
322{
323 struct lgdt3302_state *state = fe->demodulator_priv;
324 param->frequency = state->current_frequency;
325 return 0;
326}
327
328static int lgdt3302_read_status(struct dvb_frontend* fe, fe_status_t* status)
329{
330 struct lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
331 u8 buf[3];
332
333 *status = 0; /* Reset status result */
334
335 /* Check the status of the tuner pll */
336 i2c_readbytes(state, state->config->pll_address, buf, 1);
337 dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[0]);
338 if ((buf[0] & 0xc0) != 0x40)
339 return 0; /* Tuner PLL not locked or not powered on */
340
341 /*
342 * You must set the Mask bits to 1 in the IRQ_MASK in order
343 * to see that status bit in the IRQ_STATUS register.
344 * This is done in SwReset();
345 */
346
347 /* AGC status register */
348 i2c_selectreadbytes(state, AGC_STATUS, buf, 1);
349 dprintk("%s: AGC_STATUS = 0x%02x\n", __FUNCTION__, buf[0]);
350 if ((buf[0] & 0x0c) == 0x8){
351 /* Test signal does not exist flag */
352 /* as well as the AGC lock flag. */
353 *status |= FE_HAS_SIGNAL;
354 } else {
355 /* Without a signal all other status bits are meaningless */
356 return 0;
357 }
358
359 /* signal status */
360 i2c_selectreadbytes(state, TOP_CONTROL, buf, sizeof(buf));
361 dprintk("%s: TOP_CONTROL = 0x%02x, IRO_MASK = 0x%02x, IRQ_STATUS = 0x%02x\n", __FUNCTION__, buf[0], buf[1], buf[2]);
362
363#if 0
364 /* Alternative method to check for a signal */
365 /* using the SNR good/bad interrupts. */
366 if ((buf[2] & 0x30) == 0x10)
367 *status |= FE_HAS_SIGNAL;
368#endif
369
370 /* sync status */
371 if ((buf[2] & 0x03) == 0x01) {
372 *status |= FE_HAS_SYNC;
373 }
374
375 /* FEC error status */
376 if ((buf[2] & 0x0c) == 0x08) {
377 *status |= FE_HAS_LOCK;
378 *status |= FE_HAS_VITERBI;
379 }
380
381 /* Carrier Recovery Lock Status Register */
382 i2c_selectreadbytes(state, CARRIER_LOCK, buf, 1);
383 dprintk("%s: CARRIER_LOCK = 0x%02x\n", __FUNCTION__, buf[0]);
384 switch (state->current_modulation) {
385 case QAM_256:
386 case QAM_64:
387 /* Need to undestand why there are 3 lock levels here */
388 if ((buf[0] & 0x07) == 0x07)
389 *status |= FE_HAS_CARRIER;
390 break;
391 case VSB_8:
392 if ((buf[0] & 0x80) == 0x80)
393 *status |= FE_HAS_CARRIER;
394 break;
395 default:
396 printk("KERN_WARNING lgdt3302: %s: Modulation set to unsupported value\n", __FUNCTION__);
397 }
398
399 return 0;
400}
401
402static int lgdt3302_read_signal_strength(struct dvb_frontend* fe, u16* strength)
403{
404 /* not directly available. */
405 return 0;
406}
407
408static int lgdt3302_read_snr(struct dvb_frontend* fe, u16* snr)
409{
410#ifdef SNR_IN_DB
411 /*
412 * Spec sheet shows formula for SNR_EQ = 10 log10(25 * 24**2 / noise)
413 * and SNR_PH = 10 log10(25 * 32**2 / noise) for equalizer and phase tracker
414 * respectively. The following tables are built on these formulas.
415 * The usual definition is SNR = 20 log10(signal/noise)
416 * If the specification is wrong the value retuned is 1/2 the actual SNR in db.
417 *
418 * This table is a an ordered list of noise values computed by the
419 * formula from the spec sheet such that the index into the table
420 * starting at 43 or 45 is the SNR value in db. There are duplicate noise
421 * value entries at the beginning because the SNR varies more than
422 * 1 db for a change of 1 digit in noise at very small values of noise.
423 *
424 * Examples from SNR_EQ table:
425 * noise SNR
426 * 0 43
427 * 1 42
428 * 2 39
429 * 3 37
430 * 4 36
431 * 5 35
432 * 6 34
433 * 7 33
434 * 8 33
435 * 9 32
436 * 10 32
437 * 11 31
438 * 12 31
439 * 13 30
440 */
441
442 static const u32 SNR_EQ[] =
443 { 1, 2, 2, 2, 3, 3, 4, 4, 5, 7,
444 9, 11, 13, 17, 21, 26, 33, 41, 52, 65,
445 81, 102, 129, 162, 204, 257, 323, 406, 511, 644,
446 810, 1020, 1284, 1616, 2035, 2561, 3224, 4059, 5110, 6433,
447 8098, 10195, 12835, 16158, 20341, 25608, 32238, 40585, 51094, 64323,
448 80978, 101945, 128341, 161571, 203406, 256073, 0x40000
449 };
450
451 static const u32 SNR_PH[] =
452 { 1, 2, 2, 2, 3, 3, 4, 5, 6, 8,
453 10, 12, 15, 19, 23, 29, 37, 46, 58, 73,
454 91, 115, 144, 182, 229, 288, 362, 456, 574, 722,
455 909, 1144, 1440, 1813, 2282, 2873, 3617, 4553, 5732, 7216,
456 9084, 11436, 14396, 18124, 22817, 28724, 36161, 45524, 57312, 72151,
457 90833, 114351, 143960, 181235, 228161, 0x040000
458 };
459
460 static u8 buf[5];/* read data buffer */
461 static u32 noise; /* noise value */
462 static u32 snr_db; /* index into SNR_EQ[] */
463 struct lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
464
465 /* read both equalizer and pase tracker noise data */
466 i2c_selectreadbytes(state, EQPH_ERR0, buf, sizeof(buf));
467
468 if (state->current_modulation == VSB_8) {
469 /* Equalizer Mean-Square Error Register for VSB */
470 noise = ((buf[0] & 7) << 16) | (buf[1] << 8) | buf[2];
471
472 /*
473 * Look up noise value in table.
474 * A better search algorithm could be used...
475 * watch out there are duplicate entries.
476 */
477 for (snr_db = 0; snr_db < sizeof(SNR_EQ); snr_db++) {
478 if (noise < SNR_EQ[snr_db]) {
479 *snr = 43 - snr_db;
480 break;
481 }
482 }
483 } else {
484 /* Phase Tracker Mean-Square Error Register for QAM */
485 noise = ((buf[0] & 7<<3) << 13) | (buf[3] << 8) | buf[4];
486
487 /* Look up noise value in table. */
488 for (snr_db = 0; snr_db < sizeof(SNR_PH); snr_db++) {
489 if (noise < SNR_PH[snr_db]) {
490 *snr = 45 - snr_db;
491 break;
492 }
493 }
494 }
495#else
496 /* Return the raw noise value */
497 static u8 buf[5];/* read data buffer */
498 static u32 noise; /* noise value */
499 struct lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
500
501 /* read both equalizer and pase tracker noise data */
502 i2c_selectreadbytes(state, EQPH_ERR0, buf, sizeof(buf));
503
504 if (state->current_modulation == VSB_8) {
505 /* Equalizer Mean-Square Error Register for VSB */
506 noise = ((buf[0] & 7) << 16) | (buf[1] << 8) | buf[2];
507 } else {
508 /* Phase Tracker Mean-Square Error Register for QAM */
509 noise = ((buf[0] & 7<<3) << 13) | (buf[3] << 8) | buf[4];
510 }
511
512 /* Small values for noise mean signal is better so invert noise */
513 /* Noise is 19 bit value so discard 3 LSB*/
514 *snr = ~noise>>3;
515#endif
516
517 dprintk("%s: noise = 0x%05x, snr = %idb\n",__FUNCTION__, noise, *snr);
518
519 return 0;
520}
521
522static int lgdt3302_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fe_tune_settings)
523{
524 /* I have no idea about this - it may not be needed */
525 fe_tune_settings->min_delay_ms = 500;
526 fe_tune_settings->step_size = 0;
527 fe_tune_settings->max_drift = 0;
528 return 0;
529}
530
531static void lgdt3302_release(struct dvb_frontend* fe)
532{
533 struct lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
534 kfree(state);
535}
536
537static struct dvb_frontend_ops lgdt3302_ops;
538
539struct dvb_frontend* lgdt3302_attach(const struct lgdt3302_config* config,
540 struct i2c_adapter* i2c)
541{
542 struct lgdt3302_state* state = NULL;
543 u8 buf[1];
544
545 /* Allocate memory for the internal state */
546 state = (struct lgdt3302_state*) kmalloc(sizeof(struct lgdt3302_state), GFP_KERNEL);
547 if (state == NULL)
548 goto error;
549 memset(state,0,sizeof(*state));
550
551 /* Setup the state */
552 state->config = config;
553 state->i2c = i2c;
554 memcpy(&state->ops, &lgdt3302_ops, sizeof(struct dvb_frontend_ops));
555 /* Verify communication with demod chip */
556 if (i2c_selectreadbytes(state, 2, buf, 1))
557 goto error;
558
559 state->current_frequency = -1;
560 state->current_modulation = -1;
561
562 /* Create dvb_frontend */
563 state->frontend.ops = &state->ops;
564 state->frontend.demodulator_priv = state;
565 return &state->frontend;
566
567error:
568 if (state)
569 kfree(state);
570 dprintk("%s: ERROR\n",__FUNCTION__);
571 return NULL;
572}
573
574static struct dvb_frontend_ops lgdt3302_ops = {
575 .info = {
576 .name= "LG Electronics LGDT3302 VSB/QAM Frontend",
577 .type = FE_ATSC,
578 .frequency_min= 54000000,
579 .frequency_max= 858000000,
580 .frequency_stepsize= 62500,
581 /* Symbol rate is for all VSB modes need to check QAM */
582 .symbol_rate_min = 10762000,
583 .symbol_rate_max = 10762000,
584 .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
585 },
586 .init = lgdt3302_init,
587 .set_frontend = lgdt3302_set_parameters,
588 .get_frontend = lgdt3302_get_frontend,
589 .get_tune_settings = lgdt3302_get_tune_settings,
590 .read_status = lgdt3302_read_status,
591 .read_ber = lgdt3302_read_ber,
592 .read_signal_strength = lgdt3302_read_signal_strength,
593 .read_snr = lgdt3302_read_snr,
594 .read_ucblocks = lgdt3302_read_ucblocks,
595 .release = lgdt3302_release,
596};
597
598MODULE_DESCRIPTION("LGDT3302 [DViCO FusionHDTV 3 Gold] (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver");
599MODULE_AUTHOR("Wilson Michaels");
600MODULE_LICENSE("GPL");
601
602EXPORT_SYMBOL(lgdt3302_attach);
603
604/*
605 * Local variables:
606 * c-basic-offset: 8
607 * compile-command: "make DVB=1"
608 * End:
609 */
diff --git a/drivers/media/dvb/frontends/lgdt3302.h b/drivers/media/dvb/frontends/lgdt3302.h
new file mode 100644
index 000000000000..81587a40032b
--- /dev/null
+++ b/drivers/media/dvb/frontends/lgdt3302.h
@@ -0,0 +1,49 @@
1/*
2 * $Id: lgdt3302.h,v 1.2 2005/06/28 23:50:48 mkrufky Exp $
3 *
4 * Support for LGDT3302 (DViCO FustionHDTV 3 Gold) - VSB/QAM
5 *
6 * Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24#ifndef LGDT3302_H
25#define LGDT3302_H
26
27#include <linux/dvb/frontend.h>
28
29struct lgdt3302_config
30{
31 /* The demodulator's i2c address */
32 u8 demod_address;
33 u8 pll_address;
34 struct dvb_pll_desc *pll_desc;
35
36 /* Need to set device param for start_dma */
37 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
38};
39
40extern struct dvb_frontend* lgdt3302_attach(const struct lgdt3302_config* config,
41 struct i2c_adapter* i2c);
42
43#endif /* LGDT3302_H */
44
45/*
46 * Local variables:
47 * c-basic-offset: 8
48 * End:
49 */
diff --git a/drivers/media/dvb/frontends/lgdt3302_priv.h b/drivers/media/dvb/frontends/lgdt3302_priv.h
new file mode 100644
index 000000000000..6193fa7a569d
--- /dev/null
+++ b/drivers/media/dvb/frontends/lgdt3302_priv.h
@@ -0,0 +1,72 @@
1/*
2 * $Id: lgdt3302_priv.h,v 1.2 2005/06/28 23:50:48 mkrufky Exp $
3 *
4 * Support for LGDT3302 (DViCO FustionHDTV 3 Gold) - VSB/QAM
5 *
6 * Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24#ifndef _LGDT3302_PRIV_
25#define _LGDT3302_PRIV_
26
27/* i2c control register addresses */
28enum I2C_REG {
29 TOP_CONTROL= 0x00,
30 IRQ_MASK= 0x01,
31 IRQ_STATUS= 0x02,
32 VSB_CARRIER_FREQ0= 0x16,
33 VSB_CARRIER_FREQ1= 0x17,
34 VSB_CARRIER_FREQ2= 0x18,
35 VSB_CARRIER_FREQ3= 0x19,
36 CARRIER_MSEQAM1= 0x1a,
37 CARRIER_MSEQAM2= 0x1b,
38 CARRIER_LOCK= 0x1c,
39 TIMING_RECOVERY= 0x1d,
40 AGC_DELAY0= 0x2a,
41 AGC_DELAY1= 0x2b,
42 AGC_DELAY2= 0x2c,
43 AGC_RF_BANDWIDTH0= 0x2d,
44 AGC_RF_BANDWIDTH1= 0x2e,
45 AGC_RF_BANDWIDTH2= 0x2f,
46 AGC_LOOP_BANDWIDTH0= 0x30,
47 AGC_LOOP_BANDWIDTH1= 0x31,
48 AGC_FUNC_CTRL1= 0x32,
49 AGC_FUNC_CTRL2= 0x33,
50 AGC_FUNC_CTRL3= 0x34,
51 AGC_RFIF_ACC0= 0x39,
52 AGC_RFIF_ACC1= 0x3a,
53 AGC_RFIF_ACC2= 0x3b,
54 AGC_STATUS= 0x3f,
55 SYNC_STATUS_VSB= 0x43,
56 EQPH_ERR0= 0x47,
57 EQ_ERR1= 0x48,
58 EQ_ERR2= 0x49,
59 PH_ERR1= 0x4a,
60 PH_ERR2= 0x4b,
61 DEMUX_CONTROL= 0x66,
62 PACKET_ERR_COUNTER1= 0x6a,
63 PACKET_ERR_COUNTER2= 0x6b,
64};
65
66#endif /* _LGDT3302_PRIV_ */
67
68/*
69 * Local variables:
70 * c-basic-offset: 8
71 * End:
72 */
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c
new file mode 100644
index 000000000000..4f396ac8de77
--- /dev/null
+++ b/drivers/media/dvb/frontends/s5h1420.c
@@ -0,0 +1,800 @@
1/*
2Driver for Samsung S5H1420 QPSK Demodulator
3
4Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net>
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21*/
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/string.h>
27#include <linux/slab.h>
28#include <linux/delay.h>
29
30#include "dvb_frontend.h"
31#include "s5h1420.h"
32
33
34
35#define TONE_FREQ 22000
36
37struct s5h1420_state {
38 struct i2c_adapter* i2c;
39 struct dvb_frontend_ops ops;
40 const struct s5h1420_config* config;
41 struct dvb_frontend frontend;
42
43 u8 postlocked:1;
44 u32 fclk;
45 u32 tunedfreq;
46 fe_code_rate_t fec_inner;
47 u32 symbol_rate;
48};
49
50static u32 s5h1420_getsymbolrate(struct s5h1420_state* state);
51static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings);
52
53
54static int debug = 0;
55#define dprintk if (debug) printk
56
57static int s5h1420_writereg (struct s5h1420_state* state, u8 reg, u8 data)
58{
59 u8 buf [] = { reg, data };
60 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
61 int err;
62
63 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
64 dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
65 return -EREMOTEIO;
66 }
67
68 return 0;
69}
70
71static u8 s5h1420_readreg (struct s5h1420_state* state, u8 reg)
72{
73 int ret;
74 u8 b0 [] = { reg };
75 u8 b1 [] = { 0 };
76 struct i2c_msg msg1 = { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 };
77 struct i2c_msg msg2 = { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 };
78
79 if ((ret = i2c_transfer (state->i2c, &msg1, 1)) != 1)
80 return ret;
81
82 if ((ret = i2c_transfer (state->i2c, &msg2, 1)) != 1)
83 return ret;
84
85 return b1[0];
86}
87
88static int s5h1420_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
89{
90 struct s5h1420_state* state = fe->demodulator_priv;
91
92 switch(voltage) {
93 case SEC_VOLTAGE_13:
94 s5h1420_writereg(state, 0x3c, (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02);
95 break;
96
97 case SEC_VOLTAGE_18:
98 s5h1420_writereg(state, 0x3c, s5h1420_readreg(state, 0x3c) | 0x03);
99 break;
100
101 case SEC_VOLTAGE_OFF:
102 s5h1420_writereg(state, 0x3c, s5h1420_readreg(state, 0x3c) & 0xfd);
103 break;
104 }
105
106 return 0;
107}
108
109static int s5h1420_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
110{
111 struct s5h1420_state* state = fe->demodulator_priv;
112
113 switch(tone) {
114 case SEC_TONE_ON:
115 s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08);
116 break;
117
118 case SEC_TONE_OFF:
119 s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01);
120 break;
121 }
122
123 return 0;
124}
125
126static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
127{
128 struct s5h1420_state* state = fe->demodulator_priv;
129 u8 val;
130 int i;
131 unsigned long timeout;
132 int result = 0;
133
134 /* setup for DISEQC */
135 val = s5h1420_readreg(state, 0x3b);
136 s5h1420_writereg(state, 0x3b, 0x02);
137 msleep(15);
138
139 /* write the DISEQC command bytes */
140 for(i=0; i< cmd->msg_len; i++) {
141 s5h1420_writereg(state, 0x3c + i, cmd->msg[i]);
142 }
143
144 /* kick off transmission */
145 s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | ((cmd->msg_len-1) << 4) | 0x08);
146
147 /* wait for transmission to complete */
148 timeout = jiffies + ((100*HZ) / 1000);
149 while(time_before(jiffies, timeout)) {
150 if (s5h1420_readreg(state, 0x3b) & 0x08)
151 break;
152
153 msleep(5);
154 }
155 if (time_after(jiffies, timeout))
156 result = -ETIMEDOUT;
157
158 /* restore original settings */
159 s5h1420_writereg(state, 0x3b, val);
160 msleep(15);
161 return result;
162}
163
164static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply)
165{
166 struct s5h1420_state* state = fe->demodulator_priv;
167 u8 val;
168 int i;
169 int length;
170 unsigned long timeout;
171 int result = 0;
172
173 /* setup for DISEQC recieve */
174 val = s5h1420_readreg(state, 0x3b);
175 s5h1420_writereg(state, 0x3b, 0x82); /* FIXME: guess - do we need to set DIS_RDY(0x08) in receive mode? */
176 msleep(15);
177
178 /* wait for reception to complete */
179 timeout = jiffies + ((reply->timeout*HZ) / 1000);
180 while(time_before(jiffies, timeout)) {
181 if (!(s5h1420_readreg(state, 0x3b) & 0x80)) /* FIXME: do we test DIS_RDY(0x08) or RCV_EN(0x80)? */
182 break;
183
184 msleep(5);
185 }
186 if (time_after(jiffies, timeout)) {
187 result = -ETIMEDOUT;
188 goto exit;
189 }
190
191 /* check error flag - FIXME: not sure what this does - docs do not describe
192 * beyond "error flag for diseqc receive data :( */
193 if (s5h1420_readreg(state, 0x49)) {
194 result = -EIO;
195 goto exit;
196 }
197
198 /* check length */
199 length = (s5h1420_readreg(state, 0x3b) & 0x70) >> 4;
200 if (length > sizeof(reply->msg)) {
201 result = -EOVERFLOW;
202 goto exit;
203 }
204 reply->msg_len = length;
205
206 /* extract data */
207 for(i=0; i< length; i++) {
208 reply->msg[i] = s5h1420_readreg(state, 0x3c + i);
209 }
210
211exit:
212 /* restore original settings */
213 s5h1420_writereg(state, 0x3b, val);
214 msleep(15);
215 return result;
216}
217
218static int s5h1420_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
219{
220 struct s5h1420_state* state = fe->demodulator_priv;
221 u8 val;
222 int result = 0;
223 unsigned long timeout;
224
225 /* setup for tone burst */
226 val = s5h1420_readreg(state, 0x3b);
227 s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x70) | 0x01);
228
229 /* set value for B position if requested */
230 if (minicmd == SEC_MINI_B) {
231 s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x04);
232 }
233 msleep(15);
234
235 /* start transmission */
236 s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x08);
237
238 /* wait for transmission to complete */
239 timeout = jiffies + ((20*HZ) / 1000);
240 while(time_before(jiffies, timeout)) {
241 if (!(s5h1420_readreg(state, 0x3b) & 0x08))
242 break;
243
244 msleep(5);
245 }
246 if (time_after(jiffies, timeout))
247 result = -ETIMEDOUT;
248
249 /* restore original settings */
250 s5h1420_writereg(state, 0x3b, val);
251 msleep(15);
252 return result;
253}
254
255static fe_status_t s5h1420_get_status_bits(struct s5h1420_state* state)
256{
257 u8 val;
258 fe_status_t status = 0;
259
260 val = s5h1420_readreg(state, 0x14);
261 if (val & 0x02)
262 status |= FE_HAS_SIGNAL; // FIXME: not sure if this is right
263 if (val & 0x01)
264 status |= FE_HAS_CARRIER; // FIXME: not sure if this is right
265 val = s5h1420_readreg(state, 0x36);
266 if (val & 0x01)
267 status |= FE_HAS_VITERBI;
268 if (val & 0x20)
269 status |= FE_HAS_SYNC;
270 if (status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI|FE_HAS_SYNC))
271 status |= FE_HAS_LOCK;
272
273 return status;
274}
275
276static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status)
277{
278 struct s5h1420_state* state = fe->demodulator_priv;
279 u8 val;
280
281 if (status == NULL)
282 return -EINVAL;
283
284 /* determine lock state */
285 *status = s5h1420_get_status_bits(state);
286
287 /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert the inversion,
288 wait a bit and check again */
289 if (*status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI)) {
290 val = s5h1420_readreg(state, 0x32);
291 if ((val & 0x07) == 0x03) {
292 if (val & 0x08)
293 s5h1420_writereg(state, 0x31, 0x13);
294 else
295 s5h1420_writereg(state, 0x31, 0x1b);
296
297 /* wait a bit then update lock status */
298 mdelay(200);
299 *status = s5h1420_get_status_bits(state);
300 }
301 }
302
303 /* perform post lock setup */
304 if ((*status & FE_HAS_LOCK) && (!state->postlocked)) {
305
306 /* calculate the data rate */
307 u32 tmp = s5h1420_getsymbolrate(state);
308 switch(s5h1420_readreg(state, 0x32) & 0x07) {
309 case 0:
310 tmp = (tmp * 2 * 1) / 2;
311 break;
312
313 case 1:
314 tmp = (tmp * 2 * 2) / 3;
315 break;
316
317 case 2:
318 tmp = (tmp * 2 * 3) / 4;
319 break;
320
321 case 3:
322 tmp = (tmp * 2 * 5) / 6;
323 break;
324
325 case 4:
326 tmp = (tmp * 2 * 6) / 7;
327 break;
328
329 case 5:
330 tmp = (tmp * 2 * 7) / 8;
331 break;
332 }
333 tmp = state->fclk / tmp;
334
335 /* set the MPEG_CLK_INTL for the calculated data rate */
336 if (tmp < 4)
337 val = 0x00;
338 else if (tmp < 8)
339 val = 0x01;
340 else if (tmp < 12)
341 val = 0x02;
342 else if (tmp < 16)
343 val = 0x03;
344 else if (tmp < 24)
345 val = 0x04;
346 else if (tmp < 32)
347 val = 0x05;
348 else
349 val = 0x06;
350 s5h1420_writereg(state, 0x22, val);
351
352 /* DC freeze */
353 s5h1420_writereg(state, 0x1f, s5h1420_readreg(state, 0x1f) | 0x01);
354
355 /* kicker disable + remove DC offset */
356 s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) & 0x6f);
357
358 /* post-lock processing has been done! */
359 state->postlocked = 1;
360 }
361
362 return 0;
363}
364
365static int s5h1420_read_ber(struct dvb_frontend* fe, u32* ber)
366{
367 struct s5h1420_state* state = fe->demodulator_priv;
368
369 s5h1420_writereg(state, 0x46, 0x1d);
370 mdelay(25);
371 return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47);
372}
373
374static int s5h1420_read_signal_strength(struct dvb_frontend* fe, u16* strength)
375{
376 struct s5h1420_state* state = fe->demodulator_priv;
377
378 u8 val = 0xff - s5h1420_readreg(state, 0x15);
379
380 return (int) ((val << 8) | val);
381}
382
383static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
384{
385 struct s5h1420_state* state = fe->demodulator_priv;
386
387 s5h1420_writereg(state, 0x46, 0x1f);
388 mdelay(25);
389 return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47);
390}
391
392static void s5h1420_reset(struct s5h1420_state* state)
393{
394 s5h1420_writereg (state, 0x01, 0x08);
395 s5h1420_writereg (state, 0x01, 0x00);
396 udelay(10);
397}
398
399static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_frontend_parameters *p)
400{
401 u64 val;
402
403 val = (p->u.qpsk.symbol_rate / 1000) * (1<<24);
404 if (p->u.qpsk.symbol_rate <= 21000000) {
405 val *= 2;
406 }
407 do_div(val, (state->fclk / 1000));
408
409 s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) & 0x7f);
410 s5h1420_writereg(state, 0x11, val >> 16);
411 s5h1420_writereg(state, 0x12, val >> 8);
412 s5h1420_writereg(state, 0x13, val & 0xff);
413 s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) | 0x80);
414}
415
416static u32 s5h1420_getsymbolrate(struct s5h1420_state* state)
417{
418 u64 val;
419 int sampling = 2;
420
421 if (s5h1420_readreg(state, 0x05) & 0x2)
422 sampling = 1;
423
424 s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) | 0x08);
425 val = s5h1420_readreg(state, 0x11) << 16;
426 val |= s5h1420_readreg(state, 0x12) << 8;
427 val |= s5h1420_readreg(state, 0x13);
428 s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7);
429
430 val *= (state->fclk / 1000);
431 do_div(val, ((1<<24) * sampling));
432
433 return (u32) (val * 1000);
434}
435
436static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset)
437{
438 int val;
439
440 /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so
441 * divide fclk by 1000000 to get the correct value. */
442 val = -(int) ((freqoffset * (1<<24)) / (state->fclk / 1000000));
443
444 s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) & 0xbf);
445 s5h1420_writereg(state, 0x0e, val >> 16);
446 s5h1420_writereg(state, 0x0f, val >> 8);
447 s5h1420_writereg(state, 0x10, val & 0xff);
448 s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) | 0x40);
449}
450
451static int s5h1420_getfreqoffset(struct s5h1420_state* state)
452{
453 int val;
454
455 s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) | 0x08);
456 val = s5h1420_readreg(state, 0x0e) << 16;
457 val |= s5h1420_readreg(state, 0x0f) << 8;
458 val |= s5h1420_readreg(state, 0x10);
459 s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7);
460
461 if (val & 0x800000)
462 val |= 0xff000000;
463
464 /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so
465 * divide fclk by 1000000 to get the correct value. */
466 val = - ((val * (state->fclk/1000000)) / (1<<24));
467
468 return val;
469}
470
471static void s5h1420_setfec(struct s5h1420_state* state, struct dvb_frontend_parameters *p)
472{
473 if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) {
474 s5h1420_writereg(state, 0x31, 0x00);
475 s5h1420_writereg(state, 0x30, 0x3f);
476 } else {
477 switch(p->u.qpsk.fec_inner) {
478 case FEC_1_2:
479 s5h1420_writereg(state, 0x31, 0x10);
480 s5h1420_writereg(state, 0x30, 0x01);
481 break;
482
483 case FEC_2_3:
484 s5h1420_writereg(state, 0x31, 0x11);
485 s5h1420_writereg(state, 0x30, 0x02);
486 break;
487
488 case FEC_3_4:
489 s5h1420_writereg(state, 0x31, 0x12);
490 s5h1420_writereg(state, 0x30, 0x04);
491 break;
492
493 case FEC_5_6:
494 s5h1420_writereg(state, 0x31, 0x13);
495 s5h1420_writereg(state, 0x30, 0x08);
496 break;
497
498 case FEC_6_7:
499 s5h1420_writereg(state, 0x31, 0x14);
500 s5h1420_writereg(state, 0x30, 0x10);
501 break;
502
503 case FEC_7_8:
504 s5h1420_writereg(state, 0x31, 0x15);
505 s5h1420_writereg(state, 0x30, 0x20);
506 break;
507
508 default:
509 return;
510 }
511 }
512}
513
514static fe_code_rate_t s5h1420_getfec(struct s5h1420_state* state)
515{
516 switch(s5h1420_readreg(state, 0x32) & 0x07) {
517 case 0:
518 return FEC_1_2;
519
520 case 1:
521 return FEC_2_3;
522
523 case 2:
524 return FEC_3_4;
525
526 case 3:
527 return FEC_5_6;
528
529 case 4:
530 return FEC_6_7;
531
532 case 5:
533 return FEC_7_8;
534 }
535
536 return FEC_NONE;
537}
538
539static void s5h1420_setinversion(struct s5h1420_state* state, struct dvb_frontend_parameters *p)
540{
541 if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) {
542 s5h1420_writereg(state, 0x31, 0x00);
543 s5h1420_writereg(state, 0x30, 0x3f);
544 } else {
545 u8 tmp = s5h1420_readreg(state, 0x31) & 0xf7;
546 tmp |= 0x10;
547
548 if (p->inversion == INVERSION_ON)
549 tmp |= 0x80;
550
551 s5h1420_writereg(state, 0x31, tmp);
552 }
553}
554
555static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state)
556{
557 if (s5h1420_readreg(state, 0x32) & 0x08)
558 return INVERSION_ON;
559
560 return INVERSION_OFF;
561}
562
563static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
564{
565 struct s5h1420_state* state = fe->demodulator_priv;
566 u32 frequency_delta;
567 struct dvb_frontend_tune_settings fesettings;
568
569 /* check if we should do a fast-tune */
570 memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters));
571 s5h1420_get_tune_settings(fe, &fesettings);
572 frequency_delta = p->frequency - state->tunedfreq;
573 if ((frequency_delta > -fesettings.max_drift) && (frequency_delta < fesettings.max_drift) &&
574 (frequency_delta != 0) &&
575 (state->fec_inner == p->u.qpsk.fec_inner) &&
576 (state->symbol_rate == p->u.qpsk.symbol_rate)) {
577
578 s5h1420_setfreqoffset(state, frequency_delta);
579 return 0;
580 }
581
582 /* first of all, software reset */
583 s5h1420_reset(state);
584
585 /* set tuner PLL */
586 if (state->config->pll_set) {
587 s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1);
588 state->config->pll_set(fe, p, &state->tunedfreq);
589 s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe);
590 }
591
592 /* set s5h1420 fclk PLL according to desired symbol rate */
593 if (p->u.qpsk.symbol_rate > 28000000) {
594 state->fclk = 88000000;
595 s5h1420_writereg(state, 0x03, 0x50);
596 s5h1420_writereg(state, 0x04, 0x40);
597 s5h1420_writereg(state, 0x05, 0xae);
598 } else if (p->u.qpsk.symbol_rate > 21000000) {
599 state->fclk = 59000000;
600 s5h1420_writereg(state, 0x03, 0x33);
601 s5h1420_writereg(state, 0x04, 0x40);
602 s5h1420_writereg(state, 0x05, 0xae);
603 } else {
604 state->fclk = 88000000;
605 s5h1420_writereg(state, 0x03, 0x50);
606 s5h1420_writereg(state, 0x04, 0x40);
607 s5h1420_writereg(state, 0x05, 0xac);
608 }
609
610 /* set misc registers */
611 s5h1420_writereg(state, 0x02, 0x00);
612 s5h1420_writereg(state, 0x07, 0xb0);
613 s5h1420_writereg(state, 0x0a, 0x67);
614 s5h1420_writereg(state, 0x0b, 0x78);
615 s5h1420_writereg(state, 0x0c, 0x48);
616 s5h1420_writereg(state, 0x0d, 0x6b);
617 s5h1420_writereg(state, 0x2e, 0x8e);
618 s5h1420_writereg(state, 0x35, 0x33);
619 s5h1420_writereg(state, 0x38, 0x01);
620 s5h1420_writereg(state, 0x39, 0x7d);
621 s5h1420_writereg(state, 0x3a, (state->fclk + (TONE_FREQ * 32) - 1) / (TONE_FREQ * 32));
622 s5h1420_writereg(state, 0x3c, 0x00);
623 s5h1420_writereg(state, 0x45, 0x61);
624 s5h1420_writereg(state, 0x46, 0x1d);
625
626 /* start QPSK */
627 s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1);
628
629 /* set the frequency offset to adjust for PLL inaccuracy */
630 s5h1420_setfreqoffset(state, p->frequency - state->tunedfreq);
631
632 /* set the reset of the parameters */
633 s5h1420_setsymbolrate(state, p);
634 s5h1420_setinversion(state, p);
635 s5h1420_setfec(state, p);
636
637 state->fec_inner = p->u.qpsk.fec_inner;
638 state->symbol_rate = p->u.qpsk.symbol_rate;
639 state->postlocked = 0;
640 return 0;
641}
642
643static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
644{
645 struct s5h1420_state* state = fe->demodulator_priv;
646
647 p->frequency = state->tunedfreq + s5h1420_getfreqoffset(state);
648 p->inversion = s5h1420_getinversion(state);
649 p->u.qpsk.symbol_rate = s5h1420_getsymbolrate(state);
650 p->u.qpsk.fec_inner = s5h1420_getfec(state);
651
652 return 0;
653}
654
655static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
656{
657 if (fesettings->parameters.u.qpsk.symbol_rate > 20000000) {
658 fesettings->min_delay_ms = 50;
659 fesettings->step_size = 2000;
660 fesettings->max_drift = 8000;
661 } else if (fesettings->parameters.u.qpsk.symbol_rate > 12000000) {
662 fesettings->min_delay_ms = 100;
663 fesettings->step_size = 1500;
664 fesettings->max_drift = 9000;
665 } else if (fesettings->parameters.u.qpsk.symbol_rate > 8000000) {
666 fesettings->min_delay_ms = 100;
667 fesettings->step_size = 1000;
668 fesettings->max_drift = 8000;
669 } else if (fesettings->parameters.u.qpsk.symbol_rate > 4000000) {
670 fesettings->min_delay_ms = 100;
671 fesettings->step_size = 500;
672 fesettings->max_drift = 7000;
673 } else if (fesettings->parameters.u.qpsk.symbol_rate > 2000000) {
674 fesettings->min_delay_ms = 200;
675 fesettings->step_size = (fesettings->parameters.u.qpsk.symbol_rate / 8000);
676 fesettings->max_drift = 14 * fesettings->step_size;
677 } else {
678 fesettings->min_delay_ms = 200;
679 fesettings->step_size = (fesettings->parameters.u.qpsk.symbol_rate / 8000);
680 fesettings->max_drift = 18 * fesettings->step_size;
681 }
682
683 return 0;
684}
685
686static int s5h1420_init (struct dvb_frontend* fe)
687{
688 struct s5h1420_state* state = fe->demodulator_priv;
689
690 /* disable power down and do reset */
691 s5h1420_writereg(state, 0x02, 0x10);
692 msleep(10);
693 s5h1420_reset(state);
694
695 /* init PLL */
696 if (state->config->pll_init) {
697 s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1);
698 state->config->pll_init(fe);
699 s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe);
700 }
701
702 return 0;
703}
704
705static int s5h1420_sleep(struct dvb_frontend* fe)
706{
707 struct s5h1420_state* state = fe->demodulator_priv;
708
709 return s5h1420_writereg(state, 0x02, 0x12);
710}
711
712static void s5h1420_release(struct dvb_frontend* fe)
713{
714 struct s5h1420_state* state = fe->demodulator_priv;
715 kfree(state);
716}
717
718static struct dvb_frontend_ops s5h1420_ops;
719
720struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, struct i2c_adapter* i2c)
721{
722 struct s5h1420_state* state = NULL;
723 u8 identity;
724
725 /* allocate memory for the internal state */
726 state = kmalloc(sizeof(struct s5h1420_state), GFP_KERNEL);
727 if (state == NULL)
728 goto error;
729
730 /* setup the state */
731 state->config = config;
732 state->i2c = i2c;
733 memcpy(&state->ops, &s5h1420_ops, sizeof(struct dvb_frontend_ops));
734 state->postlocked = 0;
735 state->fclk = 88000000;
736 state->tunedfreq = 0;
737 state->fec_inner = FEC_NONE;
738 state->symbol_rate = 0;
739
740 /* check if the demod is there + identify it */
741 identity = s5h1420_readreg(state, 0x00);
742 if (identity != 0x03)
743 goto error;
744
745 /* create dvb_frontend */
746 state->frontend.ops = &state->ops;
747 state->frontend.demodulator_priv = state;
748 return &state->frontend;
749
750error:
751 kfree(state);
752 return NULL;
753}
754
755static struct dvb_frontend_ops s5h1420_ops = {
756
757 .info = {
758 .name = "Samsung S5H1420 DVB-S",
759 .type = FE_QPSK,
760 .frequency_min = 950000,
761 .frequency_max = 2150000,
762 .frequency_stepsize = 125, /* kHz for QPSK frontends */
763 .frequency_tolerance = 29500,
764 .symbol_rate_min = 1000000,
765 .symbol_rate_max = 45000000,
766 /* .symbol_rate_tolerance = ???,*/
767 .caps = FE_CAN_INVERSION_AUTO |
768 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
769 FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
770 FE_CAN_QPSK
771 },
772
773 .release = s5h1420_release,
774
775 .init = s5h1420_init,
776 .sleep = s5h1420_sleep,
777
778 .set_frontend = s5h1420_set_frontend,
779 .get_frontend = s5h1420_get_frontend,
780 .get_tune_settings = s5h1420_get_tune_settings,
781
782 .read_status = s5h1420_read_status,
783 .read_ber = s5h1420_read_ber,
784 .read_signal_strength = s5h1420_read_signal_strength,
785 .read_ucblocks = s5h1420_read_ucblocks,
786
787 .diseqc_send_master_cmd = s5h1420_send_master_cmd,
788 .diseqc_recv_slave_reply = s5h1420_recv_slave_reply,
789 .diseqc_send_burst = s5h1420_send_burst,
790 .set_tone = s5h1420_set_tone,
791 .set_voltage = s5h1420_set_voltage,
792};
793
794module_param(debug, int, 0644);
795
796MODULE_DESCRIPTION("Samsung S5H1420 DVB-S Demodulator driver");
797MODULE_AUTHOR("Andrew de Quincey");
798MODULE_LICENSE("GPL");
799
800EXPORT_SYMBOL(s5h1420_attach);
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h
new file mode 100644
index 000000000000..b687fc77ceb3
--- /dev/null
+++ b/drivers/media/dvb/frontends/s5h1420.h
@@ -0,0 +1,41 @@
1/*
2 Driver for S5H1420 QPSK Demodulators
3
4 Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21*/
22
23#ifndef S5H1420_H
24#define S5H1420_H
25
26#include <linux/dvb/frontend.h>
27
28struct s5h1420_config
29{
30 /* the demodulator's i2c address */
31 u8 demod_address;
32
33 /* PLL maintenance */
34 int (*pll_init)(struct dvb_frontend* fe);
35 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout);
36};
37
38extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
39 struct i2c_adapter* i2c);
40
41#endif // S5H1420_H
diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c
index e681263bf079..928aca052afe 100644
--- a/drivers/media/dvb/frontends/stv0297.c
+++ b/drivers/media/dvb/frontends/stv0297.c
@@ -617,7 +617,7 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
617 617
618 /* wait for WGAGC lock */ 618 /* wait for WGAGC lock */
619 starttime = jiffies; 619 starttime = jiffies;
620 timeout = jiffies + (200 * HZ) / 1000; 620 timeout = jiffies + msecs_to_jiffies(2000);
621 while (time_before(jiffies, timeout)) { 621 while (time_before(jiffies, timeout)) {
622 msleep(10); 622 msleep(10);
623 if (stv0297_readreg(state, 0x43) & 0x08) 623 if (stv0297_readreg(state, 0x43) & 0x08)
@@ -629,7 +629,7 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
629 msleep(20); 629 msleep(20);
630 630
631 /* wait for equaliser partial convergence */ 631 /* wait for equaliser partial convergence */
632 timeout = jiffies + (50 * HZ) / 1000; 632 timeout = jiffies + msecs_to_jiffies(500);
633 while (time_before(jiffies, timeout)) { 633 while (time_before(jiffies, timeout)) {
634 msleep(10); 634 msleep(10);
635 635
@@ -642,7 +642,7 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
642 } 642 }
643 643
644 /* wait for equaliser full convergence */ 644 /* wait for equaliser full convergence */
645 timeout = jiffies + (delay * HZ) / 1000; 645 timeout = jiffies + msecs_to_jiffies(delay);
646 while (time_before(jiffies, timeout)) { 646 while (time_before(jiffies, timeout)) {
647 msleep(10); 647 msleep(10);
648 648
@@ -659,7 +659,7 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
659 stv0297_writereg_mask(state, 0x88, 8, 0); 659 stv0297_writereg_mask(state, 0x88, 8, 0);
660 660
661 /* wait for main lock */ 661 /* wait for main lock */
662 timeout = jiffies + (20 * HZ) / 1000; 662 timeout = jiffies + msecs_to_jiffies(20);
663 while (time_before(jiffies, timeout)) { 663 while (time_before(jiffies, timeout)) {
664 msleep(10); 664 msleep(10);
665 665
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index 0beb370792ae..ab0c032472cc 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -49,10 +49,8 @@ struct tda1004x_state {
49 /* private demod data */ 49 /* private demod data */
50 u8 initialised; 50 u8 initialised;
51 enum tda1004x_demod demod_type; 51 enum tda1004x_demod demod_type;
52 u8 fw_version;
53}; 52};
54 53
55
56static int debug; 54static int debug;
57#define dprintk(args...) \ 55#define dprintk(args...) \
58 do { \ 56 do { \
@@ -122,6 +120,8 @@ static int debug;
122#define TDA10046H_GPIO_OUT_SEL 0x41 120#define TDA10046H_GPIO_OUT_SEL 0x41
123#define TDA10046H_GPIO_SELECT 0x42 121#define TDA10046H_GPIO_SELECT 0x42
124#define TDA10046H_AGC_CONF 0x43 122#define TDA10046H_AGC_CONF 0x43
123#define TDA10046H_AGC_THR 0x44
124#define TDA10046H_AGC_RENORM 0x45
125#define TDA10046H_AGC_GAINS 0x46 125#define TDA10046H_AGC_GAINS 0x46
126#define TDA10046H_AGC_TUN_MIN 0x47 126#define TDA10046H_AGC_TUN_MIN 0x47
127#define TDA10046H_AGC_TUN_MAX 0x48 127#define TDA10046H_AGC_TUN_MAX 0x48
@@ -274,14 +274,26 @@ static int tda10046h_set_bandwidth(struct tda1004x_state *state,
274 switch (bandwidth) { 274 switch (bandwidth) {
275 case BANDWIDTH_6_MHZ: 275 case BANDWIDTH_6_MHZ:
276 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz, sizeof(bandwidth_6mhz)); 276 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz, sizeof(bandwidth_6mhz));
277 if (state->config->if_freq == TDA10046_FREQ_045) {
278 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x09);
279 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x4f);
280 }
277 break; 281 break;
278 282
279 case BANDWIDTH_7_MHZ: 283 case BANDWIDTH_7_MHZ:
280 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz, sizeof(bandwidth_7mhz)); 284 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz, sizeof(bandwidth_7mhz));
285 if (state->config->if_freq == TDA10046_FREQ_045) {
286 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0a);
287 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x79);
288 }
281 break; 289 break;
282 290
283 case BANDWIDTH_8_MHZ: 291 case BANDWIDTH_8_MHZ:
284 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz, sizeof(bandwidth_8mhz)); 292 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz, sizeof(bandwidth_8mhz));
293 if (state->config->if_freq == TDA10046_FREQ_045) {
294 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b);
295 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3);
296 }
285 break; 297 break;
286 298
287 default: 299 default:
@@ -315,20 +327,35 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
315 memcpy(buf + 1, mem + pos, tx_size); 327 memcpy(buf + 1, mem + pos, tx_size);
316 fw_msg.len = tx_size + 1; 328 fw_msg.len = tx_size + 1;
317 if (i2c_transfer(state->i2c, &fw_msg, 1) != 1) { 329 if (i2c_transfer(state->i2c, &fw_msg, 1) != 1) {
318 printk("tda1004x: Error during firmware upload\n"); 330 printk(KERN_ERR "tda1004x: Error during firmware upload\n");
319 return -EIO; 331 return -EIO;
320 } 332 }
321 pos += tx_size; 333 pos += tx_size;
322 334
323 dprintk("%s: fw_pos=0x%x\n", __FUNCTION__, pos); 335 dprintk("%s: fw_pos=0x%x\n", __FUNCTION__, pos);
324 } 336 }
337 // give the DSP a chance to settle 03/10/05 Hac
338 msleep(100);
325 339
326 return 0; 340 return 0;
327} 341}
328 342
329static int tda1004x_check_upload_ok(struct tda1004x_state *state, u8 dspVersion) 343static int tda1004x_check_upload_ok(struct tda1004x_state *state)
330{ 344{
331 u8 data1, data2; 345 u8 data1, data2;
346 unsigned long timeout;
347
348 if (state->demod_type == TDA1004X_DEMOD_TDA10046) {
349 timeout = jiffies + 2 * HZ;
350 while(!(tda1004x_read_byte(state, TDA1004X_STATUS_CD) & 0x20)) {
351 if (time_after(jiffies, timeout)) {
352 printk(KERN_ERR "tda1004x: timeout waiting for DSP ready\n");
353 break;
354 }
355 msleep(1);
356 }
357 } else
358 msleep(100);
332 359
333 // check upload was OK 360 // check upload was OK
334 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x10, 0); // we want to read from the DSP 361 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x10, 0); // we want to read from the DSP
@@ -336,9 +363,11 @@ static int tda1004x_check_upload_ok(struct tda1004x_state *state, u8 dspVersion)
336 363
337 data1 = tda1004x_read_byte(state, TDA1004X_DSP_DATA1); 364 data1 = tda1004x_read_byte(state, TDA1004X_DSP_DATA1);
338 data2 = tda1004x_read_byte(state, TDA1004X_DSP_DATA2); 365 data2 = tda1004x_read_byte(state, TDA1004X_DSP_DATA2);
339 if ((data1 != 0x67) || (data2 != dspVersion)) 366 if (data1 != 0x67 || data2 < 0x20 || data2 > 0x2e) {
367 printk(KERN_INFO "tda1004x: found firmware revision %x -- invalid\n", data2);
340 return -EIO; 368 return -EIO;
341 369 }
370 printk(KERN_INFO "tda1004x: found firmware revision %x -- ok\n", data2);
342 return 0; 371 return 0;
343} 372}
344 373
@@ -349,14 +378,14 @@ static int tda10045_fwupload(struct dvb_frontend* fe)
349 const struct firmware *fw; 378 const struct firmware *fw;
350 379
351 /* don't re-upload unless necessary */ 380 /* don't re-upload unless necessary */
352 if (tda1004x_check_upload_ok(state, 0x2c) == 0) 381 if (tda1004x_check_upload_ok(state) == 0)
353 return 0; 382 return 0;
354 383
355 /* request the firmware, this will block until someone uploads it */ 384 /* request the firmware, this will block until someone uploads it */
356 printk("tda1004x: waiting for firmware upload (%s)...\n", TDA10045_DEFAULT_FIRMWARE); 385 printk(KERN_INFO "tda1004x: waiting for firmware upload (%s)...\n", TDA10045_DEFAULT_FIRMWARE);
357 ret = state->config->request_firmware(fe, &fw, TDA10045_DEFAULT_FIRMWARE); 386 ret = state->config->request_firmware(fe, &fw, TDA10045_DEFAULT_FIRMWARE);
358 if (ret) { 387 if (ret) {
359 printk("tda1004x: no firmware upload (timeout or file not found?)\n"); 388 printk(KERN_ERR "tda1004x: no firmware upload (timeout or file not found?)\n");
360 return ret; 389 return ret;
361 } 390 }
362 391
@@ -370,95 +399,93 @@ static int tda10045_fwupload(struct dvb_frontend* fe)
370 tda10045h_set_bandwidth(state, BANDWIDTH_8_MHZ); 399 tda10045h_set_bandwidth(state, BANDWIDTH_8_MHZ);
371 400
372 ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10045H_FWPAGE, TDA10045H_CODE_IN); 401 ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10045H_FWPAGE, TDA10045H_CODE_IN);
402 release_firmware(fw);
373 if (ret) 403 if (ret)
374 return ret; 404 return ret;
375 printk("tda1004x: firmware upload complete\n"); 405 printk(KERN_INFO "tda1004x: firmware upload complete\n");
376 406
377 /* wait for DSP to initialise */ 407 /* wait for DSP to initialise */
378 /* DSPREADY doesn't seem to work on the TDA10045H */ 408 /* DSPREADY doesn't seem to work on the TDA10045H */
379 msleep(100); 409 msleep(100);
380 410
381 return tda1004x_check_upload_ok(state, 0x2c); 411 return tda1004x_check_upload_ok(state);
382} 412}
383 413
384static int tda10046_get_fw_version(struct tda1004x_state *state, 414static void tda10046_init_plls(struct dvb_frontend* fe)
385 const struct firmware *fw)
386{ 415{
387 const unsigned char pattern[] = { 0x67, 0x00, 0x50, 0x62, 0x5e, 0x18, 0x67 }; 416 struct tda1004x_state* state = fe->demodulator_priv;
388 unsigned int i;
389
390 /* area guessed from firmware v20, v21 and v25 */
391 for (i = 0x660; i < 0x700; i++) {
392 if (!memcmp(&fw->data[i], pattern, sizeof(pattern))) {
393 state->fw_version = fw->data[i + sizeof(pattern)];
394 printk(KERN_INFO "tda1004x: using firmware v%02x\n",
395 state->fw_version);
396 return 0;
397 }
398 }
399 417
400 return -EINVAL; 418 tda1004x_write_byteI(state, TDA10046H_CONFPLL1, 0xf0);
419 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); // PLL M = 10
420 if (state->config->xtal_freq == TDA10046_XTAL_4M ) {
421 dprintk("%s: setting up PLLs for a 4 MHz Xtal\n", __FUNCTION__);
422 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0
423 } else {
424 dprintk("%s: setting up PLLs for a 16 MHz Xtal\n", __FUNCTION__);
425 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 3); // PLL P = 0, N = 3
426 }
427 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99);
428 switch (state->config->if_freq) {
429 case TDA10046_FREQ_3617:
430 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);
431 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c);
432 break;
433 case TDA10046_FREQ_3613:
434 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);
435 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x13);
436 break;
437 case TDA10046_FREQ_045:
438 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b);
439 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3);
440 break;
441 case TDA10046_FREQ_052:
442 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c);
443 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x06);
444 break;
445 }
446 tda10046h_set_bandwidth(state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz
401} 447}
402 448
403static int tda10046_fwupload(struct dvb_frontend* fe) 449static int tda10046_fwupload(struct dvb_frontend* fe)
404{ 450{
405 struct tda1004x_state* state = fe->demodulator_priv; 451 struct tda1004x_state* state = fe->demodulator_priv;
406 unsigned long timeout;
407 int ret; 452 int ret;
408 const struct firmware *fw; 453 const struct firmware *fw;
409 454
410 /* reset + wake up chip */ 455 /* reset + wake up chip */
411 tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 0); 456 tda1004x_write_byteI(state, TDA1004X_CONFC4, 0);
412 tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0); 457 tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0);
413 msleep(100); 458 /* let the clocks recover from sleep */
459 msleep(5);
414 460
415 /* don't re-upload unless necessary */ 461 /* don't re-upload unless necessary */
416 if (tda1004x_check_upload_ok(state, state->fw_version) == 0) 462 if (tda1004x_check_upload_ok(state) == 0)
417 return 0; 463 return 0;
418 464
419 /* request the firmware, this will block until someone uploads it */
420 printk("tda1004x: waiting for firmware upload (%s)...\n", TDA10046_DEFAULT_FIRMWARE);
421 ret = state->config->request_firmware(fe, &fw, TDA10046_DEFAULT_FIRMWARE);
422 if (ret) {
423 printk("tda1004x: no firmware upload (timeout or file not found?)\n");
424 return ret;
425 }
426
427 if (fw->size < 24478) { /* size of firmware v20, which is the smallest of v20, v21 and v25 */
428 printk("tda1004x: firmware file seems to be too small (%d bytes)\n", fw->size);
429 return -EINVAL;
430 }
431
432 ret = tda10046_get_fw_version(state, fw);
433 if (ret < 0) {
434 printk("tda1004x: unable to find firmware version\n");
435 return ret;
436 }
437
438 /* set parameters */ 465 /* set parameters */
439 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); 466 tda10046_init_plls(fe);
440 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, state->config->n_i2c); 467
441 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99); 468 if (state->config->request_firmware != NULL) {
442 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4); 469 /* request the firmware, this will block until someone uploads it */
443 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c); 470 printk(KERN_INFO "tda1004x: waiting for firmware upload...\n");
444 tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8); // going to boot from HOST 471 ret = state->config->request_firmware(fe, &fw, TDA10046_DEFAULT_FIRMWARE);
445 472 if (ret) {
446 ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10046H_CODE_CPT, TDA10046H_CODE_IN); 473 printk(KERN_ERR "tda1004x: no firmware upload (timeout or file not found?)\n");
447 if (ret) 474 return ret;
448 return ret;
449 printk("tda1004x: firmware upload complete\n");
450
451 /* wait for DSP to initialise */
452 timeout = jiffies + HZ;
453 while (!(tda1004x_read_byte(state, TDA1004X_STATUS_CD) & 0x20)) {
454 if (time_after(jiffies, timeout)) {
455 printk("tda1004x: DSP failed to initialised.\n");
456 return -EIO;
457 } 475 }
458 msleep(1); 476 tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8); // going to boot from HOST
477 ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10046H_CODE_CPT, TDA10046H_CODE_IN);
478 release_firmware(fw);
479 if (ret)
480 return ret;
481 } else {
482 /* boot from firmware eeprom */
483 /* Hac Note: we might need to do some GPIO Magic here */
484 printk(KERN_INFO "tda1004x: booting from eeprom\n");
485 tda1004x_write_mask(state, TDA1004X_CONFC4, 4, 4);
486 msleep(300);
459 } 487 }
460 488 return tda1004x_check_upload_ok(state);
461 return tda1004x_check_upload_ok(state, state->fw_version);
462} 489}
463 490
464static int tda1004x_encode_fec(int fec) 491static int tda1004x_encode_fec(int fec)
@@ -560,12 +587,10 @@ static int tda10046_init(struct dvb_frontend* fe)
560 587
561 if (tda10046_fwupload(fe)) { 588 if (tda10046_fwupload(fe)) {
562 printk("tda1004x: firmware upload failed\n"); 589 printk("tda1004x: firmware upload failed\n");
563 return -EIO; 590 return -EIO;
564 } 591 }
565 592
566 tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 0); // wake up the chip 593 // Init the tuner PLL
567
568 // Init the PLL
569 if (state->config->pll_init) { 594 if (state->config->pll_init) {
570 tda1004x_enable_tuner_i2c(state); 595 tda1004x_enable_tuner_i2c(state);
571 state->config->pll_init(fe); 596 state->config->pll_init(fe);
@@ -574,32 +599,44 @@ static int tda10046_init(struct dvb_frontend* fe)
574 599
575 // tda setup 600 // tda setup
576 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer 601 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
577 tda1004x_write_mask(state, TDA1004X_CONFC1, 0x40, 0x40); 602 tda1004x_write_byteI(state, TDA1004X_AUTO, 7); // select HP stream
578 tda1004x_write_mask(state, TDA1004X_AUTO, 8, 0); // select HP stream 603 tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer
579 tda1004x_write_mask(state, TDA1004X_CONFC1, 0x80, 0); // disable pulse killer 604
580 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); // PLL M = 10 605 tda10046_init_plls(fe);
581 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, state->config->n_i2c); // PLL P = N = 0 606 switch (state->config->agc_config) {
582 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99); // FREQOFFS = 99 607 case TDA10046_AGC_DEFAULT:
583 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4); // } PHY2 = -11221 608 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x00); // AGC setup
584 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c); // } 609 tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities
585 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0); // AGC setup 610 break;
586 tda1004x_write_mask(state, TDA10046H_CONF_POLARITY, 0x60, 0x60); // set AGC polarities 611 case TDA10046_AGC_IFO_AUTO_NEG:
612 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x0a); // AGC setup
613 tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities
614 break;
615 case TDA10046_AGC_IFO_AUTO_POS:
616 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x0a); // AGC setup
617 tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x00); // set AGC polarities
618 break;
619 case TDA10046_AGC_TDA827X:
620 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup
621 tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold
622 tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x0E); // Gain Renormalize
623 tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities
624 break;
625 }
626 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x61); // Turn both AGC outputs on
587 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0); // } 627 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0); // }
588 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values 628 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values
589 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0); // } 629 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0); // }
590 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MAX, 0xff); // } 630 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MAX, 0xff); // }
591 tda1004x_write_mask(state, TDA10046H_CVBER_CTRL, 0x30, 0x10); // 10^6 VBER measurement bits
592 tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 1); // IF gain 2, TUN gain 1 631 tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 1); // IF gain 2, TUN gain 1
593 tda1004x_write_mask(state, TDA1004X_AUTO, 0x80, 0); // crystal is 50ppm 632 tda1004x_write_byteI(state, TDA10046H_CVBER_CTRL, 0x1a); // 10^6 VBER measurement bits
594 tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config 633 tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config
595 tda1004x_write_mask(state, TDA1004X_CONF_TS2, 0x31, 0); // MPEG2 interface config 634 tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0xc0); // MPEG2 interface config
596 tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 0x9e, 0); // disable AGC_TUN 635 tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7);
636
597 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE2, 0xe1); // tristate setup 637 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE2, 0xe1); // tristate setup
598 tda1004x_write_byteI(state, TDA10046H_GPIO_OUT_SEL, 0xcc); // GPIO output config 638 tda1004x_write_byteI(state, TDA10046H_GPIO_OUT_SEL, 0xcc); // GPIO output config
599 tda1004x_write_mask(state, TDA10046H_GPIO_SELECT, 8, 8); // GPIO select 639 tda1004x_write_byteI(state, TDA10046H_GPIO_SELECT, 8); // GPIO select
600 tda10046h_set_bandwidth(state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz
601
602 tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7);
603 640
604 state->initialised = 1; 641 state->initialised = 1;
605 return 0; 642 return 0;
@@ -629,9 +666,6 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,
629 state->config->pll_set(fe, fe_params); 666 state->config->pll_set(fe, fe_params);
630 tda1004x_disable_tuner_i2c(state); 667 tda1004x_disable_tuner_i2c(state);
631 668
632 if (state->demod_type == TDA1004X_DEMOD_TDA10046)
633 tda1004x_write_mask(state, TDA10046H_AGC_CONF, 4, 4);
634
635 // Hardcoded to use auto as much as possible on the TDA10045 as it 669 // Hardcoded to use auto as much as possible on the TDA10045 as it
636 // is very unreliable if AUTO mode is _not_ used. 670 // is very unreliable if AUTO mode is _not_ used.
637 if (state->demod_type == TDA1004X_DEMOD_TDA10045) { 671 if (state->demod_type == TDA1004X_DEMOD_TDA10045) {
@@ -1089,6 +1123,11 @@ static int tda1004x_sleep(struct dvb_frontend* fe)
1089 break; 1123 break;
1090 1124
1091 case TDA1004X_DEMOD_TDA10046: 1125 case TDA1004X_DEMOD_TDA10046:
1126 if (state->config->pll_sleep != NULL) {
1127 tda1004x_enable_tuner_i2c(state);
1128 state->config->pll_sleep(fe);
1129 tda1004x_disable_tuner_i2c(state);
1130 }
1092 tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1); 1131 tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1);
1093 break; 1132 break;
1094 } 1133 }
@@ -1100,8 +1139,9 @@ static int tda1004x_sleep(struct dvb_frontend* fe)
1100static int tda1004x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) 1139static int tda1004x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
1101{ 1140{
1102 fesettings->min_delay_ms = 800; 1141 fesettings->min_delay_ms = 800;
1103 fesettings->step_size = 166667; 1142 /* Drift compensation makes no sense for DVB-T */
1104 fesettings->max_drift = 166667*2; 1143 fesettings->step_size = 0;
1144 fesettings->max_drift = 0;
1105 return 0; 1145 return 0;
1106} 1146}
1107 1147
@@ -1216,7 +1256,6 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
1216 memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops)); 1256 memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
1217 state->initialised = 0; 1257 state->initialised = 0;
1218 state->demod_type = TDA1004X_DEMOD_TDA10046; 1258 state->demod_type = TDA1004X_DEMOD_TDA10046;
1219 state->fw_version = 0x20; /* dummy default value */
1220 1259
1221 /* check if the demod is there */ 1260 /* check if the demod is there */
1222 if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) { 1261 if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) {
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h
index c8e1d54ff262..8659c52647ad 100644
--- a/drivers/media/dvb/frontends/tda1004x.h
+++ b/drivers/media/dvb/frontends/tda1004x.h
@@ -26,6 +26,25 @@
26#include <linux/dvb/frontend.h> 26#include <linux/dvb/frontend.h>
27#include <linux/firmware.h> 27#include <linux/firmware.h>
28 28
29enum tda10046_xtal {
30 TDA10046_XTAL_4M,
31 TDA10046_XTAL_16M,
32};
33
34enum tda10046_agc {
35 TDA10046_AGC_DEFAULT, /* original configuration */
36 TDA10046_AGC_IFO_AUTO_NEG, /* IF AGC only, automatic, negtive */
37 TDA10046_AGC_IFO_AUTO_POS, /* IF AGC only, automatic, positive */
38 TDA10046_AGC_TDA827X, /* IF AGC only, special setup for tda827x */
39};
40
41enum tda10046_if {
42 TDA10046_FREQ_3617, /* original config, 36,166 MHZ */
43 TDA10046_FREQ_3613, /* 36,13 MHZ */
44 TDA10046_FREQ_045, /* low IF, 4.0, 4.5, or 5.0 MHZ */
45 TDA10046_FREQ_052, /* low IF, 5.1667 MHZ for tda9889 */
46};
47
29struct tda1004x_config 48struct tda1004x_config
30{ 49{
31 /* the demodulator's i2c address */ 50 /* the demodulator's i2c address */
@@ -37,14 +56,22 @@ struct tda1004x_config
37 /* Does the OCLK signal need inverted? */ 56 /* Does the OCLK signal need inverted? */
38 u8 invert_oclk; 57 u8 invert_oclk;
39 58
40 /* value of N_I2C of the CONF_PLL3 register */ 59 /* Xtal frequency, 4 or 16MHz*/
41 u8 n_i2c; 60 enum tda10046_xtal xtal_freq;
61
62 /* IF frequency */
63 enum tda10046_if if_freq;
64
65 /* AGC configuration */
66 enum tda10046_agc agc_config;
42 67
43 /* PLL maintenance */ 68 /* PLL maintenance */
44 int (*pll_init)(struct dvb_frontend* fe); 69 int (*pll_init)(struct dvb_frontend* fe);
70 void (*pll_sleep)(struct dvb_frontend* fe);
45 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 71 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
46 72
47 /* request firmware for device */ 73 /* request firmware for device */
74 /* set this to NULL if the card has a firmware EEPROM */
48 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 75 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
49}; 76};
50 77
diff --git a/drivers/media/dvb/frontends/tda80xx.c b/drivers/media/dvb/frontends/tda80xx.c
index 032d348dafb7..88e125079ca1 100644
--- a/drivers/media/dvb/frontends/tda80xx.c
+++ b/drivers/media/dvb/frontends/tda80xx.c
@@ -27,7 +27,6 @@
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/threads.h> 28#include <linux/threads.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/irq.h>
31#include <linux/kernel.h> 30#include <linux/kernel.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/slab.h> 32#include <linux/slab.h>
diff --git a/drivers/media/dvb/pluto2/Kconfig b/drivers/media/dvb/pluto2/Kconfig
new file mode 100644
index 000000000000..f02842be0d60
--- /dev/null
+++ b/drivers/media/dvb/pluto2/Kconfig
@@ -0,0 +1,16 @@
1config DVB_PLUTO2
2 tristate "Pluto2 cards"
3 depends on DVB_CORE && PCI
4 select I2C
5 select I2C_ALGOBIT
6 select DVB_TDA1004X
7 help
8 Support for PCI cards based on the Pluto2 FPGA like the Satelco
9 Easywatch Mobile Terrestrial DVB-T Receiver.
10
11 Since these cards have no MPEG decoder onboard, they transmit
12 only compressed MPEG data over the PCI bus, so you need
13 an external software decoder to watch TV on your computer.
14
15 Say Y or M if you own such a device and want to use it.
16
diff --git a/drivers/media/dvb/pluto2/Makefile b/drivers/media/dvb/pluto2/Makefile
new file mode 100644
index 000000000000..86ca84b2be6e
--- /dev/null
+++ b/drivers/media/dvb/pluto2/Makefile
@@ -0,0 +1,3 @@
1obj-$(CONFIG_DVB_PLUTO2) = pluto2.o
2
3EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
new file mode 100644
index 000000000000..706e0bcb5ede
--- /dev/null
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -0,0 +1,809 @@
1/*
2 * pluto2.c - Satelco Easywatch Mobile Terrestrial Receiver [DVB-T]
3 *
4 * Copyright (C) 2005 Andreas Oberritter <obi@linuxtv.org>
5 *
6 * based on pluto2.c 1.10 - http://instinct-wp8.no-ip.org/pluto/
7 * by Dany Salman <salmandany@yahoo.fr>
8 * Copyright (c) 2004 TDF
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25
26#include <linux/i2c.h>
27#include <linux/i2c-algo-bit.h>
28#include <linux/init.h>
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/pci.h>
32#include <linux/dma-mapping.h>
33
34#include "demux.h"
35#include "dmxdev.h"
36#include "dvb_demux.h"
37#include "dvb_frontend.h"
38#include "dvb_net.h"
39#include "dvbdev.h"
40#include "tda1004x.h"
41
42#define DRIVER_NAME "pluto2"
43
44#define REG_PIDn(n) ((n) << 2) /* PID n pattern registers */
45#define REG_PCAR 0x0020 /* PC address register */
46#define REG_TSCR 0x0024 /* TS ctrl & status */
47#define REG_MISC 0x0028 /* miscellaneous */
48#define REG_MMAC 0x002c /* MSB MAC address */
49#define REG_IMAC 0x0030 /* ISB MAC address */
50#define REG_LMAC 0x0034 /* LSB MAC address */
51#define REG_SPID 0x0038 /* SPI data */
52#define REG_SLCS 0x003c /* serial links ctrl/status */
53
54#define PID0_NOFIL (0x0001 << 16)
55#define PIDn_ENP (0x0001 << 15)
56#define PID0_END (0x0001 << 14)
57#define PID0_AFIL (0x0001 << 13)
58#define PIDn_PID (0x1fff << 0)
59
60#define TSCR_NBPACKETS (0x00ff << 24)
61#define TSCR_DEM (0x0001 << 17)
62#define TSCR_DE (0x0001 << 16)
63#define TSCR_RSTN (0x0001 << 15)
64#define TSCR_MSKO (0x0001 << 14)
65#define TSCR_MSKA (0x0001 << 13)
66#define TSCR_MSKL (0x0001 << 12)
67#define TSCR_OVR (0x0001 << 11)
68#define TSCR_AFUL (0x0001 << 10)
69#define TSCR_LOCK (0x0001 << 9)
70#define TSCR_IACK (0x0001 << 8)
71#define TSCR_ADEF (0x007f << 0)
72
73#define MISC_DVR (0x0fff << 4)
74#define MISC_ALED (0x0001 << 3)
75#define MISC_FRST (0x0001 << 2)
76#define MISC_LED1 (0x0001 << 1)
77#define MISC_LED0 (0x0001 << 0)
78
79#define SPID_SPIDR (0x00ff << 0)
80
81#define SLCS_SCL (0x0001 << 7)
82#define SLCS_SDA (0x0001 << 6)
83#define SLCS_CSN (0x0001 << 2)
84#define SLCS_OVR (0x0001 << 1)
85#define SLCS_SWC (0x0001 << 0)
86
87#define TS_DMA_PACKETS (8)
88#define TS_DMA_BYTES (188 * TS_DMA_PACKETS)
89
90#define I2C_ADDR_TDA10046 0x10
91#define I2C_ADDR_TUA6034 0xc2
92#define NHWFILTERS 8
93
94struct pluto {
95 /* pci */
96 struct pci_dev *pdev;
97 u8 __iomem *io_mem;
98
99 /* dvb */
100 struct dmx_frontend hw_frontend;
101 struct dmx_frontend mem_frontend;
102 struct dmxdev dmxdev;
103 struct dvb_adapter dvb_adapter;
104 struct dvb_demux demux;
105 struct dvb_frontend *fe;
106 struct dvb_net dvbnet;
107 unsigned int full_ts_users;
108 unsigned int users;
109
110 /* i2c */
111 struct i2c_algo_bit_data i2c_bit;
112 struct i2c_adapter i2c_adap;
113 unsigned int i2cbug;
114
115 /* irq */
116 unsigned int overflow;
117
118 /* dma */
119 dma_addr_t dma_addr;
120 u8 dma_buf[TS_DMA_BYTES];
121 u8 dummy[4096];
122};
123
124static inline struct pluto *feed_to_pluto(struct dvb_demux_feed *feed)
125{
126 return container_of(feed->demux, struct pluto, demux);
127}
128
129static inline struct pluto *frontend_to_pluto(struct dvb_frontend *fe)
130{
131 return container_of(fe->dvb, struct pluto, dvb_adapter);
132}
133
134static inline u32 pluto_readreg(struct pluto *pluto, u32 reg)
135{
136 return readl(&pluto->io_mem[reg]);
137}
138
139static inline void pluto_writereg(struct pluto *pluto, u32 reg, u32 val)
140{
141 writel(val, &pluto->io_mem[reg]);
142}
143
144static inline void pluto_rw(struct pluto *pluto, u32 reg, u32 mask, u32 bits)
145{
146 u32 val = readl(&pluto->io_mem[reg]);
147 val &= ~mask;
148 val |= bits;
149 writel(val, &pluto->io_mem[reg]);
150}
151
152static void pluto_setsda(void *data, int state)
153{
154 struct pluto *pluto = data;
155
156 if (state)
157 pluto_rw(pluto, REG_SLCS, SLCS_SDA, SLCS_SDA);
158 else
159 pluto_rw(pluto, REG_SLCS, SLCS_SDA, 0);
160}
161
162static void pluto_setscl(void *data, int state)
163{
164 struct pluto *pluto = data;
165
166 if (state)
167 pluto_rw(pluto, REG_SLCS, SLCS_SCL, SLCS_SCL);
168 else
169 pluto_rw(pluto, REG_SLCS, SLCS_SCL, 0);
170
171 /* try to detect i2c_inb() to workaround hardware bug:
172 * reset SDA to high after SCL has been set to low */
173 if ((state) && (pluto->i2cbug == 0)) {
174 pluto->i2cbug = 1;
175 } else {
176 if ((!state) && (pluto->i2cbug == 1))
177 pluto_setsda(pluto, 1);
178 pluto->i2cbug = 0;
179 }
180}
181
182static int pluto_getsda(void *data)
183{
184 struct pluto *pluto = data;
185
186 return pluto_readreg(pluto, REG_SLCS) & SLCS_SDA;
187}
188
189static int pluto_getscl(void *data)
190{
191 struct pluto *pluto = data;
192
193 return pluto_readreg(pluto, REG_SLCS) & SLCS_SCL;
194}
195
196static void pluto_reset_frontend(struct pluto *pluto, int reenable)
197{
198 u32 val = pluto_readreg(pluto, REG_MISC);
199
200 if (val & MISC_FRST) {
201 val &= ~MISC_FRST;
202 pluto_writereg(pluto, REG_MISC, val);
203 }
204 if (reenable) {
205 val |= MISC_FRST;
206 pluto_writereg(pluto, REG_MISC, val);
207 }
208}
209
210static void pluto_reset_ts(struct pluto *pluto, int reenable)
211{
212 u32 val = pluto_readreg(pluto, REG_TSCR);
213
214 if (val & TSCR_RSTN) {
215 val &= ~TSCR_RSTN;
216 pluto_writereg(pluto, REG_TSCR, val);
217 }
218 if (reenable) {
219 val |= TSCR_RSTN;
220 pluto_writereg(pluto, REG_TSCR, val);
221 }
222}
223
224static void pluto_set_dma_addr(struct pluto *pluto)
225{
226 pluto_writereg(pluto, REG_PCAR, cpu_to_le32(pluto->dma_addr));
227}
228
229static int __devinit pluto_dma_map(struct pluto *pluto)
230{
231 pluto->dma_addr = pci_map_single(pluto->pdev, pluto->dma_buf,
232 TS_DMA_BYTES, PCI_DMA_FROMDEVICE);
233
234 return pci_dma_mapping_error(pluto->dma_addr);
235}
236
237static void pluto_dma_unmap(struct pluto *pluto)
238{
239 pci_unmap_single(pluto->pdev, pluto->dma_addr,
240 TS_DMA_BYTES, PCI_DMA_FROMDEVICE);
241}
242
243static int pluto_start_feed(struct dvb_demux_feed *f)
244{
245 struct pluto *pluto = feed_to_pluto(f);
246
247 /* enable PID filtering */
248 if (pluto->users++ == 0)
249 pluto_rw(pluto, REG_PIDn(0), PID0_AFIL | PID0_NOFIL, 0);
250
251 if ((f->pid < 0x2000) && (f->index < NHWFILTERS))
252 pluto_rw(pluto, REG_PIDn(f->index), PIDn_ENP | PIDn_PID, PIDn_ENP | f->pid);
253 else if (pluto->full_ts_users++ == 0)
254 pluto_rw(pluto, REG_PIDn(0), PID0_NOFIL, PID0_NOFIL);
255
256 return 0;
257}
258
259static int pluto_stop_feed(struct dvb_demux_feed *f)
260{
261 struct pluto *pluto = feed_to_pluto(f);
262
263 /* disable PID filtering */
264 if (--pluto->users == 0)
265 pluto_rw(pluto, REG_PIDn(0), PID0_AFIL, PID0_AFIL);
266
267 if ((f->pid < 0x2000) && (f->index < NHWFILTERS))
268 pluto_rw(pluto, REG_PIDn(f->index), PIDn_ENP | PIDn_PID, 0x1fff);
269 else if (--pluto->full_ts_users == 0)
270 pluto_rw(pluto, REG_PIDn(0), PID0_NOFIL, 0);
271
272 return 0;
273}
274
275static void pluto_dma_end(struct pluto *pluto, unsigned int nbpackets)
276{
277 /* synchronize the DMA transfer with the CPU
278 * first so that we see updated contents. */
279 pci_dma_sync_single_for_cpu(pluto->pdev, pluto->dma_addr,
280 TS_DMA_BYTES, PCI_DMA_FROMDEVICE);
281
282 /* Workaround for broken hardware:
283 * [1] On startup NBPACKETS seems to contain an uninitialized value,
284 * but no packets have been transfered.
285 * [2] Sometimes (actually very often) NBPACKETS stays at zero
286 * although one packet has been transfered.
287 */
288 if ((nbpackets == 0) || (nbpackets > TS_DMA_PACKETS)) {
289 unsigned int i = 0, valid;
290 while (pluto->dma_buf[i] == 0x47)
291 i += 188;
292 valid = i / 188;
293 if (nbpackets != valid) {
294 dev_err(&pluto->pdev->dev, "nbpackets=%u valid=%u\n",
295 nbpackets, valid);
296 nbpackets = valid;
297 }
298 }
299
300 dvb_dmx_swfilter_packets(&pluto->demux, pluto->dma_buf, nbpackets);
301
302 /* clear the dma buffer. this is needed to be able to identify
303 * new valid ts packets above */
304 memset(pluto->dma_buf, 0, nbpackets * 188);
305
306 /* reset the dma address */
307 pluto_set_dma_addr(pluto);
308
309 /* sync the buffer and give it back to the card */
310 pci_dma_sync_single_for_device(pluto->pdev, pluto->dma_addr,
311 TS_DMA_BYTES, PCI_DMA_FROMDEVICE);
312}
313
314static irqreturn_t pluto_irq(int irq, void *dev_id, struct pt_regs *regs)
315{
316 struct pluto *pluto = dev_id;
317 u32 tscr;
318
319 /* check whether an interrupt occured on this device */
320 tscr = pluto_readreg(pluto, REG_TSCR);
321 if (!(tscr & (TSCR_DE | TSCR_OVR)))
322 return IRQ_NONE;
323
324 if (tscr == 0xffffffff) {
325 // FIXME: maybe recover somehow
326 dev_err(&pluto->pdev->dev, "card hung up :(\n");
327 return IRQ_HANDLED;
328 }
329
330 /* dma end interrupt */
331 if (tscr & TSCR_DE) {
332 pluto_dma_end(pluto, (tscr & TSCR_NBPACKETS) >> 24);
333 /* overflow interrupt */
334 if (tscr & TSCR_OVR)
335 pluto->overflow++;
336 if (pluto->overflow) {
337 dev_err(&pluto->pdev->dev, "overflow irq (%d)\n",
338 pluto->overflow);
339 pluto_reset_ts(pluto, 1);
340 pluto->overflow = 0;
341 }
342 } else if (tscr & TSCR_OVR) {
343 pluto->overflow++;
344 }
345
346 /* ACK the interrupt */
347 pluto_writereg(pluto, REG_TSCR, tscr | TSCR_IACK);
348
349 return IRQ_HANDLED;
350}
351
352static void __devinit pluto_enable_irqs(struct pluto *pluto)
353{
354 u32 val = pluto_readreg(pluto, REG_TSCR);
355
356 /* set the number of packets */
357 val &= ~TSCR_ADEF;
358 val |= TS_DMA_PACKETS / 2;
359 /* disable AFUL and LOCK interrupts */
360 val |= (TSCR_MSKA | TSCR_MSKL);
361 /* enable DMA and OVERFLOW interrupts */
362 val &= ~(TSCR_DEM | TSCR_MSKO);
363 /* clear pending interrupts */
364 val |= TSCR_IACK;
365
366 pluto_writereg(pluto, REG_TSCR, val);
367}
368
369static void pluto_disable_irqs(struct pluto *pluto)
370{
371 u32 val = pluto_readreg(pluto, REG_TSCR);
372
373 /* disable all interrupts */
374 val |= (TSCR_DEM | TSCR_MSKO | TSCR_MSKA | TSCR_MSKL);
375 /* clear pending interrupts */
376 val |= TSCR_IACK;
377
378 pluto_writereg(pluto, REG_TSCR, val);
379}
380
381static int __devinit pluto_hw_init(struct pluto *pluto)
382{
383 pluto_reset_frontend(pluto, 1);
384
385 /* set automatic LED control by FPGA */
386 pluto_rw(pluto, REG_MISC, MISC_ALED, MISC_ALED);
387
388 /* set data endianess */
389#ifdef __LITTLE_ENDIAN
390 pluto_rw(pluto, REG_PIDn(0), PID0_END, PID0_END);
391#else
392 pluto_rw(pluto, REG_PIDn(0), PID0_END, 0);
393#endif
394 /* map DMA and set address */
395 pluto_dma_map(pluto);
396 pluto_set_dma_addr(pluto);
397
398 /* enable interrupts */
399 pluto_enable_irqs(pluto);
400
401 /* reset TS logic */
402 pluto_reset_ts(pluto, 1);
403
404 return 0;
405}
406
407static void pluto_hw_exit(struct pluto *pluto)
408{
409 /* disable interrupts */
410 pluto_disable_irqs(pluto);
411
412 pluto_reset_ts(pluto, 0);
413
414 /* LED: disable automatic control, enable yellow, disable green */
415 pluto_rw(pluto, REG_MISC, MISC_ALED | MISC_LED1 | MISC_LED0, MISC_LED1);
416
417 /* unmap DMA */
418 pluto_dma_unmap(pluto);
419
420 pluto_reset_frontend(pluto, 0);
421}
422
423static inline u32 divide(u32 numerator, u32 denominator)
424{
425 if (denominator == 0)
426 return ~0;
427
428 return (numerator + denominator / 2) / denominator;
429}
430
431/* LG Innotek TDTE-E001P (Infineon TUA6034) */
432static int lg_tdtpe001p_pll_set(struct dvb_frontend *fe,
433 struct dvb_frontend_parameters *p)
434{
435 struct pluto *pluto = frontend_to_pluto(fe);
436 struct i2c_msg msg;
437 int ret;
438 u8 buf[4];
439 u32 div;
440
441 // Fref = 166.667 Hz
442 // Fref * 3 = 500.000 Hz
443 // IF = 36166667
444 // IF / Fref = 217
445 //div = divide(p->frequency + 36166667, 166667);
446 div = divide(p->frequency * 3, 500000) + 217;
447 buf[0] = (div >> 8) & 0x7f;
448 buf[1] = (div >> 0) & 0xff;
449
450 if (p->frequency < 611000000)
451 buf[2] = 0xb4;
452 else if (p->frequency < 811000000)
453 buf[2] = 0xbc;
454 else
455 buf[2] = 0xf4;
456
457 // VHF: 174-230 MHz
458 // center: 350 MHz
459 // UHF: 470-862 MHz
460 if (p->frequency < 350000000)
461 buf[3] = 0x02;
462 else
463 buf[3] = 0x04;
464
465 if (p->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
466 buf[3] |= 0x08;
467
468 if (sizeof(buf) == 6) {
469 buf[4] = buf[2];
470 buf[4] &= ~0x1c;
471 buf[4] |= 0x18;
472
473 buf[5] = (0 << 7) | (2 << 4);
474 }
475
476 msg.addr = I2C_ADDR_TUA6034 >> 1;
477 msg.flags = 0;
478 msg.buf = buf;
479 msg.len = sizeof(buf);
480
481 ret = i2c_transfer(&pluto->i2c_adap, &msg, 1);
482 if (ret < 0)
483 return ret;
484 else if (ret == 0)
485 return -EREMOTEIO;
486
487 return 0;
488}
489
490static int pluto2_request_firmware(struct dvb_frontend *fe,
491 const struct firmware **fw, char *name)
492{
493 struct pluto *pluto = frontend_to_pluto(fe);
494
495 return request_firmware(fw, name, &pluto->pdev->dev);
496}
497
498static struct tda1004x_config pluto2_fe_config __devinitdata = {
499 .demod_address = I2C_ADDR_TDA10046 >> 1,
500 .invert = 1,
501 .invert_oclk = 0,
502 .xtal_freq = TDA10046_XTAL_16M,
503 .agc_config = TDA10046_AGC_DEFAULT,
504 .if_freq = TDA10046_FREQ_3617,
505 .pll_set = lg_tdtpe001p_pll_set,
506 .pll_sleep = NULL,
507 .request_firmware = pluto2_request_firmware,
508};
509
510static int __devinit frontend_init(struct pluto *pluto)
511{
512 int ret;
513
514 pluto->fe = tda10046_attach(&pluto2_fe_config, &pluto->i2c_adap);
515 if (!pluto->fe) {
516 dev_err(&pluto->pdev->dev, "could not attach frontend\n");
517 return -ENODEV;
518 }
519
520 ret = dvb_register_frontend(&pluto->dvb_adapter, pluto->fe);
521 if (ret < 0) {
522 if (pluto->fe->ops->release)
523 pluto->fe->ops->release(pluto->fe);
524 return ret;
525 }
526
527 return 0;
528}
529
530static void __devinit pluto_read_rev(struct pluto *pluto)
531{
532 u32 val = pluto_readreg(pluto, REG_MISC) & MISC_DVR;
533 dev_info(&pluto->pdev->dev, "board revision %d.%d\n",
534 (val >> 12) & 0x0f, (val >> 4) & 0xff);
535}
536
537static void __devinit pluto_read_mac(struct pluto *pluto, u8 *mac)
538{
539 u32 val = pluto_readreg(pluto, REG_MMAC);
540 mac[0] = (val >> 8) & 0xff;
541 mac[1] = (val >> 0) & 0xff;
542
543 val = pluto_readreg(pluto, REG_IMAC);
544 mac[2] = (val >> 8) & 0xff;
545 mac[3] = (val >> 0) & 0xff;
546
547 val = pluto_readreg(pluto, REG_LMAC);
548 mac[4] = (val >> 8) & 0xff;
549 mac[5] = (val >> 0) & 0xff;
550
551 dev_info(&pluto->pdev->dev, "MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
552 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
553}
554
555static int __devinit pluto_read_serial(struct pluto *pluto)
556{
557 struct pci_dev *pdev = pluto->pdev;
558 unsigned int i, j;
559 u8 __iomem *cis;
560
561 cis = pci_iomap(pdev, 1, 0);
562 if (!cis)
563 return -EIO;
564
565 dev_info(&pdev->dev, "S/N ");
566
567 for (i = 0xe0; i < 0x100; i += 4) {
568 u32 val = readl(&cis[i]);
569 for (j = 0; j < 32; j += 8) {
570 if ((val & 0xff) == 0xff)
571 goto out;
572 printk("%c", val & 0xff);
573 val >>= 8;
574 }
575 }
576out:
577 printk("\n");
578 pci_iounmap(pdev, cis);
579
580 return 0;
581}
582
583static int __devinit pluto2_probe(struct pci_dev *pdev,
584 const struct pci_device_id *ent)
585{
586 struct pluto *pluto;
587 struct dvb_adapter *dvb_adapter;
588 struct dvb_demux *dvbdemux;
589 struct dmx_demux *dmx;
590 int ret = -ENOMEM;
591
592 pluto = kmalloc(sizeof(struct pluto), GFP_KERNEL);
593 if (!pluto)
594 goto out;
595
596 memset(pluto, 0, sizeof(struct pluto));
597 pluto->pdev = pdev;
598
599 ret = pci_enable_device(pdev);
600 if (ret < 0)
601 goto err_kfree;
602
603 /* enable interrupts */
604 pci_write_config_dword(pdev, 0x6c, 0x8000);
605
606 ret = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
607 if (ret < 0)
608 goto err_pci_disable_device;
609
610 pci_set_master(pdev);
611
612 ret = pci_request_regions(pdev, DRIVER_NAME);
613 if (ret < 0)
614 goto err_pci_disable_device;
615
616 pluto->io_mem = pci_iomap(pdev, 0, 0x40);
617 if (!pluto->io_mem) {
618 ret = -EIO;
619 goto err_pci_release_regions;
620 }
621
622 pci_set_drvdata(pdev, pluto);
623
624 ret = request_irq(pdev->irq, pluto_irq, SA_SHIRQ, DRIVER_NAME, pluto);
625 if (ret < 0)
626 goto err_pci_iounmap;
627
628 ret = pluto_hw_init(pluto);
629 if (ret < 0)
630 goto err_free_irq;
631
632 /* i2c */
633 i2c_set_adapdata(&pluto->i2c_adap, pluto);
634 strcpy(pluto->i2c_adap.name, DRIVER_NAME);
635 pluto->i2c_adap.owner = THIS_MODULE;
636 pluto->i2c_adap.id = I2C_ALGO_BIT;
637 pluto->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
638 pluto->i2c_adap.dev.parent = &pdev->dev;
639 pluto->i2c_adap.algo_data = &pluto->i2c_bit;
640 pluto->i2c_bit.data = pluto;
641 pluto->i2c_bit.setsda = pluto_setsda;
642 pluto->i2c_bit.setscl = pluto_setscl;
643 pluto->i2c_bit.getsda = pluto_getsda;
644 pluto->i2c_bit.getscl = pluto_getscl;
645 pluto->i2c_bit.udelay = 10;
646 pluto->i2c_bit.timeout = 10;
647
648 /* Raise SCL and SDA */
649 pluto_setsda(pluto, 1);
650 pluto_setscl(pluto, 1);
651
652 ret = i2c_bit_add_bus(&pluto->i2c_adap);
653 if (ret < 0)
654 goto err_pluto_hw_exit;
655
656 /* dvb */
657 ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE);
658 if (ret < 0)
659 goto err_i2c_bit_del_bus;
660
661 dvb_adapter = &pluto->dvb_adapter;
662
663 pluto_read_rev(pluto);
664 pluto_read_serial(pluto);
665 pluto_read_mac(pluto, dvb_adapter->proposed_mac);
666
667 dvbdemux = &pluto->demux;
668 dvbdemux->filternum = 256;
669 dvbdemux->feednum = 256;
670 dvbdemux->start_feed = pluto_start_feed;
671 dvbdemux->stop_feed = pluto_stop_feed;
672 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING |
673 DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING);
674 ret = dvb_dmx_init(dvbdemux);
675 if (ret < 0)
676 goto err_dvb_unregister_adapter;
677
678 dmx = &dvbdemux->dmx;
679
680 pluto->hw_frontend.source = DMX_FRONTEND_0;
681 pluto->mem_frontend.source = DMX_MEMORY_FE;
682 pluto->dmxdev.filternum = NHWFILTERS;
683 pluto->dmxdev.demux = dmx;
684
685 ret = dvb_dmxdev_init(&pluto->dmxdev, dvb_adapter);
686 if (ret < 0)
687 goto err_dvb_dmx_release;
688
689 ret = dmx->add_frontend(dmx, &pluto->hw_frontend);
690 if (ret < 0)
691 goto err_dvb_dmxdev_release;
692
693 ret = dmx->add_frontend(dmx, &pluto->mem_frontend);
694 if (ret < 0)
695 goto err_remove_hw_frontend;
696
697 ret = dmx->connect_frontend(dmx, &pluto->hw_frontend);
698 if (ret < 0)
699 goto err_remove_mem_frontend;
700
701 ret = frontend_init(pluto);
702 if (ret < 0)
703 goto err_disconnect_frontend;
704
705 dvb_net_init(dvb_adapter, &pluto->dvbnet, dmx);
706out:
707 return ret;
708
709err_disconnect_frontend:
710 dmx->disconnect_frontend(dmx);
711err_remove_mem_frontend:
712 dmx->remove_frontend(dmx, &pluto->mem_frontend);
713err_remove_hw_frontend:
714 dmx->remove_frontend(dmx, &pluto->hw_frontend);
715err_dvb_dmxdev_release:
716 dvb_dmxdev_release(&pluto->dmxdev);
717err_dvb_dmx_release:
718 dvb_dmx_release(dvbdemux);
719err_dvb_unregister_adapter:
720 dvb_unregister_adapter(dvb_adapter);
721err_i2c_bit_del_bus:
722 i2c_bit_del_bus(&pluto->i2c_adap);
723err_pluto_hw_exit:
724 pluto_hw_exit(pluto);
725err_free_irq:
726 free_irq(pdev->irq, pluto);
727err_pci_iounmap:
728 pci_iounmap(pdev, pluto->io_mem);
729err_pci_release_regions:
730 pci_release_regions(pdev);
731err_pci_disable_device:
732 pci_disable_device(pdev);
733err_kfree:
734 pci_set_drvdata(pdev, NULL);
735 kfree(pluto);
736 goto out;
737}
738
739static void __devexit pluto2_remove(struct pci_dev *pdev)
740{
741 struct pluto *pluto = pci_get_drvdata(pdev);
742 struct dvb_adapter *dvb_adapter = &pluto->dvb_adapter;
743 struct dvb_demux *dvbdemux = &pluto->demux;
744 struct dmx_demux *dmx = &dvbdemux->dmx;
745
746 dmx->close(dmx);
747 dvb_net_release(&pluto->dvbnet);
748 if (pluto->fe)
749 dvb_unregister_frontend(pluto->fe);
750
751 dmx->disconnect_frontend(dmx);
752 dmx->remove_frontend(dmx, &pluto->mem_frontend);
753 dmx->remove_frontend(dmx, &pluto->hw_frontend);
754 dvb_dmxdev_release(&pluto->dmxdev);
755 dvb_dmx_release(dvbdemux);
756 dvb_unregister_adapter(dvb_adapter);
757 i2c_bit_del_bus(&pluto->i2c_adap);
758 pluto_hw_exit(pluto);
759 free_irq(pdev->irq, pluto);
760 pci_iounmap(pdev, pluto->io_mem);
761 pci_release_regions(pdev);
762 pci_disable_device(pdev);
763 pci_set_drvdata(pdev, NULL);
764 kfree(pluto);
765}
766
767#ifndef PCI_VENDOR_ID_SCM
768#define PCI_VENDOR_ID_SCM 0x0432
769#endif
770#ifndef PCI_DEVICE_ID_PLUTO2
771#define PCI_DEVICE_ID_PLUTO2 0x0001
772#endif
773
774static struct pci_device_id pluto2_id_table[] __devinitdata = {
775 {
776 .vendor = PCI_VENDOR_ID_SCM,
777 .device = PCI_DEVICE_ID_PLUTO2,
778 .subvendor = PCI_ANY_ID,
779 .subdevice = PCI_ANY_ID,
780 }, {
781 /* empty */
782 },
783};
784
785MODULE_DEVICE_TABLE(pci, pluto2_id_table);
786
787static struct pci_driver pluto2_driver = {
788 .name = DRIVER_NAME,
789 .id_table = pluto2_id_table,
790 .probe = pluto2_probe,
791 .remove = __devexit_p(pluto2_remove),
792};
793
794static int __init pluto2_init(void)
795{
796 return pci_register_driver(&pluto2_driver);
797}
798
799static void __exit pluto2_exit(void)
800{
801 pci_unregister_driver(&pluto2_driver);
802}
803
804module_init(pluto2_init);
805module_exit(pluto2_exit);
806
807MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
808MODULE_DESCRIPTION("Pluto2 driver");
809MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index 7ffa2c7315b3..bf3c011d2cfb 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -12,7 +12,7 @@ config DVB_AV7110
12 select DVB_STV0297 12 select DVB_STV0297
13 select DVB_L64781 13 select DVB_L64781
14 help 14 help
15 Support for SAA7146 and AV7110 based DVB cards as produced 15 Support for SAA7146 and AV7110 based DVB cards as produced
16 by Fujitsu-Siemens, Technotrend, Hauppauge and others. 16 by Fujitsu-Siemens, Technotrend, Hauppauge and others.
17 17
18 This driver only supports the fullfeatured cards with 18 This driver only supports the fullfeatured cards with
@@ -33,7 +33,7 @@ config DVB_AV7110_FIRMWARE
33 If you want to compile the firmware into the driver you need to say 33 If you want to compile the firmware into the driver you need to say
34 Y here and provide the correct path of the firmware. You need this 34 Y here and provide the correct path of the firmware. You need this
35 option if you want to compile the whole driver statically into the 35 option if you want to compile the whole driver statically into the
36 kernel. 36 kernel.
37 37
38 All other people say N. 38 All other people say N.
39 39
@@ -66,6 +66,7 @@ config DVB_BUDGET
66 select DVB_L64781 66 select DVB_L64781
67 select DVB_TDA8083 67 select DVB_TDA8083
68 select DVB_TDA10021 68 select DVB_TDA10021
69 select DVB_S5H1420
69 help 70 help
70 Support for simple SAA7146 based DVB cards 71 Support for simple SAA7146 based DVB cards
71 (so called Budget- or Nova-PCI cards) without onboard 72 (so called Budget- or Nova-PCI cards) without onboard
@@ -119,9 +120,9 @@ config DVB_BUDGET_PATCH
119 select DVB_VES1X93 120 select DVB_VES1X93
120 select DVB_TDA8083 121 select DVB_TDA8083
121 help 122 help
122 Support for Budget Patch (full TS) modification on 123 Support for Budget Patch (full TS) modification on
123 SAA7146+AV7110 based cards (DVB-S cards). This 124 SAA7146+AV7110 based cards (DVB-S cards). This
124 driver doesn't use onboard MPEG2 decoder. The 125 driver doesn't use onboard MPEG2 decoder. The
125 card is driven in Budget-only mode. Card is 126 card is driven in Budget-only mode. Card is
126 required to have loaded firmware to tune properly. 127 required to have loaded firmware to tune properly.
127 Firmware can be loaded by insertion and removal of 128 Firmware can be loaded by insertion and removal of
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 8e33a850e13e..e4c6e87f6c5d 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -116,13 +116,18 @@ static int av7110_num = 0;
116 116
117static void init_av7110_av(struct av7110 *av7110) 117static void init_av7110_av(struct av7110 *av7110)
118{ 118{
119 int ret;
119 struct saa7146_dev *dev = av7110->dev; 120 struct saa7146_dev *dev = av7110->dev;
120 121
121 /* set internal volume control to maximum */ 122 /* set internal volume control to maximum */
122 av7110->adac_type = DVB_ADAC_TI; 123 av7110->adac_type = DVB_ADAC_TI;
123 av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); 124 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
125 if (ret < 0)
126 printk("dvb-ttpci:cannot set internal volume to maximum:%d\n",ret);
124 127
125 av7710_set_video_mode(av7110, vidmode); 128 ret = av7710_set_video_mode(av7110, vidmode);
129 if (ret < 0)
130 printk("dvb-ttpci:cannot set video mode:%d\n",ret);
126 131
127 /* handle different card types */ 132 /* handle different card types */
128 /* remaining inits according to card and frontend type */ 133 /* remaining inits according to card and frontend type */
@@ -156,8 +161,12 @@ static void init_av7110_av(struct av7110 *av7110)
156 161
157 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) { 162 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) {
158 // switch DVB SCART on 163 // switch DVB SCART on
159 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0); 164 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
160 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1); 165 if (ret < 0)
166 printk("dvb-ttpci:cannot switch on SCART(Main):%d\n",ret);
167 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1);
168 if (ret < 0)
169 printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret);
161 if (rgb_on && 170 if (rgb_on &&
162 (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) { 171 (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) {
163 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16 172 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
@@ -165,8 +174,12 @@ static void init_av7110_av(struct av7110 *av7110)
165 } 174 }
166 } 175 }
167 176
168 av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); 177 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
169 av7110_setup_irc_config(av7110, 0); 178 if (ret < 0)
179 printk("dvb-ttpci:cannot set volume :%d\n",ret);
180 ret = av7110_setup_irc_config(av7110, 0);
181 if (ret < 0)
182 printk("dvb-ttpci:cannot setup irc config :%d\n",ret);
170} 183}
171 184
172static void recover_arm(struct av7110 *av7110) 185static void recover_arm(struct av7110 *av7110)
@@ -258,8 +271,9 @@ static int arm_thread(void *data)
258 * 271 *
259 * If we want to support multiple controls we would have to do much more... 272 * If we want to support multiple controls we would have to do much more...
260 */ 273 */
261void av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) 274int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
262{ 275{
276 int ret = 0;
263 static struct av7110 *last; 277 static struct av7110 *last;
264 278
265 dprintk(4, "%p\n", av7110); 279 dprintk(4, "%p\n", av7110);
@@ -270,9 +284,10 @@ void av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
270 last = av7110; 284 last = av7110;
271 285
272 if (av7110) { 286 if (av7110) {
273 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); 287 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config);
274 av7110->ir_config = ir_config; 288 av7110->ir_config = ir_config;
275 } 289 }
290 return ret;
276} 291}
277 292
278static void (*irc_handler)(u32); 293static void (*irc_handler)(u32);
@@ -765,13 +780,14 @@ static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
765 pcrpid, vpid, apid, ttpid, subpid); 780 pcrpid, vpid, apid, ttpid, subpid);
766} 781}
767 782
768void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, 783int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
769 u16 subpid, u16 pcrpid) 784 u16 subpid, u16 pcrpid)
770{ 785{
786 int ret = 0;
771 dprintk(4, "%p\n", av7110); 787 dprintk(4, "%p\n", av7110);
772 788
773 if (down_interruptible(&av7110->pid_mutex)) 789 if (down_interruptible(&av7110->pid_mutex))
774 return; 790 return -ERESTARTSYS;
775 791
776 if (!(vpid & 0x8000)) 792 if (!(vpid & 0x8000))
777 av7110->pids[DMX_PES_VIDEO] = vpid; 793 av7110->pids[DMX_PES_VIDEO] = vpid;
@@ -786,10 +802,11 @@ void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
786 802
787 if (av7110->fe_synced) { 803 if (av7110->fe_synced) {
788 pcrpid = av7110->pids[DMX_PES_PCR]; 804 pcrpid = av7110->pids[DMX_PES_PCR];
789 SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid); 805 ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid);
790 } 806 }
791 807
792 up(&av7110->pid_mutex); 808 up(&av7110->pid_mutex);
809 return ret;
793} 810}
794 811
795 812
@@ -832,11 +849,13 @@ static int StartHWFilter(struct dvb_demux_filter *dvbdmxfilter)
832 ret = av7110_fw_request(av7110, buf, 20, &handle, 1); 849 ret = av7110_fw_request(av7110, buf, 20, &handle, 1);
833 if (ret != 0 || handle >= 32) { 850 if (ret != 0 || handle >= 32) {
834 printk("dvb-ttpci: %s error buf %04x %04x %04x %04x " 851 printk("dvb-ttpci: %s error buf %04x %04x %04x %04x "
835 "ret %x handle %04x\n", 852 "ret %d handle %04x\n",
836 __FUNCTION__, buf[0], buf[1], buf[2], buf[3], 853 __FUNCTION__, buf[0], buf[1], buf[2], buf[3],
837 ret, handle); 854 ret, handle);
838 dvbdmxfilter->hw_handle = 0xffff; 855 dvbdmxfilter->hw_handle = 0xffff;
839 return -1; 856 if (!ret)
857 ret = -1;
858 return ret;
840 } 859 }
841 860
842 av7110->handle2filter[handle] = dvbdmxfilter; 861 av7110->handle2filter[handle] = dvbdmxfilter;
@@ -859,7 +878,7 @@ static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter)
859 if (handle >= 32) { 878 if (handle >= 32) {
860 printk("%s tried to stop invalid filter %04x, filter type = %x\n", 879 printk("%s tried to stop invalid filter %04x, filter type = %x\n",
861 __FUNCTION__, handle, dvbdmxfilter->type); 880 __FUNCTION__, handle, dvbdmxfilter->type);
862 return 0; 881 return -EINVAL;
863 } 882 }
864 883
865 av7110->handle2filter[handle] = NULL; 884 av7110->handle2filter[handle] = NULL;
@@ -873,18 +892,20 @@ static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter)
873 "resp %04x %04x pid %d\n", 892 "resp %04x %04x pid %d\n",
874 __FUNCTION__, buf[0], buf[1], buf[2], ret, 893 __FUNCTION__, buf[0], buf[1], buf[2], ret,
875 answ[0], answ[1], dvbdmxfilter->feed->pid); 894 answ[0], answ[1], dvbdmxfilter->feed->pid);
876 ret = -1; 895 if (!ret)
896 ret = -1;
877 } 897 }
878 return ret; 898 return ret;
879} 899}
880 900
881 901
882static void dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed) 902static int dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed)
883{ 903{
884 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 904 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
885 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv; 905 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv;
886 u16 *pid = dvbdmx->pids, npids[5]; 906 u16 *pid = dvbdmx->pids, npids[5];
887 int i; 907 int i;
908 int ret = 0;
888 909
889 dprintk(4, "%p\n", av7110); 910 dprintk(4, "%p\n", av7110);
890 911
@@ -893,36 +914,49 @@ static void dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed)
893 npids[i] = (pid[i]&0x8000) ? 0 : pid[i]; 914 npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
894 if ((i == 2) && npids[i] && (dvbdmxfeed->ts_type & TS_PACKET)) { 915 if ((i == 2) && npids[i] && (dvbdmxfeed->ts_type & TS_PACKET)) {
895 npids[i] = 0; 916 npids[i] = 0;
896 ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); 917 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
897 StartHWFilter(dvbdmxfeed->filter); 918 if (!ret)
898 return; 919 ret = StartHWFilter(dvbdmxfeed->filter);
920 return ret;
921 }
922 if (dvbdmxfeed->pes_type <= 2 || dvbdmxfeed->pes_type == 4) {
923 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
924 if (ret)
925 return ret;
899 } 926 }
900 if (dvbdmxfeed->pes_type <= 2 || dvbdmxfeed->pes_type == 4)
901 ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
902 927
903 if (dvbdmxfeed->pes_type < 2 && npids[0]) 928 if (dvbdmxfeed->pes_type < 2 && npids[0])
904 if (av7110->fe_synced) 929 if (av7110->fe_synced)
905 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0); 930 {
931 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
932 if (ret)
933 return ret;
934 }
906 935
907 if ((dvbdmxfeed->ts_type & TS_PACKET)) { 936 if ((dvbdmxfeed->ts_type & TS_PACKET)) {
908 if (dvbdmxfeed->pes_type == 0 && !(dvbdmx->pids[0] & 0x8000)) 937 if (dvbdmxfeed->pes_type == 0 && !(dvbdmx->pids[0] & 0x8000))
909 av7110_av_start_record(av7110, RP_AUDIO, dvbdmxfeed); 938 ret = av7110_av_start_record(av7110, RP_AUDIO, dvbdmxfeed);
910 if (dvbdmxfeed->pes_type == 1 && !(dvbdmx->pids[1] & 0x8000)) 939 if (dvbdmxfeed->pes_type == 1 && !(dvbdmx->pids[1] & 0x8000))
911 av7110_av_start_record(av7110, RP_VIDEO, dvbdmxfeed); 940 ret = av7110_av_start_record(av7110, RP_VIDEO, dvbdmxfeed);
912 } 941 }
942 return ret;
913} 943}
914 944
915static void dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed) 945static int dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed)
916{ 946{
917 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 947 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
918 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv; 948 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv;
919 u16 *pid = dvbdmx->pids, npids[5]; 949 u16 *pid = dvbdmx->pids, npids[5];
920 int i; 950 int i;
921 951
952 int ret = 0;
953
922 dprintk(4, "%p\n", av7110); 954 dprintk(4, "%p\n", av7110);
923 955
924 if (dvbdmxfeed->pes_type <= 1) { 956 if (dvbdmxfeed->pes_type <= 1) {
925 av7110_av_stop(av7110, dvbdmxfeed->pes_type ? RP_VIDEO : RP_AUDIO); 957 ret = av7110_av_stop(av7110, dvbdmxfeed->pes_type ? RP_VIDEO : RP_AUDIO);
958 if (ret)
959 return ret;
926 if (!av7110->rec_mode) 960 if (!av7110->rec_mode)
927 dvbdmx->recording = 0; 961 dvbdmx->recording = 0;
928 if (!av7110->playing) 962 if (!av7110->playing)
@@ -933,24 +967,27 @@ static void dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed)
933 switch (i) { 967 switch (i) {
934 case 2: //teletext 968 case 2: //teletext
935 if (dvbdmxfeed->ts_type & TS_PACKET) 969 if (dvbdmxfeed->ts_type & TS_PACKET)
936 StopHWFilter(dvbdmxfeed->filter); 970 ret = StopHWFilter(dvbdmxfeed->filter);
937 npids[2] = 0; 971 npids[2] = 0;
938 break; 972 break;
939 case 0: 973 case 0:
940 case 1: 974 case 1:
941 case 4: 975 case 4:
942 if (!pids_off) 976 if (!pids_off)
943 return; 977 return 0;
944 npids[i] = (pid[i]&0x8000) ? 0 : pid[i]; 978 npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
945 break; 979 break;
946 } 980 }
947 ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); 981 if (!ret)
982 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
983 return ret;
948} 984}
949 985
950static int av7110_start_feed(struct dvb_demux_feed *feed) 986static int av7110_start_feed(struct dvb_demux_feed *feed)
951{ 987{
952 struct dvb_demux *demux = feed->demux; 988 struct dvb_demux *demux = feed->demux;
953 struct av7110 *av7110 = demux->priv; 989 struct av7110 *av7110 = demux->priv;
990 int ret = 0;
954 991
955 dprintk(4, "%p\n", av7110); 992 dprintk(4, "%p\n", av7110);
956 993
@@ -971,21 +1008,22 @@ static int av7110_start_feed(struct dvb_demux_feed *feed)
971 !(demux->pids[1] & 0x8000)) { 1008 !(demux->pids[1] & 0x8000)) {
972 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout); 1009 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
973 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout); 1010 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
974 av7110_av_start_play(av7110,RP_AV); 1011 ret = av7110_av_start_play(av7110,RP_AV);
975 demux->playing = 1; 1012 if (!ret)
1013 demux->playing = 1;
976 } 1014 }
977 break; 1015 break;
978 default: 1016 default:
979 dvb_feed_start_pid(feed); 1017 ret = dvb_feed_start_pid(feed);
980 break; 1018 break;
981 } 1019 }
982 } else if ((feed->ts_type & TS_PACKET) && 1020 } else if ((feed->ts_type & TS_PACKET) &&
983 (demux->dmx.frontend->source != DMX_MEMORY_FE)) { 1021 (demux->dmx.frontend->source != DMX_MEMORY_FE)) {
984 StartHWFilter(feed->filter); 1022 ret = StartHWFilter(feed->filter);
985 } 1023 }
986 } 1024 }
987 1025
988 if (feed->type == DMX_TYPE_SEC) { 1026 else if (feed->type == DMX_TYPE_SEC) {
989 int i; 1027 int i;
990 1028
991 for (i = 0; i < demux->filternum; i++) { 1029 for (i = 0; i < demux->filternum; i++) {
@@ -996,12 +1034,15 @@ static int av7110_start_feed(struct dvb_demux_feed *feed)
996 if (demux->filter[i].filter.parent != &feed->feed.sec) 1034 if (demux->filter[i].filter.parent != &feed->feed.sec)
997 continue; 1035 continue;
998 demux->filter[i].state = DMX_STATE_GO; 1036 demux->filter[i].state = DMX_STATE_GO;
999 if (demux->dmx.frontend->source != DMX_MEMORY_FE) 1037 if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
1000 StartHWFilter(&demux->filter[i]); 1038 ret = StartHWFilter(&demux->filter[i]);
1039 if (ret)
1040 break;
1041 }
1001 } 1042 }
1002 } 1043 }
1003 1044
1004 return 0; 1045 return ret;
1005} 1046}
1006 1047
1007 1048
@@ -1009,7 +1050,7 @@ static int av7110_stop_feed(struct dvb_demux_feed *feed)
1009{ 1050{
1010 struct dvb_demux *demux = feed->demux; 1051 struct dvb_demux *demux = feed->demux;
1011 struct av7110 *av7110 = demux->priv; 1052 struct av7110 *av7110 = demux->priv;
1012 1053 int i, rc, ret = 0;
1013 dprintk(4, "%p\n", av7110); 1054 dprintk(4, "%p\n", av7110);
1014 1055
1015 if (feed->type == DMX_TYPE_TS) { 1056 if (feed->type == DMX_TYPE_TS) {
@@ -1022,26 +1063,29 @@ static int av7110_stop_feed(struct dvb_demux_feed *feed)
1022 } 1063 }
1023 if (feed->ts_type & TS_DECODER && 1064 if (feed->ts_type & TS_DECODER &&
1024 feed->pes_type < DMX_TS_PES_OTHER) { 1065 feed->pes_type < DMX_TS_PES_OTHER) {
1025 dvb_feed_stop_pid(feed); 1066 ret = dvb_feed_stop_pid(feed);
1026 } else 1067 } else
1027 if ((feed->ts_type & TS_PACKET) && 1068 if ((feed->ts_type & TS_PACKET) &&
1028 (demux->dmx.frontend->source != DMX_MEMORY_FE)) 1069 (demux->dmx.frontend->source != DMX_MEMORY_FE))
1029 StopHWFilter(feed->filter); 1070 ret = StopHWFilter(feed->filter);
1030 } 1071 }
1031 1072
1032 if (feed->type == DMX_TYPE_SEC) { 1073 if (!ret && feed->type == DMX_TYPE_SEC) {
1033 int i; 1074 for (i = 0; i<demux->filternum; i++) {
1034
1035 for (i = 0; i<demux->filternum; i++)
1036 if (demux->filter[i].state == DMX_STATE_GO && 1075 if (demux->filter[i].state == DMX_STATE_GO &&
1037 demux->filter[i].filter.parent == &feed->feed.sec) { 1076 demux->filter[i].filter.parent == &feed->feed.sec) {
1038 demux->filter[i].state = DMX_STATE_READY; 1077 demux->filter[i].state = DMX_STATE_READY;
1039 if (demux->dmx.frontend->source != DMX_MEMORY_FE) 1078 if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
1040 StopHWFilter(&demux->filter[i]); 1079 rc = StopHWFilter(&demux->filter[i]);
1080 if (!ret)
1081 ret = rc;
1082 /* keep going, stop as many filters as possible */
1083 }
1084 }
1041 } 1085 }
1042 } 1086 }
1043 1087
1044 return 0; 1088 return ret;
1045} 1089}
1046 1090
1047 1091
@@ -1093,7 +1137,7 @@ static int dvb_get_stc(struct dmx_demux *demux, unsigned int num,
1093 ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4); 1137 ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4);
1094 if (ret) { 1138 if (ret) {
1095 printk(KERN_ERR "%s: av7110_fw_request error\n", __FUNCTION__); 1139 printk(KERN_ERR "%s: av7110_fw_request error\n", __FUNCTION__);
1096 return -EIO; 1140 return ret;
1097 } 1141 }
1098 dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n", 1142 dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n",
1099 fwstc[0], fwstc[1], fwstc[2], fwstc[3]); 1143 fwstc[0], fwstc[1], fwstc[2], fwstc[3]);
@@ -1119,18 +1163,14 @@ static int av7110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
1119 1163
1120 switch (tone) { 1164 switch (tone) {
1121 case SEC_TONE_ON: 1165 case SEC_TONE_ON:
1122 Set22K(av7110, 1); 1166 return Set22K(av7110, 1);
1123 break;
1124 1167
1125 case SEC_TONE_OFF: 1168 case SEC_TONE_OFF:
1126 Set22K(av7110, 0); 1169 return Set22K(av7110, 0);
1127 break;
1128 1170
1129 default: 1171 default:
1130 return -EINVAL; 1172 return -EINVAL;
1131 } 1173 }
1132
1133 return 0;
1134} 1174}
1135 1175
1136static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe, 1176static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe,
@@ -1138,9 +1178,7 @@ static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe,
1138{ 1178{
1139 struct av7110* av7110 = fe->dvb->priv; 1179 struct av7110* av7110 = fe->dvb->priv;
1140 1180
1141 av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1); 1181 return av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1);
1142
1143 return 0;
1144} 1182}
1145 1183
1146static int av7110_diseqc_send_burst(struct dvb_frontend* fe, 1184static int av7110_diseqc_send_burst(struct dvb_frontend* fe,
@@ -1148,9 +1186,7 @@ static int av7110_diseqc_send_burst(struct dvb_frontend* fe,
1148{ 1186{
1149 struct av7110* av7110 = fe->dvb->priv; 1187 struct av7110* av7110 = fe->dvb->priv;
1150 1188
1151 av7110_diseqc_send(av7110, 0, NULL, minicmd); 1189 return av7110_diseqc_send(av7110, 0, NULL, minicmd);
1152
1153 return 0;
1154} 1190}
1155 1191
1156/* simplified code from budget-core.c */ 1192/* simplified code from budget-core.c */
@@ -1992,76 +2028,85 @@ static struct l64781_config grundig_29504_401_config = {
1992 2028
1993 2029
1994 2030
1995static void av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status) 2031static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
1996{ 2032{
2033 int ret = 0;
1997 int synced = (status & FE_HAS_LOCK) ? 1 : 0; 2034 int synced = (status & FE_HAS_LOCK) ? 1 : 0;
1998 2035
1999 av7110->fe_status = status; 2036 av7110->fe_status = status;
2000 2037
2001 if (av7110->fe_synced == synced) 2038 if (av7110->fe_synced == synced)
2002 return; 2039 return 0;
2003
2004 av7110->fe_synced = synced;
2005 2040
2006 if (av7110->playing) 2041 if (av7110->playing)
2007 return; 2042 return 0;
2008 2043
2009 if (down_interruptible(&av7110->pid_mutex)) 2044 if (down_interruptible(&av7110->pid_mutex))
2010 return; 2045 return -ERESTARTSYS;
2011 2046
2012 if (av7110->fe_synced) { 2047 if (synced) {
2013 SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO], 2048 ret = SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO],
2014 av7110->pids[DMX_PES_AUDIO], 2049 av7110->pids[DMX_PES_AUDIO],
2015 av7110->pids[DMX_PES_TELETEXT], 0, 2050 av7110->pids[DMX_PES_TELETEXT], 0,
2016 av7110->pids[DMX_PES_PCR]); 2051 av7110->pids[DMX_PES_PCR]);
2017 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0); 2052 if (!ret)
2053 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
2018 } else { 2054 } else {
2019 SetPIDs(av7110, 0, 0, 0, 0, 0); 2055 ret = SetPIDs(av7110, 0, 0, 0, 0, 0);
2020 av7110_fw_cmd(av7110, COMTYPE_PID_FILTER, FlushTSQueue, 0); 2056 if (!ret) {
2021 av7110_wait_msgstate(av7110, GPMQBusy); 2057 ret = av7110_fw_cmd(av7110, COMTYPE_PID_FILTER, FlushTSQueue, 0);
2058 if (!ret)
2059 ret = av7110_wait_msgstate(av7110, GPMQBusy);
2060 }
2022 } 2061 }
2023 2062
2063 if (!ret)
2064 av7110->fe_synced = synced;
2065
2024 up(&av7110->pid_mutex); 2066 up(&av7110->pid_mutex);
2067 return ret;
2025} 2068}
2026 2069
2027static int av7110_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 2070static int av7110_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
2028{ 2071{
2029 struct av7110* av7110 = fe->dvb->priv; 2072 struct av7110* av7110 = fe->dvb->priv;
2030 av7110_fe_lock_fix(av7110, 0); 2073
2031 return av7110->fe_set_frontend(fe, params); 2074 int ret = av7110_fe_lock_fix(av7110, 0);
2075 if (!ret)
2076 ret = av7110->fe_set_frontend(fe, params);
2077 return ret;
2032} 2078}
2033 2079
2034static int av7110_fe_init(struct dvb_frontend* fe) 2080static int av7110_fe_init(struct dvb_frontend* fe)
2035{ 2081{
2036 struct av7110* av7110 = fe->dvb->priv; 2082 struct av7110* av7110 = fe->dvb->priv;
2037 2083
2038 av7110_fe_lock_fix(av7110, 0); 2084 int ret = av7110_fe_lock_fix(av7110, 0);
2039 return av7110->fe_init(fe); 2085 if (!ret)
2086 ret = av7110->fe_init(fe);
2087 return ret;
2040} 2088}
2041 2089
2042static int av7110_fe_read_status(struct dvb_frontend* fe, fe_status_t* status) 2090static int av7110_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
2043{ 2091{
2044 struct av7110* av7110 = fe->dvb->priv; 2092 struct av7110* av7110 = fe->dvb->priv;
2045 int ret;
2046 2093
2047 /* call the real implementation */ 2094 /* call the real implementation */
2048 ret = av7110->fe_read_status(fe, status); 2095 int ret = av7110->fe_read_status(fe, status);
2049 if (ret) 2096 if (!ret)
2050 return ret; 2097 if (((*status ^ av7110->fe_status) & FE_HAS_LOCK) && (*status & FE_HAS_LOCK))
2051 2098 ret = av7110_fe_lock_fix(av7110, *status);
2052 if (((*status ^ av7110->fe_status) & FE_HAS_LOCK) && (*status & FE_HAS_LOCK)) { 2099 return ret;
2053 av7110_fe_lock_fix(av7110, *status);
2054 }
2055
2056 return 0;
2057} 2100}
2058 2101
2059static int av7110_fe_diseqc_reset_overload(struct dvb_frontend* fe) 2102static int av7110_fe_diseqc_reset_overload(struct dvb_frontend* fe)
2060{ 2103{
2061 struct av7110* av7110 = fe->dvb->priv; 2104 struct av7110* av7110 = fe->dvb->priv;
2062 2105
2063 av7110_fe_lock_fix(av7110, 0); 2106 int ret = av7110_fe_lock_fix(av7110, 0);
2064 return av7110->fe_diseqc_reset_overload(fe); 2107 if (!ret)
2108 ret = av7110->fe_diseqc_reset_overload(fe);
2109 return ret;
2065} 2110}
2066 2111
2067static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe, 2112static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe,
@@ -2069,40 +2114,50 @@ static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe,
2069{ 2114{
2070 struct av7110* av7110 = fe->dvb->priv; 2115 struct av7110* av7110 = fe->dvb->priv;
2071 2116
2072 av7110_fe_lock_fix(av7110, 0); 2117 int ret = av7110_fe_lock_fix(av7110, 0);
2073 return av7110->fe_diseqc_send_master_cmd(fe, cmd); 2118 if (!ret)
2119 ret = av7110->fe_diseqc_send_master_cmd(fe, cmd);
2120 return ret;
2074} 2121}
2075 2122
2076static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd) 2123static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
2077{ 2124{
2078 struct av7110* av7110 = fe->dvb->priv; 2125 struct av7110* av7110 = fe->dvb->priv;
2079 2126
2080 av7110_fe_lock_fix(av7110, 0); 2127 int ret = av7110_fe_lock_fix(av7110, 0);
2081 return av7110->fe_diseqc_send_burst(fe, minicmd); 2128 if (!ret)
2129 ret = av7110->fe_diseqc_send_burst(fe, minicmd);
2130 return ret;
2082} 2131}
2083 2132
2084static int av7110_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 2133static int av7110_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
2085{ 2134{
2086 struct av7110* av7110 = fe->dvb->priv; 2135 struct av7110* av7110 = fe->dvb->priv;
2087 2136
2088 av7110_fe_lock_fix(av7110, 0); 2137 int ret = av7110_fe_lock_fix(av7110, 0);
2089 return av7110->fe_set_tone(fe, tone); 2138 if (!ret)
2139 ret = av7110->fe_set_tone(fe, tone);
2140 return ret;
2090} 2141}
2091 2142
2092static int av7110_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 2143static int av7110_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
2093{ 2144{
2094 struct av7110* av7110 = fe->dvb->priv; 2145 struct av7110* av7110 = fe->dvb->priv;
2095 2146
2096 av7110_fe_lock_fix(av7110, 0); 2147 int ret = av7110_fe_lock_fix(av7110, 0);
2097 return av7110->fe_set_voltage(fe, voltage); 2148 if (!ret)
2149 ret = av7110->fe_set_voltage(fe, voltage);
2150 return ret;
2098} 2151}
2099 2152
2100static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned int cmd) 2153static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned int cmd)
2101{ 2154{
2102 struct av7110* av7110 = fe->dvb->priv; 2155 struct av7110* av7110 = fe->dvb->priv;
2103 2156
2104 av7110_fe_lock_fix(av7110, 0); 2157 int ret = av7110_fe_lock_fix(av7110, 0);
2105 return av7110->fe_dishnetwork_send_legacy_command(fe, cmd); 2158 if (!ret)
2159 ret = av7110->fe_dishnetwork_send_legacy_command(fe, cmd);
2160 return ret;
2106} 2161}
2107 2162
2108static u8 read_pwm(struct av7110* av7110) 2163static u8 read_pwm(struct av7110* av7110)
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
index 4f69b4d01479..508b7739c609 100644
--- a/drivers/media/dvb/ttpci/av7110.h
+++ b/drivers/media/dvb/ttpci/av7110.h
@@ -119,8 +119,7 @@ struct av7110 {
119 volatile int bmp_state; 119 volatile int bmp_state;
120#define BMP_NONE 0 120#define BMP_NONE 0
121#define BMP_LOADING 1 121#define BMP_LOADING 1
122#define BMP_LOADINGS 2 122#define BMP_LOADED 2
123#define BMP_LOADED 3
124 wait_queue_head_t bmpq; 123 wait_queue_head_t bmpq;
125 124
126 125
@@ -255,12 +254,12 @@ struct av7110 {
255}; 254};
256 255
257 256
258extern void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, 257extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
259 u16 subpid, u16 pcrpid); 258 u16 subpid, u16 pcrpid);
260 259
261extern void av7110_register_irc_handler(void (*func)(u32)); 260extern void av7110_register_irc_handler(void (*func)(u32));
262extern void av7110_unregister_irc_handler(void (*func)(u32)); 261extern void av7110_unregister_irc_handler(void (*func)(u32));
263extern void av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config); 262extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config);
264 263
265extern int av7110_ir_init (void); 264extern int av7110_ir_init (void);
266extern void av7110_ir_exit (void); 265extern void av7110_ir_exit (void);
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index ccf946125d02..0696a5a4f855 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -121,6 +121,7 @@ static int dvb_filter_pes2ts_cb(void *priv, unsigned char *data)
121int av7110_av_start_record(struct av7110 *av7110, int av, 121int av7110_av_start_record(struct av7110 *av7110, int av,
122 struct dvb_demux_feed *dvbdmxfeed) 122 struct dvb_demux_feed *dvbdmxfeed)
123{ 123{
124 int ret = 0;
124 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 125 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
125 126
126 dprintk(2, "av7110:%p, , dvb_demux_feed:%p\n", av7110, dvbdmxfeed); 127 dprintk(2, "av7110:%p, , dvb_demux_feed:%p\n", av7110, dvbdmxfeed);
@@ -137,7 +138,7 @@ int av7110_av_start_record(struct av7110 *av7110, int av,
137 dvbdmx->pesfilter[0]->pid, 138 dvbdmx->pesfilter[0]->pid,
138 dvb_filter_pes2ts_cb, 139 dvb_filter_pes2ts_cb,
139 (void *) dvbdmx->pesfilter[0]); 140 (void *) dvbdmx->pesfilter[0]);
140 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0); 141 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0);
141 break; 142 break;
142 143
143 case RP_VIDEO: 144 case RP_VIDEO:
@@ -145,7 +146,7 @@ int av7110_av_start_record(struct av7110 *av7110, int av,
145 dvbdmx->pesfilter[1]->pid, 146 dvbdmx->pesfilter[1]->pid,
146 dvb_filter_pes2ts_cb, 147 dvb_filter_pes2ts_cb,
147 (void *) dvbdmx->pesfilter[1]); 148 (void *) dvbdmx->pesfilter[1]);
148 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0); 149 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0);
149 break; 150 break;
150 151
151 case RP_AV: 152 case RP_AV:
@@ -157,14 +158,15 @@ int av7110_av_start_record(struct av7110 *av7110, int av,
157 dvbdmx->pesfilter[1]->pid, 158 dvbdmx->pesfilter[1]->pid,
158 dvb_filter_pes2ts_cb, 159 dvb_filter_pes2ts_cb,
159 (void *) dvbdmx->pesfilter[1]); 160 (void *) dvbdmx->pesfilter[1]);
160 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AV_PES, 0); 161 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AV_PES, 0);
161 break; 162 break;
162 } 163 }
163 return 0; 164 return ret;
164} 165}
165 166
166int av7110_av_start_play(struct av7110 *av7110, int av) 167int av7110_av_start_play(struct av7110 *av7110, int av)
167{ 168{
169 int ret = 0;
168 dprintk(2, "av7110:%p, \n", av7110); 170 dprintk(2, "av7110:%p, \n", av7110);
169 171
170 if (av7110->rec_mode) 172 if (av7110->rec_mode)
@@ -182,54 +184,57 @@ int av7110_av_start_play(struct av7110 *av7110, int av)
182 av7110->playing |= av; 184 av7110->playing |= av;
183 switch (av7110->playing) { 185 switch (av7110->playing) {
184 case RP_AUDIO: 186 case RP_AUDIO:
185 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0); 187 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0);
186 break; 188 break;
187 case RP_VIDEO: 189 case RP_VIDEO:
188 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0); 190 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0);
189 av7110->sinfo = 0; 191 av7110->sinfo = 0;
190 break; 192 break;
191 case RP_AV: 193 case RP_AV:
192 av7110->sinfo = 0; 194 av7110->sinfo = 0;
193 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AV_PES, 0); 195 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AV_PES, 0);
194 break; 196 break;
195 } 197 }
196 return av7110->playing; 198 if (!ret)
199 ret = av7110->playing;
200 return ret;
197} 201}
198 202
199void av7110_av_stop(struct av7110 *av7110, int av) 203int av7110_av_stop(struct av7110 *av7110, int av)
200{ 204{
205 int ret = 0;
201 dprintk(2, "av7110:%p, \n", av7110); 206 dprintk(2, "av7110:%p, \n", av7110);
202 207
203 if (!(av7110->playing & av) && !(av7110->rec_mode & av)) 208 if (!(av7110->playing & av) && !(av7110->rec_mode & av))
204 return; 209 return 0;
205
206 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0); 210 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0);
207 if (av7110->playing) { 211 if (av7110->playing) {
208 av7110->playing &= ~av; 212 av7110->playing &= ~av;
209 switch (av7110->playing) { 213 switch (av7110->playing) {
210 case RP_AUDIO: 214 case RP_AUDIO:
211 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0); 215 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0);
212 break; 216 break;
213 case RP_VIDEO: 217 case RP_VIDEO:
214 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0); 218 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0);
215 break; 219 break;
216 case RP_NONE: 220 case RP_NONE:
217 av7110_set_vidmode(av7110, av7110->vidmode); 221 ret = av7110_set_vidmode(av7110, av7110->vidmode);
218 break; 222 break;
219 } 223 }
220 } else { 224 } else {
221 av7110->rec_mode &= ~av; 225 av7110->rec_mode &= ~av;
222 switch (av7110->rec_mode) { 226 switch (av7110->rec_mode) {
223 case RP_AUDIO: 227 case RP_AUDIO:
224 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0); 228 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0);
225 break; 229 break;
226 case RP_VIDEO: 230 case RP_VIDEO:
227 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0); 231 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0);
228 break; 232 break;
229 case RP_NONE: 233 case RP_NONE:
230 break; 234 break;
231 } 235 }
232 } 236 }
237 return ret;
233} 238}
234 239
235 240
@@ -317,19 +322,22 @@ int av7110_set_volume(struct av7110 *av7110, int volleft, int volright)
317 return 0; 322 return 0;
318} 323}
319 324
320void av7110_set_vidmode(struct av7110 *av7110, int mode) 325int av7110_set_vidmode(struct av7110 *av7110, int mode)
321{ 326{
327 int ret;
322 dprintk(2, "av7110:%p, \n", av7110); 328 dprintk(2, "av7110:%p, \n", av7110);
323 329
324 av7110_fw_cmd(av7110, COMTYPE_ENCODER, LoadVidCode, 1, mode); 330 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, LoadVidCode, 1, mode);
325 331
326 if (!av7110->playing) { 332 if (!ret && !av7110->playing) {
327 ChangePIDs(av7110, av7110->pids[DMX_PES_VIDEO], 333 ret = ChangePIDs(av7110, av7110->pids[DMX_PES_VIDEO],
328 av7110->pids[DMX_PES_AUDIO], 334 av7110->pids[DMX_PES_AUDIO],
329 av7110->pids[DMX_PES_TELETEXT], 335 av7110->pids[DMX_PES_TELETEXT],
330 0, av7110->pids[DMX_PES_PCR]); 336 0, av7110->pids[DMX_PES_PCR]);
331 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0); 337 if (!ret)
338 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
332 } 339 }
340 return ret;
333} 341}
334 342
335 343
@@ -340,17 +348,18 @@ static int sw2mode[16] = {
340 VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL, 348 VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL,
341}; 349};
342 350
343static void get_video_format(struct av7110 *av7110, u8 *buf, int count) 351static int get_video_format(struct av7110 *av7110, u8 *buf, int count)
344{ 352{
345 int i; 353 int i;
346 int hsize, vsize; 354 int hsize, vsize;
347 int sw; 355 int sw;
348 u8 *p; 356 u8 *p;
357 int ret = 0;
349 358
350 dprintk(2, "av7110:%p, \n", av7110); 359 dprintk(2, "av7110:%p, \n", av7110);
351 360
352 if (av7110->sinfo) 361 if (av7110->sinfo)
353 return; 362 return 0;
354 for (i = 7; i < count - 10; i++) { 363 for (i = 7; i < count - 10; i++) {
355 p = buf + i; 364 p = buf + i;
356 if (p[0] || p[1] || p[2] != 0x01 || p[3] != 0xb3) 365 if (p[0] || p[1] || p[2] != 0x01 || p[3] != 0xb3)
@@ -359,11 +368,14 @@ static void get_video_format(struct av7110 *av7110, u8 *buf, int count)
359 hsize = ((p[1] &0xF0) >> 4) | (p[0] << 4); 368 hsize = ((p[1] &0xF0) >> 4) | (p[0] << 4);
360 vsize = ((p[1] &0x0F) << 8) | (p[2]); 369 vsize = ((p[1] &0x0F) << 8) | (p[2]);
361 sw = (p[3] & 0x0F); 370 sw = (p[3] & 0x0F);
362 av7110_set_vidmode(av7110, sw2mode[sw]); 371 ret = av7110_set_vidmode(av7110, sw2mode[sw]);
363 dprintk(2, "playback %dx%d fr=%d\n", hsize, vsize, sw); 372 if (!ret) {
364 av7110->sinfo = 1; 373 dprintk(2, "playback %dx%d fr=%d\n", hsize, vsize, sw);
374 av7110->sinfo = 1;
375 }
365 break; 376 break;
366 } 377 }
378 return ret;
367} 379}
368 380
369 381
@@ -974,7 +986,7 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
974 unsigned long arg = (unsigned long) parg; 986 unsigned long arg = (unsigned long) parg;
975 int ret = 0; 987 int ret = 0;
976 988
977 dprintk(2, "av7110:%p, \n", av7110); 989 dprintk(1, "av7110:%p, cmd=%04x\n", av7110,cmd);
978 990
979 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 991 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
980 if ( cmd != VIDEO_GET_STATUS && cmd != VIDEO_GET_EVENT && 992 if ( cmd != VIDEO_GET_STATUS && cmd != VIDEO_GET_EVENT &&
@@ -987,49 +999,57 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
987 case VIDEO_STOP: 999 case VIDEO_STOP:
988 av7110->videostate.play_state = VIDEO_STOPPED; 1000 av7110->videostate.play_state = VIDEO_STOPPED;
989 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY) 1001 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY)
990 av7110_av_stop(av7110, RP_VIDEO); 1002 ret = av7110_av_stop(av7110, RP_VIDEO);
991 else 1003 else
992 vidcom(av7110, VIDEO_CMD_STOP, 1004 ret = vidcom(av7110, VIDEO_CMD_STOP,
993 av7110->videostate.video_blank ? 0 : 1); 1005 av7110->videostate.video_blank ? 0 : 1);
994 av7110->trickmode = TRICK_NONE; 1006 if (!ret)
1007 av7110->trickmode = TRICK_NONE;
995 break; 1008 break;
996 1009
997 case VIDEO_PLAY: 1010 case VIDEO_PLAY:
998 av7110->trickmode = TRICK_NONE; 1011 av7110->trickmode = TRICK_NONE;
999 if (av7110->videostate.play_state == VIDEO_FREEZED) { 1012 if (av7110->videostate.play_state == VIDEO_FREEZED) {
1000 av7110->videostate.play_state = VIDEO_PLAYING; 1013 av7110->videostate.play_state = VIDEO_PLAYING;
1001 vidcom(av7110, VIDEO_CMD_PLAY, 0); 1014 ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
1015 if (ret)
1016 break;
1002 } 1017 }
1003 1018
1004 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY) { 1019 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY) {
1005 if (av7110->playing == RP_AV) { 1020 if (av7110->playing == RP_AV) {
1006 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0); 1021 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0);
1022 if (ret)
1023 break;
1007 av7110->playing &= ~RP_VIDEO; 1024 av7110->playing &= ~RP_VIDEO;
1008 } 1025 }
1009 av7110_av_start_play(av7110, RP_VIDEO); 1026 ret = av7110_av_start_play(av7110, RP_VIDEO);
1010 vidcom(av7110, VIDEO_CMD_PLAY, 0);
1011 } else {
1012 //av7110_av_stop(av7110, RP_VIDEO);
1013 vidcom(av7110, VIDEO_CMD_PLAY, 0);
1014 } 1027 }
1015 av7110->videostate.play_state = VIDEO_PLAYING; 1028 if (!ret)
1029 ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
1030 if (!ret)
1031 av7110->videostate.play_state = VIDEO_PLAYING;
1016 break; 1032 break;
1017 1033
1018 case VIDEO_FREEZE: 1034 case VIDEO_FREEZE:
1019 av7110->videostate.play_state = VIDEO_FREEZED; 1035 av7110->videostate.play_state = VIDEO_FREEZED;
1020 if (av7110->playing & RP_VIDEO) 1036 if (av7110->playing & RP_VIDEO)
1021 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Pause, 0); 1037 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Pause, 0);
1022 else 1038 else
1023 vidcom(av7110, VIDEO_CMD_FREEZE, 1); 1039 ret = vidcom(av7110, VIDEO_CMD_FREEZE, 1);
1024 av7110->trickmode = TRICK_FREEZE; 1040 if (!ret)
1041 av7110->trickmode = TRICK_FREEZE;
1025 break; 1042 break;
1026 1043
1027 case VIDEO_CONTINUE: 1044 case VIDEO_CONTINUE:
1028 if (av7110->playing & RP_VIDEO) 1045 if (av7110->playing & RP_VIDEO)
1029 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Continue, 0); 1046 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Continue, 0);
1030 vidcom(av7110, VIDEO_CMD_PLAY, 0); 1047 if (!ret)
1031 av7110->videostate.play_state = VIDEO_PLAYING; 1048 ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
1032 av7110->trickmode = TRICK_NONE; 1049 if (!ret) {
1050 av7110->videostate.play_state = VIDEO_PLAYING;
1051 av7110->trickmode = TRICK_NONE;
1052 }
1033 break; 1053 break;
1034 1054
1035 case VIDEO_SELECT_SOURCE: 1055 case VIDEO_SELECT_SOURCE:
@@ -1045,7 +1065,7 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
1045 break; 1065 break;
1046 1066
1047 case VIDEO_GET_EVENT: 1067 case VIDEO_GET_EVENT:
1048 ret=dvb_video_get_event(av7110, parg, file->f_flags); 1068 ret = dvb_video_get_event(av7110, parg, file->f_flags);
1049 break; 1069 break;
1050 1070
1051 case VIDEO_GET_SIZE: 1071 case VIDEO_GET_SIZE:
@@ -1105,25 +1125,32 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
1105 case VIDEO_FAST_FORWARD: 1125 case VIDEO_FAST_FORWARD:
1106 //note: arg is ignored by firmware 1126 //note: arg is ignored by firmware
1107 if (av7110->playing & RP_VIDEO) 1127 if (av7110->playing & RP_VIDEO)
1108 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1128 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1109 __Scan_I, 2, AV_PES, 0); 1129 __Scan_I, 2, AV_PES, 0);
1110 else 1130 else
1111 vidcom(av7110, VIDEO_CMD_FFWD, arg); 1131 ret = vidcom(av7110, VIDEO_CMD_FFWD, arg);
1112 av7110->trickmode = TRICK_FAST; 1132 if (!ret) {
1113 av7110->videostate.play_state = VIDEO_PLAYING; 1133 av7110->trickmode = TRICK_FAST;
1134 av7110->videostate.play_state = VIDEO_PLAYING;
1135 }
1114 break; 1136 break;
1115 1137
1116 case VIDEO_SLOWMOTION: 1138 case VIDEO_SLOWMOTION:
1117 if (av7110->playing&RP_VIDEO) { 1139 if (av7110->playing&RP_VIDEO) {
1118 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Slow, 2, 0, 0); 1140 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Slow, 2, 0, 0);
1119 vidcom(av7110, VIDEO_CMD_SLOW, arg); 1141 if (!ret)
1142 ret = vidcom(av7110, VIDEO_CMD_SLOW, arg);
1120 } else { 1143 } else {
1121 vidcom(av7110, VIDEO_CMD_PLAY, 0); 1144 ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
1122 vidcom(av7110, VIDEO_CMD_STOP, 0); 1145 if (!ret)
1123 vidcom(av7110, VIDEO_CMD_SLOW, arg); 1146 ret = vidcom(av7110, VIDEO_CMD_STOP, 0);
1147 if (!ret)
1148 ret = vidcom(av7110, VIDEO_CMD_SLOW, arg);
1149 }
1150 if (!ret) {
1151 av7110->trickmode = TRICK_SLOW;
1152 av7110->videostate.play_state = VIDEO_PLAYING;
1124 } 1153 }
1125 av7110->trickmode = TRICK_SLOW;
1126 av7110->videostate.play_state = VIDEO_PLAYING;
1127 break; 1154 break;
1128 1155
1129 case VIDEO_GET_CAPABILITIES: 1156 case VIDEO_GET_CAPABILITIES:
@@ -1136,18 +1163,21 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
1136 av7110_ipack_reset(&av7110->ipack[1]); 1163 av7110_ipack_reset(&av7110->ipack[1]);
1137 1164
1138 if (av7110->playing == RP_AV) { 1165 if (av7110->playing == RP_AV) {
1139 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1166 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1140 __Play, 2, AV_PES, 0); 1167 __Play, 2, AV_PES, 0);
1168 if (ret)
1169 break;
1141 if (av7110->trickmode == TRICK_FAST) 1170 if (av7110->trickmode == TRICK_FAST)
1142 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1171 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1143 __Scan_I, 2, AV_PES, 0); 1172 __Scan_I, 2, AV_PES, 0);
1144 if (av7110->trickmode == TRICK_SLOW) { 1173 if (av7110->trickmode == TRICK_SLOW) {
1145 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1174 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1146 __Slow, 2, 0, 0); 1175 __Slow, 2, 0, 0);
1147 vidcom(av7110, VIDEO_CMD_SLOW, arg); 1176 if (!ret)
1177 ret = vidcom(av7110, VIDEO_CMD_SLOW, arg);
1148 } 1178 }
1149 if (av7110->trickmode == TRICK_FREEZE) 1179 if (av7110->trickmode == TRICK_FREEZE)
1150 vidcom(av7110, VIDEO_CMD_STOP, 1); 1180 ret = vidcom(av7110, VIDEO_CMD_STOP, 1);
1151 } 1181 }
1152 break; 1182 break;
1153 1183
@@ -1170,7 +1200,7 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1170 unsigned long arg = (unsigned long) parg; 1200 unsigned long arg = (unsigned long) parg;
1171 int ret = 0; 1201 int ret = 0;
1172 1202
1173 dprintk(2, "av7110:%p, \n", av7110); 1203 dprintk(1, "av7110:%p, cmd=%04x\n", av7110,cmd);
1174 1204
1175 if (((file->f_flags & O_ACCMODE) == O_RDONLY) && 1205 if (((file->f_flags & O_ACCMODE) == O_RDONLY) &&
1176 (cmd != AUDIO_GET_STATUS)) 1206 (cmd != AUDIO_GET_STATUS))
@@ -1179,28 +1209,32 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1179 switch (cmd) { 1209 switch (cmd) {
1180 case AUDIO_STOP: 1210 case AUDIO_STOP:
1181 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY) 1211 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
1182 av7110_av_stop(av7110, RP_AUDIO); 1212 ret = av7110_av_stop(av7110, RP_AUDIO);
1183 else 1213 else
1184 audcom(av7110, AUDIO_CMD_MUTE); 1214 ret = audcom(av7110, AUDIO_CMD_MUTE);
1185 av7110->audiostate.play_state = AUDIO_STOPPED; 1215 if (!ret)
1216 av7110->audiostate.play_state = AUDIO_STOPPED;
1186 break; 1217 break;
1187 1218
1188 case AUDIO_PLAY: 1219 case AUDIO_PLAY:
1189 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY) 1220 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
1190 av7110_av_start_play(av7110, RP_AUDIO); 1221 ret = av7110_av_start_play(av7110, RP_AUDIO);
1191 audcom(av7110, AUDIO_CMD_UNMUTE); 1222 if (!ret)
1192 av7110->audiostate.play_state = AUDIO_PLAYING; 1223 ret = audcom(av7110, AUDIO_CMD_UNMUTE);
1224 if (!ret)
1225 av7110->audiostate.play_state = AUDIO_PLAYING;
1193 break; 1226 break;
1194 1227
1195 case AUDIO_PAUSE: 1228 case AUDIO_PAUSE:
1196 audcom(av7110, AUDIO_CMD_MUTE); 1229 ret = audcom(av7110, AUDIO_CMD_MUTE);
1197 av7110->audiostate.play_state = AUDIO_PAUSED; 1230 if (!ret)
1231 av7110->audiostate.play_state = AUDIO_PAUSED;
1198 break; 1232 break;
1199 1233
1200 case AUDIO_CONTINUE: 1234 case AUDIO_CONTINUE:
1201 if (av7110->audiostate.play_state == AUDIO_PAUSED) { 1235 if (av7110->audiostate.play_state == AUDIO_PAUSED) {
1202 av7110->audiostate.play_state = AUDIO_PLAYING; 1236 av7110->audiostate.play_state = AUDIO_PLAYING;
1203 audcom(av7110, AUDIO_CMD_MUTE | AUDIO_CMD_PCM16); 1237 ret = audcom(av7110, AUDIO_CMD_UNMUTE | AUDIO_CMD_PCM16);
1204 } 1238 }
1205 break; 1239 break;
1206 1240
@@ -1210,14 +1244,15 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1210 1244
1211 case AUDIO_SET_MUTE: 1245 case AUDIO_SET_MUTE:
1212 { 1246 {
1213 audcom(av7110, arg ? AUDIO_CMD_MUTE : AUDIO_CMD_UNMUTE); 1247 ret = audcom(av7110, arg ? AUDIO_CMD_MUTE : AUDIO_CMD_UNMUTE);
1214 av7110->audiostate.mute_state = (int) arg; 1248 if (!ret)
1249 av7110->audiostate.mute_state = (int) arg;
1215 break; 1250 break;
1216 } 1251 }
1217 1252
1218 case AUDIO_SET_AV_SYNC: 1253 case AUDIO_SET_AV_SYNC:
1219 av7110->audiostate.AV_sync_state = (int) arg; 1254 av7110->audiostate.AV_sync_state = (int) arg;
1220 audcom(av7110, arg ? AUDIO_CMD_SYNC_ON : AUDIO_CMD_SYNC_OFF); 1255 ret = audcom(av7110, arg ? AUDIO_CMD_SYNC_ON : AUDIO_CMD_SYNC_OFF);
1221 break; 1256 break;
1222 1257
1223 case AUDIO_SET_BYPASS_MODE: 1258 case AUDIO_SET_BYPASS_MODE:
@@ -1229,21 +1264,24 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1229 1264
1230 switch(av7110->audiostate.channel_select) { 1265 switch(av7110->audiostate.channel_select) {
1231 case AUDIO_STEREO: 1266 case AUDIO_STEREO:
1232 audcom(av7110, AUDIO_CMD_STEREO); 1267 ret = audcom(av7110, AUDIO_CMD_STEREO);
1233 if (av7110->adac_type == DVB_ADAC_CRYSTAL) 1268 if (!ret)
1234 i2c_writereg(av7110, 0x20, 0x02, 0x49); 1269 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1270 i2c_writereg(av7110, 0x20, 0x02, 0x49);
1235 break; 1271 break;
1236 1272
1237 case AUDIO_MONO_LEFT: 1273 case AUDIO_MONO_LEFT:
1238 audcom(av7110, AUDIO_CMD_MONO_L); 1274 ret = audcom(av7110, AUDIO_CMD_MONO_L);
1239 if (av7110->adac_type == DVB_ADAC_CRYSTAL) 1275 if (!ret)
1240 i2c_writereg(av7110, 0x20, 0x02, 0x4a); 1276 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1277 i2c_writereg(av7110, 0x20, 0x02, 0x4a);
1241 break; 1278 break;
1242 1279
1243 case AUDIO_MONO_RIGHT: 1280 case AUDIO_MONO_RIGHT:
1244 audcom(av7110, AUDIO_CMD_MONO_R); 1281 ret = audcom(av7110, AUDIO_CMD_MONO_R);
1245 if (av7110->adac_type == DVB_ADAC_CRYSTAL) 1282 if (!ret)
1246 i2c_writereg(av7110, 0x20, 0x02, 0x45); 1283 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1284 i2c_writereg(av7110, 0x20, 0x02, 0x45);
1247 break; 1285 break;
1248 1286
1249 default: 1287 default:
@@ -1264,8 +1302,8 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1264 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout); 1302 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
1265 av7110_ipack_reset(&av7110->ipack[0]); 1303 av7110_ipack_reset(&av7110->ipack[0]);
1266 if (av7110->playing == RP_AV) 1304 if (av7110->playing == RP_AV)
1267 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1305 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1268 __Play, 2, AV_PES, 0); 1306 __Play, 2, AV_PES, 0);
1269 break; 1307 break;
1270 case AUDIO_SET_ID: 1308 case AUDIO_SET_ID:
1271 1309
@@ -1274,7 +1312,7 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1274 { 1312 {
1275 struct audio_mixer *amix = (struct audio_mixer *)parg; 1313 struct audio_mixer *amix = (struct audio_mixer *)parg;
1276 1314
1277 av7110_set_volume(av7110, amix->volume_left, amix->volume_right); 1315 ret = av7110_set_volume(av7110, amix->volume_left, amix->volume_right);
1278 break; 1316 break;
1279 } 1317 }
1280 case AUDIO_SET_STREAMTYPE: 1318 case AUDIO_SET_STREAMTYPE:
diff --git a/drivers/media/dvb/ttpci/av7110_av.h b/drivers/media/dvb/ttpci/av7110_av.h
index cc5e7a7e87c3..45dc144b8b43 100644
--- a/drivers/media/dvb/ttpci/av7110_av.h
+++ b/drivers/media/dvb/ttpci/av7110_av.h
@@ -3,14 +3,14 @@
3 3
4struct av7110; 4struct av7110;
5 5
6extern void av7110_set_vidmode(struct av7110 *av7110, int mode); 6extern int av7110_set_vidmode(struct av7110 *av7110, int mode);
7 7
8extern int av7110_record_cb(struct dvb_filter_pes2ts *p2t, u8 *buf, size_t len); 8extern int av7110_record_cb(struct dvb_filter_pes2ts *p2t, u8 *buf, size_t len);
9extern int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen); 9extern int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen);
10extern int av7110_write_to_decoder(struct dvb_demux_feed *feed, const u8 *buf, size_t len); 10extern int av7110_write_to_decoder(struct dvb_demux_feed *feed, const u8 *buf, size_t len);
11 11
12extern int av7110_set_volume(struct av7110 *av7110, int volleft, int volright); 12extern int av7110_set_volume(struct av7110 *av7110, int volleft, int volright);
13extern void av7110_av_stop(struct av7110 *av7110, int av); 13extern int av7110_av_stop(struct av7110 *av7110, int av);
14extern int av7110_av_start_record(struct av7110 *av7110, int av, 14extern int av7110_av_start_record(struct av7110 *av7110, int av,
15 struct dvb_demux_feed *dvbdmxfeed); 15 struct dvb_demux_feed *dvbdmxfeed);
16extern int av7110_av_start_play(struct av7110 *av7110, int av); 16extern int av7110_av_start_play(struct av7110 *av7110, int av);
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
index 7fa4a0ebe133..1220826696c5 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/drivers/media/dvb/ttpci/av7110_hw.c
@@ -137,7 +137,7 @@ static int waitdebi(struct av7110 *av7110, int adr, int state)
137 return 0; 137 return 0;
138 udelay(5); 138 udelay(5);
139 } 139 }
140 return -1; 140 return -ETIMEDOUT;
141} 141}
142 142
143static int load_dram(struct av7110 *av7110, u32 *data, int len) 143static int load_dram(struct av7110 *av7110, u32 *data, int len)
@@ -155,7 +155,7 @@ static int load_dram(struct av7110 *av7110, u32 *data, int len)
155 for (i = 0; i < blocks; i++) { 155 for (i = 0; i < blocks; i++) {
156 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) { 156 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
157 printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at block %d\n", i); 157 printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at block %d\n", i);
158 return -1; 158 return -ETIMEDOUT;
159 } 159 }
160 dprintk(4, "writing DRAM block %d\n", i); 160 dprintk(4, "writing DRAM block %d\n", i);
161 mwdebi(av7110, DEBISWAB, bootblock, 161 mwdebi(av7110, DEBISWAB, bootblock,
@@ -170,7 +170,7 @@ static int load_dram(struct av7110 *av7110, u32 *data, int len)
170 if (rest > 0) { 170 if (rest > 0) {
171 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) { 171 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
172 printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at last block\n"); 172 printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at last block\n");
173 return -1; 173 return -ETIMEDOUT;
174 } 174 }
175 if (rest > 4) 175 if (rest > 4)
176 mwdebi(av7110, DEBISWAB, bootblock, 176 mwdebi(av7110, DEBISWAB, bootblock,
@@ -185,13 +185,13 @@ static int load_dram(struct av7110 *av7110, u32 *data, int len)
185 } 185 }
186 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) { 186 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
187 printk(KERN_ERR "dvb-ttpci: load_dram(): timeout after last block\n"); 187 printk(KERN_ERR "dvb-ttpci: load_dram(): timeout after last block\n");
188 return -1; 188 return -ETIMEDOUT;
189 } 189 }
190 iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, 0, 2); 190 iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, 0, 2);
191 iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); 191 iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
192 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BOOT_COMPLETE) < 0) { 192 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BOOT_COMPLETE) < 0) {
193 printk(KERN_ERR "dvb-ttpci: load_dram(): final handshake timeout\n"); 193 printk(KERN_ERR "dvb-ttpci: load_dram(): final handshake timeout\n");
194 return -1; 194 return -ETIMEDOUT;
195 } 195 }
196 return 0; 196 return 0;
197} 197}
@@ -263,7 +263,7 @@ int av7110_bootarm(struct av7110 *av7110)
263 if (saa7146_wait_for_debi_done(av7110->dev, 1)) { 263 if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
264 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " 264 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): "
265 "saa7146_wait_for_debi_done() timed out\n"); 265 "saa7146_wait_for_debi_done() timed out\n");
266 return -1; 266 return -ETIMEDOUT;
267 } 267 }
268 saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); 268 saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
269 mdelay(1); 269 mdelay(1);
@@ -284,7 +284,7 @@ int av7110_bootarm(struct av7110 *av7110)
284 if (saa7146_wait_for_debi_done(av7110->dev, 1)) { 284 if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
285 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " 285 printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): "
286 "saa7146_wait_for_debi_done() timed out after loading DRAM\n"); 286 "saa7146_wait_for_debi_done() timed out after loading DRAM\n");
287 return -1; 287 return -ETIMEDOUT;
288 } 288 }
289 saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); 289 saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
290 msleep(30); /* the firmware needs some time to initialize */ 290 msleep(30); /* the firmware needs some time to initialize */
@@ -308,6 +308,7 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
308{ 308{
309 unsigned long start; 309 unsigned long start;
310 u32 stat; 310 u32 stat;
311 int err;
311 312
312 if (FW_VERSION(av7110->arm_app) <= 0x261c) { 313 if (FW_VERSION(av7110->arm_app) <= 0x261c) {
313 /* not supported by old firmware */ 314 /* not supported by old firmware */
@@ -318,17 +319,17 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
318 /* new firmware */ 319 /* new firmware */
319 start = jiffies; 320 start = jiffies;
320 for (;;) { 321 for (;;) {
322 err = time_after(jiffies, start + ARM_WAIT_FREE);
321 if (down_interruptible(&av7110->dcomlock)) 323 if (down_interruptible(&av7110->dcomlock))
322 return -ERESTARTSYS; 324 return -ERESTARTSYS;
323 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); 325 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
324 up(&av7110->dcomlock); 326 up(&av7110->dcomlock);
325 if ((stat & flags) == 0) { 327 if ((stat & flags) == 0)
326 break; 328 break;
327 } 329 if (err) {
328 if (time_after(jiffies, start + ARM_WAIT_FREE)) {
329 printk(KERN_ERR "%s: timeout waiting for MSGSTATE %04x\n", 330 printk(KERN_ERR "%s: timeout waiting for MSGSTATE %04x\n",
330 __FUNCTION__, stat & flags); 331 __FUNCTION__, stat & flags);
331 return -1; 332 return -ETIMEDOUT;
332 } 333 }
333 msleep(1); 334 msleep(1);
334 } 335 }
@@ -342,6 +343,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
342 char *type = NULL; 343 char *type = NULL;
343 u16 flags[2] = {0, 0}; 344 u16 flags[2] = {0, 0};
344 u32 stat; 345 u32 stat;
346 int err;
345 347
346// dprintk(4, "%p\n", av7110); 348// dprintk(4, "%p\n", av7110);
347 349
@@ -351,24 +353,30 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
351 } 353 }
352 354
353 start = jiffies; 355 start = jiffies;
354 while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) { 356 while (1) {
355 msleep(1); 357 err = time_after(jiffies, start + ARM_WAIT_FREE);
356 if (time_after(jiffies, start + ARM_WAIT_FREE)) { 358 if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)
359 break;
360 if (err) {
357 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND idle\n", __FUNCTION__); 361 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND idle\n", __FUNCTION__);
358 return -ETIMEDOUT; 362 return -ETIMEDOUT;
359 } 363 }
364 msleep(1);
360 } 365 }
361 366
362 wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); 367 wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2);
363 368
364#ifndef _NOHANDSHAKE 369#ifndef _NOHANDSHAKE
365 start = jiffies; 370 start = jiffies;
366 while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 )) { 371 while (1) {
367 msleep(1); 372 err = time_after(jiffies, start + ARM_WAIT_SHAKE);
368 if (time_after(jiffies, start + ARM_WAIT_SHAKE)) { 373 if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)
374 break;
375 if (err) {
369 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); 376 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
370 return -ETIMEDOUT; 377 return -ETIMEDOUT;
371 } 378 }
379 msleep(1);
372 } 380 }
373#endif 381#endif
374 382
@@ -401,6 +409,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
401 /* non-immediate COMMAND type */ 409 /* non-immediate COMMAND type */
402 start = jiffies; 410 start = jiffies;
403 for (;;) { 411 for (;;) {
412 err = time_after(jiffies, start + ARM_WAIT_FREE);
404 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); 413 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
405 if (stat & flags[0]) { 414 if (stat & flags[0]) {
406 printk(KERN_ERR "%s: %s QUEUE overflow\n", 415 printk(KERN_ERR "%s: %s QUEUE overflow\n",
@@ -409,10 +418,10 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
409 } 418 }
410 if ((stat & flags[1]) == 0) 419 if ((stat & flags[1]) == 0)
411 break; 420 break;
412 if (time_after(jiffies, start + ARM_WAIT_FREE)) { 421 if (err) {
413 printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n", 422 printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n",
414 __FUNCTION__, type); 423 __FUNCTION__, type);
415 return -1; 424 return -ETIMEDOUT;
416 } 425 }
417 msleep(1); 426 msleep(1);
418 } 427 }
@@ -432,13 +441,16 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
432 441
433#ifdef COM_DEBUG 442#ifdef COM_DEBUG
434 start = jiffies; 443 start = jiffies;
435 while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) { 444 while (1) {
436 msleep(1); 445 err = time_after(jiffies, start + ARM_WAIT_FREE);
437 if (time_after(jiffies, start + ARM_WAIT_FREE)) { 446 if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)
438 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND to complete\n", 447 break;
439 __FUNCTION__); 448 if (err) {
449 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND %d to complete\n",
450 __FUNCTION__, (buf[0] >> 8) & 0xff);
440 return -ETIMEDOUT; 451 return -ETIMEDOUT;
441 } 452 }
453 msleep(1);
442 } 454 }
443 455
444 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); 456 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
@@ -470,7 +482,7 @@ static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
470 482
471 ret = __av7110_send_fw_cmd(av7110, buf, length); 483 ret = __av7110_send_fw_cmd(av7110, buf, length);
472 up(&av7110->dcomlock); 484 up(&av7110->dcomlock);
473 if (ret) 485 if (ret && ret!=-ERESTARTSYS)
474 printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n", 486 printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n",
475 __FUNCTION__, ret); 487 __FUNCTION__, ret);
476 return ret; 488 return ret;
@@ -495,7 +507,7 @@ int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
495 } 507 }
496 508
497 ret = av7110_send_fw_cmd(av7110, buf, num + 2); 509 ret = av7110_send_fw_cmd(av7110, buf, num + 2);
498 if (ret) 510 if (ret && ret != -ERESTARTSYS)
499 printk(KERN_ERR "dvb-ttpci: av7110_fw_cmd error %d\n", ret); 511 printk(KERN_ERR "dvb-ttpci: av7110_fw_cmd error %d\n", ret);
500 return ret; 512 return ret;
501} 513}
@@ -518,7 +530,7 @@ int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len)
518 } 530 }
519 531
520 ret = av7110_send_fw_cmd(av7110, cmd, 18); 532 ret = av7110_send_fw_cmd(av7110, cmd, 18);
521 if (ret) 533 if (ret && ret != -ERESTARTSYS)
522 printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret); 534 printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret);
523 return ret; 535 return ret;
524} 536}
@@ -551,26 +563,32 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
551 } 563 }
552 564
553 start = jiffies; 565 start = jiffies;
554 while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2)) { 566 while (1) {
555#ifdef _NOHANDSHAKE 567 err = time_after(jiffies, start + ARM_WAIT_FREE);
556 msleep(1); 568 if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)
557#endif 569 break;
558 if (time_after(jiffies, start + ARM_WAIT_FREE)) { 570 if (err) {
559 printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__); 571 printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__);
560 up(&av7110->dcomlock); 572 up(&av7110->dcomlock);
561 return -1; 573 return -ETIMEDOUT;
562 } 574 }
575#ifdef _NOHANDSHAKE
576 msleep(1);
577#endif
563 } 578 }
564 579
565#ifndef _NOHANDSHAKE 580#ifndef _NOHANDSHAKE
566 start = jiffies; 581 start = jiffies;
567 while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 )) { 582 while (1) {
568 msleep(1); 583 err = time_after(jiffies, start + ARM_WAIT_SHAKE);
569 if (time_after(jiffies, start + ARM_WAIT_SHAKE)) { 584 if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)
585 break;
586 if (err) {
570 printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); 587 printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
571 up(&av7110->dcomlock); 588 up(&av7110->dcomlock);
572 return -1; 589 return -ETIMEDOUT;
573 } 590 }
591 msleep(1);
574 } 592 }
575#endif 593#endif
576 594
@@ -667,10 +685,10 @@ int av7110_diseqc_send(struct av7110 *av7110, int len, u8 *msg, unsigned long bu
667 for (i = 0; i < len; i++) 685 for (i = 0; i < len; i++)
668 buf[i + 4] = msg[i]; 686 buf[i + 4] = msg[i];
669 687
670 if ((ret = av7110_send_fw_cmd(av7110, buf, 18))) 688 ret = av7110_send_fw_cmd(av7110, buf, 18);
689 if (ret && ret!=-ERESTARTSYS)
671 printk(KERN_ERR "dvb-ttpci: av7110_diseqc_send error %d\n", ret); 690 printk(KERN_ERR "dvb-ttpci: av7110_diseqc_send error %d\n", ret);
672 691 return ret;
673 return 0;
674} 692}
675 693
676 694
@@ -705,18 +723,22 @@ static inline int SetFont(struct av7110 *av7110, u8 windownr, u8 fontsize,
705static int FlushText(struct av7110 *av7110) 723static int FlushText(struct av7110 *av7110)
706{ 724{
707 unsigned long start; 725 unsigned long start;
726 int err;
708 727
709 if (down_interruptible(&av7110->dcomlock)) 728 if (down_interruptible(&av7110->dcomlock))
710 return -ERESTARTSYS; 729 return -ERESTARTSYS;
711 start = jiffies; 730 start = jiffies;
712 while (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2)) { 731 while (1) {
713 msleep(1); 732 err = time_after(jiffies, start + ARM_WAIT_OSD);
714 if (time_after(jiffies, start + ARM_WAIT_OSD)) { 733 if (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2) == 0)
734 break;
735 if (err) {
715 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n", 736 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n",
716 __FUNCTION__); 737 __FUNCTION__);
717 up(&av7110->dcomlock); 738 up(&av7110->dcomlock);
718 return -1; 739 return -ETIMEDOUT;
719 } 740 }
741 msleep(1);
720 } 742 }
721 up(&av7110->dcomlock); 743 up(&av7110->dcomlock);
722 return 0; 744 return 0;
@@ -733,25 +755,31 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
733 return -ERESTARTSYS; 755 return -ERESTARTSYS;
734 756
735 start = jiffies; 757 start = jiffies;
736 while (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2)) { 758 while (1) {
737 msleep(1); 759 ret = time_after(jiffies, start + ARM_WAIT_OSD);
738 if (time_after(jiffies, start + ARM_WAIT_OSD)) { 760 if (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2) == 0)
761 break;
762 if (ret) {
739 printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n", 763 printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n",
740 __FUNCTION__); 764 __FUNCTION__);
741 up(&av7110->dcomlock); 765 up(&av7110->dcomlock);
742 return -1; 766 return -ETIMEDOUT;
743 } 767 }
768 msleep(1);
744 } 769 }
745#ifndef _NOHANDSHAKE 770#ifndef _NOHANDSHAKE
746 start = jiffies; 771 start = jiffies;
747 while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2)) { 772 while (1) {
748 msleep(1); 773 ret = time_after(jiffies, start + ARM_WAIT_SHAKE);
749 if (time_after(jiffies, start + ARM_WAIT_SHAKE)) { 774 if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)
775 break;
776 if (ret) {
750 printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n", 777 printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n",
751 __FUNCTION__); 778 __FUNCTION__);
752 up(&av7110->dcomlock); 779 up(&av7110->dcomlock);
753 return -1; 780 return -ETIMEDOUT;
754 } 781 }
782 msleep(1);
755 } 783 }
756#endif 784#endif
757 for (i = 0; i < length / 2; i++) 785 for (i = 0; i < length / 2; i++)
@@ -761,7 +789,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
761 wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2); 789 wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2);
762 ret = __av7110_send_fw_cmd(av7110, cbuf, 5); 790 ret = __av7110_send_fw_cmd(av7110, cbuf, 5);
763 up(&av7110->dcomlock); 791 up(&av7110->dcomlock);
764 if (ret) 792 if (ret && ret!=-ERESTARTSYS)
765 printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret); 793 printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret);
766 return ret; 794 return ret;
767} 795}
@@ -816,9 +844,25 @@ static osd_raw_window_t bpp2bit[8] = {
816 OSD_BITMAP1, OSD_BITMAP2, 0, OSD_BITMAP4, 0, 0, 0, OSD_BITMAP8 844 OSD_BITMAP1, OSD_BITMAP2, 0, OSD_BITMAP4, 0, 0, 0, OSD_BITMAP8
817}; 845};
818 846
819static inline int LoadBitmap(struct av7110 *av7110, u16 format, 847static inline int WaitUntilBmpLoaded(struct av7110 *av7110)
848{
849 int ret = wait_event_interruptible_timeout(av7110->bmpq,
850 av7110->bmp_state != BMP_LOADING, 10*HZ);
851 if (ret == -ERESTARTSYS)
852 return ret;
853 if (ret == 0) {
854 printk("dvb-ttpci: warning: timeout waiting in LoadBitmap: %d, %d\n",
855 ret, av7110->bmp_state);
856 av7110->bmp_state = BMP_NONE;
857 return -ETIMEDOUT;
858 }
859 return 0;
860}
861
862static inline int LoadBitmap(struct av7110 *av7110,
820 u16 dx, u16 dy, int inc, u8 __user * data) 863 u16 dx, u16 dy, int inc, u8 __user * data)
821{ 864{
865 u16 format;
822 int bpp; 866 int bpp;
823 int i; 867 int i;
824 int d, delta; 868 int d, delta;
@@ -827,14 +871,7 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format,
827 871
828 dprintk(4, "%p\n", av7110); 872 dprintk(4, "%p\n", av7110);
829 873
830 ret = wait_event_interruptible_timeout(av7110->bmpq, av7110->bmp_state != BMP_LOADING, HZ); 874 format = bpp2bit[av7110->osdbpp[av7110->osdwin]];
831 if (ret == -ERESTARTSYS || ret == 0) {
832 printk("dvb-ttpci: warning: timeout waiting in LoadBitmap: %d, %d\n",
833 ret, av7110->bmp_state);
834 av7110->bmp_state = BMP_NONE;
835 return -1;
836 }
837 BUG_ON (av7110->bmp_state == BMP_LOADING);
838 875
839 av7110->bmp_state = BMP_LOADING; 876 av7110->bmp_state = BMP_LOADING;
840 if (format == OSD_BITMAP8) { 877 if (format == OSD_BITMAP8) {
@@ -847,18 +884,18 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format,
847 bpp=1; delta = 8; 884 bpp=1; delta = 8;
848 } else { 885 } else {
849 av7110->bmp_state = BMP_NONE; 886 av7110->bmp_state = BMP_NONE;
850 return -1; 887 return -EINVAL;
851 } 888 }
852 av7110->bmplen = ((dx * dy * bpp + 7) & ~7) / 8; 889 av7110->bmplen = ((dx * dy * bpp + 7) & ~7) / 8;
853 av7110->bmpp = 0; 890 av7110->bmpp = 0;
854 if (av7110->bmplen > 32768) { 891 if (av7110->bmplen > 32768) {
855 av7110->bmp_state = BMP_NONE; 892 av7110->bmp_state = BMP_NONE;
856 return -1; 893 return -EINVAL;
857 } 894 }
858 for (i = 0; i < dy; i++) { 895 for (i = 0; i < dy; i++) {
859 if (copy_from_user(av7110->bmpbuf + 1024 + i * dx, data + i * inc, dx)) { 896 if (copy_from_user(av7110->bmpbuf + 1024 + i * dx, data + i * inc, dx)) {
860 av7110->bmp_state = BMP_NONE; 897 av7110->bmp_state = BMP_NONE;
861 return -1; 898 return -EINVAL;
862 } 899 }
863 } 900 }
864 if (format != OSD_BITMAP8) { 901 if (format != OSD_BITMAP8) {
@@ -873,37 +910,27 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format,
873 } 910 }
874 av7110->bmplen += 1024; 911 av7110->bmplen += 1024;
875 dprintk(4, "av7110_fw_cmd: LoadBmp size %d\n", av7110->bmplen); 912 dprintk(4, "av7110_fw_cmd: LoadBmp size %d\n", av7110->bmplen);
876 return av7110_fw_cmd(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy); 913 ret = av7110_fw_cmd(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy);
914 if (!ret)
915 ret = WaitUntilBmpLoaded(av7110);
916 return ret;
877} 917}
878 918
879static int BlitBitmap(struct av7110 *av7110, u16 win, u16 x, u16 y, u16 trans) 919static int BlitBitmap(struct av7110 *av7110, u16 x, u16 y)
880{ 920{
881 int ret;
882
883 dprintk(4, "%p\n", av7110); 921 dprintk(4, "%p\n", av7110);
884 922
885 BUG_ON (av7110->bmp_state == BMP_NONE); 923 return av7110_fw_cmd(av7110, COMTYPE_OSD, BlitBmp, 4, av7110->osdwin, x, y, 0);
886
887 ret = wait_event_interruptible_timeout(av7110->bmpq,
888 av7110->bmp_state != BMP_LOADING, 10*HZ);
889 if (ret == -ERESTARTSYS || ret == 0) {
890 printk("dvb-ttpci: warning: timeout waiting in BlitBitmap: %d, %d\n",
891 ret, av7110->bmp_state);
892 av7110->bmp_state = BMP_NONE;
893 return (ret == 0) ? -ETIMEDOUT : ret;
894 }
895
896 BUG_ON (av7110->bmp_state != BMP_LOADED);
897
898 return av7110_fw_cmd(av7110, COMTYPE_OSD, BlitBmp, 4, win, x, y, trans);
899} 924}
900 925
901static inline int ReleaseBitmap(struct av7110 *av7110) 926static inline int ReleaseBitmap(struct av7110 *av7110)
902{ 927{
903 dprintk(4, "%p\n", av7110); 928 dprintk(4, "%p\n", av7110);
904 929
905 if (av7110->bmp_state != BMP_LOADED) 930 if (av7110->bmp_state != BMP_LOADED && FW_VERSION(av7110->arm_app) < 0x261e)
906 return -1; 931 return -1;
932 if (av7110->bmp_state == BMP_LOADING)
933 dprintk(1,"ReleaseBitmap called while BMP_LOADING\n");
907 av7110->bmp_state = BMP_NONE; 934 av7110->bmp_state = BMP_NONE;
908 return av7110_fw_cmd(av7110, COMTYPE_OSD, ReleaseBmp, 0); 935 return av7110_fw_cmd(av7110, COMTYPE_OSD, ReleaseBmp, 0);
909} 936}
@@ -924,18 +951,22 @@ static u32 RGB2YUV(u16 R, u16 G, u16 B)
924 return Cr | (Cb << 16) | (Y << 8); 951 return Cr | (Cb << 16) | (Y << 8);
925} 952}
926 953
927static void OSDSetColor(struct av7110 *av7110, u8 color, u8 r, u8 g, u8 b, u8 blend) 954static int OSDSetColor(struct av7110 *av7110, u8 color, u8 r, u8 g, u8 b, u8 blend)
928{ 955{
956 int ret;
957
929 u16 ch, cl; 958 u16 ch, cl;
930 u32 yuv; 959 u32 yuv;
931 960
932 yuv = blend ? RGB2YUV(r,g,b) : 0; 961 yuv = blend ? RGB2YUV(r,g,b) : 0;
933 cl = (yuv & 0xffff); 962 cl = (yuv & 0xffff);
934 ch = ((yuv >> 16) & 0xffff); 963 ch = ((yuv >> 16) & 0xffff);
935 SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], 964 ret = SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]],
936 color, ch, cl); 965 color, ch, cl);
937 SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], 966 if (!ret)
938 color, ((blend >> 4) & 0x0f)); 967 ret = SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]],
968 color, ((blend >> 4) & 0x0f));
969 return ret;
939} 970}
940 971
941static int OSDSetPalette(struct av7110 *av7110, u32 __user * colors, u8 first, u8 last) 972static int OSDSetPalette(struct av7110 *av7110, u32 __user * colors, u8 first, u8 last)
@@ -968,14 +999,14 @@ static int OSDSetBlock(struct av7110 *av7110, int x0, int y0,
968{ 999{
969 uint w, h, bpp, bpl, size, lpb, bnum, brest; 1000 uint w, h, bpp, bpl, size, lpb, bnum, brest;
970 int i; 1001 int i;
971 int rc; 1002 int rc,release_rc;
972 1003
973 w = x1 - x0 + 1; 1004 w = x1 - x0 + 1;
974 h = y1 - y0 + 1; 1005 h = y1 - y0 + 1;
975 if (inc <= 0) 1006 if (inc <= 0)
976 inc = w; 1007 inc = w;
977 if (w <= 0 || w > 720 || h <= 0 || h > 576) 1008 if (w <= 0 || w > 720 || h <= 0 || h > 576)
978 return -1; 1009 return -EINVAL;
979 bpp = av7110->osdbpp[av7110->osdwin] + 1; 1010 bpp = av7110->osdbpp[av7110->osdwin] + 1;
980 bpl = ((w * bpp + 7) & ~7) / 8; 1011 bpl = ((w * bpp + 7) & ~7) / 8;
981 size = h * bpl; 1012 size = h * bpl;
@@ -983,176 +1014,186 @@ static int OSDSetBlock(struct av7110 *av7110, int x0, int y0,
983 bnum = size / (lpb * bpl); 1014 bnum = size / (lpb * bpl);
984 brest = size - bnum * lpb * bpl; 1015 brest = size - bnum * lpb * bpl;
985 1016
986 for (i = 0; i < bnum; i++) { 1017 if (av7110->bmp_state == BMP_LOADING) {
987 rc = LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], 1018 /* possible if syscall is repeated by -ERESTARTSYS and if firmware cannot abort */
988 w, lpb, inc, data); 1019 BUG_ON (FW_VERSION(av7110->arm_app) >= 0x261e);
989 if (rc) 1020 rc = WaitUntilBmpLoaded(av7110);
990 return rc;
991 rc = BlitBitmap(av7110, av7110->osdwin, x0, y0 + i * lpb, 0);
992 if (rc) 1021 if (rc)
993 return rc; 1022 return rc;
994 data += lpb * inc; 1023 /* just continue. This should work for all fw versions
1024 * if bnum==1 && !brest && LoadBitmap was successful
1025 */
995 } 1026 }
996 if (brest) { 1027
997 rc = LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], 1028 rc = 0;
998 w, brest / bpl, inc, data); 1029 for (i = 0; i < bnum; i++) {
1030 rc = LoadBitmap(av7110, w, lpb, inc, data);
999 if (rc) 1031 if (rc)
1000 return rc; 1032 break;
1001 rc = BlitBitmap(av7110, av7110->osdwin, x0, y0 + bnum * lpb, 0); 1033 rc = BlitBitmap(av7110, x0, y0 + i * lpb);
1002 if (rc) 1034 if (rc)
1003 return rc; 1035 break;
1036 data += lpb * inc;
1004 } 1037 }
1005 ReleaseBitmap(av7110); 1038 if (!rc && brest) {
1006 return 0; 1039 rc = LoadBitmap(av7110, w, brest / bpl, inc, data);
1040 if (!rc)
1041 rc = BlitBitmap(av7110, x0, y0 + bnum * lpb);
1042 }
1043 release_rc = ReleaseBitmap(av7110);
1044 if (!rc)
1045 rc = release_rc;
1046 if (rc)
1047 dprintk(1,"returns %d\n",rc);
1048 return rc;
1007} 1049}
1008 1050
1009int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc) 1051int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
1010{ 1052{
1011 int ret; 1053 int ret;
1012 1054
1013 ret = down_interruptible(&av7110->osd_sema); 1055 if (down_interruptible(&av7110->osd_sema))
1014 if (ret)
1015 return -ERESTARTSYS; 1056 return -ERESTARTSYS;
1016 1057
1017 /* stupid, but OSD functions don't provide a return code anyway */
1018 ret = 0;
1019
1020 switch (dc->cmd) { 1058 switch (dc->cmd) {
1021 case OSD_Close: 1059 case OSD_Close:
1022 DestroyOSDWindow(av7110, av7110->osdwin); 1060 ret = DestroyOSDWindow(av7110, av7110->osdwin);
1023 goto out; 1061 break;
1024 case OSD_Open: 1062 case OSD_Open:
1025 av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7; 1063 av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7;
1026 CreateOSDWindow(av7110, av7110->osdwin, 1064 ret = CreateOSDWindow(av7110, av7110->osdwin,
1027 bpp2bit[av7110->osdbpp[av7110->osdwin]], 1065 bpp2bit[av7110->osdbpp[av7110->osdwin]],
1028 dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1); 1066 dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1);
1067 if (ret)
1068 break;
1029 if (!dc->data) { 1069 if (!dc->data) {
1030 MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); 1070 ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
1031 SetColorBlend(av7110, av7110->osdwin); 1071 if (ret)
1072 break;
1073 ret = SetColorBlend(av7110, av7110->osdwin);
1032 } 1074 }
1033 goto out; 1075 break;
1034 case OSD_Show: 1076 case OSD_Show:
1035 MoveWindowRel(av7110, av7110->osdwin, 0, 0); 1077 ret = MoveWindowRel(av7110, av7110->osdwin, 0, 0);
1036 goto out; 1078 break;
1037 case OSD_Hide: 1079 case OSD_Hide:
1038 HideWindow(av7110, av7110->osdwin); 1080 ret = HideWindow(av7110, av7110->osdwin);
1039 goto out; 1081 break;
1040 case OSD_Clear: 1082 case OSD_Clear:
1041 DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0); 1083 ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0);
1042 goto out; 1084 break;
1043 case OSD_Fill: 1085 case OSD_Fill:
1044 DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color); 1086 ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color);
1045 goto out; 1087 break;
1046 case OSD_SetColor: 1088 case OSD_SetColor:
1047 OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1); 1089 ret = OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1);
1048 goto out; 1090 break;
1049 case OSD_SetPalette: 1091 case OSD_SetPalette:
1050 { 1092 if (FW_VERSION(av7110->arm_app) >= 0x2618)
1051 if (FW_VERSION(av7110->arm_app) >= 0x2618) {
1052 ret = OSDSetPalette(av7110, dc->data, dc->color, dc->x0); 1093 ret = OSDSetPalette(av7110, dc->data, dc->color, dc->x0);
1053 goto out; 1094 else {
1054 } else {
1055 int i, len = dc->x0-dc->color+1; 1095 int i, len = dc->x0-dc->color+1;
1056 u8 __user *colors = (u8 __user *)dc->data; 1096 u8 __user *colors = (u8 __user *)dc->data;
1057 u8 r, g, b, blend; 1097 u8 r, g, b, blend;
1058 1098 ret = 0;
1059 for (i = 0; i<len; i++) { 1099 for (i = 0; i<len; i++) {
1060 if (get_user(r, colors + i * 4) || 1100 if (get_user(r, colors + i * 4) ||
1061 get_user(g, colors + i * 4 + 1) || 1101 get_user(g, colors + i * 4 + 1) ||
1062 get_user(b, colors + i * 4 + 2) || 1102 get_user(b, colors + i * 4 + 2) ||
1063 get_user(blend, colors + i * 4 + 3)) { 1103 get_user(blend, colors + i * 4 + 3)) {
1064 ret = -EFAULT; 1104 ret = -EFAULT;
1065 goto out; 1105 break;
1066 } 1106 }
1067 OSDSetColor(av7110, dc->color + i, r, g, b, blend); 1107 ret = OSDSetColor(av7110, dc->color + i, r, g, b, blend);
1108 if (ret)
1109 break;
1068 } 1110 }
1069 } 1111 }
1070 ret = 0; 1112 break;
1071 goto out;
1072 }
1073 case OSD_SetTrans:
1074 goto out;
1075 case OSD_SetPixel: 1113 case OSD_SetPixel:
1076 DrawLine(av7110, av7110->osdwin, 1114 ret = DrawLine(av7110, av7110->osdwin,
1077 dc->x0, dc->y0, 0, 0, dc->color); 1115 dc->x0, dc->y0, 0, 0, dc->color);
1078 goto out; 1116 break;
1079 case OSD_GetPixel:
1080 goto out;
1081 case OSD_SetRow: 1117 case OSD_SetRow:
1082 dc->y1 = dc->y0; 1118 dc->y1 = dc->y0;
1083 /* fall through */ 1119 /* fall through */
1084 case OSD_SetBlock: 1120 case OSD_SetBlock:
1085 ret = OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data); 1121 ret = OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data);
1086 goto out; 1122 break;
1087 case OSD_FillRow: 1123 case OSD_FillRow:
1088 DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, 1124 ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
1089 dc->x1-dc->x0+1, dc->y1, dc->color); 1125 dc->x1-dc->x0+1, dc->y1, dc->color);
1090 goto out; 1126 break;
1091 case OSD_FillBlock: 1127 case OSD_FillBlock:
1092 DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, 1128 ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
1093 dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1, dc->color); 1129 dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1, dc->color);
1094 goto out; 1130 break;
1095 case OSD_Line: 1131 case OSD_Line:
1096 DrawLine(av7110, av7110->osdwin, 1132 ret = DrawLine(av7110, av7110->osdwin,
1097 dc->x0, dc->y0, dc->x1 - dc->x0, dc->y1 - dc->y0, dc->color); 1133 dc->x0, dc->y0, dc->x1 - dc->x0, dc->y1 - dc->y0, dc->color);
1098 goto out; 1134 break;
1099 case OSD_Query:
1100 goto out;
1101 case OSD_Test:
1102 goto out;
1103 case OSD_Text: 1135 case OSD_Text:
1104 { 1136 {
1105 char textbuf[240]; 1137 char textbuf[240];
1106 1138
1107 if (strncpy_from_user(textbuf, dc->data, 240) < 0) { 1139 if (strncpy_from_user(textbuf, dc->data, 240) < 0) {
1108 ret = -EFAULT; 1140 ret = -EFAULT;
1109 goto out; 1141 break;
1110 } 1142 }
1111 textbuf[239] = 0; 1143 textbuf[239] = 0;
1112 if (dc->x1 > 3) 1144 if (dc->x1 > 3)
1113 dc->x1 = 3; 1145 dc->x1 = 3;
1114 SetFont(av7110, av7110->osdwin, dc->x1, 1146 ret = SetFont(av7110, av7110->osdwin, dc->x1,
1115 (u16) (dc->color & 0xffff), (u16) (dc->color >> 16)); 1147 (u16) (dc->color & 0xffff), (u16) (dc->color >> 16));
1116 FlushText(av7110); 1148 if (!ret)
1117 WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf); 1149 ret = FlushText(av7110);
1118 goto out; 1150 if (!ret)
1151 ret = WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf);
1152 break;
1119 } 1153 }
1120 case OSD_SetWindow: 1154 case OSD_SetWindow:
1121 if (dc->x0 < 1 || dc->x0 > 7) { 1155 if (dc->x0 < 1 || dc->x0 > 7)
1122 ret = -EINVAL; 1156 ret = -EINVAL;
1123 goto out; 1157 else {
1158 av7110->osdwin = dc->x0;
1159 ret = 0;
1124 } 1160 }
1125 av7110->osdwin = dc->x0; 1161 break;
1126 goto out;
1127 case OSD_MoveWindow: 1162 case OSD_MoveWindow:
1128 MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); 1163 ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
1129 SetColorBlend(av7110, av7110->osdwin); 1164 if (!ret)
1130 goto out; 1165 ret = SetColorBlend(av7110, av7110->osdwin);
1166 break;
1131 case OSD_OpenRaw: 1167 case OSD_OpenRaw:
1132 if (dc->color < OSD_BITMAP1 || dc->color > OSD_CURSOR) { 1168 if (dc->color < OSD_BITMAP1 || dc->color > OSD_CURSOR) {
1133 ret = -EINVAL; 1169 ret = -EINVAL;
1134 goto out; 1170 break;
1135 } 1171 }
1136 if (dc->color >= OSD_BITMAP1 && dc->color <= OSD_BITMAP8HR) { 1172 if (dc->color >= OSD_BITMAP1 && dc->color <= OSD_BITMAP8HR)
1137 av7110->osdbpp[av7110->osdwin] = (1 << (dc->color & 3)) - 1; 1173 av7110->osdbpp[av7110->osdwin] = (1 << (dc->color & 3)) - 1;
1138 } 1174 else
1139 else {
1140 av7110->osdbpp[av7110->osdwin] = 0; 1175 av7110->osdbpp[av7110->osdwin] = 0;
1141 } 1176 ret = CreateOSDWindow(av7110, av7110->osdwin, (osd_raw_window_t)dc->color,
1142 CreateOSDWindow(av7110, av7110->osdwin, (osd_raw_window_t)dc->color,
1143 dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1); 1177 dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1);
1178 if (ret)
1179 break;
1144 if (!dc->data) { 1180 if (!dc->data) {
1145 MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); 1181 ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
1146 SetColorBlend(av7110, av7110->osdwin); 1182 if (!ret)
1183 ret = SetColorBlend(av7110, av7110->osdwin);
1147 } 1184 }
1148 goto out; 1185 break;
1149 default: 1186 default:
1150 ret = -EINVAL; 1187 ret = -EINVAL;
1151 goto out; 1188 break;
1152 } 1189 }
1153 1190
1154out:
1155 up(&av7110->osd_sema); 1191 up(&av7110->osd_sema);
1192 if (ret==-ERESTARTSYS)
1193 dprintk(1, "av7110_osd_cmd(%d) returns with -ERESTARTSYS\n",dc->cmd);
1194 else if (ret)
1195 dprintk(1, "av7110_osd_cmd(%d) returns with %d\n",dc->cmd,ret);
1196
1156 return ret; 1197 return ret;
1157} 1198}
1158 1199
diff --git a/drivers/media/dvb/ttpci/av7110_hw.h b/drivers/media/dvb/ttpci/av7110_hw.h
index 52061e17c6dd..fedd20f9815d 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.h
+++ b/drivers/media/dvb/ttpci/av7110_hw.h
@@ -458,27 +458,27 @@ static inline int SendDAC(struct av7110 *av7110, u8 addr, u8 data)
458 return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, AudioDAC, 2, addr, data); 458 return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, AudioDAC, 2, addr, data);
459} 459}
460 460
461static inline void av7710_set_video_mode(struct av7110 *av7110, int mode) 461static inline int av7710_set_video_mode(struct av7110 *av7110, int mode)
462{ 462{
463 av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetVidMode, 1, mode); 463 return av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetVidMode, 1, mode);
464} 464}
465 465
466static int inline vidcom(struct av7110 *av7110, u32 com, u32 arg) 466static inline int vidcom(struct av7110 *av7110, u32 com, u32 arg)
467{ 467{
468 return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_VIDEO_COMMAND, 4, 468 return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_VIDEO_COMMAND, 4,
469 (com>>16), (com&0xffff), 469 (com>>16), (com&0xffff),
470 (arg>>16), (arg&0xffff)); 470 (arg>>16), (arg&0xffff));
471} 471}
472 472
473static int inline audcom(struct av7110 *av7110, u32 com) 473static inline int audcom(struct av7110 *av7110, u32 com)
474{ 474{
475 return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_AUDIO_COMMAND, 2, 475 return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_AUDIO_COMMAND, 2,
476 (com>>16), (com&0xffff)); 476 (com>>16), (com&0xffff));
477} 477}
478 478
479static inline void Set22K(struct av7110 *av7110, int state) 479static inline int Set22K(struct av7110 *av7110, int state)
480{ 480{
481 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, (state ? ON22K : OFF22K), 0); 481 return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, (state ? ON22K : OFF22K), 0);
482} 482}
483 483
484 484
diff --git a/drivers/media/dvb/ttpci/av7110_ipack.c b/drivers/media/dvb/ttpci/av7110_ipack.c
index 246640741888..699ef8b5b99a 100644
--- a/drivers/media/dvb/ttpci/av7110_ipack.c
+++ b/drivers/media/dvb/ttpci/av7110_ipack.c
@@ -24,7 +24,7 @@ int av7110_ipack_init(struct ipack *p, int size,
24 void (*func)(u8 *buf, int size, void *priv)) 24 void (*func)(u8 *buf, int size, void *priv))
25{ 25{
26 if (!(p->buf = vmalloc(size*sizeof(u8)))) { 26 if (!(p->buf = vmalloc(size*sizeof(u8)))) {
27 printk ("Couldn't allocate memory for ipack\n"); 27 printk(KERN_WARNING "Couldn't allocate memory for ipack\n");
28 return -ENOMEM; 28 return -ENOMEM;
29 } 29 }
30 p->size = size; 30 p->size = size;
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 6e0f5d307c52..9746d2bb916f 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -570,9 +570,9 @@ static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_p
570 570
571 buf[0] = (div >> 8) & 0x7f; 571 buf[0] = (div >> 8) & 0x7f;
572 buf[1] = div & 0xff; 572 buf[1] = div & 0xff;
573 buf[2] = 0x8e; 573 buf[2] = 0x86;
574 buf[3] = (params->frequency < 174500000 ? 0xa1 : 574 buf[3] = (params->frequency < 150000000 ? 0x01 :
575 params->frequency < 454000000 ? 0x92 : 0x34); 575 params->frequency < 445000000 ? 0x02 : 0x04);
576 576
577 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1) 577 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
578 return -EIO; 578 return -EIO;
@@ -695,8 +695,12 @@ static struct tda1004x_config philips_tu1216_config = {
695 .demod_address = 0x8, 695 .demod_address = 0x8,
696 .invert = 1, 696 .invert = 1,
697 .invert_oclk = 1, 697 .invert_oclk = 1,
698 .xtal_freq = TDA10046_XTAL_4M,
699 .agc_config = TDA10046_AGC_DEFAULT,
700 .if_freq = TDA10046_FREQ_3617,
698 .pll_init = philips_tu1216_pll_init, 701 .pll_init = philips_tu1216_pll_init,
699 .pll_set = philips_tu1216_pll_set, 702 .pll_set = philips_tu1216_pll_set,
703 .pll_sleep = NULL,
700 .request_firmware = philips_tu1216_request_firmware, 704 .request_firmware = philips_tu1216_request_firmware,
701}; 705};
702 706
@@ -1018,7 +1022,7 @@ static struct pci_device_id pci_tbl[] = {
1018MODULE_DEVICE_TABLE(pci, pci_tbl); 1022MODULE_DEVICE_TABLE(pci, pci_tbl);
1019 1023
1020static struct saa7146_extension budget_extension = { 1024static struct saa7146_extension budget_extension = {
1021 .name = "budget dvb /w video in\0", 1025 .name = "budget_av",
1022 .pci_tbl = pci_tbl, 1026 .pci_tbl = pci_tbl,
1023 1027
1024 .module = THIS_MODULE, 1028 .module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index dce116111376..a1267054bc01 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -69,6 +69,7 @@ struct budget_ci {
69 int slot_status; 69 int slot_status;
70 struct dvb_ca_en50221 ca; 70 struct dvb_ca_en50221 ca;
71 char ir_dev_name[50]; 71 char ir_dev_name[50];
72 u8 tuner_pll_address; /* used for philips_tdm1316l configs */
72}; 73};
73 74
74/* from reading the following remotes: 75/* from reading the following remotes:
@@ -723,7 +724,7 @@ static int philips_tdm1316l_pll_init(struct dvb_frontend *fe)
723 struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; 724 struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
724 static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab }; 725 static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab };
725 static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 }; 726 static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
726 struct i2c_msg tuner_msg = {.addr = 0x63,.flags = 0,.buf = td1316_init,.len = 727 struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = td1316_init,.len =
727 sizeof(td1316_init) }; 728 sizeof(td1316_init) };
728 729
729 // setup PLL configuration 730 // setup PLL configuration
@@ -746,7 +747,7 @@ static int philips_tdm1316l_pll_set(struct dvb_frontend *fe, struct dvb_frontend
746{ 747{
747 struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; 748 struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
748 u8 tuner_buf[4]; 749 u8 tuner_buf[4];
749 struct i2c_msg tuner_msg = {.addr = 0x63,.flags = 0,.buf = tuner_buf,.len = sizeof(tuner_buf) }; 750 struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = tuner_buf,.len = sizeof(tuner_buf) };
750 int tuner_frequency = 0; 751 int tuner_frequency = 0;
751 u8 band, cp, filter; 752 u8 band, cp, filter;
752 753
@@ -838,8 +839,12 @@ static struct tda1004x_config philips_tdm1316l_config = {
838 .demod_address = 0x8, 839 .demod_address = 0x8,
839 .invert = 0, 840 .invert = 0,
840 .invert_oclk = 0, 841 .invert_oclk = 0,
842 .xtal_freq = TDA10046_XTAL_4M,
843 .agc_config = TDA10046_AGC_DEFAULT,
844 .if_freq = TDA10046_FREQ_3617,
841 .pll_init = philips_tdm1316l_pll_init, 845 .pll_init = philips_tdm1316l_pll_init,
842 .pll_set = philips_tdm1316l_pll_set, 846 .pll_set = philips_tdm1316l_pll_set,
847 .pll_sleep = NULL,
843 .request_firmware = philips_tdm1316l_request_firmware, 848 .request_firmware = philips_tdm1316l_request_firmware,
844}; 849};
845 850
@@ -865,12 +870,22 @@ static void frontend_init(struct budget_ci *budget_ci)
865 break; 870 break;
866 871
867 case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) 872 case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
873 budget_ci->tuner_pll_address = 0x63;
868 budget_ci->budget.dvb_frontend = 874 budget_ci->budget.dvb_frontend =
869 tda10045_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 875 tda10045_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
870 if (budget_ci->budget.dvb_frontend) { 876 if (budget_ci->budget.dvb_frontend) {
871 break; 877 break;
872 } 878 }
873 break; 879 break;
880
881 case 0x1012: // Hauppauge/TT Nova-T CI budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
882 budget_ci->tuner_pll_address = 0x60;
883 budget_ci->budget.dvb_frontend =
884 tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
885 if (budget_ci->budget.dvb_frontend) {
886 break;
887 }
888 break;
874 } 889 }
875 890
876 if (budget_ci->budget.dvb_frontend == NULL) { 891 if (budget_ci->budget.dvb_frontend == NULL) {
@@ -950,11 +965,13 @@ static struct saa7146_extension budget_extension;
950 965
951MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC); 966MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC);
952MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); 967MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
968MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT);
953 969
954static struct pci_device_id pci_tbl[] = { 970static struct pci_device_id pci_tbl[] = {
955 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c), 971 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c),
956 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f), 972 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f),
957 MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011), 973 MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011),
974 MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012),
958 { 975 {
959 .vendor = 0, 976 .vendor = 0,
960 } 977 }
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 083fd44e5f90..9961917e8a7f 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -40,6 +40,7 @@
40#include "ves1820.h" 40#include "ves1820.h"
41#include "l64781.h" 41#include "l64781.h"
42#include "tda8083.h" 42#include "tda8083.h"
43#include "s5h1420.h"
43 44
44static void Set22K (struct budget *budget, int state) 45static void Set22K (struct budget *budget, int state)
45{ 46{
@@ -177,6 +178,62 @@ static int budget_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t m
177 return 0; 178 return 0;
178} 179}
179 180
181static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
182{
183 struct budget* budget = (struct budget*) fe->dvb->priv;
184 u8 buf;
185 struct i2c_msg msg = { .addr = 0x08, .flags = I2C_M_RD, .buf = &buf, .len = sizeof(buf) };
186
187 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
188
189 switch(voltage) {
190 case SEC_VOLTAGE_13:
191 buf = (buf & 0xf7) | 0x04;
192 break;
193
194 case SEC_VOLTAGE_18:
195 buf = (buf & 0xf7) | 0x0c;
196 break;
197
198 case SEC_VOLTAGE_OFF:
199 buf = buf & 0xf0;
200 break;
201 }
202
203 msg.flags = 0;
204 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
205
206 return 0;
207}
208
209static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend* fe, int arg)
210{
211 struct budget* budget = (struct budget*) fe->dvb->priv;
212 u8 buf;
213 struct i2c_msg msg = { .addr = 0x08, .flags = I2C_M_RD, .buf = &buf, .len = sizeof(buf) };
214
215 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
216
217 if (arg) {
218 buf = buf | 0x10;
219 } else {
220 buf = buf & 0xef;
221 }
222
223 msg.flags = 0;
224 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
225
226 return 0;
227}
228
229static void lnbp21_init(struct budget* budget)
230{
231 u8 buf = 0x00;
232 struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = &buf, .len = sizeof(buf) };
233
234 i2c_transfer (&budget->i2c_adap, &msg, 1);
235}
236
180static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 237static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
181{ 238{
182 struct budget* budget = (struct budget*) fe->dvb->priv; 239 struct budget* budget = (struct budget*) fe->dvb->priv;
@@ -395,6 +452,38 @@ static struct tda8083_config grundig_29504_451_config = {
395 .pll_set = grundig_29504_451_pll_set, 452 .pll_set = grundig_29504_451_pll_set,
396}; 453};
397 454
455static int s5h1420_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout)
456{
457 struct budget* budget = (struct budget*) fe->dvb->priv;
458 u32 div;
459 u8 data[4];
460 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
461
462 div = params->frequency / 1000;
463 data[0] = (div >> 8) & 0x7f;
464 data[1] = div & 0xff;
465 data[2] = 0xc2;
466
467 if (div < 1450)
468 data[3] = 0x00;
469 else if (div < 1850)
470 data[3] = 0x40;
471 else if (div < 2000)
472 data[3] = 0x80;
473 else
474 data[3] = 0xc0;
475
476 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
477
478 *freqout = div * 1000;
479 return 0;
480}
481
482static struct s5h1420_config s5h1420_config = {
483 .demod_address = 0x53,
484 .pll_set = s5h1420_pll_set,
485};
486
398static u8 read_pwm(struct budget* budget) 487static u8 read_pwm(struct budget* budget)
399{ 488{
400 u8 b = 0xff; 489 u8 b = 0xff;
@@ -459,6 +548,15 @@ static void frontend_init(struct budget *budget)
459 break; 548 break;
460 } 549 }
461 break; 550 break;
551
552 case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260))
553 budget->dvb_frontend = s5h1420_attach(&s5h1420_config, &budget->i2c_adap);
554 if (budget->dvb_frontend) {
555 budget->dvb_frontend->ops->set_voltage = lnbp21_set_voltage;
556 budget->dvb_frontend->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
557 lnbp21_init(budget);
558 break;
559 }
462 } 560 }
463 561
464 if (budget->dvb_frontend == NULL) { 562 if (budget->dvb_frontend == NULL) {
@@ -532,6 +630,7 @@ static struct pci_device_id pci_tbl[] = {
532 MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004), 630 MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004),
533 MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005), 631 MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005),
534 MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013), 632 MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
633 MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016),
535 MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60), 634 MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60),
536 MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61), 635 MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61),
537 { 636 {
diff --git a/drivers/media/dvb/ttusb-budget/Kconfig b/drivers/media/dvb/ttusb-budget/Kconfig
index 4aa714ab4c28..c6c1d41a2efb 100644
--- a/drivers/media/dvb/ttusb-budget/Kconfig
+++ b/drivers/media/dvb/ttusb-budget/Kconfig
@@ -3,6 +3,7 @@ config DVB_TTUSB_BUDGET
3 depends on DVB_CORE && USB 3 depends on DVB_CORE && USB
4 select DVB_CX22700 4 select DVB_CX22700
5 select DVB_TDA1004X 5 select DVB_TDA1004X
6 select DVB_VES1820
6 select DVB_TDA8083 7 select DVB_TDA8083
7 select DVB_STV0299 8 select DVB_STV0299
8 help 9 help
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index afa0e7a0e506..aa43b5fcb8e7 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -24,6 +24,7 @@
24#include "dmxdev.h" 24#include "dmxdev.h"
25#include "dvb_demux.h" 25#include "dvb_demux.h"
26#include "dvb_net.h" 26#include "dvb_net.h"
27#include "ves1820.h"
27#include "cx22700.h" 28#include "cx22700.h"
28#include "tda1004x.h" 29#include "tda1004x.h"
29#include "stv0299.h" 30#include "stv0299.h"
@@ -1367,6 +1368,47 @@ static struct tda8083_config ttusb_novas_grundig_29504_491_config = {
1367 .pll_set = ttusb_novas_grundig_29504_491_pll_set, 1368 .pll_set = ttusb_novas_grundig_29504_491_pll_set,
1368}; 1369};
1369 1370
1371static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1372{
1373 struct ttusb* ttusb = fe->dvb->priv;
1374 u32 div;
1375 u8 data[4];
1376 struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
1377
1378 div = (params->frequency + 35937500 + 31250) / 62500;
1379
1380 data[0] = (div >> 8) & 0x7f;
1381 data[1] = div & 0xff;
1382 data[2] = 0x85 | ((div >> 10) & 0x60);
1383 data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81);
1384
1385 if (i2c_transfer (&ttusb->i2c_adap, &msg, 1) != 1)
1386 return -EIO;
1387
1388 return 0;
1389}
1390
1391
1392static struct ves1820_config alps_tdbe2_config = {
1393 .demod_address = 0x09,
1394 .xin = 57840000UL,
1395 .invert = 1,
1396 .selagc = VES1820_SELAGC_SIGNAMPERR,
1397 .pll_set = alps_tdbe2_pll_set,
1398};
1399
1400static u8 read_pwm(struct ttusb* ttusb)
1401{
1402 u8 b = 0xff;
1403 u8 pwm;
1404 struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
1405 { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
1406
1407 if ((i2c_transfer(&ttusb->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
1408 pwm = 0x48;
1409
1410 return pwm;
1411}
1370 1412
1371 1413
1372static void frontend_init(struct ttusb* ttusb) 1414static void frontend_init(struct ttusb* ttusb)
@@ -1394,6 +1436,12 @@ static void frontend_init(struct ttusb* ttusb)
1394 1436
1395 break; 1437 break;
1396 1438
1439 case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659))
1440 ttusb->fe = ves1820_attach(&alps_tdbe2_config, &ttusb->i2c_adap, read_pwm(ttusb));
1441 if (ttusb->fe != NULL)
1442 break;
1443 break;
1444
1397 case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??)) 1445 case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??))
1398 // try the ALPS TDMB7 first 1446 // try the ALPS TDMB7 first
1399 ttusb->fe = cx22700_attach(&alps_tdmb7_config, &ttusb->i2c_adap); 1447 ttusb->fe = cx22700_attach(&alps_tdmb7_config, &ttusb->i2c_adap);
@@ -1570,7 +1618,7 @@ static void ttusb_disconnect(struct usb_interface *intf)
1570 1618
1571static struct usb_device_id ttusb_table[] = { 1619static struct usb_device_id ttusb_table[] = {
1572 {USB_DEVICE(0xb48, 0x1003)}, 1620 {USB_DEVICE(0xb48, 0x1003)},
1573/* {USB_DEVICE(0xb48, 0x1004)},UNDEFINED HARDWARE - mail linuxtv.org list*/ /* to be confirmed ???? */ 1621 {USB_DEVICE(0xb48, 0x1004)},
1574 {USB_DEVICE(0xb48, 0x1005)}, 1622 {USB_DEVICE(0xb48, 0x1005)},
1575 {} 1623 {}
1576}; 1624};
@@ -1578,7 +1626,7 @@ static struct usb_device_id ttusb_table[] = {
1578MODULE_DEVICE_TABLE(usb, ttusb_table); 1626MODULE_DEVICE_TABLE(usb, ttusb_table);
1579 1627
1580static struct usb_driver ttusb_driver = { 1628static struct usb_driver ttusb_driver = {
1581 .name = "Technotrend/Hauppauge USB-Nova", 1629 .name = "ttusb",
1582 .probe = ttusb_probe, 1630 .probe = ttusb_probe,
1583 .disconnect = ttusb_disconnect, 1631 .disconnect = ttusb_disconnect,
1584 .id_table = ttusb_table, 1632 .id_table = ttusb_table,
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 505bdaff5a7e..45c9a9a08e4d 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1281,6 +1281,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1281 if (firmware_size < 60) { 1281 if (firmware_size < 60) {
1282 printk("%s: firmware size too small for DSP code (%zu < 60).\n", 1282 printk("%s: firmware size too small for DSP code (%zu < 60).\n",
1283 __FUNCTION__, firmware_size); 1283 __FUNCTION__, firmware_size);
1284 release_firmware(fw_entry);
1284 return -1; 1285 return -1;
1285 } 1286 }
1286 1287
@@ -1294,6 +1295,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1294 printk("%s: crc32 check of DSP code failed (calculated " 1295 printk("%s: crc32 check of DSP code failed (calculated "
1295 "0x%08x != 0x%08x in file), file invalid.\n", 1296 "0x%08x != 0x%08x in file), file invalid.\n",
1296 __FUNCTION__, crc32_csum, crc32_check); 1297 __FUNCTION__, crc32_csum, crc32_check);
1298 release_firmware(fw_entry);
1297 return -1; 1299 return -1;
1298 } 1300 }
1299 memcpy(idstring, &firmware[36], 20); 1301 memcpy(idstring, &firmware[36], 20);
@@ -1308,15 +1310,19 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1308 1310
1309 result = ttusb_dec_send_command(dec, 0x41, sizeof(b0), b0, NULL, NULL); 1311 result = ttusb_dec_send_command(dec, 0x41, sizeof(b0), b0, NULL, NULL);
1310 1312
1311 if (result) 1313 if (result) {
1314 release_firmware(fw_entry);
1312 return result; 1315 return result;
1316 }
1313 1317
1314 trans_count = 0; 1318 trans_count = 0;
1315 j = 0; 1319 j = 0;
1316 1320
1317 b = kmalloc(ARM_PACKET_SIZE, GFP_KERNEL); 1321 b = kmalloc(ARM_PACKET_SIZE, GFP_KERNEL);
1318 if (b == NULL) 1322 if (b == NULL) {
1323 release_firmware(fw_entry);
1319 return -ENOMEM; 1324 return -ENOMEM;
1325 }
1320 1326
1321 for (i = 0; i < firmware_size; i += COMMAND_PACKET_SIZE) { 1327 for (i = 0; i < firmware_size; i += COMMAND_PACKET_SIZE) {
1322 size = firmware_size - i; 1328 size = firmware_size - i;
@@ -1345,6 +1351,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1345 1351
1346 result = ttusb_dec_send_command(dec, 0x43, sizeof(b1), b1, NULL, NULL); 1352 result = ttusb_dec_send_command(dec, 0x43, sizeof(b1), b1, NULL, NULL);
1347 1353
1354 release_firmware(fw_entry);
1348 kfree(b); 1355 kfree(b);
1349 1356
1350 return result; 1357 return result;
diff --git a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
index 1699cc9f6bb0..725af3af5b27 100644
--- a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
+++ b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
@@ -157,7 +157,8 @@ struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* conf
157 157
158 /* allocate memory for the internal state */ 158 /* allocate memory for the internal state */
159 state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); 159 state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
160 if (state == NULL) goto error; 160 if (state == NULL)
161 return NULL;
161 162
162 /* setup the state */ 163 /* setup the state */
163 state->config = config; 164 state->config = config;
@@ -167,10 +168,6 @@ struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* conf
167 state->frontend.ops = &state->ops; 168 state->frontend.ops = &state->ops;
168 state->frontend.demodulator_priv = state; 169 state->frontend.demodulator_priv = state;
169 return &state->frontend; 170 return &state->frontend;
170
171error:
172 kfree(state);
173 return NULL;
174} 171}
175 172
176static struct dvb_frontend_ops ttusbdecfe_dvbs_ops; 173static struct dvb_frontend_ops ttusbdecfe_dvbs_ops;
@@ -181,7 +178,8 @@ struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* conf
181 178
182 /* allocate memory for the internal state */ 179 /* allocate memory for the internal state */
183 state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); 180 state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
184 if (state == NULL) goto error; 181 if (state == NULL)
182 return NULL;
185 183
186 /* setup the state */ 184 /* setup the state */
187 state->config = config; 185 state->config = config;
@@ -193,10 +191,6 @@ struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* conf
193 state->frontend.ops = &state->ops; 191 state->frontend.ops = &state->ops;
194 state->frontend.demodulator_priv = state; 192 state->frontend.demodulator_priv = state;
195 return &state->frontend; 193 return &state->frontend;
196
197error:
198 kfree(state);
199 return NULL;
200} 194}
201 195
202static struct dvb_frontend_ops ttusbdecfe_dvbt_ops = { 196static struct dvb_frontend_ops ttusbdecfe_dvbt_ops = {
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 1b70f8b0feb9..f461750c7646 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -7,19 +7,6 @@ menu "Video For Linux"
7 7
8comment "Video Adapters" 8comment "Video Adapters"
9 9
10config TUNER_MULTI_I2C
11 bool "Enable support for multiple I2C devices on Video Adapters (EXPERIMENTAL)"
12 depends on VIDEO_DEV && EXPERIMENTAL
13 ---help---
14 Some video adapters have more than one tuner inside. This patch
15 enables support for using more than one tuner. This is required
16 for some cards to allow tunning both video and radio.
17 It also improves I2C autodetection for these cards.
18
19 Only few tuners currently is supporting this. More to come.
20
21 It is safe to say 'Y' here even if your card has only one I2C tuner.
22
23config VIDEO_BT848 10config VIDEO_BT848
24 tristate "BT848 Video For Linux" 11 tristate "BT848 Video For Linux"
25 depends on VIDEO_DEV && PCI && I2C 12 depends on VIDEO_DEV && PCI && I2C
@@ -344,6 +331,7 @@ config VIDEO_CX88_DVB
344 select DVB_MT352 331 select DVB_MT352
345 select DVB_OR51132 332 select DVB_OR51132
346 select DVB_CX22702 333 select DVB_CX22702
334 select DVB_LGDT3302
347 ---help--- 335 ---help---
348 This adds support for DVB/ATSC cards based on the 336 This adds support for DVB/ATSC cards based on the
349 Connexant 2388x chip. 337 Connexant 2388x chip.
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index 9a642c7de545..a070417e65e6 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -138,25 +138,13 @@ int bt832_init(struct i2c_client *i2c_client_s)
138 138
139 bt832_hexdump(i2c_client_s,buf); 139 bt832_hexdump(i2c_client_s,buf);
140 140
141#if 0
142 // Full 30/25 Frame rate
143 printk("Full 30/25 Frame rate\n");
144 buf[0]=BT832_VP_CONTROL0; // Reg.39
145 buf[1]= 0x00;
146 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
147 printk("bt832: i2c i/o error FFR: rc == %d (should be 2)\n",rc);
148
149 bt832_hexdump(i2c_client_s,buf);
150#endif
151 141
152#if 1
153 // for testing (even works when no camera attached) 142 // for testing (even works when no camera attached)
154 printk("bt832: *** Generate NTSC M Bars *****\n"); 143 printk("bt832: *** Generate NTSC M Bars *****\n");
155 buf[0]=BT832_VP_TESTCONTROL0; // Reg. 42 144 buf[0]=BT832_VP_TESTCONTROL0; // Reg. 42
156 buf[1]=3; // Generate NTSC System M bars, Generate Frame timing internally 145 buf[1]=3; // Generate NTSC System M bars, Generate Frame timing internally
157 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 146 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
158 printk("bt832: i2c i/o error MBAR: rc == %d (should be 2)\n",rc); 147 printk("bt832: i2c i/o error MBAR: rc == %d (should be 2)\n",rc);
159#endif
160 148
161 printk("Bt832: Camera Present: %s\n", 149 printk("Bt832: Camera Present: %s\n",
162 (buf[1+BT832_CAM_STATUS] & BT832_56_CAMERA_PRESENT) ? "yes":"no"); 150 (buf[1+BT832_CAM_STATUS] & BT832_56_CAMERA_PRESENT) ? "yes":"no");
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
index 251092e7f19f..2dbf5ec43abd 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bttv-cards.c
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: bttv-cards.c,v 1.49 2005/06/10 17:20:24 mchehab Exp $ 2 $Id: bttv-cards.c,v 1.53 2005/07/05 17:37:35 nsh Exp $
3 3
4 bttv-cards.c 4 bttv-cards.c
5 5
@@ -39,9 +39,6 @@
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#include "bttvp.h" 41#include "bttvp.h"
42#if 0 /* not working yet */
43#include "bt832.h"
44#endif
45 42
46/* fwd decl */ 43/* fwd decl */
47static void boot_msp34xx(struct bttv *btv, int pin); 44static void boot_msp34xx(struct bttv *btv, int pin);
@@ -513,13 +510,8 @@ struct tvcard bttv_tvcards[] = {
513 .svhs = 2, 510 .svhs = 2,
514 .gpiomask = 0x01fe00, 511 .gpiomask = 0x01fe00,
515 .muxsel = { 2, 3, 1, 1}, 512 .muxsel = { 2, 3, 1, 1},
516#if 0
517 // old
518 .audiomux = { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 },
519#else
520 // 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru> 513 // 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru>
521 .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, 514 .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 },
522#endif
523 .needs_tvaudio = 1, 515 .needs_tvaudio = 1,
524 .pll = PLL_28, 516 .pll = PLL_28,
525 .tuner_type = -1, 517 .tuner_type = -1,
@@ -766,14 +758,9 @@ struct tvcard bttv_tvcards[] = {
766 .tuner = 0, 758 .tuner = 0,
767 .svhs = 2, 759 .svhs = 2,
768 .muxsel = { 2, 3, 1, 1, 0}, // TV, CVid, SVid, CVid over SVid connector 760 .muxsel = { 2, 3, 1, 1, 0}, // TV, CVid, SVid, CVid over SVid connector
769#if 0
770 .gpiomask = 0xc33000,
771 .audiomux = { 0x422000,0x1000,0x0000,0x620000,0x800000 },
772#else
773 /* Alexander Varakin <avarakin@hotmail.com> [stereo version] */ 761 /* Alexander Varakin <avarakin@hotmail.com> [stereo version] */
774 .gpiomask = 0xb33000, 762 .gpiomask = 0xb33000,
775 .audiomux = { 0x122000,0x1000,0x0000,0x620000,0x800000 }, 763 .audiomux = { 0x122000,0x1000,0x0000,0x620000,0x800000 },
776#endif
777 /* Audio Routing for "WinFast 2000 XP" (no tv stereo !) 764 /* Audio Routing for "WinFast 2000 XP" (no tv stereo !)
778 gpio23 -- hef4052:nEnable (0x800000) 765 gpio23 -- hef4052:nEnable (0x800000)
779 gpio12 -- hef4052:A1 766 gpio12 -- hef4052:A1
@@ -1603,20 +1590,11 @@ struct tvcard bttv_tvcards[] = {
1603 .video_inputs = 4, 1590 .video_inputs = 4,
1604 .audio_inputs = 1, 1591 .audio_inputs = 1,
1605 .tuner = -1, 1592 .tuner = -1,
1606#if 0 /* TODO ... */
1607 .svhs = OSPREY540_SVID_ANALOG,
1608 .muxsel = { [OSPREY540_COMP_ANALOG] = 2,
1609 [OSPREY540_SVID_ANALOG] = 3, },
1610#endif
1611 .pll = PLL_28, 1593 .pll = PLL_28,
1612 .tuner_type = -1, 1594 .tuner_type = -1,
1613 .no_msp34xx = 1, 1595 .no_msp34xx = 1,
1614 .no_tda9875 = 1, 1596 .no_tda9875 = 1,
1615 .no_tda7432 = 1, 1597 .no_tda7432 = 1,
1616#if 0 /* TODO ... */
1617 .muxsel_hook = osprey_540_muxsel,
1618 .picture_hook = osprey_540_set_picture,
1619#endif
1620},{ 1598},{
1621 1599
1622 /* ---- card 0x5C ---------------------------------- */ 1600 /* ---- card 0x5C ---------------------------------- */
@@ -2546,21 +2524,12 @@ static void eagle_muxsel(struct bttv *btv, unsigned int input)
2546 btaor((2)<<5, ~(3<<5), BT848_IFORM); 2524 btaor((2)<<5, ~(3<<5), BT848_IFORM);
2547 gpio_bits(3,bttv_tvcards[btv->c.type].muxsel[input&7]); 2525 gpio_bits(3,bttv_tvcards[btv->c.type].muxsel[input&7]);
2548 2526
2549#if 0
2550 /* svhs */
2551 /* wake chroma ADC */
2552 btand(~BT848_ADC_C_SLEEP, BT848_ADC);
2553 /* set to YC video */
2554 btor(BT848_CONTROL_COMP, BT848_E_CONTROL);
2555 btor(BT848_CONTROL_COMP, BT848_O_CONTROL);
2556#else
2557 /* composite */ 2527 /* composite */
2558 /* set chroma ADC to sleep */ 2528 /* set chroma ADC to sleep */
2559 btor(BT848_ADC_C_SLEEP, BT848_ADC); 2529 btor(BT848_ADC_C_SLEEP, BT848_ADC);
2560 /* set to composite video */ 2530 /* set to composite video */
2561 btand(~BT848_CONTROL_COMP, BT848_E_CONTROL); 2531 btand(~BT848_CONTROL_COMP, BT848_E_CONTROL);
2562 btand(~BT848_CONTROL_COMP, BT848_O_CONTROL); 2532 btand(~BT848_CONTROL_COMP, BT848_O_CONTROL);
2563#endif
2564 2533
2565 /* switch sync drive off */ 2534 /* switch sync drive off */
2566 gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE); 2535 gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE);
@@ -2813,10 +2782,18 @@ void __devinit bttv_init_card2(struct bttv *btv)
2813 btv->tuner_type = tuner[btv->c.nr]; 2782 btv->tuner_type = tuner[btv->c.nr];
2814 printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type); 2783 printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type);
2815 if (btv->pinnacle_id != UNSET) 2784 if (btv->pinnacle_id != UNSET)
2816 bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE, 2785 bttv_call_i2c_clients(btv, AUDC_CONFIG_PINNACLE,
2817 &btv->pinnacle_id); 2786 &btv->pinnacle_id);
2818 if (btv->tuner_type != UNSET) 2787 if (btv->tuner_type != UNSET) {
2819 bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type); 2788 struct tuner_setup tun_setup;
2789
2790 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
2791 tun_setup.type = btv->tuner_type;
2792 tun_setup.addr = ADDR_UNSET;
2793
2794 bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup);
2795 }
2796
2820 btv->svhs = bttv_tvcards[btv->c.type].svhs; 2797 btv->svhs = bttv_tvcards[btv->c.type].svhs;
2821 if (svhs[btv->c.nr] != UNSET) 2798 if (svhs[btv->c.nr] != UNSET)
2822 btv->svhs = svhs[btv->c.nr]; 2799 btv->svhs = svhs[btv->c.nr];
@@ -3125,14 +3102,6 @@ static int tuner_0_table[] = {
3125 TUNER_PHILIPS_SECAM, TUNER_PHILIPS_SECAM, 3102 TUNER_PHILIPS_SECAM, TUNER_PHILIPS_SECAM,
3126 TUNER_PHILIPS_SECAM, TUNER_PHILIPS_PAL, 3103 TUNER_PHILIPS_SECAM, TUNER_PHILIPS_PAL,
3127 TUNER_PHILIPS_FM1216ME_MK3 }; 3104 TUNER_PHILIPS_FM1216ME_MK3 };
3128#if 0
3129int tuner_0_fm_table[] = {
3130 PHILIPS_FR1236_NTSC, PHILIPS_FR1216_PAL,
3131 PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
3132 PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
3133 PHILIPS_FR1236_SECAM, PHILIPS_FR1236_SECAM,
3134 PHILIPS_FR1236_SECAM, PHILIPS_FR1216_PAL};
3135#endif
3136 3105
3137static int tuner_1_table[] = { 3106static int tuner_1_table[] = {
3138 TUNER_TEMIC_NTSC, TUNER_TEMIC_PAL, 3107 TUNER_TEMIC_NTSC, TUNER_TEMIC_PAL,
@@ -3218,36 +3187,6 @@ static void __devinit boot_msp34xx(struct bttv *btv, int pin)
3218 3187
3219static void __devinit boot_bt832(struct bttv *btv) 3188static void __devinit boot_bt832(struct bttv *btv)
3220{ 3189{
3221#if 0 /* not working yet */
3222 int resetbit=0;
3223
3224 switch (btv->c.type) {
3225 case BTTV_PXELVWPLTVPAK:
3226 resetbit = 0x400000;
3227 break;
3228 case BTTV_MODTEC_205:
3229 resetbit = 1<<9;
3230 break;
3231 default:
3232 BUG();
3233 }
3234
3235 request_module("bt832");
3236 bttv_call_i2c_clients(btv, BT832_HEXDUMP, NULL);
3237
3238 printk("bttv%d: Reset Bt832 [line=0x%x]\n",btv->c.nr,resetbit);
3239 gpio_write(0);
3240 gpio_inout(resetbit, resetbit);
3241 udelay(5);
3242 gpio_bits(resetbit, resetbit);
3243 udelay(5);
3244 gpio_bits(resetbit, 0);
3245 udelay(5);
3246
3247 // bt832 on pixelview changes from i2c 0x8a to 0x88 after
3248 // being reset as above. So we must follow by this:
3249 bttv_call_i2c_clients(btv, BT832_REATTACH, NULL);
3250#endif
3251} 3190}
3252 3191
3253/* ----------------------------------------------------------------------- */ 3192/* ----------------------------------------------------------------------- */
@@ -3572,11 +3511,6 @@ void tea5757_set_freq(struct bttv *btv, unsigned short freq)
3572{ 3511{
3573 dprintk("tea5757_set_freq %d\n",freq); 3512 dprintk("tea5757_set_freq %d\n",freq);
3574 tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */ 3513 tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */
3575#if 0
3576 /* breaks Miro PCTV */
3577 value = tea5757_read(btv);
3578 dprintk("bttv%d: tea5757 readback=0x%x\n",btv->c.nr,value);
3579#endif
3580} 3514}
3581 3515
3582 3516
@@ -3656,13 +3590,8 @@ gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set)
3656{ 3590{
3657 unsigned int val, con; 3591 unsigned int val, con;
3658 3592
3659#if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3660 if (btv->radio_user) 3593 if (btv->radio_user)
3661 return; 3594 return;
3662#else
3663 if (btv->radio)
3664 return;
3665#endif
3666 3595
3667 val = gpio_read(); 3596 val = gpio_read();
3668 if (set) { 3597 if (set) {
@@ -3851,13 +3780,8 @@ pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set)
3851{ 3780{
3852 unsigned int val = 0; 3781 unsigned int val = 0;
3853 3782
3854#if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3855 if (btv->radio_user) 3783 if (btv->radio_user)
3856 return; 3784 return;
3857#else
3858 if (btv->radio)
3859 return;
3860#endif
3861 3785
3862 if (set) { 3786 if (set) {
3863 if (v->mode & VIDEO_SOUND_MONO) { 3787 if (v->mode & VIDEO_SOUND_MONO) {
@@ -3888,13 +3812,8 @@ fv2000s_audio(struct bttv *btv, struct video_audio *v, int set)
3888{ 3812{
3889 unsigned int val = 0xffff; 3813 unsigned int val = 0xffff;
3890 3814
3891#if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3892 if (btv->radio_user) 3815 if (btv->radio_user)
3893 return; 3816 return;
3894#else
3895 if (btv->radio)
3896 return;
3897#endif
3898 if (set) { 3817 if (set) {
3899 if (v->mode & VIDEO_SOUND_MONO) { 3818 if (v->mode & VIDEO_SOUND_MONO) {
3900 val = 0x0000; 3819 val = 0x0000;
@@ -4371,11 +4290,6 @@ void __devinit bttv_check_chipset(void)
4371 latency = 0x0A; 4290 latency = 0x0A;
4372#endif 4291#endif
4373 4292
4374#if 0
4375 /* print which chipset we have */
4376 while ((dev = pci_find_class(PCI_CLASS_BRIDGE_HOST << 8,dev)))
4377 printk(KERN_INFO "bttv: Host bridge is %s\n",pci_name(dev));
4378#endif
4379 4293
4380 /* print warnings about any quirks found */ 4294 /* print warnings about any quirks found */
4381 if (triton1) 4295 if (triton1)
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index 7d62b394c509..51a0f6d68e73 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: bttv-driver.c,v 1.40 2005/06/16 21:38:45 nsh Exp $ 2 $Id: bttv-driver.c,v 1.42 2005/07/05 17:37:35 nsh Exp $
3 3
4 bttv - Bt848 frame grabber driver 4 bttv - Bt848 frame grabber driver
5 5
@@ -35,6 +35,7 @@
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/kdev_t.h> 37#include <linux/kdev_t.h>
38#include <linux/dma-mapping.h>
38 39
39#include <asm/io.h> 40#include <asm/io.h>
40#include <asm/byteorder.h> 41#include <asm/byteorder.h>
@@ -698,12 +699,10 @@ int locked_btres(struct bttv *btv, int bit)
698static 699static
699void free_btres(struct bttv *btv, struct bttv_fh *fh, int bits) 700void free_btres(struct bttv *btv, struct bttv_fh *fh, int bits)
700{ 701{
701#if 1 /* DEBUG */
702 if ((fh->resources & bits) != bits) { 702 if ((fh->resources & bits) != bits) {
703 /* trying to free ressources not allocated by us ... */ 703 /* trying to free ressources not allocated by us ... */
704 printk("bttv: BUG! (btres)\n"); 704 printk("bttv: BUG! (btres)\n");
705 } 705 }
706#endif
707 down(&btv->reslock); 706 down(&btv->reslock);
708 fh->resources &= ~bits; 707 fh->resources &= ~bits;
709 btv->resources &= ~bits; 708 btv->resources &= ~bits;
@@ -943,11 +942,6 @@ audio_mux(struct bttv *btv, int mode)
943 i2c_mux = mux = (btv->audio & AUDIO_MUTE) ? AUDIO_OFF : btv->audio; 942 i2c_mux = mux = (btv->audio & AUDIO_MUTE) ? AUDIO_OFF : btv->audio;
944 if (btv->opt_automute && !signal && !btv->radio_user) 943 if (btv->opt_automute && !signal && !btv->radio_user)
945 mux = AUDIO_OFF; 944 mux = AUDIO_OFF;
946#if 0
947 printk("bttv%d: amux: mode=%d audio=%d signal=%s mux=%d/%d irq=%s\n",
948 btv->c.nr, mode, btv->audio, signal ? "yes" : "no",
949 mux, i2c_mux, in_interrupt() ? "yes" : "no");
950#endif
951 945
952 val = bttv_tvcards[btv->c.type].audiomux[mux]; 946 val = bttv_tvcards[btv->c.type].audiomux[mux];
953 gpio_bits(bttv_tvcards[btv->c.type].gpiomask,val); 947 gpio_bits(bttv_tvcards[btv->c.type].gpiomask,val);
@@ -994,11 +988,6 @@ set_tvnorm(struct bttv *btv, unsigned int norm)
994 case BTTV_VOODOOTV_FM: 988 case BTTV_VOODOOTV_FM:
995 bttv_tda9880_setnorm(btv,norm); 989 bttv_tda9880_setnorm(btv,norm);
996 break; 990 break;
997#if 0
998 case BTTV_OSPREY540:
999 osprey_540_set_norm(btv,norm);
1000 break;
1001#endif
1002 } 991 }
1003 return 0; 992 return 0;
1004} 993}
@@ -1849,7 +1838,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1849 1838
1850 if (unlikely(f->tuner != 0)) 1839 if (unlikely(f->tuner != 0))
1851 return -EINVAL; 1840 return -EINVAL;
1852 if (unlikely(f->type != V4L2_TUNER_ANALOG_TV)) 1841 if (unlikely (f->type != V4L2_TUNER_ANALOG_TV))
1853 return -EINVAL; 1842 return -EINVAL;
1854 down(&btv->lock); 1843 down(&btv->lock);
1855 btv->freq = f->frequency; 1844 btv->freq = f->frequency;
@@ -3865,7 +3854,7 @@ static int __devinit bttv_probe(struct pci_dev *dev,
3865 btv->c.nr); 3854 btv->c.nr);
3866 return -EIO; 3855 return -EIO;
3867 } 3856 }
3868 if (pci_set_dma_mask(dev, 0xffffffff)) { 3857 if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) {
3869 printk(KERN_WARNING "bttv%d: No suitable DMA available.\n", 3858 printk(KERN_WARNING "bttv%d: No suitable DMA available.\n",
3870 btv->c.nr); 3859 btv->c.nr);
3871 return -EIO; 3860 return -EIO;
diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c
index da448a5f9e9c..234a85563769 100644
--- a/drivers/media/video/bttv-i2c.c
+++ b/drivers/media/video/bttv-i2c.c
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: bttv-i2c.c,v 1.21 2005/06/10 17:20:24 mchehab Exp $ 2 $Id: bttv-i2c.c,v 1.25 2005/07/05 17:37:35 nsh Exp $
3 3
4 bttv-i2c.c -- all the i2c code is here 4 bttv-i2c.c -- all the i2c code is here
5 5
@@ -295,14 +295,26 @@ static int attach_inform(struct i2c_client *client)
295{ 295{
296 struct bttv *btv = i2c_get_adapdata(client->adapter); 296 struct bttv *btv = i2c_get_adapdata(client->adapter);
297 297
298 if (btv->tuner_type != UNSET) 298 if (bttv_debug)
299 bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type); 299 printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n",
300 btv->c.nr,client->driver->name,client->addr,
301 i2c_clientname(client));
302 if (!client->driver->command)
303 return 0;
304
305 if (btv->tuner_type != UNSET) {
306 struct tuner_setup tun_setup;
307
308 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
309 tun_setup.type = btv->tuner_type;
310 tun_setup.addr = ADDR_UNSET;
311
312 client->driver->command (client, TUNER_SET_TYPE_ADDR, &tun_setup);
313 }
314
300 if (btv->pinnacle_id != UNSET) 315 if (btv->pinnacle_id != UNSET)
301 bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE, 316 client->driver->command(client,AUDC_CONFIG_PINNACLE,
302 &btv->pinnacle_id); 317 &btv->pinnacle_id);
303 if (bttv_debug)
304 printk("bttv%d: i2c attach [client=%s]\n",
305 btv->c.nr, i2c_clientname(client));
306 return 0; 318 return 0;
307} 319}
308 320
diff --git a/drivers/media/video/bttv-risc.c b/drivers/media/video/bttv-risc.c
index bdc5ce6c43b9..9ed21fd190c6 100644
--- a/drivers/media/video/bttv-risc.c
+++ b/drivers/media/video/bttv-risc.c
@@ -334,10 +334,6 @@ bttv_calc_geo(struct bttv *btv, struct bttv_geometry *geo,
334 } 334 }
335 335
336 vdelay = tvnorm->vdelay; 336 vdelay = tvnorm->vdelay;
337#if 0 /* FIXME */
338 if (vdelay < btv->vbi.lines*2)
339 vdelay = btv->vbi.lines*2;
340#endif
341 337
342 xsf = (width*scaledtwidth)/swidth; 338 xsf = (width*scaledtwidth)/swidth;
343 geo->hscale = ((totalwidth*4096UL)/xsf-4096); 339 geo->hscale = ((totalwidth*4096UL)/xsf-4096);
@@ -776,13 +772,8 @@ bttv_overlay_risc(struct bttv *btv,
776 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 0, 0); 772 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 0, 0);
777 break; 773 break;
778 case V4L2_FIELD_INTERLACED: 774 case V4L2_FIELD_INTERLACED:
779#if 0
780 bttv_risc_overlay(btv, &buf->top, fmt, ov, 1, 0);
781 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 0, 1);
782#else
783 bttv_risc_overlay(btv, &buf->top, fmt, ov, 0, 1); 775 bttv_risc_overlay(btv, &buf->top, fmt, ov, 0, 1);
784 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 1, 0); 776 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 1, 0);
785#endif
786 break; 777 break;
787 default: 778 default:
788 BUG(); 779 BUG();
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 91f8afeded88..4f39688f780a 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -690,11 +690,9 @@ static void blackbird_codec_settings(struct cx8802_dev *dev)
690 int bitrate_mode = 1; 690 int bitrate_mode = 1;
691 int bitrate = 7500000; 691 int bitrate = 7500000;
692 int bitrate_peak = 7500000; 692 int bitrate_peak = 7500000;
693#if 1
694 bitrate_mode = BLACKBIRD_VIDEO_CBR; 693 bitrate_mode = BLACKBIRD_VIDEO_CBR;
695 bitrate = 4000*1024; 694 bitrate = 4000*1024;
696 bitrate_peak = 4000*1024; 695 bitrate_peak = 4000*1024;
697#endif
698 696
699 /* assign stream type */ 697 /* assign stream type */
700 blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_PROGRAM); 698 blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_PROGRAM);
@@ -810,9 +808,6 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
810 cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */ 808 cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */
811 cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */ 809 cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */
812 810
813#if 0 /* FIXME */
814 set_scale(dev, 720, 480, V4L2_FIELD_INTERLACED);
815#endif
816 blackbird_codec_settings(dev); 811 blackbird_codec_settings(dev);
817 msleep(1); 812 msleep(1);
818 813
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index b3fb04356b71..b0b47c3cde3c 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-cards.c,v 1.76 2005/06/08 01:28:09 mchehab Exp $ 2 * $Id: cx88-cards.c,v 1.85 2005/07/04 19:35:05 mkrufky Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * card-specific stuff. 5 * card-specific stuff.
@@ -401,7 +401,7 @@ struct cx88_board cx88_boards[] = {
401 .dvb = 1, 401 .dvb = 1,
402 }, 402 },
403 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = { 403 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = {
404 .name = "DVICO FusionHDTV DVB-T1", 404 .name = "DViCO FusionHDTV DVB-T1",
405 .tuner_type = TUNER_ABSENT, /* No analog tuner */ 405 .tuner_type = TUNER_ABSENT, /* No analog tuner */
406 .radio_type = UNSET, 406 .radio_type = UNSET,
407 .tuner_addr = ADDR_UNSET, 407 .tuner_addr = ADDR_UNSET,
@@ -445,8 +445,8 @@ struct cx88_board cx88_boards[] = {
445 .gpio0 = 0x000007f8, 445 .gpio0 = 0x000007f8,
446 }, 446 },
447 }, 447 },
448 [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD] = { 448 [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q] = {
449 .name = "DViCO - FusionHDTV 3 Gold", 449 .name = "DViCO FusionHDTV 3 Gold-Q",
450 .tuner_type = TUNER_MICROTUNE_4042FI5, 450 .tuner_type = TUNER_MICROTUNE_4042FI5,
451 .radio_type = UNSET, 451 .radio_type = UNSET,
452 .tuner_addr = ADDR_UNSET, 452 .tuner_addr = ADDR_UNSET,
@@ -464,6 +464,9 @@ struct cx88_board cx88_boards[] = {
464 GPIO[3] selects RF input connector on tuner module 464 GPIO[3] selects RF input connector on tuner module
465 0 - RF connector labeled CABLE 465 0 - RF connector labeled CABLE
466 1 - RF connector labeled ANT 466 1 - RF connector labeled ANT
467 GPIO[4] selects high RF for QAM256 mode
468 0 - normal RF
469 1 - high RF
467 */ 470 */
468 .input = {{ 471 .input = {{
469 .type = CX88_VMUX_TELEVISION, 472 .type = CX88_VMUX_TELEVISION,
@@ -482,6 +485,7 @@ struct cx88_board cx88_boards[] = {
482 .vmux = 2, 485 .vmux = 2,
483 .gpio0 = 0x0f00, 486 .gpio0 = 0x0f00,
484 }}, 487 }},
488 .dvb = 1,
485 }, 489 },
486 [CX88_BOARD_HAUPPAUGE_DVB_T1] = { 490 [CX88_BOARD_HAUPPAUGE_DVB_T1] = {
487 .name = "Hauppauge Nova-T DVB-T", 491 .name = "Hauppauge Nova-T DVB-T",
@@ -520,7 +524,7 @@ struct cx88_board cx88_boards[] = {
520 .blackbird = 1, 524 .blackbird = 1,
521 }, 525 },
522 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = { 526 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = {
523 .name = "DVICO FusionHDTV DVB-T Plus", 527 .name = "DViCO FusionHDTV DVB-T Plus",
524 .tuner_type = TUNER_ABSENT, /* No analog tuner */ 528 .tuner_type = TUNER_ABSENT, /* No analog tuner */
525 .radio_type = UNSET, 529 .radio_type = UNSET,
526 .tuner_addr = ADDR_UNSET, 530 .tuner_addr = ADDR_UNSET,
@@ -700,21 +704,17 @@ struct cx88_board cx88_boards[] = {
700 }, 704 },
701 }, 705 },
702 [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T] = { 706 [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T] = {
703 .name = "DViCO - FusionHDTV 3 Gold-T", 707 .name = "DViCO FusionHDTV 3 Gold-T",
704 .tuner_type = TUNER_THOMSON_DTT7611, 708 .tuner_type = TUNER_THOMSON_DTT7611,
705 .radio_type = UNSET, 709 .radio_type = UNSET,
706 .tuner_addr = ADDR_UNSET, 710 .tuner_addr = ADDR_UNSET,
707 .radio_addr = ADDR_UNSET, 711 .radio_addr = ADDR_UNSET,
708 /* See DViCO FusionHDTV 3 Gold for GPIO documentation. */ 712 /* See DViCO FusionHDTV 3 Gold-Q for GPIO documentation. */
709 .input = {{ 713 .input = {{
710 .type = CX88_VMUX_TELEVISION, 714 .type = CX88_VMUX_TELEVISION,
711 .vmux = 0, 715 .vmux = 0,
712 .gpio0 = 0x0f0d, 716 .gpio0 = 0x0f0d,
713 },{ 717 },{
714 .type = CX88_VMUX_CABLE,
715 .vmux = 0,
716 .gpio0 = 0x0f05,
717 },{
718 .type = CX88_VMUX_COMPOSITE1, 718 .type = CX88_VMUX_COMPOSITE1,
719 .vmux = 1, 719 .vmux = 1,
720 .gpio0 = 0x0f00, 720 .gpio0 = 0x0f00,
@@ -723,7 +723,36 @@ struct cx88_board cx88_boards[] = {
723 .vmux = 2, 723 .vmux = 2,
724 .gpio0 = 0x0f00, 724 .gpio0 = 0x0f00,
725 }}, 725 }},
726 .dvb = 1,
726 }, 727 },
728 [CX88_BOARD_ADSTECH_DVB_T_PCI] = {
729 .name = "ADS Tech Instant TV DVB-T PCI",
730 .tuner_type = TUNER_ABSENT,
731 .radio_type = UNSET,
732 .tuner_addr = ADDR_UNSET,
733 .radio_addr = ADDR_UNSET,
734 .input = {{
735 .type = CX88_VMUX_COMPOSITE1,
736 .vmux = 1,
737 .gpio0 = 0x0700,
738 .gpio2 = 0x0101,
739 },{
740 .type = CX88_VMUX_SVIDEO,
741 .vmux = 2,
742 .gpio0 = 0x0700,
743 .gpio2 = 0x0101,
744 }},
745 .dvb = 1,
746 },
747 [CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1] = {
748 .name = "TerraTec Cinergy 1400 DVB-T",
749 .tuner_type = TUNER_ABSENT,
750 .input = {{
751 .type = CX88_VMUX_DVB,
752 .vmux = 0,
753 }},
754 .dvb = 1,
755 },
727}; 756};
728const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); 757const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
729 758
@@ -794,7 +823,7 @@ struct cx88_subid cx88_subids[] = {
794 },{ 823 },{
795 .subvendor = 0x18ac, 824 .subvendor = 0x18ac,
796 .subdevice = 0xd810, 825 .subdevice = 0xd810,
797 .card = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD, 826 .card = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q,
798 },{ 827 },{
799 .subvendor = 0x18ac, 828 .subvendor = 0x18ac,
800 .subdevice = 0xd820, 829 .subdevice = 0xd820,
@@ -843,7 +872,15 @@ struct cx88_subid cx88_subids[] = {
843 .subvendor = 0x10fc, 872 .subvendor = 0x10fc,
844 .subdevice = 0xd035, 873 .subdevice = 0xd035,
845 .card = CX88_BOARD_IODATA_GVBCTV7E, 874 .card = CX88_BOARD_IODATA_GVBCTV7E,
846 } 875 },{
876 .subvendor = 0x1421,
877 .subdevice = 0x0334,
878 .card = CX88_BOARD_ADSTECH_DVB_T_PCI,
879 },{
880 .subvendor = 0x153b,
881 .subdevice = 0x1166,
882 .card = CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1,
883 },
847}; 884};
848const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); 885const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
849 886
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index c046a23537d3..5e868f5cd0c0 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-core.c,v 1.28 2005/06/12 04:19:19 mchehab Exp $ 2 * $Id: cx88-core.c,v 1.33 2005/07/07 14:17:47 mchehab Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * driver core 5 * driver core
@@ -470,25 +470,6 @@ int cx88_risc_decode(u32 risc)
470 return incr[risc >> 28] ? incr[risc >> 28] : 1; 470 return incr[risc >> 28] ? incr[risc >> 28] : 1;
471} 471}
472 472
473#if 0 /* currently unused, but useful for debugging */
474void cx88_risc_disasm(struct cx88_core *core,
475 struct btcx_riscmem *risc)
476{
477 unsigned int i,j,n;
478
479 printk("%s: risc disasm: %p [dma=0x%08lx]\n",
480 core->name, risc->cpu, (unsigned long)risc->dma);
481 for (i = 0; i < (risc->size >> 2); i += n) {
482 printk("%s: %04d: ", core->name, i);
483 n = cx88_risc_decode(risc->cpu[i]);
484 for (j = 1; j < n; j++)
485 printk("%s: %04d: 0x%08x [ arg #%d ]\n",
486 core->name, i+j, risc->cpu[i+j], j);
487 if (risc->cpu[i] == RISC_JUMP)
488 break;
489 }
490}
491#endif
492 473
493void cx88_sram_channel_dump(struct cx88_core *core, 474void cx88_sram_channel_dump(struct cx88_core *core,
494 struct sram_channel *ch) 475 struct sram_channel *ch)
@@ -551,21 +532,6 @@ static char *cx88_pci_irqs[32] = {
551 "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err", 532 "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
552 "i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1" 533 "i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1"
553}; 534};
554char *cx88_vid_irqs[32] = {
555 "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
556 "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
557 "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
558 "y_sync", "u_sync", "v_sync", "vbi_sync",
559 "opc_err", "par_err", "rip_err", "pci_abort",
560};
561char *cx88_mpeg_irqs[32] = {
562 "ts_risci1", NULL, NULL, NULL,
563 "ts_risci2", NULL, NULL, NULL,
564 "ts_oflow", NULL, NULL, NULL,
565 "ts_sync", NULL, NULL, NULL,
566 "opc_err", "par_err", "rip_err", "pci_abort",
567 "ts_err?",
568};
569 535
570void cx88_print_irqbits(char *name, char *tag, char **strings, 536void cx88_print_irqbits(char *name, char *tag, char **strings,
571 u32 bits, u32 mask) 537 u32 bits, u32 mask)
@@ -615,16 +581,11 @@ void cx88_wakeup(struct cx88_core *core,
615 break; 581 break;
616 buf = list_entry(q->active.next, 582 buf = list_entry(q->active.next,
617 struct cx88_buffer, vb.queue); 583 struct cx88_buffer, vb.queue);
618#if 0
619 if (buf->count > count)
620 break;
621#else
622 /* count comes from the hw and is is 16bit wide -- 584 /* count comes from the hw and is is 16bit wide --
623 * this trick handles wrap-arounds correctly for 585 * this trick handles wrap-arounds correctly for
624 * up to 32767 buffers in flight... */ 586 * up to 32767 buffers in flight... */
625 if ((s16) (count - buf->count) < 0) 587 if ((s16) (count - buf->count) < 0)
626 break; 588 break;
627#endif
628 do_gettimeofday(&buf->vb.ts); 589 do_gettimeofday(&buf->vb.ts);
629 dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i, 590 dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i,
630 count, buf->count); 591 count, buf->count);
@@ -952,12 +913,10 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
952 norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); 913 norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
953 cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat); 914 cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat);
954 915
955#if 1
956 // FIXME: as-is from DScaler 916 // FIXME: as-is from DScaler
957 dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n", 917 dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
958 norm->cxoformat, cx_read(MO_OUTPUT_FORMAT)); 918 norm->cxoformat, cx_read(MO_OUTPUT_FORMAT));
959 cx_write(MO_OUTPUT_FORMAT, norm->cxoformat); 919 cx_write(MO_OUTPUT_FORMAT, norm->cxoformat);
960#endif
961 920
962 // MO_SCONV_REG = adc clock / video dec clock * 2^17 921 // MO_SCONV_REG = adc clock / video dec clock * 2^17
963 tmp64 = adc_clock * (u64)(1 << 17); 922 tmp64 = adc_clock * (u64)(1 << 17);
@@ -1006,21 +965,7 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
1006 set_tvaudio(core); 965 set_tvaudio(core);
1007 966
1008 // tell i2c chips 967 // tell i2c chips
1009#ifdef V4L2_I2C_CLIENTS
1010 cx88_call_i2c_clients(core,VIDIOC_S_STD,&norm->id); 968 cx88_call_i2c_clients(core,VIDIOC_S_STD,&norm->id);
1011#else
1012 {
1013 struct video_channel c;
1014 memset(&c,0,sizeof(c));
1015 c.channel = core->input;
1016 c.norm = VIDEO_MODE_PAL;
1017 if ((norm->id & (V4L2_STD_NTSC_M|V4L2_STD_NTSC_M_JP)))
1018 c.norm = VIDEO_MODE_NTSC;
1019 if (norm->id & V4L2_STD_SECAM)
1020 c.norm = VIDEO_MODE_SECAM;
1021 cx88_call_i2c_clients(core,VIDIOCSCHAN,&c);
1022 }
1023#endif
1024 969
1025 // done 970 // done
1026 return 0; 971 return 0;
@@ -1230,8 +1175,6 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
1230/* ------------------------------------------------------------------ */ 1175/* ------------------------------------------------------------------ */
1231 1176
1232EXPORT_SYMBOL(cx88_print_ioctl); 1177EXPORT_SYMBOL(cx88_print_ioctl);
1233EXPORT_SYMBOL(cx88_vid_irqs);
1234EXPORT_SYMBOL(cx88_mpeg_irqs);
1235EXPORT_SYMBOL(cx88_print_irqbits); 1178EXPORT_SYMBOL(cx88_print_irqbits);
1236 1179
1237EXPORT_SYMBOL(cx88_core_irq); 1180EXPORT_SYMBOL(cx88_core_irq);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 1a259c3966cd..8db68f2d1351 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-dvb.c,v 1.33 2005/06/12 04:19:19 mchehab Exp $ 2 * $Id: cx88-dvb.c,v 1.41 2005/07/04 19:35:05 mkrufky Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * MPEG Transport Stream (DVB) routines 5 * MPEG Transport Stream (DVB) routines
@@ -30,20 +30,27 @@
30#include <linux/file.h> 30#include <linux/file.h>
31#include <linux/suspend.h> 31#include <linux/suspend.h>
32 32
33/* those two frontends need merging via linuxtv cvs ... */ 33#define CONFIG_DVB_MT352 1
34#define HAVE_CX22702 1 34#define CONFIG_DVB_CX22702 1
35#define HAVE_OR51132 1 35#define CONFIG_DVB_OR51132 1
36#define CONFIG_DVB_LGDT3302 1
36 37
37#include "cx88.h" 38#include "cx88.h"
38#include "dvb-pll.h" 39#include "dvb-pll.h"
39#include "mt352.h" 40
40#include "mt352_priv.h" 41#if CONFIG_DVB_MT352
41#if HAVE_CX22702 42# include "mt352.h"
43# include "mt352_priv.h"
44#endif
45#if CONFIG_DVB_CX22702
42# include "cx22702.h" 46# include "cx22702.h"
43#endif 47#endif
44#if HAVE_OR51132 48#if CONFIG_DVB_OR51132
45# include "or51132.h" 49# include "or51132.h"
46#endif 50#endif
51#if CONFIG_DVB_LGDT3302
52# include "lgdt3302.h"
53#endif
47 54
48MODULE_DESCRIPTION("driver for cx2388x based DVB cards"); 55MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
49MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); 56MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
@@ -100,6 +107,7 @@ static struct videobuf_queue_ops dvb_qops = {
100 107
101/* ------------------------------------------------------------------ */ 108/* ------------------------------------------------------------------ */
102 109
110#if CONFIG_DVB_MT352
103static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) 111static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
104{ 112{
105 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 }; 113 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
@@ -167,8 +175,9 @@ static struct mt352_config dntv_live_dvbt_config = {
167 .demod_init = dntv_live_dvbt_demod_init, 175 .demod_init = dntv_live_dvbt_demod_init,
168 .pll_set = mt352_pll_set, 176 .pll_set = mt352_pll_set,
169}; 177};
178#endif
170 179
171#if HAVE_CX22702 180#if CONFIG_DVB_CX22702
172static struct cx22702_config connexant_refboard_config = { 181static struct cx22702_config connexant_refboard_config = {
173 .demod_address = 0x43, 182 .demod_address = 0x43,
174 .pll_address = 0x60, 183 .pll_address = 0x60,
@@ -182,7 +191,7 @@ static struct cx22702_config hauppauge_novat_config = {
182}; 191};
183#endif 192#endif
184 193
185#if HAVE_OR51132 194#if CONFIG_DVB_OR51132
186static int or51132_set_ts_param(struct dvb_frontend* fe, 195static int or51132_set_ts_param(struct dvb_frontend* fe,
187 int is_punctured) 196 int is_punctured)
188{ 197{
@@ -199,6 +208,32 @@ static struct or51132_config pchdtv_hd3000 = {
199}; 208};
200#endif 209#endif
201 210
211#if CONFIG_DVB_LGDT3302
212static int lgdt3302_set_ts_param(struct dvb_frontend* fe, int is_punctured)
213{
214 struct cx8802_dev *dev= fe->dvb->priv;
215 if (is_punctured)
216 dev->ts_gen_cntrl |= 0x04;
217 else
218 dev->ts_gen_cntrl &= ~0x04;
219 return 0;
220}
221
222static struct lgdt3302_config fusionhdtv_3_gold_q = {
223 .demod_address = 0x0e,
224 .pll_address = 0x61,
225 .pll_desc = &dvb_pll_microtune_4042,
226 .set_ts_params = lgdt3302_set_ts_param,
227};
228
229static struct lgdt3302_config fusionhdtv_3_gold_t = {
230 .demod_address = 0x0e,
231 .pll_address = 0x61,
232 .pll_desc = &dvb_pll_thomson_dtt7611,
233 .set_ts_params = lgdt3302_set_ts_param,
234};
235#endif
236
202static int dvb_register(struct cx8802_dev *dev) 237static int dvb_register(struct cx8802_dev *dev)
203{ 238{
204 /* init struct videobuf_dvb */ 239 /* init struct videobuf_dvb */
@@ -207,16 +242,18 @@ static int dvb_register(struct cx8802_dev *dev)
207 242
208 /* init frontend */ 243 /* init frontend */
209 switch (dev->core->board) { 244 switch (dev->core->board) {
210#if HAVE_CX22702 245#if CONFIG_DVB_CX22702
211 case CX88_BOARD_HAUPPAUGE_DVB_T1: 246 case CX88_BOARD_HAUPPAUGE_DVB_T1:
212 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config, 247 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config,
213 &dev->core->i2c_adap); 248 &dev->core->i2c_adap);
214 break; 249 break;
250 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
215 case CX88_BOARD_CONEXANT_DVB_T1: 251 case CX88_BOARD_CONEXANT_DVB_T1:
216 dev->dvb.frontend = cx22702_attach(&connexant_refboard_config, 252 dev->dvb.frontend = cx22702_attach(&connexant_refboard_config,
217 &dev->core->i2c_adap); 253 &dev->core->i2c_adap);
218 break; 254 break;
219#endif 255#endif
256#if CONFIG_DVB_MT352
220 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 257 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
221 dev->core->pll_addr = 0x61; 258 dev->core->pll_addr = 0x61;
222 dev->core->pll_desc = &dvb_pll_lg_z201; 259 dev->core->pll_desc = &dvb_pll_lg_z201;
@@ -231,17 +268,49 @@ static int dvb_register(struct cx8802_dev *dev)
231 break; 268 break;
232 case CX88_BOARD_KWORLD_DVB_T: 269 case CX88_BOARD_KWORLD_DVB_T:
233 case CX88_BOARD_DNTV_LIVE_DVB_T: 270 case CX88_BOARD_DNTV_LIVE_DVB_T:
271 case CX88_BOARD_ADSTECH_DVB_T_PCI:
234 dev->core->pll_addr = 0x61; 272 dev->core->pll_addr = 0x61;
235 dev->core->pll_desc = &dvb_pll_unknown_1; 273 dev->core->pll_desc = &dvb_pll_unknown_1;
236 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config, 274 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
237 &dev->core->i2c_adap); 275 &dev->core->i2c_adap);
238 break; 276 break;
239#if HAVE_OR51132 277#endif
278#if CONFIG_DVB_OR51132
240 case CX88_BOARD_PCHDTV_HD3000: 279 case CX88_BOARD_PCHDTV_HD3000:
241 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000, 280 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000,
242 &dev->core->i2c_adap); 281 &dev->core->i2c_adap);
243 break; 282 break;
244#endif 283#endif
284#if CONFIG_DVB_LGDT3302
285 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
286 dev->ts_gen_cntrl = 0x08;
287 {
288 /* Do a hardware reset of chip before using it. */
289 struct cx88_core *core = dev->core;
290
291 cx_clear(MO_GP0_IO, 1);
292 mdelay(100);
293 cx_set(MO_GP0_IO, 9); // ANT connector too FIXME
294 mdelay(200);
295 dev->dvb.frontend = lgdt3302_attach(&fusionhdtv_3_gold_q,
296 &dev->core->i2c_adap);
297 }
298 break;
299 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
300 dev->ts_gen_cntrl = 0x08;
301 {
302 /* Do a hardware reset of chip before using it. */
303 struct cx88_core *core = dev->core;
304
305 cx_clear(MO_GP0_IO, 1);
306 mdelay(100);
307 cx_set(MO_GP0_IO, 9); /* ANT connector too FIXME */
308 mdelay(200);
309 dev->dvb.frontend = lgdt3302_attach(&fusionhdtv_3_gold_t,
310 &dev->core->i2c_adap);
311 }
312 break;
313#endif
245 default: 314 default:
246 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", 315 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
247 dev->core->name); 316 dev->core->name);
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index e20adefcfc6c..8403c4e95050 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: cx88-i2c.c,v 1.23 2005/06/12 04:19:19 mchehab Exp $ 2 $Id: cx88-i2c.c,v 1.28 2005/07/05 17:37:35 nsh Exp $
3 3
4 cx88-i2c.c -- all the i2c code is here 4 cx88-i2c.c -- all the i2c code is here
5 5
@@ -91,25 +91,32 @@ static int cx8800_bit_getsda(void *data)
91 91
92static int attach_inform(struct i2c_client *client) 92static int attach_inform(struct i2c_client *client)
93{ 93{
94 struct tuner_addr tun_addr; 94 struct tuner_setup tun_setup;
95 struct cx88_core *core = i2c_get_adapdata(client->adapter); 95 struct cx88_core *core = i2c_get_adapdata(client->adapter);
96 96
97 dprintk(1, "i2c attach [addr=0x%x,client=%s]\n", 97 dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
98 client->addr, i2c_clientname(client)); 98 client->driver->name,client->addr,i2c_clientname(client));
99 if (!client->driver->command) 99 if (!client->driver->command)
100 return 0; 100 return 0;
101 101
102 if (core->radio_type != UNSET) { 102 if (core->radio_type != UNSET) {
103 tun_addr.v4l2_tuner = V4L2_TUNER_RADIO; 103 if ((core->radio_addr==ADDR_UNSET)||(core->radio_addr==client->addr)) {
104 tun_addr.type = core->radio_type; 104 tun_setup.mode_mask = T_RADIO;
105 tun_addr.addr = core->radio_addr; 105 tun_setup.type = core->radio_type;
106 client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr); 106 tun_setup.addr = core->radio_addr;
107
108 client->driver->command (client, TUNER_SET_TYPE_ADDR, &tun_setup);
109 }
107 } 110 }
108 if (core->tuner_type != UNSET) { 111 if (core->tuner_type != UNSET) {
109 tun_addr.v4l2_tuner = V4L2_TUNER_ANALOG_TV; 112 if ((core->tuner_addr==ADDR_UNSET)||(core->tuner_addr==client->addr)) {
110 tun_addr.type = core->tuner_type; 113
111 tun_addr.addr = core->tuner_addr; 114 tun_setup.mode_mask = T_ANALOG_TV;
112 client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr); 115 tun_setup.type = core->tuner_type;
116 tun_setup.addr = core->tuner_addr;
117
118 client->driver->command (client,TUNER_SET_TYPE_ADDR, &tun_setup);
119 }
113 } 120 }
114 121
115 if (core->tda9887_conf) 122 if (core->tda9887_conf)
@@ -157,6 +164,7 @@ static struct i2c_client cx8800_i2c_client_template = {
157}; 164};
158 165
159static char *i2c_devs[128] = { 166static char *i2c_devs[128] = {
167 [ 0x1c >> 1 ] = "lgdt3302",
160 [ 0x86 >> 1 ] = "tda9887/cx22702", 168 [ 0x86 >> 1 ] = "tda9887/cx22702",
161 [ 0xa0 >> 1 ] = "eeprom", 169 [ 0xa0 >> 1 ] = "eeprom",
162 [ 0xc0 >> 1 ] = "tuner (analog)", 170 [ 0xc0 >> 1 ] = "tuner (analog)",
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index dc0dcf249aac..214887798192 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-input.c,v 1.11 2005/05/22 20:57:56 nsh Exp $ 2 * $Id: cx88-input.c,v 1.15 2005/07/07 13:58:38 mchehab Exp $
3 * 3 *
4 * Device driver for GPIO attached remote control interfaces 4 * Device driver for GPIO attached remote control interfaces
5 * on Conexant 2388x based TV/DVB cards. 5 * on Conexant 2388x based TV/DVB cards.
@@ -38,119 +38,206 @@
38 38
39/* DigitalNow DNTV Live DVB-T Remote */ 39/* DigitalNow DNTV Live DVB-T Remote */
40static IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = { 40static IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = {
41 [ 0x00 ] = KEY_ESC, // 'go up a level?' 41 [0x00] = KEY_ESC, /* 'go up a level?' */
42 [ 0x01 ] = KEY_KP1, // '1' 42 /* Keys 0 to 9 */
43 [ 0x02 ] = KEY_KP2, // '2' 43 [0x0a] = KEY_KP0,
44 [ 0x03 ] = KEY_KP3, // '3' 44 [0x01] = KEY_KP1,
45 [ 0x04 ] = KEY_KP4, // '4' 45 [0x02] = KEY_KP2,
46 [ 0x05 ] = KEY_KP5, // '5' 46 [0x03] = KEY_KP3,
47 [ 0x06 ] = KEY_KP6, // '6' 47 [0x04] = KEY_KP4,
48 [ 0x07 ] = KEY_KP7, // '7' 48 [0x05] = KEY_KP5,
49 [ 0x08 ] = KEY_KP8, // '8' 49 [0x06] = KEY_KP6,
50 [ 0x09 ] = KEY_KP9, // '9' 50 [0x07] = KEY_KP7,
51 [ 0x0a ] = KEY_KP0, // '0' 51 [0x08] = KEY_KP8,
52 [ 0x0b ] = KEY_TUNER, // 'tv/fm' 52 [0x09] = KEY_KP9,
53 [ 0x0c ] = KEY_SEARCH, // 'scan' 53
54 [ 0x0d ] = KEY_STOP, // 'stop' 54 [0x0b] = KEY_TUNER, /* tv/fm */
55 [ 0x0e ] = KEY_PAUSE, // 'pause' 55 [0x0c] = KEY_SEARCH, /* scan */
56 [ 0x0f ] = KEY_LIST, // 'source' 56 [0x0d] = KEY_STOP,
57 57 [0x0e] = KEY_PAUSE,
58 [ 0x10 ] = KEY_MUTE, // 'mute' 58 [0x0f] = KEY_LIST, /* source */
59 [ 0x11 ] = KEY_REWIND, // 'backward <<' 59
60 [ 0x12 ] = KEY_POWER, // 'power' 60 [0x10] = KEY_MUTE,
61 [ 0x13 ] = KEY_S, // 'snap' 61 [0x11] = KEY_REWIND, /* backward << */
62 [ 0x14 ] = KEY_AUDIO, // 'stereo' 62 [0x12] = KEY_POWER,
63 [ 0x15 ] = KEY_CLEAR, // 'reset' 63 [0x13] = KEY_S, /* snap */
64 [ 0x16 ] = KEY_PLAY, // 'play' 64 [0x14] = KEY_AUDIO, /* stereo */
65 [ 0x17 ] = KEY_ENTER, // 'enter' 65 [0x15] = KEY_CLEAR, /* reset */
66 [ 0x18 ] = KEY_ZOOM, // 'full screen' 66 [0x16] = KEY_PLAY,
67 [ 0x19 ] = KEY_FASTFORWARD, // 'forward >>' 67 [0x17] = KEY_ENTER,
68 [ 0x1a ] = KEY_CHANNELUP, // 'channel +' 68 [0x18] = KEY_ZOOM, /* full screen */
69 [ 0x1b ] = KEY_VOLUMEUP, // 'volume +' 69 [0x19] = KEY_FASTFORWARD, /* forward >> */
70 [ 0x1c ] = KEY_INFO, // 'preview' 70 [0x1a] = KEY_CHANNELUP,
71 [ 0x1d ] = KEY_RECORD, // 'record' 71 [0x1b] = KEY_VOLUMEUP,
72 [ 0x1e ] = KEY_CHANNELDOWN, // 'channel -' 72 [0x1c] = KEY_INFO, /* preview */
73 [ 0x1f ] = KEY_VOLUMEDOWN, // 'volume -' 73 [0x1d] = KEY_RECORD, /* record */
74 [0x1e] = KEY_CHANNELDOWN,
75 [0x1f] = KEY_VOLUMEDOWN,
74}; 76};
75 77
76/* ---------------------------------------------------------------------- */ 78/* ---------------------------------------------------------------------- */
77 79
78/* IO-DATA BCTV7E Remote */ 80/* IO-DATA BCTV7E Remote */
79static IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE] = { 81static IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE] = {
80 [ 0x40 ] = KEY_TV, // TV 82 [0x40] = KEY_TV,
81 [ 0x20 ] = KEY_RADIO, // FM 83 [0x20] = KEY_RADIO, /* FM */
82 [ 0x60 ] = KEY_EPG, // EPG 84 [0x60] = KEY_EPG,
83 [ 0x00 ] = KEY_POWER, // power 85 [0x00] = KEY_POWER,
84 86
85 [ 0x50 ] = KEY_KP1, // 1 87 /* Keys 0 to 9 */
86 [ 0x30 ] = KEY_KP2, // 2 88 [0x44] = KEY_KP0, /* 10 */
87 [ 0x70 ] = KEY_KP3, // 3 89 [0x50] = KEY_KP1,
88 [ 0x10 ] = KEY_L, // Live 90 [0x30] = KEY_KP2,
89 91 [0x70] = KEY_KP3,
90 [ 0x48 ] = KEY_KP4, // 4 92 [0x48] = KEY_KP4,
91 [ 0x28 ] = KEY_KP5, // 5 93 [0x28] = KEY_KP5,
92 [ 0x68 ] = KEY_KP6, // 6 94 [0x68] = KEY_KP6,
93 [ 0x08 ] = KEY_T, // Time Shift 95 [0x58] = KEY_KP7,
94 96 [0x38] = KEY_KP8,
95 [ 0x58 ] = KEY_KP7, // 7 97 [0x78] = KEY_KP9,
96 [ 0x38 ] = KEY_KP8, // 8 98
97 [ 0x78 ] = KEY_KP9, // 9 99 [0x10] = KEY_L, /* Live */
98 [ 0x18 ] = KEY_PLAYPAUSE, // Play 100 [0x08] = KEY_T, /* Time Shift */
99 101
100 [ 0x44 ] = KEY_KP0, // 10 102 [0x18] = KEY_PLAYPAUSE, /* Play */
101 [ 0x24 ] = KEY_ENTER, // 11 103
102 [ 0x64 ] = KEY_ESC, // 12 104 [0x24] = KEY_ENTER, /* 11 */
103 [ 0x04 ] = KEY_M, // Multi 105 [0x64] = KEY_ESC, /* 12 */
104 106 [0x04] = KEY_M, /* Multi */
105 [ 0x54 ] = KEY_VIDEO, // VIDEO 107
106 [ 0x34 ] = KEY_CHANNELUP, // channel + 108 [0x54] = KEY_VIDEO,
107 [ 0x74 ] = KEY_VOLUMEUP, // volume + 109 [0x34] = KEY_CHANNELUP,
108 [ 0x14 ] = KEY_MUTE, // Mute 110 [0x74] = KEY_VOLUMEUP,
109 111 [0x14] = KEY_MUTE,
110 [ 0x4c ] = KEY_S, // SVIDEO 112
111 [ 0x2c ] = KEY_CHANNELDOWN, // channel - 113 [0x4c] = KEY_S, /* SVIDEO */
112 [ 0x6c ] = KEY_VOLUMEDOWN, // volume - 114 [0x2c] = KEY_CHANNELDOWN,
113 [ 0x0c ] = KEY_ZOOM, // Zoom 115 [0x6c] = KEY_VOLUMEDOWN,
114 116 [0x0c] = KEY_ZOOM,
115 [ 0x5c ] = KEY_PAUSE, // pause 117
116 [ 0x3c ] = KEY_C, // || (red) 118 [0x5c] = KEY_PAUSE,
117 [ 0x7c ] = KEY_RECORD, // recording 119 [0x3c] = KEY_C, /* || (red) */
118 [ 0x1c ] = KEY_STOP, // stop 120 [0x7c] = KEY_RECORD, /* recording */
119 121 [0x1c] = KEY_STOP,
120 [ 0x41 ] = KEY_REWIND, // backward << 122
121 [ 0x21 ] = KEY_PLAY, // play 123 [0x41] = KEY_REWIND, /* backward << */
122 [ 0x61 ] = KEY_FASTFORWARD, // forward >> 124 [0x21] = KEY_PLAY,
123 [ 0x01 ] = KEY_NEXT, // skip >| 125 [0x61] = KEY_FASTFORWARD, /* forward >> */
126 [0x01] = KEY_NEXT, /* skip >| */
127};
128
129/* ---------------------------------------------------------------------- */
130
131/* ADS Tech Instant TV DVB-T PCI Remote */
132static IR_KEYTAB_TYPE ir_codes_adstech_dvb_t_pci[IR_KEYTAB_SIZE] = {
133 /* Keys 0 to 9 */
134 [0x4d] = KEY_0,
135 [0x57] = KEY_1,
136 [0x4f] = KEY_2,
137 [0x53] = KEY_3,
138 [0x56] = KEY_4,
139 [0x4e] = KEY_5,
140 [0x5e] = KEY_6,
141 [0x54] = KEY_7,
142 [0x4c] = KEY_8,
143 [0x5c] = KEY_9,
144
145 [0x5b] = KEY_POWER,
146 [0x5f] = KEY_MUTE,
147 [0x55] = KEY_GOTO,
148 [0x5d] = KEY_SEARCH,
149 [0x17] = KEY_EPG, /* Guide */
150 [0x1f] = KEY_MENU,
151 [0x0f] = KEY_UP,
152 [0x46] = KEY_DOWN,
153 [0x16] = KEY_LEFT,
154 [0x1e] = KEY_RIGHT,
155 [0x0e] = KEY_SELECT, /* Enter */
156 [0x5a] = KEY_INFO,
157 [0x52] = KEY_EXIT,
158 [0x59] = KEY_PREVIOUS,
159 [0x51] = KEY_NEXT,
160 [0x58] = KEY_REWIND,
161 [0x50] = KEY_FORWARD,
162 [0x44] = KEY_PLAYPAUSE,
163 [0x07] = KEY_STOP,
164 [0x1b] = KEY_RECORD,
165 [0x13] = KEY_TUNER, /* Live */
166 [0x0a] = KEY_A,
167 [0x12] = KEY_B,
168 [0x03] = KEY_PROG1, /* 1 */
169 [0x01] = KEY_PROG2, /* 2 */
170 [0x00] = KEY_PROG3, /* 3 */
171 [0x06] = KEY_DVD,
172 [0x48] = KEY_AUX, /* Photo */
173 [0x40] = KEY_VIDEO,
174 [0x19] = KEY_AUDIO, /* Music */
175 [0x0b] = KEY_CHANNELUP,
176 [0x08] = KEY_CHANNELDOWN,
177 [0x15] = KEY_VOLUMEUP,
178 [0x1c] = KEY_VOLUMEDOWN,
179};
180
181/* ---------------------------------------------------------------------- */
182
183/* MSI TV@nywhere remote */
184static IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = {
185 /* Keys 0 to 9 */
186 [0x00] = KEY_0,
187 [0x01] = KEY_1,
188 [0x02] = KEY_2,
189 [0x03] = KEY_3,
190 [0x04] = KEY_4,
191 [0x05] = KEY_5,
192 [0x06] = KEY_6,
193 [0x07] = KEY_7,
194 [0x08] = KEY_8,
195 [0x09] = KEY_9,
196
197 [0x0c] = KEY_MUTE,
198 [0x0f] = KEY_SCREEN, /* Full Screen */
199 [0x10] = KEY_F, /* Funtion */
200 [0x11] = KEY_T, /* Time shift */
201 [0x12] = KEY_POWER,
202 [0x13] = KEY_MEDIA, /* MTS */
203 [0x14] = KEY_SLOW,
204 [0x16] = KEY_REWIND, /* backward << */
205 [0x17] = KEY_ENTER, /* Return */
206 [0x18] = KEY_FASTFORWARD, /* forward >> */
207 [0x1a] = KEY_CHANNELUP,
208 [0x1b] = KEY_VOLUMEUP,
209 [0x1e] = KEY_CHANNELDOWN,
210 [0x1f] = KEY_VOLUMEDOWN,
124}; 211};
125 212
126/* ---------------------------------------------------------------------- */ 213/* ---------------------------------------------------------------------- */
127 214
128struct cx88_IR { 215struct cx88_IR {
129 struct cx88_core *core; 216 struct cx88_core *core;
130 struct input_dev input; 217 struct input_dev input;
131 struct ir_input_state ir; 218 struct ir_input_state ir;
132 char name[32]; 219 char name[32];
133 char phys[32]; 220 char phys[32];
134 221
135 /* sample from gpio pin 16 */ 222 /* sample from gpio pin 16 */
136 int sampling; 223 int sampling;
137 u32 samples[16]; 224 u32 samples[16];
138 int scount; 225 int scount;
139 unsigned long release; 226 unsigned long release;
140 227
141 /* poll external decoder */ 228 /* poll external decoder */
142 int polling; 229 int polling;
143 struct work_struct work; 230 struct work_struct work;
144 struct timer_list timer; 231 struct timer_list timer;
145 u32 gpio_addr; 232 u32 gpio_addr;
146 u32 last_gpio; 233 u32 last_gpio;
147 u32 mask_keycode; 234 u32 mask_keycode;
148 u32 mask_keydown; 235 u32 mask_keydown;
149 u32 mask_keyup; 236 u32 mask_keyup;
150}; 237};
151 238
152static int ir_debug = 0; 239static int ir_debug = 0;
153module_param(ir_debug, int, 0644); /* debug level [IR] */ 240module_param(ir_debug, int, 0644); /* debug level [IR] */
154MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); 241MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
155 242
156#define ir_dprintk(fmt, arg...) if (ir_debug) \ 243#define ir_dprintk(fmt, arg...) if (ir_debug) \
@@ -174,37 +261,37 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
174 /* extract data */ 261 /* extract data */
175 data = ir_extract_bits(gpio, ir->mask_keycode); 262 data = ir_extract_bits(gpio, ir->mask_keycode);
176 ir_dprintk("irq gpio=0x%x code=%d | %s%s%s\n", 263 ir_dprintk("irq gpio=0x%x code=%d | %s%s%s\n",
177 gpio, data, 264 gpio, data,
178 ir->polling ? "poll" : "irq", 265 ir->polling ? "poll" : "irq",
179 (gpio & ir->mask_keydown) ? " down" : "", 266 (gpio & ir->mask_keydown) ? " down" : "",
180 (gpio & ir->mask_keyup) ? " up" : ""); 267 (gpio & ir->mask_keyup) ? " up" : "");
181 268
182 if (ir->mask_keydown) { 269 if (ir->mask_keydown) {
183 /* bit set on keydown */ 270 /* bit set on keydown */
184 if (gpio & ir->mask_keydown) { 271 if (gpio & ir->mask_keydown) {
185 ir_input_keydown(&ir->input,&ir->ir,data,data); 272 ir_input_keydown(&ir->input, &ir->ir, data, data);
186 } else { 273 } else {
187 ir_input_nokey(&ir->input,&ir->ir); 274 ir_input_nokey(&ir->input, &ir->ir);
188 } 275 }
189 276
190 } else if (ir->mask_keyup) { 277 } else if (ir->mask_keyup) {
191 /* bit cleared on keydown */ 278 /* bit cleared on keydown */
192 if (0 == (gpio & ir->mask_keyup)) { 279 if (0 == (gpio & ir->mask_keyup)) {
193 ir_input_keydown(&ir->input,&ir->ir,data,data); 280 ir_input_keydown(&ir->input, &ir->ir, data, data);
194 } else { 281 } else {
195 ir_input_nokey(&ir->input,&ir->ir); 282 ir_input_nokey(&ir->input, &ir->ir);
196 } 283 }
197 284
198 } else { 285 } else {
199 /* can't distinguish keydown/up :-/ */ 286 /* can't distinguish keydown/up :-/ */
200 ir_input_keydown(&ir->input,&ir->ir,data,data); 287 ir_input_keydown(&ir->input, &ir->ir, data, data);
201 ir_input_nokey(&ir->input,&ir->ir); 288 ir_input_nokey(&ir->input, &ir->ir);
202 } 289 }
203} 290}
204 291
205static void ir_timer(unsigned long data) 292static void ir_timer(unsigned long data)
206{ 293{
207 struct cx88_IR *ir = (struct cx88_IR*)data; 294 struct cx88_IR *ir = (struct cx88_IR *)data;
208 295
209 schedule_work(&ir->work); 296 schedule_work(&ir->work);
210} 297}
@@ -227,47 +314,61 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
227 IR_KEYTAB_TYPE *ir_codes = NULL; 314 IR_KEYTAB_TYPE *ir_codes = NULL;
228 int ir_type = IR_TYPE_OTHER; 315 int ir_type = IR_TYPE_OTHER;
229 316
230 ir = kmalloc(sizeof(*ir),GFP_KERNEL); 317 ir = kmalloc(sizeof(*ir), GFP_KERNEL);
231 if (NULL == ir) 318 if (NULL == ir)
232 return -ENOMEM; 319 return -ENOMEM;
233 memset(ir,0,sizeof(*ir)); 320 memset(ir, 0, sizeof(*ir));
234 321
235 /* detect & configure */ 322 /* detect & configure */
236 switch (core->board) { 323 switch (core->board) {
237 case CX88_BOARD_DNTV_LIVE_DVB_T: 324 case CX88_BOARD_DNTV_LIVE_DVB_T:
238 case CX88_BOARD_KWORLD_DVB_T: 325 case CX88_BOARD_KWORLD_DVB_T:
239 ir_codes = ir_codes_dntv_live_dvb_t; 326 ir_codes = ir_codes_dntv_live_dvb_t;
240 ir->gpio_addr = MO_GP1_IO; 327 ir->gpio_addr = MO_GP1_IO;
241 ir->mask_keycode = 0x1f; 328 ir->mask_keycode = 0x1f;
242 ir->mask_keyup = 0x60; 329 ir->mask_keyup = 0x60;
243 ir->polling = 50; // ms 330 ir->polling = 50; /* ms */
244 break; 331 break;
245 case CX88_BOARD_HAUPPAUGE: 332 case CX88_BOARD_HAUPPAUGE:
246 case CX88_BOARD_HAUPPAUGE_DVB_T1: 333 case CX88_BOARD_HAUPPAUGE_DVB_T1:
247 ir_codes = ir_codes_hauppauge_new; 334 ir_codes = ir_codes_hauppauge_new;
248 ir_type = IR_TYPE_RC5; 335 ir_type = IR_TYPE_RC5;
249 ir->sampling = 1; 336 ir->sampling = 1;
250 break; 337 break;
251 case CX88_BOARD_WINFAST2000XP_EXPERT: 338 case CX88_BOARD_WINFAST2000XP_EXPERT:
252 ir_codes = ir_codes_winfast; 339 ir_codes = ir_codes_winfast;
253 ir->gpio_addr = MO_GP0_IO; 340 ir->gpio_addr = MO_GP0_IO;
254 ir->mask_keycode = 0x8f8; 341 ir->mask_keycode = 0x8f8;
255 ir->mask_keyup = 0x100; 342 ir->mask_keyup = 0x100;
256 ir->polling = 1; // ms 343 ir->polling = 1; /* ms */
257 break; 344 break;
258 case CX88_BOARD_IODATA_GVBCTV7E: 345 case CX88_BOARD_IODATA_GVBCTV7E:
259 ir_codes = ir_codes_iodata_bctv7e; 346 ir_codes = ir_codes_iodata_bctv7e;
260 ir->gpio_addr = MO_GP0_IO; 347 ir->gpio_addr = MO_GP0_IO;
261 ir->mask_keycode = 0xfd; 348 ir->mask_keycode = 0xfd;
262 ir->mask_keydown = 0x02; 349 ir->mask_keydown = 0x02;
263 ir->polling = 5; // ms 350 ir->polling = 5; /* ms */
264 break; 351 break;
265 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO: 352 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
266 ir_codes = ir_codes_pixelview; 353 ir_codes = ir_codes_pixelview;
267 ir->gpio_addr = MO_GP1_IO; 354 ir->gpio_addr = MO_GP1_IO;
355 ir->mask_keycode = 0x1f;
356 ir->mask_keyup = 0x80;
357 ir->polling = 1; /* ms */
358 break;
359 case CX88_BOARD_ADSTECH_DVB_T_PCI:
360 ir_codes = ir_codes_adstech_dvb_t_pci;
361 ir->gpio_addr = MO_GP1_IO;
362 ir->mask_keycode = 0xbf;
363 ir->mask_keyup = 0x40;
364 ir->polling = 50; /* ms */
365 break;
366 case CX88_BOARD_MSI_TVANYWHERE_MASTER:
367 ir_codes = ir_codes_msi_tvanywhere;
368 ir->gpio_addr = MO_GP1_IO;
268 ir->mask_keycode = 0x1f; 369 ir->mask_keycode = 0x1f;
269 ir->mask_keyup = 0x80; 370 ir->mask_keyup = 0x40;
270 ir->polling = 1; // ms 371 ir->polling = 1; /* ms */
271 break; 372 break;
272 } 373 }
273 374
@@ -279,8 +380,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
279 /* init input device */ 380 /* init input device */
280 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", 381 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)",
281 cx88_boards[core->board].name); 382 cx88_boards[core->board].name);
282 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 383 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
283 pci_name(pci));
284 384
285 ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes); 385 ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes);
286 ir->input.name = ir->name; 386 ir->input.name = ir->name;
@@ -288,10 +388,10 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
288 ir->input.id.bustype = BUS_PCI; 388 ir->input.id.bustype = BUS_PCI;
289 ir->input.id.version = 1; 389 ir->input.id.version = 1;
290 if (pci->subsystem_vendor) { 390 if (pci->subsystem_vendor) {
291 ir->input.id.vendor = pci->subsystem_vendor; 391 ir->input.id.vendor = pci->subsystem_vendor;
292 ir->input.id.product = pci->subsystem_device; 392 ir->input.id.product = pci->subsystem_device;
293 } else { 393 } else {
294 ir->input.id.vendor = pci->vendor; 394 ir->input.id.vendor = pci->vendor;
295 ir->input.id.product = pci->device; 395 ir->input.id.product = pci->device;
296 } 396 }
297 397
@@ -303,13 +403,13 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
303 INIT_WORK(&ir->work, cx88_ir_work, ir); 403 INIT_WORK(&ir->work, cx88_ir_work, ir);
304 init_timer(&ir->timer); 404 init_timer(&ir->timer);
305 ir->timer.function = ir_timer; 405 ir->timer.function = ir_timer;
306 ir->timer.data = (unsigned long)ir; 406 ir->timer.data = (unsigned long)ir;
307 schedule_work(&ir->work); 407 schedule_work(&ir->work);
308 } 408 }
309 if (ir->sampling) { 409 if (ir->sampling) {
310 core->pci_irqmask |= (1<<18); // IR_SMP_INT 410 core->pci_irqmask |= (1 << 18); /* IR_SMP_INT */
311 cx_write(MO_DDS_IO, 0xa80a80); // 4 kHz sample rate 411 cx_write(MO_DDS_IO, 0xa80a80); /* 4 kHz sample rate */
312 cx_write(MO_DDSCFG_IO, 0x5); // enable 412 cx_write(MO_DDSCFG_IO, 0x5); /* enable */
313 } 413 }
314 414
315 /* all done */ 415 /* all done */
@@ -345,7 +445,7 @@ int cx88_ir_fini(struct cx88_core *core)
345void cx88_ir_irq(struct cx88_core *core) 445void cx88_ir_irq(struct cx88_core *core)
346{ 446{
347 struct cx88_IR *ir = core->ir; 447 struct cx88_IR *ir = core->ir;
348 u32 samples,rc5; 448 u32 samples, rc5;
349 int i; 449 int i;
350 450
351 if (NULL == ir) 451 if (NULL == ir)
@@ -354,7 +454,7 @@ void cx88_ir_irq(struct cx88_core *core)
354 return; 454 return;
355 455
356 samples = cx_read(MO_SAMPLE_IO); 456 samples = cx_read(MO_SAMPLE_IO);
357 if (0 != samples && 0xffffffff != samples) { 457 if (0 != samples && 0xffffffff != samples) {
358 /* record sample data */ 458 /* record sample data */
359 if (ir->scount < ARRAY_SIZE(ir->samples)) 459 if (ir->scount < ARRAY_SIZE(ir->samples))
360 ir->samples[ir->scount++] = samples; 460 ir->samples[ir->scount++] = samples;
@@ -362,8 +462,8 @@ void cx88_ir_irq(struct cx88_core *core)
362 } 462 }
363 if (!ir->scount) { 463 if (!ir->scount) {
364 /* nothing to sample */ 464 /* nothing to sample */
365 if (ir->ir.keypressed && time_after(jiffies,ir->release)) 465 if (ir->ir.keypressed && time_after(jiffies, ir->release))
366 ir_input_nokey(&ir->input,&ir->ir); 466 ir_input_nokey(&ir->input, &ir->ir);
367 return; 467 return;
368 } 468 }
369 469
@@ -373,14 +473,14 @@ void cx88_ir_irq(struct cx88_core *core)
373 for (i = 0; i < ir->scount; i++) 473 for (i = 0; i < ir->scount; i++)
374 ir->samples[i] = ~ir->samples[i]; 474 ir->samples[i] = ~ir->samples[i];
375 if (ir_debug) 475 if (ir_debug)
376 ir_dump_samples(ir->samples,ir->scount); 476 ir_dump_samples(ir->samples, ir->scount);
377 477
378 /* decode it */ 478 /* decode it */
379 switch (core->board) { 479 switch (core->board) {
380 case CX88_BOARD_HAUPPAUGE: 480 case CX88_BOARD_HAUPPAUGE:
381 case CX88_BOARD_HAUPPAUGE_DVB_T1: 481 case CX88_BOARD_HAUPPAUGE_DVB_T1:
382 rc5 = ir_decode_biphase(ir->samples,ir->scount,5,7); 482 rc5 = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
383 ir_dprintk("biphase decoded: %x\n",rc5); 483 ir_dprintk("biphase decoded: %x\n", rc5);
384 if ((rc5 & 0xfffff000) != 0x3000) 484 if ((rc5 & 0xfffff000) != 0x3000)
385 break; 485 break;
386 ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5); 486 ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5);
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 9ade2ae91e9b..fe2767c0ff94 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-mpeg.c,v 1.26 2005/06/03 13:31:51 mchehab Exp $ 2 * $Id: cx88-mpeg.c,v 1.31 2005/07/07 14:17:47 mchehab Exp $
3 * 3 *
4 * Support for the mpeg transport stream transfers 4 * Support for the mpeg transport stream transfers
5 * PCI function #2 of the cx2388x. 5 * PCI function #2 of the cx2388x.
@@ -64,17 +64,21 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
64 /* write TS length to chip */ 64 /* write TS length to chip */
65 cx_write(MO_TS_LNGTH, buf->vb.width); 65 cx_write(MO_TS_LNGTH, buf->vb.width);
66 66
67#if 1
68 /* FIXME: this needs a review. 67 /* FIXME: this needs a review.
69 * also: move to cx88-blackbird + cx88-dvb source files? */ 68 * also: move to cx88-blackbird + cx88-dvb source files? */
70 69
71 if (cx88_boards[core->board].dvb) { 70 if (cx88_boards[core->board].dvb) {
72 /* negedge driven & software reset */ 71 /* negedge driven & software reset */
73 cx_write(TS_GEN_CNTRL, 0x40); 72 cx_write(TS_GEN_CNTRL, 0x0040 | dev->ts_gen_cntrl);
74 udelay(100); 73 udelay(100);
75 cx_write(MO_PINMUX_IO, 0x00); 74 cx_write(MO_PINMUX_IO, 0x00);
76 cx_write(TS_HW_SOP_CNTRL,47<<16|188<<4|0x00); 75 cx_write(TS_HW_SOP_CNTRL,0x47<<16|188<<4|0x01);
77 cx_write(TS_SOP_STAT,0x00); 76 if ((core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q) ||
77 (core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T)) {
78 cx_write(TS_SOP_STAT, 1<<13);
79 } else {
80 cx_write(TS_SOP_STAT, 0x00);
81 }
78 cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl); 82 cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl);
79 udelay(100); 83 udelay(100);
80 } 84 }
@@ -93,7 +97,6 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
93 cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */ 97 cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */
94 udelay(100); 98 udelay(100);
95 } 99 }
96#endif
97 100
98 /* reset counter */ 101 /* reset counter */
99 cx_write(MO_TS_GPCNTRL, GP_COUNT_CONTROL_RESET); 102 cx_write(MO_TS_GPCNTRL, GP_COUNT_CONTROL_RESET);
@@ -265,6 +268,15 @@ static void cx8802_timeout(unsigned long data)
265 do_cancel_buffers(dev,"timeout",1); 268 do_cancel_buffers(dev,"timeout",1);
266} 269}
267 270
271static char *cx88_mpeg_irqs[32] = {
272 "ts_risci1", NULL, NULL, NULL,
273 "ts_risci2", NULL, NULL, NULL,
274 "ts_oflow", NULL, NULL, NULL,
275 "ts_sync", NULL, NULL, NULL,
276 "opc_err", "par_err", "rip_err", "pci_abort",
277 "ts_err?",
278};
279
268static void cx8802_mpeg_irq(struct cx8802_dev *dev) 280static void cx8802_mpeg_irq(struct cx8802_dev *dev)
269{ 281{
270 struct cx88_core *core = dev->core; 282 struct cx88_core *core = dev->core;
@@ -277,10 +289,7 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
277 return; 289 return;
278 290
279 cx_write(MO_TS_INTSTAT, status); 291 cx_write(MO_TS_INTSTAT, status);
280#if 0 292
281 cx88_print_irqbits(core->name, "irq mpeg ",
282 cx88_mpeg_irqs, status, mask);
283#endif
284 if (debug || (status & mask & ~0xff)) 293 if (debug || (status & mask & ~0xff))
285 cx88_print_irqbits(core->name, "irq mpeg ", 294 cx88_print_irqbits(core->name, "irq mpeg ",
286 cx88_mpeg_irqs, status, mask); 295 cx88_mpeg_irqs, status, mask);
@@ -436,10 +445,8 @@ int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
436 } 445 }
437 spin_unlock(&dev->slock); 446 spin_unlock(&dev->slock);
438 447
439#if 1
440 /* FIXME -- shutdown device */ 448 /* FIXME -- shutdown device */
441 cx88_shutdown(dev->core); 449 cx88_shutdown(dev->core);
442#endif
443 450
444 pci_save_state(pci_dev); 451 pci_save_state(pci_dev);
445 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { 452 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
@@ -461,10 +468,8 @@ int cx8802_resume_common(struct pci_dev *pci_dev)
461 pci_set_power_state(pci_dev, PCI_D0); 468 pci_set_power_state(pci_dev, PCI_D0);
462 pci_restore_state(pci_dev); 469 pci_restore_state(pci_dev);
463 470
464#if 1
465 /* FIXME: re-initialize hardware */ 471 /* FIXME: re-initialize hardware */
466 cx88_reset(dev->core); 472 cx88_reset(dev->core);
467#endif
468 473
469 /* restart video+vbi capture */ 474 /* restart video+vbi capture */
470 spin_lock(&dev->slock); 475 spin_lock(&dev->slock);
diff --git a/drivers/media/video/cx88/cx88-reg.h b/drivers/media/video/cx88/cx88-reg.h
index 63ad33f5818b..37f82662d265 100644
--- a/drivers/media/video/cx88/cx88-reg.h
+++ b/drivers/media/video/cx88/cx88-reg.h
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: cx88-reg.h,v 1.7 2005/06/03 13:31:51 mchehab Exp $ 2 $Id: cx88-reg.h,v 1.8 2005/07/07 13:58:38 mchehab Exp $
3 3
4 cx88x-hw.h - CX2388x register offsets 4 cx88x-hw.h - CX2388x register offsets
5 5
@@ -604,20 +604,11 @@
604#define EN_I2SIN_STR2DAC 0x00004000 604#define EN_I2SIN_STR2DAC 0x00004000
605#define EN_I2SIN_ENABLE 0x00008000 605#define EN_I2SIN_ENABLE 0x00008000
606 606
607#if 0
608/* old */
609#define EN_DMTRX_SUMDIFF 0x00000800
610#define EN_DMTRX_SUMR 0x00000880
611#define EN_DMTRX_LR 0x00000900
612#define EN_DMTRX_MONO 0x00000980
613#else
614/* dscaler cvs */
615#define EN_DMTRX_SUMDIFF (0 << 7) 607#define EN_DMTRX_SUMDIFF (0 << 7)
616#define EN_DMTRX_SUMR (1 << 7) 608#define EN_DMTRX_SUMR (1 << 7)
617#define EN_DMTRX_LR (2 << 7) 609#define EN_DMTRX_LR (2 << 7)
618#define EN_DMTRX_MONO (3 << 7) 610#define EN_DMTRX_MONO (3 << 7)
619#define EN_DMTRX_BYPASS (1 << 11) 611#define EN_DMTRX_BYPASS (1 << 11)
620#endif
621 612
622// Video 613// Video
623#define VID_CAPTURE_CONTROL 0x310180 614#define VID_CAPTURE_CONTROL 0x310180
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 46d78b1dc9b2..91207f10bae7 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: cx88-tvaudio.c,v 1.36 2005/06/05 05:53:45 mchehab Exp $ 2 $Id: cx88-tvaudio.c,v 1.37 2005/07/07 13:58:38 mchehab Exp $
3 3
4 cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver 4 cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
5 5
@@ -278,80 +278,6 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap)
278 set_audio_finish(core); 278 set_audio_finish(core);
279} 279}
280 280
281#if 0
282static void set_audio_standard_NICAM(struct cx88_core *core)
283{
284 static const struct rlist nicam_common[] = {
285 /* from dscaler */
286 { AUD_RATE_ADJ1, 0x00000010 },
287 { AUD_RATE_ADJ2, 0x00000040 },
288 { AUD_RATE_ADJ3, 0x00000100 },
289 { AUD_RATE_ADJ4, 0x00000400 },
290 { AUD_RATE_ADJ5, 0x00001000 },
291 // { AUD_DMD_RA_DDS, 0x00c0d5ce },
292
293 // Deemphasis 1:
294 { AUD_DEEMPHGAIN_R, 0x000023c2 },
295 { AUD_DEEMPHNUMER1_R, 0x0002a7bc },
296 { AUD_DEEMPHNUMER2_R, 0x0003023e },
297 { AUD_DEEMPHDENOM1_R, 0x0000f3d0 },
298 { AUD_DEEMPHDENOM2_R, 0x00000000 },
299
300#if 0
301 // Deemphasis 2: (other tv norm?)
302 { AUD_DEEMPHGAIN_R, 0x0000c600 },
303 { AUD_DEEMPHNUMER1_R, 0x00066738 },
304 { AUD_DEEMPHNUMER2_R, 0x00066739 },
305 { AUD_DEEMPHDENOM1_R, 0x0001e88c },
306 { AUD_DEEMPHDENOM2_R, 0x0001e88c },
307#endif
308
309 { AUD_DEEMPHDENOM2_R, 0x00000000 },
310 { AUD_ERRLOGPERIOD_R, 0x00000fff },
311 { AUD_ERRINTRPTTHSHLD1_R, 0x000003ff },
312 { AUD_ERRINTRPTTHSHLD2_R, 0x000000ff },
313 { AUD_ERRINTRPTTHSHLD3_R, 0x0000003f },
314 { AUD_POLYPH80SCALEFAC, 0x00000003 },
315
316 // setup QAM registers
317 { AUD_PDF_DDS_CNST_BYTE2, 0x06 },
318 { AUD_PDF_DDS_CNST_BYTE1, 0x82 },
319 { AUD_PDF_DDS_CNST_BYTE0, 0x16 },
320 { AUD_QAM_MODE, 0x05 },
321
322 { /* end of list */ },
323 };
324 static const struct rlist nicam_pal_i[] = {
325 { AUD_PDF_DDS_CNST_BYTE0, 0x12 },
326 { AUD_PHACC_FREQ_8MSB, 0x3a },
327 { AUD_PHACC_FREQ_8LSB, 0x93 },
328
329 { /* end of list */ },
330 };
331 static const struct rlist nicam_default[] = {
332 { AUD_PDF_DDS_CNST_BYTE0, 0x16 },
333 { AUD_PHACC_FREQ_8MSB, 0x34 },
334 { AUD_PHACC_FREQ_8LSB, 0x4c },
335
336 { /* end of list */ },
337 };
338
339 set_audio_start(core, 0x0010,
340 EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO);
341 set_audio_registers(core, nicam_common);
342 switch (core->tvaudio) {
343 case WW_NICAM_I:
344 dprintk("%s PAL-I NICAM (status: unknown)\n",__FUNCTION__);
345 set_audio_registers(core, nicam_pal_i);
346 break;
347 case WW_NICAM_BGDKL:
348 dprintk("%s PAL-BGDK NICAM (status: unknown)\n",__FUNCTION__);
349 set_audio_registers(core, nicam_default);
350 break;
351 };
352 set_audio_finish(core);
353}
354#endif
355 281
356static void set_audio_standard_NICAM_L(struct cx88_core *core, int stereo) 282static void set_audio_standard_NICAM_L(struct cx88_core *core, int stereo)
357{ 283{
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index e4ca7350df15..c44a079d08c0 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-video.c,v 1.63 2005/06/12 04:19:19 mchehab Exp $ 2 * $Id: cx88-video.c,v 1.79 2005/07/07 14:17:47 mchehab Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * video4linux video interface 5 * video4linux video interface
@@ -86,13 +86,6 @@ static struct cx88_tvnorm tvnorms[] = {
86 .id = V4L2_STD_NTSC_M_JP, 86 .id = V4L2_STD_NTSC_M_JP,
87 .cxiformat = VideoFormatNTSCJapan, 87 .cxiformat = VideoFormatNTSCJapan,
88 .cxoformat = 0x181f0008, 88 .cxoformat = 0x181f0008,
89#if 0
90 },{
91 .name = "NTSC-4.43",
92 .id = FIXME,
93 .cxiformat = VideoFormatNTSC443,
94 .cxoformat = 0x181f0008,
95#endif
96 },{ 89 },{
97 .name = "PAL-BG", 90 .name = "PAL-BG",
98 .id = V4L2_STD_PAL_BG, 91 .id = V4L2_STD_PAL_BG,
@@ -248,6 +241,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
248 .default_value = 0, 241 .default_value = 0,
249 .type = V4L2_CTRL_TYPE_INTEGER, 242 .type = V4L2_CTRL_TYPE_INTEGER,
250 }, 243 },
244 .off = 0,
251 .reg = MO_CONTR_BRIGHT, 245 .reg = MO_CONTR_BRIGHT,
252 .mask = 0xff00, 246 .mask = 0xff00,
253 .shift = 8, 247 .shift = 8,
@@ -261,7 +255,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
261 .default_value = 0, 255 .default_value = 0,
262 .type = V4L2_CTRL_TYPE_INTEGER, 256 .type = V4L2_CTRL_TYPE_INTEGER,
263 }, 257 },
264 .off = 0, 258 .off = 128,
265 .reg = MO_HUE, 259 .reg = MO_HUE,
266 .mask = 0x00ff, 260 .mask = 0x00ff,
267 .shift = 0, 261 .shift = 0,
@@ -674,231 +668,6 @@ static struct videobuf_queue_ops cx8800_video_qops = {
674 668
675/* ------------------------------------------------------------------ */ 669/* ------------------------------------------------------------------ */
676 670
677#if 0 /* overlay support not finished yet */
678static u32* ov_risc_field(struct cx8800_dev *dev, struct cx8800_fh *fh,
679 u32 *rp, struct btcx_skiplist *skips,
680 u32 sync_line, int skip_even, int skip_odd)
681{
682 int line,maxy,start,end,skip,nskips;
683 u32 ri,ra;
684 u32 addr;
685
686 /* sync instruction */
687 *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
688
689 addr = (unsigned long)dev->fbuf.base;
690 addr += dev->fbuf.fmt.bytesperline * fh->win.w.top;
691 addr += (fh->fmt->depth >> 3) * fh->win.w.left;
692
693 /* scan lines */
694 for (maxy = -1, line = 0; line < fh->win.w.height;
695 line++, addr += dev->fbuf.fmt.bytesperline) {
696 if ((line%2) == 0 && skip_even)
697 continue;
698 if ((line%2) == 1 && skip_odd)
699 continue;
700
701 /* calculate clipping */
702 if (line > maxy)
703 btcx_calc_skips(line, fh->win.w.width, &maxy,
704 skips, &nskips, fh->clips, fh->nclips);
705
706 /* write out risc code */
707 for (start = 0, skip = 0; start < fh->win.w.width; start = end) {
708 if (skip >= nskips) {
709 ri = RISC_WRITE;
710 end = fh->win.w.width;
711 } else if (start < skips[skip].start) {
712 ri = RISC_WRITE;
713 end = skips[skip].start;
714 } else {
715 ri = RISC_SKIP;
716 end = skips[skip].end;
717 skip++;
718 }
719 if (RISC_WRITE == ri)
720 ra = addr + (fh->fmt->depth>>3)*start;
721 else
722 ra = 0;
723
724 if (0 == start)
725 ri |= RISC_SOL;
726 if (fh->win.w.width == end)
727 ri |= RISC_EOL;
728 ri |= (fh->fmt->depth>>3) * (end-start);
729
730 *(rp++)=cpu_to_le32(ri);
731 if (0 != ra)
732 *(rp++)=cpu_to_le32(ra);
733 }
734 }
735 kfree(skips);
736 return rp;
737}
738
739static int ov_risc_frame(struct cx8800_dev *dev, struct cx8800_fh *fh,
740 struct cx88_buffer *buf)
741{
742 struct btcx_skiplist *skips;
743 u32 instructions,fields;
744 u32 *rp;
745 int rc;
746
747 /* skip list for window clipping */
748 if (NULL == (skips = kmalloc(sizeof(*skips) * fh->nclips,GFP_KERNEL)))
749 return -ENOMEM;
750
751 fields = 0;
752 if (V4L2_FIELD_HAS_TOP(fh->win.field))
753 fields++;
754 if (V4L2_FIELD_HAS_BOTTOM(fh->win.field))
755 fields++;
756
757 /* estimate risc mem: worst case is (clip+1) * lines instructions
758 + syncs + jump (all 2 dwords) */
759 instructions = (fh->nclips+1) * fh->win.w.height;
760 instructions += 3 + 4;
761 if ((rc = btcx_riscmem_alloc(dev->pci,&buf->risc,instructions*8)) < 0) {
762 kfree(skips);
763 return rc;
764 }
765
766 /* write risc instructions */
767 rp = buf->risc.cpu;
768 switch (fh->win.field) {
769 case V4L2_FIELD_TOP:
770 rp = ov_risc_field(dev, fh, rp, skips, 0, 0, 0);
771 break;
772 case V4L2_FIELD_BOTTOM:
773 rp = ov_risc_field(dev, fh, rp, skips, 0x200, 0, 0);
774 break;
775 case V4L2_FIELD_INTERLACED:
776 rp = ov_risc_field(dev, fh, rp, skips, 0, 0, 1);
777 rp = ov_risc_field(dev, fh, rp, skips, 0x200, 1, 0);
778 break;
779 default:
780 BUG();
781 }
782
783 /* save pointer to jmp instruction address */
784 buf->risc.jmp = rp;
785 kfree(skips);
786 return 0;
787}
788
789static int verify_window(struct cx8800_dev *dev, struct v4l2_window *win)
790{
791 enum v4l2_field field;
792 int maxw, maxh;
793
794 if (NULL == dev->fbuf.base)
795 return -EINVAL;
796 if (win->w.width < 48 || win->w.height < 32)
797 return -EINVAL;
798 if (win->clipcount > 2048)
799 return -EINVAL;
800
801 field = win->field;
802 maxw = norm_maxw(core->tvnorm);
803 maxh = norm_maxh(core->tvnorm);
804
805 if (V4L2_FIELD_ANY == field) {
806 field = (win->w.height > maxh/2)
807 ? V4L2_FIELD_INTERLACED
808 : V4L2_FIELD_TOP;
809 }
810 switch (field) {
811 case V4L2_FIELD_TOP:
812 case V4L2_FIELD_BOTTOM:
813 maxh = maxh / 2;
814 break;
815 case V4L2_FIELD_INTERLACED:
816 break;
817 default:
818 return -EINVAL;
819 }
820
821 win->field = field;
822 if (win->w.width > maxw)
823 win->w.width = maxw;
824 if (win->w.height > maxh)
825 win->w.height = maxh;
826 return 0;
827}
828
829static int setup_window(struct cx8800_dev *dev, struct cx8800_fh *fh,
830 struct v4l2_window *win)
831{
832 struct v4l2_clip *clips = NULL;
833 int n,size,retval = 0;
834
835 if (NULL == fh->fmt)
836 return -EINVAL;
837 retval = verify_window(dev,win);
838 if (0 != retval)
839 return retval;
840
841 /* copy clips -- luckily v4l1 + v4l2 are binary
842 compatible here ...*/
843 n = win->clipcount;
844 size = sizeof(*clips)*(n+4);
845 clips = kmalloc(size,GFP_KERNEL);
846 if (NULL == clips)
847 return -ENOMEM;
848 if (n > 0) {
849 if (copy_from_user(clips,win->clips,sizeof(struct v4l2_clip)*n)) {
850 kfree(clips);
851 return -EFAULT;
852 }
853 }
854
855 /* clip against screen */
856 if (NULL != dev->fbuf.base)
857 n = btcx_screen_clips(dev->fbuf.fmt.width, dev->fbuf.fmt.height,
858 &win->w, clips, n);
859 btcx_sort_clips(clips,n);
860
861 /* 4-byte alignments */
862 switch (fh->fmt->depth) {
863 case 8:
864 case 24:
865 btcx_align(&win->w, clips, n, 3);
866 break;
867 case 16:
868 btcx_align(&win->w, clips, n, 1);
869 break;
870 case 32:
871 /* no alignment fixups needed */
872 break;
873 default:
874 BUG();
875 }
876
877 down(&fh->vidq.lock);
878 if (fh->clips)
879 kfree(fh->clips);
880 fh->clips = clips;
881 fh->nclips = n;
882 fh->win = *win;
883#if 0
884 fh->ov.setup_ok = 1;
885#endif
886
887 /* update overlay if needed */
888 retval = 0;
889#if 0
890 if (check_btres(fh, RESOURCE_OVERLAY)) {
891 struct bttv_buffer *new;
892
893 new = videobuf_alloc(sizeof(*new));
894 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
895 retval = bttv_switch_overlay(btv,fh,new);
896 }
897#endif
898 up(&fh->vidq.lock);
899 return retval;
900}
901#endif
902 671
903/* ------------------------------------------------------------------ */ 672/* ------------------------------------------------------------------ */
904 673
@@ -1327,9 +1096,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1327 struct cx8800_fh *fh = file->private_data; 1096 struct cx8800_fh *fh = file->private_data;
1328 struct cx8800_dev *dev = fh->dev; 1097 struct cx8800_dev *dev = fh->dev;
1329 struct cx88_core *core = dev->core; 1098 struct cx88_core *core = dev->core;
1330#if 0
1331 unsigned long flags;
1332#endif
1333 int err; 1099 int err;
1334 1100
1335 if (video_debug > 1) 1101 if (video_debug > 1)
@@ -1350,12 +1116,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1350 V4L2_CAP_READWRITE | 1116 V4L2_CAP_READWRITE |
1351 V4L2_CAP_STREAMING | 1117 V4L2_CAP_STREAMING |
1352 V4L2_CAP_VBI_CAPTURE | 1118 V4L2_CAP_VBI_CAPTURE |
1353#if 0
1354 V4L2_TUNER_CAP_LOW |
1355#endif
1356#if 0
1357 V4L2_CAP_VIDEO_OVERLAY |
1358#endif
1359 0; 1119 0;
1360 if (UNSET != core->tuner_type) 1120 if (UNSET != core->tuner_type)
1361 cap->capabilities |= V4L2_CAP_TUNER; 1121 cap->capabilities |= V4L2_CAP_TUNER;
@@ -1456,36 +1216,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1456 } 1216 }
1457 1217
1458 1218
1459#if 0
1460 /* needs review */
1461 case VIDIOC_G_AUDIO:
1462 {
1463 struct v4l2_audio *a = arg;
1464 unsigned int n = a->index;
1465
1466 memset(a,0,sizeof(*a));
1467 a->index = n;
1468 switch (n) {
1469 case 0:
1470 if ((CX88_VMUX_TELEVISION == INPUT(n)->type)
1471 || (CX88_VMUX_CABLE == INPUT(n)->type)) {
1472 strcpy(a->name,"Television");
1473 // FIXME figure out if stereo received and set V4L2_AUDCAP_STEREO.
1474 return 0;
1475 }
1476 break;
1477 case 1:
1478 if (CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD == core->board) {
1479 strcpy(a->name,"Line In");
1480 a->capability = V4L2_AUDCAP_STEREO;
1481 return 0;
1482 }
1483 break;
1484 }
1485 // Audio input not available.
1486 return -EINVAL;
1487 }
1488#endif
1489 1219
1490 /* --- capture ioctls ---------------------------------------- */ 1220 /* --- capture ioctls ---------------------------------------- */
1491 case VIDIOC_ENUM_FMT: 1221 case VIDIOC_ENUM_FMT:
@@ -1588,13 +1318,16 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1588 { 1318 {
1589 struct v4l2_frequency *f = arg; 1319 struct v4l2_frequency *f = arg;
1590 1320
1321 memset(f,0,sizeof(*f));
1322
1591 if (UNSET == core->tuner_type) 1323 if (UNSET == core->tuner_type)
1592 return -EINVAL; 1324 return -EINVAL;
1593 if (f->tuner != 0) 1325
1594 return -EINVAL;
1595 memset(f,0,sizeof(*f));
1596 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1326 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1597 f->frequency = dev->freq; 1327 f->frequency = dev->freq;
1328
1329 cx88_call_i2c_clients(dev->core,VIDIOC_G_FREQUENCY,f);
1330
1598 return 0; 1331 return 0;
1599 } 1332 }
1600 case VIDIOC_S_FREQUENCY: 1333 case VIDIOC_S_FREQUENCY:
@@ -1612,11 +1345,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1612 down(&dev->lock); 1345 down(&dev->lock);
1613 dev->freq = f->frequency; 1346 dev->freq = f->frequency;
1614 cx88_newstation(core); 1347 cx88_newstation(core);
1615#ifdef V4L2_I2C_CLIENTS
1616 cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f); 1348 cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f);
1617#else
1618 cx88_call_i2c_clients(dev->core,VIDIOCSFREQ,&dev->freq);
1619#endif
1620 up(&dev->lock); 1349 up(&dev->lock);
1621 return 0; 1350 return 0;
1622 } 1351 }
@@ -1714,11 +1443,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
1714 sizeof(cap->card)); 1443 sizeof(cap->card));
1715 sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci)); 1444 sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci));
1716 cap->version = CX88_VERSION_CODE; 1445 cap->version = CX88_VERSION_CODE;
1717 cap->capabilities = V4L2_CAP_TUNER 1446 cap->capabilities = V4L2_CAP_TUNER;
1718#if 0
1719 | V4L2_TUNER_CAP_LOW
1720#endif
1721 ;
1722 return 0; 1447 return 0;
1723 } 1448 }
1724 case VIDIOC_G_TUNER: 1449 case VIDIOC_G_TUNER:
@@ -1730,19 +1455,8 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
1730 1455
1731 memset(t,0,sizeof(*t)); 1456 memset(t,0,sizeof(*t));
1732 strcpy(t->name, "Radio"); 1457 strcpy(t->name, "Radio");
1733 t->rangelow = (int)(65*16);
1734 t->rangehigh = (int)(108*16);
1735 1458
1736#ifdef V4L2_I2C_CLIENTS
1737 cx88_call_i2c_clients(dev->core,VIDIOC_G_TUNER,t); 1459 cx88_call_i2c_clients(dev->core,VIDIOC_G_TUNER,t);
1738#else
1739 {
1740 struct video_tuner vt;
1741 memset(&vt,0,sizeof(vt));
1742 cx88_call_i2c_clients(dev,VIDIOCGTUNER,&vt);
1743 t->signal = vt.signal;
1744 }
1745#endif
1746 return 0; 1460 return 0;
1747 } 1461 }
1748 case VIDIOC_ENUMINPUT: 1462 case VIDIOC_ENUMINPUT:
@@ -1775,8 +1489,29 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
1775 *id = 0; 1489 *id = 0;
1776 return 0; 1490 return 0;
1777 } 1491 }
1778 case VIDIOC_S_AUDIO: 1492 case VIDIOCSTUNER:
1493 {
1494 struct video_tuner *v = arg;
1495
1496 if (v->tuner) /* Only tuner 0 */
1497 return -EINVAL;
1498
1499 cx88_call_i2c_clients(dev->core,VIDIOCSTUNER,v);
1500 return 0;
1501 }
1779 case VIDIOC_S_TUNER: 1502 case VIDIOC_S_TUNER:
1503 {
1504 struct v4l2_tuner *t = arg;
1505
1506 if (0 != t->index)
1507 return -EINVAL;
1508
1509 cx88_call_i2c_clients(dev->core,VIDIOC_S_TUNER,t);
1510
1511 return 0;
1512 }
1513
1514 case VIDIOC_S_AUDIO:
1780 case VIDIOC_S_INPUT: 1515 case VIDIOC_S_INPUT:
1781 case VIDIOC_S_STD: 1516 case VIDIOC_S_STD:
1782 return 0; 1517 return 0;
@@ -1847,6 +1582,14 @@ static void cx8800_vid_timeout(unsigned long data)
1847 spin_unlock_irqrestore(&dev->slock,flags); 1582 spin_unlock_irqrestore(&dev->slock,flags);
1848} 1583}
1849 1584
1585static char *cx88_vid_irqs[32] = {
1586 "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
1587 "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
1588 "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
1589 "y_sync", "u_sync", "v_sync", "vbi_sync",
1590 "opc_err", "par_err", "rip_err", "pci_abort",
1591};
1592
1850static void cx8800_vid_irq(struct cx8800_dev *dev) 1593static void cx8800_vid_irq(struct cx8800_dev *dev)
1851{ 1594{
1852 struct cx88_core *core = dev->core; 1595 struct cx88_core *core = dev->core;
@@ -2014,7 +1757,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
2014{ 1757{
2015 struct cx8800_dev *dev; 1758 struct cx8800_dev *dev;
2016 struct cx88_core *core; 1759 struct cx88_core *core;
2017 struct tuner_addr tun_addr;
2018 int err; 1760 int err;
2019 1761
2020 dev = kmalloc(sizeof(*dev),GFP_KERNEL); 1762 dev = kmalloc(sizeof(*dev),GFP_KERNEL);
@@ -2088,22 +1830,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
2088 request_module("tuner"); 1830 request_module("tuner");
2089 if (core->tda9887_conf) 1831 if (core->tda9887_conf)
2090 request_module("tda9887"); 1832 request_module("tda9887");
2091 if (core->radio_type != UNSET) {
2092 tun_addr.v4l2_tuner = V4L2_TUNER_RADIO;
2093 tun_addr.type = core->radio_type;
2094 tun_addr.addr = core->radio_addr;
2095 cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE_ADDR, &tun_addr);
2096 }
2097 if (core->tuner_type != UNSET) {
2098 tun_addr.v4l2_tuner = V4L2_TUNER_ANALOG_TV;
2099 tun_addr.type = core->tuner_type;
2100 tun_addr.addr = core->tuner_addr;
2101 cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE_ADDR, &tun_addr);
2102 }
2103
2104 if (core->tda9887_conf)
2105 cx88_call_i2c_clients(dev->core,TDA9887_SET_CONFIG,&core->tda9887_conf);
2106
2107 /* register v4l devices */ 1833 /* register v4l devices */
2108 dev->video_dev = cx88_vdev_init(core,dev->pci, 1834 dev->video_dev = cx88_vdev_init(core,dev->pci,
2109 &cx8800_video_template,"video"); 1835 &cx8800_video_template,"video");
@@ -2213,10 +1939,8 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
2213 } 1939 }
2214 spin_unlock(&dev->slock); 1940 spin_unlock(&dev->slock);
2215 1941
2216#if 1
2217 /* FIXME -- shutdown device */ 1942 /* FIXME -- shutdown device */
2218 cx88_shutdown(dev->core); 1943 cx88_shutdown(dev->core);
2219#endif
2220 1944
2221 pci_save_state(pci_dev); 1945 pci_save_state(pci_dev);
2222 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { 1946 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
@@ -2238,10 +1962,8 @@ static int cx8800_resume(struct pci_dev *pci_dev)
2238 pci_set_power_state(pci_dev, PCI_D0); 1962 pci_set_power_state(pci_dev, PCI_D0);
2239 pci_restore_state(pci_dev); 1963 pci_restore_state(pci_dev);
2240 1964
2241#if 1
2242 /* FIXME: re-initialize hardware */ 1965 /* FIXME: re-initialize hardware */
2243 cx88_reset(dev->core); 1966 cx88_reset(dev->core);
2244#endif
2245 1967
2246 /* restart video+vbi capture */ 1968 /* restart video+vbi capture */
2247 spin_lock(&dev->slock); 1969 spin_lock(&dev->slock);
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 867e988a5a93..307beae04f2a 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88.h,v 1.62 2005/06/12 04:19:19 mchehab Exp $ 2 * $Id: cx88.h,v 1.68 2005/07/07 14:17:47 mchehab Exp $
3 * 3 *
4 * v4l2 device driver for cx2388x based TV cards 4 * v4l2 device driver for cx2388x based TV cards
5 * 5 *
@@ -51,8 +51,6 @@
51/* ----------------------------------------------------------- */ 51/* ----------------------------------------------------------- */
52/* defines and enums */ 52/* defines and enums */
53 53
54#define V4L2_I2C_CLIENTS 1
55
56#define FORMAT_FLAGS_PACKED 0x01 54#define FORMAT_FLAGS_PACKED 0x01
57#define FORMAT_FLAGS_PLANAR 0x02 55#define FORMAT_FLAGS_PLANAR 0x02
58 56
@@ -84,9 +82,9 @@ struct cx88_tvnorm {
84static unsigned int inline norm_maxw(struct cx88_tvnorm *norm) 82static unsigned int inline norm_maxw(struct cx88_tvnorm *norm)
85{ 83{
86 return (norm->id & V4L2_STD_625_50) ? 768 : 640; 84 return (norm->id & V4L2_STD_625_50) ? 768 : 640;
87// return (norm->id & V4L2_STD_625_50) ? 720 : 640;
88} 85}
89 86
87
90static unsigned int inline norm_maxh(struct cx88_tvnorm *norm) 88static unsigned int inline norm_maxh(struct cx88_tvnorm *norm)
91{ 89{
92 return (norm->id & V4L2_STD_625_50) ? 576 : 480; 90 return (norm->id & V4L2_STD_625_50) ? 576 : 480;
@@ -159,7 +157,7 @@ extern struct sram_channel cx88_sram_channels[];
159#define CX88_BOARD_KWORLD_DVB_T 14 157#define CX88_BOARD_KWORLD_DVB_T 14
160#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1 15 158#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1 15
161#define CX88_BOARD_KWORLD_LTV883 16 159#define CX88_BOARD_KWORLD_LTV883 16
162#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD 17 160#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q 17
163#define CX88_BOARD_HAUPPAUGE_DVB_T1 18 161#define CX88_BOARD_HAUPPAUGE_DVB_T1 18
164#define CX88_BOARD_CONEXANT_DVB_T1 19 162#define CX88_BOARD_CONEXANT_DVB_T1 19
165#define CX88_BOARD_PROVIDEO_PV259 20 163#define CX88_BOARD_PROVIDEO_PV259 20
@@ -167,10 +165,12 @@ extern struct sram_channel cx88_sram_channels[];
167#define CX88_BOARD_PCHDTV_HD3000 22 165#define CX88_BOARD_PCHDTV_HD3000 22
168#define CX88_BOARD_DNTV_LIVE_DVB_T 23 166#define CX88_BOARD_DNTV_LIVE_DVB_T 23
169#define CX88_BOARD_HAUPPAUGE_ROSLYN 24 167#define CX88_BOARD_HAUPPAUGE_ROSLYN 24
170#define CX88_BOARD_DIGITALLOGIC_MEC 25 168#define CX88_BOARD_DIGITALLOGIC_MEC 25
171#define CX88_BOARD_IODATA_GVBCTV7E 26 169#define CX88_BOARD_IODATA_GVBCTV7E 26
172#define CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO 27 170#define CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO 27
173#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T 28 171#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T 28
172#define CX88_BOARD_ADSTECH_DVB_T_PCI 29
173#define CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1 30
174 174
175enum cx88_itype { 175enum cx88_itype {
176 CX88_VMUX_COMPOSITE1 = 1, 176 CX88_VMUX_COMPOSITE1 = 1,
@@ -220,7 +220,6 @@ struct cx88_subid {
220#define RESOURCE_VBI 4 220#define RESOURCE_VBI 4
221 221
222#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */ 222#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */
223//#define BUFFER_TIMEOUT (HZ*2)
224 223
225/* buffer for one video frame */ 224/* buffer for one video frame */
226struct cx88_buffer { 225struct cx88_buffer {
@@ -336,11 +335,6 @@ struct cx8800_dev {
336 struct pci_dev *pci; 335 struct pci_dev *pci;
337 unsigned char pci_rev,pci_lat; 336 unsigned char pci_rev,pci_lat;
338 337
339#if 0
340 /* video overlay */
341 struct v4l2_framebuffer fbuf;
342 struct cx88_buffer *screen;
343#endif
344 338
345 /* capture queues */ 339 /* capture queues */
346 struct cx88_dmaqueue vidq; 340 struct cx88_dmaqueue vidq;
@@ -435,8 +429,6 @@ struct cx8802_dev {
435/* ----------------------------------------------------------- */ 429/* ----------------------------------------------------------- */
436/* cx88-core.c */ 430/* cx88-core.c */
437 431
438extern char *cx88_vid_irqs[32];
439extern char *cx88_mpeg_irqs[32];
440extern void cx88_print_irqbits(char *name, char *tag, char **strings, 432extern void cx88_print_irqbits(char *name, char *tag, char **strings,
441 u32 bits, u32 mask); 433 u32 bits, u32 mask);
442extern void cx88_print_ioctl(char *name, unsigned int cmd); 434extern void cx88_print_ioctl(char *name, unsigned int cmd);
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 92664f75d327..9fc5055e001c 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ir-kbd-i2c.c,v 1.10 2004/12/09 12:51:35 kraxel Exp $ 2 * $Id: ir-kbd-i2c.c,v 1.11 2005/07/07 16:42:11 mchehab Exp $
3 * 3 *
4 * keyboard input driver for i2c IR remote controls 4 * keyboard input driver for i2c IR remote controls
5 * 5 *
@@ -66,26 +66,26 @@ static IR_KEYTAB_TYPE ir_codes_pv951[IR_KEYTAB_SIZE] = {
66 [ 29 ] = KEY_PAGEDOWN, 66 [ 29 ] = KEY_PAGEDOWN,
67 [ 19 ] = KEY_SOUND, 67 [ 19 ] = KEY_SOUND,
68 68
69 [ 24 ] = KEY_KPPLUSMINUS, // CH +/- 69 [ 24 ] = KEY_KPPLUSMINUS, /* CH +/- */
70 [ 22 ] = KEY_SUBTITLE, // CC 70 [ 22 ] = KEY_SUBTITLE, /* CC */
71 [ 13 ] = KEY_TEXT, // TTX 71 [ 13 ] = KEY_TEXT, /* TTX */
72 [ 11 ] = KEY_TV, // AIR/CBL 72 [ 11 ] = KEY_TV, /* AIR/CBL */
73 [ 17 ] = KEY_PC, // PC/TV 73 [ 17 ] = KEY_PC, /* PC/TV */
74 [ 23 ] = KEY_OK, // CH RTN 74 [ 23 ] = KEY_OK, /* CH RTN */
75 [ 25 ] = KEY_MODE, // FUNC 75 [ 25 ] = KEY_MODE, /* FUNC */
76 [ 12 ] = KEY_SEARCH, // AUTOSCAN 76 [ 12 ] = KEY_SEARCH, /* AUTOSCAN */
77 77
78 /* Not sure what to do with these ones! */ 78 /* Not sure what to do with these ones! */
79 [ 15 ] = KEY_SELECT, // SOURCE 79 [ 15 ] = KEY_SELECT, /* SOURCE */
80 [ 10 ] = KEY_KPPLUS, // +100 80 [ 10 ] = KEY_KPPLUS, /* +100 */
81 [ 20 ] = KEY_KPEQUAL, // SYNC 81 [ 20 ] = KEY_KPEQUAL, /* SYNC */
82 [ 28 ] = KEY_MEDIA, // PC/TV 82 [ 28 ] = KEY_MEDIA, /* PC/TV */
83}; 83};
84 84
85static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = { 85static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
86 [ 0x3 ] = KEY_POWER, 86 [ 0x3 ] = KEY_POWER,
87 [ 0x6f ] = KEY_MUTE, 87 [ 0x6f ] = KEY_MUTE,
88 [ 0x10 ] = KEY_BACKSPACE, // Recall 88 [ 0x10 ] = KEY_BACKSPACE, /* Recall */
89 89
90 [ 0x11 ] = KEY_KP0, 90 [ 0x11 ] = KEY_KP0,
91 [ 0x4 ] = KEY_KP1, 91 [ 0x4 ] = KEY_KP1,
@@ -97,7 +97,7 @@ static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
97 [ 0xc ] = KEY_KP7, 97 [ 0xc ] = KEY_KP7,
98 [ 0xd ] = KEY_KP8, 98 [ 0xd ] = KEY_KP8,
99 [ 0xe ] = KEY_KP9, 99 [ 0xe ] = KEY_KP9,
100 [ 0x12 ] = KEY_KPDOT, // 100+ 100 [ 0x12 ] = KEY_KPDOT, /* 100+ */
101 101
102 [ 0x7 ] = KEY_VOLUMEUP, 102 [ 0x7 ] = KEY_VOLUMEUP,
103 [ 0xb ] = KEY_VOLUMEDOWN, 103 [ 0xb ] = KEY_VOLUMEDOWN,
@@ -109,25 +109,16 @@ static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
109 [ 0x13 ] = KEY_CHANNELDOWN, 109 [ 0x13 ] = KEY_CHANNELDOWN,
110 [ 0x48 ] = KEY_ZOOM, 110 [ 0x48 ] = KEY_ZOOM,
111 111
112 [ 0x1b ] = KEY_VIDEO, // Video source 112 [ 0x1b ] = KEY_VIDEO, /* Video source */
113#if 0 113 [ 0x49 ] = KEY_LANGUAGE, /* MTS Select */
114 [ 0x1f ] = KEY_S, // Snapshot 114 [ 0x19 ] = KEY_SEARCH, /* Auto Scan */
115#endif
116 [ 0x49 ] = KEY_LANGUAGE, // MTS Select
117 [ 0x19 ] = KEY_SEARCH, // Auto Scan
118 115
119 [ 0x4b ] = KEY_RECORD, 116 [ 0x4b ] = KEY_RECORD,
120 [ 0x46 ] = KEY_PLAY, 117 [ 0x46 ] = KEY_PLAY,
121 [ 0x45 ] = KEY_PAUSE, // Pause 118 [ 0x45 ] = KEY_PAUSE, /* Pause */
122 [ 0x44 ] = KEY_STOP, 119 [ 0x44 ] = KEY_STOP,
123#if 0 120 [ 0x40 ] = KEY_FORWARD, /* Forward ? */
124 [ 0x43 ] = KEY_T, // Time Shift 121 [ 0x42 ] = KEY_REWIND, /* Backward ? */
125 [ 0x47 ] = KEY_Y, // Time Shift OFF
126 [ 0x4a ] = KEY_O, // TOP
127 [ 0x17 ] = KEY_F, // SURF CH
128#endif
129 [ 0x40 ] = KEY_FORWARD, // Forward ?
130 [ 0x42 ] = KEY_REWIND, // Backward ?
131 122
132}; 123};
133 124
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index b4ee9dfe6d42..6239254db27e 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -567,10 +567,6 @@ static void msp3400c_set_audmode(struct i2c_client *client, int audmode)
567 switch (audmode) { 567 switch (audmode) {
568 case V4L2_TUNER_MODE_STEREO: 568 case V4L2_TUNER_MODE_STEREO:
569 src = 0x0020 | nicam; 569 src = 0x0020 | nicam;
570#if 0
571 /* spatial effect */
572 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0005,0x4000);
573#endif
574 break; 570 break;
575 case V4L2_TUNER_MODE_MONO: 571 case V4L2_TUNER_MODE_MONO:
576 if (msp->mode == MSP_MODE_AM_NICAM) { 572 if (msp->mode == MSP_MODE_AM_NICAM) {
@@ -741,16 +737,14 @@ static int msp34xx_sleep(struct msp3400c *msp, int timeout)
741 set_current_state(TASK_INTERRUPTIBLE); 737 set_current_state(TASK_INTERRUPTIBLE);
742 schedule(); 738 schedule();
743 } else { 739 } else {
744#if 0
745 /* hmm, that one doesn't return on wakeup ... */
746 msleep_interruptible(timeout);
747#else
748 set_current_state(TASK_INTERRUPTIBLE); 740 set_current_state(TASK_INTERRUPTIBLE);
749 schedule_timeout(msecs_to_jiffies(timeout)); 741 schedule_timeout(msecs_to_jiffies(timeout));
750#endif
751 } 742 }
752 } 743 }
753 try_to_freeze(); 744 if (current->flags & PF_FREEZE) {
745 refrigerator ();
746 }
747
754 remove_wait_queue(&msp->wq, &wait); 748 remove_wait_queue(&msp->wq, &wait);
755 return msp->restart; 749 return msp->restart;
756} 750}
@@ -1154,17 +1148,10 @@ static int msp3410d_thread(void *data)
1154 MSP_CARRIER(10.7)); 1148 MSP_CARRIER(10.7));
1155 /* scart routing */ 1149 /* scart routing */
1156 msp3400c_set_scart(client,SCART_IN2,0); 1150 msp3400c_set_scart(client,SCART_IN2,0);
1157#if 0
1158 /* radio from SCART_IN2 */
1159 msp3400c_write(client,I2C_MSP3400C_DFP, 0x08, 0x0220);
1160 msp3400c_write(client,I2C_MSP3400C_DFP, 0x09, 0x0220);
1161 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0b, 0x0220);
1162#else
1163 /* msp34xx does radio decoding */ 1151 /* msp34xx does radio decoding */
1164 msp3400c_write(client,I2C_MSP3400C_DFP, 0x08, 0x0020); 1152 msp3400c_write(client,I2C_MSP3400C_DFP, 0x08, 0x0020);
1165 msp3400c_write(client,I2C_MSP3400C_DFP, 0x09, 0x0020); 1153 msp3400c_write(client,I2C_MSP3400C_DFP, 0x09, 0x0020);
1166 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0b, 0x0020); 1154 msp3400c_write(client,I2C_MSP3400C_DFP, 0x0b, 0x0020);
1167#endif
1168 break; 1155 break;
1169 case 0x0003: 1156 case 0x0003:
1170 case 0x0004: 1157 case 0x0004:
@@ -1507,10 +1494,6 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
1507 return -1; 1494 return -1;
1508 } 1495 }
1509 1496
1510#if 0
1511 /* this will turn on a 1kHz beep - might be useful for debugging... */
1512 msp3400c_write(c,I2C_MSP3400C_DFP, 0x0014, 0x1040);
1513#endif
1514 msp3400c_setvolume(c, msp->muted, msp->volume, msp->balance); 1497 msp3400c_setvolume(c, msp->muted, msp->volume, msp->balance);
1515 1498
1516 snprintf(c->name, sizeof(c->name), "MSP34%02d%c-%c%d", 1499 snprintf(c->name, sizeof(c->name), "MSP34%02d%c-%c%d",
diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c
index 9c005cb128d7..2fb7c2d1787a 100644
--- a/drivers/media/video/mt20xx.c
+++ b/drivers/media/video/mt20xx.c
@@ -511,22 +511,6 @@ int microtune_init(struct i2c_client *c)
511 tuner_info("microtune: companycode=%04x part=%02x rev=%02x\n", 511 tuner_info("microtune: companycode=%04x part=%02x rev=%02x\n",
512 company_code,buf[0x13],buf[0x14]); 512 company_code,buf[0x13],buf[0x14]);
513 513
514#if 0
515 /* seems to cause more problems than it solves ... */
516 switch (company_code) {
517 case 0x30bf:
518 case 0x3cbf:
519 case 0x3dbf:
520 case 0x4d54:
521 case 0x8e81:
522 case 0x8e91:
523 /* ok (?) */
524 break;
525 default:
526 tuner_warn("tuner: microtune: unknown companycode\n");
527 return 0;
528 }
529#endif
530 514
531 if (buf[0x13] < ARRAY_SIZE(microtune_part) && 515 if (buf[0x13] < ARRAY_SIZE(microtune_part) &&
532 NULL != microtune_part[buf[0x13]]) 516 NULL != microtune_part[buf[0x13]])
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 70bf1f1fad59..486234d41b56 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -326,6 +326,7 @@ static int mxb_init_done(struct saa7146_dev* dev)
326 struct mxb* mxb = (struct mxb*)dev->ext_priv; 326 struct mxb* mxb = (struct mxb*)dev->ext_priv;
327 struct video_decoder_init init; 327 struct video_decoder_init init;
328 struct i2c_msg msg; 328 struct i2c_msg msg;
329 struct tuner_setup tun_setup;
329 330
330 int i = 0, err = 0; 331 int i = 0, err = 0;
331 struct tea6415c_multiplex vm; 332 struct tea6415c_multiplex vm;
@@ -349,8 +350,10 @@ static int mxb_init_done(struct saa7146_dev* dev)
349 mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_VBI_BYPASS, &i); 350 mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_VBI_BYPASS, &i);
350 351
351 /* select a tuner type */ 352 /* select a tuner type */
352 i = 5; 353 tun_setup.mode_mask = T_ANALOG_TV;
353 mxb->tuner->driver->command(mxb->tuner,TUNER_SET_TYPE, &i); 354 tun_setup.addr = ADDR_UNSET;
355 tun_setup.type = 5;
356 mxb->tuner->driver->command(mxb->tuner,TUNER_SET_TYPE_ADDR, &tun_setup);
354 357
355 /* mute audio on tea6420s */ 358 /* mute audio on tea6420s */
356 mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_line[6][0]); 359 mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_line[6][0]);
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index e6d0a18833d6..79d05ea1b69b 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -155,10 +155,6 @@ static struct v4l2_mpeg_compression param_defaults =
155 .target = 256, 155 .target = 256,
156 }, 156 },
157 157
158#if 0
159 /* FIXME: size? via S_FMT? */
160 .video_format = MPEG_VIDEO_FORMAT_D1,
161#endif
162}; 158};
163 159
164/* ---------------------------------------------------------------------- */ 160/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 0c781e24c446..88b71a20b602 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -1,6 +1,5 @@
1
2/* 1/*
3 * $Id: saa7134-cards.c,v 1.58 2005/06/07 18:05:00 nsh Exp $ 2 * $Id: saa7134-cards.c,v 1.80 2005/07/07 01:49:30 mkrufky Exp $
4 * 3 *
5 * device driver for philips saa7134 based TV cards 4 * device driver for philips saa7134 based TV cards
6 * card-specific stuff. 5 * card-specific stuff.
@@ -47,6 +46,10 @@ struct saa7134_board saa7134_boards[] = {
47 .name = "UNKNOWN/GENERIC", 46 .name = "UNKNOWN/GENERIC",
48 .audio_clock = 0x00187de7, 47 .audio_clock = 0x00187de7,
49 .tuner_type = TUNER_ABSENT, 48 .tuner_type = TUNER_ABSENT,
49 .radio_type = UNSET,
50 .tuner_addr = ADDR_UNSET,
51 .radio_addr = ADDR_UNSET,
52
50 .inputs = {{ 53 .inputs = {{
51 .name = "default", 54 .name = "default",
52 .vmux = 0, 55 .vmux = 0,
@@ -58,6 +61,10 @@ struct saa7134_board saa7134_boards[] = {
58 .name = "Proteus Pro [philips reference design]", 61 .name = "Proteus Pro [philips reference design]",
59 .audio_clock = 0x00187de7, 62 .audio_clock = 0x00187de7,
60 .tuner_type = TUNER_PHILIPS_PAL, 63 .tuner_type = TUNER_PHILIPS_PAL,
64 .radio_type = UNSET,
65 .tuner_addr = ADDR_UNSET,
66 .radio_addr = ADDR_UNSET,
67
61 .inputs = {{ 68 .inputs = {{
62 .name = name_comp1, 69 .name = name_comp1,
63 .vmux = 0, 70 .vmux = 0,
@@ -83,6 +90,10 @@ struct saa7134_board saa7134_boards[] = {
83 .name = "LifeView FlyVIDEO3000", 90 .name = "LifeView FlyVIDEO3000",
84 .audio_clock = 0x00200000, 91 .audio_clock = 0x00200000,
85 .tuner_type = TUNER_PHILIPS_PAL, 92 .tuner_type = TUNER_PHILIPS_PAL,
93 .radio_type = UNSET,
94 .tuner_addr = ADDR_UNSET,
95 .radio_addr = ADDR_UNSET,
96
86 .gpiomask = 0xe000, 97 .gpiomask = 0xe000,
87 .inputs = {{ 98 .inputs = {{
88 .name = name_tv, 99 .name = name_tv,
@@ -90,7 +101,7 @@ struct saa7134_board saa7134_boards[] = {
90 .amux = TV, 101 .amux = TV,
91 .gpio = 0x8000, 102 .gpio = 0x8000,
92 .tv = 1, 103 .tv = 1,
93 },{ 104 },{
94 .name = name_tv_mono, 105 .name = name_tv_mono,
95 .vmux = 1, 106 .vmux = 1,
96 .amux = LINE2, 107 .amux = LINE2,
@@ -117,12 +128,21 @@ struct saa7134_board saa7134_boards[] = {
117 .amux = LINE2, 128 .amux = LINE2,
118 .gpio = 0x2000, 129 .gpio = 0x2000,
119 }, 130 },
131 .mute = {
132 .name = name_mute,
133 .amux = TV,
134 .gpio = 0x8000,
135 },
120 }, 136 },
121 [SAA7134_BOARD_FLYVIDEO2000] = { 137 [SAA7134_BOARD_FLYVIDEO2000] = {
122 /* "TC Wan" <tcwan@cs.usm.my> */ 138 /* "TC Wan" <tcwan@cs.usm.my> */
123 .name = "LifeView FlyVIDEO2000", 139 .name = "LifeView FlyVIDEO2000",
124 .audio_clock = 0x00200000, 140 .audio_clock = 0x00200000,
125 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 141 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
142 .radio_type = UNSET,
143 .tuner_addr = ADDR_UNSET,
144 .radio_addr = ADDR_UNSET,
145
126 .gpiomask = 0xe000, 146 .gpiomask = 0xe000,
127 .inputs = {{ 147 .inputs = {{
128 .name = name_tv, 148 .name = name_tv,
@@ -146,14 +166,14 @@ struct saa7134_board saa7134_boards[] = {
146 .amux = LINE2, 166 .amux = LINE2,
147 .gpio = 0x4000, 167 .gpio = 0x4000,
148 }}, 168 }},
149 .radio = { 169 .radio = {
150 .name = name_radio, 170 .name = name_radio,
151 .amux = LINE2, 171 .amux = LINE2,
152 .gpio = 0x2000, 172 .gpio = 0x2000,
153 }, 173 },
154 .mute = { 174 .mute = {
155 .name = name_mute, 175 .name = name_mute,
156 .amux = LINE2, 176 .amux = LINE2,
157 .gpio = 0x8000, 177 .gpio = 0x8000,
158 }, 178 },
159 }, 179 },
@@ -162,6 +182,10 @@ struct saa7134_board saa7134_boards[] = {
162 .name = "LifeView FlyTV Platinum Mini", 182 .name = "LifeView FlyTV Platinum Mini",
163 .audio_clock = 0x00200000, 183 .audio_clock = 0x00200000,
164 .tuner_type = TUNER_PHILIPS_TDA8290, 184 .tuner_type = TUNER_PHILIPS_TDA8290,
185 .radio_type = UNSET,
186 .tuner_addr = ADDR_UNSET,
187 .radio_addr = ADDR_UNSET,
188
165 .inputs = {{ 189 .inputs = {{
166 .name = name_tv, 190 .name = name_tv,
167 .vmux = 1, 191 .vmux = 1,
@@ -183,6 +207,10 @@ struct saa7134_board saa7134_boards[] = {
183 .name = "LifeView FlyTV Platinum FM", 207 .name = "LifeView FlyTV Platinum FM",
184 .audio_clock = 0x00200000, 208 .audio_clock = 0x00200000,
185 .tuner_type = TUNER_PHILIPS_TDA8290, 209 .tuner_type = TUNER_PHILIPS_TDA8290,
210 .radio_type = UNSET,
211 .tuner_addr = ADDR_UNSET,
212 .radio_addr = ADDR_UNSET,
213
186 .gpiomask = 0x1E000, /* Set GP16 and unused 15,14,13 to Output */ 214 .gpiomask = 0x1E000, /* Set GP16 and unused 15,14,13 to Output */
187 .inputs = {{ 215 .inputs = {{
188 .name = name_tv, 216 .name = name_tv,
@@ -190,7 +218,7 @@ struct saa7134_board saa7134_boards[] = {
190 .amux = TV, 218 .amux = TV,
191 .gpio = 0x10000, /* GP16=1 selects TV input */ 219 .gpio = 0x10000, /* GP16=1 selects TV input */
192 .tv = 1, 220 .tv = 1,
193 },{ 221 },{
194/* .name = name_tv_mono, 222/* .name = name_tv_mono,
195 .vmux = 1, 223 .vmux = 1,
196 .amux = LINE2, 224 .amux = LINE2,
@@ -200,29 +228,38 @@ struct saa7134_board saa7134_boards[] = {
200*/ .name = name_comp1, /* Composite signal on S-Video input */ 228*/ .name = name_comp1, /* Composite signal on S-Video input */
201 .vmux = 0, 229 .vmux = 0,
202 .amux = LINE2, 230 .amux = LINE2,
203// .gpio = 0x4000, 231/* .gpio = 0x4000, */
204 },{ 232 },{
205 .name = name_comp2, /* Composite input */ 233 .name = name_comp2, /* Composite input */
206 .vmux = 3, 234 .vmux = 3,
207 .amux = LINE2, 235 .amux = LINE2,
208// .gpio = 0x4000, 236/* .gpio = 0x4000, */
209 },{ 237 },{
210 .name = name_svideo, /* S-Video signal on S-Video input */ 238 .name = name_svideo, /* S-Video signal on S-Video input */
211 .vmux = 8, 239 .vmux = 8,
212 .amux = LINE2, 240 .amux = LINE2,
213// .gpio = 0x4000, 241/* .gpio = 0x4000, */
214 }}, 242 }},
215 .radio = { 243 .radio = {
216 .name = name_radio, 244 .name = name_radio,
217 .amux = TV, 245 .amux = TV,
218 .gpio = 0x00000, /* GP16=0 selects FM radio antenna */ 246 .gpio = 0x00000, /* GP16=0 selects FM radio antenna */
219 }, 247 },
248 .mute = {
249 .name = name_mute,
250 .amux = TV,
251 .gpio = 0x10000,
252 },
220 }, 253 },
221 [SAA7134_BOARD_EMPRESS] = { 254 [SAA7134_BOARD_EMPRESS] = {
222 /* "Gert Vervoort" <gert.vervoort@philips.com> */ 255 /* "Gert Vervoort" <gert.vervoort@philips.com> */
223 .name = "EMPRESS", 256 .name = "EMPRESS",
224 .audio_clock = 0x00187de7, 257 .audio_clock = 0x00187de7,
225 .tuner_type = TUNER_PHILIPS_PAL, 258 .tuner_type = TUNER_PHILIPS_PAL,
259 .radio_type = UNSET,
260 .tuner_addr = ADDR_UNSET,
261 .radio_addr = ADDR_UNSET,
262
226 .inputs = {{ 263 .inputs = {{
227 .name = name_comp1, 264 .name = name_comp1,
228 .vmux = 0, 265 .vmux = 0,
@@ -245,33 +282,40 @@ struct saa7134_board saa7134_boards[] = {
245 .video_out = CCIR656, 282 .video_out = CCIR656,
246 }, 283 },
247 [SAA7134_BOARD_MONSTERTV] = { 284 [SAA7134_BOARD_MONSTERTV] = {
248 /* "K.Ohta" <alpha292@bremen.or.jp> */ 285 /* "K.Ohta" <alpha292@bremen.or.jp> */
249 .name = "SKNet Monster TV", 286 .name = "SKNet Monster TV",
250 .audio_clock = 0x00187de7, 287 .audio_clock = 0x00187de7,
251 .tuner_type = TUNER_PHILIPS_NTSC_M, 288 .tuner_type = TUNER_PHILIPS_NTSC_M,
252 .inputs = {{ 289 .radio_type = UNSET,
253 .name = name_tv, 290 .tuner_addr = ADDR_UNSET,
254 .vmux = 1, 291 .radio_addr = ADDR_UNSET,
255 .amux = TV, 292
256 .tv = 1, 293 .inputs = {{
257 },{ 294 .name = name_tv,
258 .name = name_comp1, 295 .vmux = 1,
259 .vmux = 0, 296 .amux = TV,
260 .amux = LINE1, 297 .tv = 1,
261 },{ 298 },{
262 .name = name_svideo, 299 .name = name_comp1,
263 .vmux = 8, 300 .vmux = 0,
264 .amux = LINE1, 301 .amux = LINE1,
265 }}, 302 },{
266 .radio = { 303 .name = name_svideo,
267 .name = name_radio, 304 .vmux = 8,
268 .amux = LINE2, 305 .amux = LINE1,
269 }, 306 }},
307 .radio = {
308 .name = name_radio,
309 .amux = LINE2,
310 },
270 }, 311 },
271 [SAA7134_BOARD_MD9717] = { 312 [SAA7134_BOARD_MD9717] = {
272 .name = "Tevion MD 9717", 313 .name = "Tevion MD 9717",
273 .audio_clock = 0x00200000, 314 .audio_clock = 0x00200000,
274 .tuner_type = TUNER_PHILIPS_PAL, 315 .tuner_type = TUNER_PHILIPS_PAL,
316 .radio_type = UNSET,
317 .tuner_addr = ADDR_UNSET,
318 .radio_addr = ADDR_UNSET,
275 .inputs = {{ 319 .inputs = {{
276 .name = name_tv, 320 .name = name_tv,
277 .vmux = 1, 321 .vmux = 1,
@@ -302,10 +346,13 @@ struct saa7134_board saa7134_boards[] = {
302 }, 346 },
303 }, 347 },
304 [SAA7134_BOARD_TVSTATION_RDS] = { 348 [SAA7134_BOARD_TVSTATION_RDS] = {
305 /* Typhoon TV Tuner RDS: Art.Nr. 50694 */ 349 /* Typhoon TV Tuner RDS: Art.Nr. 50694 */
306 .name = "KNC One TV-Station RDS / Typhoon TV Tuner RDS", 350 .name = "KNC One TV-Station RDS / Typhoon TV Tuner RDS",
307 .audio_clock = 0x00200000, 351 .audio_clock = 0x00200000,
308 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, 352 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
353 .radio_type = UNSET,
354 .tuner_addr = ADDR_UNSET,
355 .radio_addr = ADDR_UNSET,
309 .tda9887_conf = TDA9887_PRESENT, 356 .tda9887_conf = TDA9887_PRESENT,
310 .inputs = {{ 357 .inputs = {{
311 .name = name_tv, 358 .name = name_tv,
@@ -314,10 +361,10 @@ struct saa7134_board saa7134_boards[] = {
314 .tv = 1, 361 .tv = 1,
315 },{ 362 },{
316 .name = name_tv_mono, 363 .name = name_tv_mono,
317 .vmux = 1, 364 .vmux = 1,
318 .amux = LINE2, 365 .amux = LINE2,
319 .tv = 1, 366 .tv = 1,
320 },{ 367 },{
321 368
322 .name = name_svideo, 369 .name = name_svideo,
323 .vmux = 8, 370 .vmux = 8,
@@ -328,10 +375,10 @@ struct saa7134_board saa7134_boards[] = {
328 .amux = LINE1, 375 .amux = LINE1,
329 },{ 376 },{
330 377
331 .name = "CVid over SVid", 378 .name = "CVid over SVid",
332 .vmux = 0, 379 .vmux = 0,
333 .amux = LINE1, 380 .amux = LINE1,
334 }}, 381 }},
335 .radio = { 382 .radio = {
336 .name = name_radio, 383 .name = name_radio,
337 .amux = LINE2, 384 .amux = LINE2,
@@ -341,6 +388,9 @@ struct saa7134_board saa7134_boards[] = {
341 .name = "KNC One TV-Station DVR", 388 .name = "KNC One TV-Station DVR",
342 .audio_clock = 0x00200000, 389 .audio_clock = 0x00200000,
343 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, 390 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
391 .radio_type = UNSET,
392 .tuner_addr = ADDR_UNSET,
393 .radio_addr = ADDR_UNSET,
344 .tda9887_conf = TDA9887_PRESENT, 394 .tda9887_conf = TDA9887_PRESENT,
345 .gpiomask = 0x820000, 395 .gpiomask = 0x820000,
346 .inputs = {{ 396 .inputs = {{
@@ -369,32 +419,38 @@ struct saa7134_board saa7134_boards[] = {
369 .video_out = CCIR656, 419 .video_out = CCIR656,
370 }, 420 },
371 [SAA7134_BOARD_CINERGY400] = { 421 [SAA7134_BOARD_CINERGY400] = {
372 .name = "Terratec Cinergy 400 TV", 422 .name = "Terratec Cinergy 400 TV",
373 .audio_clock = 0x00200000, 423 .audio_clock = 0x00200000,
374 .tuner_type = TUNER_PHILIPS_PAL, 424 .tuner_type = TUNER_PHILIPS_PAL,
375 .inputs = {{ 425 .radio_type = UNSET,
376 .name = name_tv, 426 .tuner_addr = ADDR_UNSET,
377 .vmux = 1, 427 .radio_addr = ADDR_UNSET,
378 .amux = TV, 428 .inputs = {{
379 .tv = 1, 429 .name = name_tv,
380 },{ 430 .vmux = 1,
381 .name = name_comp1, 431 .amux = TV,
382 .vmux = 4, 432 .tv = 1,
383 .amux = LINE1, 433 },{
384 },{ 434 .name = name_comp1,
385 .name = name_svideo, 435 .vmux = 4,
386 .vmux = 8, 436 .amux = LINE1,
387 .amux = LINE1, 437 },{
388 },{ 438 .name = name_svideo,
389 .name = name_comp2, // CVideo over SVideo Connector 439 .vmux = 8,
390 .vmux = 0, 440 .amux = LINE1,
391 .amux = LINE1, 441 },{
392 }} 442 .name = name_comp2, /* CVideo over SVideo Connector */
393 }, 443 .vmux = 0,
444 .amux = LINE1,
445 }}
446 },
394 [SAA7134_BOARD_MD5044] = { 447 [SAA7134_BOARD_MD5044] = {
395 .name = "Medion 5044", 448 .name = "Medion 5044",
396 .audio_clock = 0x00187de7, // was: 0x00200000, 449 .audio_clock = 0x00187de7, /* was: 0x00200000, */
397 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, 450 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
451 .radio_type = UNSET,
452 .tuner_addr = ADDR_UNSET,
453 .radio_addr = ADDR_UNSET,
398 .tda9887_conf = TDA9887_PRESENT, 454 .tda9887_conf = TDA9887_PRESENT,
399 .inputs = {{ 455 .inputs = {{
400 .name = name_tv, 456 .name = name_tv,
@@ -426,57 +482,65 @@ struct saa7134_board saa7134_boards[] = {
426 }, 482 },
427 }, 483 },
428 [SAA7134_BOARD_KWORLD] = { 484 [SAA7134_BOARD_KWORLD] = {
429 .name = "Kworld/KuroutoShikou SAA7130-TVPCI", 485 .name = "Kworld/KuroutoShikou SAA7130-TVPCI",
430 .audio_clock = 0x00187de7, 486 .audio_clock = 0x00187de7,
431 .tuner_type = TUNER_PHILIPS_NTSC_M, 487 .tuner_type = TUNER_PHILIPS_NTSC_M,
432 .inputs = {{ 488 .radio_type = UNSET,
433 .name = name_svideo, 489 .tuner_addr = ADDR_UNSET,
434 .vmux = 8, 490 .radio_addr = ADDR_UNSET,
435 .amux = LINE1, 491 .inputs = {{
436 },{ 492 .name = name_svideo,
437 .name = name_comp1, 493 .vmux = 8,
438 .vmux = 3, 494 .amux = LINE1,
439 .amux = LINE1, 495 },{
440 },{ 496 .name = name_comp1,
441 .name = name_tv, 497 .vmux = 3,
442 .vmux = 1, 498 .amux = LINE1,
443 .amux = LINE2, 499 },{
444 .tv = 1, 500 .name = name_tv,
445 }}, 501 .vmux = 1,
446 }, 502 .amux = LINE2,
503 .tv = 1,
504 }},
505 },
447 [SAA7134_BOARD_CINERGY600] = { 506 [SAA7134_BOARD_CINERGY600] = {
448 .name = "Terratec Cinergy 600 TV", 507 .name = "Terratec Cinergy 600 TV",
449 .audio_clock = 0x00200000, 508 .audio_clock = 0x00200000,
450 .tuner_type = TUNER_PHILIPS_PAL, 509 .tuner_type = TUNER_PHILIPS_PAL,
510 .radio_type = UNSET,
511 .tuner_addr = ADDR_UNSET,
512 .radio_addr = ADDR_UNSET,
451 .tda9887_conf = TDA9887_PRESENT, 513 .tda9887_conf = TDA9887_PRESENT,
452 .inputs = {{ 514 .inputs = {{
453 .name = name_tv, 515 .name = name_tv,
454 .vmux = 1, 516 .vmux = 1,
455 .amux = TV, 517 .amux = TV,
456 .tv = 1, 518 .tv = 1,
457 },{ 519 },{
458 .name = name_comp1, 520 .name = name_comp1,
459 .vmux = 4, 521 .vmux = 4,
460 .amux = LINE1, 522 .amux = LINE1,
461 },{ 523 },{
462 .name = name_svideo, 524 .name = name_svideo,
463 .vmux = 8, 525 .vmux = 8,
464 .amux = LINE1, 526 .amux = LINE1,
465 },{ 527 },{
466 .name = name_comp2, // CVideo over SVideo Connector 528 .name = name_comp2, /* CVideo over SVideo Connector */
467 .vmux = 0, 529 .vmux = 0,
468 .amux = LINE1, 530 .amux = LINE1,
469 }}, 531 }},
470 .radio = { 532 .radio = {
471 .name = name_radio, 533 .name = name_radio,
472 .amux = LINE2, 534 .amux = LINE2,
473 }, 535 },
474 }, 536 },
475 [SAA7134_BOARD_MD7134] = { 537 [SAA7134_BOARD_MD7134] = {
476 .name = "Medion 7134", 538 .name = "Medion 7134",
477 //.audio_clock = 0x00200000,
478 .audio_clock = 0x00187de7, 539 .audio_clock = 0x00187de7,
479 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, 540 .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3,
541 .radio_type = UNSET,
542 .tuner_addr = ADDR_UNSET,
543 .radio_addr = ADDR_UNSET,
480 .tda9887_conf = TDA9887_PRESENT, 544 .tda9887_conf = TDA9887_PRESENT,
481 .mpeg = SAA7134_MPEG_DVB, 545 .mpeg = SAA7134_MPEG_DVB,
482 .inputs = {{ 546 .inputs = {{
@@ -504,6 +568,9 @@ struct saa7134_board saa7134_boards[] = {
504 .name = "Typhoon TV+Radio 90031", 568 .name = "Typhoon TV+Radio 90031",
505 .audio_clock = 0x00200000, 569 .audio_clock = 0x00200000,
506 .tuner_type = TUNER_PHILIPS_PAL, 570 .tuner_type = TUNER_PHILIPS_PAL,
571 .radio_type = UNSET,
572 .tuner_addr = ADDR_UNSET,
573 .radio_addr = ADDR_UNSET,
507 .tda9887_conf = TDA9887_PRESENT, 574 .tda9887_conf = TDA9887_PRESENT,
508 .inputs = {{ 575 .inputs = {{
509 .name = name_tv, 576 .name = name_tv,
@@ -523,11 +590,14 @@ struct saa7134_board saa7134_boards[] = {
523 .name = name_radio, 590 .name = name_radio,
524 .amux = LINE2, 591 .amux = LINE2,
525 }, 592 },
526 }, 593 },
527 [SAA7134_BOARD_ELSA] = { 594 [SAA7134_BOARD_ELSA] = {
528 .name = "ELSA EX-VISION 300TV", 595 .name = "ELSA EX-VISION 300TV",
529 .audio_clock = 0x00187de7, 596 .audio_clock = 0x00187de7,
530 .tuner_type = TUNER_HITACHI_NTSC, 597 .tuner_type = TUNER_HITACHI_NTSC,
598 .radio_type = UNSET,
599 .tuner_addr = ADDR_UNSET,
600 .radio_addr = ADDR_UNSET,
531 .inputs = {{ 601 .inputs = {{
532 .name = name_svideo, 602 .name = name_svideo,
533 .vmux = 8, 603 .vmux = 8,
@@ -542,11 +612,14 @@ struct saa7134_board saa7134_boards[] = {
542 .amux = LINE2, 612 .amux = LINE2,
543 .tv = 1, 613 .tv = 1,
544 }}, 614 }},
545 }, 615 },
546 [SAA7134_BOARD_ELSA_500TV] = { 616 [SAA7134_BOARD_ELSA_500TV] = {
547 .name = "ELSA EX-VISION 500TV", 617 .name = "ELSA EX-VISION 500TV",
548 .audio_clock = 0x00187de7, 618 .audio_clock = 0x00187de7,
549 .tuner_type = TUNER_HITACHI_NTSC, 619 .tuner_type = TUNER_HITACHI_NTSC,
620 .radio_type = UNSET,
621 .tuner_addr = ADDR_UNSET,
622 .radio_addr = ADDR_UNSET,
550 .inputs = {{ 623 .inputs = {{
551 .name = name_svideo, 624 .name = name_svideo,
552 .vmux = 7, 625 .vmux = 7,
@@ -562,83 +635,100 @@ struct saa7134_board saa7134_boards[] = {
562 .amux = LINE2, 635 .amux = LINE2,
563 .tv = 1, 636 .tv = 1,
564 }}, 637 }},
565 }, 638 },
566 [SAA7134_BOARD_ASUSTeK_TVFM7134] = { 639 [SAA7134_BOARD_ASUSTeK_TVFM7134] = {
567 .name = "ASUS TV-FM 7134", 640 .name = "ASUS TV-FM 7134",
568 .audio_clock = 0x00187de7, 641 .audio_clock = 0x00187de7,
569 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, 642 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
570 .tda9887_conf = TDA9887_PRESENT, 643 .radio_type = UNSET,
571 .inputs = {{ 644 .tuner_addr = ADDR_UNSET,
572 .name = name_tv, 645 .radio_addr = ADDR_UNSET,
573 .vmux = 1, 646 .tda9887_conf = TDA9887_PRESENT,
574 .amux = TV, 647 .inputs = {{
575 .tv = 1, 648 .name = name_tv,
576 },{ 649 .vmux = 1,
577 .name = name_comp1, 650 .amux = TV,
578 .vmux = 4, 651 .tv = 1,
579 .amux = LINE2, 652 },{
580 },{ 653 .name = name_comp1,
581 .name = name_svideo, 654 .vmux = 4,
582 .vmux = 6, 655 .amux = LINE2,
583 .amux = LINE2, 656 },{
584 }}, 657 .name = name_svideo,
585 .radio = { 658 .vmux = 6,
586 .name = name_radio, 659 .amux = LINE2,
587 .amux = LINE1, 660 }},
588 }, 661 .radio = {
589 }, 662 .name = name_radio,
590 [SAA7135_BOARD_ASUSTeK_TVFM7135] = { 663 .amux = LINE1,
591 .name = "ASUS TV-FM 7135", 664 },
592 .audio_clock = 0x00187de7, 665 },
593 .tuner_type = TUNER_PHILIPS_TDA8290, 666 [SAA7134_BOARD_ASUSTeK_TVFM7135] = {
667 .name = "ASUS TV-FM 7135",
668 .audio_clock = 0x00187de7,
669 .tuner_type = TUNER_PHILIPS_TDA8290,
670 .radio_type = UNSET,
671 .tuner_addr = ADDR_UNSET,
672 .radio_addr = ADDR_UNSET,
594 .gpiomask = 0x200000, 673 .gpiomask = 0x200000,
595 .inputs = {{ 674 .inputs = {{
596 .name = name_tv, 675 .name = name_tv,
597 .vmux = 1, 676 .vmux = 1,
598 .amux = TV, 677 .amux = TV,
599 .gpio = 0x0000, 678 .gpio = 0x0000,
600 .tv = 1, 679 .tv = 1,
601 },{ 680 },{
602 .name = name_comp1, 681 .name = name_comp1,
603 .vmux = 4, 682 .vmux = 4,
604 .amux = LINE2, 683 .amux = LINE2,
605 .gpio = 0x0000, 684 .gpio = 0x0000,
606 },{ 685 },{
607 .name = name_svideo, 686 .name = name_svideo,
608 .vmux = 6, 687 .vmux = 6,
609 .amux = LINE2, 688 .amux = LINE2,
610 .gpio = 0x0000, 689 .gpio = 0x0000,
611 }}, 690 }},
612 .radio = { 691 .radio = {
613 .name = name_radio, 692 .name = name_radio,
614 .amux = TV, 693 .amux = TV,
615 .gpio = 0x200000, 694 .gpio = 0x200000,
616 }, 695 },
696 .mute = {
697 .name = name_mute,
698 .gpio = 0x0000,
699 },
700
617 }, 701 },
618 [SAA7134_BOARD_VA1000POWER] = { 702 [SAA7134_BOARD_VA1000POWER] = {
619 .name = "AOPEN VA1000 POWER", 703 .name = "AOPEN VA1000 POWER",
620 .audio_clock = 0x00187de7, 704 .audio_clock = 0x00187de7,
621 .tuner_type = TUNER_PHILIPS_NTSC, 705 .tuner_type = TUNER_PHILIPS_NTSC,
622 .inputs = {{ 706 .radio_type = UNSET,
623 .name = name_svideo, 707 .tuner_addr = ADDR_UNSET,
624 .vmux = 8, 708 .radio_addr = ADDR_UNSET,
625 .amux = LINE1, 709 .inputs = {{
626 },{ 710 .name = name_svideo,
627 .name = name_comp1, 711 .vmux = 8,
628 .vmux = 3, 712 .amux = LINE1,
629 .amux = LINE1, 713 },{
630 },{ 714 .name = name_comp1,
631 .name = name_tv, 715 .vmux = 3,
632 .vmux = 1, 716 .amux = LINE1,
633 .amux = LINE2, 717 },{
634 .tv = 1, 718 .name = name_tv,
635 }}, 719 .vmux = 1,
720 .amux = LINE2,
721 .tv = 1,
722 }},
636 }, 723 },
637 [SAA7134_BOARD_10MOONSTVMASTER] = { 724 [SAA7134_BOARD_10MOONSTVMASTER] = {
638 /* "lilicheng" <llc@linuxfans.org> */ 725 /* "lilicheng" <llc@linuxfans.org> */
639 .name = "10MOONS PCI TV CAPTURE CARD", 726 .name = "10MOONS PCI TV CAPTURE CARD",
640 .audio_clock = 0x00200000, 727 .audio_clock = 0x00200000,
641 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 728 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
729 .radio_type = UNSET,
730 .tuner_addr = ADDR_UNSET,
731 .radio_addr = ADDR_UNSET,
642 .gpiomask = 0xe000, 732 .gpiomask = 0xe000,
643 .inputs = {{ 733 .inputs = {{
644 .name = name_tv, 734 .name = name_tv,
@@ -662,14 +752,14 @@ struct saa7134_board saa7134_boards[] = {
662 .amux = LINE2, 752 .amux = LINE2,
663 .gpio = 0x4000, 753 .gpio = 0x4000,
664 }}, 754 }},
665 .radio = { 755 .radio = {
666 .name = name_radio, 756 .name = name_radio,
667 .amux = LINE2, 757 .amux = LINE2,
668 .gpio = 0x2000, 758 .gpio = 0x2000,
669 }, 759 },
670 .mute = { 760 .mute = {
671 .name = name_mute, 761 .name = name_mute,
672 .amux = LINE2, 762 .amux = LINE2,
673 .gpio = 0x8000, 763 .gpio = 0x8000,
674 }, 764 },
675 }, 765 },
@@ -678,6 +768,9 @@ struct saa7134_board saa7134_boards[] = {
678 .name = "BMK MPEX No Tuner", 768 .name = "BMK MPEX No Tuner",
679 .audio_clock = 0x200000, 769 .audio_clock = 0x200000,
680 .tuner_type = TUNER_ABSENT, 770 .tuner_type = TUNER_ABSENT,
771 .radio_type = UNSET,
772 .tuner_addr = ADDR_UNSET,
773 .radio_addr = ADDR_UNSET,
681 .inputs = {{ 774 .inputs = {{
682 .name = name_comp1, 775 .name = name_comp1,
683 .vmux = 4, 776 .vmux = 4,
@@ -706,80 +799,94 @@ struct saa7134_board saa7134_boards[] = {
706 .name = "Compro VideoMate TV", 799 .name = "Compro VideoMate TV",
707 .audio_clock = 0x00187de7, 800 .audio_clock = 0x00187de7,
708 .tuner_type = TUNER_PHILIPS_NTSC_M, 801 .tuner_type = TUNER_PHILIPS_NTSC_M,
709 .inputs = {{ 802 .radio_type = UNSET,
710 .name = name_svideo, 803 .tuner_addr = ADDR_UNSET,
711 .vmux = 8, 804 .radio_addr = ADDR_UNSET,
712 .amux = LINE1, 805 .inputs = {{
713 },{ 806 .name = name_svideo,
714 .name = name_comp1, 807 .vmux = 8,
715 .vmux = 3, 808 .amux = LINE1,
716 .amux = LINE1, 809 },{
717 },{ 810 .name = name_comp1,
718 .name = name_tv, 811 .vmux = 3,
719 .vmux = 1, 812 .amux = LINE1,
720 .amux = LINE2, 813 },{
721 .tv = 1, 814 .name = name_tv,
722 }}, 815 .vmux = 1,
723 }, 816 .amux = LINE2,
724 [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS] = { 817 .tv = 1,
818 }},
819 },
820 [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS] = {
725 .name = "Compro VideoMate TV Gold+", 821 .name = "Compro VideoMate TV Gold+",
726 .audio_clock = 0x00187de7, 822 .audio_clock = 0x00187de7,
727 .tuner_type = TUNER_PHILIPS_NTSC_M, 823 .tuner_type = TUNER_PHILIPS_NTSC_M,
728 .gpiomask = 0x800c0000, 824 .gpiomask = 0x800c0000,
729 .inputs = {{ 825 .radio_type = UNSET,
730 .name = name_svideo, 826 .tuner_addr = ADDR_UNSET,
731 .vmux = 8, 827 .radio_addr = ADDR_UNSET,
732 .amux = LINE1, 828 .inputs = {{
733 .gpio = 0x06c00012, 829 .name = name_svideo,
734 },{ 830 .vmux = 8,
735 .name = name_comp1, 831 .amux = LINE1,
736 .vmux = 3, 832 .gpio = 0x06c00012,
737 .amux = LINE1, 833 },{
738 .gpio = 0x0ac20012, 834 .name = name_comp1,
739 },{ 835 .vmux = 3,
740 .name = name_tv, 836 .amux = LINE1,
741 .vmux = 1, 837 .gpio = 0x0ac20012,
742 .amux = LINE2, 838 },{
743 .gpio = 0x08c20012, 839 .name = name_tv,
744 .tv = 1, 840 .vmux = 1,
745 }}, 841 .amux = LINE2,
746 }, 842 .gpio = 0x08c20012,
843 .tv = 1,
844 }}, /* radio and probably mute is missing */
845 },
747 [SAA7134_BOARD_CRONOS_PLUS] = { 846 [SAA7134_BOARD_CRONOS_PLUS] = {
748 /* gpio pins: 847 /*
749 0 .. 3 BASE_ID 848 gpio pins:
750 4 .. 7 PROTECT_ID 849 0 .. 3 BASE_ID
751 8 .. 11 USER_OUT 850 4 .. 7 PROTECT_ID
752 12 .. 13 USER_IN 851 8 .. 11 USER_OUT
753 14 .. 15 VIDIN_SEL */ 852 12 .. 13 USER_IN
853 14 .. 15 VIDIN_SEL
854 */
754 .name = "Matrox CronosPlus", 855 .name = "Matrox CronosPlus",
755 .tuner_type = TUNER_ABSENT, 856 .tuner_type = TUNER_ABSENT,
857 .radio_type = UNSET,
858 .tuner_addr = ADDR_UNSET,
859 .radio_addr = ADDR_UNSET,
756 .gpiomask = 0xcf00, 860 .gpiomask = 0xcf00,
757 .inputs = {{ 861 .inputs = {{
758 .name = name_comp1, 862 .name = name_comp1,
759 .vmux = 0, 863 .vmux = 0,
760 .gpio = 2 << 14, 864 .gpio = 2 << 14,
761 },{ 865 },{
762 .name = name_comp2, 866 .name = name_comp2,
763 .vmux = 0, 867 .vmux = 0,
764 .gpio = 1 << 14, 868 .gpio = 1 << 14,
765 },{ 869 },{
766 .name = name_comp3, 870 .name = name_comp3,
767 .vmux = 0, 871 .vmux = 0,
768 .gpio = 0 << 14, 872 .gpio = 0 << 14,
769 },{ 873 },{
770 .name = name_comp4, 874 .name = name_comp4,
771 .vmux = 0, 875 .vmux = 0,
772 .gpio = 3 << 14, 876 .gpio = 3 << 14,
773 },{ 877 },{
774 .name = name_svideo, 878 .name = name_svideo,
775 .vmux = 8, 879 .vmux = 8,
776 .gpio = 2 << 14, 880 .gpio = 2 << 14,
777 }}, 881 }},
778 }, 882 },
779 [SAA7134_BOARD_MD2819] = { 883 [SAA7134_BOARD_MD2819] = {
780 .name = "AverMedia M156 / Medion 2819", 884 .name = "AverMedia M156 / Medion 2819",
781 .audio_clock = 0x00187de7, 885 .audio_clock = 0x00187de7,
782 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, 886 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
887 .radio_type = UNSET,
888 .tuner_addr = ADDR_UNSET,
889 .radio_addr = ADDR_UNSET,
783 .tda9887_conf = TDA9887_PRESENT, 890 .tda9887_conf = TDA9887_PRESENT,
784 .inputs = {{ 891 .inputs = {{
785 .name = name_tv, 892 .name = name_tv,
@@ -809,6 +916,9 @@ struct saa7134_board saa7134_boards[] = {
809 .name = "BMK MPEX Tuner", 916 .name = "BMK MPEX Tuner",
810 .audio_clock = 0x200000, 917 .audio_clock = 0x200000,
811 .tuner_type = TUNER_PHILIPS_PAL, 918 .tuner_type = TUNER_PHILIPS_PAL,
919 .radio_type = UNSET,
920 .tuner_addr = ADDR_UNSET,
921 .radio_addr = ADDR_UNSET,
812 .inputs = {{ 922 .inputs = {{
813 .name = name_comp1, 923 .name = name_comp1,
814 .vmux = 1, 924 .vmux = 1,
@@ -825,62 +935,72 @@ struct saa7134_board saa7134_boards[] = {
825 }}, 935 }},
826 .mpeg = SAA7134_MPEG_EMPRESS, 936 .mpeg = SAA7134_MPEG_EMPRESS,
827 .video_out = CCIR656, 937 .video_out = CCIR656,
828 }, 938 },
829 [SAA7134_BOARD_ASUSTEK_TVFM7133] = { 939 [SAA7134_BOARD_ASUSTEK_TVFM7133] = {
830 .name = "ASUS TV-FM 7133", 940 .name = "ASUS TV-FM 7133",
831 .audio_clock = 0x00187de7, 941 .audio_clock = 0x00187de7,
832 // probably wrong, the 7133 one is the NTSC version ... 942 /* probably wrong, the 7133 one is the NTSC version ...
833 // .tuner_type = TUNER_PHILIPS_FM1236_MK3 943 * .tuner_type = TUNER_PHILIPS_FM1236_MK3 */
834 .tuner_type = TUNER_LG_NTSC_NEW_TAPC, 944 .tuner_type = TUNER_LG_NTSC_NEW_TAPC,
835 .tda9887_conf = TDA9887_PRESENT, 945 .radio_type = UNSET,
836 .inputs = {{ 946 .tuner_addr = ADDR_UNSET,
837 .name = name_tv, 947 .radio_addr = ADDR_UNSET,
838 .vmux = 1, 948 .tda9887_conf = TDA9887_PRESENT,
839 .amux = TV, 949 .inputs = {{
840 .tv = 1, 950 .name = name_tv,
841 },{ 951 .vmux = 1,
842 .name = name_comp1, 952 .amux = TV,
843 .vmux = 4, 953 .tv = 1,
844 .amux = LINE2, 954
845 },{ 955 },{
846 .name = name_svideo, 956 .name = name_comp1,
847 .vmux = 6, 957 .vmux = 4,
848 .amux = LINE2, 958 .amux = LINE2,
849 }}, 959 },{
850 .radio = { 960 .name = name_svideo,
851 .name = name_radio, 961 .vmux = 6,
852 .amux = LINE1, 962 .amux = LINE2,
853 }, 963 }},
854 }, 964 .radio = {
965 .name = name_radio,
966 .amux = LINE1,
967 },
968 },
855 [SAA7134_BOARD_PINNACLE_PCTV_STEREO] = { 969 [SAA7134_BOARD_PINNACLE_PCTV_STEREO] = {
856 .name = "Pinnacle PCTV Stereo (saa7134)", 970 .name = "Pinnacle PCTV Stereo (saa7134)",
857 .audio_clock = 0x00187de7, 971 .audio_clock = 0x00187de7,
858 .tuner_type = TUNER_MT2032, 972 .tuner_type = TUNER_MT2032,
859 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER, 973 .radio_type = UNSET,
860 .inputs = {{ 974 .tuner_addr = ADDR_UNSET,
861 .name = name_tv, 975 .radio_addr = ADDR_UNSET,
862 .vmux = 3, 976 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER,
863 .amux = TV, 977 .inputs = {{
864 .tv = 1, 978 .name = name_tv,
865 },{ 979 .vmux = 3,
866 .name = name_comp1, 980 .amux = TV,
867 .vmux = 0, 981 .tv = 1,
868 .amux = LINE2, 982 },{
869 },{ 983 .name = name_comp1,
870 .name = name_comp2, 984 .vmux = 0,
871 .vmux = 1, 985 .amux = LINE2,
872 .amux = LINE2, 986 },{
873 },{ 987 .name = name_comp2,
874 .name = name_svideo, 988 .vmux = 1,
875 .vmux = 8, 989 .amux = LINE2,
876 .amux = LINE2, 990 },{
877 }}, 991 .name = name_svideo,
878 }, 992 .vmux = 8,
993 .amux = LINE2,
994 }},
995 },
879 [SAA7134_BOARD_MANLI_MTV002] = { 996 [SAA7134_BOARD_MANLI_MTV002] = {
880 /* Ognjen Nastic <ognjen@logosoft.ba> */ 997 /* Ognjen Nastic <ognjen@logosoft.ba> */
881 .name = "Manli MuchTV M-TV002/Behold TV 403 FM", 998 .name = "Manli MuchTV M-TV002/Behold TV 403 FM",
882 .audio_clock = 0x00200000, 999 .audio_clock = 0x00200000,
883 .tuner_type = TUNER_PHILIPS_PAL, 1000 .tuner_type = TUNER_PHILIPS_PAL,
1001 .radio_type = UNSET,
1002 .tuner_addr = ADDR_UNSET,
1003 .radio_addr = ADDR_UNSET,
884 .inputs = {{ 1004 .inputs = {{
885 .name = name_svideo, 1005 .name = name_svideo,
886 .vmux = 8, 1006 .vmux = 8,
@@ -905,6 +1025,9 @@ struct saa7134_board saa7134_boards[] = {
905 .name = "Manli MuchTV M-TV001/Behold TV 401", 1025 .name = "Manli MuchTV M-TV001/Behold TV 401",
906 .audio_clock = 0x00200000, 1026 .audio_clock = 0x00200000,
907 .tuner_type = TUNER_PHILIPS_PAL, 1027 .tuner_type = TUNER_PHILIPS_PAL,
1028 .radio_type = UNSET,
1029 .tuner_addr = ADDR_UNSET,
1030 .radio_addr = ADDR_UNSET,
908 .inputs = {{ 1031 .inputs = {{
909 .name = name_svideo, 1032 .name = name_svideo,
910 .vmux = 8, 1033 .vmux = 8,
@@ -921,14 +1044,17 @@ struct saa7134_board saa7134_boards[] = {
921 }}, 1044 }},
922 .mute = { 1045 .mute = {
923 .name = name_mute, 1046 .name = name_mute,
924 .amux = LINE1, 1047 .amux = LINE1,
925 }, 1048 },
926 }, 1049 },
927 [SAA7134_BOARD_TG3000TV] = { 1050 [SAA7134_BOARD_TG3000TV] = {
928 /* TransGear 3000TV */ 1051 /* TransGear 3000TV */
929 .name = "Nagase Sangyo TransGear 3000TV", 1052 .name = "Nagase Sangyo TransGear 3000TV",
930 .audio_clock = 0x00187de7, 1053 .audio_clock = 0x00187de7,
931 .tuner_type = TUNER_PHILIPS_NTSC_M, 1054 .tuner_type = TUNER_PHILIPS_NTSC_M,
1055 .radio_type = UNSET,
1056 .tuner_addr = ADDR_UNSET,
1057 .radio_addr = ADDR_UNSET,
932 .inputs = {{ 1058 .inputs = {{
933 .name = name_tv, 1059 .name = name_tv,
934 .vmux = 1, 1060 .vmux = 1,
@@ -944,81 +1070,90 @@ struct saa7134_board saa7134_boards[] = {
944 .amux = LINE2, 1070 .amux = LINE2,
945 }}, 1071 }},
946 }, 1072 },
947 [SAA7134_BOARD_ECS_TVP3XP] = { 1073 [SAA7134_BOARD_ECS_TVP3XP] = {
948 .name = "Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM) ", 1074 .name = "Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM) ",
949 .audio_clock = 0x187de7, // xtal 32.1 MHz 1075 .audio_clock = 0x187de7, /* xtal 32.1 MHz */
950 .tuner_type = TUNER_PHILIPS_PAL, 1076 .tuner_type = TUNER_PHILIPS_PAL,
951 .inputs = {{ 1077 .radio_type = UNSET,
952 .name = name_tv, 1078 .tuner_addr = ADDR_UNSET,
953 .vmux = 1, 1079 .radio_addr = ADDR_UNSET,
954 .amux = TV, 1080 .inputs = {{
955 .tv = 1, 1081 .name = name_tv,
956 },{ 1082 .vmux = 1,
957 .name = name_tv_mono, 1083 .amux = TV,
958 .vmux = 1, 1084 .tv = 1,
959 .amux = LINE2, 1085 },{
960 .tv = 1, 1086 .name = name_tv_mono,
961 },{ 1087 .vmux = 1,
962 .name = name_comp1, 1088 .amux = LINE2,
963 .vmux = 3, 1089 .tv = 1,
964 .amux = LINE1, 1090 },{
965 },{ 1091 .name = name_comp1,
966 .name = name_svideo, 1092 .vmux = 3,
967 .vmux = 8, 1093 .amux = LINE1,
968 .amux = LINE1, 1094 },{
1095 .name = name_svideo,
1096 .vmux = 8,
1097 .amux = LINE1,
969 },{ 1098 },{
970 .name = "CVid over SVid", 1099 .name = "CVid over SVid",
971 .vmux = 0, 1100 .vmux = 0,
972 .amux = LINE1, 1101 .amux = LINE1,
973 }}, 1102 }},
974 .radio = { 1103 .radio = {
975 .name = name_radio, 1104 .name = name_radio,
976 .amux = LINE2, 1105 .amux = LINE2,
977 }, 1106 },
978 }, 1107 },
979 [SAA7134_BOARD_ECS_TVP3XP_4CB5] = { 1108 [SAA7134_BOARD_ECS_TVP3XP_4CB5] = {
980 .name = "Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM)", 1109 .name = "Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM)",
981 .audio_clock = 0x187de7, 1110 .audio_clock = 0x187de7,
982 .tuner_type = TUNER_PHILIPS_NTSC, 1111 .tuner_type = TUNER_PHILIPS_NTSC,
983 .inputs = {{ 1112 .radio_type = UNSET,
984 .name = name_tv, 1113 .tuner_addr = ADDR_UNSET,
985 .vmux = 1, 1114 .radio_addr = ADDR_UNSET,
986 .amux = TV, 1115 .inputs = {{
987 .tv = 1, 1116 .name = name_tv,
988 },{ 1117 .vmux = 1,
989 .name = name_tv_mono, 1118 .amux = TV,
990 .vmux = 1, 1119 .tv = 1,
991 .amux = LINE2, 1120 },{
992 .tv = 1, 1121 .name = name_tv_mono,
993 },{ 1122 .vmux = 1,
994 .name = name_comp1, 1123 .amux = LINE2,
995 .vmux = 3, 1124 .tv = 1,
996 .amux = LINE1, 1125 },{
997 },{ 1126 .name = name_comp1,
998 .name = name_svideo, 1127 .vmux = 3,
999 .vmux = 8, 1128 .amux = LINE1,
1000 .amux = LINE1, 1129 },{
1001 },{ 1130 .name = name_svideo,
1002 .name = "CVid over SVid", 1131 .vmux = 8,
1003 .vmux = 0, 1132 .amux = LINE1,
1004 .amux = LINE1, 1133 },{
1005 }}, 1134 .name = "CVid over SVid",
1006 .radio = { 1135 .vmux = 0,
1007 .name = name_radio, 1136 .amux = LINE1,
1008 .amux = LINE2, 1137 }},
1009 }, 1138 .radio = {
1010 }, 1139 .name = name_radio,
1140 .amux = LINE2,
1141 },
1142 },
1011 [SAA7134_BOARD_AVACSSMARTTV] = { 1143 [SAA7134_BOARD_AVACSSMARTTV] = {
1012 /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */ 1144 /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */
1013 .name = "AVACS SmartTV", 1145 .name = "AVACS SmartTV",
1014 .audio_clock = 0x00187de7, 1146 .audio_clock = 0x00187de7,
1015 .tuner_type = TUNER_PHILIPS_PAL, 1147 .tuner_type = TUNER_PHILIPS_PAL,
1148 .radio_type = UNSET,
1149 .tuner_addr = ADDR_UNSET,
1150 .radio_addr = ADDR_UNSET,
1016 .inputs = {{ 1151 .inputs = {{
1017 .name = name_tv, 1152 .name = name_tv,
1018 .vmux = 1, 1153 .vmux = 1,
1019 .amux = TV, 1154 .amux = TV,
1020 .tv = 1, 1155 .tv = 1,
1021 },{ 1156 },{
1022 .name = name_tv_mono, 1157 .name = name_tv_mono,
1023 .vmux = 1, 1158 .vmux = 1,
1024 .amux = LINE2, 1159 .amux = LINE2,
@@ -1047,6 +1182,9 @@ struct saa7134_board saa7134_boards[] = {
1047 .name = "AVerMedia DVD EZMaker", 1182 .name = "AVerMedia DVD EZMaker",
1048 .audio_clock = 0x00187de7, 1183 .audio_clock = 0x00187de7,
1049 .tuner_type = TUNER_ABSENT, 1184 .tuner_type = TUNER_ABSENT,
1185 .radio_type = UNSET,
1186 .tuner_addr = ADDR_UNSET,
1187 .radio_addr = ADDR_UNSET,
1050 .inputs = {{ 1188 .inputs = {{
1051 .name = name_comp1, 1189 .name = name_comp1,
1052 .vmux = 3, 1190 .vmux = 3,
@@ -1055,28 +1193,34 @@ struct saa7134_board saa7134_boards[] = {
1055 .vmux = 8, 1193 .vmux = 8,
1056 }}, 1194 }},
1057 }, 1195 },
1058 [SAA7134_BOARD_NOVAC_PRIMETV7133] = { 1196 [SAA7134_BOARD_NOVAC_PRIMETV7133] = {
1059 /* toshii@netbsd.org */ 1197 /* toshii@netbsd.org */
1060 .name = "Noval Prime TV 7133", 1198 .name = "Noval Prime TV 7133",
1061 .audio_clock = 0x00200000, 1199 .audio_clock = 0x00200000,
1062 .tuner_type = TUNER_ALPS_TSBH1_NTSC, 1200 .tuner_type = TUNER_ALPS_TSBH1_NTSC,
1063 .inputs = {{ 1201 .radio_type = UNSET,
1064 .name = name_comp1, 1202 .tuner_addr = ADDR_UNSET,
1065 .vmux = 3, 1203 .radio_addr = ADDR_UNSET,
1066 },{ 1204 .inputs = {{
1067 .name = name_tv, 1205 .name = name_comp1,
1068 .vmux = 1, 1206 .vmux = 3,
1069 .amux = TV, 1207 },{
1070 .tv = 1, 1208 .name = name_tv,
1071 },{ 1209 .vmux = 1,
1072 .name = name_svideo, 1210 .amux = TV,
1073 .vmux = 8, 1211 .tv = 1,
1074 }}, 1212 },{
1075 }, 1213 .name = name_svideo,
1214 .vmux = 8,
1215 }},
1216 },
1076 [SAA7134_BOARD_AVERMEDIA_STUDIO_305] = { 1217 [SAA7134_BOARD_AVERMEDIA_STUDIO_305] = {
1077 .name = "AverMedia AverTV Studio 305", 1218 .name = "AverMedia AverTV Studio 305",
1078 .audio_clock = 0x00187de7, 1219 .audio_clock = 0x00187de7,
1079 .tuner_type = TUNER_PHILIPS_FM1256_IH3, 1220 .tuner_type = TUNER_PHILIPS_FM1256_IH3,
1221 .radio_type = UNSET,
1222 .tuner_addr = ADDR_UNSET,
1223 .radio_addr = ADDR_UNSET,
1080 .tda9887_conf = TDA9887_PRESENT, 1224 .tda9887_conf = TDA9887_PRESENT,
1081 .inputs = {{ 1225 .inputs = {{
1082 .name = name_tv, 1226 .name = name_tv,
@@ -1097,35 +1241,41 @@ struct saa7134_board saa7134_boards[] = {
1097 .amux = LINE2, 1241 .amux = LINE2,
1098 }}, 1242 }},
1099 .radio = { 1243 .radio = {
1100 .name = name_radio, 1244 .name = name_radio,
1101 .amux = LINE2, 1245 .amux = LINE2,
1102 }, 1246 },
1103 .mute = { 1247 .mute = {
1104 .name = name_mute, 1248 .name = name_mute,
1105 .amux = LINE1, 1249 .amux = LINE1,
1106 }, 1250 },
1107 }, 1251 },
1108 [SAA7133_BOARD_UPMOST_PURPLE_TV] = { 1252 [SAA7134_BOARD_UPMOST_PURPLE_TV] = {
1109 .name = "UPMOST PURPLE TV", 1253 .name = "UPMOST PURPLE TV",
1110 .audio_clock = 0x00187de7, 1254 .audio_clock = 0x00187de7,
1111 .tuner_type = TUNER_PHILIPS_FM1236_MK3, 1255 .tuner_type = TUNER_PHILIPS_FM1236_MK3,
1112 .tda9887_conf = TDA9887_PRESENT, 1256 .radio_type = UNSET,
1113 .inputs = {{ 1257 .tuner_addr = ADDR_UNSET,
1114 .name = name_tv, 1258 .radio_addr = ADDR_UNSET,
1115 .vmux = 7, 1259 .tda9887_conf = TDA9887_PRESENT,
1116 .amux = TV, 1260 .inputs = {{
1117 .tv = 1, 1261 .name = name_tv,
1118 },{ 1262 .vmux = 7,
1119 .name = name_svideo, 1263 .amux = TV,
1120 .vmux = 7, 1264 .tv = 1,
1121 .amux = LINE1, 1265 },{
1122 }}, 1266 .name = name_svideo,
1267 .vmux = 7,
1268 .amux = LINE1,
1269 }},
1123 }, 1270 },
1124 [SAA7134_BOARD_ITEMS_MTV005] = { 1271 [SAA7134_BOARD_ITEMS_MTV005] = {
1125 /* Norman Jonas <normanjonas@arcor.de> */ 1272 /* Norman Jonas <normanjonas@arcor.de> */
1126 .name = "Items MuchTV Plus / IT-005", 1273 .name = "Items MuchTV Plus / IT-005",
1127 .audio_clock = 0x00187de7, 1274 .audio_clock = 0x00187de7,
1128 .tuner_type = TUNER_PHILIPS_PAL, 1275 .tuner_type = TUNER_PHILIPS_PAL,
1276 .radio_type = UNSET,
1277 .tuner_addr = ADDR_UNSET,
1278 .radio_addr = ADDR_UNSET,
1129 .inputs = {{ 1279 .inputs = {{
1130 .name = name_tv, 1280 .name = name_tv,
1131 .vmux = 3, 1281 .vmux = 3,
@@ -1149,27 +1299,30 @@ struct saa7134_board saa7134_boards[] = {
1149 .name = "Terratec Cinergy 200 TV", 1299 .name = "Terratec Cinergy 200 TV",
1150 .audio_clock = 0x00200000, 1300 .audio_clock = 0x00200000,
1151 .tuner_type = TUNER_PHILIPS_PAL, 1301 .tuner_type = TUNER_PHILIPS_PAL,
1302 .radio_type = UNSET,
1303 .tuner_addr = ADDR_UNSET,
1304 .radio_addr = ADDR_UNSET,
1152 .inputs = {{ 1305 .inputs = {{
1153 .name = name_tv, 1306 .name = name_tv,
1154 .vmux = 1, 1307 .vmux = 1,
1155 .amux = LINE2, 1308 .amux = LINE2,
1156 .tv = 1, 1309 .tv = 1,
1157 },{ 1310 },{
1158 .name = name_comp1, 1311 .name = name_comp1,
1159 .vmux = 4, 1312 .vmux = 4,
1160 .amux = LINE1, 1313 .amux = LINE1,
1161 },{ 1314 },{
1162 .name = name_svideo, 1315 .name = name_svideo,
1163 .vmux = 8, 1316 .vmux = 8,
1164 .amux = LINE1, 1317 .amux = LINE1,
1165 },{ 1318 },{
1166 .name = name_comp2, // CVideo over SVideo Connector 1319 .name = name_comp2, /* CVideo over SVideo Connector */
1167 .vmux = 0, 1320 .vmux = 0,
1168 .amux = LINE1, 1321 .amux = LINE1,
1169 }}, 1322 }},
1170 .mute = { 1323 .mute = {
1171 .name = name_mute, 1324 .name = name_mute,
1172 .amux = LINE2, 1325 .amux = LINE2,
1173 }, 1326 },
1174 }, 1327 },
1175 [SAA7134_BOARD_VIDEOMATE_TV_PVR] = { 1328 [SAA7134_BOARD_VIDEOMATE_TV_PVR] = {
@@ -1177,84 +1330,96 @@ struct saa7134_board saa7134_boards[] = {
1177 .name = "Compro VideoMate TV PVR/FM", 1330 .name = "Compro VideoMate TV PVR/FM",
1178 .audio_clock = 0x00187de7, 1331 .audio_clock = 0x00187de7,
1179 .tuner_type = TUNER_PHILIPS_NTSC_M, 1332 .tuner_type = TUNER_PHILIPS_NTSC_M,
1333 .radio_type = UNSET,
1334 .tuner_addr = ADDR_UNSET,
1335 .radio_addr = ADDR_UNSET,
1180 .gpiomask = 0x808c0080, 1336 .gpiomask = 0x808c0080,
1181 .inputs = {{ 1337 .inputs = {{
1182 .name = name_svideo, 1338 .name = name_svideo,
1183 .vmux = 8, 1339 .vmux = 8,
1184 .amux = LINE1, 1340 .amux = LINE1,
1185 .gpio = 0x00080, 1341 .gpio = 0x00080,
1186 },{ 1342 },{
1187 .name = name_comp1, 1343 .name = name_comp1,
1188 .vmux = 3, 1344 .vmux = 3,
1189 .amux = LINE1, 1345 .amux = LINE1,
1190 .gpio = 0x00080, 1346 .gpio = 0x00080,
1191 },{ 1347 },{
1192 .name = name_tv, 1348 .name = name_tv,
1193 .vmux = 1, 1349 .vmux = 1,
1194 .amux = LINE2_LEFT, 1350 .amux = LINE2_LEFT,
1195 .tv = 1, 1351 .tv = 1,
1196 .gpio = 0x00080, 1352 .gpio = 0x00080,
1197 }}, 1353 }},
1198 .radio = { 1354 .radio = {
1199 .name = name_radio, 1355 .name = name_radio,
1200 .amux = LINE2, 1356 .amux = LINE2,
1201 .gpio = 0x80000, 1357 .gpio = 0x80000,
1202 }, 1358 },
1203 .mute = { 1359 .mute = {
1204 .name = name_mute, 1360 .name = name_mute,
1205 .amux = LINE2, 1361 .amux = LINE2,
1206 .gpio = 0x40000, 1362 .gpio = 0x40000,
1207 }, 1363 },
1208 }, 1364 },
1209 [SAA7134_BOARD_SABRENT_SBTTVFM] = { 1365 [SAA7134_BOARD_SABRENT_SBTTVFM] = {
1210 /* Michael Rodriguez-Torrent <mrtorrent@asu.edu> */ 1366 /* Michael Rodriguez-Torrent <mrtorrent@asu.edu> */
1211 .name = "Sabrent SBT-TVFM (saa7130)", 1367 .name = "Sabrent SBT-TVFM (saa7130)",
1212 .audio_clock = 0x00187de7, 1368 .audio_clock = 0x00187de7,
1213 .tuner_type = TUNER_PHILIPS_NTSC_M, 1369 .tuner_type = TUNER_PHILIPS_NTSC_M,
1214 .inputs = {{ 1370 .radio_type = UNSET,
1371 .tuner_addr = ADDR_UNSET,
1372 .radio_addr = ADDR_UNSET,
1373 .inputs = {{
1215 .name = name_comp1, 1374 .name = name_comp1,
1216 .vmux = 1, 1375 .vmux = 1,
1217 .amux = LINE2, 1376 .amux = LINE2,
1218 },{ 1377 },{
1219 .name = name_tv, 1378 .name = name_tv,
1220 .vmux = 3, 1379 .vmux = 3,
1221 .amux = LINE2, 1380 .amux = LINE2,
1222 .tv = 1, 1381 .tv = 1,
1223 },{ 1382 },{
1224 .name = name_svideo, 1383 .name = name_svideo,
1225 .vmux = 8, 1384 .vmux = 8,
1226 .amux = LINE2, 1385 .amux = LINE2,
1227 }}, 1386 }},
1228 .radio = { 1387 .radio = {
1229 .name = name_radio, 1388 .name = name_radio,
1230 .amux = LINE2, 1389 .amux = LINE2,
1231 }, 1390 },
1232 }, 1391 },
1233 [SAA7134_BOARD_ZOLID_XPERT_TV7134] = { 1392 [SAA7134_BOARD_ZOLID_XPERT_TV7134] = {
1234 /* Helge Jensen <helge.jensen@slog.dk> */ 1393 /* Helge Jensen <helge.jensen@slog.dk> */
1235 .name = ":Zolid Xpert TV7134", 1394 .name = ":Zolid Xpert TV7134",
1236 .audio_clock = 0x00187de7, 1395 .audio_clock = 0x00187de7,
1237 .tuner_type = TUNER_PHILIPS_NTSC, 1396 .tuner_type = TUNER_PHILIPS_NTSC,
1238 .inputs = {{ 1397 .radio_type = UNSET,
1398 .tuner_addr = ADDR_UNSET,
1399 .radio_addr = ADDR_UNSET,
1400 .inputs = {{
1239 .name = name_svideo, 1401 .name = name_svideo,
1240 .vmux = 8, 1402 .vmux = 8,
1241 .amux = LINE1, 1403 .amux = LINE1,
1242 },{ 1404 },{
1243 .name = name_comp1, 1405 .name = name_comp1,
1244 .vmux = 3, 1406 .vmux = 3,
1245 .amux = LINE1, 1407 .amux = LINE1,
1246 },{ 1408 },{
1247 .name = name_tv, 1409 .name = name_tv,
1248 .vmux = 1, 1410 .vmux = 1,
1249 .amux = LINE2, 1411 .amux = LINE2,
1250 .tv = 1, 1412 .tv = 1,
1251 }}, 1413 }},
1252 }, 1414 },
1253 [SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE] = { 1415 [SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE] = {
1254 /* "Matteo Az" <matte.az@nospam.libero.it> ;-) */ 1416 /* "Matteo Az" <matte.az@nospam.libero.it> ;-) */
1255 .name = "Empire PCI TV-Radio LE", 1417 .name = "Empire PCI TV-Radio LE",
1256 .audio_clock = 0x00187de7, 1418 .audio_clock = 0x00187de7,
1257 .tuner_type = TUNER_PHILIPS_PAL, 1419 .tuner_type = TUNER_PHILIPS_PAL,
1420 .radio_type = UNSET,
1421 .tuner_addr = ADDR_UNSET,
1422 .radio_addr = ADDR_UNSET,
1258 .gpiomask = 0x4000, 1423 .gpiomask = 0x4000,
1259 .inputs = {{ 1424 .inputs = {{
1260 .name = name_tv_mono, 1425 .name = name_tv_mono,
@@ -1273,18 +1438,18 @@ struct saa7134_board saa7134_boards[] = {
1273 .amux = LINE1, 1438 .amux = LINE1,
1274 .gpio = 0x8000, 1439 .gpio = 0x8000,
1275 }}, 1440 }},
1276 .radio = { 1441 .radio = {
1277 .name = name_radio, 1442 .name = name_radio,
1278 .amux = LINE1, 1443 .amux = LINE1,
1279 .gpio = 0x8000, 1444 .gpio = 0x8000,
1280 }, 1445 },
1281 .mute = { 1446 .mute = {
1282 .name = name_mute, 1447 .name = name_mute,
1283 .amux = TV, 1448 .amux = TV,
1284 .gpio =0x8000, 1449 .gpio =0x8000,
1285 } 1450 }
1286 }, 1451 },
1287 [SAA7134_BOARD_AVERMEDIA_STUDIO_307] = { 1452 [SAA7134_BOARD_AVERMEDIA_STUDIO_307] = {
1288 /* 1453 /*
1289 Nickolay V. Shmyrev <nshmyrev@yandex.ru> 1454 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
1290 Lots of thanks to Andrey Zolotarev <zolotarev_andrey@mail.ru> 1455 Lots of thanks to Andrey Zolotarev <zolotarev_andrey@mail.ru>
@@ -1292,6 +1457,9 @@ struct saa7134_board saa7134_boards[] = {
1292 .name = "Avermedia AVerTV Studio 307", 1457 .name = "Avermedia AVerTV Studio 307",
1293 .audio_clock = 0x00187de7, 1458 .audio_clock = 0x00187de7,
1294 .tuner_type = TUNER_PHILIPS_FM1256_IH3, 1459 .tuner_type = TUNER_PHILIPS_FM1256_IH3,
1460 .radio_type = UNSET,
1461 .tuner_addr = ADDR_UNSET,
1462 .radio_addr = ADDR_UNSET,
1295 .tda9887_conf = TDA9887_PRESENT, 1463 .tda9887_conf = TDA9887_PRESENT,
1296 .gpiomask = 0x03, 1464 .gpiomask = 0x03,
1297 .inputs = {{ 1465 .inputs = {{
@@ -1321,13 +1489,21 @@ struct saa7134_board saa7134_boards[] = {
1321 .amux = LINE1, 1489 .amux = LINE1,
1322 .gpio = 0x01, 1490 .gpio = 0x01,
1323 }, 1491 },
1324 }, 1492 .mute = {
1325 [SAA7134_BOARD_AVERMEDIA_GO_007_FM] = { 1493 .name = name_mute,
1494 .amux = LINE1,
1495 .gpio = 0x00,
1496 },
1497 },
1498 [SAA7134_BOARD_AVERMEDIA_GO_007_FM] = {
1326 .name = "Avermedia AVerTV GO 007 FM", 1499 .name = "Avermedia AVerTV GO 007 FM",
1327 .audio_clock = 0x00187de7, 1500 .audio_clock = 0x00187de7,
1328 .tuner_type = TUNER_PHILIPS_TDA8290, 1501 .tuner_type = TUNER_PHILIPS_TDA8290,
1502 .radio_type = UNSET,
1503 .tuner_addr = ADDR_UNSET,
1504 .radio_addr = ADDR_UNSET,
1329 .gpiomask = 0x00300003, 1505 .gpiomask = 0x00300003,
1330// .gpiomask = 0x8c240003, 1506 /* .gpiomask = 0x8c240003, */
1331 .inputs = {{ 1507 .inputs = {{
1332 .name = name_tv, 1508 .name = name_tv,
1333 .vmux = 1, 1509 .vmux = 1,
@@ -1350,16 +1526,24 @@ struct saa7134_board saa7134_boards[] = {
1350 .amux = LINE1, 1526 .amux = LINE1,
1351 .gpio = 0x00300001, 1527 .gpio = 0x00300001,
1352 }, 1528 },
1353 }, 1529 .mute = {
1530 .name = name_mute,
1531 .amux = TV,
1532 .gpio = 0x01,
1533 },
1534 },
1354 [SAA7134_BOARD_AVERMEDIA_CARDBUS] = { 1535 [SAA7134_BOARD_AVERMEDIA_CARDBUS] = {
1355 /* Jon Westgate <oryn@oryn.fsck.tv> */ 1536 /* Kees.Blom@cwi.nl */
1356 .name = "AVerMedia Cardbus TV/Radio", 1537 .name = "AVerMedia Cardbus TV/Radio (E500)",
1357 .audio_clock = 0x00200000, 1538 .audio_clock = 0x187de7,
1358 .tuner_type = TUNER_PHILIPS_PAL, 1539 .tuner_type = TUNER_PHILIPS_TDA8290,
1540 .radio_type = UNSET,
1541 .tuner_addr = ADDR_UNSET,
1542 .radio_addr = ADDR_UNSET,
1359 .inputs = {{ 1543 .inputs = {{
1360 .name = name_tv, 1544 .name = name_tv,
1361 .vmux = 1, 1545 .vmux = 1,
1362 .amux = LINE2, 1546 .amux = TV,
1363 .tv = 1, 1547 .tv = 1,
1364 },{ 1548 },{
1365 .name = name_comp1, 1549 .name = name_comp1,
@@ -1368,10 +1552,10 @@ struct saa7134_board saa7134_boards[] = {
1368 },{ 1552 },{
1369 .name = name_svideo, 1553 .name = name_svideo,
1370 .vmux = 8, 1554 .vmux = 8,
1371 .amux = LINE2, 1555 .amux = LINE1,
1372 }}, 1556 }},
1373 .radio = { 1557 .radio = {
1374 .name = name_radio, 1558 .name = name_radio,
1375 .amux = LINE1, 1559 .amux = LINE1,
1376 }, 1560 },
1377 }, 1561 },
@@ -1379,119 +1563,134 @@ struct saa7134_board saa7134_boards[] = {
1379 .name = "Terratec Cinergy 400 mobile", 1563 .name = "Terratec Cinergy 400 mobile",
1380 .audio_clock = 0x187de7, 1564 .audio_clock = 0x187de7,
1381 .tuner_type = TUNER_ALPS_TSBE5_PAL, 1565 .tuner_type = TUNER_ALPS_TSBE5_PAL,
1382 .tda9887_conf = TDA9887_PRESENT, 1566 .radio_type = UNSET,
1567 .tuner_addr = ADDR_UNSET,
1568 .radio_addr = ADDR_UNSET,
1569 .tda9887_conf = TDA9887_PRESENT,
1383 .inputs = {{ 1570 .inputs = {{
1384 .name = name_tv, 1571 .name = name_tv,
1385 .vmux = 1, 1572 .vmux = 1,
1386 .amux = TV, 1573 .amux = TV,
1387 .tv = 1, 1574 .tv = 1,
1388 },{ 1575 },{
1389 .name = name_tv_mono, 1576 .name = name_tv_mono,
1390 .vmux = 1, 1577 .vmux = 1,
1391 .amux = LINE2, 1578 .amux = LINE2,
1392 .tv = 1, 1579 .tv = 1,
1393 },{ 1580 },{
1394 .name = name_comp1, 1581 .name = name_comp1,
1395 .vmux = 3, 1582 .vmux = 3,
1396 .amux = LINE1, 1583 .amux = LINE1,
1397 },{ 1584 },{
1398 .name = name_svideo, 1585 .name = name_svideo,
1399 .vmux = 8, 1586 .vmux = 8,
1400 .amux = LINE1, 1587 .amux = LINE1,
1401 }}, 1588 }},
1402 }, 1589 },
1403 [SAA7134_BOARD_CINERGY600_MK3] = { 1590 [SAA7134_BOARD_CINERGY600_MK3] = {
1404 .name = "Terratec Cinergy 600 TV MK3", 1591 .name = "Terratec Cinergy 600 TV MK3",
1405 .audio_clock = 0x00200000, 1592 .audio_clock = 0x00200000,
1406 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, 1593 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
1407 .tda9887_conf = TDA9887_PRESENT, 1594 .radio_type = UNSET,
1408 .inputs = {{ 1595 .tuner_addr = ADDR_UNSET,
1409 .name = name_tv, 1596 .radio_addr = ADDR_UNSET,
1410 .vmux = 1, 1597 .tda9887_conf = TDA9887_PRESENT,
1411 .amux = TV, 1598 .inputs = {{
1412 .tv = 1, 1599 .name = name_tv,
1413 },{ 1600 .vmux = 1,
1414 .name = name_comp1, 1601 .amux = TV,
1415 .vmux = 4, 1602 .tv = 1,
1416 .amux = LINE1, 1603 },{
1417 },{ 1604 .name = name_comp1,
1418 .name = name_svideo, 1605 .vmux = 4,
1419 .vmux = 8, 1606 .amux = LINE1,
1420 .amux = LINE1, 1607 },{
1421 },{ 1608 .name = name_svideo,
1422 .name = name_comp2, // CVideo over SVideo Connector 1609 .vmux = 8,
1423 .vmux = 0, 1610 .amux = LINE1,
1424 .amux = LINE1, 1611 },{
1425 }}, 1612 .name = name_comp2, /* CVideo over SVideo Connector */
1613 .vmux = 0,
1614 .amux = LINE1,
1615 }},
1426 .radio = { 1616 .radio = {
1427 .name = name_radio, 1617 .name = name_radio,
1428 .amux = LINE2, 1618 .amux = LINE2,
1429 }, 1619 },
1430 }, 1620 },
1431 [SAA7134_BOARD_VIDEOMATE_GOLD_PLUS] = { 1621 [SAA7134_BOARD_VIDEOMATE_GOLD_PLUS] = {
1432 /* Dylan Walkden <dylan_walkden@hotmail.com> */ 1622 /* Dylan Walkden <dylan_walkden@hotmail.com> */
1433 .name = "Compro VideoMate Gold+ Pal", 1623 .name = "Compro VideoMate Gold+ Pal",
1434 .audio_clock = 0x00187de7, 1624 .audio_clock = 0x00187de7,
1435 .tuner_type = TUNER_PHILIPS_PAL, 1625 .tuner_type = TUNER_PHILIPS_PAL,
1436 .gpiomask = 0x1ce780, 1626 .radio_type = UNSET,
1437 .inputs = {{ 1627 .tuner_addr = ADDR_UNSET,
1438 .name = name_svideo, 1628 .radio_addr = ADDR_UNSET,
1439 .vmux = 0, // CVideo over SVideo Connector - ok? 1629 .gpiomask = 0x1ce780,
1440 .amux = LINE1, 1630 .inputs = {{
1441 .gpio = 0x008080, 1631 .name = name_svideo,
1442 },{ 1632 .vmux = 0, /* CVideo over SVideo Connector - ok? */
1443 .name = name_comp1, 1633 .amux = LINE1,
1444 .vmux = 3, 1634 .gpio = 0x008080,
1445 .amux = LINE1, 1635 },{
1446 .gpio = 0x008080, 1636 .name = name_comp1,
1447 },{ 1637 .vmux = 3,
1448 .name = name_tv, 1638 .amux = LINE1,
1449 .vmux = 1, 1639 .gpio = 0x008080,
1450 .amux = TV, 1640 },{
1451 .tv = 1, 1641 .name = name_tv,
1452 .gpio = 0x008080, 1642 .vmux = 1,
1453 }}, 1643 .amux = TV,
1454 .radio = { 1644 .tv = 1,
1455 .name = name_radio, 1645 .gpio = 0x008080,
1456 .amux = LINE2, 1646 }},
1457 .gpio = 0x80000, 1647 .radio = {
1458 }, 1648 .name = name_radio,
1459 .mute = { 1649 .amux = LINE2,
1460 .name = name_mute, 1650 .gpio = 0x80000,
1461 .amux = LINE2, 1651 },
1462 .gpio = 0x0c8000, 1652 .mute = {
1463 }, 1653 .name = name_mute,
1464 }, 1654 .amux = LINE2,
1655 .gpio = 0x0c8000,
1656 },
1657 },
1465 [SAA7134_BOARD_PINNACLE_300I_DVBT_PAL] = { 1658 [SAA7134_BOARD_PINNACLE_300I_DVBT_PAL] = {
1466 .name = "Pinnacle PCTV 300i DVB-T + PAL", 1659 .name = "Pinnacle PCTV 300i DVB-T + PAL",
1467 .audio_clock = 0x00187de7, 1660 .audio_clock = 0x00187de7,
1468 .tuner_type = TUNER_MT2032, 1661 .tuner_type = TUNER_MT2032,
1469 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER, 1662 .radio_type = UNSET,
1663 .tuner_addr = ADDR_UNSET,
1664 .radio_addr = ADDR_UNSET,
1665 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER,
1470 .mpeg = SAA7134_MPEG_DVB, 1666 .mpeg = SAA7134_MPEG_DVB,
1471 .inputs = {{ 1667 .inputs = {{
1472 .name = name_tv, 1668 .name = name_tv,
1473 .vmux = 3, 1669 .vmux = 3,
1474 .amux = TV, 1670 .amux = TV,
1475 .tv = 1, 1671 .tv = 1,
1476 },{ 1672 },{
1477 .name = name_comp1, 1673 .name = name_comp1,
1478 .vmux = 0, 1674 .vmux = 0,
1479 .amux = LINE2, 1675 .amux = LINE2,
1480 },{ 1676 },{
1481 .name = name_comp2, 1677 .name = name_comp2,
1482 .vmux = 1, 1678 .vmux = 1,
1483 .amux = LINE2, 1679 .amux = LINE2,
1484 },{ 1680 },{
1485 .name = name_svideo, 1681 .name = name_svideo,
1486 .vmux = 8, 1682 .vmux = 8,
1487 .amux = LINE2, 1683 .amux = LINE2,
1488 }}, 1684 }},
1489 }, 1685 },
1490 [SAA7134_BOARD_PROVIDEO_PV952] = { 1686 [SAA7134_BOARD_PROVIDEO_PV952] = {
1491 /* andreas.kretschmer@web.de */ 1687 /* andreas.kretschmer@web.de */
1492 .name = "ProVideo PV952", 1688 .name = "ProVideo PV952",
1493 .audio_clock = 0x00187de7, 1689 .audio_clock = 0x00187de7,
1494 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, 1690 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
1691 .radio_type = UNSET,
1692 .tuner_addr = ADDR_UNSET,
1693 .radio_addr = ADDR_UNSET,
1495 .tda9887_conf = TDA9887_PRESENT, 1694 .tda9887_conf = TDA9887_PRESENT,
1496 .inputs = {{ 1695 .inputs = {{
1497 .name = name_comp1, 1696 .name = name_comp1,
@@ -1515,10 +1714,13 @@ struct saa7134_board saa7134_boards[] = {
1515 }, 1714 },
1516 [SAA7134_BOARD_AVERMEDIA_305] = { 1715 [SAA7134_BOARD_AVERMEDIA_305] = {
1517 /* much like the "studio" version but without radio 1716 /* much like the "studio" version but without radio
1518 * and another tuner (sirspiritus@yandex.ru) */ 1717 * and another tuner (sirspiritus@yandex.ru) */
1519 .name = "AverMedia AverTV/305", 1718 .name = "AverMedia AverTV/305",
1520 .audio_clock = 0x00187de7, 1719 .audio_clock = 0x00187de7,
1521 .tuner_type = TUNER_PHILIPS_FQ1216ME, 1720 .tuner_type = TUNER_PHILIPS_FQ1216ME,
1721 .radio_type = UNSET,
1722 .tuner_addr = ADDR_UNSET,
1723 .radio_addr = ADDR_UNSET,
1522 .tda9887_conf = TDA9887_PRESENT, 1724 .tda9887_conf = TDA9887_PRESENT,
1523 .inputs = {{ 1725 .inputs = {{
1524 .name = name_tv, 1726 .name = name_tv,
@@ -1539,115 +1741,268 @@ struct saa7134_board saa7134_boards[] = {
1539 .amux = LINE2, 1741 .amux = LINE2,
1540 }}, 1742 }},
1541 .mute = { 1743 .mute = {
1542 .name = name_mute, 1744 .name = name_mute,
1543 .amux = LINE1, 1745 .amux = LINE1,
1544 }, 1746 },
1545 }, 1747 },
1546 [SAA7134_BOARD_FLYDVBTDUO] = { 1748 [SAA7134_BOARD_FLYDVBTDUO] = {
1547 /* LifeView FlyDVB-T DUO */ 1749 /* LifeView FlyDVB-T DUO */
1548 /* "Nico Sabbi <nsabbi@tiscali.it> */ 1750 /* "Nico Sabbi <nsabbi@tiscali.it> Hartmut Hackmann hartmut.hackmann@t-online.de*/
1549 .name = "LifeView FlyDVB-T DUO", 1751 .name = "LifeView FlyDVB-T DUO",
1550 .audio_clock = 0x00200000, 1752 .audio_clock = 0x00200000,
1551 .tuner_type = TUNER_PHILIPS_TDA8290, 1753 .tuner_type = TUNER_PHILIPS_TDA8290,
1552// .gpiomask = 0xe000, 1754 .radio_type = UNSET,
1755 .tuner_addr = ADDR_UNSET,
1756 .radio_addr = ADDR_UNSET,
1757 .mpeg = SAA7134_MPEG_DVB,
1553 .inputs = {{ 1758 .inputs = {{
1554 .name = name_tv, 1759 .name = name_tv,
1555 .vmux = 1, 1760 .vmux = 1,
1556 .amux = TV, 1761 .amux = TV,
1557// .gpio = 0x0000,
1558 .tv = 1, 1762 .tv = 1,
1559 },{ 1763 },{
1560 .name = name_comp1, /* Composite signal on S-Video input */ 1764 .name = name_comp1, /* Composite signal on S-Video input */
1561 .vmux = 0, 1765 .vmux = 0,
1562 .amux = LINE2, 1766 .amux = LINE2,
1563// .gpio = 0x4000,
1564 },{ 1767 },{
1565 .name = name_comp2, /* Composite input */ 1768 .name = name_comp2, /* Composite input */
1566 .vmux = 3, 1769 .vmux = 3,
1567 .amux = LINE2, 1770 .amux = LINE2,
1568// .gpio = 0x4000,
1569 },{ 1771 },{
1570 .name = name_svideo, /* S-Video signal on S-Video input */ 1772 .name = name_svideo, /* S-Video signal on S-Video input */
1571 .vmux = 8, 1773 .vmux = 8,
1572 .amux = LINE2, 1774 .amux = LINE2,
1573// .gpio = 0x4000,
1574 }}, 1775 }},
1575 }, 1776 },
1576 [SAA7134_BOARD_AVERMEDIA_307] = { 1777 [SAA7134_BOARD_PHILIPS_TOUGH] = {
1577 /* 1778 .name = "Philips TOUGH DVB-T reference design",
1578 Davydov Vladimir <vladimir@iqmedia.com> 1779 .tuner_type = TUNER_ABSENT,
1579 */ 1780 .audio_clock = 0x00187de7,
1580 .name = "Avermedia AVerTV 307", 1781 .radio_type = UNSET,
1581 .audio_clock = 0x00187de7, 1782 .tuner_addr = ADDR_UNSET,
1582 .tuner_type = TUNER_PHILIPS_FQ1216ME, 1783 .radio_addr = ADDR_UNSET,
1583 .tda9887_conf = TDA9887_PRESENT, 1784 .mpeg = SAA7134_MPEG_DVB,
1584 .inputs = {{ 1785 .inputs = {{
1585 .name = name_tv, 1786 .name = name_comp1,
1586 .vmux = 1, 1787 .vmux = 0,
1587 .amux = TV, 1788 .amux = LINE1,
1588 .tv = 1, 1789 },{
1589 },{ 1790 .name = name_svideo,
1590 .name = name_comp1, 1791 .vmux = 8,
1591 .vmux = 0, 1792 .amux = LINE1,
1592 .amux = LINE1, 1793 }},
1593 },{ 1794 },
1594 .name = name_comp2, 1795 [SAA7134_BOARD_AVERMEDIA_307] = {
1595 .vmux = 3, 1796 /*
1596 .amux = LINE1, 1797 Davydov Vladimir <vladimir@iqmedia.com>
1597 },{ 1798 */
1598 .name = name_svideo, 1799 .name = "Avermedia AVerTV 307",
1599 .vmux = 8, 1800 .audio_clock = 0x00187de7,
1600 .amux = LINE1, 1801 .tuner_type = TUNER_PHILIPS_FQ1216ME,
1601 }}, 1802 .radio_type = UNSET,
1602 }, 1803 .tuner_addr = ADDR_UNSET,
1804 .radio_addr = ADDR_UNSET,
1805 .tda9887_conf = TDA9887_PRESENT,
1806 .inputs = {{
1807 .name = name_tv,
1808 .vmux = 1,
1809 .amux = TV,
1810 .tv = 1,
1811 },{
1812 .name = name_comp1,
1813 .vmux = 0,
1814 .amux = LINE1,
1815 },{
1816 .name = name_comp2,
1817 .vmux = 3,
1818 .amux = LINE1,
1819 },{
1820 .name = name_svideo,
1821 .vmux = 8,
1822 .amux = LINE1,
1823 }},
1824 },
1603 [SAA7134_BOARD_ADS_INSTANT_TV] = { 1825 [SAA7134_BOARD_ADS_INSTANT_TV] = {
1604 .name = "ADS Tech Instant TV (saa7135)", 1826 .name = "ADS Tech Instant TV (saa7135)",
1827 .audio_clock = 0x00187de7,
1828 .tuner_type = TUNER_PHILIPS_TDA8290,
1829 .radio_type = UNSET,
1830 .tuner_addr = ADDR_UNSET,
1831 .radio_addr = ADDR_UNSET,
1832 .inputs = {{
1833 .name = name_tv,
1834 .vmux = 1,
1835 .amux = TV,
1836 .tv = 1,
1837 },{
1838 .name = name_comp1,
1839 .vmux = 3,
1840 .amux = LINE2,
1841 },{
1842 .name = name_svideo,
1843 .vmux = 8,
1844 .amux = LINE2,
1845 }},
1846 },
1847 [SAA7134_BOARD_KWORLD_VSTREAM_XPERT] = {
1848 .name = "Kworld/Tevion V-Stream Xpert TV PVR7134",
1605 .audio_clock = 0x00187de7, 1849 .audio_clock = 0x00187de7,
1606 .tuner_type = TUNER_PHILIPS_TDA8290, 1850 .tuner_type = TUNER_PHILIPS_PAL_I,
1607 .inputs = {{ 1851 .radio_type = UNSET,
1608 .name = name_tv, 1852 .tuner_addr = ADDR_UNSET,
1609 .vmux = 1, 1853 .radio_addr = ADDR_UNSET,
1610 .amux = TV, 1854 .gpiomask = 0x0700,
1611 .tv = 1, 1855 .inputs = {{
1612 },{ 1856 .name = name_tv,
1613 .name = name_comp1, 1857 .vmux = 1,
1614 .vmux = 3, 1858 .amux = TV,
1615 .amux = LINE2, 1859 .tv = 1,
1616 },{ 1860 .gpio = 0x000,
1617 .name = name_svideo, 1861 },{
1618 .vmux = 8, 1862 .name = name_comp1,
1619 .amux = LINE2, 1863 .vmux = 3,
1620 }}, 1864 .amux = LINE1,
1621 }, 1865 .gpio = 0x200, /* gpio by DScaler */
1622 [SAA7134_BOARD_KWORLD_VSTREAM_XPERT] = { 1866 },{
1623 .name = "Kworld/Tevion V-Stream Xpert TV PVR7134", 1867 .name = name_svideo,
1624 .audio_clock = 0x00187de7, 1868 .vmux = 0,
1625 .tuner_type = TUNER_PHILIPS_PAL_I, 1869 .amux = LINE1,
1626 .gpiomask = 0x0700, 1870 .gpio = 0x200,
1627 .inputs = {{ 1871 }},
1628 .name = name_tv, 1872 .radio = {
1629 .vmux = 1, 1873 .name = name_radio,
1630 .amux = TV, 1874 .amux = LINE1,
1631 .tv = 1, 1875 .gpio = 0x100,
1632 .gpio = 0x000, 1876 },
1633 },{ 1877 .mute = {
1634 .name = name_comp1, 1878 .name = name_mute,
1635 .vmux = 3, 1879 .amux = TV,
1636 .amux = LINE1, 1880 .gpio = 0x000,
1637 .gpio = 0x200, //gpio by DScaler 1881 },
1638 },{ 1882 },
1639 .name = name_svideo, 1883 [SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS] = {
1640 .vmux = 0, 1884 .name = "Typhoon DVB-T Duo Digital/Analog Cardbus",
1641 .amux = LINE1, 1885 .audio_clock = 0x00200000,
1642 .gpio = 0x200, 1886 .tuner_type = TUNER_PHILIPS_TDA8290,
1643 }}, 1887 .radio_type = UNSET,
1644 .radio = { 1888 .tuner_addr = ADDR_UNSET,
1645 .name = name_radio, 1889 .radio_addr = ADDR_UNSET,
1646 .amux = LINE1, 1890 .mpeg = SAA7134_MPEG_DVB,
1647 .gpio = 0x100, 1891 /* .gpiomask = 0xe000, */
1648 }, 1892 .inputs = {{
1649 }, 1893 .name = name_tv,
1650 }; 1894 .vmux = 1,
1895 .amux = TV,
1896 /* .gpio = 0x0000, */
1897 .tv = 1,
1898 },{
1899 .name = name_comp1, /* Composite signal on S-Video input */
1900 .vmux = 0,
1901 .amux = LINE2,
1902 /* .gpio = 0x4000, */
1903 },{
1904 .name = name_comp2, /* Composite input */
1905 .vmux = 3,
1906 .amux = LINE2,
1907 /* .gpio = 0x4000, */
1908 },{
1909 .name = name_svideo, /* S-Video signal on S-Video input */
1910 .vmux = 8,
1911 .amux = LINE2,
1912 /* .gpio = 0x4000, */
1913 }},
1914 .radio = {
1915 .name = name_radio,
1916 .amux = LINE2,
1917 },
1918 .mute = {
1919 .name = name_mute,
1920 .amux = LINE1,
1921 },
1922 },
1923 [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII] = {
1924 .name = "Compro VideoMate TV Gold+II",
1925 .audio_clock = 0x002187de7,
1926 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
1927 .radio_type = TUNER_TEA5767,
1928 .tuner_addr = 0x63,
1929 .radio_addr = 0x60,
1930 .gpiomask = 0x8c1880,
1931 .inputs = {{
1932 .name = name_svideo,
1933 .vmux = 0,
1934 .amux = LINE1,
1935 .gpio = 0x800800,
1936 },{
1937 .name = name_comp1,
1938 .vmux = 3,
1939 .amux = LINE1,
1940 .gpio = 0x801000,
1941 },{
1942 .name = name_tv,
1943 .vmux = 1,
1944 .amux = TV,
1945 .tv = 1,
1946 .gpio = 0x800000,
1947 }},
1948 .radio = {
1949 .name = name_radio,
1950 .amux = TV,
1951 .gpio = 0x880000,
1952 },
1953 .mute = {
1954 .name = name_mute,
1955 .amux = LINE2,
1956 .gpio = 0x840000,
1957 },
1958 },
1959 [SAA7134_BOARD_KWORLD_XPERT] = {
1960 /*
1961 FIXME:
1962 - Remote control doesn't initialize properly.
1963 - Audio volume starts muted,
1964 then gradually increases after channel change.
1965 - Overlay scaling problems (application error?)
1966 - Composite S-Video untested.
1967 From: Konrad Rzepecki <hannibal@megapolis.pl>
1968 */
1969 .name = "Kworld Xpert TV PVR7134",
1970 .audio_clock = 0x00187de7,
1971 .tuner_type = TUNER_TENA_9533_DI,
1972 .radio_type = TUNER_TEA5767,
1973 .tuner_addr = 0x61,
1974 .radio_addr = 0x60,
1975 .gpiomask = 0x0700,
1976 .inputs = {{
1977 .name = name_tv,
1978 .vmux = 1,
1979 .amux = TV,
1980 .tv = 1,
1981 .gpio = 0x000,
1982 },{
1983 .name = name_comp1,
1984 .vmux = 3,
1985 .amux = LINE1,
1986 .gpio = 0x200, /* gpio by DScaler */
1987 },{
1988 .name = name_svideo,
1989 .vmux = 0,
1990 .amux = LINE1,
1991 .gpio = 0x200,
1992 }},
1993 .radio = {
1994 .name = name_radio,
1995 .amux = LINE1,
1996 .gpio = 0x100,
1997 },
1998 .mute = {
1999 .name = name_mute,
2000 .amux = TV,
2001 .gpio = 0x000,
2002 },
2003 },
2004};
2005
1651 2006
1652const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 2007const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
1653 2008
@@ -1661,13 +2016,13 @@ struct pci_device_id saa7134_pci_tbl[] = {
1661 .subvendor = PCI_VENDOR_ID_PHILIPS, 2016 .subvendor = PCI_VENDOR_ID_PHILIPS,
1662 .subdevice = 0x2001, 2017 .subdevice = 0x2001,
1663 .driver_data = SAA7134_BOARD_PROTEUS_PRO, 2018 .driver_data = SAA7134_BOARD_PROTEUS_PRO,
1664 },{ 2019 },{
1665 .vendor = PCI_VENDOR_ID_PHILIPS, 2020 .vendor = PCI_VENDOR_ID_PHILIPS,
1666 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2021 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1667 .subvendor = PCI_VENDOR_ID_PHILIPS, 2022 .subvendor = PCI_VENDOR_ID_PHILIPS,
1668 .subdevice = 0x2001, 2023 .subdevice = 0x2001,
1669 .driver_data = SAA7134_BOARD_PROTEUS_PRO, 2024 .driver_data = SAA7134_BOARD_PROTEUS_PRO,
1670 },{ 2025 },{
1671 .vendor = PCI_VENDOR_ID_PHILIPS, 2026 .vendor = PCI_VENDOR_ID_PHILIPS,
1672 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2027 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1673 .subvendor = PCI_VENDOR_ID_PHILIPS, 2028 .subvendor = PCI_VENDOR_ID_PHILIPS,
@@ -1676,70 +2031,70 @@ struct pci_device_id saa7134_pci_tbl[] = {
1676 },{ 2031 },{
1677 .vendor = PCI_VENDOR_ID_PHILIPS, 2032 .vendor = PCI_VENDOR_ID_PHILIPS,
1678 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2033 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1679 .subvendor = 0x1131, 2034 .subvendor = 0x1131,
1680 .subdevice = 0x4e85, 2035 .subdevice = 0x4e85,
1681 .driver_data = SAA7134_BOARD_MONSTERTV, 2036 .driver_data = SAA7134_BOARD_MONSTERTV,
1682 },{ 2037 },{
1683 .vendor = PCI_VENDOR_ID_PHILIPS, 2038 .vendor = PCI_VENDOR_ID_PHILIPS,
1684 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2039 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1685 .subvendor = 0x153B, 2040 .subvendor = 0x153B,
1686 .subdevice = 0x1142, 2041 .subdevice = 0x1142,
1687 .driver_data = SAA7134_BOARD_CINERGY400, 2042 .driver_data = SAA7134_BOARD_CINERGY400,
1688 },{ 2043 },{
1689 .vendor = PCI_VENDOR_ID_PHILIPS, 2044 .vendor = PCI_VENDOR_ID_PHILIPS,
1690 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2045 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1691 .subvendor = 0x153B, 2046 .subvendor = 0x153B,
1692 .subdevice = 0x1143, 2047 .subdevice = 0x1143,
1693 .driver_data = SAA7134_BOARD_CINERGY600, 2048 .driver_data = SAA7134_BOARD_CINERGY600,
1694 },{ 2049 },{
1695 .vendor = PCI_VENDOR_ID_PHILIPS, 2050 .vendor = PCI_VENDOR_ID_PHILIPS,
1696 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2051 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1697 .subvendor = 0x153B, 2052 .subvendor = 0x153B,
1698 .subdevice = 0x1158, 2053 .subdevice = 0x1158,
1699 .driver_data = SAA7134_BOARD_CINERGY600_MK3, 2054 .driver_data = SAA7134_BOARD_CINERGY600_MK3,
1700 },{ 2055 },{
1701 .vendor = PCI_VENDOR_ID_PHILIPS, 2056 .vendor = PCI_VENDOR_ID_PHILIPS,
1702 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2057 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1703 .subvendor = 0x153b, 2058 .subvendor = 0x153b,
1704 .subdevice = 0x1162, 2059 .subdevice = 0x1162,
1705 .driver_data = SAA7134_BOARD_CINERGY400_CARDBUS, 2060 .driver_data = SAA7134_BOARD_CINERGY400_CARDBUS,
1706 },{ 2061 },{
1707 .vendor = PCI_VENDOR_ID_PHILIPS, 2062 .vendor = PCI_VENDOR_ID_PHILIPS,
1708 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2063 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1709 .subvendor = 0x5168, 2064 .subvendor = 0x5168,
1710 .subdevice = 0x0138, 2065 .subdevice = 0x0138,
1711 .driver_data = SAA7134_BOARD_FLYVIDEO3000, 2066 .driver_data = SAA7134_BOARD_FLYVIDEO3000,
1712 },{ 2067 },{
1713 .vendor = PCI_VENDOR_ID_PHILIPS, 2068 .vendor = PCI_VENDOR_ID_PHILIPS,
1714 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2069 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1715 .subvendor = 0x4e42, //"Typhoon PCI Capture TV Card" Art.No. 50673 2070 .subvendor = 0x4e42, /* "Typhoon PCI Capture TV Card" Art.No. 50673 */
1716 .subdevice = 0x0138, 2071 .subdevice = 0x0138,
1717 .driver_data = SAA7134_BOARD_FLYVIDEO3000, 2072 .driver_data = SAA7134_BOARD_FLYVIDEO3000,
1718 },{ 2073 },{
1719 .vendor = PCI_VENDOR_ID_PHILIPS, 2074 .vendor = PCI_VENDOR_ID_PHILIPS,
1720 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2075 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1721 .subvendor = 0x5168, 2076 .subvendor = 0x5168,
1722 .subdevice = 0x0138, 2077 .subdevice = 0x0138,
1723 .driver_data = SAA7134_BOARD_FLYVIDEO2000, 2078 .driver_data = SAA7134_BOARD_FLYVIDEO2000,
1724 },{ 2079 },{
1725 .vendor = PCI_VENDOR_ID_PHILIPS, 2080 .vendor = PCI_VENDOR_ID_PHILIPS,
1726 .device = PCI_DEVICE_ID_PHILIPS_SAA7135, 2081 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1727 .subvendor = 0x5168, 2082 .subvendor = 0x5168,
1728 .subdevice = 0x0212, /* minipci, LR212 */ 2083 .subdevice = 0x0212, /* minipci, LR212 */
1729 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_MINI, 2084 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_MINI,
1730 },{ 2085 },{
1731 .vendor = PCI_VENDOR_ID_PHILIPS, 2086 .vendor = PCI_VENDOR_ID_PHILIPS,
1732 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2087 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1733 .subvendor = 0x5168, /* Animation Technologies (LifeView) */ 2088 .subvendor = 0x5168, /* Animation Technologies (LifeView) */
1734 .subdevice = 0x0214, /* Standard PCI, LR214WF */ 2089 .subdevice = 0x0214, /* Standard PCI, LR214WF */
1735 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, 2090 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM,
1736 },{ 2091 },{
1737 .vendor = PCI_VENDOR_ID_PHILIPS, 2092 .vendor = PCI_VENDOR_ID_PHILIPS,
1738 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2093 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1739 .subvendor = 0x1489, /* KYE */ 2094 .subvendor = 0x1489, /* KYE */
1740 .subdevice = 0x0214, /* Genius VideoWonder ProTV */ 2095 .subdevice = 0x0214, /* Genius VideoWonder ProTV */
1741 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, /* is an LR214WF actually */ 2096 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, /* is an LR214WF actually */
1742 },{ 2097 },{
1743 .vendor = PCI_VENDOR_ID_PHILIPS, 2098 .vendor = PCI_VENDOR_ID_PHILIPS,
1744 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2099 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1745 .subvendor = 0x16be, 2100 .subvendor = 0x16be,
@@ -1758,36 +2113,36 @@ struct pci_device_id saa7134_pci_tbl[] = {
1758 .subdevice = 0x226b, 2113 .subdevice = 0x226b,
1759 .driver_data = SAA7134_BOARD_ELSA_500TV, 2114 .driver_data = SAA7134_BOARD_ELSA_500TV,
1760 },{ 2115 },{
1761 .vendor = PCI_VENDOR_ID_PHILIPS, 2116 .vendor = PCI_VENDOR_ID_PHILIPS,
1762 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2117 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1763 .subvendor = PCI_VENDOR_ID_ASUSTEK, 2118 .subvendor = PCI_VENDOR_ID_ASUSTEK,
1764 .subdevice = 0x4842, 2119 .subdevice = 0x4842,
1765 .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134, 2120 .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
1766 },{ 2121 },{
1767 .vendor = PCI_VENDOR_ID_PHILIPS, 2122 .vendor = PCI_VENDOR_ID_PHILIPS,
1768 .device = PCI_DEVICE_ID_PHILIPS_SAA7135, 2123 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1769 .subvendor = PCI_VENDOR_ID_ASUSTEK, 2124 .subvendor = PCI_VENDOR_ID_ASUSTEK,
1770 .subdevice = 0x4845, 2125 .subdevice = 0x4845,
1771 .driver_data = SAA7135_BOARD_ASUSTeK_TVFM7135, 2126 .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7135,
1772 },{ 2127 },{
1773 .vendor = PCI_VENDOR_ID_PHILIPS, 2128 .vendor = PCI_VENDOR_ID_PHILIPS,
1774 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2129 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1775 .subvendor = PCI_VENDOR_ID_ASUSTEK, 2130 .subvendor = PCI_VENDOR_ID_ASUSTEK,
1776 .subdevice = 0x4830, 2131 .subdevice = 0x4830,
1777 .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134, 2132 .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
1778 },{ 2133 },{
1779 .vendor = PCI_VENDOR_ID_PHILIPS, 2134 .vendor = PCI_VENDOR_ID_PHILIPS,
1780 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2135 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1781 .subvendor = PCI_VENDOR_ID_ASUSTEK, 2136 .subvendor = PCI_VENDOR_ID_ASUSTEK,
1782 .subdevice = 0x4843, 2137 .subdevice = 0x4843,
1783 .driver_data = SAA7134_BOARD_ASUSTEK_TVFM7133, 2138 .driver_data = SAA7134_BOARD_ASUSTEK_TVFM7133,
2139 },{
2140 .vendor = PCI_VENDOR_ID_PHILIPS,
2141 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
2142 .subvendor = PCI_VENDOR_ID_ASUSTEK,
2143 .subdevice = 0x4840,
2144 .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
1784 },{ 2145 },{
1785 .vendor = PCI_VENDOR_ID_PHILIPS,
1786 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1787 .subvendor = PCI_VENDOR_ID_ASUSTEK,
1788 .subdevice = 0x4840,
1789 .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
1790 },{
1791 .vendor = PCI_VENDOR_ID_PHILIPS, 2146 .vendor = PCI_VENDOR_ID_PHILIPS,
1792 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2147 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1793 .subvendor = PCI_VENDOR_ID_PHILIPS, 2148 .subvendor = PCI_VENDOR_ID_PHILIPS,
@@ -1808,118 +2163,118 @@ struct pci_device_id saa7134_pci_tbl[] = {
1808 },{ 2163 },{
1809 .vendor = PCI_VENDOR_ID_PHILIPS, 2164 .vendor = PCI_VENDOR_ID_PHILIPS,
1810 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2165 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1811 .subvendor = 0x1131, 2166 .subvendor = 0x1131,
1812 .subdevice = 0x7133, 2167 .subdevice = 0x7133,
1813 .driver_data = SAA7134_BOARD_VA1000POWER, 2168 .driver_data = SAA7134_BOARD_VA1000POWER,
1814 },{ 2169 },{
1815 .vendor = PCI_VENDOR_ID_PHILIPS, 2170 .vendor = PCI_VENDOR_ID_PHILIPS,
1816 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2171 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1817 .subvendor = PCI_VENDOR_ID_PHILIPS, 2172 .subvendor = PCI_VENDOR_ID_PHILIPS,
1818 .subdevice = 0x2001, 2173 .subdevice = 0x2001,
1819 .driver_data = SAA7134_BOARD_10MOONSTVMASTER, 2174 .driver_data = SAA7134_BOARD_10MOONSTVMASTER,
1820 },{ 2175 },{
1821 .vendor = PCI_VENDOR_ID_PHILIPS, 2176 .vendor = PCI_VENDOR_ID_PHILIPS,
1822 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2177 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1823 .subvendor = 0x185b, 2178 .subvendor = 0x185b,
1824 .subdevice = 0xc100, 2179 .subdevice = 0xc100,
1825 .driver_data = SAA7134_BOARD_VIDEOMATE_TV, 2180 .driver_data = SAA7134_BOARD_VIDEOMATE_TV,
1826 },{ 2181 },{
1827 .vendor = PCI_VENDOR_ID_PHILIPS, 2182 .vendor = PCI_VENDOR_ID_PHILIPS,
1828 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2183 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1829 .subvendor = 0x185b, 2184 .subvendor = 0x185b,
1830 .subdevice = 0xc100, 2185 .subdevice = 0xc100,
1831 .driver_data = SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS, 2186 .driver_data = SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS,
1832 },{ 2187 },{
1833 .vendor = PCI_VENDOR_ID_PHILIPS, 2188 .vendor = PCI_VENDOR_ID_PHILIPS,
1834 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2189 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1835 .subvendor = PCI_VENDOR_ID_MATROX, 2190 .subvendor = PCI_VENDOR_ID_MATROX,
1836 .subdevice = 0x48d0, 2191 .subdevice = 0x48d0,
1837 .driver_data = SAA7134_BOARD_CRONOS_PLUS, 2192 .driver_data = SAA7134_BOARD_CRONOS_PLUS,
1838 },{ 2193 },{
1839 .vendor = PCI_VENDOR_ID_PHILIPS, 2194 .vendor = PCI_VENDOR_ID_PHILIPS,
1840 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2195 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1841 .subvendor = 0x1461, /* Avermedia Technologies Inc */ 2196 .subvendor = 0x1461, /* Avermedia Technologies Inc */
1842 .subdevice = 0xa70b, 2197 .subdevice = 0xa70b,
1843 .driver_data = SAA7134_BOARD_MD2819, 2198 .driver_data = SAA7134_BOARD_MD2819,
1844 },{ 2199 },{
1845 .vendor = PCI_VENDOR_ID_PHILIPS, 2200 .vendor = PCI_VENDOR_ID_PHILIPS,
1846 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2201 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1847 .subvendor = 0x1461, /* Avermedia Technologies Inc */ 2202 .subvendor = 0x1461, /* Avermedia Technologies Inc */
1848 .subdevice = 0x2115, 2203 .subdevice = 0x2115,
1849 .driver_data = SAA7134_BOARD_AVERMEDIA_STUDIO_305, 2204 .driver_data = SAA7134_BOARD_AVERMEDIA_STUDIO_305,
1850 },{ 2205 },{
1851 .vendor = PCI_VENDOR_ID_PHILIPS, 2206 .vendor = PCI_VENDOR_ID_PHILIPS,
1852 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2207 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1853 .subvendor = 0x1461, /* Avermedia Technologies Inc */ 2208 .subvendor = 0x1461, /* Avermedia Technologies Inc */
1854 .subdevice = 0x2108, 2209 .subdevice = 0x2108,
1855 .driver_data = SAA7134_BOARD_AVERMEDIA_305, 2210 .driver_data = SAA7134_BOARD_AVERMEDIA_305,
1856 },{ 2211 },{
1857 .vendor = PCI_VENDOR_ID_PHILIPS, 2212 .vendor = PCI_VENDOR_ID_PHILIPS,
1858 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2213 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1859 .subvendor = 0x1461, /* Avermedia Technologies Inc */ 2214 .subvendor = 0x1461, /* Avermedia Technologies Inc */
1860 .subdevice = 0x10ff, 2215 .subdevice = 0x10ff,
1861 .driver_data = SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER, 2216 .driver_data = SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER,
1862 },{ 2217 },{
1863 /* AVerMedia CardBus */ 2218 /* AVerMedia CardBus */
1864 .vendor = PCI_VENDOR_ID_PHILIPS, 2219 .vendor = PCI_VENDOR_ID_PHILIPS,
1865 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2220 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1866 .subvendor = 0x1461, /* Avermedia Technologies Inc */ 2221 .subvendor = 0x1461, /* Avermedia Technologies Inc */
1867 .subdevice = 0xd6ee, 2222 .subdevice = 0xd6ee,
1868 .driver_data = SAA7134_BOARD_AVERMEDIA_CARDBUS, 2223 .driver_data = SAA7134_BOARD_AVERMEDIA_CARDBUS,
1869 },{ 2224 },{
1870 /* TransGear 3000TV */ 2225 /* TransGear 3000TV */
1871 .vendor = PCI_VENDOR_ID_PHILIPS, 2226 .vendor = PCI_VENDOR_ID_PHILIPS,
1872 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2227 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1873 .subvendor = 0x1461, /* Avermedia Technologies Inc */ 2228 .subvendor = 0x1461, /* Avermedia Technologies Inc */
1874 .subdevice = 0x050c, 2229 .subdevice = 0x050c,
1875 .driver_data = SAA7134_BOARD_TG3000TV, 2230 .driver_data = SAA7134_BOARD_TG3000TV,
1876 },{ 2231 },{
1877 .vendor = PCI_VENDOR_ID_PHILIPS,
1878 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1879 .subvendor = 0x11bd,
1880 .subdevice = 0x002b,
1881 .driver_data = SAA7134_BOARD_PINNACLE_PCTV_STEREO,
1882 },{
1883 .vendor = PCI_VENDOR_ID_PHILIPS,
1884 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1885 .subvendor = 0x11bd,
1886 .subdevice = 0x002d,
1887 .driver_data = SAA7134_BOARD_PINNACLE_300I_DVBT_PAL,
1888 },{
1889 .vendor = PCI_VENDOR_ID_PHILIPS,
1890 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1891 .subvendor = 0x1019,
1892 .subdevice = 0x4cb4,
1893 .driver_data = SAA7134_BOARD_ECS_TVP3XP,
1894 },{
1895 .vendor = PCI_VENDOR_ID_PHILIPS,
1896 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1897 .subvendor = 0x1019,
1898 .subdevice = 0x4cb5,
1899 .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5,
1900 },{
1901 .vendor = PCI_VENDOR_ID_PHILIPS, 2232 .vendor = PCI_VENDOR_ID_PHILIPS,
1902 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2233 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1903 .subvendor = 0x12ab, 2234 .subvendor = 0x11bd,
1904 .subdevice = 0x0800, 2235 .subdevice = 0x002b,
1905 .driver_data = SAA7133_BOARD_UPMOST_PURPLE_TV, 2236 .driver_data = SAA7134_BOARD_PINNACLE_PCTV_STEREO,
2237 },{
2238 .vendor = PCI_VENDOR_ID_PHILIPS,
2239 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
2240 .subvendor = 0x11bd,
2241 .subdevice = 0x002d,
2242 .driver_data = SAA7134_BOARD_PINNACLE_300I_DVBT_PAL,
2243 },{
2244 .vendor = PCI_VENDOR_ID_PHILIPS,
2245 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
2246 .subvendor = 0x1019,
2247 .subdevice = 0x4cb4,
2248 .driver_data = SAA7134_BOARD_ECS_TVP3XP,
2249 },{
2250 .vendor = PCI_VENDOR_ID_PHILIPS,
2251 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
2252 .subvendor = 0x1019,
2253 .subdevice = 0x4cb5,
2254 .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5,
2255 },{
2256 .vendor = PCI_VENDOR_ID_PHILIPS,
2257 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
2258 .subvendor = 0x12ab,
2259 .subdevice = 0x0800,
2260 .driver_data = SAA7134_BOARD_UPMOST_PURPLE_TV,
1906 },{ 2261 },{
1907 .vendor = PCI_VENDOR_ID_PHILIPS, 2262 .vendor = PCI_VENDOR_ID_PHILIPS,
1908 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2263 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1909 .subvendor = 0x153B, 2264 .subvendor = 0x153B,
1910 .subdevice = 0x1152, 2265 .subdevice = 0x1152,
1911 .driver_data = SAA7134_BOARD_CINERGY200, 2266 .driver_data = SAA7134_BOARD_CINERGY200,
1912 },{ 2267 },{
1913 .vendor = PCI_VENDOR_ID_PHILIPS, 2268 .vendor = PCI_VENDOR_ID_PHILIPS,
1914 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2269 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1915 .subvendor = 0x185b, 2270 .subvendor = 0x185b,
1916 .subdevice = 0xc100, 2271 .subdevice = 0xc100,
1917 .driver_data = SAA7134_BOARD_VIDEOMATE_TV_PVR, 2272 .driver_data = SAA7134_BOARD_VIDEOMATE_TV_PVR,
1918 },{ 2273 },{
1919 .vendor = PCI_VENDOR_ID_PHILIPS, 2274 .vendor = PCI_VENDOR_ID_PHILIPS,
1920 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2275 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1921 .subvendor = 0x1131, 2276 .subvendor = 0x1131,
1922 .subdevice = 0, 2277 .subdevice = 0,
1923 .driver_data = SAA7134_BOARD_SABRENT_SBTTVFM, 2278 .driver_data = SAA7134_BOARD_SABRENT_SBTTVFM,
1924 },{ 2279 },{
1925 .vendor = PCI_VENDOR_ID_PHILIPS, 2280 .vendor = PCI_VENDOR_ID_PHILIPS,
@@ -1939,18 +2294,24 @@ struct pci_device_id saa7134_pci_tbl[] = {
1939 .subvendor = 0x185b, 2294 .subvendor = 0x185b,
1940 .subdevice = 0xc200, 2295 .subdevice = 0xc200,
1941 .driver_data = SAA7134_BOARD_VIDEOMATE_GOLD_PLUS, 2296 .driver_data = SAA7134_BOARD_VIDEOMATE_GOLD_PLUS,
1942 },{ 2297 },{
1943 .vendor = PCI_VENDOR_ID_PHILIPS, 2298 .vendor = PCI_VENDOR_ID_PHILIPS,
1944 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2299 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1945 .subvendor = 0x1540, 2300 .subvendor = 0x1540,
1946 .subdevice = 0x9524, 2301 .subdevice = 0x9524,
1947 .driver_data = SAA7134_BOARD_PROVIDEO_PV952, 2302 .driver_data = SAA7134_BOARD_PROVIDEO_PV952,
1948 2303
1949 },{ 2304 },{
1950 .vendor = PCI_VENDOR_ID_PHILIPS, 2305 .vendor = PCI_VENDOR_ID_PHILIPS,
1951 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2306 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1952 .subvendor = 0x5168, 2307 .subvendor = 0x5168,
1953 .subdevice = 0x0306, 2308 .subdevice = 0x0502, /* Cardbus version */
2309 .driver_data = SAA7134_BOARD_FLYDVBTDUO,
2310 },{
2311 .vendor = PCI_VENDOR_ID_PHILIPS,
2312 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
2313 .subvendor = 0x5168,
2314 .subdevice = 0x0306, /* PCI version */
1954 .driver_data = SAA7134_BOARD_FLYDVBTDUO, 2315 .driver_data = SAA7134_BOARD_FLYDVBTDUO,
1955 },{ 2316 },{
1956 .vendor = PCI_VENDOR_ID_PHILIPS, 2317 .vendor = PCI_VENDOR_ID_PHILIPS,
@@ -1959,31 +2320,44 @@ struct pci_device_id saa7134_pci_tbl[] = {
1959 .subdevice = 0xf31f, 2320 .subdevice = 0xf31f,
1960 .driver_data = SAA7134_BOARD_AVERMEDIA_GO_007_FM, 2321 .driver_data = SAA7134_BOARD_AVERMEDIA_GO_007_FM,
1961 2322
1962 },{ 2323 },{
1963 .vendor = PCI_VENDOR_ID_PHILIPS, 2324 .vendor = PCI_VENDOR_ID_PHILIPS,
1964 .device = PCI_DEVICE_ID_PHILIPS_SAA7135, 2325 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
2326 .subvendor = PCI_VENDOR_ID_PHILIPS,
2327 .subdevice = 0x2004,
2328 .driver_data = SAA7134_BOARD_PHILIPS_TOUGH,
2329 },{
2330 .vendor = PCI_VENDOR_ID_PHILIPS,
2331 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1965 .subvendor = 0x1421, 2332 .subvendor = 0x1421,
1966 .subdevice = 0x0350, /* PCI version */ 2333 .subdevice = 0x0350, /* PCI version */
1967 .driver_data = SAA7134_BOARD_ADS_INSTANT_TV, 2334 .driver_data = SAA7134_BOARD_ADS_INSTANT_TV,
1968 2335
1969 },{ 2336 },{
1970 .vendor = PCI_VENDOR_ID_PHILIPS, 2337 .vendor = PCI_VENDOR_ID_PHILIPS,
1971 .device = PCI_DEVICE_ID_PHILIPS_SAA7135, 2338 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1972 .subvendor = 0x1421, 2339 .subvendor = 0x1421,
1973 .subdevice = 0x0370, /* cardbus version */ 2340 .subdevice = 0x0370, /* cardbus version */
1974 .driver_data = SAA7134_BOARD_ADS_INSTANT_TV, 2341 .driver_data = SAA7134_BOARD_ADS_INSTANT_TV,
1975 2342
1976 },{ 2343 },{ /* Typhoon DVB-T Duo Digital/Analog Cardbus */
2344 .vendor = PCI_VENDOR_ID_PHILIPS,
2345 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
2346 .subvendor = 0x4e42,
2347 .subdevice = 0x0502,
2348 .driver_data = SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS,
2349
2350 },{
1977 /* --- boards without eeprom + subsystem ID --- */ 2351 /* --- boards without eeprom + subsystem ID --- */
1978 .vendor = PCI_VENDOR_ID_PHILIPS, 2352 .vendor = PCI_VENDOR_ID_PHILIPS,
1979 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2353 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1980 .subvendor = PCI_VENDOR_ID_PHILIPS, 2354 .subvendor = PCI_VENDOR_ID_PHILIPS,
1981 .subdevice = 0, 2355 .subdevice = 0,
1982 .driver_data = SAA7134_BOARD_NOAUTO, 2356 .driver_data = SAA7134_BOARD_NOAUTO,
1983 },{ 2357 },{
1984 .vendor = PCI_VENDOR_ID_PHILIPS, 2358 .vendor = PCI_VENDOR_ID_PHILIPS,
1985 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2359 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1986 .subvendor = PCI_VENDOR_ID_PHILIPS, 2360 .subvendor = PCI_VENDOR_ID_PHILIPS,
1987 .subdevice = 0, 2361 .subdevice = 0,
1988 .driver_data = SAA7134_BOARD_NOAUTO, 2362 .driver_data = SAA7134_BOARD_NOAUTO,
1989 },{ 2363 },{
@@ -1991,26 +2365,26 @@ struct pci_device_id saa7134_pci_tbl[] = {
1991 /* --- default catch --- */ 2365 /* --- default catch --- */
1992 .vendor = PCI_VENDOR_ID_PHILIPS, 2366 .vendor = PCI_VENDOR_ID_PHILIPS,
1993 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2367 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
1994 .subvendor = PCI_ANY_ID, 2368 .subvendor = PCI_ANY_ID,
1995 .subdevice = PCI_ANY_ID, 2369 .subdevice = PCI_ANY_ID,
1996 .driver_data = SAA7134_BOARD_UNKNOWN, 2370 .driver_data = SAA7134_BOARD_UNKNOWN,
1997 },{ 2371 },{
1998 .vendor = PCI_VENDOR_ID_PHILIPS, 2372 .vendor = PCI_VENDOR_ID_PHILIPS,
1999 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2373 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
2000 .subvendor = PCI_ANY_ID, 2374 .subvendor = PCI_ANY_ID,
2001 .subdevice = PCI_ANY_ID, 2375 .subdevice = PCI_ANY_ID,
2002 .driver_data = SAA7134_BOARD_UNKNOWN, 2376 .driver_data = SAA7134_BOARD_UNKNOWN,
2003 },{ 2377 },{
2004 .vendor = PCI_VENDOR_ID_PHILIPS, 2378 .vendor = PCI_VENDOR_ID_PHILIPS,
2005 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 2379 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
2006 .subvendor = PCI_ANY_ID, 2380 .subvendor = PCI_ANY_ID,
2007 .subdevice = PCI_ANY_ID, 2381 .subdevice = PCI_ANY_ID,
2008 .driver_data = SAA7134_BOARD_UNKNOWN, 2382 .driver_data = SAA7134_BOARD_UNKNOWN,
2009 },{ 2383 },{
2010 .vendor = PCI_VENDOR_ID_PHILIPS, 2384 .vendor = PCI_VENDOR_ID_PHILIPS,
2011 .device = PCI_DEVICE_ID_PHILIPS_SAA7135, 2385 .device = PCI_DEVICE_ID_PHILIPS_SAA7135,
2012 .subvendor = PCI_ANY_ID, 2386 .subvendor = PCI_ANY_ID,
2013 .subdevice = PCI_ANY_ID, 2387 .subdevice = PCI_ANY_ID,
2014 .driver_data = SAA7134_BOARD_UNKNOWN, 2388 .driver_data = SAA7134_BOARD_UNKNOWN,
2015 },{ 2389 },{
2016 /* --- end of list --- */ 2390 /* --- end of list --- */
@@ -2021,46 +2395,9 @@ MODULE_DEVICE_TABLE(pci, saa7134_pci_tbl);
2021/* ----------------------------------------------------------- */ 2395/* ----------------------------------------------------------- */
2022/* flyvideo tweaks */ 2396/* flyvideo tweaks */
2023 2397
2024#if 0
2025static struct {
2026 char *model;
2027 int tuner_type;
2028} fly_list[0x20] = {
2029 /* default catch ... */
2030 [ 0 ... 0x1f ] = {
2031 .model = "UNKNOWN",
2032 .tuner_type = TUNER_ABSENT,
2033 },
2034 /* ... the ones known so far */
2035 [ 0x05 ] = {
2036 .model = "PAL-BG",
2037 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
2038 },
2039 [ 0x10 ] = {
2040 .model = "PAL-BG / PAL-DK",
2041 .tuner_type = TUNER_PHILIPS_PAL,
2042 },
2043 [ 0x15 ] = {
2044 .model = "NTSC",
2045 .tuner_type = TUNER_ABSENT /* FIXME */,
2046 },
2047};
2048#endif
2049 2398
2050static void board_flyvideo(struct saa7134_dev *dev) 2399static void board_flyvideo(struct saa7134_dev *dev)
2051{ 2400{
2052#if 0
2053 /* non-working attempt to detect the correct tuner type ... */
2054 u32 value;
2055 int index;
2056
2057 value = dev->gpio_value;
2058 index = (value & 0x1f00) >> 8;
2059 printk(KERN_INFO "%s: flyvideo: gpio is 0x%x [model=%s,tuner=%d]\n",
2060 dev->name, value, fly_list[index].model,
2061 fly_list[index].tuner_type);
2062 dev->tuner_type = fly_list[index].tuner_type;
2063#endif
2064 printk("%s: there are different flyvideo cards with different tuners\n" 2401 printk("%s: there are different flyvideo cards with different tuners\n"
2065 "%s: out there, you might have to use the tuner=<nr> insmod\n" 2402 "%s: out there, you might have to use the tuner=<nr> insmod\n"
2066 "%s: option to override the default value.\n", 2403 "%s: option to override the default value.\n",
@@ -2071,7 +2408,7 @@ static void board_flyvideo(struct saa7134_dev *dev)
2071 2408
2072int saa7134_board_init1(struct saa7134_dev *dev) 2409int saa7134_board_init1(struct saa7134_dev *dev)
2073{ 2410{
2074 // Always print gpio, often manufacturers encode tuner type and other info. 2411 /* Always print gpio, often manufacturers encode tuner type and other info. */
2075 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0); 2412 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0);
2076 dev->gpio_value = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); 2413 dev->gpio_value = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
2077 printk(KERN_INFO "%s: board init: gpio is %x\n", dev->name, dev->gpio_value); 2414 printk(KERN_INFO "%s: board init: gpio is %x\n", dev->name, dev->gpio_value);
@@ -2082,7 +2419,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
2082 dev->has_remote = 1; 2419 dev->has_remote = 1;
2083 board_flyvideo(dev); 2420 board_flyvideo(dev);
2084 break; 2421 break;
2085 case SAA7134_BOARD_FLYTVPLATINUM_FM: 2422 case SAA7134_BOARD_FLYTVPLATINUM_FM:
2086 case SAA7134_BOARD_CINERGY400: 2423 case SAA7134_BOARD_CINERGY400:
2087 case SAA7134_BOARD_CINERGY600: 2424 case SAA7134_BOARD_CINERGY600:
2088 case SAA7134_BOARD_CINERGY600_MK3: 2425 case SAA7134_BOARD_CINERGY600_MK3:
@@ -2090,23 +2427,25 @@ int saa7134_board_init1(struct saa7134_dev *dev)
2090 case SAA7134_BOARD_ECS_TVP3XP_4CB5: 2427 case SAA7134_BOARD_ECS_TVP3XP_4CB5:
2091 case SAA7134_BOARD_MD2819: 2428 case SAA7134_BOARD_MD2819:
2092 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: 2429 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
2430 case SAA7134_BOARD_KWORLD_XPERT:
2093 case SAA7134_BOARD_AVERMEDIA_STUDIO_305: 2431 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
2094 case SAA7134_BOARD_AVERMEDIA_305: 2432 case SAA7134_BOARD_AVERMEDIA_305:
2095 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 2433 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
2096 case SAA7134_BOARD_AVERMEDIA_307: 2434 case SAA7134_BOARD_AVERMEDIA_307:
2097 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 2435 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
2098// case SAA7134_BOARD_SABRENT_SBTTVFM: /* not finished yet */ 2436/* case SAA7134_BOARD_SABRENT_SBTTVFM: */ /* not finished yet */
2099 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 2437 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
2100 case SAA7134_BOARD_MANLI_MTV001: 2438 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
2101 case SAA7134_BOARD_MANLI_MTV002: 2439 case SAA7134_BOARD_MANLI_MTV001:
2440 case SAA7134_BOARD_MANLI_MTV002:
2102 case SAA7134_BOARD_AVACSSMARTTV: 2441 case SAA7134_BOARD_AVACSSMARTTV:
2103 dev->has_remote = 1; 2442 dev->has_remote = 1;
2104 break; 2443 break;
2105 case SAA7134_BOARD_MD5044: 2444 case SAA7134_BOARD_MD5044:
2106 printk("%s: seems there are two different versions of the MD5044\n" 2445 printk("%s: seems there are two different versions of the MD5044\n"
2107 "%s: (with the same ID) out there. If sound doesn't work for\n" 2446 "%s: (with the same ID) out there. If sound doesn't work for\n"
2108 "%s: you try the audio_clock_override=0x200000 insmod option.\n", 2447 "%s: you try the audio_clock_override=0x200000 insmod option.\n",
2109 dev->name,dev->name,dev->name); 2448 dev->name,dev->name,dev->name);
2110 break; 2449 break;
2111 case SAA7134_BOARD_CINERGY400_CARDBUS: 2450 case SAA7134_BOARD_CINERGY400_CARDBUS:
2112 /* power-up tuner chip */ 2451 /* power-up tuner chip */
@@ -2114,11 +2453,19 @@ int saa7134_board_init1(struct saa7134_dev *dev)
2114 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000); 2453 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000);
2115 msleep(1); 2454 msleep(1);
2116 break; 2455 break;
2456 case SAA7134_BOARD_FLYDVBTDUO:
2457 case SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS:
2458 /* turn the fan on Hac: static for the time being */
2459 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08);
2460 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x06);
2461 break;
2462 case SAA7134_BOARD_AVERMEDIA_CARDBUS:
2463 /* power-up tuner chip */
2464 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff);
2465 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0xffffffff);
2466 msleep(1);
2467 break;
2117 } 2468 }
2118 if (dev->has_remote)
2119 dev->irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18 |
2120 SAA7134_IRQ2_INTE_GPIO18A |
2121 SAA7134_IRQ2_INTE_GPIO16 );
2122 return 0; 2469 return 0;
2123} 2470}
2124 2471
@@ -2139,10 +2486,85 @@ int saa7134_board_init2(struct saa7134_dev *dev)
2139 break; 2486 break;
2140 dev->board = board; 2487 dev->board = board;
2141 printk("%s: board type fixup: %s\n", dev->name, 2488 printk("%s: board type fixup: %s\n", dev->name,
2142 saa7134_boards[dev->board].name); 2489 saa7134_boards[dev->board].name);
2143 dev->tuner_type = saa7134_boards[dev->board].tuner_type; 2490 dev->tuner_type = saa7134_boards[dev->board].tuner_type;
2144 if (TUNER_ABSENT != dev->tuner_type) 2491
2145 saa7134_i2c_call_clients(dev,TUNER_SET_TYPE,&dev->tuner_type); 2492 if (TUNER_ABSENT != dev->tuner_type) {
2493 struct tuner_setup tun_setup;
2494
2495 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
2496 tun_setup.type = dev->tuner_type;
2497 tun_setup.addr = ADDR_UNSET;
2498
2499 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup);
2500 }
2501 break;
2502case SAA7134_BOARD_MD7134:
2503 {
2504 struct tuner_setup tun_setup;
2505 u8 subaddr;
2506 u8 data[3];
2507 int ret, tuner_t;
2508
2509 struct i2c_msg msg[] = {{.addr=0x50, .flags=0, .buf=&subaddr, .len = 1},
2510 {.addr=0x50, .flags=I2C_M_RD, .buf=data, .len = 3}};
2511 subaddr= 0x14;
2512 tuner_t = 0;
2513 ret = i2c_transfer(&dev->i2c_adap, msg, 2);
2514 if (ret != 2) {
2515 printk(KERN_ERR "EEPROM read failure\n");
2516 } else if ((data[0] != 0) && (data[0] != 0xff)) {
2517 /* old config structure */
2518 subaddr = data[0] + 2;
2519 msg[1].len = 2;
2520 i2c_transfer(&dev->i2c_adap, msg, 2);
2521 tuner_t = (data[0] << 8) + data[1];
2522 switch (tuner_t){
2523 case 0x0103:
2524 dev->tuner_type = TUNER_PHILIPS_PAL;
2525 break;
2526 case 0x010C:
2527 dev->tuner_type = TUNER_PHILIPS_FM1216ME_MK3;
2528 break;
2529 default:
2530 printk(KERN_ERR "%s Cant determine tuner type %x from EEPROM\n", dev->name, tuner_t);
2531 }
2532 } else if ((data[1] != 0) && (data[1] != 0xff)) {
2533 /* new config structure */
2534 subaddr = data[1] + 1;
2535 msg[1].len = 1;
2536 i2c_transfer(&dev->i2c_adap, msg, 2);
2537 subaddr = data[0] + 1;
2538 msg[1].len = 2;
2539 i2c_transfer(&dev->i2c_adap, msg, 2);
2540 tuner_t = (data[1] << 8) + data[0];
2541 switch (tuner_t) {
2542 case 0x0005:
2543 dev->tuner_type = TUNER_PHILIPS_FM1216ME_MK3;
2544 break;
2545 case 0x001d:
2546 dev->tuner_type = TUNER_PHILIPS_FMD1216ME_MK3;
2547 printk(KERN_INFO "%s Board has DVB-T\n", dev->name);
2548 break;
2549 default:
2550 printk(KERN_ERR "%s Cant determine tuner type %x from EEPROM\n", dev->name, tuner_t);
2551 }
2552 } else {
2553 printk(KERN_ERR "%s unexpected config structure\n", dev->name);
2554 }
2555
2556 printk(KERN_INFO "%s Tuner type is %d\n", dev->name, dev->tuner_type);
2557 if (dev->tuner_type == TUNER_PHILIPS_FMD1216ME_MK3) {
2558 dev->tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE | TDA9887_PORT2_ACTIVE;
2559 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG, &dev->tda9887_conf);
2560 }
2561
2562 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
2563 tun_setup.type = dev->tuner_type;
2564 tun_setup.addr = ADDR_UNSET;
2565
2566 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
2567 }
2146 break; 2568 break;
2147 } 2569 }
2148 return 0; 2570 return 0;
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index f61ed1849a2a..1dbe61755e9f 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134-core.c,v 1.30 2005/05/22 19:23:39 nsh Exp $ 2 * $Id: saa7134-core.c,v 1.39 2005/07/05 17:37:35 nsh Exp $
3 * 3 *
4 * device driver for philips saa7134 based TV cards 4 * device driver for philips saa7134 based TV cards
5 * driver core 5 * driver core
@@ -183,46 +183,6 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
183 183
184/* ------------------------------------------------------------------ */ 184/* ------------------------------------------------------------------ */
185 185
186#if 0
187static char *dec1_bits[8] = {
188 "DCSTD0", "DCSCT1", "WIPA", "GLIMB",
189 "GLIMT", "SLTCA", "HLCK"
190};
191static char *dec2_bits[8] = {
192 "RDCAP", "COPRO", "COLSTR", "TYPE3",
193 NULL, "FIDT", "HLVLN", "INTL"
194};
195static char *scale1_bits[8] = {
196 "VID_A", "VBI_A", NULL, NULL, "VID_B", "VBI_B"
197};
198static char *scale2_bits[8] = {
199 "TRERR", "CFERR", "LDERR", "WASRST",
200 "FIDSCI", "FIDSCO", "D6^D5", "TASK"
201};
202
203static void dump_statusreg(struct saa7134_dev *dev, int reg,
204 char *regname, char **bits)
205{
206 int value,i;
207
208 value = saa_readb(reg);
209 printk(KERN_DEBUG "%s: %s:", dev->name, regname);
210 for (i = 7; i >= 0; i--) {
211 if (NULL == bits[i])
212 continue;
213 printk(" %s=%d", bits[i], (value & (1 << i)) ? 1 : 0);
214 }
215 printk("\n");
216}
217
218static void dump_statusregs(struct saa7134_dev *dev)
219{
220 dump_statusreg(dev,SAA7134_STATUS_VIDEO1,"dec1",dec1_bits);
221 dump_statusreg(dev,SAA7134_STATUS_VIDEO2,"dec2",dec2_bits);
222 dump_statusreg(dev,SAA7134_SCALER_STATUS0,"scale0",scale1_bits);
223 dump_statusreg(dev,SAA7134_SCALER_STATUS1,"scale1",scale2_bits);
224}
225#endif
226 186
227/* ----------------------------------------------------------- */ 187/* ----------------------------------------------------------- */
228/* delayed request_module */ 188/* delayed request_module */
@@ -616,10 +576,6 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
616 if (irq_debug) 576 if (irq_debug)
617 print_irqstatus(dev,loop,report,status); 577 print_irqstatus(dev,loop,report,status);
618 578
619#if 0
620 if (report & SAA7134_IRQ_REPORT_CONF_ERR)
621 dump_statusregs(dev);
622#endif
623 579
624 if (report & SAA7134_IRQ_REPORT_RDCAP /* _INTL */) 580 if (report & SAA7134_IRQ_REPORT_RDCAP /* _INTL */)
625 saa7134_irq_video_intl(dev); 581 saa7134_irq_video_intl(dev);
@@ -711,7 +667,6 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
711 SAA7134_MAIN_CTRL_EVFE1 | 667 SAA7134_MAIN_CTRL_EVFE1 |
712 SAA7134_MAIN_CTRL_EVFE2 | 668 SAA7134_MAIN_CTRL_EVFE2 |
713 SAA7134_MAIN_CTRL_ESFE | 669 SAA7134_MAIN_CTRL_ESFE |
714 SAA7134_MAIN_CTRL_EBADC |
715 SAA7134_MAIN_CTRL_EBDAC); 670 SAA7134_MAIN_CTRL_EBDAC);
716 671
717 /* enable peripheral devices */ 672 /* enable peripheral devices */
@@ -726,14 +681,28 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
726/* late init (with i2c + irq) */ 681/* late init (with i2c + irq) */
727static int saa7134_hwinit2(struct saa7134_dev *dev) 682static int saa7134_hwinit2(struct saa7134_dev *dev)
728{ 683{
684 unsigned int irq2_mask;
729 dprintk("hwinit2\n"); 685 dprintk("hwinit2\n");
730 686
731 saa7134_video_init2(dev); 687 saa7134_video_init2(dev);
732 saa7134_tvaudio_init2(dev); 688 saa7134_tvaudio_init2(dev);
733 689
734 /* enable IRQ's */ 690 /* enable IRQ's */
691 irq2_mask =
692 SAA7134_IRQ2_INTE_DEC3 |
693 SAA7134_IRQ2_INTE_DEC2 |
694 SAA7134_IRQ2_INTE_DEC1 |
695 SAA7134_IRQ2_INTE_DEC0 |
696 SAA7134_IRQ2_INTE_PE |
697 SAA7134_IRQ2_INTE_AR;
698
699 if (dev->has_remote)
700 irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18 |
701 SAA7134_IRQ2_INTE_GPIO18A |
702 SAA7134_IRQ2_INTE_GPIO16 );
703
735 saa_writel(SAA7134_IRQ1, 0); 704 saa_writel(SAA7134_IRQ1, 0);
736 saa_writel(SAA7134_IRQ2, dev->irq2_mask); 705 saa_writel(SAA7134_IRQ2, irq2_mask);
737 706
738 return 0; 707 return 0;
739} 708}
@@ -954,13 +923,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
954 } 923 }
955 924
956 /* initialize hardware #1 */ 925 /* initialize hardware #1 */
957 dev->irq2_mask =
958 SAA7134_IRQ2_INTE_DEC3 |
959 SAA7134_IRQ2_INTE_DEC2 |
960 SAA7134_IRQ2_INTE_DEC1 |
961 SAA7134_IRQ2_INTE_DEC0 |
962 SAA7134_IRQ2_INTE_PE |
963 SAA7134_IRQ2_INTE_AR;
964 saa7134_board_init1(dev); 926 saa7134_board_init1(dev);
965 saa7134_hwinit1(dev); 927 saa7134_hwinit1(dev);
966 928
@@ -990,6 +952,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
990 request_module("saa6752hs"); 952 request_module("saa6752hs");
991 request_module_depend("saa7134-empress",&need_empress); 953 request_module_depend("saa7134-empress",&need_empress);
992 } 954 }
955
993 if (card_is_dvb(dev)) 956 if (card_is_dvb(dev))
994 request_module_depend("saa7134-dvb",&need_dvb); 957 request_module_depend("saa7134-dvb",&need_dvb);
995 958
@@ -1144,9 +1107,6 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1144 release_mem_region(pci_resource_start(pci_dev,0), 1107 release_mem_region(pci_resource_start(pci_dev,0),
1145 pci_resource_len(pci_dev,0)); 1108 pci_resource_len(pci_dev,0));
1146 1109
1147#if 0 /* causes some trouble when reinserting the driver ... */
1148 pci_disable_device(pci_dev);
1149#endif
1150 pci_set_drvdata(pci_dev, NULL); 1110 pci_set_drvdata(pci_dev, NULL);
1151 1111
1152 /* free memory */ 1112 /* free memory */
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index aa8e2cf62d55..334bc1850092 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -1,8 +1,11 @@
1/* 1/*
2 * $Id: saa7134-dvb.c,v 1.13 2005/06/12 04:19:19 mchehab Exp $ 2 * $Id: saa7134-dvb.c,v 1.18 2005/07/04 16:05:50 mkrufky Exp $
3 * 3 *
4 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] 4 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
5 * 5 *
6 * Extended 3 / 2005 by Hartmut Hackmann to support various
7 * cards with the tda10046 DVB-T channel decoder
8 *
6 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 10 * 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 11 * the Free Software Foundation; either version 2 of the License, or
@@ -27,23 +30,31 @@
27#include <linux/kthread.h> 30#include <linux/kthread.h>
28#include <linux/suspend.h> 31#include <linux/suspend.h>
29 32
33#define CONFIG_DVB_MT352 1
34#define CONFIG_DVB_TDA1004X 1
35
30#include "saa7134-reg.h" 36#include "saa7134-reg.h"
31#include "saa7134.h" 37#include "saa7134.h"
32 38
33#include "dvb-pll.h" 39#if CONFIG_DVB_MT352
34#include "mt352.h" 40# include "mt352.h"
35#include "mt352_priv.h" /* FIXME */ 41# include "mt352_priv.h" /* FIXME */
36#include "tda1004x.h" 42#endif
43#if CONFIG_DVB_TDA1004X
44# include "tda1004x.h"
45#endif
37 46
38MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 47MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
39MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
40 49
41static unsigned int antenna_pwr = 0; 50static unsigned int antenna_pwr = 0;
51
42module_param(antenna_pwr, int, 0444); 52module_param(antenna_pwr, int, 0444);
43MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)"); 53MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
44 54
45/* ------------------------------------------------------------------ */ 55/* ------------------------------------------------------------------ */
46 56
57#if CONFIG_DVB_MT352
47static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on) 58static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
48{ 59{
49 u32 ok; 60 u32 ok;
@@ -138,51 +149,390 @@ static struct mt352_config pinnacle_300i = {
138 .demod_init = mt352_pinnacle_init, 149 .demod_init = mt352_pinnacle_init,
139 .pll_set = mt352_pinnacle_pll_set, 150 .pll_set = mt352_pinnacle_pll_set,
140}; 151};
152#endif
141 153
142/* ------------------------------------------------------------------ */ 154/* ------------------------------------------------------------------ */
143 155
144static int medion_cardbus_init(struct dvb_frontend* fe) 156#if CONFIG_DVB_TDA1004X
157static int philips_tu1216_pll_init(struct dvb_frontend *fe)
145{ 158{
146 /* anything to do here ??? */ 159 struct saa7134_dev *dev = fe->dvb->priv;
160 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
161 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
162
163 /* setup PLL configuration */
164 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
165 return -EIO;
166 msleep(1);
167
147 return 0; 168 return 0;
148} 169}
149 170
150static int medion_cardbus_pll_set(struct dvb_frontend* fe, 171static int philips_tu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
151 struct dvb_frontend_parameters* params)
152{ 172{
153 struct saa7134_dev *dev = fe->dvb->priv; 173 struct saa7134_dev *dev = fe->dvb->priv;
154 struct v4l2_frequency f; 174 u8 tuner_buf[4];
175 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,.len =
176 sizeof(tuner_buf) };
177 int tuner_frequency = 0;
178 u8 band, cp, filter;
179
180 /* determine charge pump */
181 tuner_frequency = params->frequency + 36166000;
182 if (tuner_frequency < 87000000)
183 return -EINVAL;
184 else if (tuner_frequency < 130000000)
185 cp = 3;
186 else if (tuner_frequency < 160000000)
187 cp = 5;
188 else if (tuner_frequency < 200000000)
189 cp = 6;
190 else if (tuner_frequency < 290000000)
191 cp = 3;
192 else if (tuner_frequency < 420000000)
193 cp = 5;
194 else if (tuner_frequency < 480000000)
195 cp = 6;
196 else if (tuner_frequency < 620000000)
197 cp = 3;
198 else if (tuner_frequency < 830000000)
199 cp = 5;
200 else if (tuner_frequency < 895000000)
201 cp = 7;
202 else
203 return -EINVAL;
204
205 /* determine band */
206 if (params->frequency < 49000000)
207 return -EINVAL;
208 else if (params->frequency < 161000000)
209 band = 1;
210 else if (params->frequency < 444000000)
211 band = 2;
212 else if (params->frequency < 861000000)
213 band = 4;
214 else
215 return -EINVAL;
216
217 /* setup PLL filter */
218 switch (params->u.ofdm.bandwidth) {
219 case BANDWIDTH_6_MHZ:
220 filter = 0;
221 break;
155 222
156 /* 223 case BANDWIDTH_7_MHZ:
157 * this instructs tuner.o to set the frequency, the call will 224 filter = 0;
158 * end up in tuner_command(), VIDIOC_S_FREQUENCY switch. 225 break;
159 * tda9887.o will see that as well. 226
227 case BANDWIDTH_8_MHZ:
228 filter = 1;
229 break;
230
231 default:
232 return -EINVAL;
233 }
234
235 /* calculate divisor
236 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
160 */ 237 */
161 f.tuner = 0; 238 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
162 f.type = V4L2_TUNER_DIGITAL_TV; 239
163 f.frequency = params->frequency / 1000 * 16 / 1000; 240 /* setup tuner buffer */
164 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f); 241 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
242 tuner_buf[1] = tuner_frequency & 0xff;
243 tuner_buf[2] = 0xca;
244 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
245
246 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
247 return -EIO;
248
249 msleep(1);
165 return 0; 250 return 0;
166} 251}
167 252
168static int fe_request_firmware(struct dvb_frontend* fe, 253static int philips_tu1216_request_firmware(struct dvb_frontend *fe,
169 const struct firmware **fw, char* name) 254 const struct firmware **fw, char *name)
170{ 255{
171 struct saa7134_dev *dev = fe->dvb->priv; 256 struct saa7134_dev *dev = fe->dvb->priv;
172 return request_firmware(fw, name, &dev->pci->dev); 257 return request_firmware(fw, name, &dev->pci->dev);
173} 258}
174 259
260static struct tda1004x_config philips_tu1216_config = {
261
262 .demod_address = 0x8,
263 .invert = 1,
264 .invert_oclk = 1,
265 .xtal_freq = TDA10046_XTAL_4M,
266 .agc_config = TDA10046_AGC_DEFAULT,
267 .if_freq = TDA10046_FREQ_3617,
268 .pll_init = philips_tu1216_pll_init,
269 .pll_set = philips_tu1216_pll_set,
270 .pll_sleep = NULL,
271 .request_firmware = philips_tu1216_request_firmware,
272};
273
274/* ------------------------------------------------------------------ */
275
276
277static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
278{
279 struct saa7134_dev *dev = fe->dvb->priv;
280 /* this message is to set up ATC and ALC */
281 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
282 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
283
284 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
285 return -EIO;
286 msleep(1);
287
288 return 0;
289}
290
291static void philips_fmd1216_analog(struct dvb_frontend *fe)
292{
293 struct saa7134_dev *dev = fe->dvb->priv;
294 /* this message actually turns the tuner back to analog mode */
295 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
296 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
297
298 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
299 msleep(1);
300 fmd1216_init[2] = 0x86;
301 fmd1216_init[3] = 0x54;
302 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
303 msleep(1);
304}
305
306static int philips_fmd1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
307{
308 struct saa7134_dev *dev = fe->dvb->priv;
309 u8 tuner_buf[4];
310 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len =
311 sizeof(tuner_buf) };
312 int tuner_frequency = 0;
313 int divider = 0;
314 u8 band, mode, cp;
315
316 /* determine charge pump */
317 tuner_frequency = params->frequency + 36130000;
318 if (tuner_frequency < 87000000)
319 return -EINVAL;
320 /* low band */
321 else if (tuner_frequency < 180000000) {
322 band = 1;
323 mode = 7;
324 cp = 0;
325 } else if (tuner_frequency < 195000000) {
326 band = 1;
327 mode = 6;
328 cp = 1;
329 /* mid band */
330 } else if (tuner_frequency < 366000000) {
331 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
332 band = 10;
333 } else {
334 band = 2;
335 }
336 mode = 7;
337 cp = 0;
338 } else if (tuner_frequency < 478000000) {
339 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
340 band = 10;
341 } else {
342 band = 2;
343 }
344 mode = 6;
345 cp = 1;
346 /* high band */
347 } else if (tuner_frequency < 662000000) {
348 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
349 band = 12;
350 } else {
351 band = 4;
352 }
353 mode = 7;
354 cp = 0;
355 } else if (tuner_frequency < 840000000) {
356 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
357 band = 12;
358 } else {
359 band = 4;
360 }
361 mode = 6;
362 cp = 1;
363 } else {
364 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
365 band = 12;
366 } else {
367 band = 4;
368 }
369 mode = 7;
370 cp = 1;
371
372 }
373 /* calculate divisor */
374 /* ((36166000 + Finput) / 166666) rounded! */
375 divider = (tuner_frequency + 83333) / 166667;
376
377 /* setup tuner buffer */
378 tuner_buf[0] = (divider >> 8) & 0x7f;
379 tuner_buf[1] = divider & 0xff;
380 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
381 tuner_buf[3] = 0x40 | band;
382
383 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
384 return -EIO;
385 return 0;
386}
387
388
175static struct tda1004x_config medion_cardbus = { 389static struct tda1004x_config medion_cardbus = {
176 .demod_address = 0x08, /* not sure this is correct */ 390 .demod_address = 0x08,
177 .invert = 0, 391 .invert = 1,
178 .invert_oclk = 0, 392 .invert_oclk = 0,
179 .pll_init = medion_cardbus_init, 393 .xtal_freq = TDA10046_XTAL_16M,
180 .pll_set = medion_cardbus_pll_set, 394 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
181 .request_firmware = fe_request_firmware, 395 .if_freq = TDA10046_FREQ_3613,
396 .pll_init = philips_fmd1216_pll_init,
397 .pll_set = philips_fmd1216_pll_set,
398 .pll_sleep = philips_fmd1216_analog,
399 .request_firmware = NULL,
182}; 400};
183 401
184/* ------------------------------------------------------------------ */ 402/* ------------------------------------------------------------------ */
185 403
404struct tda827x_data {
405 u32 lomax;
406 u8 spd;
407 u8 bs;
408 u8 bp;
409 u8 cp;
410 u8 gc3;
411 u8 div1p5;
412};
413
414static struct tda827x_data tda827x_dvbt[] = {
415 { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
416 { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
417 { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
418 { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
419 { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
420 { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
421 { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
422 { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
423 { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
424 { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
425 { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
426 { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
427 { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
428 { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
429 { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
430 { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
431 { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
432 { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
433 { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
434 { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
435 { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
436 { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
437 { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
438 { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
439 { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
440 { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
441 { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
442 { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
443 { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
444};
445
446static int philips_tda827x_pll_init(struct dvb_frontend *fe)
447{
448 return 0;
449}
450
451static int philips_tda827x_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
452{
453 struct saa7134_dev *dev = fe->dvb->priv;
454 u8 tuner_buf[14];
455
456 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,
457 .len = sizeof(tuner_buf) };
458 int i, tuner_freq, if_freq;
459 u32 N;
460 switch (params->u.ofdm.bandwidth) {
461 case BANDWIDTH_6_MHZ:
462 if_freq = 4000000;
463 break;
464 case BANDWIDTH_7_MHZ:
465 if_freq = 4500000;
466 break;
467 default: /* 8 MHz or Auto */
468 if_freq = 5000000;
469 break;
470 }
471 tuner_freq = params->frequency + if_freq;
472
473 i = 0;
474 while (tda827x_dvbt[i].lomax < tuner_freq) {
475 if(tda827x_dvbt[i + 1].lomax == 0)
476 break;
477 i++;
478 }
479
480 N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2);
481 tuner_buf[0] = 0;
482 tuner_buf[1] = (N>>8) | 0x40;
483 tuner_buf[2] = N & 0xff;
484 tuner_buf[3] = 0;
485 tuner_buf[4] = 0x52;
486 tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
487 (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
488 tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
489 tuner_buf[7] = 0xbf;
490 tuner_buf[8] = 0x2a;
491 tuner_buf[9] = 0x05;
492 tuner_buf[10] = 0xff;
493 tuner_buf[11] = 0x00;
494 tuner_buf[12] = 0x00;
495 tuner_buf[13] = 0x40;
496
497 tuner_msg.len = 14;
498 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
499 return -EIO;
500
501 msleep(500);
502 /* correct CP value */
503 tuner_buf[0] = 0x30;
504 tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
505 tuner_msg.len = 2;
506 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
507
508 return 0;
509}
510
511static void philips_tda827x_pll_sleep(struct dvb_frontend *fe)
512{
513 struct saa7134_dev *dev = fe->dvb->priv;
514 static u8 tda827x_sleep[] = { 0x30, 0xd0};
515 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep,
516 .len = sizeof(tda827x_sleep) };
517 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
518}
519
520static struct tda1004x_config tda827x_lifeview_config = {
521 .demod_address = 0x08,
522 .invert = 1,
523 .invert_oclk = 0,
524 .xtal_freq = TDA10046_XTAL_16M,
525 .agc_config = TDA10046_AGC_TDA827X,
526 .if_freq = TDA10046_FREQ_045,
527 .pll_init = philips_tda827x_pll_init,
528 .pll_set = philips_tda827x_pll_set,
529 .pll_sleep = philips_tda827x_pll_sleep,
530 .request_firmware = NULL,
531};
532#endif
533
534/* ------------------------------------------------------------------ */
535
186static int dvb_init(struct saa7134_dev *dev) 536static int dvb_init(struct saa7134_dev *dev)
187{ 537{
188 /* init struct videobuf_dvb */ 538 /* init struct videobuf_dvb */
@@ -197,18 +547,31 @@ static int dvb_init(struct saa7134_dev *dev)
197 dev); 547 dev);
198 548
199 switch (dev->board) { 549 switch (dev->board) {
550#if CONFIG_DVB_MT352
200 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: 551 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
201 printk("%s: pinnacle 300i dvb setup\n",dev->name); 552 printk("%s: pinnacle 300i dvb setup\n",dev->name);
202 dev->dvb.frontend = mt352_attach(&pinnacle_300i, 553 dev->dvb.frontend = mt352_attach(&pinnacle_300i,
203 &dev->i2c_adap); 554 &dev->i2c_adap);
204 break; 555 break;
556#endif
557#if CONFIG_DVB_TDA1004X
205 case SAA7134_BOARD_MD7134: 558 case SAA7134_BOARD_MD7134:
206 dev->dvb.frontend = tda10046_attach(&medion_cardbus, 559 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
207 &dev->i2c_adap); 560 &dev->i2c_adap);
208 if (NULL == dev->dvb.frontend)
209 printk("%s: Hmm, looks like this is the old MD7134 "
210 "version without DVB-T support\n",dev->name);
211 break; 561 break;
562 case SAA7134_BOARD_PHILIPS_TOUGH:
563 dev->dvb.frontend = tda10046_attach(&philips_tu1216_config,
564 &dev->i2c_adap);
565 break;
566 case SAA7134_BOARD_FLYDVBTDUO:
567 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config,
568 &dev->i2c_adap);
569 break;
570 case SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS:
571 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config,
572 &dev->i2c_adap);
573 break;
574#endif
212 default: 575 default:
213 printk("%s: Huh? unknown DVB card?\n",dev->name); 576 printk("%s: Huh? unknown DVB card?\n",dev->name);
214 break; 577 break;
@@ -227,8 +590,6 @@ static int dvb_fini(struct saa7134_dev *dev)
227{ 590{
228 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE; 591 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
229 592
230 printk("%s: %s\n",dev->name,__FUNCTION__);
231
232 switch (dev->board) { 593 switch (dev->board) {
233 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: 594 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
234 /* otherwise we don't detect the tuner on next insmod */ 595 /* otherwise we don't detect the tuner on next insmod */
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c
index b6f002e8421d..93dd61978541 100644
--- a/drivers/media/video/saa7134/saa7134-i2c.c
+++ b/drivers/media/video/saa7134/saa7134-i2c.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134-i2c.c,v 1.11 2005/06/12 01:36:14 mchehab Exp $ 2 * $Id: saa7134-i2c.c,v 1.19 2005/07/07 01:49:30 mkrufky Exp $
3 * 3 *
4 * device driver for philips saa7134 based TV cards 4 * device driver for philips saa7134 based TV cards
5 * i2c interface support 5 * i2c interface support
@@ -197,10 +197,6 @@ static inline int i2c_send_byte(struct saa7134_dev *dev,
197 enum i2c_status status; 197 enum i2c_status status;
198 __u32 dword; 198 __u32 dword;
199 199
200#if 0
201 i2c_set_attr(dev,attr);
202 saa_writeb(SAA7134_I2C_DATA, data);
203#else
204 /* have to write both attr + data in one 32bit word */ 200 /* have to write both attr + data in one 32bit word */
205 dword = saa_readl(SAA7134_I2C_ATTR_STATUS >> 2); 201 dword = saa_readl(SAA7134_I2C_ATTR_STATUS >> 2);
206 dword &= 0x0f; 202 dword &= 0x0f;
@@ -210,7 +206,6 @@ static inline int i2c_send_byte(struct saa7134_dev *dev,
210// dword |= 0x40 << 16; /* 400 kHz */ 206// dword |= 0x40 << 16; /* 400 kHz */
211 dword |= 0xf0 << 24; 207 dword |= 0xf0 << 24;
212 saa_writel(SAA7134_I2C_ATTR_STATUS >> 2, dword); 208 saa_writel(SAA7134_I2C_ATTR_STATUS >> 2, dword);
213#endif
214 d2printk(KERN_DEBUG "%s: i2c data => 0x%x\n",dev->name,data); 209 d2printk(KERN_DEBUG "%s: i2c data => 0x%x\n",dev->name,data);
215 210
216 if (!i2c_is_busy_wait(dev)) 211 if (!i2c_is_busy_wait(dev))
@@ -331,12 +326,44 @@ static u32 functionality(struct i2c_adapter *adap)
331 326
332static int attach_inform(struct i2c_client *client) 327static int attach_inform(struct i2c_client *client)
333{ 328{
334 struct saa7134_dev *dev = client->adapter->algo_data; 329 struct saa7134_dev *dev = client->adapter->algo_data;
335 int tuner = dev->tuner_type; 330 int tuner = dev->tuner_type;
336 int conf = dev->tda9887_conf; 331 int conf = dev->tda9887_conf;
332 struct tuner_setup tun_setup;
333
334 d1printk( "%s i2c attach [addr=0x%x,client=%s]\n",
335 client->driver->name,client->addr,i2c_clientname(client));
336
337 if (!client->driver->command)
338 return 0;
339
340 if (saa7134_boards[dev->board].radio_type != UNSET) {
341
342 tun_setup.type = saa7134_boards[dev->board].radio_type;
343 tun_setup.addr = saa7134_boards[dev->board].radio_addr;
344
345 if ((tun_setup.addr == ADDR_UNSET) || (tun_setup.addr == client->addr)) {
346 tun_setup.mode_mask = T_RADIO;
347
348 client->driver->command(client, TUNER_SET_TYPE_ADDR, &tun_setup);
349 }
350 }
351
352 if (tuner != UNSET) {
353
354 tun_setup.type = tuner;
355 tun_setup.addr = saa7134_boards[dev->board].tuner_addr;
356
357 if ((tun_setup.addr == ADDR_UNSET)||(tun_setup.addr == client->addr)) {
358
359 tun_setup.mode_mask = T_ANALOG_TV;
360
361 client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_setup);
362 }
363 }
364
365 client->driver->command(client, TDA9887_SET_CONFIG, &conf);
337 366
338 saa7134_i2c_call_clients(dev,TUNER_SET_TYPE,&tuner);
339 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&conf);
340 return 0; 367 return 0;
341} 368}
342 369
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index aba2b9de60de..213740122fe6 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134-input.c,v 1.19 2005/06/07 18:02:26 nsh Exp $ 2 * $Id: saa7134-input.c,v 1.21 2005/06/22 23:37:34 nsh Exp $
3 * 3 *
4 * handle saa7134 IR remotes via linux kernel input layer. 4 * handle saa7134 IR remotes via linux kernel input layer.
5 * 5 *
@@ -68,10 +68,8 @@ static IR_KEYTAB_TYPE flyvideo_codes[IR_KEYTAB_SIZE] = {
68 [ 6 ] = KEY_AGAIN, // Recal 68 [ 6 ] = KEY_AGAIN, // Recal
69 [ 16 ] = KEY_KPENTER, // Enter 69 [ 16 ] = KEY_KPENTER, // Enter
70 70
71#if 1 /* FIXME */
72 [ 26 ] = KEY_F22, // Stereo 71 [ 26 ] = KEY_F22, // Stereo
73 [ 24 ] = KEY_EDIT, // AV Source 72 [ 24 ] = KEY_EDIT, // AV Source
74#endif
75}; 73};
76 74
77static IR_KEYTAB_TYPE cinergy_codes[IR_KEYTAB_SIZE] = { 75static IR_KEYTAB_TYPE cinergy_codes[IR_KEYTAB_SIZE] = {
@@ -172,45 +170,45 @@ static IR_KEYTAB_TYPE eztv_codes[IR_KEYTAB_SIZE] = {
172}; 170};
173 171
174static IR_KEYTAB_TYPE avacssmart_codes[IR_KEYTAB_SIZE] = { 172static IR_KEYTAB_TYPE avacssmart_codes[IR_KEYTAB_SIZE] = {
175 [ 30 ] = KEY_POWER, // power 173 [ 30 ] = KEY_POWER, // power
176 [ 28 ] = KEY_SEARCH, // scan 174 [ 28 ] = KEY_SEARCH, // scan
177 [ 7 ] = KEY_SELECT, // source 175 [ 7 ] = KEY_SELECT, // source
178 176
179 [ 22 ] = KEY_VOLUMEUP, 177 [ 22 ] = KEY_VOLUMEUP,
180 [ 20 ] = KEY_VOLUMEDOWN, 178 [ 20 ] = KEY_VOLUMEDOWN,
181 [ 31 ] = KEY_CHANNELUP, 179 [ 31 ] = KEY_CHANNELUP,
182 [ 23 ] = KEY_CHANNELDOWN, 180 [ 23 ] = KEY_CHANNELDOWN,
183 [ 24 ] = KEY_MUTE, 181 [ 24 ] = KEY_MUTE,
184 182
185 [ 2 ] = KEY_KP0, 183 [ 2 ] = KEY_KP0,
186 [ 1 ] = KEY_KP1, 184 [ 1 ] = KEY_KP1,
187 [ 11 ] = KEY_KP2, 185 [ 11 ] = KEY_KP2,
188 [ 27 ] = KEY_KP3, 186 [ 27 ] = KEY_KP3,
189 [ 5 ] = KEY_KP4, 187 [ 5 ] = KEY_KP4,
190 [ 9 ] = KEY_KP5, 188 [ 9 ] = KEY_KP5,
191 [ 21 ] = KEY_KP6, 189 [ 21 ] = KEY_KP6,
192 [ 6 ] = KEY_KP7, 190 [ 6 ] = KEY_KP7,
193 [ 10 ] = KEY_KP8, 191 [ 10 ] = KEY_KP8,
194 [ 18 ] = KEY_KP9, 192 [ 18 ] = KEY_KP9,
195 [ 16 ] = KEY_KPDOT, 193 [ 16 ] = KEY_KPDOT,
196 194
197 [ 3 ] = KEY_TUNER, // tv/fm 195 [ 3 ] = KEY_TUNER, // tv/fm
198 [ 4 ] = KEY_REWIND, // fm tuning left or function left 196 [ 4 ] = KEY_REWIND, // fm tuning left or function left
199 [ 12 ] = KEY_FORWARD, // fm tuning right or function right 197 [ 12 ] = KEY_FORWARD, // fm tuning right or function right
200 198
201 [ 0 ] = KEY_RECORD, 199 [ 0 ] = KEY_RECORD,
202 [ 8 ] = KEY_STOP, 200 [ 8 ] = KEY_STOP,
203 [ 17 ] = KEY_PLAY, 201 [ 17 ] = KEY_PLAY,
204 202
205 [ 25 ] = KEY_ZOOM, 203 [ 25 ] = KEY_ZOOM,
206 [ 14 ] = KEY_MENU, // function 204 [ 14 ] = KEY_MENU, // function
207 [ 19 ] = KEY_AGAIN, // recall 205 [ 19 ] = KEY_AGAIN, // recall
208 [ 29 ] = KEY_RESTART, // reset 206 [ 29 ] = KEY_RESTART, // reset
207 [ 26 ] = KEY_SHUFFLE, // snapshot/shuffle
209 208
210// FIXME 209// FIXME
211 [ 13 ] = KEY_F21, // mts 210 [ 13 ] = KEY_F21, // mts
212 [ 15 ] = KEY_F22, // min 211 [ 15 ] = KEY_F22, // min
213 [ 26 ] = KEY_F23, // freeze
214}; 212};
215 213
216/* Alex Hermann <gaaf@gmx.net> */ 214/* Alex Hermann <gaaf@gmx.net> */
@@ -489,13 +487,14 @@ int saa7134_input_init1(struct saa7134_dev *dev)
489 break; 487 break;
490 case SAA7134_BOARD_ECS_TVP3XP: 488 case SAA7134_BOARD_ECS_TVP3XP:
491 case SAA7134_BOARD_ECS_TVP3XP_4CB5: 489 case SAA7134_BOARD_ECS_TVP3XP_4CB5:
492 ir_codes = eztv_codes; 490 ir_codes = eztv_codes;
493 mask_keycode = 0x00017c; 491 mask_keycode = 0x00017c;
494 mask_keyup = 0x000002; 492 mask_keyup = 0x000002;
495 polling = 50; // ms 493 polling = 50; // ms
496 break; 494 break;
495 case SAA7134_BOARD_KWORLD_XPERT:
497 case SAA7134_BOARD_AVACSSMARTTV: 496 case SAA7134_BOARD_AVACSSMARTTV:
498 ir_codes = avacssmart_codes; 497 ir_codes = avacssmart_codes;
499 mask_keycode = 0x00001F; 498 mask_keycode = 0x00001F;
500 mask_keyup = 0x000020; 499 mask_keyup = 0x000020;
501 polling = 50; // ms 500 polling = 50; // ms
@@ -524,6 +523,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
524 polling = 50; // ms 523 polling = 50; // ms
525 break; 524 break;
526 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 525 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
526 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
527 ir_codes = videomate_tv_pvr_codes; 527 ir_codes = videomate_tv_pvr_codes;
528 mask_keycode = 0x00003F; 528 mask_keycode = 0x00003F;
529 mask_keyup = 0x400000; 529 mask_keyup = 0x400000;
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index 81732904623f..b5bede95dbf5 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134-oss.c,v 1.14 2005/05/18 22:45:16 hhackmann Exp $ 2 * $Id: saa7134-oss.c,v 1.17 2005/06/28 23:41:47 mkrufky Exp $
3 * 3 *
4 * device driver for philips saa7134 based TV cards 4 * device driver for philips saa7134 based TV cards
5 * oss dsp interface 5 * oss dsp interface
@@ -556,21 +556,28 @@ mixer_recsrc_7134(struct saa7134_dev *dev)
556static int 556static int
557mixer_recsrc_7133(struct saa7134_dev *dev) 557mixer_recsrc_7133(struct saa7134_dev *dev)
558{ 558{
559 u32 value = 0xbbbbbb; 559 u32 anabar, xbarin;
560 560
561 xbarin = 0x03; // adc
562 anabar = 0;
561 switch (dev->oss.input) { 563 switch (dev->oss.input) {
562 case TV: 564 case TV:
563 value = 0xbbbb10; /* MAIN */ 565 xbarin = 0; // Demodulator
566 anabar = 2; // DACs
564 break; 567 break;
565 case LINE1: 568 case LINE1:
566 value = 0xbbbb32; /* AUX1 */ 569 anabar = 0; // aux1, aux1
567 break; 570 break;
568 case LINE2: 571 case LINE2:
569 case LINE2_LEFT: 572 case LINE2_LEFT:
570 value = 0xbbbb54; /* AUX2 */ 573 anabar = 9; // aux2, aux2
571 break; 574 break;
572 } 575 }
573 saa_dsp_writel(dev, 0x46c >> 2, value); 576 /* output xbar always main channel */
577 saa_dsp_writel(dev, 0x46c >> 2, 0xbbbb10);
578 saa_dsp_writel(dev, 0x464 >> 2, xbarin);
579 saa_writel(0x594 >> 2, anabar);
580
574 return 0; 581 return 0;
575} 582}
576 583
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
index 345eb2a8c28d..4dd9f1b23928 100644
--- a/drivers/media/video/saa7134/saa7134-ts.c
+++ b/drivers/media/video/saa7134/saa7134-ts.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134-ts.c,v 1.14 2005/02/03 10:24:33 kraxel Exp $ 2 * $Id: saa7134-ts.c,v 1.15 2005/06/14 22:48:18 hhackmann Exp $
3 * 3 *
4 * device driver for philips saa7134 based TV cards 4 * device driver for philips saa7134 based TV cards
5 * video4linux video interface 5 * video4linux video interface
@@ -221,10 +221,10 @@ void saa7134_irq_ts_done(struct saa7134_dev *dev, unsigned long status)
221 if (dev->ts_q.curr) { 221 if (dev->ts_q.curr) {
222 field = dev->ts_q.curr->vb.field; 222 field = dev->ts_q.curr->vb.field;
223 if (field == V4L2_FIELD_TOP) { 223 if (field == V4L2_FIELD_TOP) {
224 if ((status & 0x100000) != 0x000000) 224 if ((status & 0x100000) != 0x100000)
225 goto done; 225 goto done;
226 } else { 226 } else {
227 if ((status & 0x100000) != 0x100000) 227 if ((status & 0x100000) != 0x000000)
228 goto done; 228 goto done;
229 } 229 }
230 saa7134_buffer_finish(dev,&dev->ts_q,STATE_DONE); 230 saa7134_buffer_finish(dev,&dev->ts_q,STATE_DONE);
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
index 3617e7f7a410..eeafa5a71d2b 100644
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134-tvaudio.c,v 1.25 2005/06/07 19:00:38 nsh Exp $ 2 * $Id: saa7134-tvaudio.c,v 1.30 2005/06/28 23:41:47 mkrufky Exp $
3 * 3 *
4 * device driver for philips saa7134 based TV cards 4 * device driver for philips saa7134 based TV cards
5 * tv audio decoder (fm stereo, nicam, ...) 5 * tv audio decoder (fm stereo, nicam, ...)
@@ -169,7 +169,7 @@ static void tvaudio_init(struct saa7134_dev *dev)
169 int clock = saa7134_boards[dev->board].audio_clock; 169 int clock = saa7134_boards[dev->board].audio_clock;
170 170
171 if (UNSET != audio_clock_override) 171 if (UNSET != audio_clock_override)
172 clock = audio_clock_override; 172 clock = audio_clock_override;
173 173
174 /* init all audio registers */ 174 /* init all audio registers */
175 saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x00); 175 saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x00);
@@ -219,14 +219,17 @@ static void mute_input_7134(struct saa7134_dev *dev)
219 in = dev->input; 219 in = dev->input;
220 mute = (dev->ctl_mute || 220 mute = (dev->ctl_mute ||
221 (dev->automute && (&card(dev).radio) != in)); 221 (dev->automute && (&card(dev).radio) != in));
222 if (PCI_DEVICE_ID_PHILIPS_SAA7130 == dev->pci->device && 222 if (card(dev).mute.name) {
223 card(dev).mute.name) { 223 /*
224 /* 7130 - we'll mute using some unconnected audio input */ 224 * 7130 - we'll mute using some unconnected audio input
225 * 7134 - we'll probably should switch external mux with gpio
226 */
225 if (mute) 227 if (mute)
226 in = &card(dev).mute; 228 in = &card(dev).mute;
227 } 229 }
230
228 if (dev->hw_mute == mute && 231 if (dev->hw_mute == mute &&
229 dev->hw_input == in) { 232 dev->hw_input == in) {
230 dprintk("mute/input: nothing to do [mute=%d,input=%s]\n", 233 dprintk("mute/input: nothing to do [mute=%d,input=%s]\n",
231 mute,in->name); 234 mute,in->name);
232 return; 235 return;
@@ -260,6 +263,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
260 /* switch gpio-connected external audio mux */ 263 /* switch gpio-connected external audio mux */
261 if (0 == card(dev).gpiomask) 264 if (0 == card(dev).gpiomask)
262 return; 265 return;
266
263 mask = card(dev).gpiomask; 267 mask = card(dev).gpiomask;
264 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); 268 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
265 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio); 269 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
@@ -339,13 +343,8 @@ static int tvaudio_sleep(struct saa7134_dev *dev, int timeout)
339 set_current_state(TASK_INTERRUPTIBLE); 343 set_current_state(TASK_INTERRUPTIBLE);
340 schedule(); 344 schedule();
341 } else { 345 } else {
342#if 0
343 /* hmm, that one doesn't return on wakeup ... */
344 msleep_interruptible(timeout);
345#else
346 set_current_state(TASK_INTERRUPTIBLE); 346 set_current_state(TASK_INTERRUPTIBLE);
347 schedule_timeout(msecs_to_jiffies(timeout)); 347 schedule_timeout(msecs_to_jiffies(timeout));
348#endif
349 } 348 }
350 } 349 }
351 remove_wait_queue(&dev->thread.wq, &wait); 350 remove_wait_queue(&dev->thread.wq, &wait);
@@ -400,27 +399,10 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
400 return value; 399 return value;
401} 400}
402 401
403#if 0
404static void sifdebug_dump_regs(struct saa7134_dev *dev)
405{
406 print_regb(AUDIO_STATUS);
407 print_regb(IDENT_SIF);
408 print_regb(LEVEL_READOUT1);
409 print_regb(LEVEL_READOUT2);
410 print_regb(DCXO_IDENT_CTRL);
411 print_regb(DEMODULATOR);
412 print_regb(AGC_GAIN_SELECT);
413 print_regb(MONITOR_SELECT);
414 print_regb(FM_DEEMPHASIS);
415 print_regb(FM_DEMATRIX);
416 print_regb(SIF_SAMPLE_FREQ);
417 print_regb(ANALOG_IO_SELECT);
418}
419#endif
420 402
421static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *audio) 403static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *audio)
422{ 404{
423 __u32 idp,nicam; 405 __u32 idp, nicam, nicam_status;
424 int retval = -1; 406 int retval = -1;
425 407
426 switch (audio->mode) { 408 switch (audio->mode) {
@@ -442,18 +424,24 @@ static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au
442 break; 424 break;
443 case TVAUDIO_NICAM_FM: 425 case TVAUDIO_NICAM_FM:
444 case TVAUDIO_NICAM_AM: 426 case TVAUDIO_NICAM_AM:
445 nicam = saa_readb(SAA7134_NICAM_STATUS); 427 nicam = saa_readb(SAA7134_AUDIO_STATUS);
446 dprintk("getstereo: nicam=0x%x\n",nicam); 428 dprintk("getstereo: nicam=0x%x\n",nicam);
447 switch (nicam & 0x0b) { 429 if (nicam & 0x1) {
448 case 0x08: 430 nicam_status = saa_readb(SAA7134_NICAM_STATUS);
449 retval = V4L2_TUNER_SUB_MONO; 431 dprintk("getstereo: nicam_status=0x%x\n", nicam_status);
450 break; 432
451 case 0x09: 433 switch (nicam_status & 0x03) {
452 retval = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 434 case 0x01:
453 break; 435 retval = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
454 case 0x0a: 436 break;
455 retval = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; 437 case 0x02:
456 break; 438 retval = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
439 break;
440 default:
441 retval = V4L2_TUNER_SUB_MONO;
442 }
443 } else {
444 /* No nicam detected */
457 } 445 }
458 break; 446 break;
459 } 447 }
@@ -489,15 +477,15 @@ static int tvaudio_setstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au
489 break; 477 break;
490 case TVAUDIO_FM_K_STEREO: 478 case TVAUDIO_FM_K_STEREO:
491 case TVAUDIO_FM_BG_STEREO: 479 case TVAUDIO_FM_BG_STEREO:
480 case TVAUDIO_NICAM_AM:
481 case TVAUDIO_NICAM_FM:
492 dprintk("setstereo [fm] => %s\n", 482 dprintk("setstereo [fm] => %s\n",
493 name[ mode % ARRAY_SIZE(name) ]); 483 name[ mode % ARRAY_SIZE(name) ]);
494 reg = fm[ mode % ARRAY_SIZE(fm) ]; 484 reg = fm[ mode % ARRAY_SIZE(fm) ];
495 saa_writeb(SAA7134_FM_DEMATRIX, reg); 485 saa_writeb(SAA7134_FM_DEMATRIX, reg);
496 break; 486 break;
497 case TVAUDIO_FM_SAT_STEREO: 487 case TVAUDIO_FM_SAT_STEREO:
498 case TVAUDIO_NICAM_AM: 488 /* Not implemented */
499 case TVAUDIO_NICAM_FM:
500 /* FIXME */
501 break; 489 break;
502 } 490 }
503 return 0; 491 return 0;
@@ -596,7 +584,7 @@ static int tvaudio_thread(void *data)
596 /* find the exact tv audio norm */ 584 /* find the exact tv audio norm */
597 for (audio = UNSET, i = 0; i < TVAUDIO; i++) { 585 for (audio = UNSET, i = 0; i < TVAUDIO; i++) {
598 if (dev->tvnorm->id != UNSET && 586 if (dev->tvnorm->id != UNSET &&
599 !(dev->tvnorm->id & tvaudio[i].std)) 587 !(dev->tvnorm->id & tvaudio[i].std))
600 continue; 588 continue;
601 if (tvaudio[i].carr1 != carrier) 589 if (tvaudio[i].carr1 != carrier)
602 continue; 590 continue;
@@ -703,24 +691,6 @@ static inline int saa_dsp_wait_bit(struct saa7134_dev *dev, int bit)
703 return 0; 691 return 0;
704} 692}
705 693
706#if 0
707static int saa_dsp_readl(struct saa7134_dev *dev, int reg, u32 *value)
708{
709 int err;
710
711 d2printk("dsp read reg 0x%x\n", reg<<2);
712 saa_readl(reg);
713 err = saa_dsp_wait_bit(dev,SAA7135_DSP_RWSTATE_RDB);
714 if (err < 0)
715 return err;
716 *value = saa_readl(reg);
717 d2printk("dsp read => 0x%06x\n", *value & 0xffffff);
718 err = saa_dsp_wait_bit(dev,SAA7135_DSP_RWSTATE_IDA);
719 if (err < 0)
720 return err;
721 return 0;
722}
723#endif
724 694
725int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value) 695int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value)
726{ 696{
@@ -753,31 +723,50 @@ static int getstereo_7133(struct saa7134_dev *dev)
753static int mute_input_7133(struct saa7134_dev *dev) 723static int mute_input_7133(struct saa7134_dev *dev)
754{ 724{
755 u32 reg = 0; 725 u32 reg = 0;
726 u32 xbarin, xbarout;
756 int mask; 727 int mask;
728 struct saa7134_input *in;
757 729
730 /* Hac 0506 route OSS sound simultanously */
731 xbarin = 0x03;
758 switch (dev->input->amux) { 732 switch (dev->input->amux) {
759 case TV: 733 case TV:
760 reg = 0x02; 734 reg = 0x02;
735 xbarin = 0;
761 break; 736 break;
762 case LINE1: 737 case LINE1:
763 reg = 0x00; 738 reg = 0x00;
764 break; 739 break;
765 case LINE2: 740 case LINE2:
766 case LINE2_LEFT: 741 case LINE2_LEFT:
767 reg = 0x01; 742 reg = 0x09;
768 break; 743 break;
769 } 744 }
770 if (dev->ctl_mute) 745 saa_dsp_writel(dev, 0x464 >> 2, xbarin);
746 if (dev->ctl_mute) {
771 reg = 0x07; 747 reg = 0x07;
748 xbarout = 0xbbbbbb;
749 } else
750 xbarout = 0xbbbb10;
751 saa_dsp_writel(dev, 0x46c >> 2, xbarout);
752
772 saa_writel(0x594 >> 2, reg); 753 saa_writel(0x594 >> 2, reg);
773 754
755
774 /* switch gpio-connected external audio mux */ 756 /* switch gpio-connected external audio mux */
775 if (0 != card(dev).gpiomask) { 757 if (0 != card(dev).gpiomask) {
776 mask = card(dev).gpiomask; 758 mask = card(dev).gpiomask;
759
760 if (card(dev).mute.name && dev->ctl_mute)
761 in = &card(dev).mute;
762 else
763 in = dev->input;
764
777 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); 765 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
778 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, dev->input->gpio); 766 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
779 saa7134_track_gpio(dev,dev->input->name); 767 saa7134_track_gpio(dev,in->name);
780 } 768 }
769
781 return 0; 770 return 0;
782} 771}
783 772
diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c
index 3c33c591cc85..29e51cad2aaf 100644
--- a/drivers/media/video/saa7134/saa7134-vbi.c
+++ b/drivers/media/video/saa7134/saa7134-vbi.c
@@ -130,13 +130,7 @@ static int buffer_prepare(struct videobuf_queue *q,
130 lines = norm->vbi_v_stop_0 - norm->vbi_v_start_0 +1; 130 lines = norm->vbi_v_stop_0 - norm->vbi_v_start_0 +1;
131 if (lines > VBI_LINE_COUNT) 131 if (lines > VBI_LINE_COUNT)
132 lines = VBI_LINE_COUNT; 132 lines = VBI_LINE_COUNT;
133#if 1
134 llength = VBI_LINE_LENGTH; 133 llength = VBI_LINE_LENGTH;
135#else
136 llength = (norm->h_stop - norm->h_start +1) * 2;
137 if (llength > VBI_LINE_LENGTH)
138 llength = VBI_LINE_LENGTH;
139#endif
140 size = lines * llength * 2; 134 size = lines * llength * 2;
141 if (0 != buf->vb.baddr && buf->vb.bsize < size) 135 if (0 != buf->vb.baddr && buf->vb.bsize < size)
142 return -EINVAL; 136 return -EINVAL;
@@ -178,13 +172,7 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
178 int llength,lines; 172 int llength,lines;
179 173
180 lines = dev->tvnorm->vbi_v_stop_0 - dev->tvnorm->vbi_v_start_0 +1; 174 lines = dev->tvnorm->vbi_v_stop_0 - dev->tvnorm->vbi_v_start_0 +1;
181#if 1
182 llength = VBI_LINE_LENGTH; 175 llength = VBI_LINE_LENGTH;
183#else
184 llength = (norm->h_stop - norm->h_start +1) * 2;
185 if (llength > VBI_LINE_LENGTH)
186 llength = VBI_LINE_LENGTH;
187#endif
188 *size = lines * llength * 2; 176 *size = lines * llength * 2;
189 if (0 == *count) 177 if (0 == *count)
190 *count = vbibufs; 178 *count = vbibufs;
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index c0a2ee520531..a4c2f751d097 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134-video.c,v 1.30 2005/06/07 19:00:38 nsh Exp $ 2 * $Id: saa7134-video.c,v 1.36 2005/06/28 23:41:47 mkrufky Exp $
3 * 3 *
4 * device driver for philips saa7134 based TV cards 4 * device driver for philips saa7134 based TV cards
5 * video4linux video interface 5 * video4linux video interface
@@ -274,7 +274,7 @@ static struct saa7134_tvnorm tvnorms[] = {
274 274
275 .h_start = 0, 275 .h_start = 0,
276 .h_stop = 719, 276 .h_stop = 719,
277 .video_v_start = 23, 277 .video_v_start = 23,
278 .video_v_stop = 262, 278 .video_v_stop = 262,
279 .vbi_v_start_0 = 10, 279 .vbi_v_start_0 = 10,
280 .vbi_v_stop_0 = 21, 280 .vbi_v_stop_0 = 21,
@@ -1204,7 +1204,6 @@ static int video_open(struct inode *inode, struct file *file)
1204 struct list_head *list; 1204 struct list_head *list;
1205 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1205 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1206 int radio = 0; 1206 int radio = 0;
1207
1208 list_for_each(list,&saa7134_devlist) { 1207 list_for_each(list,&saa7134_devlist) {
1209 h = list_entry(list, struct saa7134_dev, devlist); 1208 h = list_entry(list, struct saa7134_dev, devlist);
1210 if (h->video_dev && (h->video_dev->minor == minor)) 1209 if (h->video_dev && (h->video_dev->minor == minor))
@@ -1256,12 +1255,12 @@ static int video_open(struct inode *inode, struct file *file)
1256 if (fh->radio) { 1255 if (fh->radio) {
1257 /* switch to radio mode */ 1256 /* switch to radio mode */
1258 saa7134_tvaudio_setinput(dev,&card(dev).radio); 1257 saa7134_tvaudio_setinput(dev,&card(dev).radio);
1259 saa7134_i2c_call_clients(dev,AUDC_SET_RADIO,NULL); 1258 saa7134_i2c_call_clients(dev,AUDC_SET_RADIO, NULL);
1260 } else { 1259 } else {
1261 /* switch to video/vbi mode */ 1260 /* switch to video/vbi mode */
1262 video_mux(dev,dev->ctl_input); 1261 video_mux(dev,dev->ctl_input);
1263 } 1262 }
1264 return 0; 1263 return 0;
1265} 1264}
1266 1265
1267static ssize_t 1266static ssize_t
@@ -1304,10 +1303,10 @@ video_poll(struct file *file, struct poll_table_struct *wait)
1304 } else { 1303 } else {
1305 down(&fh->cap.lock); 1304 down(&fh->cap.lock);
1306 if (UNSET == fh->cap.read_off) { 1305 if (UNSET == fh->cap.read_off) {
1307 /* need to capture a new frame */ 1306 /* need to capture a new frame */
1308 if (res_locked(fh->dev,RESOURCE_VIDEO)) { 1307 if (res_locked(fh->dev,RESOURCE_VIDEO)) {
1309 up(&fh->cap.lock); 1308 up(&fh->cap.lock);
1310 return POLLERR; 1309 return POLLERR;
1311 } 1310 }
1312 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) { 1311 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) {
1313 up(&fh->cap.lock); 1312 up(&fh->cap.lock);
@@ -1363,6 +1362,36 @@ static int video_release(struct inode *inode, struct file *file)
1363 res_free(dev,fh,RESOURCE_VBI); 1362 res_free(dev,fh,RESOURCE_VBI);
1364 } 1363 }
1365 1364
1365 /* ts-capture will not work in planar mode, so turn it off Hac: 04.05*/
1366 saa_andorb(SAA7134_OFMT_VIDEO_A, 0x1f, 0);
1367 saa_andorb(SAA7134_OFMT_VIDEO_B, 0x1f, 0);
1368 saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0);
1369 saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0);
1370
1371 if (dev->tuner_type == TUNER_PHILIPS_TDA8290) {
1372 u8 data[2];
1373 int ret;
1374 struct i2c_msg msg = {.addr=I2C_ADDR_TDA8290, .flags=0, .buf=data, .len = 2};
1375 data[0] = 0x21;
1376 data[1] = 0xc0;
1377 ret = i2c_transfer(&dev->i2c_adap, &msg, 1);
1378 if (ret != 1)
1379 printk(KERN_ERR "TDA8290 access failure\n");
1380 msg.addr = I2C_ADDR_TDA8275;
1381 data[0] = 0x30;
1382 data[1] = 0xd0;
1383 ret = i2c_transfer(&dev->i2c_adap, &msg, 1);
1384 if (ret != 1)
1385 printk(KERN_ERR "TDA8275 access failure\n");
1386 msg.addr = I2C_ADDR_TDA8290;
1387 data[0] = 0x21;
1388 data[1] = 0x80;
1389 i2c_transfer(&dev->i2c_adap, &msg, 1);
1390 data[0] = 0x00;
1391 data[1] = 0x02;
1392 i2c_transfer(&dev->i2c_adap, &msg, 1);
1393 }
1394
1366 /* free stuff */ 1395 /* free stuff */
1367 videobuf_mmap_free(&fh->cap); 1396 videobuf_mmap_free(&fh->cap);
1368 videobuf_mmap_free(&fh->vbi); 1397 videobuf_mmap_free(&fh->vbi);
@@ -1399,13 +1428,6 @@ static void saa7134_vbi_fmt(struct saa7134_dev *dev, struct v4l2_format *f)
1399 f->fmt.vbi.count[1] = f->fmt.vbi.count[0]; 1428 f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
1400 f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */ 1429 f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */
1401 1430
1402#if 0
1403 if (V4L2_STD_PAL == norm->id) {
1404 /* FIXME */
1405 f->fmt.vbi.start[0] += 3;
1406 f->fmt.vbi.start[1] += 3*2;
1407 }
1408#endif
1409} 1431}
1410 1432
1411static int saa7134_g_fmt(struct saa7134_dev *dev, struct saa7134_fh *fh, 1433static int saa7134_g_fmt(struct saa7134_dev *dev, struct saa7134_fh *fh,
@@ -2120,8 +2142,6 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
2120 2142
2121 memset(t,0,sizeof(*t)); 2143 memset(t,0,sizeof(*t));
2122 strcpy(t->name, "Radio"); 2144 strcpy(t->name, "Radio");
2123 t->rangelow = (int)(65*16);
2124 t->rangehigh = (int)(108*16);
2125 2145
2126 saa7134_i2c_call_clients(dev, VIDIOC_G_TUNER, t); 2146 saa7134_i2c_call_clients(dev, VIDIOC_G_TUNER, t);
2127 2147
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index d6b1c0d4d0f9..6836c07794fc 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134.h,v 1.41 2005/06/07 18:02:26 nsh Exp $ 2 * $Id: saa7134.h,v 1.48 2005/07/01 08:22:24 nsh Exp $
3 * 3 *
4 * v4l2 device driver for philips saa7134 based TV cards 4 * v4l2 device driver for philips saa7134 based TV cards
5 * 5 *
@@ -46,8 +46,6 @@
46#endif 46#endif
47#define UNSET (-1U) 47#define UNSET (-1U)
48 48
49/* 2.4 / 2.5 driver compatibility stuff */
50
51/* ----------------------------------------------------------- */ 49/* ----------------------------------------------------------- */
52/* enums */ 50/* enums */
53 51
@@ -159,7 +157,7 @@ struct saa7134_format {
159#define SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER 33 157#define SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER 33
160#define SAA7134_BOARD_NOVAC_PRIMETV7133 34 158#define SAA7134_BOARD_NOVAC_PRIMETV7133 34
161#define SAA7134_BOARD_AVERMEDIA_STUDIO_305 35 159#define SAA7134_BOARD_AVERMEDIA_STUDIO_305 35
162#define SAA7133_BOARD_UPMOST_PURPLE_TV 36 160#define SAA7134_BOARD_UPMOST_PURPLE_TV 36
163#define SAA7134_BOARD_ITEMS_MTV005 37 161#define SAA7134_BOARD_ITEMS_MTV005 37
164#define SAA7134_BOARD_CINERGY200 38 162#define SAA7134_BOARD_CINERGY200 38
165#define SAA7134_BOARD_FLYTVPLATINUM_MINI 39 163#define SAA7134_BOARD_FLYTVPLATINUM_MINI 39
@@ -176,13 +174,17 @@ struct saa7134_format {
176#define SAA7134_BOARD_PINNACLE_300I_DVBT_PAL 50 174#define SAA7134_BOARD_PINNACLE_300I_DVBT_PAL 50
177#define SAA7134_BOARD_PROVIDEO_PV952 51 175#define SAA7134_BOARD_PROVIDEO_PV952 51
178#define SAA7134_BOARD_AVERMEDIA_305 52 176#define SAA7134_BOARD_AVERMEDIA_305 52
179#define SAA7135_BOARD_ASUSTeK_TVFM7135 53 177#define SAA7134_BOARD_ASUSTeK_TVFM7135 53
180#define SAA7134_BOARD_FLYTVPLATINUM_FM 54 178#define SAA7134_BOARD_FLYTVPLATINUM_FM 54
181#define SAA7134_BOARD_FLYDVBTDUO 55 179#define SAA7134_BOARD_FLYDVBTDUO 55
182#define SAA7134_BOARD_AVERMEDIA_307 56 180#define SAA7134_BOARD_AVERMEDIA_307 56
183#define SAA7134_BOARD_AVERMEDIA_GO_007_FM 57 181#define SAA7134_BOARD_AVERMEDIA_GO_007_FM 57
184#define SAA7134_BOARD_ADS_INSTANT_TV 58 182#define SAA7134_BOARD_ADS_INSTANT_TV 58
185#define SAA7134_BOARD_KWORLD_VSTREAM_XPERT 59 183#define SAA7134_BOARD_KWORLD_VSTREAM_XPERT 59
184#define SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS 60
185#define SAA7134_BOARD_PHILIPS_TOUGH 61
186#define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62
187#define SAA7134_BOARD_KWORLD_XPERT 63
186 188
187#define SAA7134_MAXBOARDS 8 189#define SAA7134_MAXBOARDS 8
188#define SAA7134_INPUT_MAX 8 190#define SAA7134_INPUT_MAX 8
@@ -213,6 +215,10 @@ struct saa7134_board {
213 215
214 /* i2c chip info */ 216 /* i2c chip info */
215 unsigned int tuner_type; 217 unsigned int tuner_type;
218 unsigned int radio_type;
219 unsigned char tuner_addr;
220 unsigned char radio_addr;
221
216 unsigned int tda9887_conf; 222 unsigned int tda9887_conf;
217 223
218 /* peripheral I/O */ 224 /* peripheral I/O */
@@ -403,9 +409,12 @@ struct saa7134_dev {
403 /* config info */ 409 /* config info */
404 unsigned int board; 410 unsigned int board;
405 unsigned int tuner_type; 411 unsigned int tuner_type;
412 unsigned int radio_type;
413 unsigned char tuner_addr;
414 unsigned char radio_addr;
415
406 unsigned int tda9887_conf; 416 unsigned int tda9887_conf;
407 unsigned int gpio_value; 417 unsigned int gpio_value;
408 unsigned int irq2_mask;
409 418
410 /* i2c i/o */ 419 /* i2c i/o */
411 struct i2c_adapter i2c_adap; 420 struct i2c_adapter i2c_adap;
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index 07ba6d3ed08c..7cb1fb3e66f9 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -243,19 +243,6 @@ static int tda7432_write(struct i2c_client *client, int subaddr, int val)
243} 243}
244 244
245/* I don't think we ever actually _read_ the chip... */ 245/* I don't think we ever actually _read_ the chip... */
246#if 0
247static int tda7432_read(struct i2c_client *client)
248{
249 unsigned char buffer;
250 d2printk("tda7432: In tda7432_read\n");
251 if (1 != i2c_master_recv(client,&buffer,1)) {
252 printk(KERN_WARNING "tda7432: I/O error, trying (read)\n");
253 return -1;
254 }
255 dprintk("tda7432: Read 0x%02x\n", buffer);
256 return buffer;
257}
258#endif
259 246
260static int tda7432_set(struct i2c_client *client) 247static int tda7432_set(struct i2c_client *client)
261{ 248{
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c
index f59d4601cc63..a8b6a8df5109 100644
--- a/drivers/media/video/tda8290.c
+++ b/drivers/media/video/tda8290.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: tda8290.c,v 1.11 2005/06/18 06:09:06 nsh Exp $ 2 * $Id: tda8290.c,v 1.15 2005/07/08 20:21:33 mchehab Exp $
3 * 3 *
4 * i2c tv tuner chip device driver 4 * i2c tv tuner chip device driver
5 * controls the philips tda8290+75 tuner chip combo. 5 * controls the philips tda8290+75 tuner chip combo.
@@ -136,15 +136,12 @@ static int tda8290_tune(struct i2c_client *c)
136 return 0; 136 return 0;
137} 137}
138 138
139static void set_frequency(struct tuner *t, u16 ifc) 139static void set_frequency(struct tuner *t, u16 ifc, unsigned int freq)
140{ 140{
141 u32 freq;
142 u32 N; 141 u32 N;
143 142
144 if (t->mode == V4L2_TUNER_RADIO) 143 if (t->mode == V4L2_TUNER_RADIO)
145 freq = t->freq / 1000; 144 freq = freq / 1000;
146 else
147 freq = t->freq;
148 145
149 N = (((freq<<3)+ifc)&0x3fffc); 146 N = (((freq<<3)+ifc)&0x3fffc);
150 147
@@ -187,14 +184,14 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
187 struct tuner *t = i2c_get_clientdata(c); 184 struct tuner *t = i2c_get_clientdata(c);
188 185
189 set_audio(t); 186 set_audio(t);
190 set_frequency(t, 864); 187 set_frequency(t, 864, freq);
191 tda8290_tune(c); 188 tda8290_tune(c);
192} 189}
193 190
194static void set_radio_freq(struct i2c_client *c, unsigned int freq) 191static void set_radio_freq(struct i2c_client *c, unsigned int freq)
195{ 192{
196 struct tuner *t = i2c_get_clientdata(c); 193 struct tuner *t = i2c_get_clientdata(c);
197 set_frequency(t, 704); 194 set_frequency(t, 704, freq);
198 tda8290_tune(c); 195 tda8290_tune(c);
199} 196}
200 197
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index 97b113e070f3..566e1a5ca135 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -123,19 +123,6 @@ static int tda9875_write(struct i2c_client *client, int subaddr, unsigned char v
123 return 0; 123 return 0;
124} 124}
125 125
126#if 0
127static int tda9875_read(struct i2c_client *client)
128{
129 unsigned char buffer;
130 dprintk("In tda9875_read\n");
131 if (1 != i2c_master_recv(client,&buffer,1)) {
132 printk(KERN_WARNING "tda9875: I/O error, trying (read)\n");
133 return -1;
134 }
135 dprintk("Read 0x%02x\n", buffer);
136 return buffer;
137}
138#endif
139 126
140static int i2c_read_register(struct i2c_adapter *adap, int addr, int reg) 127static int i2c_read_register(struct i2c_adapter *adap, int addr, int reg)
141{ 128{
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index ee35562f4d1a..108c3ad7d622 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -569,15 +569,6 @@ static int tda9887_configure(struct tda9887 *t)
569 tda9887_set_config(t,buf); 569 tda9887_set_config(t,buf);
570 tda9887_set_insmod(t,buf); 570 tda9887_set_insmod(t,buf);
571 571
572#if 0
573 /* This as-is breaks some cards, must be fixed in a
574 * card-specific way, probably using TDA9887_SET_CONFIG to
575 * turn on/off port2 */
576 if (t->std & V4L2_STD_SECAM_L) {
577 /* secam fixup (FIXME: move this to tvnorms array?) */
578 buf[1] &= ~cOutputPort2Inactive;
579 }
580#endif
581 572
582 dprintk(PREFIX "writing: b=0x%02x c=0x%02x e=0x%02x\n", 573 dprintk(PREFIX "writing: b=0x%02x c=0x%02x e=0x%02x\n",
583 buf[1],buf[2],buf[3]); 574 buf[1],buf[2],buf[3]);
diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c
index a29f08f81f63..b53c748caf2a 100644
--- a/drivers/media/video/tea5767.c
+++ b/drivers/media/video/tea5767.c
@@ -2,7 +2,7 @@
2 * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview 2 * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview
3 * I2C address is allways 0xC0. 3 * I2C address is allways 0xC0.
4 * 4 *
5 * $Id: tea5767.c,v 1.11 2005/06/21 15:40:33 mchehab Exp $ 5 * $Id: tea5767.c,v 1.18 2005/07/07 03:02:55 mchehab Exp $
6 * 6 *
7 * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) 7 * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br)
8 * This code is placed under the terms of the GNU General Public License 8 * This code is placed under the terms of the GNU General Public License
@@ -11,23 +11,11 @@
11 * from their contributions on DScaler. 11 * from their contributions on DScaler.
12 */ 12 */
13 13
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <linux/sched.h>
18#include <linux/string.h>
19#include <linux/timer.h>
20#include <linux/delay.h>
21#include <linux/errno.h>
22#include <linux/slab.h>
23#include <linux/videodev.h>
24#include <linux/i2c.h> 14#include <linux/i2c.h>
25#include <linux/i2c-algo-bit.h> 15#include <linux/videodev.h>
26 16#include <linux/delay.h>
17#include <media/tuner.h>
27#include <media/tuner.h> 18#include <media/tuner.h>
28
29/* Declared at tuner-core.c */
30extern unsigned int tuner_debug;
31 19
32#define PREFIX "TEA5767 " 20#define PREFIX "TEA5767 "
33 21
@@ -38,8 +26,8 @@ extern unsigned int tuner_debug;
38 ******************************/ 26 ******************************/
39 27
40/* First register */ 28/* First register */
41#define TEA5767_MUTE 0x80 /* Mutes output */ 29#define TEA5767_MUTE 0x80 /* Mutes output */
42#define TEA5767_SEARCH 0x40 /* Activates station search */ 30#define TEA5767_SEARCH 0x40 /* Activates station search */
43/* Bits 0-5 for divider MSB */ 31/* Bits 0-5 for divider MSB */
44 32
45/* Second register */ 33/* Second register */
@@ -130,6 +118,14 @@ extern unsigned int tuner_debug;
130/* Reserved for future extensions */ 118/* Reserved for future extensions */
131#define TEA5767_RESERVED_MASK 0xff 119#define TEA5767_RESERVED_MASK 0xff
132 120
121enum tea5767_xtal_freq {
122 TEA5767_LOW_LO_32768 = 0,
123 TEA5767_HIGH_LO_32768 = 1,
124 TEA5767_LOW_LO_13MHz = 2,
125 TEA5767_HIGH_LO_13MHz = 3,
126};
127
128
133/*****************************************************************************/ 129/*****************************************************************************/
134 130
135static void set_tv_freq(struct i2c_client *c, unsigned int freq) 131static void set_tv_freq(struct i2c_client *c, unsigned int freq)
@@ -153,103 +149,112 @@ static void tea5767_status_dump(unsigned char *buffer)
153 else 149 else
154 printk(PREFIX "Tuner not at band limit\n"); 150 printk(PREFIX "Tuner not at band limit\n");
155 151
156 div=((buffer[0]&0x3f)<<8) | buffer[1]; 152 div = ((buffer[0] & 0x3f) << 8) | buffer[1];
157 153
158 switch (TEA5767_HIGH_LO_32768) { 154 switch (TEA5767_HIGH_LO_32768) {
159 case TEA5767_HIGH_LO_13MHz: 155 case TEA5767_HIGH_LO_13MHz:
160 frq = 1000*(div*50-700-225)/4; /* Freq in KHz */ 156 frq = 1000 * (div * 50 - 700 - 225) / 4; /* Freq in KHz */
161 break; 157 break;
162 case TEA5767_LOW_LO_13MHz: 158 case TEA5767_LOW_LO_13MHz:
163 frq = 1000*(div*50+700+225)/4; /* Freq in KHz */ 159 frq = 1000 * (div * 50 + 700 + 225) / 4; /* Freq in KHz */
164 break; 160 break;
165 case TEA5767_LOW_LO_32768: 161 case TEA5767_LOW_LO_32768:
166 frq = 1000*(div*32768/1000+700+225)/4; /* Freq in KHz */ 162 frq = 1000 * (div * 32768 / 1000 + 700 + 225) / 4; /* Freq in KHz */
167 break; 163 break;
168 case TEA5767_HIGH_LO_32768: 164 case TEA5767_HIGH_LO_32768:
169 default: 165 default:
170 frq = 1000*(div*32768/1000-700-225)/4; /* Freq in KHz */ 166 frq = 1000 * (div * 32768 / 1000 - 700 - 225) / 4; /* Freq in KHz */
171 break; 167 break;
172 } 168 }
173 buffer[0] = (div>>8) & 0x3f; 169 buffer[0] = (div >> 8) & 0x3f;
174 buffer[1] = div & 0xff; 170 buffer[1] = div & 0xff;
175 171
176 printk(PREFIX "Frequency %d.%03d KHz (divider = 0x%04x)\n", 172 printk(PREFIX "Frequency %d.%03d KHz (divider = 0x%04x)\n",
177 frq/1000,frq%1000,div); 173 frq / 1000, frq % 1000, div);
178 174
179 if (TEA5767_STEREO_MASK & buffer[2]) 175 if (TEA5767_STEREO_MASK & buffer[2])
180 printk(PREFIX "Stereo\n"); 176 printk(PREFIX "Stereo\n");
181 else 177 else
182 printk(PREFIX "Mono\n"); 178 printk(PREFIX "Mono\n");
183 179
184 printk(PREFIX "IF Counter = %d\n",buffer[2] & TEA5767_IF_CNTR_MASK); 180 printk(PREFIX "IF Counter = %d\n", buffer[2] & TEA5767_IF_CNTR_MASK);
185 181
186 printk(PREFIX "ADC Level = %d\n",(buffer[3] & TEA5767_ADC_LEVEL_MASK)>>4); 182 printk(PREFIX "ADC Level = %d\n",
183 (buffer[3] & TEA5767_ADC_LEVEL_MASK) >> 4);
187 184
188 printk(PREFIX "Chip ID = %d\n",(buffer[3] & TEA5767_CHIP_ID_MASK)); 185 printk(PREFIX "Chip ID = %d\n", (buffer[3] & TEA5767_CHIP_ID_MASK));
189 186
190 printk(PREFIX "Reserved = 0x%02x\n",(buffer[4] & TEA5767_RESERVED_MASK)); 187 printk(PREFIX "Reserved = 0x%02x\n",
188 (buffer[4] & TEA5767_RESERVED_MASK));
191} 189}
192 190
193/* Freq should be specifyed at 62.5 Hz */ 191/* Freq should be specifyed at 62.5 Hz */
194static void set_radio_freq(struct i2c_client *c, unsigned int frq) 192static void set_radio_freq(struct i2c_client *c, unsigned int frq)
195{ 193{
196 struct tuner *t = i2c_get_clientdata(c); 194 struct tuner *t = i2c_get_clientdata(c);
197 unsigned char buffer[5]; 195 unsigned char buffer[5];
198 unsigned div; 196 unsigned div;
199 int rc; 197 int rc;
200 198
201 if ( tuner_debug ) 199 tuner_dbg (PREFIX "radio freq counter %d\n", frq);
202 printk(PREFIX "radio freq counter %d\n",frq);
203 200
204 /* Rounds freq to next decimal value - for 62.5 KHz step */ 201 /* Rounds freq to next decimal value - for 62.5 KHz step */
205 /* frq = 20*(frq/16)+radio_frq[frq%16]; */ 202 /* frq = 20*(frq/16)+radio_frq[frq%16]; */
206 203
207 buffer[2] = TEA5767_PORT1_HIGH; 204 buffer[2] = TEA5767_PORT1_HIGH;
208 buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL | TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND; 205 buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL |
209 buffer[4]=0; 206 TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND;
207 buffer[4] = 0;
208
209 if (t->mode == T_STANDBY) {
210 tuner_dbg("TEA5767 set to standby mode\n");
211 buffer[3] |= TEA5767_STDBY;
212 }
210 213
211 if (t->audmode == V4L2_TUNER_MODE_MONO) { 214 if (t->audmode == V4L2_TUNER_MODE_MONO) {
212 tuner_dbg("TEA5767 set to mono\n"); 215 tuner_dbg("TEA5767 set to mono\n");
213 buffer[2] |= TEA5767_MONO; 216 buffer[2] |= TEA5767_MONO;
214 } else 217 } else {
215 tuner_dbg("TEA5767 set to stereo\n"); 218 tuner_dbg("TEA5767 set to stereo\n");
219 }
216 220
217 switch (t->type) { 221 /* Should be replaced */
222 switch (TEA5767_HIGH_LO_32768) {
218 case TEA5767_HIGH_LO_13MHz: 223 case TEA5767_HIGH_LO_13MHz:
219 tuner_dbg("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n"); 224 tuner_dbg ("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n");
220 buffer[2] |= TEA5767_HIGH_LO_INJECT; 225 buffer[2] |= TEA5767_HIGH_LO_INJECT;
221 buffer[4] |= TEA5767_PLLREF_ENABLE; 226 buffer[4] |= TEA5767_PLLREF_ENABLE;
222 div = (frq*4/16+700+225+25)/50; 227 div = (frq * 4 / 16 + 700 + 225 + 25) / 50;
223 break; 228 break;
224 case TEA5767_LOW_LO_13MHz: 229 case TEA5767_LOW_LO_13MHz:
225 tuner_dbg("TEA5767 radio LOW LO inject xtal @ 13 MHz\n"); 230 tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 13 MHz\n");
226 231
227 buffer[4] |= TEA5767_PLLREF_ENABLE; 232 buffer[4] |= TEA5767_PLLREF_ENABLE;
228 div = (frq*4/16-700-225+25)/50; 233 div = (frq * 4 / 16 - 700 - 225 + 25) / 50;
229 break; 234 break;
230 case TEA5767_LOW_LO_32768: 235 case TEA5767_LOW_LO_32768:
231 tuner_dbg("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n"); 236 tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n");
232 buffer[3] |= TEA5767_XTAL_32768; 237 buffer[3] |= TEA5767_XTAL_32768;
233 /* const 700=4000*175 Khz - to adjust freq to right value */ 238 /* const 700=4000*175 Khz - to adjust freq to right value */
234 div = (1000*(frq*4/16-700-225)+16384)>>15; 239 div = (1000 * (frq * 4 / 16 - 700 - 225) + 16384) >> 15;
235 break; 240 break;
236 case TEA5767_HIGH_LO_32768: 241 case TEA5767_HIGH_LO_32768:
237 default: 242 default:
238 tuner_dbg("TEA5767 radio HIGH LO inject xtal @ 32,768 MHz\n"); 243 tuner_dbg ("TEA5767 radio HIGH LO inject xtal @ 32,768 MHz\n");
239 244
240 buffer[2] |= TEA5767_HIGH_LO_INJECT; 245 buffer[2] |= TEA5767_HIGH_LO_INJECT;
241 buffer[3] |= TEA5767_XTAL_32768; 246 buffer[3] |= TEA5767_XTAL_32768;
242 div = (1000*(frq*4/16+700+225)+16384)>>15; 247 div = (1000 * (frq * 4 / 16 + 700 + 225) + 16384) >> 15;
243 break; 248 break;
244 } 249 }
245 buffer[0] = (div>>8) & 0x3f; 250 buffer[0] = (div >> 8) & 0x3f;
246 buffer[1] = div & 0xff; 251 buffer[1] = div & 0xff;
247 252
248 if ( tuner_debug ) 253 if (tuner_debug)
249 tea5767_status_dump(buffer); 254 tea5767_status_dump(buffer);
250 255
251 if (5 != (rc = i2c_master_send(c,buffer,5))) 256 if (5 != (rc = i2c_master_send(c, buffer, 5)))
252 tuner_warn("i2c i/o error: rc == %d (should be 5)\n",rc); 257 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
253} 258}
254 259
255static int tea5767_signal(struct i2c_client *c) 260static int tea5767_signal(struct i2c_client *c)
@@ -258,11 +263,11 @@ static int tea5767_signal(struct i2c_client *c)
258 int rc; 263 int rc;
259 struct tuner *t = i2c_get_clientdata(c); 264 struct tuner *t = i2c_get_clientdata(c);
260 265
261 memset(buffer,0,sizeof(buffer)); 266 memset(buffer, 0, sizeof(buffer));
262 if (5 != (rc = i2c_master_recv(c,buffer,5))) 267 if (5 != (rc = i2c_master_recv(c, buffer, 5)))
263 tuner_warn ( "i2c i/o error: rc == %d (should be 5)\n",rc); 268 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
264 269
265 return ((buffer[3] & TEA5767_ADC_LEVEL_MASK) <<(13-4)); 270 return ((buffer[3] & TEA5767_ADC_LEVEL_MASK) << (13 - 4));
266} 271}
267 272
268static int tea5767_stereo(struct i2c_client *c) 273static int tea5767_stereo(struct i2c_client *c)
@@ -271,47 +276,46 @@ static int tea5767_stereo(struct i2c_client *c)
271 int rc; 276 int rc;
272 struct tuner *t = i2c_get_clientdata(c); 277 struct tuner *t = i2c_get_clientdata(c);
273 278
274 memset(buffer,0,sizeof(buffer)); 279 memset(buffer, 0, sizeof(buffer));
275 if (5 != (rc = i2c_master_recv(c,buffer,5))) 280 if (5 != (rc = i2c_master_recv(c, buffer, 5)))
276 tuner_warn ( "i2c i/o error: rc == %d (should be 5)\n",rc); 281 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
277 282
278 rc = buffer[2] & TEA5767_STEREO_MASK; 283 rc = buffer[2] & TEA5767_STEREO_MASK;
279 284
280 if ( tuner_debug ) 285 tuner_dbg("TEA5767 radio ST GET = %02x\n", rc);
281 tuner_dbg("TEA5767 radio ST GET = %02x\n", rc);
282 286
283 return ( (buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO: 0); 287 return ((buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO : 0);
284} 288}
285 289
286int tea_detection(struct i2c_client *c) 290int tea5767_autodetection(struct i2c_client *c)
287{ 291{
288 unsigned char buffer[5]= { 0xff, 0xff, 0xff, 0xff, 0xff }; 292 unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff };
289 int rc; 293 int rc;
290 struct tuner *t = i2c_get_clientdata(c); 294 struct tuner *t = i2c_get_clientdata(c);
291 295
292 if (5 != (rc = i2c_master_recv(c,buffer,5))) { 296 if (5 != (rc = i2c_master_recv(c, buffer, 5))) {
293 tuner_warn ( "it is not a TEA5767. Received %i chars.\n",rc ); 297 tuner_warn("it is not a TEA5767. Received %i chars.\n", rc);
294 return EINVAL; 298 return EINVAL;
295 } 299 }
296 300
297 /* If all bytes are the same then it's a TV tuner and not a tea5767 chip. */ 301 /* If all bytes are the same then it's a TV tuner and not a tea5767 chip. */
298 if (buffer[0] == buffer[1] && buffer[0] == buffer[2] && 302 if (buffer[0] == buffer[1] && buffer[0] == buffer[2] &&
299 buffer[0] == buffer[3] && buffer[0] == buffer[4]) { 303 buffer[0] == buffer[3] && buffer[0] == buffer[4]) {
300 tuner_warn ( "All bytes are equal. It is not a TEA5767\n" ); 304 tuner_warn("All bytes are equal. It is not a TEA5767\n");
301 return EINVAL; 305 return EINVAL;
302 } 306 }
303 307
304 /* Status bytes: 308 /* Status bytes:
305 * Byte 4: bit 3:1 : CI (Chip Identification) == 0 309 * Byte 4: bit 3:1 : CI (Chip Identification) == 0
306 * bit 0 : internally set to 0 310 * bit 0 : internally set to 0
307 * Byte 5: bit 7:0 : == 0 311 * Byte 5: bit 7:0 : == 0
308 */ 312 */
309 313
310 if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) { 314 if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) {
311 tuner_warn ( "Chip ID is not zero. It is not a TEA5767\n" ); 315 tuner_warn("Chip ID is not zero. It is not a TEA5767\n");
312 return EINVAL; 316 return EINVAL;
313 } 317 }
314 tuner_warn ( "TEA5767 detected.\n" ); 318 tuner_warn("TEA5767 detected.\n");
315 return 0; 319 return 0;
316} 320}
317 321
@@ -319,16 +323,16 @@ int tea5767_tuner_init(struct i2c_client *c)
319{ 323{
320 struct tuner *t = i2c_get_clientdata(c); 324 struct tuner *t = i2c_get_clientdata(c);
321 325
322 if (tea_detection(c)==EINVAL) return EINVAL; 326 if (tea5767_autodetection(c) == EINVAL)
327 return EINVAL;
323 328
324 tuner_info("type set to %d (%s)\n", 329 tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio");
325 t->type, TEA5767_TUNER_NAME); 330 strlcpy(c->name, "tea5767", sizeof(c->name));
326 strlcpy(c->name, TEA5767_TUNER_NAME, sizeof(c->name));
327 331
328 t->tv_freq = set_tv_freq; 332 t->tv_freq = set_tv_freq;
329 t->radio_freq = set_radio_freq; 333 t->radio_freq = set_radio_freq;
330 t->has_signal = tea5767_signal; 334 t->has_signal = tea5767_signal;
331 t->is_stereo = tea5767_stereo; 335 t->is_stereo = tea5767_stereo;
332 336
333 return (0); 337 return (0);
334} 338}
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index 51748c6578d1..7d825e510ffd 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -152,7 +152,7 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
152 152
153 switch (cmd) 153 switch (cmd)
154 { 154 {
155 case TUNER_SET_TVFREQ: 155 case VIDIOCSFREQ:
156 set_tv_freq(client, *iarg); 156 set_tv_freq(client, *iarg);
157 break; 157 break;
158 158
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 6f6bf4a633fc..de190630babb 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: tuner-core.c,v 1.29 2005/06/21 15:40:33 mchehab Exp $ 2 * $Id: tuner-core.c,v 1.55 2005/07/08 13:20:33 mchehab Exp $
3 * 3 *
4 * i2c tv tuner chip device driver 4 * i2c tv tuner chip device driver
5 * core core, i.e. kernel interfaces, registering and so on 5 * core core, i.e. kernel interfaces, registering and so on
@@ -23,42 +23,36 @@
23#include <media/tuner.h> 23#include <media/tuner.h>
24#include <media/audiochip.h> 24#include <media/audiochip.h>
25 25
26/*
27 * comment line bellow to return to old behavor, where only one I2C device is supported
28 */
29
30#define UNSET (-1U) 26#define UNSET (-1U)
31 27
32/* standard i2c insmod options */ 28/* standard i2c insmod options */
33static unsigned short normal_i2c[] = { 29static unsigned short normal_i2c[] = {
34 0x4b, /* tda8290 */ 30 0x4b, /* tda8290 */
35 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 31 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
36 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 32 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
37 I2C_CLIENT_END 33 I2C_CLIENT_END
38}; 34};
35
39I2C_CLIENT_INSMOD; 36I2C_CLIENT_INSMOD;
40 37
41/* insmod options used at init time => read/only */ 38/* insmod options used at init time => read/only */
42static unsigned int addr = 0; 39static unsigned int addr = 0;
43module_param(addr, int, 0444); 40module_param(addr, int, 0444);
44 41
45/* insmod options used at runtime => read/write */ 42/* insmod options used at runtime => read/write */
46unsigned int tuner_debug = 0; 43unsigned int tuner_debug = 0;
47module_param(tuner_debug, int, 0644); 44module_param(tuner_debug, int, 0644);
48 45
49static unsigned int tv_range[2] = { 44, 958 }; 46static unsigned int tv_range[2] = { 44, 958 };
50static unsigned int radio_range[2] = { 65, 108 }; 47static unsigned int radio_range[2] = { 65, 108 };
51 48
52module_param_array(tv_range, int, NULL, 0644); 49module_param_array(tv_range, int, NULL, 0644);
53module_param_array(radio_range, int, NULL, 0644); 50module_param_array(radio_range, int, NULL, 0644);
54 51
55MODULE_DESCRIPTION("device driver for various TV and TV+FM radio tuners"); 52MODULE_DESCRIPTION("device driver for various TV and TV+FM radio tuners");
56MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer"); 53MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer");
57MODULE_LICENSE("GPL"); 54MODULE_LICENSE("GPL");
58 55
59static int this_adap;
60static unsigned short first_tuner, tv_tuner, radio_tuner;
61
62static struct i2c_driver driver; 56static struct i2c_driver driver;
63static struct i2c_client client_template; 57static struct i2c_client client_template;
64 58
@@ -70,18 +64,19 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
70 struct tuner *t = i2c_get_clientdata(c); 64 struct tuner *t = i2c_get_clientdata(c);
71 65
72 if (t->type == UNSET) { 66 if (t->type == UNSET) {
73 tuner_info("tuner type not set\n"); 67 tuner_warn ("tuner type not set\n");
74 return; 68 return;
75 } 69 }
76 if (NULL == t->tv_freq) { 70 if (NULL == t->tv_freq) {
77 tuner_info("Huh? tv_set is NULL?\n"); 71 tuner_warn ("Tuner has no way to set tv freq\n");
78 return; 72 return;
79 } 73 }
80 if (freq < tv_range[0]*16 || freq > tv_range[1]*16) { 74 if (freq < tv_range[0] * 16 || freq > tv_range[1] * 16) {
81 tuner_info("TV freq (%d.%02d) out of range (%d-%d)\n", 75 tuner_dbg ("TV freq (%d.%02d) out of range (%d-%d)\n",
82 freq/16,freq%16*100/16,tv_range[0],tv_range[1]); 76 freq / 16, freq % 16 * 100 / 16, tv_range[0],
77 tv_range[1]);
83 } 78 }
84 t->tv_freq(c,freq); 79 t->tv_freq(c, freq);
85} 80}
86 81
87static void set_radio_freq(struct i2c_client *c, unsigned int freq) 82static void set_radio_freq(struct i2c_client *c, unsigned int freq)
@@ -89,24 +84,20 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
89 struct tuner *t = i2c_get_clientdata(c); 84 struct tuner *t = i2c_get_clientdata(c);
90 85
91 if (t->type == UNSET) { 86 if (t->type == UNSET) {
92 tuner_info("tuner type not set\n"); 87 tuner_warn ("tuner type not set\n");
93 return; 88 return;
94 } 89 }
95 if (NULL == t->radio_freq) { 90 if (NULL == t->radio_freq) {
96 tuner_info("no radio tuning for this one, sorry.\n"); 91 tuner_warn ("tuner has no way to set radio frequency\n");
97 return; 92 return;
98 } 93 }
99 if (freq >= radio_range[0]*16000 && freq <= radio_range[1]*16000) { 94 if (freq <= radio_range[0] * 16000 || freq >= radio_range[1] * 16000) {
100 if (tuner_debug) 95 tuner_dbg ("radio freq (%d.%02d) out of range (%d-%d)\n",
101 tuner_info("radio freq step 62.5Hz (%d.%06d)\n", 96 freq / 16000, freq % 16000 * 100 / 16000,
102 freq/16000,freq%16000*1000/16); 97 radio_range[0], radio_range[1]);
103 t->radio_freq(c,freq);
104 } else {
105 tuner_info("radio freq (%d.%02d) out of range (%d-%d)\n",
106 freq/16,freq%16*100/16,
107 radio_range[0],radio_range[1]);
108 } 98 }
109 99
100 t->radio_freq(c, freq);
110 return; 101 return;
111} 102}
112 103
@@ -117,42 +108,45 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
117 switch (t->mode) { 108 switch (t->mode) {
118 case V4L2_TUNER_RADIO: 109 case V4L2_TUNER_RADIO:
119 tuner_dbg("radio freq set to %lu.%02lu\n", 110 tuner_dbg("radio freq set to %lu.%02lu\n",
120 freq/16,freq%16*100/16); 111 freq / 16000, freq % 16000 * 100 / 16000);
121 set_radio_freq(c,freq); 112 set_radio_freq(c, freq);
122 break; 113 break;
123 case V4L2_TUNER_ANALOG_TV: 114 case V4L2_TUNER_ANALOG_TV:
124 case V4L2_TUNER_DIGITAL_TV: 115 case V4L2_TUNER_DIGITAL_TV:
125 tuner_dbg("tv freq set to %lu.%02lu\n", 116 tuner_dbg("tv freq set to %lu.%02lu\n",
126 freq/16,freq%16*100/16); 117 freq / 16, freq % 16 * 100 / 16);
127 set_tv_freq(c, freq); 118 set_tv_freq(c, freq);
128 break; 119 break;
129 } 120 }
130 t->freq = freq; 121 t->freq = freq;
131} 122}
132 123
133static void set_type(struct i2c_client *c, unsigned int type) 124static void set_type(struct i2c_client *c, unsigned int type,
125 unsigned int new_mode_mask)
134{ 126{
135 struct tuner *t = i2c_get_clientdata(c); 127 struct tuner *t = i2c_get_clientdata(c);
136 unsigned char buffer[4]; 128 unsigned char buffer[4];
137 129
138 /* sanity check */ 130 if (type == UNSET || type == TUNER_ABSENT) {
139 if (type == UNSET || type == TUNER_ABSENT) 131 tuner_dbg ("tuner 0x%02x: Tuner type absent\n",c->addr);
140 return; 132 return;
141 if (type >= tuner_count) 133 }
134
135 if (type >= tuner_count) {
136 tuner_warn ("tuner 0x%02x: Tuner count greater than %d\n",c->addr,tuner_count);
142 return; 137 return;
138 }
143 139
140 /* This code detects calls by card attach_inform */
144 if (NULL == t->i2c.dev.driver) { 141 if (NULL == t->i2c.dev.driver) {
145 /* not registered yet */ 142 tuner_dbg ("tuner 0x%02x: called during i2c_client register by adapter's attach_inform\n", c->addr);
146 t->type = type; 143
144 t->type=type;
147 return; 145 return;
148 } 146 }
149 if ((t->initialized) && (t->type == type))
150 /* run only once except type change Hac 04/05*/
151 return;
152
153 t->initialized = 1;
154 147
155 t->type = type; 148 t->type = type;
149
156 switch (t->type) { 150 switch (t->type) {
157 case TUNER_MT2032: 151 case TUNER_MT2032:
158 microtune_init(c); 152 microtune_init(c);
@@ -161,136 +155,194 @@ static void set_type(struct i2c_client *c, unsigned int type)
161 tda8290_init(c); 155 tda8290_init(c);
162 break; 156 break;
163 case TUNER_TEA5767: 157 case TUNER_TEA5767:
164 if (tea5767_tuner_init(c)==EINVAL) t->type=TUNER_ABSENT; 158 if (tea5767_tuner_init(c) == EINVAL) {
159 t->type = TUNER_ABSENT;
160 t->mode_mask = T_UNINITIALIZED;
161 return;
162 }
163 t->mode_mask = T_RADIO;
165 break; 164 break;
166 case TUNER_PHILIPS_FMD1216ME_MK3: 165 case TUNER_PHILIPS_FMD1216ME_MK3:
167 buffer[0] = 0x0b; 166 buffer[0] = 0x0b;
168 buffer[1] = 0xdc; 167 buffer[1] = 0xdc;
169 buffer[2] = 0x9c; 168 buffer[2] = 0x9c;
170 buffer[3] = 0x60; 169 buffer[3] = 0x60;
171 i2c_master_send(c,buffer,4); 170 i2c_master_send(c, buffer, 4);
172 mdelay(1); 171 mdelay(1);
173 buffer[2] = 0x86; 172 buffer[2] = 0x86;
174 buffer[3] = 0x54; 173 buffer[3] = 0x54;
175 i2c_master_send(c,buffer,4); 174 i2c_master_send(c, buffer, 4);
176 default_tuner_init(c); 175 default_tuner_init(c);
177 break; 176 break;
178 default: 177 default:
179 /* TEA5767 autodetection code */
180 if (tea5767_tuner_init(c)!=EINVAL) {
181 t->type = TUNER_TEA5767;
182 if (first_tuner == 0x60)
183 first_tuner++;
184 break;
185 }
186
187 default_tuner_init(c); 178 default_tuner_init(c);
188 break; 179 break;
189 } 180 }
190 tuner_dbg ("I2C addr 0x%02x with type %d\n",c->addr<<1,type); 181
182 if (t->mode_mask == T_UNINITIALIZED)
183 t->mode_mask = new_mode_mask;
184
185 set_freq(c, t->freq);
186 tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n",
187 c->adapter->name, c->driver->name, c->addr << 1, type,
188 t->mode_mask);
191} 189}
192 190
193#define CHECK_ADDR(tp,cmd,tun) if (client->addr!=tp) { \ 191/*
194 return 0; } else if (tuner_debug) \ 192 * This function apply tuner config to tuner specified
195 tuner_info ("Cmd %s accepted to "tun"\n",cmd); 193 * by tun_setup structure. I addr is unset, then admin status
196#define CHECK_MODE(cmd) if (t->mode == V4L2_TUNER_RADIO) { \ 194 * and tun addr status is more precise then current status,
197 CHECK_ADDR(radio_tuner,cmd,"radio") } else \ 195 * it's applied. Otherwise status and type are applied only to
198 { CHECK_ADDR(tv_tuner,cmd,"TV"); } 196 * tuner with exactly the same addr.
197*/
198
199static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup)
200{
201 struct tuner *t = i2c_get_clientdata(c);
202
203 if (tun_setup->addr == ADDR_UNSET) {
204 if (t->mode_mask & tun_setup->mode_mask)
205 set_type(c, tun_setup->type, tun_setup->mode_mask);
206 } else if (tun_setup->addr == c->addr) {
207 set_type(c, tun_setup->type, tun_setup->mode_mask);
208 }
209}
199 210
200static void set_addr(struct i2c_client *c, struct tuner_addr *tun_addr) 211static inline int check_mode(struct tuner *t, char *cmd)
201{ 212{
202 /* ADDR_UNSET defaults to first available tuner */ 213 if (1 << t->mode & t->mode_mask) {
203 if ( tun_addr->addr == ADDR_UNSET ) { 214 switch (t->mode) {
204 if (first_tuner != c->addr)
205 return;
206 switch (tun_addr->v4l2_tuner) {
207 case V4L2_TUNER_RADIO: 215 case V4L2_TUNER_RADIO:
208 radio_tuner=c->addr; 216 tuner_dbg("Cmd %s accepted for radio\n", cmd);
209 break; 217 break;
210 default: 218 case V4L2_TUNER_ANALOG_TV:
211 tv_tuner=c->addr; 219 tuner_dbg("Cmd %s accepted for analog TV\n", cmd);
220 break;
221 case V4L2_TUNER_DIGITAL_TV:
222 tuner_dbg("Cmd %s accepted for digital TV\n", cmd);
212 break; 223 break;
213 } 224 }
214 } else { 225 return 0;
215 /* Sets tuner to its configured value */
216 switch (tun_addr->v4l2_tuner) {
217 case V4L2_TUNER_RADIO:
218 radio_tuner=tun_addr->addr;
219 if ( tun_addr->addr == c->addr ) set_type(c,tun_addr->type);
220 return;
221 default:
222 tv_tuner=tun_addr->addr;
223 if ( tun_addr->addr == c->addr ) set_type(c,tun_addr->type);
224 return;
225 }
226 } 226 }
227 set_type(c,tun_addr->type); 227 return EINVAL;
228} 228}
229 229
230static char pal[] = "-"; 230static char pal[] = "-";
231module_param_string(pal, pal, sizeof(pal), 0644); 231module_param_string(pal, pal, sizeof(pal), 0644);
232static char secam[] = "-";
233module_param_string(secam, secam, sizeof(secam), 0644);
232 234
235/* get more precise norm info from insmod option */
233static int tuner_fixup_std(struct tuner *t) 236static int tuner_fixup_std(struct tuner *t)
234{ 237{
235 if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) { 238 if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) {
236 /* get more precise norm info from insmod option */
237 switch (pal[0]) { 239 switch (pal[0]) {
238 case 'b': 240 case 'b':
239 case 'B': 241 case 'B':
240 case 'g': 242 case 'g':
241 case 'G': 243 case 'G':
242 tuner_dbg("insmod fixup: PAL => PAL-BG\n"); 244 tuner_dbg ("insmod fixup: PAL => PAL-BG\n");
243 t->std = V4L2_STD_PAL_BG; 245 t->std = V4L2_STD_PAL_BG;
244 break; 246 break;
245 case 'i': 247 case 'i':
246 case 'I': 248 case 'I':
247 tuner_dbg("insmod fixup: PAL => PAL-I\n"); 249 tuner_dbg ("insmod fixup: PAL => PAL-I\n");
248 t->std = V4L2_STD_PAL_I; 250 t->std = V4L2_STD_PAL_I;
249 break; 251 break;
250 case 'd': 252 case 'd':
251 case 'D': 253 case 'D':
252 case 'k': 254 case 'k':
253 case 'K': 255 case 'K':
254 tuner_dbg("insmod fixup: PAL => PAL-DK\n"); 256 tuner_dbg ("insmod fixup: PAL => PAL-DK\n");
255 t->std = V4L2_STD_PAL_DK; 257 t->std = V4L2_STD_PAL_DK;
256 break; 258 break;
259 case 'M':
260 case 'm':
261 tuner_dbg ("insmod fixup: PAL => PAL-M\n");
262 t->std = V4L2_STD_PAL_M;
263 break;
264 case 'N':
265 case 'n':
266 tuner_dbg ("insmod fixup: PAL => PAL-N\n");
267 t->std = V4L2_STD_PAL_N;
268 break;
257 } 269 }
258 } 270 }
271 if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) {
272 switch (secam[0]) {
273 case 'd':
274 case 'D':
275 case 'k':
276 case 'K':
277 tuner_dbg ("insmod fixup: SECAM => SECAM-DK\n");
278 t->std = V4L2_STD_SECAM_DK;
279 break;
280 case 'l':
281 case 'L':
282 tuner_dbg ("insmod fixup: SECAM => SECAM-L\n");
283 t->std = V4L2_STD_SECAM_L;
284 break;
285 }
286 }
287
259 return 0; 288 return 0;
260} 289}
261 290
262/* ---------------------------------------------------------------------- */ 291/* ---------------------------------------------------------------------- */
263 292
293/* static var Used only in tuner_attach and tuner_probe */
294static unsigned default_mode_mask;
295
296/* During client attach, set_type is called by adapter's attach_inform callback.
297 set_type must then be completed by tuner_attach.
298 */
264static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) 299static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
265{ 300{
266 struct tuner *t; 301 struct tuner *t;
267 302
268 /* by default, first I2C card is both tv and radio tuner */ 303 client_template.adapter = adap;
269 if (this_adap == 0) { 304 client_template.addr = addr;
270 first_tuner = addr;
271 tv_tuner = addr;
272 radio_tuner = addr;
273 }
274 this_adap++;
275
276 client_template.adapter = adap;
277 client_template.addr = addr;
278 305
279 t = kmalloc(sizeof(struct tuner),GFP_KERNEL); 306 t = kmalloc(sizeof(struct tuner), GFP_KERNEL);
280 if (NULL == t) 307 if (NULL == t)
281 return -ENOMEM; 308 return -ENOMEM;
282 memset(t,0,sizeof(struct tuner)); 309 memset(t, 0, sizeof(struct tuner));
283 memcpy(&t->i2c,&client_template,sizeof(struct i2c_client)); 310 memcpy(&t->i2c, &client_template, sizeof(struct i2c_client));
284 i2c_set_clientdata(&t->i2c, t); 311 i2c_set_clientdata(&t->i2c, t);
285 t->type = UNSET; 312 t->type = UNSET;
286 t->radio_if2 = 10700*1000; /* 10.7MHz - FM radio */ 313 t->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
287 t->audmode = V4L2_TUNER_MODE_STEREO; 314 t->audmode = V4L2_TUNER_MODE_STEREO;
315 t->mode_mask = T_UNINITIALIZED;
316
317
318 tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
319
320 /* TEA5767 autodetection code - only for addr = 0xc0 */
321 if (addr == 0x60) {
322 if (tea5767_autodetection(&t->i2c) != EINVAL) {
323 t->type = TUNER_TEA5767;
324 t->mode_mask = T_RADIO;
325 t->mode = T_STANDBY;
326 t->freq = 87.5 * 16; /* Sets freq to FM range */
327 default_mode_mask &= ~T_RADIO;
328
329 i2c_attach_client (&t->i2c);
330 set_type(&t->i2c,t->type, t->mode_mask);
331 return 0;
332 }
333 }
288 334
289 i2c_attach_client(&t->i2c); 335 /* Initializes only the first adapter found */
290 tuner_info("chip found @ 0x%x (%s)\n", 336 if (default_mode_mask != T_UNINITIALIZED) {
291 addr << 1, adap->name); 337 tuner_dbg ("Setting mode_mask to 0x%02x\n", default_mode_mask);
338 t->mode_mask = default_mode_mask;
339 t->freq = 400 * 16; /* Sets freq to VHF High */
340 default_mode_mask = T_UNINITIALIZED;
341 }
292 342
293 set_type(&t->i2c, t->type); 343 /* Should be just before return */
344 i2c_attach_client (&t->i2c);
345 set_type (&t->i2c,t->type, t->mode_mask);
294 return 0; 346 return 0;
295} 347}
296 348
@@ -300,11 +352,8 @@ static int tuner_probe(struct i2c_adapter *adap)
300 normal_i2c[0] = addr; 352 normal_i2c[0] = addr;
301 normal_i2c[1] = I2C_CLIENT_END; 353 normal_i2c[1] = I2C_CLIENT_END;
302 } 354 }
303 this_adap = 0;
304 355
305 first_tuner = 0; 356 default_mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
306 tv_tuner = 0;
307 radio_tuner = 0;
308 357
309 if (adap->class & I2C_CLASS_TV_ANALOG) 358 if (adap->class & I2C_CLASS_TV_ANALOG)
310 return i2c_probe(adap, &addr_data, tuner_attach); 359 return i2c_probe(adap, &addr_data, tuner_attach);
@@ -316,9 +365,10 @@ static int tuner_detach(struct i2c_client *client)
316 struct tuner *t = i2c_get_clientdata(client); 365 struct tuner *t = i2c_get_clientdata(client);
317 int err; 366 int err;
318 367
319 err=i2c_detach_client(&t->i2c); 368 err = i2c_detach_client(&t->i2c);
320 if (err) { 369 if (err) {
321 tuner_warn ("Client deregistration failed, client not detached.\n"); 370 tuner_warn
371 ("Client deregistration failed, client not detached.\n");
322 return err; 372 return err;
323 } 373 }
324 374
@@ -326,37 +376,65 @@ static int tuner_detach(struct i2c_client *client)
326 return 0; 376 return 0;
327} 377}
328 378
329#define SWITCH_V4L2 if (!t->using_v4l2 && tuner_debug) \ 379/*
330 tuner_info("switching to v4l2\n"); \ 380 * Switch tuner to other mode. If tuner support both tv and radio,
331 t->using_v4l2 = 1; 381 * set another frequency to some value (This is needed for some pal
332#define CHECK_V4L2 if (t->using_v4l2) { if (tuner_debug) \ 382 * tuners to avoid locking). Otherwise, just put second tuner in
333 tuner_info("ignore v4l1 call\n"); \ 383 * standby mode.
334 return 0; } 384 */
385
386static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd)
387{
388 if (mode != t->mode) {
389
390 t->mode = mode;
391 if (check_mode(t, cmd) == EINVAL) {
392 t->mode = T_STANDBY;
393 if (V4L2_TUNER_RADIO == mode) {
394 set_tv_freq(client, 400 * 16);
395 } else {
396 set_radio_freq(client, 87.5 * 16000);
397 }
398 return EINVAL;
399 }
400 }
401 return 0;
402}
403
404#define switch_v4l2() if (!t->using_v4l2) \
405 tuner_dbg("switching to v4l2\n"); \
406 t->using_v4l2 = 1;
407
408static inline int check_v4l2(struct tuner *t)
409{
410 if (t->using_v4l2) {
411 tuner_dbg ("ignore v4l1 call\n");
412 return EINVAL;
413 }
414 return 0;
415}
335 416
336static int 417static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
337tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
338{ 418{
339 struct tuner *t = i2c_get_clientdata(client); 419 struct tuner *t = i2c_get_clientdata(client);
340 unsigned int *iarg = (int*)arg; 420 unsigned int *iarg = (int *)arg;
341 421
342 switch (cmd) { 422 switch (cmd) {
343 /* --- configuration --- */ 423 /* --- configuration --- */
344 case TUNER_SET_TYPE:
345 set_type(client,*iarg);
346 break;
347 case TUNER_SET_TYPE_ADDR: 424 case TUNER_SET_TYPE_ADDR:
348 set_addr(client,(struct tuner_addr *)arg); 425 tuner_dbg ("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x\n",
426 ((struct tuner_setup *)arg)->type,
427 ((struct tuner_setup *)arg)->addr,
428 ((struct tuner_setup *)arg)->mode_mask);
429
430 set_addr(client, (struct tuner_setup *)arg);
349 break; 431 break;
350 case AUDC_SET_RADIO: 432 case AUDC_SET_RADIO:
351 t->mode = V4L2_TUNER_RADIO; 433 set_mode(client,t,V4L2_TUNER_RADIO, "AUDC_SET_RADIO");
352 CHECK_ADDR(tv_tuner,"AUDC_SET_RADIO","TV");
353
354 if (V4L2_TUNER_RADIO != t->mode) {
355 set_tv_freq(client,400 * 16);
356 }
357 break; 434 break;
358 case AUDC_CONFIG_PINNACLE: 435 case AUDC_CONFIG_PINNACLE:
359 CHECK_ADDR(tv_tuner,"AUDC_CONFIG_PINNACLE","TV"); 436 if (check_mode(t, "AUDC_CONFIG_PINNACLE") == EINVAL)
437 return 0;
360 switch (*iarg) { 438 switch (*iarg) {
361 case 2: 439 case 2:
362 tuner_dbg("pinnacle pal\n"); 440 tuner_dbg("pinnacle pal\n");
@@ -368,219 +446,238 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
368 break; 446 break;
369 } 447 }
370 break; 448 break;
449 case TDA9887_SET_CONFIG:
450 break;
371 /* --- v4l ioctls --- */ 451 /* --- v4l ioctls --- */
372 /* take care: bttv does userspace copying, we'll get a 452 /* take care: bttv does userspace copying, we'll get a
373 kernel pointer here... */ 453 kernel pointer here... */
374 case VIDIOCSCHAN: 454 case VIDIOCSCHAN:
375 { 455 {
376 static const v4l2_std_id map[] = { 456 static const v4l2_std_id map[] = {
377 [ VIDEO_MODE_PAL ] = V4L2_STD_PAL, 457 [VIDEO_MODE_PAL] = V4L2_STD_PAL,
378 [ VIDEO_MODE_NTSC ] = V4L2_STD_NTSC_M, 458 [VIDEO_MODE_NTSC] = V4L2_STD_NTSC_M,
379 [ VIDEO_MODE_SECAM ] = V4L2_STD_SECAM, 459 [VIDEO_MODE_SECAM] = V4L2_STD_SECAM,
380 [ 4 /* bttv */ ] = V4L2_STD_PAL_M, 460 [4 /* bttv */ ] = V4L2_STD_PAL_M,
381 [ 5 /* bttv */ ] = V4L2_STD_PAL_N, 461 [5 /* bttv */ ] = V4L2_STD_PAL_N,
382 [ 6 /* bttv */ ] = V4L2_STD_NTSC_M_JP, 462 [6 /* bttv */ ] = V4L2_STD_NTSC_M_JP,
383 }; 463 };
384 struct video_channel *vc = arg; 464 struct video_channel *vc = arg;
385 465
386 CHECK_V4L2; 466 if (check_v4l2(t) == EINVAL)
387 t->mode = V4L2_TUNER_ANALOG_TV; 467 return 0;
388 CHECK_ADDR(tv_tuner,"VIDIOCSCHAN","TV"); 468
389 469 if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==EINVAL)
390 if (vc->norm < ARRAY_SIZE(map)) 470 return 0;
391 t->std = map[vc->norm]; 471
392 tuner_fixup_std(t); 472 if (vc->norm < ARRAY_SIZE(map))
393 if (t->freq) 473 t->std = map[vc->norm];
394 set_tv_freq(client,t->freq); 474 tuner_fixup_std(t);
395 return 0; 475 if (t->freq)
396 } 476 set_tv_freq(client, t->freq);
477 return 0;
478 }
397 case VIDIOCSFREQ: 479 case VIDIOCSFREQ:
398 { 480 {
399 unsigned long *v = arg; 481 unsigned long *v = arg;
400 482
401 CHECK_MODE("VIDIOCSFREQ"); 483 if (check_mode(t, "VIDIOCSFREQ") == EINVAL)
402 CHECK_V4L2; 484 return 0;
403 set_freq(client,*v); 485 if (check_v4l2(t) == EINVAL)
404 return 0; 486 return 0;
405 } 487
488 set_freq(client, *v);
489 return 0;
490 }
406 case VIDIOCGTUNER: 491 case VIDIOCGTUNER:
407 { 492 {
408 struct video_tuner *vt = arg; 493 struct video_tuner *vt = arg;
409 494
410 CHECK_ADDR(radio_tuner,"VIDIOCGTUNER","radio"); 495 if (check_mode(t, "VIDIOCGTUNER") == EINVAL)
411 CHECK_V4L2; 496 return 0;
412 if (V4L2_TUNER_RADIO == t->mode) { 497 if (check_v4l2(t) == EINVAL)
413 if (t->has_signal) 498 return 0;
414 vt->signal = t->has_signal(client); 499
415 if (t->is_stereo) { 500 if (V4L2_TUNER_RADIO == t->mode) {
416 if (t->is_stereo(client)) 501 if (t->has_signal)
417 vt->flags |= VIDEO_TUNER_STEREO_ON; 502 vt->signal = t->has_signal(client);
418 else 503 if (t->is_stereo) {
419 vt->flags &= ~VIDEO_TUNER_STEREO_ON; 504 if (t->is_stereo(client))
420 } 505 vt->flags |=
421 vt->flags |= V4L2_TUNER_CAP_LOW; /* Allow freqs at 62.5 Hz */ 506 VIDEO_TUNER_STEREO_ON;
507 else
508 vt->flags &=
509 ~VIDEO_TUNER_STEREO_ON;
510 }
511 vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */
422 512
423 vt->rangelow = radio_range[0] * 16000; 513 vt->rangelow = radio_range[0] * 16000;
424 vt->rangehigh = radio_range[1] * 16000; 514 vt->rangehigh = radio_range[1] * 16000;
425 515
426 } else { 516 } else {
427 vt->rangelow = tv_range[0] * 16; 517 vt->rangelow = tv_range[0] * 16;
428 vt->rangehigh = tv_range[1] * 16; 518 vt->rangehigh = tv_range[1] * 16;
429 } 519 }
430 520
431 return 0; 521 return 0;
432 } 522 }
433 case VIDIOCGAUDIO: 523 case VIDIOCGAUDIO:
434 { 524 {
435 struct video_audio *va = arg; 525 struct video_audio *va = arg;
436 526
437 CHECK_ADDR(radio_tuner,"VIDIOCGAUDIO","radio"); 527 if (check_mode(t, "VIDIOCGAUDIO") == EINVAL)
438 CHECK_V4L2; 528 return 0;
439 if (V4L2_TUNER_RADIO == t->mode && t->is_stereo) 529 if (check_v4l2(t) == EINVAL)
440 va->mode = t->is_stereo(client) 530 return 0;
441 ? VIDEO_SOUND_STEREO 531
442 : VIDEO_SOUND_MONO; 532 if (V4L2_TUNER_RADIO == t->mode && t->is_stereo)
443 return 0; 533 va->mode = t->is_stereo(client)
444 } 534 ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
535 return 0;
536 }
445 537
446 case VIDIOC_S_STD: 538 case VIDIOC_S_STD:
447 { 539 {
448 v4l2_std_id *id = arg; 540 v4l2_std_id *id = arg;
449 541
450 SWITCH_V4L2; 542 if (set_mode (client, t, V4L2_TUNER_ANALOG_TV, "VIDIOC_S_STD")
451 t->mode = V4L2_TUNER_ANALOG_TV; 543 == EINVAL)
452 CHECK_ADDR(tv_tuner,"VIDIOC_S_STD","TV"); 544 return 0;
453 545
454 t->std = *id; 546 switch_v4l2();
455 tuner_fixup_std(t); 547
456 if (t->freq) 548 t->std = *id;
457 set_freq(client,t->freq); 549 tuner_fixup_std(t);
458 break; 550 if (t->freq)
459 } 551 set_freq(client, t->freq);
552 break;
553 }
460 case VIDIOC_S_FREQUENCY: 554 case VIDIOC_S_FREQUENCY:
461 { 555 {
462 struct v4l2_frequency *f = arg; 556 struct v4l2_frequency *f = arg;
463 557
464 CHECK_MODE("VIDIOC_S_FREQUENCY"); 558 t->freq = f->frequency;
465 SWITCH_V4L2; 559 switch_v4l2();
466 if (V4L2_TUNER_RADIO == f->type && 560 if (V4L2_TUNER_RADIO == f->type &&
467 V4L2_TUNER_RADIO != t->mode) 561 V4L2_TUNER_RADIO != t->mode) {
468 set_tv_freq(client,400*16); 562 if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY")
469 t->mode = f->type; 563 == EINVAL)
470 set_freq(client,f->frequency); 564 return 0;
471 break; 565 }
472 } 566 set_freq(client,t->freq);
473 case VIDIOC_G_FREQUENCY:
474 {
475 struct v4l2_frequency *f = arg;
476 567
477 CHECK_MODE("VIDIOC_G_FREQUENCY"); 568 break;
478 SWITCH_V4L2; 569 }
479 f->type = t->mode; 570 case VIDIOC_G_FREQUENCY:
480 f->frequency = t->freq; 571 {
481 break; 572 struct v4l2_frequency *f = arg;
482 } 573
574 if (check_mode(t, "VIDIOC_G_FREQUENCY") == EINVAL)
575 return 0;
576 switch_v4l2();
577 f->type = t->mode;
578 f->frequency = t->freq;
579 break;
580 }
483 case VIDIOC_G_TUNER: 581 case VIDIOC_G_TUNER:
484 { 582 {
485 struct v4l2_tuner *tuner = arg; 583 struct v4l2_tuner *tuner = arg;
486 584
487 CHECK_MODE("VIDIOC_G_TUNER"); 585 if (check_mode(t, "VIDIOC_G_TUNER") == EINVAL)
488 SWITCH_V4L2; 586 return 0;
489 if (V4L2_TUNER_RADIO == t->mode) { 587 switch_v4l2();
490 if (t->has_signal) 588
491 tuner -> signal = t->has_signal(client); 589 if (V4L2_TUNER_RADIO == t->mode) {
492 if (t->is_stereo) { 590
493 if (t->is_stereo(client)) { 591 if (t->has_signal)
494 tuner -> rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO; 592 tuner->signal = t->has_signal(client);
495 } else { 593
496 tuner -> rxsubchans = V4L2_TUNER_SUB_MONO; 594 if (t->is_stereo) {
595 if (t->is_stereo(client)) {
596 tuner->rxsubchans =
597 V4L2_TUNER_SUB_STEREO |
598 V4L2_TUNER_SUB_MONO;
599 } else {
600 tuner->rxsubchans =
601 V4L2_TUNER_SUB_MONO;
602 }
497 } 603 }
604
605 tuner->capability |=
606 V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
607
608 tuner->audmode = t->audmode;
609
610 tuner->rangelow = radio_range[0] * 16000;
611 tuner->rangehigh = radio_range[1] * 16000;
612 } else {
613 tuner->rangelow = tv_range[0] * 16;
614 tuner->rangehigh = tv_range[1] * 16;
498 } 615 }
499 tuner->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; 616 break;
500 tuner->audmode = t->audmode; 617 }
501 618 case VIDIOC_S_TUNER:
502 tuner->rangelow = radio_range[0] * 16000; 619 {
503 tuner->rangehigh = radio_range[1] * 16000; 620 struct v4l2_tuner *tuner = arg;
504 } else { 621
505 tuner->rangelow = tv_range[0] * 16; 622 if (check_mode(t, "VIDIOC_S_TUNER") == EINVAL)
506 tuner->rangehigh = tv_range[1] * 16; 623 return 0;
624
625 switch_v4l2();
626
627 if (V4L2_TUNER_RADIO == t->mode) {
628 t->audmode = tuner->audmode;
629 set_radio_freq(client, t->freq);
630 }
631 break;
507 } 632 }
508 break;
509 }
510 case VIDIOC_S_TUNER: /* Allow changing radio range and audio mode */
511 {
512 struct v4l2_tuner *tuner = arg;
513
514 CHECK_ADDR(radio_tuner,"VIDIOC_S_TUNER","radio");
515 SWITCH_V4L2;
516
517 /* To switch the audio mode, applications initialize the
518 index and audmode fields and the reserved array and
519 call the VIDIOC_S_TUNER ioctl. */
520 /* rxsubchannels: V4L2_TUNER_MODE_MONO, V4L2_TUNER_MODE_STEREO,
521 V4L2_TUNER_MODE_LANG1, V4L2_TUNER_MODE_LANG2,
522 V4L2_TUNER_MODE_SAP */
523
524 if (tuner->audmode == V4L2_TUNER_MODE_MONO)
525 t->audmode = V4L2_TUNER_MODE_MONO;
526 else
527 t->audmode = V4L2_TUNER_MODE_STEREO;
528
529 set_radio_freq(client, t->freq);
530 break;
531 }
532 case TDA9887_SET_CONFIG: /* Nothing to do on tuner-core */
533 break;
534 default: 633 default:
535 tuner_dbg ("Unimplemented IOCTL 0x%08x called to tuner.\n", cmd); 634 tuner_dbg("Unimplemented IOCTL 0x%08x called to tuner.\n", cmd);
536 /* nothing */
537 break; 635 break;
538 } 636 }
539 637
540 return 0; 638 return 0;
541} 639}
542 640
543static int tuner_suspend(struct device * dev, u32 state, u32 level) 641static int tuner_suspend(struct device *dev, u32 state, u32 level)
544{ 642{
545 struct i2c_client *c = container_of(dev, struct i2c_client, dev); 643 struct i2c_client *c = container_of (dev, struct i2c_client, dev);
546 struct tuner *t = i2c_get_clientdata(c); 644 struct tuner *t = i2c_get_clientdata (c);
547 645
548 tuner_dbg("suspend\n"); 646 tuner_dbg ("suspend\n");
549 /* FIXME: power down ??? */ 647 /* FIXME: power down ??? */
550 return 0; 648 return 0;
551} 649}
552 650
553static int tuner_resume(struct device * dev, u32 level) 651static int tuner_resume(struct device *dev, u32 level)
554{ 652{
555 struct i2c_client *c = container_of(dev, struct i2c_client, dev); 653 struct i2c_client *c = container_of (dev, struct i2c_client, dev);
556 struct tuner *t = i2c_get_clientdata(c); 654 struct tuner *t = i2c_get_clientdata (c);
557 655
558 tuner_dbg("resume\n"); 656 tuner_dbg ("resume\n");
559 if (t->freq) 657 if (t->freq)
560 set_freq(c,t->freq); 658 set_freq(c, t->freq);
561 return 0; 659 return 0;
562} 660}
563 661
564/* ----------------------------------------------------------------------- */ 662/* ----------------------------------------------------------------------- */
565 663
566static struct i2c_driver driver = { 664static struct i2c_driver driver = {
567 .owner = THIS_MODULE, 665 .owner = THIS_MODULE,
568 .name = "tuner", 666 .name = "tuner",
569 .id = I2C_DRIVERID_TUNER, 667 .id = I2C_DRIVERID_TUNER,
570 .flags = I2C_DF_NOTIFY, 668 .flags = I2C_DF_NOTIFY,
571 .attach_adapter = tuner_probe, 669 .attach_adapter = tuner_probe,
572 .detach_client = tuner_detach, 670 .detach_client = tuner_detach,
573 .command = tuner_command, 671 .command = tuner_command,
574 .driver = { 672 .driver = {
575 .suspend = tuner_suspend, 673 .suspend = tuner_suspend,
576 .resume = tuner_resume, 674 .resume = tuner_resume,
577 }, 675 },
578}; 676};
579static struct i2c_client client_template = 677static struct i2c_client client_template = {
580{
581 I2C_DEVNAME("(tuner unset)"), 678 I2C_DEVNAME("(tuner unset)"),
582 .flags = I2C_CLIENT_ALLOW_USE, 679 .flags = I2C_CLIENT_ALLOW_USE,
583 .driver = &driver, 680 .driver = &driver,
584}; 681};
585 682
586static int __init tuner_init_module(void) 683static int __init tuner_init_module(void)
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index c39ed6226ee0..a3f8e83f5314 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: tuner-simple.c,v 1.31 2005/06/21 16:02:25 mkrufky Exp $ 2 * $Id: tuner-simple.c,v 1.39 2005/07/07 01:49:30 mkrufky Exp $
3 * 3 *
4 * i2c tv tuner chip device driver 4 * i2c tv tuner chip device driver
5 * controls all those simple 4-control-bytes style tuners. 5 * controls all those simple 4-control-bytes style tuners.
@@ -54,6 +54,27 @@
54#define PHILIPS_MF_SET_PAL_L 0x03 // France 54#define PHILIPS_MF_SET_PAL_L 0x03 // France
55#define PHILIPS_MF_SET_PAL_L2 0x02 // L' 55#define PHILIPS_MF_SET_PAL_L2 0x02 // L'
56 56
57/* Control byte */
58
59#define TUNER_RATIO_MASK 0x06 /* Bit cb1:cb2 */
60#define TUNER_RATIO_SELECT_50 0x00
61#define TUNER_RATIO_SELECT_32 0x02
62#define TUNER_RATIO_SELECT_166 0x04
63#define TUNER_RATIO_SELECT_62 0x06
64
65#define TUNER_CHARGE_PUMP 0x40 /* Bit cb6 */
66
67/* Status byte */
68
69#define TUNER_POR 0x80
70#define TUNER_FL 0x40
71#define TUNER_MODE 0x38
72#define TUNER_AFC 0x07
73#define TUNER_SIGNAL 0x07
74#define TUNER_STEREO 0x10
75
76#define TUNER_PLL_LOCKED 0x40
77#define TUNER_STEREO_MK3 0x04
57 78
58/* ---------------------------------------------------------------------- */ 79/* ---------------------------------------------------------------------- */
59 80
@@ -211,21 +232,17 @@ static struct tunertype tuners[] = {
211 16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 }, 232 16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 },
212 { "Philips FQ1236A MK4", Philips, NTSC, 233 { "Philips FQ1236A MK4", Philips, NTSC,
213 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 }, 234 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 },
214 235 { "Ymec TVision TVF-8531MF/8831MF/8731MF", Philips, NTSC,
215 /* Should work for TVF8531MF, TVF8831MF, TVF8731MF */
216 { "Ymec TVision TVF-8531MF", Philips, NTSC,
217 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732}, 236 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732},
218 { "Ymec TVision TVF-5533MF", Philips, NTSC, 237 { "Ymec TVision TVF-5533MF", Philips, NTSC,
219 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732}, 238 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732},
239
220 { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, 240 { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC,
221 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, 241 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732},
222 /* Should work for TNF9533-D/IF, TNF9533-B/DF */ 242 { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL,
223 { "Tena TNF9533-D/IF", Philips, PAL,
224 16*160.25,16*464.25,0x01,0x02,0x04,0x8e,623}, 243 16*160.25,16*464.25,0x01,0x02,0x04,0x8e,623},
225 244 { "Philips TEA5767HN FM Radio", Philips, RADIO,
226 /* This entry is for TEA5767 FM radio only chip used on several boards w/TV tuner */ 245 /* see tea5767.c for details */},
227 { TEA5767_TUNER_NAME, Philips, RADIO,
228 -1, -1, 0, 0, 0, TEA5767_LOW_LO_32768,0},
229 { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, 246 { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL,
230 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, 247 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 },
231}; 248};
@@ -244,15 +261,6 @@ static int tuner_getstatus(struct i2c_client *c)
244 return byte; 261 return byte;
245} 262}
246 263
247#define TUNER_POR 0x80
248#define TUNER_FL 0x40
249#define TUNER_MODE 0x38
250#define TUNER_AFC 0x07
251
252#define TUNER_STEREO 0x10 /* radio mode */
253#define TUNER_STEREO_MK3 0x04 /* radio mode */
254#define TUNER_SIGNAL 0x07 /* radio mode */
255
256static int tuner_signal(struct i2c_client *c) 264static int tuner_signal(struct i2c_client *c)
257{ 265{
258 return (tuner_getstatus(c) & TUNER_SIGNAL) << 13; 266 return (tuner_getstatus(c) & TUNER_SIGNAL) << 13;
@@ -278,22 +286,6 @@ static int tuner_stereo(struct i2c_client *c)
278 return stereo; 286 return stereo;
279} 287}
280 288
281#if 0 /* unused */
282static int tuner_islocked (struct i2c_client *c)
283{
284 return (tuner_getstatus (c) & TUNER_FL);
285}
286
287static int tuner_afcstatus (struct i2c_client *c)
288{
289 return (tuner_getstatus (c) & TUNER_AFC) - 2;
290}
291
292static int tuner_mode (struct i2c_client *c)
293{
294 return (tuner_getstatus (c) & TUNER_MODE) >> 3;
295}
296#endif
297 289
298/* ---------------------------------------------------------------------- */ 290/* ---------------------------------------------------------------------- */
299 291
@@ -376,7 +368,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
376 368
377 case TUNER_MICROTUNE_4042FI5: 369 case TUNER_MICROTUNE_4042FI5:
378 /* Set the charge pump for fast tuning */ 370 /* Set the charge pump for fast tuning */
379 tun->config |= 0x40; 371 tun->config |= TUNER_CHARGE_PUMP;
380 break; 372 break;
381 } 373 }
382 374
@@ -425,14 +417,13 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
425 tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc); 417 tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc);
426 break; 418 break;
427 } 419 }
428 /* bit 6 is PLL locked indicator */ 420 if (status_byte & TUNER_PLL_LOCKED)
429 if (status_byte & 0x40)
430 break; 421 break;
431 udelay(10); 422 udelay(10);
432 } 423 }
433 424
434 /* Set the charge pump for optimized phase noise figure */ 425 /* Set the charge pump for optimized phase noise figure */
435 tun->config &= ~0x40; 426 tun->config &= ~TUNER_CHARGE_PUMP;
436 buffer[0] = (div>>8) & 0x7f; 427 buffer[0] = (div>>8) & 0x7f;
437 buffer[1] = div & 0xff; 428 buffer[1] = div & 0xff;
438 buffer[2] = tun->config; 429 buffer[2] = tun->config;
@@ -453,26 +444,22 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
453 unsigned div; 444 unsigned div;
454 int rc; 445 int rc;
455 446
456 tun=&tuners[t->type]; 447 tun = &tuners[t->type];
457 div = (freq / 1000) + (int)(16*10.7); 448 div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */
458 buffer[2] = tun->config; 449 buffer[2] = (tun->config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */
459 450
460 switch (t->type) { 451 switch (t->type) {
461 case TUNER_TENA_9533_DI: 452 case TUNER_TENA_9533_DI:
462 case TUNER_YMEC_TVF_5533MF: 453 case TUNER_YMEC_TVF_5533MF:
463 /*These values are empirically determinated */ 454 tuner_dbg ("This tuner doesn't have FM. Most cards has a TEA5767 for FM\n");
464 div = (freq * 122) / 16000 - 20; 455 return;
465 buffer[2] = 0x88; /* could be also 0x80 */
466 buffer[3] = 0x19; /* could be also 0x10, 0x18, 0x99 */
467 break;
468 case TUNER_PHILIPS_FM1216ME_MK3: 456 case TUNER_PHILIPS_FM1216ME_MK3:
469 case TUNER_PHILIPS_FM1236_MK3: 457 case TUNER_PHILIPS_FM1236_MK3:
470 case TUNER_PHILIPS_FMD1216ME_MK3: 458 case TUNER_PHILIPS_FMD1216ME_MK3:
471 buffer[3] = 0x19; 459 buffer[3] = 0x19;
472 break; 460 break;
473 case TUNER_PHILIPS_FM1256_IH3: 461 case TUNER_PHILIPS_FM1256_IH3:
474 div = (20 * freq) / 16000 + 333 * 2; 462 div = (20 * freq) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */
475 buffer[2] = 0x80;
476 buffer[3] = 0x19; 463 buffer[3] = 0x19;
477 break; 464 break;
478 case TUNER_LG_PAL_FM: 465 case TUNER_LG_PAL_FM:
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 9a493bea76d8..d8b78f1d686b 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -864,13 +864,8 @@ static int tda9874a_getmode(struct CHIPSTATE *chip)
864 * But changing the mode to VIDEO_SOUND_MONO would switch 864 * But changing the mode to VIDEO_SOUND_MONO would switch
865 * external 4052 multiplexer in audio_hook(). 865 * external 4052 multiplexer in audio_hook().
866 */ 866 */
867#if 0
868 if((nsr & 0x02) && !(dsr & 0x10)) /* NSR.S/MB=1 and DSR.AMSTAT=0 */
869 mode |= VIDEO_SOUND_STEREO;
870#else
871 if(nsr & 0x02) /* NSR.S/MB=1 */ 867 if(nsr & 0x02) /* NSR.S/MB=1 */
872 mode |= VIDEO_SOUND_STEREO; 868 mode |= VIDEO_SOUND_STEREO;
873#endif
874 if(nsr & 0x01) /* NSR.D/SB=1 */ 869 if(nsr & 0x01) /* NSR.D/SB=1 */
875 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; 870 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
876 } else { 871 } else {
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 0f03c25489f1..e8d9440977cb 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -400,14 +400,6 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data
400 } 400 }
401 } 401 }
402 402
403#if 0
404 if (t_format < sizeof(hauppauge_tuner_fmt)/sizeof(struct HAUPPAUGE_TUNER_FMT)) {
405 tvee->tuner_formats = hauppauge_tuner_fmt[t_format].id;
406 t_fmt_name = hauppauge_tuner_fmt[t_format].name;
407 } else {
408 t_fmt_name = "<unknown>";
409 }
410#endif
411 403
412 TVEEPROM_KERN_INFO("Hauppauge: model = %d, rev = %s, serial# = %d\n", 404 TVEEPROM_KERN_INFO("Hauppauge: model = %d, rev = %s, serial# = %d\n",
413 tvee->model, 405 tvee->model,
@@ -482,6 +474,7 @@ static unsigned short normal_i2c[] = {
482 0xa0 >> 1, 474 0xa0 >> 1,
483 I2C_CLIENT_END, 475 I2C_CLIENT_END,
484}; 476};
477
485I2C_CLIENT_INSMOD; 478I2C_CLIENT_INSMOD;
486 479
487struct i2c_driver i2c_driver_tveeprom; 480struct i2c_driver i2c_driver_tveeprom;
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 8b623278ccd2..ffbe6f4720e1 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1363,19 +1363,7 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state)
1363 u32 device_state; 1363 u32 device_state;
1364 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1364 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1365 1365
1366 switch(state) 1366 device_state=pci_choose_state(pdev, state);
1367 {
1368 case 1: /* S1 */
1369 device_state=1; /* D1 */;
1370 break;
1371 case 3: /* S3 */
1372 case 4: /* S4 */
1373 device_state=3; /* D3 */;
1374 break;
1375 default:
1376 return -EAGAIN /*FIXME*/;
1377 break;
1378 }
1379 1367
1380 printk(MYIOC_s_INFO_FMT 1368 printk(MYIOC_s_INFO_FMT
1381 "pci-suspend: pdev=0x%p, slot=%s, Entering operating state [D%d]\n", 1369 "pci-suspend: pdev=0x%p, slot=%s, Entering operating state [D%d]\n",
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 5ea89bf0df19..debb8ac59545 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -84,7 +84,7 @@
84extern void mptscsih_remove(struct pci_dev *); 84extern void mptscsih_remove(struct pci_dev *);
85extern void mptscsih_shutdown(struct pci_dev *); 85extern void mptscsih_shutdown(struct pci_dev *);
86#ifdef CONFIG_PM 86#ifdef CONFIG_PM
87extern int mptscsih_suspend(struct pci_dev *pdev, u32 state); 87extern int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state);
88extern int mptscsih_resume(struct pci_dev *pdev); 88extern int mptscsih_resume(struct pci_dev *pdev);
89#endif 89#endif
90extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func); 90extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func);
diff --git a/drivers/message/i2o/config-osm.c b/drivers/message/i2o/config-osm.c
index d0267609a949..fe2e7afc9eae 100644
--- a/drivers/message/i2o/config-osm.c
+++ b/drivers/message/i2o/config-osm.c
@@ -15,7 +15,9 @@
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/i2o.h> 17#include <linux/i2o.h>
18#include <linux/dcache.h>
18#include <linux/namei.h> 19#include <linux/namei.h>
20#include <linux/fs.h>
19 21
20#include <asm/uaccess.h> 22#include <asm/uaccess.h>
21 23
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 4cecdafeb87d..7fc692a8f5b0 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -6,8 +6,7 @@ menu "Misc devices"
6 6
7config IBM_ASM 7config IBM_ASM
8 tristate "Device driver for IBM RSA service processor" 8 tristate "Device driver for IBM RSA service processor"
9 depends on X86 && EXPERIMENTAL 9 depends on X86 && PCI && EXPERIMENTAL
10 default n
11 ---help--- 10 ---help---
12 This option enables device driver support for in-band access to the 11 This option enables device driver support for in-band access to the
13 IBM RSA (Condor) service processor in eServer xSeries systems. 12 IBM RSA (Condor) service processor in eServer xSeries systems.
@@ -22,7 +21,7 @@ config IBM_ASM
22 21
23 WARNING: This software may not be supported or function 22 WARNING: This software may not be supported or function
24 correctly on your IBM server. Please consult the IBM ServerProven 23 correctly on your IBM server. Please consult the IBM ServerProven
25 website <http://www.pc.ibm/ww/eserver/xseries/serverproven> for 24 website <http://www.pc.ibm.com/ww/eserver/xseries/serverproven> for
26 information on the specific driver level and support statement 25 information on the specific driver level and support statement
27 for your IBM server. 26 for your IBM server.
28 27
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c
index 3a5f6ac5b364..7a42966d755b 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/mmci.c
@@ -20,6 +20,7 @@
20#include <linux/mmc/host.h> 20#include <linux/mmc/host.h>
21#include <linux/mmc/protocol.h> 21#include <linux/mmc/protocol.h>
22 22
23#include <asm/div64.h>
23#include <asm/io.h> 24#include <asm/io.h>
24#include <asm/irq.h> 25#include <asm/irq.h>
25#include <asm/scatterlist.h> 26#include <asm/scatterlist.h>
@@ -70,6 +71,7 @@ static void mmci_stop_data(struct mmci_host *host)
70static void mmci_start_data(struct mmci_host *host, struct mmc_data *data) 71static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
71{ 72{
72 unsigned int datactrl, timeout, irqmask; 73 unsigned int datactrl, timeout, irqmask;
74 unsigned long long clks;
73 void __iomem *base; 75 void __iomem *base;
74 76
75 DBG(host, "blksz %04x blks %04x flags %08x\n", 77 DBG(host, "blksz %04x blks %04x flags %08x\n",
@@ -81,9 +83,10 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
81 83
82 mmci_init_sg(host, data); 84 mmci_init_sg(host, data);
83 85
84 timeout = data->timeout_clks + 86 clks = (unsigned long long)data->timeout_ns * host->cclk;
85 ((unsigned long long)data->timeout_ns * host->cclk) / 87 do_div(clks, 1000000000UL);
86 1000000000ULL; 88
89 timeout = data->timeout_clks + (unsigned int)clks;
87 90
88 base = host->base; 91 base = host->base;
89 writel(timeout, base + MMCIDATATIMER); 92 writel(timeout, base + MMCIDATATIMER);
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index b7fbd30b49a0..0c41d4b41a65 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -54,28 +54,6 @@
54#define DBGF(x...) do { } while (0) 54#define DBGF(x...) do { } while (0)
55#endif 55#endif
56 56
57#ifdef CONFIG_MMC_DEBUG
58void DBG_REG(int reg, u8 value)
59{
60 int i;
61
62 printk(KERN_DEBUG "wbsd: Register %d: 0x%02X %3d '%c' ",
63 reg, (int)value, (int)value, (value < 0x20)?'.':value);
64
65 for (i = 7;i >= 0;i--)
66 {
67 if (value & (1 << i))
68 printk("x");
69 else
70 printk(".");
71 }
72
73 printk("\n");
74}
75#else
76#define DBG_REG(r, v) do {} while (0)
77#endif
78
79/* 57/*
80 * Device resources 58 * Device resources
81 */ 59 */
@@ -92,6 +70,13 @@ MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
92 70
93#endif /* CONFIG_PNP */ 71#endif /* CONFIG_PNP */
94 72
73static const int config_ports[] = { 0x2E, 0x4E };
74static const int unlock_codes[] = { 0x83, 0x87 };
75
76static const int valid_ids[] = {
77 0x7112,
78 };
79
95#ifdef CONFIG_PNP 80#ifdef CONFIG_PNP
96static unsigned int nopnp = 0; 81static unsigned int nopnp = 0;
97#else 82#else
@@ -1051,6 +1036,20 @@ static struct mmc_host_ops wbsd_ops = {
1051\*****************************************************************************/ 1036\*****************************************************************************/
1052 1037
1053/* 1038/*
1039 * Helper function for card detection
1040 */
1041static void wbsd_detect_card(unsigned long data)
1042{
1043 struct wbsd_host *host = (struct wbsd_host*)data;
1044
1045 BUG_ON(host == NULL);
1046
1047 DBG("Executing card detection\n");
1048
1049 mmc_detect_change(host->mmc);
1050}
1051
1052/*
1054 * Tasklets 1053 * Tasklets
1055 */ 1054 */
1056 1055
@@ -1075,7 +1074,6 @@ static void wbsd_tasklet_card(unsigned long param)
1075{ 1074{
1076 struct wbsd_host* host = (struct wbsd_host*)param; 1075 struct wbsd_host* host = (struct wbsd_host*)param;
1077 u8 csr; 1076 u8 csr;
1078 int change = 0;
1079 1077
1080 spin_lock(&host->lock); 1078 spin_lock(&host->lock);
1081 1079
@@ -1094,14 +1092,20 @@ static void wbsd_tasklet_card(unsigned long param)
1094 { 1092 {
1095 DBG("Card inserted\n"); 1093 DBG("Card inserted\n");
1096 host->flags |= WBSD_FCARD_PRESENT; 1094 host->flags |= WBSD_FCARD_PRESENT;
1097 change = 1; 1095
1096 /*
1097 * Delay card detection to allow electrical connections
1098 * to stabilise.
1099 */
1100 mod_timer(&host->timer, jiffies + HZ/2);
1098 } 1101 }
1102
1103 spin_unlock(&host->lock);
1099 } 1104 }
1100 else if (host->flags & WBSD_FCARD_PRESENT) 1105 else if (host->flags & WBSD_FCARD_PRESENT)
1101 { 1106 {
1102 DBG("Card removed\n"); 1107 DBG("Card removed\n");
1103 host->flags &= ~WBSD_FCARD_PRESENT; 1108 host->flags &= ~WBSD_FCARD_PRESENT;
1104 change = 1;
1105 1109
1106 if (host->mrq) 1110 if (host->mrq)
1107 { 1111 {
@@ -1112,15 +1116,14 @@ static void wbsd_tasklet_card(unsigned long param)
1112 host->mrq->cmd->error = MMC_ERR_FAILED; 1116 host->mrq->cmd->error = MMC_ERR_FAILED;
1113 tasklet_schedule(&host->finish_tasklet); 1117 tasklet_schedule(&host->finish_tasklet);
1114 } 1118 }
1115 } 1119
1116 1120 /*
1117 /* 1121 * Unlock first since we might get a call back.
1118 * Unlock first since we might get a call back. 1122 */
1119 */ 1123 spin_unlock(&host->lock);
1120 spin_unlock(&host->lock);
1121 1124
1122 if (change)
1123 mmc_detect_change(host->mmc); 1125 mmc_detect_change(host->mmc);
1126 }
1124} 1127}
1125 1128
1126static void wbsd_tasklet_fifo(unsigned long param) 1129static void wbsd_tasklet_fifo(unsigned long param)
@@ -1325,6 +1328,13 @@ static int __devinit wbsd_alloc_mmc(struct device* dev)
1325 spin_lock_init(&host->lock); 1328 spin_lock_init(&host->lock);
1326 1329
1327 /* 1330 /*
1331 * Set up detection timer
1332 */
1333 init_timer(&host->timer);
1334 host->timer.data = (unsigned long)host;
1335 host->timer.function = wbsd_detect_card;
1336
1337 /*
1328 * Maximum number of segments. Worst case is one sector per segment 1338 * Maximum number of segments. Worst case is one sector per segment
1329 * so this will be 64kB/512. 1339 * so this will be 64kB/512.
1330 */ 1340 */
@@ -1351,11 +1361,17 @@ static int __devinit wbsd_alloc_mmc(struct device* dev)
1351static void __devexit wbsd_free_mmc(struct device* dev) 1361static void __devexit wbsd_free_mmc(struct device* dev)
1352{ 1362{
1353 struct mmc_host* mmc; 1363 struct mmc_host* mmc;
1364 struct wbsd_host* host;
1354 1365
1355 mmc = dev_get_drvdata(dev); 1366 mmc = dev_get_drvdata(dev);
1356 if (!mmc) 1367 if (!mmc)
1357 return; 1368 return;
1358 1369
1370 host = mmc_priv(mmc);
1371 BUG_ON(host == NULL);
1372
1373 del_timer_sync(&host->timer);
1374
1359 mmc_free_host(mmc); 1375 mmc_free_host(mmc);
1360 1376
1361 dev_set_drvdata(dev, NULL); 1377 dev_set_drvdata(dev, NULL);
diff --git a/drivers/mmc/wbsd.h b/drivers/mmc/wbsd.h
index 864f30828d01..661a9f6a6e6f 100644
--- a/drivers/mmc/wbsd.h
+++ b/drivers/mmc/wbsd.h
@@ -8,13 +8,6 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11const int config_ports[] = { 0x2E, 0x4E };
12const int unlock_codes[] = { 0x83, 0x87 };
13
14const int valid_ids[] = {
15 0x7112,
16 };
17
18#define LOCK_CODE 0xAA 11#define LOCK_CODE 0xAA
19 12
20#define WBSD_CONF_SWRST 0x02 13#define WBSD_CONF_SWRST 0x02
@@ -187,4 +180,6 @@ struct wbsd_host
187 struct tasklet_struct timeout_tasklet; 180 struct tasklet_struct timeout_tasklet;
188 struct tasklet_struct finish_tasklet; 181 struct tasklet_struct finish_tasklet;
189 struct tasklet_struct block_tasklet; 182 struct tasklet_struct block_tasklet;
183
184 struct timer_list timer; /* Card detection timer */
190}; 185};
diff --git a/drivers/mtd/afs.c b/drivers/mtd/afs.c
index 801e6c7d0892..7363e101eb0f 100644
--- a/drivers/mtd/afs.c
+++ b/drivers/mtd/afs.c
@@ -219,7 +219,7 @@ static int parse_afs_partitions(struct mtd_info *mtd,
219 */ 219 */
220 for (idx = off = 0; off < mtd->size; off += mtd->erasesize) { 220 for (idx = off = 0; off < mtd->size; off += mtd->erasesize) {
221 struct image_info_struct iis; 221 struct image_info_struct iis;
222 u_int iis_ptr, img_ptr, size; 222 u_int iis_ptr, img_ptr;
223 223
224 /* Read the footer. */ 224 /* Read the footer. */
225 ret = afs_read_footer(mtd, &img_ptr, &iis_ptr, off, mask); 225 ret = afs_read_footer(mtd, &img_ptr, &iis_ptr, off, mask);
@@ -236,21 +236,9 @@ static int parse_afs_partitions(struct mtd_info *mtd,
236 continue; 236 continue;
237 237
238 strcpy(str, iis.name); 238 strcpy(str, iis.name);
239 size = mtd->erasesize + off - img_ptr;
240
241 /*
242 * In order to support JFFS2 partitions on this layout,
243 * we must lie to MTD about the real size of JFFS2
244 * partitions; this ensures that the AFS flash footer
245 * won't be erased by JFFS2. Please ensure that your
246 * JFFS2 partitions are given image numbers between
247 * 1000 and 2000 inclusive.
248 */
249 if (iis.imageNumber >= 1000 && iis.imageNumber < 2000)
250 size -= mtd->erasesize;
251 239
252 parts[idx].name = str; 240 parts[idx].name = str;
253 parts[idx].size = size; 241 parts[idx].size = (iis.length + mtd->erasesize - 1) & ~(mtd->erasesize - 1);
254 parts[idx].offset = img_ptr; 242 parts[idx].offset = img_ptr;
255 parts[idx].mask_flags = 0; 243 parts[idx].mask_flags = 0;
256 244
diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig
index d682dbc8157e..b5dc59389bb3 100644
--- a/drivers/mtd/chips/Kconfig
+++ b/drivers/mtd/chips/Kconfig
@@ -1,5 +1,5 @@
1# drivers/mtd/chips/Kconfig 1# drivers/mtd/chips/Kconfig
2# $Id: Kconfig,v 1.13 2004/12/01 15:49:10 nico Exp $ 2# $Id: Kconfig,v 1.15 2005/06/06 23:04:35 tpoynor Exp $
3 3
4menu "RAM/ROM/Flash chip drivers" 4menu "RAM/ROM/Flash chip drivers"
5 depends on MTD!=n 5 depends on MTD!=n
@@ -155,6 +155,31 @@ config MTD_CFI_I8
155 If your flash chips are interleaved in eights - i.e. you have eight 155 If your flash chips are interleaved in eights - i.e. you have eight
156 flash chips addressed by each bus cycle, then say 'Y'. 156 flash chips addressed by each bus cycle, then say 'Y'.
157 157
158config MTD_OTP
159 bool "Protection Registers aka one-time programmable (OTP) bits"
160 depends on MTD_CFI_ADV_OPTIONS
161 default n
162 help
163 This enables support for reading, writing and locking so called
164 "Protection Registers" present on some flash chips.
165 A subset of them are pre-programmed at the factory with a
166 unique set of values. The rest is user-programmable.
167
168 The user-programmable Protection Registers contain one-time
169 programmable (OTP) bits; when programmed, register bits cannot be
170 erased. Each Protection Register can be accessed multiple times to
171 program individual bits, as long as the register remains unlocked.
172
173 Each Protection Register has an associated Lock Register bit. When a
174 Lock Register bit is programmed, the associated Protection Register
175 can only be read; it can no longer be programmed. Additionally,
176 because the Lock Register bits themselves are OTP, when programmed,
177 Lock Register bits cannot be erased. Therefore, when a Protection
178 Register is locked, it cannot be unlocked.
179
180 This feature should therefore be used with extreme care. Any mistake
181 in the programming of OTP bits will waste them.
182
158config MTD_CFI_INTELEXT 183config MTD_CFI_INTELEXT
159 tristate "Support for Intel/Sharp flash chips" 184 tristate "Support for Intel/Sharp flash chips"
160 depends on MTD_GEN_PROBE 185 depends on MTD_GEN_PROBE
@@ -275,7 +300,7 @@ config MTD_JEDEC
275 300
276config MTD_XIP 301config MTD_XIP
277 bool "XIP aware MTD support" 302 bool "XIP aware MTD support"
278 depends on !SMP && MTD_CFI_INTELEXT && EXPERIMENTAL 303 depends on !SMP && (MTD_CFI_INTELEXT || MTD_CFI_AMDSTD) && EXPERIMENTAL
279 default y if XIP_KERNEL 304 default y if XIP_KERNEL
280 help 305 help
281 This allows MTD support to work with flash memory which is also 306 This allows MTD support to work with flash memory which is also
diff --git a/drivers/mtd/chips/amd_flash.c b/drivers/mtd/chips/amd_flash.c
index 41e2e3e31603..2dafeba3f3d5 100644
--- a/drivers/mtd/chips/amd_flash.c
+++ b/drivers/mtd/chips/amd_flash.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Author: Jonas Holmberg <jonas.holmberg@axis.com> 4 * Author: Jonas Holmberg <jonas.holmberg@axis.com>
5 * 5 *
6 * $Id: amd_flash.c,v 1.26 2004/11/20 12:49:04 dwmw2 Exp $ 6 * $Id: amd_flash.c,v 1.27 2005/02/04 07:43:09 jonashg Exp $
7 * 7 *
8 * Copyright (c) 2001 Axis Communications AB 8 * Copyright (c) 2001 Axis Communications AB
9 * 9 *
@@ -67,7 +67,6 @@
67#define AM29LV160DT 0x22C4 67#define AM29LV160DT 0x22C4
68#define AM29LV160DB 0x2249 68#define AM29LV160DB 0x2249
69#define AM29BDS323D 0x22D1 69#define AM29BDS323D 0x22D1
70#define AM29BDS643D 0x227E
71 70
72/* Atmel */ 71/* Atmel */
73#define AT49xV16x 0x00C0 72#define AT49xV16x 0x00C0
@@ -618,17 +617,6 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
618 { .offset = 0x3f0000, .erasesize = 0x02000, .numblocks = 8 }, 617 { .offset = 0x3f0000, .erasesize = 0x02000, .numblocks = 8 },
619 } 618 }
620 }, { 619 }, {
621 .mfr_id = MANUFACTURER_AMD,
622 .dev_id = AM29BDS643D,
623 .name = "AMD AM29BDS643D",
624 .size = 0x00800000,
625 .numeraseregions = 3,
626 .regions = {
627 { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 96 },
628 { .offset = 0x600000, .erasesize = 0x10000, .numblocks = 31 },
629 { .offset = 0x7f0000, .erasesize = 0x02000, .numblocks = 8 },
630 }
631 }, {
632 .mfr_id = MANUFACTURER_ATMEL, 620 .mfr_id = MANUFACTURER_ATMEL,
633 .dev_id = AT49xV16x, 621 .dev_id = AT49xV16x,
634 .name = "Atmel AT49xV16x", 622 .name = "Atmel AT49xV16x",
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index c268bcd71720..0cfcd88468e0 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0001.c,v 1.164 2004/11/16 18:29:00 dwmw2 Exp $ 7 * $Id: cfi_cmdset_0001.c,v 1.178 2005/05/19 17:05:43 nico Exp $
8 * 8 *
9 * 9 *
10 * 10/10/2000 Nicolas Pitre <nico@cam.org> 10 * 10/10/2000 Nicolas Pitre <nico@cam.org>
@@ -29,6 +29,7 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/reboot.h>
32#include <linux/mtd/xip.h> 33#include <linux/mtd/xip.h>
33#include <linux/mtd/map.h> 34#include <linux/mtd/map.h>
34#include <linux/mtd/mtd.h> 35#include <linux/mtd/mtd.h>
@@ -48,16 +49,25 @@
48#define M50LPW080 0x002F 49#define M50LPW080 0x002F
49 50
50static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); 51static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
51//static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
52//static int cfi_intelext_read_fact_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
53static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); 52static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
54static int cfi_intelext_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); 53static int cfi_intelext_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
55static int cfi_intelext_erase_varsize(struct mtd_info *, struct erase_info *); 54static int cfi_intelext_erase_varsize(struct mtd_info *, struct erase_info *);
56static void cfi_intelext_sync (struct mtd_info *); 55static void cfi_intelext_sync (struct mtd_info *);
57static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len); 56static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len);
58static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len); 57static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len);
58#ifdef CONFIG_MTD_OTP
59static int cfi_intelext_read_fact_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
60static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
61static int cfi_intelext_write_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
62static int cfi_intelext_lock_user_prot_reg (struct mtd_info *, loff_t, size_t);
63static int cfi_intelext_get_fact_prot_info (struct mtd_info *,
64 struct otp_info *, size_t);
65static int cfi_intelext_get_user_prot_info (struct mtd_info *,
66 struct otp_info *, size_t);
67#endif
59static int cfi_intelext_suspend (struct mtd_info *); 68static int cfi_intelext_suspend (struct mtd_info *);
60static void cfi_intelext_resume (struct mtd_info *); 69static void cfi_intelext_resume (struct mtd_info *);
70static int cfi_intelext_reboot (struct notifier_block *, unsigned long, void *);
61 71
62static void cfi_intelext_destroy(struct mtd_info *); 72static void cfi_intelext_destroy(struct mtd_info *);
63 73
@@ -252,7 +262,8 @@ read_pri_intelext(struct map_info *map, __u16 adr)
252 int nb_parts, i; 262 int nb_parts, i;
253 263
254 /* Protection Register info */ 264 /* Protection Register info */
255 extra_size += (extp->NumProtectionFields - 1) * (4 + 6); 265 extra_size += (extp->NumProtectionFields - 1) *
266 sizeof(struct cfi_intelext_otpinfo);
256 267
257 /* Burst Read info */ 268 /* Burst Read info */
258 extra_size += 6; 269 extra_size += 6;
@@ -324,7 +335,9 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
324 mtd->resume = cfi_intelext_resume; 335 mtd->resume = cfi_intelext_resume;
325 mtd->flags = MTD_CAP_NORFLASH; 336 mtd->flags = MTD_CAP_NORFLASH;
326 mtd->name = map->name; 337 mtd->name = map->name;
327 338
339 mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
340
328 if (cfi->cfi_mode == CFI_MODE_CFI) { 341 if (cfi->cfi_mode == CFI_MODE_CFI) {
329 /* 342 /*
330 * It's a real CFI chip, not one for which the probe 343 * It's a real CFI chip, not one for which the probe
@@ -422,9 +435,13 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
422 mtd->eraseregions[i].numblocks); 435 mtd->eraseregions[i].numblocks);
423 } 436 }
424 437
425#if 0 438#ifdef CONFIG_MTD_OTP
426 mtd->read_user_prot_reg = cfi_intelext_read_user_prot_reg;
427 mtd->read_fact_prot_reg = cfi_intelext_read_fact_prot_reg; 439 mtd->read_fact_prot_reg = cfi_intelext_read_fact_prot_reg;
440 mtd->read_user_prot_reg = cfi_intelext_read_user_prot_reg;
441 mtd->write_user_prot_reg = cfi_intelext_write_user_prot_reg;
442 mtd->lock_user_prot_reg = cfi_intelext_lock_user_prot_reg;
443 mtd->get_fact_prot_info = cfi_intelext_get_fact_prot_info;
444 mtd->get_user_prot_info = cfi_intelext_get_user_prot_info;
428#endif 445#endif
429 446
430 /* This function has the potential to distort the reality 447 /* This function has the potential to distort the reality
@@ -433,6 +450,7 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
433 goto setup_err; 450 goto setup_err;
434 451
435 __module_get(THIS_MODULE); 452 __module_get(THIS_MODULE);
453 register_reboot_notifier(&mtd->reboot_notifier);
436 return mtd; 454 return mtd;
437 455
438 setup_err: 456 setup_err:
@@ -471,7 +489,8 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
471 int offs, numregions, numparts, partshift, numvirtchips, i, j; 489 int offs, numregions, numparts, partshift, numvirtchips, i, j;
472 490
473 /* Protection Register info */ 491 /* Protection Register info */
474 offs = (extp->NumProtectionFields - 1) * (4 + 6); 492 offs = (extp->NumProtectionFields - 1) *
493 sizeof(struct cfi_intelext_otpinfo);
475 494
476 /* Burst Read info */ 495 /* Burst Read info */
477 offs += 6; 496 offs += 6;
@@ -563,7 +582,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
563 resettime: 582 resettime:
564 timeo = jiffies + HZ; 583 timeo = jiffies + HZ;
565 retry: 584 retry:
566 if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING)) { 585 if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING || mode == FL_OTP_WRITE)) {
567 /* 586 /*
568 * OK. We have possibility for contension on the write/erase 587 * OK. We have possibility for contension on the write/erase
569 * operations which are global to the real chip and not per 588 * operations which are global to the real chip and not per
@@ -807,10 +826,6 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
807 * assembly to make sure inline functions were actually inlined and that gcc 826 * assembly to make sure inline functions were actually inlined and that gcc
808 * didn't emit calls to its own support functions). Also configuring MTD CFI 827 * didn't emit calls to its own support functions). Also configuring MTD CFI
809 * support to a single buswidth and a single interleave is also recommended. 828 * support to a single buswidth and a single interleave is also recommended.
810 * Note that not only IRQs are disabled but the preemption count is also
811 * increased to prevent other locking primitives (namely spin_unlock) from
812 * decrementing the preempt count to zero and scheduling the CPU away while
813 * not in array mode.
814 */ 829 */
815 830
816static void xip_disable(struct map_info *map, struct flchip *chip, 831static void xip_disable(struct map_info *map, struct flchip *chip,
@@ -818,7 +833,6 @@ static void xip_disable(struct map_info *map, struct flchip *chip,
818{ 833{
819 /* TODO: chips with no XIP use should ignore and return */ 834 /* TODO: chips with no XIP use should ignore and return */
820 (void) map_read(map, adr); /* ensure mmu mapping is up to date */ 835 (void) map_read(map, adr); /* ensure mmu mapping is up to date */
821 preempt_disable();
822 local_irq_disable(); 836 local_irq_disable();
823} 837}
824 838
@@ -831,9 +845,8 @@ static void __xipram xip_enable(struct map_info *map, struct flchip *chip,
831 chip->state = FL_READY; 845 chip->state = FL_READY;
832 } 846 }
833 (void) map_read(map, adr); 847 (void) map_read(map, adr);
834 asm volatile (".rep 8; nop; .endr"); /* fill instruction prefetch */ 848 xip_iprefetch();
835 local_irq_enable(); 849 local_irq_enable();
836 preempt_enable();
837} 850}
838 851
839/* 852/*
@@ -909,7 +922,7 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip,
909 (void) map_read(map, adr); 922 (void) map_read(map, adr);
910 asm volatile (".rep 8; nop; .endr"); 923 asm volatile (".rep 8; nop; .endr");
911 local_irq_enable(); 924 local_irq_enable();
912 preempt_enable(); 925 spin_unlock(chip->mutex);
913 asm volatile (".rep 8; nop; .endr"); 926 asm volatile (".rep 8; nop; .endr");
914 cond_resched(); 927 cond_resched();
915 928
@@ -919,15 +932,15 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip,
919 * a suspended erase state. If so let's wait 932 * a suspended erase state. If so let's wait
920 * until it's done. 933 * until it's done.
921 */ 934 */
922 preempt_disable(); 935 spin_lock(chip->mutex);
923 while (chip->state != newstate) { 936 while (chip->state != newstate) {
924 DECLARE_WAITQUEUE(wait, current); 937 DECLARE_WAITQUEUE(wait, current);
925 set_current_state(TASK_UNINTERRUPTIBLE); 938 set_current_state(TASK_UNINTERRUPTIBLE);
926 add_wait_queue(&chip->wq, &wait); 939 add_wait_queue(&chip->wq, &wait);
927 preempt_enable(); 940 spin_unlock(chip->mutex);
928 schedule(); 941 schedule();
929 remove_wait_queue(&chip->wq, &wait); 942 remove_wait_queue(&chip->wq, &wait);
930 preempt_disable(); 943 spin_lock(chip->mutex);
931 } 944 }
932 /* Disallow XIP again */ 945 /* Disallow XIP again */
933 local_irq_disable(); 946 local_irq_disable();
@@ -956,12 +969,14 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip,
956 * The INVALIDATE_CACHED_RANGE() macro is normally used in parallel while 969 * The INVALIDATE_CACHED_RANGE() macro is normally used in parallel while
957 * the flash is actively programming or erasing since we have to poll for 970 * the flash is actively programming or erasing since we have to poll for
958 * the operation to complete anyway. We can't do that in a generic way with 971 * the operation to complete anyway. We can't do that in a generic way with
959 * a XIP setup so do it before the actual flash operation in this case. 972 * a XIP setup so do it before the actual flash operation in this case
973 * and stub it out from INVALIDATE_CACHE_UDELAY.
960 */ 974 */
961#undef INVALIDATE_CACHED_RANGE 975#define XIP_INVAL_CACHED_RANGE(map, from, size) \
962#define INVALIDATE_CACHED_RANGE(x...) 976 INVALIDATE_CACHED_RANGE(map, from, size)
963#define XIP_INVAL_CACHED_RANGE(map, from, size) \ 977
964 do { if(map->inval_cache) map->inval_cache(map, from, size); } while(0) 978#define INVALIDATE_CACHE_UDELAY(map, chip, adr, len, usec) \
979 UDELAY(map, chip, adr, usec)
965 980
966/* 981/*
967 * Extra notes: 982 * Extra notes:
@@ -984,11 +999,23 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip,
984 999
985#define xip_disable(map, chip, adr) 1000#define xip_disable(map, chip, adr)
986#define xip_enable(map, chip, adr) 1001#define xip_enable(map, chip, adr)
987
988#define UDELAY(map, chip, adr, usec) cfi_udelay(usec)
989
990#define XIP_INVAL_CACHED_RANGE(x...) 1002#define XIP_INVAL_CACHED_RANGE(x...)
991 1003
1004#define UDELAY(map, chip, adr, usec) \
1005do { \
1006 spin_unlock(chip->mutex); \
1007 cfi_udelay(usec); \
1008 spin_lock(chip->mutex); \
1009} while (0)
1010
1011#define INVALIDATE_CACHE_UDELAY(map, chip, adr, len, usec) \
1012do { \
1013 spin_unlock(chip->mutex); \
1014 INVALIDATE_CACHED_RANGE(map, adr, len); \
1015 cfi_udelay(usec); \
1016 spin_lock(chip->mutex); \
1017} while (0)
1018
992#endif 1019#endif
993 1020
994static int do_point_onechip (struct map_info *map, struct flchip *chip, loff_t adr, size_t len) 1021static int do_point_onechip (struct map_info *map, struct flchip *chip, loff_t adr, size_t len)
@@ -1176,111 +1203,11 @@ static int cfi_intelext_read (struct mtd_info *mtd, loff_t from, size_t len, siz
1176 return ret; 1203 return ret;
1177} 1204}
1178 1205
1179#if 0
1180static int __xipram cfi_intelext_read_prot_reg (struct mtd_info *mtd,
1181 loff_t from, size_t len,
1182 size_t *retlen,
1183 u_char *buf,
1184 int base_offst, int reg_sz)
1185{
1186 struct map_info *map = mtd->priv;
1187 struct cfi_private *cfi = map->fldrv_priv;
1188 struct cfi_pri_intelext *extp = cfi->cmdset_priv;
1189 struct flchip *chip;
1190 int ofs_factor = cfi->interleave * cfi->device_type;
1191 int count = len;
1192 int chip_num, offst;
1193 int ret;
1194
1195 chip_num = ((unsigned int)from/reg_sz);
1196 offst = from - (reg_sz*chip_num)+base_offst;
1197
1198 while (count) {
1199 /* Calculate which chip & protection register offset we need */
1200
1201 if (chip_num >= cfi->numchips)
1202 goto out;
1203
1204 chip = &cfi->chips[chip_num];
1205
1206 spin_lock(chip->mutex);
1207 ret = get_chip(map, chip, chip->start, FL_JEDEC_QUERY);
1208 if (ret) {
1209 spin_unlock(chip->mutex);
1210 return (len-count)?:ret;
1211 }
1212
1213 xip_disable(map, chip, chip->start);
1214
1215 if (chip->state != FL_JEDEC_QUERY) {
1216 map_write(map, CMD(0x90), chip->start);
1217 chip->state = FL_JEDEC_QUERY;
1218 }
1219
1220 while (count && ((offst-base_offst) < reg_sz)) {
1221 *buf = map_read8(map,(chip->start+((extp->ProtRegAddr+1)*ofs_factor)+offst));
1222 buf++;
1223 offst++;
1224 count--;
1225 }
1226
1227 xip_enable(map, chip, chip->start);
1228 put_chip(map, chip, chip->start);
1229 spin_unlock(chip->mutex);
1230
1231 /* Move on to the next chip */
1232 chip_num++;
1233 offst = base_offst;
1234 }
1235
1236 out:
1237 return len-count;
1238}
1239
1240static int cfi_intelext_read_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
1241{
1242 struct map_info *map = mtd->priv;
1243 struct cfi_private *cfi = map->fldrv_priv;
1244 struct cfi_pri_intelext *extp=cfi->cmdset_priv;
1245 int base_offst,reg_sz;
1246
1247 /* Check that we actually have some protection registers */
1248 if(!extp || !(extp->FeatureSupport&64)){
1249 printk(KERN_WARNING "%s: This flash device has no protection data to read!\n",map->name);
1250 return 0;
1251 }
1252
1253 base_offst=(1<<extp->FactProtRegSize);
1254 reg_sz=(1<<extp->UserProtRegSize);
1255
1256 return cfi_intelext_read_prot_reg(mtd, from, len, retlen, buf, base_offst, reg_sz);
1257}
1258
1259static int cfi_intelext_read_fact_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
1260{
1261 struct map_info *map = mtd->priv;
1262 struct cfi_private *cfi = map->fldrv_priv;
1263 struct cfi_pri_intelext *extp=cfi->cmdset_priv;
1264 int base_offst,reg_sz;
1265
1266 /* Check that we actually have some protection registers */
1267 if(!extp || !(extp->FeatureSupport&64)){
1268 printk(KERN_WARNING "%s: This flash device has no protection data to read!\n",map->name);
1269 return 0;
1270 }
1271
1272 base_offst=0;
1273 reg_sz=(1<<extp->FactProtRegSize);
1274
1275 return cfi_intelext_read_prot_reg(mtd, from, len, retlen, buf, base_offst, reg_sz);
1276}
1277#endif
1278
1279static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, 1206static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1280 unsigned long adr, map_word datum) 1207 unsigned long adr, map_word datum, int mode)
1281{ 1208{
1282 struct cfi_private *cfi = map->fldrv_priv; 1209 struct cfi_private *cfi = map->fldrv_priv;
1283 map_word status, status_OK; 1210 map_word status, status_OK, write_cmd;
1284 unsigned long timeo; 1211 unsigned long timeo;
1285 int z, ret=0; 1212 int z, ret=0;
1286 1213
@@ -1288,9 +1215,14 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1288 1215
1289 /* Let's determine this according to the interleave only once */ 1216 /* Let's determine this according to the interleave only once */
1290 status_OK = CMD(0x80); 1217 status_OK = CMD(0x80);
1218 switch (mode) {
1219 case FL_WRITING: write_cmd = CMD(0x40); break;
1220 case FL_OTP_WRITE: write_cmd = CMD(0xc0); break;
1221 default: return -EINVAL;
1222 }
1291 1223
1292 spin_lock(chip->mutex); 1224 spin_lock(chip->mutex);
1293 ret = get_chip(map, chip, adr, FL_WRITING); 1225 ret = get_chip(map, chip, adr, mode);
1294 if (ret) { 1226 if (ret) {
1295 spin_unlock(chip->mutex); 1227 spin_unlock(chip->mutex);
1296 return ret; 1228 return ret;
@@ -1299,19 +1231,18 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1299 XIP_INVAL_CACHED_RANGE(map, adr, map_bankwidth(map)); 1231 XIP_INVAL_CACHED_RANGE(map, adr, map_bankwidth(map));
1300 ENABLE_VPP(map); 1232 ENABLE_VPP(map);
1301 xip_disable(map, chip, adr); 1233 xip_disable(map, chip, adr);
1302 map_write(map, CMD(0x40), adr); 1234 map_write(map, write_cmd, adr);
1303 map_write(map, datum, adr); 1235 map_write(map, datum, adr);
1304 chip->state = FL_WRITING; 1236 chip->state = mode;
1305 1237
1306 spin_unlock(chip->mutex); 1238 INVALIDATE_CACHE_UDELAY(map, chip,
1307 INVALIDATE_CACHED_RANGE(map, adr, map_bankwidth(map)); 1239 adr, map_bankwidth(map),
1308 UDELAY(map, chip, adr, chip->word_write_time); 1240 chip->word_write_time);
1309 spin_lock(chip->mutex);
1310 1241
1311 timeo = jiffies + (HZ/2); 1242 timeo = jiffies + (HZ/2);
1312 z = 0; 1243 z = 0;
1313 for (;;) { 1244 for (;;) {
1314 if (chip->state != FL_WRITING) { 1245 if (chip->state != mode) {
1315 /* Someone's suspended the write. Sleep */ 1246 /* Someone's suspended the write. Sleep */
1316 DECLARE_WAITQUEUE(wait, current); 1247 DECLARE_WAITQUEUE(wait, current);
1317 1248
@@ -1339,10 +1270,8 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1339 } 1270 }
1340 1271
1341 /* Latency issues. Drop the lock, wait a while and retry */ 1272 /* Latency issues. Drop the lock, wait a while and retry */
1342 spin_unlock(chip->mutex);
1343 z++; 1273 z++;
1344 UDELAY(map, chip, adr, 1); 1274 UDELAY(map, chip, adr, 1);
1345 spin_lock(chip->mutex);
1346 } 1275 }
1347 if (!z) { 1276 if (!z) {
1348 chip->word_write_time--; 1277 chip->word_write_time--;
@@ -1399,7 +1328,7 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1399 datum = map_word_load_partial(map, datum, buf, gap, n); 1328 datum = map_word_load_partial(map, datum, buf, gap, n);
1400 1329
1401 ret = do_write_oneword(map, &cfi->chips[chipnum], 1330 ret = do_write_oneword(map, &cfi->chips[chipnum],
1402 bus_ofs, datum); 1331 bus_ofs, datum, FL_WRITING);
1403 if (ret) 1332 if (ret)
1404 return ret; 1333 return ret;
1405 1334
@@ -1420,7 +1349,7 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1420 map_word datum = map_word_load(map, buf); 1349 map_word datum = map_word_load(map, buf);
1421 1350
1422 ret = do_write_oneword(map, &cfi->chips[chipnum], 1351 ret = do_write_oneword(map, &cfi->chips[chipnum],
1423 ofs, datum); 1352 ofs, datum, FL_WRITING);
1424 if (ret) 1353 if (ret)
1425 return ret; 1354 return ret;
1426 1355
@@ -1444,7 +1373,7 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1444 datum = map_word_load_partial(map, datum, buf, 0, len); 1373 datum = map_word_load_partial(map, datum, buf, 0, len);
1445 1374
1446 ret = do_write_oneword(map, &cfi->chips[chipnum], 1375 ret = do_write_oneword(map, &cfi->chips[chipnum],
1447 ofs, datum); 1376 ofs, datum, FL_WRITING);
1448 if (ret) 1377 if (ret)
1449 return ret; 1378 return ret;
1450 1379
@@ -1506,9 +1435,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1506 if (map_word_andequal(map, status, status_OK, status_OK)) 1435 if (map_word_andequal(map, status, status_OK, status_OK))
1507 break; 1436 break;
1508 1437
1509 spin_unlock(chip->mutex);
1510 UDELAY(map, chip, cmd_adr, 1); 1438 UDELAY(map, chip, cmd_adr, 1);
1511 spin_lock(chip->mutex);
1512 1439
1513 if (++z > 20) { 1440 if (++z > 20) {
1514 /* Argh. Not ready for write to buffer */ 1441 /* Argh. Not ready for write to buffer */
@@ -1554,10 +1481,9 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1554 map_write(map, CMD(0xd0), cmd_adr); 1481 map_write(map, CMD(0xd0), cmd_adr);
1555 chip->state = FL_WRITING; 1482 chip->state = FL_WRITING;
1556 1483
1557 spin_unlock(chip->mutex); 1484 INVALIDATE_CACHE_UDELAY(map, chip,
1558 INVALIDATE_CACHED_RANGE(map, adr, len); 1485 cmd_adr, len,
1559 UDELAY(map, chip, cmd_adr, chip->buffer_write_time); 1486 chip->buffer_write_time);
1560 spin_lock(chip->mutex);
1561 1487
1562 timeo = jiffies + (HZ/2); 1488 timeo = jiffies + (HZ/2);
1563 z = 0; 1489 z = 0;
@@ -1589,10 +1515,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1589 } 1515 }
1590 1516
1591 /* Latency issues. Drop the lock, wait a while and retry */ 1517 /* Latency issues. Drop the lock, wait a while and retry */
1592 spin_unlock(chip->mutex);
1593 UDELAY(map, chip, cmd_adr, 1);
1594 z++; 1518 z++;
1595 spin_lock(chip->mutex); 1519 UDELAY(map, chip, cmd_adr, 1);
1596 } 1520 }
1597 if (!z) { 1521 if (!z) {
1598 chip->buffer_write_time--; 1522 chip->buffer_write_time--;
@@ -1720,10 +1644,9 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1720 chip->state = FL_ERASING; 1644 chip->state = FL_ERASING;
1721 chip->erase_suspended = 0; 1645 chip->erase_suspended = 0;
1722 1646
1723 spin_unlock(chip->mutex); 1647 INVALIDATE_CACHE_UDELAY(map, chip,
1724 INVALIDATE_CACHED_RANGE(map, adr, len); 1648 adr, len,
1725 UDELAY(map, chip, adr, chip->erase_time*1000/2); 1649 chip->erase_time*1000/2);
1726 spin_lock(chip->mutex);
1727 1650
1728 /* FIXME. Use a timer to check this, and return immediately. */ 1651 /* FIXME. Use a timer to check this, and return immediately. */
1729 /* Once the state machine's known to be working I'll do that */ 1652 /* Once the state machine's known to be working I'll do that */
@@ -1768,9 +1691,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1768 } 1691 }
1769 1692
1770 /* Latency issues. Drop the lock, wait a while and retry */ 1693 /* Latency issues. Drop the lock, wait a while and retry */
1771 spin_unlock(chip->mutex);
1772 UDELAY(map, chip, adr, 1000000/HZ); 1694 UDELAY(map, chip, adr, 1000000/HZ);
1773 spin_lock(chip->mutex);
1774 } 1695 }
1775 1696
1776 /* We've broken this before. It doesn't hurt to be safe */ 1697 /* We've broken this before. It doesn't hurt to be safe */
@@ -1780,44 +1701,34 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1780 1701
1781 /* check for lock bit */ 1702 /* check for lock bit */
1782 if (map_word_bitsset(map, status, CMD(0x3a))) { 1703 if (map_word_bitsset(map, status, CMD(0x3a))) {
1783 unsigned char chipstatus; 1704 unsigned long chipstatus;
1784 1705
1785 /* Reset the error bits */ 1706 /* Reset the error bits */
1786 map_write(map, CMD(0x50), adr); 1707 map_write(map, CMD(0x50), adr);
1787 map_write(map, CMD(0x70), adr); 1708 map_write(map, CMD(0x70), adr);
1788 xip_enable(map, chip, adr); 1709 xip_enable(map, chip, adr);
1789 1710
1790 chipstatus = status.x[0]; 1711 chipstatus = MERGESTATUS(status);
1791 if (!map_word_equal(map, status, CMD(chipstatus))) {
1792 int i, w;
1793 for (w=0; w<map_words(map); w++) {
1794 for (i = 0; i<cfi_interleave(cfi); i++) {
1795 chipstatus |= status.x[w] >> (cfi->device_type * 8);
1796 }
1797 }
1798 printk(KERN_WARNING "Status is not identical for all chips: 0x%lx. Merging to give 0x%02x\n",
1799 status.x[0], chipstatus);
1800 }
1801 1712
1802 if ((chipstatus & 0x30) == 0x30) { 1713 if ((chipstatus & 0x30) == 0x30) {
1803 printk(KERN_NOTICE "Chip reports improper command sequence: status 0x%x\n", chipstatus); 1714 printk(KERN_NOTICE "Chip reports improper command sequence: status 0x%lx\n", chipstatus);
1804 ret = -EIO; 1715 ret = -EIO;
1805 } else if (chipstatus & 0x02) { 1716 } else if (chipstatus & 0x02) {
1806 /* Protection bit set */ 1717 /* Protection bit set */
1807 ret = -EROFS; 1718 ret = -EROFS;
1808 } else if (chipstatus & 0x8) { 1719 } else if (chipstatus & 0x8) {
1809 /* Voltage */ 1720 /* Voltage */
1810 printk(KERN_WARNING "Chip reports voltage low on erase: status 0x%x\n", chipstatus); 1721 printk(KERN_WARNING "Chip reports voltage low on erase: status 0x%lx\n", chipstatus);
1811 ret = -EIO; 1722 ret = -EIO;
1812 } else if (chipstatus & 0x20) { 1723 } else if (chipstatus & 0x20) {
1813 if (retries--) { 1724 if (retries--) {
1814 printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%x. Retrying...\n", adr, chipstatus); 1725 printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%lx. Retrying...\n", adr, chipstatus);
1815 timeo = jiffies + HZ; 1726 timeo = jiffies + HZ;
1816 put_chip(map, chip, adr); 1727 put_chip(map, chip, adr);
1817 spin_unlock(chip->mutex); 1728 spin_unlock(chip->mutex);
1818 goto retry; 1729 goto retry;
1819 } 1730 }
1820 printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%x\n", adr, chipstatus); 1731 printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%lx\n", adr, chipstatus);
1821 ret = -EIO; 1732 ret = -EIO;
1822 } 1733 }
1823 } else { 1734 } else {
@@ -1882,6 +1793,7 @@ static void cfi_intelext_sync (struct mtd_info *mtd)
1882 1793
1883 if (chip->state == FL_SYNCING) { 1794 if (chip->state == FL_SYNCING) {
1884 chip->state = chip->oldstate; 1795 chip->state = chip->oldstate;
1796 chip->oldstate = FL_READY;
1885 wake_up(&chip->wq); 1797 wake_up(&chip->wq);
1886 } 1798 }
1887 spin_unlock(chip->mutex); 1799 spin_unlock(chip->mutex);
@@ -1897,8 +1809,9 @@ static int __xipram do_printlockstatus_oneblock(struct map_info *map,
1897 struct cfi_private *cfi = map->fldrv_priv; 1809 struct cfi_private *cfi = map->fldrv_priv;
1898 int status, ofs_factor = cfi->interleave * cfi->device_type; 1810 int status, ofs_factor = cfi->interleave * cfi->device_type;
1899 1811
1812 adr += chip->start;
1900 xip_disable(map, chip, adr+(2*ofs_factor)); 1813 xip_disable(map, chip, adr+(2*ofs_factor));
1901 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); 1814 map_write(map, CMD(0x90), adr+(2*ofs_factor));
1902 chip->state = FL_JEDEC_QUERY; 1815 chip->state = FL_JEDEC_QUERY;
1903 status = cfi_read_query(map, adr+(2*ofs_factor)); 1816 status = cfi_read_query(map, adr+(2*ofs_factor));
1904 xip_enable(map, chip, 0); 1817 xip_enable(map, chip, 0);
@@ -1915,6 +1828,7 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
1915 unsigned long adr, int len, void *thunk) 1828 unsigned long adr, int len, void *thunk)
1916{ 1829{
1917 struct cfi_private *cfi = map->fldrv_priv; 1830 struct cfi_private *cfi = map->fldrv_priv;
1831 struct cfi_pri_intelext *extp = cfi->cmdset_priv;
1918 map_word status, status_OK; 1832 map_word status, status_OK;
1919 unsigned long timeo = jiffies + HZ; 1833 unsigned long timeo = jiffies + HZ;
1920 int ret; 1834 int ret;
@@ -1944,9 +1858,13 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
1944 } else 1858 } else
1945 BUG(); 1859 BUG();
1946 1860
1947 spin_unlock(chip->mutex); 1861 /*
1948 UDELAY(map, chip, adr, 1000000/HZ); 1862 * If Instant Individual Block Locking supported then no need
1949 spin_lock(chip->mutex); 1863 * to delay.
1864 */
1865
1866 if (!extp || !(extp->FeatureSupport & (1 << 5)))
1867 UDELAY(map, chip, adr, 1000000/HZ);
1950 1868
1951 /* FIXME. Use a timer to check this, and return immediately. */ 1869 /* FIXME. Use a timer to check this, and return immediately. */
1952 /* Once the state machine's known to be working I'll do that */ 1870 /* Once the state machine's known to be working I'll do that */
@@ -1973,9 +1891,7 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
1973 } 1891 }
1974 1892
1975 /* Latency issues. Drop the lock, wait a while and retry */ 1893 /* Latency issues. Drop the lock, wait a while and retry */
1976 spin_unlock(chip->mutex);
1977 UDELAY(map, chip, adr, 1); 1894 UDELAY(map, chip, adr, 1);
1978 spin_lock(chip->mutex);
1979 } 1895 }
1980 1896
1981 /* Done and happy. */ 1897 /* Done and happy. */
@@ -2034,6 +1950,274 @@ static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
2034 return ret; 1950 return ret;
2035} 1951}
2036 1952
1953#ifdef CONFIG_MTD_OTP
1954
1955typedef int (*otp_op_t)(struct map_info *map, struct flchip *chip,
1956 u_long data_offset, u_char *buf, u_int size,
1957 u_long prot_offset, u_int groupno, u_int groupsize);
1958
1959static int __xipram
1960do_otp_read(struct map_info *map, struct flchip *chip, u_long offset,
1961 u_char *buf, u_int size, u_long prot, u_int grpno, u_int grpsz)
1962{
1963 struct cfi_private *cfi = map->fldrv_priv;
1964 int ret;
1965
1966 spin_lock(chip->mutex);
1967 ret = get_chip(map, chip, chip->start, FL_JEDEC_QUERY);
1968 if (ret) {
1969 spin_unlock(chip->mutex);
1970 return ret;
1971 }
1972
1973 /* let's ensure we're not reading back cached data from array mode */
1974 INVALIDATE_CACHED_RANGE(map, chip->start + offset, size);
1975
1976 xip_disable(map, chip, chip->start);
1977 if (chip->state != FL_JEDEC_QUERY) {
1978 map_write(map, CMD(0x90), chip->start);
1979 chip->state = FL_JEDEC_QUERY;
1980 }
1981 map_copy_from(map, buf, chip->start + offset, size);
1982 xip_enable(map, chip, chip->start);
1983
1984 /* then ensure we don't keep OTP data in the cache */
1985 INVALIDATE_CACHED_RANGE(map, chip->start + offset, size);
1986
1987 put_chip(map, chip, chip->start);
1988 spin_unlock(chip->mutex);
1989 return 0;
1990}
1991
1992static int
1993do_otp_write(struct map_info *map, struct flchip *chip, u_long offset,
1994 u_char *buf, u_int size, u_long prot, u_int grpno, u_int grpsz)
1995{
1996 int ret;
1997
1998 while (size) {
1999 unsigned long bus_ofs = offset & ~(map_bankwidth(map)-1);
2000 int gap = offset - bus_ofs;
2001 int n = min_t(int, size, map_bankwidth(map)-gap);
2002 map_word datum = map_word_ff(map);
2003
2004 datum = map_word_load_partial(map, datum, buf, gap, n);
2005 ret = do_write_oneword(map, chip, bus_ofs, datum, FL_OTP_WRITE);
2006 if (ret)
2007 return ret;
2008
2009 offset += n;
2010 buf += n;
2011 size -= n;
2012 }
2013
2014 return 0;
2015}
2016
2017static int
2018do_otp_lock(struct map_info *map, struct flchip *chip, u_long offset,
2019 u_char *buf, u_int size, u_long prot, u_int grpno, u_int grpsz)
2020{
2021 struct cfi_private *cfi = map->fldrv_priv;
2022 map_word datum;
2023
2024 /* make sure area matches group boundaries */
2025 if (size != grpsz)
2026 return -EXDEV;
2027
2028 datum = map_word_ff(map);
2029 datum = map_word_clr(map, datum, CMD(1 << grpno));
2030 return do_write_oneword(map, chip, prot, datum, FL_OTP_WRITE);
2031}
2032
2033static int cfi_intelext_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
2034 size_t *retlen, u_char *buf,
2035 otp_op_t action, int user_regs)
2036{
2037 struct map_info *map = mtd->priv;
2038 struct cfi_private *cfi = map->fldrv_priv;
2039 struct cfi_pri_intelext *extp = cfi->cmdset_priv;
2040 struct flchip *chip;
2041 struct cfi_intelext_otpinfo *otp;
2042 u_long devsize, reg_prot_offset, data_offset;
2043 u_int chip_num, chip_step, field, reg_fact_size, reg_user_size;
2044 u_int groups, groupno, groupsize, reg_fact_groups, reg_user_groups;
2045 int ret;
2046
2047 *retlen = 0;
2048
2049 /* Check that we actually have some OTP registers */
2050 if (!extp || !(extp->FeatureSupport & 64) || !extp->NumProtectionFields)
2051 return -ENODATA;
2052
2053 /* we need real chips here not virtual ones */
2054 devsize = (1 << cfi->cfiq->DevSize) * cfi->interleave;
2055 chip_step = devsize >> cfi->chipshift;
2056 chip_num = 0;
2057
2058 /* Some chips have OTP located in the _top_ partition only.
2059 For example: Intel 28F256L18T (T means top-parameter device) */
2060 if (cfi->mfr == MANUFACTURER_INTEL) {
2061 switch (cfi->id) {
2062 case 0x880b:
2063 case 0x880c:
2064 case 0x880d:
2065 chip_num = chip_step - 1;
2066 }
2067 }
2068
2069 for ( ; chip_num < cfi->numchips; chip_num += chip_step) {
2070 chip = &cfi->chips[chip_num];
2071 otp = (struct cfi_intelext_otpinfo *)&extp->extra[0];
2072
2073 /* first OTP region */
2074 field = 0;
2075 reg_prot_offset = extp->ProtRegAddr;
2076 reg_fact_groups = 1;
2077 reg_fact_size = 1 << extp->FactProtRegSize;
2078 reg_user_groups = 1;
2079 reg_user_size = 1 << extp->UserProtRegSize;
2080
2081 while (len > 0) {
2082 /* flash geometry fixup */
2083 data_offset = reg_prot_offset + 1;
2084 data_offset *= cfi->interleave * cfi->device_type;
2085 reg_prot_offset *= cfi->interleave * cfi->device_type;
2086 reg_fact_size *= cfi->interleave;
2087 reg_user_size *= cfi->interleave;
2088
2089 if (user_regs) {
2090 groups = reg_user_groups;
2091 groupsize = reg_user_size;
2092 /* skip over factory reg area */
2093 groupno = reg_fact_groups;
2094 data_offset += reg_fact_groups * reg_fact_size;
2095 } else {
2096 groups = reg_fact_groups;
2097 groupsize = reg_fact_size;
2098 groupno = 0;
2099 }
2100
2101 while (len > 0 && groups > 0) {
2102 if (!action) {
2103 /*
2104 * Special case: if action is NULL
2105 * we fill buf with otp_info records.
2106 */
2107 struct otp_info *otpinfo;
2108 map_word lockword;
2109 len -= sizeof(struct otp_info);
2110 if (len <= 0)
2111 return -ENOSPC;
2112 ret = do_otp_read(map, chip,
2113 reg_prot_offset,
2114 (u_char *)&lockword,
2115 map_bankwidth(map),
2116 0, 0, 0);
2117 if (ret)
2118 return ret;
2119 otpinfo = (struct otp_info *)buf;
2120 otpinfo->start = from;
2121 otpinfo->length = groupsize;
2122 otpinfo->locked =
2123 !map_word_bitsset(map, lockword,
2124 CMD(1 << groupno));
2125 from += groupsize;
2126 buf += sizeof(*otpinfo);
2127 *retlen += sizeof(*otpinfo);
2128 } else if (from >= groupsize) {
2129 from -= groupsize;
2130 data_offset += groupsize;
2131 } else {
2132 int size = groupsize;
2133 data_offset += from;
2134 size -= from;
2135 from = 0;
2136 if (size > len)
2137 size = len;
2138 ret = action(map, chip, data_offset,
2139 buf, size, reg_prot_offset,
2140 groupno, groupsize);
2141 if (ret < 0)
2142 return ret;
2143 buf += size;
2144 len -= size;
2145 *retlen += size;
2146 data_offset += size;
2147 }
2148 groupno++;
2149 groups--;
2150 }
2151
2152 /* next OTP region */
2153 if (++field == extp->NumProtectionFields)
2154 break;
2155 reg_prot_offset = otp->ProtRegAddr;
2156 reg_fact_groups = otp->FactGroups;
2157 reg_fact_size = 1 << otp->FactProtRegSize;
2158 reg_user_groups = otp->UserGroups;
2159 reg_user_size = 1 << otp->UserProtRegSize;
2160 otp++;
2161 }
2162 }
2163
2164 return 0;
2165}
2166
2167static int cfi_intelext_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
2168 size_t len, size_t *retlen,
2169 u_char *buf)
2170{
2171 return cfi_intelext_otp_walk(mtd, from, len, retlen,
2172 buf, do_otp_read, 0);
2173}
2174
2175static int cfi_intelext_read_user_prot_reg(struct mtd_info *mtd, loff_t from,
2176 size_t len, size_t *retlen,
2177 u_char *buf)
2178{
2179 return cfi_intelext_otp_walk(mtd, from, len, retlen,
2180 buf, do_otp_read, 1);
2181}
2182
2183static int cfi_intelext_write_user_prot_reg(struct mtd_info *mtd, loff_t from,
2184 size_t len, size_t *retlen,
2185 u_char *buf)
2186{
2187 return cfi_intelext_otp_walk(mtd, from, len, retlen,
2188 buf, do_otp_write, 1);
2189}
2190
2191static int cfi_intelext_lock_user_prot_reg(struct mtd_info *mtd,
2192 loff_t from, size_t len)
2193{
2194 size_t retlen;
2195 return cfi_intelext_otp_walk(mtd, from, len, &retlen,
2196 NULL, do_otp_lock, 1);
2197}
2198
2199static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd,
2200 struct otp_info *buf, size_t len)
2201{
2202 size_t retlen;
2203 int ret;
2204
2205 ret = cfi_intelext_otp_walk(mtd, 0, len, &retlen, (u_char *)buf, NULL, 0);
2206 return ret ? : retlen;
2207}
2208
2209static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd,
2210 struct otp_info *buf, size_t len)
2211{
2212 size_t retlen;
2213 int ret;
2214
2215 ret = cfi_intelext_otp_walk(mtd, 0, len, &retlen, (u_char *)buf, NULL, 1);
2216 return ret ? : retlen;
2217}
2218
2219#endif
2220
2037static int cfi_intelext_suspend(struct mtd_info *mtd) 2221static int cfi_intelext_suspend(struct mtd_info *mtd)
2038{ 2222{
2039 struct map_info *map = mtd->priv; 2223 struct map_info *map = mtd->priv;
@@ -2125,10 +2309,46 @@ static void cfi_intelext_resume(struct mtd_info *mtd)
2125 } 2309 }
2126} 2310}
2127 2311
2312static int cfi_intelext_reset(struct mtd_info *mtd)
2313{
2314 struct map_info *map = mtd->priv;
2315 struct cfi_private *cfi = map->fldrv_priv;
2316 int i, ret;
2317
2318 for (i=0; i < cfi->numchips; i++) {
2319 struct flchip *chip = &cfi->chips[i];
2320
2321 /* force the completion of any ongoing operation
2322 and switch to array mode so any bootloader in
2323 flash is accessible for soft reboot. */
2324 spin_lock(chip->mutex);
2325 ret = get_chip(map, chip, chip->start, FL_SYNCING);
2326 if (!ret) {
2327 map_write(map, CMD(0xff), chip->start);
2328 chip->state = FL_READY;
2329 }
2330 spin_unlock(chip->mutex);
2331 }
2332
2333 return 0;
2334}
2335
2336static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val,
2337 void *v)
2338{
2339 struct mtd_info *mtd;
2340
2341 mtd = container_of(nb, struct mtd_info, reboot_notifier);
2342 cfi_intelext_reset(mtd);
2343 return NOTIFY_DONE;
2344}
2345
2128static void cfi_intelext_destroy(struct mtd_info *mtd) 2346static void cfi_intelext_destroy(struct mtd_info *mtd)
2129{ 2347{
2130 struct map_info *map = mtd->priv; 2348 struct map_info *map = mtd->priv;
2131 struct cfi_private *cfi = map->fldrv_priv; 2349 struct cfi_private *cfi = map->fldrv_priv;
2350 cfi_intelext_reset(mtd);
2351 unregister_reboot_notifier(&mtd->reboot_notifier);
2132 kfree(cfi->cmdset_priv); 2352 kfree(cfi->cmdset_priv);
2133 kfree(cfi->cfiq); 2353 kfree(cfi->cfiq);
2134 kfree(cfi->chips[0].priv); 2354 kfree(cfi->chips[0].priv);
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index fca8ff6f7e14..8505f118f2db 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -4,16 +4,20 @@
4 * 4 *
5 * Copyright (C) 2000 Crossnet Co. <info@crossnet.co.jp> 5 * Copyright (C) 2000 Crossnet Co. <info@crossnet.co.jp>
6 * Copyright (C) 2004 Arcom Control Systems Ltd <linux@arcom.com> 6 * Copyright (C) 2004 Arcom Control Systems Ltd <linux@arcom.com>
7 * Copyright (C) 2005 MontaVista Software Inc. <source@mvista.com>
7 * 8 *
8 * 2_by_8 routines added by Simon Munton 9 * 2_by_8 routines added by Simon Munton
9 * 10 *
10 * 4_by_16 work by Carolyn J. Smith 11 * 4_by_16 work by Carolyn J. Smith
11 * 12 *
13 * XIP support hooks by Vitaly Wool (based on code for Intel flash
14 * by Nicolas Pitre)
15 *
12 * Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com 16 * Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com
13 * 17 *
14 * This code is GPL 18 * This code is GPL
15 * 19 *
16 * $Id: cfi_cmdset_0002.c,v 1.114 2004/12/11 15:43:53 dedekind Exp $ 20 * $Id: cfi_cmdset_0002.c,v 1.118 2005/07/04 22:34:29 gleixner Exp $
17 * 21 *
18 */ 22 */
19 23
@@ -34,6 +38,7 @@
34#include <linux/mtd/map.h> 38#include <linux/mtd/map.h>
35#include <linux/mtd/mtd.h> 39#include <linux/mtd/mtd.h>
36#include <linux/mtd/cfi.h> 40#include <linux/mtd/cfi.h>
41#include <linux/mtd/xip.h>
37 42
38#define AMD_BOOTLOC_BUG 43#define AMD_BOOTLOC_BUG
39#define FORCE_WORD_WRITE 0 44#define FORCE_WORD_WRITE 0
@@ -43,6 +48,7 @@
43#define MANUFACTURER_AMD 0x0001 48#define MANUFACTURER_AMD 0x0001
44#define MANUFACTURER_SST 0x00BF 49#define MANUFACTURER_SST 0x00BF
45#define SST49LF004B 0x0060 50#define SST49LF004B 0x0060
51#define SST49LF008A 0x005a
46 52
47static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); 53static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
48static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); 54static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
@@ -191,6 +197,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
191}; 197};
192static struct cfi_fixup jedec_fixup_table[] = { 198static struct cfi_fixup jedec_fixup_table[] = {
193 { MANUFACTURER_SST, SST49LF004B, fixup_use_fwh_lock, NULL, }, 199 { MANUFACTURER_SST, SST49LF004B, fixup_use_fwh_lock, NULL, },
200 { MANUFACTURER_SST, SST49LF008A, fixup_use_fwh_lock, NULL, },
194 { 0, 0, NULL, NULL } 201 { 0, 0, NULL, NULL }
195}; 202};
196 203
@@ -391,7 +398,7 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
391 * correctly and is therefore not done (particulary with interleaved chips 398 * correctly and is therefore not done (particulary with interleaved chips
392 * as each chip must be checked independantly of the others). 399 * as each chip must be checked independantly of the others).
393 */ 400 */
394static int chip_ready(struct map_info *map, unsigned long addr) 401static int __xipram chip_ready(struct map_info *map, unsigned long addr)
395{ 402{
396 map_word d, t; 403 map_word d, t;
397 404
@@ -401,6 +408,32 @@ static int chip_ready(struct map_info *map, unsigned long addr)
401 return map_word_equal(map, d, t); 408 return map_word_equal(map, d, t);
402} 409}
403 410
411/*
412 * Return true if the chip is ready and has the correct value.
413 *
414 * Ready is one of: read mode, query mode, erase-suspend-read mode (in any
415 * non-suspended sector) and it is indicated by no bits toggling.
416 *
417 * Error are indicated by toggling bits or bits held with the wrong value,
418 * or with bits toggling.
419 *
420 * Note that anything more complicated than checking if no bits are toggling
421 * (including checking DQ5 for an error status) is tricky to get working
422 * correctly and is therefore not done (particulary with interleaved chips
423 * as each chip must be checked independantly of the others).
424 *
425 */
426static int __xipram chip_good(struct map_info *map, unsigned long addr, map_word expected)
427{
428 map_word oldd, curd;
429
430 oldd = map_read(map, addr);
431 curd = map_read(map, addr);
432
433 return map_word_equal(map, oldd, curd) &&
434 map_word_equal(map, curd, expected);
435}
436
404static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode) 437static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode)
405{ 438{
406 DECLARE_WAITQUEUE(wait, current); 439 DECLARE_WAITQUEUE(wait, current);
@@ -420,12 +453,12 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
420 453
421 if (time_after(jiffies, timeo)) { 454 if (time_after(jiffies, timeo)) {
422 printk(KERN_ERR "Waiting for chip to be ready timed out.\n"); 455 printk(KERN_ERR "Waiting for chip to be ready timed out.\n");
423 cfi_spin_unlock(chip->mutex); 456 spin_unlock(chip->mutex);
424 return -EIO; 457 return -EIO;
425 } 458 }
426 cfi_spin_unlock(chip->mutex); 459 spin_unlock(chip->mutex);
427 cfi_udelay(1); 460 cfi_udelay(1);
428 cfi_spin_lock(chip->mutex); 461 spin_lock(chip->mutex);
429 /* Someone else might have been playing with it. */ 462 /* Someone else might have been playing with it. */
430 goto retry; 463 goto retry;
431 } 464 }
@@ -473,15 +506,23 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
473 return -EIO; 506 return -EIO;
474 } 507 }
475 508
476 cfi_spin_unlock(chip->mutex); 509 spin_unlock(chip->mutex);
477 cfi_udelay(1); 510 cfi_udelay(1);
478 cfi_spin_lock(chip->mutex); 511 spin_lock(chip->mutex);
479 /* Nobody will touch it while it's in state FL_ERASE_SUSPENDING. 512 /* Nobody will touch it while it's in state FL_ERASE_SUSPENDING.
480 So we can just loop here. */ 513 So we can just loop here. */
481 } 514 }
482 chip->state = FL_READY; 515 chip->state = FL_READY;
483 return 0; 516 return 0;
484 517
518 case FL_XIP_WHILE_ERASING:
519 if (mode != FL_READY && mode != FL_POINT &&
520 (!cfip || !(cfip->EraseSuspend&2)))
521 goto sleep;
522 chip->oldstate = chip->state;
523 chip->state = FL_READY;
524 return 0;
525
485 case FL_POINT: 526 case FL_POINT:
486 /* Only if there's no operation suspended... */ 527 /* Only if there's no operation suspended... */
487 if (mode == FL_READY && chip->oldstate == FL_READY) 528 if (mode == FL_READY && chip->oldstate == FL_READY)
@@ -491,10 +532,10 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
491 sleep: 532 sleep:
492 set_current_state(TASK_UNINTERRUPTIBLE); 533 set_current_state(TASK_UNINTERRUPTIBLE);
493 add_wait_queue(&chip->wq, &wait); 534 add_wait_queue(&chip->wq, &wait);
494 cfi_spin_unlock(chip->mutex); 535 spin_unlock(chip->mutex);
495 schedule(); 536 schedule();
496 remove_wait_queue(&chip->wq, &wait); 537 remove_wait_queue(&chip->wq, &wait);
497 cfi_spin_lock(chip->mutex); 538 spin_lock(chip->mutex);
498 goto resettime; 539 goto resettime;
499 } 540 }
500} 541}
@@ -512,6 +553,11 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
512 chip->state = FL_ERASING; 553 chip->state = FL_ERASING;
513 break; 554 break;
514 555
556 case FL_XIP_WHILE_ERASING:
557 chip->state = chip->oldstate;
558 chip->oldstate = FL_READY;
559 break;
560
515 case FL_READY: 561 case FL_READY:
516 case FL_STATUS: 562 case FL_STATUS:
517 /* We should really make set_vpp() count, rather than doing this */ 563 /* We should really make set_vpp() count, rather than doing this */
@@ -523,6 +569,198 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
523 wake_up(&chip->wq); 569 wake_up(&chip->wq);
524} 570}
525 571
572#ifdef CONFIG_MTD_XIP
573
574/*
575 * No interrupt what so ever can be serviced while the flash isn't in array
576 * mode. This is ensured by the xip_disable() and xip_enable() functions
577 * enclosing any code path where the flash is known not to be in array mode.
578 * And within a XIP disabled code path, only functions marked with __xipram
579 * may be called and nothing else (it's a good thing to inspect generated
580 * assembly to make sure inline functions were actually inlined and that gcc
581 * didn't emit calls to its own support functions). Also configuring MTD CFI
582 * support to a single buswidth and a single interleave is also recommended.
583 */
584
585static void xip_disable(struct map_info *map, struct flchip *chip,
586 unsigned long adr)
587{
588 /* TODO: chips with no XIP use should ignore and return */
589 (void) map_read(map, adr); /* ensure mmu mapping is up to date */
590 local_irq_disable();
591}
592
593static void __xipram xip_enable(struct map_info *map, struct flchip *chip,
594 unsigned long adr)
595{
596 struct cfi_private *cfi = map->fldrv_priv;
597
598 if (chip->state != FL_POINT && chip->state != FL_READY) {
599 map_write(map, CMD(0xf0), adr);
600 chip->state = FL_READY;
601 }
602 (void) map_read(map, adr);
603 xip_iprefetch();
604 local_irq_enable();
605}
606
607/*
608 * When a delay is required for the flash operation to complete, the
609 * xip_udelay() function is polling for both the given timeout and pending
610 * (but still masked) hardware interrupts. Whenever there is an interrupt
611 * pending then the flash erase operation is suspended, array mode restored
612 * and interrupts unmasked. Task scheduling might also happen at that
613 * point. The CPU eventually returns from the interrupt or the call to
614 * schedule() and the suspended flash operation is resumed for the remaining
615 * of the delay period.
616 *
617 * Warning: this function _will_ fool interrupt latency tracing tools.
618 */
619
620static void __xipram xip_udelay(struct map_info *map, struct flchip *chip,
621 unsigned long adr, int usec)
622{
623 struct cfi_private *cfi = map->fldrv_priv;
624 struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
625 map_word status, OK = CMD(0x80);
626 unsigned long suspended, start = xip_currtime();
627 flstate_t oldstate;
628
629 do {
630 cpu_relax();
631 if (xip_irqpending() && extp &&
632 ((chip->state == FL_ERASING && (extp->EraseSuspend & 2))) &&
633 (cfi_interleave_is_1(cfi) || chip->oldstate == FL_READY)) {
634 /*
635 * Let's suspend the erase operation when supported.
636 * Note that we currently don't try to suspend
637 * interleaved chips if there is already another
638 * operation suspended (imagine what happens
639 * when one chip was already done with the current
640 * operation while another chip suspended it, then
641 * we resume the whole thing at once). Yes, it
642 * can happen!
643 */
644 map_write(map, CMD(0xb0), adr);
645 usec -= xip_elapsed_since(start);
646 suspended = xip_currtime();
647 do {
648 if (xip_elapsed_since(suspended) > 100000) {
649 /*
650 * The chip doesn't want to suspend
651 * after waiting for 100 msecs.
652 * This is a critical error but there
653 * is not much we can do here.
654 */
655 return;
656 }
657 status = map_read(map, adr);
658 } while (!map_word_andequal(map, status, OK, OK));
659
660 /* Suspend succeeded */
661 oldstate = chip->state;
662 if (!map_word_bitsset(map, status, CMD(0x40)))
663 break;
664 chip->state = FL_XIP_WHILE_ERASING;
665 chip->erase_suspended = 1;
666 map_write(map, CMD(0xf0), adr);
667 (void) map_read(map, adr);
668 asm volatile (".rep 8; nop; .endr");
669 local_irq_enable();
670 spin_unlock(chip->mutex);
671 asm volatile (".rep 8; nop; .endr");
672 cond_resched();
673
674 /*
675 * We're back. However someone else might have
676 * decided to go write to the chip if we are in
677 * a suspended erase state. If so let's wait
678 * until it's done.
679 */
680 spin_lock(chip->mutex);
681 while (chip->state != FL_XIP_WHILE_ERASING) {
682 DECLARE_WAITQUEUE(wait, current);
683 set_current_state(TASK_UNINTERRUPTIBLE);
684 add_wait_queue(&chip->wq, &wait);
685 spin_unlock(chip->mutex);
686 schedule();
687 remove_wait_queue(&chip->wq, &wait);
688 spin_lock(chip->mutex);
689 }
690 /* Disallow XIP again */
691 local_irq_disable();
692
693 /* Resume the write or erase operation */
694 map_write(map, CMD(0x30), adr);
695 chip->state = oldstate;
696 start = xip_currtime();
697 } else if (usec >= 1000000/HZ) {
698 /*
699 * Try to save on CPU power when waiting delay
700 * is at least a system timer tick period.
701 * No need to be extremely accurate here.
702 */
703 xip_cpu_idle();
704 }
705 status = map_read(map, adr);
706 } while (!map_word_andequal(map, status, OK, OK)
707 && xip_elapsed_since(start) < usec);
708}
709
710#define UDELAY(map, chip, adr, usec) xip_udelay(map, chip, adr, usec)
711
712/*
713 * The INVALIDATE_CACHED_RANGE() macro is normally used in parallel while
714 * the flash is actively programming or erasing since we have to poll for
715 * the operation to complete anyway. We can't do that in a generic way with
716 * a XIP setup so do it before the actual flash operation in this case
717 * and stub it out from INVALIDATE_CACHE_UDELAY.
718 */
719#define XIP_INVAL_CACHED_RANGE(map, from, size) \
720 INVALIDATE_CACHED_RANGE(map, from, size)
721
722#define INVALIDATE_CACHE_UDELAY(map, chip, adr, len, usec) \
723 UDELAY(map, chip, adr, usec)
724
725/*
726 * Extra notes:
727 *
728 * Activating this XIP support changes the way the code works a bit. For
729 * example the code to suspend the current process when concurrent access
730 * happens is never executed because xip_udelay() will always return with the
731 * same chip state as it was entered with. This is why there is no care for
732 * the presence of add_wait_queue() or schedule() calls from within a couple
733 * xip_disable()'d areas of code, like in do_erase_oneblock for example.
734 * The queueing and scheduling are always happening within xip_udelay().
735 *
736 * Similarly, get_chip() and put_chip() just happen to always be executed
737 * with chip->state set to FL_READY (or FL_XIP_WHILE_*) where flash state
738 * is in array mode, therefore never executing many cases therein and not
739 * causing any problem with XIP.
740 */
741
742#else
743
744#define xip_disable(map, chip, adr)
745#define xip_enable(map, chip, adr)
746#define XIP_INVAL_CACHED_RANGE(x...)
747
748#define UDELAY(map, chip, adr, usec) \
749do { \
750 spin_unlock(chip->mutex); \
751 cfi_udelay(usec); \
752 spin_lock(chip->mutex); \
753} while (0)
754
755#define INVALIDATE_CACHE_UDELAY(map, chip, adr, len, usec) \
756do { \
757 spin_unlock(chip->mutex); \
758 INVALIDATE_CACHED_RANGE(map, adr, len); \
759 cfi_udelay(usec); \
760 spin_lock(chip->mutex); \
761} while (0)
762
763#endif
526 764
527static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf) 765static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf)
528{ 766{
@@ -535,10 +773,10 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
535 /* Ensure cmd read/writes are aligned. */ 773 /* Ensure cmd read/writes are aligned. */
536 cmd_addr = adr & ~(map_bankwidth(map)-1); 774 cmd_addr = adr & ~(map_bankwidth(map)-1);
537 775
538 cfi_spin_lock(chip->mutex); 776 spin_lock(chip->mutex);
539 ret = get_chip(map, chip, cmd_addr, FL_READY); 777 ret = get_chip(map, chip, cmd_addr, FL_READY);
540 if (ret) { 778 if (ret) {
541 cfi_spin_unlock(chip->mutex); 779 spin_unlock(chip->mutex);
542 return ret; 780 return ret;
543 } 781 }
544 782
@@ -551,7 +789,7 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
551 789
552 put_chip(map, chip, cmd_addr); 790 put_chip(map, chip, cmd_addr);
553 791
554 cfi_spin_unlock(chip->mutex); 792 spin_unlock(chip->mutex);
555 return 0; 793 return 0;
556} 794}
557 795
@@ -605,7 +843,7 @@ static inline int do_read_secsi_onechip(struct map_info *map, struct flchip *chi
605 struct cfi_private *cfi = map->fldrv_priv; 843 struct cfi_private *cfi = map->fldrv_priv;
606 844
607 retry: 845 retry:
608 cfi_spin_lock(chip->mutex); 846 spin_lock(chip->mutex);
609 847
610 if (chip->state != FL_READY){ 848 if (chip->state != FL_READY){
611#if 0 849#if 0
@@ -614,7 +852,7 @@ static inline int do_read_secsi_onechip(struct map_info *map, struct flchip *chi
614 set_current_state(TASK_UNINTERRUPTIBLE); 852 set_current_state(TASK_UNINTERRUPTIBLE);
615 add_wait_queue(&chip->wq, &wait); 853 add_wait_queue(&chip->wq, &wait);
616 854
617 cfi_spin_unlock(chip->mutex); 855 spin_unlock(chip->mutex);
618 856
619 schedule(); 857 schedule();
620 remove_wait_queue(&chip->wq, &wait); 858 remove_wait_queue(&chip->wq, &wait);
@@ -643,7 +881,7 @@ static inline int do_read_secsi_onechip(struct map_info *map, struct flchip *chi
643 cfi_send_gen_cmd(0x00, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 881 cfi_send_gen_cmd(0x00, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
644 882
645 wake_up(&chip->wq); 883 wake_up(&chip->wq);
646 cfi_spin_unlock(chip->mutex); 884 spin_unlock(chip->mutex);
647 885
648 return 0; 886 return 0;
649} 887}
@@ -692,7 +930,7 @@ static int cfi_amdstd_secsi_read (struct mtd_info *mtd, loff_t from, size_t len,
692} 930}
693 931
694 932
695static int do_write_oneword(struct map_info *map, struct flchip *chip, unsigned long adr, map_word datum) 933static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, unsigned long adr, map_word datum)
696{ 934{
697 struct cfi_private *cfi = map->fldrv_priv; 935 struct cfi_private *cfi = map->fldrv_priv;
698 unsigned long timeo = jiffies + HZ; 936 unsigned long timeo = jiffies + HZ;
@@ -712,10 +950,10 @@ static int do_write_oneword(struct map_info *map, struct flchip *chip, unsigned
712 950
713 adr += chip->start; 951 adr += chip->start;
714 952
715 cfi_spin_lock(chip->mutex); 953 spin_lock(chip->mutex);
716 ret = get_chip(map, chip, adr, FL_WRITING); 954 ret = get_chip(map, chip, adr, FL_WRITING);
717 if (ret) { 955 if (ret) {
718 cfi_spin_unlock(chip->mutex); 956 spin_unlock(chip->mutex);
719 return ret; 957 return ret;
720 } 958 }
721 959
@@ -735,7 +973,9 @@ static int do_write_oneword(struct map_info *map, struct flchip *chip, unsigned
735 goto op_done; 973 goto op_done;
736 } 974 }
737 975
976 XIP_INVAL_CACHED_RANGE(map, adr, map_bankwidth(map));
738 ENABLE_VPP(map); 977 ENABLE_VPP(map);
978 xip_disable(map, chip, adr);
739 retry: 979 retry:
740 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 980 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
741 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 981 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
@@ -743,9 +983,9 @@ static int do_write_oneword(struct map_info *map, struct flchip *chip, unsigned
743 map_write(map, datum, adr); 983 map_write(map, datum, adr);
744 chip->state = FL_WRITING; 984 chip->state = FL_WRITING;
745 985
746 cfi_spin_unlock(chip->mutex); 986 INVALIDATE_CACHE_UDELAY(map, chip,
747 cfi_udelay(chip->word_write_time); 987 adr, map_bankwidth(map),
748 cfi_spin_lock(chip->mutex); 988 chip->word_write_time);
749 989
750 /* See comment above for timeout value. */ 990 /* See comment above for timeout value. */
751 timeo = jiffies + uWriteTimeout; 991 timeo = jiffies + uWriteTimeout;
@@ -756,39 +996,43 @@ static int do_write_oneword(struct map_info *map, struct flchip *chip, unsigned
756 996
757 set_current_state(TASK_UNINTERRUPTIBLE); 997 set_current_state(TASK_UNINTERRUPTIBLE);
758 add_wait_queue(&chip->wq, &wait); 998 add_wait_queue(&chip->wq, &wait);
759 cfi_spin_unlock(chip->mutex); 999 spin_unlock(chip->mutex);
760 schedule(); 1000 schedule();
761 remove_wait_queue(&chip->wq, &wait); 1001 remove_wait_queue(&chip->wq, &wait);
762 timeo = jiffies + (HZ / 2); /* FIXME */ 1002 timeo = jiffies + (HZ / 2); /* FIXME */
763 cfi_spin_lock(chip->mutex); 1003 spin_lock(chip->mutex);
764 continue; 1004 continue;
765 } 1005 }
766 1006
767 if (chip_ready(map, adr)) 1007 if (chip_ready(map, adr))
768 goto op_done; 1008 break;
769 1009
770 if (time_after(jiffies, timeo)) 1010 if (time_after(jiffies, timeo)) {
1011 xip_enable(map, chip, adr);
1012 printk(KERN_WARNING "MTD %s(): software timeout\n", __func__);
1013 xip_disable(map, chip, adr);
771 break; 1014 break;
1015 }
772 1016
773 /* Latency issues. Drop the lock, wait a while and retry */ 1017 /* Latency issues. Drop the lock, wait a while and retry */
774 cfi_spin_unlock(chip->mutex); 1018 UDELAY(map, chip, adr, 1);
775 cfi_udelay(1);
776 cfi_spin_lock(chip->mutex);
777 } 1019 }
1020 /* Did we succeed? */
1021 if (!chip_good(map, adr, datum)) {
1022 /* reset on all failures. */
1023 map_write( map, CMD(0xF0), chip->start );
1024 /* FIXME - should have reset delay before continuing */
778 1025
779 printk(KERN_WARNING "MTD %s(): software timeout\n", __func__); 1026 if (++retry_cnt <= MAX_WORD_RETRIES)
780 1027 goto retry;
781 /* reset on all failures. */
782 map_write( map, CMD(0xF0), chip->start );
783 /* FIXME - should have reset delay before continuing */
784 if (++retry_cnt <= MAX_WORD_RETRIES)
785 goto retry;
786 1028
787 ret = -EIO; 1029 ret = -EIO;
1030 }
1031 xip_enable(map, chip, adr);
788 op_done: 1032 op_done:
789 chip->state = FL_READY; 1033 chip->state = FL_READY;
790 put_chip(map, chip, adr); 1034 put_chip(map, chip, adr);
791 cfi_spin_unlock(chip->mutex); 1035 spin_unlock(chip->mutex);
792 1036
793 return ret; 1037 return ret;
794} 1038}
@@ -820,7 +1064,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
820 map_word tmp_buf; 1064 map_word tmp_buf;
821 1065
822 retry: 1066 retry:
823 cfi_spin_lock(cfi->chips[chipnum].mutex); 1067 spin_lock(cfi->chips[chipnum].mutex);
824 1068
825 if (cfi->chips[chipnum].state != FL_READY) { 1069 if (cfi->chips[chipnum].state != FL_READY) {
826#if 0 1070#if 0
@@ -829,7 +1073,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
829 set_current_state(TASK_UNINTERRUPTIBLE); 1073 set_current_state(TASK_UNINTERRUPTIBLE);
830 add_wait_queue(&cfi->chips[chipnum].wq, &wait); 1074 add_wait_queue(&cfi->chips[chipnum].wq, &wait);
831 1075
832 cfi_spin_unlock(cfi->chips[chipnum].mutex); 1076 spin_unlock(cfi->chips[chipnum].mutex);
833 1077
834 schedule(); 1078 schedule();
835 remove_wait_queue(&cfi->chips[chipnum].wq, &wait); 1079 remove_wait_queue(&cfi->chips[chipnum].wq, &wait);
@@ -843,7 +1087,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
843 /* Load 'tmp_buf' with old contents of flash */ 1087 /* Load 'tmp_buf' with old contents of flash */
844 tmp_buf = map_read(map, bus_ofs+chipstart); 1088 tmp_buf = map_read(map, bus_ofs+chipstart);
845 1089
846 cfi_spin_unlock(cfi->chips[chipnum].mutex); 1090 spin_unlock(cfi->chips[chipnum].mutex);
847 1091
848 /* Number of bytes to copy from buffer */ 1092 /* Number of bytes to copy from buffer */
849 n = min_t(int, len, map_bankwidth(map)-i); 1093 n = min_t(int, len, map_bankwidth(map)-i);
@@ -898,7 +1142,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
898 map_word tmp_buf; 1142 map_word tmp_buf;
899 1143
900 retry1: 1144 retry1:
901 cfi_spin_lock(cfi->chips[chipnum].mutex); 1145 spin_lock(cfi->chips[chipnum].mutex);
902 1146
903 if (cfi->chips[chipnum].state != FL_READY) { 1147 if (cfi->chips[chipnum].state != FL_READY) {
904#if 0 1148#if 0
@@ -907,7 +1151,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
907 set_current_state(TASK_UNINTERRUPTIBLE); 1151 set_current_state(TASK_UNINTERRUPTIBLE);
908 add_wait_queue(&cfi->chips[chipnum].wq, &wait); 1152 add_wait_queue(&cfi->chips[chipnum].wq, &wait);
909 1153
910 cfi_spin_unlock(cfi->chips[chipnum].mutex); 1154 spin_unlock(cfi->chips[chipnum].mutex);
911 1155
912 schedule(); 1156 schedule();
913 remove_wait_queue(&cfi->chips[chipnum].wq, &wait); 1157 remove_wait_queue(&cfi->chips[chipnum].wq, &wait);
@@ -920,7 +1164,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
920 1164
921 tmp_buf = map_read(map, ofs + chipstart); 1165 tmp_buf = map_read(map, ofs + chipstart);
922 1166
923 cfi_spin_unlock(cfi->chips[chipnum].mutex); 1167 spin_unlock(cfi->chips[chipnum].mutex);
924 1168
925 tmp_buf = map_word_load_partial(map, tmp_buf, buf, 0, len); 1169 tmp_buf = map_word_load_partial(map, tmp_buf, buf, 0, len);
926 1170
@@ -939,8 +1183,9 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
939/* 1183/*
940 * FIXME: interleaved mode not tested, and probably not supported! 1184 * FIXME: interleaved mode not tested, and probably not supported!
941 */ 1185 */
942static inline int do_write_buffer(struct map_info *map, struct flchip *chip, 1186static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
943 unsigned long adr, const u_char *buf, int len) 1187 unsigned long adr, const u_char *buf,
1188 int len)
944{ 1189{
945 struct cfi_private *cfi = map->fldrv_priv; 1190 struct cfi_private *cfi = map->fldrv_priv;
946 unsigned long timeo = jiffies + HZ; 1191 unsigned long timeo = jiffies + HZ;
@@ -954,10 +1199,10 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
954 adr += chip->start; 1199 adr += chip->start;
955 cmd_adr = adr; 1200 cmd_adr = adr;
956 1201
957 cfi_spin_lock(chip->mutex); 1202 spin_lock(chip->mutex);
958 ret = get_chip(map, chip, adr, FL_WRITING); 1203 ret = get_chip(map, chip, adr, FL_WRITING);
959 if (ret) { 1204 if (ret) {
960 cfi_spin_unlock(chip->mutex); 1205 spin_unlock(chip->mutex);
961 return ret; 1206 return ret;
962 } 1207 }
963 1208
@@ -966,7 +1211,10 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
966 DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", 1211 DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n",
967 __func__, adr, datum.x[0] ); 1212 __func__, adr, datum.x[0] );
968 1213
1214 XIP_INVAL_CACHED_RANGE(map, adr, len);
969 ENABLE_VPP(map); 1215 ENABLE_VPP(map);
1216 xip_disable(map, chip, cmd_adr);
1217
970 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1218 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
971 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 1219 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
972 //cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1220 //cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
@@ -996,9 +1244,9 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
996 map_write(map, CMD(0x29), cmd_adr); 1244 map_write(map, CMD(0x29), cmd_adr);
997 chip->state = FL_WRITING; 1245 chip->state = FL_WRITING;
998 1246
999 cfi_spin_unlock(chip->mutex); 1247 INVALIDATE_CACHE_UDELAY(map, chip,
1000 cfi_udelay(chip->buffer_write_time); 1248 adr, map_bankwidth(map),
1001 cfi_spin_lock(chip->mutex); 1249 chip->word_write_time);
1002 1250
1003 timeo = jiffies + uWriteTimeout; 1251 timeo = jiffies + uWriteTimeout;
1004 1252
@@ -1009,38 +1257,39 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
1009 1257
1010 set_current_state(TASK_UNINTERRUPTIBLE); 1258 set_current_state(TASK_UNINTERRUPTIBLE);
1011 add_wait_queue(&chip->wq, &wait); 1259 add_wait_queue(&chip->wq, &wait);
1012 cfi_spin_unlock(chip->mutex); 1260 spin_unlock(chip->mutex);
1013 schedule(); 1261 schedule();
1014 remove_wait_queue(&chip->wq, &wait); 1262 remove_wait_queue(&chip->wq, &wait);
1015 timeo = jiffies + (HZ / 2); /* FIXME */ 1263 timeo = jiffies + (HZ / 2); /* FIXME */
1016 cfi_spin_lock(chip->mutex); 1264 spin_lock(chip->mutex);
1017 continue; 1265 continue;
1018 } 1266 }
1019 1267
1020 if (chip_ready(map, adr)) 1268 if (chip_ready(map, adr)) {
1269 xip_enable(map, chip, adr);
1021 goto op_done; 1270 goto op_done;
1271 }
1022 1272
1023 if( time_after(jiffies, timeo)) 1273 if( time_after(jiffies, timeo))
1024 break; 1274 break;
1025 1275
1026 /* Latency issues. Drop the lock, wait a while and retry */ 1276 /* Latency issues. Drop the lock, wait a while and retry */
1027 cfi_spin_unlock(chip->mutex); 1277 UDELAY(map, chip, adr, 1);
1028 cfi_udelay(1);
1029 cfi_spin_lock(chip->mutex);
1030 } 1278 }
1031 1279
1032 printk(KERN_WARNING "MTD %s(): software timeout\n",
1033 __func__ );
1034
1035 /* reset on all failures. */ 1280 /* reset on all failures. */
1036 map_write( map, CMD(0xF0), chip->start ); 1281 map_write( map, CMD(0xF0), chip->start );
1282 xip_enable(map, chip, adr);
1037 /* FIXME - should have reset delay before continuing */ 1283 /* FIXME - should have reset delay before continuing */
1038 1284
1285 printk(KERN_WARNING "MTD %s(): software timeout\n",
1286 __func__ );
1287
1039 ret = -EIO; 1288 ret = -EIO;
1040 op_done: 1289 op_done:
1041 chip->state = FL_READY; 1290 chip->state = FL_READY;
1042 put_chip(map, chip, adr); 1291 put_chip(map, chip, adr);
1043 cfi_spin_unlock(chip->mutex); 1292 spin_unlock(chip->mutex);
1044 1293
1045 return ret; 1294 return ret;
1046} 1295}
@@ -1130,7 +1379,7 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
1130 * Handle devices with one erase region, that only implement 1379 * Handle devices with one erase region, that only implement
1131 * the chip erase command. 1380 * the chip erase command.
1132 */ 1381 */
1133static inline int do_erase_chip(struct map_info *map, struct flchip *chip) 1382static int __xipram do_erase_chip(struct map_info *map, struct flchip *chip)
1134{ 1383{
1135 struct cfi_private *cfi = map->fldrv_priv; 1384 struct cfi_private *cfi = map->fldrv_priv;
1136 unsigned long timeo = jiffies + HZ; 1385 unsigned long timeo = jiffies + HZ;
@@ -1140,17 +1389,20 @@ static inline int do_erase_chip(struct map_info *map, struct flchip *chip)
1140 1389
1141 adr = cfi->addr_unlock1; 1390 adr = cfi->addr_unlock1;
1142 1391
1143 cfi_spin_lock(chip->mutex); 1392 spin_lock(chip->mutex);
1144 ret = get_chip(map, chip, adr, FL_WRITING); 1393 ret = get_chip(map, chip, adr, FL_WRITING);
1145 if (ret) { 1394 if (ret) {
1146 cfi_spin_unlock(chip->mutex); 1395 spin_unlock(chip->mutex);
1147 return ret; 1396 return ret;
1148 } 1397 }
1149 1398
1150 DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n", 1399 DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n",
1151 __func__, chip->start ); 1400 __func__, chip->start );
1152 1401
1402 XIP_INVAL_CACHED_RANGE(map, adr, map->size);
1153 ENABLE_VPP(map); 1403 ENABLE_VPP(map);
1404 xip_disable(map, chip, adr);
1405
1154 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1406 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
1155 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 1407 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
1156 cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1408 cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
@@ -1162,9 +1414,9 @@ static inline int do_erase_chip(struct map_info *map, struct flchip *chip)
1162 chip->erase_suspended = 0; 1414 chip->erase_suspended = 0;
1163 chip->in_progress_block_addr = adr; 1415 chip->in_progress_block_addr = adr;
1164 1416
1165 cfi_spin_unlock(chip->mutex); 1417 INVALIDATE_CACHE_UDELAY(map, chip,
1166 msleep(chip->erase_time/2); 1418 adr, map->size,
1167 cfi_spin_lock(chip->mutex); 1419 chip->erase_time*500);
1168 1420
1169 timeo = jiffies + (HZ*20); 1421 timeo = jiffies + (HZ*20);
1170 1422
@@ -1173,10 +1425,10 @@ static inline int do_erase_chip(struct map_info *map, struct flchip *chip)
1173 /* Someone's suspended the erase. Sleep */ 1425 /* Someone's suspended the erase. Sleep */
1174 set_current_state(TASK_UNINTERRUPTIBLE); 1426 set_current_state(TASK_UNINTERRUPTIBLE);
1175 add_wait_queue(&chip->wq, &wait); 1427 add_wait_queue(&chip->wq, &wait);
1176 cfi_spin_unlock(chip->mutex); 1428 spin_unlock(chip->mutex);
1177 schedule(); 1429 schedule();
1178 remove_wait_queue(&chip->wq, &wait); 1430 remove_wait_queue(&chip->wq, &wait);
1179 cfi_spin_lock(chip->mutex); 1431 spin_lock(chip->mutex);
1180 continue; 1432 continue;
1181 } 1433 }
1182 if (chip->erase_suspended) { 1434 if (chip->erase_suspended) {
@@ -1187,36 +1439,36 @@ static inline int do_erase_chip(struct map_info *map, struct flchip *chip)
1187 } 1439 }
1188 1440
1189 if (chip_ready(map, adr)) 1441 if (chip_ready(map, adr))
1190 goto op_done; 1442 break;
1191 1443
1192 if (time_after(jiffies, timeo)) 1444 if (time_after(jiffies, timeo)) {
1445 printk(KERN_WARNING "MTD %s(): software timeout\n",
1446 __func__ );
1193 break; 1447 break;
1448 }
1194 1449
1195 /* Latency issues. Drop the lock, wait a while and retry */ 1450 /* Latency issues. Drop the lock, wait a while and retry */
1196 cfi_spin_unlock(chip->mutex); 1451 UDELAY(map, chip, adr, 1000000/HZ);
1197 set_current_state(TASK_UNINTERRUPTIBLE);
1198 schedule_timeout(1);
1199 cfi_spin_lock(chip->mutex);
1200 } 1452 }
1453 /* Did we succeed? */
1454 if (!chip_good(map, adr, map_word_ff(map))) {
1455 /* reset on all failures. */
1456 map_write( map, CMD(0xF0), chip->start );
1457 /* FIXME - should have reset delay before continuing */
1201 1458
1202 printk(KERN_WARNING "MTD %s(): software timeout\n", 1459 ret = -EIO;
1203 __func__ ); 1460 }
1204
1205 /* reset on all failures. */
1206 map_write( map, CMD(0xF0), chip->start );
1207 /* FIXME - should have reset delay before continuing */
1208 1461
1209 ret = -EIO;
1210 op_done:
1211 chip->state = FL_READY; 1462 chip->state = FL_READY;
1463 xip_enable(map, chip, adr);
1212 put_chip(map, chip, adr); 1464 put_chip(map, chip, adr);
1213 cfi_spin_unlock(chip->mutex); 1465 spin_unlock(chip->mutex);
1214 1466
1215 return ret; 1467 return ret;
1216} 1468}
1217 1469
1218 1470
1219static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr, int len, void *thunk) 1471static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr, int len, void *thunk)
1220{ 1472{
1221 struct cfi_private *cfi = map->fldrv_priv; 1473 struct cfi_private *cfi = map->fldrv_priv;
1222 unsigned long timeo = jiffies + HZ; 1474 unsigned long timeo = jiffies + HZ;
@@ -1225,17 +1477,20 @@ static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, u
1225 1477
1226 adr += chip->start; 1478 adr += chip->start;
1227 1479
1228 cfi_spin_lock(chip->mutex); 1480 spin_lock(chip->mutex);
1229 ret = get_chip(map, chip, adr, FL_ERASING); 1481 ret = get_chip(map, chip, adr, FL_ERASING);
1230 if (ret) { 1482 if (ret) {
1231 cfi_spin_unlock(chip->mutex); 1483 spin_unlock(chip->mutex);
1232 return ret; 1484 return ret;
1233 } 1485 }
1234 1486
1235 DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n", 1487 DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n",
1236 __func__, adr ); 1488 __func__, adr );
1237 1489
1490 XIP_INVAL_CACHED_RANGE(map, adr, len);
1238 ENABLE_VPP(map); 1491 ENABLE_VPP(map);
1492 xip_disable(map, chip, adr);
1493
1239 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1494 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
1240 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 1495 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
1241 cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1496 cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
@@ -1246,10 +1501,10 @@ static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, u
1246 chip->state = FL_ERASING; 1501 chip->state = FL_ERASING;
1247 chip->erase_suspended = 0; 1502 chip->erase_suspended = 0;
1248 chip->in_progress_block_addr = adr; 1503 chip->in_progress_block_addr = adr;
1249 1504
1250 cfi_spin_unlock(chip->mutex); 1505 INVALIDATE_CACHE_UDELAY(map, chip,
1251 msleep(chip->erase_time/2); 1506 adr, len,
1252 cfi_spin_lock(chip->mutex); 1507 chip->erase_time*500);
1253 1508
1254 timeo = jiffies + (HZ*20); 1509 timeo = jiffies + (HZ*20);
1255 1510
@@ -1258,10 +1513,10 @@ static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, u
1258 /* Someone's suspended the erase. Sleep */ 1513 /* Someone's suspended the erase. Sleep */
1259 set_current_state(TASK_UNINTERRUPTIBLE); 1514 set_current_state(TASK_UNINTERRUPTIBLE);
1260 add_wait_queue(&chip->wq, &wait); 1515 add_wait_queue(&chip->wq, &wait);
1261 cfi_spin_unlock(chip->mutex); 1516 spin_unlock(chip->mutex);
1262 schedule(); 1517 schedule();
1263 remove_wait_queue(&chip->wq, &wait); 1518 remove_wait_queue(&chip->wq, &wait);
1264 cfi_spin_lock(chip->mutex); 1519 spin_lock(chip->mutex);
1265 continue; 1520 continue;
1266 } 1521 }
1267 if (chip->erase_suspended) { 1522 if (chip->erase_suspended) {
@@ -1271,31 +1526,33 @@ static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, u
1271 chip->erase_suspended = 0; 1526 chip->erase_suspended = 0;
1272 } 1527 }
1273 1528
1274 if (chip_ready(map, adr)) 1529 if (chip_ready(map, adr)) {
1275 goto op_done; 1530 xip_enable(map, chip, adr);
1531 break;
1532 }
1276 1533
1277 if (time_after(jiffies, timeo)) 1534 if (time_after(jiffies, timeo)) {
1535 xip_enable(map, chip, adr);
1536 printk(KERN_WARNING "MTD %s(): software timeout\n",
1537 __func__ );
1278 break; 1538 break;
1539 }
1279 1540
1280 /* Latency issues. Drop the lock, wait a while and retry */ 1541 /* Latency issues. Drop the lock, wait a while and retry */
1281 cfi_spin_unlock(chip->mutex); 1542 UDELAY(map, chip, adr, 1000000/HZ);
1282 set_current_state(TASK_UNINTERRUPTIBLE); 1543 }
1283 schedule_timeout(1); 1544 /* Did we succeed? */
1284 cfi_spin_lock(chip->mutex); 1545 if (!chip_good(map, adr, map_word_ff(map))) {
1546 /* reset on all failures. */
1547 map_write( map, CMD(0xF0), chip->start );
1548 /* FIXME - should have reset delay before continuing */
1549
1550 ret = -EIO;
1285 } 1551 }
1286
1287 printk(KERN_WARNING "MTD %s(): software timeout\n",
1288 __func__ );
1289
1290 /* reset on all failures. */
1291 map_write( map, CMD(0xF0), chip->start );
1292 /* FIXME - should have reset delay before continuing */
1293 1552
1294 ret = -EIO;
1295 op_done:
1296 chip->state = FL_READY; 1553 chip->state = FL_READY;
1297 put_chip(map, chip, adr); 1554 put_chip(map, chip, adr);
1298 cfi_spin_unlock(chip->mutex); 1555 spin_unlock(chip->mutex);
1299 return ret; 1556 return ret;
1300} 1557}
1301 1558
@@ -1355,7 +1612,7 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1355 chip = &cfi->chips[i]; 1612 chip = &cfi->chips[i];
1356 1613
1357 retry: 1614 retry:
1358 cfi_spin_lock(chip->mutex); 1615 spin_lock(chip->mutex);
1359 1616
1360 switch(chip->state) { 1617 switch(chip->state) {
1361 case FL_READY: 1618 case FL_READY:
@@ -1369,14 +1626,14 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1369 * with the chip now anyway. 1626 * with the chip now anyway.
1370 */ 1627 */
1371 case FL_SYNCING: 1628 case FL_SYNCING:
1372 cfi_spin_unlock(chip->mutex); 1629 spin_unlock(chip->mutex);
1373 break; 1630 break;
1374 1631
1375 default: 1632 default:
1376 /* Not an idle state */ 1633 /* Not an idle state */
1377 add_wait_queue(&chip->wq, &wait); 1634 add_wait_queue(&chip->wq, &wait);
1378 1635
1379 cfi_spin_unlock(chip->mutex); 1636 spin_unlock(chip->mutex);
1380 1637
1381 schedule(); 1638 schedule();
1382 1639
@@ -1391,13 +1648,13 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1391 for (i--; i >=0; i--) { 1648 for (i--; i >=0; i--) {
1392 chip = &cfi->chips[i]; 1649 chip = &cfi->chips[i];
1393 1650
1394 cfi_spin_lock(chip->mutex); 1651 spin_lock(chip->mutex);
1395 1652
1396 if (chip->state == FL_SYNCING) { 1653 if (chip->state == FL_SYNCING) {
1397 chip->state = chip->oldstate; 1654 chip->state = chip->oldstate;
1398 wake_up(&chip->wq); 1655 wake_up(&chip->wq);
1399 } 1656 }
1400 cfi_spin_unlock(chip->mutex); 1657 spin_unlock(chip->mutex);
1401 } 1658 }
1402} 1659}
1403 1660
@@ -1413,7 +1670,7 @@ static int cfi_amdstd_suspend(struct mtd_info *mtd)
1413 for (i=0; !ret && i<cfi->numchips; i++) { 1670 for (i=0; !ret && i<cfi->numchips; i++) {
1414 chip = &cfi->chips[i]; 1671 chip = &cfi->chips[i];
1415 1672
1416 cfi_spin_lock(chip->mutex); 1673 spin_lock(chip->mutex);
1417 1674
1418 switch(chip->state) { 1675 switch(chip->state) {
1419 case FL_READY: 1676 case FL_READY:
@@ -1433,7 +1690,7 @@ static int cfi_amdstd_suspend(struct mtd_info *mtd)
1433 ret = -EAGAIN; 1690 ret = -EAGAIN;
1434 break; 1691 break;
1435 } 1692 }
1436 cfi_spin_unlock(chip->mutex); 1693 spin_unlock(chip->mutex);
1437 } 1694 }
1438 1695
1439 /* Unlock the chips again */ 1696 /* Unlock the chips again */
@@ -1442,13 +1699,13 @@ static int cfi_amdstd_suspend(struct mtd_info *mtd)
1442 for (i--; i >=0; i--) { 1699 for (i--; i >=0; i--) {
1443 chip = &cfi->chips[i]; 1700 chip = &cfi->chips[i];
1444 1701
1445 cfi_spin_lock(chip->mutex); 1702 spin_lock(chip->mutex);
1446 1703
1447 if (chip->state == FL_PM_SUSPENDED) { 1704 if (chip->state == FL_PM_SUSPENDED) {
1448 chip->state = chip->oldstate; 1705 chip->state = chip->oldstate;
1449 wake_up(&chip->wq); 1706 wake_up(&chip->wq);
1450 } 1707 }
1451 cfi_spin_unlock(chip->mutex); 1708 spin_unlock(chip->mutex);
1452 } 1709 }
1453 } 1710 }
1454 1711
@@ -1467,7 +1724,7 @@ static void cfi_amdstd_resume(struct mtd_info *mtd)
1467 1724
1468 chip = &cfi->chips[i]; 1725 chip = &cfi->chips[i];
1469 1726
1470 cfi_spin_lock(chip->mutex); 1727 spin_lock(chip->mutex);
1471 1728
1472 if (chip->state == FL_PM_SUSPENDED) { 1729 if (chip->state == FL_PM_SUSPENDED) {
1473 chip->state = FL_READY; 1730 chip->state = FL_READY;
@@ -1477,7 +1734,7 @@ static void cfi_amdstd_resume(struct mtd_info *mtd)
1477 else 1734 else
1478 printk(KERN_ERR "Argh. Chip not in PM_SUSPENDED state upon resume()\n"); 1735 printk(KERN_ERR "Argh. Chip not in PM_SUSPENDED state upon resume()\n");
1479 1736
1480 cfi_spin_unlock(chip->mutex); 1737 spin_unlock(chip->mutex);
1481 } 1738 }
1482} 1739}
1483 1740
diff --git a/drivers/mtd/chips/fwh_lock.h b/drivers/mtd/chips/fwh_lock.h
index fbf44708a861..e1a5b76596c5 100644
--- a/drivers/mtd/chips/fwh_lock.h
+++ b/drivers/mtd/chips/fwh_lock.h
@@ -58,10 +58,10 @@ static int fwh_xxlock_oneblock(struct map_info *map, struct flchip *chip,
58 * to flash memory - that means that we don't have to check status 58 * to flash memory - that means that we don't have to check status
59 * and timeout. 59 * and timeout.
60 */ 60 */
61 cfi_spin_lock(chip->mutex); 61 spin_lock(chip->mutex);
62 ret = get_chip(map, chip, adr, FL_LOCKING); 62 ret = get_chip(map, chip, adr, FL_LOCKING);
63 if (ret) { 63 if (ret) {
64 cfi_spin_unlock(chip->mutex); 64 spin_unlock(chip->mutex);
65 return ret; 65 return ret;
66 } 66 }
67 67
@@ -71,7 +71,7 @@ static int fwh_xxlock_oneblock(struct map_info *map, struct flchip *chip,
71 /* Done and happy. */ 71 /* Done and happy. */
72 chip->state = FL_READY; 72 chip->state = FL_READY;
73 put_chip(map, chip, adr); 73 put_chip(map, chip, adr);
74 cfi_spin_unlock(chip->mutex); 74 spin_unlock(chip->mutex);
75 return 0; 75 return 0;
76} 76}
77 77
diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c
index fc982c4671f0..dc065b22f79e 100644
--- a/drivers/mtd/chips/gen_probe.c
+++ b/drivers/mtd/chips/gen_probe.c
@@ -2,7 +2,7 @@
2 * Routines common to all CFI-type probes. 2 * Routines common to all CFI-type probes.
3 * (C) 2001-2003 Red Hat, Inc. 3 * (C) 2001-2003 Red Hat, Inc.
4 * GPL'd 4 * GPL'd
5 * $Id: gen_probe.c,v 1.21 2004/08/14 15:14:05 dwmw2 Exp $ 5 * $Id: gen_probe.c,v 1.22 2005/01/24 23:49:50 rmk Exp $
6 */ 6 */
7 7
8#include <linux/kernel.h> 8#include <linux/kernel.h>
@@ -162,7 +162,7 @@ static int genprobe_new_chip(struct map_info *map, struct chip_probe *cp,
162 int max_chips = map_bankwidth(map); /* And minimum 1 */ 162 int max_chips = map_bankwidth(map); /* And minimum 1 */
163 int nr_chips, type; 163 int nr_chips, type;
164 164
165 for (nr_chips = min_chips; nr_chips <= max_chips; nr_chips <<= 1) { 165 for (nr_chips = max_chips; nr_chips >= min_chips; nr_chips >>= 1) {
166 166
167 if (!cfi_interleave_supported(nr_chips)) 167 if (!cfi_interleave_supported(nr_chips))
168 continue; 168 continue;
diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c
index 30325a25ab95..30da428eb7b9 100644
--- a/drivers/mtd/chips/jedec_probe.c
+++ b/drivers/mtd/chips/jedec_probe.c
@@ -1,7 +1,7 @@
1/* 1/*
2 Common Flash Interface probe code. 2 Common Flash Interface probe code.
3 (C) 2000 Red Hat. GPL'd. 3 (C) 2000 Red Hat. GPL'd.
4 $Id: jedec_probe.c,v 1.61 2004/11/19 20:52:16 thayne Exp $ 4 $Id: jedec_probe.c,v 1.63 2005/02/14 16:30:32 bjd Exp $
5 See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5) 5 See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5)
6 for the standard this probe goes back to. 6 for the standard this probe goes back to.
7 7
@@ -142,6 +142,7 @@
142#define SST29LE512 0x003d 142#define SST29LE512 0x003d
143#define SST39LF800 0x2781 143#define SST39LF800 0x2781
144#define SST39LF160 0x2782 144#define SST39LF160 0x2782
145#define SST39VF1601 0x234b
145#define SST39LF512 0x00D4 146#define SST39LF512 0x00D4
146#define SST39LF010 0x00D5 147#define SST39LF010 0x00D5
147#define SST39LF020 0x00D6 148#define SST39LF020 0x00D6
@@ -1448,6 +1449,21 @@ static const struct amd_flash_info jedec_table[] = {
1448 ERASEINFO(0x1000,256), 1449 ERASEINFO(0x1000,256),
1449 ERASEINFO(0x1000,256) 1450 ERASEINFO(0x1000,256)
1450 } 1451 }
1452 }, {
1453 .mfr_id = MANUFACTURER_SST, /* should be CFI */
1454 .dev_id = SST39VF1601,
1455 .name = "SST 39VF1601",
1456 .uaddr = {
1457 [0] = MTD_UADDR_0x5555_0x2AAA, /* x8 */
1458 [1] = MTD_UADDR_0x5555_0x2AAA /* x16 */
1459 },
1460 .DevSize = SIZE_2MiB,
1461 .CmdSet = P_ID_AMD_STD,
1462 .NumEraseRegions= 2,
1463 .regions = {
1464 ERASEINFO(0x1000,256),
1465 ERASEINFO(0x1000,256)
1466 }
1451 1467
1452 }, { 1468 }, {
1453 .mfr_id = MANUFACTURER_ST, /* FIXME - CFI device? */ 1469 .mfr_id = MANUFACTURER_ST, /* FIXME - CFI device? */
@@ -1856,6 +1872,16 @@ static inline int jedec_match( __u32 base,
1856 case CFI_DEVICETYPE_X8: 1872 case CFI_DEVICETYPE_X8:
1857 mfr = (__u8)finfo->mfr_id; 1873 mfr = (__u8)finfo->mfr_id;
1858 id = (__u8)finfo->dev_id; 1874 id = (__u8)finfo->dev_id;
1875
1876 /* bjd: it seems that if we do this, we can end up
1877 * detecting 16bit flashes as an 8bit device, even though
1878 * there aren't.
1879 */
1880 if (finfo->dev_id > 0xff) {
1881 DEBUG( MTD_DEBUG_LEVEL3, "%s(): ID is not 8bit\n",
1882 __func__);
1883 goto match_done;
1884 }
1859 break; 1885 break;
1860 case CFI_DEVICETYPE_X16: 1886 case CFI_DEVICETYPE_X16:
1861 mfr = (__u16)finfo->mfr_id; 1887 mfr = (__u16)finfo->mfr_id;
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index 60ab4b89a2f9..ef24837019d3 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cmdlinepart.c,v 1.17 2004/11/26 11:18:47 lavinen Exp $ 2 * $Id: cmdlinepart.c,v 1.18 2005/06/07 15:04:26 joern Exp $
3 * 3 *
4 * Read flash partition table from command line 4 * Read flash partition table from command line
5 * 5 *
@@ -239,7 +239,8 @@ static int mtdpart_setup_real(char *s)
239 &num_parts, /* out: number of parts */ 239 &num_parts, /* out: number of parts */
240 0, /* first partition */ 240 0, /* first partition */
241 (unsigned char**)&this_mtd, /* out: extra mem */ 241 (unsigned char**)&this_mtd, /* out: extra mem */
242 mtd_id_len + 1 + sizeof(*this_mtd)); 242 mtd_id_len + 1 + sizeof(*this_mtd) +
243 sizeof(void*)-1 /*alignment*/);
243 if(!parts) 244 if(!parts)
244 { 245 {
245 /* 246 /*
@@ -252,6 +253,9 @@ static int mtdpart_setup_real(char *s)
252 return 0; 253 return 0;
253 } 254 }
254 255
256 /* align this_mtd */
257 this_mtd = (struct cmdline_mtd_partition *)
258 ALIGN((unsigned long)this_mtd, sizeof(void*));
255 /* enter results */ 259 /* enter results */
256 this_mtd->parts = parts; 260 this_mtd->parts = parts;
257 this_mtd->num_parts = num_parts; 261 this_mtd->num_parts = num_parts;
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index cfe6ccf07972..4a7a805e7564 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * $Id: block2mtd.c,v 1.23 2005/01/05 17:05:46 dwmw2 Exp $ 2 * $Id: block2mtd.c,v 1.28 2005/03/19 22:40:44 gleixner Exp $
3 * 3 *
4 * block2mtd.c - create an mtd from a block device 4 * block2mtd.c - create an mtd from a block device
5 * 5 *
6 * Copyright (C) 2001,2002 Simon Evans <spse@secret.org.uk> 6 * Copyright (C) 2001,2002 Simon Evans <spse@secret.org.uk>
7 * Copyright (C) 2004 Gareth Bult <Gareth@Encryptec.net>
8 * Copyright (C) 2004,2005 Jörn Engel <joern@wh.fh-wedel.de> 7 * Copyright (C) 2004,2005 Jörn Engel <joern@wh.fh-wedel.de>
9 * 8 *
10 * Licence: GPL 9 * Licence: GPL
@@ -20,7 +19,7 @@
20#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
21#include <linux/buffer_head.h> 20#include <linux/buffer_head.h>
22 21
23#define VERSION "$Revision: 1.23 $" 22#define VERSION "$Revision: 1.28 $"
24 23
25 24
26#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args) 25#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
@@ -89,7 +88,6 @@ void cache_readahead(struct address_space *mapping, int index)
89static struct page* page_readahead(struct address_space *mapping, int index) 88static struct page* page_readahead(struct address_space *mapping, int index)
90{ 89{
91 filler_t *filler = (filler_t*)mapping->a_ops->readpage; 90 filler_t *filler = (filler_t*)mapping->a_ops->readpage;
92 //do_page_cache_readahead(mapping, index, XXX, 64);
93 cache_readahead(mapping, index); 91 cache_readahead(mapping, index);
94 return read_cache_page(mapping, index, filler, NULL); 92 return read_cache_page(mapping, index, filler, NULL);
95} 93}
@@ -157,7 +155,7 @@ static int block2mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
157 struct block2mtd_dev *dev = mtd->priv; 155 struct block2mtd_dev *dev = mtd->priv;
158 struct page *page; 156 struct page *page;
159 int index = from >> PAGE_SHIFT; 157 int index = from >> PAGE_SHIFT;
160 int offset = from & (PAGE_SHIFT-1); 158 int offset = from & (PAGE_SIZE-1);
161 int cpylen; 159 int cpylen;
162 160
163 if (from > mtd->size) 161 if (from > mtd->size)
@@ -370,16 +368,16 @@ static int ustrtoul(const char *cp, char **endp, unsigned int base)
370} 368}
371 369
372 370
373static int parse_num32(u32 *num32, const char *token) 371static int parse_num(size_t *num, const char *token)
374{ 372{
375 char *endp; 373 char *endp;
376 unsigned long n; 374 size_t n;
377 375
378 n = ustrtoul(token, &endp, 0); 376 n = (size_t) ustrtoul(token, &endp, 0);
379 if (*endp) 377 if (*endp)
380 return -EINVAL; 378 return -EINVAL;
381 379
382 *num32 = n; 380 *num = n;
383 return 0; 381 return 0;
384} 382}
385 383
@@ -422,7 +420,7 @@ static int block2mtd_setup(const char *val, struct kernel_param *kp)
422 char buf[80+12], *str=buf; /* 80 for device, 12 for erase size */ 420 char buf[80+12], *str=buf; /* 80 for device, 12 for erase size */
423 char *token[2]; 421 char *token[2];
424 char *name; 422 char *name;
425 u32 erase_size = PAGE_SIZE; 423 size_t erase_size = PAGE_SIZE;
426 int i, ret; 424 int i, ret;
427 425
428 if (strnlen(val, sizeof(buf)) >= sizeof(buf)) 426 if (strnlen(val, sizeof(buf)) >= sizeof(buf))
@@ -449,7 +447,7 @@ static int block2mtd_setup(const char *val, struct kernel_param *kp)
449 return 0; 447 return 0;
450 448
451 if (token[1]) { 449 if (token[1]) {
452 ret = parse_num32(&erase_size, token[1]); 450 ret = parse_num(&erase_size, token[1]);
453 if (ret) 451 if (ret)
454 parse_err("illegal erase size"); 452 parse_err("illegal erase size");
455 } 453 }
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c
index 380ff08d29e4..f5026cee087f 100644
--- a/drivers/mtd/devices/ms02-nv.c
+++ b/drivers/mtd/devices/ms02-nv.c
@@ -6,7 +6,7 @@
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
8 * 8 *
9 * $Id: ms02-nv.c,v 1.8 2005/01/05 18:05:12 dwmw2 Exp $ 9 * $Id: ms02-nv.c,v 1.10 2005/06/20 12:24:41 macro Exp $
10 */ 10 */
11 11
12#include <linux/init.h> 12#include <linux/init.h>
@@ -99,8 +99,8 @@ static inline uint ms02nv_probe_one(ulong addr)
99 * The firmware writes MS02NV_ID at MS02NV_MAGIC and also 99 * The firmware writes MS02NV_ID at MS02NV_MAGIC and also
100 * a diagnostic status at MS02NV_DIAG. 100 * a diagnostic status at MS02NV_DIAG.
101 */ 101 */
102 ms02nv_diagp = (ms02nv_uint *)(KSEG1ADDR(addr + MS02NV_DIAG)); 102 ms02nv_diagp = (ms02nv_uint *)(CKSEG1ADDR(addr + MS02NV_DIAG));
103 ms02nv_magicp = (ms02nv_uint *)(KSEG1ADDR(addr + MS02NV_MAGIC)); 103 ms02nv_magicp = (ms02nv_uint *)(CKSEG1ADDR(addr + MS02NV_MAGIC));
104 err = get_dbe(ms02nv_magic, ms02nv_magicp); 104 err = get_dbe(ms02nv_magic, ms02nv_magicp);
105 if (err) 105 if (err)
106 return 0; 106 return 0;
@@ -233,7 +233,7 @@ static int __init ms02nv_init_one(ulong addr)
233 goto err_out_csr_res; 233 goto err_out_csr_res;
234 } 234 }
235 235
236 printk(KERN_INFO "mtd%d: %s at 0x%08lx, size %uMiB.\n", 236 printk(KERN_INFO "mtd%d: %s at 0x%08lx, size %zuMiB.\n",
237 mtd->index, ms02nv_name, addr, size >> 20); 237 mtd->index, ms02nv_name, addr, size >> 20);
238 238
239 mp->next = root_ms02nv_mtd; 239 mp->next = root_ms02nv_mtd;
diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c
index edac4156d69c..bb713fed2f37 100644
--- a/drivers/mtd/devices/mtdram.c
+++ b/drivers/mtd/devices/mtdram.c
@@ -1,9 +1,10 @@
1/* 1/*
2 * mtdram - a test mtd device 2 * mtdram - a test mtd device
3 * $Id: mtdram.c,v 1.35 2005/01/05 18:05:12 dwmw2 Exp $ 3 * $Id: mtdram.c,v 1.37 2005/04/21 03:42:11 joern Exp $
4 * Author: Alexander Larsson <alex@cendio.se> 4 * Author: Alexander Larsson <alex@cendio.se>
5 * 5 *
6 * Copyright (c) 1999 Alexander Larsson <alex@cendio.se> 6 * Copyright (c) 1999 Alexander Larsson <alex@cendio.se>
7 * Copyright (c) 2005 Joern Engel <joern@wh.fh-wedel.de>
7 * 8 *
8 * This code is GPL 9 * This code is GPL
9 * 10 *
@@ -18,213 +19,140 @@
18#include <linux/mtd/compatmac.h> 19#include <linux/mtd/compatmac.h>
19#include <linux/mtd/mtd.h> 20#include <linux/mtd/mtd.h>
20 21
21#ifndef CONFIG_MTDRAM_ABS_POS
22 #define CONFIG_MTDRAM_ABS_POS 0
23#endif
24
25#if CONFIG_MTDRAM_ABS_POS > 0
26 #include <asm/io.h>
27#endif
28
29#ifdef MODULE
30static unsigned long total_size = CONFIG_MTDRAM_TOTAL_SIZE; 22static unsigned long total_size = CONFIG_MTDRAM_TOTAL_SIZE;
31static unsigned long erase_size = CONFIG_MTDRAM_ERASE_SIZE; 23static unsigned long erase_size = CONFIG_MTDRAM_ERASE_SIZE;
32module_param(total_size,ulong,0);
33MODULE_PARM_DESC(total_size, "Total device size in KiB");
34module_param(erase_size,ulong,0);
35MODULE_PARM_DESC(erase_size, "Device erase block size in KiB");
36#define MTDRAM_TOTAL_SIZE (total_size * 1024) 24#define MTDRAM_TOTAL_SIZE (total_size * 1024)
37#define MTDRAM_ERASE_SIZE (erase_size * 1024) 25#define MTDRAM_ERASE_SIZE (erase_size * 1024)
38#else
39#define MTDRAM_TOTAL_SIZE (CONFIG_MTDRAM_TOTAL_SIZE * 1024)
40#define MTDRAM_ERASE_SIZE (CONFIG_MTDRAM_ERASE_SIZE * 1024)
41#endif
42 26
27#ifdef MODULE
28module_param(total_size, ulong, 0);
29MODULE_PARM_DESC(total_size, "Total device size in KiB");
30module_param(erase_size, ulong, 0);
31MODULE_PARM_DESC(erase_size, "Device erase block size in KiB");
32#endif
43 33
44// We could store these in the mtd structure, but we only support 1 device.. 34// We could store these in the mtd structure, but we only support 1 device..
45static struct mtd_info *mtd_info; 35static struct mtd_info *mtd_info;
46 36
47 37static int ram_erase(struct mtd_info *mtd, struct erase_info *instr)
48static int
49ram_erase(struct mtd_info *mtd, struct erase_info *instr)
50{ 38{
51 DEBUG(MTD_DEBUG_LEVEL2, "ram_erase(pos:%ld, len:%ld)\n", (long)instr->addr, (long)instr->len); 39 if (instr->addr + instr->len > mtd->size)
52 if (instr->addr + instr->len > mtd->size) { 40 return -EINVAL;
53 DEBUG(MTD_DEBUG_LEVEL1, "ram_erase() out of bounds (%ld > %ld)\n", (long)(instr->addr + instr->len), (long)mtd->size); 41
54 return -EINVAL; 42 memset((char *)mtd->priv + instr->addr, 0xff, instr->len);
55 } 43
56 44 instr->state = MTD_ERASE_DONE;
57 memset((char *)mtd->priv + instr->addr, 0xff, instr->len); 45 mtd_erase_callback(instr);
58 46
59 instr->state = MTD_ERASE_DONE; 47 return 0;
60 mtd_erase_callback(instr);
61
62 return 0;
63} 48}
64 49
65static int ram_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf) 50static int ram_point(struct mtd_info *mtd, loff_t from, size_t len,
51 size_t *retlen, u_char **mtdbuf)
66{ 52{
67 if (from + len > mtd->size) 53 if (from + len > mtd->size)
68 return -EINVAL; 54 return -EINVAL;
69 55
70 *mtdbuf = mtd->priv + from; 56 *mtdbuf = mtd->priv + from;
71 *retlen = len; 57 *retlen = len;
72 return 0; 58 return 0;
73} 59}
74 60
75static void ram_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, 61static void ram_unpoint(struct mtd_info *mtd, u_char * addr, loff_t from,
76 size_t len) 62 size_t len)
77{ 63{
78 DEBUG(MTD_DEBUG_LEVEL2, "ram_unpoint\n");
79} 64}
80 65
81static int ram_read(struct mtd_info *mtd, loff_t from, size_t len, 66static int ram_read(struct mtd_info *mtd, loff_t from, size_t len,
82 size_t *retlen, u_char *buf) 67 size_t *retlen, u_char *buf)
83{ 68{
84 DEBUG(MTD_DEBUG_LEVEL2, "ram_read(pos:%ld, len:%ld)\n", (long)from, (long)len); 69 if (from + len > mtd->size)
85 if (from + len > mtd->size) { 70 return -EINVAL;
86 DEBUG(MTD_DEBUG_LEVEL1, "ram_read() out of bounds (%ld > %ld)\n", (long)(from + len), (long)mtd->size);
87 return -EINVAL;
88 }
89 71
90 memcpy(buf, mtd->priv + from, len); 72 memcpy(buf, mtd->priv + from, len);
91 73
92 *retlen=len; 74 *retlen = len;
93 return 0; 75 return 0;
94} 76}
95 77
96static int ram_write(struct mtd_info *mtd, loff_t to, size_t len, 78static int ram_write(struct mtd_info *mtd, loff_t to, size_t len,
97 size_t *retlen, const u_char *buf) 79 size_t *retlen, const u_char *buf)
98{ 80{
99 DEBUG(MTD_DEBUG_LEVEL2, "ram_write(pos:%ld, len:%ld)\n", (long)to, (long)len); 81 if (to + len > mtd->size)
100 if (to + len > mtd->size) { 82 return -EINVAL;
101 DEBUG(MTD_DEBUG_LEVEL1, "ram_write() out of bounds (%ld > %ld)\n", (long)(to + len), (long)mtd->size);
102 return -EINVAL;
103 }
104 83
105 memcpy ((char *)mtd->priv + to, buf, len); 84 memcpy((char *)mtd->priv + to, buf, len);
106 85
107 *retlen=len; 86 *retlen = len;
108 return 0; 87 return 0;
109} 88}
110 89
111static void __exit cleanup_mtdram(void) 90static void __exit cleanup_mtdram(void)
112{ 91{
113 if (mtd_info) { 92 if (mtd_info) {
114 del_mtd_device(mtd_info); 93 del_mtd_device(mtd_info);
115#if CONFIG_MTDRAM_TOTAL_SIZE > 0 94 if (mtd_info->priv)
116 if (mtd_info->priv) 95 vfree(mtd_info->priv);
117#if CONFIG_MTDRAM_ABS_POS > 0 96 kfree(mtd_info);
118 iounmap(mtd_info->priv); 97 }
119#else
120 vfree(mtd_info->priv);
121#endif
122#endif
123 kfree(mtd_info);
124 }
125}
126
127int mtdram_init_device(struct mtd_info *mtd, void *mapped_address,
128 unsigned long size, char *name)
129{
130 memset(mtd, 0, sizeof(*mtd));
131
132 /* Setup the MTD structure */
133 mtd->name = name;
134 mtd->type = MTD_RAM;
135 mtd->flags = MTD_CAP_RAM;
136 mtd->size = size;
137 mtd->erasesize = MTDRAM_ERASE_SIZE;
138 mtd->priv = mapped_address;
139
140 mtd->owner = THIS_MODULE;
141 mtd->erase = ram_erase;
142 mtd->point = ram_point;
143 mtd->unpoint = ram_unpoint;
144 mtd->read = ram_read;
145 mtd->write = ram_write;
146
147 if (add_mtd_device(mtd)) {
148 return -EIO;
149 }
150
151 return 0;
152}
153
154#if CONFIG_MTDRAM_TOTAL_SIZE > 0
155#if CONFIG_MTDRAM_ABS_POS > 0
156static int __init init_mtdram(void)
157{
158 void *addr;
159 int err;
160 /* Allocate some memory */
161 mtd_info = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
162 if (!mtd_info)
163 return -ENOMEM;
164
165 addr = ioremap(CONFIG_MTDRAM_ABS_POS, MTDRAM_TOTAL_SIZE);
166 if (!addr) {
167 DEBUG(MTD_DEBUG_LEVEL1,
168 "Failed to ioremap) memory region of size %ld at ABS_POS:%ld\n",
169 (long)MTDRAM_TOTAL_SIZE, (long)CONFIG_MTDRAM_ABS_POS);
170 kfree(mtd_info);
171 mtd_info = NULL;
172 return -ENOMEM;
173 }
174 err = mtdram_init_device(mtd_info, addr,
175 MTDRAM_TOTAL_SIZE, "mtdram test device");
176 if (err)
177 {
178 iounmap(addr);
179 kfree(mtd_info);
180 mtd_info = NULL;
181 return err;
182 }
183 memset(mtd_info->priv, 0xff, MTDRAM_TOTAL_SIZE);
184 return err;
185} 98}
186 99
187#else /* CONFIG_MTDRAM_ABS_POS > 0 */ 100int mtdram_init_device(struct mtd_info *mtd, void *mapped_address,
188 101 unsigned long size, char *name)
189static int __init init_mtdram(void)
190{ 102{
191 void *addr; 103 memset(mtd, 0, sizeof(*mtd));
192 int err; 104
193 /* Allocate some memory */ 105 /* Setup the MTD structure */
194 mtd_info = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); 106 mtd->name = name;
195 if (!mtd_info) 107 mtd->type = MTD_RAM;
196 return -ENOMEM; 108 mtd->flags = MTD_CAP_RAM;
197 109 mtd->size = size;
198 addr = vmalloc(MTDRAM_TOTAL_SIZE); 110 mtd->erasesize = MTDRAM_ERASE_SIZE;
199 if (!addr) { 111 mtd->priv = mapped_address;
200 DEBUG(MTD_DEBUG_LEVEL1, 112
201 "Failed to vmalloc memory region of size %ld\n", 113 mtd->owner = THIS_MODULE;
202 (long)MTDRAM_TOTAL_SIZE); 114 mtd->erase = ram_erase;
203 kfree(mtd_info); 115 mtd->point = ram_point;
204 mtd_info = NULL; 116 mtd->unpoint = ram_unpoint;
205 return -ENOMEM; 117 mtd->read = ram_read;
206 } 118 mtd->write = ram_write;
207 err = mtdram_init_device(mtd_info, addr, 119
208 MTDRAM_TOTAL_SIZE, "mtdram test device"); 120 if (add_mtd_device(mtd)) {
209 if (err) 121 return -EIO;
210 { 122 }
211 vfree(addr); 123
212 kfree(mtd_info); 124 return 0;
213 mtd_info = NULL;
214 return err;
215 }
216 memset(mtd_info->priv, 0xff, MTDRAM_TOTAL_SIZE);
217 return err;
218} 125}
219#endif /* !(CONFIG_MTDRAM_ABS_POS > 0) */
220
221#else /* CONFIG_MTDRAM_TOTAL_SIZE > 0 */
222 126
223static int __init init_mtdram(void) 127static int __init init_mtdram(void)
224{ 128{
225 return 0; 129 void *addr;
130 int err;
131
132 if (!total_size)
133 return -EINVAL;
134
135 /* Allocate some memory */
136 mtd_info = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
137 if (!mtd_info)
138 return -ENOMEM;
139
140 addr = vmalloc(MTDRAM_TOTAL_SIZE);
141 if (!addr) {
142 kfree(mtd_info);
143 mtd_info = NULL;
144 return -ENOMEM;
145 }
146 err = mtdram_init_device(mtd_info, addr, MTDRAM_TOTAL_SIZE, "mtdram test device");
147 if (err) {
148 vfree(addr);
149 kfree(mtd_info);
150 mtd_info = NULL;
151 return err;
152 }
153 memset(mtd_info->priv, 0xff, MTDRAM_TOTAL_SIZE);
154 return err;
226} 155}
227#endif /* !(CONFIG_MTDRAM_TOTAL_SIZE > 0) */
228 156
229module_init(init_mtdram); 157module_init(init_mtdram);
230module_exit(cleanup_mtdram); 158module_exit(cleanup_mtdram);
@@ -232,4 +160,3 @@ module_exit(cleanup_mtdram);
232MODULE_LICENSE("GPL"); 160MODULE_LICENSE("GPL");
233MODULE_AUTHOR("Alexander Larsson <alexl@redhat.com>"); 161MODULE_AUTHOR("Alexander Larsson <alexl@redhat.com>");
234MODULE_DESCRIPTION("Simulated MTD driver for testing"); 162MODULE_DESCRIPTION("Simulated MTD driver for testing");
235
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 5f8e164ddb71..a423a382095a 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -1,5 +1,5 @@
1/** 1/**
2 * $Id: phram.c,v 1.11 2005/01/05 18:05:13 dwmw2 Exp $ 2 * $Id: phram.c,v 1.14 2005/03/07 21:43:38 joern Exp $
3 * 3 *
4 * Copyright (c) ???? Jochen Schäuble <psionic@psionic.de> 4 * Copyright (c) ???? Jochen Schäuble <psionic@psionic.de>
5 * Copyright (c) 2003-2004 Jörn Engel <joern@wh.fh-wedel.de> 5 * Copyright (c) 2003-2004 Jörn Engel <joern@wh.fh-wedel.de>
@@ -15,9 +15,7 @@
15 * 15 *
16 * Example: 16 * Example:
17 * phram=swap,64Mi,128Mi phram=test,900Mi,1Mi 17 * phram=swap,64Mi,128Mi phram=test,900Mi,1Mi
18 *
19 */ 18 */
20
21#include <asm/io.h> 19#include <asm/io.h>
22#include <linux/init.h> 20#include <linux/init.h>
23#include <linux/kernel.h> 21#include <linux/kernel.h>
@@ -36,7 +34,6 @@ struct phram_mtd_list {
36static LIST_HEAD(phram_list); 34static LIST_HEAD(phram_list);
37 35
38 36
39
40static int phram_erase(struct mtd_info *mtd, struct erase_info *instr) 37static int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
41{ 38{
42 u_char *start = mtd->priv; 39 u_char *start = mtd->priv;
@@ -71,7 +68,8 @@ static int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
71 return 0; 68 return 0;
72} 69}
73 70
74static void phram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, size_t len) 71static void phram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from,
72 size_t len)
75{ 73{
76} 74}
77 75
@@ -80,8 +78,11 @@ static int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
80{ 78{
81 u_char *start = mtd->priv; 79 u_char *start = mtd->priv;
82 80
83 if (from + len > mtd->size) 81 if (from >= mtd->size)
84 return -EINVAL; 82 return -EINVAL;
83
84 if (len > mtd->size - from)
85 len = mtd->size - from;
85 86
86 memcpy(buf, start + from, len); 87 memcpy(buf, start + from, len);
87 88
@@ -94,8 +95,11 @@ static int phram_write(struct mtd_info *mtd, loff_t to, size_t len,
94{ 95{
95 u_char *start = mtd->priv; 96 u_char *start = mtd->priv;
96 97
97 if (to + len > mtd->size) 98 if (to >= mtd->size)
98 return -EINVAL; 99 return -EINVAL;
100
101 if (len > mtd->size - to)
102 len = mtd->size - to;
99 103
100 memcpy(start + to, buf, len); 104 memcpy(start + to, buf, len);
101 105
@@ -107,9 +111,9 @@ static int phram_write(struct mtd_info *mtd, loff_t to, size_t len,
107 111
108static void unregister_devices(void) 112static void unregister_devices(void)
109{ 113{
110 struct phram_mtd_list *this; 114 struct phram_mtd_list *this, *safe;
111 115
112 list_for_each_entry(this, &phram_list, list) { 116 list_for_each_entry_safe(this, safe, &phram_list, list) {
113 del_mtd_device(&this->mtd); 117 del_mtd_device(&this->mtd);
114 iounmap(this->mtd.priv); 118 iounmap(this->mtd.priv);
115 kfree(this); 119 kfree(this);
@@ -145,7 +149,7 @@ static int register_device(char *name, unsigned long start, unsigned long len)
145 new->mtd.write = phram_write; 149 new->mtd.write = phram_write;
146 new->mtd.owner = THIS_MODULE; 150 new->mtd.owner = THIS_MODULE;
147 new->mtd.type = MTD_RAM; 151 new->mtd.type = MTD_RAM;
148 new->mtd.erasesize = 0; 152 new->mtd.erasesize = PAGE_SIZE;
149 153
150 ret = -EAGAIN; 154 ret = -EAGAIN;
151 if (add_mtd_device(&new->mtd)) { 155 if (add_mtd_device(&new->mtd)) {
@@ -214,6 +218,15 @@ static int parse_name(char **pname, const char *token)
214 return 0; 218 return 0;
215} 219}
216 220
221
222static inline void kill_final_newline(char *str)
223{
224 char *newline = strrchr(str, '\n');
225 if (newline && !newline[1])
226 *newline = 0;
227}
228
229
217#define parse_err(fmt, args...) do { \ 230#define parse_err(fmt, args...) do { \
218 ERROR(fmt , ## args); \ 231 ERROR(fmt , ## args); \
219 return 0; \ 232 return 0; \
@@ -232,6 +245,7 @@ static int phram_setup(const char *val, struct kernel_param *kp)
232 parse_err("parameter too long\n"); 245 parse_err("parameter too long\n");
233 246
234 strcpy(str, val); 247 strcpy(str, val);
248 kill_final_newline(str);
235 249
236 for (i=0; i<3; i++) 250 for (i=0; i<3; i++)
237 token[i] = strsep(&str, ","); 251 token[i] = strsep(&str, ",");
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 5ab15e643be7..84fa91392a8c 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -1,6 +1,6 @@
1/*====================================================================== 1/*======================================================================
2 2
3 $Id: slram.c,v 1.33 2005/01/05 18:05:13 dwmw2 Exp $ 3 $Id: slram.c,v 1.34 2005/01/06 21:16:42 jwboyer Exp $
4 4
5 This driver provides a method to access memory not used by the kernel 5 This driver provides a method to access memory not used by the kernel
6 itself (i.e. if the kernel commandline mem=xxx is used). To actually 6 itself (i.e. if the kernel commandline mem=xxx is used). To actually
@@ -50,6 +50,7 @@
50#include <linux/mtd/mtd.h> 50#include <linux/mtd/mtd.h>
51 51
52#define SLRAM_MAX_DEVICES_PARAMS 6 /* 3 parameters / device */ 52#define SLRAM_MAX_DEVICES_PARAMS 6 /* 3 parameters / device */
53#define SLRAM_BLK_SZ 0x4000
53 54
54#define T(fmt, args...) printk(KERN_DEBUG fmt, ## args) 55#define T(fmt, args...) printk(KERN_DEBUG fmt, ## args)
55#define E(fmt, args...) printk(KERN_NOTICE fmt, ## args) 56#define E(fmt, args...) printk(KERN_NOTICE fmt, ## args)
@@ -108,6 +109,9 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,
108{ 109{
109 slram_priv_t *priv = mtd->priv; 110 slram_priv_t *priv = mtd->priv;
110 111
112 if (from + len > mtd->size)
113 return -EINVAL;
114
111 *mtdbuf = priv->start + from; 115 *mtdbuf = priv->start + from;
112 *retlen = len; 116 *retlen = len;
113 return(0); 117 return(0);
@@ -121,7 +125,13 @@ static int slram_read(struct mtd_info *mtd, loff_t from, size_t len,
121 size_t *retlen, u_char *buf) 125 size_t *retlen, u_char *buf)
122{ 126{
123 slram_priv_t *priv = mtd->priv; 127 slram_priv_t *priv = mtd->priv;
124 128
129 if (from > mtd->size)
130 return -EINVAL;
131
132 if (from + len > mtd->size)
133 len = mtd->size - from;
134
125 memcpy(buf, priv->start + from, len); 135 memcpy(buf, priv->start + from, len);
126 136
127 *retlen = len; 137 *retlen = len;
@@ -133,6 +143,9 @@ static int slram_write(struct mtd_info *mtd, loff_t to, size_t len,
133{ 143{
134 slram_priv_t *priv = mtd->priv; 144 slram_priv_t *priv = mtd->priv;
135 145
146 if (to + len > mtd->size)
147 return -EINVAL;
148
136 memcpy(priv->start + to, buf, len); 149 memcpy(priv->start + to, buf, len);
137 150
138 *retlen = len; 151 *retlen = len;
@@ -188,7 +201,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
188 (*curmtd)->mtdinfo->name = name; 201 (*curmtd)->mtdinfo->name = name;
189 (*curmtd)->mtdinfo->size = length; 202 (*curmtd)->mtdinfo->size = length;
190 (*curmtd)->mtdinfo->flags = MTD_CLEAR_BITS | MTD_SET_BITS | 203 (*curmtd)->mtdinfo->flags = MTD_CLEAR_BITS | MTD_SET_BITS |
191 MTD_WRITEB_WRITEABLE | MTD_VOLATILE; 204 MTD_WRITEB_WRITEABLE | MTD_VOLATILE | MTD_CAP_RAM;
192 (*curmtd)->mtdinfo->erase = slram_erase; 205 (*curmtd)->mtdinfo->erase = slram_erase;
193 (*curmtd)->mtdinfo->point = slram_point; 206 (*curmtd)->mtdinfo->point = slram_point;
194 (*curmtd)->mtdinfo->unpoint = slram_unpoint; 207 (*curmtd)->mtdinfo->unpoint = slram_unpoint;
@@ -196,7 +209,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
196 (*curmtd)->mtdinfo->write = slram_write; 209 (*curmtd)->mtdinfo->write = slram_write;
197 (*curmtd)->mtdinfo->owner = THIS_MODULE; 210 (*curmtd)->mtdinfo->owner = THIS_MODULE;
198 (*curmtd)->mtdinfo->type = MTD_RAM; 211 (*curmtd)->mtdinfo->type = MTD_RAM;
199 (*curmtd)->mtdinfo->erasesize = 0x0; 212 (*curmtd)->mtdinfo->erasesize = SLRAM_BLK_SZ;
200 213
201 if (add_mtd_device((*curmtd)->mtdinfo)) { 214 if (add_mtd_device((*curmtd)->mtdinfo)) {
202 E("slram: Failed to register new device\n"); 215 E("slram: Failed to register new device\n");
@@ -261,7 +274,7 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength)
261 } 274 }
262 T("slram: devname=%s, devstart=0x%lx, devlength=0x%lx\n", 275 T("slram: devname=%s, devstart=0x%lx, devlength=0x%lx\n",
263 devname, devstart, devlength); 276 devname, devstart, devlength);
264 if ((devstart < 0) || (devlength < 0)) { 277 if ((devstart < 0) || (devlength < 0) || (devlength % SLRAM_BLK_SZ != 0)) {
265 E("slram: Illegal start / length parameter.\n"); 278 E("slram: Illegal start / length parameter.\n");
266 return(-EINVAL); 279 return(-EINVAL);
267 } 280 }
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index 18cc8846e733..d9ab60b36fd4 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -1,5 +1,5 @@
1/* This version ported to the Linux-MTD system by dwmw2@infradead.org 1/* This version ported to the Linux-MTD system by dwmw2@infradead.org
2 * $Id: ftl.c,v 1.54 2004/11/16 18:33:15 dwmw2 Exp $ 2 * $Id: ftl.c,v 1.55 2005/01/17 13:47:21 hvr Exp $
3 * 3 *
4 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br> 4 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups 5 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups
@@ -357,6 +357,7 @@ static int erase_xfer(partition_t *part,
357 if (!erase) 357 if (!erase)
358 return -ENOMEM; 358 return -ENOMEM;
359 359
360 erase->mtd = part->mbd.mtd;
360 erase->callback = ftl_erase_callback; 361 erase->callback = ftl_erase_callback;
361 erase->addr = xfer->Offset; 362 erase->addr = xfer->Offset;
362 erase->len = 1 << part->header.EraseUnitSize; 363 erase->len = 1 << part->header.EraseUnitSize;
@@ -1096,7 +1097,7 @@ struct mtd_blktrans_ops ftl_tr = {
1096 1097
1097int init_ftl(void) 1098int init_ftl(void)
1098{ 1099{
1099 DEBUG(0, "$Id: ftl.c,v 1.54 2004/11/16 18:33:15 dwmw2 Exp $\n"); 1100 DEBUG(0, "$Id: ftl.c,v 1.55 2005/01/17 13:47:21 hvr Exp $\n");
1100 1101
1101 return register_mtd_blktrans(&ftl_tr); 1102 return register_mtd_blktrans(&ftl_tr);
1102} 1103}
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 2bea2e0b06f2..44781a83b2e7 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -1,5 +1,5 @@
1# drivers/mtd/maps/Kconfig 1# drivers/mtd/maps/Kconfig
2# $Id: Kconfig,v 1.42 2005/01/05 16:59:50 dwmw2 Exp $ 2# $Id: Kconfig,v 1.55 2005/07/02 01:53:24 tpoynor Exp $
3 3
4menu "Mapping drivers for chip access" 4menu "Mapping drivers for chip access"
5 depends on MTD!=n 5 depends on MTD!=n
@@ -122,16 +122,6 @@ config MTD_SBC_GXX
122 More info at 122 More info at
123 <http://www.arcomcontrols.com/products/icp/pc104/processors/SBC_GX1.htm>. 123 <http://www.arcomcontrols.com/products/icp/pc104/processors/SBC_GX1.htm>.
124 124
125config MTD_ELAN_104NC
126 tristate "CFI Flash device mapped on Arcom ELAN-104NC"
127 depends on X86 && MTD_CFI_INTELEXT && MTD_PARTITIONS && MTD_COMPLEX_MAPPINGS
128 help
129 This provides a driver for the on-board flash of the Arcom Control
130 System's ELAN-104NC development board. By default the flash
131 is split into 3 partitions which are accessed as separate MTD
132 devices. This board utilizes Intel StrataFlash. More info at
133 <http://www.arcomcontrols.com/products/icp/pc104/processors/ELAN104NC.htm>.
134
135config MTD_LUBBOCK 125config MTD_LUBBOCK
136 tristate "CFI Flash device mapped on Intel Lubbock XScale eval board" 126 tristate "CFI Flash device mapped on Intel Lubbock XScale eval board"
137 depends on ARCH_LUBBOCK && MTD_CFI_INTELEXT && MTD_PARTITIONS 127 depends on ARCH_LUBBOCK && MTD_CFI_INTELEXT && MTD_PARTITIONS
@@ -139,6 +129,14 @@ config MTD_LUBBOCK
139 This provides a driver for the on-board flash of the Intel 129 This provides a driver for the on-board flash of the Intel
140 'Lubbock' XScale evaluation board. 130 'Lubbock' XScale evaluation board.
141 131
132config MTD_MAINSTONE
133 tristate "CFI Flash device mapped on Intel Mainstone XScale eval board"
134 depends on MACH_MAINSTONE && MTD_CFI_INTELEXT
135 select MTD_PARTITIONS
136 help
137 This provides a driver for the on-board flash of the Intel
138 'Mainstone PXA27x evaluation board.
139
142config MTD_OCTAGON 140config MTD_OCTAGON
143 tristate "JEDEC Flash device mapped on Octagon 5066 SBC" 141 tristate "JEDEC Flash device mapped on Octagon 5066 SBC"
144 depends on X86 && MTD_JEDEC && MTD_COMPLEX_MAPPINGS 142 depends on X86 && MTD_JEDEC && MTD_COMPLEX_MAPPINGS
@@ -213,74 +211,11 @@ config MTD_NETtel
213 help 211 help
214 Support for flash chips on NETtel/SecureEdge/SnapGear boards. 212 Support for flash chips on NETtel/SecureEdge/SnapGear boards.
215 213
216config MTD_PB1XXX 214config MTD_ALCHEMY
217 tristate "Flash devices on Alchemy PB1xxx boards" 215 tristate ' AMD Alchemy Pb1xxx/Db1xxx/RDK MTD support'
218 depends on MIPS && ( MIPS_PB1000 || MIPS_PB1100 || MIPS_PB1500 ) 216 depends on MIPS && SOC_AU1X00
219 help
220 Flash memory access on Alchemy Pb1000/Pb1100/Pb1500 boards
221
222config MTD_PB1XXX_BOOT
223 bool "PB1x00 boot flash device"
224 depends on MTD_PB1XXX && ( MIPS_PB1100 || MIPS_PB1500 )
225 help
226 Use the first of the two 32MiB flash banks on Pb1100/Pb1500 board.
227 You can say 'Y' to both this and 'MTD_PB1XXX_USER' below, to use
228 both banks.
229
230config MTD_PB1XXX_USER
231 bool "PB1x00 user flash device"
232 depends on MTD_PB1XXX && ( MIPS_PB1100 || MIPS_PB1500 )
233 default y if MTD_PB1XX_BOOT = n
234 help
235 Use the second of the two 32MiB flash banks on Pb1100/Pb1500 board.
236 You can say 'Y' to both this and 'MTD_PB1XXX_BOOT' above, to use
237 both banks.
238
239config MTD_PB1550
240 tristate "Flash devices on Alchemy PB1550 board"
241 depends on MIPS && MIPS_PB1550
242 help
243 Flash memory access on Alchemy Pb1550 board
244
245config MTD_PB1550_BOOT
246 bool "PB1550 boot flash device"
247 depends on MTD_PB1550
248 help 217 help
249 Use the first of the two 64MiB flash banks on Pb1550 board. 218 Flash memory access on AMD Alchemy Pb/Db/RDK Reference Boards
250 You can say 'Y' to both this and 'MTD_PB1550_USER' below, to use
251 both banks.
252
253config MTD_PB1550_USER
254 bool "PB1550 user flash device"
255 depends on MTD_PB1550
256 default y if MTD_PB1550_BOOT = n
257 help
258 Use the second of the two 64MiB flash banks on Pb1550 board.
259 You can say 'Y' to both this and 'MTD_PB1550_BOOT' above, to use
260 both banks.
261
262config MTD_DB1550
263 tristate "Flash devices on Alchemy DB1550 board"
264 depends on MIPS && MIPS_DB1550
265 help
266 Flash memory access on Alchemy Db1550 board
267
268config MTD_DB1550_BOOT
269 bool "DB1550 boot flash device"
270 depends on MTD_DB1550
271 help
272 Use the first of the two 64MiB flash banks on Db1550 board.
273 You can say 'Y' to both this and 'MTD_DB1550_USER' below, to use
274 both banks.
275
276config MTD_DB1550_USER
277 bool "DB1550 user flash device"
278 depends on MTD_DB1550
279 default y if MTD_DB1550_BOOT = n
280 help
281 Use the second of the two 64MiB flash banks on Db1550 board.
282 You can say 'Y' to both this and 'MTD_DB1550_BOOT' above, to use
283 both banks.
284 219
285config MTD_DILNETPC 220config MTD_DILNETPC
286 tristate "CFI Flash device mapped on DIL/Net PC" 221 tristate "CFI Flash device mapped on DIL/Net PC"
@@ -588,6 +523,15 @@ config MTD_MPC1211
588 This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02). 523 This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02).
589 If you have such a board, say 'Y'. 524 If you have such a board, say 'Y'.
590 525
526config MTD_OMAP_NOR
527 tristate "TI OMAP board mappings"
528 depends on MTD_CFI && ARCH_OMAP
529 help
530 This enables access to the NOR flash chips on TI OMAP-based
531 boards defining flash platform devices and flash platform data.
532 These boards include the Innovator, H2, H3, OSK, Perseus2, and
533 more. If you have such a board, say 'Y'.
534
591# This needs CFI or JEDEC, depending on the cards found. 535# This needs CFI or JEDEC, depending on the cards found.
592config MTD_PCI 536config MTD_PCI
593 tristate "PCI MTD driver" 537 tristate "PCI MTD driver"
@@ -647,13 +591,14 @@ config MTD_DMV182
647 Map driver for Dy-4 SVME/DMV-182 board. 591 Map driver for Dy-4 SVME/DMV-182 board.
648 592
649config MTD_BAST 593config MTD_BAST
650 tristate "Map driver for Simtec BAST (EB2410ITX)" 594 tristate "Map driver for Simtec BAST (EB2410ITX) or Thorcom VR1000"
651 depends on ARCH_BAST 595 depends on ARCH_BAST || MACH_VR1000
652 select MTD_PARTITIONS 596 select MTD_PARTITIONS
653 select MTD_MAP_BANK_WIDTH_16 597 select MTD_MAP_BANK_WIDTH_16
654 select MTD_JEDECPROBE 598 select MTD_JEDECPROBE
655 help 599 help
656 Map driver for NOR flash on the Simtec BAST (EB2410ITX). 600 Map driver for NOR flash on the Simtec BAST (EB2410ITX), or the
601 Thorcom VR1000
657 602
658 Note, this driver *cannot* over-ride the WP link on the 603 Note, this driver *cannot* over-ride the WP link on the
659 board, or currently detect the state of the link. 604 board, or currently detect the state of the link.
@@ -669,5 +614,15 @@ config MTD_SHARP_SL
669 help 614 help
670 This enables access to the flash chip on the Sharp SL Series of PDAs. 615 This enables access to the flash chip on the Sharp SL Series of PDAs.
671 616
617config MTD_PLATRAM
618 tristate "Map driver for platform device RAM (mtd-ram)"
619 depends on MTD
620 select MTD_RAM
621 help
622 Map driver for RAM areas described via the platform device
623 system.
624
625 This selection automatically selects the map_ram driver.
626
672endmenu 627endmenu
673 628
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 7ffe02b85301..7bcbc49e329f 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -1,7 +1,7 @@
1# 1#
2# linux/drivers/maps/Makefile 2# linux/drivers/maps/Makefile
3# 3#
4# $Id: Makefile.common,v 1.23 2005/01/05 17:06:36 dwmw2 Exp $ 4# $Id: Makefile.common,v 1.30 2005/07/02 01:53:24 tpoynor Exp $
5 5
6ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y) 6ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y)
7obj-$(CONFIG_MTD) += map_funcs.o 7obj-$(CONFIG_MTD) += map_funcs.o
@@ -15,7 +15,6 @@ obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o
15obj-$(CONFIG_MTD_CSTM_MIPS_IXX) += cstm_mips_ixx.o 15obj-$(CONFIG_MTD_CSTM_MIPS_IXX) += cstm_mips_ixx.o
16obj-$(CONFIG_MTD_DC21285) += dc21285.o 16obj-$(CONFIG_MTD_DC21285) += dc21285.o
17obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o 17obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o
18obj-$(CONFIG_MTD_ELAN_104NC) += elan-104nc.o
19obj-$(CONFIG_MTD_EPXA10DB) += epxa10db-flash.o 18obj-$(CONFIG_MTD_EPXA10DB) += epxa10db-flash.o
20obj-$(CONFIG_MTD_IQ80310) += iq80310.o 19obj-$(CONFIG_MTD_IQ80310) += iq80310.o
21obj-$(CONFIG_MTD_L440GX) += l440gx.o 20obj-$(CONFIG_MTD_L440GX) += l440gx.o
@@ -23,6 +22,7 @@ obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o
23obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o 22obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o
24obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o 23obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o
25obj-$(CONFIG_MTD_LUBBOCK) += lubbock-flash.o 24obj-$(CONFIG_MTD_LUBBOCK) += lubbock-flash.o
25obj-$(CONFIG_MTD_MAINSTONE) += mainstone-flash.o
26obj-$(CONFIG_MTD_MBX860) += mbx860.o 26obj-$(CONFIG_MTD_MBX860) += mbx860.o
27obj-$(CONFIG_MTD_CEIVA) += ceiva.o 27obj-$(CONFIG_MTD_CEIVA) += ceiva.o
28obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o 28obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o
@@ -44,10 +44,7 @@ obj-$(CONFIG_MTD_DBOX2) += dbox2-flash.o
44obj-$(CONFIG_MTD_OCELOT) += ocelot.o 44obj-$(CONFIG_MTD_OCELOT) += ocelot.o
45obj-$(CONFIG_MTD_SOLUTIONENGINE)+= solutionengine.o 45obj-$(CONFIG_MTD_SOLUTIONENGINE)+= solutionengine.o
46obj-$(CONFIG_MTD_PCI) += pci.o 46obj-$(CONFIG_MTD_PCI) += pci.o
47obj-$(CONFIG_MTD_PB1XXX) += pb1xxx-flash.o 47obj-$(CONFIG_MTD_ALCHEMY) += alchemy-flash.o
48obj-$(CONFIG_MTD_DB1X00) += db1x00-flash.o
49obj-$(CONFIG_MTD_PB1550) += pb1550-flash.o
50obj-$(CONFIG_MTD_DB1550) += db1550-flash.o
51obj-$(CONFIG_MTD_LASAT) += lasat.o 48obj-$(CONFIG_MTD_LASAT) += lasat.o
52obj-$(CONFIG_MTD_AUTCPU12) += autcpu12-nvram.o 49obj-$(CONFIG_MTD_AUTCPU12) += autcpu12-nvram.o
53obj-$(CONFIG_MTD_EDB7312) += edb7312.o 50obj-$(CONFIG_MTD_EDB7312) += edb7312.o
@@ -71,3 +68,5 @@ obj-$(CONFIG_MTD_IXP2000) += ixp2000.o
71obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o 68obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o
72obj-$(CONFIG_MTD_DMV182) += dmv182.o 69obj-$(CONFIG_MTD_DMV182) += dmv182.o
73obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o 70obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o
71obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o
72obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
diff --git a/drivers/mtd/maps/alchemy-flash.c b/drivers/mtd/maps/alchemy-flash.c
new file mode 100644
index 000000000000..27fd2a3c3b60
--- /dev/null
+++ b/drivers/mtd/maps/alchemy-flash.c
@@ -0,0 +1,192 @@
1/*
2 * Flash memory access on AMD Alchemy evaluation boards
3 *
4 * $Id: alchemy-flash.c,v 1.1 2005/02/27 21:50:21 ppopov Exp $
5 *
6 * (C) 2003, 2004 Pete Popov <ppopov@embeddedalley.com>
7 *
8 */
9
10#include <linux/config.h>
11#include <linux/init.h>
12#include <linux/module.h>
13#include <linux/types.h>
14#include <linux/kernel.h>
15
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/map.h>
18#include <linux/mtd/partitions.h>
19
20#include <asm/io.h>
21
22#ifdef DEBUG_RW
23#define DBG(x...) printk(x)
24#else
25#define DBG(x...)
26#endif
27
28#ifdef CONFIG_MIPS_PB1000
29#define BOARD_MAP_NAME "Pb1000 Flash"
30#define BOARD_FLASH_SIZE 0x00800000 /* 8MB */
31#define BOARD_FLASH_WIDTH 4 /* 32-bits */
32#endif
33
34#ifdef CONFIG_MIPS_PB1500
35#define BOARD_MAP_NAME "Pb1500 Flash"
36#define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
37#define BOARD_FLASH_WIDTH 4 /* 32-bits */
38#endif
39
40#ifdef CONFIG_MIPS_PB1100
41#define BOARD_MAP_NAME "Pb1100 Flash"
42#define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
43#define BOARD_FLASH_WIDTH 4 /* 32-bits */
44#endif
45
46#ifdef CONFIG_MIPS_PB1550
47#define BOARD_MAP_NAME "Pb1550 Flash"
48#define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
49#define BOARD_FLASH_WIDTH 4 /* 32-bits */
50#endif
51
52#ifdef CONFIG_MIPS_PB1200
53#define BOARD_MAP_NAME "Pb1200 Flash"
54#define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
55#define BOARD_FLASH_WIDTH 2 /* 16-bits */
56#endif
57
58#ifdef CONFIG_MIPS_DB1000
59#define BOARD_MAP_NAME "Db1000 Flash"
60#define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
61#define BOARD_FLASH_WIDTH 4 /* 32-bits */
62#endif
63
64#ifdef CONFIG_MIPS_DB1500
65#define BOARD_MAP_NAME "Db1500 Flash"
66#define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
67#define BOARD_FLASH_WIDTH 4 /* 32-bits */
68#endif
69
70#ifdef CONFIG_MIPS_DB1100
71#define BOARD_MAP_NAME "Db1100 Flash"
72#define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
73#define BOARD_FLASH_WIDTH 4 /* 32-bits */
74#endif
75
76#ifdef CONFIG_MIPS_DB1550
77#define BOARD_MAP_NAME "Db1550 Flash"
78#define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
79#define BOARD_FLASH_WIDTH 4 /* 32-bits */
80#endif
81
82#ifdef CONFIG_MIPS_DB1200
83#define BOARD_MAP_NAME "Db1200 Flash"
84#define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
85#define BOARD_FLASH_WIDTH 2 /* 16-bits */
86#endif
87
88#ifdef CONFIG_MIPS_HYDROGEN3
89#define BOARD_MAP_NAME "Hydrogen3 Flash"
90#define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
91#define BOARD_FLASH_WIDTH 4 /* 32-bits */
92#define USE_LOCAL_ACCESSORS /* why? */
93#endif
94
95#ifdef CONFIG_MIPS_BOSPORUS
96#define BOARD_MAP_NAME "Bosporus Flash"
97#define BOARD_FLASH_SIZE 0x01000000 /* 16MB */
98#define BOARD_FLASH_WIDTH 2 /* 16-bits */
99#endif
100
101#ifdef CONFIG_MIPS_MIRAGE
102#define BOARD_MAP_NAME "Mirage Flash"
103#define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
104#define BOARD_FLASH_WIDTH 4 /* 32-bits */
105#define USE_LOCAL_ACCESSORS /* why? */
106#endif
107
108static struct map_info alchemy_map = {
109 .name = BOARD_MAP_NAME,
110};
111
112static struct mtd_partition alchemy_partitions[] = {
113 {
114 .name = "User FS",
115 .size = BOARD_FLASH_SIZE - 0x00400000,
116 .offset = 0x0000000
117 },{
118 .name = "YAMON",
119 .size = 0x0100000,
120 .offset = MTDPART_OFS_APPEND,
121 .mask_flags = MTD_WRITEABLE
122 },{
123 .name = "raw kernel",
124 .size = (0x300000 - 0x40000), /* last 256KB is yamon env */
125 .offset = MTDPART_OFS_APPEND,
126 }
127};
128
129#define NB_OF(x) (sizeof(x)/sizeof(x[0]))
130
131static struct mtd_info *mymtd;
132
133int __init alchemy_mtd_init(void)
134{
135 struct mtd_partition *parts;
136 int nb_parts = 0;
137 unsigned long window_addr;
138 unsigned long window_size;
139
140 /* Default flash buswidth */
141 alchemy_map.bankwidth = BOARD_FLASH_WIDTH;
142
143 window_addr = 0x20000000 - BOARD_FLASH_SIZE;
144 window_size = BOARD_FLASH_SIZE;
145#ifdef CONFIG_MIPS_MIRAGE_WHY
146 /* Boot ROM flash bank only; no user bank */
147 window_addr = 0x1C000000;
148 window_size = 0x04000000;
149 /* USERFS from 0x1C00 0000 to 0x1FC00000 */
150 alchemy_partitions[0].size = 0x03C00000;
151#endif
152
153 /*
154 * Static partition definition selection
155 */
156 parts = alchemy_partitions;
157 nb_parts = NB_OF(alchemy_partitions);
158 alchemy_map.size = window_size;
159
160 /*
161 * Now let's probe for the actual flash. Do it here since
162 * specific machine settings might have been set above.
163 */
164 printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",
165 alchemy_map.bankwidth*8);
166 alchemy_map.virt = ioremap(window_addr, window_size);
167 mymtd = do_map_probe("cfi_probe", &alchemy_map);
168 if (!mymtd) {
169 iounmap(alchemy_map.virt);
170 return -ENXIO;
171 }
172 mymtd->owner = THIS_MODULE;
173
174 add_mtd_partitions(mymtd, parts, nb_parts);
175 return 0;
176}
177
178static void __exit alchemy_mtd_cleanup(void)
179{
180 if (mymtd) {
181 del_mtd_partitions(mymtd);
182 map_destroy(mymtd);
183 iounmap(alchemy_map.virt);
184 }
185}
186
187module_init(alchemy_mtd_init);
188module_exit(alchemy_mtd_cleanup);
189
190MODULE_AUTHOR("Embedded Alley Solutions, Inc");
191MODULE_DESCRIPTION(BOARD_MAP_NAME " MTD driver");
192MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
index 51e97b05304e..e8a900a77685 100644
--- a/drivers/mtd/maps/amd76xrom.c
+++ b/drivers/mtd/maps/amd76xrom.c
@@ -2,7 +2,7 @@
2 * amd76xrom.c 2 * amd76xrom.c
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * $Id: amd76xrom.c,v 1.19 2004/11/28 09:40:39 dwmw2 Exp $ 5 * $Id: amd76xrom.c,v 1.20 2005/03/18 14:04:35 gleixner Exp $
6 */ 6 */
7 7
8#include <linux/module.h> 8#include <linux/module.h>
@@ -314,7 +314,7 @@ static int __init init_amd76xrom(void)
314 } 314 }
315 return -ENXIO; 315 return -ENXIO;
316#if 0 316#if 0
317 return pci_module_init(&amd76xrom_driver); 317 return pci_register_driver(&amd76xrom_driver);
318#endif 318#endif
319} 319}
320 320
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c
index 44de3a81b277..0c45464e3f7b 100644
--- a/drivers/mtd/maps/bast-flash.c
+++ b/drivers/mtd/maps/bast-flash.c
@@ -1,14 +1,15 @@
1/* linux/drivers/mtd/maps/bast_flash.c 1/* linux/drivers/mtd/maps/bast_flash.c
2 * 2 *
3 * Copyright (c) 2004 Simtec Electronics 3 * Copyright (c) 2004-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 4 * Ben Dooks <ben@simtec.co.uk>
5 * 5 *
6 * Simtec Bast (EB2410ITX) NOR MTD Mapping driver 6 * Simtec Bast (EB2410ITX) NOR MTD Mapping driver
7 * 7 *
8 * Changelog: 8 * Changelog:
9 * 20-Sep-2004 BJD Initial version 9 * 20-Sep-2004 BJD Initial version
10 * 17-Jan-2005 BJD Add whole device if no partitions found
10 * 11 *
11 * $Id: bast-flash.c,v 1.1 2004/09/21 14:29:04 bjd Exp $ 12 * $Id: bast-flash.c,v 1.2 2005/01/18 11:13:47 bjd Exp $
12 * 13 *
13 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License as published by
@@ -46,9 +47,9 @@
46#include <asm/arch/bast-cpld.h> 47#include <asm/arch/bast-cpld.h>
47 48
48#ifdef CONFIG_MTD_BAST_MAXSIZE 49#ifdef CONFIG_MTD_BAST_MAXSIZE
49#define AREA_MAXSIZE (CONFIG_MTD_BAST_MAXSIZE * (1024*1024)) 50#define AREA_MAXSIZE (CONFIG_MTD_BAST_MAXSIZE * SZ_1M)
50#else 51#else
51#define AREA_MAXSIZE (32*1024*1024) 52#define AREA_MAXSIZE (32 * SZ_1M)
52#endif 53#endif
53 54
54#define PFX "bast-flash: " 55#define PFX "bast-flash: "
@@ -189,6 +190,8 @@ static int bast_flash_probe(struct device *dev)
189 err = add_mtd_partitions(info->mtd, info->partitions, err); 190 err = add_mtd_partitions(info->mtd, info->partitions, err);
190 if (err) 191 if (err)
191 printk(KERN_ERR PFX "cannot add/parse partitions\n"); 192 printk(KERN_ERR PFX "cannot add/parse partitions\n");
193 } else {
194 err = add_mtd_device(info->mtd);
192 } 195 }
193 196
194 if (err == 0) 197 if (err == 0)
diff --git a/drivers/mtd/maps/db1550-flash.c b/drivers/mtd/maps/db1550-flash.c
deleted file mode 100644
index d213888462a4..000000000000
--- a/drivers/mtd/maps/db1550-flash.c
+++ /dev/null
@@ -1,187 +0,0 @@
1/*
2 * Flash memory access on Alchemy Db1550 board
3 *
4 * $Id: db1550-flash.c,v 1.7 2004/11/04 13:24:14 gleixner Exp $
5 *
6 * (C) 2004 Embedded Edge, LLC, based on db1550-flash.c:
7 * (C) 2003, 2004 Pete Popov <ppopov@embeddedalley.com>
8 *
9 */
10
11#include <linux/config.h>
12#include <linux/init.h>
13#include <linux/module.h>
14#include <linux/types.h>
15#include <linux/kernel.h>
16
17#include <linux/mtd/mtd.h>
18#include <linux/mtd/map.h>
19#include <linux/mtd/partitions.h>
20
21#include <asm/io.h>
22
23#ifdef DEBUG_RW
24#define DBG(x...) printk(x)
25#else
26#define DBG(x...)
27#endif
28
29static unsigned long window_addr;
30static unsigned long window_size;
31
32
33static struct map_info db1550_map = {
34 .name = "Db1550 flash",
35};
36
37static unsigned char flash_bankwidth = 4;
38
39/*
40 * Support only 64MB NOR Flash parts
41 */
42
43#if defined(CONFIG_MTD_DB1550_BOOT) && defined(CONFIG_MTD_DB1550_USER)
44#define DB1550_BOTH_BANKS
45#elif defined(CONFIG_MTD_DB1550_BOOT) && !defined(CONFIG_MTD_DB1550_USER)
46#define DB1550_BOOT_ONLY
47#elif !defined(CONFIG_MTD_DB1550_BOOT) && defined(CONFIG_MTD_DB1550_USER)
48#define DB1550_USER_ONLY
49#endif
50
51#ifdef DB1550_BOTH_BANKS
52/* both banks will be used. Combine the first bank and the first
53 * part of the second bank together into a single jffs/jffs2
54 * partition.
55 */
56static struct mtd_partition db1550_partitions[] = {
57 /* assume boot[2:0]:swap is '0000' or '1000', which translates to:
58 * 1C00 0000 1FFF FFFF CE0 64MB Boot NOR Flash
59 * 1800 0000 1BFF FFFF CE0 64MB Param NOR Flash
60 */
61 {
62 .name = "User FS",
63 .size = (0x1FC00000 - 0x18000000),
64 .offset = 0x0000000
65 },{
66 .name = "yamon",
67 .size = 0x0100000,
68 .offset = MTDPART_OFS_APPEND,
69 .mask_flags = MTD_WRITEABLE
70 },{
71 .name = "raw kernel",
72 .size = (0x300000 - 0x40000), /* last 256KB is yamon env */
73 .offset = MTDPART_OFS_APPEND,
74 }
75};
76#elif defined(DB1550_BOOT_ONLY)
77static struct mtd_partition db1550_partitions[] = {
78 /* assume boot[2:0]:swap is '0000' or '1000', which translates to:
79 * 1C00 0000 1FFF FFFF CE0 64MB Boot NOR Flash
80 */
81 {
82 .name = "User FS",
83 .size = 0x03c00000,
84 .offset = 0x0000000
85 },{
86 .name = "yamon",
87 .size = 0x0100000,
88 .offset = MTDPART_OFS_APPEND,
89 .mask_flags = MTD_WRITEABLE
90 },{
91 .name = "raw kernel",
92 .size = (0x300000-0x40000), /* last 256KB is yamon env */
93 .offset = MTDPART_OFS_APPEND,
94 }
95};
96#elif defined(DB1550_USER_ONLY)
97static struct mtd_partition db1550_partitions[] = {
98 /* assume boot[2:0]:swap is '0000' or '1000', which translates to:
99 * 1800 0000 1BFF FFFF CE0 64MB Param NOR Flash
100 */
101 {
102 .name = "User FS",
103 .size = (0x4000000 - 0x200000), /* reserve 2MB for raw kernel */
104 .offset = 0x0000000
105 },{
106 .name = "raw kernel",
107 .size = MTDPART_SIZ_FULL,
108 .offset = MTDPART_OFS_APPEND,
109 }
110};
111#else
112#error MTD_DB1550 define combo error /* should never happen */
113#endif
114
115#define NB_OF(x) (sizeof(x)/sizeof(x[0]))
116
117static struct mtd_info *mymtd;
118
119/*
120 * Probe the flash density and setup window address and size
121 * based on user CONFIG options. There are times when we don't
122 * want the MTD driver to be probing the boot or user flash,
123 * so having the option to enable only one bank is important.
124 */
125int setup_flash_params(void)
126{
127#if defined(DB1550_BOTH_BANKS)
128 window_addr = 0x18000000;
129 window_size = 0x8000000;
130#elif defined(DB1550_BOOT_ONLY)
131 window_addr = 0x1C000000;
132 window_size = 0x4000000;
133#else /* USER ONLY */
134 window_addr = 0x18000000;
135 window_size = 0x4000000;
136#endif
137 return 0;
138}
139
140int __init db1550_mtd_init(void)
141{
142 struct mtd_partition *parts;
143 int nb_parts = 0;
144
145 /* Default flash bankwidth */
146 db1550_map.bankwidth = flash_bankwidth;
147
148 if (setup_flash_params())
149 return -ENXIO;
150
151 /*
152 * Static partition definition selection
153 */
154 parts = db1550_partitions;
155 nb_parts = NB_OF(db1550_partitions);
156 db1550_map.size = window_size;
157
158 /*
159 * Now let's probe for the actual flash. Do it here since
160 * specific machine settings might have been set above.
161 */
162 printk(KERN_NOTICE "Db1550 flash: probing %d-bit flash bus\n",
163 db1550_map.bankwidth*8);
164 db1550_map.virt = ioremap(window_addr, window_size);
165 mymtd = do_map_probe("cfi_probe", &db1550_map);
166 if (!mymtd) return -ENXIO;
167 mymtd->owner = THIS_MODULE;
168
169 add_mtd_partitions(mymtd, parts, nb_parts);
170 return 0;
171}
172
173static void __exit db1550_mtd_cleanup(void)
174{
175 if (mymtd) {
176 del_mtd_partitions(mymtd);
177 map_destroy(mymtd);
178 iounmap((void *) db1550_map.virt);
179 }
180}
181
182module_init(db1550_mtd_init);
183module_exit(db1550_mtd_cleanup);
184
185MODULE_AUTHOR("Embedded Edge, LLC");
186MODULE_DESCRIPTION("Db1550 mtd map driver");
187MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/maps/db1x00-flash.c b/drivers/mtd/maps/db1x00-flash.c
deleted file mode 100644
index faa68ec56902..000000000000
--- a/drivers/mtd/maps/db1x00-flash.c
+++ /dev/null
@@ -1,226 +0,0 @@
1/*
2 * Flash memory access on Alchemy Db1xxx boards
3 *
4 * $Id: db1x00-flash.c,v 1.6 2004/11/04 13:24:14 gleixner Exp $
5 *
6 * (C) 2003 Pete Popov <ppopov@embeddedalley.com>
7 *
8 */
9
10#include <linux/config.h>
11#include <linux/module.h>
12#include <linux/types.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/map.h>
18#include <linux/mtd/partitions.h>
19
20#include <asm/io.h>
21
22#ifdef DEBUG_RW
23#define DBG(x...) printk(x)
24#else
25#define DBG(x...)
26#endif
27
28/* MTD CONFIG OPTIONS */
29#if defined(CONFIG_MTD_DB1X00_BOOT) && defined(CONFIG_MTD_DB1X00_USER)
30#define DB1X00_BOTH_BANKS
31#elif defined(CONFIG_MTD_DB1X00_BOOT) && !defined(CONFIG_MTD_DB1X00_USER)
32#define DB1X00_BOOT_ONLY
33#elif !defined(CONFIG_MTD_DB1X00_BOOT) && defined(CONFIG_MTD_DB1X00_USER)
34#define DB1X00_USER_ONLY
35#endif
36
37static unsigned long window_addr;
38static unsigned long window_size;
39static unsigned long flash_size;
40
41static unsigned short *bcsr = (unsigned short *)0xAE000000;
42static unsigned char flash_bankwidth = 4;
43
44/*
45 * The Db1x boards support different flash densities. We setup
46 * the mtd_partition structures below for default of 64Mbit
47 * flash densities, and override the partitions sizes, if
48 * necessary, after we check the board status register.
49 */
50
51#ifdef DB1X00_BOTH_BANKS
52/* both banks will be used. Combine the first bank and the first
53 * part of the second bank together into a single jffs/jffs2
54 * partition.
55 */
56static struct mtd_partition db1x00_partitions[] = {
57 {
58 .name = "User FS",
59 .size = 0x1c00000,
60 .offset = 0x0000000
61 },{
62 .name = "yamon",
63 .size = 0x0100000,
64 .offset = MTDPART_OFS_APPEND,
65 .mask_flags = MTD_WRITEABLE
66 },{
67 .name = "raw kernel",
68 .size = (0x300000-0x40000), /* last 256KB is env */
69 .offset = MTDPART_OFS_APPEND,
70 }
71};
72#elif defined(DB1X00_BOOT_ONLY)
73static struct mtd_partition db1x00_partitions[] = {
74 {
75 .name = "User FS",
76 .size = 0x00c00000,
77 .offset = 0x0000000
78 },{
79 .name = "yamon",
80 .size = 0x0100000,
81 .offset = MTDPART_OFS_APPEND,
82 .mask_flags = MTD_WRITEABLE
83 },{
84 .name = "raw kernel",
85 .size = (0x300000-0x40000), /* last 256KB is env */
86 .offset = MTDPART_OFS_APPEND,
87 }
88};
89#elif defined(DB1X00_USER_ONLY)
90static struct mtd_partition db1x00_partitions[] = {
91 {
92 .name = "User FS",
93 .size = 0x0e00000,
94 .offset = 0x0000000
95 },{
96 .name = "raw kernel",
97 .size = MTDPART_SIZ_FULL,
98 .offset = MTDPART_OFS_APPEND,
99 }
100};
101#else
102#error MTD_DB1X00 define combo error /* should never happen */
103#endif
104#define NB_OF(x) (sizeof(x)/sizeof(x[0]))
105
106#define NAME "Db1x00 Linux Flash"
107
108static struct map_info db1xxx_mtd_map = {
109 .name = NAME,
110};
111
112static struct mtd_partition *parsed_parts;
113static struct mtd_info *db1xxx_mtd;
114
115/*
116 * Probe the flash density and setup window address and size
117 * based on user CONFIG options. There are times when we don't
118 * want the MTD driver to be probing the boot or user flash,
119 * so having the option to enable only one bank is important.
120 */
121int setup_flash_params(void)
122{
123 switch ((bcsr[2] >> 14) & 0x3) {
124 case 0: /* 64Mbit devices */
125 flash_size = 0x800000; /* 8MB per part */
126#if defined(DB1X00_BOTH_BANKS)
127 window_addr = 0x1E000000;
128 window_size = 0x2000000;
129#elif defined(DB1X00_BOOT_ONLY)
130 window_addr = 0x1F000000;
131 window_size = 0x1000000;
132#else /* USER ONLY */
133 window_addr = 0x1E000000;
134 window_size = 0x1000000;
135#endif
136 break;
137 case 1:
138 /* 128 Mbit devices */
139 flash_size = 0x1000000; /* 16MB per part */
140#if defined(DB1X00_BOTH_BANKS)
141 window_addr = 0x1C000000;
142 window_size = 0x4000000;
143 /* USERFS from 0x1C00 0000 to 0x1FC0 0000 */
144 db1x00_partitions[0].size = 0x3C00000;
145#elif defined(DB1X00_BOOT_ONLY)
146 window_addr = 0x1E000000;
147 window_size = 0x2000000;
148 /* USERFS from 0x1E00 0000 to 0x1FC0 0000 */
149 db1x00_partitions[0].size = 0x1C00000;
150#else /* USER ONLY */
151 window_addr = 0x1C000000;
152 window_size = 0x2000000;
153 /* USERFS from 0x1C00 0000 to 0x1DE00000 */
154 db1x00_partitions[0].size = 0x1DE0000;
155#endif
156 break;
157 case 2:
158 /* 256 Mbit devices */
159 flash_size = 0x4000000; /* 64MB per part */
160#if defined(DB1X00_BOTH_BANKS)
161 return 1;
162#elif defined(DB1X00_BOOT_ONLY)
163 /* Boot ROM flash bank only; no user bank */
164 window_addr = 0x1C000000;
165 window_size = 0x4000000;
166 /* USERFS from 0x1C00 0000 to 0x1FC00000 */
167 db1x00_partitions[0].size = 0x3C00000;
168#else /* USER ONLY */
169 return 1;
170#endif
171 break;
172 default:
173 return 1;
174 }
175 db1xxx_mtd_map.size = window_size;
176 db1xxx_mtd_map.bankwidth = flash_bankwidth;
177 db1xxx_mtd_map.phys = window_addr;
178 db1xxx_mtd_map.bankwidth = flash_bankwidth;
179 return 0;
180}
181
182int __init db1x00_mtd_init(void)
183{
184 struct mtd_partition *parts;
185 int nb_parts = 0;
186
187 if (setup_flash_params())
188 return -ENXIO;
189
190 /*
191 * Static partition definition selection
192 */
193 parts = db1x00_partitions;
194 nb_parts = NB_OF(db1x00_partitions);
195
196 /*
197 * Now let's probe for the actual flash. Do it here since
198 * specific machine settings might have been set above.
199 */
200 printk(KERN_NOTICE "Db1xxx flash: probing %d-bit flash bus\n",
201 db1xxx_mtd_map.bankwidth*8);
202 db1xxx_mtd_map.virt = ioremap(window_addr, window_size);
203 db1xxx_mtd = do_map_probe("cfi_probe", &db1xxx_mtd_map);
204 if (!db1xxx_mtd) return -ENXIO;
205 db1xxx_mtd->owner = THIS_MODULE;
206
207 add_mtd_partitions(db1xxx_mtd, parts, nb_parts);
208 return 0;
209}
210
211static void __exit db1x00_mtd_cleanup(void)
212{
213 if (db1xxx_mtd) {
214 del_mtd_partitions(db1xxx_mtd);
215 map_destroy(db1xxx_mtd);
216 if (parsed_parts)
217 kfree(parsed_parts);
218 }
219}
220
221module_init(db1x00_mtd_init);
222module_exit(db1x00_mtd_cleanup);
223
224MODULE_AUTHOR("Pete Popov");
225MODULE_DESCRIPTION("Db1x00 mtd map driver");
226MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/maps/elan-104nc.c b/drivers/mtd/maps/elan-104nc.c
deleted file mode 100644
index e9465f5c069e..000000000000
--- a/drivers/mtd/maps/elan-104nc.c
+++ /dev/null
@@ -1,228 +0,0 @@
1/* elan-104nc.c -- MTD map driver for Arcom Control Systems ELAN-104NC
2
3 Copyright (C) 2000 Arcom Control System Ltd
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18
19 $Id: elan-104nc.c,v 1.25 2004/11/28 09:40:39 dwmw2 Exp $
20
21The ELAN-104NC has up to 8 Mibyte of Intel StrataFlash (28F320/28F640) in x16
22mode. This drivers uses the CFI probe and Intel Extended Command Set drivers.
23
24The flash is accessed as follows:
25
26 32 kbyte memory window at 0xb0000-0xb7fff
27
28 16 bit I/O port (0x22) for some sort of paging.
29
30The single flash device is divided into 3 partition which appear as separate
31MTD devices.
32
33Linux thinks that the I/O port is used by the PIC and hence check_region() will
34always fail. So we don't do it. I just hope it doesn't break anything.
35*/
36#include <linux/module.h>
37#include <linux/slab.h>
38#include <linux/ioport.h>
39#include <linux/init.h>
40#include <asm/io.h>
41
42#include <linux/mtd/map.h>
43#include <linux/mtd/mtd.h>
44#include <linux/mtd/partitions.h>
45
46#define WINDOW_START 0xb0000
47/* Number of bits in offset. */
48#define WINDOW_SHIFT 15
49#define WINDOW_LENGTH (1 << WINDOW_SHIFT)
50/* The bits for the offset into the window. */
51#define WINDOW_MASK (WINDOW_LENGTH-1)
52#define PAGE_IO 0x22
53#define PAGE_IO_SIZE 2
54
55static volatile int page_in_window = -1; // Current page in window.
56static void __iomem *iomapadr;
57static DEFINE_SPINLOCK(elan_104nc_spin);
58
59/* partition_info gives details on the logical partitions that the split the
60 * single flash device into. If the size if zero we use up to the end of the
61 * device. */
62static struct mtd_partition partition_info[]={
63 { .name = "ELAN-104NC flash boot partition",
64 .offset = 0,
65 .size = 640*1024 },
66 { .name = "ELAN-104NC flash partition 1",
67 .offset = 640*1024,
68 .size = 896*1024 },
69 { .name = "ELAN-104NC flash partition 2",
70 .offset = (640+896)*1024 }
71};
72#define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0]))
73
74/*
75 * If no idea what is going on here. This is taken from the FlashFX stuff.
76 */
77#define ROMCS 1
78
79static inline void elan_104nc_setup(void)
80{
81 u16 t;
82
83 outw( 0x0023 + ROMCS*2, PAGE_IO );
84 t=inb( PAGE_IO+1 );
85
86 t=(t & 0xf9) | 0x04;
87
88 outw( ((0x0023 + ROMCS*2) | (t << 8)), PAGE_IO );
89}
90
91static inline void elan_104nc_page(struct map_info *map, unsigned long ofs)
92{
93 unsigned long page = ofs >> WINDOW_SHIFT;
94
95 if( page!=page_in_window ) {
96 int cmd1;
97 int cmd2;
98
99 cmd1=(page & 0x700) + 0x0833 + ROMCS*0x4000;
100 cmd2=((page & 0xff) << 8) + 0x0032;
101
102 outw( cmd1, PAGE_IO );
103 outw( cmd2, PAGE_IO );
104
105 page_in_window = page;
106 }
107}
108
109
110static map_word elan_104nc_read16(struct map_info *map, unsigned long ofs)
111{
112 map_word ret;
113 spin_lock(&elan_104nc_spin);
114 elan_104nc_page(map, ofs);
115 ret.x[0] = readw(iomapadr + (ofs & WINDOW_MASK));
116 spin_unlock(&elan_104nc_spin);
117 return ret;
118}
119
120static void elan_104nc_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
121{
122 while (len) {
123 unsigned long thislen = len;
124 if (len > (WINDOW_LENGTH - (from & WINDOW_MASK)))
125 thislen = WINDOW_LENGTH-(from & WINDOW_MASK);
126
127 spin_lock(&elan_104nc_spin);
128 elan_104nc_page(map, from);
129 memcpy_fromio(to, iomapadr + (from & WINDOW_MASK), thislen);
130 spin_unlock(&elan_104nc_spin);
131 to += thislen;
132 from += thislen;
133 len -= thislen;
134 }
135}
136
137static void elan_104nc_write16(struct map_info *map, map_word d, unsigned long adr)
138{
139 spin_lock(&elan_104nc_spin);
140 elan_104nc_page(map, adr);
141 writew(d.x[0], iomapadr + (adr & WINDOW_MASK));
142 spin_unlock(&elan_104nc_spin);
143}
144
145static void elan_104nc_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
146{
147 while(len) {
148 unsigned long thislen = len;
149 if (len > (WINDOW_LENGTH - (to & WINDOW_MASK)))
150 thislen = WINDOW_LENGTH-(to & WINDOW_MASK);
151
152 spin_lock(&elan_104nc_spin);
153 elan_104nc_page(map, to);
154 memcpy_toio(iomapadr + (to & WINDOW_MASK), from, thislen);
155 spin_unlock(&elan_104nc_spin);
156 to += thislen;
157 from += thislen;
158 len -= thislen;
159 }
160}
161
162static struct map_info elan_104nc_map = {
163 .name = "ELAN-104NC flash",
164 .phys = NO_XIP,
165 .size = 8*1024*1024, /* this must be set to a maximum possible amount
166 of flash so the cfi probe routines find all
167 the chips */
168 .bankwidth = 2,
169 .read = elan_104nc_read16,
170 .copy_from = elan_104nc_copy_from,
171 .write = elan_104nc_write16,
172 .copy_to = elan_104nc_copy_to
173};
174
175/* MTD device for all of the flash. */
176static struct mtd_info *all_mtd;
177
178static void cleanup_elan_104nc(void)
179{
180 if( all_mtd ) {
181 del_mtd_partitions( all_mtd );
182 map_destroy( all_mtd );
183 }
184
185 iounmap(iomapadr);
186}
187
188static int __init init_elan_104nc(void)
189{
190 /* Urg! We use I/O port 0x22 without request_region()ing it,
191 because it's already allocated to the PIC. */
192
193 iomapadr = ioremap(WINDOW_START, WINDOW_LENGTH);
194 if (!iomapadr) {
195 printk( KERN_ERR"%s: failed to ioremap memory region\n",
196 elan_104nc_map.name );
197 return -EIO;
198 }
199
200 printk( KERN_INFO"%s: IO:0x%x-0x%x MEM:0x%x-0x%x\n",
201 elan_104nc_map.name,
202 PAGE_IO, PAGE_IO+PAGE_IO_SIZE-1,
203 WINDOW_START, WINDOW_START+WINDOW_LENGTH-1 );
204
205 elan_104nc_setup();
206
207 /* Probe for chip. */
208 all_mtd = do_map_probe("cfi_probe", &elan_104nc_map );
209 if( !all_mtd ) {
210 cleanup_elan_104nc();
211 return -ENXIO;
212 }
213
214 all_mtd->owner = THIS_MODULE;
215
216 /* Create MTD devices for each partition. */
217 add_mtd_partitions( all_mtd, partition_info, NUM_PARTITIONS );
218
219 return 0;
220}
221
222module_init(init_elan_104nc);
223module_exit(cleanup_elan_104nc);
224
225
226MODULE_LICENSE("GPL");
227MODULE_AUTHOR("Arcom Control Systems Ltd.");
228MODULE_DESCRIPTION("MTD map driver for Arcom Control Systems ELAN-104NC");
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
index 29d1cc1bb426..e505207cd489 100644
--- a/drivers/mtd/maps/ichxrom.c
+++ b/drivers/mtd/maps/ichxrom.c
@@ -2,7 +2,7 @@
2 * ichxrom.c 2 * ichxrom.c
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * $Id: ichxrom.c,v 1.16 2004/11/28 09:40:39 dwmw2 Exp $ 5 * $Id: ichxrom.c,v 1.18 2005/07/07 10:26:20 dwmw2 Exp $
6 */ 6 */
7 7
8#include <linux/module.h> 8#include <linux/module.h>
@@ -338,9 +338,9 @@ static struct pci_device_id ichxrom_pci_tbl[] __devinitdata = {
338 { 0, }, 338 { 0, },
339}; 339};
340 340
341#if 0
341MODULE_DEVICE_TABLE(pci, ichxrom_pci_tbl); 342MODULE_DEVICE_TABLE(pci, ichxrom_pci_tbl);
342 343
343#if 0
344static struct pci_driver ichxrom_driver = { 344static struct pci_driver ichxrom_driver = {
345 .name = MOD_NAME, 345 .name = MOD_NAME,
346 .id_table = ichxrom_pci_tbl, 346 .id_table = ichxrom_pci_tbl,
@@ -366,7 +366,7 @@ static int __init init_ichxrom(void)
366 } 366 }
367 return -ENXIO; 367 return -ENXIO;
368#if 0 368#if 0
369 return pci_module_init(&ichxrom_driver); 369 return pci_register_driver(&ichxrom_driver);
370#endif 370#endif
371} 371}
372 372
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index c5b5f447e34b..3e94b616743d 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ixp2000.c,v 1.5 2004/11/16 17:15:48 dsaxena Exp $ 2 * $Id: ixp2000.c,v 1.6 2005/03/18 14:07:46 gleixner Exp $
3 * 3 *
4 * drivers/mtd/maps/ixp2000.c 4 * drivers/mtd/maps/ixp2000.c
5 * 5 *
@@ -216,11 +216,6 @@ static int ixp2000_flash_probe(struct device *_dev)
216 goto Error; 216 goto Error;
217 } 217 }
218 218
219 /*
220 * Setup read mode for FLASH
221 */
222 *IXP2000_SLOWPORT_FRM = 1;
223
224#if defined(__ARMEB__) 219#if defined(__ARMEB__)
225 /* 220 /*
226 * Enable erratum 44 workaround for NPUs with broken slowport 221 * Enable erratum 44 workaround for NPUs with broken slowport
diff --git a/drivers/mtd/maps/mainstone-flash.c b/drivers/mtd/maps/mainstone-flash.c
new file mode 100644
index 000000000000..87e93fa60588
--- /dev/null
+++ b/drivers/mtd/maps/mainstone-flash.c
@@ -0,0 +1,178 @@
1/*
2 * $Id: $
3 *
4 * Map driver for the Mainstone developer platform.
5 *
6 * Author: Nicolas Pitre
7 * Copyright: (C) 2001 MontaVista Software Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/module.h>
15#include <linux/types.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/dma-mapping.h>
19#include <linux/mtd/mtd.h>
20#include <linux/mtd/map.h>
21#include <linux/mtd/partitions.h>
22#include <asm/io.h>
23#include <asm/hardware.h>
24#include <asm/arch/pxa-regs.h>
25#include <asm/arch/mainstone.h>
26
27
28#define ROM_ADDR 0x00000000
29#define FLASH_ADDR 0x04000000
30
31#define WINDOW_SIZE 0x04000000
32
33static void mainstone_map_inval_cache(struct map_info *map, unsigned long from,
34 ssize_t len)
35{
36 consistent_sync((char *)map->cached + from, len, DMA_FROM_DEVICE);
37}
38
39static struct map_info mainstone_maps[2] = { {
40 .size = WINDOW_SIZE,
41 .phys = PXA_CS0_PHYS,
42 .inval_cache = mainstone_map_inval_cache,
43}, {
44 .size = WINDOW_SIZE,
45 .phys = PXA_CS1_PHYS,
46 .inval_cache = mainstone_map_inval_cache,
47} };
48
49static struct mtd_partition mainstone_partitions[] = {
50 {
51 .name = "Bootloader",
52 .size = 0x00040000,
53 .offset = 0,
54 .mask_flags = MTD_WRITEABLE /* force read-only */
55 },{
56 .name = "Kernel",
57 .size = 0x00400000,
58 .offset = 0x00040000,
59 },{
60 .name = "Filesystem",
61 .size = MTDPART_SIZ_FULL,
62 .offset = 0x00440000
63 }
64};
65
66static struct mtd_info *mymtds[2];
67static struct mtd_partition *parsed_parts[2];
68static int nr_parsed_parts[2];
69
70static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
71
72static int __init init_mainstone(void)
73{
74 int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
75 int ret = 0, i;
76
77 mainstone_maps[0].bankwidth = (BOOT_DEF & 1) ? 2 : 4;
78 mainstone_maps[1].bankwidth = 4;
79
80 /* Compensate for SW7 which swaps the flash banks */
81 mainstone_maps[SW7].name = "processor flash";
82 mainstone_maps[SW7 ^ 1].name = "main board flash";
83
84 printk(KERN_NOTICE "Mainstone configured to boot from %s\n",
85 mainstone_maps[0].name);
86
87 for (i = 0; i < 2; i++) {
88 mainstone_maps[i].virt = ioremap(mainstone_maps[i].phys,
89 WINDOW_SIZE);
90 if (!mainstone_maps[i].virt) {
91 printk(KERN_WARNING "Failed to ioremap %s\n",
92 mainstone_maps[i].name);
93 if (!ret)
94 ret = -ENOMEM;
95 continue;
96 }
97 mainstone_maps[i].cached =
98 ioremap_cached(mainstone_maps[i].phys, WINDOW_SIZE);
99 if (!mainstone_maps[i].cached)
100 printk(KERN_WARNING "Failed to ioremap cached %s\n",
101 mainstone_maps[i].name);
102 simple_map_init(&mainstone_maps[i]);
103
104 printk(KERN_NOTICE
105 "Probing %s at physical address 0x%08lx"
106 " (%d-bit bankwidth)\n",
107 mainstone_maps[i].name, mainstone_maps[i].phys,
108 mainstone_maps[i].bankwidth * 8);
109
110 mymtds[i] = do_map_probe("cfi_probe", &mainstone_maps[i]);
111
112 if (!mymtds[i]) {
113 iounmap((void *)mainstone_maps[i].virt);
114 if (mainstone_maps[i].cached)
115 iounmap(mainstone_maps[i].cached);
116 if (!ret)
117 ret = -EIO;
118 continue;
119 }
120 mymtds[i]->owner = THIS_MODULE;
121
122 ret = parse_mtd_partitions(mymtds[i], probes,
123 &parsed_parts[i], 0);
124
125 if (ret > 0)
126 nr_parsed_parts[i] = ret;
127 }
128
129 if (!mymtds[0] && !mymtds[1])
130 return ret;
131
132 for (i = 0; i < 2; i++) {
133 if (!mymtds[i]) {
134 printk(KERN_WARNING "%s is absent. Skipping\n",
135 mainstone_maps[i].name);
136 } else if (nr_parsed_parts[i]) {
137 add_mtd_partitions(mymtds[i], parsed_parts[i],
138 nr_parsed_parts[i]);
139 } else if (!i) {
140 printk("Using static partitions on %s\n",
141 mainstone_maps[i].name);
142 add_mtd_partitions(mymtds[i], mainstone_partitions,
143 ARRAY_SIZE(mainstone_partitions));
144 } else {
145 printk("Registering %s as whole device\n",
146 mainstone_maps[i].name);
147 add_mtd_device(mymtds[i]);
148 }
149 }
150 return 0;
151}
152
153static void __exit cleanup_mainstone(void)
154{
155 int i;
156 for (i = 0; i < 2; i++) {
157 if (!mymtds[i])
158 continue;
159
160 if (nr_parsed_parts[i] || !i)
161 del_mtd_partitions(mymtds[i]);
162 else
163 del_mtd_device(mymtds[i]);
164
165 map_destroy(mymtds[i]);
166 iounmap((void *)mainstone_maps[i].virt);
167 if (mainstone_maps[i].cached)
168 iounmap(mainstone_maps[i].cached);
169 kfree(parsed_parts[i]);
170 }
171}
172
173module_init(init_mainstone);
174module_exit(cleanup_mainstone);
175
176MODULE_LICENSE("GPL");
177MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
178MODULE_DESCRIPTION("MTD map driver for Intel Mainstone");
diff --git a/drivers/mtd/maps/map_funcs.c b/drivers/mtd/maps/map_funcs.c
index 38f6a7af53f8..9105e6ca0aa6 100644
--- a/drivers/mtd/maps/map_funcs.c
+++ b/drivers/mtd/maps/map_funcs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: map_funcs.c,v 1.9 2004/07/13 22:33:15 dwmw2 Exp $ 2 * $Id: map_funcs.c,v 1.10 2005/06/06 23:04:36 tpoynor Exp $
3 * 3 *
4 * Out-of-line map I/O functions for simple maps when CONFIG_COMPLEX_MAPPINGS 4 * Out-of-line map I/O functions for simple maps when CONFIG_COMPLEX_MAPPINGS
5 * is enabled. 5 * is enabled.
@@ -9,23 +9,24 @@
9#include <linux/module.h> 9#include <linux/module.h>
10 10
11#include <linux/mtd/map.h> 11#include <linux/mtd/map.h>
12#include <linux/mtd/xip.h>
12 13
13static map_word simple_map_read(struct map_info *map, unsigned long ofs) 14static map_word __xipram simple_map_read(struct map_info *map, unsigned long ofs)
14{ 15{
15 return inline_map_read(map, ofs); 16 return inline_map_read(map, ofs);
16} 17}
17 18
18static void simple_map_write(struct map_info *map, const map_word datum, unsigned long ofs) 19static void __xipram simple_map_write(struct map_info *map, const map_word datum, unsigned long ofs)
19{ 20{
20 inline_map_write(map, datum, ofs); 21 inline_map_write(map, datum, ofs);
21} 22}
22 23
23static void simple_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) 24static void __xipram simple_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
24{ 25{
25 inline_map_copy_from(map, to, from, len); 26 inline_map_copy_from(map, to, from, len);
26} 27}
27 28
28static void simple_map_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) 29static void __xipram simple_map_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
29{ 30{
30 inline_map_copy_to(map, to, from, len); 31 inline_map_copy_to(map, to, from, len);
31} 32}
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
new file mode 100644
index 000000000000..8cc71409a328
--- /dev/null
+++ b/drivers/mtd/maps/omap_nor.c
@@ -0,0 +1,179 @@
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/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/mtd/mtd.h>
40#include <linux/mtd/map.h>
41#include <linux/mtd/partitions.h>
42
43#include <asm/io.h>
44#include <asm/hardware.h>
45#include <asm/mach-types.h>
46#include <asm/mach/flash.h>
47#include <asm/arch/tc.h>
48
49#ifdef CONFIG_MTD_PARTITIONS
50static const char *part_probes[] = { /* "RedBoot", */ "cmdlinepart", NULL };
51#endif
52
53struct omapflash_info {
54 struct mtd_partition *parts;
55 struct mtd_info *mtd;
56 struct map_info map;
57};
58
59static void omap_set_vpp(struct map_info *map, int enable)
60{
61 static int count;
62
63 if (enable) {
64 if (count++ == 0)
65 OMAP_EMIFS_CONFIG_REG |= OMAP_EMIFS_CONFIG_WP;
66 } else {
67 if (count && (--count == 0))
68 OMAP_EMIFS_CONFIG_REG &= ~OMAP_EMIFS_CONFIG_WP;
69 }
70}
71
72static int __devinit omapflash_probe(struct device *dev)
73{
74 int err;
75 struct omapflash_info *info;
76 struct platform_device *pdev = to_platform_device(dev);
77 struct flash_platform_data *pdata = pdev->dev.platform_data;
78 struct resource *res = pdev->resource;
79 unsigned long size = res->end - res->start + 1;
80
81 info = kmalloc(sizeof(struct omapflash_info), GFP_KERNEL);
82 if (!info)
83 return -ENOMEM;
84
85 memset(info, 0, sizeof(struct omapflash_info));
86
87 if (!request_mem_region(res->start, size, "flash")) {
88 err = -EBUSY;
89 goto out_free_info;
90 }
91
92 info->map.virt = ioremap(res->start, size);
93 if (!info->map.virt) {
94 err = -ENOMEM;
95 goto out_release_mem_region;
96 }
97 info->map.name = pdev->dev.bus_id;
98 info->map.phys = res->start;
99 info->map.size = size;
100 info->map.bankwidth = pdata->width;
101 info->map.set_vpp = omap_set_vpp;
102
103 simple_map_init(&info->map);
104 info->mtd = do_map_probe(pdata->map_name, &info->map);
105 if (!info->mtd) {
106 err = -EIO;
107 goto out_iounmap;
108 }
109 info->mtd->owner = THIS_MODULE;
110
111#ifdef CONFIG_MTD_PARTITIONS
112 err = parse_mtd_partitions(info->mtd, part_probes, &info->parts, 0);
113 if (err > 0)
114 add_mtd_partitions(info->mtd, info->parts, err);
115 else if (err < 0 && pdata->parts)
116 add_mtd_partitions(info->mtd, pdata->parts, pdata->nr_parts);
117 else
118#endif
119 add_mtd_device(info->mtd);
120
121 dev_set_drvdata(&pdev->dev, info);
122
123 return 0;
124
125out_iounmap:
126 iounmap(info->map.virt);
127out_release_mem_region:
128 release_mem_region(res->start, size);
129out_free_info:
130 kfree(info);
131
132 return err;
133}
134
135static int __devexit omapflash_remove(struct device *dev)
136{
137 struct platform_device *pdev = to_platform_device(dev);
138 struct omapflash_info *info = dev_get_drvdata(&pdev->dev);
139
140 dev_set_drvdata(&pdev->dev, NULL);
141
142 if (info) {
143 if (info->parts) {
144 del_mtd_partitions(info->mtd);
145 kfree(info->parts);
146 } else
147 del_mtd_device(info->mtd);
148 map_destroy(info->mtd);
149 release_mem_region(info->map.phys, info->map.size);
150 iounmap((void __iomem *) info->map.virt);
151 kfree(info);
152 }
153
154 return 0;
155}
156
157static struct device_driver omapflash_driver = {
158 .name = "omapflash",
159 .bus = &platform_bus_type,
160 .probe = omapflash_probe,
161 .remove = __devexit_p(omapflash_remove),
162};
163
164static int __init omapflash_init(void)
165{
166 return driver_register(&omapflash_driver);
167}
168
169static void __exit omapflash_exit(void)
170{
171 driver_unregister(&omapflash_driver);
172}
173
174module_init(omapflash_init);
175module_exit(omapflash_exit);
176
177MODULE_LICENSE("GPL");
178MODULE_DESCRIPTION("MTD NOR map driver for TI OMAP boards");
179
diff --git a/drivers/mtd/maps/pb1550-flash.c b/drivers/mtd/maps/pb1550-flash.c
deleted file mode 100644
index 1424726a219e..000000000000
--- a/drivers/mtd/maps/pb1550-flash.c
+++ /dev/null
@@ -1,203 +0,0 @@
1/*
2 * Flash memory access on Alchemy Pb1550 board
3 *
4 * $Id: pb1550-flash.c,v 1.6 2004/11/04 13:24:15 gleixner Exp $
5 *
6 * (C) 2004 Embedded Edge, LLC, based on pb1550-flash.c:
7 * (C) 2003 Pete Popov <ppopov@pacbell.net>
8 *
9 */
10
11#include <linux/config.h>
12#include <linux/init.h>
13#include <linux/module.h>
14#include <linux/types.h>
15#include <linux/kernel.h>
16
17#include <linux/mtd/mtd.h>
18#include <linux/mtd/map.h>
19#include <linux/mtd/partitions.h>
20
21#include <asm/io.h>
22#include <asm/au1000.h>
23#include <asm/pb1550.h>
24
25#ifdef DEBUG_RW
26#define DBG(x...) printk(x)
27#else
28#define DBG(x...)
29#endif
30
31static unsigned long window_addr;
32static unsigned long window_size;
33
34
35static struct map_info pb1550_map = {
36 .name = "Pb1550 flash",
37};
38
39static unsigned char flash_bankwidth = 4;
40
41/*
42 * Support only 64MB NOR Flash parts
43 */
44
45#ifdef PB1550_BOTH_BANKS
46/* both banks will be used. Combine the first bank and the first
47 * part of the second bank together into a single jffs/jffs2
48 * partition.
49 */
50static struct mtd_partition pb1550_partitions[] = {
51 /* assume boot[2:0]:swap is '0000' or '1000', which translates to:
52 * 1C00 0000 1FFF FFFF CE0 64MB Boot NOR Flash
53 * 1800 0000 1BFF FFFF CE0 64MB Param NOR Flash
54 */
55 {
56 .name = "User FS",
57 .size = (0x1FC00000 - 0x18000000),
58 .offset = 0x0000000
59 },{
60 .name = "yamon",
61 .size = 0x0100000,
62 .offset = MTDPART_OFS_APPEND,
63 .mask_flags = MTD_WRITEABLE
64 },{
65 .name = "raw kernel",
66 .size = (0x300000 - 0x40000), /* last 256KB is yamon env */
67 .offset = MTDPART_OFS_APPEND,
68 }
69};
70#elif defined(PB1550_BOOT_ONLY)
71static struct mtd_partition pb1550_partitions[] = {
72 /* assume boot[2:0]:swap is '0000' or '1000', which translates to:
73 * 1C00 0000 1FFF FFFF CE0 64MB Boot NOR Flash
74 */
75 {
76 .name = "User FS",
77 .size = 0x03c00000,
78 .offset = 0x0000000
79 },{
80 .name = "yamon",
81 .size = 0x0100000,
82 .offset = MTDPART_OFS_APPEND,
83 .mask_flags = MTD_WRITEABLE
84 },{
85 .name = "raw kernel",
86 .size = (0x300000-0x40000), /* last 256KB is yamon env */
87 .offset = MTDPART_OFS_APPEND,
88 }
89};
90#elif defined(PB1550_USER_ONLY)
91static struct mtd_partition pb1550_partitions[] = {
92 /* assume boot[2:0]:swap is '0000' or '1000', which translates to:
93 * 1800 0000 1BFF FFFF CE0 64MB Param NOR Flash
94 */
95 {
96 .name = "User FS",
97 .size = (0x4000000 - 0x200000), /* reserve 2MB for raw kernel */
98 .offset = 0x0000000
99 },{
100 .name = "raw kernel",
101 .size = MTDPART_SIZ_FULL,
102 .offset = MTDPART_OFS_APPEND,
103 }
104};
105#else
106#error MTD_PB1550 define combo error /* should never happen */
107#endif
108
109#define NB_OF(x) (sizeof(x)/sizeof(x[0]))
110
111static struct mtd_info *mymtd;
112
113/*
114 * Probe the flash density and setup window address and size
115 * based on user CONFIG options. There are times when we don't
116 * want the MTD driver to be probing the boot or user flash,
117 * so having the option to enable only one bank is important.
118 */
119int setup_flash_params(void)
120{
121 u16 boot_swapboot;
122 boot_swapboot = (au_readl(MEM_STSTAT) & (0x7<<1)) |
123 ((bcsr->status >> 6) & 0x1);
124 printk("Pb1550 MTD: boot:swap %d\n", boot_swapboot);
125
126 switch (boot_swapboot) {
127 case 0: /* 512Mbit devices, both enabled */
128 case 1:
129 case 8:
130 case 9:
131#if defined(PB1550_BOTH_BANKS)
132 window_addr = 0x18000000;
133 window_size = 0x8000000;
134#elif defined(PB1550_BOOT_ONLY)
135 window_addr = 0x1C000000;
136 window_size = 0x4000000;
137#else /* USER ONLY */
138 window_addr = 0x1E000000;
139 window_size = 0x4000000;
140#endif
141 break;
142 case 0xC:
143 case 0xD:
144 case 0xE:
145 case 0xF:
146 /* 64 MB Boot NOR Flash is disabled */
147 /* and the start address is moved to 0x0C00000 */
148 window_addr = 0x0C000000;
149 window_size = 0x4000000;
150 default:
151 printk("Pb1550 MTD: unsupported boot:swap setting\n");
152 return 1;
153 }
154 return 0;
155}
156
157int __init pb1550_mtd_init(void)
158{
159 struct mtd_partition *parts;
160 int nb_parts = 0;
161
162 /* Default flash bankwidth */
163 pb1550_map.bankwidth = flash_bankwidth;
164
165 if (setup_flash_params())
166 return -ENXIO;
167
168 /*
169 * Static partition definition selection
170 */
171 parts = pb1550_partitions;
172 nb_parts = NB_OF(pb1550_partitions);
173 pb1550_map.size = window_size;
174
175 /*
176 * Now let's probe for the actual flash. Do it here since
177 * specific machine settings might have been set above.
178 */
179 printk(KERN_NOTICE "Pb1550 flash: probing %d-bit flash bus\n",
180 pb1550_map.bankwidth*8);
181 pb1550_map.virt = ioremap(window_addr, window_size);
182 mymtd = do_map_probe("cfi_probe", &pb1550_map);
183 if (!mymtd) return -ENXIO;
184 mymtd->owner = THIS_MODULE;
185
186 add_mtd_partitions(mymtd, parts, nb_parts);
187 return 0;
188}
189
190static void __exit pb1550_mtd_cleanup(void)
191{
192 if (mymtd) {
193 del_mtd_partitions(mymtd);
194 map_destroy(mymtd);
195 }
196}
197
198module_init(pb1550_mtd_init);
199module_exit(pb1550_mtd_cleanup);
200
201MODULE_AUTHOR("Embedded Edge, LLC");
202MODULE_DESCRIPTION("Pb1550 mtd map driver");
203MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/maps/pb1xxx-flash.c b/drivers/mtd/maps/pb1xxx-flash.c
deleted file mode 100644
index 06e731540552..000000000000
--- a/drivers/mtd/maps/pb1xxx-flash.c
+++ /dev/null
@@ -1,178 +0,0 @@
1/*
2 * Flash memory access on Alchemy Pb1xxx boards
3 *
4 * (C) 2001 Pete Popov <ppopov@mvista.com>
5 *
6 * $Id: pb1xxx-flash.c,v 1.14 2004/11/04 13:24:15 gleixner Exp $
7 */
8
9#include <linux/config.h>
10#include <linux/module.h>
11#include <linux/types.h>
12#include <linux/init.h>
13#include <linux/kernel.h>
14
15#include <linux/mtd/mtd.h>
16#include <linux/mtd/map.h>
17#include <linux/mtd/partitions.h>
18
19#include <asm/io.h>
20
21#ifdef DEBUG_RW
22#define DBG(x...) printk(x)
23#else
24#define DBG(x...)
25#endif
26
27#ifdef CONFIG_MIPS_PB1000
28
29#define WINDOW_ADDR 0x1F800000
30#define WINDOW_SIZE 0x800000
31
32static struct mtd_partition pb1xxx_partitions[] = {
33 {
34 .name = "yamon env",
35 .size = 0x00020000,
36 .offset = 0,
37 .mask_flags = MTD_WRITEABLE},
38 {
39 .name = "User FS",
40 .size = 0x003e0000,
41 .offset = 0x20000,},
42 {
43 .name = "boot code",
44 .size = 0x100000,
45 .offset = 0x400000,
46 .mask_flags = MTD_WRITEABLE},
47 {
48 .name = "raw/kernel",
49 .size = 0x300000,
50 .offset = 0x500000}
51};
52
53#elif defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1100)
54
55#if defined(CONFIG_MTD_PB1500_BOOT) && defined(CONFIG_MTD_PB1500_USER)
56/* both 32MB banks will be used. Combine the first 32MB bank and the
57 * first 28MB of the second bank together into a single jffs/jffs2
58 * partition.
59 */
60#define WINDOW_ADDR 0x1C000000
61#define WINDOW_SIZE 0x4000000
62static struct mtd_partition pb1xxx_partitions[] = {
63 {
64 .name = "User FS",
65 .size = 0x3c00000,
66 .offset = 0x0000000
67 },{
68 .name = "yamon",
69 .size = 0x0100000,
70 .offset = 0x3c00000,
71 .mask_flags = MTD_WRITEABLE
72 },{
73 .name = "raw kernel",
74 .size = 0x02c0000,
75 .offset = 0x3d00000
76 }
77};
78#elif defined(CONFIG_MTD_PB1500_BOOT) && !defined(CONFIG_MTD_PB1500_USER)
79#define WINDOW_ADDR 0x1E000000
80#define WINDOW_SIZE 0x2000000
81static struct mtd_partition pb1xxx_partitions[] = {
82 {
83 .name = "User FS",
84 .size = 0x1c00000,
85 .offset = 0x0000000
86 },{
87 .name = "yamon",
88 .size = 0x0100000,
89 .offset = 0x1c00000,
90 .mask_flags = MTD_WRITEABLE
91 },{
92 .name = "raw kernel",
93 .size = 0x02c0000,
94 .offset = 0x1d00000
95 }
96};
97#elif !defined(CONFIG_MTD_PB1500_BOOT) && defined(CONFIG_MTD_PB1500_USER)
98#define WINDOW_ADDR 0x1C000000
99#define WINDOW_SIZE 0x2000000
100static struct mtd_partition pb1xxx_partitions[] = {
101 {
102 .name = "User FS",
103 .size = 0x1e00000,
104 .offset = 0x0000000
105 },{
106 .name = "raw kernel",
107 .size = 0x0200000,
108 .offset = 0x1e00000,
109 }
110};
111#else
112#error MTD_PB1500 define combo error /* should never happen */
113#endif
114#else
115#error Unsupported board
116#endif
117
118#define NAME "Pb1x00 Linux Flash"
119#define PADDR WINDOW_ADDR
120#define BUSWIDTH 4
121#define SIZE WINDOW_SIZE
122#define PARTITIONS 4
123
124static struct map_info pb1xxx_mtd_map = {
125 .name = NAME,
126 .size = SIZE,
127 .bankwidth = BUSWIDTH,
128 .phys = PADDR,
129};
130
131static struct mtd_info *pb1xxx_mtd;
132
133int __init pb1xxx_mtd_init(void)
134{
135 struct mtd_partition *parts;
136 int nb_parts = 0;
137 char *part_type;
138
139 /*
140 * Static partition definition selection
141 */
142 part_type = "static";
143 parts = pb1xxx_partitions;
144 nb_parts = ARRAY_SIZE(pb1xxx_partitions);
145
146 /*
147 * Now let's probe for the actual flash. Do it here since
148 * specific machine settings might have been set above.
149 */
150 printk(KERN_NOTICE "Pb1xxx flash: probing %d-bit flash bus\n",
151 BUSWIDTH*8);
152 pb1xxx_mtd_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
153
154 simple_map_init(&pb1xxx_mtd_map);
155
156 pb1xxx_mtd = do_map_probe("cfi_probe", &pb1xxx_mtd_map);
157 if (!pb1xxx_mtd) return -ENXIO;
158 pb1xxx_mtd->owner = THIS_MODULE;
159
160 add_mtd_partitions(pb1xxx_mtd, parts, nb_parts);
161 return 0;
162}
163
164static void __exit pb1xxx_mtd_cleanup(void)
165{
166 if (pb1xxx_mtd) {
167 del_mtd_partitions(pb1xxx_mtd);
168 map_destroy(pb1xxx_mtd);
169 iounmap((void *) pb1xxx_mtd_map.virt);
170 }
171}
172
173module_init(pb1xxx_mtd_init);
174module_exit(pb1xxx_mtd_cleanup);
175
176MODULE_AUTHOR("Pete Popov");
177MODULE_DESCRIPTION("Pb1xxx CFI map driver");
178MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c
index 08b60bdc5381..18dbd3af1eaa 100644
--- a/drivers/mtd/maps/pci.c
+++ b/drivers/mtd/maps/pci.c
@@ -7,7 +7,7 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * $Id: pci.c,v 1.9 2004/11/28 09:40:40 dwmw2 Exp $ 10 * $Id: pci.c,v 1.10 2005/03/18 14:04:35 gleixner Exp $
11 * 11 *
12 * Generic PCI memory map driver. We support the following boards: 12 * Generic PCI memory map driver. We support the following boards:
13 * - Intel IQ80310 ATU. 13 * - Intel IQ80310 ATU.
@@ -370,7 +370,7 @@ static struct pci_driver mtd_pci_driver = {
370 370
371static int __init mtd_pci_maps_init(void) 371static int __init mtd_pci_maps_init(void)
372{ 372{
373 return pci_module_init(&mtd_pci_driver); 373 return pci_register_driver(&mtd_pci_driver);
374} 374}
375 375
376static void __exit mtd_pci_maps_exit(void) 376static void __exit mtd_pci_maps_exit(void)
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index c2655a817e3d..ff7c50d10180 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -18,7 +18,6 @@
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/system.h> 19#include <asm/system.h>
20 20
21#include <pcmcia/version.h>
22#include <pcmcia/cs_types.h> 21#include <pcmcia/cs_types.h>
23#include <pcmcia/cs.h> 22#include <pcmcia/cs.h>
24#include <pcmcia/cistpl.h> 23#include <pcmcia/cistpl.h>
@@ -800,11 +799,6 @@ static dev_link_t *pcmciamtd_attach(void)
800 799
801 /* Register with Card Services */ 800 /* Register with Card Services */
802 client_reg.dev_info = &dev_info; 801 client_reg.dev_info = &dev_info;
803 client_reg.EventMask =
804 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
805 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
806 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
807 client_reg.event_handler = &pcmciamtd_event;
808 client_reg.Version = 0x0210; 802 client_reg.Version = 0x0210;
809 client_reg.event_callback_args.client_data = link; 803 client_reg.event_callback_args.client_data = link;
810 DEBUG(2, "Calling RegisterClient"); 804 DEBUG(2, "Calling RegisterClient");
@@ -850,6 +844,7 @@ static struct pcmcia_driver pcmciamtd_driver = {
850 .name = "pcmciamtd" 844 .name = "pcmciamtd"
851 }, 845 },
852 .attach = pcmciamtd_attach, 846 .attach = pcmciamtd_attach,
847 .event = pcmciamtd_event,
853 .detach = pcmciamtd_detach, 848 .detach = pcmciamtd_detach,
854 .owner = THIS_MODULE, 849 .owner = THIS_MODULE,
855 .id_table = pcmciamtd_ids, 850 .id_table = pcmciamtd_ids,
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
new file mode 100644
index 000000000000..118b04544cad
--- /dev/null
+++ b/drivers/mtd/maps/plat-ram.c
@@ -0,0 +1,278 @@
1/* drivers/mtd/maps/plat-ram.c
2 *
3 * (c) 2004-2005 Simtec Electronics
4 * http://www.simtec.co.uk/products/SWLINUX/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * Generic platfrom device based RAM map
8 *
9 * $Id: plat-ram.c,v 1.3 2005/03/19 22:41:27 gleixner Exp $
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24*/
25
26#include <linux/module.h>
27#include <linux/types.h>
28#include <linux/init.h>
29#include <linux/kernel.h>
30#include <linux/string.h>
31#include <linux/ioport.h>
32#include <linux/device.h>
33
34#include <linux/mtd/mtd.h>
35#include <linux/mtd/map.h>
36#include <linux/mtd/partitions.h>
37#include <linux/mtd/plat-ram.h>
38
39#include <asm/io.h>
40
41/* private structure for each mtd platform ram device created */
42
43struct platram_info {
44 struct device *dev;
45 struct mtd_info *mtd;
46 struct map_info map;
47 struct mtd_partition *partitions;
48 struct resource *area;
49 struct platdata_mtd_ram *pdata;
50};
51
52/* to_platram_info()
53 *
54 * device private data to struct platram_info conversion
55*/
56
57static inline struct platram_info *to_platram_info(struct device *dev)
58{
59 return (struct platram_info *)dev_get_drvdata(dev);
60}
61
62/* platram_setrw
63 *
64 * call the platform device's set rw/ro control
65 *
66 * to = 0 => read-only
67 * = 1 => read-write
68*/
69
70static inline void platram_setrw(struct platram_info *info, int to)
71{
72 if (info->pdata == NULL)
73 return;
74
75 if (info->pdata->set_rw != NULL)
76 (info->pdata->set_rw)(info->dev, to);
77}
78
79/* platram_remove
80 *
81 * called to remove the device from the driver's control
82*/
83
84static int platram_remove(struct device *dev)
85{
86 struct platram_info *info = to_platram_info(dev);
87
88 dev_set_drvdata(dev, NULL);
89
90 dev_dbg(dev, "removing device\n");
91
92 if (info == NULL)
93 return 0;
94
95 if (info->mtd) {
96#ifdef CONFIG_MTD_PARTITIONS
97 if (info->partitions) {
98 del_mtd_partitions(info->mtd);
99 kfree(info->partitions);
100 }
101#endif
102 del_mtd_device(info->mtd);
103 map_destroy(info->mtd);
104 }
105
106 /* ensure ram is left read-only */
107
108 platram_setrw(info, PLATRAM_RO);
109
110 /* release resources */
111
112 if (info->area) {
113 release_resource(info->area);
114 kfree(info->area);
115 }
116
117 if (info->map.virt != NULL)
118 iounmap(info->map.virt);
119
120 kfree(info);
121
122 return 0;
123}
124
125/* platram_probe
126 *
127 * called from device drive system when a device matching our
128 * driver is found.
129*/
130
131static int platram_probe(struct device *dev)
132{
133 struct platform_device *pd = to_platform_device(dev);
134 struct platdata_mtd_ram *pdata;
135 struct platram_info *info;
136 struct resource *res;
137 int err = 0;
138
139 dev_dbg(dev, "probe entered\n");
140
141 if (dev->platform_data == NULL) {
142 dev_err(dev, "no platform data supplied\n");
143 err = -ENOENT;
144 goto exit_error;
145 }
146
147 pdata = dev->platform_data;
148
149 info = kmalloc(sizeof(*info), GFP_KERNEL);
150 if (info == NULL) {
151 dev_err(dev, "no memory for flash info\n");
152 err = -ENOMEM;
153 goto exit_error;
154 }
155
156 memset(info, 0, sizeof(*info));
157 dev_set_drvdata(dev, info);
158
159 info->dev = dev;
160 info->pdata = pdata;
161
162 /* get the resource for the memory mapping */
163
164 res = platform_get_resource(pd, IORESOURCE_MEM, 0);
165
166 if (res == NULL) {
167 dev_err(dev, "no memory resource specified\n");
168 err = -ENOENT;
169 goto exit_free;
170 }
171
172 dev_dbg(dev, "got platform resource %p (0x%lx)\n", res, res->start);
173
174 /* setup map parameters */
175
176 info->map.phys = res->start;
177 info->map.size = (res->end - res->start) + 1;
178 info->map.name = pdata->mapname != NULL ? pdata->mapname : pd->name;
179 info->map.bankwidth = pdata->bankwidth;
180
181 /* register our usage of the memory area */
182
183 info->area = request_mem_region(res->start, info->map.size, pd->name);
184 if (info->area == NULL) {
185 dev_err(dev, "failed to request memory region\n");
186 err = -EIO;
187 goto exit_free;
188 }
189
190 /* remap the memory area */
191
192 info->map.virt = ioremap(res->start, info->map.size);
193 dev_dbg(dev, "virt %p, %lu bytes\n", info->map.virt, info->map.size);
194
195 if (info->map.virt == NULL) {
196 dev_err(dev, "failed to ioremap() region\n");
197 err = -EIO;
198 goto exit_free;
199 }
200
201 simple_map_init(&info->map);
202
203 dev_dbg(dev, "initialised map, probing for mtd\n");
204
205 /* probe for the right mtd map driver */
206
207 info->mtd = do_map_probe("map_ram" , &info->map);
208 if (info->mtd == NULL) {
209 dev_err(dev, "failed to probe for map_ram\n");
210 err = -ENOMEM;
211 goto exit_free;
212 }
213
214 info->mtd->owner = THIS_MODULE;
215
216 platram_setrw(info, PLATRAM_RW);
217
218 /* check to see if there are any available partitions, or wether
219 * to add this device whole */
220
221#ifdef CONFIG_MTD_PARTITIONS
222 if (pdata->nr_partitions > 0) {
223 const char **probes = { NULL };
224
225 if (pdata->probes)
226 probes = (const char **)pdata->probes;
227
228 err = parse_mtd_partitions(info->mtd, probes,
229 &info->partitions, 0);
230 if (err > 0) {
231 err = add_mtd_partitions(info->mtd, info->partitions,
232 err);
233 }
234 }
235#endif /* CONFIG_MTD_PARTITIONS */
236
237 if (add_mtd_device(info->mtd)) {
238 dev_err(dev, "add_mtd_device() failed\n");
239 err = -ENOMEM;
240 }
241
242 dev_info(dev, "registered mtd device\n");
243 return err;
244
245 exit_free:
246 platram_remove(dev);
247 exit_error:
248 return err;
249}
250
251/* device driver info */
252
253static struct device_driver platram_driver = {
254 .name = "mtd-ram",
255 .bus = &platform_bus_type,
256 .probe = platram_probe,
257 .remove = platram_remove,
258};
259
260/* module init/exit */
261
262static int __init platram_init(void)
263{
264 printk("Generic platform RAM MTD, (c) 2004 Simtec Electronics\n");
265 return driver_register(&platram_driver);
266}
267
268static void __exit platram_exit(void)
269{
270 driver_unregister(&platram_driver);
271}
272
273module_init(platram_init);
274module_exit(platram_exit);
275
276MODULE_LICENSE("GPL");
277MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
278MODULE_DESCRIPTION("MTD platform RAM map driver");
diff --git a/drivers/mtd/maps/scb2_flash.c b/drivers/mtd/maps/scb2_flash.c
index 5bb3b600e5d0..97a8dfd69258 100644
--- a/drivers/mtd/maps/scb2_flash.c
+++ b/drivers/mtd/maps/scb2_flash.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * MTD map driver for BIOS Flash on Intel SCB2 boards 2 * MTD map driver for BIOS Flash on Intel SCB2 boards
3 * $Id: scb2_flash.c,v 1.11 2004/11/28 09:40:40 dwmw2 Exp $ 3 * $Id: scb2_flash.c,v 1.12 2005/03/18 14:04:35 gleixner Exp $
4 * Copyright (C) 2002 Sun Microsystems, Inc. 4 * Copyright (C) 2002 Sun Microsystems, Inc.
5 * Tim Hockin <thockin@sun.com> 5 * Tim Hockin <thockin@sun.com>
6 * 6 *
@@ -238,7 +238,7 @@ static struct pci_driver scb2_flash_driver = {
238static int __init 238static int __init
239scb2_flash_init(void) 239scb2_flash_init(void)
240{ 240{
241 return pci_module_init(&scb2_flash_driver); 241 return pci_register_driver(&scb2_flash_driver);
242} 242}
243 243
244static void __exit 244static void __exit
diff --git a/drivers/mtd/maps/sharpsl-flash.c b/drivers/mtd/maps/sharpsl-flash.c
index b3b39cb7c608..d15da6fd84c1 100644
--- a/drivers/mtd/maps/sharpsl-flash.c
+++ b/drivers/mtd/maps/sharpsl-flash.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2001 Lineo Japan, Inc. 4 * Copyright (C) 2001 Lineo Japan, Inc.
5 * Copyright (C) 2002 SHARP 5 * Copyright (C) 2002 SHARP
6 * 6 *
7 * $Id: sharpsl-flash.c,v 1.2 2004/11/24 20:38:06 rpurdie Exp $ 7 * $Id: sharpsl-flash.c,v 1.5 2005/03/21 08:42:11 rpurdie Exp $
8 * 8 *
9 * based on rpxlite.c,v 1.15 2001/10/02 15:05:14 dwmw2 Exp 9 * based on rpxlite.c,v 1.15 2001/10/02 15:05:14 dwmw2 Exp
10 * Handle mapping of the flash on the RPX Lite and CLLF boards 10 * Handle mapping of the flash on the RPX Lite and CLLF boards
@@ -24,13 +24,14 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <asm/io.h>
28#include <linux/mtd/mtd.h> 27#include <linux/mtd/mtd.h>
29#include <linux/mtd/map.h> 28#include <linux/mtd/map.h>
30#include <linux/mtd/partitions.h> 29#include <linux/mtd/partitions.h>
30#include <asm/io.h>
31#include <asm/mach-types.h>
31 32
32#define WINDOW_ADDR 0x00000000 33#define WINDOW_ADDR 0x00000000
33#define WINDOW_SIZE 0x01000000 34#define WINDOW_SIZE 0x00800000
34#define BANK_WIDTH 2 35#define BANK_WIDTH 2
35 36
36static struct mtd_info *mymtd; 37static struct mtd_info *mymtd;
@@ -44,9 +45,7 @@ struct map_info sharpsl_map = {
44 45
45static struct mtd_partition sharpsl_partitions[1] = { 46static struct mtd_partition sharpsl_partitions[1] = {
46 { 47 {
47 name: "Filesystem", 48 name: "Boot PROM Filesystem",
48 size: 0x006d0000,
49 offset: 0x00120000
50 } 49 }
51}; 50};
52 51
@@ -58,12 +57,16 @@ int __init init_sharpsl(void)
58 int nb_parts = 0; 57 int nb_parts = 0;
59 char *part_type = "static"; 58 char *part_type = "static";
60 59
61 printk(KERN_NOTICE "Sharp SL series flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR); 60 printk(KERN_NOTICE "Sharp SL series flash device: %x at %x\n",
61 WINDOW_SIZE, WINDOW_ADDR);
62 sharpsl_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); 62 sharpsl_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
63 if (!sharpsl_map.virt) { 63 if (!sharpsl_map.virt) {
64 printk("Failed to ioremap\n"); 64 printk("Failed to ioremap\n");
65 return -EIO; 65 return -EIO;
66 } 66 }
67
68 simple_map_init(&sharpsl_map);
69
67 mymtd = do_map_probe("map_rom", &sharpsl_map); 70 mymtd = do_map_probe("map_rom", &sharpsl_map);
68 if (!mymtd) { 71 if (!mymtd) {
69 iounmap(sharpsl_map.virt); 72 iounmap(sharpsl_map.virt);
@@ -72,6 +75,22 @@ int __init init_sharpsl(void)
72 75
73 mymtd->owner = THIS_MODULE; 76 mymtd->owner = THIS_MODULE;
74 77
78 if (machine_is_corgi() || machine_is_shepherd() || machine_is_husky()
79 || machine_is_poodle()) {
80 sharpsl_partitions[0].size=0x006d0000;
81 sharpsl_partitions[0].offset=0x00120000;
82 } else if (machine_is_tosa()) {
83 sharpsl_partitions[0].size=0x006a0000;
84 sharpsl_partitions[0].offset=0x00160000;
85 } else if (machine_is_spitz()) {
86 sharpsl_partitions[0].size=0x006b0000;
87 sharpsl_partitions[0].offset=0x00140000;
88 } else {
89 map_destroy(mymtd);
90 iounmap(sharpsl_map.virt);
91 return -ENODEV;
92 }
93
75 parts = sharpsl_partitions; 94 parts = sharpsl_partitions;
76 nb_parts = NB_OF(sharpsl_partitions); 95 nb_parts = NB_OF(sharpsl_partitions);
77 96
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 510ad78312cc..1ed602a0f24c 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: mtdchar.c,v 1.66 2005/01/05 18:05:11 dwmw2 Exp $ 2 * $Id: mtdchar.c,v 1.73 2005/07/04 17:36:41 gleixner Exp $
3 * 3 *
4 * Character-device access to raw MTD devices. 4 * Character-device access to raw MTD devices.
5 * 5 *
@@ -15,27 +15,30 @@
15#include <linux/fs.h> 15#include <linux/fs.h>
16#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17 17
18#ifdef CONFIG_DEVFS_FS 18#include <linux/device.h>
19#include <linux/devfs_fs_kernel.h> 19
20static struct class *mtd_class;
20 21
21static void mtd_notify_add(struct mtd_info* mtd) 22static void mtd_notify_add(struct mtd_info* mtd)
22{ 23{
23 if (!mtd) 24 if (!mtd)
24 return; 25 return;
25 26
26 devfs_mk_cdev(MKDEV(MTD_CHAR_MAJOR, mtd->index*2), 27 class_device_create(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
27 S_IFCHR | S_IRUGO | S_IWUGO, "mtd/%d", mtd->index); 28 NULL, "mtd%d", mtd->index);
28 29
29 devfs_mk_cdev(MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), 30 class_device_create(mtd_class,
30 S_IFCHR | S_IRUGO, "mtd/%dro", mtd->index); 31 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
32 NULL, "mtd%dro", mtd->index);
31} 33}
32 34
33static void mtd_notify_remove(struct mtd_info* mtd) 35static void mtd_notify_remove(struct mtd_info* mtd)
34{ 36{
35 if (!mtd) 37 if (!mtd)
36 return; 38 return;
37 devfs_remove("mtd/%d", mtd->index); 39
38 devfs_remove("mtd/%dro", mtd->index); 40 class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2));
41 class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1));
39} 42}
40 43
41static struct mtd_notifier notifier = { 44static struct mtd_notifier notifier = {
@@ -43,25 +46,25 @@ static struct mtd_notifier notifier = {
43 .remove = mtd_notify_remove, 46 .remove = mtd_notify_remove,
44}; 47};
45 48
46static inline void mtdchar_devfs_init(void) 49/*
47{ 50 * We use file->private_data to store a pointer to the MTDdevice.
48 devfs_mk_dir("mtd"); 51 * Since alighment is at least 32 bits, we have 2 bits free for OTP
49 register_mtd_user(&notifier); 52 * modes as well.
50} 53 */
51 54
52static inline void mtdchar_devfs_exit(void) 55#define TO_MTD(file) (struct mtd_info *)((long)((file)->private_data) & ~3L)
53{ 56
54 unregister_mtd_user(&notifier); 57#define MTD_MODE_OTP_FACT 1
55 devfs_remove("mtd"); 58#define MTD_MODE_OTP_USER 2
56} 59#define MTD_MODE(file) ((long)((file)->private_data) & 3)
57#else /* !DEVFS */ 60
58#define mtdchar_devfs_init() do { } while(0) 61#define SET_MTD_MODE(file, mode) \
59#define mtdchar_devfs_exit() do { } while(0) 62 do { long __p = (long)((file)->private_data); \
60#endif 63 (file)->private_data = (void *)((__p & ~3L) | mode); } while (0)
61 64
62static loff_t mtd_lseek (struct file *file, loff_t offset, int orig) 65static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
63{ 66{
64 struct mtd_info *mtd = file->private_data; 67 struct mtd_info *mtd = TO_MTD(file);
65 68
66 switch (orig) { 69 switch (orig) {
67 case 0: 70 case 0:
@@ -134,7 +137,7 @@ static int mtd_close(struct inode *inode, struct file *file)
134 137
135 DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n"); 138 DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n");
136 139
137 mtd = file->private_data; 140 mtd = TO_MTD(file);
138 141
139 if (mtd->sync) 142 if (mtd->sync)
140 mtd->sync(mtd); 143 mtd->sync(mtd);
@@ -151,7 +154,7 @@ static int mtd_close(struct inode *inode, struct file *file)
151 154
152static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t *ppos) 155static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t *ppos)
153{ 156{
154 struct mtd_info *mtd = file->private_data; 157 struct mtd_info *mtd = TO_MTD(file);
155 size_t retlen=0; 158 size_t retlen=0;
156 size_t total_retlen=0; 159 size_t total_retlen=0;
157 int ret=0; 160 int ret=0;
@@ -178,7 +181,16 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
178 if (!kbuf) 181 if (!kbuf)
179 return -ENOMEM; 182 return -ENOMEM;
180 183
181 ret = MTD_READ(mtd, *ppos, len, &retlen, kbuf); 184 switch (MTD_MODE(file)) {
185 case MTD_MODE_OTP_FACT:
186 ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf);
187 break;
188 case MTD_MODE_OTP_USER:
189 ret = mtd->read_user_prot_reg(mtd, *ppos, len, &retlen, kbuf);
190 break;
191 default:
192 ret = MTD_READ(mtd, *ppos, len, &retlen, kbuf);
193 }
182 /* Nand returns -EBADMSG on ecc errors, but it returns 194 /* Nand returns -EBADMSG on ecc errors, but it returns
183 * the data. For our userspace tools it is important 195 * the data. For our userspace tools it is important
184 * to dump areas with ecc errors ! 196 * to dump areas with ecc errors !
@@ -196,6 +208,8 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
196 208
197 count -= retlen; 209 count -= retlen;
198 buf += retlen; 210 buf += retlen;
211 if (retlen == 0)
212 count = 0;
199 } 213 }
200 else { 214 else {
201 kfree(kbuf); 215 kfree(kbuf);
@@ -210,7 +224,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
210 224
211static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count,loff_t *ppos) 225static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count,loff_t *ppos)
212{ 226{
213 struct mtd_info *mtd = file->private_data; 227 struct mtd_info *mtd = TO_MTD(file);
214 char *kbuf; 228 char *kbuf;
215 size_t retlen; 229 size_t retlen;
216 size_t total_retlen=0; 230 size_t total_retlen=0;
@@ -245,7 +259,20 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
245 return -EFAULT; 259 return -EFAULT;
246 } 260 }
247 261
248 ret = (*(mtd->write))(mtd, *ppos, len, &retlen, kbuf); 262 switch (MTD_MODE(file)) {
263 case MTD_MODE_OTP_FACT:
264 ret = -EROFS;
265 break;
266 case MTD_MODE_OTP_USER:
267 if (!mtd->write_user_prot_reg) {
268 ret = -EOPNOTSUPP;
269 break;
270 }
271 ret = mtd->write_user_prot_reg(mtd, *ppos, len, &retlen, kbuf);
272 break;
273 default:
274 ret = (*(mtd->write))(mtd, *ppos, len, &retlen, kbuf);
275 }
249 if (!ret) { 276 if (!ret) {
250 *ppos += retlen; 277 *ppos += retlen;
251 total_retlen += retlen; 278 total_retlen += retlen;
@@ -276,7 +303,7 @@ static void mtdchar_erase_callback (struct erase_info *instr)
276static int mtd_ioctl(struct inode *inode, struct file *file, 303static int mtd_ioctl(struct inode *inode, struct file *file,
277 u_int cmd, u_long arg) 304 u_int cmd, u_long arg)
278{ 305{
279 struct mtd_info *mtd = file->private_data; 306 struct mtd_info *mtd = TO_MTD(file);
280 void __user *argp = (void __user *)arg; 307 void __user *argp = (void __user *)arg;
281 int ret = 0; 308 int ret = 0;
282 u_long size; 309 u_long size;
@@ -518,6 +545,80 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
518 break; 545 break;
519 } 546 }
520 547
548#ifdef CONFIG_MTD_OTP
549 case OTPSELECT:
550 {
551 int mode;
552 if (copy_from_user(&mode, argp, sizeof(int)))
553 return -EFAULT;
554 SET_MTD_MODE(file, 0);
555 switch (mode) {
556 case MTD_OTP_FACTORY:
557 if (!mtd->read_fact_prot_reg)
558 ret = -EOPNOTSUPP;
559 else
560 SET_MTD_MODE(file, MTD_MODE_OTP_FACT);
561 break;
562 case MTD_OTP_USER:
563 if (!mtd->read_fact_prot_reg)
564 ret = -EOPNOTSUPP;
565 else
566 SET_MTD_MODE(file, MTD_MODE_OTP_USER);
567 break;
568 default:
569 ret = -EINVAL;
570 case MTD_OTP_OFF:
571 break;
572 }
573 file->f_pos = 0;
574 break;
575 }
576
577 case OTPGETREGIONCOUNT:
578 case OTPGETREGIONINFO:
579 {
580 struct otp_info *buf = kmalloc(4096, GFP_KERNEL);
581 if (!buf)
582 return -ENOMEM;
583 ret = -EOPNOTSUPP;
584 switch (MTD_MODE(file)) {
585 case MTD_MODE_OTP_FACT:
586 if (mtd->get_fact_prot_info)
587 ret = mtd->get_fact_prot_info(mtd, buf, 4096);
588 break;
589 case MTD_MODE_OTP_USER:
590 if (mtd->get_user_prot_info)
591 ret = mtd->get_user_prot_info(mtd, buf, 4096);
592 break;
593 }
594 if (ret >= 0) {
595 if (cmd == OTPGETREGIONCOUNT) {
596 int nbr = ret / sizeof(struct otp_info);
597 ret = copy_to_user(argp, &nbr, sizeof(int));
598 } else
599 ret = copy_to_user(argp, buf, ret);
600 if (ret)
601 ret = -EFAULT;
602 }
603 kfree(buf);
604 break;
605 }
606
607 case OTPLOCK:
608 {
609 struct otp_info info;
610
611 if (MTD_MODE(file) != MTD_MODE_OTP_USER)
612 return -EINVAL;
613 if (copy_from_user(&info, argp, sizeof(info)))
614 return -EFAULT;
615 if (!mtd->lock_user_prot_reg)
616 return -EOPNOTSUPP;
617 ret = mtd->lock_user_prot_reg(mtd, info.start, info.length);
618 break;
619 }
620#endif
621
521 default: 622 default:
522 ret = -ENOTTY; 623 ret = -ENOTTY;
523 } 624 }
@@ -543,13 +644,22 @@ static int __init init_mtdchar(void)
543 return -EAGAIN; 644 return -EAGAIN;
544 } 645 }
545 646
546 mtdchar_devfs_init(); 647 mtd_class = class_create(THIS_MODULE, "mtd");
648
649 if (IS_ERR(mtd_class)) {
650 printk(KERN_ERR "Error creating mtd class.\n");
651 unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
652 return PTR_ERR(mtd_class);
653 }
654
655 register_mtd_user(&notifier);
547 return 0; 656 return 0;
548} 657}
549 658
550static void __exit cleanup_mtdchar(void) 659static void __exit cleanup_mtdchar(void)
551{ 660{
552 mtdchar_devfs_exit(); 661 unregister_mtd_user(&notifier);
662 class_destroy(mtd_class);
553 unregister_chrdev(MTD_CHAR_MAJOR, "mtd"); 663 unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
554} 664}
555 665
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 9c0315d1b1c4..dc86df18e94b 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: mtdcore.c,v 1.44 2004/11/16 18:28:59 dwmw2 Exp $ 2 * $Id: mtdcore.c,v 1.45 2005/02/18 14:34:50 dedekind Exp $
3 * 3 *
4 * Core registration and callback routines for MTD 4 * Core registration and callback routines for MTD
5 * drivers and users. 5 * drivers and users.
@@ -149,8 +149,8 @@ void register_mtd_user (struct mtd_notifier *new)
149} 149}
150 150
151/** 151/**
152 * register_mtd_user - unregister a 'user' of MTD devices. 152 * unregister_mtd_user - unregister a 'user' of MTD devices.
153 * @new: pointer to notifier info structure 153 * @old: pointer to notifier info structure
154 * 154 *
155 * Removes a callback function pair from the list of 'users' to be 155 * Removes a callback function pair from the list of 'users' to be
156 * notified upon addition or removal of MTD devices. Causes the 156 * notified upon addition or removal of MTD devices. Causes the
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 96ebb52f24b1..b92e6bfffaf2 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 * 7 *
8 * $Id: mtdpart.c,v 1.51 2004/11/16 18:28:59 dwmw2 Exp $ 8 * $Id: mtdpart.c,v 1.53 2005/02/08 17:11:13 nico Exp $
9 * 9 *
10 * 02-21-2002 Thomas Gleixner <gleixner@autronix.de> 10 * 02-21-2002 Thomas Gleixner <gleixner@autronix.de>
11 * added support for read_oob, write_oob 11 * added support for read_oob, write_oob
@@ -116,6 +116,13 @@ static int part_read_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t le
116 len, retlen, buf); 116 len, retlen, buf);
117} 117}
118 118
119static int part_get_user_prot_info (struct mtd_info *mtd,
120 struct otp_info *buf, size_t len)
121{
122 struct mtd_part *part = PART(mtd);
123 return part->master->get_user_prot_info (part->master, buf, len);
124}
125
119static int part_read_fact_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, 126static int part_read_fact_prot_reg (struct mtd_info *mtd, loff_t from, size_t len,
120 size_t *retlen, u_char *buf) 127 size_t *retlen, u_char *buf)
121{ 128{
@@ -124,6 +131,13 @@ static int part_read_fact_prot_reg (struct mtd_info *mtd, loff_t from, size_t le
124 len, retlen, buf); 131 len, retlen, buf);
125} 132}
126 133
134static int part_get_fact_prot_info (struct mtd_info *mtd,
135 struct otp_info *buf, size_t len)
136{
137 struct mtd_part *part = PART(mtd);
138 return part->master->get_fact_prot_info (part->master, buf, len);
139}
140
127static int part_write (struct mtd_info *mtd, loff_t to, size_t len, 141static int part_write (struct mtd_info *mtd, loff_t to, size_t len,
128 size_t *retlen, const u_char *buf) 142 size_t *retlen, const u_char *buf)
129{ 143{
@@ -182,6 +196,12 @@ static int part_write_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t l
182 len, retlen, buf); 196 len, retlen, buf);
183} 197}
184 198
199static int part_lock_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len)
200{
201 struct mtd_part *part = PART(mtd);
202 return part->master->lock_user_prot_reg (part->master, from, len);
203}
204
185static int part_writev (struct mtd_info *mtd, const struct kvec *vecs, 205static int part_writev (struct mtd_info *mtd, const struct kvec *vecs,
186 unsigned long count, loff_t to, size_t *retlen) 206 unsigned long count, loff_t to, size_t *retlen)
187{ 207{
@@ -409,6 +429,12 @@ int add_mtd_partitions(struct mtd_info *master,
409 slave->mtd.read_fact_prot_reg = part_read_fact_prot_reg; 429 slave->mtd.read_fact_prot_reg = part_read_fact_prot_reg;
410 if(master->write_user_prot_reg) 430 if(master->write_user_prot_reg)
411 slave->mtd.write_user_prot_reg = part_write_user_prot_reg; 431 slave->mtd.write_user_prot_reg = part_write_user_prot_reg;
432 if(master->lock_user_prot_reg)
433 slave->mtd.lock_user_prot_reg = part_lock_user_prot_reg;
434 if(master->get_user_prot_info)
435 slave->mtd.get_user_prot_info = part_get_user_prot_info;
436 if(master->get_fact_prot_info)
437 slave->mtd.get_fact_prot_info = part_get_fact_prot_info;
412 if (master->sync) 438 if (master->sync)
413 slave->mtd.sync = part_sync; 439 slave->mtd.sync = part_sync;
414 if (!i && master->suspend && master->resume) { 440 if (!i && master->suspend && master->resume) {
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index f7801eb730ce..36d34e5e5a5a 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -1,5 +1,5 @@
1# drivers/mtd/nand/Kconfig 1# drivers/mtd/nand/Kconfig
2# $Id: Kconfig,v 1.26 2005/01/05 12:42:24 dwmw2 Exp $ 2# $Id: Kconfig,v 1.31 2005/06/20 12:03:21 bjd Exp $
3 3
4menu "NAND Flash Device Drivers" 4menu "NAND Flash Device Drivers"
5 depends on MTD!=n 5 depends on MTD!=n
@@ -58,20 +58,6 @@ config MTD_NAND_TOTO
58config MTD_NAND_IDS 58config MTD_NAND_IDS
59 tristate 59 tristate
60 60
61config MTD_NAND_TX4925NDFMC
62 tristate "SmartMedia Card on Toshiba RBTX4925 reference board"
63 depends on TOSHIBA_RBTX4925 && MTD_NAND && TOSHIBA_RBTX4925_MPLEX_NAND
64 help
65 This enables the driver for the NAND flash device found on the
66 Toshiba RBTX4925 reference board, which is a SmartMediaCard.
67
68config MTD_NAND_TX4938NDFMC
69 tristate "NAND Flash device on Toshiba RBTX4938 reference board"
70 depends on TOSHIBA_RBTX4938 && MTD_NAND && TOSHIBA_RBTX4938_MPLEX_NAND
71 help
72 This enables the driver for the NAND flash device found on the
73 Toshiba RBTX4938 reference board.
74
75config MTD_NAND_AU1550 61config MTD_NAND_AU1550
76 tristate "Au1550 NAND support" 62 tristate "Au1550 NAND support"
77 depends on SOC_AU1550 && MTD_NAND 63 depends on SOC_AU1550 && MTD_NAND
@@ -95,10 +81,11 @@ config MTD_NAND_PPCHAMELEONEVB
95 This enables the NAND flash driver on the PPChameleon EVB Board. 81 This enables the NAND flash driver on the PPChameleon EVB Board.
96 82
97config MTD_NAND_S3C2410 83config MTD_NAND_S3C2410
98 tristate "NAND Flash support for S3C2410 SoC" 84 tristate "NAND Flash support for S3C2410/S3C2440 SoC"
99 depends on ARCH_S3C2410 && MTD_NAND 85 depends on ARCH_S3C2410 && MTD_NAND
100 help 86 help
101 This enables the NAND flash controller on the S3C2410. 87 This enables the NAND flash controller on the S3C2410 and S3C2440
88 SoCs
102 89
103 No board specfic support is done by this driver, each board 90 No board specfic support is done by this driver, each board
104 must advertise a platform_device for the driver to attach. 91 must advertise a platform_device for the driver to attach.
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index d9dc8cc2da8c..41742026a52e 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -10,8 +10,6 @@ obj-$(CONFIG_MTD_NAND_SPIA) += spia.o
10obj-$(CONFIG_MTD_NAND_TOTO) += toto.o 10obj-$(CONFIG_MTD_NAND_TOTO) += toto.o
11obj-$(CONFIG_MTD_NAND_AUTCPU12) += autcpu12.o 11obj-$(CONFIG_MTD_NAND_AUTCPU12) += autcpu12.o
12obj-$(CONFIG_MTD_NAND_EDB7312) += edb7312.o 12obj-$(CONFIG_MTD_NAND_EDB7312) += edb7312.o
13obj-$(CONFIG_MTD_NAND_TX4925NDFMC) += tx4925ndfmc.o
14obj-$(CONFIG_MTD_NAND_TX4938NDFMC) += tx4938ndfmc.o
15obj-$(CONFIG_MTD_NAND_AU1550) += au1550nd.o 13obj-$(CONFIG_MTD_NAND_AU1550) += au1550nd.o
16obj-$(CONFIG_MTD_NAND_PPCHAMELEONEVB) += ppchameleonevb.o 14obj-$(CONFIG_MTD_NAND_PPCHAMELEONEVB) += ppchameleonevb.o
17obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o 15obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index 02135c3ac29a..fdb5d4ad3d52 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -16,7 +16,7 @@
16 * 16 *
17 * Interface to generic NAND code for M-Systems DiskOnChip devices 17 * Interface to generic NAND code for M-Systems DiskOnChip devices
18 * 18 *
19 * $Id: diskonchip.c,v 1.45 2005/01/05 18:05:14 dwmw2 Exp $ 19 * $Id: diskonchip.c,v 1.54 2005/04/07 14:22:55 dbrown Exp $
20 */ 20 */
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -35,13 +35,13 @@
35#include <linux/mtd/inftl.h> 35#include <linux/mtd/inftl.h>
36 36
37/* Where to look for the devices? */ 37/* Where to look for the devices? */
38#ifndef CONFIG_MTD_DISKONCHIP_PROBE_ADDRESS 38#ifndef CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS
39#define CONFIG_MTD_DISKONCHIP_PROBE_ADDRESS 0 39#define CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS 0
40#endif 40#endif
41 41
42static unsigned long __initdata doc_locations[] = { 42static unsigned long __initdata doc_locations[] = {
43#if defined (__alpha__) || defined(__i386__) || defined(__x86_64__) 43#if defined (__alpha__) || defined(__i386__) || defined(__x86_64__)
44#ifdef CONFIG_MTD_DISKONCHIP_PROBE_HIGH 44#ifdef CONFIG_MTD_NAND_DISKONCHIP_PROBE_HIGH
45 0xfffc8000, 0xfffca000, 0xfffcc000, 0xfffce000, 45 0xfffc8000, 0xfffca000, 0xfffcc000, 0xfffce000,
46 0xfffd0000, 0xfffd2000, 0xfffd4000, 0xfffd6000, 46 0xfffd0000, 0xfffd2000, 0xfffd4000, 0xfffd6000,
47 0xfffd8000, 0xfffda000, 0xfffdc000, 0xfffde000, 47 0xfffd8000, 0xfffda000, 0xfffdc000, 0xfffde000,
@@ -81,11 +81,6 @@ struct doc_priv {
81 struct mtd_info *nextdoc; 81 struct mtd_info *nextdoc;
82}; 82};
83 83
84/* Max number of eraseblocks to scan (from start of device) for the (I)NFTL
85 MediaHeader. The spec says to just keep going, I think, but that's just
86 silly. */
87#define MAX_MEDIAHEADER_SCAN 8
88
89/* This is the syndrome computed by the HW ecc generator upon reading an empty 84/* This is the syndrome computed by the HW ecc generator upon reading an empty
90 page, one with all 0xff for data and stored ecc code. */ 85 page, one with all 0xff for data and stored ecc code. */
91static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a }; 86static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a };
@@ -111,10 +106,11 @@ module_param(try_dword, int, 0);
111static int no_ecc_failures=0; 106static int no_ecc_failures=0;
112module_param(no_ecc_failures, int, 0); 107module_param(no_ecc_failures, int, 0);
113 108
114#ifdef CONFIG_MTD_PARTITIONS
115static int no_autopart=0; 109static int no_autopart=0;
116module_param(no_autopart, int, 0); 110module_param(no_autopart, int, 0);
117#endif 111
112static int show_firmware_partition=0;
113module_param(show_firmware_partition, int, 0);
118 114
119#ifdef MTD_NAND_DISKONCHIP_BBTWRITE 115#ifdef MTD_NAND_DISKONCHIP_BBTWRITE
120static int inftl_bbt_write=1; 116static int inftl_bbt_write=1;
@@ -123,7 +119,7 @@ static int inftl_bbt_write=0;
123#endif 119#endif
124module_param(inftl_bbt_write, int, 0); 120module_param(inftl_bbt_write, int, 0);
125 121
126static unsigned long doc_config_location = CONFIG_MTD_DISKONCHIP_PROBE_ADDRESS; 122static unsigned long doc_config_location = CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS;
127module_param(doc_config_location, ulong, 0); 123module_param(doc_config_location, ulong, 0);
128MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip"); 124MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip");
129 125
@@ -410,7 +406,12 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)
410 doc200x_hwcontrol(mtd, NAND_CTL_SETALE); 406 doc200x_hwcontrol(mtd, NAND_CTL_SETALE);
411 this->write_byte(mtd, 0); 407 this->write_byte(mtd, 0);
412 doc200x_hwcontrol(mtd, NAND_CTL_CLRALE); 408 doc200x_hwcontrol(mtd, NAND_CTL_CLRALE);
413 409
410 /* We cant' use dev_ready here, but at least we wait for the
411 * command to complete
412 */
413 udelay(50);
414
414 ret = this->read_byte(mtd) << 8; 415 ret = this->read_byte(mtd) << 8;
415 ret |= this->read_byte(mtd); 416 ret |= this->read_byte(mtd);
416 417
@@ -429,6 +430,8 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)
429 doc2000_write_byte(mtd, 0); 430 doc2000_write_byte(mtd, 0);
430 doc200x_hwcontrol(mtd, NAND_CTL_CLRALE); 431 doc200x_hwcontrol(mtd, NAND_CTL_CLRALE);
431 432
433 udelay(50);
434
432 ident.dword = readl(docptr + DoC_2k_CDSN_IO); 435 ident.dword = readl(docptr + DoC_2k_CDSN_IO);
433 if (((ident.byte[0] << 8) | ident.byte[1]) == ret) { 436 if (((ident.byte[0] << 8) | ident.byte[1]) == ret) {
434 printk(KERN_INFO "DiskOnChip 2000 responds to DWORD access\n"); 437 printk(KERN_INFO "DiskOnChip 2000 responds to DWORD access\n");
@@ -1046,11 +1049,21 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_
1046 1049
1047//u_char mydatabuf[528]; 1050//u_char mydatabuf[528];
1048 1051
1052/* The strange out-of-order .oobfree list below is a (possibly unneeded)
1053 * attempt to retain compatibility. It used to read:
1054 * .oobfree = { {8, 8} }
1055 * Since that leaves two bytes unusable, it was changed. But the following
1056 * scheme might affect existing jffs2 installs by moving the cleanmarker:
1057 * .oobfree = { {6, 10} }
1058 * jffs2 seems to handle the above gracefully, but the current scheme seems
1059 * safer. The only problem with it is that any code that parses oobfree must
1060 * be able to handle out-of-order segments.
1061 */
1049static struct nand_oobinfo doc200x_oobinfo = { 1062static struct nand_oobinfo doc200x_oobinfo = {
1050 .useecc = MTD_NANDECC_AUTOPLACE, 1063 .useecc = MTD_NANDECC_AUTOPLACE,
1051 .eccbytes = 6, 1064 .eccbytes = 6,
1052 .eccpos = {0, 1, 2, 3, 4, 5}, 1065 .eccpos = {0, 1, 2, 3, 4, 5},
1053 .oobfree = { {8, 8} } 1066 .oobfree = { {8, 8}, {6, 2} }
1054}; 1067};
1055 1068
1056/* Find the (I)NFTL Media Header, and optionally also the mirror media header. 1069/* Find the (I)NFTL Media Header, and optionally also the mirror media header.
@@ -1064,12 +1077,11 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf,
1064{ 1077{
1065 struct nand_chip *this = mtd->priv; 1078 struct nand_chip *this = mtd->priv;
1066 struct doc_priv *doc = this->priv; 1079 struct doc_priv *doc = this->priv;
1067 unsigned offs, end = (MAX_MEDIAHEADER_SCAN << this->phys_erase_shift); 1080 unsigned offs;
1068 int ret; 1081 int ret;
1069 size_t retlen; 1082 size_t retlen;
1070 1083
1071 end = min(end, mtd->size); // paranoia 1084 for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
1072 for (offs = 0; offs < end; offs += mtd->erasesize) {
1073 ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); 1085 ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf);
1074 if (retlen != mtd->oobblock) continue; 1086 if (retlen != mtd->oobblock) continue;
1075 if (ret) { 1087 if (ret) {
@@ -1111,6 +1123,7 @@ static inline int __init nftl_partscan(struct mtd_info *mtd,
1111 u_char *buf; 1123 u_char *buf;
1112 struct NFTLMediaHeader *mh; 1124 struct NFTLMediaHeader *mh;
1113 const unsigned psize = 1 << this->page_shift; 1125 const unsigned psize = 1 << this->page_shift;
1126 int numparts = 0;
1114 unsigned blocks, maxblocks; 1127 unsigned blocks, maxblocks;
1115 int offs, numheaders; 1128 int offs, numheaders;
1116 1129
@@ -1122,8 +1135,10 @@ static inline int __init nftl_partscan(struct mtd_info *mtd,
1122 if (!(numheaders=find_media_headers(mtd, buf, "ANAND", 1))) goto out; 1135 if (!(numheaders=find_media_headers(mtd, buf, "ANAND", 1))) goto out;
1123 mh = (struct NFTLMediaHeader *) buf; 1136 mh = (struct NFTLMediaHeader *) buf;
1124 1137
1125//#ifdef CONFIG_MTD_DEBUG_VERBOSE 1138 mh->NumEraseUnits = le16_to_cpu(mh->NumEraseUnits);
1126// if (CONFIG_MTD_DEBUG_VERBOSE >= 2) 1139 mh->FirstPhysicalEUN = le16_to_cpu(mh->FirstPhysicalEUN);
1140 mh->FormattedSize = le32_to_cpu(mh->FormattedSize);
1141
1127 printk(KERN_INFO " DataOrgID = %s\n" 1142 printk(KERN_INFO " DataOrgID = %s\n"
1128 " NumEraseUnits = %d\n" 1143 " NumEraseUnits = %d\n"
1129 " FirstPhysicalEUN = %d\n" 1144 " FirstPhysicalEUN = %d\n"
@@ -1132,7 +1147,6 @@ static inline int __init nftl_partscan(struct mtd_info *mtd,
1132 mh->DataOrgID, mh->NumEraseUnits, 1147 mh->DataOrgID, mh->NumEraseUnits,
1133 mh->FirstPhysicalEUN, mh->FormattedSize, 1148 mh->FirstPhysicalEUN, mh->FormattedSize,
1134 mh->UnitSizeFactor); 1149 mh->UnitSizeFactor);
1135//#endif
1136 1150
1137 blocks = mtd->size >> this->phys_erase_shift; 1151 blocks = mtd->size >> this->phys_erase_shift;
1138 maxblocks = min(32768U, mtd->erasesize - psize); 1152 maxblocks = min(32768U, mtd->erasesize - psize);
@@ -1175,23 +1189,28 @@ static inline int __init nftl_partscan(struct mtd_info *mtd,
1175 offs <<= this->page_shift; 1189 offs <<= this->page_shift;
1176 offs += mtd->erasesize; 1190 offs += mtd->erasesize;
1177 1191
1178 //parts[0].name = " DiskOnChip Boot / Media Header partition"; 1192 if (show_firmware_partition == 1) {
1179 //parts[0].offset = 0; 1193 parts[0].name = " DiskOnChip Firmware / Media Header partition";
1180 //parts[0].size = offs; 1194 parts[0].offset = 0;
1195 parts[0].size = offs;
1196 numparts = 1;
1197 }
1181 1198
1182 parts[0].name = " DiskOnChip BDTL partition"; 1199 parts[numparts].name = " DiskOnChip BDTL partition";
1183 parts[0].offset = offs; 1200 parts[numparts].offset = offs;
1184 parts[0].size = (mh->NumEraseUnits - numheaders) << this->bbt_erase_shift; 1201 parts[numparts].size = (mh->NumEraseUnits - numheaders) << this->bbt_erase_shift;
1202
1203 offs += parts[numparts].size;
1204 numparts++;
1185 1205
1186 offs += parts[0].size;
1187 if (offs < mtd->size) { 1206 if (offs < mtd->size) {
1188 parts[1].name = " DiskOnChip Remainder partition"; 1207 parts[numparts].name = " DiskOnChip Remainder partition";
1189 parts[1].offset = offs; 1208 parts[numparts].offset = offs;
1190 parts[1].size = mtd->size - offs; 1209 parts[numparts].size = mtd->size - offs;
1191 ret = 2; 1210 numparts++;
1192 goto out;
1193 } 1211 }
1194 ret = 1; 1212
1213 ret = numparts;
1195out: 1214out:
1196 kfree(buf); 1215 kfree(buf);
1197 return ret; 1216 return ret;
@@ -1233,8 +1252,6 @@ static inline int __init inftl_partscan(struct mtd_info *mtd,
1233 mh->FormatFlags = le32_to_cpu(mh->FormatFlags); 1252 mh->FormatFlags = le32_to_cpu(mh->FormatFlags);
1234 mh->PercentUsed = le32_to_cpu(mh->PercentUsed); 1253 mh->PercentUsed = le32_to_cpu(mh->PercentUsed);
1235 1254
1236//#ifdef CONFIG_MTD_DEBUG_VERBOSE
1237// if (CONFIG_MTD_DEBUG_VERBOSE >= 2)
1238 printk(KERN_INFO " bootRecordID = %s\n" 1255 printk(KERN_INFO " bootRecordID = %s\n"
1239 " NoOfBootImageBlocks = %d\n" 1256 " NoOfBootImageBlocks = %d\n"
1240 " NoOfBinaryPartitions = %d\n" 1257 " NoOfBinaryPartitions = %d\n"
@@ -1252,7 +1269,6 @@ static inline int __init inftl_partscan(struct mtd_info *mtd,
1252 ((unsigned char *) &mh->OsakVersion)[2] & 0xf, 1269 ((unsigned char *) &mh->OsakVersion)[2] & 0xf,
1253 ((unsigned char *) &mh->OsakVersion)[3] & 0xf, 1270 ((unsigned char *) &mh->OsakVersion)[3] & 0xf,
1254 mh->PercentUsed); 1271 mh->PercentUsed);
1255//#endif
1256 1272
1257 vshift = this->phys_erase_shift + mh->BlockMultiplierBits; 1273 vshift = this->phys_erase_shift + mh->BlockMultiplierBits;
1258 1274
@@ -1278,8 +1294,6 @@ static inline int __init inftl_partscan(struct mtd_info *mtd,
1278 ip->spareUnits = le32_to_cpu(ip->spareUnits); 1294 ip->spareUnits = le32_to_cpu(ip->spareUnits);
1279 ip->Reserved0 = le32_to_cpu(ip->Reserved0); 1295 ip->Reserved0 = le32_to_cpu(ip->Reserved0);
1280 1296
1281//#ifdef CONFIG_MTD_DEBUG_VERBOSE
1282// if (CONFIG_MTD_DEBUG_VERBOSE >= 2)
1283 printk(KERN_INFO " PARTITION[%d] ->\n" 1297 printk(KERN_INFO " PARTITION[%d] ->\n"
1284 " virtualUnits = %d\n" 1298 " virtualUnits = %d\n"
1285 " firstUnit = %d\n" 1299 " firstUnit = %d\n"
@@ -1289,16 +1303,14 @@ static inline int __init inftl_partscan(struct mtd_info *mtd,
1289 i, ip->virtualUnits, ip->firstUnit, 1303 i, ip->virtualUnits, ip->firstUnit,
1290 ip->lastUnit, ip->flags, 1304 ip->lastUnit, ip->flags,
1291 ip->spareUnits); 1305 ip->spareUnits);
1292//#endif
1293 1306
1294/* 1307 if ((show_firmware_partition == 1) &&
1295 if ((i == 0) && (ip->firstUnit > 0)) { 1308 (i == 0) && (ip->firstUnit > 0)) {
1296 parts[0].name = " DiskOnChip IPL / Media Header partition"; 1309 parts[0].name = " DiskOnChip IPL / Media Header partition";
1297 parts[0].offset = 0; 1310 parts[0].offset = 0;
1298 parts[0].size = mtd->erasesize * ip->firstUnit; 1311 parts[0].size = mtd->erasesize * ip->firstUnit;
1299 numparts = 1; 1312 numparts = 1;
1300 } 1313 }
1301*/
1302 1314
1303 if (ip->flags & INFTL_BINARY) 1315 if (ip->flags & INFTL_BINARY)
1304 parts[numparts].name = " DiskOnChip BDK partition"; 1316 parts[numparts].name = " DiskOnChip BDK partition";
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 44d5b128911f..1bd71a598c79 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -28,6 +28,24 @@
28 * among multiple independend devices. Suggestions and initial patch 28 * among multiple independend devices. Suggestions and initial patch
29 * from Ben Dooks <ben-mtd@fluff.org> 29 * from Ben Dooks <ben-mtd@fluff.org>
30 * 30 *
31 * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb" issue.
32 * Basically, any block not rewritten may lose data when surrounding blocks
33 * are rewritten many times. JFFS2 ensures this doesn't happen for blocks
34 * it uses, but the Bad Block Table(s) may not be rewritten. To ensure they
35 * do not lose data, force them to be rewritten when some of the surrounding
36 * blocks are erased. Rather than tracking a specific nearby block (which
37 * could itself go bad), use a page address 'mask' to select several blocks
38 * in the same area, and rewrite the BBT when any of them are erased.
39 *
40 * 01-03-2005 dmarlin: added support for the device recovery command sequence for Renesas
41 * AG-AND chips. If there was a sudden loss of power during an erase operation,
42 * a "device recovery" operation must be performed when power is restored
43 * to ensure correct operation.
44 *
45 * 01-20-2005 dmarlin: added support for optional hardware specific callback routine to
46 * perform extra error status checks on erase and write failures. This required
47 * adding a wrapper function for nand_read_ecc.
48 *
31 * Credits: 49 * Credits:
32 * David Woodhouse for adding multichip support 50 * David Woodhouse for adding multichip support
33 * 51 *
@@ -41,7 +59,7 @@
41 * The AG-AND chips have nice features for speed improvement, 59 * The AG-AND chips have nice features for speed improvement,
42 * which are not supported yet. Read / program 4 pages in one go. 60 * which are not supported yet. Read / program 4 pages in one go.
43 * 61 *
44 * $Id: nand_base.c,v 1.126 2004/12/13 11:22:25 lavinen Exp $ 62 * $Id: nand_base.c,v 1.146 2005/06/17 15:02:06 gleixner Exp $
45 * 63 *
46 * This program is free software; you can redistribute it and/or modify 64 * This program is free software; you can redistribute it and/or modify
47 * it under the terms of the GNU General Public License version 2 as 65 * it under the terms of the GNU General Public License version 2 as
@@ -149,17 +167,21 @@ static void nand_release_device (struct mtd_info *mtd)
149 167
150 /* De-select the NAND device */ 168 /* De-select the NAND device */
151 this->select_chip(mtd, -1); 169 this->select_chip(mtd, -1);
152 /* Do we have a hardware controller ? */ 170
153 if (this->controller) { 171 if (this->controller) {
172 /* Release the controller and the chip */
154 spin_lock(&this->controller->lock); 173 spin_lock(&this->controller->lock);
155 this->controller->active = NULL; 174 this->controller->active = NULL;
175 this->state = FL_READY;
176 wake_up(&this->controller->wq);
156 spin_unlock(&this->controller->lock); 177 spin_unlock(&this->controller->lock);
178 } else {
179 /* Release the chip */
180 spin_lock(&this->chip_lock);
181 this->state = FL_READY;
182 wake_up(&this->wq);
183 spin_unlock(&this->chip_lock);
157 } 184 }
158 /* Release the chip */
159 spin_lock (&this->chip_lock);
160 this->state = FL_READY;
161 wake_up (&this->wq);
162 spin_unlock (&this->chip_lock);
163} 185}
164 186
165/** 187/**
@@ -443,7 +465,8 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
443 465
444 /* Get block number */ 466 /* Get block number */
445 block = ((int) ofs) >> this->bbt_erase_shift; 467 block = ((int) ofs) >> this->bbt_erase_shift;
446 this->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1); 468 if (this->bbt)
469 this->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1);
447 470
448 /* Do we have a flash based bad block table ? */ 471 /* Do we have a flash based bad block table ? */
449 if (this->options & NAND_USE_FLASH_BBT) 472 if (this->options & NAND_USE_FLASH_BBT)
@@ -466,7 +489,7 @@ static int nand_check_wp (struct mtd_info *mtd)
466 struct nand_chip *this = mtd->priv; 489 struct nand_chip *this = mtd->priv;
467 /* Check the WP bit */ 490 /* Check the WP bit */
468 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); 491 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
469 return (this->read_byte(mtd) & 0x80) ? 0 : 1; 492 return (this->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1;
470} 493}
471 494
472/** 495/**
@@ -490,6 +513,22 @@ static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, i
490 return nand_isbad_bbt (mtd, ofs, allowbbt); 513 return nand_isbad_bbt (mtd, ofs, allowbbt);
491} 514}
492 515
516/*
517 * Wait for the ready pin, after a command
518 * The timeout is catched later.
519 */
520static void nand_wait_ready(struct mtd_info *mtd)
521{
522 struct nand_chip *this = mtd->priv;
523 unsigned long timeo = jiffies + 2;
524
525 /* wait until command is processed or timeout occures */
526 do {
527 if (this->dev_ready(mtd))
528 return;
529 } while (time_before(jiffies, timeo));
530}
531
493/** 532/**
494 * nand_command - [DEFAULT] Send command to NAND device 533 * nand_command - [DEFAULT] Send command to NAND device
495 * @mtd: MTD device structure 534 * @mtd: MTD device structure
@@ -571,7 +610,7 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in
571 this->hwcontrol(mtd, NAND_CTL_SETCLE); 610 this->hwcontrol(mtd, NAND_CTL_SETCLE);
572 this->write_byte(mtd, NAND_CMD_STATUS); 611 this->write_byte(mtd, NAND_CMD_STATUS);
573 this->hwcontrol(mtd, NAND_CTL_CLRCLE); 612 this->hwcontrol(mtd, NAND_CTL_CLRCLE);
574 while ( !(this->read_byte(mtd) & 0x40)); 613 while ( !(this->read_byte(mtd) & NAND_STATUS_READY));
575 return; 614 return;
576 615
577 /* This applies to read commands */ 616 /* This applies to read commands */
@@ -585,12 +624,11 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in
585 return; 624 return;
586 } 625 }
587 } 626 }
588
589 /* Apply this short delay always to ensure that we do wait tWB in 627 /* Apply this short delay always to ensure that we do wait tWB in
590 * any case on any machine. */ 628 * any case on any machine. */
591 ndelay (100); 629 ndelay (100);
592 /* wait until command is processed */ 630
593 while (!this->dev_ready(mtd)); 631 nand_wait_ready(mtd);
594} 632}
595 633
596/** 634/**
@@ -619,7 +657,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
619 /* Begin command latch cycle */ 657 /* Begin command latch cycle */
620 this->hwcontrol(mtd, NAND_CTL_SETCLE); 658 this->hwcontrol(mtd, NAND_CTL_SETCLE);
621 /* Write out the command to the device. */ 659 /* Write out the command to the device. */
622 this->write_byte(mtd, command); 660 this->write_byte(mtd, (command & 0xff));
623 /* End command latch cycle */ 661 /* End command latch cycle */
624 this->hwcontrol(mtd, NAND_CTL_CLRCLE); 662 this->hwcontrol(mtd, NAND_CTL_CLRCLE);
625 663
@@ -647,8 +685,8 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
647 685
648 /* 686 /*
649 * program and erase have their own busy handlers 687 * program and erase have their own busy handlers
650 * status and sequential in needs no delay 688 * status, sequential in, and deplete1 need no delay
651 */ 689 */
652 switch (command) { 690 switch (command) {
653 691
654 case NAND_CMD_CACHEDPROG: 692 case NAND_CMD_CACHEDPROG:
@@ -657,8 +695,19 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
657 case NAND_CMD_ERASE2: 695 case NAND_CMD_ERASE2:
658 case NAND_CMD_SEQIN: 696 case NAND_CMD_SEQIN:
659 case NAND_CMD_STATUS: 697 case NAND_CMD_STATUS:
698 case NAND_CMD_DEPLETE1:
660 return; 699 return;
661 700
701 /*
702 * read error status commands require only a short delay
703 */
704 case NAND_CMD_STATUS_ERROR:
705 case NAND_CMD_STATUS_ERROR0:
706 case NAND_CMD_STATUS_ERROR1:
707 case NAND_CMD_STATUS_ERROR2:
708 case NAND_CMD_STATUS_ERROR3:
709 udelay(this->chip_delay);
710 return;
662 711
663 case NAND_CMD_RESET: 712 case NAND_CMD_RESET:
664 if (this->dev_ready) 713 if (this->dev_ready)
@@ -667,7 +716,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
667 this->hwcontrol(mtd, NAND_CTL_SETCLE); 716 this->hwcontrol(mtd, NAND_CTL_SETCLE);
668 this->write_byte(mtd, NAND_CMD_STATUS); 717 this->write_byte(mtd, NAND_CMD_STATUS);
669 this->hwcontrol(mtd, NAND_CTL_CLRCLE); 718 this->hwcontrol(mtd, NAND_CTL_CLRCLE);
670 while ( !(this->read_byte(mtd) & 0x40)); 719 while ( !(this->read_byte(mtd) & NAND_STATUS_READY));
671 return; 720 return;
672 721
673 case NAND_CMD_READ0: 722 case NAND_CMD_READ0:
@@ -690,12 +739,12 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
690 return; 739 return;
691 } 740 }
692 } 741 }
693 742
694 /* Apply this short delay always to ensure that we do wait tWB in 743 /* Apply this short delay always to ensure that we do wait tWB in
695 * any case on any machine. */ 744 * any case on any machine. */
696 ndelay (100); 745 ndelay (100);
697 /* wait until command is processed */ 746
698 while (!this->dev_ready(mtd)); 747 nand_wait_ready(mtd);
699} 748}
700 749
701/** 750/**
@@ -708,37 +757,34 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
708 */ 757 */
709static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state) 758static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state)
710{ 759{
711 struct nand_chip *active = this; 760 struct nand_chip *active;
712 761 spinlock_t *lock;
762 wait_queue_head_t *wq;
713 DECLARE_WAITQUEUE (wait, current); 763 DECLARE_WAITQUEUE (wait, current);
714 764
715 /* 765 lock = (this->controller) ? &this->controller->lock : &this->chip_lock;
716 * Grab the lock and see if the device is available 766 wq = (this->controller) ? &this->controller->wq : &this->wq;
717 */
718retry: 767retry:
768 active = this;
769 spin_lock(lock);
770
719 /* Hardware controller shared among independend devices */ 771 /* Hardware controller shared among independend devices */
720 if (this->controller) { 772 if (this->controller) {
721 spin_lock (&this->controller->lock);
722 if (this->controller->active) 773 if (this->controller->active)
723 active = this->controller->active; 774 active = this->controller->active;
724 else 775 else
725 this->controller->active = this; 776 this->controller->active = this;
726 spin_unlock (&this->controller->lock);
727 } 777 }
728 778 if (active == this && this->state == FL_READY) {
729 if (active == this) { 779 this->state = new_state;
730 spin_lock (&this->chip_lock); 780 spin_unlock(lock);
731 if (this->state == FL_READY) { 781 return;
732 this->state = new_state; 782 }
733 spin_unlock (&this->chip_lock); 783 set_current_state(TASK_UNINTERRUPTIBLE);
734 return; 784 add_wait_queue(wq, &wait);
735 } 785 spin_unlock(lock);
736 } 786 schedule();
737 set_current_state (TASK_UNINTERRUPTIBLE); 787 remove_wait_queue(wq, &wait);
738 add_wait_queue (&active->wq, &wait);
739 spin_unlock (&active->chip_lock);
740 schedule ();
741 remove_wait_queue (&active->wq, &wait);
742 goto retry; 788 goto retry;
743} 789}
744 790
@@ -785,7 +831,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
785 if (this->read_byte(mtd) & NAND_STATUS_READY) 831 if (this->read_byte(mtd) & NAND_STATUS_READY)
786 break; 832 break;
787 } 833 }
788 yield (); 834 cond_resched();
789 } 835 }
790 status = (int) this->read_byte(mtd); 836 status = (int) this->read_byte(mtd);
791 return status; 837 return status;
@@ -871,8 +917,14 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa
871 if (!cached) { 917 if (!cached) {
872 /* call wait ready function */ 918 /* call wait ready function */
873 status = this->waitfunc (mtd, this, FL_WRITING); 919 status = this->waitfunc (mtd, this, FL_WRITING);
920
921 /* See if operation failed and additional status checks are available */
922 if ((status & NAND_STATUS_FAIL) && (this->errstat)) {
923 status = this->errstat(mtd, this, FL_WRITING, status, page);
924 }
925
874 /* See if device thinks it succeeded */ 926 /* See if device thinks it succeeded */
875 if (status & 0x01) { 927 if (status & NAND_STATUS_FAIL) {
876 DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page); 928 DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page);
877 return -EIO; 929 return -EIO;
878 } 930 }
@@ -975,7 +1027,7 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
975 if (!this->dev_ready) 1027 if (!this->dev_ready)
976 udelay (this->chip_delay); 1028 udelay (this->chip_delay);
977 else 1029 else
978 while (!this->dev_ready(mtd)); 1030 nand_wait_ready(mtd);
979 1031
980 /* All done, return happy */ 1032 /* All done, return happy */
981 if (!numpages) 1033 if (!numpages)
@@ -997,23 +1049,24 @@ out:
997#endif 1049#endif
998 1050
999/** 1051/**
1000 * nand_read - [MTD Interface] MTD compability function for nand_read_ecc 1052 * nand_read - [MTD Interface] MTD compability function for nand_do_read_ecc
1001 * @mtd: MTD device structure 1053 * @mtd: MTD device structure
1002 * @from: offset to read from 1054 * @from: offset to read from
1003 * @len: number of bytes to read 1055 * @len: number of bytes to read
1004 * @retlen: pointer to variable to store the number of read bytes 1056 * @retlen: pointer to variable to store the number of read bytes
1005 * @buf: the databuffer to put data 1057 * @buf: the databuffer to put data
1006 * 1058 *
1007 * This function simply calls nand_read_ecc with oob buffer and oobsel = NULL 1059 * This function simply calls nand_do_read_ecc with oob buffer and oobsel = NULL
1008*/ 1060 * and flags = 0xff
1061 */
1009static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf) 1062static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf)
1010{ 1063{
1011 return nand_read_ecc (mtd, from, len, retlen, buf, NULL, NULL); 1064 return nand_do_read_ecc (mtd, from, len, retlen, buf, NULL, &mtd->oobinfo, 0xff);
1012} 1065}
1013 1066
1014 1067
1015/** 1068/**
1016 * nand_read_ecc - [MTD Interface] Read data with ECC 1069 * nand_read_ecc - [MTD Interface] MTD compability function for nand_do_read_ecc
1017 * @mtd: MTD device structure 1070 * @mtd: MTD device structure
1018 * @from: offset to read from 1071 * @from: offset to read from
1019 * @len: number of bytes to read 1072 * @len: number of bytes to read
@@ -1022,11 +1075,39 @@ static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * re
1022 * @oob_buf: filesystem supplied oob data buffer 1075 * @oob_buf: filesystem supplied oob data buffer
1023 * @oobsel: oob selection structure 1076 * @oobsel: oob selection structure
1024 * 1077 *
1025 * NAND read with ECC 1078 * This function simply calls nand_do_read_ecc with flags = 0xff
1026 */ 1079 */
1027static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, 1080static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1028 size_t * retlen, u_char * buf, u_char * oob_buf, struct nand_oobinfo *oobsel) 1081 size_t * retlen, u_char * buf, u_char * oob_buf, struct nand_oobinfo *oobsel)
1029{ 1082{
1083 /* use userspace supplied oobinfo, if zero */
1084 if (oobsel == NULL)
1085 oobsel = &mtd->oobinfo;
1086 return nand_do_read_ecc(mtd, from, len, retlen, buf, oob_buf, oobsel, 0xff);
1087}
1088
1089
1090/**
1091 * nand_do_read_ecc - [MTD Interface] Read data with ECC
1092 * @mtd: MTD device structure
1093 * @from: offset to read from
1094 * @len: number of bytes to read
1095 * @retlen: pointer to variable to store the number of read bytes
1096 * @buf: the databuffer to put data
1097 * @oob_buf: filesystem supplied oob data buffer (can be NULL)
1098 * @oobsel: oob selection structure
1099 * @flags: flag to indicate if nand_get_device/nand_release_device should be preformed
1100 * and how many corrected error bits are acceptable:
1101 * bits 0..7 - number of tolerable errors
1102 * bit 8 - 0 == do not get/release chip, 1 == get/release chip
1103 *
1104 * NAND read with ECC
1105 */
1106int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1107 size_t * retlen, u_char * buf, u_char * oob_buf,
1108 struct nand_oobinfo *oobsel, int flags)
1109{
1110
1030 int i, j, col, realpage, page, end, ecc, chipnr, sndcmd = 1; 1111 int i, j, col, realpage, page, end, ecc, chipnr, sndcmd = 1;
1031 int read = 0, oob = 0, ecc_status = 0, ecc_failed = 0; 1112 int read = 0, oob = 0, ecc_status = 0, ecc_failed = 0;
1032 struct nand_chip *this = mtd->priv; 1113 struct nand_chip *this = mtd->priv;
@@ -1051,12 +1132,9 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1051 } 1132 }
1052 1133
1053 /* Grab the lock and see if the device is available */ 1134 /* Grab the lock and see if the device is available */
1054 nand_get_device (this, mtd ,FL_READING); 1135 if (flags & NAND_GET_DEVICE)
1136 nand_get_device (this, mtd, FL_READING);
1055 1137
1056 /* use userspace supplied oobinfo, if zero */
1057 if (oobsel == NULL)
1058 oobsel = &mtd->oobinfo;
1059
1060 /* Autoplace of oob data ? Use the default placement scheme */ 1138 /* Autoplace of oob data ? Use the default placement scheme */
1061 if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) 1139 if (oobsel->useecc == MTD_NANDECC_AUTOPLACE)
1062 oobsel = this->autooob; 1140 oobsel = this->autooob;
@@ -1118,7 +1196,8 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1118 } 1196 }
1119 1197
1120 /* get oob area, if we have no oob buffer from fs-driver */ 1198 /* get oob area, if we have no oob buffer from fs-driver */
1121 if (!oob_buf || oobsel->useecc == MTD_NANDECC_AUTOPLACE) 1199 if (!oob_buf || oobsel->useecc == MTD_NANDECC_AUTOPLACE ||
1200 oobsel->useecc == MTD_NANDECC_AUTOPL_USR)
1122 oob_data = &this->data_buf[end]; 1201 oob_data = &this->data_buf[end];
1123 1202
1124 eccsteps = this->eccsteps; 1203 eccsteps = this->eccsteps;
@@ -1155,7 +1234,8 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1155 /* We calc error correction directly, it checks the hw 1234 /* We calc error correction directly, it checks the hw
1156 * generator for an error, reads back the syndrome and 1235 * generator for an error, reads back the syndrome and
1157 * does the error correction on the fly */ 1236 * does the error correction on the fly */
1158 if (this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]) == -1) { 1237 ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]);
1238 if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) {
1159 DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " 1239 DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: "
1160 "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr); 1240 "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr);
1161 ecc_failed++; 1241 ecc_failed++;
@@ -1194,7 +1274,7 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1194 p[i] = ecc_status; 1274 p[i] = ecc_status;
1195 } 1275 }
1196 1276
1197 if (ecc_status == -1) { 1277 if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) {
1198 DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page); 1278 DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page);
1199 ecc_failed++; 1279 ecc_failed++;
1200 } 1280 }
@@ -1206,14 +1286,14 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1206 /* without autoplace. Legacy mode used by YAFFS1 */ 1286 /* without autoplace. Legacy mode used by YAFFS1 */
1207 switch(oobsel->useecc) { 1287 switch(oobsel->useecc) {
1208 case MTD_NANDECC_AUTOPLACE: 1288 case MTD_NANDECC_AUTOPLACE:
1289 case MTD_NANDECC_AUTOPL_USR:
1209 /* Walk through the autoplace chunks */ 1290 /* Walk through the autoplace chunks */
1210 for (i = 0, j = 0; j < mtd->oobavail; i++) { 1291 for (i = 0; oobsel->oobfree[i][1]; i++) {
1211 int from = oobsel->oobfree[i][0]; 1292 int from = oobsel->oobfree[i][0];
1212 int num = oobsel->oobfree[i][1]; 1293 int num = oobsel->oobfree[i][1];
1213 memcpy(&oob_buf[oob], &oob_data[from], num); 1294 memcpy(&oob_buf[oob], &oob_data[from], num);
1214 j+= num; 1295 oob += num;
1215 } 1296 }
1216 oob += mtd->oobavail;
1217 break; 1297 break;
1218 case MTD_NANDECC_PLACE: 1298 case MTD_NANDECC_PLACE:
1219 /* YAFFS1 legacy mode */ 1299 /* YAFFS1 legacy mode */
@@ -1239,7 +1319,7 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1239 if (!this->dev_ready) 1319 if (!this->dev_ready)
1240 udelay (this->chip_delay); 1320 udelay (this->chip_delay);
1241 else 1321 else
1242 while (!this->dev_ready(mtd)); 1322 nand_wait_ready(mtd);
1243 1323
1244 if (read == len) 1324 if (read == len)
1245 break; 1325 break;
@@ -1264,7 +1344,8 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
1264 } 1344 }
1265 1345
1266 /* Deselect and wake up anyone waiting on the device */ 1346 /* Deselect and wake up anyone waiting on the device */
1267 nand_release_device(mtd); 1347 if (flags & NAND_GET_DEVICE)
1348 nand_release_device(mtd);
1268 1349
1269 /* 1350 /*
1270 * Return success, if no ECC failures, else -EBADMSG 1351 * Return success, if no ECC failures, else -EBADMSG
@@ -1337,7 +1418,7 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t
1337 if (!this->dev_ready) 1418 if (!this->dev_ready)
1338 udelay (this->chip_delay); 1419 udelay (this->chip_delay);
1339 else 1420 else
1340 while (!this->dev_ready(mtd)); 1421 nand_wait_ready(mtd);
1341 1422
1342 /* Read more ? */ 1423 /* Read more ? */
1343 if (i < len) { 1424 if (i < len) {
@@ -1417,7 +1498,7 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len,
1417 if (!this->dev_ready) 1498 if (!this->dev_ready)
1418 udelay (this->chip_delay); 1499 udelay (this->chip_delay);
1419 else 1500 else
1420 while (!this->dev_ready(mtd)); 1501 nand_wait_ready(mtd);
1421 1502
1422 /* Check, if the chip supports auto page increment */ 1503 /* Check, if the chip supports auto page increment */
1423 if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) 1504 if (!NAND_CANAUTOINCR(this) || !(page & blockcheck))
@@ -1567,6 +1648,8 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
1567 oobsel = this->autooob; 1648 oobsel = this->autooob;
1568 autoplace = 1; 1649 autoplace = 1;
1569 } 1650 }
1651 if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR)
1652 autoplace = 1;
1570 1653
1571 /* Setup variables and oob buffer */ 1654 /* Setup variables and oob buffer */
1572 totalpages = len >> this->page_shift; 1655 totalpages = len >> this->page_shift;
@@ -1733,7 +1816,7 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t *
1733 status = this->waitfunc (mtd, this, FL_WRITING); 1816 status = this->waitfunc (mtd, this, FL_WRITING);
1734 1817
1735 /* See if device thinks it succeeded */ 1818 /* See if device thinks it succeeded */
1736 if (status & 0x01) { 1819 if (status & NAND_STATUS_FAIL) {
1737 DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page); 1820 DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page);
1738 ret = -EIO; 1821 ret = -EIO;
1739 goto out; 1822 goto out;
@@ -1841,6 +1924,8 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
1841 oobsel = this->autooob; 1924 oobsel = this->autooob;
1842 autoplace = 1; 1925 autoplace = 1;
1843 } 1926 }
1927 if (oobsel->useecc == MTD_NANDECC_AUTOPL_USR)
1928 autoplace = 1;
1844 1929
1845 /* Setup start page */ 1930 /* Setup start page */
1846 page = (int) (to >> this->page_shift); 1931 page = (int) (to >> this->page_shift);
@@ -1987,6 +2072,7 @@ static int nand_erase (struct mtd_info *mtd, struct erase_info *instr)
1987 return nand_erase_nand (mtd, instr, 0); 2072 return nand_erase_nand (mtd, instr, 0);
1988} 2073}
1989 2074
2075#define BBT_PAGE_MASK 0xffffff3f
1990/** 2076/**
1991 * nand_erase_intern - [NAND Interface] erase block(s) 2077 * nand_erase_intern - [NAND Interface] erase block(s)
1992 * @mtd: MTD device structure 2078 * @mtd: MTD device structure
@@ -1999,6 +2085,10 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
1999{ 2085{
2000 int page, len, status, pages_per_block, ret, chipnr; 2086 int page, len, status, pages_per_block, ret, chipnr;
2001 struct nand_chip *this = mtd->priv; 2087 struct nand_chip *this = mtd->priv;
2088 int rewrite_bbt[NAND_MAX_CHIPS]={0}; /* flags to indicate the page, if bbt needs to be rewritten. */
2089 unsigned int bbt_masked_page; /* bbt mask to compare to page being erased. */
2090 /* It is used to see if the current page is in the same */
2091 /* 256 block group and the same bank as the bbt. */
2002 2092
2003 DEBUG (MTD_DEBUG_LEVEL3, 2093 DEBUG (MTD_DEBUG_LEVEL3,
2004 "nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len); 2094 "nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len);
@@ -2044,6 +2134,13 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
2044 goto erase_exit; 2134 goto erase_exit;
2045 } 2135 }
2046 2136
2137 /* if BBT requires refresh, set the BBT page mask to see if the BBT should be rewritten */
2138 if (this->options & BBT_AUTO_REFRESH) {
2139 bbt_masked_page = this->bbt_td->pages[chipnr] & BBT_PAGE_MASK;
2140 } else {
2141 bbt_masked_page = 0xffffffff; /* should not match anything */
2142 }
2143
2047 /* Loop through the pages */ 2144 /* Loop through the pages */
2048 len = instr->len; 2145 len = instr->len;
2049 2146
@@ -2066,13 +2163,26 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
2066 2163
2067 status = this->waitfunc (mtd, this, FL_ERASING); 2164 status = this->waitfunc (mtd, this, FL_ERASING);
2068 2165
2166 /* See if operation failed and additional status checks are available */
2167 if ((status & NAND_STATUS_FAIL) && (this->errstat)) {
2168 status = this->errstat(mtd, this, FL_ERASING, status, page);
2169 }
2170
2069 /* See if block erase succeeded */ 2171 /* See if block erase succeeded */
2070 if (status & 0x01) { 2172 if (status & NAND_STATUS_FAIL) {
2071 DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page); 2173 DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page);
2072 instr->state = MTD_ERASE_FAILED; 2174 instr->state = MTD_ERASE_FAILED;
2073 instr->fail_addr = (page << this->page_shift); 2175 instr->fail_addr = (page << this->page_shift);
2074 goto erase_exit; 2176 goto erase_exit;
2075 } 2177 }
2178
2179 /* if BBT requires refresh, set the BBT rewrite flag to the page being erased */
2180 if (this->options & BBT_AUTO_REFRESH) {
2181 if (((page & BBT_PAGE_MASK) == bbt_masked_page) &&
2182 (page != this->bbt_td->pages[chipnr])) {
2183 rewrite_bbt[chipnr] = (page << this->page_shift);
2184 }
2185 }
2076 2186
2077 /* Increment page address and decrement length */ 2187 /* Increment page address and decrement length */
2078 len -= (1 << this->phys_erase_shift); 2188 len -= (1 << this->phys_erase_shift);
@@ -2083,6 +2193,13 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
2083 chipnr++; 2193 chipnr++;
2084 this->select_chip(mtd, -1); 2194 this->select_chip(mtd, -1);
2085 this->select_chip(mtd, chipnr); 2195 this->select_chip(mtd, chipnr);
2196
2197 /* if BBT requires refresh and BBT-PERCHIP,
2198 * set the BBT page mask to see if this BBT should be rewritten */
2199 if ((this->options & BBT_AUTO_REFRESH) && (this->bbt_td->options & NAND_BBT_PERCHIP)) {
2200 bbt_masked_page = this->bbt_td->pages[chipnr] & BBT_PAGE_MASK;
2201 }
2202
2086 } 2203 }
2087 } 2204 }
2088 instr->state = MTD_ERASE_DONE; 2205 instr->state = MTD_ERASE_DONE;
@@ -2097,6 +2214,18 @@ erase_exit:
2097 /* Deselect and wake up anyone waiting on the device */ 2214 /* Deselect and wake up anyone waiting on the device */
2098 nand_release_device(mtd); 2215 nand_release_device(mtd);
2099 2216
2217 /* if BBT requires refresh and erase was successful, rewrite any selected bad block tables */
2218 if ((this->options & BBT_AUTO_REFRESH) && (!ret)) {
2219 for (chipnr = 0; chipnr < this->numchips; chipnr++) {
2220 if (rewrite_bbt[chipnr]) {
2221 /* update the BBT for chip */
2222 DEBUG (MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt (%d:0x%0x 0x%0x)\n",
2223 chipnr, rewrite_bbt[chipnr], this->bbt_td->pages[chipnr]);
2224 nand_update_bbt (mtd, rewrite_bbt[chipnr]);
2225 }
2226 }
2227 }
2228
2100 /* Return more or less happy */ 2229 /* Return more or less happy */
2101 return ret; 2230 return ret;
2102} 2231}
@@ -2168,7 +2297,7 @@ static int nand_block_markbad (struct mtd_info *mtd, loff_t ofs)
2168 */ 2297 */
2169int nand_scan (struct mtd_info *mtd, int maxchips) 2298int nand_scan (struct mtd_info *mtd, int maxchips)
2170{ 2299{
2171 int i, j, nand_maf_id, nand_dev_id, busw; 2300 int i, nand_maf_id, nand_dev_id, busw, maf_id;
2172 struct nand_chip *this = mtd->priv; 2301 struct nand_chip *this = mtd->priv;
2173 2302
2174 /* Get buswidth to select the correct functions*/ 2303 /* Get buswidth to select the correct functions*/
@@ -2256,12 +2385,18 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2256 busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16; 2385 busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16;
2257 } 2386 }
2258 2387
2388 /* Try to identify manufacturer */
2389 for (maf_id = 0; nand_manuf_ids[maf_id].id != 0x0; maf_id++) {
2390 if (nand_manuf_ids[maf_id].id == nand_maf_id)
2391 break;
2392 }
2393
2259 /* Check, if buswidth is correct. Hardware drivers should set 2394 /* Check, if buswidth is correct. Hardware drivers should set
2260 * this correct ! */ 2395 * this correct ! */
2261 if (busw != (this->options & NAND_BUSWIDTH_16)) { 2396 if (busw != (this->options & NAND_BUSWIDTH_16)) {
2262 printk (KERN_INFO "NAND device: Manufacturer ID:" 2397 printk (KERN_INFO "NAND device: Manufacturer ID:"
2263 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, 2398 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id,
2264 nand_manuf_ids[i].name , mtd->name); 2399 nand_manuf_ids[maf_id].name , mtd->name);
2265 printk (KERN_WARNING 2400 printk (KERN_WARNING
2266 "NAND bus width %d instead %d bit\n", 2401 "NAND bus width %d instead %d bit\n",
2267 (this->options & NAND_BUSWIDTH_16) ? 16 : 8, 2402 (this->options & NAND_BUSWIDTH_16) ? 16 : 8,
@@ -2300,14 +2435,9 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2300 if (mtd->oobblock > 512 && this->cmdfunc == nand_command) 2435 if (mtd->oobblock > 512 && this->cmdfunc == nand_command)
2301 this->cmdfunc = nand_command_lp; 2436 this->cmdfunc = nand_command_lp;
2302 2437
2303 /* Try to identify manufacturer */
2304 for (j = 0; nand_manuf_ids[j].id != 0x0; j++) {
2305 if (nand_manuf_ids[j].id == nand_maf_id)
2306 break;
2307 }
2308 printk (KERN_INFO "NAND device: Manufacturer ID:" 2438 printk (KERN_INFO "NAND device: Manufacturer ID:"
2309 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, 2439 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id,
2310 nand_manuf_ids[j].name , nand_flash_ids[i].name); 2440 nand_manuf_ids[maf_id].name , nand_flash_ids[i].name);
2311 break; 2441 break;
2312 } 2442 }
2313 2443
@@ -2388,12 +2518,9 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2388 2518
2389 /* The number of bytes available for the filesystem to place fs dependend 2519 /* The number of bytes available for the filesystem to place fs dependend
2390 * oob data */ 2520 * oob data */
2391 if (this->options & NAND_BUSWIDTH_16) { 2521 mtd->oobavail = 0;
2392 mtd->oobavail = mtd->oobsize - (this->autooob->eccbytes + 2); 2522 for (i = 0; this->autooob->oobfree[i][1]; i++)
2393 if (this->autooob->eccbytes & 0x01) 2523 mtd->oobavail += this->autooob->oobfree[i][1];
2394 mtd->oobavail--;
2395 } else
2396 mtd->oobavail = mtd->oobsize - (this->autooob->eccbytes + 1);
2397 2524
2398 /* 2525 /*
2399 * check ECC mode, default to software 2526 * check ECC mode, default to software
@@ -2524,6 +2651,10 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
2524 memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo)); 2651 memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo));
2525 2652
2526 mtd->owner = THIS_MODULE; 2653 mtd->owner = THIS_MODULE;
2654
2655 /* Check, if we should skip the bad block table scan */
2656 if (this->options & NAND_SKIP_BBTSCAN)
2657 return 0;
2527 2658
2528 /* Build bad block table */ 2659 /* Build bad block table */
2529 return this->scan_bbt (mtd); 2660 return this->scan_bbt (mtd);
@@ -2555,8 +2686,8 @@ void nand_release (struct mtd_info *mtd)
2555 kfree (this->data_buf); 2686 kfree (this->data_buf);
2556} 2687}
2557 2688
2558EXPORT_SYMBOL (nand_scan); 2689EXPORT_SYMBOL_GPL (nand_scan);
2559EXPORT_SYMBOL (nand_release); 2690EXPORT_SYMBOL_GPL (nand_release);
2560 2691
2561MODULE_LICENSE ("GPL"); 2692MODULE_LICENSE ("GPL");
2562MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>"); 2693MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>");
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 9a1949751c1f..5ac2d2962220 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -6,7 +6,7 @@
6 * 6 *
7 * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de) 7 * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
8 * 8 *
9 * $Id: nand_bbt.c,v 1.28 2004/11/13 10:19:09 gleixner Exp $ 9 * $Id: nand_bbt.c,v 1.33 2005/06/14 15:47:56 gleixner Exp $
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -77,7 +77,7 @@
77*/ 77*/
78static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td) 78static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
79{ 79{
80 int i, end; 80 int i, end = 0;
81 uint8_t *p = buf; 81 uint8_t *p = buf;
82 82
83 end = paglen + td->offs; 83 end = paglen + td->offs;
@@ -95,9 +95,9 @@ static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_des
95 return -1; 95 return -1;
96 } 96 }
97 97
98 p += td->len;
99 end += td->len;
100 if (td->options & NAND_BBT_SCANEMPTY) { 98 if (td->options & NAND_BBT_SCANEMPTY) {
99 p += td->len;
100 end += td->len;
101 for (i = end; i < len; i++) { 101 for (i = end; i < len; i++) {
102 if (*p++ != 0xff) 102 if (*p++ != 0xff)
103 return -1; 103 return -1;
@@ -106,6 +106,32 @@ static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_des
106 return 0; 106 return 0;
107} 107}
108 108
109/**
110 * check_short_pattern - [GENERIC] check if a pattern is in the buffer
111 * @buf: the buffer to search
112 * @len: the length of buffer to search
113 * @paglen: the pagelength
114 * @td: search pattern descriptor
115 *
116 * Check for a pattern at the given place. Used to search bad block
117 * tables and good / bad block identifiers. Same as check_pattern, but
118 * no optional empty check and the pattern is expected to start
119 * at offset 0.
120 *
121*/
122static int check_short_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
123{
124 int i;
125 uint8_t *p = buf;
126
127 /* Compare the pattern */
128 for (i = 0; i < td->len; i++) {
129 if (p[i] != td->pattern[i])
130 return -1;
131 }
132 return 0;
133}
134
109/** 135/**
110 * read_bbt - [GENERIC] Read the bad block table starting from page 136 * read_bbt - [GENERIC] Read the bad block table starting from page
111 * @mtd: MTD device structure 137 * @mtd: MTD device structure
@@ -252,7 +278,7 @@ static int read_abs_bbts (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_de
252 * Create a bad block table by scanning the device 278 * Create a bad block table by scanning the device
253 * for the given good/bad block identify pattern 279 * for the given good/bad block identify pattern
254 */ 280 */
255static void create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip) 281static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip)
256{ 282{
257 struct nand_chip *this = mtd->priv; 283 struct nand_chip *this = mtd->priv;
258 int i, j, numblocks, len, scanlen; 284 int i, j, numblocks, len, scanlen;
@@ -270,9 +296,17 @@ static void create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
270 else 296 else
271 len = 1; 297 len = 1;
272 } 298 }
273 scanlen = mtd->oobblock + mtd->oobsize; 299
274 readlen = len * mtd->oobblock; 300 if (!(bd->options & NAND_BBT_SCANEMPTY)) {
275 ooblen = len * mtd->oobsize; 301 /* We need only read few bytes from the OOB area */
302 scanlen = ooblen = 0;
303 readlen = bd->len;
304 } else {
305 /* Full page content should be read */
306 scanlen = mtd->oobblock + mtd->oobsize;
307 readlen = len * mtd->oobblock;
308 ooblen = len * mtd->oobsize;
309 }
276 310
277 if (chip == -1) { 311 if (chip == -1) {
278 /* Note that numblocks is 2 * (real numblocks) here, see i+=2 below as it 312 /* Note that numblocks is 2 * (real numblocks) here, see i+=2 below as it
@@ -284,7 +318,7 @@ static void create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
284 if (chip >= this->numchips) { 318 if (chip >= this->numchips) {
285 printk (KERN_WARNING "create_bbt(): chipnr (%d) > available chips (%d)\n", 319 printk (KERN_WARNING "create_bbt(): chipnr (%d) > available chips (%d)\n",
286 chip + 1, this->numchips); 320 chip + 1, this->numchips);
287 return; 321 return -EINVAL;
288 } 322 }
289 numblocks = this->chipsize >> (this->bbt_erase_shift - 1); 323 numblocks = this->chipsize >> (this->bbt_erase_shift - 1);
290 startblock = chip * numblocks; 324 startblock = chip * numblocks;
@@ -293,18 +327,41 @@ static void create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
293 } 327 }
294 328
295 for (i = startblock; i < numblocks;) { 329 for (i = startblock; i < numblocks;) {
296 nand_read_raw (mtd, buf, from, readlen, ooblen); 330 int ret;
331
332 if (bd->options & NAND_BBT_SCANEMPTY)
333 if ((ret = nand_read_raw (mtd, buf, from, readlen, ooblen)))
334 return ret;
335
297 for (j = 0; j < len; j++) { 336 for (j = 0; j < len; j++) {
298 if (check_pattern (&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { 337 if (!(bd->options & NAND_BBT_SCANEMPTY)) {
299 this->bbt[i >> 3] |= 0x03 << (i & 0x6); 338 size_t retlen;
300 printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 339
301 i >> 1, (unsigned int) from); 340 /* No need to read pages fully, just read required OOB bytes */
302 break; 341 ret = mtd->read_oob(mtd, from + j * mtd->oobblock + bd->offs,
342 readlen, &retlen, &buf[0]);
343 if (ret)
344 return ret;
345
346 if (check_short_pattern (&buf[j * scanlen], scanlen, mtd->oobblock, bd)) {
347 this->bbt[i >> 3] |= 0x03 << (i & 0x6);
348 printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
349 i >> 1, (unsigned int) from);
350 break;
351 }
352 } else {
353 if (check_pattern (&buf[j * scanlen], scanlen, mtd->oobblock, bd)) {
354 this->bbt[i >> 3] |= 0x03 << (i & 0x6);
355 printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
356 i >> 1, (unsigned int) from);
357 break;
358 }
303 } 359 }
304 } 360 }
305 i += 2; 361 i += 2;
306 from += (1 << this->bbt_erase_shift); 362 from += (1 << this->bbt_erase_shift);
307 } 363 }
364 return 0;
308} 365}
309 366
310/** 367/**
@@ -589,14 +646,12 @@ write:
589 * The function creates a memory based bbt by scanning the device 646 * The function creates a memory based bbt by scanning the device
590 * for manufacturer / software marked good / bad blocks 647 * for manufacturer / software marked good / bad blocks
591*/ 648*/
592static int nand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) 649static inline int nand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
593{ 650{
594 struct nand_chip *this = mtd->priv; 651 struct nand_chip *this = mtd->priv;
595 652
596 /* Ensure that we only scan for the pattern and nothing else */ 653 bd->options &= ~NAND_BBT_SCANEMPTY;
597 bd->options = 0; 654 return create_bbt (mtd, this->data_buf, bd, -1);
598 create_bbt (mtd, this->data_buf, bd, -1);
599 return 0;
600} 655}
601 656
602/** 657/**
@@ -808,8 +863,14 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
808 /* If no primary table decriptor is given, scan the device 863 /* If no primary table decriptor is given, scan the device
809 * to build a memory based bad block table 864 * to build a memory based bad block table
810 */ 865 */
811 if (!td) 866 if (!td) {
812 return nand_memory_bbt(mtd, bd); 867 if ((res = nand_memory_bbt(mtd, bd))) {
868 printk (KERN_ERR "nand_bbt: Can't scan flash and build the RAM-based BBT\n");
869 kfree (this->bbt);
870 this->bbt = NULL;
871 }
872 return res;
873 }
813 874
814 /* Allocate a temporary buffer for one eraseblock incl. oob */ 875 /* Allocate a temporary buffer for one eraseblock incl. oob */
815 len = (1 << this->bbt_erase_shift); 876 len = (1 << this->bbt_erase_shift);
@@ -904,14 +965,11 @@ out:
904} 965}
905 966
906/* Define some generic bad / good block scan pattern which are used 967/* Define some generic bad / good block scan pattern which are used
907 * while scanning a device for factory marked good / bad blocks 968 * while scanning a device for factory marked good / bad blocks. */
908 *
909 * The memory based patterns just
910 */
911static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; 969static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
912 970
913static struct nand_bbt_descr smallpage_memorybased = { 971static struct nand_bbt_descr smallpage_memorybased = {
914 .options = 0, 972 .options = NAND_BBT_SCAN2NDPAGE,
915 .offs = 5, 973 .offs = 5,
916 .len = 1, 974 .len = 1,
917 .pattern = scan_ff_pattern 975 .pattern = scan_ff_pattern
@@ -1042,7 +1100,7 @@ int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt)
1042 res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03; 1100 res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03;
1043 1101
1044 DEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n", 1102 DEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n",
1045 (unsigned int)offs, res, block >> 1); 1103 (unsigned int)offs, block >> 1, res);
1046 1104
1047 switch ((int)res) { 1105 switch ((int)res) {
1048 case 0x00: return 0; 1106 case 0x00: return 0;
diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c
index 2d8c4321275b..efe246961b69 100644
--- a/drivers/mtd/nand/nand_ids.c
+++ b/drivers/mtd/nand/nand_ids.c
@@ -2,8 +2,8 @@
2 * drivers/mtd/nandids.c 2 * drivers/mtd/nandids.c
3 * 3 *
4 * Copyright (C) 2002 Thomas Gleixner (tglx@linutronix.de) 4 * Copyright (C) 2002 Thomas Gleixner (tglx@linutronix.de)
5 * 5 *
6 * $Id: nand_ids.c,v 1.10 2004/05/26 13:40:12 gleixner Exp $ 6 * $Id: nand_ids.c,v 1.14 2005/06/23 09:38:50 gleixner Exp $
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
@@ -56,17 +56,24 @@ struct nand_flash_dev nand_flash_ids[] = {
56 {"NAND 64MiB 3,3V 16-bit", 0x56, 512, 64, 0x4000, NAND_BUSWIDTH_16}, 56 {"NAND 64MiB 3,3V 16-bit", 0x56, 512, 64, 0x4000, NAND_BUSWIDTH_16},
57 57
58 {"NAND 128MiB 1,8V 8-bit", 0x78, 512, 128, 0x4000, 0}, 58 {"NAND 128MiB 1,8V 8-bit", 0x78, 512, 128, 0x4000, 0},
59 {"NAND 128MiB 1,8V 8-bit", 0x39, 512, 128, 0x4000, 0},
59 {"NAND 128MiB 3,3V 8-bit", 0x79, 512, 128, 0x4000, 0}, 60 {"NAND 128MiB 3,3V 8-bit", 0x79, 512, 128, 0x4000, 0},
60 {"NAND 128MiB 1,8V 16-bit", 0x72, 512, 128, 0x4000, NAND_BUSWIDTH_16}, 61 {"NAND 128MiB 1,8V 16-bit", 0x72, 512, 128, 0x4000, NAND_BUSWIDTH_16},
62 {"NAND 128MiB 1,8V 16-bit", 0x49, 512, 128, 0x4000, NAND_BUSWIDTH_16},
61 {"NAND 128MiB 3,3V 16-bit", 0x74, 512, 128, 0x4000, NAND_BUSWIDTH_16}, 63 {"NAND 128MiB 3,3V 16-bit", 0x74, 512, 128, 0x4000, NAND_BUSWIDTH_16},
64 {"NAND 128MiB 3,3V 16-bit", 0x59, 512, 128, 0x4000, NAND_BUSWIDTH_16},
62 65
63 {"NAND 256MiB 3,3V 8-bit", 0x71, 512, 256, 0x4000, 0}, 66 {"NAND 256MiB 3,3V 8-bit", 0x71, 512, 256, 0x4000, 0},
64 67
65 {"NAND 512MiB 3,3V 8-bit", 0xDC, 512, 512, 0x4000, 0},
66
67 /* These are the new chips with large page size. The pagesize 68 /* These are the new chips with large page size. The pagesize
68 * and the erasesize is determined from the extended id bytes 69 * and the erasesize is determined from the extended id bytes
69 */ 70 */
71 /*512 Megabit */
72 {"NAND 64MiB 1,8V 8-bit", 0xA2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
73 {"NAND 64MiB 3,3V 8-bit", 0xF2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
74 {"NAND 64MiB 1,8V 16-bit", 0xB2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
75 {"NAND 64MiB 3,3V 16-bit", 0xC2, 0, 64, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR},
76
70 /* 1 Gigabit */ 77 /* 1 Gigabit */
71 {"NAND 128MiB 1,8V 8-bit", 0xA1, 0, 128, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 78 {"NAND 128MiB 1,8V 8-bit", 0xA1, 0, 128, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
72 {"NAND 128MiB 3,3V 8-bit", 0xF1, 0, 128, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR}, 79 {"NAND 128MiB 3,3V 8-bit", 0xF1, 0, 128, 0, NAND_SAMSUNG_LP_OPTIONS | NAND_NO_AUTOINCR},
@@ -103,7 +110,7 @@ struct nand_flash_dev nand_flash_ids[] = {
103 * Anyway JFFS2 would increase the eraseblock size so we chose a combined one which can be erased in one go 110 * Anyway JFFS2 would increase the eraseblock size so we chose a combined one which can be erased in one go
104 * There are more speed improvements for reads and writes possible, but not implemented now 111 * There are more speed improvements for reads and writes possible, but not implemented now
105 */ 112 */
106 {"AND 128MiB 3,3V 8-bit", 0x01, 2048, 128, 0x4000, NAND_IS_AND | NAND_NO_AUTOINCR | NAND_4PAGE_ARRAY}, 113 {"AND 128MiB 3,3V 8-bit", 0x01, 2048, 128, 0x4000, NAND_IS_AND | NAND_NO_AUTOINCR | NAND_4PAGE_ARRAY | BBT_AUTO_REFRESH},
107 114
108 {NULL,} 115 {NULL,}
109}; 116};
@@ -118,6 +125,7 @@ struct nand_manufacturers nand_manuf_ids[] = {
118 {NAND_MFR_NATIONAL, "National"}, 125 {NAND_MFR_NATIONAL, "National"},
119 {NAND_MFR_RENESAS, "Renesas"}, 126 {NAND_MFR_RENESAS, "Renesas"},
120 {NAND_MFR_STMICRO, "ST Micro"}, 127 {NAND_MFR_STMICRO, "ST Micro"},
128 {NAND_MFR_HYNIX, "Hynix"},
121 {0x0, "Unknown"} 129 {0x0, "Unknown"}
122}; 130};
123 131
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 13feefd7d8ca..754b6ed7ce14 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -22,7 +22,7 @@
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
24 * 24 *
25 * $Id: nandsim.c,v 1.7 2004/12/06 11:53:06 dedekind Exp $ 25 * $Id: nandsim.c,v 1.8 2005/03/19 15:33:56 dedekind Exp $
26 */ 26 */
27 27
28#include <linux/config.h> 28#include <linux/config.h>
@@ -1484,33 +1484,6 @@ ns_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
1484} 1484}
1485 1485
1486/* 1486/*
1487 * Having only NAND chip IDs we call nand_scan which detects NAND flash
1488 * parameters and then calls scan_bbt in order to scan/find/build the
1489 * NAND flash bad block table. But since at that moment the NAND flash
1490 * image isn't allocated in the simulator, errors arise. To avoid this
1491 * we redefine the scan_bbt callback and initialize the nandsim structure
1492 * before the flash media scanning.
1493 */
1494int ns_scan_bbt(struct mtd_info *mtd)
1495{
1496 struct nand_chip *chip = (struct nand_chip *)mtd->priv;
1497 struct nandsim *ns = (struct nandsim *)(chip->priv);
1498 int retval;
1499
1500 if (!NS_IS_INITIALIZED(ns))
1501 if ((retval = init_nandsim(mtd)) != 0) {
1502 NS_ERR("scan_bbt: can't initialize the nandsim structure\n");
1503 return retval;
1504 }
1505 if ((retval = nand_default_bbt(mtd)) != 0) {
1506 free_nandsim(ns);
1507 return retval;
1508 }
1509
1510 return 0;
1511}
1512
1513/*
1514 * Module initialization function 1487 * Module initialization function
1515 */ 1488 */
1516int __init ns_init_module(void) 1489int __init ns_init_module(void)
@@ -1544,7 +1517,6 @@ int __init ns_init_module(void)
1544 chip->hwcontrol = ns_hwcontrol; 1517 chip->hwcontrol = ns_hwcontrol;
1545 chip->read_byte = ns_nand_read_byte; 1518 chip->read_byte = ns_nand_read_byte;
1546 chip->dev_ready = ns_device_ready; 1519 chip->dev_ready = ns_device_ready;
1547 chip->scan_bbt = ns_scan_bbt;
1548 chip->write_byte = ns_nand_write_byte; 1520 chip->write_byte = ns_nand_write_byte;
1549 chip->write_buf = ns_nand_write_buf; 1521 chip->write_buf = ns_nand_write_buf;
1550 chip->read_buf = ns_nand_read_buf; 1522 chip->read_buf = ns_nand_read_buf;
@@ -1552,6 +1524,7 @@ int __init ns_init_module(void)
1552 chip->write_word = ns_nand_write_word; 1524 chip->write_word = ns_nand_write_word;
1553 chip->read_word = ns_nand_read_word; 1525 chip->read_word = ns_nand_read_word;
1554 chip->eccmode = NAND_ECC_SOFT; 1526 chip->eccmode = NAND_ECC_SOFT;
1527 chip->options |= NAND_SKIP_BBTSCAN;
1555 1528
1556 /* 1529 /*
1557 * Perform minimum nandsim structure initialization to handle 1530 * Perform minimum nandsim structure initialization to handle
@@ -1580,6 +1553,16 @@ int __init ns_init_module(void)
1580 goto error; 1553 goto error;
1581 } 1554 }
1582 1555
1556 if ((retval = init_nandsim(nsmtd)) != 0) {
1557 NS_ERR("scan_bbt: can't initialize the nandsim structure\n");
1558 goto error;
1559 }
1560
1561 if ((retval = nand_default_bbt(nsmtd)) != 0) {
1562 free_nandsim(nand);
1563 goto error;
1564 }
1565
1583 /* Register NAND as one big partition */ 1566 /* Register NAND as one big partition */
1584 add_mtd_partitions(nsmtd, &nand->part, 1); 1567 add_mtd_partitions(nsmtd, &nand->part, 1);
1585 1568
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
index 02305a2adca7..031051cbde76 100644
--- a/drivers/mtd/nand/rtc_from4.c
+++ b/drivers/mtd/nand/rtc_from4.c
@@ -6,7 +6,7 @@
6 * Derived from drivers/mtd/nand/spia.c 6 * Derived from drivers/mtd/nand/spia.c
7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) 7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
8 * 8 *
9 * $Id: rtc_from4.c,v 1.7 2004/11/04 12:53:10 gleixner Exp $ 9 * $Id: rtc_from4.c,v 1.9 2005/01/24 20:40:11 dmarlin Exp $
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -83,13 +83,18 @@ static struct mtd_info *rtc_from4_mtd = NULL;
83#define RTC_FROM4_RS_ECC_CHK (RTC_FROM4_NAND_ADDR_FPGA | 0x00000070) 83#define RTC_FROM4_RS_ECC_CHK (RTC_FROM4_NAND_ADDR_FPGA | 0x00000070)
84#define RTC_FROM4_RS_ECC_CHK_ERROR (1 << 7) 84#define RTC_FROM4_RS_ECC_CHK_ERROR (1 << 7)
85 85
86#define ERR_STAT_ECC_AVAILABLE 0x20
87
86/* Undefine for software ECC */ 88/* Undefine for software ECC */
87#define RTC_FROM4_HWECC 1 89#define RTC_FROM4_HWECC 1
88 90
91/* Define as 1 for no virtual erase blocks (in JFFS2) */
92#define RTC_FROM4_NO_VIRTBLOCKS 0
93
89/* 94/*
90 * Module stuff 95 * Module stuff
91 */ 96 */
92static void __iomem *rtc_from4_fio_base = P2SEGADDR(RTC_FROM4_FIO_BASE); 97static void __iomem *rtc_from4_fio_base = (void *)P2SEGADDR(RTC_FROM4_FIO_BASE);
93 98
94const static struct mtd_partition partition_info[] = { 99const static struct mtd_partition partition_info[] = {
95 { 100 {
@@ -267,7 +272,6 @@ static void rtc_from4_nand_select_chip(struct mtd_info *mtd, int chip)
267} 272}
268 273
269 274
270
271/* 275/*
272 * rtc_from4_nand_device_ready - hardware specific ready/busy check 276 * rtc_from4_nand_device_ready - hardware specific ready/busy check
273 * @mtd: MTD device structure 277 * @mtd: MTD device structure
@@ -286,6 +290,40 @@ static int rtc_from4_nand_device_ready(struct mtd_info *mtd)
286 290
287} 291}
288 292
293
294/*
295 * deplete - code to perform device recovery in case there was a power loss
296 * @mtd: MTD device structure
297 * @chip: Chip to select (0 == slot 3, 1 == slot 4)
298 *
299 * If there was a sudden loss of power during an erase operation, a
300 * "device recovery" operation must be performed when power is restored
301 * to ensure correct operation. This routine performs the required steps
302 * for the requested chip.
303 *
304 * See page 86 of the data sheet for details.
305 *
306 */
307static void deplete(struct mtd_info *mtd, int chip)
308{
309 struct nand_chip *this = mtd->priv;
310
311 /* wait until device is ready */
312 while (!this->dev_ready(mtd));
313
314 this->select_chip(mtd, chip);
315
316 /* Send the commands for device recovery, phase 1 */
317 this->cmdfunc (mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0000);
318 this->cmdfunc (mtd, NAND_CMD_DEPLETE2, -1, -1);
319
320 /* Send the commands for device recovery, phase 2 */
321 this->cmdfunc (mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0004);
322 this->cmdfunc (mtd, NAND_CMD_DEPLETE2, -1, -1);
323
324}
325
326
289#ifdef RTC_FROM4_HWECC 327#ifdef RTC_FROM4_HWECC
290/* 328/*
291 * rtc_from4_enable_hwecc - hardware specific hardware ECC enable function 329 * rtc_from4_enable_hwecc - hardware specific hardware ECC enable function
@@ -329,6 +367,7 @@ static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode)
329 367
330} 368}
331 369
370
332/* 371/*
333 * rtc_from4_calculate_ecc - hardware specific code to read ECC code 372 * rtc_from4_calculate_ecc - hardware specific code to read ECC code
334 * @mtd: MTD device structure 373 * @mtd: MTD device structure
@@ -356,6 +395,7 @@ static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_c
356 ecc_code[7] |= 0x0f; /* set the last four bits (not used) */ 395 ecc_code[7] |= 0x0f; /* set the last four bits (not used) */
357} 396}
358 397
398
359/* 399/*
360 * rtc_from4_correct_data - hardware specific code to correct data using ECC code 400 * rtc_from4_correct_data - hardware specific code to correct data using ECC code
361 * @mtd: MTD device structure 401 * @mtd: MTD device structure
@@ -365,16 +405,14 @@ static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_c
365 * 405 *
366 * The FPGA tells us fast, if there's an error or not. If no, we go back happy 406 * The FPGA tells us fast, if there's an error or not. If no, we go back happy
367 * else we read the ecc results from the fpga and call the rs library to decode 407 * else we read the ecc results from the fpga and call the rs library to decode
368 * and hopefully correct the error 408 * and hopefully correct the error.
369 * 409 *
370 * For now I use the code, which we read from the FLASH to use the RS lib,
371 * as the syndrom conversion has a unresolved issue.
372 */ 410 */
373static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_char *ecc1, u_char *ecc2) 411static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_char *ecc1, u_char *ecc2)
374{ 412{
375 int i, j, res; 413 int i, j, res;
376 unsigned short status; 414 unsigned short status;
377 uint16_t par[6], syn[6], tmp; 415 uint16_t par[6], syn[6];
378 uint8_t ecc[8]; 416 uint8_t ecc[8];
379 volatile unsigned short *rs_ecc; 417 volatile unsigned short *rs_ecc;
380 418
@@ -416,15 +454,86 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha
416 } 454 }
417 455
418 /* Let the library code do its magic.*/ 456 /* Let the library code do its magic.*/
419 res = decode_rs8(rs_decoder, buf, par, 512, syn, 0, NULL, 0xff, NULL); 457 res = decode_rs8(rs_decoder, (uint8_t *)buf, par, 512, syn, 0, NULL, 0xff, NULL);
420 if (res > 0) { 458 if (res > 0) {
421 DEBUG (MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: " 459 DEBUG (MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: "
422 "ECC corrected %d errors on read\n", res); 460 "ECC corrected %d errors on read\n", res);
423 } 461 }
424 return res; 462 return res;
425} 463}
464
465
466/**
467 * rtc_from4_errstat - perform additional error status checks
468 * @mtd: MTD device structure
469 * @this: NAND chip structure
470 * @state: state or the operation
471 * @status: status code returned from read status
472 * @page: startpage inside the chip, must be called with (page & this->pagemask)
473 *
474 * Perform additional error status checks on erase and write failures
475 * to determine if errors are correctable. For this device, correctable
476 * 1-bit errors on erase and write are considered acceptable.
477 *
478 * note: see pages 34..37 of data sheet for details.
479 *
480 */
481static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page)
482{
483 int er_stat=0;
484 int rtn, retlen;
485 size_t len;
486 uint8_t *buf;
487 int i;
488
489 this->cmdfunc (mtd, NAND_CMD_STATUS_CLEAR, -1, -1);
490
491 if (state == FL_ERASING) {
492 for (i=0; i<4; i++) {
493 if (status & 1<<(i+1)) {
494 this->cmdfunc (mtd, (NAND_CMD_STATUS_ERROR + i + 1), -1, -1);
495 rtn = this->read_byte(mtd);
496 this->cmdfunc (mtd, NAND_CMD_STATUS_RESET, -1, -1);
497 if (!(rtn & ERR_STAT_ECC_AVAILABLE)) {
498 er_stat |= 1<<(i+1); /* err_ecc_not_avail */
499 }
500 }
501 }
502 } else if (state == FL_WRITING) {
503 /* single bank write logic */
504 this->cmdfunc (mtd, NAND_CMD_STATUS_ERROR, -1, -1);
505 rtn = this->read_byte(mtd);
506 this->cmdfunc (mtd, NAND_CMD_STATUS_RESET, -1, -1);
507 if (!(rtn & ERR_STAT_ECC_AVAILABLE)) {
508 er_stat |= 1<<1; /* err_ecc_not_avail */
509 } else {
510 len = mtd->oobblock;
511 buf = kmalloc (len, GFP_KERNEL);
512 if (!buf) {
513 printk (KERN_ERR "rtc_from4_errstat: Out of memory!\n");
514 er_stat = 1; /* if we can't check, assume failed */
515 } else {
516 /* recovery read */
517 /* page read */
518 rtn = nand_do_read_ecc (mtd, page, len, &retlen, buf, NULL, this->autooob, 1);
519 if (rtn) { /* if read failed or > 1-bit error corrected */
520 er_stat |= 1<<1; /* ECC read failed */
521 }
522 kfree(buf);
523 }
524 }
525 }
526
527 rtn = status;
528 if (er_stat == 0) { /* if ECC is available */
529 rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */
530 }
531
532 return rtn;
533}
426#endif 534#endif
427 535
536
428/* 537/*
429 * Main initialization routine 538 * Main initialization routine
430 */ 539 */
@@ -432,6 +541,7 @@ int __init rtc_from4_init (void)
432{ 541{
433 struct nand_chip *this; 542 struct nand_chip *this;
434 unsigned short bcr1, bcr2, wcr2; 543 unsigned short bcr1, bcr2, wcr2;
544 int i;
435 545
436 /* Allocate memory for MTD device structure and private data */ 546 /* Allocate memory for MTD device structure and private data */
437 rtc_from4_mtd = kmalloc(sizeof(struct mtd_info) + sizeof (struct nand_chip), 547 rtc_from4_mtd = kmalloc(sizeof(struct mtd_info) + sizeof (struct nand_chip),
@@ -483,6 +593,8 @@ int __init rtc_from4_init (void)
483 593
484 this->eccmode = NAND_ECC_HW8_512; 594 this->eccmode = NAND_ECC_HW8_512;
485 this->options |= NAND_HWECC_SYNDROME; 595 this->options |= NAND_HWECC_SYNDROME;
596 /* return the status of extra status and ECC checks */
597 this->errstat = rtc_from4_errstat;
486 /* set the nand_oobinfo to support FPGA H/W error detection */ 598 /* set the nand_oobinfo to support FPGA H/W error detection */
487 this->autooob = &rtc_from4_nand_oobinfo; 599 this->autooob = &rtc_from4_nand_oobinfo;
488 this->enable_hwecc = rtc_from4_enable_hwecc; 600 this->enable_hwecc = rtc_from4_enable_hwecc;
@@ -504,6 +616,18 @@ int __init rtc_from4_init (void)
504 return -ENXIO; 616 return -ENXIO;
505 } 617 }
506 618
619 /* Perform 'device recovery' for each chip in case there was a power loss. */
620 for (i=0; i < this->numchips; i++) {
621 deplete(rtc_from4_mtd, i);
622 }
623
624#if RTC_FROM4_NO_VIRTBLOCKS
625 /* use a smaller erase block to minimize wasted space when a block is bad */
626 /* note: this uses eight times as much RAM as using the default and makes */
627 /* mounts take four times as long. */
628 rtc_from4_mtd->flags |= MTD_NO_VIRTBLOCKS;
629#endif
630
507 /* Register the partitions */ 631 /* Register the partitions */
508 add_mtd_partitions(rtc_from4_mtd, partition_info, NUM_PARTITIONS); 632 add_mtd_partitions(rtc_from4_mtd, partition_info, NUM_PARTITIONS);
509 633
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index d05e9b97947d..891e3a1b9110 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -1,17 +1,24 @@
1/* linux/drivers/mtd/nand/s3c2410.c 1/* linux/drivers/mtd/nand/s3c2410.c
2 * 2 *
3 * Copyright (c) 2004 Simtec Electronics 3 * Copyright (c) 2004,2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 4 * http://www.simtec.co.uk/products/SWLINUX/
5 * Ben Dooks <ben@simtec.co.uk>
5 * 6 *
6 * Samsung S3C2410 NAND driver 7 * Samsung S3C2410/S3C240 NAND driver
7 * 8 *
8 * Changelog: 9 * Changelog:
9 * 21-Sep-2004 BJD Initial version 10 * 21-Sep-2004 BJD Initial version
10 * 23-Sep-2004 BJD Mulitple device support 11 * 23-Sep-2004 BJD Mulitple device support
11 * 28-Sep-2004 BJD Fixed ECC placement for Hardware mode 12 * 28-Sep-2004 BJD Fixed ECC placement for Hardware mode
12 * 12-Oct-2004 BJD Fixed errors in use of platform data 13 * 12-Oct-2004 BJD Fixed errors in use of platform data
14 * 18-Feb-2005 BJD Fix sparse errors
15 * 14-Mar-2005 BJD Applied tglx's code reduction patch
16 * 02-May-2005 BJD Fixed s3c2440 support
17 * 02-May-2005 BJD Reduced hwcontrol decode
18 * 20-Jun-2005 BJD Updated s3c2440 support, fixed timing bug
19 * 08-Jul-2005 BJD Fix OOPS when no platform data supplied
13 * 20 *
14 * $Id: s3c2410.c,v 1.7 2005/01/05 18:05:14 dwmw2 Exp $ 21 * $Id: s3c2410.c,v 1.14 2005/07/06 20:05:06 bjd Exp $
15 * 22 *
16 * This program is free software; you can redistribute it and/or modify 23 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by 24 * it under the terms of the GNU General Public License as published by
@@ -69,10 +76,10 @@ static int hardware_ecc = 0;
69 */ 76 */
70 77
71static struct nand_oobinfo nand_hw_eccoob = { 78static struct nand_oobinfo nand_hw_eccoob = {
72 .useecc = MTD_NANDECC_AUTOPLACE, 79 .useecc = MTD_NANDECC_AUTOPLACE,
73 .eccbytes = 3, 80 .eccbytes = 3,
74 .eccpos = {0, 1, 2 }, 81 .eccpos = {0, 1, 2 },
75 .oobfree = { {8, 8} } 82 .oobfree = { {8, 8} }
76}; 83};
77 84
78/* controller and mtd information */ 85/* controller and mtd information */
@@ -99,8 +106,10 @@ struct s3c2410_nand_info {
99 struct device *device; 106 struct device *device;
100 struct resource *area; 107 struct resource *area;
101 struct clk *clk; 108 struct clk *clk;
102 void *regs; 109 void __iomem *regs;
103 int mtd_count; 110 int mtd_count;
111
112 unsigned char is_s3c2440;
104}; 113};
105 114
106/* conversion functions */ 115/* conversion functions */
@@ -165,12 +174,12 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
165 /* calculate the timing information for the controller */ 174 /* calculate the timing information for the controller */
166 175
167 if (plat != NULL) { 176 if (plat != NULL) {
168 tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 8); 177 tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 4);
169 twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8); 178 twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8);
170 twrph1 = s3c2410_nand_calc_rate(plat->twrph1, clkrate, 8); 179 twrph1 = s3c2410_nand_calc_rate(plat->twrph1, clkrate, 8);
171 } else { 180 } else {
172 /* default timings */ 181 /* default timings */
173 tacls = 8; 182 tacls = 4;
174 twrph0 = 8; 183 twrph0 = 8;
175 twrph1 = 8; 184 twrph1 = 8;
176 } 185 }
@@ -185,10 +194,16 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
185 to_ns(twrph0, clkrate), 194 to_ns(twrph0, clkrate),
186 to_ns(twrph1, clkrate)); 195 to_ns(twrph1, clkrate));
187 196
188 cfg = S3C2410_NFCONF_EN; 197 if (!info->is_s3c2440) {
189 cfg |= S3C2410_NFCONF_TACLS(tacls-1); 198 cfg = S3C2410_NFCONF_EN;
190 cfg |= S3C2410_NFCONF_TWRPH0(twrph0-1); 199 cfg |= S3C2410_NFCONF_TACLS(tacls-1);
191 cfg |= S3C2410_NFCONF_TWRPH1(twrph1-1); 200 cfg |= S3C2410_NFCONF_TWRPH0(twrph0-1);
201 cfg |= S3C2410_NFCONF_TWRPH1(twrph1-1);
202 } else {
203 cfg = S3C2440_NFCONF_TACLS(tacls-1);
204 cfg |= S3C2440_NFCONF_TWRPH0(twrph0-1);
205 cfg |= S3C2440_NFCONF_TWRPH1(twrph1-1);
206 }
192 207
193 pr_debug(PFX "NF_CONF is 0x%lx\n", cfg); 208 pr_debug(PFX "NF_CONF is 0x%lx\n", cfg);
194 209
@@ -203,17 +218,22 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
203 struct s3c2410_nand_info *info; 218 struct s3c2410_nand_info *info;
204 struct s3c2410_nand_mtd *nmtd; 219 struct s3c2410_nand_mtd *nmtd;
205 struct nand_chip *this = mtd->priv; 220 struct nand_chip *this = mtd->priv;
221 void __iomem *reg;
206 unsigned long cur; 222 unsigned long cur;
223 unsigned long bit;
207 224
208 nmtd = this->priv; 225 nmtd = this->priv;
209 info = nmtd->info; 226 info = nmtd->info;
210 227
211 cur = readl(info->regs + S3C2410_NFCONF); 228 bit = (info->is_s3c2440) ? S3C2440_NFCONT_nFCE : S3C2410_NFCONF_nFCE;
229 reg = info->regs+((info->is_s3c2440) ? S3C2440_NFCONT:S3C2410_NFCONF);
230
231 cur = readl(reg);
212 232
213 if (chip == -1) { 233 if (chip == -1) {
214 cur |= S3C2410_NFCONF_nFCE; 234 cur |= bit;
215 } else { 235 } else {
216 if (chip > nmtd->set->nr_chips) { 236 if (nmtd->set != NULL && chip > nmtd->set->nr_chips) {
217 printk(KERN_ERR PFX "chip %d out of range\n", chip); 237 printk(KERN_ERR PFX "chip %d out of range\n", chip);
218 return; 238 return;
219 } 239 }
@@ -223,143 +243,76 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
223 (info->platform->select_chip)(nmtd->set, chip); 243 (info->platform->select_chip)(nmtd->set, chip);
224 } 244 }
225 245
226 cur &= ~S3C2410_NFCONF_nFCE; 246 cur &= ~bit;
227 } 247 }
228 248
229 writel(cur, info->regs + S3C2410_NFCONF); 249 writel(cur, reg);
230} 250}
231 251
232/* command and control functions */ 252/* command and control functions
253 *
254 * Note, these all use tglx's method of changing the IO_ADDR_W field
255 * to make the code simpler, and use the nand layer's code to issue the
256 * command and address sequences via the proper IO ports.
257 *
258*/
233 259
234static void s3c2410_nand_hwcontrol(struct mtd_info *mtd, int cmd) 260static void s3c2410_nand_hwcontrol(struct mtd_info *mtd, int cmd)
235{ 261{
236 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 262 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
237 unsigned long cur; 263 struct nand_chip *chip = mtd->priv;
238 264
239 switch (cmd) { 265 switch (cmd) {
240 case NAND_CTL_SETNCE: 266 case NAND_CTL_SETNCE:
241 cur = readl(info->regs + S3C2410_NFCONF);
242 cur &= ~S3C2410_NFCONF_nFCE;
243 writel(cur, info->regs + S3C2410_NFCONF);
244 break;
245
246 case NAND_CTL_CLRNCE: 267 case NAND_CTL_CLRNCE:
247 cur = readl(info->regs + S3C2410_NFCONF); 268 printk(KERN_ERR "%s: called for NCE\n", __FUNCTION__);
248 cur |= S3C2410_NFCONF_nFCE;
249 writel(cur, info->regs + S3C2410_NFCONF);
250 break; 269 break;
251 270
252 /* we don't need to implement these */
253 case NAND_CTL_SETCLE: 271 case NAND_CTL_SETCLE:
254 case NAND_CTL_CLRCLE: 272 chip->IO_ADDR_W = info->regs + S3C2410_NFCMD;
273 break;
274
255 case NAND_CTL_SETALE: 275 case NAND_CTL_SETALE:
256 case NAND_CTL_CLRALE: 276 chip->IO_ADDR_W = info->regs + S3C2410_NFADDR;
257 pr_debug(PFX "s3c2410_nand_hwcontrol(%d) unusedn", cmd); 277 break;
278
279 /* NAND_CTL_CLRCLE: */
280 /* NAND_CTL_CLRALE: */
281 default:
282 chip->IO_ADDR_W = info->regs + S3C2410_NFDATA;
258 break; 283 break;
259 } 284 }
260} 285}
261 286
262/* s3c2410_nand_command 287/* command and control functions */
263 *
264 * This function implements sending commands and the relevant address
265 * information to the chip, via the hardware controller. Since the
266 * S3C2410 generates the correct ALE/CLE signaling automatically, we
267 * do not need to use hwcontrol.
268*/
269 288
270static void s3c2410_nand_command (struct mtd_info *mtd, unsigned command, 289static void s3c2440_nand_hwcontrol(struct mtd_info *mtd, int cmd)
271 int column, int page_addr)
272{ 290{
273 register struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 291 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
274 register struct nand_chip *this = mtd->priv; 292 struct nand_chip *chip = mtd->priv;
275 293
276 /* 294 switch (cmd) {
277 * Write out the command to the device. 295 case NAND_CTL_SETNCE:
278 */ 296 case NAND_CTL_CLRNCE:
279 if (command == NAND_CMD_SEQIN) { 297 printk(KERN_ERR "%s: called for NCE\n", __FUNCTION__);
280 int readcmd; 298 break;
281
282 if (column >= mtd->oobblock) {
283 /* OOB area */
284 column -= mtd->oobblock;
285 readcmd = NAND_CMD_READOOB;
286 } else if (column < 256) {
287 /* First 256 bytes --> READ0 */
288 readcmd = NAND_CMD_READ0;
289 } else {
290 column -= 256;
291 readcmd = NAND_CMD_READ1;
292 }
293
294 writeb(readcmd, info->regs + S3C2410_NFCMD);
295 }
296 writeb(command, info->regs + S3C2410_NFCMD);
297 299
298 /* Set ALE and clear CLE to start address cycle */ 300 case NAND_CTL_SETCLE:
301 chip->IO_ADDR_W = info->regs + S3C2440_NFCMD;
302 break;
299 303
300 if (column != -1 || page_addr != -1) { 304 case NAND_CTL_SETALE:
305 chip->IO_ADDR_W = info->regs + S3C2440_NFADDR;
306 break;
301 307
302 /* Serially input address */ 308 /* NAND_CTL_CLRCLE: */
303 if (column != -1) { 309 /* NAND_CTL_CLRALE: */
304 /* Adjust columns for 16 bit buswidth */
305 if (this->options & NAND_BUSWIDTH_16)
306 column >>= 1;
307 writeb(column, info->regs + S3C2410_NFADDR);
308 }
309 if (page_addr != -1) {
310 writeb((unsigned char) (page_addr), info->regs + S3C2410_NFADDR);
311 writeb((unsigned char) (page_addr >> 8), info->regs + S3C2410_NFADDR);
312 /* One more address cycle for higher density devices */
313 if (this->chipsize & 0x0c000000)
314 writeb((unsigned char) ((page_addr >> 16) & 0x0f),
315 info->regs + S3C2410_NFADDR);
316 }
317 /* Latch in address */
318 }
319
320 /*
321 * program and erase have their own busy handlers
322 * status and sequential in needs no delay
323 */
324 switch (command) {
325
326 case NAND_CMD_PAGEPROG:
327 case NAND_CMD_ERASE1:
328 case NAND_CMD_ERASE2:
329 case NAND_CMD_SEQIN:
330 case NAND_CMD_STATUS:
331 return;
332
333 case NAND_CMD_RESET:
334 if (this->dev_ready)
335 break;
336
337 udelay(this->chip_delay);
338 writeb(NAND_CMD_STATUS, info->regs + S3C2410_NFCMD);
339
340 while ( !(this->read_byte(mtd) & 0x40));
341 return;
342
343 /* This applies to read commands */
344 default: 310 default:
345 /* 311 chip->IO_ADDR_W = info->regs + S3C2440_NFDATA;
346 * If we don't have access to the busy pin, we apply the given 312 break;
347 * command delay
348 */
349 if (!this->dev_ready) {
350 udelay (this->chip_delay);
351 return;
352 }
353 } 313 }
354
355 /* Apply this short delay always to ensure that we do wait tWB in
356 * any case on any machine. */
357 ndelay (100);
358 /* wait until command is processed */
359 while (!this->dev_ready(mtd));
360} 314}
361 315
362
363/* s3c2410_nand_devready() 316/* s3c2410_nand_devready()
364 * 317 *
365 * returns 0 if the nand is busy, 1 if it is ready 318 * returns 0 if the nand is busy, 1 if it is ready
@@ -369,9 +322,12 @@ static int s3c2410_nand_devready(struct mtd_info *mtd)
369{ 322{
370 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 323 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
371 324
325 if (info->is_s3c2440)
326 return readb(info->regs + S3C2440_NFSTAT) & S3C2440_NFSTAT_READY;
372 return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY; 327 return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY;
373} 328}
374 329
330
375/* ECC handling functions */ 331/* ECC handling functions */
376 332
377static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat, 333static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
@@ -394,6 +350,12 @@ static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
394 return -1; 350 return -1;
395} 351}
396 352
353/* ECC functions
354 *
355 * These allow the s3c2410 and s3c2440 to use the controller's ECC
356 * generator block to ECC the data as it passes through]
357*/
358
397static void s3c2410_nand_enable_hwecc(struct mtd_info *mtd, int mode) 359static void s3c2410_nand_enable_hwecc(struct mtd_info *mtd, int mode)
398{ 360{
399 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 361 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
@@ -404,6 +366,15 @@ static void s3c2410_nand_enable_hwecc(struct mtd_info *mtd, int mode)
404 writel(ctrl, info->regs + S3C2410_NFCONF); 366 writel(ctrl, info->regs + S3C2410_NFCONF);
405} 367}
406 368
369static void s3c2440_nand_enable_hwecc(struct mtd_info *mtd, int mode)
370{
371 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
372 unsigned long ctrl;
373
374 ctrl = readl(info->regs + S3C2440_NFCONT);
375 writel(ctrl | S3C2440_NFCONT_INITECC, info->regs + S3C2440_NFCONT);
376}
377
407static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, 378static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd,
408 const u_char *dat, u_char *ecc_code) 379 const u_char *dat, u_char *ecc_code)
409{ 380{
@@ -420,7 +391,26 @@ static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd,
420} 391}
421 392
422 393
423/* over-ride the standard functions for a little more speed? */ 394static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd,
395 const u_char *dat, u_char *ecc_code)
396{
397 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
398 unsigned long ecc = readl(info->regs + S3C2440_NFMECC0);
399
400 ecc_code[0] = ecc;
401 ecc_code[1] = ecc >> 8;
402 ecc_code[2] = ecc >> 16;
403
404 pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n",
405 ecc_code[0], ecc_code[1], ecc_code[2]);
406
407 return 0;
408}
409
410
411/* over-ride the standard functions for a little more speed. We can
412 * use read/write block to move the data buffers to/from the controller
413*/
424 414
425static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) 415static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
426{ 416{
@@ -523,11 +513,10 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
523{ 513{
524 struct nand_chip *chip = &nmtd->chip; 514 struct nand_chip *chip = &nmtd->chip;
525 515
526 chip->IO_ADDR_R = (char *)info->regs + S3C2410_NFDATA; 516 chip->IO_ADDR_R = info->regs + S3C2410_NFDATA;
527 chip->IO_ADDR_W = (char *)info->regs + S3C2410_NFDATA; 517 chip->IO_ADDR_W = info->regs + S3C2410_NFDATA;
528 chip->hwcontrol = s3c2410_nand_hwcontrol; 518 chip->hwcontrol = s3c2410_nand_hwcontrol;
529 chip->dev_ready = s3c2410_nand_devready; 519 chip->dev_ready = s3c2410_nand_devready;
530 chip->cmdfunc = s3c2410_nand_command;
531 chip->write_buf = s3c2410_nand_write_buf; 520 chip->write_buf = s3c2410_nand_write_buf;
532 chip->read_buf = s3c2410_nand_read_buf; 521 chip->read_buf = s3c2410_nand_read_buf;
533 chip->select_chip = s3c2410_nand_select_chip; 522 chip->select_chip = s3c2410_nand_select_chip;
@@ -536,6 +525,12 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
536 chip->options = 0; 525 chip->options = 0;
537 chip->controller = &info->controller; 526 chip->controller = &info->controller;
538 527
528 if (info->is_s3c2440) {
529 chip->IO_ADDR_R = info->regs + S3C2440_NFDATA;
530 chip->IO_ADDR_W = info->regs + S3C2440_NFDATA;
531 chip->hwcontrol = s3c2440_nand_hwcontrol;
532 }
533
539 nmtd->info = info; 534 nmtd->info = info;
540 nmtd->mtd.priv = chip; 535 nmtd->mtd.priv = chip;
541 nmtd->set = set; 536 nmtd->set = set;
@@ -546,6 +541,11 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
546 chip->calculate_ecc = s3c2410_nand_calculate_ecc; 541 chip->calculate_ecc = s3c2410_nand_calculate_ecc;
547 chip->eccmode = NAND_ECC_HW3_512; 542 chip->eccmode = NAND_ECC_HW3_512;
548 chip->autooob = &nand_hw_eccoob; 543 chip->autooob = &nand_hw_eccoob;
544
545 if (info->is_s3c2440) {
546 chip->enable_hwecc = s3c2440_nand_enable_hwecc;
547 chip->calculate_ecc = s3c2440_nand_calculate_ecc;
548 }
549 } else { 549 } else {
550 chip->eccmode = NAND_ECC_SOFT; 550 chip->eccmode = NAND_ECC_SOFT;
551 } 551 }
@@ -559,7 +559,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
559 * nand layer to look for devices 559 * nand layer to look for devices
560*/ 560*/
561 561
562static int s3c2410_nand_probe(struct device *dev) 562static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
563{ 563{
564 struct platform_device *pdev = to_platform_device(dev); 564 struct platform_device *pdev = to_platform_device(dev);
565 struct s3c2410_platform_nand *plat = to_nand_plat(dev); 565 struct s3c2410_platform_nand *plat = to_nand_plat(dev);
@@ -585,6 +585,7 @@ static int s3c2410_nand_probe(struct device *dev)
585 dev_set_drvdata(dev, info); 585 dev_set_drvdata(dev, info);
586 586
587 spin_lock_init(&info->controller.lock); 587 spin_lock_init(&info->controller.lock);
588 init_waitqueue_head(&info->controller.wq);
588 589
589 /* get the clock source and enable it */ 590 /* get the clock source and enable it */
590 591
@@ -600,7 +601,8 @@ static int s3c2410_nand_probe(struct device *dev)
600 601
601 /* allocate and map the resource */ 602 /* allocate and map the resource */
602 603
603 res = pdev->resource; /* assume that the flash has one resource */ 604 /* currently we assume we have the one resource */
605 res = pdev->resource;
604 size = res->end - res->start + 1; 606 size = res->end - res->start + 1;
605 607
606 info->area = request_mem_region(res->start, size, pdev->name); 608 info->area = request_mem_region(res->start, size, pdev->name);
@@ -611,9 +613,10 @@ static int s3c2410_nand_probe(struct device *dev)
611 goto exit_error; 613 goto exit_error;
612 } 614 }
613 615
614 info->device = dev; 616 info->device = dev;
615 info->platform = plat; 617 info->platform = plat;
616 info->regs = ioremap(res->start, size); 618 info->regs = ioremap(res->start, size);
619 info->is_s3c2440 = is_s3c2440;
617 620
618 if (info->regs == NULL) { 621 if (info->regs == NULL) {
619 printk(KERN_ERR PFX "cannot reserve register region\n"); 622 printk(KERN_ERR PFX "cannot reserve register region\n");
@@ -678,6 +681,18 @@ static int s3c2410_nand_probe(struct device *dev)
678 return err; 681 return err;
679} 682}
680 683
684/* driver device registration */
685
686static int s3c2410_nand_probe(struct device *dev)
687{
688 return s3c24xx_nand_probe(dev, 0);
689}
690
691static int s3c2440_nand_probe(struct device *dev)
692{
693 return s3c24xx_nand_probe(dev, 1);
694}
695
681static struct device_driver s3c2410_nand_driver = { 696static struct device_driver s3c2410_nand_driver = {
682 .name = "s3c2410-nand", 697 .name = "s3c2410-nand",
683 .bus = &platform_bus_type, 698 .bus = &platform_bus_type,
@@ -685,14 +700,24 @@ static struct device_driver s3c2410_nand_driver = {
685 .remove = s3c2410_nand_remove, 700 .remove = s3c2410_nand_remove,
686}; 701};
687 702
703static struct device_driver s3c2440_nand_driver = {
704 .name = "s3c2440-nand",
705 .bus = &platform_bus_type,
706 .probe = s3c2440_nand_probe,
707 .remove = s3c2410_nand_remove,
708};
709
688static int __init s3c2410_nand_init(void) 710static int __init s3c2410_nand_init(void)
689{ 711{
690 printk("S3C2410 NAND Driver, (c) 2004 Simtec Electronics\n"); 712 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n");
713
714 driver_register(&s3c2440_nand_driver);
691 return driver_register(&s3c2410_nand_driver); 715 return driver_register(&s3c2410_nand_driver);
692} 716}
693 717
694static void __exit s3c2410_nand_exit(void) 718static void __exit s3c2410_nand_exit(void)
695{ 719{
720 driver_unregister(&s3c2440_nand_driver);
696 driver_unregister(&s3c2410_nand_driver); 721 driver_unregister(&s3c2410_nand_driver);
697} 722}
698 723
@@ -701,4 +726,4 @@ module_exit(s3c2410_nand_exit);
701 726
702MODULE_LICENSE("GPL"); 727MODULE_LICENSE("GPL");
703MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); 728MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
704MODULE_DESCRIPTION("S3C2410 MTD NAND driver"); 729MODULE_DESCRIPTION("S3C24XX MTD NAND driver");
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index 29572793334c..9853b87bb756 100755..100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2004 Richard Purdie 4 * Copyright (C) 2004 Richard Purdie
5 * 5 *
6 * $Id: sharpsl.c,v 1.3 2005/01/03 14:53:50 rpurdie Exp $ 6 * $Id: sharpsl.c,v 1.4 2005/01/23 11:09:19 rpurdie Exp $
7 * 7 *
8 * Based on Sharp's NAND driver sharp_sl.c 8 * Based on Sharp's NAND driver sharp_sl.c
9 * 9 *
@@ -216,7 +216,7 @@ sharpsl_nand_init(void)
216 nr_partitions = DEFAULT_NUM_PARTITIONS; 216 nr_partitions = DEFAULT_NUM_PARTITIONS;
217 sharpsl_partition_info = sharpsl_nand_default_partition_info; 217 sharpsl_partition_info = sharpsl_nand_default_partition_info;
218 if (machine_is_poodle()) { 218 if (machine_is_poodle()) {
219 sharpsl_partition_info[1].size=22 * 1024 * 1024; 219 sharpsl_partition_info[1].size=30 * 1024 * 1024;
220 } else if (machine_is_corgi() || machine_is_shepherd()) { 220 } else if (machine_is_corgi() || machine_is_shepherd()) {
221 sharpsl_partition_info[1].size=25 * 1024 * 1024; 221 sharpsl_partition_info[1].size=25 * 1024 * 1024;
222 } else if (machine_is_husky()) { 222 } else if (machine_is_husky()) {
diff --git a/drivers/mtd/nand/tx4925ndfmc.c b/drivers/mtd/nand/tx4925ndfmc.c
deleted file mode 100644
index bba688830c9b..000000000000
--- a/drivers/mtd/nand/tx4925ndfmc.c
+++ /dev/null
@@ -1,416 +0,0 @@
1/*
2 * drivers/mtd/tx4925ndfmc.c
3 *
4 * Overview:
5 * This is a device driver for the NAND flash device found on the
6 * Toshiba RBTX4925 reference board, which is a SmartMediaCard. It supports
7 * 16MiB, 32MiB and 64MiB cards.
8 *
9 * Author: MontaVista Software, Inc. source@mvista.com
10 *
11 * Derived from drivers/mtd/autcpu12.c
12 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
13 *
14 * $Id: tx4925ndfmc.c,v 1.5 2004/10/05 13:50:20 gleixner Exp $
15 *
16 * Copyright (C) 2001 Toshiba Corporation
17 *
18 * 2003 (c) MontaVista Software, Inc. This file is licensed under
19 * the terms of the GNU General Public License version 2. This program
20 * is licensed "as is" without any warranty of any kind, whether express
21 * or implied.
22 *
23 */
24
25#include <linux/slab.h>
26#include <linux/init.h>
27#include <linux/module.h>
28#include <linux/mtd/mtd.h>
29#include <linux/mtd/nand.h>
30#include <linux/mtd/partitions.h>
31#include <linux/delay.h>
32#include <asm/io.h>
33#include <asm/tx4925/tx4925_nand.h>
34
35extern struct nand_oobinfo jffs2_oobinfo;
36
37/*
38 * MTD structure for RBTX4925 board
39 */
40static struct mtd_info *tx4925ndfmc_mtd = NULL;
41
42/*
43 * Define partitions for flash devices
44 */
45
46static struct mtd_partition partition_info16k[] = {
47 { .name = "RBTX4925 flash partition 1",
48 .offset = 0,
49 .size = 8 * 0x00100000 },
50 { .name = "RBTX4925 flash partition 2",
51 .offset = 8 * 0x00100000,
52 .size = 8 * 0x00100000 },
53};
54
55static struct mtd_partition partition_info32k[] = {
56 { .name = "RBTX4925 flash partition 1",
57 .offset = 0,
58 .size = 8 * 0x00100000 },
59 { .name = "RBTX4925 flash partition 2",
60 .offset = 8 * 0x00100000,
61 .size = 24 * 0x00100000 },
62};
63
64static struct mtd_partition partition_info64k[] = {
65 { .name = "User FS",
66 .offset = 0,
67 .size = 16 * 0x00100000 },
68 { .name = "RBTX4925 flash partition 2",
69 .offset = 16 * 0x00100000,
70 .size = 48 * 0x00100000},
71};
72
73static struct mtd_partition partition_info128k[] = {
74 { .name = "Skip bad section",
75 .offset = 0,
76 .size = 16 * 0x00100000 },
77 { .name = "User FS",
78 .offset = 16 * 0x00100000,
79 .size = 112 * 0x00100000 },
80};
81#define NUM_PARTITIONS16K 2
82#define NUM_PARTITIONS32K 2
83#define NUM_PARTITIONS64K 2
84#define NUM_PARTITIONS128K 2
85
86/*
87 * hardware specific access to control-lines
88*/
89static void tx4925ndfmc_hwcontrol(struct mtd_info *mtd, int cmd)
90{
91
92 switch(cmd){
93
94 case NAND_CTL_SETCLE:
95 tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_CLE;
96 break;
97 case NAND_CTL_CLRCLE:
98 tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_CLE;
99 break;
100 case NAND_CTL_SETALE:
101 tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_ALE;
102 break;
103 case NAND_CTL_CLRALE:
104 tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_ALE;
105 break;
106 case NAND_CTL_SETNCE:
107 tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_CE;
108 break;
109 case NAND_CTL_CLRNCE:
110 tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_CE;
111 break;
112 case NAND_CTL_SETWP:
113 tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_WE;
114 break;
115 case NAND_CTL_CLRWP:
116 tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_WE;
117 break;
118 }
119}
120
121/*
122* read device ready pin
123*/
124static int tx4925ndfmc_device_ready(struct mtd_info *mtd)
125{
126 int ready;
127 ready = (tx4925_ndfmcptr->sr & TX4925_NDSFR_BUSY) ? 0 : 1;
128 return ready;
129}
130void tx4925ndfmc_enable_hwecc(struct mtd_info *mtd, int mode)
131{
132 /* reset first */
133 tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_ECC_CNTL_MASK;
134 tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_ECC_CNTL_MASK;
135 tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_ECC_CNTL_ENAB;
136}
137static void tx4925ndfmc_disable_ecc(void)
138{
139 tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_ECC_CNTL_MASK;
140}
141static void tx4925ndfmc_enable_read_ecc(void)
142{
143 tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_ECC_CNTL_MASK;
144 tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_ECC_CNTL_READ;
145}
146void tx4925ndfmc_readecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code){
147 int i;
148 u_char *ecc = ecc_code;
149 tx4925ndfmc_enable_read_ecc();
150 for (i = 0;i < 6;i++,ecc++)
151 *ecc = tx4925_read_nfmc(&(tx4925_ndfmcptr->dtr));
152 tx4925ndfmc_disable_ecc();
153}
154void tx4925ndfmc_device_setup(void)
155{
156
157 *(unsigned char *)0xbb005000 &= ~0x08;
158
159 /* reset NDFMC */
160 tx4925_ndfmcptr->rstr |= TX4925_NDFRSTR_RST;
161 while (tx4925_ndfmcptr->rstr & TX4925_NDFRSTR_RST);
162
163 /* setup BusSeparete, Hold Time, Strobe Pulse Width */
164 tx4925_ndfmcptr->mcr = TX4925_BSPRT ? TX4925_NDFMCR_BSPRT : 0;
165 tx4925_ndfmcptr->spr = TX4925_HOLD << 4 | TX4925_SPW;
166}
167static u_char tx4925ndfmc_nand_read_byte(struct mtd_info *mtd)
168{
169 struct nand_chip *this = mtd->priv;
170 return tx4925_read_nfmc(this->IO_ADDR_R);
171}
172
173static void tx4925ndfmc_nand_write_byte(struct mtd_info *mtd, u_char byte)
174{
175 struct nand_chip *this = mtd->priv;
176 tx4925_write_nfmc(byte, this->IO_ADDR_W);
177}
178
179static void tx4925ndfmc_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
180{
181 int i;
182 struct nand_chip *this = mtd->priv;
183
184 for (i=0; i<len; i++)
185 tx4925_write_nfmc(buf[i], this->IO_ADDR_W);
186}
187
188static void tx4925ndfmc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
189{
190 int i;
191 struct nand_chip *this = mtd->priv;
192
193 for (i=0; i<len; i++)
194 buf[i] = tx4925_read_nfmc(this->IO_ADDR_R);
195}
196
197static int tx4925ndfmc_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
198{
199 int i;
200 struct nand_chip *this = mtd->priv;
201
202 for (i=0; i<len; i++)
203 if (buf[i] != tx4925_read_nfmc(this->IO_ADDR_R))
204 return -EFAULT;
205
206 return 0;
207}
208
209/*
210 * Send command to NAND device
211 */
212static void tx4925ndfmc_nand_command (struct mtd_info *mtd, unsigned command, int column, int page_addr)
213{
214 register struct nand_chip *this = mtd->priv;
215
216 /* Begin command latch cycle */
217 this->hwcontrol(mtd, NAND_CTL_SETCLE);
218 /*
219 * Write out the command to the device.
220 */
221 if (command == NAND_CMD_SEQIN) {
222 int readcmd;
223
224 if (column >= mtd->oobblock) {
225 /* OOB area */
226 column -= mtd->oobblock;
227 readcmd = NAND_CMD_READOOB;
228 } else if (column < 256) {
229 /* First 256 bytes --> READ0 */
230 readcmd = NAND_CMD_READ0;
231 } else {
232 column -= 256;
233 readcmd = NAND_CMD_READ1;
234 }
235 this->write_byte(mtd, readcmd);
236 }
237 this->write_byte(mtd, command);
238
239 /* Set ALE and clear CLE to start address cycle */
240 this->hwcontrol(mtd, NAND_CTL_CLRCLE);
241
242 if (column != -1 || page_addr != -1) {
243 this->hwcontrol(mtd, NAND_CTL_SETALE);
244
245 /* Serially input address */
246 if (column != -1)
247 this->write_byte(mtd, column);
248 if (page_addr != -1) {
249 this->write_byte(mtd, (unsigned char) (page_addr & 0xff));
250 this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff));
251 /* One more address cycle for higher density devices */
252 if (mtd->size & 0x0c000000)
253 this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0x0f));
254 }
255 /* Latch in address */
256 this->hwcontrol(mtd, NAND_CTL_CLRALE);
257 }
258
259 /*
260 * program and erase have their own busy handlers
261 * status and sequential in needs no delay
262 */
263 switch (command) {
264
265 case NAND_CMD_PAGEPROG:
266 /* Turn off WE */
267 this->hwcontrol (mtd, NAND_CTL_CLRWP);
268 return;
269
270 case NAND_CMD_SEQIN:
271 /* Turn on WE */
272 this->hwcontrol (mtd, NAND_CTL_SETWP);
273 return;
274
275 case NAND_CMD_ERASE1:
276 case NAND_CMD_ERASE2:
277 case NAND_CMD_STATUS:
278 return;
279
280 case NAND_CMD_RESET:
281 if (this->dev_ready)
282 break;
283 this->hwcontrol(mtd, NAND_CTL_SETCLE);
284 this->write_byte(mtd, NAND_CMD_STATUS);
285 this->hwcontrol(mtd, NAND_CTL_CLRCLE);
286 while ( !(this->read_byte(mtd) & 0x40));
287 return;
288
289 /* This applies to read commands */
290 default:
291 /*
292 * If we don't have access to the busy pin, we apply the given
293 * command delay
294 */
295 if (!this->dev_ready) {
296 udelay (this->chip_delay);
297 return;
298 }
299 }
300
301 /* wait until command is processed */
302 while (!this->dev_ready(mtd));
303}
304
305#ifdef CONFIG_MTD_CMDLINE_PARTS
306extern int parse_cmdline_partitions(struct mtd_info *master, struct mtd_partitio
307n **pparts, char *);
308#endif
309
310/*
311 * Main initialization routine
312 */
313extern int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc);
314int __init tx4925ndfmc_init (void)
315{
316 struct nand_chip *this;
317 int err = 0;
318
319 /* Allocate memory for MTD device structure and private data */
320 tx4925ndfmc_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip),
321 GFP_KERNEL);
322 if (!tx4925ndfmc_mtd) {
323 printk ("Unable to allocate RBTX4925 NAND MTD device structure.\n");
324 err = -ENOMEM;
325 goto out;
326 }
327
328 tx4925ndfmc_device_setup();
329
330 /* io is indirect via a register so don't need to ioremap address */
331
332 /* Get pointer to private data */
333 this = (struct nand_chip *) (&tx4925ndfmc_mtd[1]);
334
335 /* Initialize structures */
336 memset((char *) tx4925ndfmc_mtd, 0, sizeof(struct mtd_info));
337 memset((char *) this, 0, sizeof(struct nand_chip));
338
339 /* Link the private data with the MTD structure */
340 tx4925ndfmc_mtd->priv = this;
341
342 /* Set address of NAND IO lines */
343 this->IO_ADDR_R = (void __iomem *)&(tx4925_ndfmcptr->dtr);
344 this->IO_ADDR_W = (void __iomem *)&(tx4925_ndfmcptr->dtr);
345 this->hwcontrol = tx4925ndfmc_hwcontrol;
346 this->enable_hwecc = tx4925ndfmc_enable_hwecc;
347 this->calculate_ecc = tx4925ndfmc_readecc;
348 this->correct_data = nand_correct_data;
349 this->eccmode = NAND_ECC_HW6_512;
350 this->dev_ready = tx4925ndfmc_device_ready;
351 /* 20 us command delay time */
352 this->chip_delay = 20;
353 this->read_byte = tx4925ndfmc_nand_read_byte;
354 this->write_byte = tx4925ndfmc_nand_write_byte;
355 this->cmdfunc = tx4925ndfmc_nand_command;
356 this->write_buf = tx4925ndfmc_nand_write_buf;
357 this->read_buf = tx4925ndfmc_nand_read_buf;
358 this->verify_buf = tx4925ndfmc_nand_verify_buf;
359
360 /* Scan to find existance of the device */
361 if (nand_scan (tx4925ndfmc_mtd, 1)) {
362 err = -ENXIO;
363 goto out_ior;
364 }
365
366 /* Register the partitions */
367#ifdef CONFIG_MTD_CMDLINE_PARTS
368 {
369 int mtd_parts_nb = 0;
370 struct mtd_partition *mtd_parts = 0;
371 mtd_parts_nb = parse_cmdline_partitions(tx4925ndfmc_mtd, &mtd_parts, "tx4925ndfmc");
372 if (mtd_parts_nb > 0)
373 add_mtd_partitions(tx4925ndfmc_mtd, mtd_parts, mtd_parts_nb);
374 else
375 add_mtd_device(tx4925ndfmc_mtd);
376 }
377#else /* ifdef CONFIG_MTD_CMDLINE_PARTS */
378 switch(tx4925ndfmc_mtd->size){
379 case 0x01000000: add_mtd_partitions(tx4925ndfmc_mtd, partition_info16k, NUM_PARTITIONS16K); break;
380 case 0x02000000: add_mtd_partitions(tx4925ndfmc_mtd, partition_info32k, NUM_PARTITIONS32K); break;
381 case 0x04000000: add_mtd_partitions(tx4925ndfmc_mtd, partition_info64k, NUM_PARTITIONS64K); break;
382 case 0x08000000: add_mtd_partitions(tx4925ndfmc_mtd, partition_info128k, NUM_PARTITIONS128K); break;
383 default: {
384 printk ("Unsupported SmartMedia device\n");
385 err = -ENXIO;
386 goto out_ior;
387 }
388 }
389#endif /* ifdef CONFIG_MTD_CMDLINE_PARTS */
390 goto out;
391
392out_ior:
393out:
394 return err;
395}
396
397module_init(tx4925ndfmc_init);
398
399/*
400 * Clean up routine
401 */
402#ifdef MODULE
403static void __exit tx4925ndfmc_cleanup (void)
404{
405 /* Release resources, unregister device */
406 nand_release (tx4925ndfmc_mtd);
407
408 /* Free the MTD device structure */
409 kfree (tx4925ndfmc_mtd);
410}
411module_exit(tx4925ndfmc_cleanup);
412#endif
413
414MODULE_LICENSE("GPL");
415MODULE_AUTHOR("Alice Hennessy <ahennessy@mvista.com>");
416MODULE_DESCRIPTION("Glue layer for SmartMediaCard on Toshiba RBTX4925");
diff --git a/drivers/mtd/nand/tx4938ndfmc.c b/drivers/mtd/nand/tx4938ndfmc.c
deleted file mode 100644
index df26e58820b3..000000000000
--- a/drivers/mtd/nand/tx4938ndfmc.c
+++ /dev/null
@@ -1,406 +0,0 @@
1/*
2 * drivers/mtd/nand/tx4938ndfmc.c
3 *
4 * Overview:
5 * This is a device driver for the NAND flash device connected to
6 * TX4938 internal NAND Memory Controller.
7 * TX4938 NDFMC is almost same as TX4925 NDFMC, but register size are 64 bit.
8 *
9 * Author: source@mvista.com
10 *
11 * Based on spia.c by Steven J. Hill
12 *
13 * $Id: tx4938ndfmc.c,v 1.4 2004/10/05 13:50:20 gleixner Exp $
14 *
15 * Copyright (C) 2000-2001 Toshiba Corporation
16 *
17 * 2003 (c) MontaVista Software, Inc. This file is licensed under the
18 * terms of the GNU General Public License version 2. This program is
19 * licensed "as is" without any warranty of any kind, whether express
20 * or implied.
21 */
22#include <linux/config.h>
23#include <linux/slab.h>
24#include <linux/init.h>
25#include <linux/module.h>
26#include <linux/mtd/mtd.h>
27#include <linux/mtd/nand.h>
28#include <linux/mtd/nand_ecc.h>
29#include <linux/mtd/partitions.h>
30#include <asm/io.h>
31#include <asm/bootinfo.h>
32#include <linux/delay.h>
33#include <asm/tx4938/rbtx4938.h>
34
35extern struct nand_oobinfo jffs2_oobinfo;
36
37/*
38 * MTD structure for TX4938 NDFMC
39 */
40static struct mtd_info *tx4938ndfmc_mtd;
41
42/*
43 * Define partitions for flash device
44 */
45#define flush_wb() (void)tx4938_ndfmcptr->mcr;
46
47#define NUM_PARTITIONS 3
48#define NUMBER_OF_CIS_BLOCKS 24
49#define SIZE_OF_BLOCK 0x00004000
50#define NUMBER_OF_BLOCK_PER_ZONE 1024
51#define SIZE_OF_ZONE (NUMBER_OF_BLOCK_PER_ZONE * SIZE_OF_BLOCK)
52#ifndef CONFIG_MTD_CMDLINE_PARTS
53/*
54 * You can use the following sample of MTD partitions
55 * on the NAND Flash Memory 32MB or more.
56 *
57 * The following figure shows the image of the sample partition on
58 * the 32MB NAND Flash Memory.
59 *
60 * Block No.
61 * 0 +-----------------------------+ ------
62 * | CIS | ^
63 * 24 +-----------------------------+ |
64 * | kernel image | | Zone 0
65 * | | |
66 * +-----------------------------+ |
67 * 1023 | unused area | v
68 * +-----------------------------+ ------
69 * 1024 | JFFS2 | ^
70 * | | |
71 * | | | Zone 1
72 * | | |
73 * | | |
74 * | | v
75 * 2047 +-----------------------------+ ------
76 *
77 */
78static struct mtd_partition partition_info[NUM_PARTITIONS] = {
79 {
80 .name = "RBTX4938 CIS Area",
81 .offset = 0,
82 .size = (NUMBER_OF_CIS_BLOCKS * SIZE_OF_BLOCK),
83 .mask_flags = MTD_WRITEABLE /* This partition is NOT writable */
84 },
85 {
86 .name = "RBTX4938 kernel image",
87 .offset = MTDPART_OFS_APPEND,
88 .size = 8 * 0x00100000, /* 8MB (Depends on size of kernel image) */
89 .mask_flags = MTD_WRITEABLE /* This partition is NOT writable */
90 },
91 {
92 .name = "Root FS (JFFS2)",
93 .offset = (0 + SIZE_OF_ZONE), /* start address of next zone */
94 .size = MTDPART_SIZ_FULL
95 },
96};
97#endif
98
99static void tx4938ndfmc_hwcontrol(struct mtd_info *mtd, int cmd)
100{
101 switch (cmd) {
102 case NAND_CTL_SETCLE:
103 tx4938_ndfmcptr->mcr |= TX4938_NDFMCR_CLE;
104 break;
105 case NAND_CTL_CLRCLE:
106 tx4938_ndfmcptr->mcr &= ~TX4938_NDFMCR_CLE;
107 break;
108 case NAND_CTL_SETALE:
109 tx4938_ndfmcptr->mcr |= TX4938_NDFMCR_ALE;
110 break;
111 case NAND_CTL_CLRALE:
112 tx4938_ndfmcptr->mcr &= ~TX4938_NDFMCR_ALE;
113 break;
114 /* TX4938_NDFMCR_CE bit is 0:high 1:low */
115 case NAND_CTL_SETNCE:
116 tx4938_ndfmcptr->mcr |= TX4938_NDFMCR_CE;
117 break;
118 case NAND_CTL_CLRNCE:
119 tx4938_ndfmcptr->mcr &= ~TX4938_NDFMCR_CE;
120 break;
121 case NAND_CTL_SETWP:
122 tx4938_ndfmcptr->mcr |= TX4938_NDFMCR_WE;
123 break;
124 case NAND_CTL_CLRWP:
125 tx4938_ndfmcptr->mcr &= ~TX4938_NDFMCR_WE;
126 break;
127 }
128}
129static int tx4938ndfmc_dev_ready(struct mtd_info *mtd)
130{
131 flush_wb();
132 return !(tx4938_ndfmcptr->sr & TX4938_NDFSR_BUSY);
133}
134static void tx4938ndfmc_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
135{
136 u32 mcr = tx4938_ndfmcptr->mcr;
137 mcr &= ~TX4938_NDFMCR_ECC_ALL;
138 tx4938_ndfmcptr->mcr = mcr | TX4938_NDFMCR_ECC_OFF;
139 tx4938_ndfmcptr->mcr = mcr | TX4938_NDFMCR_ECC_READ;
140 ecc_code[1] = tx4938_ndfmcptr->dtr;
141 ecc_code[0] = tx4938_ndfmcptr->dtr;
142 ecc_code[2] = tx4938_ndfmcptr->dtr;
143 tx4938_ndfmcptr->mcr = mcr | TX4938_NDFMCR_ECC_OFF;
144}
145static void tx4938ndfmc_enable_hwecc(struct mtd_info *mtd, int mode)
146{
147 u32 mcr = tx4938_ndfmcptr->mcr;
148 mcr &= ~TX4938_NDFMCR_ECC_ALL;
149 tx4938_ndfmcptr->mcr = mcr | TX4938_NDFMCR_ECC_RESET;
150 tx4938_ndfmcptr->mcr = mcr | TX4938_NDFMCR_ECC_OFF;
151 tx4938_ndfmcptr->mcr = mcr | TX4938_NDFMCR_ECC_ON;
152}
153
154static u_char tx4938ndfmc_nand_read_byte(struct mtd_info *mtd)
155{
156 struct nand_chip *this = mtd->priv;
157 return tx4938_read_nfmc(this->IO_ADDR_R);
158}
159
160static void tx4938ndfmc_nand_write_byte(struct mtd_info *mtd, u_char byte)
161{
162 struct nand_chip *this = mtd->priv;
163 tx4938_write_nfmc(byte, this->IO_ADDR_W);
164}
165
166static void tx4938ndfmc_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
167{
168 int i;
169 struct nand_chip *this = mtd->priv;
170
171 for (i=0; i<len; i++)
172 tx4938_write_nfmc(buf[i], this->IO_ADDR_W);
173}
174
175static void tx4938ndfmc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
176{
177 int i;
178 struct nand_chip *this = mtd->priv;
179
180 for (i=0; i<len; i++)
181 buf[i] = tx4938_read_nfmc(this->IO_ADDR_R);
182}
183
184static int tx4938ndfmc_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
185{
186 int i;
187 struct nand_chip *this = mtd->priv;
188
189 for (i=0; i<len; i++)
190 if (buf[i] != tx4938_read_nfmc(this->IO_ADDR_R))
191 return -EFAULT;
192
193 return 0;
194}
195
196/*
197 * Send command to NAND device
198 */
199static void tx4938ndfmc_nand_command (struct mtd_info *mtd, unsigned command, int column, int page_addr)
200{
201 register struct nand_chip *this = mtd->priv;
202
203 /* Begin command latch cycle */
204 this->hwcontrol(mtd, NAND_CTL_SETCLE);
205 /*
206 * Write out the command to the device.
207 */
208 if (command == NAND_CMD_SEQIN) {
209 int readcmd;
210
211 if (column >= mtd->oobblock) {
212 /* OOB area */
213 column -= mtd->oobblock;
214 readcmd = NAND_CMD_READOOB;
215 } else if (column < 256) {
216 /* First 256 bytes --> READ0 */
217 readcmd = NAND_CMD_READ0;
218 } else {
219 column -= 256;
220 readcmd = NAND_CMD_READ1;
221 }
222 this->write_byte(mtd, readcmd);
223 }
224 this->write_byte(mtd, command);
225
226 /* Set ALE and clear CLE to start address cycle */
227 this->hwcontrol(mtd, NAND_CTL_CLRCLE);
228
229 if (column != -1 || page_addr != -1) {
230 this->hwcontrol(mtd, NAND_CTL_SETALE);
231
232 /* Serially input address */
233 if (column != -1)
234 this->write_byte(mtd, column);
235 if (page_addr != -1) {
236 this->write_byte(mtd, (unsigned char) (page_addr & 0xff));
237 this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff));
238 /* One more address cycle for higher density devices */
239 if (mtd->size & 0x0c000000)
240 this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0x0f));
241 }
242 /* Latch in address */
243 this->hwcontrol(mtd, NAND_CTL_CLRALE);
244 }
245
246 /*
247 * program and erase have their own busy handlers
248 * status and sequential in needs no delay
249 */
250 switch (command) {
251
252 case NAND_CMD_PAGEPROG:
253 /* Turn off WE */
254 this->hwcontrol (mtd, NAND_CTL_CLRWP);
255 return;
256
257 case NAND_CMD_SEQIN:
258 /* Turn on WE */
259 this->hwcontrol (mtd, NAND_CTL_SETWP);
260 return;
261
262 case NAND_CMD_ERASE1:
263 case NAND_CMD_ERASE2:
264 case NAND_CMD_STATUS:
265 return;
266
267 case NAND_CMD_RESET:
268 if (this->dev_ready)
269 break;
270 this->hwcontrol(mtd, NAND_CTL_SETCLE);
271 this->write_byte(mtd, NAND_CMD_STATUS);
272 this->hwcontrol(mtd, NAND_CTL_CLRCLE);
273 while ( !(this->read_byte(mtd) & 0x40));
274 return;
275
276 /* This applies to read commands */
277 default:
278 /*
279 * If we don't have access to the busy pin, we apply the given
280 * command delay
281 */
282 if (!this->dev_ready) {
283 udelay (this->chip_delay);
284 return;
285 }
286 }
287
288 /* wait until command is processed */
289 while (!this->dev_ready(mtd));
290}
291
292#ifdef CONFIG_MTD_CMDLINE_PARTS
293extern int parse_cmdline_partitions(struct mtd_info *master, struct mtd_partition **pparts, char *);
294#endif
295/*
296 * Main initialization routine
297 */
298int __init tx4938ndfmc_init (void)
299{
300 struct nand_chip *this;
301 int bsprt = 0, hold = 0xf, spw = 0xf;
302 int protected = 0;
303
304 if ((*rbtx4938_piosel_ptr & 0x0c) != 0x08) {
305 printk("TX4938 NDFMC: disabled by IOC PIOSEL\n");
306 return -ENODEV;
307 }
308 bsprt = 1;
309 hold = 2;
310 spw = 9 - 1; /* 8 GBUSCLK = 80ns (@ GBUSCLK 100MHz) */
311
312 if ((tx4938_ccfgptr->pcfg &
313 (TX4938_PCFG_ATA_SEL|TX4938_PCFG_ISA_SEL|TX4938_PCFG_NDF_SEL))
314 != TX4938_PCFG_NDF_SEL) {
315 printk("TX4938 NDFMC: disabled by PCFG.\n");
316 return -ENODEV;
317 }
318
319 /* reset NDFMC */
320 tx4938_ndfmcptr->rstr |= TX4938_NDFRSTR_RST;
321 while (tx4938_ndfmcptr->rstr & TX4938_NDFRSTR_RST)
322 ;
323 /* setup BusSeparete, Hold Time, Strobe Pulse Width */
324 tx4938_ndfmcptr->mcr = bsprt ? TX4938_NDFMCR_BSPRT : 0;
325 tx4938_ndfmcptr->spr = hold << 4 | spw;
326
327 /* Allocate memory for MTD device structure and private data */
328 tx4938ndfmc_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip),
329 GFP_KERNEL);
330 if (!tx4938ndfmc_mtd) {
331 printk ("Unable to allocate TX4938 NDFMC MTD device structure.\n");
332 return -ENOMEM;
333 }
334
335 /* Get pointer to private data */
336 this = (struct nand_chip *) (&tx4938ndfmc_mtd[1]);
337
338 /* Initialize structures */
339 memset((char *) tx4938ndfmc_mtd, 0, sizeof(struct mtd_info));
340 memset((char *) this, 0, sizeof(struct nand_chip));
341
342 /* Link the private data with the MTD structure */
343 tx4938ndfmc_mtd->priv = this;
344
345 /* Set address of NAND IO lines */
346 this->IO_ADDR_R = (unsigned long)&tx4938_ndfmcptr->dtr;
347 this->IO_ADDR_W = (unsigned long)&tx4938_ndfmcptr->dtr;
348 this->hwcontrol = tx4938ndfmc_hwcontrol;
349 this->dev_ready = tx4938ndfmc_dev_ready;
350 this->calculate_ecc = tx4938ndfmc_calculate_ecc;
351 this->correct_data = nand_correct_data;
352 this->enable_hwecc = tx4938ndfmc_enable_hwecc;
353 this->eccmode = NAND_ECC_HW3_256;
354 this->chip_delay = 100;
355 this->read_byte = tx4938ndfmc_nand_read_byte;
356 this->write_byte = tx4938ndfmc_nand_write_byte;
357 this->cmdfunc = tx4938ndfmc_nand_command;
358 this->write_buf = tx4938ndfmc_nand_write_buf;
359 this->read_buf = tx4938ndfmc_nand_read_buf;
360 this->verify_buf = tx4938ndfmc_nand_verify_buf;
361
362 /* Scan to find existance of the device */
363 if (nand_scan (tx4938ndfmc_mtd, 1)) {
364 kfree (tx4938ndfmc_mtd);
365 return -ENXIO;
366 }
367
368 if (protected) {
369 printk(KERN_INFO "TX4938 NDFMC: write protected.\n");
370 tx4938ndfmc_mtd->flags &= ~(MTD_WRITEABLE | MTD_ERASEABLE);
371 }
372
373#ifdef CONFIG_MTD_CMDLINE_PARTS
374 {
375 int mtd_parts_nb = 0;
376 struct mtd_partition *mtd_parts = 0;
377 mtd_parts_nb = parse_cmdline_partitions(tx4938ndfmc_mtd, &mtd_parts, "tx4938ndfmc");
378 if (mtd_parts_nb > 0)
379 add_mtd_partitions(tx4938ndfmc_mtd, mtd_parts, mtd_parts_nb);
380 else
381 add_mtd_device(tx4938ndfmc_mtd);
382 }
383#else
384 add_mtd_partitions(tx4938ndfmc_mtd, partition_info, NUM_PARTITIONS );
385#endif
386
387 return 0;
388}
389module_init(tx4938ndfmc_init);
390
391/*
392 * Clean up routine
393 */
394static void __exit tx4938ndfmc_cleanup (void)
395{
396 /* Release resources, unregister device */
397 nand_release (tx4938ndfmc_mtd);
398
399 /* Free the MTD device structure */
400 kfree (tx4938ndfmc_mtd);
401}
402module_exit(tx4938ndfmc_cleanup);
403
404MODULE_LICENSE("GPL");
405MODULE_AUTHOR("Alice Hennessy <ahennessy@mvista.com>");
406MODULE_DESCRIPTION("Board-specific glue layer for NAND flash on TX4938 NDFMC");
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 2b55687f6ee9..9a07ff7a7777 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -3,6 +3,8 @@
3# Network device configuration 3# Network device configuration
4# 4#
5 5
6menu "Network device support"
7
6config NETDEVICES 8config NETDEVICES
7 depends on NET 9 depends on NET
8 bool "Network device support" 10 bool "Network device support"
@@ -2547,3 +2549,4 @@ config NETCONSOLE
2547 If you want to log kernel messages over the network, enable this. 2549 If you want to log kernel messages over the network, enable this.
2548 See <file:Documentation/networking/netconsole.txt> for details. 2550 See <file:Documentation/networking/netconsole.txt> for details.
2549 2551
2552endmenu
diff --git a/drivers/net/appletalk/Kconfig b/drivers/net/appletalk/Kconfig
index 69c488d933a2..b14e89004c3a 100644
--- a/drivers/net/appletalk/Kconfig
+++ b/drivers/net/appletalk/Kconfig
@@ -1,6 +1,33 @@
1# 1#
2# Appletalk driver configuration 2# Appletalk driver configuration
3# 3#
4config ATALK
5 tristate "Appletalk protocol support"
6 select LLC
7 ---help---
8 AppleTalk is the protocol that Apple computers can use to communicate
9 on a network. If your Linux box is connected to such a network and you
10 wish to connect to it, say Y. You will need to use the netatalk package
11 so that your Linux box can act as a print and file server for Macs as
12 well as access AppleTalk printers. Check out
13 <http://www.zettabyte.net/netatalk/> on the WWW for details.
14 EtherTalk is the name used for AppleTalk over Ethernet and the
15 cheaper and slower LocalTalk is AppleTalk over a proprietary Apple
16 network using serial links. EtherTalk and LocalTalk are fully
17 supported by Linux.
18
19 General information about how to connect Linux, Windows machines and
20 Macs is on the WWW at <http://www.eats.com/linux_mac_win.html>. The
21 NET-3-HOWTO, available from
22 <http://www.tldp.org/docs.html#howto>, contains valuable
23 information as well.
24
25 To compile this driver as a module, choose M here: the module will be
26 called appletalk. You almost certainly want to compile it as a
27 module so you can restart your AppleTalk stack without rebooting
28 your machine. I hear that the GNU boycott of Apple is over, so
29 even politically correct people are allowed to say Y here.
30
4config DEV_APPLETALK 31config DEV_APPLETALK
5 bool "Appletalk interfaces support" 32 bool "Appletalk interfaces support"
6 depends on ATALK 33 depends on ATALK
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index f1bd45e3da31..94939f570f78 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -1930,6 +1930,7 @@ static int b44_suspend(struct pci_dev *pdev, pm_message_t state)
1930 b44_free_rings(bp); 1930 b44_free_rings(bp);
1931 1931
1932 spin_unlock_irq(&bp->lock); 1932 spin_unlock_irq(&bp->lock);
1933 pci_disable_device(pdev);
1933 return 0; 1934 return 0;
1934} 1935}
1935 1936
@@ -1939,6 +1940,8 @@ static int b44_resume(struct pci_dev *pdev)
1939 struct b44 *bp = netdev_priv(dev); 1940 struct b44 *bp = netdev_priv(dev);
1940 1941
1941 pci_restore_state(pdev); 1942 pci_restore_state(pdev);
1943 pci_enable_device(pdev);
1944 pci_set_master(pdev);
1942 1945
1943 if (!netif_running(dev)) 1946 if (!netif_running(dev))
1944 return 0; 1947 return 0;
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index 00e5257b176f..8dc657fc8afb 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -1261,7 +1261,7 @@ static void bmac_reset_and_enable(struct net_device *dev)
1261 spin_unlock_irqrestore(&bp->lock, flags); 1261 spin_unlock_irqrestore(&bp->lock, flags);
1262} 1262}
1263 1263
1264static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_match *match) 1264static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_id *match)
1265{ 1265{
1266 int j, rev, ret; 1266 int j, rev, ret;
1267 struct bmac_data *bp; 1267 struct bmac_data *bp;
@@ -1645,16 +1645,13 @@ static int __devexit bmac_remove(struct macio_dev *mdev)
1645 return 0; 1645 return 0;
1646} 1646}
1647 1647
1648static struct of_match bmac_match[] = 1648static struct of_device_id bmac_match[] =
1649{ 1649{
1650 { 1650 {
1651 .name = "bmac", 1651 .name = "bmac",
1652 .type = OF_ANY_MATCH,
1653 .compatible = OF_ANY_MATCH,
1654 .data = (void *)0, 1652 .data = (void *)0,
1655 }, 1653 },
1656 { 1654 {
1657 .name = OF_ANY_MATCH,
1658 .type = "network", 1655 .type = "network",
1659 .compatible = "bmac+", 1656 .compatible = "bmac+",
1660 .data = (void *)1, 1657 .data = (void *)1,
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index ece1b1a13186..c27e417f32bf 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -304,7 +304,7 @@ static inline void scc_discard_buffers(struct scc_channel *scc)
304 scc->tx_buff = NULL; 304 scc->tx_buff = NULL;
305 } 305 }
306 306
307 while (skb_queue_len(&scc->tx_queue)) 307 while (!skb_queue_empty(&scc->tx_queue))
308 dev_kfree_skb(skb_dequeue(&scc->tx_queue)); 308 dev_kfree_skb(skb_dequeue(&scc->tx_queue));
309 309
310 spin_unlock_irqrestore(&scc->lock, flags); 310 spin_unlock_irqrestore(&scc->lock, flags);
@@ -1126,8 +1126,7 @@ static void t_dwait(unsigned long channel)
1126 1126
1127 if (scc->stat.tx_state == TXS_WAIT) /* maxkeyup or idle timeout */ 1127 if (scc->stat.tx_state == TXS_WAIT) /* maxkeyup or idle timeout */
1128 { 1128 {
1129 if (skb_queue_len(&scc->tx_queue) == 0) /* nothing to send */ 1129 if (skb_queue_empty(&scc->tx_queue)) { /* nothing to send */
1130 {
1131 scc->stat.tx_state = TXS_IDLE; 1130 scc->stat.tx_state = TXS_IDLE;
1132 netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */ 1131 netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */
1133 return; 1132 return;
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index 6ed2d7dbd44c..81d0a26e4f41 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -109,7 +109,7 @@ bitrev(int b)
109} 109}
110 110
111 111
112static int __devinit mace_probe(struct macio_dev *mdev, const struct of_match *match) 112static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_id *match)
113{ 113{
114 struct device_node *mace = macio_get_of_node(mdev); 114 struct device_node *mace = macio_get_of_node(mdev);
115 struct net_device *dev; 115 struct net_device *dev;
@@ -1009,12 +1009,10 @@ static irqreturn_t mace_rxdma_intr(int irq, void *dev_id, struct pt_regs *regs)
1009 return IRQ_HANDLED; 1009 return IRQ_HANDLED;
1010} 1010}
1011 1011
1012static struct of_match mace_match[] = 1012static struct of_device_id mace_match[] =
1013{ 1013{
1014 { 1014 {
1015 .name = "mace", 1015 .name = "mace",
1016 .type = OF_ANY_MATCH,
1017 .compatible = OF_ANY_MATCH
1018 }, 1016 },
1019 {}, 1017 {},
1020}; 1018};
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index aad5494c83cf..f0996ce5c268 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -369,7 +369,7 @@ static void myri_tx(struct myri_eth *mp, struct net_device *dev)
369 * assume 802.3 if the type field is short enough to be a length. 369 * assume 802.3 if the type field is short enough to be a length.
370 * This is normal practice and works for any 'now in use' protocol. 370 * This is normal practice and works for any 'now in use' protocol.
371 */ 371 */
372static unsigned short myri_type_trans(struct sk_buff *skb, struct net_device *dev) 372static __be16 myri_type_trans(struct sk_buff *skb, struct net_device *dev)
373{ 373{
374 struct ethhdr *eth; 374 struct ethhdr *eth;
375 unsigned char *rawp; 375 unsigned char *rawp;
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index a1a6c08e7dcf..f1c01ac29102 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -660,6 +660,7 @@ static int ne2k_pci_suspend (struct pci_dev *pdev, pm_message_t state)
660 660
661 netif_device_detach(dev); 661 netif_device_detach(dev);
662 pci_save_state(pdev); 662 pci_save_state(pdev);
663 pci_disable_device(pdev);
663 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 664 pci_set_power_state(pdev, pci_choose_state(pdev, state));
664 665
665 return 0; 666 return 0;
@@ -671,6 +672,8 @@ static int ne2k_pci_resume (struct pci_dev *pdev)
671 672
672 pci_set_power_state(pdev, 0); 673 pci_set_power_state(pdev, 0);
673 pci_restore_state(pdev); 674 pci_restore_state(pdev);
675 pci_enable_device(pdev);
676 pci_set_master(pdev);
674 NS8390_init(dev, 1); 677 NS8390_init(dev, 1);
675 netif_device_attach(dev); 678 netif_device_attach(dev);
676 679
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index f0fc04bd37c4..71fd41122c91 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -86,7 +86,6 @@ earlier 3Com products.
86#include <linux/ethtool.h> 86#include <linux/ethtool.h>
87#include <linux/bitops.h> 87#include <linux/bitops.h>
88 88
89#include <pcmcia/version.h>
90#include <pcmcia/cs_types.h> 89#include <pcmcia/cs_types.h>
91#include <pcmcia/cs.h> 90#include <pcmcia/cs.h>
92#include <pcmcia/cistpl.h> 91#include <pcmcia/cistpl.h>
@@ -312,11 +311,6 @@ static dev_link_t *tc574_attach(void)
312 link->next = dev_list; 311 link->next = dev_list;
313 dev_list = link; 312 dev_list = link;
314 client_reg.dev_info = &dev_info; 313 client_reg.dev_info = &dev_info;
315 client_reg.EventMask =
316 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
317 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
318 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
319 client_reg.event_handler = &tc574_event;
320 client_reg.Version = 0x0210; 314 client_reg.Version = 0x0210;
321 client_reg.event_callback_args.client_data = link; 315 client_reg.event_callback_args.client_data = link;
322 ret = pcmcia_register_client(&link->handle, &client_reg); 316 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1299,6 +1293,7 @@ static struct pcmcia_driver tc574_driver = {
1299 .name = "3c574_cs", 1293 .name = "3c574_cs",
1300 }, 1294 },
1301 .attach = tc574_attach, 1295 .attach = tc574_attach,
1296 .event = tc574_event,
1302 .detach = tc574_detach, 1297 .detach = tc574_detach,
1303 .id_table = tc574_ids, 1298 .id_table = tc574_ids,
1304}; 1299};
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 8fa1b5f0fb68..d83fdd8c1943 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -40,7 +40,6 @@
40#include <linux/ioport.h> 40#include <linux/ioport.h>
41#include <linux/bitops.h> 41#include <linux/bitops.h>
42 42
43#include <pcmcia/version.h>
44#include <pcmcia/cs_types.h> 43#include <pcmcia/cs_types.h>
45#include <pcmcia/cs.h> 44#include <pcmcia/cs.h>
46#include <pcmcia/cistpl.h> 45#include <pcmcia/cistpl.h>
@@ -226,11 +225,6 @@ static dev_link_t *tc589_attach(void)
226 link->next = dev_list; 225 link->next = dev_list;
227 dev_list = link; 226 dev_list = link;
228 client_reg.dev_info = &dev_info; 227 client_reg.dev_info = &dev_info;
229 client_reg.EventMask =
230 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
231 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
232 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
233 client_reg.event_handler = &tc589_event;
234 client_reg.Version = 0x0210; 228 client_reg.Version = 0x0210;
235 client_reg.event_callback_args.client_data = link; 229 client_reg.event_callback_args.client_data = link;
236 ret = pcmcia_register_client(&link->handle, &client_reg); 230 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1074,6 +1068,7 @@ static struct pcmcia_driver tc589_driver = {
1074 .name = "3c589_cs", 1068 .name = "3c589_cs",
1075 }, 1069 },
1076 .attach = tc589_attach, 1070 .attach = tc589_attach,
1071 .event = tc589_event,
1077 .detach = tc589_detach, 1072 .detach = tc589_detach,
1078 .id_table = tc589_ids, 1073 .id_table = tc589_ids,
1079}; 1074};
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 23ce77b1d5b0..8bb4e85689ea 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -37,7 +37,6 @@
37#include <linux/netdevice.h> 37#include <linux/netdevice.h>
38#include "../8390.h" 38#include "../8390.h"
39 39
40#include <pcmcia/version.h>
41#include <pcmcia/cs_types.h> 40#include <pcmcia/cs_types.h>
42#include <pcmcia/cs.h> 41#include <pcmcia/cs.h>
43#include <pcmcia/cistpl.h> 42#include <pcmcia/cistpl.h>
@@ -181,11 +180,6 @@ static dev_link_t *axnet_attach(void)
181 link->next = dev_list; 180 link->next = dev_list;
182 dev_list = link; 181 dev_list = link;
183 client_reg.dev_info = &dev_info; 182 client_reg.dev_info = &dev_info;
184 client_reg.EventMask =
185 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
186 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
187 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
188 client_reg.event_handler = &axnet_event;
189 client_reg.Version = 0x0210; 183 client_reg.Version = 0x0210;
190 client_reg.event_callback_args.client_data = link; 184 client_reg.event_callback_args.client_data = link;
191 ret = pcmcia_register_client(&link->handle, &client_reg); 185 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -884,6 +878,7 @@ static struct pcmcia_driver axnet_cs_driver = {
884 .name = "axnet_cs", 878 .name = "axnet_cs",
885 }, 879 },
886 .attach = axnet_attach, 880 .attach = axnet_attach,
881 .event = axnet_event,
887 .detach = axnet_detach, 882 .detach = axnet_detach,
888 .id_table = axnet_ids, 883 .id_table = axnet_ids,
889}; 884};
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 68d58cc58d31..b9355d9498a3 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -43,7 +43,6 @@
43#include <linux/arcdevice.h> 43#include <linux/arcdevice.h>
44#include <linux/com20020.h> 44#include <linux/com20020.h>
45 45
46#include <pcmcia/version.h>
47#include <pcmcia/cs_types.h> 46#include <pcmcia/cs_types.h>
48#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
@@ -200,11 +199,6 @@ static dev_link_t *com20020_attach(void)
200 link->next = dev_list; 199 link->next = dev_list;
201 dev_list = link; 200 dev_list = link;
202 client_reg.dev_info = &dev_info; 201 client_reg.dev_info = &dev_info;
203 client_reg.EventMask =
204 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
205 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
206 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
207 client_reg.event_handler = &com20020_event;
208 client_reg.Version = 0x0210; 202 client_reg.Version = 0x0210;
209 client_reg.event_callback_args.client_data = link; 203 client_reg.event_callback_args.client_data = link;
210 ret = pcmcia_register_client(&link->handle, &client_reg); 204 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -495,6 +489,7 @@ static struct pcmcia_driver com20020_cs_driver = {
495 .name = "com20020_cs", 489 .name = "com20020_cs",
496 }, 490 },
497 .attach = com20020_attach, 491 .attach = com20020_attach,
492 .event = com20020_event,
498 .detach = com20020_detach, 493 .detach = com20020_detach,
499 .id_table = com20020_ids, 494 .id_table = com20020_ids,
500}; 495};
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 917adbbf0b5b..9d8197bb293a 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -49,7 +49,6 @@
49#include <linux/ioport.h> 49#include <linux/ioport.h>
50#include <linux/crc32.h> 50#include <linux/crc32.h>
51 51
52#include <pcmcia/version.h>
53#include <pcmcia/cs_types.h> 52#include <pcmcia/cs_types.h>
54#include <pcmcia/cs.h> 53#include <pcmcia/cs.h>
55#include <pcmcia/cistpl.h> 54#include <pcmcia/cistpl.h>
@@ -288,11 +287,6 @@ static dev_link_t *fmvj18x_attach(void)
288 link->next = dev_list; 287 link->next = dev_list;
289 dev_list = link; 288 dev_list = link;
290 client_reg.dev_info = &dev_info; 289 client_reg.dev_info = &dev_info;
291 client_reg.EventMask =
292 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
293 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
294 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
295 client_reg.event_handler = &fmvj18x_event;
296 client_reg.Version = 0x0210; 290 client_reg.Version = 0x0210;
297 client_reg.event_callback_args.client_data = link; 291 client_reg.event_callback_args.client_data = link;
298 ret = pcmcia_register_client(&link->handle, &client_reg); 292 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -797,6 +791,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = {
797 .name = "fmvj18x_cs", 791 .name = "fmvj18x_cs",
798 }, 792 },
799 .attach = fmvj18x_attach, 793 .attach = fmvj18x_attach,
794 .event = fmvj18x_event,
800 .detach = fmvj18x_detach, 795 .detach = fmvj18x_detach,
801 .id_table = fmvj18x_ids, 796 .id_table = fmvj18x_ids,
802}; 797};
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index cf6d073ea558..b6c140eb9799 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -57,7 +57,6 @@
57#include <linux/trdevice.h> 57#include <linux/trdevice.h>
58#include <linux/ibmtr.h> 58#include <linux/ibmtr.h>
59 59
60#include <pcmcia/version.h>
61#include <pcmcia/cs_types.h> 60#include <pcmcia/cs_types.h>
62#include <pcmcia/cs.h> 61#include <pcmcia/cs.h>
63#include <pcmcia/cistpl.h> 62#include <pcmcia/cistpl.h>
@@ -190,11 +189,6 @@ static dev_link_t *ibmtr_attach(void)
190 link->next = dev_list; 189 link->next = dev_list;
191 dev_list = link; 190 dev_list = link;
192 client_reg.dev_info = &dev_info; 191 client_reg.dev_info = &dev_info;
193 client_reg.EventMask =
194 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
195 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
196 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
197 client_reg.event_handler = &ibmtr_event;
198 client_reg.Version = 0x0210; 192 client_reg.Version = 0x0210;
199 client_reg.event_callback_args.client_data = link; 193 client_reg.event_callback_args.client_data = link;
200 ret = pcmcia_register_client(&link->handle, &client_reg); 194 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -521,6 +515,7 @@ static struct pcmcia_driver ibmtr_cs_driver = {
521 .name = "ibmtr_cs", 515 .name = "ibmtr_cs",
522 }, 516 },
523 .attach = ibmtr_attach, 517 .attach = ibmtr_attach,
518 .event = ibmtr_event,
524 .detach = ibmtr_detach, 519 .detach = ibmtr_detach,
525 .id_table = ibmtr_ids, 520 .id_table = ibmtr_ids,
526}; 521};
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index b86e7253fbfc..dbb941004ae9 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -146,7 +146,6 @@ Include Files
146#include <linux/ioport.h> 146#include <linux/ioport.h>
147#include <linux/bitops.h> 147#include <linux/bitops.h>
148 148
149#include <pcmcia/version.h>
150#include <pcmcia/cs_types.h> 149#include <pcmcia/cs_types.h>
151#include <pcmcia/cs.h> 150#include <pcmcia/cs.h>
152#include <pcmcia/cisreg.h> 151#include <pcmcia/cisreg.h>
@@ -502,11 +501,6 @@ static dev_link_t *nmclan_attach(void)
502 link->next = dev_list; 501 link->next = dev_list;
503 dev_list = link; 502 dev_list = link;
504 client_reg.dev_info = &dev_info; 503 client_reg.dev_info = &dev_info;
505 client_reg.EventMask =
506 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
507 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
508 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
509 client_reg.event_handler = &nmclan_event;
510 client_reg.Version = 0x0210; 504 client_reg.Version = 0x0210;
511 client_reg.event_callback_args.client_data = link; 505 client_reg.event_callback_args.client_data = link;
512 ret = pcmcia_register_client(&link->handle, &client_reg); 506 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1688,6 +1682,7 @@ static struct pcmcia_driver nmclan_cs_driver = {
1688 .name = "nmclan_cs", 1682 .name = "nmclan_cs",
1689 }, 1683 },
1690 .attach = nmclan_attach, 1684 .attach = nmclan_attach,
1685 .event = nmclan_event,
1691 .detach = nmclan_detach, 1686 .detach = nmclan_detach,
1692 .id_table = nmclan_ids, 1687 .id_table = nmclan_ids,
1693}; 1688};
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 855a45d062b1..e1664aef3dfd 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -40,7 +40,6 @@
40#include <linux/netdevice.h> 40#include <linux/netdevice.h>
41#include <../drivers/net/8390.h> 41#include <../drivers/net/8390.h>
42 42
43#include <pcmcia/version.h>
44#include <pcmcia/cs_types.h> 43#include <pcmcia/cs_types.h>
45#include <pcmcia/cs.h> 44#include <pcmcia/cs.h>
46#include <pcmcia/cistpl.h> 45#include <pcmcia/cistpl.h>
@@ -276,11 +275,6 @@ static dev_link_t *pcnet_attach(void)
276 link->next = dev_list; 275 link->next = dev_list;
277 dev_list = link; 276 dev_list = link;
278 client_reg.dev_info = &dev_info; 277 client_reg.dev_info = &dev_info;
279 client_reg.EventMask =
280 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
281 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
282 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
283 client_reg.event_handler = &pcnet_event;
284 client_reg.Version = 0x0210; 278 client_reg.Version = 0x0210;
285 client_reg.event_callback_args.client_data = link; 279 client_reg.event_callback_args.client_data = link;
286 ret = pcmcia_register_client(&link->handle, &client_reg); 280 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1844,6 +1838,7 @@ static struct pcmcia_driver pcnet_driver = {
1844 .name = "pcnet_cs", 1838 .name = "pcnet_cs",
1845 }, 1839 },
1846 .attach = pcnet_attach, 1840 .attach = pcnet_attach,
1841 .event = pcnet_event,
1847 .detach = pcnet_detach, 1842 .detach = pcnet_detach,
1848 .owner = THIS_MODULE, 1843 .owner = THIS_MODULE,
1849 .id_table = pcnet_ids, 1844 .id_table = pcnet_ids,
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index bc01c88c6709..fbc2f58ff688 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -42,7 +42,6 @@
42#include <linux/ethtool.h> 42#include <linux/ethtool.h>
43#include <linux/mii.h> 43#include <linux/mii.h>
44 44
45#include <pcmcia/version.h>
46#include <pcmcia/cs_types.h> 45#include <pcmcia/cs_types.h>
47#include <pcmcia/cs.h> 46#include <pcmcia/cs.h>
48#include <pcmcia/cistpl.h> 47#include <pcmcia/cistpl.h>
@@ -370,10 +369,6 @@ static dev_link_t *smc91c92_attach(void)
370 link->next = dev_list; 369 link->next = dev_list;
371 dev_list = link; 370 dev_list = link;
372 client_reg.dev_info = &dev_info; 371 client_reg.dev_info = &dev_info;
373 client_reg.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
374 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
375 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
376 client_reg.event_handler = &smc91c92_event;
377 client_reg.Version = 0x0210; 372 client_reg.Version = 0x0210;
378 client_reg.event_callback_args.client_data = link; 373 client_reg.event_callback_args.client_data = link;
379 ret = pcmcia_register_client(&link->handle, &client_reg); 374 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -2365,6 +2360,7 @@ static struct pcmcia_driver smc91c92_cs_driver = {
2365 .name = "smc91c92_cs", 2360 .name = "smc91c92_cs",
2366 }, 2361 },
2367 .attach = smc91c92_attach, 2362 .attach = smc91c92_attach,
2363 .event = smc91c92_event,
2368 .detach = smc91c92_detach, 2364 .detach = smc91c92_detach,
2369 .id_table = smc91c92_ids, 2365 .id_table = smc91c92_ids,
2370}; 2366};
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 0cd225e1595c..9f33bad174e9 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -81,7 +81,6 @@
81#include <linux/ioport.h> 81#include <linux/ioport.h>
82#include <linux/bitops.h> 82#include <linux/bitops.h>
83 83
84#include <pcmcia/version.h>
85#include <pcmcia/cs_types.h> 84#include <pcmcia/cs_types.h>
86#include <pcmcia/cs.h> 85#include <pcmcia/cs.h>
87#include <pcmcia/cistpl.h> 86#include <pcmcia/cistpl.h>
@@ -619,11 +618,6 @@ xirc2ps_attach(void)
619 link->next = dev_list; 618 link->next = dev_list;
620 dev_list = link; 619 dev_list = link;
621 client_reg.dev_info = &dev_info; 620 client_reg.dev_info = &dev_info;
622 client_reg.EventMask =
623 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
624 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
625 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
626 client_reg.event_handler = &xirc2ps_event;
627 client_reg.Version = 0x0210; 621 client_reg.Version = 0x0210;
628 client_reg.event_callback_args.client_data = link; 622 client_reg.event_callback_args.client_data = link;
629 if ((err = pcmcia_register_client(&link->handle, &client_reg))) { 623 if ((err = pcmcia_register_client(&link->handle, &client_reg))) {
@@ -2016,6 +2010,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = {
2016 .name = "xirc2ps_cs", 2010 .name = "xirc2ps_cs",
2017 }, 2011 },
2018 .attach = xirc2ps_attach, 2012 .attach = xirc2ps_attach,
2013 .event = xirc2ps_event,
2019 .detach = xirc2ps_detach, 2014 .detach = xirc2ps_detach,
2020 .id_table = xirc2ps_ids, 2015 .id_table = xirc2ps_ids,
2021}; 2016};
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index f4b62405d2e5..21537ee3a6a7 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -540,7 +540,7 @@ plip_receive(unsigned short nibble_timeout, struct net_device *dev,
540 * in far too many old systems not all even running Linux. 540 * in far too many old systems not all even running Linux.
541 */ 541 */
542 542
543static unsigned short plip_type_trans(struct sk_buff *skb, struct net_device *dev) 543static __be16 plip_type_trans(struct sk_buff *skb, struct net_device *dev)
544{ 544{
545 struct ethhdr *eth; 545 struct ethhdr *eth;
546 unsigned char *rawp; 546 unsigned char *rawp;
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index 5e48b9ab3045..59e8183c639e 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -364,7 +364,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
364 spin_lock_irqsave(&ap->recv_lock, flags); 364 spin_lock_irqsave(&ap->recv_lock, flags);
365 ppp_async_input(ap, buf, cflags, count); 365 ppp_async_input(ap, buf, cflags, count);
366 spin_unlock_irqrestore(&ap->recv_lock, flags); 366 spin_unlock_irqrestore(&ap->recv_lock, flags);
367 if (skb_queue_len(&ap->rqueue)) 367 if (!skb_queue_empty(&ap->rqueue))
368 tasklet_schedule(&ap->tsk); 368 tasklet_schedule(&ap->tsk);
369 ap_put(ap); 369 ap_put(ap);
370 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) 370 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index ab726ab43798..a32668e88e09 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1237,8 +1237,8 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1237 pch = list_entry(list, struct channel, clist); 1237 pch = list_entry(list, struct channel, clist);
1238 navail += pch->avail = (pch->chan != NULL); 1238 navail += pch->avail = (pch->chan != NULL);
1239 if (pch->avail) { 1239 if (pch->avail) {
1240 if (skb_queue_len(&pch->file.xq) == 0 1240 if (skb_queue_empty(&pch->file.xq) ||
1241 || !pch->had_frag) { 1241 !pch->had_frag) {
1242 pch->avail = 2; 1242 pch->avail = 2;
1243 ++nfree; 1243 ++nfree;
1244 } 1244 }
@@ -1374,8 +1374,8 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1374 1374
1375 /* try to send it down the channel */ 1375 /* try to send it down the channel */
1376 chan = pch->chan; 1376 chan = pch->chan;
1377 if (skb_queue_len(&pch->file.xq) 1377 if (!skb_queue_empty(&pch->file.xq) ||
1378 || !chan->ops->start_xmit(chan, frag)) 1378 !chan->ops->start_xmit(chan, frag))
1379 skb_queue_tail(&pch->file.xq, frag); 1379 skb_queue_tail(&pch->file.xq, frag);
1380 pch->had_frag = 1; 1380 pch->had_frag = 1;
1381 p += flen; 1381 p += flen;
@@ -1412,7 +1412,7 @@ ppp_channel_push(struct channel *pch)
1412 1412
1413 spin_lock_bh(&pch->downl); 1413 spin_lock_bh(&pch->downl);
1414 if (pch->chan != 0) { 1414 if (pch->chan != 0) {
1415 while (skb_queue_len(&pch->file.xq) > 0) { 1415 while (!skb_queue_empty(&pch->file.xq)) {
1416 skb = skb_dequeue(&pch->file.xq); 1416 skb = skb_dequeue(&pch->file.xq);
1417 if (!pch->chan->ops->start_xmit(pch->chan, skb)) { 1417 if (!pch->chan->ops->start_xmit(pch->chan, skb)) {
1418 /* put the packet back and try again later */ 1418 /* put the packet back and try again later */
@@ -1426,7 +1426,7 @@ ppp_channel_push(struct channel *pch)
1426 } 1426 }
1427 spin_unlock_bh(&pch->downl); 1427 spin_unlock_bh(&pch->downl);
1428 /* see if there is anything from the attached unit to be sent */ 1428 /* see if there is anything from the attached unit to be sent */
1429 if (skb_queue_len(&pch->file.xq) == 0) { 1429 if (skb_queue_empty(&pch->file.xq)) {
1430 read_lock_bh(&pch->upl); 1430 read_lock_bh(&pch->upl);
1431 ppp = pch->ppp; 1431 ppp = pch->ppp;
1432 if (ppp != 0) 1432 if (ppp != 0)
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
index fd9f50180355..4d51c0c8023d 100644
--- a/drivers/net/ppp_synctty.c
+++ b/drivers/net/ppp_synctty.c
@@ -406,7 +406,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
406 spin_lock_irqsave(&ap->recv_lock, flags); 406 spin_lock_irqsave(&ap->recv_lock, flags);
407 ppp_sync_input(ap, buf, cflags, count); 407 ppp_sync_input(ap, buf, cflags, count);
408 spin_unlock_irqrestore(&ap->recv_lock, flags); 408 spin_unlock_irqrestore(&ap->recv_lock, flags);
409 if (skb_queue_len(&ap->rqueue)) 409 if (!skb_queue_empty(&ap->rqueue))
410 tasklet_schedule(&ap->tsk); 410 tasklet_schedule(&ap->tsk);
411 sp_put(ap); 411 sp_put(ap);
412 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) 412 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c
index 20edeb345792..3ad0b6751f6f 100644
--- a/drivers/net/shaper.c
+++ b/drivers/net/shaper.c
@@ -135,10 +135,8 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
135{ 135{
136 struct shaper *shaper = dev->priv; 136 struct shaper *shaper = dev->priv;
137 struct sk_buff *ptr; 137 struct sk_buff *ptr;
138 138
139 if (down_trylock(&shaper->sem)) 139 spin_lock(&shaper->lock);
140 return -1;
141
142 ptr=shaper->sendq.prev; 140 ptr=shaper->sendq.prev;
143 141
144 /* 142 /*
@@ -232,7 +230,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
232 shaper->stats.collisions++; 230 shaper->stats.collisions++;
233 } 231 }
234 shaper_kick(shaper); 232 shaper_kick(shaper);
235 up(&shaper->sem); 233 spin_unlock(&shaper->lock);
236 return 0; 234 return 0;
237} 235}
238 236
@@ -271,11 +269,9 @@ static void shaper_timer(unsigned long data)
271{ 269{
272 struct shaper *shaper = (struct shaper *)data; 270 struct shaper *shaper = (struct shaper *)data;
273 271
274 if (!down_trylock(&shaper->sem)) { 272 spin_lock(&shaper->lock);
275 shaper_kick(shaper); 273 shaper_kick(shaper);
276 up(&shaper->sem); 274 spin_unlock(&shaper->lock);
277 } else
278 mod_timer(&shaper->timer, jiffies);
279} 275}
280 276
281/* 277/*
@@ -332,21 +328,6 @@ static void shaper_kick(struct shaper *shaper)
332 328
333 329
334/* 330/*
335 * Flush the shaper queues on a closedown
336 */
337
338static void shaper_flush(struct shaper *shaper)
339{
340 struct sk_buff *skb;
341
342 down(&shaper->sem);
343 while((skb=skb_dequeue(&shaper->sendq))!=NULL)
344 dev_kfree_skb(skb);
345 shaper_kick(shaper);
346 up(&shaper->sem);
347}
348
349/*
350 * Bring the interface up. We just disallow this until a 331 * Bring the interface up. We just disallow this until a
351 * bind. 332 * bind.
352 */ 333 */
@@ -375,7 +356,15 @@ static int shaper_open(struct net_device *dev)
375static int shaper_close(struct net_device *dev) 356static int shaper_close(struct net_device *dev)
376{ 357{
377 struct shaper *shaper=dev->priv; 358 struct shaper *shaper=dev->priv;
378 shaper_flush(shaper); 359 struct sk_buff *skb;
360
361 while ((skb = skb_dequeue(&shaper->sendq)) != NULL)
362 dev_kfree_skb(skb);
363
364 spin_lock_bh(&shaper->lock);
365 shaper_kick(shaper);
366 spin_unlock_bh(&shaper->lock);
367
379 del_timer_sync(&shaper->timer); 368 del_timer_sync(&shaper->timer);
380 return 0; 369 return 0;
381} 370}
@@ -576,6 +565,7 @@ static void shaper_init_priv(struct net_device *dev)
576 init_timer(&sh->timer); 565 init_timer(&sh->timer);
577 sh->timer.function=shaper_timer; 566 sh->timer.function=shaper_timer;
578 sh->timer.data=(unsigned long)sh; 567 sh->timer.data=(unsigned long)sh;
568 spin_lock_init(&sh->lock);
579} 569}
580 570
581/* 571/*
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 3dbb1cb09ed8..5cacc7ad9e79 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -3259,7 +3259,7 @@ static void __devexit skge_remove(struct pci_dev *pdev)
3259} 3259}
3260 3260
3261#ifdef CONFIG_PM 3261#ifdef CONFIG_PM
3262static int skge_suspend(struct pci_dev *pdev, u32 state) 3262static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
3263{ 3263{
3264 struct skge_hw *hw = pci_get_drvdata(pdev); 3264 struct skge_hw *hw = pci_get_drvdata(pdev);
3265 int i, wol = 0; 3265 int i, wol = 0;
@@ -3279,7 +3279,7 @@ static int skge_suspend(struct pci_dev *pdev, u32 state)
3279 } 3279 }
3280 3280
3281 pci_save_state(pdev); 3281 pci_save_state(pdev);
3282 pci_enable_wake(pdev, state, wol); 3282 pci_enable_wake(pdev, pci_choose_state(pdev, state), wol);
3283 pci_disable_device(pdev); 3283 pci_disable_device(pdev);
3284 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3284 pci_set_power_state(pdev, pci_choose_state(pdev, state));
3285 3285
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 14d0cc01fb9a..fced3d2bc072 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -7,6 +7,7 @@
7/* PCI config registers */ 7/* PCI config registers */
8#define PCI_DEV_REG1 0x40 8#define PCI_DEV_REG1 0x40
9#define PCI_DEV_REG2 0x44 9#define PCI_DEV_REG2 0x44
10#define PCI_REV_DESC 0x4
10 11
11#define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \ 12#define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \
12 PCI_STATUS_SIG_SYSTEM_ERROR | \ 13 PCI_STATUS_SIG_SYSTEM_ERROR | \
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 1f5655655c40..2608e7a3d214 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -3079,7 +3079,9 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3079 gp->phy_mii.dev = dev; 3079 gp->phy_mii.dev = dev;
3080 gp->phy_mii.mdio_read = _phy_read; 3080 gp->phy_mii.mdio_read = _phy_read;
3081 gp->phy_mii.mdio_write = _phy_write; 3081 gp->phy_mii.mdio_write = _phy_write;
3082 3082#ifdef CONFIG_PPC_PMAC
3083 gp->phy_mii.platform_data = gp->of_node;
3084#endif
3083 /* By default, we start with autoneg */ 3085 /* By default, we start with autoneg */
3084 gp->want_autoneg = 1; 3086 gp->want_autoneg = 1;
3085 3087
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
index 0fca414d3657..d3ddb41d6e5c 100644
--- a/drivers/net/sungem_phy.c
+++ b/drivers/net/sungem_phy.c
@@ -32,6 +32,10 @@
32#include <linux/ethtool.h> 32#include <linux/ethtool.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34 34
35#ifdef CONFIG_PPC_PMAC
36#include <asm/prom.h>
37#endif
38
35#include "sungem_phy.h" 39#include "sungem_phy.h"
36 40
37/* Link modes of the BCM5400 PHY */ 41/* Link modes of the BCM5400 PHY */
@@ -281,10 +285,12 @@ static int bcm5411_suspend(struct mii_phy* phy)
281static int bcm5421_init(struct mii_phy* phy) 285static int bcm5421_init(struct mii_phy* phy)
282{ 286{
283 u16 data; 287 u16 data;
284 int rev; 288 unsigned int id;
285 289
286 rev = phy_read(phy, MII_PHYSID2) & 0x000f; 290 id = (phy_read(phy, MII_PHYSID1) << 16 | phy_read(phy, MII_PHYSID2));
287 if (rev == 0) { 291
292 /* Revision 0 of 5421 needs some fixups */
293 if (id == 0x002060e0) {
288 /* This is borrowed from MacOS 294 /* This is borrowed from MacOS
289 */ 295 */
290 phy_write(phy, 0x18, 0x1007); 296 phy_write(phy, 0x18, 0x1007);
@@ -297,21 +303,28 @@ static int bcm5421_init(struct mii_phy* phy)
297 data = phy_read(phy, 0x15); 303 data = phy_read(phy, 0x15);
298 phy_write(phy, 0x15, data | 0x0200); 304 phy_write(phy, 0x15, data | 0x0200);
299 } 305 }
300#if 0
301 /* This has to be verified before I enable it */
302 /* Enable automatic low-power */
303 phy_write(phy, 0x1c, 0x9002);
304 phy_write(phy, 0x1c, 0xa821);
305 phy_write(phy, 0x1c, 0x941d);
306#endif
307 return 0;
308}
309 306
310static int bcm5421k2_init(struct mii_phy* phy) 307 /* Pick up some init code from OF for K2 version */
311{ 308 if ((id & 0xfffffff0) == 0x002062e0) {
312 /* Init code borrowed from OF */ 309 phy_write(phy, 4, 0x01e1);
313 phy_write(phy, 4, 0x01e1); 310 phy_write(phy, 9, 0x0300);
314 phy_write(phy, 9, 0x0300); 311 }
312
313 /* Check if we can enable automatic low power */
314#ifdef CONFIG_PPC_PMAC
315 if (phy->platform_data) {
316 struct device_node *np = of_get_parent(phy->platform_data);
317 int can_low_power = 1;
318 if (np == NULL || get_property(np, "no-autolowpower", NULL))
319 can_low_power = 0;
320 if (can_low_power) {
321 /* Enable automatic low-power */
322 phy_write(phy, 0x1c, 0x9002);
323 phy_write(phy, 0x1c, 0xa821);
324 phy_write(phy, 0x1c, 0x941d);
325 }
326 }
327#endif /* CONFIG_PPC_PMAC */
315 328
316 return 0; 329 return 0;
317} 330}
@@ -762,7 +775,7 @@ static struct mii_phy_def bcm5421_phy_def = {
762 775
763/* Broadcom BCM 5421 built-in K2 */ 776/* Broadcom BCM 5421 built-in K2 */
764static struct mii_phy_ops bcm5421k2_phy_ops = { 777static struct mii_phy_ops bcm5421k2_phy_ops = {
765 .init = bcm5421k2_init, 778 .init = bcm5421_init,
766 .suspend = bcm5411_suspend, 779 .suspend = bcm5411_suspend,
767 .setup_aneg = bcm54xx_setup_aneg, 780 .setup_aneg = bcm54xx_setup_aneg,
768 .setup_forced = bcm54xx_setup_forced, 781 .setup_forced = bcm54xx_setup_forced,
@@ -779,6 +792,25 @@ static struct mii_phy_def bcm5421k2_phy_def = {
779 .ops = &bcm5421k2_phy_ops 792 .ops = &bcm5421k2_phy_ops
780}; 793};
781 794
795/* Broadcom BCM 5462 built-in Vesta */
796static struct mii_phy_ops bcm5462V_phy_ops = {
797 .init = bcm5421_init,
798 .suspend = bcm5411_suspend,
799 .setup_aneg = bcm54xx_setup_aneg,
800 .setup_forced = bcm54xx_setup_forced,
801 .poll_link = genmii_poll_link,
802 .read_link = bcm54xx_read_link,
803};
804
805static struct mii_phy_def bcm5462V_phy_def = {
806 .phy_id = 0x002060d0,
807 .phy_id_mask = 0xfffffff0,
808 .name = "BCM5462-Vesta",
809 .features = MII_GBIT_FEATURES,
810 .magic_aneg = 1,
811 .ops = &bcm5462V_phy_ops
812};
813
782/* Marvell 88E1101 (Apple seem to deal with 2 different revs, 814/* Marvell 88E1101 (Apple seem to deal with 2 different revs,
783 * I masked out the 8 last bits to get both, but some specs 815 * I masked out the 8 last bits to get both, but some specs
784 * would be useful here) --BenH. 816 * would be useful here) --BenH.
@@ -824,6 +856,7 @@ static struct mii_phy_def* mii_phy_table[] = {
824 &bcm5411_phy_def, 856 &bcm5411_phy_def,
825 &bcm5421_phy_def, 857 &bcm5421_phy_def,
826 &bcm5421k2_phy_def, 858 &bcm5421k2_phy_def,
859 &bcm5462V_phy_def,
827 &marvell_phy_def, 860 &marvell_phy_def,
828 &genmii_phy_def, 861 &genmii_phy_def,
829 NULL 862 NULL
diff --git a/drivers/net/sungem_phy.h b/drivers/net/sungem_phy.h
index 822cb58174ea..430544496c52 100644
--- a/drivers/net/sungem_phy.h
+++ b/drivers/net/sungem_phy.h
@@ -43,9 +43,10 @@ struct mii_phy
43 int pause; 43 int pause;
44 44
45 /* Provided by host chip */ 45 /* Provided by host chip */
46 struct net_device* dev; 46 struct net_device *dev;
47 int (*mdio_read) (struct net_device *dev, int mii_id, int reg); 47 int (*mdio_read) (struct net_device *dev, int mii_id, int reg);
48 void (*mdio_write) (struct net_device *dev, int mii_id, int reg, int val); 48 void (*mdio_write) (struct net_device *dev, int mii_id, int reg, int val);
49 void *platform_data;
49}; 50};
50 51
51/* Pass in a struct mii_phy with dev, mdio_read and mdio_write 52/* Pass in a struct mii_phy with dev, mdio_read and mdio_write
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 7e371b1209a1..54640686e983 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -66,8 +66,8 @@
66 66
67#define DRV_MODULE_NAME "tg3" 67#define DRV_MODULE_NAME "tg3"
68#define PFX DRV_MODULE_NAME ": " 68#define PFX DRV_MODULE_NAME ": "
69#define DRV_MODULE_VERSION "3.32" 69#define DRV_MODULE_VERSION "3.33"
70#define DRV_MODULE_RELDATE "June 24, 2005" 70#define DRV_MODULE_RELDATE "July 5, 2005"
71 71
72#define TG3_DEF_MAC_MODE 0 72#define TG3_DEF_MAC_MODE 0
73#define TG3_DEF_RX_MODE 0 73#define TG3_DEF_RX_MODE 0
@@ -5117,7 +5117,7 @@ static void tg3_set_bdinfo(struct tg3 *tp, u32 bdinfo_addr,
5117} 5117}
5118 5118
5119static void __tg3_set_rx_mode(struct net_device *); 5119static void __tg3_set_rx_mode(struct net_device *);
5120static void tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec) 5120static void __tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec)
5121{ 5121{
5122 tw32(HOSTCC_RXCOL_TICKS, ec->rx_coalesce_usecs); 5122 tw32(HOSTCC_RXCOL_TICKS, ec->rx_coalesce_usecs);
5123 tw32(HOSTCC_TXCOL_TICKS, ec->tx_coalesce_usecs); 5123 tw32(HOSTCC_TXCOL_TICKS, ec->tx_coalesce_usecs);
@@ -5460,7 +5460,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5460 udelay(10); 5460 udelay(10);
5461 } 5461 }
5462 5462
5463 tg3_set_coalesce(tp, &tp->coal); 5463 __tg3_set_coalesce(tp, &tp->coal);
5464 5464
5465 /* set status block DMA address */ 5465 /* set status block DMA address */
5466 tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, 5466 tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
@@ -7821,6 +7821,60 @@ static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
7821 return 0; 7821 return 0;
7822} 7822}
7823 7823
7824static int tg3_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
7825{
7826 struct tg3 *tp = netdev_priv(dev);
7827 u32 max_rxcoal_tick_int = 0, max_txcoal_tick_int = 0;
7828 u32 max_stat_coal_ticks = 0, min_stat_coal_ticks = 0;
7829
7830 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
7831 max_rxcoal_tick_int = MAX_RXCOAL_TICK_INT;
7832 max_txcoal_tick_int = MAX_TXCOAL_TICK_INT;
7833 max_stat_coal_ticks = MAX_STAT_COAL_TICKS;
7834 min_stat_coal_ticks = MIN_STAT_COAL_TICKS;
7835 }
7836
7837 if ((ec->rx_coalesce_usecs > MAX_RXCOL_TICKS) ||
7838 (ec->tx_coalesce_usecs > MAX_TXCOL_TICKS) ||
7839 (ec->rx_max_coalesced_frames > MAX_RXMAX_FRAMES) ||
7840 (ec->tx_max_coalesced_frames > MAX_TXMAX_FRAMES) ||
7841 (ec->rx_coalesce_usecs_irq > max_rxcoal_tick_int) ||
7842 (ec->tx_coalesce_usecs_irq > max_txcoal_tick_int) ||
7843 (ec->rx_max_coalesced_frames_irq > MAX_RXCOAL_MAXF_INT) ||
7844 (ec->tx_max_coalesced_frames_irq > MAX_TXCOAL_MAXF_INT) ||
7845 (ec->stats_block_coalesce_usecs > max_stat_coal_ticks) ||
7846 (ec->stats_block_coalesce_usecs < min_stat_coal_ticks))
7847 return -EINVAL;
7848
7849 /* No rx interrupts will be generated if both are zero */
7850 if ((ec->rx_coalesce_usecs == 0) &&
7851 (ec->rx_max_coalesced_frames == 0))
7852 return -EINVAL;
7853
7854 /* No tx interrupts will be generated if both are zero */
7855 if ((ec->tx_coalesce_usecs == 0) &&
7856 (ec->tx_max_coalesced_frames == 0))
7857 return -EINVAL;
7858
7859 /* Only copy relevant parameters, ignore all others. */
7860 tp->coal.rx_coalesce_usecs = ec->rx_coalesce_usecs;
7861 tp->coal.tx_coalesce_usecs = ec->tx_coalesce_usecs;
7862 tp->coal.rx_max_coalesced_frames = ec->rx_max_coalesced_frames;
7863 tp->coal.tx_max_coalesced_frames = ec->tx_max_coalesced_frames;
7864 tp->coal.rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq;
7865 tp->coal.tx_coalesce_usecs_irq = ec->tx_coalesce_usecs_irq;
7866 tp->coal.rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq;
7867 tp->coal.tx_max_coalesced_frames_irq = ec->tx_max_coalesced_frames_irq;
7868 tp->coal.stats_block_coalesce_usecs = ec->stats_block_coalesce_usecs;
7869
7870 if (netif_running(dev)) {
7871 tg3_full_lock(tp, 0);
7872 __tg3_set_coalesce(tp, &tp->coal);
7873 tg3_full_unlock(tp);
7874 }
7875 return 0;
7876}
7877
7824static struct ethtool_ops tg3_ethtool_ops = { 7878static struct ethtool_ops tg3_ethtool_ops = {
7825 .get_settings = tg3_get_settings, 7879 .get_settings = tg3_get_settings,
7826 .set_settings = tg3_set_settings, 7880 .set_settings = tg3_set_settings,
@@ -7856,6 +7910,7 @@ static struct ethtool_ops tg3_ethtool_ops = {
7856 .get_stats_count = tg3_get_stats_count, 7910 .get_stats_count = tg3_get_stats_count,
7857 .get_ethtool_stats = tg3_get_ethtool_stats, 7911 .get_ethtool_stats = tg3_get_ethtool_stats,
7858 .get_coalesce = tg3_get_coalesce, 7912 .get_coalesce = tg3_get_coalesce,
7913 .set_coalesce = tg3_set_coalesce,
7859}; 7914};
7860 7915
7861static void __devinit tg3_get_eeprom_size(struct tg3 *tp) 7916static void __devinit tg3_get_eeprom_size(struct tg3 *tp)
@@ -9800,6 +9855,12 @@ static void __devinit tg3_init_coal(struct tg3 *tp)
9800 ec->tx_coalesce_usecs = LOW_TXCOL_TICKS_CLRTCKS; 9855 ec->tx_coalesce_usecs = LOW_TXCOL_TICKS_CLRTCKS;
9801 ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT_CLRTCKS; 9856 ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT_CLRTCKS;
9802 } 9857 }
9858
9859 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
9860 ec->rx_coalesce_usecs_irq = 0;
9861 ec->tx_coalesce_usecs_irq = 0;
9862 ec->stats_block_coalesce_usecs = 0;
9863 }
9803} 9864}
9804 9865
9805static int __devinit tg3_init_one(struct pci_dev *pdev, 9866static int __devinit tg3_init_one(struct pci_dev *pdev,
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 99c5f9675a56..70ad450733e6 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -879,31 +879,41 @@
879#define LOW_RXCOL_TICKS_CLRTCKS 0x00000014 879#define LOW_RXCOL_TICKS_CLRTCKS 0x00000014
880#define DEFAULT_RXCOL_TICKS 0x00000048 880#define DEFAULT_RXCOL_TICKS 0x00000048
881#define HIGH_RXCOL_TICKS 0x00000096 881#define HIGH_RXCOL_TICKS 0x00000096
882#define MAX_RXCOL_TICKS 0x000003ff
882#define HOSTCC_TXCOL_TICKS 0x00003c0c 883#define HOSTCC_TXCOL_TICKS 0x00003c0c
883#define LOW_TXCOL_TICKS 0x00000096 884#define LOW_TXCOL_TICKS 0x00000096
884#define LOW_TXCOL_TICKS_CLRTCKS 0x00000048 885#define LOW_TXCOL_TICKS_CLRTCKS 0x00000048
885#define DEFAULT_TXCOL_TICKS 0x0000012c 886#define DEFAULT_TXCOL_TICKS 0x0000012c
886#define HIGH_TXCOL_TICKS 0x00000145 887#define HIGH_TXCOL_TICKS 0x00000145
888#define MAX_TXCOL_TICKS 0x000003ff
887#define HOSTCC_RXMAX_FRAMES 0x00003c10 889#define HOSTCC_RXMAX_FRAMES 0x00003c10
888#define LOW_RXMAX_FRAMES 0x00000005 890#define LOW_RXMAX_FRAMES 0x00000005
889#define DEFAULT_RXMAX_FRAMES 0x00000008 891#define DEFAULT_RXMAX_FRAMES 0x00000008
890#define HIGH_RXMAX_FRAMES 0x00000012 892#define HIGH_RXMAX_FRAMES 0x00000012
893#define MAX_RXMAX_FRAMES 0x000000ff
891#define HOSTCC_TXMAX_FRAMES 0x00003c14 894#define HOSTCC_TXMAX_FRAMES 0x00003c14
892#define LOW_TXMAX_FRAMES 0x00000035 895#define LOW_TXMAX_FRAMES 0x00000035
893#define DEFAULT_TXMAX_FRAMES 0x0000004b 896#define DEFAULT_TXMAX_FRAMES 0x0000004b
894#define HIGH_TXMAX_FRAMES 0x00000052 897#define HIGH_TXMAX_FRAMES 0x00000052
898#define MAX_TXMAX_FRAMES 0x000000ff
895#define HOSTCC_RXCOAL_TICK_INT 0x00003c18 899#define HOSTCC_RXCOAL_TICK_INT 0x00003c18
896#define DEFAULT_RXCOAL_TICK_INT 0x00000019 900#define DEFAULT_RXCOAL_TICK_INT 0x00000019
897#define DEFAULT_RXCOAL_TICK_INT_CLRTCKS 0x00000014 901#define DEFAULT_RXCOAL_TICK_INT_CLRTCKS 0x00000014
902#define MAX_RXCOAL_TICK_INT 0x000003ff
898#define HOSTCC_TXCOAL_TICK_INT 0x00003c1c 903#define HOSTCC_TXCOAL_TICK_INT 0x00003c1c
899#define DEFAULT_TXCOAL_TICK_INT 0x00000019 904#define DEFAULT_TXCOAL_TICK_INT 0x00000019
900#define DEFAULT_TXCOAL_TICK_INT_CLRTCKS 0x00000014 905#define DEFAULT_TXCOAL_TICK_INT_CLRTCKS 0x00000014
906#define MAX_TXCOAL_TICK_INT 0x000003ff
901#define HOSTCC_RXCOAL_MAXF_INT 0x00003c20 907#define HOSTCC_RXCOAL_MAXF_INT 0x00003c20
902#define DEFAULT_RXCOAL_MAXF_INT 0x00000005 908#define DEFAULT_RXCOAL_MAXF_INT 0x00000005
909#define MAX_RXCOAL_MAXF_INT 0x000000ff
903#define HOSTCC_TXCOAL_MAXF_INT 0x00003c24 910#define HOSTCC_TXCOAL_MAXF_INT 0x00003c24
904#define DEFAULT_TXCOAL_MAXF_INT 0x00000005 911#define DEFAULT_TXCOAL_MAXF_INT 0x00000005
912#define MAX_TXCOAL_MAXF_INT 0x000000ff
905#define HOSTCC_STAT_COAL_TICKS 0x00003c28 913#define HOSTCC_STAT_COAL_TICKS 0x00003c28
906#define DEFAULT_STAT_COAL_TICKS 0x000f4240 914#define DEFAULT_STAT_COAL_TICKS 0x000f4240
915#define MAX_STAT_COAL_TICKS 0xd693d400
916#define MIN_STAT_COAL_TICKS 0x00000064
907/* 0x3c2c --> 0x3c30 unused */ 917/* 0x3c2c --> 0x3c30 unused */
908#define HOSTCC_STATS_BLK_HOST_ADDR 0x00003c30 /* 64-bit */ 918#define HOSTCC_STATS_BLK_HOST_ADDR 0x00003c30 /* 64-bit */
909#define HOSTCC_STATUS_BLK_HOST_ADDR 0x00003c38 /* 64-bit */ 919#define HOSTCC_STATUS_BLK_HOST_ADDR 0x00003c38 /* 64-bit */
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 7bfee366297b..effab0b9adca 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -215,7 +215,7 @@ static unsigned int tun_chr_poll(struct file *file, poll_table * wait)
215 215
216 poll_wait(file, &tun->read_wait, wait); 216 poll_wait(file, &tun->read_wait, wait);
217 217
218 if (skb_queue_len(&tun->readq)) 218 if (!skb_queue_empty(&tun->readq))
219 mask |= POLLIN | POLLRDNORM; 219 mask |= POLLIN | POLLRDNORM;
220 220
221 return mask; 221 return mask;
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 0b5ca2537963..ecfa6f8805ce 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -1906,9 +1906,9 @@ typhoon_sleep(struct typhoon *tp, pci_power_t state, u16 events)
1906 */ 1906 */
1907 netif_carrier_off(tp->dev); 1907 netif_carrier_off(tp->dev);
1908 1908
1909 pci_enable_wake(tp->pdev, pci_choose_state(pdev, state), 1); 1909 pci_enable_wake(tp->pdev, state, 1);
1910 pci_disable_device(pdev); 1910 pci_disable_device(pdev);
1911 return pci_set_power_state(pdev, pci_choose_state(pdev, state)); 1911 return pci_set_power_state(pdev, state);
1912} 1912}
1913 1913
1914static int 1914static int
@@ -2274,7 +2274,7 @@ typhoon_suspend(struct pci_dev *pdev, pm_message_t state)
2274 goto need_resume; 2274 goto need_resume;
2275 } 2275 }
2276 2276
2277 if(typhoon_sleep(tp, state, tp->wol_events) < 0) { 2277 if(typhoon_sleep(tp, pci_choose_state(pdev, state), tp->wol_events) < 0) {
2278 printk(KERN_ERR "%s: unable to put card to sleep\n", dev->name); 2278 printk(KERN_ERR "%s: unable to put card to sleep\n", dev->name);
2279 goto need_resume; 2279 goto need_resume;
2280 } 2280 }
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 7217d44e8854..2c83cca34b86 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -861,8 +861,7 @@ fst_tx_dma_complete(struct fst_card_info *card, struct fst_port_info *port,
861/* 861/*
862 * Mark it for our own raw sockets interface 862 * Mark it for our own raw sockets interface
863 */ 863 */
864static unsigned short farsync_type_trans(struct sk_buff *skb, 864static __be16 farsync_type_trans(struct sk_buff *skb, struct net_device *dev)
865 struct net_device *dev)
866{ 865{
867 skb->dev = dev; 866 skb->dev = dev;
868 skb->mac.raw = skb->data; 867 skb->mac.raw = skb->data;
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index 87496843681a..48c03c11cd9a 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -91,8 +91,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
91 91
92 92
93 93
94static unsigned short cisco_type_trans(struct sk_buff *skb, 94static __be16 cisco_type_trans(struct sk_buff *skb, struct net_device *dev)
95 struct net_device *dev)
96{ 95{
97 hdlc_header *data = (hdlc_header*)skb->data; 96 hdlc_header *data = (hdlc_header*)skb->data;
98 97
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index 7cd6195a2e46..b81263eaede0 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -66,8 +66,7 @@ static void ppp_close(struct net_device *dev)
66 66
67 67
68 68
69static unsigned short ppp_type_trans(struct sk_buff *skb, 69static __be16 ppp_type_trans(struct sk_buff *skb, struct net_device *dev)
70 struct net_device *dev)
71{ 70{
72 return __constant_htons(ETH_P_WAN_PPP); 71 return __constant_htons(ETH_P_WAN_PPP);
73} 72}
diff --git a/drivers/net/wan/hdlc_raw.c b/drivers/net/wan/hdlc_raw.c
index c41fb70b6929..9456d31cb1c1 100644
--- a/drivers/net/wan/hdlc_raw.c
+++ b/drivers/net/wan/hdlc_raw.c
@@ -24,8 +24,7 @@
24#include <linux/hdlc.h> 24#include <linux/hdlc.h>
25 25
26 26
27static unsigned short raw_type_trans(struct sk_buff *skb, 27static __be16 raw_type_trans(struct sk_buff *skb, struct net_device *dev)
28 struct net_device *dev)
29{ 28{
30 return __constant_htons(ETH_P_IP); 29 return __constant_htons(ETH_P_IP);
31} 30}
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index c12648d8192b..47f3c5d0203d 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2374,7 +2374,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
2374 /* 2374 /*
2375 * Clean out tx queue 2375 * Clean out tx queue
2376 */ 2376 */
2377 if (test_bit(FLAG_MPI, &ai->flags) && skb_queue_len (&ai->txq) > 0) { 2377 if (test_bit(FLAG_MPI, &ai->flags) && !skb_queue_empty(&ai->txq)) {
2378 struct sk_buff *skb = NULL; 2378 struct sk_buff *skb = NULL;
2379 for (;(skb = skb_dequeue(&ai->txq));) 2379 for (;(skb = skb_dequeue(&ai->txq));)
2380 dev_kfree_skb(skb); 2380 dev_kfree_skb(skb);
@@ -3287,7 +3287,7 @@ exitrx:
3287 if (status & EV_TXEXC) 3287 if (status & EV_TXEXC)
3288 get_tx_error(apriv, -1); 3288 get_tx_error(apriv, -1);
3289 spin_lock_irqsave(&apriv->aux_lock, flags); 3289 spin_lock_irqsave(&apriv->aux_lock, flags);
3290 if (skb_queue_len (&apriv->txq)) { 3290 if (!skb_queue_empty(&apriv->txq)) {
3291 spin_unlock_irqrestore(&apriv->aux_lock,flags); 3291 spin_unlock_irqrestore(&apriv->aux_lock,flags);
3292 mpi_send_packet (dev); 3292 mpi_send_packet (dev);
3293 } else { 3293 } else {
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index f10a9523034a..bf25584d68d3 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -33,7 +33,6 @@
33#include <linux/timer.h> 33#include <linux/timer.h>
34#include <linux/netdevice.h> 34#include <linux/netdevice.h>
35 35
36#include <pcmcia/version.h>
37#include <pcmcia/cs_types.h> 36#include <pcmcia/cs_types.h>
38#include <pcmcia/cs.h> 37#include <pcmcia/cs.h>
39#include <pcmcia/cistpl.h> 38#include <pcmcia/cistpl.h>
@@ -210,11 +209,6 @@ static dev_link_t *airo_attach(void)
210 link->next = dev_list; 209 link->next = dev_list;
211 dev_list = link; 210 dev_list = link;
212 client_reg.dev_info = &dev_info; 211 client_reg.dev_info = &dev_info;
213 client_reg.EventMask =
214 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
215 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
216 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
217 client_reg.event_handler = &airo_event;
218 client_reg.Version = 0x0210; 212 client_reg.Version = 0x0210;
219 client_reg.event_callback_args.client_data = link; 213 client_reg.event_callback_args.client_data = link;
220 ret = pcmcia_register_client(&link->handle, &client_reg); 214 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -574,6 +568,7 @@ static struct pcmcia_driver airo_driver = {
574 .name = "airo_cs", 568 .name = "airo_cs",
575 }, 569 },
576 .attach = airo_attach, 570 .attach = airo_attach,
571 .event = airo_event,
577 .detach = airo_detach, 572 .detach = airo_detach,
578 .id_table = airo_ids, 573 .id_table = airo_ids,
579}; 574};
diff --git a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c
index b4f4bd7956a2..9d496703c465 100644
--- a/drivers/net/wireless/airport.c
+++ b/drivers/net/wireless/airport.c
@@ -184,7 +184,7 @@ static int airport_hard_reset(struct orinoco_private *priv)
184} 184}
185 185
186static int 186static int
187airport_attach(struct macio_dev *mdev, const struct of_match *match) 187airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
188{ 188{
189 struct orinoco_private *priv; 189 struct orinoco_private *priv;
190 struct net_device *dev; 190 struct net_device *dev;
@@ -266,16 +266,16 @@ MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
266MODULE_DESCRIPTION("Driver for the Apple Airport wireless card."); 266MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
267MODULE_LICENSE("Dual MPL/GPL"); 267MODULE_LICENSE("Dual MPL/GPL");
268 268
269static struct of_match airport_match[] = 269static struct of_device_id airport_match[] =
270{ 270{
271 { 271 {
272 .name = "radio", 272 .name = "radio",
273 .type = OF_ANY_MATCH,
274 .compatible = OF_ANY_MATCH
275 }, 273 },
276 {}, 274 {},
277}; 275};
278 276
277MODULE_DEVICE_TABLE (of, airport_match);
278
279static struct macio_driver airport_driver = 279static struct macio_driver airport_driver =
280{ 280{
281 .name = DRIVER_NAME, 281 .name = DRIVER_NAME,
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 86379d4998ac..ff031a3985b3 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -43,7 +43,6 @@
43#include <linux/moduleparam.h> 43#include <linux/moduleparam.h>
44#include <linux/device.h> 44#include <linux/device.h>
45 45
46#include <pcmcia/version.h>
47#include <pcmcia/cs_types.h> 46#include <pcmcia/cs_types.h>
48#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
@@ -218,11 +217,6 @@ static dev_link_t *atmel_attach(void)
218 link->next = dev_list; 217 link->next = dev_list;
219 dev_list = link; 218 dev_list = link;
220 client_reg.dev_info = &dev_info; 219 client_reg.dev_info = &dev_info;
221 client_reg.EventMask =
222 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
223 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
224 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
225 client_reg.event_handler = &atmel_event;
226 client_reg.Version = 0x0210; 220 client_reg.Version = 0x0210;
227 client_reg.event_callback_args.client_data = link; 221 client_reg.event_callback_args.client_data = link;
228 ret = pcmcia_register_client(&link->handle, &client_reg); 222 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -668,12 +662,13 @@ static struct pcmcia_device_id atmel_ids[] = {
668MODULE_DEVICE_TABLE(pcmcia, atmel_ids); 662MODULE_DEVICE_TABLE(pcmcia, atmel_ids);
669 663
670static struct pcmcia_driver atmel_driver = { 664static struct pcmcia_driver atmel_driver = {
671 .owner = THIS_MODULE, 665 .owner = THIS_MODULE,
672 .drv = { 666 .drv = {
673 .name = "atmel_cs", 667 .name = "atmel_cs",
674 }, 668 },
675 .attach = atmel_attach, 669 .attach = atmel_attach,
676 .detach = atmel_detach, 670 .event = atmel_event,
671 .detach = atmel_detach,
677 .id_table = atmel_ids, 672 .id_table = atmel_ids,
678}; 673};
679 674
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index e12bd75b2694..5f507c49907b 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -62,7 +62,6 @@
62#endif /* WIRELESS_EXT > 12 */ 62#endif /* WIRELESS_EXT > 12 */
63#endif 63#endif
64 64
65#include <pcmcia/version.h>
66#include <pcmcia/cs_types.h> 65#include <pcmcia/cs_types.h>
67#include <pcmcia/cs.h> 66#include <pcmcia/cs.h>
68#include <pcmcia/cistpl.h> 67#include <pcmcia/cistpl.h>
@@ -491,11 +490,6 @@ static dev_link_t *netwave_attach(void)
491 link->next = dev_list; 490 link->next = dev_list;
492 dev_list = link; 491 dev_list = link;
493 client_reg.dev_info = &dev_info; 492 client_reg.dev_info = &dev_info;
494 client_reg.EventMask =
495 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
496 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
497 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
498 client_reg.event_handler = &netwave_event;
499 client_reg.Version = 0x0210; 493 client_reg.Version = 0x0210;
500 client_reg.event_callback_args.client_data = link; 494 client_reg.event_callback_args.client_data = link;
501 ret = pcmcia_register_client(&link->handle, &client_reg); 495 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1680,6 +1674,7 @@ static struct pcmcia_driver netwave_driver = {
1680 .name = "netwave_cs", 1674 .name = "netwave_cs",
1681 }, 1675 },
1682 .attach = netwave_attach, 1676 .attach = netwave_attach,
1677 .event = netwave_event,
1683 .detach = netwave_detach, 1678 .detach = netwave_detach,
1684 .id_table = netwave_ids, 1679 .id_table = netwave_ids,
1685}; 1680};
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index 597c4586d049..368d2f962f67 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -31,7 +31,6 @@
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/wireless.h> 32#include <linux/wireless.h>
33 33
34#include <pcmcia/version.h>
35#include <pcmcia/cs_types.h> 34#include <pcmcia/cs_types.h>
36#include <pcmcia/cs.h> 35#include <pcmcia/cs.h>
37#include <pcmcia/cistpl.h> 36#include <pcmcia/cistpl.h>
@@ -186,11 +185,6 @@ orinoco_cs_attach(void)
186 dev_list = link; 185 dev_list = link;
187 186
188 client_reg.dev_info = &dev_info; 187 client_reg.dev_info = &dev_info;
189 client_reg.EventMask =
190 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
191 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
192 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
193 client_reg.event_handler = &orinoco_cs_event;
194 client_reg.Version = 0x0210; /* FIXME: what does this mean? */ 188 client_reg.Version = 0x0210; /* FIXME: what does this mean? */
195 client_reg.event_callback_args.client_data = link; 189 client_reg.event_callback_args.client_data = link;
196 190
@@ -664,6 +658,7 @@ static struct pcmcia_driver orinoco_driver = {
664 .name = DRIVER_NAME, 658 .name = DRIVER_NAME,
665 }, 659 },
666 .attach = orinoco_cs_attach, 660 .attach = orinoco_cs_attach,
661 .event = orinoco_cs_event,
667 .detach = orinoco_cs_detach, 662 .detach = orinoco_cs_detach,
668 .id_table = orinoco_cs_ids, 663 .id_table = orinoco_cs_ids,
669}; 664};
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 31652af52eac..0e0ba614259a 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -46,7 +46,6 @@
46#include <linux/skbuff.h> 46#include <linux/skbuff.h>
47#include <linux/ethtool.h> 47#include <linux/ethtool.h>
48 48
49#include <pcmcia/version.h>
50#include <pcmcia/cs_types.h> 49#include <pcmcia/cs_types.h>
51#include <pcmcia/cs.h> 50#include <pcmcia/cs.h>
52#include <pcmcia/cistpl.h> 51#include <pcmcia/cistpl.h>
@@ -393,11 +392,6 @@ static dev_link_t *ray_attach(void)
393 link->next = dev_list; 392 link->next = dev_list;
394 dev_list = link; 393 dev_list = link;
395 client_reg.dev_info = &dev_info; 394 client_reg.dev_info = &dev_info;
396 client_reg.EventMask =
397 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
398 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
399 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
400 client_reg.event_handler = &ray_event;
401 client_reg.Version = 0x0210; 395 client_reg.Version = 0x0210;
402 client_reg.event_callback_args.client_data = link; 396 client_reg.event_callback_args.client_data = link;
403 397
@@ -2916,6 +2910,7 @@ static struct pcmcia_driver ray_driver = {
2916 .name = "ray_cs", 2910 .name = "ray_cs",
2917 }, 2911 },
2918 .attach = ray_attach, 2912 .attach = ray_attach,
2913 .event = ray_event,
2919 .detach = ray_detach, 2914 .detach = ray_detach,
2920 .id_table = ray_ids, 2915 .id_table = ray_ids,
2921}; 2916};
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 89532fd92941..f6130a53b796 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -4684,12 +4684,6 @@ wavelan_attach(void)
4684 4684
4685 /* Register with Card Services */ 4685 /* Register with Card Services */
4686 client_reg.dev_info = &dev_info; 4686 client_reg.dev_info = &dev_info;
4687 client_reg.EventMask =
4688 CS_EVENT_REGISTRATION_COMPLETE |
4689 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
4690 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
4691 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
4692 client_reg.event_handler = &wavelan_event;
4693 client_reg.Version = 0x0210; 4687 client_reg.Version = 0x0210;
4694 client_reg.event_callback_args.client_data = link; 4688 client_reg.event_callback_args.client_data = link;
4695 4689
@@ -4904,6 +4898,7 @@ static struct pcmcia_driver wavelan_driver = {
4904 .name = "wavelan_cs", 4898 .name = "wavelan_cs",
4905 }, 4899 },
4906 .attach = wavelan_attach, 4900 .attach = wavelan_attach,
4901 .event = wavelan_event,
4907 .detach = wavelan_detach, 4902 .detach = wavelan_detach,
4908 .id_table = wavelan_ids, 4903 .id_table = wavelan_ids,
4909}; 4904};
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index ea2ef8dddb92..677ff71883cb 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -452,7 +452,6 @@
452#include <pcmcia/cistpl.h> 452#include <pcmcia/cistpl.h>
453#include <pcmcia/cisreg.h> 453#include <pcmcia/cisreg.h>
454#include <pcmcia/ds.h> 454#include <pcmcia/ds.h>
455#include <pcmcia/version.h>
456 455
457/* Wavelan declarations */ 456/* Wavelan declarations */
458#include "i82593.h" /* Definitions for the Intel chip */ 457#include "i82593.h" /* Definitions for the Intel chip */
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index e3a900482d92..dd902126d018 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -49,7 +49,6 @@
49 49
50#include <net/iw_handler.h> 50#include <net/iw_handler.h>
51 51
52#include <pcmcia/version.h>
53#include <pcmcia/cs_types.h> 52#include <pcmcia/cs_types.h>
54#include <pcmcia/cs.h> 53#include <pcmcia/cs.h>
55#include <pcmcia/cistpl.h> 54#include <pcmcia/cistpl.h>
@@ -2005,13 +2004,6 @@ static dev_link_t *wl3501_attach(void)
2005 link->next = wl3501_dev_list; 2004 link->next = wl3501_dev_list;
2006 wl3501_dev_list = link; 2005 wl3501_dev_list = link;
2007 client_reg.dev_info = &wl3501_dev_info; 2006 client_reg.dev_info = &wl3501_dev_info;
2008 client_reg.EventMask = CS_EVENT_CARD_INSERTION |
2009 CS_EVENT_RESET_PHYSICAL |
2010 CS_EVENT_CARD_RESET |
2011 CS_EVENT_CARD_REMOVAL |
2012 CS_EVENT_PM_SUSPEND |
2013 CS_EVENT_PM_RESUME;
2014 client_reg.event_handler = wl3501_event;
2015 client_reg.Version = 0x0210; 2007 client_reg.Version = 0x0210;
2016 client_reg.event_callback_args.client_data = link; 2008 client_reg.event_callback_args.client_data = link;
2017 ret = pcmcia_register_client(&link->handle, &client_reg); 2009 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -2246,12 +2238,13 @@ static struct pcmcia_device_id wl3501_ids[] = {
2246MODULE_DEVICE_TABLE(pcmcia, wl3501_ids); 2238MODULE_DEVICE_TABLE(pcmcia, wl3501_ids);
2247 2239
2248static struct pcmcia_driver wl3501_driver = { 2240static struct pcmcia_driver wl3501_driver = {
2249 .owner = THIS_MODULE, 2241 .owner = THIS_MODULE,
2250 .drv = { 2242 .drv = {
2251 .name = "wl3501_cs", 2243 .name = "wl3501_cs",
2252 }, 2244 },
2253 .attach = wl3501_attach, 2245 .attach = wl3501_attach,
2254 .detach = wl3501_detach, 2246 .event = wl3501_event,
2247 .detach = wl3501_detach,
2255 .id_table = wl3501_ids, 2248 .id_table = wl3501_ids,
2256}; 2249};
2257 2250
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index ff45662c4f7c..24e6aacddb74 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -48,7 +48,6 @@
48#include <linux/parport.h> 48#include <linux/parport.h>
49#include <linux/parport_pc.h> 49#include <linux/parport_pc.h>
50 50
51#include <pcmcia/version.h>
52#include <pcmcia/cs_types.h> 51#include <pcmcia/cs_types.h>
53#include <pcmcia/cs.h> 52#include <pcmcia/cs.h>
54#include <pcmcia/cistpl.h> 53#include <pcmcia/cistpl.h>
@@ -133,11 +132,6 @@ static dev_link_t *parport_attach(void)
133 link->next = dev_list; 132 link->next = dev_list;
134 dev_list = link; 133 dev_list = link;
135 client_reg.dev_info = &dev_info; 134 client_reg.dev_info = &dev_info;
136 client_reg.EventMask =
137 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
138 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
139 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
140 client_reg.event_handler = &parport_event;
141 client_reg.Version = 0x0210; 135 client_reg.Version = 0x0210;
142 client_reg.event_callback_args.client_data = link; 136 client_reg.event_callback_args.client_data = link;
143 ret = pcmcia_register_client(&link->handle, &client_reg); 137 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -386,6 +380,7 @@ static struct pcmcia_driver parport_cs_driver = {
386 .name = "parport_cs", 380 .name = "parport_cs",
387 }, 381 },
388 .attach = parport_attach, 382 .attach = parport_attach,
383 .event = parport_event,
389 .detach = parport_detach, 384 .detach = parport_detach,
390 .id_table = parport_ids, 385 .id_table = parport_ids,
391 386
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 80edfa3abd29..4598c6a9212d 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -3008,7 +3008,7 @@ static int __init parport_pc_init_superio (int autoirq, int autodma)
3008 int ret = 0; 3008 int ret = 0;
3009 3009
3010 while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { 3010 while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) {
3011 id = pci_match_device (parport_pc_pci_tbl, pdev); 3011 id = pci_match_id(parport_pc_pci_tbl, pdev);
3012 if (id == NULL || id->driver_data >= last_sio) 3012 if (id == NULL || id->driver_data >= last_sio)
3013 continue; 3013 continue;
3014 3014
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 7dea494c0d7b..3657f6199c48 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_HOTPLUG_PCI) += hotplug/
19# 19#
20# Some architectures use the generic PCI setup functions 20# Some architectures use the generic PCI setup functions
21# 21#
22obj-$(CONFIG_X86) += setup-bus.o
22obj-$(CONFIG_ALPHA) += setup-bus.o setup-irq.o 23obj-$(CONFIG_ALPHA) += setup-bus.o setup-irq.o
23obj-$(CONFIG_ARM) += setup-bus.o setup-irq.o 24obj-$(CONFIG_ARM) += setup-bus.o setup-irq.o
24obj-$(CONFIG_PARISC) += setup-bus.o 25obj-$(CONFIG_PARISC) += setup-bus.o
diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
index 3903f8c559b6..b844bc972324 100644
--- a/drivers/pci/hotplug.c
+++ b/drivers/pci/hotplug.c
@@ -54,7 +54,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
54 54
55 envp[i++] = scratch; 55 envp[i++] = scratch;
56 length += scnprintf (scratch, buffer_size - length, 56 length += scnprintf (scratch, buffer_size - length,
57 "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n", 57 "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x",
58 pdev->vendor, pdev->device, 58 pdev->vendor, pdev->device,
59 pdev->subsystem_vendor, pdev->subsystem_device, 59 pdev->subsystem_vendor, pdev->subsystem_device,
60 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), 60 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig
index 1a4d4ca2a4dc..9c4a39ee89b5 100644
--- a/drivers/pci/hotplug/Kconfig
+++ b/drivers/pci/hotplug/Kconfig
@@ -187,9 +187,10 @@ config HOTPLUG_PCI_RPA_DLPAR
187 187
188config HOTPLUG_PCI_SGI 188config HOTPLUG_PCI_SGI
189 tristate "SGI PCI Hotplug Support" 189 tristate "SGI PCI Hotplug Support"
190 depends on HOTPLUG_PCI && IA64_SGI_SN2 190 depends on HOTPLUG_PCI && (IA64_SGI_SN2 || IA64_GENERIC)
191 help 191 help
192 Say Y here if you have an SGI IA64 Altix system. 192 Say Y here if you want to use the SGI Altix Hotplug
193 Driver for PCI devices.
193 194
194 When in doubt, say N. 195 When in doubt, say N.
195 196
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
index 3e632ff8c717..31a307004b94 100644
--- a/drivers/pci/hotplug/Makefile
+++ b/drivers/pci/hotplug/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_HOTPLUG_PCI_PCIE) += pciehp.o
14obj-$(CONFIG_HOTPLUG_PCI_SHPC) += shpchp.o 14obj-$(CONFIG_HOTPLUG_PCI_SHPC) += shpchp.o
15obj-$(CONFIG_HOTPLUG_PCI_RPA) += rpaphp.o 15obj-$(CONFIG_HOTPLUG_PCI_RPA) += rpaphp.o
16obj-$(CONFIG_HOTPLUG_PCI_RPA_DLPAR) += rpadlpar_io.o 16obj-$(CONFIG_HOTPLUG_PCI_RPA_DLPAR) += rpadlpar_io.o
17obj-$(CONFIG_HOTPLUG_PCI_SGI) += sgi_hotplug.o
17 18
18pci_hotplug-objs := pci_hotplug_core.o 19pci_hotplug-objs := pci_hotplug_core.o
19 20
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
new file mode 100644
index 000000000000..323041fd41dc
--- /dev/null
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -0,0 +1,611 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2005 Silicon Graphics, Inc. All rights reserved.
7 *
8 * This work was based on the 2.4/2.6 kernel development by Dick Reigner.
9 * Work to add BIOS PROM support was completed by Mike Habeck.
10 */
11
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/pci.h>
16#include <linux/proc_fs.h>
17#include <linux/types.h>
18
19#include <asm/sn/addrs.h>
20#include <asm/sn/l1.h>
21#include <asm/sn/module.h>
22#include <asm/sn/pcibr_provider.h>
23#include <asm/sn/pcibus_provider_defs.h>
24#include <asm/sn/pcidev.h>
25#include <asm/sn/sn_sal.h>
26#include <asm/sn/types.h>
27
28#include "../pci.h"
29#include "pci_hotplug.h"
30
31MODULE_LICENSE("GPL");
32MODULE_AUTHOR("SGI (prarit@sgi.com, dickie@sgi.com, habeck@sgi.com)");
33MODULE_DESCRIPTION("SGI Altix Hot Plug PCI Controller Driver");
34
35#define PCIIO_ASIC_TYPE_TIOCA 4
36#define PCI_SLOT_ALREADY_UP 2 /* slot already up */
37#define PCI_SLOT_ALREADY_DOWN 3 /* slot already down */
38#define PCI_L1_ERR 7 /* L1 console command error */
39#define PCI_EMPTY_33MHZ 15 /* empty 33 MHz bus */
40#define PCI_L1_QSIZE 128 /* our L1 message buffer size */
41#define SN_MAX_HP_SLOTS 32 /* max number of hotplug slots */
42#define SGI_HOTPLUG_PROM_REV 0x0420 /* Min. required PROM version */
43
44/* internal list head */
45static struct list_head sn_hp_list;
46
47/* hotplug_slot struct's private pointer */
48struct slot {
49 int device_num;
50 struct pci_bus *pci_bus;
51 /* this struct for glue internal only */
52 struct hotplug_slot *hotplug_slot;
53 struct list_head hp_list;
54};
55
56struct pcibr_slot_enable_resp {
57 int resp_sub_errno;
58 char resp_l1_msg[PCI_L1_QSIZE + 1];
59};
60
61struct pcibr_slot_disable_resp {
62 int resp_sub_errno;
63 char resp_l1_msg[PCI_L1_QSIZE + 1];
64};
65
66enum sn_pci_req_e {
67 PCI_REQ_SLOT_ELIGIBLE,
68 PCI_REQ_SLOT_DISABLE
69};
70
71static int enable_slot(struct hotplug_slot *slot);
72static int disable_slot(struct hotplug_slot *slot);
73static int get_power_status(struct hotplug_slot *slot, u8 *value);
74
75static struct hotplug_slot_ops sn_hotplug_slot_ops = {
76 .owner = THIS_MODULE,
77 .enable_slot = enable_slot,
78 .disable_slot = disable_slot,
79 .get_power_status = get_power_status,
80};
81
82static DECLARE_MUTEX(sn_hotplug_sem);
83
84static int sn_pci_slot_valid(struct pci_bus *pci_bus, int device)
85{
86 struct pcibus_info *pcibus_info;
87 int bricktype;
88 int bus_num;
89
90 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(pci_bus);
91
92 /* Check to see if this is a valid slot on 'pci_bus' */
93 if (!(pcibus_info->pbi_valid_devices & (1 << device)))
94 return -EPERM;
95
96 bricktype = MODULE_GET_BTYPE(pcibus_info->pbi_moduleid);
97 bus_num = pcibus_info->pbi_buscommon.bs_persist_busnum & 0xf;
98
99 /* Do not allow hotplug operations on base I/O cards */
100 if ((bricktype == L1_BRICKTYPE_IX || bricktype == L1_BRICKTYPE_IA) &&
101 (bus_num == 1 && device != 1))
102 return -EPERM;
103
104 return 1;
105}
106
107static int sn_pci_bus_valid(struct pci_bus *pci_bus)
108{
109 struct pcibus_info *pcibus_info;
110 int asic_type;
111 int bricktype;
112
113 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(pci_bus);
114
115 /* Don't register slots hanging off the TIOCA bus */
116 asic_type = pcibus_info->pbi_buscommon.bs_asic_type;
117 if (asic_type == PCIIO_ASIC_TYPE_TIOCA)
118 return -EPERM;
119
120 /* Only register slots in I/O Bricks that support hotplug */
121 bricktype = MODULE_GET_BTYPE(pcibus_info->pbi_moduleid);
122 switch (bricktype) {
123 case L1_BRICKTYPE_IX:
124 case L1_BRICKTYPE_PX:
125 case L1_BRICKTYPE_IA:
126 case L1_BRICKTYPE_PA:
127 return 1;
128 break;
129 default:
130 return -EPERM;
131 break;
132 }
133
134 return -EIO;
135}
136
137static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot,
138 struct pci_bus *pci_bus, int device)
139{
140 struct pcibus_info *pcibus_info;
141 struct slot *slot;
142
143 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(pci_bus);
144
145 bss_hotplug_slot->private = kcalloc(1, sizeof(struct slot),
146 GFP_KERNEL);
147 if (!bss_hotplug_slot->private)
148 return -ENOMEM;
149 slot = (struct slot *)bss_hotplug_slot->private;
150
151 bss_hotplug_slot->name = kmalloc(33, GFP_KERNEL);
152 if (!bss_hotplug_slot->name) {
153 kfree(bss_hotplug_slot->private);
154 return -ENOMEM;
155 }
156
157 slot->device_num = device;
158 slot->pci_bus = pci_bus;
159
160 sprintf(bss_hotplug_slot->name, "module_%c%c%c%c%.2d_b_%d_s_%d",
161 '0'+RACK_GET_CLASS(MODULE_GET_RACK(pcibus_info->pbi_moduleid)),
162 '0'+RACK_GET_GROUP(MODULE_GET_RACK(pcibus_info->pbi_moduleid)),
163 '0'+RACK_GET_NUM(MODULE_GET_RACK(pcibus_info->pbi_moduleid)),
164 MODULE_GET_BTCHAR(pcibus_info->pbi_moduleid),
165 MODULE_GET_BPOS(pcibus_info->pbi_moduleid),
166 ((int)pcibus_info->pbi_buscommon.bs_persist_busnum) & 0xf,
167 device + 1);
168
169 slot->hotplug_slot = bss_hotplug_slot;
170 list_add(&slot->hp_list, &sn_hp_list);
171
172 return 0;
173}
174
175static struct hotplug_slot * sn_hp_destroy(void)
176{
177 struct slot *slot;
178 struct list_head *list;
179 struct hotplug_slot *bss_hotplug_slot = NULL;
180
181 list_for_each(list, &sn_hp_list) {
182 slot = list_entry(list, struct slot, hp_list);
183 bss_hotplug_slot = slot->hotplug_slot;
184 list_del(&((struct slot *)bss_hotplug_slot->private)->
185 hp_list);
186 break;
187 }
188 return bss_hotplug_slot;
189}
190
191static void sn_bus_alloc_data(struct pci_dev *dev)
192{
193 struct list_head *node;
194 struct pci_bus *subordinate_bus;
195 struct pci_dev *child;
196
197 sn_pci_fixup_slot(dev);
198
199 /* Recursively sets up the sn_irq_info structs */
200 if (dev->subordinate) {
201 subordinate_bus = dev->subordinate;
202 list_for_each(node, &subordinate_bus->devices) {
203 child = list_entry(node, struct pci_dev, bus_list);
204 sn_bus_alloc_data(child);
205 }
206 }
207}
208
209static void sn_bus_free_data(struct pci_dev *dev)
210{
211 struct list_head *node;
212 struct pci_bus *subordinate_bus;
213 struct pci_dev *child;
214
215 /* Recursively clean up sn_irq_info structs */
216 if (dev->subordinate) {
217 subordinate_bus = dev->subordinate;
218 list_for_each(node, &subordinate_bus->devices) {
219 child = list_entry(node, struct pci_dev, bus_list);
220 sn_bus_free_data(child);
221 }
222 }
223 sn_pci_unfixup_slot(dev);
224}
225
226static u8 sn_power_status_get(struct hotplug_slot *bss_hotplug_slot)
227{
228 struct slot *slot = (struct slot *)bss_hotplug_slot->private;
229 struct pcibus_info *pcibus_info;
230 u8 retval;
231
232 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus);
233 retval = pcibus_info->pbi_enabled_devices & (1 << slot->device_num);
234
235 return retval ? 1 : 0;
236}
237
238static void sn_slot_mark_enable(struct hotplug_slot *bss_hotplug_slot,
239 int device_num)
240{
241 struct slot *slot = (struct slot *)bss_hotplug_slot->private;
242 struct pcibus_info *pcibus_info;
243
244 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus);
245 pcibus_info->pbi_enabled_devices |= (1 << device_num);
246}
247
248static void sn_slot_mark_disable(struct hotplug_slot *bss_hotplug_slot,
249 int device_num)
250{
251 struct slot *slot = (struct slot *)bss_hotplug_slot->private;
252 struct pcibus_info *pcibus_info;
253
254 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus);
255 pcibus_info->pbi_enabled_devices &= ~(1 << device_num);
256}
257
258static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot,
259 int device_num)
260{
261 struct slot *slot = (struct slot *)bss_hotplug_slot->private;
262 struct pcibus_info *pcibus_info;
263 struct pcibr_slot_enable_resp resp;
264 int rc;
265
266 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus);
267
268 /*
269 * Power-on and initialize the slot in the SN
270 * PCI infrastructure.
271 */
272 rc = sal_pcibr_slot_enable(pcibus_info, device_num, &resp);
273
274 if (rc == PCI_SLOT_ALREADY_UP) {
275 dev_dbg(slot->pci_bus->self, "is already active\n");
276 return -EPERM;
277 }
278
279 if (rc == PCI_L1_ERR) {
280 dev_dbg(slot->pci_bus->self,
281 "L1 failure %d with message: %s",
282 resp.resp_sub_errno, resp.resp_l1_msg);
283 return -EPERM;
284 }
285
286 if (rc) {
287 dev_dbg(slot->pci_bus->self,
288 "insert failed with error %d sub-error %d\n",
289 rc, resp.resp_sub_errno);
290 return -EIO;
291 }
292
293 sn_slot_mark_enable(bss_hotplug_slot, device_num);
294
295 return 0;
296}
297
298static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot,
299 int device_num, int action)
300{
301 struct slot *slot = (struct slot *)bss_hotplug_slot->private;
302 struct pcibus_info *pcibus_info;
303 struct pcibr_slot_disable_resp resp;
304 int rc;
305
306 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus);
307
308 rc = sal_pcibr_slot_disable(pcibus_info, device_num, action, &resp);
309
310 if (action == PCI_REQ_SLOT_ELIGIBLE && rc == PCI_SLOT_ALREADY_DOWN) {
311 dev_dbg(slot->pci_bus->self, "Slot %s already inactive\n");
312 return -ENODEV;
313 }
314
315 if (action == PCI_REQ_SLOT_ELIGIBLE && rc == PCI_EMPTY_33MHZ) {
316 dev_dbg(slot->pci_bus->self,
317 "Cannot remove last 33MHz card\n");
318 return -EPERM;
319 }
320
321 if (action == PCI_REQ_SLOT_ELIGIBLE && rc == PCI_L1_ERR) {
322 dev_dbg(slot->pci_bus->self,
323 "L1 failure %d with message \n%s\n",
324 resp.resp_sub_errno, resp.resp_l1_msg);
325 return -EPERM;
326 }
327
328 if (action == PCI_REQ_SLOT_ELIGIBLE && rc) {
329 dev_dbg(slot->pci_bus->self,
330 "remove failed with error %d sub-error %d\n",
331 rc, resp.resp_sub_errno);
332 return -EIO;
333 }
334
335 if (action == PCI_REQ_SLOT_ELIGIBLE && !rc)
336 return 0;
337
338 if (action == PCI_REQ_SLOT_DISABLE && !rc) {
339 sn_slot_mark_disable(bss_hotplug_slot, device_num);
340 dev_dbg(slot->pci_bus->self, "remove successful\n");
341 return 0;
342 }
343
344 if (action == PCI_REQ_SLOT_DISABLE && rc) {
345 dev_dbg(slot->pci_bus->self,"remove failed rc = %d\n", rc);
346 return rc;
347 }
348
349 return rc;
350}
351
352static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
353{
354 struct slot *slot = (struct slot *)bss_hotplug_slot->private;
355 struct pci_bus *new_bus = NULL;
356 struct pci_dev *dev;
357 int func, num_funcs;
358 int new_ppb = 0;
359 int rc;
360
361 /* Serialize the Linux PCI infrastructure */
362 down(&sn_hotplug_sem);
363
364 /*
365 * Power-on and initialize the slot in the SN
366 * PCI infrastructure.
367 */
368 rc = sn_slot_enable(bss_hotplug_slot, slot->device_num);
369 if (rc) {
370 up(&sn_hotplug_sem);
371 return rc;
372 }
373
374 num_funcs = pci_scan_slot(slot->pci_bus, PCI_DEVFN(slot->device_num+1,
375 PCI_FUNC(0)));
376 if (!num_funcs) {
377 dev_dbg(slot->pci_bus->self, "no device in slot\n");
378 up(&sn_hotplug_sem);
379 return -ENODEV;
380 }
381
382 sn_pci_controller_fixup(pci_domain_nr(slot->pci_bus),
383 slot->pci_bus->number,
384 slot->pci_bus);
385 /*
386 * Map SN resources for all functions on the card
387 * to the Linux PCI interface and tell the drivers
388 * about them.
389 */
390 for (func = 0; func < num_funcs; func++) {
391 dev = pci_get_slot(slot->pci_bus,
392 PCI_DEVFN(slot->device_num + 1,
393 PCI_FUNC(func)));
394
395
396 if (dev) {
397 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
398 unsigned char sec_bus;
399 pci_read_config_byte(dev, PCI_SECONDARY_BUS,
400 &sec_bus);
401 new_bus = pci_add_new_bus(dev->bus, dev,
402 sec_bus);
403 pci_scan_child_bus(new_bus);
404 sn_pci_controller_fixup(pci_domain_nr(new_bus),
405 new_bus->number,
406 new_bus);
407 new_ppb = 1;
408 }
409 sn_bus_alloc_data(dev);
410 pci_dev_put(dev);
411 }
412 }
413
414 /* Call the driver for the new device */
415 pci_bus_add_devices(slot->pci_bus);
416 /* Call the drivers for the new devices subordinate to PPB */
417 if (new_ppb)
418 pci_bus_add_devices(new_bus);
419
420 up(&sn_hotplug_sem);
421
422 if (rc == 0)
423 dev_dbg(slot->pci_bus->self,
424 "insert operation successful\n");
425 else
426 dev_dbg(slot->pci_bus->self,
427 "insert operation failed rc = %d\n", rc);
428
429 return rc;
430}
431
432static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
433{
434 struct slot *slot = (struct slot *)bss_hotplug_slot->private;
435 struct pci_dev *dev;
436 int func;
437 int rc;
438
439 /* Acquire update access to the bus */
440 down(&sn_hotplug_sem);
441
442 /* is it okay to bring this slot down? */
443 rc = sn_slot_disable(bss_hotplug_slot, slot->device_num,
444 PCI_REQ_SLOT_ELIGIBLE);
445 if (rc)
446 goto leaving;
447
448 /* Free the SN resources assigned to the Linux device.*/
449 for (func = 0; func < 8; func++) {
450 dev = pci_get_slot(slot->pci_bus,
451 PCI_DEVFN(slot->device_num+1,
452 PCI_FUNC(func)));
453 if (dev) {
454 /*
455 * Some drivers may use dma accesses during the
456 * driver remove function. We release the sysdata
457 * areas after the driver remove functions have
458 * been called.
459 */
460 sn_bus_store_sysdata(dev);
461 sn_bus_free_data(dev);
462 pci_remove_bus_device(dev);
463 pci_dev_put(dev);
464 }
465 }
466
467 /* free the collected sysdata pointers */
468 sn_bus_free_sysdata();
469
470 /* Deactivate slot */
471 rc = sn_slot_disable(bss_hotplug_slot, slot->device_num,
472 PCI_REQ_SLOT_DISABLE);
473 leaving:
474 /* Release the bus lock */
475 up(&sn_hotplug_sem);
476
477 return rc;
478}
479
480static int get_power_status(struct hotplug_slot *bss_hotplug_slot, u8 *value)
481{
482 down(&sn_hotplug_sem);
483 *value = sn_power_status_get(bss_hotplug_slot);
484 up(&sn_hotplug_sem);
485 return 0;
486}
487
488static void sn_release_slot(struct hotplug_slot *bss_hotplug_slot)
489{
490 kfree(bss_hotplug_slot->info);
491 kfree(bss_hotplug_slot->name);
492 kfree(bss_hotplug_slot->private);
493 kfree(bss_hotplug_slot);
494}
495
496static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
497{
498 int device;
499 struct hotplug_slot *bss_hotplug_slot;
500 int rc = 0;
501
502 /*
503 * Currently only four devices are supported,
504 * in the future there maybe more -- up to 32.
505 */
506
507 for (device = 0; device < SN_MAX_HP_SLOTS ; device++) {
508 if (sn_pci_slot_valid(pci_bus, device) != 1)
509 continue;
510
511 bss_hotplug_slot = kcalloc(1,sizeof(struct hotplug_slot),
512 GFP_KERNEL);
513 if (!bss_hotplug_slot) {
514 rc = -ENOMEM;
515 goto alloc_err;
516 }
517
518 bss_hotplug_slot->info =
519 kcalloc(1,sizeof(struct hotplug_slot_info),
520 GFP_KERNEL);
521 if (!bss_hotplug_slot->info) {
522 rc = -ENOMEM;
523 goto alloc_err;
524 }
525
526 if (sn_hp_slot_private_alloc(bss_hotplug_slot,
527 pci_bus, device)) {
528 rc = -ENOMEM;
529 goto alloc_err;
530 }
531
532 bss_hotplug_slot->ops = &sn_hotplug_slot_ops;
533 bss_hotplug_slot->release = &sn_release_slot;
534
535 rc = pci_hp_register(bss_hotplug_slot);
536 if (rc)
537 goto register_err;
538 }
539 dev_dbg(pci_bus->self, "Registered bus with hotplug\n");
540 return rc;
541
542register_err:
543 dev_dbg(pci_bus->self, "bus failed to register with err = %d\n",
544 rc);
545
546alloc_err:
547 if (rc == -ENOMEM)
548 dev_dbg(pci_bus->self, "Memory allocation error\n");
549
550 /* destroy THIS element */
551 if (bss_hotplug_slot)
552 sn_release_slot(bss_hotplug_slot);
553
554 /* destroy anything else on the list */
555 while ((bss_hotplug_slot = sn_hp_destroy()))
556 pci_hp_deregister(bss_hotplug_slot);
557
558 return rc;
559}
560
561static int sn_pci_hotplug_init(void)
562{
563 struct pci_bus *pci_bus = NULL;
564 int rc;
565 int registered = 0;
566
567 INIT_LIST_HEAD(&sn_hp_list);
568
569 if (sn_sal_rev() < SGI_HOTPLUG_PROM_REV) {
570 printk(KERN_ERR "%s: PROM version must be greater than 4.05\n",
571 __FUNCTION__);
572 return -EPERM;
573 }
574
575 while ((pci_bus = pci_find_next_bus(pci_bus))) {
576 if (!pci_bus->sysdata)
577 continue;
578
579 rc = sn_pci_bus_valid(pci_bus);
580 if (rc != 1) {
581 dev_dbg(pci_bus->self, "not a valid hotplug bus\n");
582 continue;
583 }
584 dev_dbg(pci_bus->self, "valid hotplug bus\n");
585
586 rc = sn_hotplug_slot_register(pci_bus);
587 if (!rc)
588 registered = 1;
589 else {
590 registered = 0;
591 break;
592 }
593 }
594
595 return registered == 1 ? 0 : -ENODEV;
596}
597
598static void sn_pci_hotplug_exit(void)
599{
600 struct hotplug_slot *bss_hotplug_slot;
601
602 while ((bss_hotplug_slot = sn_hp_destroy())) {
603 pci_hp_deregister(bss_hotplug_slot);
604 }
605
606 if (!list_empty(&sn_hp_list))
607 printk(KERN_ERR "%s: internal list is not empty\n", __FILE__);
608}
609
610module_init(sn_pci_hotplug_init);
611module_exit(sn_pci_hotplug_exit);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index bc01d34e2634..e9e37abe1f76 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1,9 +1,10 @@
1/* 1/*
2 * File: pci-acpi.c 2 * File: pci-acpi.c
3 * Purpose: Provide PCI supports in ACPI 3 * Purpose: Provide PCI support in ACPI
4 * 4 *
5 * Copyright (C) 2004 Intel 5 * Copyright (C) 2005 David Shaohua Li <shaohua.li@intel.com>
6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com) 6 * Copyright (C) 2004 Tom Long Nguyen <tom.l.nguyen@intel.com>
7 * Copyright (C) 2004 Intel Corp.
7 */ 8 */
8 9
9#include <linux/delay.h> 10#include <linux/delay.h>
@@ -16,6 +17,7 @@
16#include <acpi/acpi_bus.h> 17#include <acpi/acpi_bus.h>
17 18
18#include <linux/pci-acpi.h> 19#include <linux/pci-acpi.h>
20#include "pci.h"
19 21
20static u32 ctrlset_buf[3] = {0, 0, 0}; 22static u32 ctrlset_buf[3] = {0, 0, 0};
21static u32 global_ctrlsets = 0; 23static u32 global_ctrlsets = 0;
@@ -207,3 +209,105 @@ acpi_status pci_osc_control_set(u32 flags)
207 return status; 209 return status;
208} 210}
209EXPORT_SYMBOL(pci_osc_control_set); 211EXPORT_SYMBOL(pci_osc_control_set);
212
213/*
214 * _SxD returns the D-state with the highest power
215 * (lowest D-state number) supported in the S-state "x".
216 *
217 * If the devices does not have a _PRW
218 * (Power Resources for Wake) supporting system wakeup from "x"
219 * then the OS is free to choose a lower power (higher number
220 * D-state) than the return value from _SxD.
221 *
222 * But if _PRW is enabled at S-state "x", the OS
223 * must not choose a power lower than _SxD --
224 * unless the device has an _SxW method specifying
225 * the lowest power (highest D-state number) the device
226 * may enter while still able to wake the system.
227 *
228 * ie. depending on global OS policy:
229 *
230 * if (_PRW at S-state x)
231 * choose from highest power _SxD to lowest power _SxW
232 * else // no _PRW at S-state x
233 * choose highest power _SxD or any lower power
234 *
235 * currently we simply return _SxD, if present.
236 */
237
238static int acpi_pci_choose_state(struct pci_dev *pdev, pm_message_t state)
239{
240 /* TBD */
241
242 return -ENODEV;
243}
244
245static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
246{
247 acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
248 static int state_conv[] = {
249 [0] = 0,
250 [1] = 1,
251 [2] = 2,
252 [3] = 3,
253 [4] = 3
254 };
255 int acpi_state = state_conv[(int __force) state];
256
257 if (!handle)
258 return -ENODEV;
259 return acpi_bus_set_power(handle, acpi_state);
260}
261
262
263/* ACPI bus type */
264static int pci_acpi_find_device(struct device *dev, acpi_handle *handle)
265{
266 struct pci_dev * pci_dev;
267 acpi_integer addr;
268
269 pci_dev = to_pci_dev(dev);
270 /* Please ref to ACPI spec for the syntax of _ADR */
271 addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
272 *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr);
273 if (!*handle)
274 return -ENODEV;
275 return 0;
276}
277
278static int pci_acpi_find_root_bridge(struct device *dev, acpi_handle *handle)
279{
280 int num;
281 unsigned int seg, bus;
282
283 /*
284 * The string should be the same as root bridge's name
285 * Please look at 'pci_scan_bus_parented'
286 */
287 num = sscanf(dev->bus_id, "pci%04x:%02x", &seg, &bus);
288 if (num != 2)
289 return -ENODEV;
290 *handle = acpi_get_pci_rootbridge_handle(seg, bus);
291 if (!*handle)
292 return -ENODEV;
293 return 0;
294}
295
296static struct acpi_bus_type pci_acpi_bus = {
297 .bus = &pci_bus_type,
298 .find_device = pci_acpi_find_device,
299 .find_bridge = pci_acpi_find_root_bridge,
300};
301
302static int __init pci_acpi_init(void)
303{
304 int ret;
305
306 ret = register_acpi_bus_type(&pci_acpi_bus);
307 if (ret)
308 return 0;
309 platform_pci_choose_state = acpi_pci_choose_state;
310 platform_pci_set_power_state = acpi_pci_set_power_state;
311 return 0;
312}
313arch_initcall(pci_acpi_init);
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index e65bf2b395aa..e4115a0d5ba6 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -7,7 +7,6 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/device.h> 9#include <linux/device.h>
10#include <linux/pci-dynids.h>
11#include "pci.h" 10#include "pci.h"
12 11
13/* 12/*
@@ -18,36 +17,12 @@
18 * Dynamic device IDs are disabled for !CONFIG_HOTPLUG 17 * Dynamic device IDs are disabled for !CONFIG_HOTPLUG
19 */ 18 */
20 19
21#ifdef CONFIG_HOTPLUG 20struct pci_dynid {
22/** 21 struct list_head node;
23 * pci_device_probe_dynamic() 22 struct pci_device_id id;
24 * 23};
25 * Walk the dynamic ID list looking for a match.
26 * returns 0 and sets pci_dev->driver when drv claims pci_dev, else error.
27 */
28static int
29pci_device_probe_dynamic(struct pci_driver *drv, struct pci_dev *pci_dev)
30{
31 int error = -ENODEV;
32 struct list_head *pos;
33 struct dynid *dynid;
34 24
35 spin_lock(&drv->dynids.lock); 25#ifdef CONFIG_HOTPLUG
36 list_for_each(pos, &drv->dynids.list) {
37 dynid = list_entry(pos, struct dynid, node);
38 if (pci_match_one_device(&dynid->id, pci_dev)) {
39 spin_unlock(&drv->dynids.lock);
40 error = drv->probe(pci_dev, &dynid->id);
41 if (error >= 0) {
42 pci_dev->driver = drv;
43 return 0;
44 }
45 return error;
46 }
47 }
48 spin_unlock(&drv->dynids.lock);
49 return error;
50}
51 26
52/** 27/**
53 * store_new_id 28 * store_new_id
@@ -58,8 +33,7 @@ pci_device_probe_dynamic(struct pci_driver *drv, struct pci_dev *pci_dev)
58static inline ssize_t 33static inline ssize_t
59store_new_id(struct device_driver *driver, const char *buf, size_t count) 34store_new_id(struct device_driver *driver, const char *buf, size_t count)
60{ 35{
61 struct dynid *dynid; 36 struct pci_dynid *dynid;
62 struct bus_type * bus;
63 struct pci_driver *pdrv = to_pci_driver(driver); 37 struct pci_driver *pdrv = to_pci_driver(driver);
64 __u32 vendor=PCI_ANY_ID, device=PCI_ANY_ID, subvendor=PCI_ANY_ID, 38 __u32 vendor=PCI_ANY_ID, device=PCI_ANY_ID, subvendor=PCI_ANY_ID,
65 subdevice=PCI_ANY_ID, class=0, class_mask=0; 39 subdevice=PCI_ANY_ID, class=0, class_mask=0;
@@ -91,37 +65,22 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
91 list_add_tail(&pdrv->dynids.list, &dynid->node); 65 list_add_tail(&pdrv->dynids.list, &dynid->node);
92 spin_unlock(&pdrv->dynids.lock); 66 spin_unlock(&pdrv->dynids.lock);
93 67
94 bus = get_bus(pdrv->driver.bus); 68 if (get_driver(&pdrv->driver)) {
95 if (bus) { 69 driver_attach(&pdrv->driver);
96 if (get_driver(&pdrv->driver)) { 70 put_driver(&pdrv->driver);
97 down_write(&bus->subsys.rwsem);
98 driver_attach(&pdrv->driver);
99 up_write(&bus->subsys.rwsem);
100 put_driver(&pdrv->driver);
101 }
102 put_bus(bus);
103 } 71 }
104 72
105 return count; 73 return count;
106} 74}
107
108static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 75static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
109static inline void
110pci_init_dynids(struct pci_dynids *dynids)
111{
112 spin_lock_init(&dynids->lock);
113 INIT_LIST_HEAD(&dynids->list);
114}
115 76
116static void 77static void
117pci_free_dynids(struct pci_driver *drv) 78pci_free_dynids(struct pci_driver *drv)
118{ 79{
119 struct list_head *pos, *n; 80 struct pci_dynid *dynid, *n;
120 struct dynid *dynid;
121 81
122 spin_lock(&drv->dynids.lock); 82 spin_lock(&drv->dynids.lock);
123 list_for_each_safe(pos, n, &drv->dynids.list) { 83 list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
124 dynid = list_entry(pos, struct dynid, node);
125 list_del(&dynid->node); 84 list_del(&dynid->node);
126 kfree(dynid); 85 kfree(dynid);
127 } 86 }
@@ -138,83 +97,70 @@ pci_create_newid_file(struct pci_driver *drv)
138 return error; 97 return error;
139} 98}
140 99
141static int
142pci_bus_match_dynids(const struct pci_dev *pci_dev, struct pci_driver *pci_drv)
143{
144 struct list_head *pos;
145 struct dynid *dynid;
146
147 spin_lock(&pci_drv->dynids.lock);
148 list_for_each(pos, &pci_drv->dynids.list) {
149 dynid = list_entry(pos, struct dynid, node);
150 if (pci_match_one_device(&dynid->id, pci_dev)) {
151 spin_unlock(&pci_drv->dynids.lock);
152 return 1;
153 }
154 }
155 spin_unlock(&pci_drv->dynids.lock);
156 return 0;
157}
158
159#else /* !CONFIG_HOTPLUG */ 100#else /* !CONFIG_HOTPLUG */
160static inline int pci_device_probe_dynamic(struct pci_driver *drv, struct pci_dev *pci_dev)
161{
162 return -ENODEV;
163}
164static inline void pci_init_dynids(struct pci_dynids *dynids) {}
165static inline void pci_free_dynids(struct pci_driver *drv) {} 101static inline void pci_free_dynids(struct pci_driver *drv) {}
166static inline int pci_create_newid_file(struct pci_driver *drv) 102static inline int pci_create_newid_file(struct pci_driver *drv)
167{ 103{
168 return 0; 104 return 0;
169} 105}
170static inline int pci_bus_match_dynids(const struct pci_dev *pci_dev, struct pci_driver *pci_drv)
171{
172 return 0;
173}
174#endif 106#endif
175 107
176/** 108/**
177 * pci_match_device - Tell if a PCI device structure has a matching 109 * pci_match_id - See if a pci device matches a given pci_id table
178 * PCI device id structure
179 * @ids: array of PCI device id structures to search in 110 * @ids: array of PCI device id structures to search in
180 * @dev: the PCI device structure to match against 111 * @dev: the PCI device structure to match against.
181 * 112 *
182 * Used by a driver to check whether a PCI device present in the 113 * Used by a driver to check whether a PCI device present in the
183 * system is in its list of supported devices.Returns the matching 114 * system is in its list of supported devices. Returns the matching
184 * pci_device_id structure or %NULL if there is no match. 115 * pci_device_id structure or %NULL if there is no match.
116 *
117 * Depreciated, don't use this as it will not catch any dynamic ids
118 * that a driver might want to check for.
185 */ 119 */
186const struct pci_device_id * 120const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
187pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) 121 struct pci_dev *dev)
188{ 122{
189 while (ids->vendor || ids->subvendor || ids->class_mask) { 123 if (ids) {
190 if (pci_match_one_device(ids, dev)) 124 while (ids->vendor || ids->subvendor || ids->class_mask) {
191 return ids; 125 if (pci_match_one_device(ids, dev))
192 ids++; 126 return ids;
127 ids++;
128 }
193 } 129 }
194 return NULL; 130 return NULL;
195} 131}
196 132
197/** 133/**
198 * pci_device_probe_static() 134 * pci_match_device - Tell if a PCI device structure has a matching
199 * 135 * PCI device id structure
200 * returns 0 and sets pci_dev->driver when drv claims pci_dev, else error. 136 * @ids: array of PCI device id structures to search in
137 * @dev: the PCI device structure to match against
138 * @drv: the PCI driver to match against
139 *
140 * Used by a driver to check whether a PCI device present in the
141 * system is in its list of supported devices. Returns the matching
142 * pci_device_id structure or %NULL if there is no match.
201 */ 143 */
202static int 144const struct pci_device_id *pci_match_device(struct pci_driver *drv,
203pci_device_probe_static(struct pci_driver *drv, struct pci_dev *pci_dev) 145 struct pci_dev *dev)
204{ 146{
205 int error = -ENODEV;
206 const struct pci_device_id *id; 147 const struct pci_device_id *id;
148 struct pci_dynid *dynid;
207 149
208 if (!drv->id_table) 150 id = pci_match_id(drv->id_table, dev);
209 return error;
210 id = pci_match_device(drv->id_table, pci_dev);
211 if (id) 151 if (id)
212 error = drv->probe(pci_dev, id); 152 return id;
213 if (error >= 0) { 153
214 pci_dev->driver = drv; 154 /* static ids didn't match, lets look at the dynamic ones */
215 error = 0; 155 spin_lock(&drv->dynids.lock);
156 list_for_each_entry(dynid, &drv->dynids.list, node) {
157 if (pci_match_one_device(&dynid->id, dev)) {
158 spin_unlock(&drv->dynids.lock);
159 return &dynid->id;
160 }
216 } 161 }
217 return error; 162 spin_unlock(&drv->dynids.lock);
163 return NULL;
218} 164}
219 165
220/** 166/**
@@ -225,13 +171,20 @@ pci_device_probe_static(struct pci_driver *drv, struct pci_dev *pci_dev)
225 */ 171 */
226static int 172static int
227__pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) 173__pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)
228{ 174{
175 const struct pci_device_id *id;
229 int error = 0; 176 int error = 0;
230 177
231 if (!pci_dev->driver && drv->probe) { 178 if (!pci_dev->driver && drv->probe) {
232 error = pci_device_probe_static(drv, pci_dev); 179 error = -ENODEV;
233 if (error == -ENODEV) 180
234 error = pci_device_probe_dynamic(drv, pci_dev); 181 id = pci_match_device(drv, pci_dev);
182 if (id)
183 error = drv->probe(pci_dev, id);
184 if (error >= 0) {
185 pci_dev->driver = drv;
186 error = 0;
187 }
235 } 188 }
236 return error; 189 return error;
237} 190}
@@ -371,12 +324,6 @@ static struct kobj_type pci_driver_kobj_type = {
371 .sysfs_ops = &pci_driver_sysfs_ops, 324 .sysfs_ops = &pci_driver_sysfs_ops,
372}; 325};
373 326
374static int
375pci_populate_driver_dir(struct pci_driver *drv)
376{
377 return pci_create_newid_file(drv);
378}
379
380/** 327/**
381 * pci_register_driver - register a new pci driver 328 * pci_register_driver - register a new pci driver
382 * @drv: the driver structure to register 329 * @drv: the driver structure to register
@@ -401,13 +348,15 @@ int pci_register_driver(struct pci_driver *drv)
401 drv->driver.shutdown = pci_device_shutdown; 348 drv->driver.shutdown = pci_device_shutdown;
402 drv->driver.owner = drv->owner; 349 drv->driver.owner = drv->owner;
403 drv->driver.kobj.ktype = &pci_driver_kobj_type; 350 drv->driver.kobj.ktype = &pci_driver_kobj_type;
404 pci_init_dynids(&drv->dynids); 351
352 spin_lock_init(&drv->dynids.lock);
353 INIT_LIST_HEAD(&drv->dynids.list);
405 354
406 /* register with core */ 355 /* register with core */
407 error = driver_register(&drv->driver); 356 error = driver_register(&drv->driver);
408 357
409 if (!error) 358 if (!error)
410 pci_populate_driver_dir(drv); 359 error = pci_create_newid_file(drv);
411 360
412 return error; 361 return error;
413} 362}
@@ -463,21 +412,17 @@ pci_dev_driver(const struct pci_dev *dev)
463 * system is in its list of supported devices.Returns the matching 412 * system is in its list of supported devices.Returns the matching
464 * pci_device_id structure or %NULL if there is no match. 413 * pci_device_id structure or %NULL if there is no match.
465 */ 414 */
466static int pci_bus_match(struct device * dev, struct device_driver * drv) 415static int pci_bus_match(struct device *dev, struct device_driver *drv)
467{ 416{
468 const struct pci_dev * pci_dev = to_pci_dev(dev); 417 struct pci_dev *pci_dev = to_pci_dev(dev);
469 struct pci_driver * pci_drv = to_pci_driver(drv); 418 struct pci_driver *pci_drv = to_pci_driver(drv);
470 const struct pci_device_id * ids = pci_drv->id_table;
471 const struct pci_device_id *found_id; 419 const struct pci_device_id *found_id;
472 420
473 if (!ids) 421 found_id = pci_match_device(pci_drv, pci_dev);
474 return 0;
475
476 found_id = pci_match_device(ids, pci_dev);
477 if (found_id) 422 if (found_id)
478 return 1; 423 return 1;
479 424
480 return pci_bus_match_dynids(pci_dev, pci_drv); 425 return 0;
481} 426}
482 427
483/** 428/**
@@ -536,6 +481,7 @@ static int __init pci_driver_init(void)
536 481
537postcore_initcall(pci_driver_init); 482postcore_initcall(pci_driver_init);
538 483
484EXPORT_SYMBOL(pci_match_id);
539EXPORT_SYMBOL(pci_match_device); 485EXPORT_SYMBOL(pci_match_device);
540EXPORT_SYMBOL(pci_register_driver); 486EXPORT_SYMBOL(pci_register_driver);
541EXPORT_SYMBOL(pci_unregister_driver); 487EXPORT_SYMBOL(pci_unregister_driver);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index f04b9ffe4153..1b34fc56067e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -235,7 +235,7 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
235 * -EIO if device does not support PCI PM. 235 * -EIO if device does not support PCI PM.
236 * 0 if we can successfully change the power state. 236 * 0 if we can successfully change the power state.
237 */ 237 */
238 238int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t t);
239int 239int
240pci_set_power_state(struct pci_dev *dev, pci_power_t state) 240pci_set_power_state(struct pci_dev *dev, pci_power_t state)
241{ 241{
@@ -299,11 +299,20 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
299 msleep(10); 299 msleep(10);
300 else if (state == PCI_D2 || dev->current_state == PCI_D2) 300 else if (state == PCI_D2 || dev->current_state == PCI_D2)
301 udelay(200); 301 udelay(200);
302 dev->current_state = state;
303 302
303 /*
304 * Give firmware a chance to be called, such as ACPI _PRx, _PSx
305 * Firmware method after natice method ?
306 */
307 if (platform_pci_set_power_state)
308 platform_pci_set_power_state(dev, state);
309
310 dev->current_state = state;
304 return 0; 311 return 0;
305} 312}
306 313
314int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
315
307/** 316/**
308 * pci_choose_state - Choose the power state of a PCI device 317 * pci_choose_state - Choose the power state of a PCI device
309 * @dev: PCI device to be suspended 318 * @dev: PCI device to be suspended
@@ -316,10 +325,17 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
316 325
317pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) 326pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
318{ 327{
328 int ret;
329
319 if (!pci_find_capability(dev, PCI_CAP_ID_PM)) 330 if (!pci_find_capability(dev, PCI_CAP_ID_PM))
320 return PCI_D0; 331 return PCI_D0;
321 332
322 switch (state) { 333 if (platform_pci_choose_state) {
334 ret = platform_pci_choose_state(dev, state);
335 if (ret >= 0)
336 state = ret;
337 }
338 switch (state) {
323 case 0: return PCI_D0; 339 case 0: return PCI_D0;
324 case 3: return PCI_D3hot; 340 case 3: return PCI_D3hot;
325 default: 341 default:
@@ -334,10 +350,6 @@ EXPORT_SYMBOL(pci_choose_state);
334/** 350/**
335 * pci_save_state - save the PCI configuration space of a device before suspending 351 * pci_save_state - save the PCI configuration space of a device before suspending
336 * @dev: - PCI device that we're dealing with 352 * @dev: - PCI device that we're dealing with
337 * @buffer: - buffer to hold config space context
338 *
339 * @buffer must be large enough to hold the entire PCI 2.2 config space
340 * (>= 64 bytes).
341 */ 353 */
342int 354int
343pci_save_state(struct pci_dev *dev) 355pci_save_state(struct pci_dev *dev)
@@ -352,8 +364,6 @@ pci_save_state(struct pci_dev *dev)
352/** 364/**
353 * pci_restore_state - Restore the saved state of a PCI device 365 * pci_restore_state - Restore the saved state of a PCI device
354 * @dev: - PCI device that we're dealing with 366 * @dev: - PCI device that we're dealing with
355 * @buffer: - saved PCI config space
356 *
357 */ 367 */
358int 368int
359pci_restore_state(struct pci_dev *dev) 369pci_restore_state(struct pci_dev *dev)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 744da0d4ae5f..d94d7af4f7a0 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -11,6 +11,10 @@ extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
11 void (*alignf)(void *, struct resource *, 11 void (*alignf)(void *, struct resource *,
12 unsigned long, unsigned long), 12 unsigned long, unsigned long),
13 void *alignf_data); 13 void *alignf_data);
14/* Firmware callbacks */
15extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
16extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state);
17
14/* PCI /proc functions */ 18/* PCI /proc functions */
15#ifdef CONFIG_PROC_FS 19#ifdef CONFIG_PROC_FS
16extern int pci_proc_attach_device(struct pci_dev *dev); 20extern int pci_proc_attach_device(struct pci_dev *dev);
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h
index 537b372dc340..a63bd8f72601 100644
--- a/drivers/pci/pcie/portdrv.h
+++ b/drivers/pci/pcie/portdrv.h
@@ -27,6 +27,11 @@
27 27
28#define get_descriptor_id(type, service) (((type - 4) << 4) | service) 28#define get_descriptor_id(type, service) (((type - 4) << 4) | service)
29 29
30struct pcie_port_device_ext {
31 int interrupt_mode; /* [0:INTx | 1:MSI | 2:MSI-X] */
32 unsigned int saved_msi_config_space[5];
33};
34
30extern struct bus_type pcie_port_bus_type; 35extern struct bus_type pcie_port_bus_type;
31extern int pcie_port_device_probe(struct pci_dev *dev); 36extern int pcie_port_device_probe(struct pci_dev *dev);
32extern int pcie_port_device_register(struct pci_dev *dev); 37extern int pcie_port_device_register(struct pci_dev *dev);
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index f5c5f10a3d2f..393e0cee91a9 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -275,10 +275,17 @@ int pcie_port_device_probe(struct pci_dev *dev)
275 275
276int pcie_port_device_register(struct pci_dev *dev) 276int pcie_port_device_register(struct pci_dev *dev)
277{ 277{
278 struct pcie_port_device_ext *p_ext;
278 int status, type, capabilities, irq_mode, i; 279 int status, type, capabilities, irq_mode, i;
279 int vectors[PCIE_PORT_DEVICE_MAXSERVICES]; 280 int vectors[PCIE_PORT_DEVICE_MAXSERVICES];
280 u16 reg16; 281 u16 reg16;
281 282
283 /* Allocate port device extension */
284 if (!(p_ext = kmalloc(sizeof(struct pcie_port_device_ext), GFP_KERNEL)))
285 return -ENOMEM;
286
287 pci_set_drvdata(dev, p_ext);
288
282 /* Get port type */ 289 /* Get port type */
283 pci_read_config_word(dev, 290 pci_read_config_word(dev,
284 pci_find_capability(dev, PCI_CAP_ID_EXP) + 291 pci_find_capability(dev, PCI_CAP_ID_EXP) +
@@ -288,6 +295,7 @@ int pcie_port_device_register(struct pci_dev *dev)
288 /* Now get port services */ 295 /* Now get port services */
289 capabilities = get_port_device_capability(dev); 296 capabilities = get_port_device_capability(dev);
290 irq_mode = assign_interrupt_mode(dev, vectors, capabilities); 297 irq_mode = assign_interrupt_mode(dev, vectors, capabilities);
298 p_ext->interrupt_mode = irq_mode;
291 299
292 /* Allocate child services if any */ 300 /* Allocate child services if any */
293 for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) { 301 for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) {
@@ -317,7 +325,7 @@ int pcie_port_device_register(struct pci_dev *dev)
317static int suspend_iter(struct device *dev, void *data) 325static int suspend_iter(struct device *dev, void *data)
318{ 326{
319 struct pcie_port_service_driver *service_driver; 327 struct pcie_port_service_driver *service_driver;
320 u32 state = (u32)data; 328 pm_message_t state = * (pm_message_t *) data;
321 329
322 if ((dev->bus == &pcie_port_bus_type) && 330 if ((dev->bus == &pcie_port_bus_type) &&
323 (dev->driver)) { 331 (dev->driver)) {
@@ -328,9 +336,9 @@ static int suspend_iter(struct device *dev, void *data)
328 return 0; 336 return 0;
329} 337}
330 338
331int pcie_port_device_suspend(struct pci_dev *dev, u32 state) 339int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state)
332{ 340{
333 device_for_each_child(&dev->dev, (void *)state, suspend_iter); 341 device_for_each_child(&dev->dev, &state, suspend_iter);
334 return 0; 342 return 0;
335} 343}
336 344
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index e9095ee508e3..30bac7ed7c16 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -29,6 +29,78 @@ MODULE_LICENSE("GPL");
29/* global data */ 29/* global data */
30static const char device_name[] = "pcieport-driver"; 30static const char device_name[] = "pcieport-driver";
31 31
32static void pci_save_msi_state(struct pci_dev *dev)
33{
34 struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
35 int i = 0, pos;
36 u16 control;
37
38 if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0)
39 return;
40
41 pci_read_config_dword(dev, pos, &p_ext->saved_msi_config_space[i++]);
42 control = p_ext->saved_msi_config_space[0] >> 16;
43 pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_LO,
44 &p_ext->saved_msi_config_space[i++]);
45 if (control & PCI_MSI_FLAGS_64BIT) {
46 pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_HI,
47 &p_ext->saved_msi_config_space[i++]);
48 pci_read_config_dword(dev, pos + PCI_MSI_DATA_64,
49 &p_ext->saved_msi_config_space[i++]);
50 } else
51 pci_read_config_dword(dev, pos + PCI_MSI_DATA_32,
52 &p_ext->saved_msi_config_space[i++]);
53 if (control & PCI_MSI_FLAGS_MASKBIT)
54 pci_read_config_dword(dev, pos + PCI_MSI_MASK_BIT,
55 &p_ext->saved_msi_config_space[i++]);
56}
57
58static void pci_restore_msi_state(struct pci_dev *dev)
59{
60 struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
61 int i = 0, pos;
62 u16 control;
63
64 if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0)
65 return;
66
67 control = p_ext->saved_msi_config_space[i++] >> 16;
68 pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control);
69 pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_LO,
70 p_ext->saved_msi_config_space[i++]);
71 if (control & PCI_MSI_FLAGS_64BIT) {
72 pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_HI,
73 p_ext->saved_msi_config_space[i++]);
74 pci_write_config_dword(dev, pos + PCI_MSI_DATA_64,
75 p_ext->saved_msi_config_space[i++]);
76 } else
77 pci_write_config_dword(dev, pos + PCI_MSI_DATA_32,
78 p_ext->saved_msi_config_space[i++]);
79 if (control & PCI_MSI_FLAGS_MASKBIT)
80 pci_write_config_dword(dev, pos + PCI_MSI_MASK_BIT,
81 p_ext->saved_msi_config_space[i++]);
82}
83
84static void pcie_portdrv_save_config(struct pci_dev *dev)
85{
86 struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
87
88 pci_save_state(dev);
89 if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE)
90 pci_save_msi_state(dev);
91}
92
93static void pcie_portdrv_restore_config(struct pci_dev *dev)
94{
95 struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
96
97 pci_restore_state(dev);
98 if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE)
99 pci_restore_msi_state(dev);
100 pci_enable_device(dev);
101 pci_set_master(dev);
102}
103
32/* 104/*
33 * pcie_portdrv_probe - Probe PCI-Express port devices 105 * pcie_portdrv_probe - Probe PCI-Express port devices
34 * @dev: PCI-Express port device being probed 106 * @dev: PCI-Express port device being probed
@@ -64,16 +136,21 @@ static int __devinit pcie_portdrv_probe (struct pci_dev *dev,
64static void pcie_portdrv_remove (struct pci_dev *dev) 136static void pcie_portdrv_remove (struct pci_dev *dev)
65{ 137{
66 pcie_port_device_remove(dev); 138 pcie_port_device_remove(dev);
139 kfree(pci_get_drvdata(dev));
67} 140}
68 141
69#ifdef CONFIG_PM 142#ifdef CONFIG_PM
70static int pcie_portdrv_suspend (struct pci_dev *dev, pm_message_t state) 143static int pcie_portdrv_suspend (struct pci_dev *dev, pm_message_t state)
71{ 144{
72 return pcie_port_device_suspend(dev, state); 145 int ret = pcie_port_device_suspend(dev, state);
146
147 pcie_portdrv_save_config(dev);
148 return ret;
73} 149}
74 150
75static int pcie_portdrv_resume (struct pci_dev *dev) 151static int pcie_portdrv_resume (struct pci_dev *dev)
76{ 152{
153 pcie_portdrv_restore_config(dev);
77 return pcie_port_device_resume(dev); 154 return pcie_port_device_resume(dev);
78} 155}
79#endif 156#endif
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6a0a82f0508b..df3bdae2040f 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -239,9 +239,8 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
239 239
240 if (dev->transparent) { 240 if (dev->transparent) {
241 printk(KERN_INFO "PCI: Transparent bridge - %s\n", pci_name(dev)); 241 printk(KERN_INFO "PCI: Transparent bridge - %s\n", pci_name(dev));
242 for(i = 0; i < PCI_BUS_NUM_RESOURCES; i++) 242 for(i = 3; i < PCI_BUS_NUM_RESOURCES; i++)
243 child->resource[i] = child->parent->resource[i]; 243 child->resource[i] = child->parent->resource[i - 3];
244 return;
245 } 244 }
246 245
247 for(i=0; i<3; i++) 246 for(i=0; i<3; i++)
@@ -398,6 +397,16 @@ static void pci_enable_crs(struct pci_dev *dev)
398 pci_write_config_word(dev, rpcap + PCI_EXP_RTCTL, rpctl); 397 pci_write_config_word(dev, rpcap + PCI_EXP_RTCTL, rpctl);
399} 398}
400 399
400static void __devinit pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max)
401{
402 struct pci_bus *parent = child->parent;
403 while (parent->parent && parent->subordinate < max) {
404 parent->subordinate = max;
405 pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, max);
406 parent = parent->parent;
407 }
408}
409
401unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus); 410unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus);
402 411
403/* 412/*
@@ -499,7 +508,13 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
499 508
500 if (!is_cardbus) { 509 if (!is_cardbus) {
501 child->bridge_ctl = PCI_BRIDGE_CTL_NO_ISA; 510 child->bridge_ctl = PCI_BRIDGE_CTL_NO_ISA;
502 511 /*
512 * Adjust subordinate busnr in parent buses.
513 * We do this before scanning for children because
514 * some devices may not be detected if the bios
515 * was lazy.
516 */
517 pci_fixup_parent_subordinate_busnr(child, max);
503 /* Now we can scan all subordinate buses... */ 518 /* Now we can scan all subordinate buses... */
504 max = pci_scan_child_bus(child); 519 max = pci_scan_child_bus(child);
505 } else { 520 } else {
@@ -513,6 +528,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
513 max+i+1)) 528 max+i+1))
514 break; 529 break;
515 max += i; 530 max += i;
531 pci_fixup_parent_subordinate_busnr(child, max);
516 } 532 }
517 /* 533 /*
518 * Set the subordinate bus number to its real value. 534 * Set the subordinate bus number to its real value.
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 968033fd29f0..1521fd5d95cc 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -767,6 +767,7 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
767 if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) { 767 if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) {
768 if (dev->device == PCI_DEVICE_ID_INTEL_82845_HB) 768 if (dev->device == PCI_DEVICE_ID_INTEL_82845_HB)
769 switch(dev->subsystem_device) { 769 switch(dev->subsystem_device) {
770 case 0x8025: /* P4B-LX */
770 case 0x8070: /* P4B */ 771 case 0x8070: /* P4B */
771 case 0x8088: /* P4B533 */ 772 case 0x8088: /* P4B533 */
772 case 0x1626: /* L3C notebook */ 773 case 0x1626: /* L3C notebook */
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index a90a533eba0f..05fa91a31c62 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -379,6 +379,7 @@ exit:
379EXPORT_SYMBOL(pci_dev_present); 379EXPORT_SYMBOL(pci_dev_present);
380 380
381EXPORT_SYMBOL(pci_find_bus); 381EXPORT_SYMBOL(pci_find_bus);
382EXPORT_SYMBOL(pci_find_next_bus);
382EXPORT_SYMBOL(pci_find_device); 383EXPORT_SYMBOL(pci_find_device);
383EXPORT_SYMBOL(pci_find_device_reverse); 384EXPORT_SYMBOL(pci_find_device_reverse);
384EXPORT_SYMBOL(pci_find_slot); 385EXPORT_SYMBOL(pci_find_slot);
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 6b628de948af..9fe48f712be9 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -74,6 +74,7 @@ pbus_assign_resources_sorted(struct pci_bus *bus)
74 idx = res - &list->dev->resource[0]; 74 idx = res - &list->dev->resource[0];
75 if (pci_assign_resource(list->dev, idx)) { 75 if (pci_assign_resource(list->dev, idx)) {
76 res->start = 0; 76 res->start = 0;
77 res->end = 0;
77 res->flags = 0; 78 res->flags = 0;
78 } 79 }
79 tmp = list; 80 tmp = list;
@@ -273,6 +274,8 @@ find_free_bus_resource(struct pci_bus *bus, unsigned long type)
273 274
274 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { 275 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
275 r = bus->resource[i]; 276 r = bus->resource[i];
277 if (r == &ioport_resource || r == &iomem_resource)
278 continue;
276 if (r && (r->flags & type_mask) == type && !r->parent) 279 if (r && (r->flags & type_mask) == type && !r->parent)
277 return r; 280 return r;
278 } 281 }
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 52ea34594363..6485f75d2fb3 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -1,8 +1,5 @@
1# 1#
2# PCMCIA bus subsystem configuration 2# PCCARD (PCMCIA/CardBus) bus subsystem configuration
3#
4# Right now the non-CardBus choices are not supported
5# by the integrated kernel driver.
6# 3#
7 4
8menu "PCCARD (PCMCIA/CardBus) support" 5menu "PCCARD (PCMCIA/CardBus) support"
@@ -32,7 +29,7 @@ config PCMCIA_DEBUG
32 29
33 The kernel command line options are: 30 The kernel command line options are:
34 pcmcia_core.pc_debug=N 31 pcmcia_core.pc_debug=N
35 ds.pc_debug=N 32 pcmcia.pc_debug=N
36 sa11xx_core.pc_debug=N 33 sa11xx_core.pc_debug=N
37 34
38 The module option is called pc_debug=N 35 The module option is called pc_debug=N
@@ -73,7 +70,7 @@ config PCMCIA_LOAD_CIS
73 If unsure, say Y. 70 If unsure, say Y.
74 71
75config PCMCIA_IOCTL 72config PCMCIA_IOCTL
76 bool 73 bool "PCMCIA control ioctl (obsolete)"
77 depends on PCMCIA 74 depends on PCMCIA
78 default y 75 default y
79 help 76 help
@@ -81,9 +78,8 @@ config PCMCIA_IOCTL
81 subsystem will be built. It is needed by cardmgr and cardctl 78 subsystem will be built. It is needed by cardmgr and cardctl
82 (pcmcia-cs) to function properly. 79 (pcmcia-cs) to function properly.
83 80
84 If you do not use the new pcmciautils package, and have a 81 You should use the new pcmciautils package instead (see
85 yenta, Cirrus PD6729, i82092, i82365 or tcic compatible bridge, 82 <file:Documentation/Changes> for location and details).
86 you need to say Y here to be able to use 16-bit PCMCIA cards.
87 83
88 If unsure, say Y. 84 If unsure, say Y.
89 85
@@ -106,7 +102,8 @@ comment "PC-card bridges"
106 102
107config YENTA 103config YENTA
108 tristate "CardBus yenta-compatible bridge support" 104 tristate "CardBus yenta-compatible bridge support"
109 depends on CARDBUS 105 depends on PCI
106 select CARDBUS if !EMBEDDED
110 select PCCARD_NONSTATIC 107 select PCCARD_NONSTATIC
111 ---help--- 108 ---help---
112 This option enables support for CardBus host bridges. Virtually 109 This option enables support for CardBus host bridges. Virtually
diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h
index 417bc1500bad..d5122b1ea94b 100644
--- a/drivers/pcmcia/au1000_generic.h
+++ b/drivers/pcmcia/au1000_generic.h
@@ -22,7 +22,6 @@
22#define __ASM_AU1000_PCMCIA_H 22#define __ASM_AU1000_PCMCIA_H
23 23
24/* include the world */ 24/* include the world */
25#include <pcmcia/version.h>
26#include <pcmcia/cs_types.h> 25#include <pcmcia/cs_types.h>
27#include <pcmcia/cs.h> 26#include <pcmcia/cs.h>
28#include <pcmcia/ss.h> 27#include <pcmcia/ss.h>
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c
index df19ce1ea4f3..d414a3bb50b9 100644
--- a/drivers/pcmcia/au1000_pb1x00.c
+++ b/drivers/pcmcia/au1000_pb1x00.c
@@ -33,7 +33,6 @@
33#include <linux/version.h> 33#include <linux/version.h>
34#include <linux/types.h> 34#include <linux/types.h>
35 35
36#include <pcmcia/version.h>
37#include <pcmcia/cs_types.h> 36#include <pcmcia/cs_types.h>
38#include <pcmcia/cs.h> 37#include <pcmcia/cs.h>
39#include <pcmcia/ss.h> 38#include <pcmcia/ss.h>
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c
index 1dfc77653660..f113b69d699b 100644
--- a/drivers/pcmcia/au1000_xxs1500.c
+++ b/drivers/pcmcia/au1000_xxs1500.c
@@ -38,7 +38,6 @@
38#include <linux/version.h> 38#include <linux/version.h>
39#include <linux/types.h> 39#include <linux/types.h>
40 40
41#include <pcmcia/version.h>
42#include <pcmcia/cs_types.h> 41#include <pcmcia/cs_types.h>
43#include <pcmcia/cs.h> 42#include <pcmcia/cs.h>
44#include <pcmcia/ss.h> 43#include <pcmcia/ss.h>
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index 3ccb5247ec50..1d755e20880c 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -31,7 +31,6 @@
31#include <asm/io.h> 31#include <asm/io.h>
32 32
33#define IN_CARD_SERVICES 33#define IN_CARD_SERVICES
34#include <pcmcia/version.h>
35#include <pcmcia/cs_types.h> 34#include <pcmcia/cs_types.h>
36#include <pcmcia/ss.h> 35#include <pcmcia/ss.h>
37#include <pcmcia/cs.h> 36#include <pcmcia/cs.h>
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index e82859d3227a..e39178fc59d0 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -33,7 +33,6 @@
33#include <asm/irq.h> 33#include <asm/irq.h>
34 34
35#define IN_CARD_SERVICES 35#define IN_CARD_SERVICES
36#include <pcmcia/version.h>
37#include <pcmcia/cs_types.h> 36#include <pcmcia/cs_types.h>
38#include <pcmcia/ss.h> 37#include <pcmcia/ss.h>
39#include <pcmcia/cs.h> 38#include <pcmcia/cs.h>
@@ -216,6 +215,13 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
216 list_add_tail(&socket->socket_list, &pcmcia_socket_list); 215 list_add_tail(&socket->socket_list, &pcmcia_socket_list);
217 up_write(&pcmcia_socket_list_rwsem); 216 up_write(&pcmcia_socket_list_rwsem);
218 217
218#ifndef CONFIG_CARDBUS
219 /*
220 * If we do not support Cardbus, ensure that
221 * the Cardbus socket capability is disabled.
222 */
223 socket->features &= ~SS_CAP_CARDBUS;
224#endif
219 225
220 /* set proper values in socket->dev */ 226 /* set proper values in socket->dev */
221 socket->dev.class_data = socket; 227 socket->dev.class_data = socket;
@@ -449,11 +455,11 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
449 } 455 }
450 456
451 if (status & SS_CARDBUS) { 457 if (status & SS_CARDBUS) {
458 if (!(skt->features & SS_CAP_CARDBUS)) {
459 cs_err(skt, "cardbus cards are not supported.\n");
460 return CS_BAD_TYPE;
461 }
452 skt->state |= SOCKET_CARDBUS; 462 skt->state |= SOCKET_CARDBUS;
453#ifndef CONFIG_CARDBUS
454 cs_err(skt, "cardbus cards are not supported.\n");
455 return CS_BAD_TYPE;
456#endif
457 } 463 }
458 464
459 /* 465 /*
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index 0b4c18edfa49..6bbfbd0e02a5 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -99,23 +99,11 @@ static inline void cs_socket_put(struct pcmcia_socket *skt)
99 } 99 }
100} 100}
101 101
102#define CHECK_HANDLE(h) \
103 (((h) == NULL) || ((h)->client_magic != CLIENT_MAGIC))
104
105#define CHECK_SOCKET(s) \ 102#define CHECK_SOCKET(s) \
106 (((s) >= sockets) || (socket_table[s]->ops == NULL)) 103 (((s) >= sockets) || (socket_table[s]->ops == NULL))
107 104
108#define SOCKET(h) (h->Socket) 105#define SOCKET(h) (h->socket)
109#define CONFIG(h) (&SOCKET(h)->config[(h)->Function]) 106#define CONFIG(h) (&SOCKET(h)->config[(h)->func])
110
111#define CHECK_REGION(r) \
112 (((r) == NULL) || ((r)->region_magic != REGION_MAGIC))
113
114#define CHECK_ERASEQ(q) \
115 (((q) == NULL) || ((q)->eraseq_magic != ERASEQ_MAGIC))
116
117#define EVENT(h, e, p) \
118 ((h)->event_handler((e), (p), &(h)->event_callback_args))
119 107
120/* In cardbus.c */ 108/* In cardbus.c */
121int cb_alloc(struct pcmcia_socket *s); 109int cb_alloc(struct pcmcia_socket *s);
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index cabddd49f6ff..3e3c6f12bbe6 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -158,17 +158,15 @@ static const lookup_t service_table[] = {
158}; 158};
159 159
160 160
161static int pcmcia_report_error(client_handle_t handle, error_info_t *err) 161static int pcmcia_report_error(struct pcmcia_device *p_dev, error_info_t *err)
162{ 162{
163 int i; 163 int i;
164 char *serv; 164 char *serv;
165 165
166 if (CHECK_HANDLE(handle)) 166 if (!p_dev)
167 printk(KERN_NOTICE); 167 printk(KERN_NOTICE);
168 else { 168 else
169 struct pcmcia_device *p_dev = handle_to_pdev(handle);
170 printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id); 169 printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id);
171 }
172 170
173 for (i = 0; i < ARRAY_SIZE(service_table); i++) 171 for (i = 0; i < ARRAY_SIZE(service_table); i++)
174 if (service_table[i].key == err->func) 172 if (service_table[i].key == err->func)
@@ -193,10 +191,10 @@ static int pcmcia_report_error(client_handle_t handle, error_info_t *err)
193 191
194/*======================================================================*/ 192/*======================================================================*/
195 193
196void cs_error(client_handle_t handle, int func, int ret) 194void cs_error(struct pcmcia_device *p_dev, int func, int ret)
197{ 195{
198 error_info_t err = { func, ret }; 196 error_info_t err = { func, ret };
199 pcmcia_report_error(handle, &err); 197 pcmcia_report_error(p_dev, &err);
200} 198}
201EXPORT_SYMBOL(cs_error); 199EXPORT_SYMBOL(cs_error);
202 200
@@ -207,6 +205,10 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
207 unsigned int i; 205 unsigned int i;
208 u32 hash; 206 u32 hash;
209 207
208 if (!p_drv->attach || !p_drv->event || !p_drv->detach)
209 printk(KERN_DEBUG "pcmcia: %s does misses a callback function",
210 p_drv->drv.name);
211
210 while (did && did->match_flags) { 212 while (did && did->match_flags) {
211 for (i=0; i<4; i++) { 213 for (i=0; i<4; i++) {
212 if (!did->prod_id[i]) 214 if (!did->prod_id[i])
@@ -376,7 +378,7 @@ static int pcmcia_device_probe(struct device * dev)
376 378
377 if (p_drv->attach) { 379 if (p_drv->attach) {
378 p_dev->instance = p_drv->attach(); 380 p_dev->instance = p_drv->attach();
379 if ((!p_dev->instance) || (p_dev->client.state & CLIENT_UNBOUND)) { 381 if ((!p_dev->instance) || (p_dev->state & CLIENT_UNBOUND)) {
380 printk(KERN_NOTICE "ds: unable to create instance " 382 printk(KERN_NOTICE "ds: unable to create instance "
381 "of '%s'!\n", p_drv->drv.name); 383 "of '%s'!\n", p_drv->drv.name);
382 ret = -EINVAL; 384 ret = -EINVAL;
@@ -516,10 +518,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
516 sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); 518 sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no);
517 519
518 /* compat */ 520 /* compat */
519 p_dev->client.client_magic = CLIENT_MAGIC; 521 p_dev->state = CLIENT_UNBOUND;
520 p_dev->client.Socket = s;
521 p_dev->client.Function = function;
522 p_dev->client.state = CLIENT_UNBOUND;
523 522
524 /* Add to the list in pcmcia_bus_socket */ 523 /* Add to the list in pcmcia_bus_socket */
525 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 524 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
@@ -573,8 +572,6 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
573 else 572 else
574 no_funcs = 1; 573 no_funcs = 1;
575 574
576 /* this doesn't handle multifunction devices on one pcmcia function
577 * yet. */
578 for (i=0; i < no_funcs; i++) 575 for (i=0; i < no_funcs; i++)
579 pcmcia_device_add(s, i); 576 pcmcia_device_add(s, i);
580 577
@@ -847,7 +844,7 @@ pcmcia_device_stringattr(prod_id2, prod_id[1]);
847pcmcia_device_stringattr(prod_id3, prod_id[2]); 844pcmcia_device_stringattr(prod_id3, prod_id[2]);
848pcmcia_device_stringattr(prod_id4, prod_id[3]); 845pcmcia_device_stringattr(prod_id4, prod_id[3]);
849 846
850static ssize_t modalias_show(struct device *dev, char *buf) 847static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
851{ 848{
852 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 849 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
853 int i; 850 int i;
@@ -914,6 +911,7 @@ struct send_event_data {
914static int send_event_callback(struct device *dev, void * _data) 911static int send_event_callback(struct device *dev, void * _data)
915{ 912{
916 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 913 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
914 struct pcmcia_driver *p_drv;
917 struct send_event_data *data = _data; 915 struct send_event_data *data = _data;
918 916
919 /* we get called for all sockets, but may only pass the event 917 /* we get called for all sockets, but may only pass the event
@@ -921,11 +919,16 @@ static int send_event_callback(struct device *dev, void * _data)
921 if (p_dev->socket != data->skt) 919 if (p_dev->socket != data->skt)
922 return 0; 920 return 0;
923 921
924 if (p_dev->client.state & (CLIENT_UNBOUND|CLIENT_STALE)) 922 p_drv = to_pcmcia_drv(p_dev->dev.driver);
923 if (!p_drv)
925 return 0; 924 return 0;
926 925
927 if (p_dev->client.EventMask & data->event) 926 if (p_dev->state & (CLIENT_UNBOUND|CLIENT_STALE))
928 return EVENT(&p_dev->client, data->event, data->priority); 927 return 0;
928
929 if (p_drv->event)
930 return p_drv->event(data->event, data->priority,
931 &p_dev->event_callback_args);
929 932
930 return 0; 933 return 0;
931} 934}
@@ -987,11 +990,11 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
987 990
988 991
989 992
990int pcmcia_register_client(client_handle_t *handle, client_reg_t *req) 993int pcmcia_register_client(struct pcmcia_device **handle, client_reg_t *req)
991{ 994{
992 client_t *client = NULL;
993 struct pcmcia_socket *s = NULL; 995 struct pcmcia_socket *s = NULL;
994 struct pcmcia_device *p_dev = NULL; 996 struct pcmcia_device *p_dev = NULL;
997 struct pcmcia_driver *p_drv = NULL;
995 998
996 /* Look for unbound client with matching dev_info */ 999 /* Look for unbound client with matching dev_info */
997 down_read(&pcmcia_socket_list_rwsem); 1000 down_read(&pcmcia_socket_list_rwsem);
@@ -1006,18 +1009,16 @@ int pcmcia_register_client(client_handle_t *handle, client_reg_t *req)
1006 continue; 1009 continue;
1007 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 1010 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
1008 list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { 1011 list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {
1009 struct pcmcia_driver *p_drv;
1010 p_dev = pcmcia_get_dev(p_dev); 1012 p_dev = pcmcia_get_dev(p_dev);
1011 if (!p_dev) 1013 if (!p_dev)
1012 continue; 1014 continue;
1013 if (!(p_dev->client.state & CLIENT_UNBOUND) || 1015 if (!(p_dev->state & CLIENT_UNBOUND) ||
1014 (!p_dev->dev.driver)) { 1016 (!p_dev->dev.driver)) {
1015 pcmcia_put_dev(p_dev); 1017 pcmcia_put_dev(p_dev);
1016 continue; 1018 continue;
1017 } 1019 }
1018 p_drv = to_pcmcia_drv(p_dev->dev.driver); 1020 p_drv = to_pcmcia_drv(p_dev->dev.driver);
1019 if (!strncmp(p_drv->drv.name, (char *)req->dev_info, DEV_NAME_LEN)) { 1021 if (!strncmp(p_drv->drv.name, (char *)req->dev_info, DEV_NAME_LEN)) {
1020 client = &p_dev->client;
1021 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 1022 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1022 goto found; 1023 goto found;
1023 } 1024 }
@@ -1028,26 +1029,20 @@ int pcmcia_register_client(client_handle_t *handle, client_reg_t *req)
1028 } 1029 }
1029 found: 1030 found:
1030 up_read(&pcmcia_socket_list_rwsem); 1031 up_read(&pcmcia_socket_list_rwsem);
1031 if (!p_dev || !client) 1032 if (!p_dev)
1032 return -ENODEV; 1033 return -ENODEV;
1033 1034
1034 pcmcia_put_socket(s); /* safe, as we already hold a reference from bind_device */ 1035 pcmcia_put_socket(s); /* safe, as we already hold a reference from bind_device */
1035 1036
1036 *handle = client; 1037 *handle = p_dev;
1037 client->state &= ~CLIENT_UNBOUND; 1038 p_dev->state &= ~CLIENT_UNBOUND;
1038 client->Socket = s; 1039 p_dev->event_callback_args = req->event_callback_args;
1039 client->EventMask = req->EventMask; 1040 p_dev->event_callback_args.client_handle = p_dev;
1040 client->event_handler = req->event_handler;
1041 client->event_callback_args = req->event_callback_args;
1042 client->event_callback_args.client_handle = client;
1043 1041
1044 if (s->state & SOCKET_CARDBUS)
1045 client->state |= CLIENT_CARDBUS;
1046 1042
1047 if ((!(s->state & SOCKET_CARDBUS)) && (s->functions == 0) && 1043 if (!s->functions) {
1048 (client->Function != BIND_FN_ALL)) {
1049 cistpl_longlink_mfc_t mfc; 1044 cistpl_longlink_mfc_t mfc;
1050 if (pccard_read_tuple(s, client->Function, CISTPL_LONGLINK_MFC, &mfc) 1045 if (pccard_read_tuple(s, p_dev->func, CISTPL_LONGLINK_MFC, &mfc)
1051 == CS_SUCCESS) 1046 == CS_SUCCESS)
1052 s->functions = mfc.nfn; 1047 s->functions = mfc.nfn;
1053 else 1048 else
@@ -1060,13 +1055,13 @@ int pcmcia_register_client(client_handle_t *handle, client_reg_t *req)
1060 } 1055 }
1061 1056
1062 ds_dbg(1, "register_client(): client 0x%p, dev %s\n", 1057 ds_dbg(1, "register_client(): client 0x%p, dev %s\n",
1063 client, p_dev->dev.bus_id); 1058 p_dev, p_dev->dev.bus_id);
1064 if (client->EventMask & CS_EVENT_REGISTRATION_COMPLETE)
1065 EVENT(client, CS_EVENT_REGISTRATION_COMPLETE, CS_EVENT_PRI_LOW);
1066 1059
1067 if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT) { 1060 if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT) {
1068 if (client->EventMask & CS_EVENT_CARD_INSERTION) 1061 if (p_drv->event)
1069 EVENT(client, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW); 1062 p_drv->event(CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW,
1063 &p_dev->event_callback_args);
1064
1070 } 1065 }
1071 1066
1072 return CS_SUCCESS; 1067 return CS_SUCCESS;
@@ -1099,7 +1094,7 @@ static int unbind_request(struct pcmcia_socket *s)
1099 } 1094 }
1100 p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list); 1095 p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list);
1101 list_del(&p_dev->socket_device_list); 1096 list_del(&p_dev->socket_device_list);
1102 p_dev->client.state |= CLIENT_STALE; 1097 p_dev->state |= CLIENT_STALE;
1103 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 1098 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1104 1099
1105 device_unregister(&p_dev->dev); 1100 device_unregister(&p_dev->dev);
@@ -1108,31 +1103,25 @@ static int unbind_request(struct pcmcia_socket *s)
1108 return 0; 1103 return 0;
1109} /* unbind_request */ 1104} /* unbind_request */
1110 1105
1111int pcmcia_deregister_client(client_handle_t handle) 1106int pcmcia_deregister_client(struct pcmcia_device *p_dev)
1112{ 1107{
1113 struct pcmcia_socket *s; 1108 struct pcmcia_socket *s;
1114 int i; 1109 int i;
1115 struct pcmcia_device *p_dev = handle_to_pdev(handle);
1116
1117 if (CHECK_HANDLE(handle))
1118 return CS_BAD_HANDLE;
1119 1110
1120 s = SOCKET(handle); 1111 s = p_dev->socket;
1121 ds_dbg(1, "deregister_client(%p)\n", handle); 1112 ds_dbg(1, "deregister_client(%p)\n", p_dev);
1122 1113
1123 if (handle->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED)) 1114 if (p_dev->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED))
1124 goto warn_out; 1115 goto warn_out;
1125 for (i = 0; i < MAX_WIN; i++) 1116 for (i = 0; i < MAX_WIN; i++)
1126 if (handle->state & CLIENT_WIN_REQ(i)) 1117 if (p_dev->state & CLIENT_WIN_REQ(i))
1127 goto warn_out; 1118 goto warn_out;
1128 1119
1129 if (handle->state & CLIENT_STALE) { 1120 if (p_dev->state & CLIENT_STALE) {
1130 handle->client_magic = 0; 1121 p_dev->state &= ~CLIENT_STALE;
1131 handle->state &= ~CLIENT_STALE;
1132 pcmcia_put_dev(p_dev); 1122 pcmcia_put_dev(p_dev);
1133 } else { 1123 } else {
1134 handle->state = CLIENT_UNBOUND; 1124 p_dev->state = CLIENT_UNBOUND;
1135 handle->event_handler = NULL;
1136 } 1125 }
1137 1126
1138 return CS_SUCCESS; 1127 return CS_SUCCESS;
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c
index 5ab55ae0ac36..316f8bcc878b 100644
--- a/drivers/pcmcia/hd64465_ss.c
+++ b/drivers/pcmcia/hd64465_ss.c
@@ -43,7 +43,6 @@
43#include <asm/hd64465/hd64465.h> 43#include <asm/hd64465/hd64465.h>
44#include <asm/hd64465/io.h> 44#include <asm/hd64465/io.h>
45 45
46#include <pcmcia/version.h>
47#include <pcmcia/cs_types.h> 46#include <pcmcia/cs_types.h>
48#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index d72f9a35c8bd..a713015e8228 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -53,7 +53,6 @@
53#include <asm/io.h> 53#include <asm/io.h>
54#include <asm/system.h> 54#include <asm/system.h>
55 55
56#include <pcmcia/version.h>
57#include <pcmcia/cs_types.h> 56#include <pcmcia/cs_types.h>
58#include <pcmcia/ss.h> 57#include <pcmcia/ss.h>
59#include <pcmcia/cs.h> 58#include <pcmcia/cs.h>
@@ -698,14 +697,6 @@ static void __init add_pcic(int ns, int type)
698 struct i82365_socket *t = &socket[sockets-ns]; 697 struct i82365_socket *t = &socket[sockets-ns];
699 698
700 base = sockets-ns; 699 base = sockets-ns;
701 if (t->ioaddr > 0) {
702 if (!request_region(t->ioaddr, 2, "i82365")) {
703 printk(KERN_ERR "i82365: IO region conflict at %#lx, not available\n",
704 t->ioaddr);
705 return;
706 }
707 }
708
709 if (base == 0) printk("\n"); 700 if (base == 0) printk("\n");
710 printk(KERN_INFO " %s", pcic[type].name); 701 printk(KERN_INFO " %s", pcic[type].name);
711 printk(" ISA-to-PCMCIA at port %#lx ofs 0x%02x", 702 printk(" ISA-to-PCMCIA at port %#lx ofs 0x%02x",
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index b1111c6bf062..65f3ee3d4d3c 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -29,7 +29,6 @@
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/system.h> 30#include <asm/system.h>
31 31
32#include <pcmcia/version.h>
33#include <pcmcia/cs_types.h> 32#include <pcmcia/cs_types.h>
34#include <pcmcia/ss.h> 33#include <pcmcia/ss.h>
35#include <pcmcia/cs.h> 34#include <pcmcia/cs.h>
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index c0997c4714f0..7b14d7efd68c 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -30,7 +30,6 @@
30#include <asm/system.h> 30#include <asm/system.h>
31#include <asm/addrspace.h> 31#include <asm/addrspace.h>
32 32
33#include <pcmcia/version.h>
34#include <pcmcia/cs_types.h> 33#include <pcmcia/cs_types.h>
35#include <pcmcia/ss.h> 34#include <pcmcia/ss.h>
36#include <pcmcia/cs.h> 35#include <pcmcia/cs.h>
diff --git a/drivers/pcmcia/pcmcia_compat.c b/drivers/pcmcia/pcmcia_compat.c
index 1cc83317e7e3..ebb161c4f819 100644
--- a/drivers/pcmcia/pcmcia_compat.c
+++ b/drivers/pcmcia/pcmcia_compat.c
@@ -18,7 +18,6 @@
18#include <linux/init.h> 18#include <linux/init.h>
19 19
20#define IN_CARD_SERVICES 20#define IN_CARD_SERVICES
21#include <pcmcia/version.h>
22#include <pcmcia/cs_types.h> 21#include <pcmcia/cs_types.h>
23#include <pcmcia/cs.h> 22#include <pcmcia/cs.h>
24#include <pcmcia/bulkmem.h> 23#include <pcmcia/bulkmem.h>
@@ -28,64 +27,39 @@
28 27
29#include "cs_internal.h" 28#include "cs_internal.h"
30 29
31int pcmcia_get_first_tuple(client_handle_t handle, tuple_t *tuple) 30int pcmcia_get_first_tuple(struct pcmcia_device *p_dev, tuple_t *tuple)
32{ 31{
33 struct pcmcia_socket *s; 32 return pccard_get_first_tuple(p_dev->socket, p_dev->func, tuple);
34 if (CHECK_HANDLE(handle))
35 return CS_BAD_HANDLE;
36 s = SOCKET(handle);
37 return pccard_get_first_tuple(s, handle->Function, tuple);
38} 33}
39EXPORT_SYMBOL(pcmcia_get_first_tuple); 34EXPORT_SYMBOL(pcmcia_get_first_tuple);
40 35
41int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple) 36int pcmcia_get_next_tuple(struct pcmcia_device *p_dev, tuple_t *tuple)
42{ 37{
43 struct pcmcia_socket *s; 38 return pccard_get_next_tuple(p_dev->socket, p_dev->func, tuple);
44 if (CHECK_HANDLE(handle))
45 return CS_BAD_HANDLE;
46 s = SOCKET(handle);
47 return pccard_get_next_tuple(s, handle->Function, tuple);
48} 39}
49EXPORT_SYMBOL(pcmcia_get_next_tuple); 40EXPORT_SYMBOL(pcmcia_get_next_tuple);
50 41
51int pcmcia_get_tuple_data(client_handle_t handle, tuple_t *tuple) 42int pcmcia_get_tuple_data(struct pcmcia_device *p_dev, tuple_t *tuple)
52{ 43{
53 struct pcmcia_socket *s; 44 return pccard_get_tuple_data(p_dev->socket, tuple);
54 if (CHECK_HANDLE(handle))
55 return CS_BAD_HANDLE;
56 s = SOCKET(handle);
57 return pccard_get_tuple_data(s, tuple);
58} 45}
59EXPORT_SYMBOL(pcmcia_get_tuple_data); 46EXPORT_SYMBOL(pcmcia_get_tuple_data);
60 47
61int pcmcia_parse_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 48int pcmcia_parse_tuple(struct pcmcia_device *p_dev, tuple_t *tuple, cisparse_t *parse)
62{ 49{
63 return pccard_parse_tuple(tuple, parse); 50 return pccard_parse_tuple(tuple, parse);
64} 51}
65EXPORT_SYMBOL(pcmcia_parse_tuple); 52EXPORT_SYMBOL(pcmcia_parse_tuple);
66 53
67int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info) 54int pcmcia_validate_cis(struct pcmcia_device *p_dev, cisinfo_t *info)
68{ 55{
69 struct pcmcia_socket *s; 56 return pccard_validate_cis(p_dev->socket, p_dev->func, info);
70 if (CHECK_HANDLE(handle))
71 return CS_BAD_HANDLE;
72 s = SOCKET(handle);
73 return pccard_validate_cis(s, handle->Function, info);
74} 57}
75EXPORT_SYMBOL(pcmcia_validate_cis); 58EXPORT_SYMBOL(pcmcia_validate_cis);
76 59
77 60
78int pcmcia_reset_card(client_handle_t handle, client_req_t *req) 61int pcmcia_reset_card(struct pcmcia_device *p_dev, client_req_t *req)
79{ 62{
80 struct pcmcia_socket *skt; 63 return pccard_reset_card(p_dev->socket);
81
82 if (CHECK_HANDLE(handle))
83 return CS_BAD_HANDLE;
84 skt = SOCKET(handle);
85 if (!skt)
86 return CS_BAD_HANDLE;
87
88 return pccard_reset_card(skt);
89} 64}
90EXPORT_SYMBOL(pcmcia_reset_card); 65EXPORT_SYMBOL(pcmcia_reset_card);
91
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index b883bc151ed0..39ba6406fd54 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -31,7 +31,6 @@
31#include <linux/workqueue.h> 31#include <linux/workqueue.h>
32 32
33#define IN_CARD_SERVICES 33#define IN_CARD_SERVICES
34#include <pcmcia/version.h>
35#include <pcmcia/cs_types.h> 34#include <pcmcia/cs_types.h>
36#include <pcmcia/cs.h> 35#include <pcmcia/cs.h>
37#include <pcmcia/cistpl.h> 36#include <pcmcia/cistpl.h>
@@ -71,29 +70,6 @@ extern int ds_pc_debug;
71#define ds_dbg(lvl, fmt, arg...) do { } while (0) 70#define ds_dbg(lvl, fmt, arg...) do { } while (0)
72#endif 71#endif
73 72
74static const char *release = "Linux Kernel Card Services";
75
76/** pcmcia_get_card_services_info
77 *
78 * Return information about this version of Card Services
79 */
80static int pcmcia_get_card_services_info(servinfo_t *info)
81{
82 unsigned int socket_count = 0;
83 struct list_head *tmp;
84 info->Signature[0] = 'C';
85 info->Signature[1] = 'S';
86 down_read(&pcmcia_socket_list_rwsem);
87 list_for_each(tmp, &pcmcia_socket_list)
88 socket_count++;
89 up_read(&pcmcia_socket_list_rwsem);
90 info->Count = socket_count;
91 info->Revision = CS_RELEASE_CODE;
92 info->CSLevel = 0x0210;
93 info->VendorString = (char *)release;
94 return CS_SUCCESS;
95} /* get_card_services_info */
96
97 73
98/* backwards-compatible accessing of driver --- by name! */ 74/* backwards-compatible accessing of driver --- by name! */
99 75
@@ -591,9 +567,6 @@ static int ds_ioctl(struct inode * inode, struct file * file,
591 case DS_ADJUST_RESOURCE_INFO: 567 case DS_ADJUST_RESOURCE_INFO:
592 ret = pcmcia_adjust_resource_info(&buf->adjust); 568 ret = pcmcia_adjust_resource_info(&buf->adjust);
593 break; 569 break;
594 case DS_GET_CARD_SERVICES_INFO:
595 ret = pcmcia_get_card_services_info(&buf->servinfo);
596 break;
597 case DS_GET_CONFIGURATION_INFO: 570 case DS_GET_CONFIGURATION_INFO:
598 if (buf->config.Function && 571 if (buf->config.Function &&
599 (buf->config.Function >= s->functions)) 572 (buf->config.Function >= s->functions))
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index c01dc6bf1526..184f4f88b2a0 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -23,7 +23,6 @@
23#include <linux/device.h> 23#include <linux/device.h>
24 24
25#define IN_CARD_SERVICES 25#define IN_CARD_SERVICES
26#include <pcmcia/version.h>
27#include <pcmcia/cs_types.h> 26#include <pcmcia/cs_types.h>
28#include <pcmcia/ss.h> 27#include <pcmcia/ss.h>
29#include <pcmcia/cs.h> 28#include <pcmcia/cs.h>
@@ -202,14 +201,11 @@ int pccard_access_configuration_register(struct pcmcia_socket *s,
202 return CS_SUCCESS; 201 return CS_SUCCESS;
203} /* pccard_access_configuration_register */ 202} /* pccard_access_configuration_register */
204 203
205int pcmcia_access_configuration_register(client_handle_t handle, 204int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
206 conf_reg_t *reg) 205 conf_reg_t *reg)
207{ 206{
208 struct pcmcia_socket *s; 207 return pccard_access_configuration_register(p_dev->socket,
209 if (CHECK_HANDLE(handle)) 208 p_dev->func, reg);
210 return CS_BAD_HANDLE;
211 s = SOCKET(handle);
212 return pccard_access_configuration_register(s, handle->Function, reg);
213} 209}
214EXPORT_SYMBOL(pcmcia_access_configuration_register); 210EXPORT_SYMBOL(pcmcia_access_configuration_register);
215 211
@@ -271,17 +267,11 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
271 return CS_SUCCESS; 267 return CS_SUCCESS;
272} /* pccard_get_configuration_info */ 268} /* pccard_get_configuration_info */
273 269
274int pcmcia_get_configuration_info(client_handle_t handle, 270int pcmcia_get_configuration_info(struct pcmcia_device *p_dev,
275 config_info_t *config) 271 config_info_t *config)
276{ 272{
277 struct pcmcia_socket *s; 273 return pccard_get_configuration_info(p_dev->socket, p_dev->func,
278 274 config);
279 if ((CHECK_HANDLE(handle)) || !config)
280 return CS_BAD_HANDLE;
281 s = SOCKET(handle);
282 if (!s)
283 return CS_BAD_HANDLE;
284 return pccard_get_configuration_info(s, handle->Function, config);
285} 275}
286EXPORT_SYMBOL(pcmcia_get_configuration_info); 276EXPORT_SYMBOL(pcmcia_get_configuration_info);
287 277
@@ -382,10 +372,8 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
382int pcmcia_get_status(client_handle_t handle, cs_status_t *status) 372int pcmcia_get_status(client_handle_t handle, cs_status_t *status)
383{ 373{
384 struct pcmcia_socket *s; 374 struct pcmcia_socket *s;
385 if (CHECK_HANDLE(handle))
386 return CS_BAD_HANDLE;
387 s = SOCKET(handle); 375 s = SOCKET(handle);
388 return pccard_get_status(s, handle->Function, status); 376 return pccard_get_status(s, handle->func, status);
389} 377}
390EXPORT_SYMBOL(pcmcia_get_status); 378EXPORT_SYMBOL(pcmcia_get_status);
391 379
@@ -426,16 +414,14 @@ EXPORT_SYMBOL(pcmcia_map_mem_page);
426 * 414 *
427 * Modify a locked socket configuration 415 * Modify a locked socket configuration
428 */ 416 */
429int pcmcia_modify_configuration(client_handle_t handle, 417int pcmcia_modify_configuration(struct pcmcia_device *p_dev,
430 modconf_t *mod) 418 modconf_t *mod)
431{ 419{
432 struct pcmcia_socket *s; 420 struct pcmcia_socket *s;
433 config_t *c; 421 config_t *c;
434 422
435 if (CHECK_HANDLE(handle)) 423 s = p_dev->socket;
436 return CS_BAD_HANDLE; 424 c = CONFIG(p_dev);
437 s = SOCKET(handle);
438 c = CONFIG(handle);
439 if (!(s->state & SOCKET_PRESENT)) 425 if (!(s->state & SOCKET_PRESENT))
440 return CS_NO_CARD; 426 return CS_NO_CARD;
441 if (!(c->state & CONFIG_LOCKED)) 427 if (!(c->state & CONFIG_LOCKED))
@@ -472,25 +458,18 @@ int pcmcia_modify_configuration(client_handle_t handle,
472EXPORT_SYMBOL(pcmcia_modify_configuration); 458EXPORT_SYMBOL(pcmcia_modify_configuration);
473 459
474 460
475int pcmcia_release_configuration(client_handle_t handle) 461int pcmcia_release_configuration(struct pcmcia_device *p_dev)
476{ 462{
477 pccard_io_map io = { 0, 0, 0, 0, 1 }; 463 pccard_io_map io = { 0, 0, 0, 0, 1 };
478 struct pcmcia_socket *s; 464 struct pcmcia_socket *s = p_dev->socket;
479 int i; 465 int i;
480 466
481 if (CHECK_HANDLE(handle) || 467 if (!(p_dev->state & CLIENT_CONFIG_LOCKED))
482 !(handle->state & CLIENT_CONFIG_LOCKED))
483 return CS_BAD_HANDLE; 468 return CS_BAD_HANDLE;
484 handle->state &= ~CLIENT_CONFIG_LOCKED; 469 p_dev->state &= ~CLIENT_CONFIG_LOCKED;
485 s = SOCKET(handle);
486
487#ifdef CONFIG_CARDBUS
488 if (handle->state & CLIENT_CARDBUS)
489 return CS_SUCCESS;
490#endif
491 470
492 if (!(handle->state & CLIENT_STALE)) { 471 if (!(p_dev->state & CLIENT_STALE)) {
493 config_t *c = CONFIG(handle); 472 config_t *c = CONFIG(p_dev);
494 if (--(s->lock_count) == 0) { 473 if (--(s->lock_count) == 0) {
495 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */ 474 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */
496 s->socket.Vpp = 0; 475 s->socket.Vpp = 0;
@@ -523,22 +502,16 @@ EXPORT_SYMBOL(pcmcia_release_configuration);
523 * don't bother checking the port ranges against the current socket 502 * don't bother checking the port ranges against the current socket
524 * values. 503 * values.
525 */ 504 */
526int pcmcia_release_io(client_handle_t handle, io_req_t *req) 505int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
527{ 506{
528 struct pcmcia_socket *s; 507 struct pcmcia_socket *s = p_dev->socket;
529 508
530 if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IO_REQ)) 509 if (!(p_dev->state & CLIENT_IO_REQ))
531 return CS_BAD_HANDLE; 510 return CS_BAD_HANDLE;
532 handle->state &= ~CLIENT_IO_REQ; 511 p_dev->state &= ~CLIENT_IO_REQ;
533 s = SOCKET(handle);
534
535#ifdef CONFIG_CARDBUS
536 if (handle->state & CLIENT_CARDBUS)
537 return CS_SUCCESS;
538#endif
539 512
540 if (!(handle->state & CLIENT_STALE)) { 513 if (!(p_dev->state & CLIENT_STALE)) {
541 config_t *c = CONFIG(handle); 514 config_t *c = CONFIG(p_dev);
542 if (c->state & CONFIG_LOCKED) 515 if (c->state & CONFIG_LOCKED)
543 return CS_CONFIGURATION_LOCKED; 516 return CS_CONFIGURATION_LOCKED;
544 if ((c->io.BasePort1 != req->BasePort1) || 517 if ((c->io.BasePort1 != req->BasePort1) ||
@@ -558,16 +531,15 @@ int pcmcia_release_io(client_handle_t handle, io_req_t *req)
558EXPORT_SYMBOL(pcmcia_release_io); 531EXPORT_SYMBOL(pcmcia_release_io);
559 532
560 533
561int pcmcia_release_irq(client_handle_t handle, irq_req_t *req) 534int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
562{ 535{
563 struct pcmcia_socket *s; 536 struct pcmcia_socket *s = p_dev->socket;
564 if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IRQ_REQ)) 537 if (!(p_dev->state & CLIENT_IRQ_REQ))
565 return CS_BAD_HANDLE; 538 return CS_BAD_HANDLE;
566 handle->state &= ~CLIENT_IRQ_REQ; 539 p_dev->state &= ~CLIENT_IRQ_REQ;
567 s = SOCKET(handle);
568 540
569 if (!(handle->state & CLIENT_STALE)) { 541 if (!(p_dev->state & CLIENT_STALE)) {
570 config_t *c = CONFIG(handle); 542 config_t *c = CONFIG(p_dev);
571 if (c->state & CONFIG_LOCKED) 543 if (c->state & CONFIG_LOCKED)
572 return CS_CONFIGURATION_LOCKED; 544 return CS_CONFIGURATION_LOCKED;
573 if (c->irq.Attributes != req->Attributes) 545 if (c->irq.Attributes != req->Attributes)
@@ -623,29 +595,21 @@ int pcmcia_release_window(window_handle_t win)
623EXPORT_SYMBOL(pcmcia_release_window); 595EXPORT_SYMBOL(pcmcia_release_window);
624 596
625 597
626int pcmcia_request_configuration(client_handle_t handle, 598int pcmcia_request_configuration(struct pcmcia_device *p_dev,
627 config_req_t *req) 599 config_req_t *req)
628{ 600{
629 int i; 601 int i;
630 u_int base; 602 u_int base;
631 struct pcmcia_socket *s; 603 struct pcmcia_socket *s = p_dev->socket;
632 config_t *c; 604 config_t *c;
633 pccard_io_map iomap; 605 pccard_io_map iomap;
634 606
635 if (CHECK_HANDLE(handle))
636 return CS_BAD_HANDLE;
637 s = SOCKET(handle);
638 if (!(s->state & SOCKET_PRESENT)) 607 if (!(s->state & SOCKET_PRESENT))
639 return CS_NO_CARD; 608 return CS_NO_CARD;
640 609
641#ifdef CONFIG_CARDBUS
642 if (handle->state & CLIENT_CARDBUS)
643 return CS_UNSUPPORTED_MODE;
644#endif
645
646 if (req->IntType & INT_CARDBUS) 610 if (req->IntType & INT_CARDBUS)
647 return CS_UNSUPPORTED_MODE; 611 return CS_UNSUPPORTED_MODE;
648 c = CONFIG(handle); 612 c = CONFIG(p_dev);
649 if (c->state & CONFIG_LOCKED) 613 if (c->state & CONFIG_LOCKED)
650 return CS_CONFIGURATION_LOCKED; 614 return CS_CONFIGURATION_LOCKED;
651 615
@@ -746,7 +710,7 @@ int pcmcia_request_configuration(client_handle_t handle,
746 } 710 }
747 711
748 c->state |= CONFIG_LOCKED; 712 c->state |= CONFIG_LOCKED;
749 handle->state |= CLIENT_CONFIG_LOCKED; 713 p_dev->state |= CLIENT_CONFIG_LOCKED;
750 return CS_SUCCESS; 714 return CS_SUCCESS;
751} /* pcmcia_request_configuration */ 715} /* pcmcia_request_configuration */
752EXPORT_SYMBOL(pcmcia_request_configuration); 716EXPORT_SYMBOL(pcmcia_request_configuration);
@@ -757,29 +721,17 @@ EXPORT_SYMBOL(pcmcia_request_configuration);
757 * Request_io() reserves ranges of port addresses for a socket. 721 * Request_io() reserves ranges of port addresses for a socket.
758 * I have not implemented range sharing or alias addressing. 722 * I have not implemented range sharing or alias addressing.
759 */ 723 */
760int pcmcia_request_io(client_handle_t handle, io_req_t *req) 724int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)
761{ 725{
762 struct pcmcia_socket *s; 726 struct pcmcia_socket *s = p_dev->socket;
763 config_t *c; 727 config_t *c;
764 728
765 if (CHECK_HANDLE(handle))
766 return CS_BAD_HANDLE;
767 s = SOCKET(handle);
768 if (!(s->state & SOCKET_PRESENT)) 729 if (!(s->state & SOCKET_PRESENT))
769 return CS_NO_CARD; 730 return CS_NO_CARD;
770 731
771 if (handle->state & CLIENT_CARDBUS) {
772#ifdef CONFIG_CARDBUS
773 handle->state |= CLIENT_IO_REQ;
774 return CS_SUCCESS;
775#else
776 return CS_UNSUPPORTED_FUNCTION;
777#endif
778 }
779
780 if (!req) 732 if (!req)
781 return CS_UNSUPPORTED_MODE; 733 return CS_UNSUPPORTED_MODE;
782 c = CONFIG(handle); 734 c = CONFIG(p_dev);
783 if (c->state & CONFIG_LOCKED) 735 if (c->state & CONFIG_LOCKED)
784 return CS_CONFIGURATION_LOCKED; 736 return CS_CONFIGURATION_LOCKED;
785 if (c->state & CONFIG_IO_REQ) 737 if (c->state & CONFIG_IO_REQ)
@@ -804,7 +756,7 @@ int pcmcia_request_io(client_handle_t handle, io_req_t *req)
804 756
805 c->io = *req; 757 c->io = *req;
806 c->state |= CONFIG_IO_REQ; 758 c->state |= CONFIG_IO_REQ;
807 handle->state |= CLIENT_IO_REQ; 759 p_dev->state |= CLIENT_IO_REQ;
808 return CS_SUCCESS; 760 return CS_SUCCESS;
809} /* pcmcia_request_io */ 761} /* pcmcia_request_io */
810EXPORT_SYMBOL(pcmcia_request_io); 762EXPORT_SYMBOL(pcmcia_request_io);
@@ -827,19 +779,15 @@ static irqreturn_t test_action(int cpl, void *dev_id, struct pt_regs *regs)
827} 779}
828#endif 780#endif
829 781
830int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) 782int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
831{ 783{
832 struct pcmcia_socket *s; 784 struct pcmcia_socket *s = p_dev->socket;
833 config_t *c; 785 config_t *c;
834 int ret = CS_IN_USE, irq = 0; 786 int ret = CS_IN_USE, irq = 0;
835 struct pcmcia_device *p_dev = handle_to_pdev(handle);
836 787
837 if (CHECK_HANDLE(handle))
838 return CS_BAD_HANDLE;
839 s = SOCKET(handle);
840 if (!(s->state & SOCKET_PRESENT)) 788 if (!(s->state & SOCKET_PRESENT))
841 return CS_NO_CARD; 789 return CS_NO_CARD;
842 c = CONFIG(handle); 790 c = CONFIG(p_dev);
843 if (c->state & CONFIG_LOCKED) 791 if (c->state & CONFIG_LOCKED)
844 return CS_CONFIGURATION_LOCKED; 792 return CS_CONFIGURATION_LOCKED;
845 if (c->state & CONFIG_IRQ_REQ) 793 if (c->state & CONFIG_IRQ_REQ)
@@ -903,7 +851,7 @@ int pcmcia_request_irq(client_handle_t handle, irq_req_t *req)
903 s->irq.Config++; 851 s->irq.Config++;
904 852
905 c->state |= CONFIG_IRQ_REQ; 853 c->state |= CONFIG_IRQ_REQ;
906 handle->state |= CLIENT_IRQ_REQ; 854 p_dev->state |= CLIENT_IRQ_REQ;
907 855
908#ifdef CONFIG_PCMCIA_PROBE 856#ifdef CONFIG_PCMCIA_PROBE
909 pcmcia_used_irq[irq]++; 857 pcmcia_used_irq[irq]++;
@@ -919,16 +867,13 @@ EXPORT_SYMBOL(pcmcia_request_irq);
919 * Request_window() establishes a mapping between card memory space 867 * Request_window() establishes a mapping between card memory space
920 * and system memory space. 868 * and system memory space.
921 */ 869 */
922int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle_t *wh) 870int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh)
923{ 871{
924 struct pcmcia_socket *s; 872 struct pcmcia_socket *s = (*p_dev)->socket;
925 window_t *win; 873 window_t *win;
926 u_long align; 874 u_long align;
927 int w; 875 int w;
928 876
929 if (CHECK_HANDLE(*handle))
930 return CS_BAD_HANDLE;
931 s = (*handle)->Socket;
932 if (!(s->state & SOCKET_PRESENT)) 877 if (!(s->state & SOCKET_PRESENT))
933 return CS_NO_CARD; 878 return CS_NO_CARD;
934 if (req->Attributes & (WIN_PAGED | WIN_SHARED)) 879 if (req->Attributes & (WIN_PAGED | WIN_SHARED))
@@ -957,7 +902,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle
957 win = &s->win[w]; 902 win = &s->win[w];
958 win->magic = WINDOW_MAGIC; 903 win->magic = WINDOW_MAGIC;
959 win->index = w; 904 win->index = w;
960 win->handle = *handle; 905 win->handle = *p_dev;
961 win->sock = s; 906 win->sock = s;
962 907
963 if (!(s->features & SS_CAP_STATIC_MAP)) { 908 if (!(s->features & SS_CAP_STATIC_MAP)) {
@@ -966,7 +911,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle
966 if (!win->ctl.res) 911 if (!win->ctl.res)
967 return CS_IN_USE; 912 return CS_IN_USE;
968 } 913 }
969 (*handle)->state |= CLIENT_WIN_REQ(w); 914 (*p_dev)->state |= CLIENT_WIN_REQ(w);
970 915
971 /* Configure the socket controller */ 916 /* Configure the socket controller */
972 win->ctl.map = w+1; 917 win->ctl.map = w+1;
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
index f1bb79153021..e98bb3d80e7c 100644
--- a/drivers/pcmcia/sa1100_generic.c
+++ b/drivers/pcmcia/sa1100_generic.c
@@ -34,7 +34,6 @@
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/config.h> 35#include <linux/config.h>
36 36
37#include <pcmcia/version.h>
38#include <pcmcia/cs_types.h> 37#include <pcmcia/cs_types.h>
39#include <pcmcia/cs.h> 38#include <pcmcia/cs.h>
40#include <pcmcia/ss.h> 39#include <pcmcia/ss.h>
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h
index 700a155fbc78..6f14126889b3 100644
--- a/drivers/pcmcia/soc_common.h
+++ b/drivers/pcmcia/soc_common.h
@@ -11,7 +11,6 @@
11 11
12/* include the world */ 12/* include the world */
13#include <linux/cpufreq.h> 13#include <linux/cpufreq.h>
14#include <pcmcia/version.h>
15#include <pcmcia/cs_types.h> 14#include <pcmcia/cs_types.h>
16#include <pcmcia/cs.h> 15#include <pcmcia/cs.h>
17#include <pcmcia/ss.h> 16#include <pcmcia/ss.h>
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index fcef54c1c2da..1040a6c1a8a4 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -29,7 +29,6 @@
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#define IN_CARD_SERVICES 31#define IN_CARD_SERVICES
32#include <pcmcia/version.h>
33#include <pcmcia/cs_types.h> 32#include <pcmcia/cs_types.h>
34#include <pcmcia/ss.h> 33#include <pcmcia/ss.h>
35#include <pcmcia/cs.h> 34#include <pcmcia/cs.h>
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index aacbbb5f055d..d5a61eae6119 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -50,7 +50,6 @@
50#include <asm/io.h> 50#include <asm/io.h>
51#include <asm/system.h> 51#include <asm/system.h>
52 52
53#include <pcmcia/version.h>
54#include <pcmcia/cs_types.h> 53#include <pcmcia/cs_types.h>
55#include <pcmcia/cs.h> 54#include <pcmcia/cs.h>
56#include <pcmcia/ss.h> 55#include <pcmcia/ss.h>
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index c7ba99871aca..fbe233e19ceb 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -154,8 +154,6 @@
154#define ENE_TEST_C9 0xc9 /* 8bit */ 154#define ENE_TEST_C9 0xc9 /* 8bit */
155#define ENE_TEST_C9_TLTENABLE 0x02 155#define ENE_TEST_C9_TLTENABLE 0x02
156 156
157#ifdef CONFIG_CARDBUS
158
159/* 157/*
160 * Texas Instruments CardBus controller overrides. 158 * Texas Instruments CardBus controller overrides.
161 */ 159 */
@@ -843,7 +841,5 @@ static int ti1250_override(struct yenta_socket *socket)
843 return ti12xx_override(socket); 841 return ti12xx_override(socket);
844} 842}
845 843
846#endif /* CONFIG_CARDBUS */
847
848#endif /* _LINUX_TI113X_H */ 844#endif /* _LINUX_TI113X_H */
849 845
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 02b23abc2df1..6837491f021c 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -18,7 +18,6 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/module.h> 19#include <linux/module.h>
20 20
21#include <pcmcia/version.h>
22#include <pcmcia/cs_types.h> 21#include <pcmcia/cs_types.h>
23#include <pcmcia/ss.h> 22#include <pcmcia/ss.h>
24#include <pcmcia/cs.h> 23#include <pcmcia/cs.h>
@@ -528,98 +527,144 @@ static int yenta_sock_suspend(struct pcmcia_socket *sock)
528 * Use an adaptive allocation for the memory resource, 527 * Use an adaptive allocation for the memory resource,
529 * sometimes the memory behind pci bridges is limited: 528 * sometimes the memory behind pci bridges is limited:
530 * 1/8 of the size of the io window of the parent. 529 * 1/8 of the size of the io window of the parent.
531 * max 4 MB, min 16 kB. 530 * max 4 MB, min 16 kB. We try very hard to not get below
531 * the "ACC" values, though.
532 */ 532 */
533#define BRIDGE_MEM_MAX 4*1024*1024 533#define BRIDGE_MEM_MAX 4*1024*1024
534#define BRIDGE_MEM_ACC 128*1024
534#define BRIDGE_MEM_MIN 16*1024 535#define BRIDGE_MEM_MIN 16*1024
535 536
536#define BRIDGE_IO_MAX 256 537#define BRIDGE_IO_MAX 512
538#define BRIDGE_IO_ACC 256
537#define BRIDGE_IO_MIN 32 539#define BRIDGE_IO_MIN 32
538 540
539#ifndef PCIBIOS_MIN_CARDBUS_IO 541#ifndef PCIBIOS_MIN_CARDBUS_IO
540#define PCIBIOS_MIN_CARDBUS_IO PCIBIOS_MIN_IO 542#define PCIBIOS_MIN_CARDBUS_IO PCIBIOS_MIN_IO
541#endif 543#endif
542 544
543static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type) 545static int yenta_search_one_res(struct resource *root, struct resource *res,
546 u32 min)
547{
548 u32 align, size, start, end;
549
550 if (res->flags & IORESOURCE_IO) {
551 align = 1024;
552 size = BRIDGE_IO_MAX;
553 start = PCIBIOS_MIN_CARDBUS_IO;
554 end = ~0U;
555 } else {
556 unsigned long avail = root->end - root->start;
557 int i;
558 size = BRIDGE_MEM_MAX;
559 if (size > avail/8) {
560 size=(avail+1)/8;
561 /* round size down to next power of 2 */
562 i = 0;
563 while ((size /= 2) != 0)
564 i++;
565 size = 1 << i;
566 }
567 if (size < min)
568 size = min;
569 align = size;
570 start = PCIBIOS_MIN_MEM;
571 end = ~0U;
572 }
573
574 do {
575 if (allocate_resource(root, res, size, start, end, align,
576 NULL, NULL)==0) {
577 return 1;
578 }
579 size = size/2;
580 align = size;
581 } while (size >= min);
582
583 return 0;
584}
585
586
587static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
588 u32 min)
589{
590 int i;
591 for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) {
592 struct resource * root = socket->dev->bus->resource[i];
593 if (!root)
594 continue;
595
596 if ((res->flags ^ root->flags) &
597 (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH))
598 continue; /* Wrong type */
599
600 if (yenta_search_one_res(root, res, min))
601 return 1;
602 }
603 return 0;
604}
605
606static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end)
544{ 607{
545 struct pci_bus *bus; 608 struct pci_bus *bus;
546 struct resource *root, *res; 609 struct resource *root, *res;
547 u32 start, end; 610 u32 start, end;
548 u32 align, size, min;
549 unsigned offset;
550 unsigned mask; 611 unsigned mask;
551 612
552 res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr; 613 res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr;
553 /* Already allocated? */ 614 /* Already allocated? */
554 if (res->parent) 615 if (res->parent)
555 return 0; 616 return;
556 617
557 /* The granularity of the memory limit is 4kB, on IO it's 4 bytes */ 618 /* The granularity of the memory limit is 4kB, on IO it's 4 bytes */
558 mask = ~0xfff; 619 mask = ~0xfff;
559 if (type & IORESOURCE_IO) 620 if (type & IORESOURCE_IO)
560 mask = ~3; 621 mask = ~3;
561 622
562 offset = 0x1c + 8*nr;
563 bus = socket->dev->subordinate; 623 bus = socket->dev->subordinate;
564 res->name = bus->name; 624 res->name = bus->name;
565 res->flags = type; 625 res->flags = type;
566 res->start = 0;
567 res->end = 0;
568 root = pci_find_parent_resource(socket->dev, res);
569 626
570 if (!root) 627 start = config_readl(socket, addr_start) & mask;
571 return; 628 end = config_readl(socket, addr_end) | ~mask;
572
573 start = config_readl(socket, offset) & mask;
574 end = config_readl(socket, offset+4) | ~mask;
575 if (start && end > start && !override_bios) { 629 if (start && end > start && !override_bios) {
576 res->start = start; 630 res->start = start;
577 res->end = end; 631 res->end = end;
578 if (request_resource(root, res) == 0) 632 root = pci_find_parent_resource(socket->dev, res);
633 if (root && (request_resource(root, res) == 0))
579 return; 634 return;
580 printk(KERN_INFO "yenta %s: Preassigned resource %d busy, reconfiguring...\n", 635 printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n",
581 pci_name(socket->dev), nr); 636 pci_name(socket->dev), nr);
582 res->start = res->end = 0;
583 } 637 }
584 638
585 if (type & IORESOURCE_IO) { 639 if (type & IORESOURCE_IO) {
586 align = 1024; 640 if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) ||
587 size = BRIDGE_IO_MAX; 641 (yenta_search_res(socket, res, BRIDGE_IO_ACC)) ||
588 min = BRIDGE_IO_MIN; 642 (yenta_search_res(socket, res, BRIDGE_IO_MIN))) {
589 start = PCIBIOS_MIN_CARDBUS_IO; 643 config_writel(socket, addr_start, res->start);
590 end = ~0U; 644 config_writel(socket, addr_end, res->end);
645 }
591 } else { 646 } else {
592 unsigned long avail = root->end - root->start; 647 if (type & IORESOURCE_PREFETCH) {
593 int i; 648 if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
594 size = BRIDGE_MEM_MAX; 649 (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
595 if (size > avail/8) { 650 (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) {
596 size=(avail+1)/8; 651 config_writel(socket, addr_start, res->start);
597 /* round size down to next power of 2 */ 652 config_writel(socket, addr_end, res->end);
598 i = 0; 653 }
599 while ((size /= 2) != 0) 654 /* Approximating prefetchable by non-prefetchable */
600 i++; 655 res->flags = IORESOURCE_MEM;
601 size = 1 << i;
602 } 656 }
603 if (size < BRIDGE_MEM_MIN) 657 if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
604 size = BRIDGE_MEM_MIN; 658 (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
605 min = BRIDGE_MEM_MIN; 659 (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) {
606 align = size; 660 config_writel(socket, addr_start, res->start);
607 start = PCIBIOS_MIN_MEM; 661 config_writel(socket, addr_end, res->end);
608 end = ~0U;
609 }
610
611 do {
612 if (allocate_resource(root, res, size, start, end, align, NULL, NULL)==0) {
613 config_writel(socket, offset, res->start);
614 config_writel(socket, offset+4, res->end);
615 return;
616 } 662 }
617 size = size/2; 663 }
618 align = size; 664
619 } while (size >= min);
620 printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n", 665 printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n",
621 pci_name(socket->dev), type); 666 pci_name(socket->dev), type);
622 res->start = res->end = 0; 667 res->start = res->end = res->flags = 0;
623} 668}
624 669
625/* 670/*
@@ -627,10 +672,14 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ
627 */ 672 */
628static void yenta_allocate_resources(struct yenta_socket *socket) 673static void yenta_allocate_resources(struct yenta_socket *socket)
629{ 674{
630 yenta_allocate_res(socket, 0, IORESOURCE_MEM|IORESOURCE_PREFETCH); 675 yenta_allocate_res(socket, 0, IORESOURCE_IO,
631 yenta_allocate_res(socket, 1, IORESOURCE_MEM); 676 PCI_CB_IO_BASE_0, PCI_CB_IO_LIMIT_0);
632 yenta_allocate_res(socket, 2, IORESOURCE_IO); 677 yenta_allocate_res(socket, 1, IORESOURCE_IO,
633 yenta_allocate_res(socket, 3, IORESOURCE_IO); /* PCI isn't clever enough to use this one yet */ 678 PCI_CB_IO_BASE_1, PCI_CB_IO_LIMIT_1);
679 yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH,
680 PCI_CB_MEMORY_BASE_0, PCI_CB_MEMORY_LIMIT_0);
681 yenta_allocate_res(socket, 3, IORESOURCE_MEM,
682 PCI_CB_MEMORY_BASE_1, PCI_CB_MEMORY_LIMIT_1);
634} 683}
635 684
636 685
@@ -869,14 +918,11 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket)
869 */ 918 */
870static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask) 919static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask)
871{ 920{
872 socket->socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
873 socket->socket.map_size = 0x1000;
874 socket->socket.pci_irq = socket->cb_irq; 921 socket->socket.pci_irq = socket->cb_irq;
875 if (isa_probe) 922 if (isa_probe)
876 socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask); 923 socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
877 else 924 else
878 socket->socket.irq_mask = 0; 925 socket->socket.irq_mask = 0;
879 socket->socket.cb_dev = socket->dev;
880 926
881 printk(KERN_INFO "Yenta: ISA IRQ mask 0x%04x, PCI irq %d\n", 927 printk(KERN_INFO "Yenta: ISA IRQ mask 0x%04x, PCI irq %d\n",
882 socket->socket.irq_mask, socket->cb_irq); 928 socket->socket.irq_mask, socket->cb_irq);
@@ -942,6 +988,9 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
942 socket->socket.dev.dev = &dev->dev; 988 socket->socket.dev.dev = &dev->dev;
943 socket->socket.driver_data = socket; 989 socket->socket.driver_data = socket;
944 socket->socket.owner = THIS_MODULE; 990 socket->socket.owner = THIS_MODULE;
991 socket->socket.features = SS_CAP_PAGE_REGS | SS_CAP_PCCARD;
992 socket->socket.map_size = 0x1000;
993 socket->socket.cb_dev = dev;
945 994
946 /* prepare struct yenta_socket */ 995 /* prepare struct yenta_socket */
947 socket->dev = dev; 996 socket->dev = dev;
@@ -1012,6 +1061,10 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1012 socket->poll_timer.data = (unsigned long)socket; 1061 socket->poll_timer.data = (unsigned long)socket;
1013 socket->poll_timer.expires = jiffies + HZ; 1062 socket->poll_timer.expires = jiffies + HZ;
1014 add_timer(&socket->poll_timer); 1063 add_timer(&socket->poll_timer);
1064 printk(KERN_INFO "Yenta: no PCI IRQ, CardBus support disabled for this socket.\n"
1065 KERN_INFO "Yenta: check your BIOS CardBus, BIOS IRQ or ACPI settings.\n");
1066 } else {
1067 socket->socket.features |= SS_CAP_CARDBUS;
1015 } 1068 }
1016 1069
1017 /* Figure out what the dang thing can do for the PCMCIA layer... */ 1070 /* Figure out what the dang thing can do for the PCMCIA layer... */
@@ -1052,6 +1105,7 @@ static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state)
1052 pci_save_state(dev); 1105 pci_save_state(dev);
1053 pci_read_config_dword(dev, 16*4, &socket->saved_state[0]); 1106 pci_read_config_dword(dev, 16*4, &socket->saved_state[0]);
1054 pci_read_config_dword(dev, 17*4, &socket->saved_state[1]); 1107 pci_read_config_dword(dev, 17*4, &socket->saved_state[1]);
1108 pci_disable_device(dev);
1055 1109
1056 /* 1110 /*
1057 * Some laptops (IBM T22) do not like us putting the Cardbus 1111 * Some laptops (IBM T22) do not like us putting the Cardbus
@@ -1075,6 +1129,8 @@ static int yenta_dev_resume (struct pci_dev *dev)
1075 pci_restore_state(dev); 1129 pci_restore_state(dev);
1076 pci_write_config_dword(dev, 16*4, socket->saved_state[0]); 1130 pci_write_config_dword(dev, 16*4, socket->saved_state[0]);
1077 pci_write_config_dword(dev, 17*4, socket->saved_state[1]); 1131 pci_write_config_dword(dev, 17*4, socket->saved_state[1]);
1132 pci_enable_device(dev);
1133 pci_set_master(dev);
1078 1134
1079 if (socket->type && socket->type->restore_state) 1135 if (socket->type && socket->type->restore_state)
1080 socket->type->restore_state(socket); 1136 socket->type->restore_state(socket);
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index dd61e09029b1..75575f6c349c 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -160,7 +160,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
160 acpi_register_gsi(res->data.irq.interrupts[0], 160 acpi_register_gsi(res->data.irq.interrupts[0],
161 res->data.irq.edge_level, 161 res->data.irq.edge_level,
162 res->data.irq.active_high_low)); 162 res->data.irq.active_high_low));
163 pcibios_penalize_isa_irq(res->data.irq.interrupts[0]); 163 pcibios_penalize_isa_irq(res->data.irq.interrupts[0], 1);
164 } 164 }
165 break; 165 break;
166 166
@@ -171,7 +171,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
171 acpi_register_gsi(res->data.extended_irq.interrupts[0], 171 acpi_register_gsi(res->data.extended_irq.interrupts[0],
172 res->data.extended_irq.edge_level, 172 res->data.extended_irq.edge_level,
173 res->data.extended_irq.active_high_low)); 173 res->data.extended_irq.active_high_low));
174 pcibios_penalize_isa_irq(res->data.extended_irq.interrupts[0]); 174 pcibios_penalize_isa_irq(res->data.extended_irq.interrupts[0], 1);
175 } 175 }
176 break; 176 break;
177 case ACPI_RSTYPE_DMA: 177 case ACPI_RSTYPE_DMA:
@@ -444,6 +444,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
444 444
445struct acpipnp_parse_option_s { 445struct acpipnp_parse_option_s {
446 struct pnp_option *option; 446 struct pnp_option *option;
447 struct pnp_option *option_independent;
447 struct pnp_dev *dev; 448 struct pnp_dev *dev;
448}; 449};
449 450
@@ -507,7 +508,14 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
507 parse_data->option = option; 508 parse_data->option = option;
508 break; 509 break;
509 case ACPI_RSTYPE_END_DPF: 510 case ACPI_RSTYPE_END_DPF:
510 return AE_CTRL_TERMINATE; 511 /*only one EndDependentFn is allowed*/
512 if (!parse_data->option_independent) {
513 pnp_warn("PnPACPI: more than one EndDependentFn");
514 return AE_ERROR;
515 }
516 parse_data->option = parse_data->option_independent;
517 parse_data->option_independent = NULL;
518 break;
511 default: 519 default:
512 pnp_warn("PnPACPI: unknown resource type %d", res->id); 520 pnp_warn("PnPACPI: unknown resource type %d", res->id);
513 return AE_ERROR; 521 return AE_ERROR;
@@ -525,6 +533,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
525 parse_data.option = pnp_register_independent_option(dev); 533 parse_data.option = pnp_register_independent_option(dev);
526 if (!parse_data.option) 534 if (!parse_data.option)
527 return AE_ERROR; 535 return AE_ERROR;
536 parse_data.option_independent = parse_data.option;
528 parse_data.dev = dev; 537 parse_data.dev = dev;
529 status = acpi_walk_resources(handle, METHOD_NAME__PRS, 538 status = acpi_walk_resources(handle, METHOD_NAME__PRS,
530 pnpacpi_option_resource, &parse_data); 539 pnpacpi_option_resource, &parse_data);
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 79bce7b75740..9001b6f0204d 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -64,7 +64,7 @@ pnpbios_parse_allocated_irqresource(struct pnp_resource_table * res, int irq)
64 } 64 }
65 res->irq_resource[i].start = 65 res->irq_resource[i].start =
66 res->irq_resource[i].end = (unsigned long) irq; 66 res->irq_resource[i].end = (unsigned long) irq;
67 pcibios_penalize_isa_irq(irq); 67 pcibios_penalize_isa_irq(irq, 1);
68 } 68 }
69} 69}
70 70
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 2d1322dd7e19..887ad8939349 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -102,7 +102,7 @@ int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data)
102 102
103 for (i = 0; i < 16; i++) 103 for (i = 0; i < 16; i++)
104 if (test_bit(i, data->map)) 104 if (test_bit(i, data->map))
105 pcibios_penalize_isa_irq(i); 105 pcibios_penalize_isa_irq(i, 0);
106 } 106 }
107#endif 107#endif
108 return 0; 108 return 0;
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 60440dbe3a27..24c0af49c25c 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -428,7 +428,7 @@ claw_pack_skb(struct claw_privbk *privptr)
428 new_skb = NULL; /* assume no dice */ 428 new_skb = NULL; /* assume no dice */
429 pkt_cnt = 0; 429 pkt_cnt = 0;
430 CLAW_DBF_TEXT(4,trace,"PackSKBe"); 430 CLAW_DBF_TEXT(4,trace,"PackSKBe");
431 if (skb_queue_len(&p_ch->collect_queue) > 0) { 431 if (!skb_queue_empty(&p_ch->collect_queue)) {
432 /* some data */ 432 /* some data */
433 held_skb = skb_dequeue(&p_ch->collect_queue); 433 held_skb = skb_dequeue(&p_ch->collect_queue);
434 if (p_env->packing != DO_PACKED) 434 if (p_env->packing != DO_PACKED)
@@ -1254,7 +1254,7 @@ claw_write_next ( struct chbk * p_ch )
1254 privptr = (struct claw_privbk *) dev->priv; 1254 privptr = (struct claw_privbk *) dev->priv;
1255 claw_free_wrt_buf( dev ); 1255 claw_free_wrt_buf( dev );
1256 if ((privptr->write_free_count > 0) && 1256 if ((privptr->write_free_count > 0) &&
1257 (skb_queue_len(&p_ch->collect_queue) > 0)) { 1257 !skb_queue_empty(&p_ch->collect_queue)) {
1258 pk_skb = claw_pack_skb(privptr); 1258 pk_skb = claw_pack_skb(privptr);
1259 while (pk_skb != NULL) { 1259 while (pk_skb != NULL) {
1260 rc = claw_hw_tx( pk_skb, dev,1); 1260 rc = claw_hw_tx( pk_skb, dev,1);
diff --git a/drivers/s390/net/ctctty.c b/drivers/s390/net/ctctty.c
index 3080393e823d..968f2c113efe 100644
--- a/drivers/s390/net/ctctty.c
+++ b/drivers/s390/net/ctctty.c
@@ -156,7 +156,7 @@ ctc_tty_readmodem(ctc_tty_info *info)
156 skb_queue_head(&info->rx_queue, skb); 156 skb_queue_head(&info->rx_queue, skb);
157 else { 157 else {
158 kfree_skb(skb); 158 kfree_skb(skb);
159 ret = skb_queue_len(&info->rx_queue); 159 ret = !skb_queue_empty(&info->rx_queue);
160 } 160 }
161 } 161 }
162 } 162 }
@@ -530,7 +530,7 @@ ctc_tty_write(struct tty_struct *tty, const u_char * buf, int count)
530 total += c; 530 total += c;
531 count -= c; 531 count -= c;
532 } 532 }
533 if (skb_queue_len(&info->tx_queue)) { 533 if (!skb_queue_empty(&info->tx_queue)) {
534 info->lsr &= ~UART_LSR_TEMT; 534 info->lsr &= ~UART_LSR_TEMT;
535 tasklet_schedule(&info->tasklet); 535 tasklet_schedule(&info->tasklet);
536 } 536 }
@@ -594,7 +594,7 @@ ctc_tty_flush_chars(struct tty_struct *tty)
594 return; 594 return;
595 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_flush_chars")) 595 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_flush_chars"))
596 return; 596 return;
597 if (tty->stopped || tty->hw_stopped || (!skb_queue_len(&info->tx_queue))) 597 if (tty->stopped || tty->hw_stopped || skb_queue_empty(&info->tx_queue))
598 return; 598 return;
599 tasklet_schedule(&info->tasklet); 599 tasklet_schedule(&info->tasklet);
600} 600}
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 3cb88c770037..8f4d2999af8e 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -2210,7 +2210,7 @@ no_mem:
2210 return NULL; 2210 return NULL;
2211} 2211}
2212 2212
2213static inline unsigned short 2213static inline __be16
2214qeth_type_trans(struct sk_buff *skb, struct net_device *dev) 2214qeth_type_trans(struct sk_buff *skb, struct net_device *dev)
2215{ 2215{
2216 struct qeth_card *card; 2216 struct qeth_card *card;
diff --git a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c
index 8f0f46907a81..87302fb14885 100644
--- a/drivers/sbus/char/bpp.c
+++ b/drivers/sbus/char/bpp.c
@@ -79,10 +79,6 @@ struct inst {
79 79
80 unsigned char run_length; 80 unsigned char run_length;
81 unsigned char repeat_byte; 81 unsigned char repeat_byte;
82
83 /* These members manage timeouts for programmed delays */
84 wait_queue_head_t wait_queue;
85 struct timer_list timer_list;
86}; 82};
87 83
88static struct inst instances[BPP_NO]; 84static struct inst instances[BPP_NO];
@@ -297,16 +293,10 @@ static unsigned short get_pins(unsigned minor)
297 293
298#endif /* __sparc__ */ 294#endif /* __sparc__ */
299 295
300static void bpp_wake_up(unsigned long val)
301{ wake_up(&instances[val].wait_queue); }
302
303static void snooze(unsigned long snooze_time, unsigned minor) 296static void snooze(unsigned long snooze_time, unsigned minor)
304{ 297{
305 init_timer(&instances[minor].timer_list); 298 set_current_state(TASK_UNINTERRUPTIBLE);
306 instances[minor].timer_list.expires = jiffies + snooze_time + 1; 299 schedule_timeout(snooze_time + 1);
307 instances[minor].timer_list.data = minor;
308 add_timer(&instances[minor].timer_list);
309 sleep_on (&instances[minor].wait_queue);
310} 300}
311 301
312static int wait_for(unsigned short set, unsigned short clr, 302static int wait_for(unsigned short set, unsigned short clr,
@@ -880,11 +870,8 @@ static void probeLptPort(unsigned idx)
880 instances[idx].enhanced = 0; 870 instances[idx].enhanced = 0;
881 instances[idx].direction = 0; 871 instances[idx].direction = 0;
882 instances[idx].mode = COMPATIBILITY; 872 instances[idx].mode = COMPATIBILITY;
883 instances[idx].wait_queue = 0;
884 instances[idx].run_length = 0; 873 instances[idx].run_length = 0;
885 instances[idx].run_flag = 0; 874 instances[idx].run_flag = 0;
886 init_timer(&instances[idx].timer_list);
887 instances[idx].timer_list.function = bpp_wake_up;
888 if (!request_region(lpAddr,3, dev_name)) return; 875 if (!request_region(lpAddr,3, dev_name)) return;
889 876
890 /* 877 /*
@@ -977,11 +964,8 @@ static void probeLptPort(unsigned idx)
977 instances[idx].enhanced = 0; 964 instances[idx].enhanced = 0;
978 instances[idx].direction = 0; 965 instances[idx].direction = 0;
979 instances[idx].mode = COMPATIBILITY; 966 instances[idx].mode = COMPATIBILITY;
980 init_waitqueue_head(&instances[idx].wait_queue);
981 instances[idx].run_length = 0; 967 instances[idx].run_length = 0;
982 instances[idx].run_flag = 0; 968 instances[idx].run_flag = 0;
983 init_timer(&instances[idx].timer_list);
984 instances[idx].timer_list.function = bpp_wake_up;
985 969
986 if (!rp) return; 970 if (!rp) return;
987 971
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 1fef92d55dee..390cd67c57c0 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -469,7 +469,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
469 goto cleanup; 469 goto cleanup;
470 } 470 }
471 471
472 user_srbcmd = kmalloc(GFP_KERNEL, fibsize); 472 user_srbcmd = kmalloc(fibsize, GFP_KERNEL);
473 if (!user_srbcmd) { 473 if (!user_srbcmd) {
474 dprintk((KERN_DEBUG"aacraid: Could not make a copy of the srb\n")); 474 dprintk((KERN_DEBUG"aacraid: Could not make a copy of the srb\n"));
475 rcode = -ENOMEM; 475 rcode = -ENOMEM;
diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c
index edd47d1f0b17..932dcf0366eb 100644
--- a/drivers/scsi/mac53c94.c
+++ b/drivers/scsi/mac53c94.c
@@ -424,7 +424,7 @@ static struct scsi_host_template mac53c94_template = {
424 .use_clustering = DISABLE_CLUSTERING, 424 .use_clustering = DISABLE_CLUSTERING,
425}; 425};
426 426
427static int mac53c94_probe(struct macio_dev *mdev, const struct of_match *match) 427static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *match)
428{ 428{
429 struct device_node *node = macio_get_of_node(mdev); 429 struct device_node *node = macio_get_of_node(mdev);
430 struct pci_dev *pdev = macio_get_pci_dev(mdev); 430 struct pci_dev *pdev = macio_get_pci_dev(mdev);
@@ -544,15 +544,14 @@ static int mac53c94_remove(struct macio_dev *mdev)
544} 544}
545 545
546 546
547static struct of_match mac53c94_match[] = 547static struct of_device_id mac53c94_match[] =
548{ 548{
549 { 549 {
550 .name = "53c94", 550 .name = "53c94",
551 .type = OF_ANY_MATCH,
552 .compatible = OF_ANY_MATCH
553 }, 551 },
554 {}, 552 {},
555}; 553};
554MODULE_DEVICE_TABLE (of, mac53c94_match);
556 555
557static struct macio_driver mac53c94_driver = 556static struct macio_driver mac53c94_driver =
558{ 557{
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index b05737ae5eff..ff1933298da6 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -1847,7 +1847,7 @@ static struct scsi_host_template mesh_template = {
1847 .use_clustering = DISABLE_CLUSTERING, 1847 .use_clustering = DISABLE_CLUSTERING,
1848}; 1848};
1849 1849
1850static int mesh_probe(struct macio_dev *mdev, const struct of_match *match) 1850static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)
1851{ 1851{
1852 struct device_node *mesh = macio_get_of_node(mdev); 1852 struct device_node *mesh = macio_get_of_node(mdev);
1853 struct pci_dev* pdev = macio_get_pci_dev(mdev); 1853 struct pci_dev* pdev = macio_get_pci_dev(mdev);
@@ -2012,20 +2012,18 @@ static int mesh_remove(struct macio_dev *mdev)
2012} 2012}
2013 2013
2014 2014
2015static struct of_match mesh_match[] = 2015static struct of_device_id mesh_match[] =
2016{ 2016{
2017 { 2017 {
2018 .name = "mesh", 2018 .name = "mesh",
2019 .type = OF_ANY_MATCH,
2020 .compatible = OF_ANY_MATCH
2021 }, 2019 },
2022 { 2020 {
2023 .name = OF_ANY_MATCH,
2024 .type = "scsi", 2021 .type = "scsi",
2025 .compatible = "chrp,mesh0" 2022 .compatible = "chrp,mesh0"
2026 }, 2023 },
2027 {}, 2024 {},
2028}; 2025};
2026MODULE_DEVICE_TABLE (of, mesh_match);
2029 2027
2030static struct macio_driver mesh_driver = 2028static struct macio_driver mesh_driver =
2031{ 2029{
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index f1f6bf596dc9..7c5306499832 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -50,7 +50,6 @@
50#include <scsi/scsi_host.h> 50#include <scsi/scsi_host.h>
51#include "aha152x.h" 51#include "aha152x.h"
52 52
53#include <pcmcia/version.h>
54#include <pcmcia/cs_types.h> 53#include <pcmcia/cs_types.h>
55#include <pcmcia/cs.h> 54#include <pcmcia/cs.h>
56#include <pcmcia/cistpl.h> 55#include <pcmcia/cistpl.h>
@@ -134,11 +133,6 @@ static dev_link_t *aha152x_attach(void)
134 link->next = dev_list; 133 link->next = dev_list;
135 dev_list = link; 134 dev_list = link;
136 client_reg.dev_info = &dev_info; 135 client_reg.dev_info = &dev_info;
137 client_reg.event_handler = &aha152x_event;
138 client_reg.EventMask =
139 CS_EVENT_RESET_REQUEST | CS_EVENT_CARD_RESET |
140 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
141 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
142 client_reg.Version = 0x0210; 136 client_reg.Version = 0x0210;
143 client_reg.event_callback_args.client_data = link; 137 client_reg.event_callback_args.client_data = link;
144 ret = pcmcia_register_client(&link->handle, &client_reg); 138 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -334,6 +328,7 @@ static struct pcmcia_driver aha152x_cs_driver = {
334 .name = "aha152x_cs", 328 .name = "aha152x_cs",
335 }, 329 },
336 .attach = aha152x_attach, 330 .attach = aha152x_attach,
331 .event = aha152x_event,
337 .detach = aha152x_detach, 332 .detach = aha152x_detach,
338 .id_table = aha152x_ids, 333 .id_table = aha152x_ids,
339}; 334};
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 853e6ee9b71a..db8f5cd85ffe 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -47,7 +47,6 @@
47#include <scsi/scsi_host.h> 47#include <scsi/scsi_host.h>
48#include "fdomain.h" 48#include "fdomain.h"
49 49
50#include <pcmcia/version.h>
51#include <pcmcia/cs_types.h> 50#include <pcmcia/cs_types.h>
52#include <pcmcia/cs.h> 51#include <pcmcia/cs.h>
53#include <pcmcia/cistpl.h> 52#include <pcmcia/cistpl.h>
@@ -120,11 +119,6 @@ static dev_link_t *fdomain_attach(void)
120 link->next = dev_list; 119 link->next = dev_list;
121 dev_list = link; 120 dev_list = link;
122 client_reg.dev_info = &dev_info; 121 client_reg.dev_info = &dev_info;
123 client_reg.event_handler = &fdomain_event;
124 client_reg.EventMask =
125 CS_EVENT_RESET_REQUEST | CS_EVENT_CARD_RESET |
126 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
127 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
128 client_reg.Version = 0x0210; 122 client_reg.Version = 0x0210;
129 client_reg.event_callback_args.client_data = link; 123 client_reg.event_callback_args.client_data = link;
130 ret = pcmcia_register_client(&link->handle, &client_reg); 124 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -314,6 +308,7 @@ static struct pcmcia_driver fdomain_cs_driver = {
314 .name = "fdomain_cs", 308 .name = "fdomain_cs",
315 }, 309 },
316 .attach = fdomain_attach, 310 .attach = fdomain_attach,
311 .event = fdomain_event,
317 .detach = fdomain_detach, 312 .detach = fdomain_detach,
318 .id_table = fdomain_ids, 313 .id_table = fdomain_ids,
319}; 314};
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 91b3f28e7a19..3cd3b40b1a4c 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -51,7 +51,6 @@
51#include <scsi/scsi.h> 51#include <scsi/scsi.h>
52#include <scsi/scsi_ioctl.h> 52#include <scsi/scsi_ioctl.h>
53 53
54#include <pcmcia/version.h>
55#include <pcmcia/cs_types.h> 54#include <pcmcia/cs_types.h>
56#include <pcmcia/cs.h> 55#include <pcmcia/cs.h>
57#include <pcmcia/cistpl.h> 56#include <pcmcia/cistpl.h>
@@ -1642,11 +1641,6 @@ static dev_link_t *nsp_cs_attach(void)
1642 link->next = dev_list; 1641 link->next = dev_list;
1643 dev_list = link; 1642 dev_list = link;
1644 client_reg.dev_info = &dev_info; 1643 client_reg.dev_info = &dev_info;
1645 client_reg.EventMask =
1646 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
1647 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
1648 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME ;
1649 client_reg.event_handler = &nsp_cs_event;
1650 client_reg.Version = 0x0210; 1644 client_reg.Version = 0x0210;
1651 client_reg.event_callback_args.client_data = link; 1645 client_reg.event_callback_args.client_data = link;
1652 ret = pcmcia_register_client(&link->handle, &client_reg); 1646 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -2138,12 +2132,13 @@ static struct pcmcia_device_id nsp_cs_ids[] = {
2138MODULE_DEVICE_TABLE(pcmcia, nsp_cs_ids); 2132MODULE_DEVICE_TABLE(pcmcia, nsp_cs_ids);
2139 2133
2140static struct pcmcia_driver nsp_driver = { 2134static struct pcmcia_driver nsp_driver = {
2141 .owner = THIS_MODULE, 2135 .owner = THIS_MODULE,
2142 .drv = { 2136 .drv = {
2143 .name = "nsp_cs", 2137 .name = "nsp_cs",
2144 }, 2138 },
2145 .attach = nsp_cs_attach, 2139 .attach = nsp_cs_attach,
2146 .detach = nsp_cs_detach, 2140 .event = nsp_cs_event,
2141 .detach = nsp_cs_detach,
2147 .id_table = nsp_cs_ids, 2142 .id_table = nsp_cs_ids,
2148}; 2143};
2149#endif 2144#endif
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 0dcf41102abf..7a516f35834e 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -49,7 +49,6 @@
49#include <scsi/scsi_host.h> 49#include <scsi/scsi_host.h>
50#include "../qlogicfas408.h" 50#include "../qlogicfas408.h"
51 51
52#include <pcmcia/version.h>
53#include <pcmcia/cs_types.h> 52#include <pcmcia/cs_types.h>
54#include <pcmcia/cs.h> 53#include <pcmcia/cs.h>
55#include <pcmcia/cistpl.h> 54#include <pcmcia/cistpl.h>
@@ -194,8 +193,6 @@ static dev_link_t *qlogic_attach(void)
194 link->next = dev_list; 193 link->next = dev_list;
195 dev_list = link; 194 dev_list = link;
196 client_reg.dev_info = &dev_info; 195 client_reg.dev_info = &dev_info;
197 client_reg.event_handler = &qlogic_event;
198 client_reg.EventMask = CS_EVENT_RESET_REQUEST | CS_EVENT_CARD_RESET | CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
199 client_reg.Version = 0x0210; 196 client_reg.Version = 0x0210;
200 client_reg.event_callback_args.client_data = link; 197 client_reg.event_callback_args.client_data = link;
201 ret = pcmcia_register_client(&link->handle, &client_reg); 198 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -423,6 +420,7 @@ static struct pcmcia_driver qlogic_cs_driver = {
423 .name = "qlogic_cs", 420 .name = "qlogic_cs",
424 }, 421 },
425 .attach = qlogic_attach, 422 .attach = qlogic_attach,
423 .event = qlogic_event,
426 .detach = qlogic_detach, 424 .detach = qlogic_detach,
427 .id_table = qlogic_ids, 425 .id_table = qlogic_ids,
428}; 426};
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 7d4b16b6797d..b4b3a1a8a0c7 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -979,10 +979,6 @@ SYM53C500_attach(void)
979 link->next = dev_list; 979 link->next = dev_list;
980 dev_list = link; 980 dev_list = link;
981 client_reg.dev_info = &dev_info; 981 client_reg.dev_info = &dev_info;
982 client_reg.event_handler = &SYM53C500_event;
983 client_reg.EventMask = CS_EVENT_RESET_REQUEST | CS_EVENT_CARD_RESET |
984 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
985 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
986 client_reg.Version = 0x0210; 982 client_reg.Version = 0x0210;
987 client_reg.event_callback_args.client_data = link; 983 client_reg.event_callback_args.client_data = link;
988 ret = pcmcia_register_client(&link->handle, &client_reg); 984 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -1013,6 +1009,7 @@ static struct pcmcia_driver sym53c500_cs_driver = {
1013 .name = "sym53c500_cs", 1009 .name = "sym53c500_cs",
1014 }, 1010 },
1015 .attach = SYM53C500_attach, 1011 .attach = SYM53C500_attach,
1012 .event = SYM53C500_event,
1016 .detach = SYM53C500_detach, 1013 .detach = SYM53C500_detach,
1017 .id_table = sym53c500_ids, 1014 .id_table = sym53c500_ids,
1018}; 1015};
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 9224fc3184ea..7e8fc7c1d4cc 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2061,7 +2061,8 @@ static void __init serial8250_isa_init_ports(void)
2061 up->port.ops = &serial8250_pops; 2061 up->port.ops = &serial8250_pops;
2062 } 2062 }
2063 2063
2064 for (i = 0, up = serial8250_ports; i < ARRAY_SIZE(old_serial_port); 2064 for (i = 0, up = serial8250_ports;
2065 i < ARRAY_SIZE(old_serial_port) && i < UART_NR;
2065 i++, up++) { 2066 i++, up++) {
2066 up->port.iobase = old_serial_port[i].port; 2067 up->port.iobase = old_serial_port[i].port;
2067 up->port.irq = irq_canonicalize(old_serial_port[i].irq); 2068 up->port.irq = irq_canonicalize(old_serial_port[i].irq);
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
index de26cf7b003c..7911912f50c7 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
@@ -94,12 +94,42 @@ void smc1_lineif(struct uart_cpm_port *pinfo)
94 ((immap_t *)IMAP_ADDR)->im_ioport.iop_paodr &= ~iobits; 94 ((immap_t *)IMAP_ADDR)->im_ioport.iop_paodr &= ~iobits;
95 } 95 }
96 96
97#ifdef CONFIG_MPC885ADS
98 /* Enable SMC1 transceivers */
99 {
100 volatile uint __iomem *bcsr1 = ioremap(BCSR1, 4);
101 uint tmp;
102
103 tmp = in_be32(bcsr1);
104 tmp &= ~BCSR1_RS232EN_1;
105 out_be32(bcsr1, tmp);
106 iounmap(bcsr1);
107 }
108#endif
109
97 pinfo->brg = 1; 110 pinfo->brg = 1;
98} 111}
99 112
100void smc2_lineif(struct uart_cpm_port *pinfo) 113void smc2_lineif(struct uart_cpm_port *pinfo)
101{ 114{
102 /* XXX SMC2: insert port configuration here */ 115#ifdef CONFIG_MPC885ADS
116 volatile cpm8xx_t *cp = cpmp;
117 volatile uint __iomem *bcsr1;
118 uint tmp;
119
120 cp->cp_pepar |= 0x00000c00;
121 cp->cp_pedir &= ~0x00000c00;
122 cp->cp_peso &= ~0x00000400;
123 cp->cp_peso |= 0x00000800;
124
125 /* Enable SMC2 transceivers */
126 bcsr1 = ioremap(BCSR1, 4);
127 tmp = in_be32(bcsr1);
128 tmp &= ~BCSR1_RS232EN_2;
129 out_be32(bcsr1, tmp);
130 iounmap(bcsr1);
131#endif
132
103 pinfo->brg = 2; 133 pinfo->brg = 2;
104} 134}
105 135
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index 1c9f71617123..7db2f37532cf 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -1545,7 +1545,7 @@ static void pmz_dispose_port(struct uart_pmac_port *uap)
1545/* 1545/*
1546 * Called upon match with an escc node in the devive-tree. 1546 * Called upon match with an escc node in the devive-tree.
1547 */ 1547 */
1548static int pmz_attach(struct macio_dev *mdev, const struct of_match *match) 1548static int pmz_attach(struct macio_dev *mdev, const struct of_device_id *match)
1549{ 1549{
1550 int i; 1550 int i;
1551 1551
@@ -1850,20 +1850,17 @@ err_out:
1850 return rc; 1850 return rc;
1851} 1851}
1852 1852
1853static struct of_match pmz_match[] = 1853static struct of_device_id pmz_match[] =
1854{ 1854{
1855 { 1855 {
1856 .name = "ch-a", 1856 .name = "ch-a",
1857 .type = OF_ANY_MATCH,
1858 .compatible = OF_ANY_MATCH
1859 }, 1857 },
1860 { 1858 {
1861 .name = "ch-b", 1859 .name = "ch-b",
1862 .type = OF_ANY_MATCH,
1863 .compatible = OF_ANY_MATCH
1864 }, 1860 },
1865 {}, 1861 {},
1866}; 1862};
1863MODULE_DEVICE_TABLE (of, pmz_match);
1867 1864
1868static struct macio_driver pmz_driver = 1865static struct macio_driver pmz_driver =
1869{ 1866{
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 5c4678478b1d..7365d4b50b95 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -522,14 +522,11 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
522static int s3c24xx_serial_startup(struct uart_port *port) 522static int s3c24xx_serial_startup(struct uart_port *port)
523{ 523{
524 struct s3c24xx_uart_port *ourport = to_ourport(port); 524 struct s3c24xx_uart_port *ourport = to_ourport(port);
525 unsigned long flags;
526 int ret; 525 int ret;
527 526
528 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n", 527 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
529 port->mapbase, port->membase); 528 port->mapbase, port->membase);
530 529
531 local_irq_save(flags);
532
533 rx_enabled(port) = 1; 530 rx_enabled(port) = 1;
534 531
535 ret = request_irq(RX_IRQ(port), 532 ret = request_irq(RX_IRQ(port),
@@ -563,12 +560,10 @@ static int s3c24xx_serial_startup(struct uart_port *port)
563 /* the port reset code should have done the correct 560 /* the port reset code should have done the correct
564 * register setup for the port controls */ 561 * register setup for the port controls */
565 562
566 local_irq_restore(flags);
567 return ret; 563 return ret;
568 564
569 err: 565 err:
570 s3c24xx_serial_shutdown(port); 566 s3c24xx_serial_shutdown(port);
571 local_irq_restore(flags);
572 return ret; 567 return ret;
573} 568}
574 569
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 139863a787f3..54699c3a00ab 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1808,6 +1808,12 @@ uart_set_options(struct uart_port *port, struct console *co,
1808 struct termios termios; 1808 struct termios termios;
1809 int i; 1809 int i;
1810 1810
1811 /*
1812 * Ensure that the serial console lock is initialised
1813 * early.
1814 */
1815 spin_lock_init(&port->lock);
1816
1811 memset(&termios, 0, sizeof(struct termios)); 1817 memset(&termios, 0, sizeof(struct termios));
1812 1818
1813 termios.c_cflag = CREAD | HUPCL | CLOCAL; 1819 termios.c_cflag = CREAD | HUPCL | CLOCAL;
@@ -2196,10 +2202,16 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port)
2196 2202
2197 state->port = port; 2203 state->port = port;
2198 2204
2199 spin_lock_init(&port->lock);
2200 port->cons = drv->cons; 2205 port->cons = drv->cons;
2201 port->info = state->info; 2206 port->info = state->info;
2202 2207
2208 /*
2209 * If this port is a console, then the spinlock is already
2210 * initialised.
2211 */
2212 if (!uart_console(port))
2213 spin_lock_init(&port->lock);
2214
2203 uart_configure_port(drv, state, port); 2215 uart_configure_port(drv, state, port);
2204 2216
2205 /* 2217 /*
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 73a34b18866f..de0136cc5938 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -45,7 +45,6 @@
45#include <asm/io.h> 45#include <asm/io.h>
46#include <asm/system.h> 46#include <asm/system.h>
47 47
48#include <pcmcia/version.h>
49#include <pcmcia/cs_types.h> 48#include <pcmcia/cs_types.h>
50#include <pcmcia/cs.h> 49#include <pcmcia/cs.h>
51#include <pcmcia/cistpl.h> 50#include <pcmcia/cistpl.h>
@@ -232,11 +231,6 @@ static dev_link_t *serial_attach(void)
232 link->next = dev_list; 231 link->next = dev_list;
233 dev_list = link; 232 dev_list = link;
234 client_reg.dev_info = &dev_info; 233 client_reg.dev_info = &dev_info;
235 client_reg.EventMask =
236 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
237 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
238 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
239 client_reg.event_handler = &serial_event;
240 client_reg.Version = 0x0210; 234 client_reg.Version = 0x0210;
241 client_reg.event_callback_args.client_data = link; 235 client_reg.event_callback_args.client_data = link;
242 ret = pcmcia_register_client(&link->handle, &client_reg); 236 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -883,6 +877,7 @@ static struct pcmcia_driver serial_cs_driver = {
883 .name = "serial_cs", 877 .name = "serial_cs",
884 }, 878 },
885 .attach = serial_attach, 879 .attach = serial_attach,
880 .event = serial_event,
886 .detach = serial_detach, 881 .detach = serial_detach,
887 .id_table = serial_ids, 882 .id_table = serial_ids,
888}; 883};
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index ce5ebfe4af2b..57c0c6e3fbed 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -9,7 +9,6 @@
9#include <linux/errno.h> /* error codes */ 9#include <linux/errno.h> /* error codes */
10#include <linux/slab.h> 10#include <linux/slab.h>
11 11
12#include <pcmcia/version.h>
13#include <pcmcia/cs_types.h> 12#include <pcmcia/cs_types.h>
14#include <pcmcia/cs.h> 13#include <pcmcia/cs.h>
15#include <pcmcia/cistpl.h> 14#include <pcmcia/cistpl.h>
@@ -69,11 +68,6 @@ static dev_link_t *ixj_attach(void)
69 link->next = dev_list; 68 link->next = dev_list;
70 dev_list = link; 69 dev_list = link;
71 client_reg.dev_info = &dev_info; 70 client_reg.dev_info = &dev_info;
72 client_reg.EventMask =
73 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
74 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
75 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
76 client_reg.event_handler = &ixj_event;
77 client_reg.Version = 0x0210; 71 client_reg.Version = 0x0210;
78 client_reg.event_callback_args.client_data = link; 72 client_reg.event_callback_args.client_data = link;
79 ret = pcmcia_register_client(&link->handle, &client_reg); 73 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -307,6 +301,7 @@ static struct pcmcia_driver ixj_driver = {
307 .name = "ixj_cs", 301 .name = "ixj_cs",
308 }, 302 },
309 .attach = ixj_attach, 303 .attach = ixj_attach,
304 .event = ixj_event,
310 .detach = ixj_detach, 305 .detach = ixj_detach,
311 .id_table = ixj_ids, 306 .id_table = ixj_ids,
312}; 307};
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index d79cd218a551..df014c2a7c54 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -65,12 +65,14 @@ obj-$(CONFIG_USB_EMI26) += misc/
65obj-$(CONFIG_USB_EMI62) += misc/ 65obj-$(CONFIG_USB_EMI62) += misc/
66obj-$(CONFIG_USB_IDMOUSE) += misc/ 66obj-$(CONFIG_USB_IDMOUSE) += misc/
67obj-$(CONFIG_USB_LCD) += misc/ 67obj-$(CONFIG_USB_LCD) += misc/
68obj-$(CONFIG_USB_LD) += misc/
68obj-$(CONFIG_USB_LED) += misc/ 69obj-$(CONFIG_USB_LED) += misc/
69obj-$(CONFIG_USB_LEGOTOWER) += misc/ 70obj-$(CONFIG_USB_LEGOTOWER) += misc/
70obj-$(CONFIG_USB_RIO500) += misc/ 71obj-$(CONFIG_USB_RIO500) += misc/
71obj-$(CONFIG_USB_TEST) += misc/ 72obj-$(CONFIG_USB_TEST) += misc/
72obj-$(CONFIG_USB_USS720) += misc/ 73obj-$(CONFIG_USB_USS720) += misc/
73obj-$(CONFIG_USB_PHIDGETSERVO) += misc/ 74obj-$(CONFIG_USB_PHIDGETSERVO) += misc/
75obj-$(CONFIG_USB_SISUSBVGA) += misc/
74 76
75obj-$(CONFIG_USB_ATM) += atm/ 77obj-$(CONFIG_USB_ATM) += atm/
76obj-$(CONFIG_USB_SPEEDTOUCH) += atm/ 78obj-$(CONFIG_USB_SPEEDTOUCH) += atm/
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index cbd4a7d25d0b..8e184e2641cb 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -427,7 +427,7 @@ static void cxacru_poll_status(struct cxacru_data *instance)
427 atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424; 427 atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424;
428 atm_dev->signal = ATM_PHY_SIG_FOUND; 428 atm_dev->signal = ATM_PHY_SIG_FOUND;
429 429
430 dev_info(dev, "ADSL line: up (%d Kib/s down | %d Kib/s up)\n", 430 dev_info(dev, "ADSL line: up (%d kb/s down | %d kb/s up)\n",
431 buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]); 431 buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]);
432 break; 432 break;
433 433
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 6a6eaa2a3b1c..d0cbbb7f0385 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -100,6 +100,8 @@ struct speedtch_instance_data {
100 100
101 struct work_struct status_checker; 101 struct work_struct status_checker;
102 102
103 unsigned char last_status;
104
103 int poll_delay; /* milliseconds */ 105 int poll_delay; /* milliseconds */
104 106
105 struct timer_list resubmit_timer; 107 struct timer_list resubmit_timer;
@@ -423,52 +425,48 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
423 struct usbatm_data *usbatm = instance->usbatm; 425 struct usbatm_data *usbatm = instance->usbatm;
424 struct atm_dev *atm_dev = usbatm->atm_dev; 426 struct atm_dev *atm_dev = usbatm->atm_dev;
425 unsigned char *buf = instance->scratch_buffer; 427 unsigned char *buf = instance->scratch_buffer;
426 int ret; 428 int down_speed, up_speed, ret;
429 unsigned char status;
427 430
428 atm_dbg(usbatm, "%s entered\n", __func__); 431 atm_dbg(usbatm, "%s entered\n", __func__);
429 432
430 ret = speedtch_read_status(instance); 433 ret = speedtch_read_status(instance);
431 if (ret < 0) { 434 if (ret < 0) {
432 atm_warn(usbatm, "error %d fetching device status\n", ret); 435 atm_warn(usbatm, "error %d fetching device status\n", ret);
433 if (instance->poll_delay < MAX_POLL_DELAY) 436 instance->poll_delay = min(2 * instance->poll_delay, MAX_POLL_DELAY);
434 instance->poll_delay *= 2;
435 return; 437 return;
436 } 438 }
437 439
438 if (instance->poll_delay > MIN_POLL_DELAY) 440 instance->poll_delay = max(instance->poll_delay / 2, MIN_POLL_DELAY);
439 instance->poll_delay /= 2;
440 441
441 atm_dbg(usbatm, "%s: line state %02x\n", __func__, buf[OFFSET_7]); 442 status = buf[OFFSET_7];
442 443
443 switch (buf[OFFSET_7]) { 444 atm_dbg(usbatm, "%s: line state %02x\n", __func__, status);
444 case 0: 445
445 if (atm_dev->signal != ATM_PHY_SIG_LOST) { 446 if ((status != instance->last_status) || !status) {
447 switch (status) {
448 case 0:
446 atm_dev->signal = ATM_PHY_SIG_LOST; 449 atm_dev->signal = ATM_PHY_SIG_LOST;
447 atm_info(usbatm, "ADSL line is down\n"); 450 if (instance->last_status)
448 /* It'll never resync again unless we ask it to... */ 451 atm_info(usbatm, "ADSL line is down\n");
452 /* It may never resync again unless we ask it to... */
449 ret = speedtch_start_synchro(instance); 453 ret = speedtch_start_synchro(instance);
450 } 454 break;
451 break;
452 455
453 case 0x08: 456 case 0x08:
454 if (atm_dev->signal != ATM_PHY_SIG_UNKNOWN) {
455 atm_dev->signal = ATM_PHY_SIG_UNKNOWN; 457 atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
456 atm_info(usbatm, "ADSL line is blocked?\n"); 458 atm_info(usbatm, "ADSL line is blocked?\n");
457 } 459 break;
458 break;
459 460
460 case 0x10: 461 case 0x10:
461 if (atm_dev->signal != ATM_PHY_SIG_LOST) {
462 atm_dev->signal = ATM_PHY_SIG_LOST; 462 atm_dev->signal = ATM_PHY_SIG_LOST;
463 atm_info(usbatm, "ADSL line is synchronising\n"); 463 atm_info(usbatm, "ADSL line is synchronising\n");
464 } 464 break;
465 break;
466 465
467 case 0x20: 466 case 0x20:
468 if (atm_dev->signal != ATM_PHY_SIG_FOUND) { 467 down_speed = buf[OFFSET_b] | (buf[OFFSET_b + 1] << 8)
469 int down_speed = buf[OFFSET_b] | (buf[OFFSET_b + 1] << 8)
470 | (buf[OFFSET_b + 2] << 16) | (buf[OFFSET_b + 3] << 24); 468 | (buf[OFFSET_b + 2] << 16) | (buf[OFFSET_b + 3] << 24);
471 int up_speed = buf[OFFSET_b + 4] | (buf[OFFSET_b + 5] << 8) 469 up_speed = buf[OFFSET_b + 4] | (buf[OFFSET_b + 5] << 8)
472 | (buf[OFFSET_b + 6] << 16) | (buf[OFFSET_b + 7] << 24); 470 | (buf[OFFSET_b + 6] << 16) | (buf[OFFSET_b + 7] << 24);
473 471
474 if (!(down_speed & 0x0000ffff) && !(up_speed & 0x0000ffff)) { 472 if (!(down_speed & 0x0000ffff) && !(up_speed & 0x0000ffff)) {
@@ -480,17 +478,17 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
480 atm_dev->signal = ATM_PHY_SIG_FOUND; 478 atm_dev->signal = ATM_PHY_SIG_FOUND;
481 479
482 atm_info(usbatm, 480 atm_info(usbatm,
483 "ADSL line is up (%d Kib/s down | %d Kib/s up)\n", 481 "ADSL line is up (%d kb/s down | %d kb/s up)\n",
484 down_speed, up_speed); 482 down_speed, up_speed);
485 } 483 break;
486 break;
487 484
488 default: 485 default:
489 if (atm_dev->signal != ATM_PHY_SIG_UNKNOWN) {
490 atm_dev->signal = ATM_PHY_SIG_UNKNOWN; 486 atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
491 atm_info(usbatm, "Unknown line state %02x\n", buf[OFFSET_7]); 487 atm_info(usbatm, "Unknown line state %02x\n", status);
488 break;
492 } 489 }
493 break; 490
491 instance->last_status = status;
494 } 492 }
495} 493}
496 494
@@ -730,6 +728,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
730 728
731 instance->status_checker.timer.function = speedtch_status_poll; 729 instance->status_checker.timer.function = speedtch_status_poll;
732 instance->status_checker.timer.data = (unsigned long)instance; 730 instance->status_checker.timer.data = (unsigned long)instance;
731 instance->last_status = 0xff;
733 instance->poll_delay = MIN_POLL_DELAY; 732 instance->poll_delay = MIN_POLL_DELAY;
734 733
735 init_timer(&instance->resubmit_timer); 734 init_timer(&instance->resubmit_timer);
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 69e859e0f51d..adff5a77e31f 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -422,6 +422,17 @@ bail_out:
422 return -EIO; 422 return -EIO;
423} 423}
424 424
425static void acm_tty_unregister(struct acm *acm)
426{
427 tty_unregister_device(acm_tty_driver, acm->minor);
428 usb_put_intf(acm->control);
429 acm_table[acm->minor] = NULL;
430 usb_free_urb(acm->ctrlurb);
431 usb_free_urb(acm->readurb);
432 usb_free_urb(acm->writeurb);
433 kfree(acm);
434}
435
425static void acm_tty_close(struct tty_struct *tty, struct file *filp) 436static void acm_tty_close(struct tty_struct *tty, struct file *filp)
426{ 437{
427 struct acm *acm = tty->driver_data; 438 struct acm *acm = tty->driver_data;
@@ -436,14 +447,8 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
436 usb_kill_urb(acm->ctrlurb); 447 usb_kill_urb(acm->ctrlurb);
437 usb_kill_urb(acm->writeurb); 448 usb_kill_urb(acm->writeurb);
438 usb_kill_urb(acm->readurb); 449 usb_kill_urb(acm->readurb);
439 } else { 450 } else
440 tty_unregister_device(acm_tty_driver, acm->minor); 451 acm_tty_unregister(acm);
441 acm_table[acm->minor] = NULL;
442 usb_free_urb(acm->ctrlurb);
443 usb_free_urb(acm->readurb);
444 usb_free_urb(acm->writeurb);
445 kfree(acm);
446 }
447 } 452 }
448 up(&open_sem); 453 up(&open_sem);
449} 454}
@@ -905,7 +910,8 @@ skip_normal_probe:
905 910
906 usb_driver_claim_interface(&acm_driver, data_interface, acm); 911 usb_driver_claim_interface(&acm_driver, data_interface, acm);
907 912
908 tty_register_device(acm_tty_driver, minor, &intf->dev); 913 usb_get_intf(control_interface);
914 tty_register_device(acm_tty_driver, minor, &control_interface->dev);
909 915
910 acm_table[minor] = acm; 916 acm_table[minor] = acm;
911 usb_set_intfdata (intf, acm); 917 usb_set_intfdata (intf, acm);
@@ -954,12 +960,7 @@ static void acm_disconnect(struct usb_interface *intf)
954 usb_driver_release_interface(&acm_driver, acm->data); 960 usb_driver_release_interface(&acm_driver, acm->data);
955 961
956 if (!acm->used) { 962 if (!acm->used) {
957 tty_unregister_device(acm_tty_driver, acm->minor); 963 acm_tty_unregister(acm);
958 acm_table[acm->minor] = NULL;
959 usb_free_urb(acm->ctrlurb);
960 usb_free_urb(acm->readurb);
961 usb_free_urb(acm->writeurb);
962 kfree(acm);
963 up(&open_sem); 964 up(&open_sem);
964 return; 965 return;
965 } 966 }
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index b7827df21f48..fc15b4acc8af 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -106,7 +106,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd)
106void *hcd_buffer_alloc ( 106void *hcd_buffer_alloc (
107 struct usb_bus *bus, 107 struct usb_bus *bus,
108 size_t size, 108 size_t size,
109 int mem_flags, 109 unsigned mem_flags,
110 dma_addr_t *dma 110 dma_addr_t *dma
111) 111)
112{ 112{
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 71b4a8d66318..fc056062c960 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -380,6 +380,7 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
380 usb_hc_died (hcd); 380 usb_hc_died (hcd);
381 } 381 }
382 382
383 pci_enable_device(dev);
383 return retval; 384 return retval;
384} 385}
385EXPORT_SYMBOL (usb_hcd_pci_resume); 386EXPORT_SYMBOL (usb_hcd_pci_resume);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 83e732a0d64a..8616356f55e8 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1112,7 +1112,7 @@ static void urb_unlink (struct urb *urb)
1112 * expects usb_submit_urb() to have sanity checked and conditioned all 1112 * expects usb_submit_urb() to have sanity checked and conditioned all
1113 * inputs in the urb 1113 * inputs in the urb
1114 */ 1114 */
1115static int hcd_submit_urb (struct urb *urb, int mem_flags) 1115static int hcd_submit_urb (struct urb *urb, unsigned mem_flags)
1116{ 1116{
1117 int status; 1117 int status;
1118 struct usb_hcd *hcd = urb->dev->bus->hcpriv; 1118 struct usb_hcd *hcd = urb->dev->bus->hcpriv;
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 8dc13cde2f73..67db4a999b93 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -142,12 +142,12 @@ struct hcd_timeout { /* timeouts we allocate */
142 142
143struct usb_operations { 143struct usb_operations {
144 int (*get_frame_number) (struct usb_device *usb_dev); 144 int (*get_frame_number) (struct usb_device *usb_dev);
145 int (*submit_urb) (struct urb *urb, int mem_flags); 145 int (*submit_urb) (struct urb *urb, unsigned mem_flags);
146 int (*unlink_urb) (struct urb *urb, int status); 146 int (*unlink_urb) (struct urb *urb, int status);
147 147
148 /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */ 148 /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */
149 void *(*buffer_alloc)(struct usb_bus *bus, size_t size, 149 void *(*buffer_alloc)(struct usb_bus *bus, size_t size,
150 int mem_flags, 150 unsigned mem_flags,
151 dma_addr_t *dma); 151 dma_addr_t *dma);
152 void (*buffer_free)(struct usb_bus *bus, size_t size, 152 void (*buffer_free)(struct usb_bus *bus, size_t size,
153 void *addr, dma_addr_t dma); 153 void *addr, dma_addr_t dma);
@@ -200,7 +200,7 @@ struct hc_driver {
200 int (*urb_enqueue) (struct usb_hcd *hcd, 200 int (*urb_enqueue) (struct usb_hcd *hcd,
201 struct usb_host_endpoint *ep, 201 struct usb_host_endpoint *ep,
202 struct urb *urb, 202 struct urb *urb,
203 int mem_flags); 203 unsigned mem_flags);
204 int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb); 204 int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb);
205 205
206 /* hw synch, freeing endpoint resources that urb_dequeue can't */ 206 /* hw synch, freeing endpoint resources that urb_dequeue can't */
@@ -247,7 +247,7 @@ int hcd_buffer_create (struct usb_hcd *hcd);
247void hcd_buffer_destroy (struct usb_hcd *hcd); 247void hcd_buffer_destroy (struct usb_hcd *hcd);
248 248
249void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, 249void *hcd_buffer_alloc (struct usb_bus *bus, size_t size,
250 int mem_flags, dma_addr_t *dma); 250 unsigned mem_flags, dma_addr_t *dma);
251void hcd_buffer_free (struct usb_bus *bus, size_t size, 251void hcd_buffer_free (struct usb_bus *bus, size_t size,
252 void *addr, dma_addr_t dma); 252 void *addr, dma_addr_t dma);
253 253
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 32ff32181852..c3e46d24a37e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -26,6 +26,7 @@
26#include <linux/ioctl.h> 26#include <linux/ioctl.h>
27#include <linux/usb.h> 27#include <linux/usb.h>
28#include <linux/usbdevice_fs.h> 28#include <linux/usbdevice_fs.h>
29#include <linux/kthread.h>
29 30
30#include <asm/semaphore.h> 31#include <asm/semaphore.h>
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
@@ -47,8 +48,7 @@ static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */
47/* Wakes up khubd */ 48/* Wakes up khubd */
48static DECLARE_WAIT_QUEUE_HEAD(khubd_wait); 49static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
49 50
50static pid_t khubd_pid = 0; /* PID of khubd */ 51static struct task_struct *khubd_task;
51static DECLARE_COMPLETION(khubd_exited);
52 52
53/* cycle leds on hubs that aren't blinking for attention */ 53/* cycle leds on hubs that aren't blinking for attention */
54static int blinkenlights = 0; 54static int blinkenlights = 0;
@@ -2807,23 +2807,16 @@ loop:
2807 2807
2808static int hub_thread(void *__unused) 2808static int hub_thread(void *__unused)
2809{ 2809{
2810 /*
2811 * This thread doesn't need any user-level access,
2812 * so get rid of all our resources
2813 */
2814
2815 daemonize("khubd");
2816 allow_signal(SIGKILL);
2817
2818 /* Send me a signal to get me die (for debugging) */
2819 do { 2810 do {
2820 hub_events(); 2811 hub_events();
2821 wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list)); 2812 wait_event_interruptible(khubd_wait,
2813 !list_empty(&hub_event_list) ||
2814 kthread_should_stop());
2822 try_to_freeze(); 2815 try_to_freeze();
2823 } while (!signal_pending(current)); 2816 } while (!kthread_should_stop() || !list_empty(&hub_event_list));
2824 2817
2825 pr_debug ("%s: khubd exiting\n", usbcore_name); 2818 pr_debug("%s: khubd exiting\n", usbcore_name);
2826 complete_and_exit(&khubd_exited, 0); 2819 return 0;
2827} 2820}
2828 2821
2829static struct usb_device_id hub_id_table [] = { 2822static struct usb_device_id hub_id_table [] = {
@@ -2849,20 +2842,15 @@ static struct usb_driver hub_driver = {
2849 2842
2850int usb_hub_init(void) 2843int usb_hub_init(void)
2851{ 2844{
2852 pid_t pid;
2853
2854 if (usb_register(&hub_driver) < 0) { 2845 if (usb_register(&hub_driver) < 0) {
2855 printk(KERN_ERR "%s: can't register hub driver\n", 2846 printk(KERN_ERR "%s: can't register hub driver\n",
2856 usbcore_name); 2847 usbcore_name);
2857 return -1; 2848 return -1;
2858 } 2849 }
2859 2850
2860 pid = kernel_thread(hub_thread, NULL, CLONE_KERNEL); 2851 khubd_task = kthread_run(hub_thread, NULL, "khubd");
2861 if (pid >= 0) { 2852 if (!IS_ERR(khubd_task))
2862 khubd_pid = pid;
2863
2864 return 0; 2853 return 0;
2865 }
2866 2854
2867 /* Fall through if kernel_thread failed */ 2855 /* Fall through if kernel_thread failed */
2868 usb_deregister(&hub_driver); 2856 usb_deregister(&hub_driver);
@@ -2873,12 +2861,7 @@ int usb_hub_init(void)
2873 2861
2874void usb_hub_cleanup(void) 2862void usb_hub_cleanup(void)
2875{ 2863{
2876 int ret; 2864 kthread_stop(khubd_task);
2877
2878 /* Kill the thread */
2879 ret = kill_proc(khubd_pid, SIGKILL, 1);
2880
2881 wait_for_completion(&khubd_exited);
2882 2865
2883 /* 2866 /*
2884 * Hub resources are freed for us by usb_deregister. It calls 2867 * Hub resources are freed for us by usb_deregister. It calls
@@ -2890,7 +2873,6 @@ void usb_hub_cleanup(void)
2890 usb_deregister(&hub_driver); 2873 usb_deregister(&hub_driver);
2891} /* usb_hub_cleanup() */ 2874} /* usb_hub_cleanup() */
2892 2875
2893
2894static int config_descriptors_changed(struct usb_device *udev) 2876static int config_descriptors_changed(struct usb_device *udev)
2895{ 2877{
2896 unsigned index; 2878 unsigned index;
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f50aaf25c98e..a428ef479bd7 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -320,7 +320,7 @@ int usb_sg_init (
320 struct scatterlist *sg, 320 struct scatterlist *sg,
321 int nents, 321 int nents,
322 size_t length, 322 size_t length,
323 int mem_flags 323 unsigned mem_flags
324) 324)
325{ 325{
326 int i; 326 int i;
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 740cb4c668df..00297f113849 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -196,6 +196,7 @@ usb_descriptor_attr (bDeviceClass, "%02x\n")
196usb_descriptor_attr (bDeviceSubClass, "%02x\n") 196usb_descriptor_attr (bDeviceSubClass, "%02x\n")
197usb_descriptor_attr (bDeviceProtocol, "%02x\n") 197usb_descriptor_attr (bDeviceProtocol, "%02x\n")
198usb_descriptor_attr (bNumConfigurations, "%d\n") 198usb_descriptor_attr (bNumConfigurations, "%d\n")
199usb_descriptor_attr (bMaxPacketSize0, "%d\n")
199 200
200static struct attribute *dev_attrs[] = { 201static struct attribute *dev_attrs[] = {
201 /* current configuration's attributes */ 202 /* current configuration's attributes */
@@ -211,6 +212,7 @@ static struct attribute *dev_attrs[] = {
211 &dev_attr_bDeviceSubClass.attr, 212 &dev_attr_bDeviceSubClass.attr,
212 &dev_attr_bDeviceProtocol.attr, 213 &dev_attr_bDeviceProtocol.attr,
213 &dev_attr_bNumConfigurations.attr, 214 &dev_attr_bNumConfigurations.attr,
215 &dev_attr_bMaxPacketSize0.attr,
214 &dev_attr_speed.attr, 216 &dev_attr_speed.attr,
215 &dev_attr_devnum.attr, 217 &dev_attr_devnum.attr,
216 &dev_attr_version.attr, 218 &dev_attr_version.attr,
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 0faf18d511de..c0feee25ff0a 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -60,7 +60,7 @@ void usb_init_urb(struct urb *urb)
60 * 60 *
61 * The driver must call usb_free_urb() when it is finished with the urb. 61 * The driver must call usb_free_urb() when it is finished with the urb.
62 */ 62 */
63struct urb *usb_alloc_urb(int iso_packets, int mem_flags) 63struct urb *usb_alloc_urb(int iso_packets, unsigned mem_flags)
64{ 64{
65 struct urb *urb; 65 struct urb *urb;
66 66
@@ -224,7 +224,7 @@ struct urb * usb_get_urb(struct urb *urb)
224 * GFP_NOIO, unless b) or c) apply 224 * GFP_NOIO, unless b) or c) apply
225 * 225 *
226 */ 226 */
227int usb_submit_urb(struct urb *urb, int mem_flags) 227int usb_submit_urb(struct urb *urb, unsigned mem_flags)
228{ 228{
229 int pipe, temp, max; 229 int pipe, temp, max;
230 struct usb_device *dev; 230 struct usb_device *dev;
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index a3c42203213a..99c85d2f92da 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -1129,7 +1129,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
1129void *usb_buffer_alloc ( 1129void *usb_buffer_alloc (
1130 struct usb_device *dev, 1130 struct usb_device *dev,
1131 size_t size, 1131 size_t size,
1132 int mem_flags, 1132 unsigned mem_flags,
1133 dma_addr_t *dma 1133 dma_addr_t *dma
1134) 1134)
1135{ 1135{
@@ -1532,6 +1532,9 @@ EXPORT_SYMBOL(usb_register);
1532EXPORT_SYMBOL(usb_deregister); 1532EXPORT_SYMBOL(usb_deregister);
1533EXPORT_SYMBOL(usb_disabled); 1533EXPORT_SYMBOL(usb_disabled);
1534 1534
1535EXPORT_SYMBOL_GPL(usb_get_intf);
1536EXPORT_SYMBOL_GPL(usb_put_intf);
1537
1535EXPORT_SYMBOL(usb_alloc_dev); 1538EXPORT_SYMBOL(usb_alloc_dev);
1536EXPORT_SYMBOL(usb_put_dev); 1539EXPORT_SYMBOL(usb_put_dev);
1537EXPORT_SYMBOL(usb_get_dev); 1540EXPORT_SYMBOL(usb_get_dev);
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 4d692670f288..583db7c38cf1 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -470,7 +470,7 @@ static int dummy_disable (struct usb_ep *_ep)
470} 470}
471 471
472static struct usb_request * 472static struct usb_request *
473dummy_alloc_request (struct usb_ep *_ep, int mem_flags) 473dummy_alloc_request (struct usb_ep *_ep, unsigned mem_flags)
474{ 474{
475 struct dummy_ep *ep; 475 struct dummy_ep *ep;
476 struct dummy_request *req; 476 struct dummy_request *req;
@@ -507,7 +507,7 @@ dummy_alloc_buffer (
507 struct usb_ep *_ep, 507 struct usb_ep *_ep,
508 unsigned bytes, 508 unsigned bytes,
509 dma_addr_t *dma, 509 dma_addr_t *dma,
510 int mem_flags 510 unsigned mem_flags
511) { 511) {
512 char *retval; 512 char *retval;
513 struct dummy_ep *ep; 513 struct dummy_ep *ep;
@@ -540,7 +540,8 @@ fifo_complete (struct usb_ep *ep, struct usb_request *req)
540} 540}
541 541
542static int 542static int
543dummy_queue (struct usb_ep *_ep, struct usb_request *_req, int mem_flags) 543dummy_queue (struct usb_ep *_ep, struct usb_request *_req,
544 unsigned mem_flags)
544{ 545{
545 struct dummy_ep *ep; 546 struct dummy_ep *ep;
546 struct dummy_request *req; 547 struct dummy_request *req;
@@ -998,7 +999,7 @@ static int dummy_urb_enqueue (
998 struct usb_hcd *hcd, 999 struct usb_hcd *hcd,
999 struct usb_host_endpoint *ep, 1000 struct usb_host_endpoint *ep,
1000 struct urb *urb, 1001 struct urb *urb,
1001 int mem_flags 1002 unsigned mem_flags
1002) { 1003) {
1003 struct dummy *dum; 1004 struct dummy *dum;
1004 struct urbp *urbp; 1005 struct urbp *urbp;
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 5bb53ae88969..8509e955007d 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -945,15 +945,16 @@ config_buf (enum usb_device_speed speed,
945 945
946/*-------------------------------------------------------------------------*/ 946/*-------------------------------------------------------------------------*/
947 947
948static void eth_start (struct eth_dev *dev, int gfp_flags); 948static void eth_start (struct eth_dev *dev, unsigned gfp_flags);
949static int alloc_requests (struct eth_dev *dev, unsigned n, int gfp_flags); 949static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags);
950 950
951static int 951static int
952set_ether_config (struct eth_dev *dev, int gfp_flags) 952set_ether_config (struct eth_dev *dev, unsigned gfp_flags)
953{ 953{
954 int result = 0; 954 int result = 0;
955 struct usb_gadget *gadget = dev->gadget; 955 struct usb_gadget *gadget = dev->gadget;
956 956
957#if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS)
957 /* status endpoint used for RNDIS and (optionally) CDC */ 958 /* status endpoint used for RNDIS and (optionally) CDC */
958 if (!subset_active(dev) && dev->status_ep) { 959 if (!subset_active(dev) && dev->status_ep) {
959 dev->status = ep_desc (gadget, &hs_status_desc, 960 dev->status = ep_desc (gadget, &hs_status_desc,
@@ -967,6 +968,7 @@ set_ether_config (struct eth_dev *dev, int gfp_flags)
967 goto done; 968 goto done;
968 } 969 }
969 } 970 }
971#endif
970 972
971 dev->in = ep_desc (dev->gadget, &hs_source_desc, &fs_source_desc); 973 dev->in = ep_desc (dev->gadget, &hs_source_desc, &fs_source_desc);
972 dev->in_ep->driver_data = dev; 974 dev->in_ep->driver_data = dev;
@@ -1079,7 +1081,7 @@ static void eth_reset_config (struct eth_dev *dev)
1079 * that returns config descriptors, and altsetting code. 1081 * that returns config descriptors, and altsetting code.
1080 */ 1082 */
1081static int 1083static int
1082eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags) 1084eth_set_config (struct eth_dev *dev, unsigned number, unsigned gfp_flags)
1083{ 1085{
1084 int result = 0; 1086 int result = 0;
1085 struct usb_gadget *gadget = dev->gadget; 1087 struct usb_gadget *gadget = dev->gadget;
@@ -1596,7 +1598,7 @@ static void defer_kevent (struct eth_dev *dev, int flag)
1596static void rx_complete (struct usb_ep *ep, struct usb_request *req); 1598static void rx_complete (struct usb_ep *ep, struct usb_request *req);
1597 1599
1598static int 1600static int
1599rx_submit (struct eth_dev *dev, struct usb_request *req, int gfp_flags) 1601rx_submit (struct eth_dev *dev, struct usb_request *req, unsigned gfp_flags)
1600{ 1602{
1601 struct sk_buff *skb; 1603 struct sk_buff *skb;
1602 int retval = -ENOMEM; 1604 int retval = -ENOMEM;
@@ -1722,7 +1724,7 @@ clean:
1722} 1724}
1723 1725
1724static int prealloc (struct list_head *list, struct usb_ep *ep, 1726static int prealloc (struct list_head *list, struct usb_ep *ep,
1725 unsigned n, int gfp_flags) 1727 unsigned n, unsigned gfp_flags)
1726{ 1728{
1727 unsigned i; 1729 unsigned i;
1728 struct usb_request *req; 1730 struct usb_request *req;
@@ -1761,7 +1763,7 @@ extra:
1761 return 0; 1763 return 0;
1762} 1764}
1763 1765
1764static int alloc_requests (struct eth_dev *dev, unsigned n, int gfp_flags) 1766static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags)
1765{ 1767{
1766 int status; 1768 int status;
1767 1769
@@ -1777,7 +1779,7 @@ fail:
1777 return status; 1779 return status;
1778} 1780}
1779 1781
1780static void rx_fill (struct eth_dev *dev, int gfp_flags) 1782static void rx_fill (struct eth_dev *dev, unsigned gfp_flags)
1781{ 1783{
1782 struct usb_request *req; 1784 struct usb_request *req;
1783 unsigned long flags; 1785 unsigned long flags;
@@ -2022,7 +2024,7 @@ static int rndis_control_ack (struct net_device *net)
2022 2024
2023#endif /* RNDIS */ 2025#endif /* RNDIS */
2024 2026
2025static void eth_start (struct eth_dev *dev, int gfp_flags) 2027static void eth_start (struct eth_dev *dev, unsigned gfp_flags)
2026{ 2028{
2027 DEBUG (dev, "%s\n", __FUNCTION__); 2029 DEBUG (dev, "%s\n", __FUNCTION__);
2028 2030
@@ -2428,7 +2430,7 @@ autoconf_fail:
2428 dev->req->complete = eth_setup_complete; 2430 dev->req->complete = eth_setup_complete;
2429 2431
2430 /* ... and maybe likewise for status transfer */ 2432 /* ... and maybe likewise for status transfer */
2431#ifdef DEV_CONFIG_CDC 2433#if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS)
2432 if (dev->status_ep) { 2434 if (dev->status_ep) {
2433 dev->stat_req = eth_req_alloc (dev->status_ep, 2435 dev->stat_req = eth_req_alloc (dev->status_ep,
2434 STATUS_BYTECOUNT, GFP_KERNEL); 2436 STATUS_BYTECOUNT, GFP_KERNEL);
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index ed773a9111de..eaab26f4ed37 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -269,7 +269,7 @@ static int goku_ep_disable(struct usb_ep *_ep)
269/*-------------------------------------------------------------------------*/ 269/*-------------------------------------------------------------------------*/
270 270
271static struct usb_request * 271static struct usb_request *
272goku_alloc_request(struct usb_ep *_ep, int gfp_flags) 272goku_alloc_request(struct usb_ep *_ep, unsigned gfp_flags)
273{ 273{
274 struct goku_request *req; 274 struct goku_request *req;
275 275
@@ -327,7 +327,7 @@ goku_free_request(struct usb_ep *_ep, struct usb_request *_req)
327 */ 327 */
328static void * 328static void *
329goku_alloc_buffer(struct usb_ep *_ep, unsigned bytes, 329goku_alloc_buffer(struct usb_ep *_ep, unsigned bytes,
330 dma_addr_t *dma, int gfp_flags) 330 dma_addr_t *dma, unsigned gfp_flags)
331{ 331{
332 void *retval; 332 void *retval;
333 struct goku_ep *ep; 333 struct goku_ep *ep;
@@ -789,7 +789,7 @@ finished:
789/*-------------------------------------------------------------------------*/ 789/*-------------------------------------------------------------------------*/
790 790
791static int 791static int
792goku_queue(struct usb_ep *_ep, struct usb_request *_req, int gfp_flags) 792goku_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags)
793{ 793{
794 struct goku_request *req; 794 struct goku_request *req;
795 struct goku_ep *ep; 795 struct goku_ep *ep;
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index df75ab65a5ec..4842577789c9 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -1106,7 +1106,7 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep)
1106} 1106}
1107 1107
1108static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, 1108static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep,
1109 int gfp_flags) 1109 unsigned gfp_flags)
1110{ 1110{
1111 struct lh7a40x_request *req; 1111 struct lh7a40x_request *req;
1112 1112
@@ -1134,7 +1134,7 @@ static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *_req)
1134} 1134}
1135 1135
1136static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes, 1136static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes,
1137 dma_addr_t * dma, int gfp_flags) 1137 dma_addr_t * dma, unsigned gfp_flags)
1138{ 1138{
1139 char *retval; 1139 char *retval;
1140 1140
@@ -1158,7 +1158,7 @@ static void lh7a40x_free_buffer(struct usb_ep *ep, void *buf, dma_addr_t dma,
1158 * NOTE: Sets INDEX register 1158 * NOTE: Sets INDEX register
1159 */ 1159 */
1160static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req, 1160static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req,
1161 int gfp_flags) 1161 unsigned gfp_flags)
1162{ 1162{
1163 struct lh7a40x_request *req; 1163 struct lh7a40x_request *req;
1164 struct lh7a40x_ep *ep; 1164 struct lh7a40x_ep *ep;
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 13a3dbc9949b..477fab2e74d1 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -376,7 +376,7 @@ static int net2280_disable (struct usb_ep *_ep)
376/*-------------------------------------------------------------------------*/ 376/*-------------------------------------------------------------------------*/
377 377
378static struct usb_request * 378static struct usb_request *
379net2280_alloc_request (struct usb_ep *_ep, int gfp_flags) 379net2280_alloc_request (struct usb_ep *_ep, unsigned gfp_flags)
380{ 380{
381 struct net2280_ep *ep; 381 struct net2280_ep *ep;
382 struct net2280_request *req; 382 struct net2280_request *req;
@@ -463,7 +463,7 @@ net2280_alloc_buffer (
463 struct usb_ep *_ep, 463 struct usb_ep *_ep,
464 unsigned bytes, 464 unsigned bytes,
465 dma_addr_t *dma, 465 dma_addr_t *dma,
466 int gfp_flags 466 unsigned gfp_flags
467) 467)
468{ 468{
469 void *retval; 469 void *retval;
@@ -897,7 +897,7 @@ done (struct net2280_ep *ep, struct net2280_request *req, int status)
897/*-------------------------------------------------------------------------*/ 897/*-------------------------------------------------------------------------*/
898 898
899static int 899static int
900net2280_queue (struct usb_ep *_ep, struct usb_request *_req, int gfp_flags) 900net2280_queue (struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags)
901{ 901{
902 struct net2280_request *req; 902 struct net2280_request *req;
903 struct net2280_ep *ep; 903 struct net2280_ep *ep;
@@ -1490,7 +1490,7 @@ show_registers (struct device *_dev, struct device_attribute *attr, char *buf)
1490 unsigned long flags; 1490 unsigned long flags;
1491 int i; 1491 int i;
1492 u32 t1, t2; 1492 u32 t1, t2;
1493 char *s; 1493 const char *s;
1494 1494
1495 dev = dev_get_drvdata (_dev); 1495 dev = dev_get_drvdata (_dev);
1496 next = buf; 1496 next = buf;
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index a2b812af6e66..ff5533e69560 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -269,7 +269,7 @@ static int omap_ep_disable(struct usb_ep *_ep)
269/*-------------------------------------------------------------------------*/ 269/*-------------------------------------------------------------------------*/
270 270
271static struct usb_request * 271static struct usb_request *
272omap_alloc_request(struct usb_ep *ep, int gfp_flags) 272omap_alloc_request(struct usb_ep *ep, unsigned gfp_flags)
273{ 273{
274 struct omap_req *req; 274 struct omap_req *req;
275 275
@@ -298,7 +298,7 @@ omap_alloc_buffer(
298 struct usb_ep *_ep, 298 struct usb_ep *_ep,
299 unsigned bytes, 299 unsigned bytes,
300 dma_addr_t *dma, 300 dma_addr_t *dma,
301 int gfp_flags 301 unsigned gfp_flags
302) 302)
303{ 303{
304 void *retval; 304 void *retval;
@@ -937,7 +937,7 @@ static void dma_channel_release(struct omap_ep *ep)
937/*-------------------------------------------------------------------------*/ 937/*-------------------------------------------------------------------------*/
938 938
939static int 939static int
940omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, int gfp_flags) 940omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags)
941{ 941{
942 struct omap_ep *ep = container_of(_ep, struct omap_ep, ep); 942 struct omap_ep *ep = container_of(_ep, struct omap_ep, ep);
943 struct omap_req *req = container_of(_req, struct omap_req, req); 943 struct omap_req *req = container_of(_req, struct omap_req, req);
@@ -2908,6 +2908,7 @@ static int __exit omap_udc_remove(struct device *dev)
2908 * make host resumes and VBUS detection trigger OMAP wakeup events; that 2908 * make host resumes and VBUS detection trigger OMAP wakeup events; that
2909 * may involve talking to an external transceiver (e.g. isp1301). 2909 * may involve talking to an external transceiver (e.g. isp1301).
2910 */ 2910 */
2911
2911static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level) 2912static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level)
2912{ 2913{
2913 u32 devstat; 2914 u32 devstat;
@@ -2936,8 +2937,6 @@ static int omap_udc_resume(struct device *dev, u32 level)
2936 return 0; 2937 return 0;
2937 2938
2938 DBG("resume + wakeup/SRP\n"); 2939 DBG("resume + wakeup/SRP\n");
2939 udc->gadget.dev.parent->power.power_state = PMSG_ON;
2940 udc->gadget.dev.power.power_state = PMSG_ON;
2941 omap_pullup(&udc->gadget, 1); 2940 omap_pullup(&udc->gadget, 1);
2942 2941
2943 /* maybe the host would enumerate us if we nudged it */ 2942 /* maybe the host would enumerate us if we nudged it */
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 6a0b957af335..1507738337c4 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -332,7 +332,7 @@ static int pxa2xx_ep_disable (struct usb_ep *_ep)
332 * pxa2xx_ep_alloc_request - allocate a request data structure 332 * pxa2xx_ep_alloc_request - allocate a request data structure
333 */ 333 */
334static struct usb_request * 334static struct usb_request *
335pxa2xx_ep_alloc_request (struct usb_ep *_ep, int gfp_flags) 335pxa2xx_ep_alloc_request (struct usb_ep *_ep, unsigned gfp_flags)
336{ 336{
337 struct pxa2xx_request *req; 337 struct pxa2xx_request *req;
338 338
@@ -367,7 +367,7 @@ pxa2xx_ep_free_request (struct usb_ep *_ep, struct usb_request *_req)
367 */ 367 */
368static void * 368static void *
369pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes, 369pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes,
370 dma_addr_t *dma, int gfp_flags) 370 dma_addr_t *dma, unsigned gfp_flags)
371{ 371{
372 char *retval; 372 char *retval;
373 373
@@ -874,7 +874,7 @@ done:
874/*-------------------------------------------------------------------------*/ 874/*-------------------------------------------------------------------------*/
875 875
876static int 876static int
877pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, int gfp_flags) 877pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags)
878{ 878{
879 struct pxa2xx_request *req; 879 struct pxa2xx_request *req;
880 struct pxa2xx_ep *ep; 880 struct pxa2xx_ep *ep;
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index a6e035e24479..bb9b2d94eed5 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -612,7 +612,7 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req)
612} 612}
613 613
614static struct usb_request * 614static struct usb_request *
615source_sink_start_ep (struct usb_ep *ep, int gfp_flags) 615source_sink_start_ep (struct usb_ep *ep, unsigned gfp_flags)
616{ 616{
617 struct usb_request *req; 617 struct usb_request *req;
618 int status; 618 int status;
@@ -640,7 +640,7 @@ source_sink_start_ep (struct usb_ep *ep, int gfp_flags)
640} 640}
641 641
642static int 642static int
643set_source_sink_config (struct zero_dev *dev, int gfp_flags) 643set_source_sink_config (struct zero_dev *dev, unsigned gfp_flags)
644{ 644{
645 int result = 0; 645 int result = 0;
646 struct usb_ep *ep; 646 struct usb_ep *ep;
@@ -744,7 +744,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req)
744} 744}
745 745
746static int 746static int
747set_loopback_config (struct zero_dev *dev, int gfp_flags) 747set_loopback_config (struct zero_dev *dev, unsigned gfp_flags)
748{ 748{
749 int result = 0; 749 int result = 0;
750 struct usb_ep *ep; 750 struct usb_ep *ep;
@@ -845,7 +845,7 @@ static void zero_reset_config (struct zero_dev *dev)
845 * by limiting configuration choices (like the pxa2xx). 845 * by limiting configuration choices (like the pxa2xx).
846 */ 846 */
847static int 847static int
848zero_set_config (struct zero_dev *dev, unsigned number, int gfp_flags) 848zero_set_config (struct zero_dev *dev, unsigned number, unsigned gfp_flags)
849{ 849{
850 int result = 0; 850 int result = 0;
851 struct usb_gadget *gadget = dev->gadget; 851 struct usb_gadget *gadget = dev->gadget;
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 35248a37b717..149b13fc0a71 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -960,7 +960,7 @@ static int ehci_urb_enqueue (
960 struct usb_hcd *hcd, 960 struct usb_hcd *hcd,
961 struct usb_host_endpoint *ep, 961 struct usb_host_endpoint *ep,
962 struct urb *urb, 962 struct urb *urb,
963 int mem_flags 963 unsigned mem_flags
964) { 964) {
965 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 965 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
966 struct list_head qtd_list; 966 struct list_head qtd_list;
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 45d89a7083b1..d74b2d68a50e 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -898,7 +898,7 @@ submit_async (
898 struct usb_host_endpoint *ep, 898 struct usb_host_endpoint *ep,
899 struct urb *urb, 899 struct urb *urb,
900 struct list_head *qtd_list, 900 struct list_head *qtd_list,
901 int mem_flags 901 unsigned mem_flags
902) { 902) {
903 struct ehci_qtd *qtd; 903 struct ehci_qtd *qtd;
904 int epnum; 904 int epnum;
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index c2104cad4033..9af4f64532a9 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -588,7 +588,7 @@ static int intr_submit (
588 struct usb_host_endpoint *ep, 588 struct usb_host_endpoint *ep,
589 struct urb *urb, 589 struct urb *urb,
590 struct list_head *qtd_list, 590 struct list_head *qtd_list,
591 int mem_flags 591 unsigned mem_flags
592) { 592) {
593 unsigned epnum; 593 unsigned epnum;
594 unsigned long flags; 594 unsigned long flags;
@@ -633,7 +633,7 @@ done:
633/* ehci_iso_stream ops work with both ITD and SITD */ 633/* ehci_iso_stream ops work with both ITD and SITD */
634 634
635static struct ehci_iso_stream * 635static struct ehci_iso_stream *
636iso_stream_alloc (int mem_flags) 636iso_stream_alloc (unsigned mem_flags)
637{ 637{
638 struct ehci_iso_stream *stream; 638 struct ehci_iso_stream *stream;
639 639
@@ -846,7 +846,7 @@ iso_stream_find (struct ehci_hcd *ehci, struct urb *urb)
846/* ehci_iso_sched ops can be ITD-only or SITD-only */ 846/* ehci_iso_sched ops can be ITD-only or SITD-only */
847 847
848static struct ehci_iso_sched * 848static struct ehci_iso_sched *
849iso_sched_alloc (unsigned packets, int mem_flags) 849iso_sched_alloc (unsigned packets, unsigned mem_flags)
850{ 850{
851 struct ehci_iso_sched *iso_sched; 851 struct ehci_iso_sched *iso_sched;
852 int size = sizeof *iso_sched; 852 int size = sizeof *iso_sched;
@@ -919,7 +919,7 @@ itd_urb_transaction (
919 struct ehci_iso_stream *stream, 919 struct ehci_iso_stream *stream,
920 struct ehci_hcd *ehci, 920 struct ehci_hcd *ehci,
921 struct urb *urb, 921 struct urb *urb,
922 int mem_flags 922 unsigned mem_flags
923) 923)
924{ 924{
925 struct ehci_itd *itd; 925 struct ehci_itd *itd;
@@ -1412,7 +1412,8 @@ itd_complete (
1412 1412
1413/*-------------------------------------------------------------------------*/ 1413/*-------------------------------------------------------------------------*/
1414 1414
1415static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags) 1415static int itd_submit (struct ehci_hcd *ehci, struct urb *urb,
1416 unsigned mem_flags)
1416{ 1417{
1417 int status = -EINVAL; 1418 int status = -EINVAL;
1418 unsigned long flags; 1419 unsigned long flags;
@@ -1523,7 +1524,7 @@ sitd_urb_transaction (
1523 struct ehci_iso_stream *stream, 1524 struct ehci_iso_stream *stream,
1524 struct ehci_hcd *ehci, 1525 struct ehci_hcd *ehci,
1525 struct urb *urb, 1526 struct urb *urb,
1526 int mem_flags 1527 unsigned mem_flags
1527) 1528)
1528{ 1529{
1529 struct ehci_sitd *sitd; 1530 struct ehci_sitd *sitd;
@@ -1772,7 +1773,8 @@ sitd_complete (
1772} 1773}
1773 1774
1774 1775
1775static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags) 1776static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb,
1777 unsigned mem_flags)
1776{ 1778{
1777 int status = -EINVAL; 1779 int status = -EINVAL;
1778 unsigned long flags; 1780 unsigned long flags;
@@ -1822,7 +1824,8 @@ done:
1822#else 1824#else
1823 1825
1824static inline int 1826static inline int
1825sitd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags) 1827sitd_submit (struct ehci_hcd *ehci, struct urb *urb,
1828 unsigned mem_flags)
1826{ 1829{
1827 ehci_dbg (ehci, "split iso support is disabled\n"); 1830 ehci_dbg (ehci, "split iso support is disabled\n");
1828 return -ENOSYS; 1831 return -ENOSYS;
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index d9883d774d3a..81f8f6b7fdce 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -463,7 +463,8 @@ static void etrax_usb_free_epid(int epid);
463 463
464static int etrax_remove_from_sb_list(struct urb *urb); 464static int etrax_remove_from_sb_list(struct urb *urb);
465 465
466static void* etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size, int mem_flags, dma_addr_t *dma); 466static void* etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size,
467 unsigned mem_flags, dma_addr_t *dma);
467static void etrax_usb_buffer_free(struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma); 468static void etrax_usb_buffer_free(struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma);
468 469
469static void etrax_usb_add_to_bulk_sb_list(struct urb *urb, int epid); 470static void etrax_usb_add_to_bulk_sb_list(struct urb *urb, int epid);
@@ -476,7 +477,7 @@ static int etrax_usb_submit_ctrl_urb(struct urb *urb);
476static int etrax_usb_submit_intr_urb(struct urb *urb); 477static int etrax_usb_submit_intr_urb(struct urb *urb);
477static int etrax_usb_submit_isoc_urb(struct urb *urb); 478static int etrax_usb_submit_isoc_urb(struct urb *urb);
478 479
479static int etrax_usb_submit_urb(struct urb *urb, int mem_flags); 480static int etrax_usb_submit_urb(struct urb *urb, unsigned mem_flags);
480static int etrax_usb_unlink_urb(struct urb *urb, int status); 481static int etrax_usb_unlink_urb(struct urb *urb, int status);
481static int etrax_usb_get_frame_number(struct usb_device *usb_dev); 482static int etrax_usb_get_frame_number(struct usb_device *usb_dev);
482 483
@@ -1262,7 +1263,7 @@ static int etrax_usb_allocate_epid(void)
1262 return -1; 1263 return -1;
1263} 1264}
1264 1265
1265static int etrax_usb_submit_urb(struct urb *urb, int mem_flags) 1266static int etrax_usb_submit_urb(struct urb *urb, unsigned mem_flags)
1266{ 1267{
1267 etrax_hc_t *hc; 1268 etrax_hc_t *hc;
1268 int ret = -EINVAL; 1269 int ret = -EINVAL;
@@ -4277,7 +4278,8 @@ etrax_usb_bulk_eot_timer_func(unsigned long dummy)
4277} 4278}
4278 4279
4279static void* 4280static void*
4280etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size, int mem_flags, dma_addr_t *dma) 4281etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size,
4282 unsigned mem_flags, dma_addr_t *dma)
4281{ 4283{
4282 return kmalloc(size, mem_flags); 4284 return kmalloc(size, mem_flags);
4283} 4285}
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index ff0a168e8eed..50b1970fe6b6 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -17,7 +17,7 @@
17 * The driver basically works. A number of people have used it with a range 17 * The driver basically works. A number of people have used it with a range
18 * of devices. 18 * of devices.
19 * 19 *
20 *The driver passes all usbtests 1-14. 20 * The driver passes all usbtests 1-14.
21 * 21 *
22 * Suspending/resuming of root hub via sysfs works. Remote wakeup works too. 22 * Suspending/resuming of root hub via sysfs works. Remote wakeup works too.
23 * And suspending/resuming of platform device works too. Suspend/resume 23 * And suspending/resuming of platform device works too. Suspend/resume
@@ -229,7 +229,7 @@ static void preproc_atl_queue(struct isp116x *isp116x)
229 struct isp116x_ep *ep; 229 struct isp116x_ep *ep;
230 struct urb *urb; 230 struct urb *urb;
231 struct ptd *ptd; 231 struct ptd *ptd;
232 u16 toggle, dir, len; 232 u16 toggle = 0, dir = PTD_DIR_SETUP, len;
233 233
234 for (ep = isp116x->atl_active; ep; ep = ep->active) { 234 for (ep = isp116x->atl_active; ep; ep = ep->active) {
235 BUG_ON(list_empty(&ep->hep->urb_list)); 235 BUG_ON(list_empty(&ep->hep->urb_list));
@@ -251,8 +251,6 @@ static void preproc_atl_queue(struct isp116x *isp116x)
251 dir = PTD_DIR_OUT; 251 dir = PTD_DIR_OUT;
252 break; 252 break;
253 case USB_PID_SETUP: 253 case USB_PID_SETUP:
254 toggle = 0;
255 dir = PTD_DIR_SETUP;
256 len = sizeof(struct usb_ctrlrequest); 254 len = sizeof(struct usb_ctrlrequest);
257 ep->data = urb->setup_packet; 255 ep->data = urb->setup_packet;
258 break; 256 break;
@@ -264,11 +262,9 @@ static void preproc_atl_queue(struct isp116x *isp116x)
264 ? PTD_DIR_OUT : PTD_DIR_IN; 262 ? PTD_DIR_OUT : PTD_DIR_IN;
265 break; 263 break;
266 default: 264 default:
267 /* To please gcc */
268 toggle = dir = 0;
269 ERR("%s %d: ep->nextpid %d\n", __func__, __LINE__, 265 ERR("%s %d: ep->nextpid %d\n", __func__, __LINE__,
270 ep->nextpid); 266 ep->nextpid);
271 BUG_ON(1); 267 BUG();
272 } 268 }
273 269
274 ptd->count = PTD_CC_MSK | PTD_ACTIVE_MSK | PTD_TOGGLE(toggle); 270 ptd->count = PTD_CC_MSK | PTD_ACTIVE_MSK | PTD_TOGGLE(toggle);
@@ -697,7 +693,7 @@ static int balance(struct isp116x *isp116x, u16 period, u16 load)
697 693
698static int isp116x_urb_enqueue(struct usb_hcd *hcd, 694static int isp116x_urb_enqueue(struct usb_hcd *hcd,
699 struct usb_host_endpoint *hep, struct urb *urb, 695 struct usb_host_endpoint *hep, struct urb *urb,
700 int mem_flags) 696 unsigned mem_flags)
701{ 697{
702 struct isp116x *isp116x = hcd_to_isp116x(hcd); 698 struct isp116x *isp116x = hcd_to_isp116x(hcd);
703 struct usb_device *udev = urb->dev; 699 struct usb_device *udev = urb->dev;
@@ -719,7 +715,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,
719 } 715 }
720 /* avoid all allocations within spinlocks: request or endpoint */ 716 /* avoid all allocations within spinlocks: request or endpoint */
721 if (!hep->hcpriv) { 717 if (!hep->hcpriv) {
722 ep = kcalloc(1, sizeof *ep, (__force unsigned)mem_flags); 718 ep = kcalloc(1, sizeof *ep, mem_flags);
723 if (!ep) 719 if (!ep)
724 return -ENOMEM; 720 return -ENOMEM;
725 } 721 }
@@ -1054,7 +1050,7 @@ static int isp116x_hub_control(struct usb_hcd *hcd,
1054 break; 1050 break;
1055 case GetHubStatus: 1051 case GetHubStatus:
1056 DBG("GetHubStatus\n"); 1052 DBG("GetHubStatus\n");
1057 *(__le32 *) buf = cpu_to_le32(0); 1053 *(__le32 *) buf = 0;
1058 break; 1054 break;
1059 case GetPortStatus: 1055 case GetPortStatus:
1060 DBG("GetPortStatus\n"); 1056 DBG("GetPortStatus\n");
@@ -1810,9 +1806,9 @@ static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase)
1810 ret = usb_suspend_device(hcd->self.root_hub, state); 1806 ret = usb_suspend_device(hcd->self.root_hub, state);
1811 if (!ret) { 1807 if (!ret) {
1812 dev->power.power_state = state; 1808 dev->power.power_state = state;
1813 INFO("%s suspended\n", (char *)hcd_name); 1809 INFO("%s suspended\n", hcd_name);
1814 } else 1810 } else
1815 ERR("%s suspend failed\n", (char *)hcd_name); 1811 ERR("%s suspend failed\n", hcd_name);
1816 1812
1817 return ret; 1813 return ret;
1818} 1814}
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 13cd2177b557..68decab280dd 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -180,7 +180,7 @@ static int ohci_urb_enqueue (
180 struct usb_hcd *hcd, 180 struct usb_hcd *hcd,
181 struct usb_host_endpoint *ep, 181 struct usb_host_endpoint *ep,
182 struct urb *urb, 182 struct urb *urb,
183 int mem_flags 183 unsigned mem_flags
184) { 184) {
185 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 185 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
186 struct ed *ed; 186 struct ed *ed;
@@ -673,8 +673,10 @@ retry:
673 673
674 ohci_dump (ohci, 1); 674 ohci_dump (ohci, 1);
675 675
676 if (ohci_to_hcd(ohci)->self.root_hub == NULL) 676 if (ohci_to_hcd(ohci)->self.root_hub == NULL) {
677 register_reboot_notifier (&ohci->reboot_notifier);
677 create_debug_files (ohci); 678 create_debug_files (ohci);
679 }
678 680
679 return 0; 681 return 0;
680} 682}
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index e2fc4129dfc6..83ca4549a50e 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -419,10 +419,11 @@ ohci_hub_descriptor (
419 419
420 /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */ 420 /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */
421 rh = roothub_b (ohci); 421 rh = roothub_b (ohci);
422 memset(desc->bitmap, 0xff, sizeof(desc->bitmap));
422 desc->bitmap [0] = rh & RH_B_DR; 423 desc->bitmap [0] = rh & RH_B_DR;
423 if (ports > 7) { 424 if (ports > 7) {
424 desc->bitmap [1] = (rh & RH_B_DR) >> 8; 425 desc->bitmap [1] = (rh & RH_B_DR) >> 8;
425 desc->bitmap [2] = desc->bitmap [3] = 0xff; 426 desc->bitmap [2] = 0xff;
426 } else 427 } else
427 desc->bitmap [1] = 0xff; 428 desc->bitmap [1] = 0xff;
428} 429}
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c
index 23735a36af00..fd3c4d3714bd 100644
--- a/drivers/usb/host/ohci-mem.c
+++ b/drivers/usb/host/ohci-mem.c
@@ -84,7 +84,7 @@ dma_to_td (struct ohci_hcd *hc, dma_addr_t td_dma)
84 84
85/* TDs ... */ 85/* TDs ... */
86static struct td * 86static struct td *
87td_alloc (struct ohci_hcd *hc, int mem_flags) 87td_alloc (struct ohci_hcd *hc, unsigned mem_flags)
88{ 88{
89 dma_addr_t dma; 89 dma_addr_t dma;
90 struct td *td; 90 struct td *td;
@@ -118,7 +118,7 @@ td_free (struct ohci_hcd *hc, struct td *td)
118 118
119/* EDs ... */ 119/* EDs ... */
120static struct ed * 120static struct ed *
121ed_alloc (struct ohci_hcd *hc, int mem_flags) 121ed_alloc (struct ohci_hcd *hc, unsigned mem_flags)
122{ 122{
123 dma_addr_t dma; 123 dma_addr_t dma;
124 struct ed *ed; 124 struct ed *ed;
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index b62d69937694..5cde76faab93 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -456,34 +456,22 @@ static int ohci_hcd_omap_drv_remove(struct device *dev)
456 456
457#ifdef CONFIG_PM 457#ifdef CONFIG_PM
458 458
459/* states match PCI usage, always suspending the root hub except that 459static int ohci_omap_suspend(struct device *dev, pm_message_t message, u32 level)
460 * 4 ~= D3cold (ACPI D3) with clock off (resume sees reset).
461 *
462 * FIXME: above comment is not right, and code is wrong, too :-(.
463 */
464
465static int ohci_omap_suspend(struct device *dev, pm_message_t state, u32 level)
466{ 460{
467 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); 461 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev));
468 int status = -EINVAL; 462 int status = -EINVAL;
469 463
470 if (level != SUSPEND_POWER_DOWN) 464 if (level != SUSPEND_POWER_DOWN)
471 return 0; 465 return 0;
472 if (state <= dev->power.power_state)
473 return 0;
474 466
475 dev_dbg(dev, "suspend to %d\n", state);
476 down(&ohci_to_hcd(ohci)->self.root_hub->serialize); 467 down(&ohci_to_hcd(ohci)->self.root_hub->serialize);
477 status = ohci_hub_suspend(ohci_to_hcd(ohci)); 468 status = ohci_hub_suspend(ohci_to_hcd(ohci));
478 if (status == 0) { 469 if (status == 0) {
479 if (state >= 4) { 470 omap_ohci_clock_power(0);
480 omap_ohci_clock_power(0); 471 ohci_to_hcd(ohci)->self.root_hub->state =
481 ohci_to_hcd(ohci)->self.root_hub->state = 472 USB_STATE_SUSPENDED;
482 USB_STATE_SUSPENDED;
483 state = 4;
484 }
485 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; 473 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
486 dev->power.power_state = state; 474 dev->power.power_state = PMSG_SUSPEND;
487 } 475 }
488 up(&ohci_to_hcd(ohci)->self.root_hub->serialize); 476 up(&ohci_to_hcd(ohci)->self.root_hub->serialize);
489 return status; 477 return status;
@@ -497,29 +485,20 @@ static int ohci_omap_resume(struct device *dev, u32 level)
497 if (level != RESUME_POWER_ON) 485 if (level != RESUME_POWER_ON)
498 return 0; 486 return 0;
499 487
500 switch (dev->power.power_state) { 488 if (time_before(jiffies, ohci->next_statechange))
501 case 0: 489 msleep(5);
502 break; 490 ohci->next_statechange = jiffies;
503 case 4: 491 omap_ohci_clock_power(1);
504 if (time_before(jiffies, ohci->next_statechange))
505 msleep(5);
506 ohci->next_statechange = jiffies;
507 omap_ohci_clock_power(1);
508 /* FALLTHROUGH */
509 default:
510 dev_dbg(dev, "resume from %d\n", dev->power.power_state);
511#ifdef CONFIG_USB_SUSPEND 492#ifdef CONFIG_USB_SUSPEND
512 /* get extra cleanup even if remote wakeup isn't in use */ 493 /* get extra cleanup even if remote wakeup isn't in use */
513 status = usb_resume_device(ohci_to_hcd(ohci)->self.root_hub); 494 status = usb_resume_device(ohci_to_hcd(ohci)->self.root_hub);
514#else 495#else
515 down(&ohci_to_hcd(ohci)->self.root_hub->serialize); 496 down(&ohci_to_hcd(ohci)->self.root_hub->serialize);
516 status = ohci_hub_resume(ohci_to_hcd(ohci)); 497 status = ohci_hub_resume(ohci_to_hcd(ohci));
517 up(&ohci_to_hcd(ohci)->self.root_hub->serialize); 498 up(&ohci_to_hcd(ohci)->self.root_hub->serialize);
518#endif 499#endif
519 if (status == 0) 500 if (status == 0)
520 dev->power.power_state = 0; 501 dev->power.power_state = PMSG_ON;
521 break;
522 }
523 return status; 502 return status;
524} 503}
525 504
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 6c3f910bc307..7a890a65f55d 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -815,7 +815,7 @@ static int sl811h_urb_enqueue(
815 struct usb_hcd *hcd, 815 struct usb_hcd *hcd,
816 struct usb_host_endpoint *hep, 816 struct usb_host_endpoint *hep,
817 struct urb *urb, 817 struct urb *urb,
818 int mem_flags 818 unsigned mem_flags
819) { 819) {
820 struct sl811 *sl811 = hcd_to_sl811(hcd); 820 struct sl811 *sl811 = hcd_to_sl811(hcd);
821 struct usb_device *udev = urb->dev; 821 struct usb_device *udev = urb->dev;
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 269d8ef01459..38aebe361ca1 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -20,7 +20,6 @@
20#include <linux/timer.h> 20#include <linux/timer.h>
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22 22
23#include <pcmcia/version.h>
24#include <pcmcia/cs_types.h> 23#include <pcmcia/cs_types.h>
25#include <pcmcia/cs.h> 24#include <pcmcia/cs.h>
26#include <pcmcia/cistpl.h> 25#include <pcmcia/cistpl.h>
@@ -389,11 +388,6 @@ static dev_link_t *sl811_cs_attach(void)
389 dev_list = link; 388 dev_list = link;
390 client_reg.dev_info = (dev_info_t *) &driver_name; 389 client_reg.dev_info = (dev_info_t *) &driver_name;
391 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; 390 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
392 client_reg.EventMask =
393 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
394 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
395 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
396 client_reg.event_handler = &sl811_cs_event;
397 client_reg.Version = 0x0210; 391 client_reg.Version = 0x0210;
398 client_reg.event_callback_args.client_data = link; 392 client_reg.event_callback_args.client_data = link;
399 ret = pcmcia_register_client(&link->handle, &client_reg); 393 ret = pcmcia_register_client(&link->handle, &client_reg);
@@ -418,6 +412,7 @@ static struct pcmcia_driver sl811_cs_driver = {
418 .name = (char *)driver_name, 412 .name = (char *)driver_name,
419 }, 413 },
420 .attach = sl811_cs_attach, 414 .attach = sl811_cs_attach,
415 .event = sl811_cs_event,
421 .detach = sl811_cs_detach, 416 .detach = sl811_cs_detach,
422 .id_table = sl811_ids, 417 .id_table = sl811_ids,
423}; 418};
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 5f18084a116d..bbb36cd6ed61 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -1164,7 +1164,7 @@ static struct urb *uhci_find_urb_ep(struct uhci_hcd *uhci, struct urb *urb)
1164 1164
1165static int uhci_urb_enqueue(struct usb_hcd *hcd, 1165static int uhci_urb_enqueue(struct usb_hcd *hcd,
1166 struct usb_host_endpoint *ep, 1166 struct usb_host_endpoint *ep,
1167 struct urb *urb, int mem_flags) 1167 struct urb *urb, unsigned mem_flags)
1168{ 1168{
1169 int ret; 1169 int ret;
1170 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 1170 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index fd59f6bdd67f..298e4a25e3d3 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -259,3 +259,16 @@ config USB_ATI_REMOTE
259 To compile this driver as a module, choose M here: the module will be 259 To compile this driver as a module, choose M here: the module will be
260 called ati_remote. 260 called ati_remote.
261 261
262config USB_KEYSPAN_REMOTE
263 tristate "Keyspan DMR USB remote control (EXPERIMENTAL)"
264 depends on USB && INPUT && EXPERIMENTAL
265 ---help---
266 Say Y here if you want to use a Keyspan DMR USB remote control.
267 Currently only the UIA-11 type of receiver has been tested. The tag
268 on the receiver that connects to the USB port should have a P/N that
269 will tell you what type of DMR you have. The UIA-10 type is not
270 supported at this time. This driver maps all buttons to keypress
271 events.
272
273 To compile this driver as a module, choose M here: the module will
274 be called keyspan_remote.
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index 831b2b0f1f05..f1547be632d4 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_USB_ATI_REMOTE) += ati_remote.o
31obj-$(CONFIG_USB_HID) += usbhid.o 31obj-$(CONFIG_USB_HID) += usbhid.o
32obj-$(CONFIG_USB_KBD) += usbkbd.o 32obj-$(CONFIG_USB_KBD) += usbkbd.o
33obj-$(CONFIG_USB_KBTAB) += kbtab.o 33obj-$(CONFIG_USB_KBTAB) += kbtab.o
34obj-$(CONFIG_USB_KEYSPAN_REMOTE) += keyspan_remote.o
34obj-$(CONFIG_USB_MOUSE) += usbmouse.o 35obj-$(CONFIG_USB_MOUSE) += usbmouse.o
35obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o 36obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o
36obj-$(CONFIG_USB_ITMTOUCH) += itmtouch.o 37obj-$(CONFIG_USB_ITMTOUCH) += itmtouch.o
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 100b49bd1d3e..2350e7a5ad70 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1428,6 +1428,19 @@ void hid_init_reports(struct hid_device *hid)
1428#define USB_DEVICE_ID_VERNIER_SKIP 0x0003 1428#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
1429#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 1429#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
1430 1430
1431#define USB_VENDOR_ID_LD 0x0f11
1432#define USB_DEVICE_ID_CASSY 0x1000
1433#define USB_DEVICE_ID_POCKETCASSY 0x1010
1434#define USB_DEVICE_ID_MOBILECASSY 0x1020
1435#define USB_DEVICE_ID_JWM 0x1080
1436#define USB_DEVICE_ID_DMMP 0x1081
1437#define USB_DEVICE_ID_UMIP 0x1090
1438#define USB_DEVICE_ID_VIDEOCOM 0x1200
1439#define USB_DEVICE_ID_COM3LAB 0x2000
1440#define USB_DEVICE_ID_TELEPORT 0x2010
1441#define USB_DEVICE_ID_NETWORKANALYSER 0x2020
1442#define USB_DEVICE_ID_POWERCONTROL 0x2030
1443
1431 1444
1432/* 1445/*
1433 * Alphabetically sorted blacklist by quirk type. 1446 * Alphabetically sorted blacklist by quirk type.
@@ -1463,6 +1476,17 @@ static struct hid_blacklist {
1463 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE, HID_QUIRK_IGNORE }, 1476 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE, HID_QUIRK_IGNORE },
1464 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB, HID_QUIRK_IGNORE }, 1477 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB, HID_QUIRK_IGNORE },
1465 { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE }, 1478 { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE },
1479 { USB_VENDOR_ID_LD, USB_DEVICE_ID_CASSY, HID_QUIRK_IGNORE },
1480 { USB_VENDOR_ID_LD, USB_DEVICE_ID_POCKETCASSY, HID_QUIRK_IGNORE },
1481 { USB_VENDOR_ID_LD, USB_DEVICE_ID_MOBILECASSY, HID_QUIRK_IGNORE },
1482 { USB_VENDOR_ID_LD, USB_DEVICE_ID_JWM, HID_QUIRK_IGNORE },
1483 { USB_VENDOR_ID_LD, USB_DEVICE_ID_DMMP, HID_QUIRK_IGNORE },
1484 { USB_VENDOR_ID_LD, USB_DEVICE_ID_UMIP, HID_QUIRK_IGNORE },
1485 { USB_VENDOR_ID_LD, USB_DEVICE_ID_VIDEOCOM, HID_QUIRK_IGNORE },
1486 { USB_VENDOR_ID_LD, USB_DEVICE_ID_COM3LAB, HID_QUIRK_IGNORE },
1487 { USB_VENDOR_ID_LD, USB_DEVICE_ID_TELEPORT, HID_QUIRK_IGNORE },
1488 { USB_VENDOR_ID_LD, USB_DEVICE_ID_NETWORKANALYSER, HID_QUIRK_IGNORE },
1489 { USB_VENDOR_ID_LD, USB_DEVICE_ID_POWERCONTROL, HID_QUIRK_IGNORE },
1466 { USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS, HID_QUIRK_IGNORE }, 1490 { USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS, HID_QUIRK_IGNORE },
1467 { USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS, HID_QUIRK_IGNORE }, 1491 { USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS, HID_QUIRK_IGNORE },
1468 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_IGNORE }, 1492 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_IGNORE },
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
new file mode 100644
index 000000000000..67dc93685203
--- /dev/null
+++ b/drivers/usb/input/keyspan_remote.c
@@ -0,0 +1,633 @@
1/*
2 * keyspan_remote: USB driver for the Keyspan DMR
3 *
4 * Copyright (C) 2005 Zymeta Corporation - Michael Downey (downey@zymeta.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
9 *
10 * This driver has been put together with the support of Innosys, Inc.
11 * and Keyspan, Inc the manufacturers of the Keyspan USB DMR product.
12 */
13
14#include <linux/config.h>
15#include <linux/kernel.h>
16#include <linux/errno.h>
17#include <linux/init.h>
18#include <linux/slab.h>
19#include <linux/module.h>
20#include <linux/moduleparam.h>
21#include <linux/input.h>
22#include <linux/usb.h>
23
24#define DRIVER_VERSION "v0.1"
25#define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>"
26#define DRIVER_DESC "Driver for the USB Keyspan remote control."
27#define DRIVER_LICENSE "GPL"
28
29/* Parameters that can be passed to the driver. */
30static int debug;
31module_param(debug, int, 0444);
32MODULE_PARM_DESC(debug, "Enable extra debug messages and information");
33
34/* Vendor and product ids */
35#define USB_KEYSPAN_VENDOR_ID 0x06CD
36#define USB_KEYSPAN_PRODUCT_UIA11 0x0202
37
38/* Defines for converting the data from the remote. */
39#define ZERO 0x18
40#define ZERO_MASK 0x1F /* 5 bits for a 0 */
41#define ONE 0x3C
42#define ONE_MASK 0x3F /* 6 bits for a 1 */
43#define SYNC 0x3F80
44#define SYNC_MASK 0x3FFF /* 14 bits for a SYNC sequence */
45#define STOP 0x00
46#define STOP_MASK 0x1F /* 5 bits for the STOP sequence */
47#define GAP 0xFF
48
49#define RECV_SIZE 8 /* The UIA-11 type have a 8 byte limit. */
50
51/* table of devices that work with this driver */
52static struct usb_device_id keyspan_table[] = {
53 { USB_DEVICE(USB_KEYSPAN_VENDOR_ID, USB_KEYSPAN_PRODUCT_UIA11) },
54 { } /* Terminating entry */
55};
56
57/* Structure to store all the real stuff that a remote sends to us. */
58struct keyspan_message {
59 u16 system;
60 u8 button;
61 u8 toggle;
62};
63
64/* Structure used for all the bit testing magic needed to be done. */
65struct bit_tester {
66 u32 tester;
67 int len;
68 int pos;
69 int bits_left;
70 u8 buffer[32];
71};
72
73/* Structure to hold all of our driver specific stuff */
74struct usb_keyspan {
75 char name[128];
76 char phys[64];
77 struct usb_device* udev;
78 struct input_dev input;
79 struct usb_interface* interface;
80 struct usb_endpoint_descriptor* in_endpoint;
81 struct urb* irq_urb;
82 int open;
83 dma_addr_t in_dma;
84 unsigned char* in_buffer;
85
86 /* variables used to parse messages from remote. */
87 struct bit_tester data;
88 int stage;
89 int toggle;
90};
91
92/*
93 * Table that maps the 31 possible keycodes to input keys.
94 * Currently there are 15 and 17 button models so RESERVED codes
95 * are blank areas in the mapping.
96 */
97static int keyspan_key_table[] = {
98 KEY_RESERVED, /* 0 is just a place holder. */
99 KEY_RESERVED,
100 KEY_STOP,
101 KEY_PLAYCD,
102 KEY_RESERVED,
103 KEY_PREVIOUSSONG,
104 KEY_REWIND,
105 KEY_FORWARD,
106 KEY_NEXTSONG,
107 KEY_RESERVED,
108 KEY_RESERVED,
109 KEY_RESERVED,
110 KEY_PAUSE,
111 KEY_VOLUMEUP,
112 KEY_RESERVED,
113 KEY_RESERVED,
114 KEY_RESERVED,
115 KEY_VOLUMEDOWN,
116 KEY_RESERVED,
117 KEY_UP,
118 KEY_RESERVED,
119 KEY_MUTE,
120 KEY_LEFT,
121 KEY_ENTER,
122 KEY_RIGHT,
123 KEY_RESERVED,
124 KEY_RESERVED,
125 KEY_DOWN,
126 KEY_RESERVED,
127 KEY_KPASTERISK,
128 KEY_RESERVED,
129 KEY_MENU
130};
131
132static struct usb_driver keyspan_driver;
133
134/*
135 * Debug routine that prints out what we've received from the remote.
136 */
137static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/
138{
139 char codes[4*RECV_SIZE];
140 int i;
141
142 for (i = 0; i < RECV_SIZE; i++) {
143 snprintf(codes+i*3, 4, "%02x ", dev->in_buffer[i]);
144 }
145
146 dev_info(&dev->udev->dev, "%s\n", codes);
147}
148
149/*
150 * Routine that manages the bit_tester structure. It makes sure that there are
151 * at least bits_needed bits loaded into the tester.
152 */
153static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed)
154{
155 if (dev->data.bits_left >= bits_needed)
156 return(0);
157
158 /*
159 * Somehow we've missed the last message. The message will be repeated
160 * though so it's not too big a deal
161 */
162 if (dev->data.pos >= dev->data.len) {
163 dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n",
164 __FUNCTION__, dev->data.pos, dev->data.len);
165 return(-1);
166 }
167
168 /* Load as much as we can into the tester. */
169 while ((dev->data.bits_left + 7 < (sizeof(dev->data.tester) * 8)) &&
170 (dev->data.pos < dev->data.len)) {
171 dev->data.tester += (dev->data.buffer[dev->data.pos++] << dev->data.bits_left);
172 dev->data.bits_left += 8;
173 }
174
175 return(0);
176}
177
178/*
179 * Routine that handles all the logic needed to parse out the message from the remote.
180 */
181static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs)
182{
183 int i;
184 int found = 0;
185 struct keyspan_message message;
186
187 switch(remote->stage) {
188 case 0:
189 /*
190 * In stage 0 we want to find the start of a message. The remote sends a 0xFF as filler.
191 * So the first byte that isn't a FF should be the start of a new message.
192 */
193 for (i = 0; i < RECV_SIZE && remote->in_buffer[i] == GAP; ++i);
194
195 if (i < RECV_SIZE) {
196 memcpy(remote->data.buffer, remote->in_buffer, RECV_SIZE);
197 remote->data.len = RECV_SIZE;
198 remote->data.pos = 0;
199 remote->data.tester = 0;
200 remote->data.bits_left = 0;
201 remote->stage = 1;
202 }
203 break;
204
205 case 1:
206 /*
207 * Stage 1 we should have 16 bytes and should be able to detect a
208 * SYNC. The SYNC is 14 bits, 7 0's and then 7 1's.
209 */
210 memcpy(remote->data.buffer + remote->data.len, remote->in_buffer, RECV_SIZE);
211 remote->data.len += RECV_SIZE;
212
213 found = 0;
214 while ((remote->data.bits_left >= 14 || remote->data.pos < remote->data.len) && !found) {
215 for (i = 0; i < 8; ++i) {
216 if (keyspan_load_tester(remote, 14) != 0) {
217 remote->stage = 0;
218 return;
219 }
220
221 if ((remote->data.tester & SYNC_MASK) == SYNC) {
222 remote->data.tester = remote->data.tester >> 14;
223 remote->data.bits_left -= 14;
224 found = 1;
225 break;
226 } else {
227 remote->data.tester = remote->data.tester >> 1;
228 --remote->data.bits_left;
229 }
230 }
231 }
232
233 if (!found) {
234 remote->stage = 0;
235 remote->data.len = 0;
236 } else {
237 remote->stage = 2;
238 }
239 break;
240
241 case 2:
242 /*
243 * Stage 2 we should have 24 bytes which will be enough for a full
244 * message. We need to parse out the system code, button code,
245 * toggle code, and stop.
246 */
247 memcpy(remote->data.buffer + remote->data.len, remote->in_buffer, RECV_SIZE);
248 remote->data.len += RECV_SIZE;
249
250 message.system = 0;
251 for (i = 0; i < 9; i++) {
252 keyspan_load_tester(remote, 6);
253
254 if ((remote->data.tester & ZERO_MASK) == ZERO) {
255 message.system = message.system << 1;
256 remote->data.tester = remote->data.tester >> 5;
257 remote->data.bits_left -= 5;
258 } else if ((remote->data.tester & ONE_MASK) == ONE) {
259 message.system = (message.system << 1) + 1;
260 remote->data.tester = remote->data.tester >> 6;
261 remote->data.bits_left -= 6;
262 } else {
263 err("%s - Unknown sequence found in system data.\n", __FUNCTION__);
264 remote->stage = 0;
265 return;
266 }
267 }
268
269 message.button = 0;
270 for (i = 0; i < 5; i++) {
271 keyspan_load_tester(remote, 6);
272
273 if ((remote->data.tester & ZERO_MASK) == ZERO) {
274 message.button = message.button << 1;
275 remote->data.tester = remote->data.tester >> 5;
276 remote->data.bits_left -= 5;
277 } else if ((remote->data.tester & ONE_MASK) == ONE) {
278 message.button = (message.button << 1) + 1;
279 remote->data.tester = remote->data.tester >> 6;
280 remote->data.bits_left -= 6;
281 } else {
282 err("%s - Unknown sequence found in button data.\n", __FUNCTION__);
283 remote->stage = 0;
284 return;
285 }
286 }
287
288 keyspan_load_tester(remote, 6);
289 if ((remote->data.tester & ZERO_MASK) == ZERO) {
290 message.toggle = 0;
291 remote->data.tester = remote->data.tester >> 5;
292 remote->data.bits_left -= 5;
293 } else if ((remote->data.tester & ONE_MASK) == ONE) {
294 message.toggle = 1;
295 remote->data.tester = remote->data.tester >> 6;
296 remote->data.bits_left -= 6;
297 } else {
298 err("%s - Error in message, invalid toggle.\n", __FUNCTION__);
299 }
300
301 keyspan_load_tester(remote, 5);
302 if ((remote->data.tester & STOP_MASK) == STOP) {
303 remote->data.tester = remote->data.tester >> 5;
304 remote->data.bits_left -= 5;
305 } else {
306 err("Bad message recieved, no stop bit found.\n");
307 }
308
309 dev_dbg(&remote->udev,
310 "%s found valid message: system: %d, button: %d, toggle: %d\n",
311 __FUNCTION__, message.system, message.button, message.toggle);
312
313 if (message.toggle != remote->toggle) {
314 input_regs(&remote->input, regs);
315 input_report_key(&remote->input, keyspan_key_table[message.button], 1);
316 input_report_key(&remote->input, keyspan_key_table[message.button], 0);
317 input_sync(&remote->input);
318 remote->toggle = message.toggle;
319 }
320
321 remote->stage = 0;
322 break;
323 }
324}
325
326/*
327 * Routine for sending all the initialization messages to the remote.
328 */
329static int keyspan_setup(struct usb_device* dev)
330{
331 int retval = 0;
332
333 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
334 0x11, 0x40, 0x5601, 0x0, NULL, 0, 0);
335 if (retval) {
336 dev_dbg(&dev->dev, "%s - failed to set bit rate due to error: %d\n",
337 __FUNCTION__, retval);
338 return(retval);
339 }
340
341 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
342 0x44, 0x40, 0x0, 0x0, NULL, 0, 0);
343 if (retval) {
344 dev_dbg(&dev->dev, "%s - failed to set resume sensitivity due to error: %d\n",
345 __FUNCTION__, retval);
346 return(retval);
347 }
348
349 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
350 0x22, 0x40, 0x0, 0x0, NULL, 0, 0);
351 if (retval) {
352 dev_dbg(&dev->dev, "%s - failed to turn receive on due to error: %d\n",
353 __FUNCTION__, retval);
354 return(retval);
355 }
356
357 dev_dbg(&dev->dev, "%s - Setup complete.\n", __FUNCTION__);
358 return(retval);
359}
360
361/*
362 * Routine used to handle a new message that has come in.
363 */
364static void keyspan_irq_recv(struct urb *urb, struct pt_regs *regs)
365{
366 struct usb_keyspan *dev = urb->context;
367 int retval;
368
369 /* Check our status in case we need to bail out early. */
370 switch (urb->status) {
371 case 0:
372 break;
373
374 /* Device went away so don't keep trying to read from it. */
375 case -ECONNRESET:
376 case -ENOENT:
377 case -ESHUTDOWN:
378 return;
379
380 default:
381 goto resubmit;
382 break;
383 }
384
385 if (debug)
386 keyspan_print(dev);
387
388 keyspan_check_data(dev, regs);
389
390resubmit:
391 retval = usb_submit_urb(urb, GFP_ATOMIC);
392 if (retval)
393 err ("%s - usb_submit_urb failed with result: %d", __FUNCTION__, retval);
394}
395
396static int keyspan_open(struct input_dev *dev)
397{
398 struct usb_keyspan *remote = dev->private;
399
400 if (remote->open++)
401 return 0;
402
403 remote->irq_urb->dev = remote->udev;
404 if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) {
405 remote->open--;
406 return -EIO;
407 }
408
409 return 0;
410}
411
412static void keyspan_close(struct input_dev *dev)
413{
414 struct usb_keyspan *remote = dev->private;
415
416 if (!--remote->open)
417 usb_kill_urb(remote->irq_urb);
418}
419
420/*
421 * Routine that sets up the driver to handle a specific USB device detected on the bus.
422 */
423static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id)
424{
425 int i;
426 int retval = -ENOMEM;
427 char path[64];
428 char *buf;
429 struct usb_keyspan *remote = NULL;
430 struct usb_host_interface *iface_desc;
431 struct usb_endpoint_descriptor *endpoint;
432 struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface));
433
434 /* See if the offered device matches what we can accept */
435 if ((udev->descriptor.idVendor != USB_KEYSPAN_VENDOR_ID) ||
436 (udev->descriptor.idProduct != USB_KEYSPAN_PRODUCT_UIA11) )
437 return -ENODEV;
438
439 /* allocate memory for our device state and initialize it */
440 remote = kmalloc(sizeof(*remote), GFP_KERNEL);
441 if (remote == NULL) {
442 err("Out of memory\n");
443 goto error;
444 }
445 memset(remote, 0x00, sizeof(*remote));
446
447 remote->udev = udev;
448 remote->interface = interface;
449 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */
450
451 /* set up the endpoint information */
452 /* use only the first in interrupt endpoint */
453 iface_desc = interface->cur_altsetting;
454 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
455 endpoint = &iface_desc->endpoint[i].desc;
456
457 if (!remote->in_endpoint &&
458 (endpoint->bEndpointAddress & USB_DIR_IN) &&
459 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
460 /* we found our interrupt in endpoint */
461 remote->in_endpoint = endpoint;
462
463 remote->in_buffer = usb_buffer_alloc(remote->udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma);
464 if (!remote->in_buffer) {
465 retval = -ENOMEM;
466 goto error;
467 }
468 }
469 }
470
471 if (!remote->in_endpoint) {
472 err("Could not find interrupt input endpoint.\n");
473 retval = -ENODEV;
474 goto error;
475 }
476
477 remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
478 if (!remote->irq_urb) {
479 err("Failed to allocate urb.\n");
480 retval = -ENOMEM;
481 goto error;
482 }
483
484 retval = keyspan_setup(remote->udev);
485 if (retval) {
486 err("Failed to setup device.\n");
487 retval = -ENODEV;
488 goto error;
489 }
490
491 /*
492 * Setup the input system with the bits we are going to be reporting
493 */
494 remote->input.evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */
495 for (i = 0; i < 32; ++i) {
496 if (keyspan_key_table[i] != KEY_RESERVED) {
497 set_bit(keyspan_key_table[i], remote->input.keybit);
498 }
499 }
500
501 remote->input.private = remote;
502 remote->input.open = keyspan_open;
503 remote->input.close = keyspan_close;
504
505 usb_make_path(remote->udev, path, 64);
506 sprintf(remote->phys, "%s/input0", path);
507
508 remote->input.name = remote->name;
509 remote->input.phys = remote->phys;
510 remote->input.id.bustype = BUS_USB;
511 remote->input.id.vendor = le16_to_cpu(remote->udev->descriptor.idVendor);
512 remote->input.id.product = le16_to_cpu(remote->udev->descriptor.idProduct);
513 remote->input.id.version = le16_to_cpu(remote->udev->descriptor.bcdDevice);
514
515 if (!(buf = kmalloc(63, GFP_KERNEL))) {
516 usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma);
517 kfree(remote);
518 return -ENOMEM;
519 }
520
521 if (remote->udev->descriptor.iManufacturer &&
522 usb_string(remote->udev, remote->udev->descriptor.iManufacturer, buf, 63) > 0)
523 strcat(remote->name, buf);
524
525 if (remote->udev->descriptor.iProduct &&
526 usb_string(remote->udev, remote->udev->descriptor.iProduct, buf, 63) > 0)
527 sprintf(remote->name, "%s %s", remote->name, buf);
528
529 if (!strlen(remote->name))
530 sprintf(remote->name, "USB Keyspan Remote %04x:%04x",
531 remote->input.id.vendor, remote->input.id.product);
532
533 kfree(buf);
534
535 /*
536 * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open()
537 */
538 usb_fill_int_urb(remote->irq_urb,
539 remote->udev, usb_rcvintpipe(remote->udev, remote->in_endpoint->bEndpointAddress),
540 remote->in_buffer, RECV_SIZE, keyspan_irq_recv, remote,
541 remote->in_endpoint->bInterval);
542 remote->irq_urb->transfer_dma = remote->in_dma;
543 remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
544
545 /* we can register the device now, as it is ready */
546 input_register_device(&remote->input);
547
548 /* save our data pointer in this interface device */
549 usb_set_intfdata(interface, remote);
550
551 /* let the user know what node this device is now attached to */
552 info("connected: %s on %s", remote->name, path);
553 return 0;
554
555error:
556 /*
557 * In case of error we need to clean up any allocated buffers
558 */
559 if (remote->irq_urb)
560 usb_free_urb(remote->irq_urb);
561
562 if (remote->in_buffer)
563 usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma);
564
565 if (remote)
566 kfree(remote);
567
568 return retval;
569}
570
571/*
572 * Routine called when a device is disconnected from the USB.
573 */
574static void keyspan_disconnect(struct usb_interface *interface)
575{
576 struct usb_keyspan *remote;
577
578 /* prevent keyspan_open() from racing keyspan_disconnect() */
579 lock_kernel();
580
581 remote = usb_get_intfdata(interface);
582 usb_set_intfdata(interface, NULL);
583
584 if (remote) { /* We have a valid driver structure so clean up everything we allocated. */
585 input_unregister_device(&remote->input);
586 usb_kill_urb(remote->irq_urb);
587 usb_free_urb(remote->irq_urb);
588 usb_buffer_free(interface_to_usbdev(interface), RECV_SIZE, remote->in_buffer, remote->in_dma);
589 kfree(remote);
590 }
591
592 unlock_kernel();
593
594 info("USB Keyspan now disconnected");
595}
596
597/*
598 * Standard driver set up sections
599 */
600static struct usb_driver keyspan_driver =
601{
602 .owner = THIS_MODULE,
603 .name = "keyspan_remote",
604 .probe = keyspan_probe,
605 .disconnect = keyspan_disconnect,
606 .id_table = keyspan_table
607};
608
609static int __init usb_keyspan_init(void)
610{
611 int result;
612
613 /* register this driver with the USB subsystem */
614 result = usb_register(&keyspan_driver);
615 if (result)
616 err("usb_register failed. Error number %d\n", result);
617
618 return result;
619}
620
621static void __exit usb_keyspan_exit(void)
622{
623 /* deregister this driver with the USB subsystem */
624 usb_deregister(&keyspan_driver);
625}
626
627module_init(usb_keyspan_init);
628module_exit(usb_keyspan_exit);
629
630MODULE_DEVICE_TABLE(usb, keyspan_table);
631MODULE_AUTHOR(DRIVER_AUTHOR);
632MODULE_DESCRIPTION(DRIVER_DESC);
633MODULE_LICENSE(DRIVER_LICENSE);
diff --git a/drivers/usb/media/Makefile b/drivers/usb/media/Makefile
index 2b76df7005fe..d83adffa925f 100644
--- a/drivers/usb/media/Makefile
+++ b/drivers/usb/media/Makefile
@@ -2,7 +2,7 @@
2# Makefile for USB Media drivers 2# Makefile for USB Media drivers
3# 3#
4 4
5sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o sn9c102_pas106b.o sn9c102_pas202bcb.o sn9c102_tas5110c1b.o sn9c102_tas5130d1b.o 5sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bcb.o sn9c102_tas5110c1b.o sn9c102_tas5130d1b.o
6 6
7obj-$(CONFIG_USB_DABUSB) += dabusb.o 7obj-$(CONFIG_USB_DABUSB) += dabusb.o
8obj-$(CONFIG_USB_DSBR) += dsbr100.o 8obj-$(CONFIG_USB_DSBR) += dsbr100.o
diff --git a/drivers/usb/media/sn9c102.h b/drivers/usb/media/sn9c102.h
index 8b8a4c8743f8..e5cea0e2eb57 100644
--- a/drivers/usb/media/sn9c102.h
+++ b/drivers/usb/media/sn9c102.h
@@ -56,7 +56,7 @@
56#define SN9C102_MODULE_AUTHOR "(C) 2004-2005 Luca Risolia" 56#define SN9C102_MODULE_AUTHOR "(C) 2004-2005 Luca Risolia"
57#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 57#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
58#define SN9C102_MODULE_LICENSE "GPL" 58#define SN9C102_MODULE_LICENSE "GPL"
59#define SN9C102_MODULE_VERSION "1:1.24" 59#define SN9C102_MODULE_VERSION "1:1.24a"
60#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 24) 60#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 24)
61 61
62enum sn9c102_bridge { 62enum sn9c102_bridge {
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c
index 31d57400d5be..cf8cfbabefde 100644
--- a/drivers/usb/media/sn9c102_core.c
+++ b/drivers/usb/media/sn9c102_core.c
@@ -429,7 +429,7 @@ sn9c102_i2c_try_read(struct sn9c102_device* cam,
429} 429}
430 430
431 431
432static int 432int
433sn9c102_i2c_try_write(struct sn9c102_device* cam, 433sn9c102_i2c_try_write(struct sn9c102_device* cam,
434 struct sn9c102_sensor* sensor, u8 address, u8 value) 434 struct sn9c102_sensor* sensor, u8 address, u8 value)
435{ 435{
diff --git a/drivers/usb/media/sn9c102_ov7630.c b/drivers/usb/media/sn9c102_ov7630.c
new file mode 100644
index 000000000000..d27c5aedeaf8
--- /dev/null
+++ b/drivers/usb/media/sn9c102_ov7630.c
@@ -0,0 +1,394 @@
1/***************************************************************************
2 * Plug-in for OV7630 image sensor connected to the SN9C10x PC Camera *
3 * Controllers *
4 * *
5 * Copyright (C) 2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
20 ***************************************************************************/
21
22#include "sn9c102_sensor.h"
23
24
25static struct sn9c102_sensor ov7630;
26
27
28static int ov7630_init(struct sn9c102_device* cam)
29{
30 int err = 0;
31
32 err += sn9c102_write_reg(cam, 0x00, 0x14);
33 err += sn9c102_write_reg(cam, 0x60, 0x17);
34 err += sn9c102_write_reg(cam, 0x0f, 0x18);
35 err += sn9c102_write_reg(cam, 0x50, 0x19);
36
37 err += sn9c102_i2c_write(cam, 0x12, 0x8d);
38 err += sn9c102_i2c_write(cam, 0x11, 0x00);
39 err += sn9c102_i2c_write(cam, 0x15, 0x34);
40 err += sn9c102_i2c_write(cam, 0x16, 0x03);
41 err += sn9c102_i2c_write(cam, 0x17, 0x1c);
42 err += sn9c102_i2c_write(cam, 0x18, 0xbd);
43 err += sn9c102_i2c_write(cam, 0x19, 0x06);
44 err += sn9c102_i2c_write(cam, 0x1a, 0xf6);
45 err += sn9c102_i2c_write(cam, 0x1b, 0x04);
46 err += sn9c102_i2c_write(cam, 0x20, 0x44);
47 err += sn9c102_i2c_write(cam, 0x23, 0xee);
48 err += sn9c102_i2c_write(cam, 0x26, 0xa0);
49 err += sn9c102_i2c_write(cam, 0x27, 0x9a);
50 err += sn9c102_i2c_write(cam, 0x28, 0x20);
51 err += sn9c102_i2c_write(cam, 0x29, 0x30);
52 err += sn9c102_i2c_write(cam, 0x2f, 0x3d);
53 err += sn9c102_i2c_write(cam, 0x30, 0x24);
54 err += sn9c102_i2c_write(cam, 0x32, 0x86);
55 err += sn9c102_i2c_write(cam, 0x60, 0xa9);
56 err += sn9c102_i2c_write(cam, 0x61, 0x42);
57 err += sn9c102_i2c_write(cam, 0x65, 0x00);
58 err += sn9c102_i2c_write(cam, 0x69, 0x38);
59 err += sn9c102_i2c_write(cam, 0x6f, 0x88);
60 err += sn9c102_i2c_write(cam, 0x70, 0x0b);
61 err += sn9c102_i2c_write(cam, 0x71, 0x00);
62 err += sn9c102_i2c_write(cam, 0x74, 0x21);
63 err += sn9c102_i2c_write(cam, 0x7d, 0xf7);
64
65 return err;
66}
67
68
69static int ov7630_set_ctrl(struct sn9c102_device* cam,
70 const struct v4l2_control* ctrl)
71{
72 int err = 0;
73
74 switch (ctrl->id) {
75 case V4L2_CID_EXPOSURE:
76 err += sn9c102_i2c_write(cam, 0x10, ctrl->value >> 2);
77 err += sn9c102_i2c_write(cam, 0x76, ctrl->value & 0x03);
78 break;
79 case V4L2_CID_RED_BALANCE:
80 err += sn9c102_i2c_write(cam, 0x02, ctrl->value);
81 break;
82 case V4L2_CID_BLUE_BALANCE:
83 err += sn9c102_i2c_write(cam, 0x03, ctrl->value);
84 break;
85 case V4L2_CID_GAIN:
86 err += sn9c102_i2c_write(cam, 0x00, ctrl->value);
87 break;
88 case V4L2_CID_CONTRAST:
89 err += ctrl->value ? sn9c102_i2c_write(cam, 0x05,
90 (ctrl->value-1) | 0x20)
91 : sn9c102_i2c_write(cam, 0x05, 0x00);
92 break;
93 case V4L2_CID_BRIGHTNESS:
94 err += sn9c102_i2c_write(cam, 0x06, ctrl->value);
95 break;
96 case V4L2_CID_SATURATION:
97 err += sn9c102_i2c_write(cam, 0x03, ctrl->value << 4);
98 break;
99 case V4L2_CID_HUE:
100 err += ctrl->value ? sn9c102_i2c_write(cam, 0x04,
101 (ctrl->value-1) | 0x20)
102 : sn9c102_i2c_write(cam, 0x04, 0x00);
103 break;
104 case V4L2_CID_DO_WHITE_BALANCE:
105 err += sn9c102_i2c_write(cam, 0x0c, ctrl->value);
106 break;
107 case V4L2_CID_WHITENESS:
108 err += sn9c102_i2c_write(cam, 0x0d, ctrl->value);
109 break;
110 case V4L2_CID_AUTO_WHITE_BALANCE:
111 err += sn9c102_i2c_write(cam, 0x12, (ctrl->value << 2) | 0x09);
112 break;
113 case V4L2_CID_AUTOGAIN:
114 err += sn9c102_i2c_write(cam, 0x13, ctrl->value);
115 break;
116 case V4L2_CID_VFLIP:
117 err += sn9c102_i2c_write(cam, 0x75, 0x0e | (ctrl->value << 7));
118 break;
119 case V4L2_CID_BLACK_LEVEL:
120 err += sn9c102_i2c_write(cam, 0x25, ctrl->value);
121 break;
122 case SN9C102_V4L2_CID_BRIGHT_LEVEL:
123 err += sn9c102_i2c_write(cam, 0x24, ctrl->value);
124 break;
125 case SN9C102_V4L2_CID_GAMMA:
126 err += sn9c102_i2c_write(cam, 0x14, (ctrl->value << 2) | 0x80);
127 break;
128 case SN9C102_V4L2_CID_BAND_FILTER:
129 err += sn9c102_i2c_write(cam, 0x2d, ctrl->value << 2);
130 break;
131 default:
132 return -EINVAL;
133 }
134
135 return err ? -EIO : 0;
136}
137
138
139static int ov7630_set_crop(struct sn9c102_device* cam,
140 const struct v4l2_rect* rect)
141{
142 struct sn9c102_sensor* s = &ov7630;
143 int err = 0;
144 u8 v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1;
145
146 err += sn9c102_write_reg(cam, v_start, 0x13);
147
148 return err;
149}
150
151
152static int ov7630_set_pix_format(struct sn9c102_device* cam,
153 const struct v4l2_pix_format* pix)
154{
155 int err = 0;
156
157 if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X)
158 err += sn9c102_write_reg(cam, 0x20, 0x19);
159 else
160 err += sn9c102_write_reg(cam, 0x50, 0x19);
161
162 return err;
163}
164
165
166static struct sn9c102_sensor ov7630 = {
167 .name = "OV7630",
168 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
169 .sysfs_ops = SN9C102_I2C_WRITE,
170 .frequency = SN9C102_I2C_100KHZ,
171 .interface = SN9C102_I2C_2WIRES,
172 .i2c_slave_id = 0x21,
173 .init = &ov7630_init,
174 .qctrl = {
175 {
176 .id = V4L2_CID_GAIN,
177 .type = V4L2_CTRL_TYPE_INTEGER,
178 .name = "global gain",
179 .minimum = 0x00,
180 .maximum = 0x3f,
181 .step = 0x01,
182 .default_value = 0x14,
183 .flags = 0,
184 },
185 {
186 .id = V4L2_CID_HUE,
187 .type = V4L2_CTRL_TYPE_INTEGER,
188 .name = "hue",
189 .minimum = 0x00,
190 .maximum = 0x1f+1,
191 .step = 0x01,
192 .default_value = 0x00,
193 .flags = 0,
194 },
195 {
196 .id = V4L2_CID_SATURATION,
197 .type = V4L2_CTRL_TYPE_INTEGER,
198 .name = "saturation",
199 .minimum = 0x00,
200 .maximum = 0x0f,
201 .step = 0x01,
202 .default_value = 0x08,
203 .flags = 0,
204 },
205 {
206 .id = V4L2_CID_CONTRAST,
207 .type = V4L2_CTRL_TYPE_INTEGER,
208 .name = "contrast",
209 .minimum = 0x00,
210 .maximum = 0x1f+1,
211 .step = 0x01,
212 .default_value = 0x00,
213 .flags = 0,
214 },
215 {
216 .id = V4L2_CID_EXPOSURE,
217 .type = V4L2_CTRL_TYPE_INTEGER,
218 .name = "exposure",
219 .minimum = 0x000,
220 .maximum = 0x3ff,
221 .step = 0x001,
222 .default_value = 0x83<<2,
223 .flags = 0,
224 },
225 {
226 .id = V4L2_CID_RED_BALANCE,
227 .type = V4L2_CTRL_TYPE_INTEGER,
228 .name = "red balance",
229 .minimum = 0x00,
230 .maximum = 0xff,
231 .step = 0x01,
232 .default_value = 0x3a,
233 .flags = 0,
234 },
235 {
236 .id = V4L2_CID_BLUE_BALANCE,
237 .type = V4L2_CTRL_TYPE_INTEGER,
238 .name = "blue balance",
239 .minimum = 0x00,
240 .maximum = 0xff,
241 .step = 0x01,
242 .default_value = 0x77,
243 .flags = 0,
244 },
245 {
246 .id = V4L2_CID_BRIGHTNESS,
247 .type = V4L2_CTRL_TYPE_INTEGER,
248 .name = "brightness",
249 .minimum = 0x00,
250 .maximum = 0xff,
251 .step = 0x01,
252 .default_value = 0xa0,
253 .flags = 0,
254 },
255 {
256 .id = V4L2_CID_DO_WHITE_BALANCE,
257 .type = V4L2_CTRL_TYPE_INTEGER,
258 .name = "white balance background: blue",
259 .minimum = 0x00,
260 .maximum = 0x3f,
261 .step = 0x01,
262 .default_value = 0x20,
263 .flags = 0,
264 },
265 {
266 .id = V4L2_CID_WHITENESS,
267 .type = V4L2_CTRL_TYPE_INTEGER,
268 .name = "white balance background: red",
269 .minimum = 0x00,
270 .maximum = 0x3f,
271 .step = 0x01,
272 .default_value = 0x20,
273 .flags = 0,
274 },
275 {
276 .id = V4L2_CID_AUTO_WHITE_BALANCE,
277 .type = V4L2_CTRL_TYPE_BOOLEAN,
278 .name = "auto white balance",
279 .minimum = 0x00,
280 .maximum = 0x01,
281 .step = 0x01,
282 .default_value = 0x01,
283 .flags = 0,
284 },
285 {
286 .id = V4L2_CID_AUTOGAIN,
287 .type = V4L2_CTRL_TYPE_INTEGER,
288 .name = "gain & exposure mode",
289 .minimum = 0x00,
290 .maximum = 0x03,
291 .step = 0x01,
292 .default_value = 0x00,
293 .flags = 0,
294 },
295 {
296 .id = V4L2_CID_VFLIP,
297 .type = V4L2_CTRL_TYPE_BOOLEAN,
298 .name = "vertical flip",
299 .minimum = 0x00,
300 .maximum = 0x01,
301 .step = 0x01,
302 .default_value = 0x01,
303 .flags = 0,
304 },
305 {
306 .id = V4L2_CID_BLACK_LEVEL,
307 .type = V4L2_CTRL_TYPE_INTEGER,
308 .name = "black pixel ratio",
309 .minimum = 0x01,
310 .maximum = 0x9a,
311 .step = 0x01,
312 .default_value = 0x8a,
313 .flags = 0,
314 },
315 {
316 .id = SN9C102_V4L2_CID_BRIGHT_LEVEL,
317 .type = V4L2_CTRL_TYPE_INTEGER,
318 .name = "bright pixel ratio",
319 .minimum = 0x01,
320 .maximum = 0x9a,
321 .step = 0x01,
322 .default_value = 0x10,
323 .flags = 0,
324 },
325 {
326 .id = SN9C102_V4L2_CID_BAND_FILTER,
327 .type = V4L2_CTRL_TYPE_BOOLEAN,
328 .name = "band filter",
329 .minimum = 0x00,
330 .maximum = 0x01,
331 .step = 0x01,
332 .default_value = 0x00,
333 .flags = 0,
334 },
335 {
336 .id = SN9C102_V4L2_CID_GAMMA,
337 .type = V4L2_CTRL_TYPE_BOOLEAN,
338 .name = "rgb gamma",
339 .minimum = 0x00,
340 .maximum = 0x01,
341 .step = 0x01,
342 .default_value = 0x00,
343 .flags = 0,
344 },
345 },
346 .set_ctrl = &ov7630_set_ctrl,
347 .cropcap = {
348 .bounds = {
349 .left = 0,
350 .top = 0,
351 .width = 640,
352 .height = 480,
353 },
354 .defrect = {
355 .left = 0,
356 .top = 0,
357 .width = 640,
358 .height = 480,
359 },
360 },
361 .set_crop = &ov7630_set_crop,
362 .pix_format = {
363 .width = 640,
364 .height = 480,
365 .pixelformat = V4L2_PIX_FMT_SBGGR8,
366 .priv = 8,
367 },
368 .set_pix_format = &ov7630_set_pix_format
369};
370
371
372int sn9c102_probe_ov7630(struct sn9c102_device* cam)
373{
374 int err = 0;
375
376 sn9c102_attach_sensor(cam, &ov7630);
377
378 if (le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x608f &&
379 le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x602c)
380 return -ENODEV;
381
382 err += sn9c102_write_reg(cam, 0x01, 0x01);
383 err += sn9c102_write_reg(cam, 0x00, 0x01);
384 err += sn9c102_write_reg(cam, 0x28, 0x17);
385
386 if (err)
387 return -EIO;
388
389 err += sn9c102_i2c_write(cam, 0x0b, 0);
390 if (err)
391 return -ENODEV;
392
393 return 0;
394}
diff --git a/drivers/usb/media/sn9c102_sensor.h b/drivers/usb/media/sn9c102_sensor.h
index 6a7adebcb4bf..a45166c3488c 100644
--- a/drivers/usb/media/sn9c102_sensor.h
+++ b/drivers/usb/media/sn9c102_sensor.h
@@ -64,6 +64,7 @@ struct sn9c102_sensor;
64*/ 64*/
65extern int sn9c102_probe_hv7131d(struct sn9c102_device* cam); 65extern int sn9c102_probe_hv7131d(struct sn9c102_device* cam);
66extern int sn9c102_probe_mi0343(struct sn9c102_device* cam); 66extern int sn9c102_probe_mi0343(struct sn9c102_device* cam);
67extern int sn9c102_probe_ov7630(struct sn9c102_device* cam);
67extern int sn9c102_probe_pas106b(struct sn9c102_device* cam); 68extern int sn9c102_probe_pas106b(struct sn9c102_device* cam);
68extern int sn9c102_probe_pas202bcb(struct sn9c102_device* cam); 69extern int sn9c102_probe_pas202bcb(struct sn9c102_device* cam);
69extern int sn9c102_probe_tas5110c1b(struct sn9c102_device* cam); 70extern int sn9c102_probe_tas5110c1b(struct sn9c102_device* cam);
@@ -80,6 +81,7 @@ static int (*sn9c102_sensor_table[])(struct sn9c102_device*) = { \
80 &sn9c102_probe_pas106b, /* strong detection based on SENSOR ids */ \ 81 &sn9c102_probe_pas106b, /* strong detection based on SENSOR ids */ \
81 &sn9c102_probe_pas202bcb, /* strong detection based on SENSOR ids */ \ 82 &sn9c102_probe_pas202bcb, /* strong detection based on SENSOR ids */ \
82 &sn9c102_probe_hv7131d, /* strong detection based on SENSOR ids */ \ 83 &sn9c102_probe_hv7131d, /* strong detection based on SENSOR ids */ \
84 &sn9c102_probe_ov7630, /* detection mostly based on USB pid/vid */ \
83 &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ \ 85 &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ \
84 &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ \ 86 &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ \
85 NULL, \ 87 NULL, \
@@ -103,7 +105,8 @@ static const struct usb_device_id sn9c102_id_table[] = { \
103 { USB_DEVICE(0x0c45, 0x6029), }, /* PAS106B */ \ 105 { USB_DEVICE(0x0c45, 0x6029), }, /* PAS106B */ \
104 { USB_DEVICE(0x0c45, 0x602a), }, /* HV7131D */ \ 106 { USB_DEVICE(0x0c45, 0x602a), }, /* HV7131D */ \
105 { USB_DEVICE(0x0c45, 0x602b), }, /* MI-0343 */ \ 107 { USB_DEVICE(0x0c45, 0x602b), }, /* MI-0343 */ \
106 { USB_DEVICE(0x0c45, 0x602c), }, /* OV7620 */ \ 108 { USB_DEVICE(0x0c45, 0x602c), }, /* OV7630 */ \
109 { USB_DEVICE(0x0c45, 0x602d), }, \
107 { USB_DEVICE(0x0c45, 0x6030), }, /* MI03x */ \ 110 { USB_DEVICE(0x0c45, 0x6030), }, /* MI03x */ \
108 { USB_DEVICE(0x0c45, 0x6080), }, \ 111 { USB_DEVICE(0x0c45, 0x6080), }, \
109 { USB_DEVICE(0x0c45, 0x6082), }, /* MI0343 and MI0360 */ \ 112 { USB_DEVICE(0x0c45, 0x6082), }, /* MI0343 and MI0360 */ \
@@ -145,6 +148,8 @@ static const struct usb_device_id sn9c102_id_table[] = { \
145*/ 148*/
146 149
147/* The "try" I2C I/O versions are used when probing the sensor */ 150/* The "try" I2C I/O versions are used when probing the sensor */
151extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*,
152 u8 address, u8 value);
148extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, 153extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
149 u8 address); 154 u8 address);
150 155
@@ -201,6 +206,8 @@ enum sn9c102_i2c_interface {
201 SN9C102_I2C_3WIRES, 206 SN9C102_I2C_3WIRES,
202}; 207};
203 208
209#define SN9C102_MAX_CTRLS V4L2_CID_LASTP1-V4L2_CID_BASE+10
210
204struct sn9c102_sensor { 211struct sn9c102_sensor {
205 char name[32], /* sensor name */ 212 char name[32], /* sensor name */
206 maintainer[64]; /* name of the mantainer <email> */ 213 maintainer[64]; /* name of the mantainer <email> */
@@ -243,7 +250,7 @@ struct sn9c102_sensor {
243 sensor according to the default configuration structures below. 250 sensor according to the default configuration structures below.
244 */ 251 */
245 252
246 struct v4l2_queryctrl qctrl[V4L2_CID_LASTP1-V4L2_CID_BASE]; 253 struct v4l2_queryctrl qctrl[SN9C102_MAX_CTRLS];
247 /* 254 /*
248 Optional list of default controls, defined as indicated in the 255 Optional list of default controls, defined as indicated in the
249 V4L2 API. Menu type controls are not handled by this interface. 256 V4L2 API. Menu type controls are not handled by this interface.
@@ -356,7 +363,7 @@ struct sn9c102_sensor {
356 core module to store successfully updated values of the above 363 core module to store successfully updated values of the above
357 settings, for rollbacks..etc..in case of errors during atomic I/O 364 settings, for rollbacks..etc..in case of errors during atomic I/O
358 */ 365 */
359 struct v4l2_queryctrl _qctrl[V4L2_CID_LASTP1-V4L2_CID_BASE]; 366 struct v4l2_queryctrl _qctrl[SN9C102_MAX_CTRLS];
360 struct v4l2_rect _rect; 367 struct v4l2_rect _rect;
361}; 368};
362 369
@@ -367,5 +374,8 @@ struct sn9c102_sensor {
367#define SN9C102_V4L2_CID_GREEN_BALANCE V4L2_CID_PRIVATE_BASE + 1 374#define SN9C102_V4L2_CID_GREEN_BALANCE V4L2_CID_PRIVATE_BASE + 1
368#define SN9C102_V4L2_CID_RESET_LEVEL V4L2_CID_PRIVATE_BASE + 2 375#define SN9C102_V4L2_CID_RESET_LEVEL V4L2_CID_PRIVATE_BASE + 2
369#define SN9C102_V4L2_CID_PIXEL_BIAS_VOLTAGE V4L2_CID_PRIVATE_BASE + 3 376#define SN9C102_V4L2_CID_PIXEL_BIAS_VOLTAGE V4L2_CID_PRIVATE_BASE + 3
377#define SN9C102_V4L2_CID_GAMMA V4L2_CID_PRIVATE_BASE + 4
378#define SN9C102_V4L2_CID_BAND_FILTER V4L2_CID_PRIVATE_BASE + 5
379#define SN9C102_V4L2_CID_BRIGHT_LEVEL V4L2_CID_PRIVATE_BASE + 6
370 380
371#endif /* _SN9C102_SENSOR_H_ */ 381#endif /* _SN9C102_SENSOR_H_ */
diff --git a/drivers/usb/media/sn9c102_tas5110c1b.c b/drivers/usb/media/sn9c102_tas5110c1b.c
index 690d62192273..8775999b5aff 100644
--- a/drivers/usb/media/sn9c102_tas5110c1b.c
+++ b/drivers/usb/media/sn9c102_tas5110c1b.c
@@ -24,8 +24,6 @@
24 24
25static struct sn9c102_sensor tas5110c1b; 25static struct sn9c102_sensor tas5110c1b;
26 26
27static struct v4l2_control tas5110c1b_gain;
28
29 27
30static int tas5110c1b_init(struct sn9c102_device* cam) 28static int tas5110c1b_init(struct sn9c102_device* cam)
31{ 29{
@@ -46,21 +44,6 @@ static int tas5110c1b_init(struct sn9c102_device* cam)
46} 44}
47 45
48 46
49static int tas5110c1b_get_ctrl(struct sn9c102_device* cam,
50 struct v4l2_control* ctrl)
51{
52 switch (ctrl->id) {
53 case V4L2_CID_GAIN:
54 ctrl->value = tas5110c1b_gain.value;
55 break;
56 default:
57 return -EINVAL;
58 }
59
60 return 0;
61}
62
63
64static int tas5110c1b_set_ctrl(struct sn9c102_device* cam, 47static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
65 const struct v4l2_control* ctrl) 48 const struct v4l2_control* ctrl)
66{ 49{
@@ -68,8 +51,7 @@ static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
68 51
69 switch (ctrl->id) { 52 switch (ctrl->id) {
70 case V4L2_CID_GAIN: 53 case V4L2_CID_GAIN:
71 if (!(err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value))) 54 err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value);
72 tas5110c1b_gain.value = ctrl->value;
73 break; 55 break;
74 default: 56 default:
75 return -EINVAL; 57 return -EINVAL;
@@ -147,7 +129,6 @@ static struct sn9c102_sensor tas5110c1b = {
147 .height = 288, 129 .height = 288,
148 }, 130 },
149 }, 131 },
150 .get_ctrl = &tas5110c1b_get_ctrl,
151 .set_crop = &tas5110c1b_set_crop, 132 .set_crop = &tas5110c1b_set_crop,
152 .pix_format = { 133 .pix_format = {
153 .width = 352, 134 .width = 352,
diff --git a/drivers/usb/media/sn9c102_tas5130d1b.c b/drivers/usb/media/sn9c102_tas5130d1b.c
index b378e941bbe8..927eafdd8c73 100644
--- a/drivers/usb/media/sn9c102_tas5130d1b.c
+++ b/drivers/usb/media/sn9c102_tas5130d1b.c
@@ -24,8 +24,6 @@
24 24
25static struct sn9c102_sensor tas5130d1b; 25static struct sn9c102_sensor tas5130d1b;
26 26
27static struct v4l2_control tas5130d1b_gain, tas5130d1b_exposure;
28
29 27
30static int tas5130d1b_init(struct sn9c102_device* cam) 28static int tas5130d1b_init(struct sn9c102_device* cam)
31{ 29{
@@ -44,24 +42,6 @@ static int tas5130d1b_init(struct sn9c102_device* cam)
44} 42}
45 43
46 44
47static int tas5130d1b_get_ctrl(struct sn9c102_device* cam,
48 struct v4l2_control* ctrl)
49{
50 switch (ctrl->id) {
51 case V4L2_CID_GAIN:
52 ctrl->value = tas5130d1b_gain.value;
53 break;
54 case V4L2_CID_EXPOSURE:
55 ctrl->value = tas5130d1b_exposure.value;
56 break;
57 default:
58 return -EINVAL;
59 }
60
61 return 0;
62}
63
64
65static int tas5130d1b_set_ctrl(struct sn9c102_device* cam, 45static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
66 const struct v4l2_control* ctrl) 46 const struct v4l2_control* ctrl)
67{ 47{
@@ -69,12 +49,10 @@ static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
69 49
70 switch (ctrl->id) { 50 switch (ctrl->id) {
71 case V4L2_CID_GAIN: 51 case V4L2_CID_GAIN:
72 if (!(err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value))) 52 err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value);
73 tas5130d1b_gain.value = ctrl->value;
74 break; 53 break;
75 case V4L2_CID_EXPOSURE: 54 case V4L2_CID_EXPOSURE:
76 if (!(err += sn9c102_i2c_write(cam, 0x40, 0x47 - ctrl->value))) 55 err += sn9c102_i2c_write(cam, 0x40, 0x47 - ctrl->value);
77 tas5130d1b_exposure.value = ctrl->value;
78 break; 56 break;
79 default: 57 default:
80 return -EINVAL; 58 return -EINVAL;
@@ -147,7 +125,6 @@ static struct sn9c102_sensor tas5130d1b = {
147 .flags = 0, 125 .flags = 0,
148 }, 126 },
149 }, 127 },
150 .get_ctrl = &tas5130d1b_get_ctrl,
151 .set_ctrl = &tas5130d1b_set_ctrl, 128 .set_ctrl = &tas5130d1b_set_ctrl,
152 .cropcap = { 129 .cropcap = {
153 .bounds = { 130 .bounds = {
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 3a896954b3a9..6649531fa824 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -139,6 +139,16 @@ config USB_IDMOUSE
139 139
140source "drivers/usb/misc/sisusbvga/Kconfig" 140source "drivers/usb/misc/sisusbvga/Kconfig"
141 141
142config USB_LD
143 tristate "USB LD driver"
144 depends on USB && EXPERIMENTAL
145 help
146 This driver is for generic USB devices that use interrupt transfers,
147 like LD Didactic's USB devices.
148
149 To compile this driver as a module, choose M here: the
150 module will be called ldusb.
151
142config USB_TEST 152config USB_TEST
143 tristate "USB testing driver (DEVELOPMENT)" 153 tristate "USB testing driver (DEVELOPMENT)"
144 depends on USB && USB_DEVICEFS && EXPERIMENTAL 154 depends on USB && USB_DEVICEFS && EXPERIMENTAL
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 4a3814cbd48d..862e40a83689 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_EMI26) += emi26.o
9obj-$(CONFIG_USB_EMI62) += emi62.o 9obj-$(CONFIG_USB_EMI62) += emi62.o
10obj-$(CONFIG_USB_IDMOUSE) += idmouse.o 10obj-$(CONFIG_USB_IDMOUSE) += idmouse.o
11obj-$(CONFIG_USB_LCD) += usblcd.o 11obj-$(CONFIG_USB_LCD) += usblcd.o
12obj-$(CONFIG_USB_LD) += ldusb.o
12obj-$(CONFIG_USB_LED) += usbled.o 13obj-$(CONFIG_USB_LED) += usbled.o
13obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o 14obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
14obj-$(CONFIG_USB_PHIDGETKIT) += phidgetkit.o 15obj-$(CONFIG_USB_PHIDGETKIT) += phidgetkit.o
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
new file mode 100644
index 000000000000..66ec88354b93
--- /dev/null
+++ b/drivers/usb/misc/ldusb.c
@@ -0,0 +1,794 @@
1/**
2 * Generic USB driver for report based interrupt in/out devices
3 * like LD Didactic's USB devices. LD Didactic's USB devices are
4 * HID devices which do not use HID report definitons (they use
5 * raw interrupt in and our reports only for communication).
6 *
7 * This driver uses a ring buffer for time critical reading of
8 * interrupt in reports and provides read and write methods for
9 * raw interrupt reports (similar to the Windows HID driver).
10 * Devices based on the book USB COMPLETE by Jan Axelson may need
11 * such a compatibility to the Windows HID driver.
12 *
13 * Copyright (C) 2005 Michael Hund <mhund@ld-didactic.de>
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * Derived from Lego USB Tower driver
21 * Copyright (C) 2003 David Glance <advidgsf@sourceforge.net>
22 * 2001-2004 Juergen Stuber <starblue@users.sourceforge.net>
23 *
24 * V0.1 (mh) Initial version
25 * V0.11 (mh) Added raw support for HID 1.0 devices (no interrupt out endpoint)
26 */
27
28#include <linux/config.h>
29#include <linux/kernel.h>
30#include <linux/errno.h>
31#include <linux/init.h>
32#include <linux/slab.h>
33#include <linux/module.h>
34
35#include <asm/uaccess.h>
36#include <linux/input.h>
37#include <linux/usb.h>
38#include <linux/poll.h>
39
40/* Define these values to match your devices */
41#define USB_VENDOR_ID_LD 0x0f11 /* USB Vendor ID of LD Didactic GmbH */
42#define USB_DEVICE_ID_CASSY 0x1000 /* USB Product ID for all CASSY-S modules */
43#define USB_DEVICE_ID_POCKETCASSY 0x1010 /* USB Product ID for Pocket-CASSY */
44#define USB_DEVICE_ID_MOBILECASSY 0x1020 /* USB Product ID for Mobile-CASSY */
45#define USB_DEVICE_ID_JWM 0x1080 /* USB Product ID for Joule and Wattmeter */
46#define USB_DEVICE_ID_DMMP 0x1081 /* USB Product ID for Digital Multimeter P (reserved) */
47#define USB_DEVICE_ID_UMIP 0x1090 /* USB Product ID for UMI P */
48#define USB_DEVICE_ID_VIDEOCOM 0x1200 /* USB Product ID for VideoCom */
49#define USB_DEVICE_ID_COM3LAB 0x2000 /* USB Product ID for COM3LAB */
50#define USB_DEVICE_ID_TELEPORT 0x2010 /* USB Product ID for Terminal Adapter */
51#define USB_DEVICE_ID_NETWORKANALYSER 0x2020 /* USB Product ID for Network Analyser */
52#define USB_DEVICE_ID_POWERCONTROL 0x2030 /* USB Product ID for Controlling device for Power Electronics */
53
54#define USB_VENDOR_ID_VERNIER 0x08f7
55#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
56#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
57#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
58#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
59
60
61#ifdef CONFIG_USB_DYNAMIC_MINORS
62#define USB_LD_MINOR_BASE 0
63#else
64#define USB_LD_MINOR_BASE 176
65#endif
66
67/* table of devices that work with this driver */
68static struct usb_device_id ld_usb_table [] = {
69 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_CASSY) },
70 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_POCKETCASSY) },
71 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_MOBILECASSY) },
72 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_JWM) },
73 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_DMMP) },
74 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_UMIP) },
75 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_VIDEOCOM) },
76 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_COM3LAB) },
77 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_TELEPORT) },
78 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_NETWORKANALYSER) },
79 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_POWERCONTROL) },
80 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
81 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
82 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
83 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
84 { } /* Terminating entry */
85};
86MODULE_DEVICE_TABLE(usb, ld_usb_table);
87MODULE_VERSION("V0.11");
88MODULE_AUTHOR("Michael Hund <mhund@ld-didactic.de>");
89MODULE_DESCRIPTION("LD USB Driver");
90MODULE_LICENSE("GPL");
91MODULE_SUPPORTED_DEVICE("LD USB Devices");
92
93#ifdef CONFIG_USB_DEBUG
94 static int debug = 1;
95#else
96 static int debug = 0;
97#endif
98
99/* Use our own dbg macro */
100#define dbg_info(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
101
102/* Module parameters */
103module_param(debug, int, S_IRUGO | S_IWUSR);
104MODULE_PARM_DESC(debug, "Debug enabled or not");
105
106/* All interrupt in transfers are collected in a ring buffer to
107 * avoid racing conditions and get better performance of the driver.
108 */
109static int ring_buffer_size = 128;
110module_param(ring_buffer_size, int, 0);
111MODULE_PARM_DESC(ring_buffer_size, "Read ring buffer size in reports");
112
113/* The write_buffer can contain more than one interrupt out transfer.
114 */
115static int write_buffer_size = 10;
116module_param(write_buffer_size, int, 0);
117MODULE_PARM_DESC(write_buffer_size, "Write buffer size in reports");
118
119/* As of kernel version 2.6.4 ehci-hcd uses an
120 * "only one interrupt transfer per frame" shortcut
121 * to simplify the scheduling of periodic transfers.
122 * This conflicts with our standard 1ms intervals for in and out URBs.
123 * We use default intervals of 2ms for in and 2ms for out transfers,
124 * which should be fast enough.
125 * Increase the interval to allow more devices that do interrupt transfers,
126 * or set to 1 to use the standard interval from the endpoint descriptors.
127 */
128static int min_interrupt_in_interval = 2;
129module_param(min_interrupt_in_interval, int, 0);
130MODULE_PARM_DESC(min_interrupt_in_interval, "Minimum interrupt in interval in ms");
131
132static int min_interrupt_out_interval = 2;
133module_param(min_interrupt_out_interval, int, 0);
134MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in ms");
135
136/* Structure to hold all of our device specific stuff */
137struct ld_usb {
138 struct semaphore sem; /* locks this structure */
139 struct usb_interface* intf; /* save off the usb interface pointer */
140
141 int open_count; /* number of times this port has been opened */
142
143 char* ring_buffer;
144 unsigned int ring_head;
145 unsigned int ring_tail;
146
147 wait_queue_head_t read_wait;
148 wait_queue_head_t write_wait;
149
150 char* interrupt_in_buffer;
151 struct usb_endpoint_descriptor* interrupt_in_endpoint;
152 struct urb* interrupt_in_urb;
153 int interrupt_in_interval;
154 size_t interrupt_in_endpoint_size;
155 int interrupt_in_running;
156 int interrupt_in_done;
157
158 char* interrupt_out_buffer;
159 struct usb_endpoint_descriptor* interrupt_out_endpoint;
160 struct urb* interrupt_out_urb;
161 int interrupt_out_interval;
162 size_t interrupt_out_endpoint_size;
163 int interrupt_out_busy;
164};
165
166/* prevent races between open() and disconnect() */
167static DECLARE_MUTEX(disconnect_sem);
168
169static struct usb_driver ld_usb_driver;
170
171/**
172 * ld_usb_abort_transfers
173 * aborts transfers and frees associated data structures
174 */
175static void ld_usb_abort_transfers(struct ld_usb *dev)
176{
177 /* shutdown transfer */
178 if (dev->interrupt_in_running) {
179 dev->interrupt_in_running = 0;
180 if (dev->intf)
181 usb_kill_urb(dev->interrupt_in_urb);
182 }
183 if (dev->interrupt_out_busy)
184 if (dev->intf)
185 usb_kill_urb(dev->interrupt_out_urb);
186}
187
188/**
189 * ld_usb_delete
190 */
191static void ld_usb_delete(struct ld_usb *dev)
192{
193 ld_usb_abort_transfers(dev);
194
195 /* free data structures */
196 usb_free_urb(dev->interrupt_in_urb);
197 usb_free_urb(dev->interrupt_out_urb);
198 kfree(dev->ring_buffer);
199 kfree(dev->interrupt_in_buffer);
200 kfree(dev->interrupt_out_buffer);
201 kfree(dev);
202}
203
204/**
205 * ld_usb_interrupt_in_callback
206 */
207static void ld_usb_interrupt_in_callback(struct urb *urb, struct pt_regs *regs)
208{
209 struct ld_usb *dev = urb->context;
210 size_t *actual_buffer;
211 unsigned int next_ring_head;
212 int retval;
213
214 if (urb->status) {
215 if (urb->status == -ENOENT ||
216 urb->status == -ECONNRESET ||
217 urb->status == -ESHUTDOWN) {
218 goto exit;
219 } else {
220 dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n",
221 __FUNCTION__, urb->status);
222 goto resubmit; /* maybe we can recover */
223 }
224 }
225
226 if (urb->actual_length > 0) {
227 next_ring_head = (dev->ring_head+1) % ring_buffer_size;
228 if (next_ring_head != dev->ring_tail) {
229 actual_buffer = (size_t*)(dev->ring_buffer + dev->ring_head*(sizeof(size_t)+dev->interrupt_in_endpoint_size));
230 /* actual_buffer gets urb->actual_length + interrupt_in_buffer */
231 *actual_buffer = urb->actual_length;
232 memcpy(actual_buffer+1, dev->interrupt_in_buffer, urb->actual_length);
233 dev->ring_head = next_ring_head;
234 dbg_info(&dev->intf->dev, "%s: received %d bytes\n",
235 __FUNCTION__, urb->actual_length);
236 } else
237 dev_warn(&dev->intf->dev,
238 "Ring buffer overflow, %d bytes dropped\n",
239 urb->actual_length);
240 }
241
242resubmit:
243 /* resubmit if we're still running */
244 if (dev->interrupt_in_running && dev->intf) {
245 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);
246 if (retval)
247 dev_err(&dev->intf->dev,
248 "usb_submit_urb failed (%d)\n", retval);
249 }
250
251exit:
252 dev->interrupt_in_done = 1;
253 wake_up_interruptible(&dev->read_wait);
254}
255
256/**
257 * ld_usb_interrupt_out_callback
258 */
259static void ld_usb_interrupt_out_callback(struct urb *urb, struct pt_regs *regs)
260{
261 struct ld_usb *dev = urb->context;
262
263 /* sync/async unlink faults aren't errors */
264 if (urb->status && !(urb->status == -ENOENT ||
265 urb->status == -ECONNRESET ||
266 urb->status == -ESHUTDOWN))
267 dbg_info(&dev->intf->dev,
268 "%s - nonzero write interrupt status received: %d\n",
269 __FUNCTION__, urb->status);
270
271 dev->interrupt_out_busy = 0;
272 wake_up_interruptible(&dev->write_wait);
273}
274
275/**
276 * ld_usb_open
277 */
278static int ld_usb_open(struct inode *inode, struct file *file)
279{
280 struct ld_usb *dev;
281 int subminor;
282 int retval = 0;
283 struct usb_interface *interface;
284
285 nonseekable_open(inode, file);
286 subminor = iminor(inode);
287
288 down(&disconnect_sem);
289
290 interface = usb_find_interface(&ld_usb_driver, subminor);
291
292 if (!interface) {
293 err("%s - error, can't find device for minor %d\n",
294 __FUNCTION__, subminor);
295 retval = -ENODEV;
296 goto unlock_disconnect_exit;
297 }
298
299 dev = usb_get_intfdata(interface);
300
301 if (!dev) {
302 retval = -ENODEV;
303 goto unlock_disconnect_exit;
304 }
305
306 /* lock this device */
307 if (down_interruptible(&dev->sem)) {
308 retval = -ERESTARTSYS;
309 goto unlock_disconnect_exit;
310 }
311
312 /* allow opening only once */
313 if (dev->open_count) {
314 retval = -EBUSY;
315 goto unlock_exit;
316 }
317 dev->open_count = 1;
318
319 /* initialize in direction */
320 dev->ring_head = 0;
321 dev->ring_tail = 0;
322 usb_fill_int_urb(dev->interrupt_in_urb,
323 interface_to_usbdev(interface),
324 usb_rcvintpipe(interface_to_usbdev(interface),
325 dev->interrupt_in_endpoint->bEndpointAddress),
326 dev->interrupt_in_buffer,
327 dev->interrupt_in_endpoint_size,
328 ld_usb_interrupt_in_callback,
329 dev,
330 dev->interrupt_in_interval);
331
332 dev->interrupt_in_running = 1;
333 dev->interrupt_in_done = 0;
334
335 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
336 if (retval) {
337 dev_err(&interface->dev, "Couldn't submit interrupt_in_urb %d\n", retval);
338 dev->interrupt_in_running = 0;
339 dev->open_count = 0;
340 goto unlock_exit;
341 }
342
343 /* save device in the file's private structure */
344 file->private_data = dev;
345
346unlock_exit:
347 up(&dev->sem);
348
349unlock_disconnect_exit:
350 up(&disconnect_sem);
351
352 return retval;
353}
354
355/**
356 * ld_usb_release
357 */
358static int ld_usb_release(struct inode *inode, struct file *file)
359{
360 struct ld_usb *dev;
361 int retval = 0;
362
363 dev = file->private_data;
364
365 if (dev == NULL) {
366 retval = -ENODEV;
367 goto exit;
368 }
369
370 if (down_interruptible(&dev->sem)) {
371 retval = -ERESTARTSYS;
372 goto exit;
373 }
374
375 if (dev->open_count != 1) {
376 retval = -ENODEV;
377 goto unlock_exit;
378 }
379 if (dev->intf == NULL) {
380 /* the device was unplugged before the file was released */
381 up(&dev->sem);
382 /* unlock here as ld_usb_delete frees dev */
383 ld_usb_delete(dev);
384 goto exit;
385 }
386
387 /* wait until write transfer is finished */
388 if (dev->interrupt_out_busy)
389 wait_event_interruptible_timeout(dev->write_wait, !dev->interrupt_out_busy, 2 * HZ);
390 ld_usb_abort_transfers(dev);
391 dev->open_count = 0;
392
393unlock_exit:
394 up(&dev->sem);
395
396exit:
397 return retval;
398}
399
400/**
401 * ld_usb_poll
402 */
403static unsigned int ld_usb_poll(struct file *file, poll_table *wait)
404{
405 struct ld_usb *dev;
406 unsigned int mask = 0;
407
408 dev = file->private_data;
409
410 poll_wait(file, &dev->read_wait, wait);
411 poll_wait(file, &dev->write_wait, wait);
412
413 if (dev->ring_head != dev->ring_tail)
414 mask |= POLLIN | POLLRDNORM;
415 if (!dev->interrupt_out_busy)
416 mask |= POLLOUT | POLLWRNORM;
417
418 return mask;
419}
420
421/**
422 * ld_usb_read
423 */
424static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
425 loff_t *ppos)
426{
427 struct ld_usb *dev;
428 size_t *actual_buffer;
429 size_t bytes_to_read;
430 int retval = 0;
431
432 dev = file->private_data;
433
434 /* verify that we actually have some data to read */
435 if (count == 0)
436 goto exit;
437
438 /* lock this object */
439 if (down_interruptible(&dev->sem)) {
440 retval = -ERESTARTSYS;
441 goto exit;
442 }
443
444 /* verify that the device wasn't unplugged */
445 if (dev->intf == NULL) {
446 retval = -ENODEV;
447 err("No device or device unplugged %d\n", retval);
448 goto unlock_exit;
449 }
450
451 /* wait for data */
452 if (dev->ring_head == dev->ring_tail) {
453 if (file->f_flags & O_NONBLOCK) {
454 retval = -EAGAIN;
455 goto unlock_exit;
456 }
457 retval = wait_event_interruptible(dev->read_wait, dev->interrupt_in_done);
458 if (retval < 0)
459 goto unlock_exit;
460 }
461
462 /* actual_buffer contains actual_length + interrupt_in_buffer */
463 actual_buffer = (size_t*)(dev->ring_buffer + dev->ring_tail*(sizeof(size_t)+dev->interrupt_in_endpoint_size));
464 bytes_to_read = min(count, *actual_buffer);
465 if (bytes_to_read < *actual_buffer)
466 dev_warn(&dev->intf->dev, "Read buffer overflow, %d bytes dropped\n",
467 *actual_buffer-bytes_to_read);
468
469 /* copy one interrupt_in_buffer from ring_buffer into userspace */
470 if (copy_to_user(buffer, actual_buffer+1, bytes_to_read)) {
471 retval = -EFAULT;
472 goto unlock_exit;
473 }
474 dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size;
475
476 retval = bytes_to_read;
477
478unlock_exit:
479 /* unlock the device */
480 up(&dev->sem);
481
482exit:
483 return retval;
484}
485
486/**
487 * ld_usb_write
488 */
489static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
490 size_t count, loff_t *ppos)
491{
492 struct ld_usb *dev;
493 size_t bytes_to_write;
494 int retval = 0;
495
496 dev = file->private_data;
497
498 /* verify that we actually have some data to write */
499 if (count == 0)
500 goto exit;
501
502 /* lock this object */
503 if (down_interruptible(&dev->sem)) {
504 retval = -ERESTARTSYS;
505 goto exit;
506 }
507
508 /* verify that the device wasn't unplugged */
509 if (dev->intf == NULL) {
510 retval = -ENODEV;
511 err("No device or device unplugged %d\n", retval);
512 goto unlock_exit;
513 }
514
515 /* wait until previous transfer is finished */
516 if (dev->interrupt_out_busy) {
517 if (file->f_flags & O_NONBLOCK) {
518 retval = -EAGAIN;
519 goto unlock_exit;
520 }
521 retval = wait_event_interruptible(dev->write_wait, !dev->interrupt_out_busy);
522 if (retval < 0) {
523 goto unlock_exit;
524 }
525 }
526
527 /* write the data into interrupt_out_buffer from userspace */
528 bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size);
529 if (bytes_to_write < count)
530 dev_warn(&dev->intf->dev, "Write buffer overflow, %d bytes dropped\n",count-bytes_to_write);
531 dbg_info(&dev->intf->dev, "%s: count = %d, bytes_to_write = %d\n", __FUNCTION__, count, bytes_to_write);
532
533 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
534 retval = -EFAULT;
535 goto unlock_exit;
536 }
537
538 if (dev->interrupt_out_endpoint == NULL) {
539 /* try HID_REQ_SET_REPORT=9 on control_endpoint instead of interrupt_out_endpoint */
540 retval = usb_control_msg(interface_to_usbdev(dev->intf),
541 usb_sndctrlpipe(interface_to_usbdev(dev->intf), 0),
542 9,
543 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
544 1 << 8, 0,
545 dev->interrupt_out_buffer,
546 bytes_to_write,
547 USB_CTRL_SET_TIMEOUT * HZ);
548 if (retval < 0)
549 err("Couldn't submit HID_REQ_SET_REPORT %d\n", retval);
550 goto unlock_exit;
551 }
552
553 /* send off the urb */
554 usb_fill_int_urb(dev->interrupt_out_urb,
555 interface_to_usbdev(dev->intf),
556 usb_sndintpipe(interface_to_usbdev(dev->intf),
557 dev->interrupt_out_endpoint->bEndpointAddress),
558 dev->interrupt_out_buffer,
559 bytes_to_write,
560 ld_usb_interrupt_out_callback,
561 dev,
562 dev->interrupt_out_interval);
563
564 dev->interrupt_out_busy = 1;
565 wmb();
566
567 retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
568 if (retval) {
569 dev->interrupt_out_busy = 0;
570 err("Couldn't submit interrupt_out_urb %d\n", retval);
571 goto unlock_exit;
572 }
573 retval = bytes_to_write;
574
575unlock_exit:
576 /* unlock the device */
577 up(&dev->sem);
578
579exit:
580 return retval;
581}
582
583/* file operations needed when we register this driver */
584static struct file_operations ld_usb_fops = {
585 .owner = THIS_MODULE,
586 .read = ld_usb_read,
587 .write = ld_usb_write,
588 .open = ld_usb_open,
589 .release = ld_usb_release,
590 .poll = ld_usb_poll,
591};
592
593/*
594 * usb class driver info in order to get a minor number from the usb core,
595 * and to have the device registered with devfs and the driver core
596 */
597static struct usb_class_driver ld_usb_class = {
598 .name = "ldusb%d",
599 .fops = &ld_usb_fops,
600 .minor_base = USB_LD_MINOR_BASE,
601};
602
603/**
604 * ld_usb_probe
605 *
606 * Called by the usb core when a new device is connected that it thinks
607 * this driver might be interested in.
608 */
609static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
610{
611 struct usb_device *udev = interface_to_usbdev(intf);
612 struct ld_usb *dev = NULL;
613 struct usb_host_interface *iface_desc;
614 struct usb_endpoint_descriptor *endpoint;
615 char *buffer;
616 int i;
617 int retval = -ENOMEM;
618
619 /* allocate memory for our device state and intialize it */
620
621 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
622 if (dev == NULL) {
623 dev_err(&intf->dev, "Out of memory\n");
624 goto exit;
625 }
626 memset(dev, 0x00, sizeof(*dev));
627 init_MUTEX(&dev->sem);
628 dev->intf = intf;
629 init_waitqueue_head(&dev->read_wait);
630 init_waitqueue_head(&dev->write_wait);
631
632 /* workaround for early firmware versions on fast computers */
633 if ((le16_to_cpu(udev->descriptor.idVendor) == USB_VENDOR_ID_LD) &&
634 ((le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_CASSY) ||
635 (le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_COM3LAB)) &&
636 (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x103)) {
637 buffer = kmalloc(256, GFP_KERNEL);
638 /* usb_string makes SETUP+STALL to leave always ControlReadLoop */
639 usb_string(udev, 255, buffer, 256);
640 kfree(buffer);
641 }
642
643 iface_desc = intf->cur_altsetting;
644
645 /* set up the endpoint information */
646 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
647 endpoint = &iface_desc->endpoint[i].desc;
648
649 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) &&
650 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
651 dev->interrupt_in_endpoint = endpoint;
652 }
653
654 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) &&
655 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
656 dev->interrupt_out_endpoint = endpoint;
657 }
658 }
659 if (dev->interrupt_in_endpoint == NULL) {
660 dev_err(&intf->dev, "Interrupt in endpoint not found\n");
661 goto error;
662 }
663 if (dev->interrupt_out_endpoint == NULL)
664 dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n");
665
666 dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);
667 dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL);
668 if (!dev->ring_buffer) {
669 dev_err(&intf->dev, "Couldn't allocate ring_buffer\n");
670 goto error;
671 }
672 dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);
673 if (!dev->interrupt_in_buffer) {
674 dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n");
675 goto error;
676 }
677 dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
678 if (!dev->interrupt_in_urb) {
679 dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n");
680 goto error;
681 }
682 dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) :
683 udev->descriptor.bMaxPacketSize0;
684 dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);
685 if (!dev->interrupt_out_buffer) {
686 dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n");
687 goto error;
688 }
689 dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
690 if (!dev->interrupt_out_urb) {
691 dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n");
692 goto error;
693 }
694 dev->interrupt_in_interval = min_interrupt_in_interval > dev->interrupt_in_endpoint->bInterval ? min_interrupt_in_interval : dev->interrupt_in_endpoint->bInterval;
695 if (dev->interrupt_out_endpoint)
696 dev->interrupt_out_interval = min_interrupt_out_interval > dev->interrupt_out_endpoint->bInterval ? min_interrupt_out_interval : dev->interrupt_out_endpoint->bInterval;
697
698 /* we can register the device now, as it is ready */
699 usb_set_intfdata(intf, dev);
700
701 retval = usb_register_dev(intf, &ld_usb_class);
702 if (retval) {
703 /* something prevented us from registering this driver */
704 dev_err(&intf->dev, "Not able to get a minor for this device.\n");
705 usb_set_intfdata(intf, NULL);
706 goto error;
707 }
708
709 /* let the user know what node this device is now attached to */
710 dev_info(&intf->dev, "LD USB Device #%d now attached to major %d minor %d\n",
711 (intf->minor - USB_LD_MINOR_BASE), USB_MAJOR, intf->minor);
712
713exit:
714 return retval;
715
716error:
717 ld_usb_delete(dev);
718
719 return retval;
720}
721
722/**
723 * ld_usb_disconnect
724 *
725 * Called by the usb core when the device is removed from the system.
726 */
727static void ld_usb_disconnect(struct usb_interface *intf)
728{
729 struct ld_usb *dev;
730 int minor;
731
732 down(&disconnect_sem);
733
734 dev = usb_get_intfdata(intf);
735 usb_set_intfdata(intf, NULL);
736
737 down(&dev->sem);
738
739 minor = intf->minor;
740
741 /* give back our minor */
742 usb_deregister_dev(intf, &ld_usb_class);
743
744 /* if the device is not opened, then we clean up right now */
745 if (!dev->open_count) {
746 up(&dev->sem);
747 ld_usb_delete(dev);
748 } else {
749 dev->intf = NULL;
750 up(&dev->sem);
751 }
752
753 up(&disconnect_sem);
754
755 dev_info(&intf->dev, "LD USB Device #%d now disconnected\n",
756 (minor - USB_LD_MINOR_BASE));
757}
758
759/* usb specific object needed to register this driver with the usb subsystem */
760static struct usb_driver ld_usb_driver = {
761 .owner = THIS_MODULE,
762 .name = "ldusb",
763 .probe = ld_usb_probe,
764 .disconnect = ld_usb_disconnect,
765 .id_table = ld_usb_table,
766};
767
768/**
769 * ld_usb_init
770 */
771static int __init ld_usb_init(void)
772{
773 int retval;
774
775 /* register this driver with the USB subsystem */
776 retval = usb_register(&ld_usb_driver);
777 if (retval)
778 err("usb_register failed for the "__FILE__" driver. Error number %d\n", retval);
779
780 return retval;
781}
782
783/**
784 * ld_usb_exit
785 */
786static void __exit ld_usb_exit(void)
787{
788 /* deregister this driver with the USB subsystem */
789 usb_deregister(&ld_usb_driver);
790}
791
792module_init(ld_usb_init);
793module_exit(ld_usb_exit);
794
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 755a4570477f..26266b30028e 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -19,11 +19,16 @@
19#define DATA_MAX 32 19#define DATA_MAX 32
20 20
21/* 21/*
22 * Defined by USB 2.0 clause 9.3, table 9.2.
23 */
24#define SETUP_MAX 8
25
26/*
22 * This limit exists to prevent OOMs when the user process stops reading. 27 * This limit exists to prevent OOMs when the user process stops reading.
23 */ 28 */
24#define EVENT_MAX 25 29#define EVENT_MAX 25
25 30
26#define PRINTF_DFL 120 31#define PRINTF_DFL 130
27 32
28struct mon_event_text { 33struct mon_event_text {
29 struct list_head e_link; 34 struct list_head e_link;
@@ -33,7 +38,9 @@ struct mon_event_text {
33 unsigned int tstamp; 38 unsigned int tstamp;
34 int length; /* Depends on type: xfer length or act length */ 39 int length; /* Depends on type: xfer length or act length */
35 int status; 40 int status;
41 char setup_flag;
36 char data_flag; 42 char data_flag;
43 unsigned char setup[SETUP_MAX];
37 unsigned char data[DATA_MAX]; 44 unsigned char data[DATA_MAX];
38}; 45};
39 46
@@ -64,6 +71,22 @@ static void mon_text_dtor(void *, kmem_cache_t *, unsigned long);
64 * This is called with the whole mon_bus locked, so no additional lock. 71 * This is called with the whole mon_bus locked, so no additional lock.
65 */ 72 */
66 73
74static inline char mon_text_get_setup(struct mon_event_text *ep,
75 struct urb *urb, char ev_type)
76{
77
78 if (!usb_pipecontrol(urb->pipe) || ev_type != 'S')
79 return '-';
80
81 if (urb->transfer_flags & URB_NO_SETUP_DMA_MAP)
82 return 'D';
83 if (urb->setup_packet == NULL)
84 return 'Z'; /* '0' would be not as pretty. */
85
86 memcpy(ep->setup, urb->setup_packet, SETUP_MAX);
87 return 0;
88}
89
67static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb, 90static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
68 int len, char ev_type) 91 int len, char ev_type)
69{ 92{
@@ -90,7 +113,6 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
90 113
91 /* 114 /*
92 * Bulk is easy to shortcut reliably. 115 * Bulk is easy to shortcut reliably.
93 * XXX Control needs setup packet taken.
94 * XXX Other pipe types need consideration. Currently, we overdo it 116 * XXX Other pipe types need consideration. Currently, we overdo it
95 * and collect garbage for them: better more than less. 117 * and collect garbage for them: better more than less.
96 */ 118 */
@@ -144,6 +166,7 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
144 /* Collecting status makes debugging sense for submits, too */ 166 /* Collecting status makes debugging sense for submits, too */
145 ep->status = urb->status; 167 ep->status = urb->status;
146 168
169 ep->setup_flag = mon_text_get_setup(ep, urb, ev_type);
147 ep->data_flag = mon_text_get_data(ep, urb, ep->length, ev_type); 170 ep->data_flag = mon_text_get_data(ep, urb, ep->length, ev_type);
148 171
149 rp->nevents++; 172 rp->nevents++;
@@ -299,10 +322,25 @@ static ssize_t mon_text_read(struct file *file, char __user *buf,
299 default: /* PIPE_BULK */ utype = 'B'; 322 default: /* PIPE_BULK */ utype = 'B';
300 } 323 }
301 cnt += snprintf(pbuf + cnt, limit - cnt, 324 cnt += snprintf(pbuf + cnt, limit - cnt,
302 "%lx %u %c %c%c:%03u:%02u %d %d", 325 "%lx %u %c %c%c:%03u:%02u",
303 ep->id, ep->tstamp, ep->type, 326 ep->id, ep->tstamp, ep->type,
304 utype, udir, usb_pipedevice(ep->pipe), usb_pipeendpoint(ep->pipe), 327 utype, udir, usb_pipedevice(ep->pipe), usb_pipeendpoint(ep->pipe));
305 ep->status, ep->length); 328
329 if (ep->setup_flag == 0) { /* Setup packet is present and captured */
330 cnt += snprintf(pbuf + cnt, limit - cnt,
331 " s %02x %02x %04x %04x %04x",
332 ep->setup[0],
333 ep->setup[1],
334 (ep->setup[3] << 8) | ep->setup[2],
335 (ep->setup[5] << 8) | ep->setup[4],
336 (ep->setup[7] << 8) | ep->setup[6]);
337 } else if (ep->setup_flag != '-') { /* Unable to capture setup packet */
338 cnt += snprintf(pbuf + cnt, limit - cnt,
339 " %c __ __ ____ ____ ____", ep->setup_flag);
340 } else { /* No setup for this kind of URB */
341 cnt += snprintf(pbuf + cnt, limit - cnt, " %d", ep->status);
342 }
343 cnt += snprintf(pbuf + cnt, limit - cnt, " %d", ep->length);
306 344
307 if ((data_len = ep->length) > 0) { 345 if ((data_len = ep->length) > 0) {
308 if (ep->data_flag == 0) { 346 if (ep->data_flag == 0) {
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index fd6ff4cb2c62..7ffa99b9760f 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -477,7 +477,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
477} 477}
478 478
479static void kaweth_usb_receive(struct urb *, struct pt_regs *regs); 479static void kaweth_usb_receive(struct urb *, struct pt_regs *regs);
480static int kaweth_resubmit_rx_urb(struct kaweth_device *, int); 480static int kaweth_resubmit_rx_urb(struct kaweth_device *, unsigned);
481 481
482/**************************************************************** 482/****************************************************************
483 int_callback 483 int_callback
@@ -550,7 +550,7 @@ static void kaweth_resubmit_tl(void *d)
550 * kaweth_resubmit_rx_urb 550 * kaweth_resubmit_rx_urb
551 ****************************************************************/ 551 ****************************************************************/
552static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, 552static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth,
553 int mem_flags) 553 unsigned mem_flags)
554{ 554{
555 int result; 555 int result;
556 556
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 8a945f4f3693..576f3b852fce 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -3227,9 +3227,9 @@ static int usbnet_stop (struct net_device *net)
3227 temp = unlink_urbs (dev, &dev->txq) + unlink_urbs (dev, &dev->rxq); 3227 temp = unlink_urbs (dev, &dev->txq) + unlink_urbs (dev, &dev->rxq);
3228 3228
3229 // maybe wait for deletions to finish. 3229 // maybe wait for deletions to finish.
3230 while (skb_queue_len (&dev->rxq) 3230 while (!skb_queue_empty(&dev->rxq) &&
3231 && skb_queue_len (&dev->txq) 3231 !skb_queue_empty(&dev->txq) &&
3232 && skb_queue_len (&dev->done)) { 3232 !skb_queue_empty(&dev->done)) {
3233 msleep(UNLINK_TIMEOUT_MS); 3233 msleep(UNLINK_TIMEOUT_MS);
3234 if (netif_msg_ifdown (dev)) 3234 if (netif_msg_ifdown (dev))
3235 devdbg (dev, "waited for %d urb completions", temp); 3235 devdbg (dev, "waited for %d urb completions", temp);
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index d882fa3ad19a..0b03ddab53d9 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -264,16 +264,26 @@
264/* 264/*
265 * Version Information 265 * Version Information
266 */ 266 */
267#define DRIVER_VERSION "v1.4.2" 267#define DRIVER_VERSION "v1.4.3"
268#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>" 268#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>"
269#define DRIVER_DESC "USB FTDI Serial Converters Driver" 269#define DRIVER_DESC "USB FTDI Serial Converters Driver"
270 270
271static int debug; 271static int debug;
272 272
273static struct usb_device_id id_table_sio [] = { 273/* struct ftdi_sio_quirk is used by devices requiring special attention. */
274 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 274struct ftdi_sio_quirk {
275 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) }, 275 void (*setup)(struct usb_serial *); /* Special settings during startup. */
276 { } /* Terminating entry */ 276};
277
278static void ftdi_USB_UIRT_setup (struct usb_serial *serial);
279static void ftdi_HE_TIRA1_setup (struct usb_serial *serial);
280
281static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
282 .setup = ftdi_USB_UIRT_setup,
283};
284
285static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {
286 .setup = ftdi_HE_TIRA1_setup,
277}; 287};
278 288
279/* 289/*
@@ -288,237 +298,11 @@ static struct usb_device_id id_table_sio [] = {
288 * the bcdDevice value is used to differentiate FT232BM and FT245BM from 298 * the bcdDevice value is used to differentiate FT232BM and FT245BM from
289 * the earlier FT8U232AM and FT8U232BM. For now, include all known VID/PID 299 * the earlier FT8U232AM and FT8U232BM. For now, include all known VID/PID
290 * combinations in both tables. 300 * combinations in both tables.
291 * FIXME: perhaps bcdDevice can also identify 12MHz devices, but I don't know 301 * FIXME: perhaps bcdDevice can also identify 12MHz FT8U232AM devices,
292 * if those ever went into mass production. [Ian Abbott] 302 * but I don't know if those ever went into mass production. [Ian Abbott]
293 */ 303 */
294 304
295 305
296static struct usb_device_id id_table_8U232AM [] = {
297 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0, 0x3ff) },
298 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0, 0x3ff) },
299 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0, 0x3ff) },
300 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0, 0x3ff) },
301 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
302 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
303 { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0, 0x3ff) },
304 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0, 0x3ff) },
305 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_634_PID, 0, 0x3ff) },
306 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_547_PID, 0, 0x3ff) },
307 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_633_PID, 0, 0x3ff) },
308 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_631_PID, 0, 0x3ff) },
309 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_635_PID, 0, 0x3ff) },
310 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_640_PID, 0, 0x3ff) },
311 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_642_PID, 0, 0x3ff) },
312 { USB_DEVICE_VER(FTDI_VID, FTDI_VNHCPCUSB_D_PID, 0, 0x3ff) },
313 { USB_DEVICE_VER(FTDI_VID, FTDI_DSS20_PID, 0, 0x3ff) },
314 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2101_PID, 0, 0x3ff) },
315 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2102_PID, 0, 0x3ff) },
316 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2103_PID, 0, 0x3ff) },
317 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2104_PID, 0, 0x3ff) },
318 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2201_1_PID, 0, 0x3ff) },
319 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2201_2_PID, 0, 0x3ff) },
320 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2202_1_PID, 0, 0x3ff) },
321 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2202_2_PID, 0, 0x3ff) },
322 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2203_1_PID, 0, 0x3ff) },
323 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2203_2_PID, 0, 0x3ff) },
324 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_1_PID, 0, 0x3ff) },
325 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_2_PID, 0, 0x3ff) },
326 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_3_PID, 0, 0x3ff) },
327 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_4_PID, 0, 0x3ff) },
328 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_1_PID, 0, 0x3ff) },
329 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_2_PID, 0, 0x3ff) },
330 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_3_PID, 0, 0x3ff) },
331 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_4_PID, 0, 0x3ff) },
332 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_1_PID, 0, 0x3ff) },
333 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_2_PID, 0, 0x3ff) },
334 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_3_PID, 0, 0x3ff) },
335 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_4_PID, 0, 0x3ff) },
336 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_1_PID, 0, 0x3ff) },
337 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_2_PID, 0, 0x3ff) },
338 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_3_PID, 0, 0x3ff) },
339 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_4_PID, 0, 0x3ff) },
340 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_5_PID, 0, 0x3ff) },
341 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_6_PID, 0, 0x3ff) },
342 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_7_PID, 0, 0x3ff) },
343 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_8_PID, 0, 0x3ff) },
344 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_1_PID, 0, 0x3ff) },
345 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_2_PID, 0, 0x3ff) },
346 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_3_PID, 0, 0x3ff) },
347 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_4_PID, 0, 0x3ff) },
348 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_5_PID, 0, 0x3ff) },
349 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_6_PID, 0, 0x3ff) },
350 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_7_PID, 0, 0x3ff) },
351 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_8_PID, 0, 0x3ff) },
352 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_1_PID, 0, 0x3ff) },
353 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_2_PID, 0, 0x3ff) },
354 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_3_PID, 0, 0x3ff) },
355 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_4_PID, 0, 0x3ff) },
356 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_5_PID, 0, 0x3ff) },
357 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_6_PID, 0, 0x3ff) },
358 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_7_PID, 0, 0x3ff) },
359 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_8_PID, 0, 0x3ff) },
360 { USB_DEVICE_VER(IDTECH_VID, IDTECH_IDT1221U_PID, 0, 0x3ff) },
361 { USB_DEVICE_VER(OCT_VID, OCT_US101_PID, 0, 0x3ff) },
362 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_1, 0, 0x3ff) },
363 { USB_DEVICE_VER(FTDI_VID, PROTEGO_R2X0, 0, 0x3ff) },
364 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_3, 0, 0x3ff) },
365 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_4, 0, 0x3ff) },
366 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0, 0x3ff) },
367 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UM100_PID, 0, 0x3ff) },
368 { USB_DEVICE_VER(FTDI_VID, INSIDE_ACCESSO, 0, 0x3ff) },
369 { USB_DEVICE_VER(INTREPID_VID, INTREPID_VALUECAN_PID, 0, 0x3ff) },
370 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) },
371 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0, 0x3ff) },
372 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0, 0x3ff) },
373 { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0, 0x3ff) },
374 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0, 0x3ff) },
375 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0, 0x3ff) },
376 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0, 0x3ff) },
377 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0, 0x3ff) },
378 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0, 0x3ff) },
379 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0, 0x3ff) },
380 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0, 0x3ff) },
381 { } /* Terminating entry */
382};
383
384
385static struct usb_device_id id_table_FT232BM [] = {
386 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0x400, 0xffff) },
387 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0x400, 0xffff) },
388 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0x400, 0xffff) },
389 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0x400, 0xffff) },
390 { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0x400, 0xffff) },
391 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0x400, 0xffff) },
392 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_634_PID, 0x400, 0xffff) },
393 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_547_PID, 0x400, 0xffff) },
394 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_633_PID, 0x400, 0xffff) },
395 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_631_PID, 0x400, 0xffff) },
396 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_635_PID, 0x400, 0xffff) },
397 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_640_PID, 0x400, 0xffff) },
398 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_642_PID, 0x400, 0xffff) },
399 { USB_DEVICE_VER(FTDI_VID, FTDI_VNHCPCUSB_D_PID, 0x400, 0xffff) },
400 { USB_DEVICE_VER(FTDI_VID, FTDI_DSS20_PID, 0x400, 0xffff) },
401 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_0_PID, 0x400, 0xffff) },
402 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_1_PID, 0x400, 0xffff) },
403 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_2_PID, 0x400, 0xffff) },
404 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_3_PID, 0x400, 0xffff) },
405 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_4_PID, 0x400, 0xffff) },
406 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_5_PID, 0x400, 0xffff) },
407 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_6_PID, 0x400, 0xffff) },
408 { USB_DEVICE_VER(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID, 0x400, 0xffff) },
409 { USB_DEVICE_VER(FTDI_VID, FTDI_PIEGROUP_PID, 0x400, 0xffff) },
410 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2101_PID, 0x400, 0xffff) },
411 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2102_PID, 0x400, 0xffff) },
412 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2103_PID, 0x400, 0xffff) },
413 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2104_PID, 0x400, 0xffff) },
414 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2201_1_PID, 0x400, 0xffff) },
415 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2201_2_PID, 0x400, 0xffff) },
416 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2202_1_PID, 0x400, 0xffff) },
417 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2202_2_PID, 0x400, 0xffff) },
418 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2203_1_PID, 0x400, 0xffff) },
419 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2203_2_PID, 0x400, 0xffff) },
420 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_1_PID, 0x400, 0xffff) },
421 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_2_PID, 0x400, 0xffff) },
422 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_3_PID, 0x400, 0xffff) },
423 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_4_PID, 0x400, 0xffff) },
424 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_1_PID, 0x400, 0xffff) },
425 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_2_PID, 0x400, 0xffff) },
426 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_3_PID, 0x400, 0xffff) },
427 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_4_PID, 0x400, 0xffff) },
428 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_1_PID, 0x400, 0xffff) },
429 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_2_PID, 0x400, 0xffff) },
430 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_3_PID, 0x400, 0xffff) },
431 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_4_PID, 0x400, 0xffff) },
432 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_1_PID, 0x400, 0xffff) },
433 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_2_PID, 0x400, 0xffff) },
434 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_3_PID, 0x400, 0xffff) },
435 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_4_PID, 0x400, 0xffff) },
436 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_5_PID, 0x400, 0xffff) },
437 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_6_PID, 0x400, 0xffff) },
438 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_7_PID, 0x400, 0xffff) },
439 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_8_PID, 0x400, 0xffff) },
440 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_1_PID, 0x400, 0xffff) },
441 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_2_PID, 0x400, 0xffff) },
442 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_3_PID, 0x400, 0xffff) },
443 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_4_PID, 0x400, 0xffff) },
444 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_5_PID, 0x400, 0xffff) },
445 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_6_PID, 0x400, 0xffff) },
446 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_7_PID, 0x400, 0xffff) },
447 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_8_PID, 0x400, 0xffff) },
448 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_1_PID, 0x400, 0xffff) },
449 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_2_PID, 0x400, 0xffff) },
450 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_3_PID, 0x400, 0xffff) },
451 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_4_PID, 0x400, 0xffff) },
452 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_5_PID, 0x400, 0xffff) },
453 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_6_PID, 0x400, 0xffff) },
454 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_7_PID, 0x400, 0xffff) },
455 { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_8_PID, 0x400, 0xffff) },
456 { USB_DEVICE_VER(IDTECH_VID, IDTECH_IDT1221U_PID, 0x400, 0xffff) },
457 { USB_DEVICE_VER(OCT_VID, OCT_US101_PID, 0x400, 0xffff) },
458 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_1, 0x400, 0xffff) },
459 { USB_DEVICE_VER(FTDI_VID, PROTEGO_R2X0, 0x400, 0xffff) },
460 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_3, 0x400, 0xffff) },
461 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_4, 0x400, 0xffff) },
462 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E808_PID, 0x400, 0xffff) },
463 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E809_PID, 0x400, 0xffff) },
464 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80A_PID, 0x400, 0xffff) },
465 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80B_PID, 0x400, 0xffff) },
466 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80C_PID, 0x400, 0xffff) },
467 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80D_PID, 0x400, 0xffff) },
468 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80E_PID, 0x400, 0xffff) },
469 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80F_PID, 0x400, 0xffff) },
470 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E888_PID, 0x400, 0xffff) },
471 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E889_PID, 0x400, 0xffff) },
472 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88A_PID, 0x400, 0xffff) },
473 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88B_PID, 0x400, 0xffff) },
474 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88C_PID, 0x400, 0xffff) },
475 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88D_PID, 0x400, 0xffff) },
476 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) },
477 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) },
478 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0x400, 0xffff) },
479 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UM100_PID, 0x400, 0xffff) },
480 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) },
481 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) },
482 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) },
483 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_1_PID, 0x400, 0xffff) },
484 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_2_PID, 0x400, 0xffff) },
485 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
486 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
487 { USB_DEVICE_VER(FTDI_VID, INSIDE_ACCESSO, 0x400, 0xffff) },
488 { USB_DEVICE_VER(INTREPID_VID, INTREPID_VALUECAN_PID, 0x400, 0xffff) },
489 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0x400, 0xffff) },
490 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0x400, 0xffff) },
491 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0x400, 0xffff) },
492 { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0x400, 0xffff) },
493 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0x400, 0xffff) },
494 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0x400, 0xffff) },
495 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0x400, 0xffff) },
496 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0x400, 0xffff) },
497 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0x400, 0xffff) },
498 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0x400, 0xffff) },
499 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0x400, 0xffff) },
500 { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) },
501 { } /* Terminating entry */
502};
503
504
505static struct usb_device_id id_table_USB_UIRT [] = {
506 { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID) },
507 { } /* Terminating entry */
508};
509
510
511static struct usb_device_id id_table_HE_TIRA1 [] = {
512 { USB_DEVICE_VER(FTDI_VID, FTDI_HE_TIRA1_PID, 0x400, 0xffff) },
513 { } /* Terminating entry */
514};
515
516
517static struct usb_device_id id_table_FT2232C[] = {
518 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
519 { } /* Terminating entry */
520};
521
522 306
523static struct usb_device_id id_table_combined [] = { 307static struct usb_device_id id_table_combined [] = {
524 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, 308 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
@@ -540,14 +324,14 @@ static struct usb_device_id id_table_combined [] = {
540 { USB_DEVICE(FTDI_VID, FTDI_DSS20_PID) }, 324 { USB_DEVICE(FTDI_VID, FTDI_DSS20_PID) },
541 { USB_DEVICE(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID) }, 325 { USB_DEVICE(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID) },
542 { USB_DEVICE(FTDI_VID, FTDI_VNHCPCUSB_D_PID) }, 326 { USB_DEVICE(FTDI_VID, FTDI_VNHCPCUSB_D_PID) },
543 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_0_PID, 0x400, 0xffff) }, 327 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_0_PID) },
544 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_1_PID, 0x400, 0xffff) }, 328 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_1_PID) },
545 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_2_PID, 0x400, 0xffff) }, 329 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_2_PID) },
546 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_3_PID, 0x400, 0xffff) }, 330 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_3_PID) },
547 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_4_PID, 0x400, 0xffff) }, 331 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) },
548 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_5_PID, 0x400, 0xffff) }, 332 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
549 { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_6_PID, 0x400, 0xffff) }, 333 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
550 { USB_DEVICE_VER(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID, 0x400, 0xffff) }, 334 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
551 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) }, 335 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
552 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) }, 336 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) },
553 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) }, 337 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) },
@@ -597,35 +381,37 @@ static struct usb_device_id id_table_combined [] = {
597 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) }, 381 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) },
598 { USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) }, 382 { USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) },
599 { USB_DEVICE(OCT_VID, OCT_US101_PID) }, 383 { USB_DEVICE(OCT_VID, OCT_US101_PID) },
600 { USB_DEVICE_VER(FTDI_VID, FTDI_HE_TIRA1_PID, 0x400, 0xffff) }, 384 { USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),
601 { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID) }, 385 .driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },
386 { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),
387 .driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },
602 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) }, 388 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },
603 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) }, 389 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
604 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) }, 390 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
605 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) }, 391 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) },
606 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E808_PID, 0x400, 0xffff) }, 392 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E808_PID) },
607 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E809_PID, 0x400, 0xffff) }, 393 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E809_PID) },
608 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80A_PID, 0x400, 0xffff) }, 394 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80A_PID) },
609 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80B_PID, 0x400, 0xffff) }, 395 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80B_PID) },
610 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80C_PID, 0x400, 0xffff) }, 396 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80C_PID) },
611 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80D_PID, 0x400, 0xffff) }, 397 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80D_PID) },
612 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80E_PID, 0x400, 0xffff) }, 398 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80E_PID) },
613 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80F_PID, 0x400, 0xffff) }, 399 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80F_PID) },
614 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E888_PID, 0x400, 0xffff) }, 400 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E888_PID) },
615 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E889_PID, 0x400, 0xffff) }, 401 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E889_PID) },
616 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88A_PID, 0x400, 0xffff) }, 402 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88A_PID) },
617 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88B_PID, 0x400, 0xffff) }, 403 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88B_PID) },
618 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88C_PID, 0x400, 0xffff) }, 404 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88C_PID) },
619 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88D_PID, 0x400, 0xffff) }, 405 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88D_PID) },
620 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) }, 406 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88E_PID) },
621 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) }, 407 { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88F_PID) },
622 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) }, 408 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) },
623 { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) }, 409 { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) },
624 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, 410 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
625 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, 411 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
626 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) }, 412 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
627 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_1_PID, 0x400, 0xffff) }, 413 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) },
628 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_2_PID, 0x400, 0xffff) }, 414 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) },
629 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) }, 415 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
630 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) }, 416 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
631 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) }, 417 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
@@ -642,7 +428,7 @@ static struct usb_device_id id_table_combined [] = {
642 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) }, 428 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) },
643 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) }, 429 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) },
644 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) }, 430 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
645 { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) }, 431 { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) },
646 { } /* Terminating entry */ 432 { } /* Terminating entry */
647}; 433};
648 434
@@ -705,12 +491,8 @@ struct ftdi_private {
705 ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP ) 491 ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP )
706 492
707/* function prototypes for a FTDI serial converter */ 493/* function prototypes for a FTDI serial converter */
708static int ftdi_SIO_startup (struct usb_serial *serial); 494static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id);
709static int ftdi_8U232AM_startup (struct usb_serial *serial); 495static int ftdi_sio_attach (struct usb_serial *serial);
710static int ftdi_FT232BM_startup (struct usb_serial *serial);
711static int ftdi_FT2232C_startup (struct usb_serial *serial);
712static int ftdi_USB_UIRT_startup (struct usb_serial *serial);
713static int ftdi_HE_TIRA1_startup (struct usb_serial *serial);
714static void ftdi_shutdown (struct usb_serial *serial); 496static void ftdi_shutdown (struct usb_serial *serial);
715static int ftdi_open (struct usb_serial_port *port, struct file *filp); 497static int ftdi_open (struct usb_serial_port *port, struct file *filp);
716static void ftdi_close (struct usb_serial_port *port, struct file *filp); 498static void ftdi_close (struct usb_serial_port *port, struct file *filp);
@@ -733,14 +515,16 @@ static unsigned short int ftdi_232am_baud_to_divisor (int baud);
733static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base); 515static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base);
734static __u32 ftdi_232bm_baud_to_divisor (int baud); 516static __u32 ftdi_232bm_baud_to_divisor (int baud);
735 517
736static struct usb_serial_device_type ftdi_SIO_device = { 518static struct usb_serial_device_type ftdi_sio_device = {
737 .owner = THIS_MODULE, 519 .owner = THIS_MODULE,
738 .name = "FTDI SIO", 520 .name = "FTDI USB Serial Device",
739 .id_table = id_table_sio, 521 .short_name = "ftdi_sio",
522 .id_table = id_table_combined,
740 .num_interrupt_in = 0, 523 .num_interrupt_in = 0,
741 .num_bulk_in = 1, 524 .num_bulk_in = 1,
742 .num_bulk_out = 1, 525 .num_bulk_out = 1,
743 .num_ports = 1, 526 .num_ports = 1,
527 .probe = ftdi_sio_probe,
744 .open = ftdi_open, 528 .open = ftdi_open,
745 .close = ftdi_close, 529 .close = ftdi_close,
746 .throttle = ftdi_throttle, 530 .throttle = ftdi_throttle,
@@ -755,143 +539,10 @@ static struct usb_serial_device_type ftdi_SIO_device = {
755 .ioctl = ftdi_ioctl, 539 .ioctl = ftdi_ioctl,
756 .set_termios = ftdi_set_termios, 540 .set_termios = ftdi_set_termios,
757 .break_ctl = ftdi_break_ctl, 541 .break_ctl = ftdi_break_ctl,
758 .attach = ftdi_SIO_startup, 542 .attach = ftdi_sio_attach,
759 .shutdown = ftdi_shutdown, 543 .shutdown = ftdi_shutdown,
760}; 544};
761 545
762static struct usb_serial_device_type ftdi_8U232AM_device = {
763 .owner = THIS_MODULE,
764 .name = "FTDI 8U232AM Compatible",
765 .id_table = id_table_8U232AM,
766 .num_interrupt_in = 0,
767 .num_bulk_in = 1,
768 .num_bulk_out = 1,
769 .num_ports = 1,
770 .open = ftdi_open,
771 .close = ftdi_close,
772 .throttle = ftdi_throttle,
773 .unthrottle = ftdi_unthrottle,
774 .write = ftdi_write,
775 .write_room = ftdi_write_room,
776 .chars_in_buffer = ftdi_chars_in_buffer,
777 .read_bulk_callback = ftdi_read_bulk_callback,
778 .write_bulk_callback = ftdi_write_bulk_callback,
779 .tiocmget = ftdi_tiocmget,
780 .tiocmset = ftdi_tiocmset,
781 .ioctl = ftdi_ioctl,
782 .set_termios = ftdi_set_termios,
783 .break_ctl = ftdi_break_ctl,
784 .attach = ftdi_8U232AM_startup,
785 .shutdown = ftdi_shutdown,
786};
787
788static struct usb_serial_device_type ftdi_FT232BM_device = {
789 .owner = THIS_MODULE,
790 .name = "FTDI FT232BM Compatible",
791 .id_table = id_table_FT232BM,
792 .num_interrupt_in = 0,
793 .num_bulk_in = 1,
794 .num_bulk_out = 1,
795 .num_ports = 1,
796 .open = ftdi_open,
797 .close = ftdi_close,
798 .throttle = ftdi_throttle,
799 .unthrottle = ftdi_unthrottle,
800 .write = ftdi_write,
801 .write_room = ftdi_write_room,
802 .chars_in_buffer = ftdi_chars_in_buffer,
803 .read_bulk_callback = ftdi_read_bulk_callback,
804 .write_bulk_callback = ftdi_write_bulk_callback,
805 .tiocmget = ftdi_tiocmget,
806 .tiocmset = ftdi_tiocmset,
807 .ioctl = ftdi_ioctl,
808 .set_termios = ftdi_set_termios,
809 .break_ctl = ftdi_break_ctl,
810 .attach = ftdi_FT232BM_startup,
811 .shutdown = ftdi_shutdown,
812};
813
814static struct usb_serial_device_type ftdi_FT2232C_device = {
815 .owner = THIS_MODULE,
816 .name = "FTDI FT2232C Compatible",
817 .id_table = id_table_FT2232C,
818 .num_interrupt_in = 0,
819 .num_bulk_in = 1,
820 .num_bulk_out = 1,
821 .num_ports = 1,
822 .open = ftdi_open,
823 .close = ftdi_close,
824 .throttle = ftdi_throttle,
825 .unthrottle = ftdi_unthrottle,
826 .write = ftdi_write,
827 .write_room = ftdi_write_room,
828 .chars_in_buffer = ftdi_chars_in_buffer,
829 .read_bulk_callback = ftdi_read_bulk_callback,
830 .write_bulk_callback = ftdi_write_bulk_callback,
831 .tiocmget = ftdi_tiocmget,
832 .tiocmset = ftdi_tiocmset,
833 .ioctl = ftdi_ioctl,
834 .set_termios = ftdi_set_termios,
835 .break_ctl = ftdi_break_ctl,
836 .attach = ftdi_FT2232C_startup,
837 .shutdown = ftdi_shutdown,
838};
839
840static struct usb_serial_device_type ftdi_USB_UIRT_device = {
841 .owner = THIS_MODULE,
842 .name = "USB-UIRT Infrared Tranceiver",
843 .id_table = id_table_USB_UIRT,
844 .num_interrupt_in = 0,
845 .num_bulk_in = 1,
846 .num_bulk_out = 1,
847 .num_ports = 1,
848 .open = ftdi_open,
849 .close = ftdi_close,
850 .throttle = ftdi_throttle,
851 .unthrottle = ftdi_unthrottle,
852 .write = ftdi_write,
853 .write_room = ftdi_write_room,
854 .chars_in_buffer = ftdi_chars_in_buffer,
855 .read_bulk_callback = ftdi_read_bulk_callback,
856 .write_bulk_callback = ftdi_write_bulk_callback,
857 .tiocmget = ftdi_tiocmget,
858 .tiocmset = ftdi_tiocmset,
859 .ioctl = ftdi_ioctl,
860 .set_termios = ftdi_set_termios,
861 .break_ctl = ftdi_break_ctl,
862 .attach = ftdi_USB_UIRT_startup,
863 .shutdown = ftdi_shutdown,
864};
865
866/* The TIRA1 is based on a FT232BM which requires a fixed baud rate of 100000
867 * and which requires RTS-CTS to be enabled. */
868static struct usb_serial_device_type ftdi_HE_TIRA1_device = {
869 .owner = THIS_MODULE,
870 .name = "Home-Electronics TIRA-1 IR Transceiver",
871 .id_table = id_table_HE_TIRA1,
872 .num_interrupt_in = 0,
873 .num_bulk_in = 1,
874 .num_bulk_out = 1,
875 .num_ports = 1,
876 .open = ftdi_open,
877 .close = ftdi_close,
878 .throttle = ftdi_throttle,
879 .unthrottle = ftdi_unthrottle,
880 .write = ftdi_write,
881 .write_room = ftdi_write_room,
882 .chars_in_buffer = ftdi_chars_in_buffer,
883 .read_bulk_callback = ftdi_read_bulk_callback,
884 .write_bulk_callback = ftdi_write_bulk_callback,
885 .tiocmget = ftdi_tiocmget,
886 .tiocmset = ftdi_tiocmset,
887 .ioctl = ftdi_ioctl,
888 .set_termios = ftdi_set_termios,
889 .break_ctl = ftdi_break_ctl,
890 .attach = ftdi_HE_TIRA1_startup,
891 .shutdown = ftdi_shutdown,
892};
893
894
895 546
896#define WDR_TIMEOUT 5000 /* default urb timeout */ 547#define WDR_TIMEOUT 5000 /* default urb timeout */
897 548
@@ -1212,6 +863,59 @@ check_and_exit:
1212} /* set_serial_info */ 863} /* set_serial_info */
1213 864
1214 865
866/* Determine type of FTDI chip based on USB config and descriptor. */
867static void ftdi_determine_type(struct usb_serial_port *port)
868{
869 struct ftdi_private *priv = usb_get_serial_port_data(port);
870 struct usb_serial *serial = port->serial;
871 struct usb_device *udev = serial->dev;
872 unsigned version;
873 unsigned interfaces;
874
875 /* Assume it is not the original SIO device for now. */
876 priv->baud_base = 48000000 / 16;
877 priv->write_offset = 0;
878
879 version = le16_to_cpu(udev->descriptor.bcdDevice);
880 interfaces = udev->actconfig->desc.bNumInterfaces;
881 dbg("%s: bcdDevice = 0x%x, bNumInterfaces = %u", __FUNCTION__,
882 version, interfaces);
883 if (interfaces > 1) {
884 int inter;
885
886 /* Multiple interfaces. Assume FT2232C. */
887 priv->chip_type = FT2232C;
888 /* Determine interface code. */
889 inter = serial->interface->altsetting->desc.bInterfaceNumber;
890 if (inter == 0) {
891 priv->interface = PIT_SIOA;
892 } else {
893 priv->interface = PIT_SIOB;
894 }
895 /* BM-type devices have a bug where bcdDevice gets set
896 * to 0x200 when iSerialNumber is 0. */
897 if (version < 0x500) {
898 dbg("%s: something fishy - bcdDevice too low for multi-interface device",
899 __FUNCTION__);
900 }
901 } else if (version < 0x200) {
902 /* Old device. Assume its the original SIO. */
903 priv->chip_type = SIO;
904 priv->baud_base = 12000000 / 16;
905 priv->write_offset = 1;
906 } else if (version < 0x400) {
907 /* Assume its an FT8U232AM (or FT8U245AM) */
908 /* (It might be a BM because of the iSerialNumber bug,
909 * but it will still work as an AM device.) */
910 priv->chip_type = FT8U232AM;
911 } else {
912 /* Assume its an FT232BM (or FT245BM) */
913 priv->chip_type = FT232BM;
914 }
915 info("Detected %s", ftdi_chip_name[priv->chip_type]);
916}
917
918
1215/* 919/*
1216 * *************************************************************************** 920 * ***************************************************************************
1217 * Sysfs Attribute 921 * Sysfs Attribute
@@ -1355,12 +1059,20 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
1355 * *************************************************************************** 1059 * ***************************************************************************
1356 */ 1060 */
1357 1061
1358/* Common startup subroutine */ 1062/* Probe function to check for special devices */
1359/* Called from ftdi_SIO_startup, etc. */ 1063static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id)
1360static int ftdi_common_startup (struct usb_serial *serial) 1064{
1065 usb_set_serial_data(serial, (void *)id->driver_info);
1066
1067 return (0);
1068}
1069
1070/* attach subroutine */
1071static int ftdi_sio_attach (struct usb_serial *serial)
1361{ 1072{
1362 struct usb_serial_port *port = serial->port[0]; 1073 struct usb_serial_port *port = serial->port[0];
1363 struct ftdi_private *priv; 1074 struct ftdi_private *priv;
1075 struct ftdi_sio_quirk *quirk;
1364 1076
1365 dbg("%s",__FUNCTION__); 1077 dbg("%s",__FUNCTION__);
1366 1078
@@ -1400,150 +1112,49 @@ static int ftdi_common_startup (struct usb_serial *serial)
1400 port->bulk_out_buffer = NULL; 1112 port->bulk_out_buffer = NULL;
1401 1113
1402 usb_set_serial_port_data(serial->port[0], priv); 1114 usb_set_serial_port_data(serial->port[0], priv);
1403
1404 return (0);
1405}
1406
1407
1408/* Startup for the SIO chip */
1409/* Called from usbserial:serial_probe */
1410static int ftdi_SIO_startup (struct usb_serial *serial)
1411{
1412 struct ftdi_private *priv;
1413 int err;
1414
1415 dbg("%s",__FUNCTION__);
1416
1417 err = ftdi_common_startup(serial);
1418 if (err){
1419 return (err);
1420 }
1421
1422 priv = usb_get_serial_port_data(serial->port[0]);
1423 priv->chip_type = SIO;
1424 priv->baud_base = 12000000 / 16;
1425 priv->write_offset = 1;
1426
1427 return (0);
1428}
1429
1430/* Startup for the 8U232AM chip */
1431/* Called from usbserial:serial_probe */
1432static int ftdi_8U232AM_startup (struct usb_serial *serial)
1433{ /* ftdi_8U232AM_startup */
1434 struct ftdi_private *priv;
1435 int err;
1436
1437 dbg("%s",__FUNCTION__);
1438 err = ftdi_common_startup(serial);
1439 if (err){
1440 return (err);
1441 }
1442 1115
1443 priv = usb_get_serial_port_data(serial->port[0]); 1116 ftdi_determine_type (serial->port[0]);
1444 priv->chip_type = FT8U232AM;
1445 priv->baud_base = 48000000 / 2; /* Would be / 16, but FTDI supports 0.125, 0.25 and 0.5 divisor fractions! */
1446
1447 create_sysfs_attrs(serial); 1117 create_sysfs_attrs(serial);
1448
1449 return (0);
1450} /* ftdi_8U232AM_startup */
1451 1118
1452/* Startup for the FT232BM chip */ 1119 /* Check for device requiring special set up. */
1453/* Called from usbserial:serial_probe */ 1120 quirk = (struct ftdi_sio_quirk *)usb_get_serial_data(serial);
1454static int ftdi_FT232BM_startup (struct usb_serial *serial) 1121 if (quirk && quirk->setup) {
1455{ /* ftdi_FT232BM_startup */ 1122 quirk->setup(serial);
1456 struct ftdi_private *priv;
1457 int err;
1458
1459 dbg("%s",__FUNCTION__);
1460 err = ftdi_common_startup(serial);
1461 if (err){
1462 return (err);
1463 } 1123 }
1464
1465 priv = usb_get_serial_port_data(serial->port[0]);
1466 priv->chip_type = FT232BM;
1467 priv->baud_base = 48000000 / 2; /* Would be / 16, but FT232BM supports multiple of 0.125 divisor fractions! */
1468 1124
1469 create_sysfs_attrs(serial);
1470
1471 return (0); 1125 return (0);
1472} /* ftdi_FT232BM_startup */ 1126} /* ftdi_sio_attach */
1473
1474/* Startup for the FT2232C chip */
1475/* Called from usbserial:serial_probe */
1476static int ftdi_FT2232C_startup (struct usb_serial *serial)
1477{ /* ftdi_FT2232C_startup */
1478 struct ftdi_private *priv;
1479 int err;
1480 int inter;
1481
1482 dbg("%s",__FUNCTION__);
1483 err = ftdi_common_startup(serial);
1484 if (err){
1485 return (err);
1486 }
1487 1127
1488 priv = usb_get_serial_port_data(serial->port[0]);
1489 priv->chip_type = FT2232C;
1490 inter = serial->interface->altsetting->desc.bInterfaceNumber;
1491 1128
1492 if (inter) { 1129/* Setup for the USB-UIRT device, which requires hardwired
1493 priv->interface = PIT_SIOB; 1130 * baudrate (38400 gets mapped to 312500) */
1494 }
1495 else {
1496 priv->interface = PIT_SIOA;
1497 }
1498 priv->baud_base = 48000000 / 2; /* Would be / 16, but FT2232C supports multiple of 0.125 divisor fractions! */
1499
1500 create_sysfs_attrs(serial);
1501
1502 return (0);
1503} /* ftdi_FT2232C_startup */
1504
1505/* Startup for the USB-UIRT device, which requires hardwired baudrate (38400 gets mapped to 312500) */
1506/* Called from usbserial:serial_probe */ 1131/* Called from usbserial:serial_probe */
1507static int ftdi_USB_UIRT_startup (struct usb_serial *serial) 1132static void ftdi_USB_UIRT_setup (struct usb_serial *serial)
1508{ /* ftdi_USB_UIRT_startup */ 1133{
1509 struct ftdi_private *priv; 1134 struct ftdi_private *priv;
1510 int err;
1511 1135
1512 dbg("%s",__FUNCTION__); 1136 dbg("%s",__FUNCTION__);
1513 err = ftdi_8U232AM_startup(serial);
1514 if (err){
1515 return (err);
1516 }
1517 1137
1518 priv = usb_get_serial_port_data(serial->port[0]); 1138 priv = usb_get_serial_port_data(serial->port[0]);
1519 priv->flags |= ASYNC_SPD_CUST; 1139 priv->flags |= ASYNC_SPD_CUST;
1520 priv->custom_divisor = 77; 1140 priv->custom_divisor = 77;
1521 priv->force_baud = B38400; 1141 priv->force_baud = B38400;
1522 1142} /* ftdi_USB_UIRT_setup */
1523 return (0);
1524} /* ftdi_USB_UIRT_startup */
1525 1143
1526/* Startup for the HE-TIRA1 device, which requires hardwired 1144/* Setup for the HE-TIRA1 device, which requires hardwired
1527 * baudrate (38400 gets mapped to 100000) */ 1145 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */
1528static int ftdi_HE_TIRA1_startup (struct usb_serial *serial) 1146static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1529{ /* ftdi_HE_TIRA1_startup */ 1147{
1530 struct ftdi_private *priv; 1148 struct ftdi_private *priv;
1531 int err;
1532 1149
1533 dbg("%s",__FUNCTION__); 1150 dbg("%s",__FUNCTION__);
1534 err = ftdi_FT232BM_startup(serial);
1535 if (err){
1536 return (err);
1537 }
1538 1151
1539 priv = usb_get_serial_port_data(serial->port[0]); 1152 priv = usb_get_serial_port_data(serial->port[0]);
1540 priv->flags |= ASYNC_SPD_CUST; 1153 priv->flags |= ASYNC_SPD_CUST;
1541 priv->custom_divisor = 240; 1154 priv->custom_divisor = 240;
1542 priv->force_baud = B38400; 1155 priv->force_baud = B38400;
1543 priv->force_rtscts = 1; 1156 priv->force_rtscts = 1;
1544 1157} /* ftdi_HE_TIRA1_setup */
1545 return (0);
1546} /* ftdi_HE_TIRA1_startup */
1547 1158
1548 1159
1549/* ftdi_shutdown is called from usbserial:usb_serial_disconnect 1160/* ftdi_shutdown is called from usbserial:usb_serial_disconnect
@@ -2367,60 +1978,11 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
2367{ 1978{
2368 struct ftdi_private *priv = usb_get_serial_port_data(port); 1979 struct ftdi_private *priv = usb_get_serial_port_data(port);
2369 1980
2370 int ret, mask;
2371
2372 dbg("%s cmd 0x%04x", __FUNCTION__, cmd); 1981 dbg("%s cmd 0x%04x", __FUNCTION__, cmd);
2373 1982
2374 /* Based on code from acm.c and others */ 1983 /* Based on code from acm.c and others */
2375 switch (cmd) { 1984 switch (cmd) {
2376 1985
2377 case TIOCMBIS: /* turns on (Sets) the lines as specified by the mask */
2378 dbg("%s TIOCMBIS", __FUNCTION__);
2379 if (get_user(mask, (unsigned long __user *) arg))
2380 return -EFAULT;
2381 if (mask & TIOCM_DTR){
2382 if ((ret = set_dtr(port, HIGH)) < 0) {
2383 err("Urb to set DTR failed");
2384 return(ret);
2385 }
2386 }
2387 if (mask & TIOCM_RTS) {
2388 if ((ret = set_rts(port, HIGH)) < 0){
2389 err("Urb to set RTS failed");
2390 return(ret);
2391 }
2392 }
2393 return(0);
2394 break;
2395
2396 case TIOCMBIC: /* turns off (Clears) the lines as specified by the mask */
2397 dbg("%s TIOCMBIC", __FUNCTION__);
2398 if (get_user(mask, (unsigned long __user *) arg))
2399 return -EFAULT;
2400 if (mask & TIOCM_DTR){
2401 if ((ret = set_dtr(port, LOW)) < 0){
2402 err("Urb to unset DTR failed");
2403 return(ret);
2404 }
2405 }
2406 if (mask & TIOCM_RTS) {
2407 if ((ret = set_rts(port, LOW)) < 0){
2408 err("Urb to unset RTS failed");
2409 return(ret);
2410 }
2411 }
2412 return(0);
2413 break;
2414
2415 /*
2416 * I had originally implemented TCSET{A,S}{,F,W} and
2417 * TCGET{A,S} here separately, however when testing I
2418 * found that the higher layers actually do the termios
2419 * conversions themselves and pass the call onto
2420 * ftdi_sio_set_termios.
2421 *
2422 */
2423
2424 case TIOCGSERIAL: /* gets serial port data */ 1986 case TIOCGSERIAL: /* gets serial port data */
2425 return get_serial_info(port, (struct serial_struct __user *) arg); 1987 return get_serial_info(port, (struct serial_struct __user *) arg);
2426 1988
@@ -2516,24 +2078,9 @@ static int __init ftdi_init (void)
2516 int retval; 2078 int retval;
2517 2079
2518 dbg("%s", __FUNCTION__); 2080 dbg("%s", __FUNCTION__);
2519 retval = usb_serial_register(&ftdi_SIO_device); 2081 retval = usb_serial_register(&ftdi_sio_device);
2520 if (retval)
2521 goto failed_SIO_register;
2522 retval = usb_serial_register(&ftdi_8U232AM_device);
2523 if (retval)
2524 goto failed_8U232AM_register;
2525 retval = usb_serial_register(&ftdi_FT232BM_device);
2526 if (retval)
2527 goto failed_FT232BM_register;
2528 retval = usb_serial_register(&ftdi_FT2232C_device);
2529 if (retval)
2530 goto failed_FT2232C_register;
2531 retval = usb_serial_register(&ftdi_USB_UIRT_device);
2532 if (retval)
2533 goto failed_USB_UIRT_register;
2534 retval = usb_serial_register(&ftdi_HE_TIRA1_device);
2535 if (retval) 2082 if (retval)
2536 goto failed_HE_TIRA1_register; 2083 goto failed_sio_register;
2537 retval = usb_register(&ftdi_driver); 2084 retval = usb_register(&ftdi_driver);
2538 if (retval) 2085 if (retval)
2539 goto failed_usb_register; 2086 goto failed_usb_register;
@@ -2541,18 +2088,8 @@ static int __init ftdi_init (void)
2541 info(DRIVER_VERSION ":" DRIVER_DESC); 2088 info(DRIVER_VERSION ":" DRIVER_DESC);
2542 return 0; 2089 return 0;
2543failed_usb_register: 2090failed_usb_register:
2544 usb_serial_deregister(&ftdi_HE_TIRA1_device); 2091 usb_serial_deregister(&ftdi_sio_device);
2545failed_HE_TIRA1_register: 2092failed_sio_register:
2546 usb_serial_deregister(&ftdi_USB_UIRT_device);
2547failed_USB_UIRT_register:
2548 usb_serial_deregister(&ftdi_FT2232C_device);
2549failed_FT2232C_register:
2550 usb_serial_deregister(&ftdi_FT232BM_device);
2551failed_FT232BM_register:
2552 usb_serial_deregister(&ftdi_8U232AM_device);
2553failed_8U232AM_register:
2554 usb_serial_deregister(&ftdi_SIO_device);
2555failed_SIO_register:
2556 return retval; 2093 return retval;
2557} 2094}
2558 2095
@@ -2563,12 +2100,7 @@ static void __exit ftdi_exit (void)
2563 dbg("%s", __FUNCTION__); 2100 dbg("%s", __FUNCTION__);
2564 2101
2565 usb_deregister (&ftdi_driver); 2102 usb_deregister (&ftdi_driver);
2566 usb_serial_deregister (&ftdi_HE_TIRA1_device); 2103 usb_serial_deregister (&ftdi_sio_device);
2567 usb_serial_deregister (&ftdi_USB_UIRT_device);
2568 usb_serial_deregister (&ftdi_FT2232C_device);
2569 usb_serial_deregister (&ftdi_FT232BM_device);
2570 usb_serial_deregister (&ftdi_8U232AM_device);
2571 usb_serial_deregister (&ftdi_SIO_device);
2572 2104
2573} 2105}
2574 2106
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 9fcc7bd1fbe4..bd0ab3039bdd 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -697,7 +697,7 @@ UNUSUAL_DEV( 0x07af, 0x0004, 0x0100, 0x0133,
697UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100, 697UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100,
698 "Microtech", 698 "Microtech",
699 "USB-SCSI-HD50", 699 "USB-SCSI-HD50",
700 US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, 700 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init,
701 US_FL_SCM_MULT_TARG ), 701 US_FL_SCM_MULT_TARG ),
702 702
703#ifdef CONFIG_USB_STORAGE_DPCM 703#ifdef CONFIG_USB_STORAGE_DPCM
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index b209adbd508a..9dd0fbccf994 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -142,7 +142,6 @@ static int fbcon_set_origin(struct vc_data *);
142#define CURSOR_DRAW_DELAY (1) 142#define CURSOR_DRAW_DELAY (1)
143 143
144/* # VBL ints between cursor state changes */ 144/* # VBL ints between cursor state changes */
145#define ARM_CURSOR_BLINK_RATE (10)
146#define ATARI_CURSOR_BLINK_RATE (42) 145#define ATARI_CURSOR_BLINK_RATE (42)
147#define MAC_CURSOR_BLINK_RATE (32) 146#define MAC_CURSOR_BLINK_RATE (32)
148#define DEFAULT_CURSOR_BLINK_RATE (20) 147#define DEFAULT_CURSOR_BLINK_RATE (20)
@@ -288,7 +287,7 @@ static void fb_flashcursor(void *private)
288 release_console_sem(); 287 release_console_sem();
289} 288}
290 289
291#if (defined(__arm__) && defined(IRQ_VSYNCPULSE)) || defined(CONFIG_ATARI) || defined(CONFIG_MAC) 290#if defined(CONFIG_ATARI) || defined(CONFIG_MAC)
292static int cursor_blink_rate; 291static int cursor_blink_rate;
293static irqreturn_t fb_vbl_handler(int irq, void *dev_id, struct pt_regs *fp) 292static irqreturn_t fb_vbl_handler(int irq, void *dev_id, struct pt_regs *fp)
294{ 293{
@@ -878,11 +877,6 @@ static const char *fbcon_startup(void)
878 } 877 }
879#endif /* CONFIG_MAC */ 878#endif /* CONFIG_MAC */
880 879
881#if defined(__arm__) && defined(IRQ_VSYNCPULSE)
882 cursor_blink_rate = ARM_CURSOR_BLINK_RATE;
883 irqres = request_irq(IRQ_VSYNCPULSE, fb_vbl_handler, SA_SHIRQ,
884 "framebuffer vbl", info);
885#endif
886 /* Initialize the work queue. If the driver provides its 880 /* Initialize the work queue. If the driver provides its
887 * own work queue this means it will use something besides 881 * own work queue this means it will use something besides
888 * default timer to flash the cursor. */ 882 * default timer to flash the cursor. */
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 7dfbf39b4ed3..ddc9443254d9 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -256,7 +256,7 @@ static ssize_t show_cmap(struct class_device *class_device, char *buf)
256 unsigned int offset = 0, i; 256 unsigned int offset = 0, i;
257 257
258 if (!fb_info->cmap.red || !fb_info->cmap.blue || 258 if (!fb_info->cmap.red || !fb_info->cmap.blue ||
259 fb_info->cmap.green || fb_info->cmap.transp) 259 !fb_info->cmap.green || !fb_info->cmap.transp)
260 return -EINVAL; 260 return -EINVAL;
261 261
262 for (i = 0; i < fb_info->cmap.len; i++) { 262 for (i = 0; i < fb_info->cmap.len; i++) {
diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index 6ba10e3aceff..3e9ccf370ab2 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -63,5 +63,10 @@ config LOGO_SUPERH_CLUT224
63 depends on LOGO && SUPERH 63 depends on LOGO && SUPERH
64 default y 64 default y
65 65
66config LOGO_M32R_CLUT224
67 bool "224-color M32R Linux logo"
68 depends on LOGO && M32R
69 default y
70
66endmenu 71endmenu
67 72
diff --git a/drivers/video/logo/Makefile b/drivers/video/logo/Makefile
index b0d995020bd1..d0244c04af5a 100644
--- a/drivers/video/logo/Makefile
+++ b/drivers/video/logo/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_LOGO_SUN_CLUT224) += logo_sun_clut224.o
12obj-$(CONFIG_LOGO_SUPERH_MONO) += logo_superh_mono.o 12obj-$(CONFIG_LOGO_SUPERH_MONO) += logo_superh_mono.o
13obj-$(CONFIG_LOGO_SUPERH_VGA16) += logo_superh_vga16.o 13obj-$(CONFIG_LOGO_SUPERH_VGA16) += logo_superh_vga16.o
14obj-$(CONFIG_LOGO_SUPERH_CLUT224) += logo_superh_clut224.o 14obj-$(CONFIG_LOGO_SUPERH_CLUT224) += logo_superh_clut224.o
15obj-$(CONFIG_LOGO_M32R_CLUT224) += logo_m32r_clut224.o
15 16
16# How to generate logo's 17# How to generate logo's
17 18
diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
index 77b622075001..788fa812c871 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -33,6 +33,7 @@ extern const struct linux_logo logo_sun_clut224;
33extern const struct linux_logo logo_superh_mono; 33extern const struct linux_logo logo_superh_mono;
34extern const struct linux_logo logo_superh_vga16; 34extern const struct linux_logo logo_superh_vga16;
35extern const struct linux_logo logo_superh_clut224; 35extern const struct linux_logo logo_superh_clut224;
36extern const struct linux_logo logo_m32r_clut224;
36 37
37 38
38const struct linux_logo *fb_find_logo(int depth) 39const struct linux_logo *fb_find_logo(int depth)
@@ -97,6 +98,10 @@ const struct linux_logo *fb_find_logo(int depth)
97 /* SuperH Linux logo */ 98 /* SuperH Linux logo */
98 logo = &logo_superh_clut224; 99 logo = &logo_superh_clut224;
99#endif 100#endif
101#ifdef CONFIG_LOGO_M32R_CLUT224
102 /* M32R Linux logo */
103 logo = &logo_m32r_clut224;
104#endif
100 } 105 }
101 return logo; 106 return logo;
102} 107}
diff --git a/drivers/video/logo/logo_m32r_clut224.ppm b/drivers/video/logo/logo_m32r_clut224.ppm
new file mode 100644
index 000000000000..8b2983c5a0bd
--- /dev/null
+++ b/drivers/video/logo/logo_m32r_clut224.ppm
@@ -0,0 +1,1292 @@
1P3
2# CREATOR: The GIMP's PNM Filter Version 1.0
3#
4# Note: how to convert ppm to pnm(ascii).
5# $ convert -posterize 224 m32r.ppm - | pnm2asc -f5 >logo_m32r_clut224.ppm
6#
7# convert - imagemagick: /usr/bin/convert
8# pnm2asc - pnm to ascii-pnm format converter
9# http://www.is.aist.go.jp/etlcdb/util/p2a.htm#English
10
1180 80
12255
13 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
14 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
15 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
16 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
17 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
18 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
19 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
20 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
21 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
22 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
23 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
24 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
25 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
26 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
27 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
28 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
29 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
30 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
31 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
32 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
33 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
34 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
35 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
36 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
37 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
38 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
39 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
40 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
41 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
42 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
43 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
44 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
45 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
46 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
47 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
48 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
49 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
50 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
51 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
52 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
53 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
54 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
55 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
56 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
57 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
58 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
59 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
60 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
61 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
62 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
63 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
64 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
65 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
66 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
67 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
68 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
69 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
70 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
71 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
72 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
73 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
74 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
75 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
76 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
77 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
78 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
79 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
80 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
81 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
82 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
83 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
84 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
85 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
86 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
87 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
88 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
89 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
90 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
91 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
92 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
93 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
94 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
95 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
96 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
97 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
98 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
99 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
100 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
101 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
102 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
103 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
104 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
105 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
106 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
107 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
108 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
109 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
110 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
111 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
112 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
113 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
114 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
115 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
116 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
117 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
118 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
119 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
120 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
121 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
122 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
123 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
124 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
125 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
126 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
127 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
128 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
129 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
130 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
131 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
132 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
133 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
134 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
135 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
136 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
137 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
138 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
139 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
140 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
141 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
142 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
143 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
144 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
145 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
146 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
147 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
148 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
149 2 2 3 215 150 13 215 150 13 215 150 13 215 150 13
150 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
151 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
152 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
153 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
154 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
155 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
156 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
157 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
158 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
159 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
160 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
161 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
162 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
163 215 150 13 215 150 13 215 150 13 2 2 3 2 2 3
164 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
165 2 2 3 2 2 3 2 2 3 215 150 13 215 150 13
166 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
167 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
168 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
169 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
170 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
171 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
172 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
173 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
174 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
175 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
176 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
177 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
178 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
179 215 150 13 2 2 3 2 2 3 2 2 3 2 2 3
180 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
181 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
182 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
183 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
184 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
185 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
186 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
187 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
188 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
189 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
190 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
191 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
192 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
193 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
194 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
195 215 150 13 2 2 3 2 2 3 2 2 3 2 2 3
196 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
197 2 2 3 43 43 43 75 75 75 27 27 27 2 2 3
198 2 2 3 215 150 13 215 150 13 215 150 13 215 150 13
199 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
200 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
201 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
202 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
203 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
204 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
205 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
206 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
207 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
208 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
209 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
210 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
211 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
212 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
213 2 2 3 59 59 59 123 123 123 67 67 67 27 27 27
214 2 2 3 2 2 3 215 150 13 215 150 13 215 150 13
215 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
216 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
217 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
218 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
219 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
220 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
221 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
222 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
223 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
224 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
225 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
226 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
227 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
228 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
229 10 6 3 59 59 59 80 80 80 43 43 43 27 27 27
230 2 2 3 2 2 3 215 150 13 215 150 13 215 150 13
231 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
232 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
233 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
234 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
235 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
236 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
237 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
238 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
239 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
240 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
241 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
242 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
243 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
244 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
245 2 2 3 19 19 19 2 2 3 2 2 3 2 2 3
246 2 2 3 2 2 3 2 2 3 215 150 13 215 150 13
247 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
248 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
249 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
250 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
251 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
252 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
253 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
254 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
255 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
256 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
257 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
258 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
259 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
260 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
261 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
262 2 2 3 2 2 3 2 2 3 215 150 13 215 150 13
263 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
264 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
265 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
266 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
267 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
268 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
269 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
270 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
271 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
272 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
273 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
274 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
275 2 2 3 2 2 3 10 6 3 10 6 3 2 2 3
276 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
277 10 6 3 11 11 11 11 11 11 2 2 3 2 2 3
278 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
279 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
280 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
281 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
282 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
283 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
284 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
285 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
286 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
287 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
288 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
289 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
290 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
291 2 2 3 2 2 3 2 2 3 27 27 27 10 6 3
292 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
293 19 19 19 2 2 3 2 2 3 51 51 51 2 2 3
294 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
295 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
296 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
297 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
298 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
299 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
300 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
301 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
302 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
303 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
304 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
305 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
306 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
307 2 2 3 123 123 123 196 196 196 115 115 115 2 2 3
308 2 2 3 2 2 3 2 2 3 75 75 75 141 141 140
309 172 172 172 196 196 196 190 189 188 2 2 3 11 11 11
310 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
311 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
312 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
313 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
314 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
315 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
316 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
317 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
318 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
319 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
320 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
321 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
322 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
323 27 27 27 164 164 164 228 228 228 221 221 220 10 6 3
324 2 2 3 2 2 3 2 2 3 172 172 172 245 245 245
325 254 254 252 254 254 252 221 221 220 35 35 35 2 2 3
326 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
327 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
328 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
329 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
330 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
331 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
332 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
333 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
334 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
335 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
336 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
337 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
338 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
339 164 164 164 228 228 228 35 35 35 236 236 236 236 236 236
340 2 2 3 11 11 11 2 2 3 254 254 252 245 245 245
341 2 2 3 75 75 75 245 245 245 245 245 245 2 2 3
342 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
343 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
344 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
345 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
346 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
347 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
348 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
349 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
350 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
351 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
352 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
353 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
354 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
355 212 212 212 2 2 3 51 51 51 11 11 11 245 245 245
356 27 27 27 80 80 80 10 6 3 254 254 252 2 2 3
357 2 2 3 91 91 91 19 19 19 254 254 252 2 2 3
358 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
359 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
360 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
361 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
362 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
363 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
364 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
365 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
366 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
367 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
368 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
369 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
370 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
371 196 196 196 10 6 3 2 2 3 11 11 11 107 107 107
372 49 35 5 57 42 11 31 22 3 236 236 236 2 2 3
373 2 2 3 2 2 3 2 2 3 254 254 252 2 2 3
374 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
375 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
376 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
377 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
378 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
379 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
380 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
381 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
382 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
383 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
384 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
385 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
386 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
387 107 107 107 221 221 220 2 2 3 64 43 7 194 148 10
388 236 188 10 225 180 10 170 126 10 236 188 10 94 86 67
389 2 2 3 2 2 3 204 204 204 236 236 236 2 2 3
390 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
391 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
392 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
393 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
394 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
395 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
396 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
397 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
398 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
399 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
400 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
401 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
402 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
403 2 2 3 228 228 228 182 126 10 218 164 9 236 188 10
404 236 188 10 237 204 14 236 205 40 246 214 48 246 214 48
405 245 189 11 209 156 9 196 196 196 11 11 11 2 2 3
406 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
407 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
408 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
409 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
410 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
411 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
412 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
413 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
414 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
415 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
416 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
417 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
418 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
419 2 2 3 165 114 10 207 148 7 229 172 9 236 180 10
420 236 196 11 237 204 14 242 218 43 246 218 75 246 218 19
421 246 213 13 246 218 19 244 205 11 218 164 9 2 2 3
422 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
423 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
424 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
425 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
426 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
427 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
428 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
429 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
430 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
431 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
432 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
433 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
434 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
435 164 109 5 192 133 7 224 165 9 236 180 10 236 188 10
436 236 196 11 241 212 42 246 218 75 246 218 19 246 218 19
437 246 218 19 236 196 11 150 114 10 229 172 9 2 2 3
438 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
439 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
440 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
441 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
442 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
443 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
444 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
445 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
446 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
447 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
448 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
449 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
450 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
451 165 114 10 201 142 7 229 172 9 242 182 11 236 188 10
452 237 204 14 245 213 67 246 218 19 246 213 13 246 213 13
453 154 119 10 207 148 7 218 164 9 216 156 8 2 2 3
454 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
455 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
456 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
457 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
458 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
459 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
460 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
461 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
462 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
463 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
464 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
465 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
466 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
467 2 2 3 120 78 3 225 180 10 245 189 11 236 205 40
468 241 212 42 241 212 17 237 204 14 148 107 9 182 126 10
469 216 156 8 218 164 9 207 148 7 82 70 43 2 2 3
470 2 2 3 123 123 123 35 35 35 2 2 3 2 2 3
471 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
472 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
473 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
474 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
475 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
476 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
477 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
478 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
479 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
480 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
481 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
482 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
483 10 6 3 180 180 180 156 102 5 135 88 5 142 106 7
484 126 98 11 165 114 10 185 132 9 207 148 7 215 150 13
485 199 140 8 188 148 71 196 196 196 190 189 188 2 2 3
486 2 2 3 11 11 11 132 132 132 75 75 75 2 2 3
487 2 2 3 215 150 13 215 150 13 215 150 13 215 150 13
488 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
489 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
490 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
491 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
492 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
493 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
494 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
495 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
496 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
497 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
498 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
499 10 6 3 190 189 188 190 189 188 151 97 5 192 133 7
500 207 148 7 206 142 8 199 140 8 180 121 7 180 132 31
501 190 189 188 190 189 188 212 212 212 212 212 212 107 107 107
502 2 2 3 2 2 3 99 99 99 51 51 51 2 2 3
503 2 2 3 215 150 13 215 150 13 215 150 13 215 150 13
504 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
505 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
506 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
507 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
508 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
509 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
510 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
511 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
512 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
513 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
514 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
515 2 2 3 190 189 188 190 189 188 190 189 188 136 95 7
516 151 97 5 151 97 5 151 97 5 183 156 91 190 189 188
517 190 189 188 228 228 228 254 254 252 254 254 252 221 221 220
518 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
519 2 2 3 10 6 3 215 150 13 215 150 13 215 150 13
520 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
521 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
522 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
523 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
524 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
525 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
526 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
527 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
528 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
529 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
530 215 150 13 215 150 13 215 150 13 2 2 3 2 2 3
531 75 75 75 245 245 245 196 196 196 190 189 188 190 189 188
532 190 189 188 196 196 196 190 189 188 190 189 188 204 204 204
533 236 236 236 254 254 252 254 254 252 254 254 252 254 254 252
534 35 35 35 2 2 3 2 2 3 2 2 3 2 2 3
535 2 2 3 2 2 3 215 150 13 215 150 13 215 150 13
536 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
537 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
538 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
539 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
540 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
541 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
542 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
543 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
544 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
545 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
546 215 150 13 215 150 13 2 2 3 27 27 27 2 2 3
547 245 245 245 254 254 252 245 245 245 190 189 188 190 189 188
548 190 189 188 190 189 188 190 189 188 212 212 212 245 245 245
549 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
550 254 254 252 10 6 3 2 2 3 2 2 3 2 2 3
551 2 2 3 2 2 3 2 2 3 215 150 13 215 150 13
552 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
553 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
554 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
555 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
556 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
557 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
558 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
559 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
560 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
561 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
562 215 150 13 215 150 13 2 2 3 2 2 3 132 132 132
563 254 254 252 254 254 252 254 254 252 236 236 236 196 196 196
564 190 189 188 204 204 204 245 245 245 245 245 245 254 254 252
565 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
566 254 254 252 80 80 80 2 2 3 2 2 3 2 2 3
567 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
568 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
569 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
570 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
571 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
572 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
573 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
574 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
575 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
576 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
577 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
578 215 150 13 2 2 3 2 2 3 2 2 3 254 254 252
579 254 254 252 254 254 252 254 254 252 254 254 252 245 245 245
580 245 245 245 254 254 252 254 254 252 254 254 252 254 254 252
581 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
582 254 254 252 254 254 252 2 2 3 2 2 3 2 2 3
583 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
584 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
585 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
586 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
587 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
588 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
589 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
590 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
591 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
592 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
593 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
594 2 2 3 2 2 3 2 2 3 212 212 212 245 245 245
595 254 254 252 254 254 252 254 254 252 254 254 252 245 245 245
596 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
597 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
598 254 254 252 254 254 252 2 2 3 2 2 3 2 2 3
599 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
600 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
601 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
602 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
603 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
604 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
605 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
606 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
607 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
608 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
609 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
610 2 2 3 2 2 3 2 2 3 204 204 204 245 245 245
611 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
612 245 245 245 254 254 252 254 254 252 254 254 252 254 254 252
613 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
614 245 245 245 236 236 236 2 2 3 2 2 3 2 2 3
615 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
616 2 2 3 215 150 13 215 150 13 215 150 13 215 150 13
617 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
618 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
619 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
620 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
621 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
622 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
623 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
624 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
625 215 150 13 215 150 13 215 150 13 2 2 3 2 2 3
626 2 2 3 2 2 3 11 11 11 164 164 164 212 212 212
627 236 236 236 245 245 245 254 254 252 236 236 236 221 221 220
628 221 221 220 228 228 228 245 245 245 245 245 245 245 245 245
629 236 236 236 221 221 220 212 212 212 204 204 204 204 204 204
630 196 196 196 204 204 204 59 59 59 2 2 3 2 2 3
631 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
632 2 2 3 2 2 3 215 150 13 215 150 13 215 150 13
633 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
634 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
635 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
636 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
637 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
638 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
639 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
640 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
641 215 150 13 215 150 13 215 150 13 2 2 3 2 2 3
642 2 2 3 2 2 3 27 27 27 172 172 172 212 212 212
643 236 236 236 254 254 252 254 254 252 254 254 252 228 228 228
644 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
645 254 254 252 245 245 245 221 221 220 204 204 204 196 196 196
646 196 196 196 196 196 196 228 228 228 19 19 19 2 2 3
647 80 80 80 2 2 3 2 2 3 2 2 3 2 2 3
648 2 2 3 2 2 3 215 150 13 215 150 13 215 150 13
649 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
650 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
651 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
652 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
653 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
654 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
655 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
656 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
657 215 150 13 215 150 13 2 2 3 2 2 3 2 2 3
658 11 11 11 2 2 3 164 164 164 236 236 236 254 254 252
659 254 254 252 254 254 252 254 254 252 254 254 252 245 245 245
660 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
661 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
662 236 236 236 212 212 212 196 196 196 245 245 245 2 2 3
663 2 2 3 11 11 11 51 51 51 2 2 3 2 2 3
664 2 2 3 2 2 3 2 2 3 215 150 13 215 150 13
665 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
666 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
667 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
668 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
669 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
670 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
671 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
672 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
673 215 150 13 215 150 13 2 2 3 2 2 3 86 86 83
674 2 2 3 27 27 27 236 236 236 254 254 252 254 254 252
675 245 245 245 254 254 252 254 254 252 254 254 252 254 254 252
676 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
677 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
678 254 254 252 254 254 252 212 212 212 196 196 196 91 91 91
679 2 2 3 2 2 3 2 2 3 11 11 11 2 2 3
680 2 2 3 2 2 3 2 2 3 215 150 13 215 150 13
681 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
682 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
683 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
684 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
685 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
686 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
687 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
688 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
689 215 150 13 215 150 13 2 2 3 2 2 3 2 2 3
690 2 2 3 245 245 245 254 254 252 254 254 252 254 254 252
691 254 254 252 254 254 252 254 254 252 254 254 252 245 245 245
692 254 254 252 245 245 245 254 254 252 254 254 252 254 254 252
693 254 254 252 245 245 245 254 254 252 254 254 252 254 254 252
694 254 254 252 254 254 252 254 254 252 221 221 220 245 245 245
695 2 2 3 11 11 11 43 43 43 19 19 19 10 6 3
696 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
697 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
698 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
699 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
700 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
701 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
702 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
703 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
704 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
705 215 150 13 215 150 13 2 2 3 80 80 80 2 2 3
706 2 2 3 254 254 252 254 254 252 254 254 252 254 254 252
707 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
708 245 245 245 254 254 252 254 254 252 254 254 252 254 254 252
709 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
710 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
711 43 43 43 27 27 27 80 80 80 19 19 19 80 80 80
712 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
713 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
714 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
715 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
716 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
717 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
718 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
719 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
720 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
721 215 150 13 2 2 3 2 2 3 2 2 3 2 2 3
722 245 245 245 254 254 252 254 254 252 17 11 233 254 254 252
723 254 254 252 254 254 252 254 254 252 236 236 236 17 11 233
724 17 11 233 254 254 252 254 254 252 254 254 252 254 254 252
725 254 254 252 254 254 252 254 254 252 254 254 252 245 245 245
726 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
727 254 254 252 11 11 11 11 11 11 2 2 3 2 2 3
728 2 2 3 2 2 3 2 2 3 2 2 3 215 150 13
729 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
730 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
731 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
732 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
733 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
734 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
735 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
736 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
737 215 150 13 2 2 3 67 67 67 2 2 3 19 19 19
738 254 254 252 254 254 252 245 245 245 17 11 233 245 245 245
739 254 254 252 254 254 252 17 11 233 228 228 228 17 11 233
740 17 11 233 17 11 233 17 11 233 254 254 252 17 11 233
741 17 11 233 254 254 252 254 254 252 17 11 233 17 11 233
742 17 11 233 254 254 252 254 254 252 254 254 252 254 254 252
743 254 254 252 2 2 3 2 2 3 2 2 3 2 2 3
744 11 11 11 2 2 3 2 2 3 2 2 3 2 2 3
745 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
746 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
747 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
748 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
749 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
750 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
751 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
752 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
753 2 2 3 10 6 3 11 11 11 2 2 3 228 228 228
754 254 254 252 254 254 252 254 254 252 17 11 233 254 254 252
755 254 254 252 17 11 233 17 11 233 17 11 233 245 245 245
756 254 254 252 254 254 252 17 11 233 17 11 233 17 11 233
757 17 11 233 17 11 233 254 254 252 17 11 233 17 11 233
758 17 11 233 17 11 233 254 254 252 254 254 252 254 254 252
759 254 254 252 2 2 3 2 2 3 2 2 3 2 2 3
760 27 27 27 2 2 3 2 2 3 2 2 3 2 2 3
761 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
762 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
763 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
764 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
765 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
766 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
767 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
768 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
769 2 2 3 2 2 3 2 2 3 2 2 3 254 254 252
770 254 254 252 254 254 252 254 254 252 17 11 233 17 11 233
771 17 11 233 17 11 233 17 11 233 17 11 233 254 254 252
772 17 11 233 17 11 233 17 11 233 254 254 252 254 254 252
773 17 11 233 17 11 233 254 254 252 17 11 233 17 11 233
774 254 254 252 17 11 233 254 254 252 254 254 252 254 254 252
775 254 254 252 2 2 3 2 2 3 2 2 3 2 2 3
776 11 11 11 2 2 3 2 2 3 2 2 3 2 2 3
777 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
778 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
779 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
780 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
781 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
782 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
783 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
784 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
785 2 2 3 19 19 19 2 2 3 2 2 3 254 254 252
786 254 254 252 254 254 252 17 11 233 245 245 245 17 11 233
787 17 11 233 245 245 245 254 254 252 17 11 233 254 254 252
788 17 11 233 17 11 233 17 11 233 254 254 252 254 254 252
789 17 11 233 17 11 233 254 254 252 17 11 233 17 11 233
790 17 11 233 17 11 233 254 254 252 254 254 252 254 254 252
791 254 254 252 2 2 3 2 2 3 2 2 3 2 2 3
792 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
793 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
794 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
795 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
796 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
797 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
798 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
799 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
800 215 150 13 215 150 13 215 150 13 215 150 13 2 2 3
801 2 2 3 19 19 19 2 2 3 19 19 19 254 254 252
802 254 254 252 245 245 245 17 11 233 254 254 252 17 11 233
803 17 11 233 254 254 252 254 254 252 17 11 233 254 254 252
804 254 254 252 254 254 252 17 11 233 17 11 233 254 254 252
805 17 11 233 17 11 233 254 254 252 17 11 233 17 11 233
806 17 11 233 17 11 233 17 11 233 254 254 252 254 254 252
807 254 254 252 2 2 3 2 2 3 2 2 3 2 2 3
808 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
809 2 2 3 215 150 13 215 150 13 215 150 13 215 150 13
810 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
811 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
812 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
813 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
814 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
815 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
816 215 150 13 215 150 13 215 150 13 2 2 3 2 2 3
817 2 2 3 43 43 43 2 2 3 43 43 43 254 254 252
818 245 245 245 254 254 252 17 11 233 254 254 252 17 11 233
819 254 254 252 254 254 252 254 254 252 17 11 233 17 11 233
820 17 11 233 17 11 233 17 11 233 254 254 252 17 11 233
821 17 11 233 17 11 233 17 11 233 17 11 233 17 11 233
822 245 245 245 254 254 252 17 11 233 254 254 252 254 254 252
823 245 245 245 2 2 3 2 2 3 2 2 3 11 11 11
824 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
825 2 2 3 215 150 13 215 150 13 215 150 13 215 150 13
826 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
827 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
828 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
829 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
830 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
831 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
832 215 150 13 215 150 13 215 150 13 2 2 3 2 2 3
833 2 2 3 75 75 75 2 2 3 99 99 99 254 254 252
834 254 254 252 254 254 252 17 11 233 254 254 252 254 254 252
835 254 254 252 254 254 252 245 245 245 228 228 228 254 254 252
836 254 254 252 17 11 233 245 245 245 254 254 252 254 254 252
837 254 254 252 254 254 252 254 254 252 17 11 233 17 11 233
838 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
839 254 254 252 2 2 3 2 2 3 2 2 3 75 75 75
840 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
841 2 2 3 215 150 13 215 150 13 215 150 13 215 150 13
842 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
843 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
844 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
845 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
846 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
847 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
848 215 150 13 215 150 13 215 150 13 2 2 3 2 2 3
849 2 2 3 2 2 3 11 11 11 107 107 107 254 254 252
850 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
851 245 245 245 254 254 252 245 245 245 236 236 236 254 254 252
852 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
853 254 254 252 254 254 252 254 254 252 254 254 252 245 245 245
854 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
855 254 254 252 2 2 3 2 2 3 11 11 11 19 19 19
856 11 11 11 2 2 3 2 2 3 2 2 3 2 2 3
857 2 2 3 215 150 13 215 150 13 215 150 13 215 150 13
858 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
859 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
860 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
861 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
862 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
863 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
864 215 150 13 215 150 13 215 150 13 2 2 3 11 11 11
865 140 102 3 11 11 11 10 6 3 67 67 67 254 254 252
866 245 245 245 245 245 245 254 254 252 254 254 252 245 245 245
867 254 254 252 254 254 252 245 245 245 228 228 228 254 254 252
868 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
869 254 254 252 245 245 245 254 254 252 254 254 252 245 245 245
870 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
871 254 254 252 2 2 3 43 43 43 2 2 3 2 2 3
872 2 2 3 11 11 11 67 67 67 11 11 11 2 2 3
873 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
874 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
875 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
876 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
877 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
878 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
879 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
880 215 150 13 215 150 13 215 150 13 185 132 9 242 182 11
881 245 189 11 245 189 11 49 35 5 2 2 3 228 228 228
882 254 254 252 254 254 252 254 254 252 245 245 245 254 254 252
883 254 254 252 254 254 252 254 254 252 228 228 228 245 245 245
884 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
885 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
886 254 254 252 254 254 252 254 254 252 245 238 222 232 189 94
887 226 186 99 43 43 43 2 2 3 2 2 3 2 2 3
888 2 2 3 2 2 3 2 2 3 59 59 59 2 2 3
889 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
890 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
891 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
892 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
893 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
894 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
895 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
896 215 150 13 215 150 13 215 150 13 216 156 8 236 180 22
897 245 189 11 245 189 11 245 189 11 49 35 5 11 11 11
898 212 212 212 245 245 245 254 254 252 254 254 252 254 254 252
899 254 254 252 254 254 252 245 245 245 228 228 228 254 254 252
900 245 245 245 254 254 252 254 254 252 254 254 252 254 254 252
901 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
902 245 245 245 254 254 252 254 254 252 229 172 9 246 218 19
903 246 218 19 41 27 3 2 2 3 2 2 3 2 2 3
904 2 2 3 2 2 3 19 19 19 27 27 27 196 154 14
905 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
906 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
907 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
908 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
909 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
910 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
911 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
912 215 150 13 215 150 13 199 140 8 229 172 9 242 182 11
913 245 189 11 245 189 11 245 189 11 244 196 10 2 2 3
914 2 2 3 115 115 115 254 254 252 254 254 252 254 254 252
915 254 254 252 254 254 252 245 245 245 228 228 228 254 254 252
916 254 254 252 245 245 245 254 254 252 254 254 252 254 254 252
917 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
918 254 254 252 254 254 252 254 254 252 224 165 9 245 189 11
919 236 196 11 19 19 19 2 2 3 2 2 3 2 2 3
920 2 2 3 2 2 3 2 2 3 11 11 11 236 196 11
921 244 205 11 215 150 13 215 150 13 215 150 13 215 150 13
922 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
923 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
924 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
925 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
926 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
927 215 150 13 215 150 13 182 126 10 209 156 9 215 150 13
928 193 140 10 207 148 24 216 156 8 242 182 11 245 189 11
929 245 189 11 245 189 11 245 189 11 245 189 11 209 156 9
930 2 2 3 2 2 3 43 43 43 254 254 252 254 254 252
931 254 254 252 254 254 252 254 254 252 254 254 252 245 245 245
932 254 254 252 254 254 252 254 254 252 254 254 252 245 245 245
933 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
934 254 254 252 254 254 252 236 236 236 216 156 8 245 189 11
935 229 172 9 64 43 7 2 2 3 2 2 3 2 2 3
936 2 2 3 2 2 3 2 2 3 207 148 7 236 188 10
937 245 189 11 215 150 13 215 150 13 215 150 13 215 150 13
938 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
939 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
940 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
941 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
942 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
943 215 150 13 180 121 7 216 156 8 242 182 11 236 180 10
944 229 172 9 242 182 11 242 182 11 245 189 11 245 189 11
945 245 189 11 245 189 11 245 189 11 245 189 11 237 204 14
946 170 126 10 2 2 3 2 2 3 11 11 11 236 236 236
947 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
948 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
949 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
950 254 254 252 204 204 204 196 196 196 216 156 8 236 180 10
951 224 165 9 182 126 10 73 48 6 2 2 3 2 2 3
952 2 2 3 41 27 3 199 140 8 229 172 9 236 180 10
953 245 189 11 215 150 13 215 150 13 215 150 13 215 150 13
954 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
955 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
956 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
957 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
958 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
959 215 150 13 185 132 9 229 172 9 245 189 11 245 189 11
960 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
961 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
962 226 188 11 2 2 3 2 2 3 2 2 3 11 11 11
963 245 245 245 254 254 252 254 254 252 254 254 252 254 254 252
964 254 254 252 245 245 245 254 254 252 254 254 252 254 254 252
965 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
966 254 254 252 196 196 196 196 196 196 215 150 13 236 180 10
967 229 172 9 201 142 7 185 132 9 180 121 7 173 120 10
968 180 121 7 192 133 7 229 172 9 242 182 11 245 189 11
969 245 189 11 215 150 13 215 150 13 215 150 13 215 150 13
970 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
971 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
972 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
973 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
974 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
975 215 150 13 180 126 47 224 165 9 245 189 11 245 189 11
976 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
977 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
978 236 188 10 193 140 10 2 2 3 2 2 3 2 2 3
979 2 2 3 212 212 212 254 254 252 245 245 245 245 245 245
980 254 254 252 254 254 252 254 254 252 245 245 245 254 254 252
981 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
982 254 254 252 204 204 204 196 196 196 199 140 8 229 172 9
983 236 180 10 218 164 9 215 150 13 207 148 7 207 148 7
984 216 156 8 229 172 9 245 189 11 245 189 11 245 189 11
985 245 189 11 242 182 11 215 150 13 215 150 13 215 150 13
986 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
987 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
988 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
989 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
990 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
991 215 150 13 185 132 9 216 156 8 242 182 11 245 189 11
992 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
993 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
994 245 189 11 236 196 11 19 19 19 2 2 3 2 2 3
995 2 2 3 11 11 11 254 254 252 254 254 252 254 254 252
996 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
997 254 254 252 254 254 252 245 245 245 254 254 252 254 254 252
998 245 245 245 221 221 220 196 196 196 185 132 9 229 172 9
999 242 182 11 229 172 9 224 165 9 218 164 9 224 165 9
1000 229 172 9 236 180 10 245 189 11 245 189 11 245 189 11
1001 245 189 11 236 180 22 242 182 11 215 150 13 215 150 13
1002 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1003 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1004 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1005 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1006 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1007 215 150 13 215 150 13 215 150 13 236 180 22 245 189 11
1008 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1009 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1010 245 189 11 236 188 10 225 180 10 2 2 3 2 2 3
1011 2 2 3 11 11 11 254 254 252 254 254 252 254 254 252
1012 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
1013 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
1014 254 254 252 221 221 220 19 19 19 185 132 9 224 165 9
1015 245 189 11 245 189 11 242 182 11 236 180 10 236 180 10
1016 242 182 11 242 182 11 245 189 11 245 189 11 245 189 11
1017 245 189 11 245 189 11 245 189 11 245 189 11 196 154 14
1018 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1019 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1020 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1021 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1022 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1023 215 150 13 215 150 13 207 148 7 236 180 22 245 189 11
1024 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1025 245 189 11 245 189 11 245 189 11 245 189 11 242 182 11
1026 245 189 11 245 189 11 237 204 14 135 88 5 2 2 3
1027 27 27 27 254 254 252 254 254 252 254 254 252 254 254 252
1028 254 254 252 245 245 245 254 254 252 254 254 252 245 245 245
1029 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
1030 254 254 252 67 67 67 19 13 3 185 132 9 229 172 9
1031 242 182 11 245 189 11 245 189 11 245 189 11 245 189 11
1032 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1033 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1034 236 180 22 215 150 13 215 150 13 215 150 13 215 150 13
1035 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1036 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1037 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1038 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1039 215 150 13 215 150 13 215 150 13 245 189 11 242 182 11
1040 242 182 11 245 189 11 245 189 11 245 189 11 245 189 11
1041 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1042 245 189 11 245 189 11 236 188 10 226 188 11 104 83 48
1043 254 254 252 254 254 252 254 254 252 254 254 252 245 245 245
1044 254 254 252 254 254 252 245 245 245 254 254 252 245 245 245
1045 254 254 252 245 245 245 254 254 252 254 254 252 254 254 252
1046 2 2 3 2 2 3 56 38 5 185 132 9 229 172 9
1047 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1048 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1049 245 189 11 245 189 11 245 189 11 245 189 11 242 182 11
1050 229 172 9 215 150 13 215 150 13 215 150 13 215 150 13
1051 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1052 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1053 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1054 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1055 215 150 13 182 126 10 215 150 13 242 182 11 245 189 11
1056 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1057 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1058 245 189 11 242 182 11 245 189 11 236 196 11 216 156 8
1059 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
1060 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
1061 254 254 252 254 254 252 254 254 252 245 245 245 2 2 3
1062 2 2 3 2 2 3 75 54 3 182 126 10 229 172 9
1063 242 182 11 245 189 11 245 189 11 245 189 11 245 189 11
1064 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1065 245 189 11 245 189 11 245 189 11 245 189 11 229 172 9
1066 207 148 24 215 150 13 215 150 13 215 150 13 215 150 13
1067 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1068 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1069 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1070 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1071 215 150 13 192 133 7 229 172 9 242 182 11 245 189 11
1072 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1073 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1074 245 189 11 245 189 11 242 182 11 225 180 10 224 165 9
1075 107 69 5 245 245 245 254 254 252 254 254 252 254 254 252
1076 254 254 252 254 254 252 254 254 252 254 254 252 254 254 252
1077 254 254 252 236 236 236 2 2 3 2 2 3 2 2 3
1078 2 2 3 2 2 3 91 67 9 182 126 10 229 172 9
1079 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1080 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1081 245 189 11 242 182 11 242 182 11 216 156 8 180 126 47
1082 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1083 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1084 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1085 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1086 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1087 215 150 13 206 142 8 224 165 9 245 189 11 242 182 11
1088 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1089 245 189 11 245 189 11 245 189 11 245 189 11 242 182 11
1090 245 189 11 245 189 11 242 182 11 242 182 11 216 156 8
1091 156 102 5 19 13 3 43 43 43 196 196 196 254 254 252
1092 245 245 245 254 254 252 254 254 252 204 204 204 51 51 51
1093 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
1094 2 2 3 2 2 3 95 62 5 185 132 9 229 172 9
1095 242 182 11 245 189 11 245 189 11 245 189 11 245 189 11
1096 245 189 11 245 189 11 242 182 11 245 189 11 245 189 11
1097 236 180 22 216 156 8 206 142 8 215 150 13 215 150 13
1098 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1099 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1100 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1101 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1102 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1103 215 150 13 192 133 7 215 150 13 229 172 9 229 172 9
1104 236 180 10 236 180 22 242 182 11 242 182 11 245 189 11
1105 245 189 11 245 189 11 245 189 11 245 189 11 245 189 11
1106 245 189 11 245 189 11 245 189 11 229 172 9 216 156 8
1107 156 102 5 83 54 6 2 2 3 2 2 3 2 2 3
1108 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
1109 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
1110 2 2 3 2 2 3 115 73 3 185 132 9 229 172 9
1111 242 182 11 245 189 11 245 189 11 245 189 11 245 189 11
1112 245 189 11 242 182 11 229 172 9 229 172 9 216 156 8
1113 180 121 7 215 150 13 215 150 13 215 150 13 215 150 13
1114 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1115 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1116 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1117 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1118 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1119 215 150 13 180 121 7 182 126 10 192 133 7 199 140 8
1120 207 148 7 215 150 13 216 156 8 224 165 9 229 172 9
1121 236 180 22 245 189 11 242 182 11 245 189 11 242 182 11
1122 245 189 11 245 189 11 242 182 11 229 172 9 199 140 8
1123 151 97 5 101 67 7 2 2 3 2 2 3 2 2 3
1124 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
1125 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
1126 2 2 3 2 2 3 115 73 3 180 121 7 216 156 8
1127 236 180 22 242 182 11 245 189 11 245 189 11 242 182 11
1128 236 180 10 224 165 9 215 150 13 206 142 8 215 150 13
1129 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1130 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1131 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1132 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1133 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1134 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1135 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1136 156 102 5 164 109 5 172 114 5 180 121 7 180 121 7
1137 192 133 7 201 142 7 216 156 8 224 165 9 236 180 22
1138 245 189 11 242 182 11 229 172 9 201 142 7 172 114 5
1139 125 83 5 83 54 6 2 2 3 2 2 3 2 2 3
1140 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
1141 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3
1142 2 2 3 2 2 3 91 58 5 156 102 5 192 133 7
1143 216 156 8 229 172 9 236 180 10 236 180 10 229 172 9
1144 215 150 13 199 140 8 164 109 5 215 150 13 215 150 13
1145 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1146 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1147 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1148 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1149 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1150 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1151 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1152 215 150 13 215 150 13 215 150 13 120 78 3 132 82 3
1153 151 97 5 157 106 7 180 121 7 185 132 9 193 140 10
1154 207 148 7 207 148 7 192 133 7 172 114 5 132 82 3
1155 101 67 7 41 27 3 215 150 13 215 150 13 215 150 13
1156 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1157 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1158 215 150 13 215 150 13 73 48 6 143 90 3 180 121 7
1159 192 133 7 207 148 7 207 148 7 201 142 7 185 132 9
1160 173 120 10 136 95 7 215 150 13 215 150 13 215 150 13
1161 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1162 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1163 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1164 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1165 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1166 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1167 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1168 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1169 215 150 13 215 150 13 91 58 5 125 83 5 135 88 5
1170 144 95 7 151 97 5 132 82 3 115 73 3 95 62 5
1171 64 43 7 215 150 13 215 150 13 215 150 13 215 150 13
1172 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1173 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1174 215 150 13 215 150 13 64 43 7 91 58 5 151 97 5
1175 157 106 7 172 114 5 172 114 5 164 109 5 151 97 5
1176 85 59 6 215 150 13 215 150 13 215 150 13 215 150 13
1177 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1178 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1179 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1180 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1181 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1182 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1183 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1184 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1185 215 150 13 215 150 13 215 150 13 215 150 13 73 48 6
1186 91 58 5 95 62 5 95 62 5 91 58 5 56 38 5
1187 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1188 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1189 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1190 215 150 13 215 150 13 215 150 13 215 150 13 83 54 6
1191 107 69 5 132 82 3 125 83 5 101 67 7 71 47 31
1192 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1193 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1194 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1195 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1196 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1197 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1198 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1199 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1200 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1201 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1202 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1203 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1204 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1205 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1206 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1207 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1208 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1209 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1210 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1211 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1212 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1213 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1214 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1215 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1216 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1217 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1218 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1219 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1220 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1221 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1222 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1223 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1224 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1225 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1226 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1227 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1228 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1229 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1230 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1231 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1232 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1233 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1234 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1235 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1236 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1237 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1238 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1239 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1240 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1241 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1242 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1243 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1244 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1245 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1246 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1247 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1248 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1249 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1250 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1251 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1252 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1253 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1254 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1255 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1256 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1257 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1258 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1259 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1260 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1261 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1262 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1263 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1264 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1265 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1266 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1267 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1268 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1269 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1270 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1271 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1272 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1273 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1274 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1275 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1276 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1277 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1278 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1279 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1280 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1281 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1282 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1283 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1284 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1285 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1286 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1287 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1288 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1289 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1290 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1291 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
1292 215 150 13 215 150 13 215 150 13 215 150 13 215 150 13
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 3dd1de1539d2..b00887e9851c 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -523,7 +523,7 @@ int __init platinumfb_setup(char *options)
523#define invalidate_cache(addr) 523#define invalidate_cache(addr)
524#endif 524#endif
525 525
526static int __devinit platinumfb_probe(struct of_device* odev, const struct of_match *match) 526static int __devinit platinumfb_probe(struct of_device* odev, const struct of_device_id *match)
527{ 527{
528 struct device_node *dp = odev->node; 528 struct device_node *dp = odev->node;
529 struct fb_info *info; 529 struct fb_info *info;
@@ -647,12 +647,10 @@ static int __devexit platinumfb_remove(struct of_device* odev)
647 return 0; 647 return 0;
648} 648}
649 649
650static struct of_match platinumfb_match[] = 650static struct of_device_id platinumfb_match[] =
651{ 651{
652 { 652 {
653 .name = "platinum", 653 .name = "platinum",
654 .type = OF_ANY_MATCH,
655 .compatible = OF_ANY_MATCH,
656 }, 654 },
657 {}, 655 {},
658}; 656};
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index 789de13f461f..3848be2b9d2d 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -67,12 +67,18 @@ static struct fb_fix_screeninfo __devinitdata s1d13xxxfb_fix = {
67static inline u8 67static inline u8
68s1d13xxxfb_readreg(struct s1d13xxxfb_par *par, u16 regno) 68s1d13xxxfb_readreg(struct s1d13xxxfb_par *par, u16 regno)
69{ 69{
70#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_OPSPUT) || defined(CONFIG_PLAT_MAPPI3)
71 regno=((regno & 1) ? (regno & ~1L) : (regno + 1));
72#endif
70 return readb(par->regs + regno); 73 return readb(par->regs + regno);
71} 74}
72 75
73static inline void 76static inline void
74s1d13xxxfb_writereg(struct s1d13xxxfb_par *par, u16 regno, u8 value) 77s1d13xxxfb_writereg(struct s1d13xxxfb_par *par, u16 regno, u8 value)
75{ 78{
79#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_OPSPUT) || defined(CONFIG_PLAT_MAPPI3)
80 regno=((regno & 1) ? (regno & ~1L) : (regno + 1));
81#endif
76 writeb(value, par->regs + regno); 82 writeb(value, par->regs + regno);
77} 83}
78 84
@@ -259,7 +265,11 @@ s1d13xxxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
259 dbg("s1d13xxxfb_setcolreg: pseudo %d, val %08x\n", 265 dbg("s1d13xxxfb_setcolreg: pseudo %d, val %08x\n",
260 regno, pseudo_val); 266 regno, pseudo_val);
261 267
268#if defined(CONFIG_PLAT_MAPPI)
269 ((u32 *)info->pseudo_palette)[regno] = cpu_to_le16(pseudo_val);
270#else
262 ((u32 *)info->pseudo_palette)[regno] = pseudo_val; 271 ((u32 *)info->pseudo_palette)[regno] = pseudo_val;
272#endif
263 273
264 break; 274 break;
265 case FB_VISUAL_PSEUDOCOLOR: 275 case FB_VISUAL_PSEUDOCOLOR:
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 8fadcdae6f42..f4633d1891f1 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -2113,7 +2113,7 @@ static int savagefb_suspend (struct pci_dev* dev, pm_message_t state)
2113 printk(KERN_DEBUG "state: %u\n", state); 2113 printk(KERN_DEBUG "state: %u\n", state);
2114 2114
2115 acquire_console_sem(); 2115 acquire_console_sem();
2116 fb_set_suspend(info, state); 2116 fb_set_suspend(info, pci_choose_state(dev, state));
2117 savage_disable_mmio(par); 2117 savage_disable_mmio(par);
2118 release_console_sem(); 2118 release_console_sem();
2119 2119
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 312cf3220f12..8a9c42822502 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -516,6 +516,7 @@ static void w1_slave_found(unsigned long data, u64 rn)
516 struct w1_reg_num *tmp; 516 struct w1_reg_num *tmp;
517 int family_found = 0; 517 int family_found = 0;
518 struct w1_master *dev; 518 struct w1_master *dev;
519 u64 rn_le = cpu_to_le64(rn);
519 520
520 dev = w1_search_master(data); 521 dev = w1_search_master(data);
521 if (!dev) { 522 if (!dev) {
@@ -544,10 +545,8 @@ static void w1_slave_found(unsigned long data, u64 rn)
544 slave_count++; 545 slave_count++;
545 } 546 }
546 547
547 rn = cpu_to_le64(rn);
548
549 if (slave_count == dev->slave_count && 548 if (slave_count == dev->slave_count &&
550 rn && ((le64_to_cpu(rn) >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn, 7)) { 549 rn && ((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn_le, 7)) {
551 w1_attach_slave_device(dev, tmp); 550 w1_attach_slave_device(dev, tmp);
552 } 551 }
553 552